All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] AHCI: Workaround for ThunderX Errata#22536
@ 2016-02-03 22:37 ` tchalamarla
  0 siblings, 0 replies; 5+ messages in thread
From: tchalamarla @ 2016-02-03 22:37 UTC (permalink / raw)
  To: tj; +Cc: linux-ide, linux-kernel, linux-arm-kernel, tchalamarla

From: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>

Due to Errata in some versions of ThunderX,
HOST_IRQ_STAT is neither EDGE nor LEVEL,
ThunderX needs a special sequence for handling interrupt.
The patch attempts to satisfy the need.

Signed-off-by: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>
---
 drivers/ata/ahci.c    |  3 +++
 drivers/ata/ahci.h    |  4 ++++
 drivers/ata/libahci.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 594fcab..6416af7 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1534,6 +1534,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ahci_sb600_enable_64bit(pdev))
 		hpriv->flags &= ~AHCI_HFLAG_32BIT_ONLY;
 
+	if (pdev->vendor == 0x177d && pdev->device == 0xa01c)
+		hpriv->flags |= AHCI_HFLAG_CAVIUM_ERRATA_22536;
+
 	hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
 
 	/* must set flag prior to save config in order to take effect */
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index a44c75d..50b2afd 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -252,6 +252,10 @@ enum {
 #endif
 	AHCI_HFLAG_WAKE_BEFORE_STOP	= (1 << 22), /* wake before DMA stop */
 
+	AHCI_HFLAG_CAVIUM_ERRATA_22536	= (1 << 23), /* Thunder HOST_IRQ_STAT
+						      *	is not Level or EDGE
+						      */
+
 	/* ap->flags bits */
 
 	AHCI_FLAG_COMMON		= ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 4029679..e186482 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1952,6 +1952,55 @@ static irqreturn_t ahci_single_level_irq_intr(int irq, void *dev_instance)
 	return IRQ_RETVAL(rc);
 }
 
+
+static irqreturn_t ahci_level_irq_with_errata(int irq, void *dev_instance)
+{
+	struct ata_host *host = dev_instance;
+	struct ahci_host_priv *hpriv;
+	unsigned int rc = 0;
+	void __iomem *mmio;
+	u32 irq_stat, irq_masked;
+	unsigned int handled = 1;
+
+	VPRINTK("ENTER\n");
+
+	hpriv = host->private_data;
+	mmio = hpriv->mmio;
+
+	/* sigh.  0xffffffff is a valid return from h/w */
+	irq_stat = readl(mmio + HOST_IRQ_STAT);
+	if (!irq_stat)
+		return IRQ_NONE;
+redo:
+
+	irq_masked = irq_stat & hpriv->port_map;
+
+	spin_lock(&host->lock);
+
+	rc = ahci_handle_port_intr(host, irq_masked);
+
+	if (!rc)
+		handled = 0;
+
+	writel(irq_stat, mmio + HOST_IRQ_STAT);
+
+	/* Due to ERRATA#22536, ThunderX need to handle
+	 * HOST_IRQ_STAT differently.
+	 * Work around is to make sure all pending IRQs
+	 * are served before leaving handler
+	 */
+	irq_stat = readl(mmio + HOST_IRQ_STAT);
+
+	spin_unlock(&host->lock);
+
+	if (irq_stat)
+		goto redo;
+
+	VPRINTK("EXIT\n");
+
+	return IRQ_RETVAL(handled);
+}
+
 unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
@@ -2540,6 +2589,9 @@ int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht)
 	else if (hpriv->flags & AHCI_HFLAG_EDGE_IRQ)
 		rc = ata_host_activate(host, irq, ahci_single_edge_irq_intr,
 				       IRQF_SHARED, sht);
+	else if (hpriv->flags & AHCI_HFLAG_CAVIUM_ERRATA_22536)
+		rc = ata_host_activate(host, irq, ahci_level_irq_with_errata,
+					IRQF_SHARED, sht);
 	else
 		rc = ata_host_activate(host, irq, ahci_single_level_irq_intr,
 				       IRQF_SHARED, sht);
-- 
2.1.0

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

* [PATCH] AHCI: Workaround for ThunderX Errata#22536
@ 2016-02-03 22:37 ` tchalamarla
  0 siblings, 0 replies; 5+ messages in thread
From: tchalamarla @ 2016-02-03 22:37 UTC (permalink / raw)
  To: tj; +Cc: linux-ide, linux-kernel, linux-arm-kernel, tchalamarla

From: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>

Due to Errata in some versions of ThunderX,
HOST_IRQ_STAT is neither EDGE nor LEVEL,
ThunderX needs a special sequence for handling interrupt.
The patch attempts to satisfy the need.

