Re: [PATCH v1 5/8] usb: chipidea: tegra: Support host mode

From: Dmitry Osipenko
Date: Wed Dec 16 2020 - 04:23:23 EST


16.12.2020 12:07, Dmitry Osipenko пишет:
>>> static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable)
>>> {
>>> struct ehci_hcd *ehci = hcd_to_ehci(hcd);
>>> @@ -160,14 +166,14 @@ static int host_start(struct ci_hdrc *ci)
>>> pinctrl_select_state(ci->platdata->pctl,
>>> ci->platdata->pins_host);
>>>
>>> + ci->hcd = hcd;
>>> +
>>> ret = usb_add_hcd(hcd, 0, 0);
>>> if (ret) {
>>> goto disable_reg;
>>> } else {
>>> struct usb_otg *otg = &ci->otg;
>>>
>>> - ci->hcd = hcd;
>>> -
>> Why this changed?
> The ci->hcd is used by tegra_usb_notify_event() to handle reset event
> and the reset happens once usb_add_hcd() is invoked. Hence we need to
> pre-assign the hcd pointer, otherwise there will be a NULL dereference.

Actually, not a NULL dereference, but the reset will be skipped since we
check whether ci->hcd is NULL in the tegra's reset handler.