From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tirumalesh Chalamarla Subject: Re: [PATCH V3] AHCI: Workaround for ThunderX Errata#22536 Date: Tue, 23 Feb 2016 16:00:31 -0800 Message-ID: <56CCF29F.8030105@caviumnetworks.com> References: <1455653329-4934-1-git-send-email-tchalamarla@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mail-bn1bon0074.outbound.protection.outlook.com ([157.56.111.74]:57256 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751866AbcBXAAi (ORCPT ); Tue, 23 Feb 2016 19:00:38 -0500 In-Reply-To: <1455653329-4934-1-git-send-email-tchalamarla@caviumnetworks.com> Sender: linux-ide-owner@vger.kernel.org List-Id: linux-ide@vger.kernel.org To: tj@kernel.org Cc: stripathi@apm.com, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Hi Tejun, Any more comments on this? Thanks, Tirumalesh. On 02/16/2016 12:08 PM, tchalamarla@caviumnetworks.com wrote: > From: Tirumalesh Chalamarla > > 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 V2: > - removed newfile > - code is now under CONFIG_ARM64 > > Changes from V1: > - Rebased on top of libata/for-4.6 > - Moved ThunderX intr handler to new file > > Signed-off-by: Tirumalesh Chalamarla > --- > drivers/ata/ahci.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c > index 546a369..c8496fc 100644 > --- a/drivers/ata/ahci.c > +++ b/drivers/ata/ahci.c > @@ -1325,6 +1325,44 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host) > {} > #endif > > +#ifdef CONFIG_ARM64 > +/* 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 > + */ > +static irqreturn_t ahci_thunderx_irq_handler(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; > + irq_stat = readl(mmio + HOST_IRQ_STAT); > + if (!irq_stat) > + return IRQ_NONE; > + > + do { > + 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); > + irq_stat = readl(mmio + HOST_IRQ_STAT); > + spin_unlock(&host->lock); > + } while (irq_stat); > + VPRINTK("EXIT\n"); > + > + return IRQ_RETVAL(handled); > +} > +#endif > + > /* > * ahci_init_msix() - optionally enable per-port MSI-X otherwise defer > * to single msi. > @@ -1560,6 +1598,12 @@ 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; > > +#ifdef CONFIG_ARM64 > + /* this should be done before save config*/ > + if (pdev->vendor == 0x177d && pdev->device == 0xa01c) > + hpriv->irq_handler = ahci_thunderx_irq_handler; > +#endif > + > /* save initial config */ > ahci_pci_save_initial_config(pdev, hpriv); > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: tchalamarla@caviumnetworks.com (Tirumalesh Chalamarla) Date: Tue, 23 Feb 2016 16:00:31 -0800 Subject: [PATCH V3] AHCI: Workaround for ThunderX Errata#22536 In-Reply-To: <1455653329-4934-1-git-send-email-tchalamarla@caviumnetworks.com> References: <1455653329-4934-1-git-send-email-tchalamarla@caviumnetworks.com> Message-ID: <56CCF29F.8030105@caviumnetworks.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Tejun, Any more comments on this? Thanks, Tirumalesh. On 02/16/2016 12:08 PM, tchalamarla at caviumnetworks.com wrote: > From: Tirumalesh Chalamarla > > 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 V2: > - removed newfile > - code is now under CONFIG_ARM64 > > Changes from V1: > - Rebased on top of libata/for-4.6 > - Moved ThunderX intr handler to new file > > Signed-off-by: Tirumalesh Chalamarla > --- > drivers/ata/ahci.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c > index 546a369..c8496fc 100644 > --- a/drivers/ata/ahci.c > +++ b/drivers/ata/ahci.c > @@ -1325,6 +1325,44 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host) > {} > #endif > > +#ifdef CONFIG_ARM64 > +/* 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 > + */ > +static irqreturn_t ahci_thunderx_irq_handler(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; > + irq_stat = readl(mmio + HOST_IRQ_STAT); > + if (!irq_stat) > + return IRQ_NONE; > + > + do { > + 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); > + irq_stat = readl(mmio + HOST_IRQ_STAT); > + spin_unlock(&host->lock); > + } while (irq_stat); > + VPRINTK("EXIT\n"); > + > + return IRQ_RETVAL(handled); > +} > +#endif > + > /* > * ahci_init_msix() - optionally enable per-port MSI-X otherwise defer > * to single msi. > @@ -1560,6 +1598,12 @@ 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; > > +#ifdef CONFIG_ARM64 > + /* this should be done before save config*/ > + if (pdev->vendor == 0x177d && pdev->device == 0xa01c) > + hpriv->irq_handler = ahci_thunderx_irq_handler; > +#endif > + > /* save initial config */ > ahci_pci_save_initial_config(pdev, hpriv); > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752631AbcBXAAl (ORCPT ); Tue, 23 Feb 2016 19:00:41 -0500 Received: from mail-bn1bon0074.outbound.protection.outlook.com ([157.56.111.74]:57256 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751866AbcBXAAi (ORCPT ); Tue, 23 Feb 2016 19:00:38 -0500 Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; Subject: Re: [PATCH V3] AHCI: Workaround for ThunderX Errata#22536 To: References: <1455653329-4934-1-git-send-email-tchalamarla@caviumnetworks.com> CC: , , , From: Tirumalesh Chalamarla Message-ID: <56CCF29F.8030105@caviumnetworks.com> Date: Tue, 23 Feb 2016 16:00:31 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1455653329-4934-1-git-send-email-tchalamarla@caviumnetworks.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: CO2PR11CA0014.namprd11.prod.outlook.com (10.141.242.152) To BY1PR0701MB1782.namprd07.prod.outlook.com (25.162.141.20) X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1782;2:rur2QzIsbNof/6IXH5FqNYGdh+KmFhmb392rdYpGO1LqKxbzXdcWeRUlv7kaNUeZoDFN9bs333sVtVQM+fgbVni6506pPzQoOgVcIid1wsJsdDy0EGSzP+EEg6jQW/SWqrp7AQ4nmQpGMJkou7zZmw==;3:kS7C0pZ//Ej+D9wtV4Hkgx2bZ6A2piRM1jMKq9RbpUnNRRo8hTylhB7uitx3/cJ2TMviugpXfNdOUgHungvit7WkfrFl8mrm9FugF0p9/RufY4vyhKFrk/MzYl2lCeAC;25:lXfeXwwK2R0mmiozHJLEPfdiHTWzvibj0qaWI6zTWP3T3Jp5jy23ha4lQn6a2jKjKs4oRINuEYePme4r3wCuUtTn74LGtp8SqgKLxC8EjaaNa7+k2Hk2nIeNJFgjzH7TP6vh/hKKwuiQgbkRBz2US8YikAjWvtjWhqdFSwDvfs2CyDU5O4BEF9XDIS5gyfrvEQqNtArjevWUwRrw1Y5Taiw8SZs3ypJJzIYJjDPoSBiJ3IZ0YvOWUbBI9QZnnf342mm6iDfzMRHHYsB8jMQloiWxvv66fINhnbYD9mBw+vFfBRrvXcK3q72fC1dlKI6Rwuovl+zJximhI1y/svUxAhOTFmMUoY8uZ4CaSp8ig8Q= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1782; X-MS-Office365-Filtering-Correlation-Id: f08a7c0b-a925-401f-bf99-08d33cad85b7 X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1782;20:e/mtDRMunpXzoFQQpTJfhRV0Fr6hb4j8jfg7fNZg/mvAKd1jjNAN2w8g3kakxN+ei/vr0HGT201L9zPSnv9j2WZvrejHDHQyMGFVueA51WdK1685yCxvhSjUfVUls0CieEfCzD5OL8kqhNGiimx80SccloShXnanVFV7J8Weo6TjgGwZMHpYd+6E0JQLe3UNmI12ZETUzV9WHtf+mrjxO4fXjjKrt6fnV74vKHZf+L97pTWyYLlfP0PgZAfxcrovBK2V+ZlRZgT5W2M1lsB9ngKcshncBzQ72VC9HvsUTvtBr3oqUHA33rSwZF+mdG2+1yJx+Alqdv3XFoO3PMCa0eHDffY0DWVTHihNbaZ1EVSiM3H208kGdq1Z+CSXt0ctD7jvO5UHKEVlulSkT4Eapa6WpHWFgZyS8+5J5hPB36Yck2qcXnEHi/6cy2kPhmWGsKevayisIJRK0V8kz/Lj16QC1J8XdzSRmI8LQ4N2HPFAuuU79CD/QMb5BE1bjrhuf0Hdw8JHZpEVURCMWb7kZLtGqLmNqUjpJbKG1Fxo1UhFq4H16uTVDSSNA9yuEBuHzmxaPobTJwpOZPfrDUFY5MrCSRkrHxiW5hZJnJeTgE4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:BY1PR0701MB1782;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1782; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1782;4:MMWNBR1nq3T2XR4vA46UVu9kBN9Liu3AKfuV47qMUn+54cOxFFay/pVlGrhDhxX4uz5oQ0HoHqb0XAY1HKFGPEq3nPPd6PqNPQ0f533bwFcgoSmHIzRoOM15fLUW9AKNHFU+JnqwEZuEartTqYj6vlp0o8yeCWvm12ovl1a3RXR4hmdvcOylq66Rfxd2PjmeWfXEpd+zRkRpWJWh7OCjnHfGGNTYP96ERbpzQb4pijohQamFsrYogX9kJSNl/8G8F5HppRqPGngr9GwqkfYgobW3qhAfMtivkPKadz1fB06/FDfhIPvXih0bFVYjpcN19kTABYN7G9GMK1iI8nTIl4/O8DgW6cimVSB19SeeaOaRNPvs96JEORExlNElDh68 X-Forefront-PRVS: 08626BE3A5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(979002)(6049001)(6009001)(164054003)(189002)(199003)(479174004)(24454002)(377454003)(33656002)(64126003)(6116002)(586003)(1096002)(3846002)(2906002)(92566002)(47776003)(66066001)(2351001)(65956001)(5008740100001)(50466002)(4326007)(5001960100002)(230700001)(65806001)(110136002)(189998001)(4001350100001)(5004730100002)(59896002)(19580395003)(65816999)(87266999)(50986999)(54356999)(76176999)(80316001)(19580405001)(77096005)(40100003)(23746002)(36756003)(122386002)(87976001)(42186005)(83506001)(2950100001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1782;H:[10.18.104.43];FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BY1PR0701MB1782;23:977IQek8A2FjeUycOU8/Qlxv8cdsSQgQ+9b?= =?Windows-1252?Q?ww6tsmoUG/qLdRfjwtIdq0XtKVRbq7u7OPh3wSw7SKXXcSEClBF0YY3n?= =?Windows-1252?Q?bALTQgj8/vUzpqcJdKd1oXb8dR8Q3Jr6Bp7VXLgNsa1RrRCnqLw/lj9U?= =?Windows-1252?Q?ZaZ6HGiAFkiRDamFcUt6pftgj82hBUk3/3qvgJM/smBSZpyh9B4kJhF6?= =?Windows-1252?Q?1jfCLch/1TlXrLICnCpUOJHFfI5rKuNaUSpTqRWedDxId0lgyurMwUDO?= =?Windows-1252?Q?1HVVMr2P90AJpefg4D9kpjFkfbuy9/ITLv+RIKk8YnR7xMqeIRC7sS6V?= =?Windows-1252?Q?5nt2z9XtUnbVp5Z4WJepIffWmJzcBx7FZcfcG/HKWNahT9MrkNDnYuEQ?= =?Windows-1252?Q?jdewk45PKlowkW3YJmooUN6j676/pQ7S9g9SBvxeJ0LuBzzaKIY6uwrg?= =?Windows-1252?Q?2P9bVNrC0lTq0iyZEulmC4lQrzNf+Ff75paTWA0KVA+qPReZoBa3qLlR?= =?Windows-1252?Q?rTSPRli+xZn9Q3RRqVFCQpAof9DIczAYUz7NCPHKX4/P0YhlEU9ra/A1?= =?Windows-1252?Q?GAx5O0vc/Yxg2bP073rp2uAZ3IdSSdV3uOuyxjekQmgTrHKrZNMxKFqP?= =?Windows-1252?Q?1MO5A4UpgtumV8Vw7R4H0m5ye22SjNyHh+cZHbBhqRtS8jiplsrvYgfu?= =?Windows-1252?Q?rIdOrtqDP7N7LXxbItpCOP9KAa3CAZkebt1Amc1gEAKtleiOzy5A645V?= =?Windows-1252?Q?liutWp8x+DZ+fvN9Q3/fDVRMTY/2iRN4brVen9nH620yW19ClnvZ/l8K?= =?Windows-1252?Q?vUpX0sqtvZCcXtTBYBSO0aNYOzjjndWz76SDVOKOERPgdRh0XtNl2OvQ?= =?Windows-1252?Q?wUrODESV4MRlVH9aaKucoqenfj4ClfNB5QyB0hHgdL6yMXsPeE0n//kD?= =?Windows-1252?Q?2jIbp0abQfm8pqFB0VHL22FkKhdRL093KkAclWV/TqNOJkc/VhW8L+IH?= =?Windows-1252?Q?rTZm5aR+1USc4Kjri5cMX8iGFeURMZPUVaSObDZMIk3VxMjWNb5hY7Xq?= =?Windows-1252?Q?qym/lQpen4FpUbpbFPL+dwD32vle4vjhIwnT5tAbMzN/gYW1ETib72xR?= =?Windows-1252?Q?tAk68UNrmUuYEuGsT0dQVHOjbREl9tM8rR7kM2ClUdAorvn4dbVH9+u0?= =?Windows-1252?Q?tiB3I3/qiLlMYifuoWyUFCFCQD/IpB5I405FHqhdpUptLbo7DVExQHtD?= =?Windows-1252?Q?MI0HdYD8sR5ERETz0CtQowUy9SVQXKahh+EGmb0B8MZxXl77SonuHtMi?= =?Windows-1252?Q?Vv4Zp32KoKRhE/QQLzub3xsomLiXfFKxiED20fkHqeX3COIbFAcZ+YFv?= =?Windows-1252?Q?iqExbjJbB4gR1EE0Wls4pRwvnG0GQZBPfmUbB3+OXZl6kiYdNiaBV740?= =?Windows-1252?Q?Tn5iEAjVSwq/oD1moU2HuRWiqVHidUZKiMf2C9JUp7g=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1782;5:nfVjcsL/KM0JaH605g6RkE6bGrtlLh19wM1zfchpE24WZjAY5+1FP+7QitINg/NR1wSC22X2FTX1H/Q3oJiHFDiXfqGez8ILdWmIARtDyUfE5Bqc6JuT2dRf9v4HD5znk34OSG3CA5r4QPmiFMmgvA==;24:XiBptGpEamXgWIxqXFdT5mVDToq5BcUp0I0H51drccSYqTb/Jf+8UKK17GkaR0vYLWxtyo6bxopdxD9Zi6F22JnBEolMbJvG3DlzQqiUjDg= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2016 00:00:35.6198 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1782 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tejun, Any more comments on this? Thanks, Tirumalesh. On 02/16/2016 12:08 PM, tchalamarla@caviumnetworks.com wrote: > From: Tirumalesh Chalamarla > > 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 V2: > - removed newfile > - code is now under CONFIG_ARM64 > > Changes from V1: > - Rebased on top of libata/for-4.6 > - Moved ThunderX intr handler to new file > > Signed-off-by: Tirumalesh Chalamarla > --- > drivers/ata/ahci.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c > index 546a369..c8496fc 100644 > --- a/drivers/ata/ahci.c > +++ b/drivers/ata/ahci.c > @@ -1325,6 +1325,44 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host) > {} > #endif > > +#ifdef CONFIG_ARM64 > +/* 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 > + */ > +static irqreturn_t ahci_thunderx_irq_handler(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; > + irq_stat = readl(mmio + HOST_IRQ_STAT); > + if (!irq_stat) > + return IRQ_NONE; > + > + do { > + 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); > + irq_stat = readl(mmio + HOST_IRQ_STAT); > + spin_unlock(&host->lock); > + } while (irq_stat); > + VPRINTK("EXIT\n"); > + > + return IRQ_RETVAL(handled); > +} > +#endif > + > /* > * ahci_init_msix() - optionally enable per-port MSI-X otherwise defer > * to single msi. > @@ -1560,6 +1598,12 @@ 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; > > +#ifdef CONFIG_ARM64 > + /* this should be done before save config*/ > + if (pdev->vendor == 0x177d && pdev->device == 0xa01c) > + hpriv->irq_handler = ahci_thunderx_irq_handler; > +#endif > + > /* save initial config */ > ahci_pci_save_initial_config(pdev, hpriv); > >