Signed-off-by: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>
---
 drivers/ata/ahci.c    |  3 +++
 drivers/ata/ahci.h    |  4 ++++
 drivers/ata/libahci.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 594fcab..6416af7 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1534,6 +1534,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ahci_sb600_enable_64bit(pdev))
 		hpriv->flags &= ~AHCI_HFLAG_32BIT_ONLY;
 
+	if (pdev->vendor == 0x177d && pdev->device == 0xa01c)
+		hpriv->flags |= AHCI_HFLAG_CAVIUM_ERRATA_22536;
+
 	hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
 
 	/* must set flag prior to save config in order to take effect */
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index a44c75d..50b2afd 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -252,6 +252,10 @@ enum {
 #endif
 	AHCI_HFLAG_WAKE_BEFORE_STOP	= (1 << 22), /* wake before DMA stop */
 
+	AHCI_HFLAG_CAVIUM_ERRATA_22536	= (1 << 23), /* Thunder HOST_IRQ_STAT
+						      *	is not Level or EDGE
+						      */
+
 	/* ap->flags bits */
 
 	AHCI_FLAG_COMMON		= ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 4029679..e186482 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1952,6 +1952,55 @@ static irqreturn_t ahci_single_level_irq_intr(int irq, void *dev_instance)
 	return IRQ_RETVAL(rc);
 }
 
+
+static irqreturn_t ahci_level_irq_with_errata(int irq, void *dev_instance)
+{
+	struct ata_host *host = dev_instance;
+	struct ahci_host_priv *hpriv;
+	unsigned int rc = 0;
+	void __iomem *mmio;
+	u32 irq_stat, irq_masked;
+	unsigned int handled = 1;
+
+	VPRINTK("ENTER\n");
+
+	hpriv = host->private_data;
+	mmio = hpriv->mmio;
+
+	/* sigh.  0xffffffff is a valid return from h/w */
+	irq_stat = readl(mmio + HOST_IRQ_STAT);
+	if (!irq_stat)
+		return IRQ_NONE;
+redo:
+
+	irq_masked = irq_stat & hpriv->port_map;
+
+	spin_lock(&host->lock);
+
+	rc = ahci_handle_port_intr(host, irq_masked);
+
+	if (!rc)
+		handled = 0;
+
+	writel(irq_stat, mmio + HOST_IRQ_STAT);
+
+	/* Due to ERRATA#22536, ThunderX need to handle
+	 * HOST_IRQ_STAT differently.
+	 * Work around is to make sure all pending IRQs
+	 * are served before leaving handler
+	 */
+	irq_stat = readl(mmio + HOST_IRQ_STAT);
+
+	spin_unlock(&host->lock);
+
+	if (irq_stat)
+		goto redo;
+
+	VPRINTK("EXIT\n");
+
+	return IRQ_RETVAL(handled);
+}
+
 unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
@@ -2540,6 +2589,9 @@ int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht)
 	else if (hpriv->flags & AHCI_HFLAG_EDGE_IRQ)
 		rc = ata_host_activate(host, irq, ahci_single_edge_irq_intr,
 				       IRQF_SHARED, sht);
+	else if (hpriv->flags & AHCI_HFLAG_CAVIUM_ERRATA_22536)
+		rc = ata_host_activate(host, irq, ahci_level_irq_with_errata,
+					IRQF_SHARED, sht);
 	else
 		rc = ata_host_activate(host, irq, ahci_single_level_irq_intr,
 				       IRQF_SHARED, sht);
-- 
2.1.0

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

* [PATCH] AHCI: Workaround for ThunderX Errata#22536
@ 2016-02-03 22:37 ` tchalamarla
  0 siblings, 0 replies; 5+ messages in thread
From: tchalamarla at caviumnetworks.com @ 2016-02-03 22:37 UTC (permalink / raw)
  To: linux-arm-kernel

From: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>

Due to Errata in some versions of ThunderX,
HOST_IRQ_STAT is neither EDGE nor LEVEL,
ThunderX needs a special sequence for handling interrupt.
The patch attempts to satisfy the need.

Signed-off-by: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>
---
 drivers/ata/ahci.c    |  3 +++
 drivers/ata/ahci.h    |  4 ++++
 drivers/ata/libahci.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 594fcab..6416af7 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1534,6 +1534,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ahci_sb600_enable_64bit(pdev))
 		hpriv->flags &= ~AHCI_HFLAG_32BIT_ONLY;
 
+	if (pdev->vendor == 0x177d && pdev->device == 0xa01c)
+		hpriv->flags |= AHCI_HFLAG_CAVIUM_ERRATA_22536;
+
 	hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
 
 	/* must set flag prior to save config in order to take effect */
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index a44c75d..50b2afd 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -252,6 +252,10 @@ enum {
 #endif
 	AHCI_HFLAG_WAKE_BEFORE_STOP	= (1 << 22), /* wake before DMA stop */
 
+	AHCI_HFLAG_CAVIUM_ERRATA_22536	= (1 << 23), /* Thunder HOST_IRQ_STAT
+						      *	is not Level or EDGE
+						      */
+
 	/* ap->flags bits */
 
 	AHCI_FLAG_COMMON		= ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 4029679..e186482 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1952,6 +1952,55 @@ static irqreturn_t ahci_single_level_irq_intr(int irq, void *dev_instance)
 	return IRQ_RETVAL(rc);
 }
 
+
+static irqreturn_t ahci_level_irq_with_errata(int irq, void *dev_instance)
+{
+	struct ata_host *host = dev_instance;
+	struct ahci_host_priv *hpriv;
+	unsigned int rc = 0;
+	void __iomem *mmio;
+	u32 irq_stat, irq_masked;
+	unsigned int handled = 1;
+
+	VPRINTK("ENTER\n");
+
+	hpriv = host->private_data;
+	mmio = hpriv->mmio;
+
+	/* sigh.  0xffffffff is a valid return from h/w */
+	irq_stat = readl(mmio + HOST_IRQ_STAT);
+	if (!irq_stat)
+		return IRQ_NONE;
+redo:
+
+	irq_masked = irq_stat & hpriv->port_map;
+
+	spin_lock(&host->lock);
+
+	rc = ahci_handle_port_intr(host, irq_masked);
+
+	if (!rc)
+		handled = 0;
+
+	writel(irq_stat, mmio + HOST_IRQ_STAT);
+
+	/* Due to ERRATA#22536, ThunderX need to handle
+	 * HOST_IRQ_STAT differently.
+	 * Work around is to make sure all pending IRQs
+	 * are served before leaving handler
+	 */
+	irq_stat = readl(mmio + HOST_IRQ_STAT);
+
+	spin_unlock(&host->lock);
+
+	if (irq_stat)
+		goto redo;
+
+	VPRINTK("EXIT\n");
+
+	return IRQ_RETVAL(handled);
+}
+
 unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
@@ -2540,6 +2589,9 @@ int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht)
 	else if (hpriv->flags & AHCI_HFLAG_EDGE_IRQ)
 		rc = ata_host_activate(host, irq, ahci_single_edge_irq_intr,
 				       IRQF_SHARED, sht);
+	else if (hpriv->flags & AHCI_HFLAG_CAVIUM_ERRATA_22536)
+		rc = ata_host_activate(host, irq, ahci_level_irq_with_errata,
+					IRQF_SHARED, sht);
 	else
 		rc = ata_host_activate(host, irq, ahci_single_level_irq_intr,
 				       IRQF_SHARED, sht);
-- 
2.1.0

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

* Re: [PATCH] AHCI: Workaround for ThunderX Errata#22536
  2016-02-03 22:37 ` tchalamarla
@ 2016-02-05 17:04   ` Tejun Heo
  -1 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2016-02-05 17:04 UTC (permalink / raw)
  To: tchalamarla; +Cc: linux-ide, linux-kernel, linux-arm-kernel

Hello, Tirumalesh.

On Wed, Feb 03, 2016 at 02:37:45PM -0800, tchalamarla@caviumnetworks.com wrote:
> From: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>
> 
> Due to Errata in some versions of ThunderX,
> HOST_IRQ_STAT is neither EDGE nor LEVEL,
> ThunderX needs a special sequence for handling interrupt.
> The patch attempts to satisfy the need.

Please take a look at the following patchset and coordinate with
Suman.

 http://lkml.kernel.org/g/1454620826-22554-2-git-send-email-stripathi@apm.com

Thanks.

-- 
tejun

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

* [PATCH] AHCI: Workaround for ThunderX Errata#22536
@ 2016-02-05 17:04   ` Tejun Heo
  0 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2016-02-05 17:04 UTC (permalink / raw)
  To: linux-arm-kernel

Hello, Tirumalesh.

On Wed, Feb 03, 2016 at 02:37:45PM -0800, tchalamarla at caviumnetworks.com wrote:
> From: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>
> 
> Due to Errata in some versions of ThunderX,
> HOST_IRQ_STAT is neither EDGE nor LEVEL,
> ThunderX needs a special sequence for handling interrupt.
> The patch attempts to satisfy the need.

Please take a look at the following patchset and coordinate with
Suman.

 http://lkml.kernel.org/g/1454620826-22554-2-git-send-email-stripathi at apm.com

Thanks.

-- 
tejun

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

end of thread, other threads:[~2016-02-05 17:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-03 22:37 [PATCH] AHCI: Workaround for ThunderX Errata#22536 tchalamarla
2016-02-03 22:37 ` tchalamarla at caviumnetworks.com
2016-02-03 22:37 ` tchalamarla
2016-02-05 17:04 ` Tejun Heo
2016-02-05 17:04   ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.