Skip to content

blk: Fix duplicate partition devices after re-probing a block device

Frieder Schrempf u-boot 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20261027-blk-part-unbind-e6ba8f1ac8ca

Versions newest first

  1. v2 Latest2 patches 3 repliesIn review
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Drop the redundant device_chld_remove() call in blk_pre_remove(). Since commit 3632b5d63c8 ("dm: Remove children when parent is removed by
flags") the partition devices are always inactive at this point. (thanks Simon)
- Fix the comment and commit message of patch 1 accordingly.
- Fix the test comment and commit message of patch 2 to describe what the DM_REMOVE_ACTIVE_ALL case actually tests. (thanks Simon)
- Link to v1: https://patch.msgid.link/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2blk: Unbind partition devices when removing a block devicedrivers/block/blk-uclass.c+13 -01 reply
2/2test: blk: Check that partition devices are unbound on removetest/dm/blk.c+65 -01 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchSimon Glass
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] blk: Fix duplicate partition devices after re-probing a block device

The partition devices that blk_post_probe() binds for a block device are not unbound when the block device is removed. When it is probed again, a second set of partition devices is bound, and the EFI disk code fails to add the stale ones:

Adding partition for [email protected]:1 failed
switch to partitions #0, ERROR

This was seen on an i.MX93 board where a single failed read during the first probe of the SD card made the card unusable for the rest of the boot.

Patch 1 unbinds the partition devices in the pre_remove hook of the block uclass. Patch 2 adds a sandbox test for it.

---
Changes in v2:
- Drop the redundant device_chld_remove() call in blk_pre_remove(). Since commit 3632b5d63c8 ("dm: Remove children when parent is removed by
flags") the partition devices are always inactive at this point. (thanks Simon)
- Fix the comment and commit message of patch 1 accordingly.
- Fix the test comment and commit message of patch 2 to describe what the DM_REMOVE_ACTIVE_ALL case actually tests. (thanks Simon)
- Link to v1: https://patch.msgid.link/[email protected]

---
Frieder Schrempf (2):
blk: Unbind partition devices when removing a block device
test: blk: Check that partition devices are unbound on remove

 drivers/block/blk-uclass.c | 13 ++++++++++
 test/dm/blk.c              | 65 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)

---
base-commit: dfcfc4c9f78d1743f490a497082a4ec8e058aae8
change-id: 20261027-blk-part-unbind-e6ba8f1ac8ca

Best regards,

Signature · 1 line
Frieder Schrempf <[email protected]>