[CentOS] Multi-Card reader (SD, MMC, etc) and CONFIG_SCSI_MULTI_LUN kernel option in 34.0.2. Workaround

Thu Aug 10 08:05:35 UTC 2006
J.J. Garcia <stigmatedbrain at gmail.com>

Hi folks,

Im trying to get a multi-card reader on centos (SD, MMC, and so, 4 card
slots) and i have read (http://www.cs.sfu.ca/~ggbaker/personal/cf-linux)
that CONFIG_SCSI_MULTI_LUN should be enabled on kernel (=Y) but current
34.0.2 doesn't have it enabled by default, is there any particular
reason to not be enabled?

By the other hand i've also tweak the /etc/grub.conf file to boot the
kernel with max_luns=32 and results are the same, only scsc lun=0 is
recognized.

At the same time using the workaround mentioned in the link pasted b4
regarding to modify the /etc/modules.conf to include 'options scsi_mod
max_scsi_luns=8' gives the same results, no detection at all for the
card slots.

[root at sparkbox ~]# cat /proc/bus/usb/devices
T:  Bus=01 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#=  7 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0644 ProdID=0200 Rev= 4.00
S:  Manufacturer=TEAC
S:  Product=CA-200
S:  SerialNumber=0000020307B2
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-
storage
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=125us
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

and /var/log/dmesg still shows:
<...>
scsi3 : SCSI emulation for USB Mass Storage devices
  Vendor: TEAC      Model: USB   HS-CF Card  Rev: 4.00
  Type:   Direct-Access                      ANSI SCSI revision: 02
Attached scsi removable disk sdc at scsi3, channel 0, id 0, lun 0
USB Mass Storage device found at 7
<...>

Instead of (if i understand well for this scsi3 line) after a 

[root at sparkbox]# sg_scan -i (it should show)

/dev/sg2: scsi3 channel=0 id=0 lun=0 [em]  type=0
    Generic   STORAGE DEVICE    0128 [wide=0 sync=0 cmdq=0 sftre=0
pq=0x0]
/dev/sg3: scsi3 channel=0 id=0 lun=1 [em]  type=0
    Generic   STORAGE DEVICE    0128 [wide=0 sync=0 cmdq=0 sftre=0
pq=0x0]
/dev/sg4: scsi3 channel=0 id=0 lun=2 [em]  type=0
    Generic   STORAGE DEVICE    0128 [wide=0 sync=0 cmdq=0 sftre=0
pq=0x0]
/dev/sg5: scsi3 channel=0 id=0 lun=3 [em]  type=0
    Generic   STORAGE DEVICE    0128 [wide=0 sync=0 cmdq=0 sftre=0
pq=0x0]


But actually,

[root at sparkbox ~]# sg_scan -i
[root at sparkbox ~]# (shows nothing)

And

[root at sparkbox ~]# sg_map
Stopping because no sg devices found
Strange, could not find device /dev/sda mapped to sg device??
Strange, could not find device /dev/sdb mapped to sg device??
Strange, could not find device /dev/sdc mapped to sg device??
Strange, could not find device /dev/sdd mapped to sg device??

Looking at SCSI:

[root at sparkbox ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: HDS728080PLA380  Rev: PF2O
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: Genesys  Model: USB to IDE Disk  Rev: 0002
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: TEAC     Model: USB   HS-CF Card Rev: 4.00
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi4 Channel: 00 Id: 00 Lun: 00
  Vendor:          Model: USB DISK Pro     Rev: 1.1b
  Type:   Direct-Access                    ANSI SCSI revision: 02


And finally doing the last workaround found in the link from Greg Baker
article for my scsi3 chain:

[root at sparkbox ~]#echo >/proc/scsi/scsi "scsi add-single-device 3 0 0 1"
[root at sparkbox ~]#echo >/proc/scsi/scsi "scsi add-single-device 3 0 0 2"
[root at sparkbox ~]#echo >/proc/scsi/scsi "scsi add-single-device 3 0 0 3"

Solves the identification:

[root at sparkbox ~]# cat /proc/scsi/scsi
Attached devices:
<...>
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: TEAC     Model: USB   HS-CF Card Rev: 4.00
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 01
  Vendor: TEAC     Model: USB   HS-xD/SM   Rev: 4.00
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 02
  Vendor: TEAC     Model: USB   HS-MS Card Rev: 4.00
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 03
  Vendor: TEAC     Model: USB   HS-SD Card Rev: 4.00
  Type:   Direct-Access                    ANSI SCSI revision: 02

Now, even without update the udev rules with a new rule It seems to work
after inserting the SD (1GB card) card on card-reader, from dmesg:

<...>
SCSI device sdg: 2012160 512-byte hdwr sectors (1030 MB)
sdg: Write Protect is off
sdg: Mode Sense: 23 00 00 00
sdg: assuming drive cache: write through
SCSI device sdg: 2012160 512-byte hdwr sectors (1030 MB)
sdg: Write Protect is off
sdg: Mode Sense: 23 00 00 00
sdg: assuming drive cache: write through
 sdg: sdg1
<...>

Mounting the correct SD card on fstab and only remaining to update
permissions/udev or pamconsole (not sure where) to get RW access for
user space.

Hope it helps and just to clarify for mentionned CONFIG_SCSI_MULTI_LUN
option in kernel.



Jose.