RFC: PCI SD host controller driver & mmc/mmcsd modules improvements

Lars Engels lme at FreeBSD.org
Thu Nov 6 11:04:30 PST 2008


On Thu, Nov 06, 2008 at 07:40:17PM +0100, Lars Engels wrote:
> On Thu, Nov 06, 2008 at 11:23:38AM -0700, M. Warner Losh wrote:
> > In message: <4913345F.2050801 at FreeBSD.org>
> >             Alexander Motin <mav at FreeBSD.org> writes:
> > : Lars Engels wrote:
> > : > On another notebook with the same card reader I get a little further:
> > : > 
> > : > sdhci0: <RICOH R5C822 SD> mem 0xd8002800-0xd80028ff irq 22 at device 9.2
> > : > on pci5
> > : > sdhci0: 1 slot(s) allocated
> > : > sdhci0: [ITHREAD]
> > : > mmc0: <MMC/SD bus> on sdhci0
> > : > mmc0: detached
> > : > mmc0: <MMC/SD bus> on sdhci0
> > : > 
> > : > So the mmc device is detected everytime I insert a card and is removed
> > : > when I take the card out.
> > : 
> > : It means that controller successfully reports card insertion. You must 
> > : be a half way there.
> > : 
> > : > But I do not get a new disk device...
> > : 
> > : A bit more debugging can be produced with enabling verbose boot messages.
> > : 
> > : > pciconf tells me pretty much the same like on the other notebook:
> > : 
> > : Looks like it may depend or on controller version or on the way it is 
> > : hardwired or somehow BIOS initialized. There are were some success 
> > : stories reported with this controller.
> > 
> > Add mmcsd to the kernel?  Load it as a module?
> 
> Much better! Loading mmcsd first, then mmc and sdhci gives me the mmcsd0
> device:
> sdhci0: <RICOH R5C822 SD> mem 0xd8002800-0xd80028ff irq 22 at device 9.2
> on pci5
> sdhci0: 1 slot(s) allocated
> sdhci0: [ITHREAD]
> mmc0: <MMC/SD bus> on sdhci0
> mmcsd0: 1924MB <SD Memory Card> at mmc0 16MHz/4bit
> sdhci0-slot0: Got data interrupt 0x00000002, but there is no active
> command.
> sdhci0-slot0: ============== REGISTER DUMP ==============
> sdhci0-slot0: Sys addr: 0x30c68000 | Version:  0x00000200
> sdhci0-slot0: Blk size: 0x00000000 | Blk cnt:  0x00000000
> sdhci0-slot0: Argument: 0x00000000 | Trn mode: 0x00000013
> sdhci0-slot0: Present:  0x01ff0000 | Host ctl: 0x00000002
> sdhci0-slot0: Power:    0x0000000f | Blk gap:  0x00000000
> sdhci0-slot0: Wake-up:  0x00000000 | Clock:    0x00000107
> sdhci0-slot0: Timeout:  0x0000000c | Int stat: 0x00000000
> sdhci0-slot0: Int enab: 0x01ff00fb | Sig enab: 0x01ff00fb
> sdhci0-slot0: AC12 err: 0x00000000 | Slot int: 0x00000000
> sdhci0-slot0: Caps:     0x01c021a1 | Max curr: 0x00000040
> sdhci0-slot0: ===========================================

[...]

> But I still cannot use it:
> lars at pts/3 # ls -l /dev/mmcsd0*
> crw-r-----  1 root  operator    0, 120 Nov  6 19:36 /dev/mmcsd0
> crw-r-----  1 root  operator    0, 121 Nov  6 19:36 /dev/mmcsd0s1
> 
> lars at pts/3 # fdisk /dev/mmcsd0
> fdisk: could not detect sector size
> 
> 
> lars at pts/3 # mount -t msdosfs /dev/mmcsd0s1 /mnt
> mount_msdosfs: /dev/mmcsd0s1: : Input/output error
> 
> 
> What am I missing?

That seems to be the SD card I used...
Now I tried a SDHCI card and fdisk printed the partition table.
mmcsd0: 7580MB <SDHC Memory Card> at mmc0 16MHz/4bit

