2013-07-25 23:15:09

by Dave Hansen

[permalink] [raw]
Subject: SATA hotplug not detecting new disks

I've got a relatively new system that doesn't seem to be able to hotplug
SATA disks. I see the same behavior on 3.10, 3.11-rc2, and Ubuntu's
3.8.0-25-generic. The disks are detected right away on reboots, but
even after poking the /sys/class/scsi_host/host*/scan files, new disks
are never detected. I've disabled link power management.

Am I doing something stupid here? I thought this "just worked" on my
previous hardware.

The motherboard is an Intel DH87RL. The SATA controller is:

> 00:1f.2 SATA controller: Intel Corporation Lynx Point 6-port SATA Controller 1 [AHCI mode] (rev 04) (prog-if 01 [AHCI 1.0])
> Subsystem: Intel Corporation Device 204a
> Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
> Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
> Latency: 0
> Interrupt: pin B routed to IRQ 41
> Region 0: I/O ports at f0d0 [size=8]
> Region 1: I/O ports at f0c0 [size=4]
> Region 2: I/O ports at f0b0 [size=8]
> Region 3: I/O ports at f0a0 [size=4]
> Region 4: I/O ports at f060 [size=32]
> Region 5: Memory at f7d3a000 (32-bit, non-prefetchable) [size=2K]
> Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
> Address: fee2200c Data: 4191
> Capabilities: [70] Power Management version 3
> Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot+,D3cold-)
> Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
> Capabilities: [a8] SATA HBA v1.0 BAR4 Offset=00000004
> Kernel driver in use: ahci

Relevant dmesg from boot:

ahci 0000:00:1f.2: version 3.0
ahci 0000:00:1f.2: irq 41 for MSI/MSI-X
ahci 0000:00:1f.2: AHCI 0001.0300 32 slots 5 ports 6 Gbps 0x1e impl SATA
mode
ahci 0000:00:1f.2: flags: 64bit ncq pm led clo pio slum part ems apst
ahci 0000:00:1f.2: setting latency timer to 64
scsi0 : ahci
scsi1 : ahci
scsi2 : ahci
scsi3 : ahci
scsi4 : ahci
ata1: DUMMY
ata2: SATA max UDMA/133 abar m2048@0xf7d3a000 port 0xf7d3a180 irq 41
ata3: SATA max UDMA/133 abar m2048@0xf7d3a000 port 0xf7d3a200 irq 41
ata4: SATA max UDMA/133 abar m2048@0xf7d3a000 port 0xf7d3a280 irq 41
ata5: SATA max UDMA/133 abar m2048@0xf7d3a000 port 0xf7d3a300 irq 41


2013-07-26 01:51:14

by Aaron Lu

[permalink] [raw]
Subject: Re: SATA hotplug not detecting new disks

On 07/26/2013 07:15 AM, Dave Hansen wrote:
> I've got a relatively new system that doesn't seem to be able to hotplug
> SATA disks. I see the same behavior on 3.10, 3.11-rc2, and Ubuntu's
> 3.8.0-25-generic. The disks are detected right away on reboots, but
> even after poking the /sys/class/scsi_host/host*/scan files, new disks
> are never detected. I've disabled link power management.
>
> Am I doing something stupid here? I thought this "just worked" on my
> previous hardware.

My vague memory reminds me that not all SATA ports are hot pluggable -
you can check the port's "External SATA port" bit and "Hot Plug Capable"
bit of the PxCMD register like this:

$ grep ahci /proc/iomem
e1a40000-e1a407ff : ahci
# dd if=/dev/mem of=ahcidump bs=4096 count=1 skip=0xe1a40
You will need to change 0xe1a40 to decimal format.

Then the PxCMD is at offset 0x118 for port 0, check bit 21 for E-SATA or
bit 18 for hot pluggable bits. If any of them set to 1, this port
should be hot pluggable; otherwise, it doesn't have this capability.

>
> The motherboard is an Intel DH87RL. The SATA controller is:
>
>> 00:1f.2 SATA controller: Intel Corporation Lynx Point 6-port SATA Controller 1 [AHCI mode] (rev 04) (prog-if 01 [AHCI 1.0])
>> Subsystem: Intel Corporation Device 204a
>> Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
>> Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
>> Latency: 0
>> Interrupt: pin B routed to IRQ 41
>> Region 0: I/O ports at f0d0 [size=8]
>> Region 1: I/O ports at f0c0 [size=4]
>> Region 2: I/O ports at f0b0 [size=8]
>> Region 3: I/O ports at f0a0 [size=4]
>> Region 4: I/O ports at f060 [size=32]
>> Region 5: Memory at f7d3a000 (32-bit, non-prefetchable) [size=2K]
>> Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
>> Address: fee2200c Data: 4191
>> Capabilities: [70] Power Management version 3
>> Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot+,D3cold-)
>> Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
>> Capabilities: [a8] SATA HBA v1.0 BAR4 Offset=00000004
>> Kernel driver in use: ahci
>
> Relevant dmesg from boot:
>
> ahci 0000:00:1f.2: version 3.0
> ahci 0000:00:1f.2: irq 41 for MSI/MSI-X
> ahci 0000:00:1f.2: AHCI 0001.0300 32 slots 5 ports 6 Gbps 0x1e impl SATA
> mode
> ahci 0000:00:1f.2: flags: 64bit ncq pm led clo pio slum part ems apst

