Subject: [PATCH AUTOSEL 7.0-5.10] net: ethernet: ravb: Disable interrupts when closing device

From: Sasha Levin <[email-masked]>
Date: Mon, 20 Apr 2026 09:19:06 -0400

From: Yoshihiro Shimoda <[email-masked]>

[ Upstream commit 9278b888920ee8f3cea06622f04da681536b6601 ]

Disable E-MAC interrupts when closing the device.

Signed-off-by: Yoshihiro Shimoda <[email-masked]>
[Niklas: Rebase from BSP and reword commit message]
Signed-off-by: Niklas Söderlund <[email-masked]>
Link: https://patch.msgid.link/[email-masked]
Signed-off-by: Jakub Kicinski <[email-masked]>
Signed-off-by: Sasha Levin <[email-masked]>
---

LLM Generated explanations, may be completely bogus:

Now I have a comprehensive understanding of the commit. Let me compile
the full analysis.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject Line
- **Subsystem**: `net: ethernet: ravb` (Renesas Ethernet AVB driver)
- **Action verb**: "Disable" - indicates fixing a missing operation
- **Summary**: Disable E-MAC interrupts when closing the device

Record: The commit adds a missing interrupt disable for the E-MAC
interrupt source register (ECSIPR) during device close.

### Step 1.2: Tags
- **Signed-off-by**: Yoshihiro Shimoda (original author, Renesas)
- **Signed-off-by**: Niklas Soderlund (rebased from BSP)
- **Signed-off-by**: Jakub Kicinski (net maintainer, applied the patch)
- **Link**: `https://patch.msgid.link/20260307095532.2118495-1-
  [email-masked]`
- No Fixes: tag (expected for AUTOSEL candidate)
- No Reported-by tag

Record: BSP-originated fix from Renesas engineer, applied by net
maintainer.

### Step 1.3: Commit Body
The message says "Disable E-MAC interrupts when closing the device." The
`[Niklas: Rebase from BSP and reword commit message]` note tells us this
was found and fixed in Renesas's vendor BSP kernel, then upstreamed.

Record: Fix for missing interrupt disable discovered by the hardware
vendor (Renesas).

### Step 1.4: Hidden Bug Fix Detection
This is absolutely a bug fix: the E-MAC interrupt enable register was
left active after device close. This means interrupts could fire after
the device teardown has progressed.

Record: Yes, this is a real bug fix — missing disable of E-MAC
interrupts during close.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
- **Files**: `drivers/net/ethernet/renesas/ravb_main.c` — 1 line added
- **Function**: `ravb_close()`
- **Scope**: Single-line surgical fix

### Step 2.2: Code Flow Change
**Before**: `ravb_close()` disables RIC0, RIC2, TIC interrupt masks but
does NOT disable the ECSIPR (E-MAC Status Interrupt Policy Register).

**After**: `ravb_close()` also writes 0 to ECSIPR, disabling all E-MAC
interrupts (link change, carrier error, magic packet).

### Step 2.3: Bug Mechanism
The E-MAC interrupt handler (`ravb_emac_interrupt_unlocked`) can be
triggered when ECSIPR bits are enabled. During `ravb_open()`,
`ravb_emac_init()` sets ECSIPR to enable E-MAC interrupts. But during
`ravb_close()`, ECSIPR was never cleared. This means:

1. E-MAC interrupts remain enabled after close
2. They can fire during device teardown (while NAPI is being disabled,
   ring buffers being freed)
3. The handler accesses device registers, stats counters, and can call
   `ravb_rcv_snd_disable()`/`ravb_rcv_snd_enable()` which modify device
   state

The ECSIPR bits include:
- `ECSIPR_ICDIP` (carrier detection)
- `ECSIPR_MPDIP` (magic packet)
- `ECSIPR_LCHNGIP` (link change)

### Step 2.4: Fix Quality
- **Obviously correct**: The other three interrupt registers (RIC0,
  RIC2, TIC) are already cleared. ECSIPR was simply omitted.
