* [U-Boot] [PATCH] usb: ehci: remember init mode
@ 2015-08-20 23:38 Stephen Warren
2015-08-21 5:34 ` Marek Vasut
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Warren @ 2015-08-20 23:38 UTC (permalink / raw)
To: u-boot
From: Stephen Warren <swarren@nvidia.com>
When an EHCI device is registered in device mode, the HW isn't actually
initialized at all, and hence isn't left in a running state. Consequently,
when the device is deregistered, ehci_shutdown() will fail, since the HW
bits it expects to see set in response to its shutdown requests will not
be sent, and the message "EHCI failed to shut down host controller." will
be printed.
Fix ehci-hcd.c to remember whether the device was registered in host or
device mode, and only call ehci_shutdown() for host mode registrations.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
drivers/usb/host/ehci-hcd.c | 7 ++++++-
drivers/usb/host/ehci.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 3a0d32ee2ba1..88b670b7f8a7 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1645,8 +1645,10 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
ctrl->hcor = hcor;
ctrl->priv = ctrl;
- if (init == USB_INIT_DEVICE)
+ ctrl->init = init;
+ if (ctrl->init == USB_INIT_DEVICE)
goto done;
+
ret = ehci_reset(ctrl);
if (ret)
goto err;
@@ -1666,6 +1668,9 @@ int ehci_deregister(struct udevice *dev)
{
struct ehci_ctrl *ctrl = dev_get_priv(dev);
+ if (ctrl->init == USB_INIT_DEVICE)
+ return 0;
+
ehci_shutdown(ctrl);
return 0;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 3379c293c4df..b41c04a8b30a 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -242,6 +242,7 @@ struct ehci_ops {
};
struct ehci_ctrl {
+ enum usb_init_type init;
struct ehci_hccr *hccr; /* R/O registers, not need for volatile */
struct ehci_hcor *hcor;
int rootdev;
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: ehci: remember init mode
2015-08-20 23:38 [U-Boot] [PATCH] usb: ehci: remember init mode Stephen Warren
@ 2015-08-21 5:34 ` Marek Vasut
2015-08-21 21:58 ` Stephen Warren
0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2015-08-21 5:34 UTC (permalink / raw)
To: u-boot
On Friday, August 21, 2015 at 01:38:05 AM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> When an EHCI device is registered in device mode, the HW isn't actually
> initialized at all, and hence isn't left in a running state. Consequently,
> when the device is deregistered, ehci_shutdown() will fail, since the HW
> bits it expects to see set in response to its shutdown requests will not
> be sent, and the message "EHCI failed to shut down host controller." will
> be printed.
>
> Fix ehci-hcd.c to remember whether the device was registered in host or
> device mode, and only call ehci_shutdown() for host mode registrations.
Hi,
Shouldn't you instead check if the controller is running or not and shut
it down based on that ?
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: ehci: remember init mode
2015-08-21 5:34 ` Marek Vasut
@ 2015-08-21 21:58 ` Stephen Warren
2015-08-24 3:47 ` Marek Vasut
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Warren @ 2015-08-21 21:58 UTC (permalink / raw)
To: u-boot
On 08/20/2015 11:34 PM, Marek Vasut wrote:
> On Friday, August 21, 2015 at 01:38:05 AM, Stephen Warren wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> When an EHCI device is registered in device mode, the HW isn't actually
>> initialized at all, and hence isn't left in a running state. Consequently,
>> when the device is deregistered, ehci_shutdown() will fail, since the HW
>> bits it expects to see set in response to its shutdown requests will not
>> be sent, and the message "EHCI failed to shut down host controller." will
>> be printed.
>>
>> Fix ehci-hcd.c to remember whether the device was registered in host or
>> device mode, and only call ehci_shutdown() for host mode registrations.
>
> Hi,
>
> Shouldn't you instead check if the controller is running or not and shut
> it down based on that ?
Why would the two states be different? How can the code check if the
controller is running; is there some HW bit that should be checked for that?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: ehci: remember init mode
2015-08-21 21:58 ` Stephen Warren
@ 2015-08-24 3:47 ` Marek Vasut
2015-08-24 18:57 ` Stephen Warren
0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2015-08-24 3:47 UTC (permalink / raw)
To: u-boot
On Friday, August 21, 2015 at 11:58:55 PM, Stephen Warren wrote:
> On 08/20/2015 11:34 PM, Marek Vasut wrote:
> > On Friday, August 21, 2015 at 01:38:05 AM, Stephen Warren wrote:
> >> From: Stephen Warren <swarren@nvidia.com>
> >>
> >> When an EHCI device is registered in device mode, the HW isn't actually
> >> initialized at all, and hence isn't left in a running state.
> >> Consequently, when the device is deregistered, ehci_shutdown() will
> >> fail, since the HW bits it expects to see set in response to its
> >> shutdown requests will not be sent, and the message "EHCI failed to
> >> shut down host controller." will be printed.
> >>
> >> Fix ehci-hcd.c to remember whether the device was registered in host or
> >> device mode, and only call ehci_shutdown() for host mode registrations.
> >
> > Hi,
> >
> > Shouldn't you instead check if the controller is running or not and shut
> > it down based on that ?
>
> Why would the two states be different? How can the code check if the
> controller is running; is there some HW bit that should be checked for
> that?
Hi,
Hrm, I am not aware of any, sorry :-( But the driver can track whether the
controller was previously inited or not, right ? I mean, this is DM, so we
should be able to have a private data bit for that, no ?
Does it make sense to track this sort of thing in private data please ?
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: ehci: remember init mode
2015-08-24 3:47 ` Marek Vasut
@ 2015-08-24 18:57 ` Stephen Warren
2015-08-27 10:45 ` Marek Vasut
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Warren @ 2015-08-24 18:57 UTC (permalink / raw)
To: u-boot
On 08/23/2015 09:47 PM, Marek Vasut wrote:
> On Friday, August 21, 2015 at 11:58:55 PM, Stephen Warren wrote:
>> On 08/20/2015 11:34 PM, Marek Vasut wrote:
>>> On Friday, August 21, 2015 at 01:38:05 AM, Stephen Warren wrote:
>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>
>>>> When an EHCI device is registered in device mode, the HW isn't actually
>>>> initialized at all, and hence isn't left in a running state.
>>>> Consequently, when the device is deregistered, ehci_shutdown() will
>>>> fail, since the HW bits it expects to see set in response to its
>>>> shutdown requests will not be sent, and the message "EHCI failed to
>>>> shut down host controller." will be printed.
>>>>
>>>> Fix ehci-hcd.c to remember whether the device was registered in host or
>>>> device mode, and only call ehci_shutdown() for host mode registrations.
>>>
>>> Hi,
>>>
>>> Shouldn't you instead check if the controller is running or not and shut
>>> it down based on that ?
>>
>> Why would the two states be different? How can the code check if the
>> controller is running; is there some HW bit that should be checked for
>> that?
>
> Hi,
>
> Hrm, I am not aware of any, sorry :-( But the driver can track whether the
> controller was previously inited or not, right ? I mean, this is DM, so we
> should be able to have a private data bit for that, no ?
I believe that's exactly what this patch is doing. I added a variable to
the driver's data structure indicating whether the last initialization
call was for host mode (-> EHCI is running, and should be shut down in
remove()) or device mode (-> EHCI is not running, so should not be shut
down in remove()).
> Does it make sense to track this sort of thing in private data please ?
>
> Best regards,
> Marek Vasut
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] usb: ehci: remember init mode
2015-08-24 18:57 ` Stephen Warren
@ 2015-08-27 10:45 ` Marek Vasut
0 siblings, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2015-08-27 10:45 UTC (permalink / raw)
To: u-boot
On Monday, August 24, 2015 at 08:57:02 PM, Stephen Warren wrote:
> On 08/23/2015 09:47 PM, Marek Vasut wrote:
> > On Friday, August 21, 2015 at 11:58:55 PM, Stephen Warren wrote:
> >> On 08/20/2015 11:34 PM, Marek Vasut wrote:
> >>> On Friday, August 21, 2015 at 01:38:05 AM, Stephen Warren wrote:
> >>>> From: Stephen Warren <swarren@nvidia.com>
> >>>>
> >>>> When an EHCI device is registered in device mode, the HW isn't
> >>>> actually initialized at all, and hence isn't left in a running state.
> >>>> Consequently, when the device is deregistered, ehci_shutdown() will
> >>>> fail, since the HW bits it expects to see set in response to its
> >>>> shutdown requests will not be sent, and the message "EHCI failed to
> >>>> shut down host controller." will be printed.
> >>>>
> >>>> Fix ehci-hcd.c to remember whether the device was registered in host
> >>>> or device mode, and only call ehci_shutdown() for host mode
> >>>> registrations.
> >>>
> >>> Hi,
> >>>
> >>> Shouldn't you instead check if the controller is running or not and
> >>> shut it down based on that ?
> >>
> >> Why would the two states be different? How can the code check if the
> >> controller is running; is there some HW bit that should be checked for
> >> that?
> >
> > Hi,
> >
> > Hrm, I am not aware of any, sorry :-( But the driver can track whether
> > the controller was previously inited or not, right ? I mean, this is DM,
> > so we should be able to have a private data bit for that, no ?
>
> I believe that's exactly what this patch is doing. I added a variable to
> the driver's data structure indicating whether the last initialization
> call was for host mode (-> EHCI is running, and should be shut down in
> remove()) or device mode (-> EHCI is not running, so should not be shut
> down in remove()).
Uh, right, sorry. Applied.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-08-27 10:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 23:38 [U-Boot] [PATCH] usb: ehci: remember init mode Stephen Warren
2015-08-21 5:34 ` Marek Vasut
2015-08-21 21:58 ` Stephen Warren
2015-08-24 3:47 ` Marek Vasut
2015-08-24 18:57 ` Stephen Warren
2015-08-27 10:45 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox