Bug 16450

Summary: MTD drivers cannot be unloaded
Product: Drivers Reporter: Ben Hutchings (bhutchings)
Component: Flash/Memory Technology DevicesAssignee: David Woodhouse (dwmw2)
Status: CLOSED INVALID    
Severity: normal CC: akpm, earlmercado, maciej.rutecki, maximlevitsky, rjw
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.35-rc5 Tree: Mainline
Regression: Yes
Bug Depends on:    
Bug Blocks: 16055    

Description Ben Hutchings 2010-07-24 00:17:16 UTC
commit 048d87199566663e4edc4880df3703c04bcf41d9 "mtd: blktrans: Hotplug
fixes" causes the MTD and the MTD driver module's ref-counts to be
bumped for each block device that is created, whether or not it's
actually in use.

This means that before removing an MTD or driver module one must first
remove all the associated block devices.  But the block devices will
be removed only when the MTDs themselves are removed, which is no
longer possible.

I have submitted a fix for this: http://article.gmane.org/gmane.linux.drivers.mtd/30834
Comment 1 Andrew Morton 2010-07-24 01:53:05 UTC
Maxim, 048d87199566663e4edc4880df3703c04bcf41d9 was yours..
Comment 2 Maxim Levitsky 2010-07-24 13:15:13 UTC
Yes, I am aware of this problem.

It has to be done that way, because otherwise I had an impossible to solve deadlock.

The blktrans_open() doesn't use locks on purpose, this is a part of the fix of the deadlock.

I explain that better tommorow, when I finish last exam.
Comment 3 Ben Hutchings 2010-08-01 16:40:05 UTC
The parent devices of the MTDs can still be removed, and once that has been done it is possible to remove a MTD driver module. So although there is a regression here it is not as serious as I thought.