Skip to contentSkip to conversation

ahci: enable pmp but connected to HDD issue fixed

PATCH In review Yuan-Hsin Chen 4 participants 18 messages Jun 14, 2011 – Jun 21, 2011 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ahci: enable pmp but connected to HDD issue fixed

From: Yuan-Hsin Chen <[email protected]>

When enabling both port multiplier and platform ahci sata, ahci times out while connecting to HDD directly. This is because soft reset fails with IPMS set. Do soft reset again to port 0.

The soft reset sequence is copied from ahci.c.

---
 drivers/ata/ahci_platform.c |   62 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 61 insertions(+), 1 deletions(-)
drivers/ata/ahci_platform.c +61 -1
index 6fef1fa..6eab716 100644
@@ -27,6 +27,66 @@ static struct scsi_host_template ahci_platform_sht = {
 	AHCI_SHT("ahci_platform"),
 };
 
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+			  unsigned long deadline);
+
+static struct ata_port_operations ahci_pmp_ops = {
+	.inherits		= &ahci_ops,
+	.softreset		= ahci_pmp_softreset,
+	.pmp_softreset		= ahci_pmp_softreset,
+};
+
+static int ahci_pmp_check_ready(struct ata_link *link)
+{
+	void __iomem *port_mmio = ahci_port_base(link->ap);
+	u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
+	u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
+
+	/*
+	 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
+	 * which can save timeout delay.
+	 */
+	if (irq_status & PORT_IRQ_BAD_PMP)
+		return -EIO;
+
+	printk("%s:TFT 0x%x\n", __func__, status);
+	return ata_check_ready(status);
+}
+
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+				unsigned long deadline)
+{
+	struct ata_port *ap = link->ap;
+	void __iomem *port_mmio = ahci_port_base(ap);
+	int pmp = sata_srst_pmp(link);
+	int rc;
+	u32 irq_sts;
+
+	DPRINTK("ENTER\n");
+
+	rc = ahci_do_softreset(link, class, pmp, deadline,
+			       ahci_pmp_check_ready);
+
+	/*
+	 * Soft reset fails with IPMS set when PMP is enabled but
+	 * SATA HDD/ODD is connected to SATA port, do soft reset
+	 * again to port 0.
+	 */
+	if (rc == -EIO) {
+		irq_sts = readl(port_mmio + PORT_IRQ_STAT);
+		if (irq_sts & PORT_IRQ_BAD_PMP) {
+			ata_link_printk(link, KERN_WARNING,
+					"applying PMP SRST workaround "
+					"and retrying\n");
+			rc = ahci_do_softreset(link, class, 0, deadline,
+					       ahci_check_ready);
+		}
+	}
+
+	return rc;
+}
+
+
 static int __init ahci_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -35,7 +95,7 @@ static int __init ahci_probe(struct platform_device *pdev)
 		.flags		= AHCI_FLAG_COMMON,
 		.pio_mask	= ATA_PIO4,
 		.udma_mask	= ATA_UDMA6,
-		.port_ops	= &ahci_ops,
+		.port_ops	= &ahci_pmp_ops,
 	};
 	const struct ata_port_info *ppi[] = { &pi, NULL };
 	struct ahci_host_priv *hpriv;
Signature · 1 line
1.7.3.1
#1 lore raw
Quoted 7 lines · Yuan-Hsin Chen

From: Yuan-Hsin Chen <[email protected]>

When enabling both port multiplier and platform ahci sata, ahci times out while connecting to HDD directly. This is because soft reset fails with IPMS set. Do soft reset again to port 0.

The soft reset sequence is copied from ahci.c.

This is the same one as ahci_sb600_softreset(), right? Please don't copy & paste like that. Rename and ahci_sb600_softreset() to libahci.c, create a separate ata_port_operations for it and use the ops for the affected controllers.

Thanks.

Signature · 1 line
tejun
#18 lore raw

PATCH 1/1 ahci: enable pmp but connected to HDD issue fixed

In reply to a message not in the archive

Since more than one controllers has software reset failed problem when PMP enabled, I think it would be better to move ahci_sb600_softreset() from ahci.c to libahci.c and rename it, let's say: ahci_pmpenable_softreset() . (Just arbitrary
name, please someone may give a better function name)
Controller that has software reset problem when PMP enable may point its softreset and pmp_softreset call back function of struct ata_port_operations to ahci_pmpenable_softreset(). Regardless of PCI or Platform based AHCI controller. (ahci.c or ahci_platform.c)
Regards,
BingJiun

Quoted 101 lines · Yuan-Hsin Chen

From: Yuan-Hsin Chen <[email protected]>

When enabling both port multiplier and platform ahci sata, ahci times out while connecting to HDD directly. This is because soft reset fails with IPMS set. Do soft reset again to port 0.

The soft reset sequence is copied from ahci.c.

---
 drivers/ata/ahci_platform.c |   62 ++++++++++++++++++++++++++++++++++++++++++-

 1 files changed, 61 insertions(+), 1 deletions(-)