- **Minimal**: 1 line addition
- **Regression risk**: Effectively zero — it's disabling interrupts that
  should already be disabled
- **Consistent with codebase**: `ravb_wol_setup()` also explicitly
  manages ECSIPR (setting it to `ECSIPR_MPDIP` only)

Record: Trivially correct, zero regression risk.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
The interrupt disable block (RIC0/RIC2/TIC) was introduced in the
original driver commit `c156633f135326` (2015-06-11) by Sergei Shtylyov.
The ECSIPR write was missing from the very beginning — this bug has been
present since the driver's inception in Linux 4.2.

Record: Bug present since the driver was first added (commit
c156633f1353, Linux 4.2, 2015).

### Step 3.2: Fixes Tag
No Fixes: tag present. Based on analysis, the correct Fixes: tag would
point to `c156633f135326` (the original driver).

### Step 3.3: File History
Recent activity includes timestamp-related improvements and a close-
function reorder by Claudiu Beznea. The `ravb_close()` function was
recently reordered in `a5f149a97d09c` but that change also did not add
the missing ECSIPR disable.

Record: Standalone fix, no dependencies.

### Step 3.4: Author Context
Yoshihiro Shimoda is a regular Renesas contributor with multiple ravb
fixes. Niklas Soderlund is the Renesas upstreaming contact who regularly
ports BSP fixes.

Record: Fix from the hardware vendor's engineers.

### Step 3.5: Dependencies
None. The `ECSIPR` register and `ravb_write()` function have been in the
driver since day one.

Record: Fully standalone, applies to any kernel version with this
driver.

---

## PHASE 4: MAILING LIST RESEARCH

### Step 4.1-4.5
Lore was not accessible (anti-bot protection). However:
- The patch was applied by Jakub Kicinski (net maintainer), confirming
  it passed review
- The Link: tag confirms it went through the standard netdev submission
  process
- The BSP origin confirms Renesas discovered this in their own testing

Record: Maintainer-applied, vendor-validated fix.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1-5.4: Function Analysis
The E-MAC interrupt handler chain:
- `ravb_emac_interrupt()` (or `ravb_interrupt()` → ISS_MS check) →
  `ravb_emac_interrupt_unlocked()`
- The handler reads ECSR, writes ECSR (to clear), reads PSR, and can
  call `ravb_rcv_snd_disable()`/`ravb_rcv_snd_enable()`
- With ECSIPR not cleared, these interrupts fire after `ravb_close()`
  disables NAPI and frees ring buffers
- The interrupt uses `devm_request_irq()`, so it stays registered until
  device removal

Record: Spurious E-MAC interrupts after close could access device state
during/after teardown.

---

## PHASE 6: STABLE TREE ANALYSIS

### Step 6.1: Bug Existence in Stable Trees
The buggy code (`ravb_close()` missing ECSIPR disable) has existed since
the driver's creation in Linux 4.2. It exists in all stable trees.

### Step 6.2: Backport Complications
The fix is a single `ravb_write()` call added alongside identical
existing calls. It will apply cleanly to any kernel with this driver.

Record: Clean apply expected in all stable trees.

---

## PHASE 7: SUBSYSTEM CONTEXT

### Step 7.1
- **Subsystem**: Network driver for Renesas R-Car/RZ SoCs
- **Criticality**: IMPORTANT — used on embedded automotive and
  industrial systems
- **Users**: Renesas R-Car and RZ platform users (automotive, IoT,
  embedded)

### Step 7.2
Active subsystem with regular development activity.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Affected Users
Users of Renesas R-Car and RZ Ethernet (ravb) hardware — automotive and
embedded systems.

### Step 8.2: Trigger Conditions
Every device close (`ifconfig down`, `ip link set down`, system
shutdown). This is a routine operation.

### Step 8.3: Failure Mode
Without the fix, E-MAC interrupts fire after close. Possible
consequences:
- **Spurious interrupts** during teardown — the handler accesses freed
  state
