* [PATCH for stable 5.4 v2] usb: dwc3: gadget: fix writing NYET threshold
@ 2024-12-09 11:50 André Draszik
2024-12-09 12:05 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: André Draszik @ 2024-12-09 11:50 UTC (permalink / raw)
To: Thinh Nguyen, Greg Kroah-Hartman
Cc: linux-usb, linux-kernel, stable, André Draszik
Before writing a new value to the register, the old value needs to be
masked out for the new value to be programmed as intended, because at
least in some cases the reset value of that field is 0xf (max value).
At the moment, the dwc3 core initialises the threshold to the maximum
value (0xf), with the option to override it via a DT. No upstream DTs
seem to override it, therefore this commit doesn't change behaviour for
any upstream platform. Nevertheless, the code should be fixed to have
the desired outcome.
Do so.
Fixes: 80caf7d21adc ("usb: dwc3: add lpm erratum support")
Cc: stable@vger.kernel.org # 5.4 (needs adjustment for 5.10+)
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
* has been marked as v2, to be in line with the 5.10+ patch
* for stable-5.10+, the if() test is slightly different, so a separate
patch has been sent for it for the patch to apply.
---
drivers/usb/dwc3/core.h | 1 +
drivers/usb/dwc3/gadget.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 34f3fbba391b..e9835a1a8842 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -413,6 +413,7 @@
#define DWC3_DCTL_TRGTULST_SS_INACT (DWC3_DCTL_TRGTULST(6))
/* These apply for core versions 1.94a and later */
+#define DWC3_DCTL_NYET_THRES_MASK (0xf << 20)
#define DWC3_DCTL_NYET_THRES(n) (((n) & 0xf) << 20)
#define DWC3_DCTL_KEEP_CONNECT BIT(19)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index ecb79156351f..e40cba594ba1 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -3273,8 +3273,10 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
&& dwc->has_lpm_erratum,
"LPM Erratum not available on dwc3 revisions < 2.40a\n");
- if (dwc->has_lpm_erratum && dwc->revision >= DWC3_REVISION_240A)
+ if (dwc->has_lpm_erratum && dwc->revision >= DWC3_REVISION_240A) {
+ reg &= ~DWC3_DCTL_NYET_THRES_MASK;
reg |= DWC3_DCTL_NYET_THRES(dwc->lpm_nyet_threshold);
+ }
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
} else {
---
base-commit: cd5b619ac41b6b1a8167380ca6655df7ccf5b5eb
change-id: 20241209-dwc3-nyet-fix-5-4-a4e76b199946
Best regards,
--
André Draszik <andre.draszik@linaro.org>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH for stable 5.4 v2] usb: dwc3: gadget: fix writing NYET threshold
2024-12-09 11:50 [PATCH for stable 5.4 v2] usb: dwc3: gadget: fix writing NYET threshold André Draszik
@ 2024-12-09 12:05 ` Greg Kroah-Hartman
2024-12-09 12:12 ` André Draszik
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2024-12-09 12:05 UTC (permalink / raw)
To: André Draszik; +Cc: Thinh Nguyen, linux-usb, linux-kernel, stable
On Mon, Dec 09, 2024 at 11:50:57AM +0000, André Draszik wrote:
> Before writing a new value to the register, the old value needs to be
> masked out for the new value to be programmed as intended, because at
> least in some cases the reset value of that field is 0xf (max value).
>
> At the moment, the dwc3 core initialises the threshold to the maximum
> value (0xf), with the option to override it via a DT. No upstream DTs
> seem to override it, therefore this commit doesn't change behaviour for
> any upstream platform. Nevertheless, the code should be fixed to have
> the desired outcome.
>
> Do so.
>
> Fixes: 80caf7d21adc ("usb: dwc3: add lpm erratum support")
> Cc: stable@vger.kernel.org # 5.4 (needs adjustment for 5.10+)
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
> * has been marked as v2, to be in line with the 5.10+ patch
> * for stable-5.10+, the if() test is slightly different, so a separate
> patch has been sent for it for the patch to apply.
What is the git id of this in Linus's tree?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH for stable 5.4 v2] usb: dwc3: gadget: fix writing NYET threshold
2024-12-09 12:05 ` Greg Kroah-Hartman
@ 2024-12-09 12:12 ` André Draszik
2024-12-09 12:23 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: André Draszik @ 2024-12-09 12:12 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Thinh Nguyen, linux-usb, linux-kernel, stable
On Mon, 2024-12-09 at 13:05 +0100, Greg Kroah-Hartman wrote:
> On Mon, Dec 09, 2024 at 11:50:57AM +0000, André Draszik wrote:
> > Before writing a new value to the register, the old value needs to be
> > masked out for the new value to be programmed as intended, because at
> > least in some cases the reset value of that field is 0xf (max value).
> >
> > At the moment, the dwc3 core initialises the threshold to the maximum
> > value (0xf), with the option to override it via a DT. No upstream DTs
> > seem to override it, therefore this commit doesn't change behaviour for
> > any upstream platform. Nevertheless, the code should be fixed to have
> > the desired outcome.
> >
> > Do so.
> >
> > Fixes: 80caf7d21adc ("usb: dwc3: add lpm erratum support")
> > Cc: stable@vger.kernel.org # 5.4 (needs adjustment for 5.10+)
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> > * has been marked as v2, to be in line with the 5.10+ patch
> > * for stable-5.10+, the if() test is slightly different, so a separate
> > patch has been sent for it for the patch to apply.
>
> What is the git id of this in Linus's tree?
I guess I misunderstood the docs... It's not merged into Linus' tree
yet - the proposed patch is here:
https://lore.kernel.org/all/20241209-dwc3-nyet-fix-v2-1-02755683345b@linaro.org/
Cheers,
Andre'
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH for stable 5.4 v2] usb: dwc3: gadget: fix writing NYET threshold
2024-12-09 12:12 ` André Draszik
@ 2024-12-09 12:23 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2024-12-09 12:23 UTC (permalink / raw)
To: André Draszik; +Cc: Thinh Nguyen, linux-usb, linux-kernel, stable
On Mon, Dec 09, 2024 at 12:12:05PM +0000, André Draszik wrote:
> On Mon, 2024-12-09 at 13:05 +0100, Greg Kroah-Hartman wrote:
> > On Mon, Dec 09, 2024 at 11:50:57AM +0000, André Draszik wrote:
> > > Before writing a new value to the register, the old value needs to be
> > > masked out for the new value to be programmed as intended, because at
> > > least in some cases the reset value of that field is 0xf (max value).
> > >
> > > At the moment, the dwc3 core initialises the threshold to the maximum
> > > value (0xf), with the option to override it via a DT. No upstream DTs
> > > seem to override it, therefore this commit doesn't change behaviour for
> > > any upstream platform. Nevertheless, the code should be fixed to have
> > > the desired outcome.
> > >
> > > Do so.
> > >
> > > Fixes: 80caf7d21adc ("usb: dwc3: add lpm erratum support")
> > > Cc: stable@vger.kernel.org # 5.4 (needs adjustment for 5.10+)
> > > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > > ---
> > > * has been marked as v2, to be in line with the 5.10+ patch
> > > * for stable-5.10+, the if() test is slightly different, so a separate
> > > patch has been sent for it for the patch to apply.
> >
> > What is the git id of this in Linus's tree?
>
> I guess I misunderstood the docs... It's not merged into Linus' tree
> yet - the proposed patch is here:
>
> https://lore.kernel.org/all/20241209-dwc3-nyet-fix-v2-1-02755683345b@linaro.org/
Ah. Yeah, wait until it hits Linus's tree before telling us about this,
otherwise we'll just get confused :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-09 12:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 11:50 [PATCH for stable 5.4 v2] usb: dwc3: gadget: fix writing NYET threshold André Draszik
2024-12-09 12:05 ` Greg Kroah-Hartman
2024-12-09 12:12 ` André Draszik
2024-12-09 12:23 ` Greg Kroah-Hartman
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).