Skip to contentSkip to conversation

Hot unplugging a device in the middle of a read

DISCUSSION Adrian McMenamin 1 participant 3 messages Jan 12, 2009 – Jan 14, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

I am working on a map driver for the virtual memory unit (VMU) flash on the SEGA Dreamcast. I have a specifc concurrency issue which maybe somebody here could help with.

The VMUs are pluggable devices - users can just push them in and pull them out when they like.

It would be a perverse way to behave but it does mean users can whack the thing in and pull it out straight away.

With the block translation layer turned on this results in a crash - how do I tell the mtd/translation/block layer that the device has gone?

(The ouput below has some additional debug messages I have added)

[  184.105630] mtdblock: read on "vmu1.1.0" at 0x7400, size 0x200
[  184.122698] mtdblock: read on "vmu1.1.0" at 0x7600, size 0x200
[  184.139001] mtdblock: read on "vmu1.1.0" at 0x7800, size 0x200
[  184.156062] mtdblock: read on "vmu1.1.0" at 0x7a00, size 0x200
[  184.172359] mtdblock: read on "vmu1.1.0" at 0x7c00, size 0x200
[  184.189424] mtdblock: read on "vmu1.1.0" at 0x7e00, size 0x200
[  184.206051] mtdblock: read on "vmu1.1.0" at 0x8000, size 0x200
[  184.222790] mtdblock: read on "vmu1.1.0" at 0x8200, size 0x200
[  184.239093] mtdblock: read on "vmu1.1.0" at 0x8400, size 0x200
[  184.256158] mtdblock: read on "vmu1.1.0" at 0x8600, size 0x200
[  184.268478] Maple bus device detaching at (1, 1) busy is 1
[  184.275221] In vmu_disconnect
[  184.277538] Removing MTD device #0 (vmu1.1.0) with use count 1
[  184.302421] releasing device at (1, 1) and address 0x8C8B1980 with
queue at 0x8C5C8180
[  185.570107] end_request: I/O error, dev mtdblock0, sector 64
[  185.575136] Buffer I/O error on device mtdblock0, logical block 8
[  185.584332] Unable to handle kernel paging request at virtual
address 6b6b6b6b
[  185.590955] pc = 8c1511e8
[  185.593649] *pde = 00000000
[  185.596531] Oops: 0000 [#1]
[  185.599395] Modules linked in:
[  185.602626]
[  185.604072] Pid : 824, Comm:                 mtdblockd
[  185.608210] CPU : 0                  Not tainted
(2.6.28-06142-ga079e18-dirty #188)
[  185.608240]
[  185.617027] PC is at strnlen+0x8/0x60
[  185.620791] PR is at string+0x2e/0xc0
#1 lore raw

2009/1/12 Adrian McMenamin <[email protected]>:

Quoted 3 lines

I am working on a map driver for the virtual memory unit (VMU) flash

[  184.277538] Removing MTD device #0 (vmu1.1.0) with use count 1

Having looked through the sources I can see that this is indicating there is an additional user in play - because when I pull the VMU out when not in the middle of the initial reads I don't get this message (as use count is obviously 0) even though the code path is the same.

Can I just put in an extra 'put'? Or is there some other way of doing this?

#2 lore raw

2009/1/13 Adrian McMenamin <[email protected]>:

Quoted 12 lines

2009/1/12 Adrian McMenamin <[email protected]>:

Quoted 3 lines

I am working on a map driver for the virtual memory unit (VMU) flash

[  184.277538] Removing MTD device #0 (vmu1.1.0) with use count 1

Having looked through the sources I can see that this is indicating there is an additional user in play - because when I pull the VMU out when not in the middle of the initial reads I don't get this message (as use count is obviously 0) even though the code path is the same.

Can I just put in an extra 'put'? Or is there some other way of doing this?

For the sake of completeness for those searching on google - I wrote a function that checks if the usecount > 0, if it is, then I just have to live with the block read errors but I don't crash the system because I don't delete the mtd_info