drivers/ata/ahci_platform.c +61 -2
index 6fef1fa..6eab716 100644
@@ -27,6 +27,66 @@ static struct scsi_host_template ahci_platform_sht = {
        AHCI_SHT("ahci_platform"),
  };
 
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+                         unsigned long deadline);
+
+static struct ata_port_operations ahci_pmp_ops = {
+       .inherits               = &ahci_ops,
+       .softreset              = ahci_pmp_softreset,
+       .pmp_softreset          = ahci_pmp_softreset,
+};
+
+static int ahci_pmp_check_ready(struct ata_link *link)
+{
+       void __iomem *port_mmio = ahci_port_base(link->ap);
+       u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
+       u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
+
+       /*
+        * There is no need to check TFDATA if BAD PMP is found due to HW bug,
+        * which can save timeout delay.
+        */
+       if (irq_status & PORT_IRQ_BAD_PMP)
+               return -EIO;
+
+       printk("%s:TFT 0x%x\n", __func__, status);
+       return ata_check_ready(status);
+}
+
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+                               unsigned long deadline)
+{
+       struct ata_port *ap = link->ap;
+       void __iomem *port_mmio = ahci_port_base(ap);
+       int pmp = sata_srst_pmp(link);
+       int rc;
+       u32 irq_sts;
+
+       DPRINTK("ENTER\n");
+
+       rc = ahci_do_softreset(link, class, pmp, deadline,
+                              ahci_pmp_check_ready);
+
+       /*
+        * Soft reset fails with IPMS set when PMP is enabled but
+        * SATA HDD/ODD is connected to SATA port, do soft reset
+        * again to port 0.
+        */
+       if (rc == -EIO) {
+               irq_sts = readl(port_mmio + PORT_IRQ_STAT);
+               if (irq_sts & PORT_IRQ_BAD_PMP) {
+                       ata_link_printk(link, KERN_WARNING,
+                                       "applying PMP SRST workaround "
+                                       "and retrying\n");
+                       rc = ahci_do_softreset(link, class, 0, deadline,
+                                              ahci_check_ready);
+               }
+       }
+
+       return rc;
+}
+
+
  static int __init ahci_probe(struct platform_device *pdev)
  {
        struct device *dev = &pdev->dev;
@@ -35,7 +95,7 @@ static int __init ahci_probe(struct platform_device *pdev)
                .flags          = AHCI_FLAG_COMMON,
                .pio_mask       = ATA_PIO4,
                .udma_mask      = ATA_UDMA6,
-               .port_ops       = &ahci_ops,
+               .port_ops       = &ahci_pmp_ops,
        };
        const struct ata_port_info *ppi[] = { &pi, NULL };
        struct ahci_host_priv *hpriv;
--

1.7.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#2 lore raw

PATCH v2 1/1 ahci: fix pmp softreset with HDD

In reply to Tejun Heo

From: Yuan-Hsin Chen <[email protected]>

When enabling both port multiplier and platform ahci sata, ahci times out while connecting to HDD directly. This is because soft reset fails with IPMS set. Do soft reset again to port 0.

The soft reset sequence is copied from ahci.c.

---
v2:
1.add ahci_pmp_softreset function and ahci_pmp_ops to libahci.c 2.add SATA_PMP_RST to Kconfig

 drivers/ata/Kconfig         |   10 +++++++
 drivers/ata/ahci.h          |    1 +
 drivers/ata/ahci_platform.c |    4 +++
 drivers/ata/libahci.c       |   59 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 0 deletions(-)
drivers/ata/Kconfig +10 -0
index 75afa75..a6681df 100644
@@ -65,6 +65,16 @@ config SATA_PMP
 	  This option adds support for SATA Port Multipliers
 	  (the SATA version of an ethernet hub, or SAS expander).
 
+config SATA_PMP_RST
+	bool "SATA PMP softreset"
+	depends on SATA_PMP
+	default n
+	help
+	  When enabling both port multiplier and platform ahci sata,
+	  ahci times out while connecting to HDD directly in some
+	  ahci controller. This is because soft reset fails with
+	  IPMS set. Do soft reset again to port 0.
+
 comment "Controllers with non-SFF native interface"
 
 config SATA_AHCI
drivers/ata/ahci.h +1 -0
index 12c5282..e20f8d7 100644
@@ -312,6 +312,7 @@ extern struct device_attribute *ahci_sdev_attrs[];
 	.sdev_attrs		= ahci_sdev_attrs
 
 extern struct ata_port_operations ahci_ops;
+extern struct ata_port_operations ahci_pmp_ops;
 
 void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
 			u32 opts);
drivers/ata/ahci_platform.c +4 -0
index 6fef1fa..1c6dc16 100644
@@ -35,7 +35,11 @@ static int __init ahci_probe(struct platform_device *pdev)
 		.flags		= AHCI_FLAG_COMMON,
 		.pio_mask	= ATA_PIO4,
 		.udma_mask	= ATA_UDMA6,
+#ifdef CONFIG_SATA_PMP_RST
+		.port_ops	= &ahci_pmp_ops,
+#else
 		.port_ops	= &ahci_ops,
+#endif
 	};
 	const struct ata_port_info *ppi[] = { &pi, NULL };
 	struct ahci_host_priv *hpriv;
drivers/ata/libahci.c +59 -0

77 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#3 lore raw

Re: [PATCH v2] ahci: fix pmp softreset with HDD

Hello,

Quoted 10 lines · Yuan-Hsin Chen

From: Yuan-Hsin Chen <[email protected]>

When enabling both port multiplier and platform ahci sata, ahci times out while connecting to HDD directly. This is because soft reset fails with IPMS set. Do soft reset again to port 0.

The soft reset sequence is copied from ahci.c.

Getting closer.

drivers/ata/Kconfig config SATA_PMP · line 77

