Skip to contentSkip to conversation

xhci fixes for usb-linus

PATCH In review Mathias Nyman 3 participants 16 messages Mar 30, 2023 – Apr 3, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover xhci fixes for usb-linus

Hi Greg

A few small patches for usb-linus.
Reverting xhci-pci asynchronous probe due to Renesas host regression, and fixing a memory leak.

Thanks
Mathias

D Scott Phillips (1):
xhci: also avoid the XHCI_ZERO_64B_REGS quirk with a passthrough iommu

Mathias Nyman (2):
Revert "usb: xhci-pci: Set PROBE_PREFER_ASYNCHRONOUS"
xhci: Free the command allocated for setting LPM if we return early

 drivers/usb/host/xhci-pci.c | 7 +++----
 drivers/usb/host/xhci.c     | 7 ++++++-
 2 files changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 xhci: also avoid the XHCI_ZERO_64B_REGS quirk with a passthrough iommu

From: D Scott Phillips <[email protected]>

Previously the quirk was skipped when no iommu was present. The same rationale for skipping the quirk also applies in the iommu.passthrough=1 case.

Skip applying the XHCI_ZERO_64B_REGS quirk if the device's iommu domain is passthrough.

Fixes 12de0a35c996 ("xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers")
---
 drivers/usb/host/xhci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +5 -1
index 6183ce8574b1..bdb6dd819a3b 100644
@@ -9,6 +9,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/iommu.h>
 #include <linux/iopoll.h>
 #include <linux/irq.h>
 #include <linux/log2.h>
@@ -228,6 +229,7 @@ int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us)
 static void xhci_zero_64b_regs(struct xhci_hcd *xhci)
 {
 	struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
+	struct iommu_domain *domain;
 	int err, i;
 	u64 val;
 	u32 intrs;
@@ -246,7 +248,9 @@ static void xhci_zero_64b_regs(struct xhci_hcd *xhci)
 	 * an iommu. Doing anything when there is no iommu is definitely
 	 * unsafe...
 	 */
-	if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !device_iommu_mapped(dev))
+	domain = iommu_get_domain_for_dev(dev);
+	if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !domain ||
+	    domain->type == IOMMU_DOMAIN_IDENTITY)
 		return;
 
 	xhci_info(xhci, "Zeroing 64bit base registers, expecting fault\n");
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH 1/3] xhci: also avoid the XHCI_ZERO_64B_REGS quirk with a passthrough iommu

Quoted 10 lines · Mathias Nyman

From: D Scott Phillips <[email protected]>

Previously the quirk was skipped when no iommu was present. The same rationale for skipping the quirk also applies in the iommu.passthrough=1 case.

Skip applying the XHCI_ZERO_64B_REGS quirk if the device's iommu domain is passthrough.

Fixes 12de0a35c996 ("xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers")

Why not also for stable?

thanks,

greg k-h

#3 lore raw

Re: [PATCH 1/3] xhci: also avoid the XHCI_ZERO_64B_REGS quirk with a passthrough iommu

Quoted 7 lines · Greg KH
Quoted 6 lines · Mathias Nyman

From: D Scott Phillips <[email protected]>

Previously the quirk was skipped when no iommu was present. The same rationale for skipping the quirk also applies in the iommu.passthrough=1 case.

Quoted 6 lines
Quoted 4 lines

Skip applying the XHCI_ZERO_64B_REGS quirk if the device's iommu domain is passthrough.

Fixes 12de0a35c996 ("xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers")

Why not also for stable?

Ah, yes, this should go to stable as well.

Thanks
Mathias

maintainer
#4 lore raw

Re: [PATCH 1/3] xhci: also avoid the XHCI_ZERO_64B_REGS quirk with a passthrough iommu

Quoted 8 lines · Mathias Nyman
Quoted 7 lines · Greg KH
Quoted 6 lines · Mathias Nyman

From: D Scott Phillips <[email protected]>

Previously the quirk was skipped when no iommu was present. The same rationale for skipping the quirk also applies in the iommu.passthrough=1 case.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Skip applying the XHCI_ZERO_64B_REGS quirk if the device's iommu domain is passthrough.

Fixes 12de0a35c996 ("xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers")

Why not also for stable?

Ah, yes, this should go to stable as well.

