Repository navigation
hisilicon: SD cards come up writable -- invert SDHCI write-protect where the kernel driver does - #210
Merged
Merged
Conversation
…ere the kernel driver does
Every card attached with -drive if=sd to a hi3516ev200/ev300, hi3518ev300,
hi3516dv200 or Goke V4/V500/xmorca machine was registered by the guest as
write-protected ("mmcblk0: ... QEMU! 64.0 MiB (ro)"), so every mount came
out read-only. The guest tests that use the card only read from it, so
none of them noticed.
QEMU's generic-sdhci sets PRNSTS bit 19 for a writable card, as the SDHCI
spec has it. The vendor drivers these kernels bind read the pin the other
way round, each through SDHCI_QUIRK_INVERTED_WRITE_PROTECT in its
sdhci_pltfm_data:
hisilicon-hi3516ev200 drivers/mmc/host/sdhci-hisi.c
goke-gk7205v200 drivers/mmc/host/sdhci-goke.c
goke-gk7205v500 drivers/mmc/host/sdhci-xmedia-common.c
goke-gk7206v100 lotus/drivers/mmc/host/sdhci-lotus-common.c
The nebula driver behind hi3516cv608/cv610/cv613 and hi3519dv500/
hi3516dv500 (drivers/vendor/mmc in the hisilicon-hi3516cv6xx and
-hi3519dv500 kernels) sets no such quirk and has no get_ro, so it takes
the spec polarity, which QEMU already gives it. That rules out flipping
the property for every machine, so HisiSoCConfig gains sdhci_wp_inverted.
It is set in the four EV200-family entries and in HISI_V4_COMMON_PERIPH,
which every Goke machine on this path includes (GK7206_XMORCA_PERIPH
through it). goke.c already does the same for the GK710x SDIO.
qemu/tests/test-hisi-sdhci-wp.sh reads PRNSTS with a writable card in
slot 0 on one machine per driver: bit 19 clear on the eight inverted
machines, set on cv610 and dv500. Against master, the eight fail and the
two nebula controls pass. It runs in the CI build job. A read-only card
can't be tested: QEMU refuses a read-only drive as an SD card.
Booted from NOR with the OpenIPC lite releases in qemu-boot/, a FAT32
card now registers without "(ro)" and automount mounts it rw on
hi3516ev300 and gk7205v200. The gk7205v500 release boots to login but
probes no SD host at all, with or without this change, so its polarity
is covered by the register test only.
Fixes #209.
PR Summary by QodoMatch HiSilicon and Goke SDHCI write-protect polarity to guest drivers
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #209: on the HiSilicon / Goke machines whose kernel inverts the SDHCI write-protect pin, every
-drive if=sdcard came up read-only in the guest.What changed
HisiSoCConfig.sdhci_wp_inverted. When it's set, the SDHCI loop setswp-invertedongeneric-sdhci.It's set where the kernel driver carries
SDHCI_QUIRK_INVERTED_WRITE_PROTECT:hisilicon-hi3516ev200sdhci-hisi.cHISI_V4_COMMON_PERIPH)goke-gk7205v200sdhci-goke.cgoke-gk7205v500sdhci-xmedia-common.cGK7206_XMORCA_PERIPH, via the macro)goke-gk7206v100lotus/.../sdhci-lotus-common.cIt's left unset on hi3516cv608/cv610/cv613 and hi3519dv500/hi3516dv500. Their nebula driver (
drivers/vendor/mmc) uses the spec polarity, which QEMU already gives it.New
qemu/tests/test-hisi-sdhci-wp.sh, run in the CI build job and listed in CLAUDE.md.Evidence
bash qemu/tests/test-hisi-sdhci-wp.sh: master gives2 passed, 8 failed(every inverted machine reads PRNSTS0x01ff0000, WP bit 1). This branch gives10 passed, 0 failed(inverted machines0x01f70000; nebula controls unchanged at0x01ff0000).Booted from synthetic NOR (the
test-flash-rw.shlayout) with the OpenIPC lite releases inqemu-boot/and a FAT32 card:mmcblk0: mmc0:3244 QEMU! 64.0 MiB (ro)→vfat rommcblk0: mmc0:7438 QEMU! 64.0 MiB→vfat rwmmcblk0: mmc0:6b5f QEMU! 64.0 MiB→vfat rwNot covered
CONFIG_MMC_SDHCI_XMEDIA=yand nothing binds). For that machine the polarity is covered only by the register test. The missing probe is a separate gap.