This doesn't have sxs(support external sata) bit here, so no ports from
this host is E-SATA port. Only need to check the hot pluggable bit.

Hope this helps,
-Aaron

> ahci 0000:00:1f.2: setting latency timer to 64
> scsi0 : ahci
> scsi1 : ahci
> scsi2 : ahci
> scsi3 : ahci
> scsi4 : ahci
> ata1: DUMMY
> ata2: SATA max UDMA/133 abar m2048@0xf7d3a000 port 0xf7d3a180 irq 41
> ata3: SATA max UDMA/133 abar m2048@0xf7d3a000 port 0xf7d3a200 irq 41
> ata4: SATA max UDMA/133 abar m2048@0xf7d3a000 port 0xf7d3a280 irq 41
> ata5: SATA max UDMA/133 abar m2048@0xf7d3a000 port 0xf7d3a300 irq 41
>

2013-07-26 17:57:14

by Dave Hansen

[permalink] [raw]
Subject: Re: SATA hotplug not detecting new disks

On 07/25/2013 06:51 PM, Aaron Lu wrote:
> On 07/26/2013 07:15 AM, Dave Hansen wrote:
>> I've got a relatively new system that doesn't seem to be able to hotplug
>> SATA disks. I see the same behavior on 3.10, 3.11-rc2, and Ubuntu's
>> 3.8.0-25-generic. The disks are detected right away on reboots, but
>> even after poking the /sys/class/scsi_host/host*/scan files, new disks
>> are never detected. I've disabled link power management.
>>
>> Am I doing something stupid here? I thought this "just worked" on my
>> previous hardware.
>
> My vague memory reminds me that not all SATA ports are hot pluggable -
> you can check the port's "External SATA port" bit and "Hot Plug Capable"
> bit of the PxCMD register like this:
>
> $ grep ahci /proc/iomem
> e1a40000-e1a407ff : ahci
> # dd if=/dev/mem of=ahcidump bs=4096 count=1 skip=0xe1a40
> You will need to change 0xe1a40 to decimal format.
>
> Then the PxCMD is at offset 0x118 for port 0, check bit 21 for E-SATA or
> bit 18 for hot pluggable bits. If any of them set to 1, this port
> should be hot pluggable; otherwise, it doesn't have this capability.

That whole I/O area looks to be 0'd to me, at least for the port if I
boot with it unplugged. I even tried toggling the PORT_CMD_ALPE bit
with powertop since it is in the same port. Nothing seems to happen for
port0 (the one unplugged at boot), although I _can_ see the writes show
up for the other ports.

I also tried booting with a disk plugged in to a port, then put that
disk to sleep and unplugged it. I replugged a _different_ disk in its
place, and it was detected just fine.

Is it possible that the 'ata_dummy_port_ops' are getting left in place
at boot accidentally, that we're mistaking an unplugged port for a
disabled one?

2013-07-26 21:12:28

by Dave Hansen

[permalink] [raw]
Subject: Re: SATA hotplug not detecting new disks

On 07/25/2013 06:51 PM, Aaron Lu wrote:
> On 07/26/2013 07:15 AM, Dave Hansen wrote:
>> > I've got a relatively new system that doesn't seem to be able to hotplug
>> > SATA disks. I see the same behavior on 3.10, 3.11-rc2, and Ubuntu's
>> > 3.8.0-25-generic. The disks are detected right away on reboots, but
>> > even after poking the /sys/class/scsi_host/host*/scan files, new disks
>> > are never detected. I've disabled link power management.
>> >
>> > Am I doing something stupid here? I thought this "just worked" on my
>> > previous hardware.
> My vague memory reminds me that not all SATA ports are hot pluggable -
> you can check the port's "External SATA port" bit and "Hot Plug Capable"
> bit of the PxCMD register like this:
>
> $ grep ahci /proc/iomem
> e1a40000-e1a407ff : ahci
> # dd if=/dev/mem of=ahcidump bs=4096 count=1 skip=0xe1a40
> You will need to change 0xe1a40 to decimal format.
>
> Then the PxCMD is at offset 0x118 for port 0, check bit 21 for E-SATA or
> bit 18 for hot pluggable bits. If any of them set to 1, this port
> should be hot pluggable; otherwise, it doesn't have this capability.

<sigh>

I went digging back through the BIOS settings, and found a nice checkbox
to enable hotplug support on the ports. All seems happy now.

Thanks for the help. I hope someone else googling will hit this thread. :)