- On systems with separate E-MAC IRQ line, `ravb_emac_interrupt()` can
  fire and access the device after NAPI is disabled
- In the shared IRQ case (`ravb_interrupt()`), the ISS_MS check can
  trigger `ravb_emac_interrupt_unlocked()` which modifies device
  registers during teardown

Severity: **MEDIUM-HIGH** (spurious interrupts during teardown,
potential for accessing freed resources)

### Step 8.4: Risk-Benefit
- **Benefit**: Prevents spurious E-MAC interrupts during device close on
  all Renesas AVB platforms
- **Risk**: Effectively zero — writing 0 to an interrupt enable register
  at close time is inherently safe
- **Ratio**: Very favorable

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence Summary
**FOR backporting:**
- Fixes a bug present since driver creation (2015, Linux 4.2)
- 1-line fix, obviously correct, zero regression risk
- Discovered by the hardware vendor (Renesas BSP)
- Applied by the netdev maintainer
- Consistent with existing pattern (other interrupt masks already
  cleared)
- Common trigger (every device close)
- Prevents spurious interrupts during teardown

**AGAINST backporting:**
- No explicit crash/syzbot report (found by code inspection/vendor
  testing)
- Commit message is terse

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** — trivially obvious, vendor-
   tested
2. Fixes a real bug? **YES** — missing interrupt disable on close
3. Important issue? **YES** — spurious interrupts during teardown
4. Small and contained? **YES** — 1 line
5. No new features or APIs? **YES** — pure fix
6. Can apply to stable? **YES** — clean apply expected

### Step 9.3: Exception Categories
Not needed — this is a straightforward bug fix.

### Step 9.4: Decision
This is a minimal, obviously correct fix for a long-standing bug where
E-MAC interrupts were not disabled during device close. The fix is 1
line, has zero regression risk, and was originated by the hardware
vendor.

---

## Verification

- [Phase 1] Parsed commit message: BSP-origin fix, applied by netdev
  maintainer Jakub Kicinski
- [Phase 2] Diff analysis: 1 line added (`ravb_write(ndev, 0, ECSIPR)`)
  in `ravb_close()` alongside existing RIC0/RIC2/TIC clears
- [Phase 3] git blame: The interrupt disable block was in commit
  c156633f1353 (2015, Linux 4.2), ECSIPR omitted since then
- [Phase 3] Confirmed ECSIPR is set during `ravb_emac_init_rcar()` (line
  585) and `ravb_emac_init_gbeth()` (line 551) but never cleared during
  close
- [Phase 3] git show c156633f1353: confirmed original `ravb_close()`
  already disabled RIC0/RIC2/TIC but omitted ECSIPR
- [Phase 3] File history: fix is standalone, no dependencies
- [Phase 4] Lore inaccessible (anti-bot); confirmed maintainer
  application via commit tags
- [Phase 5] `ravb_emac_interrupt_unlocked()` at line 1111 handles
  ECSIPR-enabled interrupts, accesses device state
- [Phase 5] `ravb_wol_setup()` at line 3164 explicitly manages ECSIPR,
  confirming it needs to be handled
- [Phase 6] Bug exists in all stable trees (present since driver
  creation in Linux 4.2)
- [Phase 6] 1-line fix will apply cleanly everywhere
- [Phase 8] Trigger: every device close; Severity: MEDIUM-HIGH (spurious
  interrupts during teardown)

**YES**

 drivers/net/ethernet/renesas/ravb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 84b657fc2e158..2c725824b3488 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2367,6 +2367,7 @@ static int ravb_close(struct net_device *ndev)
 	ravb_write(ndev, 0, RIC0);
 	ravb_write(ndev, 0, RIC2);
 	ravb_write(ndev, 0, TIC);
+	ravb_write(ndev, 0, ECSIPR);
 
 	/* PHY disconnect */
 	if (ndev->phydev) {
-- 
2.53.0