From: Tony Battersby tonyb@cybernetics.com
[ Upstream commit 8f58fc64d559b5fda1b0a5e2a71422be61e79ab9 ]
When given the module parameter qlini_mode=exclusive, qla2xxx in initiator mode is initially unable to successfully send SCSI commands to devices it finds while scanning, resulting in an escalating series of resets until an adapter reset clears the issue. Fix by checking the active mode instead of the module parameter.
Signed-off-by: Tony Battersby tonyb@cybernetics.com Link: https://patch.msgid.link/1715ec14-ba9a-45dc-9cf2-d41aa6b81b5e@cybernetics.co... Signed-off-by: Martin K. Petersen martin.petersen@oracle.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
## Complete Analysis
### 1. Commit Message Analysis
The commit describes a clear bug: - **Problem:** When using `qlini_mode=exclusive`, qla2xxx in initiator mode fails to send SCSI commands to discovered devices - **Symptom:** Escalating series of resets until an adapter reset clears the issue - **Fix:** Check the active mode instead of the module parameter
No `Cc: stable@vger.kernel.org` or `Fixes:` tags are present, but this doesn't preclude backporting if the fix clearly meets stable criteria.
### 2. Code Change Analysis - The Bug
**Buggy logic (lines 3446-3458):** ```c if (ha->mqenable) { bool startit = false;
if (QLA_TGT_MODE_ENABLED()) startit = false;
if (ql2x_ini_mode == QLA2XXX_INI_MODE_ENABLED) startit = true;
for (i = 0; i < ha->max_qpairs; i++) qla2xxx_create_qpair(base_vha, 5, 0, startit); } ```
The mode values from `qla_target.h`: - `QLA2XXX_INI_MODE_EXCLUSIVE` = 0 (exclusive initiator mode - **an initiator mode!**) - `QLA2XXX_INI_MODE_DISABLED` = 1 - `QLA2XXX_INI_MODE_ENABLED` = 2 (standard initiator mode) - `QLA2XXX_INI_MODE_DUAL` = 3
**Root cause:** The code only checks for `QLA2XXX_INI_MODE_ENABLED` (value 2). When `qlini_mode=exclusive` is used, `ql2x_ini_mode` equals `QLA2XXX_INI_MODE_EXCLUSIVE` (value 0), so `startit` remains `false`. Queue pairs are never started for initiator traffic, causing SCSI commands to fail.
**The fix:** ```c bool startit = !!(host->active_mode & MODE_INITIATOR); ```
This uses the runtime `active_mode` flag which is already correctly set for all initiator modes elsewhere in the driver (see `qla_target.c:6493,6511,6515` - all set `active_mode = MODE_INITIATOR` for various initiator modes including "exclusive").
### 3. Classification
- **Type:** Bug fix (not a new feature) - **Severity:** HIGH - causes complete failure of SCSI command processing - **Category:** Logic error in mode detection
### 4. Scope and Risk Assessment
| Factor | Assessment | |--------|------------| | Lines changed | -8 removed, +1 added (net simplification) | | Files touched | 1 (qla_os.c) | | Complexity | LOW - replaces complex logic with simple check | | Risk of regression | VERY LOW - uses existing tested pattern |
### 5. User Impact
- **Who is affected:** Users of QLogic Fibre Channel HBAs (QLA2xxx) with `qlini_mode=exclusive` - **Severity:** Complete functional failure - SCSI commands fail, adapter resets repeatedly - **Impact area:** Enterprise storage - FC HBAs are common in data centers
### 6. Stability Indicators
- Signed-off by the SCSI maintainer (Martin K. Petersen) - Uses `host->active_mode` pattern already proven throughout the driver - The fix simplifies the code, reducing bug surface area
### 7. Dependency Check
- The `host->active_mode` field exists in all stable kernels (it's part of `struct Scsi_Host` in `include/scsi/scsi_host.h`) - The `MODE_INITIATOR` constant (0x01) is standard - No dependencies on other commits
---
## Conclusion
This commit should be backported to stable kernels because:
1. **Fixes a real, serious bug:** Users with `qlini_mode=exclusive` experience complete storage failure with escalating resets 2. **Obviously correct:** The fix uses the authoritative runtime mode (`host->active_mode`) instead of trying to derive it from module parameters 3. **Small and surgical:** Removes 8 lines of incorrect logic, adds 1 correct line 4. **Low risk:** Uses existing, well-tested infrastructure that's already used throughout the driver 5. **No new features:** Pure bug fix that restores intended functionality 6. **Important hardware:** QLogic FC HBAs are widely deployed in enterprise environments
The lack of explicit `Cc: stable@` tag is not disqualifying when the fix clearly meets all stable kernel criteria.
**YES**
drivers/scsi/qla2xxx/qla_os.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 5ffd945866527..70c7143ce026c 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3444,13 +3444,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->mqenable = 0;
if (ha->mqenable) { - bool startit = false; - - if (QLA_TGT_MODE_ENABLED()) - startit = false; - - if (ql2x_ini_mode == QLA2XXX_INI_MODE_ENABLED) - startit = true; + bool startit = !!(host->active_mode & MODE_INITIATOR);
/* Create start of day qpairs for Block MQ */ for (i = 0; i < ha->max_qpairs; i++)