Quoted 10 lines
drivers/ata/Kconfig +10 -0
+config SATA_PMP_RST
+	bool "SATA PMP softreset"
+	depends on SATA_PMP
+	default n
+	help
+	  When enabling both port multiplier and platform ahci sata,
+	  ahci times out while connecting to HDD directly in some
+	  ahci controller. This is because soft reset fails with
+	  IPMS set. Do soft reset again to port 0.
+

Hmmm... Is there any way to detect the specific controller from ahci_platform.c? This is workaround for a controller bug. It should be enabled automatically. Making it a config option doesn't make whole lot of sense.

Quoted 43 lines
drivers/ata/libahci.c +39 -0
@@ -1329,6 +1338,56 @@ static int ahci_softreset(struct ata_link *link, unsigned int *class,
 }
 EXPORT_SYMBOL_GPL(ahci_do_softreset);
 
+static int ahci_pmp_check_ready(struct ata_link *link)
+{
+	void __iomem *port_mmio = ahci_port_base(link->ap);
+	u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
+	u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
+
+	/*
+	 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
+	 * which can save timeout delay.
+	 */
+	if (irq_status & PORT_IRQ_BAD_PMP)
+		return -EIO;
+
+	printk("%s:TFT 0x%x\n", __func__, status);
+	return ata_check_ready(status);
+}
+
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+				unsigned long deadline)
+{
+	struct ata_port *ap = link->ap;
+	void __iomem *port_mmio = ahci_port_base(ap);
+	int pmp = sata_srst_pmp(link);
+	int rc;
+	u32 irq_sts;
+
+	DPRINTK("ENTER\n");
+
+	rc = ahci_do_softreset(link, class, pmp, deadline,
+			       ahci_pmp_check_ready);
+
+	/*
+	 * Soft reset fails with IPMS set when PMP is enabled but
+	 * SATA HDD/ODD is connected to SATA port, do soft reset
+	 * again to port 0.
+	 */
+	if (rc == -EIO) {
+		irq_sts = readl(port_mmio + PORT_IRQ_STAT);
+		if (irq_sts & PORT_IRQ_BAD_PMP) {

drivers/ata/libahci.c static int ahci_softreset(struct ata_link *link, unsigned int *class, · line 1389

Quoted 10 lines
drivers/ata/libahci.c +10 -0
+			ata_link_printk(link, KERN_WARNING,
+					"applying PMP SRST workaround "
+					"and retrying\n");
+			rc = ahci_do_softreset(link, class, 0, deadline,
+					       ahci_check_ready);
+		}
+	}
+
+	return rc;
+}

Please make two separate patches. One to rename & move sb600 ops to libahci.c and another to use it for platform. There's no reason to have two identical sets of functions doing the same thing.

Thanks.

Signature · 1 line
tejun
#4 lore raw

PATCH v3 1/1 ahci: move ahci_sb600_softreset to libahci.c and rename it

From: Yuan-Hsin Chen <[email protected]>

ahci_sb600_softreset was in ahci.c. This function is used to fix soft reset failure and renames as ahci_pmp_softreset in libahci.c.

---
v3:
Move ahci_sb600_softreset to libahci.c and rename it.
Add ahci_pmp_ops to libahci.c
Add following stuff in your platform dependent code to use ahci_pmp_ops

#include <linux/ahci_platform.h>
#include <../../../drivers/ata/ahci.h>

static struct ata_port_info ftsata100_pi =

	.flags = AHCI_FLAG_COMMON,
	.pio_mask = ATA_PIO4,
	.udma_mask = ATA_UDMA6,
	.port_ops = &ahci_pmp_ops,
};
static struct ahci_platform_data ftsata100_pdata = {
	.ata_port_info = &ftsata100_pi,
};
static struct platform_device ftsata100_device = {
	...
        .dev	= {
		...
                .platform_data = &ftsata100_pdata,
        },
};
 drivers/ata/ahci.c    |   55 +--------------------------------------------
 drivers/ata/ahci.h    |    1 +
 drivers/ata/libahci.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 53 deletions(-)
drivers/ata/ahci.c +2 -53
index 71afe03..c67f621 100644
@@ -79,8 +79,6 @@ enum board_ids {
 };
 
 static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
-			  unsigned long deadline);
 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 				 unsigned long deadline);
 static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
@@ -106,8 +104,8 @@ static struct ata_port_operations ahci_p5wdh_ops = {
 
 static struct ata_port_operations ahci_sb600_ops = {
 	.inherits		= &ahci_ops,
-	.softreset		= ahci_sb600_softreset,
-	.pmp_softreset		= ahci_sb600_softreset,
+	.softreset		= ahci_pmp_softreset,
+	.pmp_softreset		= ahci_pmp_softreset,
 };
 
 #define AHCI_HFLAGS(flags)	.private_data	= (void *)(flags)
@@ -502,55 +500,6 @@ static void ahci_pci_init_controller(struct ata_host *host)
 	ahci_init_controller(host);
 }
 
