linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* AHCI hotplug no longer functions on ICH7
@ 2024-05-19 11:40 Tasos Sahanidis
  2024-05-21 13:47 ` Niklas Cassel
  0 siblings, 1 reply; 4+ messages in thread
From: Tasos Sahanidis @ 2024-05-19 11:40 UTC (permalink / raw)
  To: cassel; +Cc: dlemoal, jhp, hch, mario.limonciello, mika.westerberg, linux-ide


[-- Attachment #1.1: Type: text/plain, Size: 1199 bytes --]

Hi,

I have a hot swap bay connected to an Intel Corporation NM10/ICH7 Family
SATA Controller [AHCI mode] [8086:27c1] (rev 01) (prog-if 01 [AHCI 1.0])
and since commit 7627a0edef54 ("ata: ahci: Drop low power policy board
type") SATA AHCI hotplug no longer functions. Plugging a device in after
the system has booted results in it not being detected.

Looking at ahci_update_initial_lpm_policy(), it is evident that
ATA_PFLAG_EXTERNAL is not set (ad->pflags == 0x84 when the function is
called) and there is no option in firmware to mark these ports as external.

My kernel was always built with CONFIG_SATA_MOBILE_LPM_POLICY=3. Booting
with ahci.mobile_lpm_policy=2 or ahci.mobile_lpm_policy=1 results in the
device being detected on hotplug, but the unplug event is never detected
and the system thinks the device remains connected, resulting in hangs.

The only way to restore functionality is with ahci.mobile_lpm_policy=0,
which if I am not mistaken has the same effect as an early return. Is
this the intended way of getting hotplug to work again from now on, on
systems that don't mark ports as external, or is this a regression?

Thank you for your time.

--
Tasos

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: AHCI hotplug no longer functions on ICH7
  2024-05-19 11:40 AHCI hotplug no longer functions on ICH7 Tasos Sahanidis
@ 2024-05-21 13:47 ` Niklas Cassel
  2024-05-27  8:59   ` Tasos Sahanidis
  0 siblings, 1 reply; 4+ messages in thread
From: Niklas Cassel @ 2024-05-21 13:47 UTC (permalink / raw)
  To: Tasos Sahanidis
  Cc: dlemoal, jhp, hch, mario.limonciello, mika.westerberg, linux-ide

Hello Tasos,

On Sun, May 19, 2024 at 02:40:12PM +0300, Tasos Sahanidis wrote:
> Hi,
> 
> I have a hot swap bay connected to an Intel Corporation NM10/ICH7 Family
> SATA Controller [AHCI mode] [8086:27c1] (rev 01) (prog-if 01 [AHCI 1.0])
> and since commit 7627a0edef54 ("ata: ahci: Drop low power policy board
> type") SATA AHCI hotplug no longer functions. Plugging a device in after
> the system has booted results in it not being detected.
> 
> Looking at ahci_update_initial_lpm_policy(), it is evident that
> ATA_PFLAG_EXTERNAL is not set (ad->pflags == 0x84 when the function is
> called) and there is no option in firmware to mark these ports as external.

If your port is external or hot plug capable, then your platform firmware/BIOS
should set either the "PORT_CMD_ESP and HOST_CAP_SXS" bits or the
"PORT_CMD_HPCP" bit.

See:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/ata?id=45b96d65ec68f625ad26ee16d2f556e29f715005

Is there any option in your BIOS to mark the port as external or hot plug
capable?


If not, then your platform firmware is broken and needs to be quirked.

Please provde the output from
# dmidecode
so that we can apply a quirk for your broken platform.


> My kernel was always built with CONFIG_SATA_MOBILE_LPM_POLICY=3. Booting
> with ahci.mobile_lpm_policy=2 or ahci.mobile_lpm_policy=1 results in the
> device being detected on hotplug, but the unplug event is never detected
> and the system thinks the device remains connected, resulting in hangs.

In older kernels, regardless if your AHCI controller reported support for
low-power modes or not, you also needed an explicit entry in ahci_pci_tbl for
it to be enabled.

Thus, even if you built with CONFIG_SATA_MOBILE_LPM_POLICY=3, and LPM was
being reported as supported by your AHCI controller, LPM was most likely not
enabled for your AHCI controller with older kernels.

In newer kernels, if CONFIG_SATA_MOBILE_LPM_POLICY=3, and the AHCI controller
reports that it supports LPM, we will enable it.
(We will not enable LPM if the port is external or hot plug capable, as that
breaks hot plug, as you found out.)


> The only way to restore functionality is with ahci.mobile_lpm_policy=0,
> which if I am not mistaken has the same effect as an early return. Is
> this the intended way of getting hotplug to work again from now on, on
> systems that don't mark ports as external, or is this a regression?

According to the AHCI specification, a port that is external or hot plug
capable should set the "PORT_CMD_ESP and HOST_CAP_SXS" bits or the
"PORT_CMD_HPCP" bit.

If your platform fails to follow the AHCI specification, then it will need to
be quirked.


Kind regards,
Niklas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: AHCI hotplug no longer functions on ICH7
  2024-05-21 13:47 ` Niklas Cassel