Thanks for confirming these, as you noticed, all are applied to my tree now.

greg k-h

#5 lore raw

PATCH 2/3 Revert "usb: xhci-pci: Set PROBE_PREFER_ASYNCHRONOUS"

In reply to Mathias Nyman

This reverts commit 4c2604a9a6899bab195edbee35fc8d64ce1444aa.

Asynch probe caused regression in a setup with both Renesas and Intel xHC controllers. Devices connected to the Renesas disconnected shortly after boot. With Asynch probe the busnumbers got interleaved.

xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 1 xhci_hcd 0000:04:00.0: new USB bus registered, assigned bus number 2 xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 3 xhci_hcd 0000:04:00.0: new USB bus registered, assigned bus number 4

Reason why this commit causes regression is still unknown, but revert it while debugging the issue.

---
 drivers/usb/host/xhci-pci.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-pci.c +3 -4
index fb988e4ea924..6db07ca419c3 100644
@@ -771,12 +771,11 @@ static struct pci_driver xhci_pci_driver = {
 	/* suspend and resume implemented later */
 
 	.shutdown = 	usb_hcd_pci_shutdown,
-	.driver = {
 #ifdef CONFIG_PM
-		.pm = &usb_hcd_pci_pm_ops,
-#endif
-		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
+	.driver = {
+		.pm = &usb_hcd_pci_pm_ops
 	},
+#endif
 };
 
 static int __init xhci_pci_init(void)
Signature · 1 line
2.25.1
maintainer
#6 lore raw

Re: [PATCH 2/3] Revert "usb: xhci-pci: Set PROBE_PREFER_ASYNCHRONOUS"

Quoted 11 lines · Mathias Nyman

This reverts commit 4c2604a9a6899bab195edbee35fc8d64ce1444aa.

Asynch probe caused regression in a setup with both Renesas and Intel xHC controllers. Devices connected to the Renesas disconnected shortly after boot. With Asynch probe the busnumbers got interleaved.

xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 1 xhci_hcd 0000:04:00.0: new USB bus registered, assigned bus number 2 xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 3 xhci_hcd 0000:04:00.0: new USB bus registered, assigned bus number 4

Quoted 5 lines

Reason why this commit causes regression is still unknown, but revert it while debugging the issue.

I'll add a Fixes: and cc: stable on this, ok?

thanks,

greg k-h

#7 lore raw

Re: [PATCH 2/3] Revert "usb: xhci-pci: Set PROBE_PREFER_ASYNCHRONOUS"

Quoted 12 lines · Greg KH
Quoted 11 lines · Mathias Nyman

This reverts commit 4c2604a9a6899bab195edbee35fc8d64ce1444aa.

Asynch probe caused regression in a setup with both Renesas and Intel xHC controllers. Devices connected to the Renesas disconnected shortly after boot. With Asynch probe the busnumbers got interleaved.

xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 1 xhci_hcd 0000:04:00.0: new USB bus registered, assigned bus number 2 xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 3 xhci_hcd 0000:04:00.0: new USB bus registered, assigned bus number 4

Quoted 7 lines
Quoted 5 lines

Reason why this commit causes regression is still unknown, but revert it while debugging the issue.

I'll add a Fixes: and cc: stable on this, ok?

Yes, please.

Thanks
Mathias

#8 lore raw

PATCH 3/3 xhci: Free the command allocated for setting LPM if we return early

In reply to Mathias Nyman

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")
---
 drivers/usb/host/xhci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +1 -0
index bdb6dd819a3b..6307bae9cddf 100644
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
 
 	if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
 		spin_unlock_irqrestore(&xhci->lock, flags);
+		xhci_free_command(xhci, command);
 		return 0;
 	}
 
Signature · 1 line
2.25.1
#9 lore raw

Re: [PATCH 3/3] xhci: Free the command allocated for setting LPM if we return early

Hi, Mathias!

Quoted 19 lines · Mathias Nyman

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")
---
  drivers/usb/host/xhci.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +0 -0
index bdb6dd819a3b..6307bae9cddf 100644

drivers/usb/host/xhci.c static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, · line 4447

Quoted 6 lines
drivers/usb/host/xhci.c +1 -0
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
 
  	if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
  		spin_unlock_irqrestore(&xhci->lock, flags);
