Changeset View
Standalone View
sys/dev/usb/controller/xhci.c
| Show First 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | struct xhci_std_temp { | ||||
| uint8_t tbc; | uint8_t tbc; | ||||
| uint8_t tlbpc; | uint8_t tlbpc; | ||||
| uint8_t step_td; | uint8_t step_td; | ||||
| uint8_t do_isoc_sync; | uint8_t do_isoc_sync; | ||||
| }; | }; | ||||
| static void xhci_do_poll(struct usb_bus *); | static void xhci_do_poll(struct usb_bus *); | ||||
| static void xhci_device_done(struct usb_xfer *, usb_error_t); | static void xhci_device_done(struct usb_xfer *, usb_error_t); | ||||
| static void xhci_get_xecp(struct xhci_softc *); | |||||
| static void xhci_root_intr(struct xhci_softc *); | static void xhci_root_intr(struct xhci_softc *); | ||||
| static void xhci_free_device_ext(struct usb_device *); | static void xhci_free_device_ext(struct usb_device *); | ||||
| static struct xhci_endpoint_ext *xhci_get_endpoint_ext(struct usb_device *, | static struct xhci_endpoint_ext *xhci_get_endpoint_ext(struct usb_device *, | ||||
| struct usb_endpoint_descriptor *); | struct usb_endpoint_descriptor *); | ||||
| static usb_proc_callback_t xhci_configure_msg; | static usb_proc_callback_t xhci_configure_msg; | ||||
| static usb_error_t xhci_configure_device(struct usb_device *); | static usb_error_t xhci_configure_device(struct usb_device *); | ||||
| static usb_error_t xhci_configure_endpoint(struct usb_device *, | static usb_error_t xhci_configure_endpoint(struct usb_device *, | ||||
| struct usb_endpoint_descriptor *, struct xhci_endpoint_ext *, | struct usb_endpoint_descriptor *, struct xhci_endpoint_ext *, | ||||
| ▲ Show 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | xhci_init(struct xhci_softc *sc, device_t self, uint8_t dma32) | ||||
| /* get DMA bits */ | /* get DMA bits */ | ||||
| sc->sc_bus.dma_bits = (XHCI_HCS0_AC64(temp) && | sc->sc_bus.dma_bits = (XHCI_HCS0_AC64(temp) && | ||||
| xhcidma32 == 0 && dma32 == 0) ? 64 : 32; | xhcidma32 == 0 && dma32 == 0) ? 64 : 32; | ||||
| device_printf(self, "%d bytes context size, %d-bit DMA\n", | device_printf(self, "%d bytes context size, %d-bit DMA\n", | ||||
| sc->sc_ctx_is_64_byte ? 64 : 32, (int)sc->sc_bus.dma_bits); | sc->sc_ctx_is_64_byte ? 64 : 32, (int)sc->sc_bus.dma_bits); | ||||
| xhci_get_xecp(sc); | |||||
| /* enable 64Kbyte control endpoint quirk */ | /* enable 64Kbyte control endpoint quirk */ | ||||
| sc->sc_bus.control_ep_quirk = (xhcictlquirk ? 1 : 0); | sc->sc_bus.control_ep_quirk = (xhcictlquirk ? 1 : 0); | ||||
| temp = XREAD4(sc, capa, XHCI_HCSPARAMS1); | temp = XREAD4(sc, capa, XHCI_HCSPARAMS1); | ||||
| /* get number of device slots */ | /* get number of device slots */ | ||||
| sc->sc_noport = XHCI_HCS1_N_PORTS(temp); | sc->sc_noport = XHCI_HCS1_N_PORTS(temp); | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | xhci_uninit(struct xhci_softc *sc) | ||||
| */ | */ | ||||
| usb_bus_mem_free_all(&sc->sc_bus, &xhci_iterate_hw_softc); | usb_bus_mem_free_all(&sc->sc_bus, &xhci_iterate_hw_softc); | ||||
| cv_destroy(&sc->sc_cmd_cv); | cv_destroy(&sc->sc_cmd_cv); | ||||
| sx_destroy(&sc->sc_cmd_sx); | sx_destroy(&sc->sc_cmd_sx); | ||||
| } | } | ||||
| static void | static void | ||||
| xhci_get_xecp(struct xhci_softc *sc) | |||||
| { | |||||
| uint32_t hccp1; | |||||
| uint32_t eec; | |||||
| uint32_t eecp; | |||||
| bool first = true; | |||||
| hccp1 = XREAD4(sc, capa, XHCI_HCSPARAMS0); | |||||
kp: That seems like it should be an assertion, not a check. | |||||
Done Inline Actionsit can probably go all together, I've pulled this out of another patch set where sc could be null and it not be a problem. Thanks for spotting it thj: it can probably go all together, I've pulled this out of another patch set where sc could be… | |||||
Not Done Inline Actionsthe hccp1 is for capabilities register. Can we rename XHCI_HCSPARAMS0 to XHCI_HCCPARAMS1 to follow the intel's manual? Of course, it can be a separated patch. aokblast: the hccp1 is for capabilities register. Can we rename XHCI_HCSPARAMS0 to XHCI_HCCPARAMS1 to… | |||||
Done Inline ActionsI've created a patch, and will post it for review once I fix my system enough that I can build things thj: I've created a patch, and will post it for review once I fix my system enough that I can build… | |||||
| if (XHCI_HCS0_XECP(hccp1) == 0) { | |||||
| device_printf(sc->sc_bus.parent, | |||||
| "xECP: no capabilities found\n"); | |||||
| return; | |||||
| } | |||||
| /* | |||||
| * Parse the xECP Capabilities table and print known caps. | |||||
| * Implemented, vendor and reserved xECP Capabilities values are | |||||
| * documented in Table 7.2 of eXtensible Host Controller Interface for | |||||
| * Universal Serial Bus (xHCI) Rev 1.2b 2023. | |||||
| */ | |||||
| device_printf(sc->sc_bus.parent, "xECP capabilities <"); | |||||
| eec = -1; | |||||
Not Done Inline ActionsProbably worth a more extensive comment emaste: Probably worth a more extensive comment | |||||
| for (eecp = XHCI_HCS0_XECP(hccp1) << 2; | |||||
| eecp != 0 && XHCI_XECP_NEXT(eec) != 0; | |||||
| eecp += XHCI_XECP_NEXT(eec) << 2) { | |||||
| eec = XREAD4(sc, capa, eecp); | |||||
| uint8_t xecpid = XHCI_XECP_ID(eec); | |||||
| if ((xecpid >= 11 && xecpid <= 16) || | |||||
| (xecpid >= 19 && xecpid <= 191)) { | |||||
Not Done Inline ActionsAccording to the xhci rev 1.2. Reserved Capabilities code is from 19. 18 is for USB3 Tunnelling Support. aokblast: According to the xhci rev 1.2. Reserved Capabilities code is from 19. 18 is for USB3… | |||||
Done Inline ActionsI think we are reading different documents. eXtensible Host Controller Interface for Table 7-2: xHCI Extended Capability Codes, has codes 18-191 as reserved thj: I think we are reading different documents.
eXtensible Host Controller Interface for
Universal… | |||||
Not Done Inline ActionsAh, yes. I am reading xHCI 1.2b not 1.2. 1.2b is from 2023. Do you need to latest docs or just let it go? aokblast: Ah, yes. I am reading xHCI 1.2b not 1.2. 1.2b is from 2023. Do you need to latest docs or just… | |||||
Done Inline ActionsAh ha! Do you have a link to a public version of the spec? I have found one which isn't distributable, but I would like a reference to update wikipedia thj: Ah ha!
Do you have a link to a public version of the spec? I have found one which isn't… | |||||
| if (!first) | |||||
Not Done Inline ActionsHow about simply adding RES() and VEND() even if no bootverbose flag? In my experience, these values are rarely found, and the flags line will not be chatty in most cases. If we are going to use this for diagnostic purposes, it would be good to have all values unconditionally. hrs: How about simply adding `RES()` and `VEND()` even if no `bootverbose` flag? In my experience… | |||||
| printf(","); | |||||
| printf("RES(%x)", xecpid); | |||||
| } else if (xecpid > 191) { | |||||
| if (!first) | |||||
| printf(","); | |||||
| printf("VEND(%x)", xecpid); | |||||
| } else { | |||||
| if (!first) | |||||
| printf(","); | |||||
| switch (xecpid) | |||||
| { | |||||
| case XHCI_ID_USB_LEGACY: | |||||
| printf("LEGACY"); | |||||
| break; | |||||
| case XHCI_ID_PROTOCOLS: | |||||
| printf("PROTO"); | |||||
| break; | |||||
| case XHCI_ID_POWER_MGMT: | |||||
| printf("POWER"); | |||||
| break; | |||||
| case XHCI_ID_VIRTUALIZATION: | |||||
| printf("VIRT"); | |||||
| break; | |||||
| case XHCI_ID_MSG_IRQ: | |||||
| printf("MSG IRQ"); | |||||
| break; | |||||
| case XHCI_ID_USB_LOCAL_MEM: | |||||
| printf("LOCAL MEM"); | |||||
| break; | |||||
| case XHCI_ID_USB_DEBUG: | |||||
| printf("DEBUG"); | |||||
| break; | |||||
| case XHCI_ID_EXT_MSI: | |||||
| printf("EXT MSI"); | |||||
| break; | |||||
| case XHCI_ID_USB3_TUN: | |||||
| printf("TUN"); | |||||
| break; | |||||
| } | |||||
| } | |||||
| first = false; | |||||
Not Done Inline ActionsIMHO. The branch here is unnecessary? aokblast: IMHO. The branch here is unnecessary? | |||||
Done Inline ActionsIt simplifies the flow rather than setting first to false in 3 places. Do you have an alternative suggestion? thj: It simplifies the flow rather than setting first to false in 3 places.
Do you have an… | |||||
Done Inline ActionsI means the
can be removed since it only needs to be true in the first time. We can always let first = false without the if statement when the code reaches here. It may saves some time on branch prediction. aokblast: I means the
> if (first)
can be removed since it only needs to be true in the first time. | |||||
| } | |||||
| printf(">\n"); | |||||
| } | |||||
| static void | |||||
| xhci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) | xhci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) | ||||
| { | { | ||||
| struct xhci_softc *sc = XHCI_BUS2SC(bus); | struct xhci_softc *sc = XHCI_BUS2SC(bus); | ||||
| switch (state) { | switch (state) { | ||||
| case USB_HW_POWER_SUSPEND: | case USB_HW_POWER_SUSPEND: | ||||
| DPRINTF("Stopping the XHCI\n"); | DPRINTF("Stopping the XHCI\n"); | ||||
| xhci_halt_controller(sc); | xhci_halt_controller(sc); | ||||
| ▲ Show 20 Lines • Show All 3,746 Lines • Show Last 20 Lines | |||||
That seems like it should be an assertion, not a check.