From patchwork Fri Aug 4 17:43:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9881845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 15821602B8 for ; Fri, 4 Aug 2017 17:47:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0287D2891B for ; Fri, 4 Aug 2017 17:47:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB98D28930; Fri, 4 Aug 2017 17:46:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5D0C12891B for ; Fri, 4 Aug 2017 17:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Hw2+QM7JvoXqrA5gKMSfT0ej7AXBHXqFhB5P2b7IeUY=; b=SbNJDs+Ycdq89CHHLtwHByoGXh oylgGtvZ27Y6VKMSj7ibvpPU67zk5S3G0aaaVM0LCt8LcN5vtqnDwilMpKD73+HIywgQZ+AsOplGS NJghvpgsRZf/NsryKfUeKsuAnzf/hS6q6MqDJ2pq8q9AqtRMzacDHf0uXL5wUohcFPXVEsARGgqdg WKRece1qbpu20FKCGhvz2Ig+F72glcMtCyOkuDIxpknNS32hIBBUaeI0BVFUdpEItFPDj/4qvG9w9 vcYQoPR4HlJwQLIjhXQiHbAJpDpXRJF2gFdDxLnXLVqjRT2ey7bmjHdoqV2DMz1rOErxjTu6oSDGp axGHhIRg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ddgga-00010v-4o; Fri, 04 Aug 2017 17:46:56 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddgeO-0006Yu-Bk for linux-arm-kernel@bombadil.infradead.org; Fri, 04 Aug 2017 17:44:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=z7nihxWu0S+4O4TVXoHtmzKCVQm9II0xJWIGwBdARGY=; b=v8w/jfFJYJFCG3fGkSuM+NPq6 E5jDvgJ2lrcoEuJqUAIsSMCb01EuQ4rOXe/rtxz9Dex96L/ugO/nI+IaD7L9bF22omU3dqpJOrkzE WWN+YsnKl4YzbhtkGQUt6CPcj7rMvkjXLQymOmTvy0pd4+RFRUzzi2GTxE2fqCHod+d9oWNBfYlsI 3PpvqijhBuJXx3l9VIz6F9k4kVivOZE4qQ+Vn5OaOJxWPVtie0I5+TfKcuZXT9qSWqhMv+4oVTknY 3Wi+OuDQShZP3v1fbJ0ThVLaErb/osOQkkku5hId9C67GErRBJYCocnhBGwv41a6YlhpQsSxFz5fu X13R4LuSg==; Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddgeI-0005gS-60 for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2017 17:44:37 +0000 Received: by mail-wm0-x234.google.com with SMTP id m85so25330347wma.0 for ; Fri, 04 Aug 2017 10:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z7nihxWu0S+4O4TVXoHtmzKCVQm9II0xJWIGwBdARGY=; b=E8HOVsJnkEjVlZYdCdfxq48z2awtsy2zysBcf4JuhWy0jg/gUTbb5u4zwmXlPAN4IR UN4Pt+gQ0tPO0n0fRcm9uB4JghRxuLUacpXANmOXkfjDD9WQ4IJ6JSzDlcSqs2Hky8Hh p0JfVaU0pscmenHiWQuQ2/HYbzF9kmJXr5qvderfRk/p7q1FWzuyDkzNoFWv+eHQIj45 xB/WPVYctvi+oT+Pqpcw6tJ47dWX3xFeRrTG6uRWJKOO19rUXaqgqqo+J0uk/zWU1RBe hAhB3v9iu23XEWkBP40AIakAb2P9MK/o5Z26412+rRLEAxqGG5Zp1jeoz5C8SpHQUvO+ 6FXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z7nihxWu0S+4O4TVXoHtmzKCVQm9II0xJWIGwBdARGY=; b=rVZDF35+2qxRzKsEsMeXsCV2SpRrwNsE3mOLhsXxUT+QLFZ0YJ/BqXGDbKJlDOBTHt qxxX29YEQhu9c8Xzli15DkORc/k8lZ9WOzFIKX3b/mbj2vm6gbxJ7hqUAyaRcFkxaApS DIouybHGOSjOirX+9rGbnzC9RewNQXYzTogGG4dQaLqzc3blzK6wxXkMEG42UsdkvU8D T7Mio5EFfsRVdpB4FYoDmRm1KefjBFF9k/HVbP3EDootn93PN1Nlzyg2usx0bgi1uJ77 4XAXwWr23AgRsRdMahhIy9+fhaGmCGVj51j0yy0suKIxtpbt53RVCCeQwe2ZpFafj3H7 4gYg== X-Gm-Message-State: AHYfb5i1Am4ryYU/OdhVEOZjOALkq9+AkhQggUKhEWHtjGqHvaq5ePOb oZGOeZOTpUWcdrz6 X-Received: by 10.28.199.207 with SMTP id x198mr1728255wmf.156.1501868652787; Fri, 04 Aug 2017 10:44:12 -0700 (PDT) Received: from localhost.localdomain (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id p17sm996082wma.45.2017.08.04.10.44.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 10:44:12 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman , Carlo Caione Subject: [PATCH 09/14] mmc: meson-gx: simplify interrupt handler Date: Fri, 4 Aug 2017 19:43:48 +0200 Message-Id: <20170804174353.16486-10-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170804174353.16486-1-jbrunet@baylibre.com> References: <20170804174353.16486-1-jbrunet@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170804_184434_396207_3B5C685C X-CRM114-Status: GOOD ( 16.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP No functional change, just improve interrupt handler readability Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 93 +++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 54 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 4cc7d6530536..d876b80db27d 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -78,16 +78,22 @@ #define STATUS_BUSY BIT(31) #define SD_EMMC_IRQ_EN 0x4c -#define IRQ_EN_MASK GENMASK(13, 0) #define IRQ_RXD_ERR_MASK GENMASK(7, 0) #define IRQ_TXD_ERR BIT(8) #define IRQ_DESC_ERR BIT(9) #define IRQ_RESP_ERR BIT(10) +#define IRQ_CRC_ERR \ + (IRQ_RXD_ERR_MASK | IRQ_TXD_ERR | IRQ_DESC_ERR | IRQ_RESP_ERR) #define IRQ_RESP_TIMEOUT BIT(11) #define IRQ_DESC_TIMEOUT BIT(12) +#define IRQ_TIMEOUTS \ + (IRQ_RESP_TIMEOUT | IRQ_DESC_TIMEOUT) #define IRQ_END_OF_CHAIN BIT(13) #define IRQ_RESP_STATUS BIT(14) #define IRQ_SDIO BIT(15) +#define IRQ_EN_MASK \ + (IRQ_CRC_ERR | IRQ_TIMEOUTS | IRQ_END_OF_CHAIN | IRQ_RESP_STATUS |\ + IRQ_SDIO) #define SD_EMMC_CMD_CFG 0x50 #define SD_EMMC_CMD_ARG 0x54 @@ -703,57 +709,40 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) struct mmc_data *data; u32 irq_en, status, raw_status; unsigned long flag; - irqreturn_t ret = IRQ_HANDLED; + irqreturn_t ret = IRQ_NONE; - if (WARN_ON(!host)) + if (WARN_ON(!host) || WARN_ON(!host->cmd)) return IRQ_NONE; - cmd = host->cmd; - - if (WARN_ON(!cmd)) - return IRQ_NONE; + spin_lock_irqsave(&host->lock, flag); + cmd = host->cmd; data = cmd->data; - - spin_lock_irqsave(&host->lock, flag); irq_en = readl(host->regs + SD_EMMC_IRQ_EN); raw_status = readl(host->regs + SD_EMMC_STATUS); status = raw_status & irq_en; - if (!status) { - dev_warn(host->dev, "Spurious IRQ! status=0x%08x, irq_en=0x%08x\n", - raw_status, irq_en); - ret = IRQ_NONE; - goto out; - } - - meson_mmc_read_resp(host->mmc, cmd); - cmd->error = 0; - if (status & IRQ_RXD_ERR_MASK) { - dev_dbg(host->dev, "Unhandled IRQ: RXD error\n"); - cmd->error = -EILSEQ; - } - if (status & IRQ_TXD_ERR) { - dev_dbg(host->dev, "Unhandled IRQ: TXD error\n"); - cmd->error = -EILSEQ; - } - if (status & IRQ_DESC_ERR) - dev_dbg(host->dev, "Unhandled IRQ: Descriptor error\n"); - if (status & IRQ_RESP_ERR) { - dev_dbg(host->dev, "Unhandled IRQ: Response error\n"); + if (status & IRQ_CRC_ERR) { + dev_dbg(host->dev, "CRC Error - status 0x%08x\n", status); cmd->error = -EILSEQ; + ret = IRQ_HANDLED; + goto out; } - if (status & IRQ_RESP_TIMEOUT) { - dev_dbg(host->dev, "Unhandled IRQ: Response timeout\n"); + + if (status & IRQ_TIMEOUTS) { + dev_dbg(host->dev, "Timeout - status 0x%08x\n", status); cmd->error = -ETIMEDOUT; + ret = IRQ_HANDLED; + goto out; } - if (status & IRQ_DESC_TIMEOUT) { - dev_dbg(host->dev, "Unhandled IRQ: Descriptor timeout\n"); - cmd->error = -ETIMEDOUT; + + meson_mmc_read_resp(host->mmc, cmd); + + if (status & IRQ_SDIO) { + dev_dbg(host->dev, "IRQ: SDIO TODO.\n"); + ret = IRQ_HANDLED; } - if (status & IRQ_SDIO) - dev_dbg(host->dev, "Unhandled IRQ: SDIO.\n"); if (status & (IRQ_END_OF_CHAIN | IRQ_RESP_STATUS)) { if (data && !cmd->error) @@ -761,26 +750,20 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) if (meson_mmc_bounce_buf_read(data) || meson_mmc_get_next_command(cmd)) ret = IRQ_WAKE_THREAD; - } else { - dev_warn(host->dev, "Unknown IRQ! status=0x%04x: MMC CMD%u arg=0x%08x flags=0x%08x stop=%d\n", - status, cmd->opcode, cmd->arg, - cmd->flags, cmd->mrq->stop ? 1 : 0); - if (cmd->data) { - struct mmc_data *data = cmd->data; - - dev_warn(host->dev, "\tblksz %u blocks %u flags 0x%08x (%s%s)", - data->blksz, data->blocks, data->flags, - data->flags & MMC_DATA_WRITE ? "write" : "", - data->flags & MMC_DATA_READ ? "read" : ""); - } + else + ret = IRQ_HANDLED; } out: - /* ack all (enabled) interrupts */ - writel(status, host->regs + SD_EMMC_STATUS); + /* ack all enabled interrupts */ + writel(irq_en, host->regs + SD_EMMC_STATUS); if (ret == IRQ_HANDLED) meson_mmc_request_done(host->mmc, cmd->mrq); + else if (ret == IRQ_NONE) + dev_warn(host->dev, + "Unexpected IRQ! status=0x%08x, irq_en=0x%08x\n", + raw_status, irq_en); spin_unlock_irqrestore(&host->lock, flag); return ret; @@ -939,10 +922,12 @@ static int meson_mmc_probe(struct platform_device *pdev) /* Stop execution */ writel(0, host->regs + SD_EMMC_START); - /* clear, ack, enable all interrupts */ + /* clear, ack and enable interrupts */ writel(0, host->regs + SD_EMMC_IRQ_EN); - writel(IRQ_EN_MASK, host->regs + SD_EMMC_STATUS); - writel(IRQ_EN_MASK, host->regs + SD_EMMC_IRQ_EN); + writel(IRQ_CRC_ERR | IRQ_TIMEOUTS | IRQ_END_OF_CHAIN, + host->regs + SD_EMMC_STATUS); + writel(IRQ_CRC_ERR | IRQ_TIMEOUTS | IRQ_END_OF_CHAIN, + host->regs + SD_EMMC_IRQ_EN); ret = devm_request_threaded_irq(&pdev->dev, irq, meson_mmc_irq, meson_mmc_irq_thread, IRQF_SHARED,