+		xhci_free_command(xhci, command);
  		return 0;
  	}

There seems to be a problem with applying this patch with "git am", as it gives the following:

commit ff9de97baa02cb9362b7cb81e95bc9be424cab89

Author: @ <@>
Date:   Mon Apr 3 08:42:33 2023 +0200

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

Thank you.

Best regards,
Mirsad

Signature · 9 lines
Mirsad Todorovac
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb
Republic of Croatia, the European Union

Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
maintainer
#10 lore raw

Re: [PATCH 3/3] xhci: Free the command allocated for setting LPM if we return early

Quoted 35 lines · Mirsad Goran Todorovac

Hi, Mathias!

Quoted 19 lines · Mathias Nyman

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")
---
  drivers/usb/host/xhci.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +0 -0
index bdb6dd819a3b..6307bae9cddf 100644

drivers/usb/host/xhci.c static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, · line 4446

Quoted 5 lines
drivers/usb/host/xhci.c +1 -0
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
  	if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
  		spin_unlock_irqrestore(&xhci->lock, flags);
+		xhci_free_command(xhci, command);
  		return 0;
  	}

There seems to be a problem with applying this patch with "git am", as it gives the following:

commit ff9de97baa02cb9362b7cb81e95bc9be424cab89

Author: @ <@>
Date:   Mon Apr 3 08:42:33 2023 +0200
Quoted 7 lines

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

This is already commit f6caea485555 ("xhci: Free the command allocated for setting LPM if we return early") in Linus's tree, do you not see it there?

And how exactly did you save the message to apply it with 'git am'? It worked for me.

thanks,

greg k-h

#11 lore raw

Re: [PATCH 3/3] xhci: Free the command allocated for setting LPM if we return early

Quoted 48 lines · Greg KH
Quoted 35 lines · Mirsad Goran Todorovac

Hi, Mathias!

Quoted 19 lines · Mathias Nyman

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")
---
   drivers/usb/host/xhci.c | 1 +
   1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +0 -0
index bdb6dd819a3b..6307bae9cddf 100644

drivers/usb/host/xhci.c static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, · line 4446

Quoted 5 lines
drivers/usb/host/xhci.c +1 -0
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
   	if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
   		spin_unlock_irqrestore(&xhci->lock, flags);
+		xhci_free_command(xhci, command);
   		return 0;
   	}

There seems to be a problem with applying this patch with "git am", as it gives the following:

commit ff9de97baa02cb9362b7cb81e95bc9be424cab89

Author: @ <@>
Date:   Mon Apr 3 08:42:33 2023 +0200
Quoted 7 lines

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

This is already commit f6caea485555 ("xhci: Free the command allocated for setting LPM if we return early") in Linus's tree, do you not see it there?

Quoted 6 lines

And how exactly did you save the message to apply it with 'git am'? It worked for me.

thanks,

greg k-h

git am ../mathias-xhci.mail

mtodorov@domac:~/linux/kernel/linux_torvalds$ cat ../mathias-xhci.mail
From: Mathias Nyman @ 2023-03-27  9:50 UTC (permalink / raw)
  To: mirsad.todorovac, linux-usb, linux-kernel
  Cc: gregkh, ubuntu-devel-discuss, stern, arnd, Mathias Nyman, Stable

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")
---
 drivers/usb/host/xhci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +1 -0
index bdb6dd819a3b..6307bae9cddf 100644
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
 
        if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
                spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_free_command(xhci, command);
                return 0;
        }
 

--
2.25.1

Sorry, no commit f6caea485555 in the "git pull":

mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | grep f6caea485555
mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | head -10
10de4cefccf7 memstick: fix memory leak if card device is never registered
feeedf59897c platform/x86: think-lmi: Clean up display of current_value on Thinkstation
86cebdbfb8d2 platform/x86: think-lmi: Fix memory leaks when parsing ThinkStation WMI strings
ff9de97baa02 The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.
2ac6d07f1a81 platform/x86: think-lmi: Fix memory leak when showing current settings
7e364e56293b Linux 6.3-rc5
6ab608fe852b Merge tag 'for-6.3-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
f95b8ea79c47 Revert "venus: firmware: Correct non-pix start and end addresses"
a10ca0950afe Merge tag 'driver-core-6.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
95d0b9d89d78 Merge tag 'powerpc-6.3-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
You have mail in /var/mail/mtodorov
mtodorov@domac:~/linux/kernel/linux_torvalds$