-static int ahci_sb600_check_ready(struct ata_link *link)
-{
-	void __iomem *port_mmio = ahci_port_base(link->ap);
-	u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
-	u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
-
-	/*
-	 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
-	 * which can save timeout delay.
-	 */
-	if (irq_status & PORT_IRQ_BAD_PMP)
-		return -EIO;
-
-	return ata_check_ready(status);
-}
-
-static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
-				unsigned long deadline)
-{
-	struct ata_port *ap = link->ap;
-	void __iomem *port_mmio = ahci_port_base(ap);
-	int pmp = sata_srst_pmp(link);
-	int rc;
-	u32 irq_sts;
-
-	DPRINTK("ENTER\n");
-
-	rc = ahci_do_softreset(link, class, pmp, deadline,
-			       ahci_sb600_check_ready);
-
-	/*
-	 * Soft reset fails on some ATI chips with IPMS set when PMP
-	 * is enabled but SATA HDD/ODD is connected to SATA port,
-	 * do soft reset again to port 0.
-	 */
-	if (rc == -EIO) {
-		irq_sts = readl(port_mmio + PORT_IRQ_STAT);
-		if (irq_sts & PORT_IRQ_BAD_PMP) {
-			ata_link_printk(link, KERN_WARNING,
-					"applying SB600 PMP SRST workaround "
-					"and retrying\n");
-			rc = ahci_do_softreset(link, class, 0, deadline,
-					       ahci_check_ready);
-		}
-	}
-
-	return rc;
-}
-
 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 				 unsigned long deadline)
 {
drivers/ata/ahci.h +1 -0
index 12c5282..e20f8d7 100644
@@ -312,6 +312,7 @@ extern struct device_attribute *ahci_sdev_attrs[];
 	.sdev_attrs		= ahci_sdev_attrs
 
 extern struct ata_port_operations ahci_ops;
+extern struct ata_port_operations ahci_pmp_ops;
 
 void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
 			u32 opts);
drivers/ata/libahci.c +59 -0

77 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#5 lore raw

Re: [PATCH v3] ahci: move ahci_sb600_softreset to libahci.c and rename it

Hello.

Quoted 44 lines · Yuan-Hsin Chen

From: Yuan-Hsin Chen<[email protected]>

ahci_sb600_softreset was in ahci.c. This function is used to fix soft reset failure and renames as ahci_pmp_softreset in libahci.c.

---
v3:
Move ahci_sb600_softreset to libahci.c and rename it.
Add ahci_pmp_ops to libahci.c
Add following stuff in your platform dependent code to use ahci_pmp_ops

#include <linux/ahci_platform.h>
#include<../../../drivers/ata/ahci.h>

static struct ata_port_info ftsata100_pi =

	.flags = AHCI_FLAG_COMMON,
	.pio_mask = ATA_PIO4,
	.udma_mask = ATA_UDMA6,
	.port_ops = &ahci_pmp_ops,
};
static struct ahci_platform_data ftsata100_pdata = {
	.ata_port_info =&ftsata100_pi,
};
static struct platform_device ftsata100_device = {
	...
         .dev	= {
		...
                 .platform_data =&ftsata100_pdata,
         },
};
  drivers/ata/ahci.c    |   55 +--------------------------------------------
  drivers/ata/ahci.h    |    1 +
  drivers/ata/libahci.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 62 insertions(+), 53 deletions(-)
drivers/ata/ahci.c +0 -0
index 71afe03..c67f621 100644

[...]

Quoted 11 lines
drivers/ata/ahci.c +2 -2
@@ -106,8 +104,8 @@ static struct ata_port_operations ahci_p5wdh_ops = {
 
  static struct ata_port_operations ahci_sb600_ops = {
  	.inherits		=&ahci_ops,
-	.softreset		= ahci_sb600_softreset,
-	.pmp_softreset		= ahci_sb600_softreset,
+	.softreset		= ahci_pmp_softreset,
+	.pmp_softreset		= ahci_pmp_softreset,
  };
 
  #define AHCI_HFLAGS(flags)	.private_data	= (void *)(flags)

[...]

drivers/ata/libahci.c static void ahci_pmp_attach(struct ata_port *ap); · line 86

Quoted 10 lines
drivers/ata/libahci.c +2 -0
index d38c40f..c4cbee9 100644
@@ -82,6 +82,8 @@ static void ahci_pmp_attach(struct ata_port *ap);
  static void ahci_pmp_detach(struct ata_port *ap);
  static int ahci_softreset(struct ata_link *link, unsigned int *class,
  			  unsigned long deadline);
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+			  unsigned long deadline);

How come it's 'static' when you use it in ahci.c?

Quoted 3 lines
drivers/ata/libahci.c +0 -0
  static int ahci_hardreset(struct ata_link *link, unsigned int *class,
  			  unsigned long deadline);
  static void ahci_postreset(struct ata_link *link, unsigned int *class);

[...]

Quoted 8 lines
drivers/ata/libahci.c +4 -0
@@ -1329,6 +1338,56 @@ static int ahci_softreset(struct ata_link *link, unsigned int *class,
  }
  EXPORT_SYMBOL_GPL(ahci_do_softreset);
 
