From owner-svn-src-stable-10@freebsd.org Sun Apr 2 10:52:02 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1A10D1D21C; Sun, 2 Apr 2017 10:52:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 701E1F49; Sun, 2 Apr 2017 10:52:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v32Aq1KX040637; Sun, 2 Apr 2017 10:52:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v32Aq0Sf040629; Sun, 2 Apr 2017 10:52:00 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704021052.v32Aq0Sf040629@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 2 Apr 2017 10:52:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316399 - in stable/10/sys: dev/isp modules/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2017 10:52:02 -0000 Author: mav Date: Sun Apr 2 10:52:00 2017 New Revision: 316399 URL: https://svnweb.freebsd.org/changeset/base/316399 Log: MFC r315579, r315670: Add initial support for multiple MSI-X vectors. For 24xx and above use 2 vectors (default and response queue). For 26xx and above use 3 vectors (default, response and ATIO queues). Due to global lock interrupt hardlers never run simultaneously now, but at least this allows to save one regitster read per interrupt. Modified: stable/10/sys/dev/isp/isp.c stable/10/sys/dev/isp/isp_freebsd.c stable/10/sys/dev/isp/isp_freebsd.h stable/10/sys/dev/isp/isp_pci.c stable/10/sys/dev/isp/isp_sbus.c stable/10/sys/dev/isp/ispmbox.h stable/10/sys/dev/isp/ispvar.h stable/10/sys/modules/isp/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp.c ============================================================================== --- stable/10/sys/dev/isp/isp.c Sun Apr 2 10:50:49 2017 (r316398) +++ stable/10/sys/dev/isp/isp.c Sun Apr 2 10:52:00 2017 (r316399) @@ -2089,7 +2089,7 @@ isp_fibre_init_2400(ispsoftc_t *isp) } if (IS_26XX(isp)) { - /* We don't support MSI-X yet, so set this unconditionally. */ + /* Use handshake to reduce global lock congestion. */ icbp->icb_fwoptions2 |= ICB2400_OPT2_ENA_IHR; icbp->icb_fwoptions2 |= ICB2400_OPT2_ENA_IHA; } @@ -2187,6 +2187,12 @@ isp_fibre_init_2400(ispsoftc_t *isp) DMA_WD1(isp->isp_atioq_dma), DMA_WD0(isp->isp_atioq_dma)); #endif + if (ISP_CAP_MSIX(isp) && isp->isp_nirq >= 2) { + icbp->icb_msixresp = 1; + if (IS_26XX(isp) && isp->isp_nirq >= 3) + icbp->icb_msixatio = 2; + } + isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init_2400: fwopt1 0x%x fwopt2 0x%x fwopt3 0x%x", icbp->icb_fwoptions1, icbp->icb_fwoptions2, icbp->icb_fwoptions3); isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init_2400: rqst %04x%04x%04x%04x rsp %04x%04x%04x%04x", DMA_WD3(isp->isp_rquest_dma), DMA_WD2(isp->isp_rquest_dma), Modified: stable/10/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:50:49 2017 (r316398) +++ stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:52:00 2017 (r316399) @@ -4159,6 +4159,34 @@ isp_platform_intr(void *arg) } void +isp_platform_intr_resp(void *arg) +{ + ispsoftc_t *isp = arg; + + ISP_LOCK(isp); + isp_intr_respq(isp); + ISP_UNLOCK(isp); + + /* We have handshake enabled, so explicitly complete interrupt */ + ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT); +} + +void +isp_platform_intr_atio(void *arg) +{ + ispsoftc_t *isp = arg; + + ISP_LOCK(isp); +#ifdef ISP_TARGET_MODE + isp_intr_atioq(isp); +#endif + ISP_UNLOCK(isp); + + /* We have handshake enabled, so explicitly complete interrupt */ + ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT); +} + +void isp_common_dmateardown(ispsoftc_t *isp, struct ccb_scsiio *csio, uint32_t hdl) { if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { Modified: stable/10/sys/dev/isp/isp_freebsd.h ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.h Sun Apr 2 10:50:49 2017 (r316398) +++ stable/10/sys/dev/isp/isp_freebsd.h Sun Apr 2 10:52:00 2017 (r316399) @@ -722,6 +722,8 @@ void isp_mbox_release(ispsoftc_t *); int isp_fc_scratch_acquire(ispsoftc_t *, int); int isp_mstohz(int); void isp_platform_intr(void *); +void isp_platform_intr_resp(void *); +void isp_platform_intr_atio(void *); void isp_common_dmateardown(ispsoftc_t *, struct ccb_scsiio *, uint32_t); void isp_fcp_reset_crn(ispsoftc_t *, int, uint32_t, int); int isp_fcp_next_crn(ispsoftc_t *, uint8_t *, XS_T *); @@ -734,8 +736,6 @@ int isp_fcp_next_crn(ispsoftc_t *, uint8 bus_dma_tag_create(a, b, c, d, e, f, g, h, i, j, k, \ busdma_lock_mutex, &isp->isp_osinfo.lock, z) -#define isp_setup_intr bus_setup_intr - #define isp_sim_alloc(a, b, c, d, e, f, g, h) \ cam_sim_alloc(a, b, c, d, e, &(d)->isp_osinfo.lock, f, g, h) Modified: stable/10/sys/dev/isp/isp_pci.c ============================================================================== --- stable/10/sys/dev/isp/isp_pci.c Sun Apr 2 10:50:49 2017 (r316398) +++ stable/10/sys/dev/isp/isp_pci.c Sun Apr 2 10:52:00 2017 (r316399) @@ -364,15 +364,17 @@ struct isp_pcisoftc { struct resource * regs; struct resource * regs1; struct resource * regs2; - void * irq; - int iqd; + struct { + int iqd; + struct resource * irq; + void * ih; + } irq[ISP_MAX_IRQS]; int rtp; int rgd; int rtp1; int rgd1; int rtp2; int rgd2; - void * ih; int16_t pci_poff[_NREG_BLKS]; bus_dma_tag_t dmat; int msicount; @@ -691,8 +693,8 @@ isp_pci_attach(device_t dev) isp_get_generic_options(dev, isp); linesz = PCI_DFLT_LNSZ; - pcs->irq = pcs->regs = pcs->regs2 = NULL; - pcs->rgd = pcs->rtp = pcs->iqd = 0; + pcs->regs = pcs->regs2 = NULL; + pcs->rgd = pcs->rtp = 0; pcs->pci_dev = dev; pcs->pci_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF; @@ -932,41 +934,6 @@ isp_pci_attach(device_t dev) data &= ~1; pci_write_config(dev, PCIR_ROMADDR, data, 4); - if (IS_26XX(isp)) { - /* 26XX chips support only MSI-X, so start from them. */ - pcs->msicount = imin(pci_msix_count(dev), 1); - if (pcs->msicount > 0 && - (i = pci_alloc_msix(dev, &pcs->msicount)) == 0) { - pcs->iqd = 1; - } else { - pcs->msicount = 0; - } - } - if (pcs->msicount == 0 && (IS_24XX(isp) || IS_2322(isp))) { - /* - * Older chips support both MSI and MSI-X, but I have - * feeling that older firmware may not support MSI-X, - * but we have no way to check the firmware flag here. - */ - pcs->msicount = imin(pci_msi_count(dev), 1); - if (pcs->msicount > 0 && - pci_alloc_msi(dev, &pcs->msicount) == 0) { - pcs->iqd = 1; - } else { - pcs->msicount = 0; - } - } - pcs->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &pcs->iqd, RF_ACTIVE | RF_SHAREABLE); - if (pcs->irq == NULL) { - device_printf(dev, "could not allocate interrupt\n"); - goto bad; - } - - if (isp_setup_intr(dev, pcs->irq, ISP_IFLAGS, NULL, isp_platform_intr, isp, &pcs->ih)) { - device_printf(dev, "could not setup interrupt\n"); - goto bad; - } - /* * Last minute checks... */ @@ -992,11 +959,10 @@ isp_pci_attach(device_t dev) return (0); bad: - if (pcs->ih) { - (void) bus_teardown_intr(dev, pcs->irq, pcs->ih); - } - if (pcs->irq) { - (void) bus_release_resource(dev, SYS_RES_IRQ, pcs->iqd, pcs->irq); + for (i = 0; i < isp->isp_nirq; i++) { + (void) bus_teardown_intr(dev, pcs->irq[i].irq, pcs->irq[i].ih); + (void) bus_release_resource(dev, SYS_RES_IRQ, pcs->irq[i].iqd, + pcs->irq[0].irq); } if (pcs->msicount) { pci_release_msi(dev); @@ -1024,7 +990,7 @@ isp_pci_detach(device_t dev) { struct isp_pcisoftc *pcs = device_get_softc(dev); ispsoftc_t *isp = &pcs->pci_isp; - int status; + int i, status; status = isp_detach(isp); if (status) @@ -1032,9 +998,11 @@ isp_pci_detach(device_t dev) ISP_LOCK(isp); isp_shutdown(isp); ISP_UNLOCK(isp); - if (pcs->ih) - (void) bus_teardown_intr(dev, pcs->irq, pcs->ih); - (void) bus_release_resource(dev, SYS_RES_IRQ, pcs->iqd, pcs->irq); + for (i = 0; i < isp->isp_nirq; i++) { + (void) bus_teardown_intr(dev, pcs->irq[i].irq, pcs->irq[i].ih); + (void) bus_release_resource(dev, SYS_RES_IRQ, pcs->irq[i].iqd, + pcs->irq[i].irq); + } if (pcs->msicount) pci_release_msi(dev); (void) bus_release_resource(dev, pcs->rtp, pcs->rgd, pcs->regs); @@ -2077,8 +2045,59 @@ isp_pci_dmasetup(ispsoftc_t *isp, struct static int isp_pci_irqsetup(ispsoftc_t *isp) { + device_t dev = isp->isp_osinfo.dev; + struct isp_pcisoftc *pcs = device_get_softc(dev); + driver_intr_t *f; + int i, max_irq; - return (0); + /* Allocate IRQs only once. */ + if (isp->isp_nirq > 0) + return (0); + + ISP_UNLOCK(isp); + if (ISP_CAP_MSIX(isp)) { + max_irq = min(ISP_MAX_IRQS, IS_26XX(isp) ? 3 : 2); + pcs->msicount = imin(pci_msix_count(dev), max_irq); + if (pcs->msicount > 0 && + pci_alloc_msix(dev, &pcs->msicount) != 0) + pcs->msicount = 0; + } + if (pcs->msicount == 0) { + pcs->msicount = imin(pci_msi_count(dev), 1); + if (pcs->msicount > 0 && + pci_alloc_msi(dev, &pcs->msicount) != 0) + pcs->msicount = 0; + } + for (i = 0; i < MAX(1, pcs->msicount); i++) { + pcs->irq[i].iqd = i + (pcs->msicount > 0); + pcs->irq[i].irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, + &pcs->irq[i].iqd, RF_ACTIVE | RF_SHAREABLE); + if (pcs->irq[i].irq == NULL) { + device_printf(dev, "could not allocate interrupt\n"); + break; + } + if (i == 0) + f = isp_platform_intr; + else if (i == 1) + f = isp_platform_intr_resp; + else + f = isp_platform_intr_atio; + if (bus_setup_intr(dev, pcs->irq[i].irq, ISP_IFLAGS, NULL, + f, isp, &pcs->irq[i].ih)) { + device_printf(dev, "could not setup interrupt\n"); + (void) bus_release_resource(dev, SYS_RES_IRQ, + pcs->irq[i].iqd, pcs->irq[i].irq); + break; + } + if (pcs->msicount > 1) { + bus_describe_intr(dev, pcs->irq[i].irq, pcs->irq[i].ih, + "%d", i); + } + isp->isp_nirq = i + 1; + } + ISP_LOCK(isp); + + return (isp->isp_nirq == 0); } static void Modified: stable/10/sys/dev/isp/isp_sbus.c ============================================================================== --- stable/10/sys/dev/isp/isp_sbus.c Sun Apr 2 10:50:49 2017 (r316398) +++ stable/10/sys/dev/isp/isp_sbus.c Sun Apr 2 10:52:00 2017 (r316399) @@ -139,7 +139,6 @@ isp_sbus_attach(device_t dev) struct isp_sbussoftc *sbs = device_get_softc(dev); ispsoftc_t *isp = &sbs->sbus_isp; int tval, isp_debug, role, ispburst, default_id; - int ints_setup = 0; sbs->sbus_dev = dev; sbs->sbus_mdvec = mdvec; @@ -262,12 +261,14 @@ isp_sbus_attach(device_t dev) goto bad; } - if (isp_setup_intr(dev, sbs->irq, ISP_IFLAGS, NULL, isp_platform_intr, + if (bus_setup_intr(dev, sbs->irq, ISP_IFLAGS, NULL, isp_platform_intr, isp, &sbs->ih)) { device_printf(dev, "could not setup interrupt\n"); + (void) bus_release_resource(dev, SYS_RES_IRQ, + sbs->iqd, sbs->irq); goto bad; } - ints_setup++; + isp->isp_nirq = 1; /* * Set up logging levels. @@ -299,13 +300,10 @@ isp_sbus_attach(device_t dev) return (0); bad: - - if (sbs && ints_setup) { + if (isp->isp_nirq > 0) { (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); - } - - if (sbs && sbs->irq) { - bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, sbs->irq); + (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, + sbs->irq); } if (sbs->regs) { @@ -329,9 +327,11 @@ isp_sbus_detach(device_t dev) ISP_LOCK(isp); isp_shutdown(isp); ISP_UNLOCK(isp); - if (sbs->ih) + if (isp->isp_nirq > 0) { (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); - (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, sbs->irq); + (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, + sbs->irq); + } (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); isp_sbus_mbxdmafree(isp); mtx_destroy(&isp->isp_osinfo.lock); Modified: stable/10/sys/dev/isp/ispmbox.h ============================================================================== --- stable/10/sys/dev/isp/ispmbox.h Sun Apr 2 10:50:49 2017 (r316398) +++ stable/10/sys/dev/isp/ispmbox.h Sun Apr 2 10:52:00 2017 (r316399) @@ -895,6 +895,8 @@ typedef struct { (IS_24XX(isp)? (isp->isp_fwattr & ISP2400_FW_ATTR_MULTIID) : 0) #define ISP_GET_VPIDX(isp, tag) \ (ISP_CAP_MULTI_ID(isp) ? tag : 0) +#define ISP_CAP_MSIX(isp) \ + (IS_24XX(isp)? (isp->isp_fwattr & ISP2400_FW_ATTR_MSIX) : 0) #define ISP_CAP_VP0(isp) \ (IS_24XX(isp)? (isp->isp_fwattr & ISP2400_FW_ATTR_VP0) : 0) Modified: stable/10/sys/dev/isp/ispvar.h ============================================================================== --- stable/10/sys/dev/isp/ispvar.h Sun Apr 2 10:50:49 2017 (r316398) +++ stable/10/sys/dev/isp/ispvar.h Sun Apr 2 10:52:00 2017 (r316399) @@ -80,6 +80,7 @@ struct ispmdvec { #endif #define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) #define ISP_MAX_LUNS(isp) (isp)->isp_maxluns +#define ISP_MAX_IRQS 3 /* * Macros to access ISP registers through bus specific layers- @@ -526,6 +527,7 @@ struct ispsoftc { uint16_t isp_maxcmds; /* max possible I/O cmds */ uint8_t isp_type; /* HBA Chip Type */ uint8_t isp_revision; /* HBA Chip H/W Revision */ + uint8_t isp_nirq; /* number of IRQs */ uint16_t isp_nchan; /* number of channels */ uint32_t isp_maxluns; /* maximum luns supported */ Modified: stable/10/sys/modules/isp/Makefile ============================================================================== --- stable/10/sys/modules/isp/Makefile Sun Apr 2 10:50:49 2017 (r316398) +++ stable/10/sys/modules/isp/Makefile Sun Apr 2 10:52:00 2017 (r316399) @@ -10,5 +10,6 @@ SRCS= bus_if.h device_if.h pci_if.h \ .if ${MACHINE} == sparc64 SRCS+= isp_sbus.c ofw_bus_if.h .endif +CFLAGS+= -Wformat -Wall -Werror .include From owner-svn-src-stable-10@freebsd.org Sun Apr 2 10:53:39 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6185CD1D4C1; Sun, 2 Apr 2017 10:53:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2474A3D4; Sun, 2 Apr 2017 10:53:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v32Arc9S041477; Sun, 2 Apr 2017 10:53:38 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v32Arb2B041473; Sun, 2 Apr 2017 10:53:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704021053.v32Arb2B041473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 2 Apr 2017 10:53:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316401 - stable/10/sys/dev/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2017 10:53:39 -0000 Author: mav Date: Sun Apr 2 10:53:37 2017 New Revision: 316401 URL: https://svnweb.freebsd.org/changeset/base/316401 Log: MFC r315587, r315652: Remove some dead/useless code. Modified: stable/10/sys/dev/isp/isp.c stable/10/sys/dev/isp/isp_freebsd.c stable/10/sys/dev/isp/isp_freebsd.h stable/10/sys/dev/isp/ispvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp.c ============================================================================== --- stable/10/sys/dev/isp/isp.c Sun Apr 2 10:53:03 2017 (r316400) +++ stable/10/sys/dev/isp/isp.c Sun Apr 2 10:53:37 2017 (r316401) @@ -4530,7 +4530,6 @@ isp_start(XS_T *xs) return (dmaresult); } isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "START cmd cdb[0]=0x%x datalen %ld", XS_CDBP(xs)[0], (long) XS_XFRLEN(xs)); - isp->isp_nactive++; return (CMD_QUEUED); } @@ -5359,9 +5358,6 @@ isp_intr_respq(ispsoftc_t *isp) } isp_destroy_handle(isp, sp->req_handle); - if (isp->isp_nactive > 0) { - isp->isp_nactive--; - } complist[ndone++] = xs; /* defer completion call until later */ ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */ last_etype = etype; @@ -5932,9 +5928,6 @@ isp_handle_other_response(ispsoftc_t *is void *ptr; switch (type) { - case RQSTYPE_STATUS_CONT: - isp_prt(isp, ISP_LOG_WARN1, "Ignored Continuation Response"); - return (1); case RQSTYPE_MARKER: isp_prt(isp, ISP_LOG_WARN1, "Marker Response"); return (1); @@ -6536,9 +6529,6 @@ isp_fastpost_complete(ispsoftc_t *isp, u if (XS_XFRLEN(xs)) { ISP_DMAFREE(isp, xs, fph); } - if (isp->isp_nactive) { - isp->isp_nactive--; - } isp_done(xs); } @@ -7579,7 +7569,6 @@ isp_reinit(ispsoftc_t *isp, int do_load_ } cleanup: - isp->isp_nactive = 0; isp_clear_commands(isp); if (IS_FC(isp)) { for (i = 0; i < isp->isp_nchan; i++) Modified: stable/10/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:53:03 2017 (r316400) +++ stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:53:37 2017 (r316401) @@ -294,7 +294,6 @@ isp_attach(ispsoftc_t *isp) callout_init_mtx(&isp->isp_osinfo.tmo, &isp->isp_osinfo.lock, 0); isp_timer_count = hz >> 2; callout_reset(&isp->isp_osinfo.tmo, isp_timer_count, isp_timer, isp); - isp->isp_osinfo.timer_active = 1; isp->isp_osinfo.cdev = make_dev(&isp_cdevsw, du, UID_ROOT, GID_OPERATOR, 0600, "%s", nu); if (isp->isp_osinfo.cdev) { @@ -315,10 +314,6 @@ unwind: ISP_UNLOCK(isp); cam_sim_free(sim, FALSE); } - if (isp->isp_osinfo.cdev) { - destroy_dev(isp->isp_osinfo.cdev); - isp->isp_osinfo.cdev = NULL; - } cam_simq_free(isp->isp_osinfo.devq); isp->isp_osinfo.devq = NULL; return (-1); @@ -327,35 +322,20 @@ unwind: int isp_detach(ispsoftc_t *isp) { - struct cam_sim *sim; int chan; - ISP_LOCK(isp); - for (chan = isp->isp_nchan - 1; chan >= 0; chan -= 1) { - ISP_GET_PC(isp, chan, sim, sim); - if (sim->refcount > 2) { - ISP_UNLOCK(isp); - return (EBUSY); - } + if (isp->isp_osinfo.cdev) { + destroy_dev(isp->isp_osinfo.cdev); + isp->isp_osinfo.cdev = NULL; } + ISP_LOCK(isp); /* Tell spawned threads that we're exiting. */ isp->isp_osinfo.is_exiting = 1; - if (isp->isp_osinfo.timer_active) { - callout_stop(&isp->isp_osinfo.tmo); - isp->isp_osinfo.timer_active = 0; - } for (chan = isp->isp_nchan - 1; chan >= 0; chan -= 1) isp_detach_chan(isp, chan); ISP_UNLOCK(isp); - - if (isp->isp_osinfo.cdev) { - destroy_dev(isp->isp_osinfo.cdev); - isp->isp_osinfo.cdev = NULL; - } - if (isp->isp_osinfo.devq != NULL) { - cam_simq_free(isp->isp_osinfo.devq); - isp->isp_osinfo.devq = NULL; - } + callout_drain(&isp->isp_osinfo.tmo); + cam_simq_free(isp->isp_osinfo.devq); return (0); } @@ -1591,7 +1571,6 @@ isp_target_start_ctio(ispsoftc_t *isp, u xpt_done(ccb); continue; } - isp->isp_nactive++; ccb->ccb_h.status = CAM_REQ_INPROG | CAM_SIM_QUEUED; if (xfrlen) { ccb->ccb_h.spriv_field0 = atp->bytes_xfered; @@ -2113,9 +2092,6 @@ isp_handle_platform_ctio(ispsoftc_t *isp isp_destroy_handle(isp, handle); resid = data_requested = PISP_PCMD(ccb)->datalen; isp_free_pcmd(isp, ccb); - if (isp->isp_nactive) { - isp->isp_nactive--; - } bus = XS_CHANNEL(ccb); if (IS_24XX(isp)) { Modified: stable/10/sys/dev/isp/isp_freebsd.h ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.h Sun Apr 2 10:53:03 2017 (r316400) +++ stable/10/sys/dev/isp/isp_freebsd.h Sun Apr 2 10:53:37 2017 (r316401) @@ -297,16 +297,7 @@ struct isposinfo { struct isp_pcmd * pcmd_pool; struct isp_pcmd * pcmd_free; - uint32_t -#ifdef ISP_TARGET_MODE - tmwanted : 1, - tmbusy : 1, -#else - : 2, -#endif - sixtyfourbit : 1, /* sixtyfour bit platform */ - timer_active : 1, - autoconf : 1; + int sixtyfourbit; /* sixtyfour bit platform */ int mbox_sleeping; int mbox_sleep_ok; int mboxbsy; Modified: stable/10/sys/dev/isp/ispvar.h ============================================================================== --- stable/10/sys/dev/isp/ispvar.h Sun Apr 2 10:53:03 2017 (r316400) +++ stable/10/sys/dev/isp/ispvar.h Sun Apr 2 10:53:37 2017 (r316401) @@ -532,9 +532,8 @@ struct ispsoftc { uint32_t isp_maxluns; /* maximum luns supported */ uint32_t isp_clock : 8, /* input clock */ - : 4, + : 5, isp_port : 1, /* 23XX/24XX only */ - isp_open : 1, /* opened (ioctl) */ isp_bustype : 1, /* SBus or PCI */ isp_loaded_fw : 1, /* loaded firmware */ isp_dblev : 16; /* debug log mask */ @@ -553,7 +552,6 @@ struct ispsoftc { volatile u_int isp_mboxbsy; /* mailbox command active */ volatile u_int isp_state; - volatile u_int isp_nactive; /* how many commands active */ volatile mbreg_t isp_curmbx; /* currently active mailbox command */ volatile uint32_t isp_reqodx; /* index of last ISP pickup */ volatile uint32_t isp_reqidx; /* index of next request */ From owner-svn-src-stable-10@freebsd.org Sun Apr 2 10:55:00 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D9B6D1D5D4; Sun, 2 Apr 2017 10:55:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1A1B18BC; Sun, 2 Apr 2017 10:55:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v32Asx0F041641; Sun, 2 Apr 2017 10:54:59 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v32AswYY041637; Sun, 2 Apr 2017 10:54:58 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704021054.v32AswYY041637@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 2 Apr 2017 10:54:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316403 - stable/10/sys/dev/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2017 10:55:00 -0000 Author: mav Date: Sun Apr 2 10:54:58 2017 New Revision: 316403 URL: https://svnweb.freebsd.org/changeset/base/316403 Log: MFC r315677: Clean/unify some macro usage. Modified: stable/10/sys/dev/isp/isp_freebsd.c stable/10/sys/dev/isp/isp_freebsd.h stable/10/sys/dev/isp/isp_pci.c stable/10/sys/dev/isp/isp_sbus.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:54:28 2017 (r316402) +++ stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:54:58 2017 (r316403) @@ -112,14 +112,11 @@ isp_attach_chan(ispsoftc_t *isp, struct int i; #endif - /* - * Construct our SIM entry. - */ - sim = cam_sim_alloc(isp_action, isp_poll, "isp", isp, device_get_unit(isp->isp_dev), &isp->isp_osinfo.lock, isp->isp_maxcmds, isp->isp_maxcmds, devq); - - if (sim == NULL) { + sim = cam_sim_alloc(isp_action, isp_poll, "isp", isp, + device_get_unit(isp->isp_dev), &isp->isp_lock, + isp->isp_maxcmds, isp->isp_maxcmds, devq); + if (sim == NULL) return (ENOMEM); - } ISP_LOCK(isp); if (xpt_bus_register(sim, isp->isp_dev, chan) != CAM_SUCCESS) { @@ -173,7 +170,7 @@ isp_attach_chan(ispsoftc_t *isp, struct fc->isp = isp; fc->ready = 1; - callout_init_mtx(&fc->gdt, &isp->isp_osinfo.lock, 0); + callout_init_mtx(&fc->gdt, &isp->isp_lock, 0); TASK_INIT(&fc->gtask, 1, isp_gdt_task, fc); #ifdef ISP_TARGET_MODE TAILQ_INIT(&fc->waitq); @@ -267,7 +264,7 @@ isp_detach_chan(ispsoftc_t *isp, int cha /* Wait for the channel's spawned threads to exit. */ wakeup(isp->isp_osinfo.pc.ptr); while (*num_threads != 0) - mtx_sleep(isp, &isp->isp_osinfo.lock, PRIBIO, "isp_reap", 100); + mtx_sleep(isp, &isp->isp_lock, PRIBIO, "isp_reap", 100); } int @@ -291,7 +288,7 @@ isp_attach(ispsoftc_t *isp) } } - callout_init_mtx(&isp->isp_osinfo.tmo, &isp->isp_osinfo.lock, 0); + callout_init_mtx(&isp->isp_osinfo.tmo, &isp->isp_lock, 0); isp_timer_count = hz >> 2; callout_reset(&isp->isp_osinfo.tmo, isp_timer_count, isp_timer, isp); @@ -2805,8 +2802,7 @@ isp_kthread(void *arg) int slp = 0, d; int lb, lim; - mtx_lock(&isp->isp_osinfo.lock); - + ISP_LOCK(isp); while (isp->isp_osinfo.is_exiting == 0) { isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d Checking FC state", chan); @@ -2860,10 +2856,10 @@ isp_kthread(void *arg) isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d sleep for %d seconds", chan, slp); - msleep(fc, &isp->isp_osinfo.lock, PRIBIO, "ispf", slp * hz); + msleep(fc, &isp->isp_lock, PRIBIO, "ispf", slp * hz); } fc->num_threads -= 1; - mtx_unlock(&isp->isp_osinfo.lock); + ISP_UNLOCK(isp); kthread_exit(); } @@ -2969,13 +2965,13 @@ isp_action(struct cam_sim *sim, union cc CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("isp_action\n")); isp = (ispsoftc_t *)cam_sim_softc(sim); - mtx_assert(&isp->isp_lock, MA_OWNED); + ISP_ASSERT_LOCKED(isp); + bus = cam_sim_bus(sim); isp_prt(isp, ISP_LOGDEBUG2, "isp_action code %x", ccb->ccb_h.func_code); ISP_PCMD(ccb) = NULL; switch (ccb->ccb_h.func_code) { case XPT_SCSI_IO: /* Execute the requested I/O operation */ - bus = XS_CHANNEL(ccb); /* * Do a couple of preliminary checks... */ @@ -3133,7 +3129,6 @@ isp_action(struct cam_sim *sim, union cc break; #endif case XPT_RESET_DEV: /* BDR the specified SCSI device */ - bus = cam_sim_bus(xpt_path_sim(ccb->ccb_h.path)); tgt = ccb->ccb_h.target_id; tgt |= (bus << 16); @@ -3192,7 +3187,6 @@ isp_action(struct cam_sim *sim, union cc break; } tgt = cts->ccb_h.target_id; - bus = cam_sim_bus(xpt_path_sim(cts->ccb_h.path)); if (IS_SCSI(isp)) { struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi; struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi; @@ -3257,7 +3251,6 @@ isp_action(struct cam_sim *sim, union cc case XPT_GET_TRAN_SETTINGS: cts = &ccb->cts; tgt = cts->ccb_h.target_id; - bus = cam_sim_bus(xpt_path_sim(cts->ccb_h.path)); if (IS_FC(isp)) { fcparam *fcp = FCPARAM(isp, bus); struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi; @@ -3346,7 +3339,6 @@ isp_action(struct cam_sim *sim, union cc break; case XPT_RESET_BUS: /* Reset the specified bus */ - bus = cam_sim_bus(sim); error = isp_control(isp, ISPCTL_RESET_BUS, bus); if (error) { ccb->ccb_h.status = CAM_REQ_CMP_ERR; @@ -3381,7 +3373,6 @@ isp_action(struct cam_sim *sim, union cc break; } - bus = cam_sim_bus(xpt_path_sim(kp->ccb_h.path)); fcp = FCPARAM(isp, bus); if (kp->xport_specific.fc.valid & KNOB_VALID_ADDRESS) { @@ -3440,7 +3431,6 @@ isp_action(struct cam_sim *sim, union cc if (IS_FC(isp)) { fcparam *fcp; - bus = cam_sim_bus(xpt_path_sim(kp->ccb_h.path)); fcp = FCPARAM(isp, bus); kp->xport_specific.fc.wwnn = fcp->isp_wwnn; @@ -3488,7 +3478,6 @@ isp_action(struct cam_sim *sim, union cc else cpi->maxio = (ISP_NSEG_MAX - 1) * PAGE_SIZE; - bus = cam_sim_bus(xpt_path_sim(cpi->ccb_h.path)); if (IS_FC(isp)) { fcparam *fcp = FCPARAM(isp, bus); @@ -4058,7 +4047,7 @@ isp_mbox_wait_complete(ispsoftc_t *isp, if (isp->isp_osinfo.mbox_sleep_ok) { isp->isp_osinfo.mbox_sleep_ok = 0; isp->isp_osinfo.mbox_sleeping = 1; - msleep_sbt(&isp->isp_osinfo.mboxcmd_done, &isp->isp_osinfo.lock, + msleep_sbt(&isp->isp_osinfo.mboxcmd_done, &isp->isp_lock, PRIBIO, "ispmbx_sleep", to * SBT_1US, 0, 0); isp->isp_osinfo.mbox_sleep_ok = 1; isp->isp_osinfo.mbox_sleeping = 0; Modified: stable/10/sys/dev/isp/isp_freebsd.h ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.h Sun Apr 2 10:54:28 2017 (r316402) +++ stable/10/sys/dev/isp/isp_freebsd.h Sun Apr 2 10:54:58 2017 (r316403) @@ -356,9 +356,9 @@ struct isposinfo { /* * Locking macros... */ -#define ISP_LOCK(isp) mtx_lock(&(isp)->isp_osinfo.lock) -#define ISP_UNLOCK(isp) mtx_unlock(&(isp)->isp_osinfo.lock) -#define ISP_ASSERT_LOCKED(isp) mtx_assert(&(isp)->isp_osinfo.lock, MA_OWNED) +#define ISP_LOCK(isp) mtx_lock(&(isp)->isp_lock) +#define ISP_UNLOCK(isp) mtx_unlock(&(isp)->isp_lock) +#define ISP_ASSERT_LOCKED(isp) mtx_assert(&(isp)->isp_lock, MA_OWNED) /* * Required Macros/Defines @@ -370,7 +370,7 @@ struct isposinfo { #define ISP_SNPRINTF snprintf #define ISP_DELAY(x) DELAY(x) #define ISP_SLEEP(isp, x) msleep_sbt(&(isp)->isp_osinfo.is_exiting, \ - &(isp)->isp_osinfo.lock, 0, "isp_sleep", (x) * SBT_1US, 0, 0) + &(isp)->isp_lock, 0, "isp_sleep", (x) * SBT_1US, 0, 0) #define ISP_MIN imin @@ -722,14 +722,6 @@ int isp_fcp_next_crn(ispsoftc_t *, uint8 /* * Platform Version specific defines */ -#define BUS_DMA_ROOTARG(x) bus_get_dma_tag(x) -#define isp_dma_tag_create(a, b, c, d, e, f, g, h, i, j, k, z) \ - bus_dma_tag_create(a, b, c, d, e, f, g, h, i, j, k, \ - busdma_lock_mutex, &isp->isp_osinfo.lock, z) - -#define isp_sim_alloc(a, b, c, d, e, f, g, h) \ - cam_sim_alloc(a, b, c, d, e, &(d)->isp_osinfo.lock, f, g, h) - #define ISP_PATH_PRT(i, l, p, ...) \ if ((l) == ISP_LOGALL || ((l)& (i)->isp_dblev) != 0) { \ xpt_print(p, __VA_ARGS__); \ Modified: stable/10/sys/dev/isp/isp_pci.c ============================================================================== --- stable/10/sys/dev/isp/isp_pci.c Sun Apr 2 10:54:28 2017 (r316402) +++ stable/10/sys/dev/isp/isp_pci.c Sun Apr 2 10:54:58 2017 (r316403) @@ -684,7 +684,7 @@ isp_pci_attach(device_t dev) isp->isp_nchan = 1; if (sizeof (bus_addr_t) > 4) isp->isp_osinfo.sixtyfourbit = 1; - mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF); + mtx_init(&isp->isp_lock, "isp", NULL, MTX_DEF); /* * Get Generic Options @@ -981,7 +981,7 @@ bad: free(pcs->pci_isp.isp_osinfo.pc.ptr, M_DEVBUF); pcs->pci_isp.isp_osinfo.pc.ptr = NULL; } - mtx_destroy(&isp->isp_osinfo.lock); + mtx_destroy(&isp->isp_lock); return (ENXIO); } @@ -1019,7 +1019,7 @@ isp_pci_detach(device_t dev) free(pcs->pci_isp.isp_osinfo.pc.ptr, M_DEVBUF); pcs->pci_isp.isp_osinfo.pc.ptr = NULL; } - mtx_destroy(&isp->isp_osinfo.lock); + mtx_destroy(&isp->isp_lock); return (0); } @@ -1532,9 +1532,9 @@ isp_pci_mbxdma(ispsoftc_t *isp) else nsegs = ISP_NSEG_MAX; - if (isp_dma_tag_create(BUS_DMA_ROOTARG(ISP_PCD(isp)), 1, + if (bus_dma_tag_create(bus_get_dma_tag(ISP_PCD(isp)), 1, slim, llim, hlim, NULL, NULL, BUS_SPACE_MAXSIZE, nsegs, slim, 0, - &isp->isp_osinfo.dmat)) { + busdma_lock_mutex, &isp->isp_lock, &isp->isp_osinfo.dmat)) { ISP_LOCK(isp); isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); return (1); @@ -1547,9 +1547,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); if (isp->isp_type >= ISP_HA_FC_2200) len += (N_XCMDS * XCMD_SIZE); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.reqdmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.reqdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag"); goto bad; } @@ -1588,9 +1589,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) * Allocate and map the result queue. */ len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.respdmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.respdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); goto bad; } @@ -1617,9 +1619,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) */ if (IS_24XX(isp)) { len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.atiodmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.atiodmat)) { isp_prt(isp, ISP_LOGERR, "cannot create ATIO DMA tag"); goto bad; } @@ -1643,9 +1646,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) #endif if (IS_FC(isp)) { - if (isp_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - 2*QENTRY_LEN, 1, 2*QENTRY_LEN, 0, &isp->isp_osinfo.iocbdmat)) { + 2*QENTRY_LEN, 1, 2*QENTRY_LEN, 0, busdma_lock_mutex, + &isp->isp_lock, &isp->isp_osinfo.iocbdmat)) { goto bad; } if (bus_dmamem_alloc(isp->isp_osinfo.iocbdmat, @@ -1658,9 +1662,10 @@ isp_pci_mbxdma(ispsoftc_t *isp) goto bad; isp->isp_iocb_dma = im.maddr; - if (isp_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - ISP_FC_SCRLEN, 1, ISP_FC_SCRLEN, 0, &isp->isp_osinfo.scdmat)) + ISP_FC_SCRLEN, 1, ISP_FC_SCRLEN, 0, busdma_lock_mutex, + &isp->isp_lock, &isp->isp_osinfo.scdmat)) goto bad; for (cmap = 0; cmap < isp->isp_nchan; cmap++) { struct isp_fc *fc = ISP_FC_PC(isp, cmap); @@ -1715,7 +1720,7 @@ gotmaxcmds: } goto bad; } - callout_init_mtx(&pcmd->wdog, &isp->isp_osinfo.lock, 0); + callout_init_mtx(&pcmd->wdog, &isp->isp_lock, 0); if (i == isp->isp_maxcmds-1) pcmd->next = NULL; else Modified: stable/10/sys/dev/isp/isp_sbus.c ============================================================================== --- stable/10/sys/dev/isp/isp_sbus.c Sun Apr 2 10:54:28 2017 (r316402) +++ stable/10/sys/dev/isp/isp_sbus.c Sun Apr 2 10:54:58 2017 (r316403) @@ -143,7 +143,7 @@ isp_sbus_attach(device_t dev) sbs->sbus_dev = dev; sbs->sbus_mdvec = mdvec; isp->isp_dev = dev; - mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF); + mtx_init(&isp->isp_lock, "isp", NULL, MTX_DEF); role = 0; if (resource_int_value(device_get_name(dev), device_get_unit(dev), @@ -310,7 +310,7 @@ bad: (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); } - mtx_destroy(&isp->isp_osinfo.lock); + mtx_destroy(&isp->isp_lock); return (ENXIO); } @@ -334,7 +334,7 @@ isp_sbus_detach(device_t dev) } (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); isp_sbus_mbxdmafree(isp); - mtx_destroy(&isp->isp_osinfo.lock); + mtx_destroy(&isp->isp_lock); return (0); } @@ -429,10 +429,11 @@ isp_sbus_mbxdma(ispsoftc_t *isp) if (isp->isp_rquest != NULL) goto gotmaxcmds; - if (isp_dma_tag_create(BUS_DMA_ROOTARG(ISP_SBD(isp)), 1, + if (bus_dma_tag_create(bus_get_dma_tag(ISP_SBD(isp)), 1, BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, - ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, &isp->isp_osinfo.dmat)) { + ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, + busdma_lock_mutex, &isp->isp_lock, &isp->isp_osinfo.dmat)) { isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); goto bad; } @@ -441,9 +442,10 @@ isp_sbus_mbxdma(ispsoftc_t *isp) * Allocate and map the request queue. */ len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.reqdmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.reqdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag"); goto bad; } @@ -468,9 +470,10 @@ isp_sbus_mbxdma(ispsoftc_t *isp) * Allocate and map the result queue. */ len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (isp_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, + if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, &isp->isp_osinfo.respdmat)) { + len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, + &isp->isp_osinfo.respdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); goto bad; } @@ -512,7 +515,7 @@ gotmaxcmds: } goto bad; } - callout_init_mtx(&pcmd->wdog, &isp->isp_osinfo.lock, 0); + callout_init_mtx(&pcmd->wdog, &isp->isp_lock, 0); if (i == isp->isp_maxcmds-1) { pcmd->next = NULL; } else { From owner-svn-src-stable-10@freebsd.org Sun Apr 2 10:56:10 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C5FE6D1D710; Sun, 2 Apr 2017 10:56:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97AB5C12; Sun, 2 Apr 2017 10:56:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v32Au9gn041942; Sun, 2 Apr 2017 10:56:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v32Au9eY041941; Sun, 2 Apr 2017 10:56:09 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704021056.v32Au9eY041941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 2 Apr 2017 10:56:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316405 - stable/10/sys/dev/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2017 10:56:10 -0000 Author: mav Date: Sun Apr 2 10:56:09 2017 New Revision: 316405 URL: https://svnweb.freebsd.org/changeset/base/316405 Log: MFC r315678: Remove questionable reqp->req_time access. Modified: stable/10/sys/dev/isp/isp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp.c ============================================================================== --- stable/10/sys/dev/isp/isp.c Sun Apr 2 10:55:40 2017 (r316404) +++ stable/10/sys/dev/isp/isp.c Sun Apr 2 10:56:09 2017 (r316405) @@ -4424,8 +4424,6 @@ isp_start(XS_T *xs) } } - tptr = &reqp->req_time; - /* * NB: we do not support long CDBs (yet) */ @@ -4439,8 +4437,9 @@ isp_start(XS_T *xs) } reqp->req_target = target | (XS_CHANNEL(xs) << 7); reqp->req_lun_trn = XS_LUN(xs); - cdbp = reqp->req_cdb; reqp->req_cdblen = cdblen; + tptr = &reqp->req_time; + cdbp = reqp->req_cdb; } else if (IS_24XX(isp)) { ispreqt7_t *t7 = (ispreqt7_t *)local; @@ -4487,15 +4486,17 @@ isp_start(XS_T *xs) ispreqt2e_t *t2e = (ispreqt2e_t *)local; t2e->req_target = lp->handle; t2e->req_scclun = XS_LUN(xs); + tptr = &t2e->req_time; cdbp = t2e->req_cdb; } else if (ISP_CAP_SCCFW(isp)) { - ispreqt2_t *t2 = (ispreqt2_t *)local; t2->req_target = lp->handle; t2->req_scclun = XS_LUN(xs); + tptr = &t2->req_time; cdbp = t2->req_cdb; } else { t2->req_target = lp->handle; t2->req_lun_trn = XS_LUN(xs); + tptr = &t2->req_time; cdbp = t2->req_cdb; } } From owner-svn-src-stable-10@freebsd.org Sun Apr 2 10:57:50 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F17DED1D81D; Sun, 2 Apr 2017 10:57:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B218BE93; Sun, 2 Apr 2017 10:57:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v32Avnfv042117; Sun, 2 Apr 2017 10:57:49 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v32AvnAb042113; Sun, 2 Apr 2017 10:57:49 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704021057.v32AvnAb042113@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 2 Apr 2017 10:57:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316407 - stable/10/sys/dev/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2017 10:57:51 -0000 Author: mav Date: Sun Apr 2 10:57:49 2017 New Revision: 316407 URL: https://svnweb.freebsd.org/changeset/base/316407 Log: MFC r315681: Improve command timeout handling. Let firmware do its best first, and if it can't, try software recovery. I would remove software timeout handler completely, but found bunch of complains on command timeout on sparc64 mailing list few years ago, so better be safe in case of interrupt loss. Modified: stable/10/sys/dev/isp/isp.c stable/10/sys/dev/isp/isp_freebsd.c stable/10/sys/dev/isp/isp_freebsd.h stable/10/sys/dev/isp/ispvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp.c ============================================================================== --- stable/10/sys/dev/isp/isp.c Sun Apr 2 10:57:19 2017 (r316406) +++ stable/10/sys/dev/isp/isp.c Sun Apr 2 10:57:49 2017 (r316407) @@ -4500,13 +4500,9 @@ isp_start(XS_T *xs) cdbp = t2->req_cdb; } } + *tptr = XS_TIME(xs); ISP_MEMCPY(cdbp, XS_CDBP(xs), cdblen); - *tptr = (XS_TIME(xs) + 999) / 1000; - if (IS_24XX(isp) && *tptr > 0x1999) { - *tptr = 0x1999; - } - /* Whew. Thankfully the same for type 7 requests */ reqp->req_handle = isp_allocate_handle(isp, xs, ISP_HANDLE_INITIATOR); if (reqp->req_handle == 0) { Modified: stable/10/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:57:19 2017 (r316406) +++ stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:57:49 2017 (r316407) @@ -1241,7 +1241,7 @@ isp_target_start_ctio(ispsoftc_t *isp, u cto->ct_iid_hi = atp->sid >> 16; cto->ct_oxid = atp->oxid; cto->ct_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(ccb)); - cto->ct_timeout = (XS_TIME(ccb) + 999) / 1000; + cto->ct_timeout = XS_TIME(ccb); cto->ct_flags = atp->tattr << CT7_TASK_ATTR_SHIFT; /* @@ -1390,7 +1390,7 @@ isp_target_start_ctio(ispsoftc_t *isp, u cto->ct_lun = ccb->ccb_h.target_lun; } } - cto->ct_timeout = (XS_TIME(ccb) + 999) / 1000; + cto->ct_timeout = XS_TIME(ccb); cto->ct_rxid = cso->tag_id; /* @@ -2958,9 +2958,10 @@ isp_abort_inot(ispsoftc_t *isp, union cc static void isp_action(struct cam_sim *sim, union ccb *ccb) { - int bus, tgt, ts, error; + int bus, tgt, error; ispsoftc_t *isp; struct ccb_trans_settings *cts; + sbintime_t ts; CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("isp_action\n")); @@ -3010,15 +3011,12 @@ isp_action(struct cam_sim *sim, union cc switch (error) { case CMD_QUEUED: ccb->ccb_h.status |= CAM_SIM_QUEUED; - if (ccb->ccb_h.timeout == CAM_TIME_INFINITY) { + if (ccb->ccb_h.timeout == CAM_TIME_INFINITY) break; - } - ts = ccb->ccb_h.timeout; - if (ts == CAM_TIME_DEFAULT) { - ts = 60*1000; - } - ts = isp_mstohz(ts); - callout_reset(&PISP_PCMD(ccb)->wdog, ts, isp_watchdog, ccb); + /* Give firmware extra 10s to handle timeout. */ + ts = SBT_1MS * ccb->ccb_h.timeout + 10 * SBT_1S; + callout_reset_sbt(&PISP_PCMD(ccb)->wdog, ts, 0, + isp_watchdog, ccb, 0); break; case CMD_RQLATER: isp_prt(isp, ISP_LOGDEBUG0, "%d.%jx retry later", @@ -4096,23 +4094,6 @@ isp_fc_scratch_acquire(ispsoftc_t *isp, return (ret); } -int -isp_mstohz(int ms) -{ - int hz; - struct timeval t; - t.tv_sec = ms / 1000; - t.tv_usec = (ms % 1000) * 1000; - hz = tvtohz(&t); - if (hz < 0) { - hz = 0x7fffffff; - } - if (hz == 0) { - hz = 1; - } - return (hz); -} - void isp_platform_intr(void *arg) { Modified: stable/10/sys/dev/isp/isp_freebsd.h ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.h Sun Apr 2 10:57:19 2017 (r316406) +++ stable/10/sys/dev/isp/isp_freebsd.h Sun Apr 2 10:57:49 2017 (r316407) @@ -520,7 +520,9 @@ default: \ #define XS_CDBLEN(ccb) (ccb)->cdb_len #define XS_XFRLEN(ccb) (ccb)->dxfer_len -#define XS_TIME(ccb) (ccb)->ccb_h.timeout +#define XS_TIME(ccb) \ + (((ccb)->ccb_h.timeout > 0xffff * 1000 - 999) ? 0 : \ + (((ccb)->ccb_h.timeout + 999) / 1000)) #define XS_GET_RESID(ccb) (ccb)->resid #define XS_SET_RESID(ccb, r) (ccb)->resid = r #define XS_STSP(ccb) (&(ccb)->scsi_status) @@ -711,7 +713,6 @@ void isp_mbox_wait_complete(ispsoftc_t * void isp_mbox_notify_done(ispsoftc_t *); void isp_mbox_release(ispsoftc_t *); int isp_fc_scratch_acquire(ispsoftc_t *, int); -int isp_mstohz(int); void isp_platform_intr(void *); void isp_platform_intr_resp(void *); void isp_platform_intr_atio(void *); Modified: stable/10/sys/dev/isp/ispvar.h ============================================================================== --- stable/10/sys/dev/isp/ispvar.h Sun Apr 2 10:57:19 2017 (r316406) +++ stable/10/sys/dev/isp/ispvar.h Sun Apr 2 10:57:49 2017 (r316407) @@ -1011,7 +1011,7 @@ void isp_prt_endcmd(ispsoftc_t *, XS_T * * XS_CDBP(xs) gets a pointer to the scsi CDB "" * XS_CDBLEN(xs) gets the CDB's length "" * XS_XFRLEN(xs) gets the associated data transfer length "" - * XS_TIME(xs) gets the time (in milliseconds) for this command + * XS_TIME(xs) gets the time (in seconds) for this command * XS_GET_RESID(xs) gets the current residual count * XS_GET_RESID(xs, resid) sets the current residual count * XS_STSP(xs) gets a pointer to the SCSI status byte "" From owner-svn-src-stable-10@freebsd.org Sun Apr 2 10:59:32 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 190B5D1D96B; Sun, 2 Apr 2017 10:59:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EA4B1175; Sun, 2 Apr 2017 10:59:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v32AxVGT042293; Sun, 2 Apr 2017 10:59:31 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v32AxUNM042291; Sun, 2 Apr 2017 10:59:30 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704021059.v32AxUNM042291@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 2 Apr 2017 10:59:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316409 - stable/10/sys/dev/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2017 10:59:32 -0000 Author: mav Date: Sun Apr 2 10:59:30 2017 New Revision: 316409 URL: https://svnweb.freebsd.org/changeset/base/316409 Log: MFC r315682, r315683: Remove some dead code left after r246713. Modified: stable/10/sys/dev/isp/isp_pci.c stable/10/sys/dev/isp/isp_sbus.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp_pci.c ============================================================================== --- stable/10/sys/dev/isp/isp_pci.c Sun Apr 2 10:58:55 2017 (r316408) +++ stable/10/sys/dev/isp/isp_pci.c Sun Apr 2 10:59:30 2017 (r316409) @@ -1835,24 +1835,11 @@ typedef struct { void *cmd_token; void *rq; /* original request */ int error; - bus_size_t mapsize; } mush_t; #define MUSHERR_NOQENTRIES -2 #ifdef ISP_TARGET_MODE -static void tdma2_2(void *, bus_dma_segment_t *, int, bus_size_t, int); -static void tdma2(void *, bus_dma_segment_t *, int, int); - -static void -tdma2_2(void *arg, bus_dma_segment_t *dm_segs, int nseg, bus_size_t mapsize, int error) -{ - mush_t *mp; - mp = (mush_t *)arg; - mp->mapsize = mapsize; - tdma2(arg, dm_segs, nseg, error); -} - static void tdma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) { @@ -1916,18 +1903,6 @@ tdma2(void *arg, bus_dma_segment_t *dm_s } #endif -static void dma2_2(void *, bus_dma_segment_t *, int, bus_size_t, int); -static void dma2(void *, bus_dma_segment_t *, int, int); - -static void -dma2_2(void *arg, bus_dma_segment_t *dm_segs, int nseg, bus_size_t mapsize, int error) -{ - mush_t *mp; - mp = (mush_t *)arg; - mp->mapsize = mapsize; - dma2(arg, dm_segs, nseg, error); -} - static void dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) { @@ -1997,7 +1972,6 @@ isp_pci_dmasetup(ispsoftc_t *isp, struct { mush_t mush, *mp; void (*eptr)(void *, bus_dma_segment_t *, int, int); - void (*eptr2)(void *, bus_dma_segment_t *, int, bus_size_t, int); int error; mp = &mush; @@ -2005,19 +1979,13 @@ isp_pci_dmasetup(ispsoftc_t *isp, struct mp->cmd_token = csio; mp->rq = ff; mp->error = 0; - mp->mapsize = 0; #ifdef ISP_TARGET_MODE - if (csio->ccb_h.func_code == XPT_CONT_TARGET_IO) { + if (csio->ccb_h.func_code == XPT_CONT_TARGET_IO) eptr = tdma2; - eptr2 = tdma2_2; - } else + else #endif - { eptr = dma2; - eptr2 = dma2_2; - } - error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, (union ccb *)csio, eptr, mp, 0); Modified: stable/10/sys/dev/isp/isp_sbus.c ============================================================================== --- stable/10/sys/dev/isp/isp_sbus.c Sun Apr 2 10:58:55 2017 (r316408) +++ stable/10/sys/dev/isp/isp_sbus.c Sun Apr 2 10:59:30 2017 (r316409) @@ -585,13 +585,10 @@ typedef struct { void *cmd_token; void *rq; /* original request */ int error; - bus_size_t mapsize; } mush_t; #define MUSHERR_NOQENTRIES -2 -static void dma2(void *, bus_dma_segment_t *, int, int); - static void dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) { @@ -634,7 +631,6 @@ static int isp_sbus_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *ff) { mush_t mush, *mp; - void (*eptr)(void *, bus_dma_segment_t *, int, int); int error; mp = &mush; @@ -642,12 +638,9 @@ isp_sbus_dmasetup(ispsoftc_t *isp, struc mp->cmd_token = csio; mp->rq = ff; mp->error = 0; - mp->mapsize = 0; - - eptr = dma2; error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat, - PISP_PCMD(csio)->dmap, (union ccb *)csio, eptr, mp, 0); + PISP_PCMD(csio)->dmap, (union ccb *)csio, dma2, mp, 0); if (error == EINPROGRESS) { bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap); mp->error = EINVAL; From owner-svn-src-stable-10@freebsd.org Sun Apr 2 11:00:20 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16314D1D9EC; Sun, 2 Apr 2017 11:00:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E5A192E5; Sun, 2 Apr 2017 11:00:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v32B0JuZ042423; Sun, 2 Apr 2017 11:00:19 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v32B0JY9042422; Sun, 2 Apr 2017 11:00:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704021100.v32B0JY9042422@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 2 Apr 2017 11:00:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316410 - stable/10/sys/dev/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2017 11:00:20 -0000 Author: mav Date: Sun Apr 2 11:00:18 2017 New Revision: 316410 URL: https://svnweb.freebsd.org/changeset/base/316410 Log: MFC r315709: Switch from using periph_links to sim_links. periph_links field belongs to periph drivers and must not be used here. Modified: stable/10/sys/dev/isp/isp_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 10:59:30 2017 (r316409) +++ stable/10/sys/dev/isp/isp_freebsd.c Sun Apr 2 11:00:18 2017 (r316410) @@ -841,7 +841,7 @@ isp_tmcmd_restart(ispsoftc_t *isp) ISP_GET_PC_ADDR(isp, bus, waitq, waitq); ccb = (union ccb *)TAILQ_FIRST(waitq); if (ccb != NULL) { - TAILQ_REMOVE(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_REMOVE(waitq, &ccb->ccb_h, sim_links.tqe); isp_target_start_ctio(isp, ccb, FROM_TIMER); } } @@ -1097,17 +1097,17 @@ isp_target_start_ctio(ispsoftc_t *isp, u /* * Insert at the tail of the list, if any, waiting CTIO CCBs */ - TAILQ_INSERT_TAIL(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_INSERT_TAIL(waitq, &ccb->ccb_h, sim_links.tqe); break; case FROM_TIMER: case FROM_SRR: case FROM_CTIO_DONE: - TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, sim_links.tqe); break; } while ((ccb = (union ccb *) TAILQ_FIRST(waitq)) != NULL) { - TAILQ_REMOVE(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_REMOVE(waitq, &ccb->ccb_h, sim_links.tqe); cso = &ccb->csio; xfrlen = cso->dxfer_len; @@ -1156,7 +1156,7 @@ isp_target_start_ctio(ispsoftc_t *isp, u */ if (atp->ctcnt >= ATPD_CCB_OUTSTANDING) { isp_prt(isp, ISP_LOGTINFO, "[0x%x] handling only %d CCBs at a time (flags for this ccb: 0x%x)", cso->tag_id, ATPD_CCB_OUTSTANDING, ccb->ccb_h.flags); - TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, sim_links.tqe); break; } @@ -1281,7 +1281,7 @@ isp_target_start_ctio(ispsoftc_t *isp, u if (atp->ests == NULL) { atp->ests = isp_get_ecmd(isp); if (atp->ests == NULL) { - TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, sim_links.tqe); break; } } @@ -1436,7 +1436,7 @@ isp_target_start_ctio(ispsoftc_t *isp, u if (atp->ests == NULL) { atp->ests = isp_get_ecmd(isp); if (atp->ests == NULL) { - TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, sim_links.tqe); break; } } @@ -1525,13 +1525,13 @@ isp_target_start_ctio(ispsoftc_t *isp, u if (isp_get_pcmd(isp, ccb)) { ISP_PATH_PRT(isp, ISP_LOGWARN, ccb->ccb_h.path, "out of PCMDs\n"); - TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, sim_links.tqe); break; } handle = isp_allocate_handle(isp, ccb, ISP_HANDLE_TARGET); if (handle == 0) { ISP_PATH_PRT(isp, ISP_LOGWARN, ccb->ccb_h.path, "No XFLIST pointers for %s\n", __func__); - TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, sim_links.tqe); isp_free_pcmd(isp, ccb); break; } @@ -1561,7 +1561,7 @@ isp_target_start_ctio(ispsoftc_t *isp, u isp_destroy_handle(isp, handle); isp_free_pcmd(isp, ccb); if (dmaresult == CMD_EAGAIN) { - TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, periph_links.tqe); + TAILQ_INSERT_HEAD(waitq, &ccb->ccb_h, sim_links.tqe); break; } ccb->ccb_h.status = CAM_REQ_CMP_ERR; From owner-svn-src-stable-10@freebsd.org Mon Apr 3 06:09:13 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 787E2D2BCCC; Mon, 3 Apr 2017 06:09:13 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4863BB34; Mon, 3 Apr 2017 06:09:13 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3369CZG011346; Mon, 3 Apr 2017 06:09:12 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3369CIo011345; Mon, 3 Apr 2017 06:09:12 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201704030609.v3369CIo011345@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 3 Apr 2017 06:09:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316440 - stable/10/share/man/man4 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Apr 2017 06:09:13 -0000 Author: delphij Date: Mon Apr 3 06:09:12 2017 New Revision: 316440 URL: https://svnweb.freebsd.org/changeset/base/316440 Log: MFC r315619: pet manlint. Modified: stable/10/share/man/man4/cpuctl.4 Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/cpuctl.4 ============================================================================== --- stable/10/share/man/man4/cpuctl.4 Mon Apr 3 06:07:40 2017 (r316439) +++ stable/10/share/man/man4/cpuctl.4 Mon Apr 3 06:09:12 2017 (r316440) @@ -160,7 +160,11 @@ field should point to the firmware image .Pp For additional information refer to .Pa cpuctl.h . -.Sh RETURN VALUES +.Sh FILES +.Bl -tag -width /dev/cpuctl -compact +.It Pa /dev/cpuctl +.El +.Sh ERRORS .Bl -tag -width Er .It Bq Er ENXIO The operation requested is not supported by the device (e.g., unsupported @@ -172,10 +176,6 @@ No physical memory was available to comp .It Bq Er EFAULT The firmware image address points outside the process address space. .El -.Sh FILES -.Bl -tag -width /dev/cpuctl -compact -.It Pa /dev/cpuctl -.El .Sh SEE ALSO .Xr hwpmc 4 , .Xr cpucontrol 8 From owner-svn-src-stable-10@freebsd.org Mon Apr 3 06:14:24 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BAD29D2BF4B; Mon, 3 Apr 2017 06:14:24 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8C79C17F; Mon, 3 Apr 2017 06:14:24 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v336ENPF015444; Mon, 3 Apr 2017 06:14:23 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v336ENJR015443; Mon, 3 Apr 2017 06:14:23 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201704030614.v336ENJR015443@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 3 Apr 2017 06:14:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316442 - stable/10/usr.bin/sed X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Apr 2017 06:14:24 -0000 Author: delphij Date: Mon Apr 3 06:14:23 2017 New Revision: 316442 URL: https://svnweb.freebsd.org/changeset/base/316442 Log: MFC r312404, r312519, r313277: Use S_ISREG instead of manual & (also it's better to compare the result from & and the pattern instead of just assuming it's one bit value). Pointed out by Tianjie Mao . Modified: stable/10/usr.bin/sed/main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/sed/main.c ============================================================================== --- stable/10/usr.bin/sed/main.c Mon Apr 3 06:13:05 2017 (r316441) +++ stable/10/usr.bin/sed/main.c Mon Apr 3 06:14:23 2017 (r316442) @@ -391,7 +391,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag if (inplace != NULL) { if (lstat(fname, &sb) != 0) err(1, "%s", fname); - if (!(sb.st_mode & S_IFREG)) + if (!S_ISREG(sb.st_mode)) errx(1, "%s: %s %s", fname, "in-place editing only", "works for regular files"); From owner-svn-src-stable-10@freebsd.org Tue Apr 4 18:01:36 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B0674D2EADB; Tue, 4 Apr 2017 18:01:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7547F2ED; Tue, 4 Apr 2017 18:01:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v34I1Zsx004306; Tue, 4 Apr 2017 18:01:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v34I1ZbT004303; Tue, 4 Apr 2017 18:01:35 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201704041801.v34I1ZbT004303@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 4 Apr 2017 18:01:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316499 - in stable/10/sys: cam sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Apr 2017 18:01:36 -0000 Author: mav Date: Tue Apr 4 18:01:35 2017 New Revision: 316499 URL: https://svnweb.freebsd.org/changeset/base/316499 Log: MFC r315673, r315674: Make CAM SIM lock optional. For three years now CAM does not use SIM lock, but still enforces SIM to use it. Remove this requirement, allowing SIMs to have any locking they prefer, if they pass no mutex to cam_sim_alloc(). Modified: stable/10/sys/cam/cam_sim.c stable/10/sys/cam/cam_xpt.c stable/10/sys/sys/param.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/cam_sim.c ============================================================================== --- stable/10/sys/cam/cam_sim.c Tue Apr 4 17:59:10 2017 (r316498) +++ stable/10/sys/cam/cam_sim.c Tue Apr 4 18:01:35 2017 (r316499) @@ -46,6 +46,9 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_CAMSIM, "CAM SIM", "CAM SIM buffers"); +static struct mtx cam_sim_free_mtx; +MTX_SYSINIT(cam_sim_free_init, &cam_sim_free_mtx, "CAM SIM free lock", MTX_DEF); + struct cam_devq * cam_simq_alloc(u_int32_t max_sim_transactions) { @@ -66,9 +69,6 @@ cam_sim_alloc(sim_action_func sim_action { struct cam_sim *sim; - if (mtx == NULL) - return (NULL); - sim = (struct cam_sim *)malloc(sizeof(struct cam_sim), M_CAMSIM, M_ZERO | M_NOWAIT); @@ -101,16 +101,23 @@ cam_sim_alloc(sim_action_func sim_action void cam_sim_free(struct cam_sim *sim, int free_devq) { + struct mtx *mtx = sim->mtx; int error; - mtx_assert(sim->mtx, MA_OWNED); + if (mtx) { + mtx_assert(mtx, MA_OWNED); + } else { + mtx = &cam_sim_free_mtx; + mtx_lock(mtx); + } sim->refcount--; if (sim->refcount > 0) { - error = msleep(sim, sim->mtx, PRIBIO, "simfree", 0); + error = msleep(sim, mtx, PRIBIO, "simfree", 0); KASSERT(error == 0, ("invalid error value for msleep(9)")); } - KASSERT(sim->refcount == 0, ("sim->refcount == 0")); + if (sim->mtx == NULL) + mtx_unlock(mtx); if (free_devq) cam_simq_free(sim->devq); @@ -120,31 +127,43 @@ cam_sim_free(struct cam_sim *sim, int fr void cam_sim_release(struct cam_sim *sim) { - int lock; + struct mtx *mtx = sim->mtx; - lock = (mtx_owned(sim->mtx) == 0); - if (lock) - CAM_SIM_LOCK(sim); + if (mtx) { + if (!mtx_owned(mtx)) + mtx_lock(mtx); + else + mtx = NULL; + } else { + mtx = &cam_sim_free_mtx; + mtx_lock(mtx); + } KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); sim->refcount--; if (sim->refcount == 0) wakeup(sim); - if (lock) - CAM_SIM_UNLOCK(sim); + if (mtx) + mtx_unlock(mtx); } void cam_sim_hold(struct cam_sim *sim) { - int lock; + struct mtx *mtx = sim->mtx; - lock = (mtx_owned(sim->mtx) == 0); - if (lock) - CAM_SIM_LOCK(sim); + if (mtx) { + if (!mtx_owned(mtx)) + mtx_lock(mtx); + else + mtx = NULL; + } else { + mtx = &cam_sim_free_mtx; + mtx_lock(mtx); + } KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); sim->refcount++; - if (lock) - CAM_SIM_UNLOCK(sim); + if (mtx) + mtx_unlock(mtx); } void Modified: stable/10/sys/cam/cam_xpt.c ============================================================================== --- stable/10/sys/cam/cam_xpt.c Tue Apr 4 17:59:10 2017 (r316498) +++ stable/10/sys/cam/cam_xpt.c Tue Apr 4 18:01:35 2017 (r316499) @@ -2483,7 +2483,7 @@ xpt_action_default(union ccb *start_ccb) { struct cam_path *path; struct cam_sim *sim; - int lock; + struct mtx *mtx; path = start_ccb->ccb_h.path; CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_action_default\n")); @@ -2637,12 +2637,14 @@ xpt_action_default(union ccb *start_ccb) case XPT_PATH_INQ: call_sim: sim = path->bus->sim; - lock = (mtx_owned(sim->mtx) == 0); - if (lock) - CAM_SIM_LOCK(sim); + mtx = sim->mtx; + if (mtx && !mtx_owned(mtx)) + mtx_lock(mtx); + else + mtx = NULL; (*(sim->sim_action))(sim, start_ccb); - if (lock) - CAM_SIM_UNLOCK(sim); + if (mtx) + mtx_unlock(mtx); break; case XPT_PATH_STATS: start_ccb->cpis.last_reset = path->bus->last_reset; @@ -2864,8 +2866,8 @@ call_sim: break; } cur_entry->event_enable = csa->event_enable; - cur_entry->event_lock = - mtx_owned(path->bus->sim->mtx) ? 1 : 0; + cur_entry->event_lock = (path->bus->sim->mtx && + mtx_owned(path->bus->sim->mtx)) ? 1 : 0; cur_entry->callback_arg = csa->callback_arg; cur_entry->callback = csa->callback; SLIST_INSERT_HEAD(async_head, cur_entry, links); @@ -3025,10 +3027,12 @@ xpt_polled_action(union ccb *start_ccb) struct cam_sim *sim; struct cam_devq *devq; struct cam_ed *dev; + struct mtx *mtx; timeout = start_ccb->ccb_h.timeout * 10; sim = start_ccb->ccb_h.path->bus->sim; devq = sim->devq; + mtx = sim->mtx; dev = start_ccb->ccb_h.path->device; mtx_unlock(&dev->device_mtx); @@ -3043,9 +3047,11 @@ xpt_polled_action(union ccb *start_ccb) (--timeout > 0)) { mtx_unlock(&devq->send_mtx); DELAY(100); - CAM_SIM_LOCK(sim); + if (mtx) + mtx_lock(mtx); (*(sim->sim_poll))(sim); - CAM_SIM_UNLOCK(sim); + if (mtx) + mtx_unlock(mtx); camisr_runqueue(); mtx_lock(&devq->send_mtx); } @@ -3055,9 +3061,11 @@ xpt_polled_action(union ccb *start_ccb) if (timeout != 0) { xpt_action(start_ccb); while(--timeout > 0) { - CAM_SIM_LOCK(sim); + if (mtx) + mtx_lock(mtx); (*(sim->sim_poll))(sim); - CAM_SIM_UNLOCK(sim); + if (mtx) + mtx_unlock(mtx); camisr_runqueue(); if ((start_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) @@ -3215,7 +3223,7 @@ static void xpt_run_devq(struct cam_devq *devq) { char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1]; - int lock; + struct mtx *mtx; CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_run_devq\n")); @@ -3317,12 +3325,14 @@ xpt_run_devq(struct cam_devq *devq) * queued device, rather than the one from the calling bus. */ sim = device->sim; - lock = (mtx_owned(sim->mtx) == 0); - if (lock) - CAM_SIM_LOCK(sim); + mtx = sim->mtx; + if (mtx && !mtx_owned(mtx)) + mtx_lock(mtx); + else + mtx = NULL; (*(sim->sim_action))(sim, work_ccb); - if (lock) - CAM_SIM_UNLOCK(sim); + if (mtx) + mtx_unlock(mtx); mtx_lock(&devq->send_mtx); } devq->send_queue.qfrozen_cnt--; @@ -3867,8 +3877,6 @@ xpt_bus_register(struct cam_sim *sim, de struct cam_path *path; cam_status status; - mtx_assert(sim->mtx, MA_OWNED); - sim->bus_id = bus; new_bus = (struct cam_eb *)malloc(sizeof(*new_bus), M_CAMXPT, M_NOWAIT|M_ZERO); @@ -4225,7 +4233,7 @@ xpt_async_bcast(struct async_list *async struct cam_path *path, void *async_arg) { struct async_node *cur_entry; - int lock; + struct mtx *mtx; cur_entry = SLIST_FIRST(async_head); while (cur_entry != NULL) { @@ -4237,14 +4245,15 @@ xpt_async_bcast(struct async_list *async */ next_entry = SLIST_NEXT(cur_entry, links); if ((cur_entry->event_enable & async_code) != 0) { - lock = cur_entry->event_lock; - if (lock) - CAM_SIM_LOCK(path->device->sim); + mtx = cur_entry->event_lock ? + path->device->sim->mtx : NULL; + if (mtx) + mtx_lock(mtx); cur_entry->callback(cur_entry->callback_arg, async_code, path, async_arg); - if (lock) - CAM_SIM_UNLOCK(path->device->sim); + if (mtx) + mtx_unlock(mtx); } cur_entry = next_entry; } Modified: stable/10/sys/sys/param.h ============================================================================== --- stable/10/sys/sys/param.h Tue Apr 4 17:59:10 2017 (r316498) +++ stable/10/sys/sys/param.h Tue Apr 4 18:01:35 2017 (r316499) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1003512 /* Master, propagated to newvers */ +#define __FreeBSD_version 1003513 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable-10@freebsd.org Wed Apr 5 21:08:27 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AF91D30459; Wed, 5 Apr 2017 21:08:27 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C8A7394; Wed, 5 Apr 2017 21:08:27 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v35L8QFZ070802; Wed, 5 Apr 2017 21:08:26 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v35L8QYT070801; Wed, 5 Apr 2017 21:08:26 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201704052108.v35L8QYT070801@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 5 Apr 2017 21:08:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316543 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Apr 2017 21:08:27 -0000 Author: brooks Date: Wed Apr 5 21:08:26 2017 New Revision: 316543 URL: https://svnweb.freebsd.org/changeset/base/316543 Log: MFC r316497: Correct a kernel stack leak in 32-bit compat when vfc_name is short. Don't zero unused pointer members again. Per discussion with secteam we are not issuing an advisory for this issue as we have no current evidence it leaks exploitable information. Reviewed by: rwatson, glebius, delphij Sponsored by: DARPA, AFRL Modified: stable/10/sys/kern/vfs_subr.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_subr.c ============================================================================== --- stable/10/sys/kern/vfs_subr.c Wed Apr 5 20:11:05 2017 (r316542) +++ stable/10/sys/kern/vfs_subr.c Wed Apr 5 21:08:26 2017 (r316543) @@ -3357,12 +3357,11 @@ vfsconf2x32(struct sysctl_req *req, stru { struct xvfsconf32 xvfsp; + bzero(&xvfsp, sizeof(xvfsp)); strcpy(xvfsp.vfc_name, vfsp->vfc_name); xvfsp.vfc_typenum = vfsp->vfc_typenum; xvfsp.vfc_refcount = vfsp->vfc_refcount; xvfsp.vfc_flags = vfsp->vfc_flags; - xvfsp.vfc_vfsops = 0; - xvfsp.vfc_next = 0; return (SYSCTL_OUT(req, &xvfsp, sizeof(xvfsp))); } #endif From owner-svn-src-stable-10@freebsd.org Thu Apr 6 05:04:21 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63584D31922; Thu, 6 Apr 2017 05:04:21 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 35184ACB; Thu, 6 Apr 2017 05:04:21 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3654K1M067570; Thu, 6 Apr 2017 05:04:20 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3654Kpc067569; Thu, 6 Apr 2017 05:04:20 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201704060504.v3654Kpc067569@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 6 Apr 2017 05:04:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316555 - stable/10 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Apr 2017 05:04:21 -0000 Author: ngie Date: Thu Apr 6 05:04:20 2017 New Revision: 316555 URL: https://svnweb.freebsd.org/changeset/base/316555 Log: MFC r316368: r316368 (by jkim): Fix typos to stop removing new files. Modified: stable/10/ObsoleteFiles.inc Directory Properties: stable/10/ (props changed) Modified: stable/10/ObsoleteFiles.inc ============================================================================== --- stable/10/ObsoleteFiles.inc Thu Apr 6 05:02:03 2017 (r316554) +++ stable/10/ObsoleteFiles.inc Thu Apr 6 05:04:20 2017 (r316555) @@ -40,16 +40,16 @@ # 20170322: rename to _test to match the FreeBSD test suite name scheme OLD_FILES+=usr/tests/usr.bin/col/col -OLD_FILES+=usr/tests/usr.sbin/pw/pw_config_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_etcdir_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_lock_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupadd_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupdel_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupmod_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_useradd_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_userdel_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_usermod_test -OLD_FILES+=usr/tests/usr.sbin/pw/pw_usernext_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_config +OLD_FILES+=usr/tests/usr.sbin/pw/pw_etcdir +OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupadd +OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupdel +OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupmod +OLD_FILES+=usr/tests/usr.sbin/pw/pw_lock +OLD_FILES+=usr/tests/usr.sbin/pw/pw_useradd +OLD_FILES+=usr/tests/usr.sbin/pw/pw_userdel +OLD_FILES+=usr/tests/usr.sbin/pw/pw_usermod +OLD_FILES+=usr/tests/usr.sbin/pw/pw_usernext # 20170214: Four files from ggate tests consolidated into one OLD_FILES+=usr/tests/sys/geom/class/gate/1_test OLD_FILES+=usr/tests/sys/geom/class/gate/2_test From owner-svn-src-stable-10@freebsd.org Thu Apr 6 06:11:06 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0DE31D317B6; Thu, 6 Apr 2017 06:11:06 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1D6F910; Thu, 6 Apr 2017 06:11:05 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v366B4mk095050; Thu, 6 Apr 2017 06:11:04 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v366B4WA095049; Thu, 6 Apr 2017 06:11:04 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201704060611.v366B4WA095049@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 6 Apr 2017 06:11:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316559 - in stable: 10/usr.sbin/ntp 11/usr.sbin/ntp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Apr 2017 06:11:06 -0000 Author: cy Date: Thu Apr 6 06:11:04 2017 New Revision: 316559 URL: https://svnweb.freebsd.org/changeset/base/316559 Log: MFC r314946: Configure leap-second smearing (always). Leap-second smearing is an experimental option that may be specified in ntp.conf(5) and the -x option on the command line to spread the effect of a leap-second over an interval as specified by the leapsmearinterval config file statement. Recommended values are between 7200 (2 hours) and 86400 (24 hours). It is advised that leap-second smearing not be used for public NTP servers (https://www.meinbergglobal.com/download/burnicki/Leap\ %20Second%20Smearing%20With%20NTP.pdf). It is also advised that NTP clients not use a mix of NTP servers using leap-second smearing with NTP servers not using leap-second smearing as that could cause undefined client behaviour. Leap-second smearing was committed to ports net/ntp and net/ntp-devel by r426825 on 2016-11-22. Suggested by: des Modified: stable/10/usr.sbin/ntp/config.h Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/usr.sbin/ntp/config.h Directory Properties: stable/11/ (props changed) Modified: stable/10/usr.sbin/ntp/config.h ============================================================================== --- stable/10/usr.sbin/ntp/config.h Thu Apr 6 05:36:35 2017 (r316558) +++ stable/10/usr.sbin/ntp/config.h Thu Apr 6 06:11:04 2017 (r316559) @@ -1336,7 +1336,7 @@ #define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 /* leap smear mechanism */ -/* #undef LEAP_SMEAR */ +#define LEAP_SMEAR 1 /* Define to any value to include libseccomp sandboxing. */ /* #undef LIBSECCOMP */ From owner-svn-src-stable-10@freebsd.org Thu Apr 6 19:13:41 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E609CD32F95; Thu, 6 Apr 2017 19:13:41 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A23048CD; Thu, 6 Apr 2017 19:13:41 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v36JDemj013334; Thu, 6 Apr 2017 19:13:40 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v36JDe8S013331; Thu, 6 Apr 2017 19:13:40 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201704061913.v36JDe8S013331@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Thu, 6 Apr 2017 19:13:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316588 - stable/10/sys/dev/e1000 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Apr 2017 19:13:42 -0000 Author: sbruno Date: Thu Apr 6 19:13:40 2017 New Revision: 316588 URL: https://svnweb.freebsd.org/changeset/base/316588 Log: Direct commit of fixes to stable/10, resolving PCI passthrough and initialization issues when trying to passthrough a i340 (igb) to VMware. While here, cleanup some bits of em(4) to DTRT as well. PR: 218113 Submitted by: Kaho Toshikazu Modified: stable/10/sys/dev/e1000/if_em.c stable/10/sys/dev/e1000/if_em.h stable/10/sys/dev/e1000/if_igb.c Modified: stable/10/sys/dev/e1000/if_em.c ============================================================================== --- stable/10/sys/dev/e1000/if_em.c Thu Apr 6 19:10:16 2017 (r316587) +++ stable/10/sys/dev/e1000/if_em.c Thu Apr 6 19:13:40 2017 (r316588) @@ -2846,7 +2846,7 @@ em_free_pci_resources(struct adapter *ad if (adapter->msix_mem != NULL) bus_release_resource(dev, SYS_RES_MEMORY, - PCIR_BAR(EM_MSIX_BAR), adapter->msix_mem); + adapter->memrid, adapter->msix_mem); if (adapter->memory != NULL) bus_release_resource(dev, SYS_RES_MEMORY, @@ -2880,9 +2880,9 @@ em_setup_msix(struct adapter *adapter) em_enable_vectors_82574(adapter); #endif /* Map the MSIX BAR */ - int rid = PCIR_BAR(EM_MSIX_BAR); + adapter->memrid = PCIR_BAR(EM_MSIX_BAR); adapter->msix_mem = bus_alloc_resource_any(dev, - SYS_RES_MEMORY, &rid, RF_ACTIVE); + SYS_RES_MEMORY, &adapter->memrid, RF_ACTIVE); if (adapter->msix_mem == NULL) { /* May not be enabled */ device_printf(adapter->dev, @@ -2933,7 +2933,7 @@ msix_one: msi: if (adapter->msix_mem != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, - PCIR_BAR(EM_MSIX_BAR), adapter->msix_mem); + adapter->memrid, adapter->msix_mem); adapter->msix_mem = NULL; } val = 1; Modified: stable/10/sys/dev/e1000/if_em.h ============================================================================== --- stable/10/sys/dev/e1000/if_em.h Thu Apr 6 19:10:16 2017 (r316587) +++ stable/10/sys/dev/e1000/if_em.h Thu Apr 6 19:13:40 2017 (r316588) @@ -400,6 +400,7 @@ struct adapter { struct resource *memory; struct resource *flash; struct resource *msix_mem; + int memrid; struct resource *res; void *tag; Modified: stable/10/sys/dev/e1000/if_igb.c ============================================================================== --- stable/10/sys/dev/e1000/if_igb.c Thu Apr 6 19:10:16 2017 (r316587) +++ stable/10/sys/dev/e1000/if_igb.c Thu Apr 6 19:13:40 2017 (r316588) @@ -2806,7 +2806,7 @@ igb_setup_msix(struct adapter *adapter) msi: if (adapter->msix_mem != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, - PCIR_BAR(IGB_MSIX_BAR), adapter->msix_mem); + adapter->memrid, adapter->msix_mem); adapter->msix_mem = NULL; } msgs = 1; From owner-svn-src-stable-10@freebsd.org Sat Apr 8 09:49:22 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98A26D33B8E; Sat, 8 Apr 2017 09:49:22 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6A6EBE95; Sat, 8 Apr 2017 09:49:22 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v389nLl5074781; Sat, 8 Apr 2017 09:49:21 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v389nL0r074780; Sat, 8 Apr 2017 09:49:21 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201704080949.v389nL0r074780@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sat, 8 Apr 2017 09:49:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r316641 - stable/10/sys/netpfil/pf X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Apr 2017 09:49:22 -0000 Author: kp Date: Sat Apr 8 09:49:21 2017 New Revision: 316641 URL: https://svnweb.freebsd.org/changeset/base/316641 Log: MFC r316355 pf: Fix leak of pf_state_keys If we hit the state limit we returned from pf_create_state() without cleaning up. PR: 217997 Submitted by: Max Modified: stable/10/sys/netpfil/pf/pf.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netpfil/pf/pf.c ============================================================================== --- stable/10/sys/netpfil/pf/pf.c Sat Apr 8 09:48:21 2017 (r316640) +++ stable/10/sys/netpfil/pf/pf.c Sat Apr 8 09:49:21 2017 (r316641) @@ -3522,7 +3522,7 @@ pf_create_state(struct pf_rule *r, struc (counter_u64_fetch(r->states_cur) >= r->max_states)) { counter_u64_add(V_pf_status.lcounters[LCNT_STATES], 1); REASON_SET(&reason, PFRES_MAXSTATES); - return (PF_DROP); + goto csfailed; } /* src node for filter rule */ if ((r->rule_flag & PFRULE_SRCTRACK ||