2008-07-31 11:53:48 Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 59702
I have the mmc/sd driver built as a module. I can load them fine (insmod spi_mmc, mmc_core, mmc_block), mount the SD card, access it, etc. All good. The problem arises when I attempt to unload them. The system faults when unloading the last one: spi_mmc
root:/> umount /mnt/sdp1
root:/> rmdir /mnt/sdp1
root:/> rmmod mmc_block
root:/> rmmod mmc_core
root:/> rmmod spi_mmc
WARNING: at lib/kref.c:33 kref_get()
Hardware Trace:
0 Target : <0x0000479c> { _dump_stack + 0x0 }
Source : <0x000852a4> { _kref_get + 0x54 }
1 Target : <0x000852a4> { _kref_get + 0x54 }
Source : <0x0000dd5a> { _printk + 0x16 }
2 Target : <0x0000dd56> { _printk + 0x12 }
Source : <0x0000dc0c> { _vprintk + 0x1b8 }
3 Target : <0x0000dc00> { _vprintk + 0x1ac }
Source : <0xffa00cf0> { __common_int_entry + 0xd8 }
4 Target : <0xffa00c8e> { __common_int_entry + 0x76 }
Source : <0xffa00ac0> { _return_from_int + 0x58 }
5 Target : <0xffa00ac0> { _return_from_int + 0x58 }
Source : <0xffa00a96> { _return_from_int + 0x2e }
6 Target : <0xffa00a68> { _return_from_int + 0x0 }
Source : <0xffa00c8a> { __common_int_entry + 0x72 }
7 Target : <0xffa00c88> { __common_int_entry + 0x70 }
Source : <0xffa003ec> { _asm_do_IRQ + 0x68 }
8 Target : <0xffa003e4> { _asm_do_IRQ + 0x60 }
Source : <0x00011e92> { __local_bh_enable + 0x3e }
9 Target : <0x00011e54> { __local_bh_enable + 0x0 }
Source : <0x00011f9c> { ___do_softirq + 0x94 }
10 Target : <0x00011f94> { ___do_softirq + 0x8c }
Source : <0x00011f74> { ___do_softirq + 0x6c }
11 Target : <0x00011f68> { ___do_softirq + 0x60 }
Source : <0x0001207c> { _tasklet_action + 0x7c }
12 Target : <0x00012076> { _tasklet_action + 0x76 }
Source : <0x00012052> { _tasklet_action + 0x52 }
13 Target : <0x00012050> { _tasklet_action + 0x50 }
Source : <0x0001bb72> { ___rcu_process_callbacks + 0xb6 }
14 Target : <0x0001bb6c> { ___rcu_process_callbacks + 0xb0 }
Source : <0x0001bb02> { ___rcu_process_callbacks + 0x46 }
15 Target : <0x0001bafe> { ___rcu_process_callbacks + 0x42 }
Source : <0x0001bb9a> { ___rcu_process_callbacks + 0xde }
Stack from 003abe08:
0002e36a 000852a8 037d2d74 037d2d5c 00000000 00136f18 00000021 0010bfd4
000846f6 037d2ee0 0000006a 00000044 00000003 00099caa 037d2d54 000240d0
007b6060 0071cbe0 00099cc2 00000073 0002e576 00001000 00099094 00099c1c
00000000 00000073 00034572 00001000 037d1096 037d2ee0 00156578 00000081
03799bd8 00000001 00000000 00027052 002eba90 0023fb20 00001fff 003abea0
5f697073 00636d6d 00000000 00000000 00000000 00000000 00000000 00000000
I'm running 2008R1 on a BF537-STAMP.
Any idea what I'm doing wrong? Thanks!
QuoteReplyEditDelete
2008-08-01 10:32:30 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 59757
I will try to reproduce it when I get access to the SPI-MMC hardware.
But I think the warning happens when some race condition happens. When kref_get() is called (someone want to take the resource), but the reference count has become 0 (which means the resource is no longer exist or is being destroyed).
-Yi
QuoteReplyEditDelete
2008-08-01 11:51:28 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 59759
It's easy to reproduce (for me anyway) even without any MMC hardware. On a plain BF537-STAMP board (without the SD daughtercard) simply do this:
root:/> cd `find / -name mmc`
root:/lib/modules/2.6.22.19-ADI-2008R1.5-svn5088/kernel/drivers/mmc> insmod spi_mmc/spi_mmc.ko
mmc_pio_spi:cs_#: 0x4, baud=0x0, flag=0xff00, ctrl=0x400
root:/lib/modules/2.6.22.19-ADI-2008R1.5-svn5088/kernel/drivers/mmc> rmmod spi_mmc
WARNING: at lib/kref.c:33 kref_get()
Hardware Trace:
0 Target : <0x0000479c> { _dump_stack + 0x0 }
Source : <0x000852a4> { _kref_get + 0x54 }
1 Target : <0x000852a4> { _kref_get + 0x54 }
Source : <0x0000dd5a> { _printk + 0x16 }
2 Target : <0x0000dd56> { _printk + 0x12 }
Source : <0x0000dc0c> { _vprintk + 0x1b8 }
3 Target : <0x0000dc00> { _vprintk + 0x1ac }
<snip>
Seems that all I need to do is load the spi_mmc.ko file, then even without using it, attempting to unload it causes this fault.
QuoteReplyEditDelete
2008-08-05 02:19:09 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 59898
you shouldnt have to remove the other drivers, just spi_mmc ... that is the only one that utilizes the SPI bus
however, i just tried trunk over here and could not replicate the issue:
root:/> modprobe spi_mmc
mmc_pio_spi:cs_#: 0xa, baud=0x0, flag=0xff00, ctrl=0x400
root:/> fdisk -l /dev/spi_mmc
New MMC/SD card found: 29 MB(31326208 bytes)
spi_mmc: spi_mmc1
Disk /dev/spi_mmc: 31 MB, 31326208 bytes
4 heads, 32 sectors/track, 478 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Device Boot Start End Blocks Id System
/dev/spi_mmc1 1 478 30566+ 4 FAT16 <32M
root:/> mount -t vfat /dev/spi_mmc1 /mnt/
root:/> ls /mnt/
apps n64roms readme.txt wiiload
boot.elf private scummvm
root:/> ls /mnt/*
/mnt/boot.elf /mnt/readme.txt
/mnt/apps:
gc-linux regionfree scummvm tetris wii64
/mnt/n64roms:
fcube.v64
/mnt/private:
wii
/mnt/scummvm:
demos kyra.dat m4.dat modern.zip scummvm.ini
igor.tbl lure.dat modern.ini queen.tbl sky.cpt
/mnt/wiiload:
lin32 osx wiiload.tar.gz win32
root:/> md5sum /mnt/readme.txt
0e87752d5885bda0fa95145130a9e3ca /mnt/readme.txt
root:/> umount /mnt
root:/> rmmod spi_mmc
root:/>
QuoteReplyEditDelete
2008-08-05 06:10:04 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 59930
I cannot reproduce your problem either. Could you update your kernel to latest svn branch and try again?
QuoteReplyEditDelete
2008-08-05 06:20:18 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 59933
I tried on latest 2008R1 SVN branch:
root:/> version
kernel: Linux release 2.6.22.19-ADI-2008R1.5-svn5102, build #15 Tue Aug 5 18:06:59 CST 2008
toolchain: bfin-linux-uclibc-gcc release gcc version 4.1.2 (ADI svn)
user-dist: release svn-6972, build #5 Tue Aug 5 18:06:32 CST 2008
If this problem still exist when you use latest branch, you could post you kernel config file here. BTW, many people use "modprobe" instread of "insmod/rmmod" to load/unload kernel module.
-Yi
QuoteReplyEditDelete
2008-08-05 12:54:40 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 59953
Hi Yi & Mike,
Many thanks for trying to replicate my problem. I've updated to the latest branch; I also tried modprobe instead of insmod/rmmod; it still faults. I've attached the .config file from the linux-2.6.x directory (file renamed to config_fvh)
root:/lib/modules/2.6.22.19-ADI-2008R1.5-svn5102/kernel/drivers/mmc/spi_mmc> version
kernel: Linux release 2.6.22.19-ADI-2008R1.5-svn5102, build #2194 Tue Aug 5 09:24:58 PDT 2008
toolchain: bfin-linux-uclibc-gcc release gcc version 4.1.2 (ADI svn)
user-dist: release svn-6972, build #477 Tue Aug 5 09:24:11 PDT 2008
root:/lib/modules/2.6.22.19-ADI-2008R1.5-svn5102/kernel/drivers/mmc/spi_mmc> modprobe spi_mmc
mmc_pio_spi:cs_#: 0x4, baud=0x0, flag=0xff00, ctrl=0x400
root:/lib/modules/2.6.22.19-ADI-2008R1.5-svn5102/kernel/drivers/mmc/spi_mmc> lsmod
Module Size Used by
spi_mmc 12668 0
root:/lib/modules/2.6.22.19-ADI-2008R1.5-svn5102/kernel/drivers/mmc/spi_mmc> modprobe -r spi_mmc
WARNING: at lib/kref.c:33 kref_get()
Hardware Trace:
0 Target : <0x0000479c> { _dump_stack + 0x0 }
Source : <0x000852a4> { _kref_get + 0x54 }
1 Target : <0x000852a4> { _kref_get + 0x54 }
Source : <0x0000dd5a> { _printk + 0x16 }
2 Target : <0x0000dd56> { _printk + 0x12 }
Source : <0x0000dc0c> { _vprintk + 0x1b8 }
<snip>
config_fvh
QuoteReplyEditDelete
2008-08-05 22:46:21 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 59960
if you just do `modprobe spi_mmc` and `rmmod spi_mmc`, does it fail ? or does it only fail if you use `modprobe -r spi_mmc` (which should remove those other mmc modules as well) ?
QuoteReplyEditDelete
2008-08-06 00:37:56 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 59968
It fails in every removal combination I've tried. It fails using rmmod, and it fails using modprobe -r. Specifically, I've tried the 4 combinations of (load & remove):
insmod & rmmod
modprobe & rmmod
insmod & modprobe -r
modprobe & modprobe -r
QuoteReplyEditDelete
2008-08-07 05:34:10 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 60092
I think I can reproduce this issue now, using your kernel configure. But I am still looking for the cause.
-Yi
QuoteReplyEditDelete
2008-08-07 10:21:08 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60104
Thanks very much Yi.
QuoteReplyEditDelete
2008-08-08 00:34:59 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 60131
The cause is that, in your configuration the SPI framework is enabled.
"
#
# SPI support
#
CONFIG_SPI=y
CONFIG_SPI_MASTER=y
"
You can disable it and try again. I also check a small fix into 2008r1 branch, to make the spi_mmc driver unable to use SPI PIO mode when SPI_MASTER is enabled.
QuoteReplyEditDelete
2008-08-08 03:18:08 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60140
Yi, you seem to have fixed one thing with your change, but it's broken something else.
:-)
The reason you're seeing the SPI Framework "enabled" in .config is because I have it set to build as a module. This is the Device Drivers -> SPI Support screen from menuconfig:
│ │ [*] SPI support │ │
│ │ --- SPI Master Controller Drivers │ │
│ │ <M> SPI controller driver for ADI Blackfin5xx │ │
│ │ < > Bitbanging SPI master │ │
│ │ --- SPI Protocol Masters │ │
│ │ < > SPI EEPROMs from most vendors │ │
│ │ < > User mode SPI device driver support
I just grabbed your new file & tried it, with the SPI framework still set to build as a module, and I confirmed that the .config file still shows SPI Support enabled (the exact same as in your post above). However, now I can indeed load & unload the spi_mmc module, which I couldn't do before. That's good news.
This is what I see in the .config file. Please note that I'm trying to build both the SPI Framework & the MMC/SD driver as modules.
#
# SPI support
#
CONFIG_SPI=y
CONFIG_SPI_MASTER=y
#
# SPI Master Controller Drivers
#
CONFIG_SPI_BFIN=m
# CONFIG_SPI_BITBANG is not set
#
# MMC/SD Card Drivers
#
CONFIG_MMC_BLOCK=m
#
# MMC/SD Host Controller Drivers
#
CONFIG_SPI_MMC=m
CONFIG_SPI_MMC_FRAMEWORK_DRIVER=y
# CONFIG_SPI_MMC_BFIN_PIO_SPI is not set
CONFIG_SPI_MMC_CS_CHAN=4
CONFIG_SPI_MMC_MAX_HZ=20000000
# CONFIG_SPI_MMC_CARD_DETECT is not set
# CONFIG_SPI_MMC_DEBUG_MODE is not set
Does this all make sense to you when building both of these drivers as modules?
You can see that now the MMC/SD driver is forced to use the SPI Framework driver, even though (a) the framework driver is configured to build as a module, and (b) the MMC/SD driver doesn't actually even work with the SPI framework driver.
The SD/MMC driver works fine if the SPI Framework is disabled in menuconfig.
(When doing "insmod spi_mmc.ko", when it works /dev/spi_mmc is created; when it doesn't work /dev/spi_mmc is not created.)
So it appears that at the moment it's not possible to build both the SPI Framework, and the MMC/SD driver, as modules at the same time. Because having the SPI Framework set to build as a module effectively causes the SD/MMC driver to break, due to forcing it to use the SPI Framework driver.
QuoteReplyEditDelete
2008-08-08 04:13:43 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 60142
Frank,
I think after the fix I checked in (quoted bellow to avoid confusion), the spi_mmc driver can be used in two ways:
1. Use SPI bus directly. In this case, the SPI framework (managing that SPI bus) should be disabled.
2. Use SPI framework.
--- branches/2008R1/drivers/mmc/spi_mmc/Kconfig 2008-08-07 14:59:20 UTC (rev 5121)
+++ branches/2008R1/drivers/mmc/spi_mmc/Kconfig 2008-08-08 03:28:34 UTC (rev 5122)
@@ -23,13 +23,13 @@
config SPI_MMC_FRAMEWORK_DRIVER
bool "SPI framework master"
- depends on SPI
+ depends on SPI_MASTER
help
Will use the SPI master of the system. This option is platform indepenent.
config SPI_MMC_BFIN_PIO_SPI
bool "Blackfin SPI bus directly"
- depends on BLACKFIN
+ depends on BLACKFIN && !SPI_MASTER
help
Will use Blackfin SPI bus directly. No other SPI device should be used with this option.
The MMC/SD card will be driven in SPI PIO mode. This is a failsafe option for testing.
In the case of using SPI framework, when you build the bfin spi master controller as module ("CONFIG_SPI_BFIN=m"), you will need to install that module together with spi_mmc driver:
root:/> modprobe spi_mmc
root:/> modprobe spi_bfin5xx
spi_mmc: configure for card detection
New MMC/SD card found: 495 MB(519569408 bytes)
spi_mmc: spi_mmc1 spi_mmc2
bfin-spi bfin-spi.0: Blackfin BF5xx on-chip SPI Contoller Driver, Version 1.0, regs_base@ffc00500, dma channel@7
As you can see, the spi_bfin5xx is not the only master driver available , there is also "SPI Bitbanging master" (I've never test it and not sure whether it works or not).
However, my above fix is not good enough. In the case of BF548, there are two SPI buses, so it should be possible to allow SPI framework managing on bus, but some other device (like spi_mmc) uses another bus.
Please also note that: people have reported (please search previouse forum post) that, when using spi framework, spi_mmc driver cannot work well when there are other spi devices using the spi framework (on the same bus). So when you are using spi_mmc driver, please set it using SPI bus directly.
-Yi
QuoteReplyEditDelete
2008-08-08 12:23:16 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60181
I guess I'm getting confused.
I thought that one of the reasons for building drivers as modules, was to allow two separate drivers for the same physical device to be built, and then the actual driver to be used could be selected/loaded at runtime.
Am I wrong in this understanding?
Because... What you're saying is that as a result of the Kconfig change, even if I build the SPI Framework driver as a module, I can no longer build the MMC/SD driver as a module with the "Blackfin SPI bus directly" option. In other words, it's not possible to have two different SPI bus drivers built as modules any more. That doesn't seem right?
Thanks!
QuoteReplyEditDelete
2008-08-11 00:17:45 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 60216
> What you're saying is that as a result of the Kconfig change, even if I build the SPI Framework driver as a module, I can no longer build the MMC/SD driver as a module with the "Blackfin SPI bus directly" option.
One problem is that, you cannot build the "SPI framework" as a module. Let's look at drivers/spi/Kconfig:
config SPI
bool "SPI support"
config SPI_MASTER
# boolean "SPI Master Support"
boolean
default SPI
config SPI_BFIN
tristate "SPI controller driver for ADI Blackfin5xx"
depends on SPI_MASTER && BLACKFIN
We need to distinguish between "SPI framework" (CONFIG_SPI) and SPI master driver (CONFIG_SPI_BFIN). The result is, we can only choose to build CONFIG_SPI (and CONFIG_SPI_MASTER) into kernel or not (I am not sure why).
The problem we have was, SPI_MMC_BFIN_PIO_SPI conflicts with CONFIG_SPI (and CONFIG_SPI_MASTER) - they are mutual exclusive - it is OK that you Build SPI_MMC_BFIN_PIO_SPI as module, but you cannot Load and Use it when CONFIG_SPI is in kernel.
And I am going to revert the Kconfig change I've made - it is not good to limit the user to BUILD the module, even if LOAD/USE the module may cause problem - the user need to make the decision of how to use it properly.
-Yi
QuoteReplyEditDelete
2008-08-11 21:14:08 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60264
Thanks Yi. That's very interesting. And I agree that backing out the Kconfig change is the right thing to do.
So it seems the problem is redefined. The original problem title was "Cannot unload spi_mmc kernel module". The revised problem title should probably be "Cannot build SPI Framework as a module".
How do you suggest we proceed? Should I start a new thread here?
Thanks!
QuoteReplyEditDelete
2008-08-11 23:50:42 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 60267
Since SPI framework is in mainline Linux kernel, and the spi_mmc is maintained locally in blackfin uclinux tree, so to "build SPI framework as module", this has to be handled in LKML level ;). For now (the 2008R1.5 release), I think we can just disable SPI framework, if spi_mmc driver uses SPI bus directly.
And we have just upgrade SVN trunk to linux-2.6.26, there is a common spi mmc driver: linux-kernel/drivers/mmc/host/mmc_spi.c. We haven't test it yet, but this driver should replace the old spi_mmc driver.
-Yi
QuoteReplyEditDelete
2008-08-12 08:28:52 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 60324
it'll suffer the same problems as the Blackfin one when using the common SPI framework, so that doesnt really help Frank all that much
QuoteReplyEditDelete
2008-08-12 18:58:04 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60348
Please don't change Kconfig to prevent the building of the SPI Framework when SPI_MMC is enabled with "SPI Bus Directly". Because doing that would make it really difficult to come up with any interim workarounds (aka "ugly hacks" :-) for this bug. My preference is definately to leave Kconfig as it is, if at all possible.
Thanks!
QuoteReplyEditDelete
2008-08-12 22:57:57 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 60360
Frank,
Yes. That is what I am doing on 2008R1 branch - leaving drivers/mmc/spi_mmc/Kconfig unchanged.
-Yi
QuoteReplyEditDelete
2008-08-12 23:19:44 Re: Cannot unload spi_mmc kernel module (driver)
Yi Li (CHINA)
Message: 60361
Mike,
Do you mean that the common driver mmc/host/mmc_spi.c still cannot work properly when using the SPI framework, if there are more than one spi devices on the same bus?
-Yi
QuoteReplyEditDelete
2008-08-12 23:53:06 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 60362
yes ... the problem has been discussed at length on our mailing lists (Bryan should be versed as well)
the SPI framework cannot provide the bus atomicity that is required by the SD protocol
QuoteReplyEditDelete
2008-08-13 18:54:20 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60429
Wow, this apparently simple question appears to be knocking us flat. Here's what we're trying to do:
Does anyone have any suggestions on how to read a file from an SD card & write that file into the serial flash? (From within uclinux.) This is to provide field-upgradeability of our product.
What we've tried:
Attempt 1. Configure the MMC/SD driver (within menuconfig) to use the SPI Framework. As we've all since learnt, the MMC/SD driver does not work with the SPI Framework.
Attempt 2. Build the SPI Framework, MTD utilities, and MMC/SD driver all as modules. Load the MMC/SD driver, copy the file from the SD card into RAM, unload the MMC/SD driver, load the SPI framework & MTD utilities and program the file into the serial flash. This attempt resulted in this "Cannot unload spi_mmc driver" thread.
Any suggestions for an attempt #3?
Many thanks.
QuoteReplyEditDelete
2008-08-14 09:24:37 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 60476
if you're good about using resources in userspace, you might be able to get away with loading the spi_mmc driver while everything else is loaded.
modify the driver to save all MMRs/states before it starts doing anything. then during unload, have it restore anything.
so long as you dont poke any of the other active drivers ...
QuoteReplyEditDelete
2008-08-14 18:04:10 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60492
Thanks Mike, we will look into that idea.
Do you have any suggestions or pointers regarding how to go about requesting a change to the SPI framework to allow it to be built as a module? I understand from Yi's post that it was not authored by anyone here.
QuoteReplyEditDelete
2008-08-14 18:35:54 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 60494
when it comes to frameworks, we tend to code the arch-specific pieces. in the case of SPI, the part we maintain is just the Blackfin SPI bus driver.
if you cannot unload that module (spi_bfin5xx), then it's a bug. maybe a bug in our master driver, maybe a bug in the SPI framework. i think for your needs, that's the only part you should need to unload.
if you want to be able to unload the whole SPI framework, then it's a feature request :). probably mention it to david brownell / lkml ... i dont think the SPI subsystem has a dedicated website/mailing list.
QuoteReplyEditDelete
2008-08-14 19:02:59 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60495
As far as I can see, there's no problem with spi_bfin5xx. It builds OK as a module, and I'm able to load & unload it OK.
The problem appears to be elsewhere. In the .config file I see:
#
# SPI support
#
CONFIG_SPI=y
CONFIG_SPI_MASTER=y
#
# SPI Master Controller Drivers
#
CONFIG_SPI_BFIN=m
# CONFIG_SPI_BITBANG is not set
As I understand it (with help from the earlier post from Yi), those first two items, the SPI & SPI_MASTER, belong to the SPI framework. It's not possible to set those to "m". Just for fun I tried, by editing the .config file, but then 'make' complained that "m" was an invalid value for them both.
I'm figuring that the other item listed above, SPI_BFIN, is the spi_bfin5xx.
Given that spi_bfin5xx is not even loaded, I don't really understand why loading & unloading the MMC/SD driver spi_mmc causes the fault. I'm almost wondering if the spi_mmc driver is somehow inadvertently "registering" with the SPI Framework that's built into the kernel, with the result that the kernel complains when the spi_mmc driver is unloaded.
QuoteReplyEditDelete
2008-08-14 19:14:13 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 60496
try editing spi_mmc_core.c and in the exit function, change CONFIG_SPI to CONFIG_SPI_MMC_BFIN_PIO_SPI ...
QuoteReplyEditDelete
2008-08-15 19:49:13 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60513
Well that was informative. Kind-of anyway.
Changing #ifdef CONFIG_SPI to #ifdef CONFIG_SPI_MMC_BFIN_PIO_SPI made no difference - it still faults when unloading.
But it raises a question. In this 'make', BOTH of these flags (CONFIG_SPI and CONFIG_SPI_MMC_BFIN_PIO_SPI) are True.
I double-checked this by virtue of some printk's.
Is this something that the spi_mmc_core.c code would expect? Intuitively, I'd think that the code would expect only one or the other?
Out of curiosity I've put an #undef CONFIG_SPI at the top of the spi_mmc_core.c file, and will try that.
EDIT: It didn't work. I was able to successfully load, use, & unload the MMC/SD driver. That's good. However, when I followed that by trying to load the SPI Framework module, it failed:
root:/lib/modules/2.6.22.19-ADI-2008R1.5-svn5191/kernel/drivers/spi> insmod spi_bfin5xx.ko
peripheral_request: Peripheral 13 function 0 is already reserved by mmc_pio_spi !
Hardware Trace:
0 Target : <0x0000479c> { _dump_stack + 0x0 }
Source : <0x00005c8c> { _peripheral_request + 0x160 }
1 Target : <0x00005c8c> { _peripheral_request + 0x160 }
Source : <0x0000dd5a> { _printk + 0x16 }
This message seems to say that spi_mmc_core (I presume) didn't clean up properly after itself, when it was removed? How do I determine what Peripheral 13 is?
QuoteReplyEditDelete
2008-08-15 20:22:02 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 60514
i imagine the relationship is pretty blurred. the driver was contributed by the guys who made the original SPI/MMC card, so we havent pounded on it terribly much.
QuoteReplyEditDelete
2008-08-15 20:43:18 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60516
Sorry Mike, I edited my post while you were replying to it.
QuoteReplyEditDelete
2008-08-19 20:01:37 Re: Cannot unload spi_mmc kernel module (driver)
Mike Frysinger (UNITED STATES)
Message: 60696
probably need to add a gpio_free() ... i see gpio_request() in the driver, but no free
same for peripheral_request_list() and peripheral_free_list() ...
QuoteReplyEditDelete
2008-08-20 01:47:54 Re: Cannot unload spi_mmc kernel module (driver)
Frank Van Hooft (CANADA)
Message: 60708
Yes, I saw that too and added them - made no real difference actually - spi_mmc still doesn't want to unload.
I'm pretty certain that the code doesn't want to see both CONFIG_SPI and CONFIG_SPI_MMC_BFIN_PIO_SPI set. In most of the code it's an #if - #else kind of thing, although not everywhere. I changed it so only CONFIG_SPI_MMC_BFIN_PIO_SPI is set (did an #undef of CONFIG_SPI) - that also made no difference.
Anyway, I've given up on this; it's simply been taking up way too much time. Sometimes you eat the bear, and sometimes the bear...
<grin>