+static int ahci_pmp_check_ready(struct ata_link *link)
+{
+	void __iomem *port_mmio = ahci_port_base(link->ap);
+	u8 status = readl(port_mmio + PORT_TFDATA)&  0xFF;

drivers/ata/libahci.c static int ahci_softreset(struct ata_link *link, unsigned int *class, · line 1354

Quoted 10 lines
drivers/ata/libahci.c +10 -0
+	u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
+
+	/*
+	 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
+	 * which can save timeout delay.
+	 */
+	if (irq_status&  PORT_IRQ_BAD_PMP)
+		return -EIO;
+
+	printk("%s:TFT 0x%x\n", __func__, status);

printk() should have a logging facility. Here you should have probably
used pr_debug()...

WBR, Sergei

#6 lore raw

Re: [PATCH v3] ahci: move ahci_sb600_softreset to libahci.c and rename it

In reply to Yuan-Hsin Chen

Hello, Yuan-Hsin.

Yeap, we're getting almost there. :)

drivers/ata/ahci.h extern struct device_attribute *ahci_sdev_attrs[]; · line 315

Quoted 9 lines · Yuan-Hsin Chen
drivers/ata/ahci.h +1 -0
index 12c5282..e20f8d7 100644
@@ -312,6 +312,7 @@ extern struct device_attribute *ahci_sdev_attrs[];
 	.sdev_attrs		= ahci_sdev_attrs
 
 extern struct ata_port_operations ahci_ops;
+extern struct ata_port_operations ahci_pmp_ops;

But I don't like ahci_pmp_ops name. ahci_ops works just fine for pmp. It's a workaround ops. Maybe something like ahci_pmp_retry_srst_ops?

drivers/ata/ahci.h extern struct device_attribute *ahci_sdev_attrs[]; · line 317

Quoted 2 lines
drivers/ata/ahci.h +2 -0
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+			  unsigned long deadline);

Similarly, ahci_pmp_retry_srst_softreset()

drivers/ata/ahci.h extern struct device_attribute *ahci_sdev_attrs[];

Quoted 5 lines
drivers/ata/ahci.h +5 -0
+struct ata_port_operations ahci_pmp_ops = {
+	.inherits		= &ahci_ops,
+	.softreset		= ahci_pmp_softreset,
+	.pmp_softreset		= ahci_pmp_softreset,
+};

Isn't overriding .softreset enough? .pmp_softreset is used only for downstream links.

Quoted 4 lines
drivers/ata/ahci.h +4 -0
+static int ahci_pmp_check_ready(struct ata_link *link)
+{
+	void __iomem *port_mmio = ahci_port_base(link->ap);
+	u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;

drivers/ata/ahci.h

Quoted 10 lines
drivers/ata/ahci.h +10 -0
+	u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
+
+	/*
+	 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
+	 * which can save timeout delay.
+	 */
+	if (irq_status & PORT_IRQ_BAD_PMP)
+		return -EIO;
+
+	printk("%s:TFT 0x%x\n", __func__, status);

You probably want ata_link_printk(link, KERN_DEBUG, ...);

Thanks.

Signature · 1 line
tejun
#7 lore raw

PATCH v4 1/1 ahci: move ahci_sb600_softreset to libahci.c and rename it

From: Yuan-Hsin Chen <[email protected]>

ahci_sb600_softreset was in ahci.c. This function is used to fix soft reset failure and renames as ahci_pmp_retry_srst_softreset in libahci.c.

---
 drivers/ata/ahci.c    |   54 +---------------------------------------------
 drivers/ata/ahci.h    |    1 +
 drivers/ata/libahci.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 53 deletions(-)
drivers/ata/ahci.c +1 -53
index 71afe03..2de36b6 100644
@@ -79,8 +79,6 @@ enum board_ids {
 };
 
 static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
-			  unsigned long deadline);
 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 				 unsigned long deadline);
 static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
@@ -106,8 +104,7 @@ static struct ata_port_operations ahci_p5wdh_ops = {
 
 static struct ata_port_operations ahci_sb600_ops = {
 	.inherits		= &ahci_ops,
-	.softreset		= ahci_sb600_softreset,
-	.pmp_softreset		= ahci_sb600_softreset,
+	.softreset		= ahci_pmp_retry_srst_softreset,
 };
 
 #define AHCI_HFLAGS(flags)	.private_data	= (void *)(flags)
@@ -502,55 +499,6 @@ static void ahci_pci_init_controller(struct ata_host *host)
 	ahci_init_controller(host);
 }
 
-static int ahci_sb600_check_ready(struct ata_link *link)
-{
-	void __iomem *port_mmio = ahci_port_base(link->ap);
-	u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
-	u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
-
-	/*
-	 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
-	 * which can save timeout delay.
-	 */
-	if (irq_status & PORT_IRQ_BAD_PMP)
-		return -EIO;
-
-	return ata_check_ready(status);
-}
-
-static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
-				unsigned long deadline)
-{
-	struct ata_port *ap = link->ap;
-	void __iomem *port_mmio = ahci_port_base(ap);
-	int pmp = sata_srst_pmp(link);
-	int rc;
-	u32 irq_sts;
-
-	DPRINTK("ENTER\n");
-
-	rc = ahci_do_softreset(link, class, pmp, deadline,
-			       ahci_sb600_check_ready);
-
-	/*
-	 * Soft reset fails on some ATI chips with IPMS set when PMP
-	 * is enabled but SATA HDD/ODD is connected to SATA port,
-	 * do soft reset again to port 0.
-	 */
-	if (rc == -EIO) {
-		irq_sts = readl(port_mmio + PORT_IRQ_STAT);
-		if (irq_sts & PORT_IRQ_BAD_PMP) {
-			ata_link_printk(link, KERN_WARNING,
-					"applying SB600 PMP SRST workaround "
-					"and retrying\n");
-			rc = ahci_do_softreset(link, class, 0, deadline,
-					       ahci_check_ready);
-		}
-	}
-
-	return rc;
-}
-
 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 				 unsigned long deadline)
 {
drivers/ata/ahci.h +1 -0
index 12c5282..b175000 100644
@@ -312,6 +312,7 @@ extern struct device_attribute *ahci_sdev_attrs[];
 	.sdev_attrs		= ahci_sdev_attrs
 
 extern struct ata_port_operations ahci_ops;
+extern struct ata_port_operations ahci_pmp_retry_srst_ops;
 
 void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
 			u32 opts);
