linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libata/ahci: Fix PCS quirk application
@ 2019-10-15 19:54 Dan Williams
  2019-10-15 20:10 ` Jens Axboe
  2019-10-15 21:02 ` Stephen Douthit
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Williams @ 2019-10-15 19:54 UTC (permalink / raw)
  To: axboe; +Cc: Andreas Friedrich, Stephen Douthit, stable, linux-ide, linux-kernel

Commit c312ef176399 "libata/ahci: Drop PCS quirk for Denverton and
beyond" got the polarity wrong on the check for which board-ids should
have the quirk applied. The board type board_ahci_pcs7 is defined at the
end of the list such that "pcs7" boards can be special cased in the
future if they need the quirk. All prior Intel board ids "<
board_ahci_pcs7" should proceed with applying the quirk.

Reported-by: Andreas Friedrich <afrie@gmx.net>
Reported-by: Stephen Douthit <stephend@silicom-usa.com>
Fixes: c312ef176399 ("libata/ahci: Drop PCS quirk for Denverton and beyond")
Cc: <stable@vger.kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/ata/ahci.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index dd92faf197d5..05c2b32dcc4d 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1600,7 +1600,9 @@ static void ahci_intel_pcs_quirk(struct pci_dev *pdev, struct ahci_host_priv *hp
 	 */
 	if (!id || id->vendor != PCI_VENDOR_ID_INTEL)
 		return;
-	if (((enum board_ids) id->driver_data) < board_ahci_pcs7)
+
+	/* Skip applying the quirk on Denverton and beyond */
+	if (((enum board_ids) id->driver_data) >= board_ahci_pcs7)
 		return;
 
 	/*


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

* Re: [PATCH] libata/ahci: Fix PCS quirk application
  2019-10-15 19:54 [PATCH] libata/ahci: Fix PCS quirk application Dan Williams
@ 2019-10-15 20:10 ` Jens Axboe
  2019-10-15 21:02 ` Stephen Douthit
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-10-15 20:10 UTC (permalink / raw)
  To: Dan Williams
  Cc: Andreas Friedrich, Stephen Douthit, stable, linux-ide, linux-kernel

On 10/15/19 1:54 PM, Dan Williams wrote:
> Commit c312ef176399 "libata/ahci: Drop PCS quirk for Denverton and
> beyond" got the polarity wrong on the check for which board-ids should
> have the quirk applied. The board type board_ahci_pcs7 is defined at the
> end of the list such that "pcs7" boards can be special cased in the
> future if they need the quirk. All prior Intel board ids "<
> board_ahci_pcs7" should proceed with applying the quirk.

Thanks Dan (and others), applied.

-- 
Jens Axboe


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

* Re: [PATCH] libata/ahci: Fix PCS quirk application
  2019-10-15 19:54 [PATCH] libata/ahci: Fix PCS quirk application Dan Williams
  2019-10-15 20:10 ` Jens Axboe
@ 2019-10-15 21:02 ` Stephen Douthit
  2019-10-15 21:26   ` Dan Williams
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Douthit @ 2019-10-15 21:02 UTC (permalink / raw)
  To: Dan Williams, axboe; +Cc: Andreas Friedrich, stable, linux-ide, linux-kernel

On 10/15/19 3:54 PM, Dan Williams wrote:
> Commit c312ef176399 "libata/ahci: Drop PCS quirk for Denverton and
> beyond" got the polarity wrong on the check for which board-ids should
> have the quirk applied. The board type board_ahci_pcs7 is defined at the
> end of the list such that "pcs7" boards can be special cased in the
> future if they need the quirk. All prior Intel board ids "<
> board_ahci_pcs7" should proceed with applying the quirk.
> 
> Reported-by: Andreas Friedrich <afrie@gmx.net>
> Reported-by: Stephen Douthit <stephend@silicom-usa.com>
> Fixes: c312ef176399 ("libata/ahci: Drop PCS quirk for Denverton and beyond")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>   drivers/ata/ahci.c |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index dd92faf197d5..05c2b32dcc4d 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -1600,7 +1600,9 @@ static void ahci_intel_pcs_quirk(struct pci_dev *pdev, struct ahci_host_priv *hp
>   	 */
>   	if (!id || id->vendor != PCI_VENDOR_ID_INTEL)
>   		return;

Unless I'm missing something this will short-circuit if there are any
older Intel controllers not explicitly listed with a PCI_VDEVICE entry
in ahci_pci_tbl.  Those will match on:

	/* Generic, PCI class code for AHCI */
	{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
	  PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },

and id->vendor will be PCI_ANY_ID so we bail before applying the quirk.
because....

static inline const struct pci_device_id *
pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev)
{
	if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) &&
	    (id->device == PCI_ANY_ID || id->device == dev->device) &&
	    (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) &&
	    (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) &&
	    !((id->class ^ dev->class) & id->class_mask))
		return id;
	return NULL;
}

