Skip to contentSkip to conversation

Lookup PCS offset, and cleanup hex formatting

PATCH Applied Stephen Douthit 2 participants 4 messages Aug 9, 2019 libata

lore
Share & tools
lore
#0 lore raw

v2 cover Lookup PCS offset, and cleanup hex formatting

v2: Fix case of hex values

Stephen Douthit (2):
ata: ahci: Lookup PCS register offset based on PCI device ID
ata: ahci: Cleanup hex values to use lowercase everywhere

 drivers/ata/ahci.c | 62 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 49 insertions(+), 13 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v2 1/2 ata: ahci: Lookup PCS register offset based on PCI device ID

Intel moved the PCS register from 0x92 to 0x94 on Denverton for some reason, so now we get to check the device ID before poking it on reset.

---
 drivers/ata/ahci.c | 42 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)
drivers/ata/ahci.c +39 -3
index f7652baa6337..7e4abeb10606 100644
@@ -623,6 +623,41 @@ static void ahci_pci_save_initial_config(struct pci_dev *pdev,
 	ahci_save_initial_config(&pdev->dev, hpriv);
 }
 
+/*
+ * Intel moved the PCS register on the Denverton AHCI controller, see which
+ * offset this controller is using
+ */
+static int ahci_pcs_offset(struct ata_host *host)
+{
+	struct pci_dev *pdev = to_pci_dev(host->dev);
+
+	switch (pdev->device) {
+	case 0x19b0:
+	case 0x19b1:
+	case 0x19b2:
+	case 0x19b3:
+	case 0x19b4:
+	case 0x19b5:
+	case 0x19b6:
+	case 0x19b7:
+	case 0x19be:
+	case 0x19bf:
+	case 0x19c0:
+	case 0x19c1:
+	case 0x19c2:
+	case 0x19c3:
+	case 0x19c4:
+	case 0x19c5:
+	case 0x19c6:
+	case 0x19c7:
+	case 0x19ce:
+	case 0x19cf:
+		return 0x94;
+	}
+
+	return 0x92;
+}
+
 static int ahci_pci_reset_controller(struct ata_host *host)
 {
 	struct pci_dev *pdev = to_pci_dev(host->dev);
@@ -634,13 +669,14 @@ static int ahci_pci_reset_controller(struct ata_host *host)
 
 	if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
 		struct ahci_host_priv *hpriv = host->private_data;
+		int pcs = ahci_pcs_offset(host);
 		u16 tmp16;
 
 		/* configure PCS */
-		pci_read_config_word(pdev, 0x92, &tmp16);
+		pci_read_config_word(pdev, pcs, &tmp16);
 		if ((tmp16 & hpriv->port_map) != hpriv->port_map) {
-			tmp16 |= hpriv->port_map;
-			pci_write_config_word(pdev, 0x92, tmp16);
+			tmp16 |= hpriv->port_map & 0xff;
+			pci_write_config_word(pdev, pcs, tmp16);
 		}
 	}
 
Signature · 1 line
2.21.0
#2 lore raw

PATCH v2 2/2 ata: ahci: Cleanup hex values to use lowercase everywhere

In reply to Stephen Douthit

Result of sed -i 's/\(0x[0-9a-fA-F]\{1,\}\)/\L\1/' drivers/ata/ahci.c

No functional change intended.

---
 drivers/ata/ahci.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/ata/ahci.c +10 -10
index 7e4abeb10606..ce7373f0a861 100644
@@ -272,8 +272,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	{ PCI_VDEVICE(INTEL, 0x19b5), board_ahci }, /* DNV AHCI */
 	{ PCI_VDEVICE(INTEL, 0x19b6), board_ahci }, /* DNV AHCI */
 	{ PCI_VDEVICE(INTEL, 0x19b7), board_ahci }, /* DNV AHCI */