drivers/ata/libahci.c +57 -0

75 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#8 lore raw

Re: [PATCH v4] ahci: move ahci_sb600_softreset to libahci.c and rename it

Hello.

Quoted 20 lines · Yuan-Hsin Chen

From: Yuan-Hsin Chen<[email protected]>

ahci_sb600_softreset was in ahci.c. This function is used to fix soft reset failure and renames as ahci_pmp_retry_srst_softreset in libahci.c.

drivers/ata/ahci.c +0 -2
index 71afe03..2de36b6 100644
@@ -79,8 +79,6 @@ enum board_ids {
  };
 
  static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
-			  unsigned long deadline);
  static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
  				 unsigned long deadline);
  static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,

drivers/ata/ahci.c static struct ata_port_operations ahci_p5wdh_ops = { · line 107

Quoted 6 lines
drivers/ata/ahci.c +1 -2
@@ -106,8 +104,7 @@ static struct ata_port_operations ahci_p5wdh_ops = {
 
  static struct ata_port_operations ahci_sb600_ops = {
  	.inherits		=&ahci_ops,
-	.softreset		= ahci_sb600_softreset,
-	.pmp_softreset		= ahci_sb600_softreset,
+	.softreset		= ahci_pmp_retry_srst_softreset,

I have to ask you again: have you tried to compile this?

drivers/ata/libahci.c static void ahci_pmp_attach(struct ata_port *ap); · line 86

Quoted 10 lines
drivers/ata/libahci.c +2 -0
index d38c40f..0fd5a30 100644
@@ -82,6 +82,8 @@ static void ahci_pmp_attach(struct ata_port *ap);
  static void ahci_pmp_detach(struct ata_port *ap);
  static int ahci_softreset(struct ata_link *link, unsigned int *class,
  			  unsigned long deadline);
+static int ahci_pmp_retry_srst_softreset(struct ata_link *link, unsigned int *class,
+			  unsigned long deadline);

How come this is static if you reference it outside this module?

WBR, Sergei

#10 lore raw

Re: [PATCH v4] ahci: move ahci_sb600_softreset to libahci.c and rename it

In reply to Yuan-Hsin Chen

Hello, Yuan.

Yeap, almost there, just few very minor things. :)

drivers/ata/ahci.c static struct ata_port_operations ahci_p5wdh_ops = { · line 108

Quoted 6 lines · Yuan-Hsin Chen

static struct ata_port_operations ahci_sb600_ops = {

drivers/ata/ahci.c +1 -2
 	.inherits		= &ahci_ops,
-	.softreset		= ahci_sb600_softreset,
-	.pmp_softreset		= ahci_sb600_softreset,
+	.softreset		= ahci_pmp_retry_srst_softreset,
 };

Why doesn't sb600 just use ahci_pmp_retry_srst_ops?

drivers/ata/ahci.h extern struct device_attribute *ahci_sdev_attrs[]; · line 315

Quoted 5 lines
drivers/ata/ahci.h +1 -0
@@ -312,6 +312,7 @@ extern struct device_attribute *ahci_sdev_attrs[];
 	.sdev_attrs		= ahci_sdev_attrs
 
 extern struct ata_port_operations ahci_ops;
+extern struct ata_port_operations ahci_pmp_retry_srst_ops;

Heh, I know I suggested that name but that is one ugly name. If anyone has any better idea, please come forward.

drivers/ata/libahci.c static void ahci_pmp_attach(struct ata_port *ap); · line 86

Quoted 6 lines
drivers/ata/libahci.c +2 -0
@@ -82,6 +82,8 @@ static void ahci_pmp_attach(struct ata_port *ap);
 static void ahci_pmp_detach(struct ata_port *ap);
 static int ahci_softreset(struct ata_link *link, unsigned int *class,
 			  unsigned long deadline);
+static int ahci_pmp_retry_srst_softreset(struct ata_link *link, unsigned int *class,
+			  unsigned long deadline);

srst equals softreset, so ahci_pmp_retry_softreset() should do.

drivers/ata/libahci.c struct device_attribute *ahci_sdev_attrs[] = { · line 153

Quoted 8 lines
drivers/ata/libahci.c +6 -0
+struct ata_port_operations ahci_pmp_retry_srst_ops = {
+	.inherits		= &ahci_ops,
+	.softreset		= ahci_pmp_retry_srst_softreset,
+};
+EXPORT_SYMBOL_GPL(ahci_pmp_retry_srst_ops);
+
 struct ata_port_operations ahci_ops = {
 	.inherits		= &sata_pmp_port_ops,

Maybe it's better to place ahci_pmp_retry_srst_ops after ahci_ops?

Quoted 1 line

+static int ahci_pmp_check_ready(struct ata_link *link)

It would be better if the name reflects that it's not for specific workaround.

Thank you.

Signature · 1 line
tejun
#9 lore raw

Re: [PATCH v4] ahci: move ahci_sb600_softreset to libahci.c and rename it

In reply to Sergei Shtylyov

Hello.
I'm really sorry for ignoring your previous e-mail. I'll fix it in the next patch. Thanks for reviewing my patch.

Yuan-Hsin

Quoted 53 lines · Sergei Shtylyov

Hello.

Quoted 24 lines · Yuan-Hsin Chen

From: Yuan-Hsin Chen<[email protected]>

ahci_sb600_softreset was in ahci.c. This function is used to fix soft reset failure and renames as ahci_pmp_retry_srst_softreset in libahci.c.

drivers/ata/ahci.c +0 -0
index 71afe03..2de36b6 100644
@@ -79,8 +79,6 @@ enum board_ids {
  };
 

 static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
-                         unsigned long deadline);
 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
                                unsigned long deadline); static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,

drivers/ata/ahci.c static struct ata_port_operations ahci_p5wdh_ops = { · line 107

Quoted 6 lines
drivers/ata/ahci.c +1 -2
@@ -106,8 +104,7 @@ static struct ata_port_operations ahci_p5wdh_ops = {
 
  static struct ata_port_operations ahci_sb600_ops = {
        .inherits               =&ahci_ops,
-       .softreset              = ahci_sb600_softreset,
-       .pmp_softreset          = ahci_sb600_softreset,
+       .softreset              = ahci_pmp_retry_srst_softreset,

  I have to ask you again: have you tried to compile this?

drivers/ata/libahci.c static void ahci_pmp_attach(struct ata_port *ap); · line 87

Quoted 11 lines
drivers/ata/libahci.c +2 -0
index d38c40f..0fd5a30 100644
@@ -82,6 +82,8 @@ static void ahci_pmp_attach(struct ata_port *ap);
  static void ahci_pmp_detach(struct ata_port *ap);
  static int ahci_softreset(struct ata_link *link, unsigned int *class,
                          unsigned long deadline);
+static int ahci_pmp_retry_srst_softreset(struct ata_link *link, unsigned
 int *class,
+                         unsigned long deadline);

  How come this is static if you reference it outside this module?

WBR, Sergei

#11 lore raw

Re: [PATCH v4] ahci: move ahci_sb600_softreset to libahci.c and rename it

In reply to Tejun Heo

Hello.

Quoted 14 lines · Tejun Heo

Hello, Yuan.

Yeap, almost there, just few very minor things. :)

Quoted 6 lines · Yuan-Hsin Chen

 static struct ata_port_operations ahci_sb600_ops = { .inherits               = &ahci_ops,
-     .softreset              = ahci_sb600_softreset,
-     .pmp_softreset          = ahci_sb600_softreset,
+     .softreset              = ahci_pmp_retry_srst_softreset, };

Why doesn't sb600 just use ahci_pmp_retry_srst_ops?

Quoted 8 lines
Quoted 5 lines
(quoted diff) +0 -0
@@ -312,6 +312,7 @@ extern struct device_attribute *ahci_sdev_attrs[];

      .sdev_attrs             = ahci_sdev_attrs

 extern struct ata_port_operations ahci_ops; +extern struct ata_port_operations ahci_pmp_retry_srst_ops;

Heh, I know I suggested that name but that is one ugly name.  If anyone has any better idea, please come forward.

How about ahci_pmp_workaround_softreset or ahci_pmp_ipms_set_softreset? Also applys to ops, ahci_pmp_workaround_ops or ahci_pmp_ipms_set_ops.

Quoted 31 lines

drivers/ata/libahci.c static void ahci_pmp_attach(struct ata_port *ap); · line 86

Quoted 7 lines
drivers/ata/libahci.c +2 -0
@@ -82,6 +82,8 @@ static void ahci_pmp_attach(struct ata_port *ap);
  static void ahci_pmp_detach(struct ata_port *ap);
  static int ahci_softreset(struct ata_link *link, unsigned int *class,
                         unsigned long deadline);
+static int ahci_pmp_retry_srst_softreset(struct ata_link *link, unsigned int *class,
+                       unsigned long deadline);

srst equals softreset, so ahci_pmp_retry_softreset() should do.

Quoted 8 lines
drivers/ata/libahci.c +6 -0
+struct ata_port_operations ahci_pmp_retry_srst_ops = {
+     .inherits               = &ahci_ops,
+     .softreset              = ahci_pmp_retry_srst_softreset,
+};
+EXPORT_SYMBOL_GPL(ahci_pmp_retry_srst_ops);
+

 struct ata_port_operations ahci_ops = { .inherits               = &sata_pmp_port_ops,

Maybe it's better to place ahci_pmp_retry_srst_ops after ahci_ops?

Quoted 1 line

+static int ahci_pmp_check_ready(struct ata_link *link)

It would be better if the name reflects that it's not for specific workaround.

Thank you.

--
tejun

#12 lore raw

Re: [PATCH v4] ahci: move ahci_sb600_softreset to libahci.c and rename it

Hello,

Quoted 5 lines · Yuan-Hsin Chen
Quoted 2 lines

Heh, I know I suggested that name but that is one ugly name.  If anyone has any better idea, please come forward.

How about ahci_pmp_workaround_softreset or ahci_pmp_ipms_set_softreset? Also applys to ops, ahci_pmp_workaround_ops or ahci_pmp_ipms_set_ops.

Heh, maybe. ahci_pmp_workaround_softreset is a bit generic but at least doesn't completely stupid. I don't know. :)

Thanks.

Signature · 1 line
tejun
#13 lore raw

Re: [PATCH v4] ahci: move ahci_sb600_softreset to libahci.c and rename it

In reply to Tejun Heo

Hello, Tejun.

Quoted 4 lines · Tejun Heo
Quoted 1 line

+static int ahci_pmp_check_ready(struct ata_link *link)

It would be better if the name reflects that it's not for specific workaround.

Do you mean it would be better to name it for specific workaround? How about ahci_bad_pmp_check_ready? Because this function is to avoid checking TFDATA if BAD PMP is found.

Thanks.

Yuan-Hsin

#14 lore raw

Re: [PATCH v4] ahci: move ahci_sb600_softreset to libahci.c and rename it

Hello,

Quoted 4 lines · Yuan-Hsin Chen
Quoted 2 lines

It would be better if the name reflects that it's not for specific workaround.

Do you mean it would be better to name it for specific workaround?

Yes, I meant that. An extra 'not' there.

Quoted 2 lines

How about ahci_bad_pmp_check_ready? Because this function is to avoid checking TFDATA if BAD PMP is found.

It's minor anyway and I don't think it matters all that much as long as we make the actual reset and ops names not too confusing.

Thank you.

Signature · 1 line
tejun
#15 lore raw

PATCH v5 1/1 ahci: move ahci_sb600_softreset to libahci.c and rename it

From: Yuan-Hsin Chen <[email protected]>

ahci_sb600_softreset was in ahci.c. This function is used to fix soft reset failure and renames as ahci_pmp_retry_softreset in libahci.c.

---
 drivers/ata/ahci.c    |   61 +-----------------------------------------------
 drivers/ata/ahci.h    |    1 +
 drivers/ata/libahci.c |   57 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 59 deletions(-)
drivers/ata/ahci.c +2 -59
index 71afe03..e1f8362 100644
@@ -79,8 +79,6 @@ enum board_ids {
 };
 
 static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
-			  unsigned long deadline);
 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 				 unsigned long deadline);
 static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
@@ -104,12 +102,6 @@ static struct ata_port_operations ahci_p5wdh_ops = {
 	.hardreset		= ahci_p5wdh_hardreset,
 };
 
-static struct ata_port_operations ahci_sb600_ops = {
-	.inherits		= &ahci_ops,
-	.softreset		= ahci_sb600_softreset,
-	.pmp_softreset		= ahci_sb600_softreset,
-};
-
 #define AHCI_HFLAGS(flags)	.private_data	= (void *)(flags)
 
 static const struct ata_port_info ahci_port_info[] = {
@@ -188,7 +180,7 @@ static const struct ata_port_info ahci_port_info[] = {
 		.flags		= AHCI_FLAG_COMMON,
 		.pio_mask	= ATA_PIO4,
 		.udma_mask	= ATA_UDMA6,
-		.port_ops	= &ahci_sb600_ops,
+		.port_ops	= &ahci_pmp_retry_srst_ops,
 	},
 	[board_ahci_sb700] =	/* for SB700 and SB800 */
 	{
@@ -196,7 +188,7 @@ static const struct ata_port_info ahci_port_info[] = {
 		.flags		= AHCI_FLAG_COMMON,
 		.pio_mask	= ATA_PIO4,
 		.udma_mask	= ATA_UDMA6,
-		.port_ops	= &ahci_sb600_ops,
+		.port_ops	= &ahci_pmp_retry_srst_ops,
 	},
 	[board_ahci_vt8251] =
 	{
@@ -502,55 +494,6 @@ static void ahci_pci_init_controller(struct ata_host *host)
 	ahci_init_controller(host);
 }
 
-static int ahci_sb600_check_ready(struct ata_link *link)
-{
-	void __iomem *port_mmio = ahci_port_base(link->ap);
-	u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
-	u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
-
-	/*
-	 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
-	 * which can save timeout delay.
-	 */
-	if (irq_status & PORT_IRQ_BAD_PMP)
-		return -EIO;
-
-	return ata_check_ready(status);
-}
-
-static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
-				unsigned long deadline)
-{
-	struct ata_port *ap = link->ap;
-	void __iomem *port_mmio = ahci_port_base(ap);
-	int pmp = sata_srst_pmp(link);
-	int rc;
-	u32 irq_sts;
-
-	DPRINTK("ENTER\n");
-
-	rc = ahci_do_softreset(link, class, pmp, deadline,
-			       ahci_sb600_check_ready);
-
-	/*
-	 * Soft reset fails on some ATI chips with IPMS set when PMP
-	 * is enabled but SATA HDD/ODD is connected to SATA port,
-	 * do soft reset again to port 0.
-	 */
-	if (rc == -EIO) {
-		irq_sts = readl(port_mmio + PORT_IRQ_STAT);
-		if (irq_sts & PORT_IRQ_BAD_PMP) {
-			ata_link_printk(link, KERN_WARNING,
-					"applying SB600 PMP SRST workaround "
-					"and retrying\n");
-			rc = ahci_do_softreset(link, class, 0, deadline,
-					       ahci_check_ready);
-		}
-	}
-
-	return rc;
-}
-
 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 				 unsigned long deadline)
 {
drivers/ata/ahci.h +1 -0
index 12c5282..b175000 100644
@@ -312,6 +312,7 @@ extern struct device_attribute *ahci_sdev_attrs[];
 	.sdev_attrs		= ahci_sdev_attrs
 
 extern struct ata_port_operations ahci_ops;
+extern struct ata_port_operations ahci_pmp_retry_srst_ops;
 
 void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
 			u32 opts);
drivers/ata/libahci.c +57 -0

75 lines not on this page · raw message

Signature · 1 line
1.7.3.1