const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
					 struct pci_dev *dev)
{
	if (ids) {
		while (ids->vendor || ids->subvendor || ids->class_mask) {
			if (pci_match_one_device(ids, dev))
				return ids;
			ids++;
		}
	}
	return NULL;
}

So we should check pdev->vendor instead.

-Steve

> -	if (((enum board_ids) id->driver_data) < board_ahci_pcs7)
> +
> +	/* Skip applying the quirk on Denverton and beyond */
> +	if (((enum board_ids) id->driver_data) >= board_ahci_pcs7)
>   		return;
>   
>   	/*
> 


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

* Re: [PATCH] libata/ahci: Fix PCS quirk application
  2019-10-15 21:02 ` Stephen Douthit
@ 2019-10-15 21:26   ` Dan Williams
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2019-10-15 21:26 UTC (permalink / raw)
  To: Stephen Douthit; +Cc: axboe, Andreas Friedrich, stable, linux-ide, linux-kernel

On Tue, Oct 15, 2019 at 2:02 PM Stephen Douthit
<stephend@silicom-usa.com> wrote:
>
> On 10/15/19 3:54 PM, Dan Williams wrote:
> > Commit c312ef176399 "libata/ahci: Drop PCS quirk for Denverton and
> > beyond" got the polarity wrong on the check for which board-ids should
> > have the quirk applied. The board type board_ahci_pcs7 is defined at the
> > end of the list such that "pcs7" boards can be special cased in the
> > future if they need the quirk. All prior Intel board ids "<
> > board_ahci_pcs7" should proceed with applying the quirk.
> >
> > Reported-by: Andreas Friedrich <afrie@gmx.net>
> > Reported-by: Stephen Douthit <stephend@silicom-usa.com>
> > Fixes: c312ef176399 ("libata/ahci: Drop PCS quirk for Denverton and beyond")
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> > ---
> >   drivers/ata/ahci.c |    4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> > index dd92faf197d5..05c2b32dcc4d 100644
> > --- a/drivers/ata/ahci.c
> > +++ b/drivers/ata/ahci.c
> > @@ -1600,7 +1600,9 @@ static void ahci_intel_pcs_quirk(struct pci_dev *pdev, struct ahci_host_priv *hp
> >        */
> >       if (!id || id->vendor != PCI_VENDOR_ID_INTEL)
> >               return;
>
> Unless I'm missing something this will short-circuit if there are any
> older Intel controllers not explicitly listed with a PCI_VDEVICE entry
> in ahci_pci_tbl.  Those will match on:
>
>         /* Generic, PCI class code for AHCI */
>         { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
>           PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },

You're not missing anything, but I think we should stick with explicit
mapping as only newer controllers tend to match on class id rather
than pci-id, and there's no way to know if that class-id match is for
PCS_6 or PCS_7. Hopefully newer controllers are tested with Linux and
the BIOS fixed prior to the breakage leaking into the wild.

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

end of thread, other threads:[~2019-10-15 21:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 19:54 [PATCH] libata/ahci: Fix PCS quirk application Dan Williams
2019-10-15 20:10 ` Jens Axboe
2019-10-15 21:02 ` Stephen Douthit
2019-10-15 21:26   ` Dan Williams

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).