Page MenuHomeFreeBSD

rtsx: refine locking in rtsx_card_task()
Needs ReviewPublic

Authored by mhorne on Feb 4 2025, 8:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 5, 2:34 PM
Unknown Object (File)
Tue, Mar 4, 9:30 PM
Unknown Object (File)
Thu, Feb 27, 2:15 PM
Unknown Object (File)
Thu, Feb 13, 2:34 AM
Unknown Object (File)
Tue, Feb 11, 9:55 PM
Unknown Object (File)
Tue, Feb 11, 8:19 PM
Unknown Object (File)
Tue, Feb 11, 8:04 PM
Unknown Object (File)
Mon, Feb 10, 10:33 PM
Subscribers
None

Details

Summary

It is invalid to call device_add_child() while holding the driver's
mutex. This was previously of no consequence, but a recent change
to device array allocation (f3d3c63442ff) switched the logic to use
M_WAITOK. Now, a LOR warning is printed when the card is inserted.

Fix this by reducing the scope of the device lock in the helper function
to:

  1. Reading device state (card & child device presence)
  2. Updating device state (after child added/before removed)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 62260
Build 59144: arc lint + arc unit

Event Timeline

mhorne requested review of this revision.Feb 4 2025, 8:25 PM
mhorne created this revision.

You split the rtsx_card_task() function between MMCCAM and not MMCCAM before introducing your update of the use of device lock.

The update seems OK for me but:

  • In the non MMCCAM version you are protecting some updates of the sc struct that are not protected in the MMCCAM, is it really needed? if so it must be updated in the MMCCAM version to be coherent. BTW I am not really knowledgeable with those locking; I shamelessly copy them from other implementations.
  • The split of rtsx_card_task() is not already in current, so I don't understand on which version your update are applied.

You split the rtsx_card_task() function between MMCCAM and not MMCCAM before introducing your update of the use of device lock.

Right, I intended to add you as a reviewer to the split, but I missed it. See D48847.

The update seems OK for me but:

  • In the non MMCCAM version you are protecting some updates of the sc struct that are not protected in the MMCCAM, is it really needed? if so it must be updated in the MMCCAM version to be coherent. BTW I am not really knowledgeable with those locking; I shamelessly copy them from other implementations.

Hmm, yes, I think the rtsx_flags field should be protected by the lock in the MMCCAM version. I will update this review soon.

  • The split of rtsx_card_task() is not already in current, so I don't understand on which version your update are applied.

Hmm, yes, I think the rtsx_flags field should be protected by the lock in the MMCCAM version. I will update this review soon.

For my personal information:

To be honest, I don't understand in which runtime scenario rtsx_flags must be protected.