CVS commit: src/sys/dev/pci
Module Name:src Committed By: nonaka Date: Sun May 1 04:22:50 UTC 2016 Modified Files: src/sys/dev/pci: agp_i810.c agpreg.h Log Message: kern/50453: Separate Pineview chipset from i915-family chipset support. Should use AGP_I965_IFPADDR instead AGP_I915_IFPADDR in Pineview, becuase AGP_I915_IFPADDR is used as PCIEXBAR. To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/sys/dev/pci/agp_i810.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/agpreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/agp_i810.c diff -u src/sys/dev/pci/agp_i810.c:1.121 src/sys/dev/pci/agp_i810.c:1.122 --- src/sys/dev/pci/agp_i810.c:1.121 Wed Oct 21 15:37:35 2015 +++ src/sys/dev/pci/agp_i810.c Sun May 1 04:22:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: agp_i810.c,v 1.121 2015/10/21 15:37:35 christos Exp $ */ +/* $NetBSD: agp_i810.c,v 1.122 2016/05/01 04:22:50 nonaka Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.121 2015/10/21 15:37:35 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.122 2016/05/01 04:22:50 nonaka Exp $"); #include #include @@ -68,13 +68,14 @@ struct agp_softc *agp_i810_sc = NULL; #define READ4(off) bus_space_read_4(isc->bst, isc->bsh, off) #define WRITE4(off,v) bus_space_write_4(isc->bst, isc->bsh, off, v) -#define CHIP_I810 0 /* i810/i815 */ -#define CHIP_I830 1 /* 830M/845G */ -#define CHIP_I855 2 /* 852GM/855GM/865G */ -#define CHIP_I915 3 /* 915G/915GM/945G/945GM/945GME */ -#define CHIP_I965 4 /* 965Q/965PM */ -#define CHIP_G33 5 /* G33/Q33/Q35 */ -#define CHIP_G4X 6 /* G45/Q45 */ +#define CHIP_I810 0 /* i810/i815 */ +#define CHIP_I830 1 /* 830M/845G */ +#define CHIP_I855 2 /* 852GM/855GM/865G */ +#define CHIP_I915 3 /* 915G/915GM/945G/945GM/945GME */ +#define CHIP_I965 4 /* 965Q/965PM */ +#define CHIP_G33 5 /* G33/Q33/Q35 */ +#define CHIP_G4X 6 /* G45/Q45 */ +#define CHIP_PINEVIEW 7 /* Pineview */ /* XXX hack, see below */ static bus_addr_t agp_i810_vga_regbase; @@ -145,6 +146,7 @@ agp_i810_write_gtt_entry(struct agp_i810 /* 965+ can do 36-bit addressing, add in the extra bits. */ if (isc->chiptype == CHIP_I965 || isc->chiptype == CHIP_G33 || + isc->chiptype == CHIP_PINEVIEW || isc->chiptype == CHIP_G4X) { if (((uintmax_t)addr >> 36) != 0) return EINVAL; @@ -216,6 +218,7 @@ agp_i810_chipset_flush(struct agp_i810_s case CHIP_I915: case CHIP_I965: case CHIP_G33: + case CHIP_PINEVIEW: case CHIP_G4X: bus_space_write_4(isc->flush_bst, isc->flush_bsh, 0, 1); break; @@ -365,8 +368,6 @@ agp_i810_attach(device_t parent, device_ case PCI_PRODUCT_INTEL_82945GM_IGD_1: case PCI_PRODUCT_INTEL_82945GME_IGD: case PCI_PRODUCT_INTEL_E7221_IGD: - case PCI_PRODUCT_INTEL_PINEVIEW_IGD: - case PCI_PRODUCT_INTEL_PINEVIEW_M_IGD: isc->chiptype = CHIP_I915; aprint_normal(": i915-family chipset\n"); break; @@ -392,6 +393,11 @@ agp_i810_attach(device_t parent, device_ isc->chiptype = CHIP_G33; aprint_normal(": G33-family chipset\n"); break; + case PCI_PRODUCT_INTEL_PINEVIEW_IGD: + case PCI_PRODUCT_INTEL_PINEVIEW_M_IGD: + isc->chiptype = CHIP_PINEVIEW; + aprint_normal(": Pineview chipset\n"); + break; case PCI_PRODUCT_INTEL_82GM45_IGD: case PCI_PRODUCT_INTEL_82GM45_IGD_1: case PCI_PRODUCT_INTEL_82IGD_E_IGD: @@ -411,6 +417,7 @@ agp_i810_attach(device_t parent, device_ switch (isc->chiptype) { case CHIP_I915: case CHIP_G33: + case CHIP_PINEVIEW: apbase = AGP_I915_GMADR; mmadr_bar = AGP_I915_MMADR; gtt_bar = AGP_I915_GTTADR; @@ -475,8 +482,9 @@ agp_i810_attach(device_t parent, device_ case CHIP_I830: case CHIP_I855: case CHIP_I915: - case CHIP_G33: case CHIP_I965: + case CHIP_G33: + case CHIP_PINEVIEW: case CHIP_G4X: isc->size = 512*1024; break; @@ -531,6 +539,7 @@ agp_i810_attach(device_t parent, device_ case CHIP_I915: case CHIP_I965: case CHIP_G33: + case CHIP_PINEVIEW: case CHIP_G4X: error = agp_i810_setup_chipset_flush_page(sc); if (error) { @@ -633,6 +642,7 @@ fail3: switch (isc->chiptype) { case CHIP_I915: case CHIP_I965: case CHIP_G33: + case CHIP_PINEVIEW: case CHIP_G4X: agp_i810_teardown_chipset_flush_page(sc); break; @@ -867,6 +877,7 @@ agp_i810_init(struct agp_softc *sc) WRITE4(AGP_I810_PGTBL_CTL, isc->pgtblctl); } else if (isc->chiptype == CHIP_I855 || isc->chiptype == CHIP_I915 || isc->chiptype == CHIP_I965 || isc->chiptype == CHIP_G33 || + isc->chiptype == CHIP_PINEVIEW || isc->chiptype == CHIP_G4X) { pcireg_t reg; u_int32_t gtt_size, stolen; /* XXX kilobytes */ @@ -925,6 +936,18 @@ agp_i810_init(struct agp_softc *sc) goto fail0; } break; + case CHIP_PINEVIEW: + switch (gcc1 & AGP_PINEVIEW_PGTBL_SIZE_MASK) { + case AGP_PINEVIEW_PGTBL_SIZE_1M: +gtt_size = 1024; +break; + default: +
CVS commit: src/sys/arch/arm/arm32
Module Name:src Committed By: ryo Date: Sat Apr 30 19:20:47 UTC 2016 Modified Files: src/sys/arch/arm/arm32: arm32_machdep.c Log Message: * fix checking physical address range. on some arm devices, physical memory doesn't start from 0x. * allow /dev/mem to read/write memory mapped I/O area depending on kauth. To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/arch/arm/arm32/arm32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/arm32/arm32_machdep.c diff -u src/sys/arch/arm/arm32/arm32_machdep.c:1.109 src/sys/arch/arm/arm32/arm32_machdep.c:1.110 --- src/sys/arch/arm/arm32/arm32_machdep.c:1.109 Sat Apr 11 13:37:59 2015 +++ src/sys/arch/arm/arm32/arm32_machdep.c Sat Apr 30 19:20:47 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: arm32_machdep.c,v 1.109 2015/04/11 13:37:59 bouyer Exp $ */ +/* $NetBSD: arm32_machdep.c,v 1.110 2016/04/30 19:20:47 ryo Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.109 2015/04/11 13:37:59 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.110 2016/04/30 19:20:47 ryo Exp $"); #include "opt_modular.h" #include "opt_md.h" @@ -680,8 +680,11 @@ module_init_md(void) int mm_md_physacc(paddr_t pa, vm_prot_t prot) { + if (pa >= physical_start && pa < physical_end) + return 0; - return (pa < ctob(physmem)) ? 0 : EFAULT; + return kauth_authorize_machdep(kauth_cred_get(), + KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL); } #ifdef __HAVE_CPU_UAREA_ALLOC_IDLELWP
CVS commit: src/sys/dev/usb
Module Name:src Committed By: jakllsch Date: Sat Apr 30 18:40:26 UTC 2016 Modified Files: src/sys/dev/usb: uhidev.c Log Message: Make #if 0 code that sets the protocol mode compilable. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/dev/usb/uhidev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uhidev.c diff -u src/sys/dev/usb/uhidev.c:1.66 src/sys/dev/usb/uhidev.c:1.67 --- src/sys/dev/usb/uhidev.c:1.66 Wed Apr 27 19:35:17 2016 +++ src/sys/dev/usb/uhidev.c Sat Apr 30 18:40:26 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: uhidev.c,v 1.66 2016/04/27 19:35:17 jakllsch Exp $ */ +/* $NetBSD: uhidev.c,v 1.67 2016/04/30 18:40:26 jakllsch Exp $ */ /* * Copyright (c) 2001, 2012 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.66 2016/04/27 19:35:17 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.67 2016/04/30 18:40:26 jakllsch Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -155,8 +155,7 @@ uhidev_attach(device_t parent, device_t (void)usbd_set_idle(iface, 0, 0); #if 0 - qflags = usbd_get_quirks(sc->sc_udev)->uq_flags; - if ((qflags & UQ_NO_SET_PROTO) == 0 && + if ((usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_NO_SET_PROTO) == 0 && id->bInterfaceSubClass != UISUBCLASS_BOOT) (void)usbd_set_protocol(iface, 1); #endif
CVS commit: src/sys/arch/prep/stand/boot
Module Name:src Committed By: skrll Date: Sat Apr 30 15:09:25 UTC 2016 Modified Files: src/sys/arch/prep/stand/boot: siop.c Log Message: Appease gcc - error: 'error' may be used uninitialized in this function To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/prep/stand/boot/siop.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/prep/stand/boot/siop.c diff -u src/sys/arch/prep/stand/boot/siop.c:1.2 src/sys/arch/prep/stand/boot/siop.c:1.3 --- src/sys/arch/prep/stand/boot/siop.c:1.2 Thu Apr 3 23:49:47 2014 +++ src/sys/arch/prep/stand/boot/siop.c Sat Apr 30 15:09:25 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: siop.c,v 1.2 2014/04/03 23:49:47 mrg Exp $ */ +/* $NetBSD: siop.c,v 1.3 2016/04/30 15:09:25 skrll Exp $ */ /* * Copyright (c) 2010 KIYOHARA Takashi * All rights reserved. @@ -864,7 +864,7 @@ scsi_interpret_sense(struct siop_adapter { struct scsi_sense_data *sense; u_int8_t key; - int error; + int error = 0; uint32_t info; static const char *error_mes[] = { "soft error (corrected)", @@ -923,7 +923,6 @@ scsi_interpret_sense(struct siop_adapter xs->resid = 0; /* not short read */ } case SKEY_EQUAL: - error = 0; break; case SKEY_NOT_READY: if (adp->sd->sc_flags & FLAGS_REMOVABLE) @@ -952,7 +951,6 @@ scsi_interpret_sense(struct siop_adapter error = EROFS; break; case SKEY_BLANK_CHECK: - error = 0; break; case SKEY_ABORTED_COMMAND: break;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 15:03:55 UTC 2016 Modified Files: src/sys/dev/usb: xhci.c Log Message: Comment updates from t-hash + Add and update comments. + Update spec URLs. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.40 src/sys/dev/usb/xhci.c:1.41 --- src/sys/dev/usb/xhci.c:1.40 Sat Apr 30 15:02:53 2016 +++ src/sys/dev/usb/xhci.c Sat Apr 30 15:03:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.40 2016/04/30 15:02:53 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.41 2016/04/30 15:03:55 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -27,16 +27,14 @@ */ /* - * USB rev 3.1 specification - * http://www.usb.org/developers/docs/usb_31_040315.zip - * USB rev 2.0 specification - * http://www.usb.org/developers/docs/usb20_docs/usb_20_031815.zip + * USB rev 2.0 and rev 3.1 specification + * http://www.usb.org/developers/docs/ * xHCI rev 1.1 specification - * http://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdf + * http://www.intel.com/technology/usb/spec.htm */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.40 2016/04/30 15:02:53 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.41 2016/04/30 15:03:55 skrll Exp $"); #include "opt_usb.h" @@ -1721,8 +1719,8 @@ xhci_close_pipe(struct usbd_pipe *pipe) if (sc->sc_dying) return; + /* xs is uninitialized before xhci_init_slot */ if (xs == NULL || xs->xs_idx == 0) - /* xs is uninitialized before xhci_init_slot */ return; DPRINTFN(4, "pipe %p slot %u dci %u", pipe, xs->xs_idx, dci, 0); @@ -2200,14 +2198,18 @@ xhci_get_lock(struct usbd_bus *bus, kmut extern uint32_t usb_cookie_no; /* - * Called if uhub_explore finds a new device (via usbd_new_device). - * Allocate and construct dev structure of default endpoint (ep0). + * xHCI 4.3 + * Called when uhub_explore finds a new device (via usbd_new_device). + * Port initialization and speed detection (4.3.1) are already done in uhub.c. + * This function does: + * Allocate and construct dev structure of default endpoint (ep0). + * Allocate and open pipe of ep0. + * Enable slot and initialize slot context. + * Set Address. + * Read initial device descriptor. * Determine initial MaxPacketSize (mps) by speed. - * Determine route string and roothub port for slot of dev. - * Allocate pipe of ep0. - * Enable and initialize slot and Set Address. - * Read device descriptor. - * Register this device. + * Read full device descriptor. + * Register this device. */ static usbd_status xhci_new_device(device_t parent, struct usbd_bus *bus, int depth, @@ -2402,7 +2404,7 @@ xhci_new_device(device_t parent, struct #if 0 /* Re-establish the default pipe with the new MPS. */ - /* In xhci this is done by xhci_update_ep0_mps. */ + /* In xhci.c xhci_update_ep0_mps() does it instead. */ usbd_kill_pipe(dev->ud_pipe0); err = usbd_setup_pipe(dev, 0, >ud_ep0, USBD_DEFAULT_INTERVAL, >ud_pipe0); @@ -2709,7 +2711,9 @@ xhci_enable_slot(struct xhci_softc * con } /* - * Deallocate DMA buffer and ring buffer, and disable_slot. + * xHCI 4.6.4 + * Deallocate ring and device/input context DMA buffers, and disable_slot. + * All endpoints in the slot should be stopped. * Should be called with sc_lock held. */ static usbd_status @@ -2750,10 +2754,11 @@ xhci_disable_slot(struct xhci_softc * co } /* - * Change slot state. - * bsr=0: ENABLED -> ADDRESSED - * bsr=1: ENABLED -> DEFAULT + * Set address of device and transition slot state from ENABLED to ADDRESSED + * if Block Setaddress Request (BSR) is false. + * If BSR==true, transition slot state from ENABLED to DEFAULT. * see xHCI 1.1 4.5.3, 3.3.4 + * Should be called without sc_lock held. */ static usbd_status xhci_address_device(struct xhci_softc * const sc,
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 15:02:53 UTC 2016 Modified Files: src/sys/dev/usb: xhci.c Log Message: Updates from t-hash + Split out printing PSI and taking ownership. + Split out resetting HC. + Split out calculating TRB index. XXX magic numbers XXX waits To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.39 src/sys/dev/usb/xhci.c:1.40 --- src/sys/dev/usb/xhci.c:1.39 Sat Apr 30 15:00:24 2016 +++ src/sys/dev/usb/xhci.c Sat Apr 30 15:02:53 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.39 2016/04/30 15:00:24 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.40 2016/04/30 15:02:53 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.39 2016/04/30 15:00:24 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.40 2016/04/30 15:02:53 skrll Exp $"); #include "opt_usb.h" @@ -495,6 +495,22 @@ xhci_trb_put(struct xhci_trb * const trb trb->trb_3 = htole32(control); } +static int +xhci_trb_get_idx(struct xhci_ring *xr, uint64_t trb_0, int *idx) +{ + /* base address of TRBs */ + bus_addr_t trbp = xhci_ring_trbp(xr, 0); + + /* trb_0 range sanity check */ + if (trb_0 == 0 || trb_0 < trbp || + (trb_0 - trbp) % sizeof(struct xhci_trb) != 0 || + (trb_0 - trbp) / sizeof(struct xhci_trb) >= xr->xr_ntrb) { + return 1; + } + *idx = (trb_0 - trbp) / sizeof(struct xhci_trb); + return 0; +} + /* --- */ void @@ -582,6 +598,59 @@ xhci_shutdown(device_t self, int flags) return false; } +static int +xhci_hc_reset(struct xhci_softc * const sc) +{ + uint32_t usbcmd, usbsts; + int i; + + /* Check controller not ready */ + for (i = 0; i < 100; i++) { + usbsts = xhci_op_read_4(sc, XHCI_USBSTS); + if ((usbsts & XHCI_STS_CNR) == 0) + break; + usb_delay_ms(>sc_bus, 1); + } + if (i >= 100) { + aprint_error_dev(sc->sc_dev, "controller not ready timeout\n"); + return EIO; + } + + /* Halt controller */ + usbcmd = 0; + xhci_op_write_4(sc, XHCI_USBCMD, usbcmd); + usb_delay_ms(>sc_bus, 1); + + /* Reset controller */ + usbcmd = XHCI_CMD_HCRST; + xhci_op_write_4(sc, XHCI_USBCMD, usbcmd); + for (i = 0; i < 100; i++) { + usbcmd = xhci_op_read_4(sc, XHCI_USBCMD); + if ((usbcmd & XHCI_CMD_HCRST) == 0) + break; + usb_delay_ms(>sc_bus, 1); + } + if (i >= 100) { + aprint_error_dev(sc->sc_dev, "host controller reset timeout\n"); + return EIO; + } + + /* Check controller not ready */ + for (i = 0; i < 100; i++) { + usbsts = xhci_op_read_4(sc, XHCI_USBSTS); + if ((usbsts & XHCI_STS_CNR) == 0) + break; + usb_delay_ms(>sc_bus, 1); + } + if (i >= 100) { + aprint_error_dev(sc->sc_dev, + "controller not ready timeout after reset\n"); + return EIO; + } + + return 0; +} + static void hexdump(const char *msg, const void *base, size_t len) @@ -610,6 +679,75 @@ hexdump(const char *msg, const void *bas #endif } +/* Process extended capabilities */ +static void +xhci_ecp(struct xhci_softc *sc, uint32_t hcc) +{ + uint32_t ecp, ecr; + + XHCIHIST_FUNC(); XHCIHIST_CALLED(); + + ecp = XHCI_HCC_XECP(hcc) * 4; + while (ecp != 0) { + ecr = xhci_read_4(sc, ecp); + aprint_debug_dev(sc->sc_dev, "ECR %x: %08x\n", ecp, ecr); + switch (XHCI_XECP_ID(ecr)) { + case XHCI_ID_PROTOCOLS: { + uint32_t w4, w8, wc; + uint16_t w2; + w2 = (ecr >> 16) & 0x; + w4 = xhci_read_4(sc, ecp + 4); + w8 = xhci_read_4(sc, ecp + 8); + wc = xhci_read_4(sc, ecp + 0xc); + aprint_debug_dev(sc->sc_dev, + " SP: %08x %08x %08x %08x\n", ecr, w4, w8, wc); + /* unused */ + if (w4 == 0x20425355 && (w2 & 0xff00) == 0x0300) { +sc->sc_ss_port_start = (w8 >> 0) & 0xff;; +sc->sc_ss_port_count = (w8 >> 8) & 0xff;; + } + if (w4 == 0x20425355 && (w2 & 0xff00) == 0x0200) { +sc->sc_hs_port_start = (w8 >> 0) & 0xff; +sc->sc_hs_port_count = (w8 >> 8) & 0xff; + } + break; + } + case XHCI_ID_USB_LEGACY: { + uint8_t bios_sem; + + /* Take host controller ownership from BIOS */ + bios_sem = xhci_read_1(sc, ecp + XHCI_XECP_BIOS_SEM); + if (bios_sem) { +/* sets xHCI to be owned by OS */ +xhci_write_1(sc, ecp + XHCI_XECP_OS_SEM, 1); +aprint_debug_dev(sc->sc_dev, +"waiting for BIOS to give up control\n"); +for (int i = 0; i < 5000; i++) { + bios_sem = xhci_read_1(sc, ecp + + XHCI_XECP_BIOS_SEM); + if (bios_sem == 0) + break; + DELAY(1000); +} +if (bios_sem) { + aprint_error_dev(sc->sc_dev, + "timed out waiting for BIOS\n"); +} + } + break; + } + default: + break; + } + ecr = xhci_read_4(sc, ecp); + if (XHCI_XECP_NEXT(ecr) == 0) { + ecp = 0; + } else { + ecp += XHCI_XECP_NEXT(ecr) * 4; + } + } +} + #define XHCI_HCCPREV1_BITS \ "\177\020" /* New bitmask */ \
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 15:00:24 UTC 2016 Modified Files: src/sys/dev/usb: xhci.c Log Message: Cancel command when command times out. From t-hash. XXX interrupt context? To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.38 src/sys/dev/usb/xhci.c:1.39 --- src/sys/dev/usb/xhci.c:1.38 Sat Apr 30 14:56:20 2016 +++ src/sys/dev/usb/xhci.c Sat Apr 30 15:00:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.38 2016/04/30 14:56:20 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.39 2016/04/30 15:00:24 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.38 2016/04/30 14:56:20 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.39 2016/04/30 15:00:24 skrll Exp $"); #include "opt_usb.h" @@ -289,7 +289,6 @@ xhci_op_write_4(const struct xhci_softc bus_space_write_4(sc->sc_iot, sc->sc_obh, offset, value); } -#if 0 /* unused */ static inline uint64_t xhci_op_read_8(const struct xhci_softc * const sc, bus_size_t offset) { @@ -309,7 +308,6 @@ xhci_op_read_8(const struct xhci_softc * return value; } -#endif /* unused */ static inline void xhci_op_write_8(const struct xhci_softc * const sc, bus_size_t offset, @@ -2536,6 +2534,46 @@ xhci_ring_put(struct xhci_softc * const } /* + * Stop execution commands, purge all commands on command ring, and + * rewind enqueue pointer. + */ +static void +xhci_abort_command(struct xhci_softc *sc) +{ + struct xhci_ring * const cr = >sc_cr; + uint64_t crcr; + int i; + + XHCIHIST_FUNC(); XHCIHIST_CALLED(); + DPRINTFN(14, "command %#"PRIx64" timeout, aborting", + sc->sc_command_addr, 0, 0, 0); + + mutex_enter(>xr_lock); + + /* 4.6.1.2 Aborting a Command */ + crcr = xhci_op_read_8(sc, XHCI_CRCR); + xhci_op_write_8(sc, XHCI_CRCR, crcr | XHCI_CRCR_LO_CA); + + for (i = 0; i < 500; i++) { + crcr = xhci_op_read_8(sc, XHCI_CRCR); + if ((crcr & XHCI_CRCR_LO_CRR) == 0) + break; + usb_delay_ms(>sc_bus, 1); + } + if ((crcr & XHCI_CRCR_LO_CRR) != 0) { + DPRINTFN(1, "Command Abort timeout", 0, 0, 0, 0); + /* reset HC here? */ + } + + /* reset command ring dequeue pointer */ + cr->xr_ep = 0; + cr->xr_cs = 1; + xhci_op_write_8(sc, XHCI_CRCR, xhci_ring_trbp(cr, 0) | cr->xr_cs); + + mutex_exit(>xr_lock); +} + +/* * Put a command on command ring, ring bell, set timer, and cv_timedwait. * Command completion is notified by cv_signal from xhci_handle_event * (called from interrupt from xHCI), or timed-out. @@ -2568,6 +2606,7 @@ xhci_do_command_locked(struct xhci_softc if (cv_timedwait(>sc_command_cv, >sc_lock, MAX(1, mstohz(timeout))) == EWOULDBLOCK) { + xhci_abort_command(sc); err = USBD_TIMEOUT; goto timedout; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 14:56:20 UTC 2016 Modified Files: src/sys/dev/usb: xhci.c Log Message: Fix type of return value in xhci_do_command To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.37 src/sys/dev/usb/xhci.c:1.38 --- src/sys/dev/usb/xhci.c:1.37 Sat Apr 30 14:53:06 2016 +++ src/sys/dev/usb/xhci.c Sat Apr 30 14:56:20 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.37 2016/04/30 14:53:06 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.38 2016/04/30 14:56:20 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.37 2016/04/30 14:53:06 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.38 2016/04/30 14:56:20 skrll Exp $"); #include "opt_usb.h" @@ -2603,7 +2603,7 @@ xhci_do_command(struct xhci_softc * cons { mutex_enter(>sc_lock); - int ret = xhci_do_command_locked(sc, trb, timeout); + usbd_status ret = xhci_do_command_locked(sc, trb, timeout); mutex_exit(>sc_lock); return ret;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 14:53:07 UTC 2016 Modified Files: src/sys/dev/usb: xhci.c Log Message: Updates from t-hash + Change xhci_init() returns errno. + Fix memory leaks in error paths. + Add more messages for critical errors. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.36 src/sys/dev/usb/xhci.c:1.37 --- src/sys/dev/usb/xhci.c:1.36 Sat Apr 30 14:51:04 2016 +++ src/sys/dev/usb/xhci.c Sat Apr 30 14:53:06 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.36 2016/04/30 14:51:04 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.37 2016/04/30 14:53:06 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.36 2016/04/30 14:51:04 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.37 2016/04/30 14:53:06 skrll Exp $"); #include "opt_usb.h" @@ -788,8 +788,10 @@ xhci_init(struct xhci_softc *sc) break; usb_delay_ms(>sc_bus, 1); } - if (i >= 100) + if (i >= 100) { + aprint_error_dev(sc->sc_dev, "controller not ready timeout\n"); return EIO; + } usbcmd = 0; xhci_op_write_4(sc, XHCI_USBCMD, usbcmd); @@ -803,8 +805,10 @@ xhci_init(struct xhci_softc *sc) break; usb_delay_ms(>sc_bus, 1); } - if (i >= 100) + if (i >= 100) { + aprint_error_dev(sc->sc_dev, "host controller reset timeout\n"); return EIO; + } for (i = 0; i < 100; i++) { usbsts = xhci_op_read_4(sc, XHCI_USBSTS); @@ -812,8 +816,11 @@ xhci_init(struct xhci_softc *sc) break; usb_delay_ms(>sc_bus, 1); } - if (i >= 100) + if (i >= 100) { + aprint_error_dev(sc->sc_dev, + "controller not ready timeout after reset\n"); return EIO; + } if (sc->sc_vendor_init) sc->sc_vendor_init(sc); @@ -821,8 +828,10 @@ xhci_init(struct xhci_softc *sc) pagesize = xhci_op_read_4(sc, XHCI_PAGESIZE); aprint_debug_dev(sc->sc_dev, "PAGESIZE 0x%08x\n", pagesize); pagesize = ffs(pagesize); - if (pagesize == 0) + if (pagesize == 0) { + aprint_error_dev(sc->sc_dev, "pagesize is 0\n"); return EIO; + } sc->sc_pgsz = 1 << (12 + (pagesize - 1)); aprint_debug_dev(sc->sc_dev, "sc_pgsz 0x%08x\n", (uint32_t)sc->sc_pgsz); aprint_debug_dev(sc->sc_dev, "sc_maxslots 0x%08x\n", @@ -830,6 +839,7 @@ xhci_init(struct xhci_softc *sc) aprint_debug_dev(sc->sc_dev, "sc_maxports %d\n", sc->sc_maxports); usbd_status err; + int rv = 0; sc->sc_maxspbuf = XHCI_HCS2_MAXSPBUF(hcs2); aprint_debug_dev(sc->sc_dev, "sc_maxspbuf %d\n", sc->sc_maxspbuf); @@ -837,8 +847,11 @@ xhci_init(struct xhci_softc *sc) err = usb_allocmem(>sc_bus, sizeof(uint64_t) * sc->sc_maxspbuf, sizeof(uint64_t), >sc_spbufarray_dma); - if (err) - return err; + if (err) { + aprint_error_dev(sc->sc_dev, + "spbufarray init fail, err %d\n", err); + return ENOMEM; + } sc->sc_spbuf_dma = kmem_zalloc(sizeof(*sc->sc_spbuf_dma) * sc->sc_maxspbuf, KM_SLEEP); @@ -848,8 +861,12 @@ xhci_init(struct xhci_softc *sc) /* allocate contexts */ err = usb_allocmem(>sc_bus, sc->sc_pgsz, sc->sc_pgsz, dma); - if (err) -return err; + if (err) { +aprint_error_dev(sc->sc_dev, +"spbufarray_dma init fail, err %d\n", err); +rv = ENOMEM; +goto bad1; + } spbufarray[i] = htole64(DMAADDR(dma, 0)); usb_syncmem(dma, 0, sc->sc_pgsz, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); @@ -867,15 +884,19 @@ xhci_init(struct xhci_softc *sc) err = xhci_ring_init(sc, >sc_cr, XHCI_COMMAND_RING_TRBS, XHCI_COMMAND_RING_SEGMENTS_ALIGN); if (err) { - aprint_error_dev(sc->sc_dev, "command ring init fail\n"); - return err; + aprint_error_dev(sc->sc_dev, "command ring init fail, err %d\n", + err); + rv = ENOMEM; + goto bad1; } err = xhci_ring_init(sc, >sc_er, XHCI_EVENT_RING_TRBS, XHCI_EVENT_RING_SEGMENTS_ALIGN); if (err) { - aprint_error_dev(sc->sc_dev, "event ring init fail\n"); - return err; + aprint_error_dev(sc->sc_dev, "event ring init fail, err %d\n", + err); + rv = ENOMEM; + goto bad2; } usb_dma_t *dma; @@ -885,23 +906,37 @@ xhci_init(struct xhci_softc *sc) dma = >sc_eventst_dma; size = roundup2(XHCI_EVENT_RING_SEGMENTS * XHCI_ERSTE_SIZE, XHCI_EVENT_RING_SEGMENT_TABLE_ALIGN); - KASSERT(size <= (512 * 1024)); + KASSERTMSG(size <= (512 * 1024), "eventst size %zu too large", size); align = XHCI_EVENT_RING_SEGMENT_TABLE_ALIGN; err = usb_allocmem(>sc_bus, size, align, dma); + if (err) { + aprint_error_dev(sc->sc_dev, "eventst init fail, err %d\n", + err); + rv = ENOMEM; + goto bad3; + } memset(KERNADDR(dma, 0), 0, size); usb_syncmem(dma, 0, size, BUS_DMASYNC_PREWRITE); - aprint_debug_dev(sc->sc_dev, "eventst: %s %016jx %p %zx\n", - usbd_errstr(err), +
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 14:51:04 UTC 2016 Modified Files: src/sys/dev/usb: xhci.c Log Message: Wrap long line. From t-hash. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.35 src/sys/dev/usb/xhci.c:1.36 --- src/sys/dev/usb/xhci.c:1.35 Sat Apr 30 14:46:05 2016 +++ src/sys/dev/usb/xhci.c Sat Apr 30 14:51:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.35 2016/04/30 14:46:05 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.36 2016/04/30 14:51:04 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.35 2016/04/30 14:46:05 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.36 2016/04/30 14:51:04 skrll Exp $"); #include "opt_usb.h" @@ -840,7 +840,8 @@ xhci_init(struct xhci_softc *sc) if (err) return err; - sc->sc_spbuf_dma = kmem_zalloc(sizeof(*sc->sc_spbuf_dma) * sc->sc_maxspbuf, KM_SLEEP); + sc->sc_spbuf_dma = kmem_zalloc(sizeof(*sc->sc_spbuf_dma) * + sc->sc_maxspbuf, KM_SLEEP); uint64_t *spbufarray = KERNADDR(>sc_spbufarray_dma, 0); for (i = 0; i < sc->sc_maxspbuf; i++) { usb_dma_t * const dma = >sc_spbuf_dma[i];
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 14:46:06 UTC 2016 Modified Files: src/sys/dev/usb: xhci.c Log Message: Use XHCI_XFER2XXFER >From t-hash To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.34 src/sys/dev/usb/xhci.c:1.35 --- src/sys/dev/usb/xhci.c:1.34 Sat Apr 23 10:15:32 2016 +++ src/sys/dev/usb/xhci.c Sat Apr 30 14:46:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.34 2016/04/23 10:15:32 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.35 2016/04/30 14:46:05 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.34 2016/04/23 10:15:32 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.35 2016/04/30 14:46:05 skrll Exp $"); #include "opt_usb.h" @@ -3152,7 +3152,7 @@ xhci_device_ctrl_start(struct usbd_xfer struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); struct xhci_ring * const tr = >xs_ep[dci].xe_tr; - struct xhci_xfer * const xx = (void *)xfer; + struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); usb_device_request_t * const req = >ux_request; const int isread = usbd_xfer_isread(xfer); const uint32_t len = UGETW(req->wLength); @@ -3310,7 +3310,7 @@ xhci_device_bulk_start(struct usbd_xfer struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); struct xhci_ring * const tr = >xs_ep[dci].xe_tr; - struct xhci_xfer * const xx = (void *)xfer; + struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); const uint32_t len = xfer->ux_length; usb_dma_t * const dma = >ux_dmabuf; uint64_t parameter; @@ -3431,7 +3431,7 @@ xhci_device_intr_start(struct usbd_xfer struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); struct xhci_ring * const tr = >xs_ep[dci].xe_tr; - struct xhci_xfer * const xx = (void *)xfer; + struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); const uint32_t len = xfer->ux_length; usb_dma_t * const dma = >ux_dmabuf; uint64_t parameter;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 14:33:16 UTC 2016 Modified Files: src/sys/dev/usb: ukbd.c Log Message: Make GDIUM_KEYBOARD_HACK compile To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 src/sys/dev/usb/ukbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ukbd.c diff -u src/sys/dev/usb/ukbd.c:1.132 src/sys/dev/usb/ukbd.c:1.133 --- src/sys/dev/usb/ukbd.c:1.132 Wed Apr 27 19:35:17 2016 +++ src/sys/dev/usb/ukbd.c Sat Apr 30 14:33:16 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ukbd.c,v 1.132 2016/04/27 19:35:17 jakllsch Exp $*/ +/* $NetBSD: ukbd.c,v 1.133 2016/04/30 14:33:16 skrll Exp $*/ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.132 2016/04/27 19:35:17 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.133 2016/04/30 14:33:16 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_ukbd.h" @@ -432,8 +432,8 @@ ukbd_attach(device_t parent, device_t se sc->sc_flags |= FLAG_APPLE_FIX_ISO; #ifdef GDIUM_KEYBOARD_HACK - if (uha->uaa->uaa_vendor == USB_VENDOR_CYPRESS && - uha->uaa->uaa_product == USB_PRODUCT_CYPRESS_LPRDK) + if (uha->uiaa->uiaa_vendor == USB_VENDOR_CYPRESS && + uha->uiaa->uiaa_product == USB_PRODUCT_CYPRESS_LPRDK) sc->sc_flags = FLAG_GDIUM_FN; #endif
CVS commit: src/share/man/man8
Module Name:src Committed By: jakllsch Date: Sat Apr 30 14:32:23 UTC 2016 Modified Files: src/share/man/man8/man8.acorn26: boot26.8 src/share/man/man8/man8.acorn32: boot32.8 Log Message: Change RB_QUIET and RB_VERBOSE to AB_QUIET and AB_VERBOSE. It appears RB_QUIET and RB_VERBOSE never existed as such. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/share/man/man8/man8.acorn26/boot26.8 cvs rdiff -u -r1.3 -r1.4 src/share/man/man8/man8.acorn32/boot32.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man8/man8.acorn26/boot26.8 diff -u src/share/man/man8/man8.acorn26/boot26.8:1.5 src/share/man/man8/man8.acorn26/boot26.8:1.6 --- src/share/man/man8/man8.acorn26/boot26.8:1.5 Fri Sep 4 23:29:03 2009 +++ src/share/man/man8/man8.acorn26/boot26.8 Sat Apr 30 14:32:22 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: boot26.8,v 1.5 2009/09/04 23:29:03 apb Exp $ +.\" $NetBSD: boot26.8,v 1.6 2016/04/30 14:32:22 jakllsch Exp $ .\" .\" Copyright (c) 2000, 2001 Ben Harris .\" All rights reserved. @@ -72,10 +72,10 @@ Cause the kernel to enter the kernel deb Enter the in-kernel device configuration manager before attaching any devices. .It Fl q -.Pq Dv RB_QUIET +.Pq Dv AB_QUIET Cause the kernel to emit fewer messages than normal while starting up. .It Fl v -.Pq Dv RB_VERBOSE +.Pq Dv AB_VERBOSE Cause the kernel to emit more messages than normal while starting up. .El .Pp Index: src/share/man/man8/man8.acorn32/boot32.8 diff -u src/share/man/man8/man8.acorn32/boot32.8:1.3 src/share/man/man8/man8.acorn32/boot32.8:1.4 --- src/share/man/man8/man8.acorn32/boot32.8:1.3 Fri Sep 4 23:29:03 2009 +++ src/share/man/man8/man8.acorn32/boot32.8 Sat Apr 30 14:32:22 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: boot32.8,v 1.3 2009/09/04 23:29:03 apb Exp $ +.\" $NetBSD: boot32.8,v 1.4 2016/04/30 14:32:22 jakllsch Exp $ .\" .\" Copyright (c) 2000, 2001 Ben Harris .\" Copyright (c) 2004 Reinoud Zandijk @@ -79,10 +79,10 @@ Cause the kernel to enter the kernel deb Enter the in-kernel device configuration manager before attaching any devices. .It Fl q -.Pq Dv RB_QUIET +.Pq Dv AB_QUIET Cause the kernel to emit fewer messages than normal while starting up. .It Fl v -.Pq Dv RB_VERBOSE +.Pq Dv AB_VERBOSE Cause the kernel to emit more messages than normal while starting up. .El .Pp
CVS commit: src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 14:31:39 UTC 2016 Modified Files: src/sys/dev/usb: usb_mem.c Log Message: Make USB_FRAG_DMA_WORKAROUND compile To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/dev/usb/usb_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_mem.c diff -u src/sys/dev/usb/usb_mem.c:1.67 src/sys/dev/usb/usb_mem.c:1.68 --- src/sys/dev/usb/usb_mem.c:1.67 Sat Apr 23 10:15:32 2016 +++ src/sys/dev/usb/usb_mem.c Sat Apr 30 14:31:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_mem.c,v 1.67 2016/04/23 10:15:32 skrll Exp $ */ +/* $NetBSD: usb_mem.c,v 1.68 2016/04/30 14:31:39 skrll Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.67 2016/04/23 10:15:32 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.68 2016/04/30 14:31:39 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -336,7 +336,7 @@ usb_allocmem_flags(struct usbd_bus *bus, p->udma_block = f->ufd_block; p->udma_offs = f->ufd_offs; #ifdef USB_FRAG_DMA_WORKAROUND - p->offs += USB_MEM_SMALL; + p->udma_offs += USB_MEM_SMALL; #endif LIST_REMOVE(f, ufd_next); mutex_exit(_blk_lock); @@ -373,7 +373,7 @@ usb_freemem(struct usbd_bus *bus, usb_dm f->ufd_block = p->udma_block; f->ufd_offs = p->udma_offs; #ifdef USB_FRAG_DMA_WORKAROUND - f->offs -= USB_MEM_SMALL; + f->ufd_offs -= USB_MEM_SMALL; #endif LIST_INSERT_HEAD(_frag_freelist, f, ufd_next); mutex_exit(_blk_lock);
CVS commit: src/lib/csu/common
Module Name:src Committed By: martin Date: Sat Apr 30 13:12:13 UTC 2016 Modified Files: src/lib/csu/common: Makefile.inc Log Message: Gcc 5.3 seems to do fine compiling this for sparc64, so exclude it from the -O1 hack To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/csu/common/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/csu/common/Makefile.inc diff -u src/lib/csu/common/Makefile.inc:1.28 src/lib/csu/common/Makefile.inc:1.29 --- src/lib/csu/common/Makefile.inc:1.28 Mon Apr 4 18:29:07 2016 +++ src/lib/csu/common/Makefile.inc Sat Apr 30 13:12:13 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.28 2016/04/04 18:29:07 martin Exp $ +# $NetBSD: Makefile.inc,v 1.29 2016/04/30 13:12:13 martin Exp $ .include @@ -20,7 +20,8 @@ CFLAGS.crtbegin.c+= -fPIE # XXXGCC5 - GCC 5 miscompiles crtbeginS.c on many platforms. on SPARC it # XXXGCC5 emits "clr %g1; call %g1", which is effectively jumping to zero. . if defined(HAVE_GCC) && ${HAVE_GCC} == 53 && \ - ${MACHINE_ARCH} != "i386" && ${MACHINE_ARCH} != "amd64" + ${CSU_MACHINE_ARCH} != "i386" && ${CSU_MACHINE_ARCH} != "amd64" && \ + ${CSU_MACHINE_ARCH} != "sparc64" CFLAGS.crt0-common.c+= -O1 CFLAGS.crtbeginS.c+= -O1 . endif
CVS commit: [nick-nhusb] src/sys
Module Name:src Committed By: skrll Date: Sat Apr 30 10:34:15 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: ehci.c ehcivar.h ohci.c ohcivar.h uhci.c uhcivar.h usbdivar.h xhci.c xhcivar.h src/sys/external/bsd/dwc2 [nick-nhusb]: dwc2.c dwc2var.h Log Message: Move the struct usb_task to struct usbd_xfer for everyone to use. To generate a diff of this commit: cvs rdiff -u -r1.234.2.100 -r1.234.2.101 src/sys/dev/usb/ehci.c cvs rdiff -u -r1.42.14.25 -r1.42.14.26 src/sys/dev/usb/ehcivar.h cvs rdiff -u -r1.254.2.72 -r1.254.2.73 src/sys/dev/usb/ohci.c cvs rdiff -u -r1.55.6.12 -r1.55.6.13 src/sys/dev/usb/ohcivar.h cvs rdiff -u -r1.264.4.74 -r1.264.4.75 src/sys/dev/usb/uhci.c cvs rdiff -u -r1.52.14.17 -r1.52.14.18 src/sys/dev/usb/uhcivar.h cvs rdiff -u -r1.109.2.26 -r1.109.2.27 src/sys/dev/usb/usbdivar.h cvs rdiff -u -r1.28.2.67 -r1.28.2.68 src/sys/dev/usb/xhci.c cvs rdiff -u -r1.4.12.8 -r1.4.12.9 src/sys/dev/usb/xhcivar.h cvs rdiff -u -r1.32.2.25 -r1.32.2.26 src/sys/external/bsd/dwc2/dwc2.c cvs rdiff -u -r1.3.12.10 -r1.3.12.11 src/sys/external/bsd/dwc2/dwc2var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.234.2.100 src/sys/dev/usb/ehci.c:1.234.2.101 --- src/sys/dev/usb/ehci.c:1.234.2.100 Sat Apr 16 16:02:42 2016 +++ src/sys/dev/usb/ehci.c Sat Apr 30 10:34:14 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.234.2.100 2016/04/16 16:02:42 skrll Exp $ */ +/* $NetBSD: ehci.c,v 1.234.2.101 2016/04/30 10:34:14 skrll Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.100 2016/04/16 16:02:42 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.101 2016/04/30 10:34:14 skrll Exp $"); #include "ohci.h" #include "uhci.h" @@ -3407,14 +3407,13 @@ Static void ehci_timeout(void *addr) { struct usbd_xfer *xfer = addr; - struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); struct usbd_pipe *pipe = xfer->ux_pipe; struct usbd_device *dev = pipe->up_dev; ehci_softc_t *sc = EHCI_XFER2SC(xfer); EHCIHIST_FUNC(); EHCIHIST_CALLED(); - DPRINTF("exfer %p", exfer, 0, 0, 0); + DPRINTF("xfer %p", xfer, 0, 0, 0); #ifdef EHCI_DEBUG if (ehcidebug >= 2) usbd_dump_pipe(pipe); @@ -3428,9 +3427,9 @@ ehci_timeout(void *addr) } /* Execute the abort in a process context. */ - usb_init_task(>ex_aborttask, ehci_timeout_task, xfer, + usb_init_task(>ux_aborttask, ehci_timeout_task, xfer, USB_TASKQ_MPSAFE); - usb_add_task(dev, >ex_aborttask, USB_TASKQ_HC); + usb_add_task(dev, >ux_aborttask, USB_TASKQ_HC); } Static void Index: src/sys/dev/usb/ehcivar.h diff -u src/sys/dev/usb/ehcivar.h:1.42.14.25 src/sys/dev/usb/ehcivar.h:1.42.14.26 --- src/sys/dev/usb/ehcivar.h:1.42.14.25 Mon Apr 4 07:43:12 2016 +++ src/sys/dev/usb/ehcivar.h Sat Apr 30 10:34:14 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ehcivar.h,v 1.42.14.25 2016/04/04 07:43:12 skrll Exp $ */ +/* $NetBSD: ehcivar.h,v 1.42.14.26 2016/04/30 10:34:14 skrll Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -91,7 +91,6 @@ typedef struct ehci_soft_itd { struct ehci_xfer { struct usbd_xfer ex_xfer; - struct usb_task ex_aborttask; TAILQ_ENTRY(ehci_xfer) ex_next; /* list of active xfers */ enum { EX_NONE, Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.254.2.72 src/sys/dev/usb/ohci.c:1.254.2.73 --- src/sys/dev/usb/ohci.c:1.254.2.72 Sat Apr 16 16:02:42 2016 +++ src/sys/dev/usb/ohci.c Sat Apr 30 10:34:14 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.254.2.72 2016/04/16 16:02:42 skrll Exp $ */ +/* $NetBSD: ohci.c,v 1.254.2.73 2016/04/30 10:34:14 skrll Exp $ */ /* * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.72 2016/04/16 16:02:42 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.73 2016/04/30 10:34:14 skrll Exp $"); #include "opt_usb.h" @@ -1917,11 +1917,10 @@ void ohci_timeout(void *addr) { struct usbd_xfer *xfer = addr; - struct ohci_xfer *oxfer = OHCI_XFER2OXFER(xfer); ohci_softc_t *sc = OHCI_XFER2SC(xfer); OHCIHIST_FUNC(); OHCIHIST_CALLED(); - DPRINTF("oxfer=%p", oxfer, 0, 0, 0); + DPRINTF("xfer=%p", xfer, 0, 0, 0); if (sc->sc_dying) { mutex_enter(>sc_lock); @@ -1931,9 +1930,9 @@ ohci_timeout(void *addr) } /* Execute the abort in a process context. */ - usb_init_task(>abort_task, ohci_timeout_task, addr, + usb_init_task(>ux_aborttask, ohci_timeout_task, addr, USB_TASKQ_MPSAFE); - usb_add_task(xfer->ux_pipe->up_dev, >abort_task, + usb_add_task(xfer->ux_pipe->up_dev, >ux_aborttask, USB_TASKQ_HC); } Index: src/sys/dev/usb/ohcivar.h diff -u src/sys/dev/usb/ohcivar.h:1.55.6.12 src/sys/dev/usb/ohcivar.h:1.55.6.13 --- src/sys/dev/usb/ohcivar.h:1.55.6.12 Sun Jan 10 10:16:00 2016 +++
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 08:48:09 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_upgt.c Log Message: Partial conversion from spl(9)/tsleep(9) to mutex(9)/condvar(9) To generate a diff of this commit: cvs rdiff -u -r1.12.4.10 -r1.12.4.11 src/sys/dev/usb/if_upgt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_upgt.c diff -u src/sys/dev/usb/if_upgt.c:1.12.4.10 src/sys/dev/usb/if_upgt.c:1.12.4.11 --- src/sys/dev/usb/if_upgt.c:1.12.4.10 Sat Mar 19 11:30:19 2016 +++ src/sys/dev/usb/if_upgt.c Sat Apr 30 08:48:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_upgt.c,v 1.12.4.10 2016/03/19 11:30:19 skrll Exp $ */ +/* $NetBSD: if_upgt.c,v 1.12.4.11 2016/04/30 08:48:09 skrll Exp $ */ /* $OpenBSD: if_upgt.c,v 1.49 2010/04/20 22:05:43 tedu Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.12.4.10 2016/03/19 11:30:19 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.12.4.11 2016/04/30 08:48:09 skrll Exp $"); #include #include @@ -1004,7 +1004,11 @@ upgt_eeprom_read(struct upgt_softc *sc) "could not transmit EEPROM data URB\n"); return EIO; } - if (tsleep(sc, 0, "eeprom_request", UPGT_USB_TIMEOUT)) { + + mutex_enter(>sc_mtx); + int res = cv_timedwait(>sc_cv, >sc_mtx, UPGT_USB_TIMEOUT); + mutex_exit(>sc_mtx); + if (res) { aprint_error_dev(sc->sc_dev, "timeout while waiting for EEPROM data\n"); return EIO; @@ -1773,12 +1777,15 @@ upgt_rx_cb(struct usbd_xfer *xfer, void DPRINTF(2, "%s: received EEPROM block (offset=%d, len=%d)\n", device_xname(sc->sc_dev), eeprom_offset, eeprom_len); + mutex_enter(>sc_mtx); memcpy(sc->sc_eeprom + eeprom_offset, data_rx->buf + sizeof(struct upgt_lmac_eeprom) + 4, eeprom_len); - /* EEPROM data has arrived in time, wakeup tsleep() */ - wakeup(sc); + /* EEPROM data has arrived in time, wakeup upgt_eeprom_read */ + /* Note eeprom data arrived */ + cv_broadcast(>sc_cv); + mutex_exit(>sc_mtx); } else if (h1_type == UPGT_H1_TYPE_CTRL && h2_type == UPGT_H2_TYPE_TX_DONE) { @@ -2304,6 +2311,7 @@ upgt_alloc_cmd(struct upgt_softc *sc) data_cmd->buf = usbd_get_buffer(data_cmd->xfer); + cv_init(>sc_cv, "upgteeprom"); mutex_init(>sc_mtx, MUTEX_DEFAULT, IPL_NONE); return 0; @@ -2350,6 +2358,7 @@ upgt_free_cmd(struct upgt_softc *sc) } mutex_destroy(>sc_mtx); + cv_destroy(>sc_cv); } static int
CVS commit: [nick-nhusb] src/sys/dev/usb
Module Name:src Committed By: skrll Date: Sat Apr 30 08:45:13 UTC 2016 Modified Files: src/sys/dev/usb [nick-nhusb]: if_otus.c if_otusvar.h Log Message: Convert from spl(9)/tsleep(9) to mutex(9)/condvar(9) To generate a diff of this commit: cvs rdiff -u -r1.25.6.5 -r1.25.6.6 src/sys/dev/usb/if_otus.c cvs rdiff -u -r1.7.12.4 -r1.7.12.5 src/sys/dev/usb/if_otusvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/if_otus.c diff -u src/sys/dev/usb/if_otus.c:1.25.6.5 src/sys/dev/usb/if_otus.c:1.25.6.6 --- src/sys/dev/usb/if_otus.c:1.25.6.5 Tue Oct 6 21:32:15 2015 +++ src/sys/dev/usb/if_otus.c Sat Apr 30 08:45:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_otus.c,v 1.25.6.5 2015/10/06 21:32:15 skrll Exp $ */ +/* $NetBSD: if_otus.c,v 1.25.6.6 2016/04/30 08:45:13 skrll Exp $ */ /* $OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $ */ /*- @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.25.6.5 2015/10/06 21:32:15 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.25.6.6 2016/04/30 08:45:13 skrll Exp $"); #include #include @@ -626,6 +626,8 @@ otus_attach(device_t parent, device_t se aprint_normal_dev(sc->sc_dev, "%s\n", devinfop); usbd_devinfo_free(devinfop); + cv_init(>sc_task_cv, "otustsk"); + cv_init(>sc_cmd_cv, "otuscmd"); mutex_init(>sc_cmd_mtx, MUTEX_DEFAULT, IPL_NONE); mutex_init(>sc_task_mtx, MUTEX_DEFAULT, IPL_NET); mutex_init(>sc_tx_mtx,MUTEX_DEFAULT, IPL_NONE); @@ -674,8 +676,10 @@ otus_wait_async(struct otus_softc *sc) DPRINTFN(DBG_FN, sc, "\n"); + mutex_spin_enter(>sc_task_mtx); while (sc->sc_cmdq.queued > 0) - tsleep(>sc_cmdq, 0, "sc_cmdq", 0); + cv_wait(>sc_task_cv, >sc_task_mtx); + mutex_spin_exit(>sc_task_mtx); } Static int @@ -716,6 +720,9 @@ otus_detach(device_t self, int flags) mutex_destroy(>sc_tx_mtx); mutex_destroy(>sc_task_mtx); mutex_destroy(>sc_cmd_mtx); + cv_destroy(>sc_task_cv); + cv_destroy(>sc_cmd_cv); + return 0; } @@ -1234,34 +1241,29 @@ otus_task(void *arg) struct otus_softc *sc; struct otus_host_cmd_ring *ring; struct otus_host_cmd *cmd; - int s; sc = arg; DPRINTFN(DBG_FN, sc, "\n"); /* Process host commands. */ - s = splusb(); mutex_spin_enter(>sc_task_mtx); ring = >sc_cmdq; while (ring->next != ring->cur) { cmd = >cmd[ring->next]; mutex_spin_exit(>sc_task_mtx); - splx(s); /* Callback. */ DPRINTFN(DBG_CMD, sc, "cb=%p queued=%d\n", cmd->cb, ring->queued); cmd->cb(sc, cmd->data); - s = splusb(); mutex_spin_enter(>sc_task_mtx); ring->queued--; ring->next = (ring->next + 1) % OTUS_HOST_CMD_RING_COUNT; } + cv_signal(>sc_task_cv); mutex_spin_exit(>sc_task_mtx); - wakeup(ring); - splx(s); } Static void @@ -1270,12 +1272,10 @@ otus_do_async(struct otus_softc *sc, voi { struct otus_host_cmd_ring *ring; struct otus_host_cmd *cmd; - int s; + bool sched = false; DPRINTFN(DBG_FN, sc, "cb=%p\n", cb); - - s = splusb(); mutex_spin_enter(>sc_task_mtx); ring = >sc_cmdq; cmd = >cmd[ring->cur]; @@ -1286,13 +1286,12 @@ otus_do_async(struct otus_softc *sc, voi /* If there is no pending command already, schedule a task. */ if (++ring->queued == 1) { - mutex_spin_exit(>sc_task_mtx); - usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER); + sched = true; } - else - mutex_spin_exit(>sc_task_mtx); - wakeup(ring); - splx(s); + cv_signal(>sc_task_cv); + mutex_spin_exit(>sc_task_mtx); + if (sched) + usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER); } Static int @@ -1393,7 +1392,7 @@ otus_cmd(struct otus_softc *sc, uint8_t { struct otus_tx_cmd *cmd; struct ar_cmd_hdr *hdr; - int s, xferlen, error; + int xferlen, error; DPRINTFN(DBG_FN, sc, "\n"); @@ -1419,14 +1418,12 @@ otus_cmd(struct otus_softc *sc, uint8_t DPRINTFN(DBG_CMD, sc, "sending command code=0x%02x len=%d token=%d\n", code, ilen, hdr->token); - s = splusb(); cmd->odata = odata; cmd->done = 0; usbd_setup_xfer(cmd->xfer, cmd, cmd->buf, xferlen, USBD_FORCE_SHORT_XFER, OTUS_CMD_TIMEOUT, NULL); error = usbd_sync_transfer(cmd->xfer); if (error != 0) { - splx(s); mutex_exit(>sc_cmd_mtx); #if defined(DIAGNOSTIC) || defined(OTUS_DEBUG) /* XXX: kill some noise */ aprint_error_dev(sc->sc_dev, @@ -1436,9 +1433,8 @@ otus_cmd(struct otus_softc *sc, uint8_t return EIO; } if (!cmd->done) - error = tsleep(cmd, PCATCH, "otuscmd", hz); + error = cv_timedwait_sig(>sc_cmd_cv, >sc_cmd_mtx, hz); cmd->odata = NULL; /* In case answer is received too late. */ - splx(s); mutex_exit(>sc_cmd_mtx); if (error != 0) { aprint_error_dev(sc->sc_dev, @@ -1639,14 +1635,18 @@ otus_cmd_rxeof(struct otus_softc *sc, ui if ((hdr->code & 0xc0) != 0xc0) { DPRINTFN(DBG_RX, sc, "received reply code=0x%02x len=%d token=%d\n", hdr->code, hdr->len, hdr->token); + mutex_enter(>sc_cmd_mtx);