From patchwork Tue Feb 16 20:08:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tirumalesh Chalamarla X-Patchwork-Id: 8331311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C248F9F6E7 for ; Tue, 16 Feb 2016 20:11:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2A832015A for ; Tue, 16 Feb 2016 20:11:04 +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 1A15920154 for ; Tue, 16 Feb 2016 20:11:04 +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 1aVlw5-0006nk-Sn; Tue, 16 Feb 2016 20:09:25 +0000 Received: from mail-bn1bon0090.outbound.protection.outlook.com ([157.56.111.90] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVlw2-0006il-6e for linux-arm-kernel@lists.infradead.org; Tue, 16 Feb 2016 20:09: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 SN1PR0701MB1792.namprd07.prod.outlook.com (10.162.100.146) with Microsoft SMTP Server (TLS) id 15.1.403.16; Tue, 16 Feb 2016 20:08:58 +0000 From: To: Subject: [PATCH V3] AHCI: Workaround for ThunderX Errata#22536 Date: Tue, 16 Feb 2016 12:08:49 -0800 Message-ID: <1455653329-4934-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: BY2PR11CA0067.namprd11.prod.outlook.com (25.163.150.163) To SN1PR0701MB1792.namprd07.prod.outlook.com (25.162.100.146) X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1792; 2:eqYOIEJvHID+Muq6Kcm5ULxoNgBBJ+fm1YcwUCN60iXhvPSkC/BjdLU0spBGWA3njs5XGTz+sVWkdZLajgG+1IM/HxzzIKn07S5T5hPMSpJHxNhHhpToacGa8FJYB61hWSVbYYWMpzzzC02hTivayg==; 3:4byZNA5BLIM47cc/2nHmW/4MlW0vHY5lKsMWxqwam0R6iVyve9BND/0zmd60aa3Tb2+DNBN/u4/WVXsuutWUmDnV+j0viVLe0l6JwZcVmlgbZX6ttvItuqkaHz/PLL76; 25:ShxqmOLh/KKZuK885DVuYU4+KLsWDI24or4c6yjcIzWorwfuuPi+ZhaN+sTBFUQrTRMyLC+so/mANTukCkgZh6NbpapYcHUtD2eH0fxqob+XIeWRbh8CWcFSg2ov05OUESyeCgD69/MjMgqsu/P2i/xJzQumUqO+4epp6E2Z4/NOw47H6TmyESIlK1Xe3qXgZeR9J+njlmKqJELQD35YZFw6CfXekW7Idot86y1aDRvICBDYPhU7U3Mg66NO37XNi86jGMYEo4v7fJeyU/aTT0JcQLyhKE41dvVffVdpltap5edp0JwWdtDG7+gNsqeN X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0701MB1792; X-MS-Office365-Filtering-Correlation-Id: d6a98df9-b5d9-47ff-7cfd-08d3370d01bd X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1792; 20:JtzNIQ62iXX4PqluQI/mUIMXxiPjrnXwN20IFSdDOTl4lKcy+FWwfyfk6FSARi+Dgol7EJb918tUmJqX643W6rP7xC8VMwrOO73mURYc3L+rxnJ2zs4/qMv7dNZOPzxs3UhIIfn2rEsxz1BRlr1GEClxfEKxIXAEltxb/kvNHJSH550KmhtPdzQfYLNZbA3HhONvE3d80C6e/f/PjAibYkfJdx4VJShXYva5awqxlZsM9qEU14x1Vy35NK76Kwz9SyKMw0w2i3ECDdz/xzUe64lE7S7GgYxL0HeIUi3rImXEF+h1tBhJDOvp2cPsV1BbLhKlIiRL1b96Bj7WIwg9YnIm1VnVXDuvJBy/vwe4yrXktodno0dTZLoq4O6eSkrJBDE5R+52Daf6g00Jdb/rxsDPMKPrcbuXRHSL/0EFd4ElPNUw4MriJDfSsFOYqY3ttH6kgJ1eiJRjfp3Oic7/dbEAkrB+2JrDtocwWBO3T5L4WJgcdjiy9S6XzrGmtJ7cWG3eqTsW07mYsG/bvwXgYt/oESm2n7AQS8wD8qBbvlF8q2L/xhNl7uNchxSu37eYLTkojI2SssghS4NC0o02yExX9K6+WM8TQJ6pAHKHGp4= 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:SN1PR0701MB1792; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0701MB1792; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1792; 4:wRHLOQONPQdZapuN2LJxPq6T3Yz+ODdsIK7FElPSrCeeY5+uvL43vxQDlzIdaLzTO8WPJWErUNHTCmXeAtfRtKeJkk7CV3/TJ2wR+2egAAt/dTq7A8Zjuze9oBVfLl9ZGYqRZnt024jiZ4GankrtMTRUrlm7PyWIyWZJvNpkxYVqSeJb1hkYnroDeglteee010wlSLRc4R/mOyYEpy6KTKc9lC/E9Ci/Rzzjz+rEYUgO4rByUX0qmolJVq2ceNKchGeyBklXus4oPPuTP6vkEDO+TpNgaAGAeIP0rXqnmsF3ju5q7muZ7tFXw1onxnkkX2PkBI+zYao0G9oDJ73FjtAfI0MFSrA2dChB7LYUDG7Zz0WY+rTIgF/DmkCXydnM X-Forefront-PRVS: 0854128AF0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(2876002)(5001960100002)(189998001)(107886002)(4326007)(87976001)(5008740100001)(1096002)(50986999)(2351001)(86152002)(110136002)(4001430100002)(586003)(229853001)(3846002)(6116002)(33646002)(92566002)(5003940100001)(77096005)(48376002)(36756003)(40100003)(53416004)(50466002)(122386002)(47776003)(19580395003)(66066001)(19580405001)(42186005)(2906002)(50226001)(5004730100002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0701MB1792; H:tiru-pc.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0701MB1792; 23:OZCCzWT7mSA5JW65K+UUho9/0X3R2QpeU7QvUrg?= =?us-ascii?Q?1hGHPt9ozTfS6sC4f2UE2gDtyKlMXWvNjzclIdgM5qWnxXLMN09te18R+SHa?= =?us-ascii?Q?oIENw1sBHzT8L79U8JL+OHx/S4m96OvbCFlteK7l9S2R/Iq6yryZwHeNmQU5?= =?us-ascii?Q?8bvuY5HHzCyWnrDIWGeZEdVlWOgWQGgcSLxt/UYoM9HpwrJzSWjamBml9b+5?= =?us-ascii?Q?e2spL5CtB12yI44v18J00niPjCc5DD9/RYq1+UrTsDTaDP28L0P7AzjbN+3V?= =?us-ascii?Q?F8R+2Ze3kBnMJH5/3K+4AeWIcVjUlfGvcMBVbt0YmQhlNkE12FfTrhiJsSHe?= =?us-ascii?Q?SotA27u7KU3aA/1syBRdHkxFIsyTlYFX4YLfV6in6ACubR7HDDIYP4lB/qi1?= =?us-ascii?Q?8Gom1Rxr/T7dde1Y+5qYHwRq6yJXDjgv+cxMEg84SWSl+YldexbRvEvsxmic?= =?us-ascii?Q?WEMSLePjkHjwkHjvcDeTk+saIii4mQRA5qPFv2ZwxhUC84kgDEnuVmjkucv6?= =?us-ascii?Q?fc/53vmfOSeAbH0DcG4ydOHftppYFcN+xCyjaAcazp0PndISTo8QY3pQxRs2?= =?us-ascii?Q?mA0wKtzq/Y/5qMXKYk7+ebaOw0BDCJdaP/t6SCp5TMN/cX+YSXtN3Ox316Xg?= =?us-ascii?Q?WESz3NqCCZRgIAaKinBVCz5MjJDGibDTe5w7uy573wgnNGUfdCdlIZDkdEof?= =?us-ascii?Q?c3GMbKqygfJnZtfbrPDdSqMqSjVv+vK6M77FN4FMFk2N8qoopUec+E/La7rA?= =?us-ascii?Q?4rCUhmAhRbTP/Vo8xkj1L7IorEjrgsQi46VXDSANJNGZk7NlmoQoatPvwqj/?= =?us-ascii?Q?35qIaCmZCO+SuOYG3xeFBf/owyS9hJWPZL6nEu5j972UpfoNaJYfxSZ/Csjt?= =?us-ascii?Q?9YotXIgaP4MD5sZA3RDyrKPnNHqxtqhCN95Iu+fSIKn8KcOaWe7T4sqCza29?= =?us-ascii?Q?b6kvDUarb2SLK2k/jgz1WK5Bz7LlfPPPeU3tra9gnUiVrVFt+D/1/bScVTfW?= =?us-ascii?Q?xz//QSPLYqVStGxJ2XynJlh3V?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1792; 5:w7zm1jvnj70cbfSXyqJ8X6KlqsFDYm1NktmXztzpSU1244aysvDis1ggbNUNHJitXzA4yuHRb7MZNw71fQY1kCkQdLF3Kd4G9hd7AqOiE57fJ+4aflv8+VIa4Y9t3CR9oBvUB1o6wgMaDUJkXPpoXw==; 24:y+emk7mhlOPpnKT+U4XV3Fg8KzlO0LPRC0GgU7B5ZE/zguowV8rGww5wfinn+z8z4+pBiCMkfJ1fhSkclY9QnK4FhioyUUCMQ1XC1Lleidw= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2016 20:08:58.9388 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0701MB1792 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160216_120922_429750_F5BBFDE9 X-CRM114-Status: UNSURE ( 8.30 ) X-CRM114-Notice: Please train this message. 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.2 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 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);