@ 2024-05-27  8:59   ` Tasos Sahanidis
  2024-05-27 16:13     ` Niklas Cassel
  0 siblings, 1 reply; 4+ messages in thread
From: Tasos Sahanidis @ 2024-05-27  8:59 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: dlemoal, jhp, hch, mario.limonciello, mika.westerberg, linux-ide

Hi Niklas,

Thank you kindly for your response.

On 2024-05-21 16:47, Niklas Cassel wrote:
> If your port is external or hot plug capable, then your platform firmware/BIOS
> should set either the "PORT_CMD_ESP and HOST_CAP_SXS" bits or the
> "PORT_CMD_HPCP" bit.
> 
> See:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/ata?id=45b96d65ec68f625ad26ee16d2f556e29f715005

Understood. I had looked at that commit, but did not look into those
bits in detail. They were obviously not set correctly, thus the port was 
not marked external.

> Is there any option in your BIOS to mark the port as external or hot plug
> capable?
> 
> 
> If not, then your platform firmware is broken and needs to be quirked.
> 
> Please provde the output from
> # dmidecode
> so that we can apply a quirk for your broken platform.

I went through again and checked for any "hotplug" or "external" options
and found nothing. I was ready to try to make a quirk for it, but then I
noticed the option "ALPE and ASP" under IDE Configuration (section 
4.3.6, page 4-17 of the user's manual [0]). It was set to enabled, so I 
disabled it. That did the trick and the ports are now marked as 
external.

It looks like that option doesn't actually enable any kind of LPM, 
because otherwise hotplug would not have worked before, but rather 
expects the OS to enable/disable it.

> In older kernels, regardless if your AHCI controller reported support for
> low-power modes or not, you also needed an explicit entry in ahci_pci_tbl for
> it to be enabled.
> 
> Thus, even if you built with CONFIG_SATA_MOBILE_LPM_POLICY=3, and LPM was
> being reported as supported by your AHCI controller, LPM was most likely not
> enabled for your AHCI controller with older kernels.
> 
> In newer kernels, if CONFIG_SATA_MOBILE_LPM_POLICY=3, and the AHCI controller
> reports that it supports LPM, we will enable it.
> (We will not enable LPM if the port is external or hot plug capable, as that
> breaks hot plug, as you found out.)

That is indeed true, yes. Thank you for the explanation. The Ven/Dev
pair is not in the list of the LPM quirked ones in the original commit.

> According to the AHCI specification, a port that is external or hot plug
> capable should set the "PORT_CMD_ESP and HOST_CAP_SXS" bits or the
> "PORT_CMD_HPCP" bit.
> 
> If your platform fails to follow the AHCI specification, then it will need to
> be quirked.
> 
> 
> Kind regards,
> Niklas

After changing that setting and removing mobile_lpm_policy=0, hotplug 
still functions as expected, so no quirk is needed.

Thank you for your time, and apologies for not noticing this earlier.
Perhaps this helps someone in the future with the same issue.

[0] https://dlcdnets.asus.com/pub/ASUS/mb/socket775/P5W%20DH%20Deluxe/e2557_p5w_dh_dlx.pdf?model=P5W%20DH%20Deluxe

--
Tasos

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: AHCI hotplug no longer functions on ICH7
  2024-05-27  8:59   ` Tasos Sahanidis
@ 2024-05-27 16:13     ` Niklas Cassel
  0 siblings, 0 replies; 4+ messages in thread
From: Niklas Cassel @ 2024-05-27 16:13 UTC (permalink / raw)
  To: Tasos Sahanidis
  Cc: dlemoal, jhp, hch, mario.limonciello, mika.westerberg, linux-ide

On Mon, May 27, 2024 at 11:59:44AM +0300, Tasos Sahanidis wrote:
> Hi Niklas,
> 
> Thank you kindly for your response.
> 
> On 2024-05-21 16:47, Niklas Cassel wrote:
> > If your port is external or hot plug capable, then your platform firmware/BIOS
> > should set either the "PORT_CMD_ESP and HOST_CAP_SXS" bits or the
> > "PORT_CMD_HPCP" bit.
> > 
> > See:
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/ata?id=45b96d65ec68f625ad26ee16d2f556e29f715005
> 
> Understood. I had looked at that commit, but did not look into those
> bits in detail. They were obviously not set correctly, thus the port was 
> not marked external.
> 
> > Is there any option in your BIOS to mark the port as external or hot plug
> > capable?
> > 
> > 
> > If not, then your platform firmware is broken and needs to be quirked.
> > 
> > Please provde the output from
> > # dmidecode
> > so that we can apply a quirk for your broken platform.
> 
> I went through again and checked for any "hotplug" or "external" options
> and found nothing. I was ready to try to make a quirk for it, but then I
> noticed the option "ALPE and ASP" under IDE Configuration (section 
> 4.3.6, page 4-17 of the user's manual [0]). It was set to enabled, so I 
> disabled it. That did the trick and the ports are now marked as 
> external.

Great!

Even if the platform implementation is not that great in my opinion...
I mean, a port is either "external"/"hotplug capable" or it isn't :)
(It shouldn't matter if ALPE (or SALP) is enabled or not.)

Aggressive Link Power Management Enable (ALPE) is simply the enable bit
corresponding to the Supports Aggressive Link Power Management (SALP) bit.

So the expectation would be that setting "ALPE" to false simply changes
the bootup value of the "ALPE" bit to false.

However, I'm guessing that your platform implementation probably toggles
"SALP" instead of toggling "ALPE".

Regardless, we can clearly see that setting "ALPE" to false also changes
either the "PORT_CMD_ESP and HOST_CAP_SXS" bits or the "PORT_CMD_HPCP" bit
as well...


> Thank you for your time, and apologies for not noticing this earlier.
> Perhaps this helps someone in the future with the same issue.

No need to apologize!

Thank you for reporting the regression on the mailing list.

Now we know that some platform implementations toggle either the
"PORT_CMD_ESP and HOST_CAP_SXS" bits or the "PORT_CMD_HPCP" bit,
when "Aggressive Link Power Management" is toggled in the BIOS.

Perhaps some other platform implementations do the same, so this
information might be helpful to others in the future.


Kind regards,
Niklas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-27 16:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-19 11:40 AHCI hotplug no longer functions on ICH7 Tasos Sahanidis
2024-05-21 13:47 ` Niklas Cassel
2024-05-27  8:59   ` Tasos Sahanidis
2024-05-27 16:13     ` Niklas Cassel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).