From: <Claudiu.Beznea@microchip.com>
To: <stern@rowland.harvard.edu>
Cc: alexandre.belloni@bootlin.com, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Ludovic.Desroches@microchip.com,
linux-arm-kernel@lists.infradead.org,
Cristian.Birsan@microchip.com
Subject: Re: [PATCH] usb: host: ohci-at91: suspend/resume ports after/before OHCI accesses
Date: Wed, 23 Jun 2021 14:09:16 +0000 [thread overview]
Message-ID: <a5c68849-a48c-5224-7ba3-1ad44e0d9874@microchip.com> (raw)
In-Reply-To: <20210623135915.GB491169@rowland.harvard.edu>
On 23.06.2021 16:59, Alan Stern wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> On Wed, Jun 23, 2021 at 12:47:56PM +0000, Claudiu.Beznea@microchip.com wrote:
>> On 10.06.2021 02:07, Alan Stern wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>>
>>> On Wed, Jun 09, 2021 at 03:10:27PM +0300, Claudiu Beznea wrote:
>>>> On SAMA7G5 suspending ports will cut the access to OHCI registers and
>>>> any subsequent access to them will lead to CPU being blocked trying to
>>>> access that memory. Same thing happens on resume: if OHCI memory is
>>>> accessed before resuming ports the CPU will block on that access. The
>>>> OCHI memory is accessed on suspend/resume though
>>>> ohci_suspend()/ohci_resume().
>>>
>>> That sounds very strange.
>>
>> The clock scheme for OHCI and EHCI IPs on SAMA7G5 is as follows
>> (I hope it is readable):
>>
>> Main Xtal
>> |
>> +-------------+
>> | |
>> +---------------------------+ \ / |
>> | +------+ | 60MHz +--------------------+ |
>> | | | | | |------+
>> | | Port |<----------| UTMI Transceiver A | | |
>> | | | | | |----+ |
>> | USB 2.0 EHCI |Router| | +--------------------+ | | |
>> | Host Controller | | | 60MHz +--------------------+ | | |
>> | | |<----------| UTMI Transceiver B |<-+ | |
>> | | | | +--------------------+ | | |
>> | | | | 60MHz +--------------------+ | | |
>> | | |<----------| UTMI Transceiver C |<-+ | |
>> | | | | +--------------------+ | |
>> | +------+ | | |
>> | | | |
>> +---------------------------+ | |
>> | |
>> +---------------------------+ | |
>> | +------+ | UHP48M | |
>> | | Root | |<---------------------------------+ |
>> | USB 1.1 OHCI | hub | | |
>> | Host Controller | and | | UHP12M |
>> | | host | |<-----------------------------------+
>> | | SIE | |
>> | +------+ |
>> | |
>> +---------------------------+
>>
>> Where UTMI transceiver A generates the 48MHz and 12MHz clocks for OHCI
>> full-speed operations.
>>
>> The ports control is done through AT91_SFR_OHCIICR via
>> ohci_at91_port_suspend() function where. Setting 0 in AT91_SFR_OHCIICR
>> means suspend is controlled by EHCI-OHCI and 1 forces the port suspend.
>> Suspending the port A will cut the clocks for OHCI. I want to mention that
>> AT91_SFR_OHCIICR register is not in the same memory space of OHCI, EHCI IPs
>> and is clocked by other clocks.
>>
>>> Suppose one of the ports is suspended, so access to the
>>> OHCI registers is blocked. Then how can you resume the port?
>>
>> For run-time control (via ohci_at91_hub_control()), I agree with you that
>> the current implemented approach is not healthy (taking into account the
>> clock scheme above) and the fact that we do force the ports suspend on
>> ohci_at91_hub_control(). For suspend/resume it should be OK as the ports
>> are suspended at the end of any OHCI accesses (I don't know how the Linux
>> USB subsystem behaves so please do correct me if I'm wrong).
>
> (I haven't checked the details recently, so I'm not certain about
> this.) In some -- perhaps all -- cases, we don't suspend the ports at
> all during system suspend. We just rely on the USB devices
> automatically going into suspend when the root hub stops sending
> packets.
>
>>> Don't you have to
>>> access the OHCI registers in order to tell the controller to do the port resume?
>>
>> On our implementation we control the port suspend/resume via
>> AT91_SFR_OHCIICR, a special kind of register, memory mapped at different
>> address (compared w/ OHCI, EHCI IPs), so clocked by other clocks.
>>
>>>
>>> What happens when there's more than one port, and one of them is suspended while
>>> the other one is still running? How can you communicate with the active port if
>>> access to the OHCI registers is blocked?
>>
>> For this kind of scenario (the run-time suspend of a port, not system
>> suspend/resume) a different mechanism should be implemented taking into
>> account the clock schema presented above.
>
> Okay, I see. It seems like the driver will need some significant
> changes to handle runtime power management properly.
>
> One thing you might consider changing: The name of the
> ohci_at91_port_suspend routine is misleading. It doesn't really
> handle suspending the port; instead it handles the clocks that drive
> the entire OHCI controller. Right?
It does both as far as I can tell at the moment.
>
> Alan Stern
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-06-23 14:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 12:10 [PATCH] usb: host: ohci-at91: suspend/resume ports after/before OHCI accesses Claudiu Beznea
2021-06-09 12:40 ` Nicolas Ferre
2021-06-09 23:07 ` Alan Stern
2021-06-23 12:47 ` Claudiu.Beznea
2021-06-23 13:59 ` Alan Stern
2021-06-23 14:09 ` Claudiu.Beznea [this message]
2021-06-23 14:19 ` Alan Stern
2021-06-23 14:33 ` Claudiu.Beznea
2021-06-23 16:41 ` Alan Stern
2021-06-24 6:40 ` Claudiu.Beznea
2021-06-24 6:54 ` Claudiu.Beznea
2021-06-24 13:23 ` Alan Stern
2021-06-30 14:46 ` Claudiu.Beznea
2021-06-30 18:21 ` Alan Stern
2021-07-01 5:45 ` Claudiu.Beznea
2021-07-01 14:01 ` Alan Stern
2021-06-30 14:47 ` Claudiu.Beznea
2021-07-21 8:08 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a5c68849-a48c-5224-7ba3-1ad44e0d9874@microchip.com \
--to=claudiu.beznea@microchip.com \
--cc=Cristian.Birsan@microchip.com \
--cc=Ludovic.Desroches@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).