I don't see it here either. But it is not critical (no security issue).

Have a nice day!

Best regards,
Mirsad

Signature · 9 lines
Mirsad Todorovac
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb
Republic of Croatia, the European Union

Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
#12 lore raw

Re: [PATCH 3/3] xhci: Free the command allocated for setting LPM if we return early

Quoted 109 lines · Mirsad Goran Todorovac
Quoted 48 lines · Greg KH
Quoted 35 lines · Mirsad Goran Todorovac

Hi, Mathias!

Quoted 19 lines · Mathias Nyman

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

---
   drivers/usb/host/xhci.c | 1 +

   1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +0 -0
index bdb6dd819a3b..6307bae9cddf 100644

drivers/usb/host/xhci.c static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, · line 4446

Quoted 5 lines
drivers/usb/host/xhci.c +1 -0
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
        if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
            spin_unlock_irqrestore(&xhci->lock, flags);
+        xhci_free_command(xhci, command);
            return 0;
        }

There seems to be a problem with applying this patch with "git am", as it gives the following:

commit ff9de97baa02cb9362b7cb81e95bc9be424cab89
Author: @ <@>
Date:   Mon Apr 3 08:42:33 2023 +0200

Quoted 7 lines

     The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

This is already commit f6caea485555 ("xhci: Free the command allocated for setting LPM if we return early") in Linus's tree, do you not see it there?

Quoted 6 lines

And how exactly did you save the message to apply it with 'git am'?  It worked for me.

thanks,

greg k-h

git am ../mathias-xhci.mail

mtodorov@domac:~/linux/kernel/linux_torvalds$ cat ../mathias-xhci.mail
From: Mathias Nyman @ 2023-03-27  9:50 UTC (permalink / raw)
   To: mirsad.todorovac, linux-usb, linux-kernel
   Cc: gregkh, ubuntu-devel-discuss, stern, arnd, Mathias Nyman, Stable

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")
---
  drivers/usb/host/xhci.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +1 -0
index bdb6dd819a3b..6307bae9cddf 100644
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
 
         if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
                 spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_free_command(xhci, command);
                 return 0;
         }
 
Signature · 22 lines
2.25.1

Sorry, no commit f6caea485555 in the "git pull":

mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | grep f6caea485555
mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | head -10
10de4cefccf7 memstick: fix memory leak if card device is never registered
feeedf59897c platform/x86: think-lmi: Clean up display of current_value on Thinkstation
86cebdbfb8d2 platform/x86: think-lmi: Fix memory leaks when parsing ThinkStation WMI strings
ff9de97baa02 The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.
2ac6d07f1a81 platform/x86: think-lmi: Fix memory leak when showing current settings
7e364e56293b Linux 6.3-rc5
6ab608fe852b Merge tag 'for-6.3-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
f95b8ea79c47 Revert "venus: firmware: Correct non-pix start and end addresses"
a10ca0950afe Merge tag 'driver-core-6.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
95d0b9d89d78 Merge tag 'powerpc-6.3-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
You have mail in /var/mail/mtodorov
mtodorov@domac:~/linux/kernel/linux_torvalds$

I don't see it here either. But it is not critical (no security issue).

Have a nice day!

P.S.

Correction.

Yes, I found it here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6caea4855553a8b99ba3ec23ecdb5ed8262f26c

"Notice: this object is not reachable from any branch."

I see Murphy's law in action :-)

Best regards,
Mirsad

Signature · 9 lines
Mirsad Todorovac
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb
Republic of Croatia, the European Union

Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
maintainer
#13 lore raw

Re: [PATCH 3/3] xhci: Free the command allocated for setting LPM if we return early

Quoted 64 lines · Mirsad Goran Todorovac
Quoted 63 lines · Mirsad Goran Todorovac
Quoted 48 lines · Greg KH
Quoted 35 lines · Mirsad Goran Todorovac

Hi, Mathias!

Quoted 19 lines · Mathias Nyman

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

---
   drivers/usb/host/xhci.c | 1 +

   1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +0 -0
