Deleted Added
full compact
ioat.c (295605) ioat.c (297746)
1/*-
2 * Copyright (C) 2012 Intel Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 2012 Intel Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/ioat/ioat.c 295605 2016-02-13 22:51:25Z cem $");
28__FBSDID("$FreeBSD: head/sys/dev/ioat/ioat.c 297746 2016-04-09 13:15:34Z cem $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/conf.h>
34#include <sys/ioccom.h>
35#include <sys/kernel.h>
36#include <sys/lock.h>

--- 272 unchanged lines hidden (view full) ---

309
310 ioat = DEVICE2SOFTC(device);
311
312 ioat_test_detach();
313 taskqueue_drain(taskqueue_thread, &ioat->reset_task);
314
315 mtx_lock(IOAT_REFLK);
316 ioat->quiescing = TRUE;
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/conf.h>
34#include <sys/ioccom.h>
35#include <sys/kernel.h>
36#include <sys/lock.h>

--- 272 unchanged lines hidden (view full) ---

309
310 ioat = DEVICE2SOFTC(device);
311
312 ioat_test_detach();
313 taskqueue_drain(taskqueue_thread, &ioat->reset_task);
314
315 mtx_lock(IOAT_REFLK);
316 ioat->quiescing = TRUE;
317 ioat->destroying = TRUE;
318 wakeup(&ioat->quiescing);
319
317 ioat_channel[ioat->chan_idx] = NULL;
318
319 ioat_drain_locked(ioat);
320 mtx_unlock(IOAT_REFLK);
321
322 ioat_teardown_intr(ioat);
323 callout_drain(&ioat->timer);
324

--- 409 unchanged lines hidden (view full) ---

734 KASSERT(error == 0, ("%s: reset failed: %d", __func__, error));
735 (void)error;
736}
737
738/*
739 * User API functions
740 */
741bus_dmaengine_t
320 ioat_channel[ioat->chan_idx] = NULL;
321
322 ioat_drain_locked(ioat);
323 mtx_unlock(IOAT_REFLK);
324
325 ioat_teardown_intr(ioat);
326 callout_drain(&ioat->timer);
327

--- 409 unchanged lines hidden (view full) ---

737 KASSERT(error == 0, ("%s: reset failed: %d", __func__, error));
738 (void)error;
739}
740
741/*
742 * User API functions
743 */
744bus_dmaengine_t
742ioat_get_dmaengine(uint32_t index)
745ioat_get_dmaengine(uint32_t index, int flags)
743{
746{
744 struct ioat_softc *sc;
747 struct ioat_softc *ioat;
745
748
749 KASSERT((flags & ~(M_NOWAIT | M_WAITOK)) == 0,
750 ("invalid flags: 0x%08x", flags));
751 KASSERT((flags & (M_NOWAIT | M_WAITOK)) != (M_NOWAIT | M_WAITOK),
752 ("invalid wait | nowait"));
753
746 if (index >= ioat_channel_index)
747 return (NULL);
748
754 if (index >= ioat_channel_index)
755 return (NULL);
756
749 sc = ioat_channel[index];
750 if (sc == NULL || sc->quiescing)
757 ioat = ioat_channel[index];
758 if (ioat == NULL || ioat->destroying)
751 return (NULL);
752
759 return (NULL);
760
753 return (&ioat_get(sc, IOAT_DMAENGINE_REF)->dmaengine);
761 if (ioat->quiescing) {
762 if ((flags & M_NOWAIT) != 0)
763 return (NULL);
764
765 mtx_lock(IOAT_REFLK);
766 while (ioat->quiescing && !ioat->destroying)
767 msleep(&ioat->quiescing, IOAT_REFLK, 0, "getdma", 0);
768 mtx_unlock(IOAT_REFLK);
769
770 if (ioat->destroying)
771 return (NULL);
772 }
773
774 /*
775 * There's a race here between the quiescing check and HW reset or
776 * module destroy.
777 */
778 return (&ioat_get(ioat, IOAT_DMAENGINE_REF)->dmaengine);
754}
755
756void
757ioat_put_dmaengine(bus_dmaengine_t dmaengine)
758{
759 struct ioat_softc *ioat;
760
761 ioat = to_ioat_softc(dmaengine);

--- 804 unchanged lines hidden (view full) ---

1566 ioat_write_chanctrl(ioat, IOAT_CHANCTRL_RUN);
1567 ioat_write_chancmp(ioat, ioat->comp_update_bus_addr);
1568 ioat_write_chainaddr(ioat, ioat->ring[0]->hw_desc_bus_addr);
1569 error = 0;
1570
1571out:
1572 mtx_lock(IOAT_REFLK);
1573 ioat->quiescing = FALSE;
779}
780
781void
782ioat_put_dmaengine(bus_dmaengine_t dmaengine)
783{
784 struct ioat_softc *ioat;
785
786 ioat = to_ioat_softc(dmaengine);

--- 804 unchanged lines hidden (view full) ---

1591 ioat_write_chanctrl(ioat, IOAT_CHANCTRL_RUN);
1592 ioat_write_chancmp(ioat, ioat->comp_update_bus_addr);
1593 ioat_write_chainaddr(ioat, ioat->ring[0]->hw_desc_bus_addr);
1594 error = 0;
1595
1596out:
1597 mtx_lock(IOAT_REFLK);
1598 ioat->quiescing = FALSE;
1599 wakeup(&ioat->quiescing);
1574 mtx_unlock(IOAT_REFLK);
1575
1576 if (error == 0)
1577 error = ioat_start_channel(ioat);
1578
1579 return (error);
1580}
1581

--- 319 unchanged lines hidden ---
1600 mtx_unlock(IOAT_REFLK);
1601
1602 if (error == 0)
1603 error = ioat_start_channel(ioat);
1604
1605 return (error);
1606}
1607

--- 319 unchanged lines hidden ---