From patchwork Fri Feb 12 23:20:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tirumalesh Chalamarla X-Patchwork-Id: 8298511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4B68DC02AA for ; Fri, 12 Feb 2016 23:23:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49B2120452 for ; Fri, 12 Feb 2016 23:23:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6140F2042B for ; Fri, 12 Feb 2016 23:23:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aUN1h-0003JX-II; Fri, 12 Feb 2016 23:21:25 +0000 Received: from mail-bl2on0099.outbound.protection.outlook.com ([65.55.169.99] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aUN1d-0003GE-Vp for linux-arm-kernel@lists.infradead.org; Fri, 12 Feb 2016 23:21:23 +0000 Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from tiru-pc.caveonetworks.com (64.2.3.194) by CY1PR0701MB1785.namprd07.prod.outlook.com (10.163.42.143) with Microsoft SMTP Server (TLS) id 15.1.409.15; Fri, 12 Feb 2016 23:20:57 +0000 From: To: Subject: [PATCH V2] AHCI: Workaround for ThunderX Errata#22536 Date: Fri, 12 Feb 2016 15:20:30 -0800 Message-ID: <1455319230-30201-1-git-send-email-tchalamarla@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: BY2PR04CA060.namprd04.prod.outlook.com (10.141.249.178) To CY1PR0701MB1785.namprd07.prod.outlook.com (25.163.42.143) X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1785; 2:v4dvZHB3GVOYChan5/jXkSQZT223jx1lQ+UlC9UGYbB7X7GDrBtId+ONppZqbhh4IuKfDgNzOvJePxFxxiLWYn4X59deyh98L1qg2pC6Yp/a8ywwDMiQJK9CFVlAk7Nxe7mekX200jcZW/K5mNKAIA==; 3:WFzoNOu6RfZIX2PaLsod0XaEWiLqCDJ3nb+QiHsxBIu0OXwHyQrICRjnQz/TV4StG/Tv9B+nOX3kpEJHVD9dKsvcGr4dyE3GA3R4kMKR7D4HsEX6gozlLF5re3/DhAGw; 25:wsD0BiknDkqtHDAn8rMBv3u5o3E3O6saaHPSfOxF3eslyhRqiDwQwUQ+SzuokVJTDZNgNYnunQeJODdDjm0qQ2OV90UA9vbDzwP78iXXWaRZbrz+QoX8pR47RQL9ED1m026GeNwRs+U1FK0Pc6Q2mQvWCVc3v6RVqVBZsHAFkUevCJgAvFvP2xnd9/Hju2Y6eln0MK2UIFSC6kX1unQrWRp2sHP2lEunLhOtBJwKHzliyuXl6RSmeKLkScQyQqdpM5RbsQKmd2K7kcUd1WEyWLPgaibPvYmVbv184d6LpOkcBYXp37+UU6dPRpoKmQ7o X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0701MB1785; X-MS-Office365-Filtering-Correlation-Id: 5d4e6e7f-44b9-40d5-e7f4-08d3340329df X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1785; 20:hM3xLVHp/NOOlhAjf9y213YeDagPs8WMH5ut7PFf0BCSvUsmRFJ0BRPNIj/LeE63LJdnJCdNVLTRFTt4Y4LvY1k4mI9IUmcqLYYvGRit+WRmDAn0euO3OqeIxHtP90L7+wS2tzvWwrBHEBkMWTuZnm7ySc687eD1dwVdv0USyY0pSRT75V0raNNczdmlWDlsajEImkBCPXKOS9+431rE1vsqWuXifK5H5NDKRDuaeixU4y8ujwlHkNDRY88pLeGbNJ/RXOgwVVtyrUuYV+3iCY8giyj1+2CMFJLHIEl6KVBnlao9TWg9f/4BGb5yTvsVuhCiUkPtuMCYTiNmbYl9vDHkE1m0Grq0rBXRn4RyGQib08PvpKiAceAqMXZZ7vuNS0j723OCg5vHhRst0Nv6RU0xHEegZX4Kvma1w1ZU3etu3Hdt5jGE2qbfSR0WwfHvzc+iERoz99fCuFrn/ehqG5HfHZ1ktxpNVLSTKoADYdU9j5asoB/oNqvxCZlbHOvjVMCyRhtSyoVO43iFSXX2uOs2dNdb/BQ5exQVxz96wLXF25+PVDCSNbKcpBot5T+mFmcfieV8jpucd0axxztCT0SwyYuyaB+qRAfkkEdYLjc= 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:CY1PR0701MB1785; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0701MB1785; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1785; 4:Al1VnMKTHgxmi9FRWRj91zuR4ZeGxIxlVenQWewieMC+YL1pT+8mj214O3+0eGgcZ6c/aPKlG4Q5Vq1x1ZyV4NHsTEE+efiHOIAOM5K/HxHwxejUEu2Vl3zVdis2ePdq5Nz3rE3zqVB8Eia376h1CQ5ZUApO+Xvrkb7KZqrGtlBDqfAKmAGEY816HlKB+C/fXZL6gKwUJZNFziNZSuVSoFjmLIQmQK5Zn3AFYNMj7XSLuAgPDpgLaaXpINCu3OVmXGnq/7ipfsi4rQQ7BC0qknt308dU8ObzmvihVtmFhp6E2Bv5NqT+b8iLJPQchFwfEqhu5kZTFBkaxZsX3ygjZ5spD/oaRyHhl95Jig00apPx1CjlgaL9lOD6PQx8y/GJ X-Forefront-PRVS: 0850800A29 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(229853001)(50466002)(4326007)(2351001)(4001430100002)(50226001)(33646002)(48376002)(77096005)(3846002)(66066001)(42186005)(6116002)(47776003)(1096002)(5001960100002)(53416004)(110136002)(107886002)(2876002)(586003)(87976001)(5008740100001)(5004730100002)(36756003)(86152002)(92566002)(19580405001)(2906002)(189998001)(19580395003)(5003940100001)(122386002)(40100003)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1785; H:tiru-pc.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0701MB1785; 23:brDDVJT6VIZBvAtiS8hhleHdSyk5qrqW5zoPeHk?= =?us-ascii?Q?CyQpGj4YADEYFOOZeEht34EQhHMRUxQepGb1Y9A6aNk+j+Jeosbs+sbeiM8y?= =?us-ascii?Q?AflnFazU+Fdsg3GY45tzVS/caYC6fNlNpENv3Wz2qbOVHtiDsC1v0ZRHkZBk?= =?us-ascii?Q?MrMebUAOn1xi6zx8H2D4r0//UkOL/daRZns8ktJqHiE4dz3iQANnjMTPtWka?= =?us-ascii?Q?xuBKs2L8MPHyetCxGPx8cgI87lmj1hvJDOeWNcs4QoKTcM7UMw6n3sjeGR01?= =?us-ascii?Q?8o7PeZo6qOAmaDEgtmW+i/WyWeqAQ/LbzrD0+/moSZkrVpIDn1gn9w1UhNkY?= =?us-ascii?Q?AI8QRD4F/bBoABYYG6Reb+RZ/3XL0hM1lbiCvY4XfTJDP8BAX4NlrAiOADGz?= =?us-ascii?Q?1Oo6jYU6xYwJWibXH6VQwEG/mgg6n0sQmcBlBjqHpXm0KLCtc3/GATIrQAyY?= =?us-ascii?Q?ksXeVWtJck22je5KygHfkl448LKvX5j7KNUHMS2Vvpm8Um+hIxV/WPJPRPy/?= =?us-ascii?Q?ZE+vUcFNsfPtV05mdeCm9OxUfRzqomO6FJiQciXJzmuYCTKbunmiHU/kZ/OT?= =?us-ascii?Q?le6MApYCnfcFgmeLF/OZp0NOfc1aML1s3jmPeZSIn6bK1vfvukSjDLXVQt7d?= =?us-ascii?Q?dVhvF5b4NNrm/FPxODJgHFNJbahZfUfjicVq+HSP8dHeDcPF7t40L4g9SHFv?= =?us-ascii?Q?tmq3LZEBLZSTpIRfv8xbncXUaGF9RpeXtGZWd9KJFk1vKANUdssugWv4g3sa?= =?us-ascii?Q?52g6Fl7hVQWQpAfR+mknB+m6tk8A4MLHh8GsTyfxyii0xJRKgxJe/kLfjnTC?= =?us-ascii?Q?IzgSTmEFAlL3VW6IeAQ4PzhgUAObDrUcJEghpaV6TaEnx2SFpsnb4GD4K40I?= =?us-ascii?Q?mRoSwda3bBJe0GbNG27XKUQ1Us4vGhCT/5zi0yDLYsQ+4lynEPukhL0TThqh?= =?us-ascii?Q?kNyjxqYZbIfkhsC47At5GDZFb1uF7Q1Dac+KXBJk4YrOXLRFhtnwIQzsR6/V?= =?us-ascii?Q?by8o=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1785; 5:c8ZY3K8/yqcRh7U8+hyp/sHYghq1xGQuVSSEspOtSVyIqROkEkrj8OLXA4EXPVW473e7rnPN4IxoyFbkXAFsyKw8vaMdCiyDRDkvxrjDLTaMGYNYPhjqE3pt7WLvVQ0vk9/4xuHxdbNm1IZvd/uxsA==; 24:Os/ShbTOORhBcCE5YesYJ4MCT8Vy2tlkPGA3Jz++dxLNr5BfYnJvj7gWcOolNz5FLdY1E4CCe/uhNl1oQcz4NAuanoZZAhlIQxVSRafCja4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2016 23:20:57.8332 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0701MB1785 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160212_152122_306621_F38E74E1 X-CRM114-Status: GOOD ( 13.19 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ide@vger.kernel.org, stripathi@apm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tchalamarla@caviumnetworks.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 V1: - Rebased on top of libata/for-4.6 - Moved ThunderX intr handler to new file Signed-off-by: Tirumalesh Chalamarla --- 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 +#include "ahci.h" +#include "libata.h" + +static irqreturn_t ahci_thunderx_irq_intr(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); +} + +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. "); +MODULE_DESCRIPTION("Cavium Inc. ThunderX sata config.");