index bdb6dd819a3b..6307bae9cddf 100644

drivers/usb/host/xhci.c static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, · line 4446

Quoted 5 lines
drivers/usb/host/xhci.c +1 -0
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
        if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
            spin_unlock_irqrestore(&xhci->lock, flags);
+        xhci_free_command(xhci, command);
            return 0;
        }

There seems to be a problem with applying this patch with "git am", as it gives the following:

commit ff9de97baa02cb9362b7cb81e95bc9be424cab89
Author: @ <@>
Date:   Mon Apr 3 08:42:33 2023 +0200

Quoted 7 lines

     The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

This is already commit f6caea485555 ("xhci: Free the command allocated for setting LPM if we return early") in Linus's tree, do you not see it there?

Quoted 6 lines

And how exactly did you save the message to apply it with 'git am'?  It worked for me.

thanks,

greg k-h

git am ../mathias-xhci.mail

mtodorov@domac:~/linux/kernel/linux_torvalds$ cat ../mathias-xhci.mail
From: Mathias Nyman @ 2023-03-27  9:50 UTC (permalink / raw)
   To: mirsad.todorovac, linux-usb, linux-kernel
   Cc: gregkh, ubuntu-devel-discuss, stern, arnd, Mathias Nyman, Stable
Quoted 7 lines
Quoted 7 lines

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

That is very odd, your mail program is not getting the full mbox information here at all. Try downloading it from lore.kernel.org as a raw message:

	https://lore.kernel.org/all/[email protected]/raw

and applying that?

Quoted 46 lines
Quoted 41 lines
---
  drivers/usb/host/xhci.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +1 -0
index bdb6dd819a3b..6307bae9cddf 100644
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
 
         if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
                 spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_free_command(xhci, command);
                 return 0;
         }
 
Signature · 24 lines
2.25.1

Sorry, no commit f6caea485555 in the "git pull":

mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | grep f6caea485555
mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | head -10
10de4cefccf7 memstick: fix memory leak if card device is never registered
feeedf59897c platform/x86: think-lmi: Clean up display of current_value on Thinkstation
86cebdbfb8d2 platform/x86: think-lmi: Fix memory leaks when parsing ThinkStation WMI strings
ff9de97baa02 The command allocated to set exit latency LPM values need
to be freed in case the command is never queued. This would be the case
if there is no change in exit latency values, or device is missing.
2ac6d07f1a81 platform/x86: think-lmi: Fix memory leak when showing current settings
7e364e56293b Linux 6.3-rc5
6ab608fe852b Merge tag 'for-6.3-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
f95b8ea79c47 Revert "venus: firmware: Correct non-pix start and end addresses"
a10ca0950afe Merge tag 'driver-core-6.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
95d0b9d89d78 Merge tag 'powerpc-6.3-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
You have mail in /var/mail/mtodorov
mtodorov@domac:~/linux/kernel/linux_torvalds$

I don't see it here either. But it is not critical (no security issue).

Have a nice day!

P.S.

Correction.

Quoted 7 lines

Yes, I found it here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6caea4855553a8b99ba3ec23ecdb5ed8262f26c

"Notice: this object is not reachable from any branch."

I see Murphy's law in action :-)

Ah, sorry, no, my fault, it's in my usb.git tree and hasn't been sent to Linus yet, that will happen later this week. It is also in the linux-next tree if you want to look there.

thanks,

greg k-h

#14 lore raw

Re: [PATCH 3/3] xhci: Free the command allocated for setting LPM if we return early

Quoted 129 lines · Greg KH
Quoted 64 lines · Mirsad Goran Todorovac
Quoted 63 lines · Mirsad Goran Todorovac
Quoted 48 lines · Greg KH
Quoted 35 lines · Mirsad Goran Todorovac

Hi, Mathias!

Quoted 19 lines · Mathias Nyman

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")
---
    drivers/usb/host/xhci.c | 1 +
    1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +0 -0
index bdb6dd819a3b..6307bae9cddf 100644

drivers/usb/host/xhci.c static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, · line 4446

Quoted 5 lines
drivers/usb/host/xhci.c +1 -0
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
        if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
            spin_unlock_irqrestore(&xhci->lock, flags);
+        xhci_free_command(xhci, command);
            return 0;
        }

