From patchwork Mon Aug 21 16:02:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 110566 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp4243297obb; Mon, 21 Aug 2017 09:03:58 -0700 (PDT) X-Received: by 10.84.212.150 with SMTP id e22mr19646871pli.398.1503331438440; Mon, 21 Aug 2017 09:03:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503331438; cv=none; d=google.com; s=arc-20160816; b=RG1TEQ4C1Tz/6El4ot6jdHIeq45xjb/aQ52+hF4+4+/Yyb5J4LeuWdCVxlSIydN4wm kyhY9f6Qh9Pk3tZpd2Ajz5r2DC+5F8dFbIq5Vnks5HnmUlT3oss/k9mMjmvK81e4eUH8 wsODBJAzhPRzMS8LEZ3+s5ZcQTIZXItvVUF8F62Aii/VL8bMZQe6DdrpiwyEWkzU+5F0 w3PsuAebUc2lLN5Tx6I72IvWJ5GDFOsLKY13Ga5Lb1oosY46CUFfx9DZ81PJ3fLNe7R7 1STaaypArfbXOWOqyy47iQNYZAtxBubm8gcO3jLfdLjk2KljmyIrUEXVp69SWkUhOfxq i9dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=IFWnSkNXFmDTgdFrGspHcwMEjJPGeQJhf6Zg/x48q0A=; b=UQ1J+cpnWcwv7l71j0wdpApIdaKIt7HVpEOfgIp/gaQ6EjA4HBO7tVt0KPA4U3gtZx Q/biPToVyx2TibACgLTITzwzqtcFo3pQvo3H4tlhQIqfJlhjhiMV3ROeLxOMoaReRvXX k0I92SfYXDVuD0MEKml1x9rvJU0hSvZR/ZpYyBwqlbqgRG6zKVkMwf09YRP7g8VwT/lF ROK9oIHU0gjl1bsHSv817Dncv5QfXcBOotzGfik87ncYRGftK+UH5Zi4L4AdxGT85D9s JwZMhHv+4fPjDCWgj3j6KDoPEIZF5tXWERxg7tp5vk/nQzgWTEVcJ/HbMcSpXjN+/vA/ 6kDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=aDUfZH0K; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q67si7423553pgq.557.2017.08.21.09.03.58; Mon, 21 Aug 2017 09:03:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=aDUfZH0K; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754485AbdHUQDY (ORCPT + 6 others); Mon, 21 Aug 2017 12:03:24 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:38300 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754474AbdHUQDS (ORCPT ); Mon, 21 Aug 2017 12:03:18 -0400 Received: by mail-wr0-f179.google.com with SMTP id p8so39041712wrf.5 for ; Mon, 21 Aug 2017 09:03:18 -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=+J6cG9wkbXpcC0qAwwD0lbK2ZfpGAAXFpuKx4Lvb8jQ=; b=aDUfZH0K0esNO4ig16Q99KfSycgMVT2UK8008jr3hVtoEGfdtsEoM4ob9vU2+Zmy65 U3IEVi5LLvQzkDo17m51cZUo/ZCNyPaeYowb9NZrfMIsy+zEMIYRJhhjaIPXkcv+kChF +yzRnkLXsmogkPJ6Vysj3MaGS4cb1y/dDGhP/Zj8x/BLkSv30IhBsoTnwnunDzRwSsdq tWS8ejh7FPSXJYJZ+DkyC5xSxpekeZE6SBnCkmBPYAUpZMjpoVLhbgg0fVMDLY8doimc kCSZW/oH6yp5SxEU0YwuZWuzZQXvfw911mRQxwc7VOVdNBGwgZEElPzmk054oPq7cpiM ZUMA== 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=+J6cG9wkbXpcC0qAwwD0lbK2ZfpGAAXFpuKx4Lvb8jQ=; b=TVVGpdRQ0UAEjRKv+Tk9u8y3p94afPiGu1khndBz6reXXxszl4uJ1EfDQ78szoSWsN VT4al0ttiJ81Rifs/ceSBLQ+1JqzWxebYi71+/jfXNC6pQe9/IeDxUeoO28l89qGmj9u uGgF3rtjXSCa/tCH3r7zvBn/9uDGcAEpXFpyUALeEz+cij0+MX+ptRUtGeO5Xa7jy5BR X39CgThAGsZ4wZOb1A6uBWtCRO4JG7F6lNKSAQkKfSC9kdB28rMlAht7iHPvyBTBHst3 3P/MeiLLdiAi8X0Y2fObbYIgrUW4k6tdH+ypOa4blhKUf61gaI3NRcNRp3zZzBhQCrtF 9ABg== X-Gm-Message-State: AHYfb5gfYIdZyIIWMygdXK+6juPYQldjkyHv3l4Anb0wZiSfVN+SlME2 KPf19xvFBf9tuVaX X-Received: by 10.28.157.1 with SMTP id g1mr4413242wme.111.1503331397400; Mon, 21 Aug 2017 09:03:17 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id 63sm8120063wra.30.2017.08.21.09.03.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 09:03:16 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman , Carlo Caione Cc: Jerome Brunet , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 11/16] mmc: meson-gx: simplify interrupt handler Date: Mon, 21 Aug 2017 18:02:56 +0200 Message-Id: <20170821160301.21899-12-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170821160301.21899-1-jbrunet@baylibre.com> References: <20170821160301.21899-1-jbrunet@baylibre.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org No functional change, just improve interrupt handler readability Reviewed-by: Kevin Hilman Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 93 +++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 54 deletions(-) -- 2.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index c37e31dc709e..5203a9f76fe3 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 @@ -761,57 +767,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) @@ -819,26 +808,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; @@ -1018,10 +1001,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,