public inbox for linux-ide@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libata-sff: Don't scan disabled ports when checking for legacy mode.
@ 2017-01-20 17:58 Darren Stevens
  2017-01-20 20:41 ` Tejun Heo
  2017-01-23  8:29 ` [PATCH] " Sergei Shtylyov
  0 siblings, 2 replies; 4+ messages in thread
From: Darren Stevens @ 2017-01-20 17:58 UTC (permalink / raw)
  To: linux-ide

libata-sff.c checks for legacy mode by testing if both primary
and secondary ports on a controller are in legacy mode and selects
legacy if either one is. However on some southbridge chips (e.g
AMD SB600/SB700) the secondary port is not wired, and when it is 
disabled by setting the disable bit in the PCI header it appears
as a fixed legacy port.
Prevent incorrect detection by not testing ports that are marked
as 'dummy'

Signed-off-by: Darren Stevens <darren@stevens-zone.net>
---

diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 051b615..05f688a 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -2429,9 +2429,16 @@ int ata_pci_sff_activate_host(struct ata_host *host,
    if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
        u8 tmp8, mask;
 
-       /* TODO: What if one channel is in native mode ... */
+       /*
+        * ATA spec says we should use legacy mode when one
+        * port is in legacy mode, but disabled ports on some
+        * PCI hosts appear as fixed legacy ports, e.g SB600/700
+        * on which the secondary port is not wired, so
+        * ignore ports that we've marked as 'dummy' during
+        * this check
+        */
        pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
-       mask = (1 << 2) | (1 << 0);
+       mask = (! ata_port_is_dummy(host->ports[1]) << 2) | (!
ata_port_is_dummy(host->ports[0]) << 0);
        if ((tmp8 & mask) != mask)
            legacy_mode = 1;
    }


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

* Re: [PATCH] libata-sff: Don't scan disabled ports when checking for legacy mode.
  2017-01-20 17:58 [PATCH] libata-sff: Don't scan disabled ports when checking for legacy mode Darren Stevens
@ 2017-01-20 20:41 ` Tejun Heo
  2017-01-22 19:40   ` Darren Stevens
  2017-01-23  8:29 ` [PATCH] " Sergei Shtylyov
  1 sibling, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2017-01-20 20:41 UTC (permalink / raw)
  To: Darren Stevens; +Cc: linux-ide

Hello,

On Fri, Jan 20, 2017 at 05:58:21PM +0000, Darren Stevens wrote:
> @@ -2429,9 +2429,16 @@ int ata_pci_sff_activate_host(struct ata_host *host,
>     if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
>         u8 tmp8, mask;
>  
> -       /* TODO: What if one channel is in native mode ... */
> +       /*
> +        * ATA spec says we should use legacy mode when one
> +        * port is in legacy mode, but disabled ports on some
> +        * PCI hosts appear as fixed legacy ports, e.g SB600/700
> +        * on which the secondary port is not wired, so
> +        * ignore ports that we've marked as 'dummy' during
> +        * this check
> +        */
>         pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
> -       mask = (1 << 2) | (1 << 0);
> +       mask = (! ata_port_is_dummy(host->ports[1]) << 2) | (!
> ata_port_is_dummy(host->ports[0]) << 0);

The patch is damaged and maybe just using two if statements would read
easier?

Thanks.

-- 
tejun

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

* Re: libata-sff: Don't scan disabled ports when checking for legacy mode.
  2017-01-20 20:41 ` Tejun Heo
@ 2017-01-22 19:40   ` Darren Stevens
  0 siblings, 0 replies; 4+ messages in thread
From: Darren Stevens @ 2017-01-22 19:40 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide

Hello Tejun

On 20/01/2017, Tejun Heo wrote:
> The patch is damaged and maybe just using two if statements would read
> easier?

Thanks for reviewing, I've made the changes you suggested, and resumbitted,
this time I have attached the patches so my emailer won't mangle them.

Both have come from my git tree and are tested as far as I can.

Regards
Darren


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

* Re: [PATCH] libata-sff: Don't scan disabled ports when checking for legacy mode.
  2017-01-20 17:58 [PATCH] libata-sff: Don't scan disabled ports when checking for legacy mode Darren Stevens
  2017-01-20 20:41 ` Tejun Heo
@ 2017-01-23  8:29 ` Sergei Shtylyov
  1 sibling, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2017-01-23  8:29 UTC (permalink / raw)
  To: Darren Stevens, linux-ide

Hello!

On 1/20/2017 8:58 PM, Darren Stevens wrote:

> libata-sff.c checks for legacy mode by testing if both primary
> and secondary ports on a controller are in legacy mode and selects
> legacy if either one is. However on some southbridge chips (e.g

    South bridge.

> AMD SB600/SB700) the secondary port is not wired, and when it is
> disabled by setting the disable bit in the PCI header it appears
> as a fixed legacy port.
> Prevent incorrect detection by not testing ports that are marked
> as 'dummy'
>
> Signed-off-by: Darren Stevens <darren@stevens-zone.net>
> ---
>
> diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
> index 051b615..05f688a 100644
> --- a/drivers/ata/libata-sff.c
> +++ b/drivers/ata/libata-sff.c
> @@ -2429,9 +2429,16 @@ int ata_pci_sff_activate_host(struct ata_host *host,
>     if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
>         u8 tmp8, mask;
>
> -       /* TODO: What if one channel is in native mode ... */
> +       /*
> +        * ATA spec says we should use legacy mode when one
> +        * port is in legacy mode, but disabled ports on some
> +        * PCI hosts appear as fixed legacy ports, e.g SB600/700
> +        * on which the secondary port is not wired, so
> +        * ignore ports that we've marked as 'dummy' during
> +        * this check
> +        */
>         pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
> -       mask = (1 << 2) | (1 << 0);
> +       mask = (! ata_port_is_dummy(host->ports[1]) << 2) | (!
> ata_port_is_dummy(host->ports[0]) << 0);

    In addition to what Tejun said: no need for spaces after !.

[...]

MBR, Sergei


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

end of thread, other threads:[~2017-01-23  8:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-20 17:58 [PATCH] libata-sff: Don't scan disabled ports when checking for legacy mode Darren Stevens
2017-01-20 20:41 ` Tejun Heo
2017-01-22 19:40   ` Darren Stevens
2017-01-23  8:29 ` [PATCH] " Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox