From patchwork Wed Feb 3 22:37:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tirumalesh Chalamarla X-Patchwork-Id: 8210431 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 48DF19F38B for ; Wed, 3 Feb 2016 22:40:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54252201C0 for ; Wed, 3 Feb 2016 22:39:59 +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 4F04E200E3 for ; Wed, 3 Feb 2016 22:39:58 +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 1aR647-0006vE-7A; Wed, 03 Feb 2016 22:38:23 +0000 Received: from mail-bn1bon0099.outbound.protection.outlook.com ([157.56.111.99] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aR644-0006ll-1t for linux-arm-kernel@lists.infradead.org; Wed, 03 Feb 2016 22:38:20 +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 BY1PR0701MB1784.namprd07.prod.outlook.com (10.162.141.22) with Microsoft SMTP Server (TLS) id 15.1.396.15; Wed, 3 Feb 2016 22:37:57 +0000 From: To: Subject: [PATCH] AHCI: Workaround for ThunderX Errata#22536 Date: Wed, 3 Feb 2016 14:37:45 -0800 Message-ID: <1454539065-16891-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: CY1PR1101CA0023.namprd11.prod.outlook.com (25.169.17.33) To BY1PR0701MB1784.namprd07.prod.outlook.com (25.162.141.22) X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1784; 2:YH0rZ+4WASWBB8dReSN5qo0OekGJkeaz+OZsD5DaD5ZHqQQ5Gby+fY7tQRRT52kG245iBCghnxExxSlUECOJKA/0qolfuQWQ1GjdfJNKHrO2FOsNGvii+hICVj8oHBx0eyBu45BQMArdLkXXlAtqTQ==; 3:54NpD+ma5Kxgm/kayte2gm+KeKk/ls/Q2OB4R5cUDFkLshU0t3ldhSN7azn1awsaX8BSmDOIzBtz7sleKLFR7J+LBE80mNYlyrikMzL9l+VghurmLwzj7FEpbeTaWNQ1; 25:Ff5I1VTmTIKV5/YzVQDzvz7CWgC9TeAWao9go4BRarDCUH4S6GMaySJ/6TMVCt/IEZjHeJChawGDQL9WZr8bjkBByRXOi83mxxYH+Uyfz8THUHlCjBFjwZjch2X9QcfJDhwch++CAtBvXrmE8EHeVcZcks43I2pCZ5cLsuEBU0dnS9hHhNhe9G3nNdY7G6elY/HY2hVsDCm28l87BIQObSnGp+/ZC8T0nuoHFgtGX/6/Ucg6cBqJRHjwf+1VkDEs X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1784; X-MS-Office365-Filtering-Correlation-Id: b9de7692-5a38-49bb-8a26-08d32ceaaa23 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1784; 20:9WMrRp1yIjvTervcLTUxfeHF+B9KnS3xsbBOdgB+9oREmtHTT9jJ3rZegOdlTdWuyYDPFkjg1sYd8wnfvD2/bqd8wKfecn2dzY5Xwxtn4uHrbi22AGbdAXe6ZFtmgOdaODWzoqnC7qjs75iBDtggtzM18qKJ6pQNXY+G/m0TgRZFyG/aXx4ss2DWkxma1EAfN2uKFI0LFLuRZbY1u21kQztVsTLWjctp9yPyPI5U6AY5O9FrP+Yty9nlAR6lTK9yRj9sBDpZjUyJ4peB23uYc5osonEZy7CRiqZQXj172Fmey6CYL2T+Cg23/uPJOlnySI9D5jlut/q45sphhqOKoMbvH2/gAXHipTxo7TxyKLSU72vqml+3Kysd2PC9x19yx3MPCEfeirbc0pugGVfGMSDgqPUxl+wbHCyGPGhQ276Xpfmm5zFstTeG1pOCw2P9ewYYMs7enJmzps4BJacpKjncTdPV5+Uv58g2tYpDwQzEe60LOOJo1VGh42f1YnnaY9uI5fU3/v11L32+0xHIq8XcQpEi835VwdFMwbZ9vSatNj11Ge68KFj+i2eU9IAfvxMCJ7IxJaU76IZTcKICt/CNYQ/3JZWvAbzljHqRnIg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY1PR0701MB1784; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1784; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1784; 4:XDL3XHbrlOJ2LfcZJgOAB2VksrdIY8SOEHIj4T2T50LFLbkiYYx2eZIOUMwm72qGxKJn8ybZqEJxNMn9jtreF0qbSwAEm+uRCVfm45Bd+FDnoZShCVffa8Fo8584+YWpzuWxgGb7R/u5wLhtNa5Yu735BRzQAMeEPppoSDOUGzR07pM6NSUX0PpBqX/L1Ufy8v8dC+byRxysFF7qu10lu9CfnijfOn8m76sQPVJhOXiU+fWMSp4V+jm59HT3yDtWV0Lx6Es1LnL/YW9IrrA9qd8e7qee+jVhykATz0LMHoE19OmDyGLS9eHuGnr/FgAs6U25CHNKW/bnZVxDQoMTkcqknMfiCR9hYjpBwhDwutHJqBw38o1Jey1wAcvJBSKi X-Forefront-PRVS: 08417837C5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(3846002)(107886002)(40100003)(586003)(5001960100002)(77096005)(36756003)(122386002)(42186005)(1096002)(33646002)(4001430100002)(50986999)(189998001)(86152002)(66066001)(6116002)(53416004)(5008740100001)(50226001)(48376002)(229853001)(2906002)(5003940100001)(50466002)(92566002)(19580395003)(19580405001)(5004730100002)(87976001)(2876002)(4326007)(2351001)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1784; H:tiru-pc.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0701MB1784; 23:eOvP+YHH4h42aiu5mvUeLMqUN7+RCpEEo6b0JsG?= =?us-ascii?Q?V2NQVHPTm0sfwTaaJVwQ8KV3NMXMcgCkajNlGH3uaHCN3y/Ly8qjtKGUiKO9?= =?us-ascii?Q?L7AMBA4msEe5pv6JdNt6NA6YT/1qURjZubJ6ejSNq05yDZ7WP1ZuqssoBL/2?= =?us-ascii?Q?ocrFHp18B3W/wlScXRwHoVV14CO4nI6gLWlh+1u9/EInRwDt7n2q537kAOVo?= =?us-ascii?Q?8Grp5SNuzXhFz2aQS7AS7BhNrmB8b5BmeOTp38t82/Arnh44DC928a9aRt5e?= =?us-ascii?Q?175qSRgSMwN9gwZJ1TqTHZOuIfu3z5werkjzcbSb3zMX1kLK+CtLZ/MU+sAw?= =?us-ascii?Q?r9rsvRYu4uCZL2Xk11YoVEal18HOshtwfQbhgOmVF+/mcjDTrjDVZL9cTbR8?= =?us-ascii?Q?t+uLjBg7bJULec7areVMhsR9ftljxNhn/P7q3uG3SjdPgREWXaEEvWMRL4Q4?= =?us-ascii?Q?pfXfzAHUMc2kR7oZq0xoGj6lkqvCJv040+tsC8QSzvmGqmIYcQbwGS1XBP5r?= =?us-ascii?Q?V7jlVrwOqT190t1gHD5hGzCWJHCX5ddlv293wSAXVkVhwFsd17bUya3THBLt?= =?us-ascii?Q?JqsvYSUVbgDDvFq021L+iPZavxNm+IpV7EhujCRsohO2D7U82mqzdBa9Plok?= =?us-ascii?Q?hOEyfl8h+LL52T9FTDdqx3m5SBaxvcacEE76lywJEK6iXFu1bd5xhUe3bif5?= =?us-ascii?Q?cMiaYmZFM2sae9FHBta2hkDhuauly5RRvUMdIPpndnthTisQ9wENnJ5QtlsQ?= =?us-ascii?Q?R+BZ7zDz5xePg46ndYJC3yVND2A3t+QO+5popLCrwdPNcswIAaeJe+Mtd2ZC?= =?us-ascii?Q?11CB2CwrmyfHAWbUfbj60DJkWsXbp0IXdQbHy4Z+Nu1BVdbfFBTJpyFI0qoi?= =?us-ascii?Q?049IvEBvP0ctrwJApPQ6jxvG9P3mziWZweX2e8wbjB9rDnqoV6wYnIREuz7L?= =?us-ascii?Q?gOQUSFc370wMTbgFcVnwGbMpMwtsQ1C4fiM7dlJnucg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1784; 5:6cWl5fAiVfA5RnGzWFlUt5DTxqsxWXExoh3rnKLYe2STPahS0OkSkgWFPOdK+UTr3mq2zPhizrT4UL3B1cNaoNOYiT/YEy9KeeVegwcbhPhc9YGyFDgAxNQ0UFp82pzLjcT9BAmOVU1Q9U43otEytw==; 24:jug3WUv5Q453+M8VymWUa+LaEkzg1R4qBXBulbve2+kiC6WIW1hE8ZDG+jCtoHPt5pdvo72q2uuKAmsbaw5onEEzl7NbYgNlQB+qPxMSgiA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2016 22:37:57.3109 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1784 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160203_143820_378413_2AB9E2F4 X-CRM114-Status: UNSURE ( 8.51 ) 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, 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.6 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 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 --- 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);