Skip to content

hi3519dv500: bsp-sfc: do not use quad - #172

Merged
dimerr merged 1 commit into
hisilicon-hi3519dv500from
hi3519dv500/no-quad
Nov 6, 2026
Merged

dimerr merged 1 commit into
hisilicon-hi3519dv500from
hi3519dv500/no-quad

Conversation

@dimerr

@dimerr dimerr commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Same change as #171, for hi3519dv500.

Change

Quad gives more problems than benefits on these cameras. The OpenIPC config leaves CLOSE_SPI_8PIN_4IO unset, so bsp-sfc offers quad here. This removes the quad modes at probe and at resume. spi_nor_quad_enable() then returns early, so SR is not written for it.

CLOSE_SPI_8PIN_4IO no longer has any effect on this branch.

Testing

Build-tested only: drivers/mtd/spi-nor with the hi3519dv500 config from OpenIPC/firmware. Please check on hardware:

  • A board boots and a whole-partition read gives a stable md5sum without quad.
  • A Winbond or GigaDevice board still boots. With no quad in hwcaps, spi_nor_dtrclear_pinreset() now reaches spi_nor_sr3_to_reset() there. It writes SR3 with no WREN first, so it should do nothing with WEL clear.

Quad gives more problems than benefits on these cameras, and this is the
same bsp-sfc code that hi3516cv6xx dropped quad from: the OpenIPC config
leaves CLOSE_SPI_8PIN_4IO unset, so quad is on. Take the quad modes out
of bsp-sfc, at probe and at resume. spi_nor_quad_enable() then returns
early and SR is not written for it.

CLOSE_SPI_8PIN_4IO no longer has any effect here.

With no quad in hwcaps, spi_nor_dtrclear_pinreset() now reaches
spi_nor_sr3_to_reset() on Winbond and GigaDevice parts. That writes SR3
with no WREN before it, so it should do nothing with WEL clear.

Build-tested only: drivers/mtd/spi-nor with the hi3519dv500 config from
OpenIPC/firmware.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

hi3519dv500: Disable BSP SFC quad modes at probe and resume

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Remove quad read and program capabilities from BSP SFC probe and resume to avoid unreliable camera
 operation.
• Keep quad-enable status-register writes from running when a non-quad protocol is selected.
• Hardware validation remains needed, particularly for Winbond and GigaDevice reset-pin handling.
Diagram

graph TD
  Probe["Device probe"] --> Caps["Non-quad capabilities"] --> Setup["Protocol setup"] --> Protocol["Single/dual protocol"] --> Quad["Quad enable skipped"]
  Resume["Device resume"] --> Caps
  Caps --> Reset["Reset-pin handling"]
Loading
High-Level Assessment

Removing quad from the controller capabilities at both entry points is the direct way to prevent its selection regardless of CLOSE_SPI_8PIN_4IO. Changing flash-specific parameters instead would not express this controller-level restriction as clearly. Validate whole-partition reads and Winbond/GigaDevice boot behavior on hardware before merging.

Files changed (2) +0 / -14

Bug fix (2) +0 / -14
bsp-sfc.cStop advertising quad modes during BSP SFC probe +0/-7

Stop advertising quad modes during BSP SFC probe

• Removes the conditional addition of quad read and page-program capabilities before SPI NOR scanning. The configuration option no longer controls quad capability advertisement at this entry point.

drivers/mtd/spi-nor/controllers/bsp-sfc.c

core.cKeep quad modes disabled during BSP SFC resume +0/-7

Keep quad modes disabled during BSP SFC resume

• Removes the corresponding conditional quad capabilities from the resume path, so protocol setup does not reselect quad after suspend. Without quad read capabilities, the existing manufacturer-specific reset-pin path can run for Winbond and GigaDevice parts.

drivers/mtd/spi-nor/core.c

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Reset pins stay disabled on some flashes 🐞 Bug ≡ Correctness
Description
spi_nor_sr3_to_reset() sends the status-register write without first enabling writes, then checks
the preceding read result instead of the write result. When a Winbond or GigaDevice flash has its
reset-enable bit clear and its write-enable latch clear, the newly reached path at probe and resume
reports success while leaving that bit unchanged.
Code

drivers/mtd/spi-nor/controllers/bsp-sfc.c[L589-592]

-	hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4 |
-		       SNOR_HWCAPS_READ_1_4_4 |
-		       SNOR_HWCAPS_PP_1_1_4 |
-		       SNOR_HWCAPS_PP_1_4_4;
Evidence
The removed probe capabilities and matching resume mask cause the no-quad condition to enter the
reset helper. That helper dispatches Winbond and GigaDevice flashes to an SR3 writer that neither
sends write-enable nor captures the write return; the existing status-register write routine
demonstrates the required write-enable sequence.

drivers/mtd/spi-nor/controllers/bsp-sfc.c[527-542]
drivers/mtd/spi-nor/core.c[3410-3444]
drivers/mtd/spi-nor/core.c[2369-2405]
drivers/mtd/spi-nor/core.c[2456-2463]
drivers/mtd/spi-nor/core.c[724-740]
drivers/mtd/spi-nor/core.c[3644-3649]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Removing quad capabilities makes probe and resume enter the reset-pin helper on Winbond and GigaDevice flashes. Its status-register write lacks write-enable and its result is discarded, so it can report success without enabling the reset pin.
## Fix Focus Areas
- drivers/mtd/spi-nor/core.c[2369-2395]
- drivers/mtd/spi-nor/core.c[2456-2463]
- drivers/mtd/spi-nor/core.c[3439-3444]
- drivers/mtd/spi-nor/core.c[3644-3649]
## Recommended Fix
If enabling RESET# is required, issue write-enable before the SR3 write, propagate the write result, wait for completion, and verify the bit. If this change must not touch SR3, avoid entering the reset-pin helper rather than treating an ineffective write as success.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@dimerr
dimerr merged commit 2dbe57f into hisilicon-hi3519dv500 Nov 6, 2026
@dimerr
dimerr deleted the hi3519dv500/no-quad branch November 6, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant