From: Zhongqiu Han <quic_zhonhan@quicinc.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>,
<Thinh.Nguyen@synopsys.com>, <gregkh@linuxfoundation.org>,
<mathias.nyman@intel.com>
Cc: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Zhongqiu Han <quic_zhonhan@quicinc.com>
Subject: Re: [PATCH 2/2] usb: xhci: ext-caps: Use cpu_relax() when polling registers
Date: Wed, 21 Aug 2024 22:04:54 +0800 [thread overview]
Message-ID: <2b38828b-ebb0-4602-9320-9adc5deb76f6@quicinc.com> (raw)
In-Reply-To: <cd0cc5d1-0776-4d5f-9f3f-8261deb0e3bb@linux.intel.com>
On 8/21/2024 5:40 PM, Mathias Nyman wrote:
> On 20.8.2024 15.15, Zhongqiu Han wrote:
>> It is considered good practice to call cpu_relax() in busy loops, see
>> Documentation/process/volatile-considered-harmful.rst. This can lower
>> CPU power consumption or yield to a hyperthreaded twin processor and
>> also serve as a compiler barrier. In addition, if something goes wrong
>> in the busy loop at least it can prevent things from getting worse.
>>
>> Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
>> ---
>> drivers/usb/host/xhci-ext-caps.h | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-
>> ext-caps.h
>> index 96eb36a58738..25d148d60ab0 100644
>> --- a/drivers/usb/host/xhci-ext-caps.h
>> +++ b/drivers/usb/host/xhci-ext-caps.h
>> @@ -144,6 +144,8 @@ static inline int xhci_find_next_ext_cap(void
>> __iomem *base, u32 start, int id)
>> if (offset != start && (id == 0 || XHCI_EXT_CAPS_ID(val) ==
>> id))
>> return offset;
>> + cpu_relax();
>> +
>> next = XHCI_EXT_CAPS_NEXT(val);
>> offset += next << 2;
>> } while (next);
>
> Similar case as with PATCH 1/2
>
> This isn't a busy loop polling for some value.
> We traverse xhci extended capabilities until the one we are looking for
> is found.
>
> Thanks
> Mathias
>
Hi Mathias,
Thanks a lot for the review, yes, it is similar case as with PATCH 1/2
there is not a busy loop polling, sorry for this and i will careful for
similar case next time, and thanks for the discussion as well.
--
Thx and BRs,
Zhongqiu Han
prev parent reply other threads:[~2024-08-21 14:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 12:14 [PATCH 0/2] usb: Call " Zhongqiu Han
2024-08-20 12:15 ` [PATCH 1/2] usb: dwc3: core: Call cpu_relax() in registers polling busy loops Zhongqiu Han
2024-08-20 22:05 ` Thinh Nguyen
2024-08-21 13:59 ` Zhongqiu Han
2024-08-20 12:15 ` [PATCH 2/2] usb: xhci: ext-caps: Use cpu_relax() when polling registers Zhongqiu Han
2024-08-21 9:40 ` Mathias Nyman
2024-08-21 14:04 ` Zhongqiu Han [this message]
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=2b38828b-ebb0-4602-9320-9adc5deb76f6@quicinc.com \
--to=quic_zhonhan@quicinc.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mathias.nyman@linux.intel.com \
/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
all inboxes | Powered by JetHome®