There seems to be a problem with applying this patch with "git am", as it gives the following:

commit ff9de97baa02cb9362b7cb81e95bc9be424cab89
Author: @ <@>
Date:   Mon Apr 3 08:42:33 2023 +0200

Quoted 7 lines

     The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

This is already commit f6caea485555 ("xhci: Free the command allocated for setting LPM if we return early") in Linus's tree, do you not see it there?

Quoted 6 lines

And how exactly did you save the message to apply it with 'git am'?  It worked for me.

thanks,

greg k-h

git am ../mathias-xhci.mail

mtodorov@domac:~/linux/kernel/linux_torvalds$ cat ../mathias-xhci.mail
From: Mathias Nyman @ 2023-03-27  9:50 UTC (permalink / raw)
    To: mirsad.todorovac, linux-usb, linux-kernel
    Cc: gregkh, ubuntu-devel-discuss, stern, arnd, Mathias Nyman, Stable
Quoted 7 lines
Quoted 7 lines

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

That is very odd, your mail program is not getting the full mbox information here at all. Try downloading it from lore.kernel.org as a raw message:

	https://lore.kernel.org/all/[email protected]/raw

and applying that?

Quoted 50 lines
Quoted 41 lines
---
   drivers/usb/host/xhci.c | 1 +
   1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +1 -0
index bdb6dd819a3b..6307bae9cddf 100644
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
 
          if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
                  spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_free_command(xhci, command);
                  return 0;
          }
 
Signature · 24 lines
2.25.1

Sorry, no commit f6caea485555 in the "git pull":

mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | grep f6caea485555
mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | head -10
10de4cefccf7 memstick: fix memory leak if card device is never registered
feeedf59897c platform/x86: think-lmi: Clean up display of current_value on Thinkstation
86cebdbfb8d2 platform/x86: think-lmi: Fix memory leaks when parsing ThinkStation WMI strings
ff9de97baa02 The command allocated to set exit latency LPM values need
to be freed in case the command is never queued. This would be the case
if there is no change in exit latency values, or device is missing.
2ac6d07f1a81 platform/x86: think-lmi: Fix memory leak when showing current settings
7e364e56293b Linux 6.3-rc5
6ab608fe852b Merge tag 'for-6.3-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
f95b8ea79c47 Revert "venus: firmware: Correct non-pix start and end addresses"
a10ca0950afe Merge tag 'driver-core-6.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
95d0b9d89d78 Merge tag 'powerpc-6.3-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
You have mail in /var/mail/mtodorov
mtodorov@domac:~/linux/kernel/linux_torvalds$

I don't see it here either. But it is not critical (no security issue).

Have a nice day!

P.S.

Correction.

Yes, I found it here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6caea4855553a8b99ba3ec23ecdb5ed8262f26c

Quoted 7 lines
Quoted 3 lines

"Notice: this object is not reachable from any branch."

I see Murphy's law in action :-)

Ah, sorry, no, my fault, it's in my usb.git tree and hasn't been sent to Linus yet, that will happen later this week. It is also in the linux-next tree if you want to look there.

No problem.

I have applied the patch manually, downloaded from here:
https://lore.kernel.org/lkml/[email protected]/

It's no big deal, I have somehow made it work.

Eventually it will propagate to the vanilla build Torvalds tree.

It's good that it's closed, I waited five months to fix this, so a day or week is no big difference ... Great experience assisting your team.

Now I have to make something for my day job.

Regards,
Mirsad

Signature · 9 lines
Mirsad Todorovac
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb
Republic of Croatia, the European Union

Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
#15 lore raw

Re: [PATCH 3/3] xhci: Free the command allocated for setting LPM if we return early

In reply to Greg KH
Quoted 131 lines · Greg KH
Quoted 64 lines · Mirsad Goran Todorovac
Quoted 63 lines · Mirsad Goran Todorovac
Quoted 48 lines · Greg KH
Quoted 35 lines · Mirsad Goran Todorovac

Hi, Mathias!

Quoted 19 lines · Mathias Nyman

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")
---
    drivers/usb/host/xhci.c | 1 +
    1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +0 -0
index bdb6dd819a3b..6307bae9cddf 100644

drivers/usb/host/xhci.c static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, · line 4446