However, when I tried to mount it, I get this error:
g_vfs_done():mmcsd0s1[WRITE(offset=2254848, length=4096)]error = 5
g_vfs_done():mmcsd0s1[WRITE(offset=2254848, length=4096)]error = 5
g_vfs_done():mmcsd0s1[WRITE(offset=2254848, length=4096)]error = 5
fsync: giving up on dirty
0xc5452d9c: tag devfs, type VCHR
    usecount 1, writecount 0, refcount 240 mountedhere 0xc474f700
    flags ()
    v_object 0xc48368b8 ref 0 pages 240
     lock type devfs: UNLOCKED

        dev mmcsd0s1


And a (reproducable) kernel panic shortly after that:


Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address   = 0x0
fault code              = supervisor read, page not present
instruction pointer     = 0x20:0xc057e6a9
stack pointer           = 0x28:0xc3fd5b84
frame pointer           = 0x28:0xc3fd5bb0
code segment            = base 0x0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, def32 1, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 19 (syncer)
Physical memory: 1002 MB
Dumping 163 MB: 148 132 116 100 84 68 52 36 20 4

Reading symbols from /boot/kernel/linux.ko...Reading symbols from /boot/kernel/linux.ko.symbols...done.
[...]
Loaded symbols for /boot/kernel/mmcsd.ko
Reading symbols from /boot/kernel/mmc.ko...done.
Loaded symbols for /boot/kernel/mmc.ko
Reading symbols from /boot/kernel/sdhci.ko...done.
Loaded symbols for /boot/kernel/sdhci.ko
#0  doadump () at pcpu.h:246
246     pcpu.h: No such file or directory.
        in pcpu.h
(kgdb) bt
#0  doadump () at pcpu.h:246
#1  0xc0477b99 in db_fncall (dummy1=-1006806728, dummy2=0, dummy3=-1063504288, dummy4=0xc3fd5918 "kÊNÀ") at /usr/src/sys/ddb/db_command.c:548
#2  0xc0477f91 in db_command (last_cmdp=0xc097143c, cmd_table=0x0, dopager=1) at /usr/src/sys/ddb/db_command.c:445
#3  0xc04780ea in db_command_loop () at /usr/src/sys/ddb/db_command.c:498
#4  0xc0479f2d in db_trap (type=12, code=0) at /usr/src/sys/ddb/db_main.c:229
#5  0xc0602076 in kdb_trap (type=12, code=0, tf=0xc3fd5b44) at /usr/src/sys/kern/subr_kdb.c:534
#6  0xc0880f6f in trap_fatal (frame=0xc3fd5b44, eva=0) at /usr/src/sys/i386/i386/trap.c:920
#7  0xc0881210 in trap_pfault (frame=0xc3fd5b44, usermode=0, eva=0) at /usr/src/sys/i386/i386/trap.c:842
#8  0xc0881bf2 in trap (frame=0xc3fd5b44) at /usr/src/sys/i386/i386/trap.c:522
#9  0xc0866cfb in calltrap () at /usr/src/sys/i386/i386/exception.s:165
#10 0xc057e6a9 in g_io_request (bp=0xc56c58c4, cp=0xc5562100) at /usr/src/sys/geom/geom_io.c:364
#11 0xc0583a06 in g_vfs_strategy (bo=0xc57dc0a8, bp=0xd82b9bc0) at /usr/src/sys/geom/geom_vfs.c:107
#12 0xc06456e1 in bufwrite (bp=0xd82b9bc0) at buf.h:397
#13 0xc063ea48 in bawrite (bp=0xd82b9bc0) at buf.h:385
#14 0xc064a23c in vop_stdfsync (ap=0xc3fd5c74) at /usr/src/sys/kern/vfs_default.c:482
#15 0xc056221e in devfs_fsync (ap=0xc3fd5c74) at /usr/src/sys/fs/devfs/devfs_vnops.c:485
#16 0xc088e312 in VOP_FSYNC_APV (vop=0xc0931520, a=0xc3fd5c74) at vnode_if.c:1007
#17 0xc065ccce in sync_vnode (slp=Variable "slp" is not available.
) at vnode_if.h:529
#18 0xc065d0c2 in sched_sync () at /usr/src/sys/kern/vfs_subr.c:1761
#19 0xc05b3b83 in fork_exit (callout=0xc065ce00 <sched_sync>, arg=0x0, frame=0xc3fd5d38) at /usr/src/sys/kern/kern_fork.c:815
#20 0xc0866d70 in fork_trampoline () at /usr/src/sys/i386/i386/exception.s:270

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20081106/eeb6a9c0/attachment.pgp


More information about the freebsd-current mailing list