* [PATCH AUTOSEL 6.18-5.10] usb: xhci: limit run_graceperiod for only usb 3.0 devices
[not found] <20251210063446.2513466-1-sashal@kernel.org>
@ 2025-12-10 6:34 ` Sasha Levin
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usbip: Fix locking bug in RT-enabled kernels Sasha Levin
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-12-10 6:34 UTC (permalink / raw)
To: patches, stable
Cc: Hongyu Xie, Mathias Nyman, Greg Kroah-Hartman, Sasha Levin,
mathias.nyman, linux-usb
From: Hongyu Xie <xiehongyu1@kylinos.cn>
[ Upstream commit 8d34983720155b8f05de765f0183d9b0e1345cc0 ]
run_graceperiod blocks usb 2.0 devices from auto suspending after
xhci_start for 500ms.
Log shows:
[ 13.387170] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100
[ 13.387177] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 13.387182] hub_suspend:3903: hub 7-0:1.0: hub_suspend
[ 13.387188] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1
[ 13.387191] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event
[ 13.387193] hcd_bus_resume:2303: usb usb7: usb auto-resume
[ 13.387296] hub_event:5779: hub 3-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 13.393343] handle_port_status:2034: xhci-hcd PNP0D10:02: handle_port_status: starting usb5 port polling.
[ 13.393353] xhci_hub_control:1271: xhci-hcd PNP0D10:02: Get port status 5-1 read: 0x206e1, return 0x10101
[ 13.400047] hub_suspend:3903: hub 3-0:1.0: hub_suspend
[ 13.403077] hub_resume:3948: hub 7-0:1.0: hub_resume
[ 13.403080] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100
[ 13.403085] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 13.403087] hub_suspend:3903: hub 7-0:1.0: hub_suspend
[ 13.403090] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1
[ 13.403093] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event
[ 13.403095] hcd_bus_resume:2303: usb usb7: usb auto-resume
[ 13.405002] handle_port_status:1913: xhci-hcd PNP0D10:04: Port change event, 9-1, id 1, portsc: 0x6e1
[ 13.405016] hub_activate:1169: usb usb5-port1: status 0101 change 0001
[ 13.405026] xhci_clear_port_change_bit:658: xhci-hcd PNP0D10:02: clear port1 connect change, portsc: 0x6e1
[ 13.413275] hcd_bus_suspend:2250: usb usb3: bus auto-suspend, wakeup 1
[ 13.419081] hub_resume:3948: hub 7-0:1.0: hub_resume
[ 13.419086] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100
[ 13.419095] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 13.419100] hub_suspend:3903: hub 7-0:1.0: hub_suspend
[ 13.419106] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1
[ 13.419110] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event
[ 13.419112] hcd_bus_resume:2303: usb usb7: usb auto-resume
[ 13.420455] handle_port_status:2034: xhci-hcd PNP0D10:04: handle_port_status: starting usb9 port polling.
[ 13.420493] handle_port_status:1913: xhci-hcd PNP0D10:05: Port change event, 10-1, id 1, portsc: 0x6e1
[ 13.425332] hcd_bus_suspend:2279: usb usb3: suspend raced with wakeup event
[ 13.431931] handle_port_status:2034: xhci-hcd PNP0D10:05: handle_port_status: starting usb10 port polling.
[ 13.435080] hub_resume:3948: hub 7-0:1.0: hub_resume
[ 13.435084] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100
[ 13.435092] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 13.435096] hub_suspend:3903: hub 7-0:1.0: hub_suspend
[ 13.435102] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1
[ 13.435106] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event
usb7 and other usb 2.0 root hub were rapidly toggling between suspend
and resume states. More, "suspend raced with wakeup event" confuses people.
So, limit run_graceperiod for only usb 3.0 devices
Signed-off-by: Hongyu Xie <xiehongyu1@kylinos.cn>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20251119142417.2820519-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Analysis Summary
### 1. COMMIT MESSAGE ANALYSIS
- **Problem**: The `run_graceperiod` mechanism (500ms delay after xHC
start) was incorrectly blocking USB 2.0 devices from auto-suspending
- **Symptom**: USB 2.0 root hubs rapidly toggling between suspend and
resume, causing "suspend raced with wakeup event" log spam
- **No Cc: stable tag** or **Fixes: tag** present, but this is fixing a
bug in code that WAS marked for stable
### 2. CODE CHANGE ANALYSIS
The change is a minimal one-line addition:
```c
- if (xhci->run_graceperiod) {
+ if (hcd->speed >= HCD_USB3 && xhci->run_graceperiod) {
```
**Root cause**: The original commit 33e321586e37b ("xhci: Add grace
period after xHC start to prevent premature runtime suspend") introduced
`run_graceperiod` in August 2022 (v6.0-rc4). The code comment explicitly
states: "SS devices are only visible to roothub after link training
completes" - SS means SuperSpeed (USB 3.0). However, the implementation
didn't actually check for USB 3.0, applying the grace period to ALL
devices incorrectly.
**Why it matters**: USB 2.0 devices don't require link training delays.
The 500ms grace period prevents them from suspending when they should be
able to, causing the rapid suspend/resume cycling shown in the logs.
### 3. CLASSIFICATION
- **Bug fix**: YES - corrects behavior to match documented intent
- **Feature addition**: NO
- **Security**: NO
### 4. SCOPE AND RISK ASSESSMENT
- **Lines changed**: 1
- **Files touched**: 1 (drivers/usb/host/xhci-hub.c)
- **Pattern used**: `hcd->speed >= HCD_USB3` is used 20+ times in xhci-
hub.c and xhci.c - this is a well-established pattern
- **Risk**: VERY LOW - trivial change using existing idiom
### 5. USER IMPACT
- **Affected users**: All systems with xHCI USB controllers (most modern
systems)
- **Severity**: Medium - not a crash, but affects power management and
creates confusing log messages
- **Visibility**: Users see rapid suspend/resume cycles and log spam
### 6. STABILITY INDICATORS
- Signed-off-by Mathias Nyman (Intel xHCI maintainer)
- Signed-off-by Greg Kroah-Hartman (Linux USB/stable maintainer)
- Follows existing code patterns extensively used in the same file
### 7. DEPENDENCY CHECK
- **Dependencies**: None - the fix uses existing variables and macros
- **Original commit**: 33e321586e37b was marked `Cc:
stable@vger.kernel.org`, so stable kernels v6.0+ have the buggy code
- The fix should be backported to all stable branches that have the
original commit
### Key Points
**Why this should be backported:**
1. Fixes a bug in code that was explicitly backported to stable
(33e321586e37b had Cc: stable)
2. The fix aligns implementation with documented intent (comment says
"SS devices")
3. Minimal, surgical change with near-zero regression risk
4. Uses well-established pattern (`hcd->speed >= HCD_USB3`) used
throughout the driver
5. Fixes real user-visible issue: power consumption and log spam
6. Maintained by the same author (Mathias Nyman) who wrote the original
**Risk vs Benefit**:
- **Benefit**: Fixes USB 2.0 power management regression, eliminates
confusing logs
- **Risk**: Extremely low - single conditional check using existing
infrastructure
The absence of explicit `Cc: stable` and `Fixes:` tags is likely an
oversight since this clearly fixes a bug in stable-destined code.
**YES**
drivers/usb/host/xhci-hub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index b3a59ce1b3f41..5e1442e91743d 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1671,7 +1671,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
* SS devices are only visible to roothub after link training completes.
* Keep polling roothubs for a grace period after xHC start
*/
- if (xhci->run_graceperiod) {
+ if (hcd->speed >= HCD_USB3 && xhci->run_graceperiod) {
if (time_before(jiffies, xhci->run_graceperiod))
status = 1;
else
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 6.18-5.10] usbip: Fix locking bug in RT-enabled kernels
[not found] <20251210063446.2513466-1-sashal@kernel.org>
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usb: xhci: limit run_graceperiod for only usb 3.0 devices Sasha Levin
@ 2025-12-10 6:34 ` Sasha Levin
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-6.17] usb: xhci: Don't unchain link TRBs on quirky HCs Sasha Levin
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usb: usb-storage: No additional quirks need to be added to the EL-R12 optical drive Sasha Levin
3 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-12-10 6:34 UTC (permalink / raw)
To: patches, stable
Cc: Lizhi Xu, syzbot+205ef33a3b636b4181fb, Shuah Khan,
Greg Kroah-Hartman, Sasha Levin, valentina.manea.m, shuah,
bigeasy, clrkwllms, rostedt, linux-usb, linux-rt-devel
From: Lizhi Xu <lizhi.xu@windriver.com>
[ Upstream commit 09bf21bf5249880f62fe759b53b14b4b52900c6c ]
Interrupts are disabled before entering usb_hcd_giveback_urb().
A spinlock_t becomes a sleeping lock on PREEMPT_RT, so it cannot be
acquired with disabled interrupts.
Save the interrupt status and restore it after usb_hcd_giveback_urb().
syz reported:
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
Call Trace:
dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
rt_spin_lock+0xc7/0x2c0 kernel/locking/spinlock_rt.c:57
spin_lock include/linux/spinlock_rt.h:44 [inline]
mon_bus_complete drivers/usb/mon/mon_main.c:134 [inline]
mon_complete+0x5c/0x200 drivers/usb/mon/mon_main.c:147
usbmon_urb_complete include/linux/usb/hcd.h:738 [inline]
__usb_hcd_giveback_urb+0x254/0x5e0 drivers/usb/core/hcd.c:1647
vhci_urb_enqueue+0xb4f/0xe70 drivers/usb/usbip/vhci_hcd.c:818
Reported-by: syzbot+205ef33a3b636b4181fb@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=205ef33a3b636b4181fb
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250916014143.1439759-1-lizhi.xu@windriver.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Analysis Summary
### 1. PROBLEM IDENTIFICATION
**Bug Type:** "Sleeping function called from invalid context" BUG on
PREEMPT_RT kernels
**Root Cause:**
- Commit 9e8586827a706 (from 2020) added
`local_irq_disable()/local_irq_enable()` around
`usb_hcd_giveback_urb()` to fix an earlier bug
- On PREEMPT_RT kernels, `spinlock_t` becomes a sleeping lock (rt_mutex)
- When `usb_hcd_giveback_urb()` is called with IRQs disabled, its
completion callbacks (like `mon_complete()` in usbmon) try to acquire
spinlock_t
- Acquiring a sleeping lock with IRQs disabled triggers: `BUG: sleeping
function called from invalid context at
kernel/locking/spinlock_rt.c:48`
### 2. THE FIX EXPLAINED
**Before (buggy):**
```c
spin_unlock_irqrestore(&vhci->lock, flags); // unlock + restore IRQs
local_irq_disable(); // disable IRQs
usb_hcd_giveback_urb(hcd, urb, urb->status); // ⚠️ callbacks can't
acquire RT spinlocks!
local_irq_enable();
```
**After (fixed):**
```c
spin_unlock(&vhci->lock); // just release lock (keep
IRQs in saved state)
usb_hcd_giveback_urb(hcd, urb, urb->status); // ✓ callbacks can acquire
RT spinlocks
spin_lock(&vhci->lock); // re-acquire
spin_unlock_irqrestore(&vhci->lock, flags); // final unlock + restore
IRQs
```
The fix keeps IRQs in the saved state from the original
`spin_lock_irqsave()` instead of explicitly disabling them, which allows
RT spinlocks to work properly.
### 3. STABLE BACKPORT CRITERIA EVALUATION
| Criterion | Assessment |
|-----------|------------|
| **Fixes real bug** | ✅ Yes - BUG/crash on PREEMPT_RT kernels with
USBIP |
| **Obviously correct** | ✅ Yes - standard RT locking pattern |
| **Small and contained** | ✅ Yes - 7 lines changed in 1 file |
| **No new features** | ✅ Correct - pure bug fix |
| **Has Fixes: tag** | ❌ No, but implicitly fixes 9e8586827a706 |
| **Has Cc: stable** | ❌ No explicit tag |
| **Maintainer approval** | ✅ Acked-by: Shuah Khan, Signed-off-by: GKH |
| **Tested** | ✅ Reported by syzbot with reproducer |
| **Dependencies** | ✅ None - standalone fix |
### 4. AFFECTED STABLE TREES
The original buggy commit 9e8586827a706 was introduced in kernel 5.10
(2020). All stable trees from 5.10.y onwards contain this bug and would
benefit from this fix. PREEMPT_RT has been increasingly mainlined,
making this fix more relevant for modern stable users.
### 5. RISK ASSESSMENT
**Risk: LOW**
- The change is mechanical - just reordering lock/unlock operations
- Locking semantics and data protection remain identical
- Only affects the error path (`no_need_xmit`/`no_need_unlink` labels)
- The fix is well-understood and targets a specific RT locking issue
**Impact: MEDIUM-HIGH for affected users**
- PREEMPT_RT is becoming more mainstream (now fully merged in mainline)
- USBIP is used in virtualization, embedded systems, and IoT
- Bug causes system crash/BUG which is severe
### 6. CONCLUSION
This commit is an excellent candidate for stable backport:
- Fixes a real, reproducible crash affecting PREEMPT_RT users with USBIP
- Small, surgical fix with no risk of regression
- Signed off by GKH (who is both USB maintainer AND stable maintainer)
- Acked by the USBIP subsystem maintainer
- The buggy code exists in all stable trees since 5.10
- No dependencies on other commits
The lack of explicit `Cc: stable` and `Fixes:` tags is unusual for such
a clear bug fix, but the technical merits strongly support backporting.
**YES**
drivers/usb/usbip/vhci_hcd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 0d6c10a8490c0..f7e405abe6084 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -831,15 +831,15 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
no_need_xmit:
usb_hcd_unlink_urb_from_ep(hcd, urb);
no_need_unlink:
- spin_unlock_irqrestore(&vhci->lock, flags);
if (!ret) {
/* usb_hcd_giveback_urb() should be called with
* irqs disabled
*/
- local_irq_disable();
+ spin_unlock(&vhci->lock);
usb_hcd_giveback_urb(hcd, urb, urb->status);
- local_irq_enable();
+ spin_lock(&vhci->lock);
}
+ spin_unlock_irqrestore(&vhci->lock, flags);
return ret;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 6.18-6.17] usb: xhci: Don't unchain link TRBs on quirky HCs
[not found] <20251210063446.2513466-1-sashal@kernel.org>
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usb: xhci: limit run_graceperiod for only usb 3.0 devices Sasha Levin
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usbip: Fix locking bug in RT-enabled kernels Sasha Levin
@ 2025-12-10 6:34 ` Sasha Levin
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usb: usb-storage: No additional quirks need to be added to the EL-R12 optical drive Sasha Levin
3 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-12-10 6:34 UTC (permalink / raw)
To: patches, stable
Cc: Michal Pecio, Mathias Nyman, Greg Kroah-Hartman, Sasha Levin,
mathias.nyman, linux-usb
From: Michal Pecio <michal.pecio@gmail.com>
[ Upstream commit e6aec6d9f5794e85d2312497a5d81296d885090e ]
Some old HCs ignore transfer ring link TRBs whose chain bit is unset.
This breaks endpoint operation and sometimes makes it execute other
ring's TDs, which may corrupt their buffers or cause unwanted device
action. We avoid this by chaining all link TRBs on affected rings.
Fix an omission which allows them to be unchained by cancelling TDs.
The patch was tested by reproducing this condition on an isochronous
endpoint (non-power-of-two TDs are sometimes split not to cross 64K)
and printing link TRBs in trb_to_noop() on good and buggy HCs.
Actual hardware malfunction is rare since it requires Missed Service
Error shortly before the unchained link TRB, at least on NEC and AMD.
I have never seen it after commit bb0ba4cb1065 ("usb: xhci: Apply the
link chain quirk on NEC isoc endpoints"), but it's Russian roulette
and I can't test all affected hosts and workloads. Fairly often MSEs
happen after cancellation because the endpoint was stopped.
Signed-off-by: Michal Pecio <michal.pecio@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20251119142417.2820519-11-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Comprehensive Analysis
### 1. Commit Message Analysis
**Subject**: "usb: xhci: Don't unchain link TRBs on quirky HCs"
The commit message clearly describes a **hardware bug fix**:
- Some old xHCI HCs "ignore transfer ring link TRBs whose chain bit is
unset"
- This "breaks endpoint operation and sometimes makes it execute other
ring's TDs"
- Can "corrupt their buffers or cause unwanted device action"
**Key signals**:
- ❌ No `Cc: stable@vger.kernel.org` tag
- ❌ No explicit `Fixes:` tag
- ✅ References related fix commit `bb0ba4cb1065` for context
- ✅ Well-documented testing methodology
- ✅ Sign-offs from xHCI maintainer (Mathias Nyman) and USB maintainer
(Greg Kroah-Hartman)
### 2. Code Change Analysis
The change is **small and surgical**:
1. **`trb_to_noop()` modification**: Adds an `unchain_links` parameter -
only unchain link TRBs when `unchain_links=true`
2. **`td_to_noop()` modification**:
- Now takes `xhci` and `ep` parameters
- Checks `xhci_link_chain_quirk()` to determine if unchaining is safe
- Only unchains on HCs without the quirk
3. **Call sites updated**: 5 call sites properly pass the new parameters
**Technical mechanism**: On quirky HCs, when TDs are cancelled and
converted to no-ops, link TRBs were being unchained unconditionally. The
quirky HCs then ignored these unchained link TRBs, causing the HC to
continue past the segment boundary and potentially execute other rings'
TRBs.
### 3. Dependency Analysis
**Critical dependency**: The fix uses `xhci_link_chain_quirk()`:
- Introduced in commit 7476a2215c077 (June 2024)
- First available in **v6.11** and later
This limits clean backporting to **6.11+ stable trees** only. Older LTS
trees (6.6.y, 6.1.y, 5.15.y) would require adaptation.
### 4. Scope and Risk Assessment
| Factor | Assessment |
|--------|------------|
| Lines changed | ~30 net lines in one file |
| Files touched | 1 (drivers/usb/host/xhci-ring.c) |
| Complexity | Low - adds conditional check |
| Regression risk | **Very Low** - only affects HCs with quirk |
### 5. User Impact
- **Affected hardware**: Older NEC, AMD 0x96 xHCI controllers
- **Severity**: Data corruption, endpoint malfunction
- **Trigger**: TD cancellation (relatively common operation)
- **Author's note**: "Actual hardware malfunction is rare" but
acknowledges "it's Russian roulette"
### 6. Classification
- ✅ Bug fix (hardware quirk handling omission)
- ✅ Not a new feature
- ✅ Uses existing quirk infrastructure
- ✅ Affects specific hardware with known quirks
### 7. Stable Criteria Evaluation
| Criterion | Met? |
|-----------|------|
| Obviously correct | ✅ Uses existing quirk logic correctly |
| Fixes real bug | ✅ Data corruption/hardware malfunction |
| Small scope | ✅ One file, surgical change |
| No new features | ✅ Fixes existing functionality |
| Already in mainline | ✅ Yes |
| Testable | ✅ Author tested on good/buggy HCs |
### Risk vs Benefit
**Benefits**:
- Prevents data corruption on quirky HCs
- Prevents USB endpoint malfunction
- Low regression risk (only affects quirky HCs)
**Risks**:
- Minimal - change is conditional
- No explicit stable tag from maintainers
### Concerns
1. **No stable tag**: The maintainers didn't explicitly request stable
backport, possibly:
- Oversight
- Wanting it to bake in mainline first
- Considering the bug "rare" enough
2. **Dependency on 6.11+ infrastructure**: Clean backport limited to
6.11+ stable trees
### Conclusion
This commit fixes a legitimate hardware bug that can cause **data
corruption** and **USB endpoint malfunction** on older xHCI controllers.
The fix is:
- Small and surgical
- Uses existing, tested quirk infrastructure
- Low risk of regression
- Well-tested by the author
- Properly reviewed and signed off by maintainers
The lack of explicit stable tags is concerning but doesn't disqualify it
- the fix clearly addresses a real hardware issue. For stable trees 6.11
and later where the helper function exists, this is a good backport
candidate.
**YES**
drivers/usb/host/xhci-ring.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 5bdcf9ab2b99d..25185552287c0 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -128,11 +128,11 @@ static void inc_td_cnt(struct urb *urb)
urb_priv->num_tds_done++;
}
-static void trb_to_noop(union xhci_trb *trb, u32 noop_type)
+static void trb_to_noop(union xhci_trb *trb, u32 noop_type, bool unchain_links)
{
if (trb_is_link(trb)) {
- /* unchain chained link TRBs */
- trb->link.control &= cpu_to_le32(~TRB_CHAIN);
+ if (unchain_links)
+ trb->link.control &= cpu_to_le32(~TRB_CHAIN);
} else {
trb->generic.field[0] = 0;
trb->generic.field[1] = 0;
@@ -465,7 +465,7 @@ static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
i_cmd->command_trb);
- trb_to_noop(i_cmd->command_trb, TRB_CMD_NOOP);
+ trb_to_noop(i_cmd->command_trb, TRB_CMD_NOOP, false);
/*
* caller waiting for completion is called when command
@@ -797,13 +797,18 @@ static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
* (The last TRB actually points to the ring enqueue pointer, which is not part
* of this TD.) This is used to remove partially enqueued isoc TDs from a ring.
*/
-static void td_to_noop(struct xhci_td *td, bool flip_cycle)
+static void td_to_noop(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
+ struct xhci_td *td, bool flip_cycle)
{
+ bool unchain_links;
struct xhci_segment *seg = td->start_seg;
union xhci_trb *trb = td->start_trb;
+ /* link TRBs should now be unchained, but some old HCs expect otherwise */
+ unchain_links = !xhci_link_chain_quirk(xhci, ep->ring ? ep->ring->type : TYPE_STREAM);
+
while (1) {
- trb_to_noop(trb, TRB_TR_NOOP);
+ trb_to_noop(trb, TRB_TR_NOOP, unchain_links);
/* flip cycle if asked to */
if (flip_cycle && trb != td->start_trb && trb != td->end_trb)
@@ -1091,16 +1096,16 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep)
"Found multiple active URBs %p and %p in stream %u?\n",
td->urb, cached_td->urb,
td->urb->stream_id);
- td_to_noop(cached_td, false);
+ td_to_noop(xhci, ep, cached_td, false);
cached_td->cancel_status = TD_CLEARED;
}
- td_to_noop(td, false);
+ td_to_noop(xhci, ep, td, false);
td->cancel_status = TD_CLEARING_CACHE;
cached_td = td;
break;
}
} else {
- td_to_noop(td, false);
+ td_to_noop(xhci, ep, td, false);
td->cancel_status = TD_CLEARED;
}
}
@@ -1125,7 +1130,7 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep)
continue;
xhci_warn(xhci, "Failed to clear cancelled cached URB %p, mark clear anyway\n",
td->urb);
- td_to_noop(td, false);
+ td_to_noop(xhci, ep, td, false);
td->cancel_status = TD_CLEARED;
}
}
@@ -4273,7 +4278,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
*/
urb_priv->td[0].end_trb = ep_ring->enqueue;
/* Every TRB except the first & last will have its cycle bit flipped. */
- td_to_noop(&urb_priv->td[0], true);
+ td_to_noop(xhci, xep, &urb_priv->td[0], true);
/* Reset the ring enqueue back to the first TRB and its cycle bit. */
ep_ring->enqueue = urb_priv->td[0].start_trb;
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 6.18-5.10] usb: usb-storage: No additional quirks need to be added to the EL-R12 optical drive.
[not found] <20251210063446.2513466-1-sashal@kernel.org>
` (2 preceding siblings ...)
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-6.17] usb: xhci: Don't unchain link TRBs on quirky HCs Sasha Levin
@ 2025-12-10 6:34 ` Sasha Levin
3 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-12-10 6:34 UTC (permalink / raw)
To: patches, stable
Cc: Chen Changcheng, Greg Kroah-Hartman, Sasha Levin, stern,
linux-usb, usb-storage
From: Chen Changcheng <chenchangcheng@kylinos.cn>
[ Upstream commit 955a48a5353f4fe009704a9a4272a3adf627cd35 ]
The optical drive of EL-R12 has the same vid and pid as INIC-3069,
as follows:
T: Bus=02 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 3 Spd=5000 MxCh= 0
D: Ver= 3.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1
P: Vendor=13fd ProdID=3940 Rev= 3.10
S: Manufacturer=HL-DT-ST
S: Product= DVD+-RW GT80N
S: SerialNumber=423349524E4E38303338323439202020
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=144mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=02 Prot=50 Driver=usb-storage
E: Ad=83(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=0a(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
This will result in the optical drive device also adding
the quirks of US_FL_NO_ATA_1X. When performing an erase operation,
it will fail, and the reason for the failure is as follows:
[ 388.967742] sr 5:0:0:0: [sr0] tag#0 Send: scmd 0x00000000d20c33a7
[ 388.967742] sr 5:0:0:0: [sr0] tag#0 CDB: ATA command pass through(12)/Blank a1 11 00 00 00 00 00 00 00 00 00 00
[ 388.967773] sr 5:0:0:0: [sr0] tag#0 Done: SUCCESS Result: hostbyte=DID_TARGET_FAILURE driverbyte=DRIVER_OK cmd_age=0s
[ 388.967773] sr 5:0:0:0: [sr0] tag#0 CDB: ATA command pass through(12)/Blank a1 11 00 00 00 00 00 00 00 00 00 00
[ 388.967803] sr 5:0:0:0: [sr0] tag#0 Sense Key : Illegal Request [current]
[ 388.967803] sr 5:0:0:0: [sr0] tag#0 Add. Sense: Invalid field in cdb
[ 388.967803] sr 5:0:0:0: [sr0] tag#0 scsi host busy 1 failed 0
[ 388.967803] sr 5:0:0:0: Notifying upper driver of completion (result 8100002)
[ 388.967834] sr 5:0:0:0: [sr0] tag#0 0 sectors total, 0 bytes done.
For the EL-R12 standard optical drive, all operational commands
and usage scenarios were tested without adding the IGNORE_RESIDUE quirks,
and no issues were encountered. It can be reasonably concluded
that removing the IGNORE_RESIDUE quirks has no impact.
Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
Link: https://patch.msgid.link/20251121064020.29332-1-chenchangcheng@kylinos.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Summary
**What the commit does:**
This commit fixes a device conflict where the EL-R12 optical drive (HL-
DT-ST DVD+-RW GT80N) with firmware revision 3.10 incorrectly receives
USB quirks intended for the INIC-3069 controller because they share the
same VID:PID (0x13fd:0x3940). The fix narrows the firmware revision
range from "all revisions" (0x0000-0x9999) to only revision 3.09
(0x0309-0x0309).
**History context:**
- Original quirk added in 2015 (commit bda13e35d584d) - was marked `Cc:
stable@vger.kernel.org # 3.16`
- IGNORE_RESIDUE added in 2017 (commit 89f23d51defcb) - also marked for
stable
- The quirk entry has existed in stable trees for years
## Meets Stable Criteria Assessment
| Criterion | Assessment |
|-----------|------------|
| Obviously correct | ✅ Yes - simple revision range narrowing |
| Fixes real bug | ✅ Yes - disc erase operations fail completely |
| Small and contained | ✅ Yes - 1 line change |
| No new features | ✅ Yes - just fixes quirk scope |
| Important issue | ✅ Yes - device operations completely fail |
## Risk vs Benefit
**Benefits:**
- Fixes real functional failure (disc erase operations)
- Users with EL-R12 optical drives can use them properly
- Minimal change, low regression risk
**Risks:**
- Could theoretically affect INIC-3069 devices with firmware versions
other than 3.09 if they exist and need these quirks
- However, the original report was from a specific device/tester, and no
evidence suggests other firmware versions need the quirks
**Mitigating factors:**
- The quirk was originally based on a single reporter's device (Benjamin
Tissoires)
- If multiple firmware versions needed quirks, we'd likely have seen
additional reports over the ~10 years since the original quirk was
added
- The commit author thoroughly tested the EL-R12 without the quirks
## Concerns
1. **No explicit Cc: stable tag** - The maintainer didn't explicitly
request stable backport
2. **No Fixes: tag** - No specific commit is pointed to as introducing
the bug
3. **Revision specificity** - We don't have absolute confirmation that
0x0309 was the original reporter's exact firmware revision
## Conclusion
This is a standard USB quirk adjustment that fixes a real user-facing
bug (optical drive operations failing). USB device quirks are routinely
backported to stable. The change is minimal (single line), surgical, and
addresses documented hardware compatibility issues. The risk of
regression is low since the original quirk was based on a single
reporter's device, and narrowing the scope shouldn't affect other users.
While the lack of a Cc: stable tag is notable, USB quirk fixes of this
nature are commonly backported because they enable proper hardware
operation. The fix allows the EL-R12 optical drive to work correctly
without impacting the original INIC-3069 devices that need the quirks.
**YES**
drivers/usb/storage/unusual_uas.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
index 1477e31d77632..b695f5ba9a409 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -98,7 +98,7 @@ UNUSUAL_DEV(0x125f, 0xa94a, 0x0160, 0x0160,
US_FL_NO_ATA_1X),
/* Reported-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> */
-UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999,
+UNUSUAL_DEV(0x13fd, 0x3940, 0x0309, 0x0309,
"Initio Corporation",
"INIC-3069",
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-10 6:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251210063446.2513466-1-sashal@kernel.org>
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usb: xhci: limit run_graceperiod for only usb 3.0 devices Sasha Levin
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usbip: Fix locking bug in RT-enabled kernels Sasha Levin
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-6.17] usb: xhci: Don't unchain link TRBs on quirky HCs Sasha Levin
2025-12-10 6:34 ` [PATCH AUTOSEL 6.18-5.10] usb: usb-storage: No additional quirks need to be added to the EL-R12 optical drive Sasha Levin
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).