-	{ PCI_VDEVICE(INTEL, 0x19bE), board_ahci }, /* DNV AHCI */
-	{ PCI_VDEVICE(INTEL, 0x19bF), board_ahci }, /* DNV AHCI */
+	{ PCI_VDEVICE(INTEL, 0x19be), board_ahci }, /* DNV AHCI */
+	{ PCI_VDEVICE(INTEL, 0x19bf), board_ahci }, /* DNV AHCI */
 	{ PCI_VDEVICE(INTEL, 0x19c0), board_ahci }, /* DNV AHCI */
 	{ PCI_VDEVICE(INTEL, 0x19c1), board_ahci }, /* DNV AHCI */
 	{ PCI_VDEVICE(INTEL, 0x19c2), board_ahci }, /* DNV AHCI */
@@ -282,8 +282,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	{ PCI_VDEVICE(INTEL, 0x19c5), board_ahci }, /* DNV AHCI */
 	{ PCI_VDEVICE(INTEL, 0x19c6), board_ahci }, /* DNV AHCI */
 	{ PCI_VDEVICE(INTEL, 0x19c7), board_ahci }, /* DNV AHCI */
-	{ PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */
-	{ PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */
+	{ PCI_VDEVICE(INTEL, 0x19ce), board_ahci }, /* DNV AHCI */
+	{ PCI_VDEVICE(INTEL, 0x19cf), board_ahci }, /* DNV AHCI */
 	{ PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
 	{ PCI_VDEVICE(INTEL, 0x1c03), board_ahci_mobile }, /* CPT M AHCI */
 	{ PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
@@ -506,7 +506,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	{ PCI_VDEVICE(SI, 0x0186), board_ahci },		/* SiS 968 */
 
 	/* ST Microelectronics */
-	{ PCI_VDEVICE(STMICRO, 0xCC06), board_ahci },		/* ST ConneXt */
+	{ PCI_VDEVICE(STMICRO, 0xcc06), board_ahci },		/* ST ConneXt */
 
 	/* Marvell */
 	{ PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv },	/* 6145 */
@@ -1192,7 +1192,7 @@ static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
 				DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6310"),
 			},
 			/* PCI slot number of the controller */
-			.driver_data = (void *)0x1FUL,
+			.driver_data = (void *)0x1fUL,
 		},
 		{
 			.ident = "HP Compaq 6720s",
@@ -1201,7 +1201,7 @@ static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
 				DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6720s"),
 			},
 			/* PCI slot number of the controller */
-			.driver_data = (void *)0x1FUL,
+			.driver_data = (void *)0x1fUL,
 		},
 
 		{ }	/* terminate list */
@@ -1490,9 +1490,9 @@ static void acer_sa5_271_workaround(struct ahci_host_priv *hpriv,
 
 	if (dmi_check_system(sysids)) {
 		dev_info(&pdev->dev, "enabling Acer Switch Alpha 12 workaround\n");
-		if ((hpriv->saved_cap & 0xC734FF00) == 0xC734FF00) {
+		if ((hpriv->saved_cap & 0xc734ff00) == 0xC734FF00) {
 			hpriv->port_map = 0x7;
-			hpriv->cap = 0xC734FF02;
+			hpriv->cap = 0xc734ff02;
 		}
 	}
 }
@@ -1691,7 +1691,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 			 "PDC42819 can only drive SATA devices with this driver\n");
 
 	/* Some devices use non-standard BARs */
-	if (pdev->vendor == PCI_VENDOR_ID_STMICRO && pdev->device == 0xCC06)
+	if (pdev->vendor == PCI_VENDOR_ID_STMICRO && pdev->device == 0xcc06)
 		ahci_pci_bar = AHCI_PCI_BAR_STA2X11;
 	else if (pdev->vendor == 0x1c44 && pdev->device == 0x8000)
 		ahci_pci_bar = AHCI_PCI_BAR_ENMOTUS;
Signature · 1 line
2.21.0
Applied
#3 lore raw
In reply to Stephen Douthit
Quoted 8 lines · Stephen Douthit

v2: Fix case of hex values

Stephen Douthit (2):
ata: ahci: Lookup PCS register offset based on PCI device ID
ata: ahci: Cleanup hex values to use lowercase everywhere

  drivers/ata/ahci.c | 62 ++++++++++++++++++++++++++++++++++++----------
  1 file changed, 49 insertions(+), 13 deletions(-)

Thanks, applied.

Signature · 1 line
Jens Axboe