Quoted 5 lines
drivers/usb/host/xhci.c +1 -0
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
        if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
            spin_unlock_irqrestore(&xhci->lock, flags);
+        xhci_free_command(xhci, command);
            return 0;
        }

There seems to be a problem with applying this patch with "git am", as it gives the following:

commit ff9de97baa02cb9362b7cb81e95bc9be424cab89
Author: @ <@>
Date:   Mon Apr 3 08:42:33 2023 +0200

Quoted 7 lines

     The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

This is already commit f6caea485555 ("xhci: Free the command allocated for setting LPM if we return early") in Linus's tree, do you not see it there?

Quoted 6 lines

And how exactly did you save the message to apply it with 'git am'?  It worked for me.

thanks,

greg k-h

git am ../mathias-xhci.mail

mtodorov@domac:~/linux/kernel/linux_torvalds$ cat ../mathias-xhci.mail
From: Mathias Nyman @ 2023-03-27  9:50 UTC (permalink / raw)
    To: mirsad.todorovac, linux-usb, linux-kernel
    Cc: gregkh, ubuntu-devel-discuss, stern, arnd, Mathias Nyman, Stable
Quoted 7 lines
Quoted 7 lines

The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing.

Fixes 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command")

That is very odd, your mail program is not getting the full mbox information here at all. Try downloading it from lore.kernel.org as a raw message:

	https://lore.kernel.org/all/[email protected]/raw

and applying that?

Quoted 52 lines
Quoted 41 lines
---
   drivers/usb/host/xhci.c | 1 +
   1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +1 -0
index bdb6dd819a3b..6307bae9cddf 100644
@@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
 
          if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
                  spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_free_command(xhci, command);
                  return 0;
          }
 
Signature · 24 lines
2.25.1

Sorry, no commit f6caea485555 in the "git pull":

mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | grep f6caea485555
mtodorov@domac:~/linux/kernel/linux_torvalds$ git log --oneline | head -10
10de4cefccf7 memstick: fix memory leak if card device is never registered
feeedf59897c platform/x86: think-lmi: Clean up display of current_value on Thinkstation
86cebdbfb8d2 platform/x86: think-lmi: Fix memory leaks when parsing ThinkStation WMI strings
ff9de97baa02 The command allocated to set exit latency LPM values need
to be freed in case the command is never queued. This would be the case
if there is no change in exit latency values, or device is missing.
2ac6d07f1a81 platform/x86: think-lmi: Fix memory leak when showing current settings
7e364e56293b Linux 6.3-rc5
6ab608fe852b Merge tag 'for-6.3-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
f95b8ea79c47 Revert "venus: firmware: Correct non-pix start and end addresses"
a10ca0950afe Merge tag 'driver-core-6.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
95d0b9d89d78 Merge tag 'powerpc-6.3-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
You have mail in /var/mail/mtodorov
mtodorov@domac:~/linux/kernel/linux_torvalds$

I don't see it here either. But it is not critical (no security issue).

Have a nice day!

P.S.

Correction.

Yes, I found it here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6caea4855553a8b99ba3ec23ecdb5ed8262f26c

"Notice: this object is not reachable from any branch."

Quoted 7 lines
Quoted 1 line

I see Murphy's law in action :-)

Ah, sorry, no, my fault, it's in my usb.git tree and hasn't been sent to Linus yet, that will happen later this week. It is also in the linux-next tree if you want to look there.

thanks,

Not at all. Thank you for the hint for the new Lore link.

The new build also compiled w/o problems and the leak appears patched in the original setting that triggered it in the first place:

[root@pc-mtodorov kernel]# uname -rms
Linux 6.3.0-rc5-mt-20230401-00007-g268a637be362 x86_64 [root@pc-mtodorov kernel]# echo scan > /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# cat /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# echo scan > /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# cat /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# echo scan > /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]# cat /sys/kernel/debug/kmemleak [root@pc-mtodorov kernel]#

However, there is a lot of homework to catch up on the Linux kernel drivers for me ... This was beginner's luck to find.

Given enough time and at high enough improbability level, a bunch of monkeys could have found it ;-)

Regards,
Mirsad

Signature · 9 lines
Mirsad Todorovac
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb
Republic of Croatia, the European Union

Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu