From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: tchalamarla@caviumnetworks.com, tj@kernel.org
Cc: linux-ide@vger.kernel.org, stripathi@apm.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V2] AHCI: Workaround for ThunderX Errata#22536
Date: Sat, 13 Feb 2016 19:54:25 +0300 [thread overview]
Message-ID: <56BF5FC1.40000@cogentembedded.com> (raw)
In-Reply-To: <1455319230-30201-1-git-send-email-tchalamarla@caviumnetworks.com>
Hello.
On 2/13/2016 2:20 AM, tchalamarla@caviumnetworks.com wrote:
> From: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>
>
> Due to Errata in ThunderX, HOST_IRQ_STAT should be
> cleared before leaving the interrupt handler.
> The patch attempts to satisfy the need.
>
> Changes from V1:
> - Rebased on top of libata/for-4.6
> - Moved ThunderX intr handler to new file
>
> Signed-off-by: Tirumalesh Chalamarla <tchalamarla@caviumnetworks.com>
> ---
> drivers/ata/Makefile | 2 +-
> drivers/ata/ahci.c | 3 ++
> drivers/ata/ahci.h | 1 +
> drivers/ata/ahci_thunderx.c | 73 +++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 78 insertions(+), 1 deletion(-)
> create mode 100644 drivers/ata/ahci_thunderx.c
>
> diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
> index 1857952..a36e70d 100644
> --- a/drivers/ata/Makefile
> +++ b/drivers/ata/Makefile
> @@ -2,7 +2,7 @@
> obj-$(CONFIG_ATA) += libata.o
>
> # non-SFF interface
> -obj-$(CONFIG_SATA_AHCI) += ahci.o libahci.o
> +obj-$(CONFIG_SATA_AHCI) += ahci.o libahci.o ahci_thunderx.o
> obj-$(CONFIG_SATA_ACARD_AHCI) += acard-ahci.o libahci.o
> obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o libahci_platform.o
> obj-$(CONFIG_SATA_FSL) += sata_fsl.o
> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index 546a369..76e310e 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -1560,6 +1560,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> if (ahci_broken_devslp(pdev))
> hpriv->flags |= AHCI_HFLAG_NO_DEVSLP;
>
> + if (pdev->vendor == 0x177d && pdev->device == 0xa01c)
> + ahci_thunderx_init(&pdev->dev, hpriv);
> +
> /* save initial config */
> ahci_pci_save_initial_config(pdev, hpriv);
>
> diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
> index 167ba7e..77ae20d 100644
> --- a/drivers/ata/ahci.h
> +++ b/drivers/ata/ahci.h
> @@ -425,6 +425,7 @@ void ahci_print_info(struct ata_host *host, const char *scc_s);
> int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht);
> void ahci_error_handler(struct ata_port *ap);
> u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked);
> +void ahci_thunderx_init(struct device *dev, struct ahci_host_priv *hpriv);
>
> static inline void __iomem *__ahci_port_base(struct ata_host *host,
> unsigned int port_no)
> diff --git a/drivers/ata/ahci_thunderx.c b/drivers/ata/ahci_thunderx.c
> new file mode 100644
> index 0000000..223e170
> --- /dev/null
> +++ b/drivers/ata/ahci_thunderx.c
> @@ -0,0 +1,73 @@
> +/*
> + * SATA glue for Cavium Thunder SOCs.
> + *
> + *
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License. See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
> + * Copyright (C) 2010-2016 Cavium Networks
> + *
> + */
> +
> +#include <linux/module.h>
> +#include "ahci.h"
> +#include "libata.h"
> +
> +static irqreturn_t ahci_thunderx_irq_intr(int irq, void *dev_instance)
*_irq_intr() is a bit tautological.
> +{
> + 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;
Why not do this in the initializers?
> +
> + /* sigh. 0xffffffff is a valid return from h/w */
> + irq_stat = readl(mmio + HOST_IRQ_STAT);
> + if (!irq_stat)
> + return IRQ_NONE;
> +redo:
Closer to the next statement, please.
> +
> + irq_masked = irq_stat & hpriv->port_map;
> +
> + spin_lock(&host->lock);
> +
> + rc = ahci_handle_port_intr(host, irq_masked);
> +
No need for empty line here.
> + if (!rc)
> + handled = 0;
Doesn't this override the valid result in case of looping?
> +
> + 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;
You can have a *do*/*while* loop, no need for *goto*.
> +
> + VPRINTK("EXIT\n");
> +
> + return IRQ_RETVAL(handled);
> +}
> +
> +void ahci_thunderx_init(struct device *dev, struct ahci_host_priv *hpriv)
> +{
> + hpriv->irq_handler = ahci_thunderx_irq_intr;
> +}
> +EXPORT_SYMBOL_GPL(ahci_thunderx_init);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Cavium, Inc. <support@cavium.com>");
> +MODULE_DESCRIPTION("Cavium Inc. ThunderX sata config.");
MBR, Sergei
next prev parent reply other threads:[~2016-02-13 16:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 23:20 [PATCH V2] AHCI: Workaround for ThunderX Errata#22536 tchalamarla
2016-02-13 16:54 ` Sergei Shtylyov [this message]
2016-02-14 17:01 ` Tejun Heo
2016-02-15 3:36 ` Tirumalesh Chalamarla
2016-02-15 18:30 ` Tejun Heo
2016-02-16 14:42 ` Robert Richter
2016-02-16 19:14 ` Tirumalesh Chalamarla
2016-02-16 19:38 ` David Daney
2016-02-16 19:50 ` Tirumalesh Chalamarla
2016-02-16 21:14 ` Robert Richter
2016-02-16 23:13 ` Tirumalesh Chalamarla
2016-02-17 11:29 ` Will Deacon
2016-02-17 18:57 ` David Daney
2016-02-17 20:00 ` Tejun Heo
2016-02-17 21:46 ` Tirumalesh Chalamarla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56BF5FC1.40000@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stripathi@apm.com \
--cc=tchalamarla@caviumnetworks.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).