Commit 7944aea3 authored by Henry Lin's avatar Henry Lin Committed by Wen Zhiwei
Browse files

xhci: tegra: fix checked USB2 port number

stable inclusion
from stable-v6.6.58
commit 9c696bf4ab54c7cec81221887564305f0ceeac0a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB3BSC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9c696bf4ab54c7cec81221887564305f0ceeac0a



--------------------------------

commit 7d381137cb6ecf558ef6698c7730ddd482d4c8f2 upstream.

If USB virtualizatoin is enabled, USB2 ports are shared between all
Virtual Functions. The USB2 port number owned by an USB2 root hub in
a Virtual Function may be less than total USB2 phy number supported
by the Tegra XUSB controller.

Using total USB2 phy number as port number to check all PORTSC values
would cause invalid memory access.

[  116.923438] Unable to handle kernel paging request at virtual address 006c622f7665642f
...
[  117.213640] Call trace:
[  117.216783]  tegra_xusb_enter_elpg+0x23c/0x658
[  117.222021]  tegra_xusb_runtime_suspend+0x40/0x68
[  117.227260]  pm_generic_runtime_suspend+0x30/0x50
[  117.232847]  __rpm_callback+0x84/0x3c0
[  117.237038]  rpm_suspend+0x2dc/0x740
[  117.241229] pm_runtime_work+0xa0/0xb8
[  117.245769]  process_scheduled_works+0x24c/0x478
[  117.251007]  worker_thread+0x23c/0x328
[  117.255547]  kthread+0x104/0x1b0
[  117.259389]  ret_from_fork+0x10/0x20
[  117.263582] Code: 54000222 f9461ae8 f8747908 b4ffff48 (f9400100)

Cc: stable@vger.kernel.org # v6.3+
Fixes: a30951d3 ("xhci: tegra: USB2 pad power controls")
Signed-off-by: default avatarHenry Lin <henryl@nvidia.com>
Link: https://lore.kernel.org/r/20241014042134.27664-1-henryl@nvidia.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 0836afa3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2183,7 +2183,7 @@ static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool runtime)
		goto out;
	}

	for (i = 0; i < tegra->num_usb_phys; i++) {
	for (i = 0; i < xhci->usb2_rhub.num_ports; i++) {
		if (!xhci->usb2_rhub.ports[i])
			continue;
		portsc = readl(xhci->usb2_rhub.ports[i]->addr);