From patchwork Tue Sep 3 14:21:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172795 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641288ocp; Tue, 3 Sep 2019 07:22:35 -0700 (PDT) X-Received: by 2002:ac2:46d8:: with SMTP id p24mr20029612lfo.58.1567520555241; Tue, 03 Sep 2019 07:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520555; cv=none; d=google.com; s=arc-20160816; b=GemAo24hJXRzrJ3f/vaFWtzfRIu/143M2GVtsXUWIndQ40WbfHflLVFiI7oUst7YFQ BTkbAM6hQU3RBJ/1/6aKC7eCBNhfxIH46k4vAjmsFh52nEuI8eCvTpGts4wavuRItkv4 LeLwhWgewifem8DPCVNGXrLDQb8gOqmsCe/fFvIK+1Y5z0l8DQIiPdYTivQSpib47aqL 6DQMPFLk2eg11ONuj7WV5SprFHUgW5194HOZkK/YmhdtN+jGY0vrZpZ2e7WtwOW5OvWs mayrWefuSW/pjHeylfldH6lhP/nvQkjpNbfVdPJFyhxB0+joJO+q2wRYbA038Xxyv4wL VclQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=D5QBbUbIGIGd6IsxRdoAWwzoHYpPt8QRqVo3tuh083M=; b=z9fUsKHh+dWjAKjTzIDWNp0SoO8ulTyMb/fVZrTLU9BB12/Vs1vg/+IOn20N9G2mxF A/EMSvms0ABr8PC6chdm3AmCdWdSs1M65owAB8AyJk8/LH7lM0Zcqv+XZVUNZvcpbs0+ sO4OauEssSrkAkv1Qm5vD5MsckyMmUNupcJANejGxHj83bis9biInsJ4TF+hl2E+HoFl OmvPPgCU0tXKnwOu7g7h967vdHSfTATfWmpPmmiBqiv06koTcWaJx6p30bY2uX5vXOm8 8I3dkJdWUjYaowzowITpGOdKcGo8aqYJmowYBO/j19JnZ8oLSZNxl2kXDlgksPzoi841 0New== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RP7NBDNt; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e8sor6618489ljl.36.2019.09.03.07.22.35 for (Google Transport Security); Tue, 03 Sep 2019 07:22:35 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RP7NBDNt; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D5QBbUbIGIGd6IsxRdoAWwzoHYpPt8QRqVo3tuh083M=; b=RP7NBDNto85o8qwpd+eBtArA8GsDbwZzo/N21c5w/x6H5zZ5ZPvBKOgT5AKNZjn4UQ VtlHjUycq/Sjk7L+8sIg5gVnv9YNWJl5mP61BIRnivL/jWz1tFolfQUSHRItCk0FfYBB tTbntNmCtOIEAtIBHrJLVQcmfKNvs03l4FAeYhME9rQZYWB2FEJ58cmnmtC30es9NDRV VCHMolZ3jrdPU57/NxfzMw6I7vpgpIjQyMAfJrwOxX9/5dccWgMqFFjuDxfa0iGilerx 7mr+AforWPw4ExJA6GKojspQDjLzq8ixKdjDidfmy3xZkXBIoaTRRLSfwlfYKC72AKzE OAug== 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=D5QBbUbIGIGd6IsxRdoAWwzoHYpPt8QRqVo3tuh083M=; b=oEjpr4KvAF/7BqZ01fGekGlfRNgRUTBmP9I0wsqcJkQbSmKiSpp94gM7vDBu1YHJcT 12d+eoMWbcS0DMvxj/DbX5sTACKpENgEMlT1m9yrqXVD2GS32Ipjuwcz9xwtnqZaT6Ad TtmO/0y1KZhD0ce2x8JAxWMSzdiX7XPtAFtOfCVtnPrUpJ17ZSbXWWTf3YLs9i+hWBcf Knq6PUBzFC+xKuYrmRvOlksI+Cvmjwl+RgJqSxnhjOH+oNGD+F7xry4dXT0YjX0JgWCh Gx1ew5ywyCebacMZr4+k7r9gqnocEjeOWwKpR8CbbqEUfBcp86VSO24CGcx0ssiJ5l03 mRAQ== X-Gm-Message-State: APjAAAWLInmr/ZC0W1gC/rb18exhysUU3PDyfKOnREACzBG9/MOAdXhb 8pJjNo172HFNsCC2hSyEfu3KIhjI X-Google-Smtp-Source: APXvYqyYZS0LZ/x/v3d6oArjV2CxJmO4miYGU2bMEsj46wakq+VgwT1upJ9K3Ttnb344DmtcvFVNBQ== X-Received: by 2002:a2e:99d7:: with SMTP id l23mr1996664ljj.86.1567520554912; Tue, 03 Sep 2019 07:22:34 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:34 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 01/11] mmc: core: Add helper function to indicate if SDIO IRQs is enabled Date: Tue, 3 Sep 2019 16:21:57 +0200 Message-Id: <20190903142207.5825-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> To avoid each host driver supporting SDIO IRQs, from keeping track internally about if SDIO IRQs has been enabled, let's introduce a common helper function, sdio_irq_enabled(). The function returns true if SDIO IRQs are enabled, via using the information about the number of claimed irqs. This is safe, even without any locks, as long as the helper function is called only from runtime/system suspend callbacks of the host driver. Signed-off-by: Ulf Hansson --- include/linux/mmc/host.h | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.17.1 diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 4a351cb7f20f..0c0a565c7ff1 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -493,6 +493,15 @@ void mmc_command_done(struct mmc_host *host, struct mmc_request *mrq); void mmc_cqe_request_done(struct mmc_host *host, struct mmc_request *mrq); +/* + * May be called from host driver's system/runtime suspend/resume callbacks, + * to know if SDIO IRQs has been enabled. +*/ +static inline bool sdio_irq_enabled(struct mmc_host *host) +{ + return host->sdio_irqs > 0; +} + static inline void mmc_signal_sdio_irq(struct mmc_host *host) { host->ops->enable_sdio_irq(host, 0); From patchwork Tue Sep 3 14:21:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172796 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641326ocp; Tue, 3 Sep 2019 07:22:36 -0700 (PDT) X-Received: by 2002:a2e:9a84:: with SMTP id p4mr19930625lji.52.1567520556500; Tue, 03 Sep 2019 07:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520556; cv=none; d=google.com; s=arc-20160816; b=Ua9dWTu21NvAR4gFbNOjRSU5sFSac+HpBMfkaaCcftrOsHq392MOP5lG60Kwab537P B+RiOTo/OHkT/u9O36MrSCIG1HqRTA5QnDSUHiFCT8cIzAow6xNa3/AUCrlnrGmvzjBs pf/Qs6Ifjgbrm5gD/Do+F9hOAZrmx3n1PO35iqocTYxq0FXOpjzfH44A2YopSwY0Mec3 3LvcWsmR3FiycIRuWDGZhw6nZKrLyKZWli7flyTbWfds9USxDrB8BK/Zf01wN7IHGlMF qQQtY/LHVs3/A6TVeFZfy9d/aPFzh/w2GOkIR/kxTP6dWKaOl+0CGfh/B/5qCFbz9CDk 00FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SADru+zeJoUa6Kq7NgE3oCMhDB2qphP6ONJw4NgANKU=; b=UCEeiQiR1ztnkfHP6O6yQWDixOv45/sMKRQllDUXImJlf4L3zDo016HbIyOsRoJM9+ NtkmoediNKiyQnF1hNSpy9wQzRqYGJ2ve1vby68FeBy2+Oyd0Pp8lNhpMAlK8wp548Dq a/GtIuqatNMv35Imb4UPzbb1TsVIxXB5mDsPaDU+VBljfnfiaXucYa9PhTudKHS31ZCu uMFUuwlxNapBdv0rPx0X1z3gPoKfNxGCBYKhOyPMP/j63sbs26fGdWHFSp8quP3fKLwc un2n9y/KtIt7Jp3kCk/o1UCLnUUCgsv6dsK8SabS6stlAZkJCL48zkuv4P14jiu7GrGv qyvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OFHtfa4w; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m17sor4908480lfp.48.2019.09.03.07.22.36 for (Google Transport Security); Tue, 03 Sep 2019 07:22:36 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OFHtfa4w; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SADru+zeJoUa6Kq7NgE3oCMhDB2qphP6ONJw4NgANKU=; b=OFHtfa4wufhXWOWb3kQTUHd0i9YHGWH7vS4YpuePByo1apgcQx0qPn5D2rDAPelA2Z c9AFN0rmRl04Af4morxrZ3mOH/6uAa5o24p5hlLofES39wmRTB39cuKWKsxsRbwOPueA DWKNvjHA7bcEZ1WnlxtbCacM07rt3dqTsZp4a0qXvTQeCR28W5+16F2Hu7sZslGhNe+2 /aLGk/irsE8VSg2imBO3LXorORY3s5UnmKKS0pZ1Wf/Tcs/Byda5X4A+tL6KlvEDpHqt vHpl86saT3X7iGXCPgRyUtq7iDDP1IjtuQWaqjKo5k1t5UqNlEovBQ6B26wBM3t7/M3q dWQA== 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=SADru+zeJoUa6Kq7NgE3oCMhDB2qphP6ONJw4NgANKU=; b=Q8POMCOT6jfQIvS/V/83EKsWeslBkiE12JFzsp5f6DDxyRDkEvrG7BsW8Rd9qap2HE zNFKLHA+baQ8YRrP7Ol/f6/L5VkKc2AhOMJ/CU39cs4xleRG6ow3/ms9+6B2etrETT7w 2pTwjJnFe+6LZfPgFg7JaGroJE9tzmYV/zKNt48ela2wdV3tS91p2PkHxlGP0CVV0rbf rSRWZUNtRj78meHHGBnSeWRanaO9Dj2e1a3PLpzfoXM5c8O3EpNHewvxIVjFmMr+Wdk1 M1HnzM7C5LEQAeKWcNOJPJWN4tN1wK1EiMuv5TdyHw6qrRKYpmNnQqLtzrrOOotP5To1 NWLg== X-Gm-Message-State: APjAAAUwHWFaqJ8MNBPLCxARfj7ixs1Ud1kJgSZQeEKfra6wun541eNl EEa6ffWWtO35wYkkUNTF9200Tvxe X-Google-Smtp-Source: APXvYqx/2ml75qZUvcITEBML+/VXCJWVUP/iHChuBbmOfuQX/0u72UoOykubRwkl0ub8F7RLyPaLPA== X-Received: by 2002:ac2:4906:: with SMTP id n6mr451699lfi.81.1567520556123; Tue, 03 Sep 2019 07:22:36 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:35 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 02/11] mmc: dw_mmc: Re-store SDIO IRQs mask at system resume Date: Tue, 3 Sep 2019 16:21:58 +0200 Message-Id: <20190903142207.5825-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> In cases when SDIO IRQs have been enabled, runtime suspend is prevented by the driver. However, this still means dw_mci_runtime_suspend|resume() gets called during system suspend/resume, via pm_runtime_force_suspend|resume(). This means during system suspend/resume, the register context of the dw_mmc device most likely loses its register context, even in cases when SDIO IRQs have been enabled. To re-enable the SDIO IRQs during system resume, the dw_mmc driver currently relies on the mmc core to re-enable the SDIO IRQs when it resumes the SDIO card, but this isn't the recommended solution. Instead, it's better to deal with this locally in the dw_mmc driver, so let's do that. Signed-off-by: Ulf Hansson --- drivers/mmc/host/dw_mmc.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.17.1 diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index eea52e2c5a0c..f114710e82b4 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -3460,6 +3460,10 @@ int dw_mci_runtime_resume(struct device *dev) /* Force setup bus to guarantee available clock output */ dw_mci_setup_bus(host->slot, true); + /* Re-enable SDIO interrupts. */ + if (sdio_irq_enabled(host->slot->mmc)) + __dw_mci_enable_sdio_irq(host->slot, 1); + /* Now that slots are all setup, we can enable card detect */ dw_mci_enable_cd(host); From patchwork Tue Sep 3 14:21:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172797 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641361ocp; Tue, 3 Sep 2019 07:22:37 -0700 (PDT) X-Received: by 2002:a19:6455:: with SMTP id b21mr21194938lfj.167.1567520557688; Tue, 03 Sep 2019 07:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520557; cv=none; d=google.com; s=arc-20160816; b=KeMsSwtwHRiJMbHsXXxSDLQUKrpAjLWOg2osjBKESu/gyvRPJoi/gaiJTIj+jCIEdD k70B7fT35tYCqt9zDWbCLKnzlJYVryALkN2hUB0qwQ6WlvMcBaRi0EcOpDNScphMB0gx PMgmq+Fid1xjvH2f3twaH2uw6emsPlbHj8HVDR6X4EQHtUsGBHIKneUhnjIOECBdGQKu xhMo9+mkcxio+DEgFqjh2H1BndGswgkXjWDiYog4oHTLPukKaQNi3u4xyWtBpv/Iok9B uivCaTEdGnGZVQVcKlvExQ7slodVX5VgouiByyDUvrG5G9Y9TzDuF+r6yC5daMQ0giHK I6+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0NvqeeJAxqM9LsjMwddoa5m6zhHcHlw9n+K/8LgxXIo=; b=UthD7uqUgTHzRL7wuOMGkTngs+qQxFDVlTrZmH/VmS4zzCH/Rz5/oi7mTQ06Ls3+T3 jXH3eVevliWuPYXFxGpMvvvhrr2cAyRGQ0OQuobSuHRVr2ijoZaKngCenO2OjaWKUmX6 xmLOnwhhWDxFrAkA5IVwpTpuRwZq9x9ofUwTOLEQdtQnxRXnm6SCISGthQkHKhfQI5rs R3WC+b6G0i4nUWjIyk2190oLAcbZ/F4se43vbQ47BI1S8kr20pxCzGreVbZ7g7Opmc6Q K28tKTLzA5mJqvyro6fxwaz+VfJIfOrJSbutlgPplJUGiswVDAqXnbcWcoyBimJkHxOX yR9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dr8gEgTB; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u8sor4948766lfc.34.2019.09.03.07.22.37 for (Google Transport Security); Tue, 03 Sep 2019 07:22:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dr8gEgTB; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0NvqeeJAxqM9LsjMwddoa5m6zhHcHlw9n+K/8LgxXIo=; b=Dr8gEgTBXp1w4VtAi4Mg6OCCy2rvOuKA2OxrnTOj+lxUU6Y5Zr/e/LiMXo9c/gTVMj dimHRhhs+yp1gkbZp4z0mztJjWrv3WJBlxkhrla8bsYlzwEUe4f1j3+POiAD3wnTTDu0 ZXSwSUnivY32b9fKF7b3hLCaNRrkTSAK5o/qkfMGdNnVK6jI/byKgyQLIFIy00GkkTiB uPgncVJ8PHuhJVF+6MiyqQbwg2bwS+dUntVWLDg+RUJc61GM/Bm5LkB+XtwrREL0QX0R VIcIjvZ6WYdM4CJ6ZIHN0AugBpHZS696oD4v4XD1agn/DGhqtNf2KkEuLA+Gw6HZccSl ttfw== 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=0NvqeeJAxqM9LsjMwddoa5m6zhHcHlw9n+K/8LgxXIo=; b=d5Tf+7owt3sYaSZQ27U4eqxrw65iIasGJPYkt6TSr7M9h3VOI/0PuOVID22cSdTiQM 49/u/LboI47n2gs7kYuaqHv+CMNSWJCnjDi5zhXImUv4SK/xg8kxKLOvFyHl9HGzjiCc yHm8y6TfOFUHZsViLJ5j2Lj8gzuZ2bQdFNZd86GZ4oKL1BX9laN1MmeMQK94TvowEh56 fjOD60vzBftqNkjgyrr0aROUHWlGgdvY7F1Zc8zJjMrPjFDhCabXlR/fIPn7ERGYX/Ag P3Gz1ZXT27+rpc9JKSqCdNlZgBnBltbkSA9CWus/W3RaOJZnPk4oO1QwyyoNzdNUjvsL 11fQ== X-Gm-Message-State: APjAAAVpxnd1BFpWJx9XdDTJnJBzH28dZYymzu1PchFu66sngPrUFPdu ciHED2Bcdl03l54GWF0Et+eouNCBO+ILDA== X-Google-Smtp-Source: APXvYqweF7JPxx3cnV/NebwZQV+1f/Ir2g4Sh+rI5IK4GEBLjBEWnZeSOmycdTJye0f6h/XH6sRvAw== X-Received: by 2002:ac2:5485:: with SMTP id t5mr18239629lfk.27.1567520557351; Tue, 03 Sep 2019 07:22:37 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:36 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 03/11] mmc: mtk-sd: Re-store SDIO IRQs mask at system resume Date: Tue, 3 Sep 2019 16:21:59 +0200 Message-Id: <20190903142207.5825-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> In cases when SDIO IRQs have been enabled, runtime suspend is prevented by the driver. However, this still means msdc_runtime_suspend|resume() gets called during system suspend/resume, via pm_runtime_force_suspend|resume(). This means during system suspend/resume, the register context of the mtk-sd device most likely loses its register context, even in cases when SDIO IRQs have been enabled. To re-enable the SDIO IRQs during system resume, the mtk-sd driver currently relies on the mmc core to re-enable the SDIO IRQs when it resumes the SDIO card, but this isn't the recommended solution. Instead, it's better to deal with this locally in the mtk-sd driver, so let's do that. Signed-off-by: Ulf Hansson --- drivers/mmc/host/mtk-sd.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index 6946bb040a28..669ea0668159 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -2408,6 +2408,9 @@ static void msdc_save_reg(struct msdc_host *host) } else { host->save_para.pad_tune = readl(host->base + tune_reg); } + + if (sdio_irq_enabled(host->mmc)) + __msdc_enable_sdio_irq(host, 1); } static void msdc_restore_reg(struct msdc_host *host) From patchwork Tue Sep 3 14:22:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172798 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641436ocp; Tue, 3 Sep 2019 07:22:40 -0700 (PDT) X-Received: by 2002:a2e:958c:: with SMTP id w12mr3510393ljh.98.1567520560479; Tue, 03 Sep 2019 07:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520560; cv=none; d=google.com; s=arc-20160816; b=latIXuAC/NqivCF2Qijhuy9N4oVh3lp+x/Nk/BTJYg7anO+SeDfa2mcehTTdXd1TpL jMgC83SH8FTEzXDCbDkORQdiE1nGwHA4ha98UJRhvgYolejlsF5On+UF1OusOHgZSNrD sm+5olmH3+rdB4amb/6WWSVshNiOaWYc91a3mh7T2qJaiU+Xv7nsJDcTzJ/czf2LBSuE 0v/m+3MFsdBKAIEnK0dyeL2AEqCrYHtIi07yPeT8GOkqIszG+LiTjTbGrXkQAbqoYSq1 3dIg8wz/y8LUMRCdHnAsD6xEYBBarNubZi7JfugR7Dl+yJTYeiLJYa7xD5afNHFp49rq en6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qvTZyKCFJI1bAINVcXhrb9dRTTR+BybSa6+sJhzvtc8=; b=Xg5jGvNaun1IEumf81X83ukJvYfR8h6+EvzKlCCpoA0I+682ZFs/9wakOSRN1v7Vkm abC8pWQ+upjJQjpcXa3u1tHH3Z8Kd/da8jujLrLAf8vF2wVShE7nJfAFWRUKkGS+a5p0 bqLqDpGoG/LcL+/fvkxGwr9kSqQTUAmTzIqQAAYIvmxXkDuGkVBhBBrWHW3rAnVu39RQ oHRn+HuO7uzcq+sxkT2WXEEmdvyAvgHjtllR6u5CyFta+KO19oL/JFFYM5PTeW8TFn2c NQp5ngreKX+ao7PLEdkU4x/JrDoLLRbl8/5oNCz50nLbux4Nc0RbY70QWf4Ug7v0/Bwf W+4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gglFd6MH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e8sor6618687ljl.36.2019.09.03.07.22.40 for (Google Transport Security); Tue, 03 Sep 2019 07:22:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gglFd6MH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qvTZyKCFJI1bAINVcXhrb9dRTTR+BybSa6+sJhzvtc8=; b=gglFd6MHuNK4Z6tmxlxiATJyByVg6zIKFequidBHSYMo1U/EyW4mJcQ/Qbc121DWUy JpJI3+si6yMcp3K513RPrh5JbCRsdrWZ8UlklF1Hi7UMHF5ESSuAp1KWjTmWC5M3kZfL WD3op0jEdXCooG55ZxloSu23l8WhaHqYUB0tN/VBCrnzeJ7WvDK7YPq6qF6zTxf3Mfni Thd1J08Oj6+NO/dzVY+iXrF/1SV1BNI31yKV7JbJ4KPT19vqSBZk52efD5Fg4YKIEejZ 7s5IRhfCKixC8qvEOXYiiawbrGJiokx1J1BkYheBOPlkZedbdnC1b1MVPc2kK2hrmmUD HHpA== 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=qvTZyKCFJI1bAINVcXhrb9dRTTR+BybSa6+sJhzvtc8=; b=kblNeYXtL6NK+W//eXm8BIbQ/6vpeW9AFhIyb2HmnSpsk+BzQb4eiYh0q2qtVN4ebq ECDKbOV+hYYTXvqbEfbxBGqv6tJz9f4MWpv0jmKkoOCgUbaG7XI6dL0JNlfQJ6YFNSNU pbkNIueuCvoaqsNRyMJcv3ZYNZuHjIYVs9QbQxXczEJ4NIqrahhaACOrefSALtNR+E7I OOR2ISYXhU4tm6NetMAxmYI6EbrOE21OGM+gxuqjWXPxARQdLEjLDt6NUQccmjRTOAFx xhD2Kauk28V0wyNs1xBIzmkf9wjhdSFHAd9FtEufCtXieq63sTFFg12Yi46x/QZ605Ne 5o9g== X-Gm-Message-State: APjAAAUECeaEwXbdC4MK9C9WknGwb904RZDFPTE56zx9CYKA2z4VrxVZ 7rJ+ASG7atVQj/4x3VwaPaHl0dj5 X-Google-Smtp-Source: APXvYqyc877+x8lrzt/YfDR3SsN0Br740tfMZzmjB6HUviT0AGI0ES80ASlAy2rNE449uMd0H8oSjA== X-Received: by 2002:a2e:6586:: with SMTP id e6mr13751574ljf.115.1567520560114; Tue, 03 Sep 2019 07:22:40 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:39 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 05/11] mmc: core: Clarify sdio_irq_pending flag for MMC_CAP2_SDIO_IRQ_NOTHREAD Date: Tue, 3 Sep 2019 16:22:01 +0200 Message-Id: <20190903142207.5825-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> In the single SDIO IRQ handler case, the sdio_irq_pending flag is used to avoid reading the SDIO_CCCR_INTx register and instead immediately call the SDIO func's >irq_handler() callback. To clarify the use behind the flag for the MMC_CAP2_SDIO_IRQ_NOTHREAD case, let's set the flag from inside sdio_signal_irq(), rather from sdio_run_irqs(). Moreover, let's also reset the flag when the SDIO IRQ have been properly processed. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio_irq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Matthias Kaehlcke diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index f75043266984..0962a4357d54 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -59,6 +59,7 @@ static int process_sdio_pending_irqs(struct mmc_host *host) { struct mmc_card *card = host->card; int i, ret, count; + bool sdio_irq_pending = host->sdio_irq_pending; unsigned char pending; struct sdio_func *func; @@ -66,13 +67,16 @@ static int process_sdio_pending_irqs(struct mmc_host *host) if (mmc_card_suspended(card)) return 0; + /* Clear the flag to indicate that we have processed the IRQ. */ + host->sdio_irq_pending = false; + /* * Optimization, if there is only 1 function interrupt registered * and we know an IRQ was signaled then call irq handler directly. * Otherwise do the full probe. */ func = card->sdio_single_irq; - if (func && host->sdio_irq_pending) { + if (func && sdio_irq_pending) { func->irq_handler(func); return 1; } @@ -110,7 +114,6 @@ static void sdio_run_irqs(struct mmc_host *host) { mmc_claim_host(host); if (host->sdio_irqs) { - host->sdio_irq_pending = true; process_sdio_pending_irqs(host); if (host->ops->ack_sdio_irq) host->ops->ack_sdio_irq(host); @@ -128,6 +131,7 @@ void sdio_irq_work(struct work_struct *work) void sdio_signal_irq(struct mmc_host *host) { + host->sdio_irq_pending = true; queue_delayed_work(system_wq, &host->sdio_irq_work, 0); } EXPORT_SYMBOL_GPL(sdio_signal_irq); @@ -173,7 +177,6 @@ static int sdio_irq_thread(void *_host) if (ret) break; ret = process_sdio_pending_irqs(host); - host->sdio_irq_pending = false; mmc_release_host(host); /* From patchwork Tue Sep 3 14:22:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172805 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641464ocp; Tue, 3 Sep 2019 07:22:42 -0700 (PDT) X-Received: by 2002:ac2:5a4c:: with SMTP id r12mr5198356lfn.52.1567520561912; Tue, 03 Sep 2019 07:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520561; cv=none; d=google.com; s=arc-20160816; b=UVe4IJ/jYBrYFGCyeUXxflKKx+siYeCk8bNA06MZOOI4ryDwLqxa2fWHFdNC4IUltI P7DSl0bTwPIV2tvVLh/LW24TgQrdnjD6IBE9mGnaXC56WJTpoMpIxdPf678KCaIAOzLA bmj6r/3o3zfY+LXGEKFKalUaDkCA8y+PNjNMV07NJSVL46eJSREcotIWFHpNcvGefmzU U1A88/PbSD4uO0GctxZCXalzfVCCmH0ozYrag5dKp7Uaa5Slqir1tC4Dsih2ehqtMNh1 9xwUaUVemnL/HwKwNG6b5UJU83QCX9RjBx9ri3G3SwROzxdChN+rRRQAiMZFfNXDY+5b Agig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bEFp+hq6WF76ZDQD++03UfUz54PPaJzLtrNfLK0kmKc=; b=ePSkBe6Yog8oGyCj/jIY3nHbSTSGfgKnGIgc8Qq/49yjrRXNEa8NJnBSxRmZIkhCD8 5tvtK+DGy6bT7SOezdnSKY0VEjtrRPiauXrliRYb2lllcVeuvRAkV7ZMsu8Ri4wJgJAR 07JMl2qAaxifHmjuf2/iUa+c0qXAtwurqxNzA4wIpBUC3J+1hzLH5xzF5HcaIvB8ccf/ CNk1im7koBBD3huOOLvq8bM6XdBbJ1vEMs4ud3I3HVqRgd7hH8l3Q2ZTxrZVXzJhTq+d bncWRGGcQhGwaRZ2o53AV7ciEQ6R1D4+2aYb3tbt1MAloXDBGug0ZnMUFyxBEFi1AwIs L1Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rAhNS1CG; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q18sor1123826ljg.15.2019.09.03.07.22.41 for (Google Transport Security); Tue, 03 Sep 2019 07:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rAhNS1CG; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bEFp+hq6WF76ZDQD++03UfUz54PPaJzLtrNfLK0kmKc=; b=rAhNS1CG/SmhFG+9WpuAZAeuPWOmk3PRWJElNLoXN9FlAYJrC5d2tMGtSLKAzzr6aX M6RoloYPdbqO7f5KwLApFXL+4m6Bk52g/kRO26+PDT6sL6QjdkhUhNAlS/6BUor2GIw9 L9o7YJEmuiMYtKfrqR+2Ryk2eKnBqa02t4dRxFRR1EMsKXIt8npFYRpTLyGUypZVdH9z AbwkoOLM+mUoCkGcJjfZFqVq4Ll6oXSS/5PGsQexGh5kQ2u8yJScqJKun/W57FppaC2V Fyd+KYGI6mXusxA9Gfyyo7L8okOZ+fwTC9VNxuYyKTKc841K7x6ArZGR+e/EomnDuygF tY5A== 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=bEFp+hq6WF76ZDQD++03UfUz54PPaJzLtrNfLK0kmKc=; b=MQjqOCQBqxwgIbZqvjcU06JwDw2QI1ovMGXu7OM9PophxsEdE6MX90AuvsaFGupWO3 6YLZHsvtVo0mfYV3MDC5Y4F/tvLjvvREynB7u4+9ffTaZRkLtywJCUn6/VT6DOKnx8An jay9CJQKSRshz5QVYGNU7znorhSkoPiB20y1AfOFF81hI+AsC9eU34dopjVQ73TKrD3n qFtL8f8q7xdH/aamgTEIVsB8rk9O+dPrJdFQcYRJ3/djR2W9GHNayvNYKBauqr8b2sih S9qE3Z3I84ZfndroyjDAn0EU/6goACJp9cXHWMjFCc+Vzogv2m77Sx3k1OoLHqlb89cA Dqew== X-Gm-Message-State: APjAAAUy9O+wiVvBO8QGxSbWEiap5aB8fTgnxbAzhl6Hoc1Wo3rsSUHh NLnmrDboeHO4qCIQN5eoIX0lZzdZ X-Google-Smtp-Source: APXvYqwW7bKtefLZcTuxAgXstvnr8V4cg5OryM4fdGNKnmzlZIkWikBetS9faCFtCgLjjSTO6ycVQw== X-Received: by 2002:a2e:2c16:: with SMTP id s22mr8923823ljs.148.1567520561447; Tue, 03 Sep 2019 07:22:41 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:40 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 06/11] mmc: core: Clarify that the ->ack_sdio_irq() callback is mandatory Date: Tue, 3 Sep 2019 16:22:02 +0200 Message-Id: <20190903142207.5825-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> For the MMC_CAP2_SDIO_IRQ_NOTHREAD case and when using sdio_signal_irq(), the ->ack_sdio_irq() is already mandatory, which was not the case for those host drivers that called sdio_run_irqs() directly. As there are no longer any drivers calling sdio_run_irqs(), let's clarify the code by dropping the unnecessary check and explicitly state that the callback is mandatory in the header file. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio_irq.c | 3 +-- include/linux/mmc/host.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Matthias Kaehlcke diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index 0962a4357d54..d7965b53a6d2 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -115,8 +115,7 @@ static void sdio_run_irqs(struct mmc_host *host) mmc_claim_host(host); if (host->sdio_irqs) { process_sdio_pending_irqs(host); - if (host->ops->ack_sdio_irq) - host->ops->ack_sdio_irq(host); + host->ops->ack_sdio_irq(host); } mmc_release_host(host); } diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 0c0a565c7ff1..ecdc1b0b1313 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -128,6 +128,7 @@ struct mmc_host_ops { int (*get_cd)(struct mmc_host *host); void (*enable_sdio_irq)(struct mmc_host *host, int enable); + /* Mandatory callback when using MMC_CAP2_SDIO_IRQ_NOTHREAD. */ void (*ack_sdio_irq)(struct mmc_host *host); /* optional callback for HC quirks */ From patchwork Tue Sep 3 14:22:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172799 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641493ocp; Tue, 3 Sep 2019 07:22:43 -0700 (PDT) X-Received: by 2002:ac2:4117:: with SMTP id b23mr5539162lfi.36.1567520563181; Tue, 03 Sep 2019 07:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520563; cv=none; d=google.com; s=arc-20160816; b=baPTqo+dUJdsRSbCMG2zWingOU8MMm2HwIGu/jMe8Vm6f6fbHUAF72QaEKjYEbMtxQ VgvO6+HC5MfkCJFXTs1/0AKvZyoAddHmT6KvMQBAl6m2QHiCvg+mQWjltlGYpuYmB5gv W9vXy2NoaEXyXTsA8aQOuupo9DQ9l31nyH79fbX90mivwXum0EHIE1XiOpd8mH4NqGut c2o0ATkizcNMe64+4yHvr4fW/CbwzI2cPjAt1H7dkn18SdcEYsD/RFmxdeYaEEEEzod9 eORrXBPL3hg/PFND96HCIYbfAaVt2tMKeKNile9wWbTZ8SwFUbWO7aed9A97EV+4F68w Nzkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bNF5KDT4NEO2S6l4e9LzOtvZky1MgilMfLbdgvOUK14=; b=h9Wc+tYKF3u2GS1lYkphf/iXqQenKKflPrl+PK33KeZmgsb7EunC2udVJoA26rxLzB /QWIgSkE18O/PRFKGe4nBW+oWWOxKYNb+NYpHLU1v57Rf4wecnuyuyjLtJNuX6Y9wTaf akVvTf/LW3mK4EwZ24S90SVc/nUiUT1l4VuoUmbnUk6eQPZsUXqVQIeeNBrO39gAuY7T WROkaDoYuNuy5rzxYJgx8KDL0QMCxdlfv4u7/6mZnyaXNXo4Y7m9vTmxVViFyp0mA4GK eaYA/LvWZO4HghRdZwkcqQYo+KhDe53uxoyNF9aHlcckdgvjm2+Mi6DNVH5rgg9KL6O6 pyuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BgIkoA6S; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j23sor4971550lfh.18.2019.09.03.07.22.43 for (Google Transport Security); Tue, 03 Sep 2019 07:22:43 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BgIkoA6S; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bNF5KDT4NEO2S6l4e9LzOtvZky1MgilMfLbdgvOUK14=; b=BgIkoA6S9HEs9gXOS1K2J8v1hct1nLo6iRbl+eWQRpwvWRAnL1gvf+6nlbSL6YQA3L YP0IzSVlJneAEtl8OLa9/CxAxpo1o1UsJgnOMYY2+Zi4BENlVOUxJ1C4U9RQXv43lRDA Mz84ak/0jeQjZANy0DnEaYTuPY760zFCzRlpLRpdw40SCH9Llqye34JP95vSzumbnnZS Zl2imszSl55QYmDXEmgLQ9Dg/rJzzHYX38Ck6g9OKS68zEeA4dAh3UGChi8gTj+nVrn9 2zFV28zKr4MoIj3TQjSFs0sV4I1qy2pFogTq2GA7SqZOvrq66YCj9MZziPPTklnjOHlO Lb7A== 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=bNF5KDT4NEO2S6l4e9LzOtvZky1MgilMfLbdgvOUK14=; b=TH/EyZ7UFg51LTU+U4IQsx5EsqJK4+i/hLLQRbfmpWlvep6M0vSPutwylPuKDi4+rc 0hkneCh+vTzQM4MR0bjTFBhbD1+kSHWDlIJkL0YCkigFmjeHDdP22i8QjEhWTmulcWZl ZAMJdBFypnGAFz9qtZ9vSv5PSyRc3iEWnOUBAbY9I43aTjU7maDMsRpteIG9DdDRDT4O jCvoaFre6ABBicQqUY+IdHcUKtcXUFqpU2WQ6iwcfuEmKrzyzeXOPkcq9NYiu8L9o+Rh mK+EhJkUxTSmRKuJbcBSuzrjxe/Vktr9RoUTwTq7cBsL0xyB6AfIatbyIF3SQBLEOb0f xSew== X-Gm-Message-State: APjAAAXIFOf17jk7DbEF8V0U1xj/U7EYwxeehwX1FXIg3xm1QwhfASG7 ffBnRU7CIKgckXGxNi8MgZjrZVeq X-Google-Smtp-Source: APXvYqyEEebdpTgfyZ3xa8X0pagg//6S5aVso4T3Lot6sSeBRjWR2Wwn14JGYYaV9PjJ35e0VWgv9Q== X-Received: by 2002:ac2:4c2f:: with SMTP id u15mr20191218lfq.174.1567520562816; Tue, 03 Sep 2019 07:22:42 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:42 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 07/11] mmc: core: WARN if SDIO IRQs are enabled for non-powered card in suspend Date: Tue, 3 Sep 2019 16:22:03 +0200 Message-Id: <20190903142207.5825-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> To make sure SDIO func drivers behaves correctly during system suspend/resume, let add a WARN_ON in case the condition is a non-powered SDIO card and there are some SDIO IRQs still being claimed. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.17.1 diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 8dd8fc32ecca..c557f1519b77 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -951,6 +951,8 @@ static int mmc_sdio_pre_suspend(struct mmc_host *host) */ static int mmc_sdio_suspend(struct mmc_host *host) { + WARN_ON(host->sdio_irqs && !mmc_card_keep_power(host)); + /* Prevent processing of SDIO IRQs in suspended state. */ mmc_card_set_suspended(host->card); cancel_delayed_work_sync(&host->sdio_irq_work); From patchwork Tue Sep 3 14:22:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172801 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641515ocp; Tue, 3 Sep 2019 07:22:44 -0700 (PDT) X-Received: by 2002:a2e:9958:: with SMTP id r24mr8375166ljj.139.1567520564386; Tue, 03 Sep 2019 07:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520564; cv=none; d=google.com; s=arc-20160816; b=rkRiwZwR6ICv9l6U7l62aydga5ENH21V3zNA9m8RVUzvpWg8wl/00+hELrxlJaZaN3 oQQnhSGfumnRkKMxSerwe24acIlup2hrcQiq5dU9NmnTGep4s/Icrcj91R7zxuhSWCIt 0VcpKC7HGdK5Y/KeL/+iK4GIertkYOTi5Zjbnu4CnuglhXUlzXofhWmkFDyqm7m9uDAe o7ipRfiqq65OqmJvQQnXDdaaaVO23bewY6jSfAcKKRz2sWaA0X4UqEf1OkwTdLnM21uA gkE5mW8Lk6FT7uERTc/K2aPasNkcbAvthuZRanzt5qLSXGPRqKjmWeKhkC0HYUyctRqa 1hJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fqo5mVILkGtSq0rdVWivMfGJMV/aCWEQdU0YePivD14=; b=fs20qk0j4TY7FiArm3gU2qQAPqV1UPcrqDIRZsAWS+Ng5Yh1Og3VKaVTQK2S2swYDq NUAmz/Lle3fvJvcDAm2oHBFLAEimmFk4ZM4ZLtGmIX3JKeIfHSfeFrxCsy/1gOLJddOp 6ez+cAD5mUJhX7mxcF1Fj/+R3M1FaPhyzVaDFzs9mbqBauO+r1po0vcjzh3rLAWJu/7Q hFLMt1+xmpI907Zazw/GgZFidbtf50GbTS46Odoe1T6nlFq+ZXS0gN11njwu90MPgFZu x4krsonsH4Cj9VENQmTcobRHvG210E0JTl4o8bvXAQwqoNH7+PI/xhxUo/LQJX2z9UVO xVzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tRNkWdgI; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v67sor4923494lfa.14.2019.09.03.07.22.44 for (Google Transport Security); Tue, 03 Sep 2019 07:22:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tRNkWdgI; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fqo5mVILkGtSq0rdVWivMfGJMV/aCWEQdU0YePivD14=; b=tRNkWdgIeGlIeHF31vEECt46I4epYMs40YdMzeIjjLXwGWZIOSybZkB58seaPdpX8t sK4/S6ZL8nQNC+J05IX8ZtuSmXyvtt4moyYsM6VWqgOFZ1xR35BzuIqvZ7vjDpWCs5xp PIAQST0jb5AsjNJQATqgg23HbTVCPPPvTseizJwniLgedXlUXZ7/GNmioOl27/gpuJiI RC9FHbBTq3rVTg6D0l9Dy5+FCNvqJcO/ak28h5+VWbDCHYUCbke2VEaZtBxPufmI7Xi8 49v5d80bi3w3XilNwMLbgLiM+D5CqG1T8vuyDsdzb8zxrZLyM6IeLXKFzsEYf7MOP3hL z2OA== 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=Fqo5mVILkGtSq0rdVWivMfGJMV/aCWEQdU0YePivD14=; b=VmiFqyFJES+Z6EVgEMkK95aBtrZJGLXNc6BsXeedeToWKe/7gA5oaJ1Ljso1aK7NdH QJEfuO03Cbt4fYwbNlM4ZbK1B/yUM+8c7UG3cjlU5WHDXLNbikRKyYKUTLvpWy3HIVTN QAma0hfXaUmLe9KxWJodHfqyIqMt0YIZxmtyK2Y7OYH/9taL+Qe29vYgc2afZLtHgE4Q mCelFtlDd9XA1DDHcLdZWvjxG7J/PZMRmLAxGiCr1C5MK5er1b4Y1mDb0h98e/7npFRe H++36Goi6z2ZJdnQ5WdoXsbKJ7kNFfGKDLPQn6R65Bc8nPJRRGlF2LRVEImBbD9zRuKd wCjQ== X-Gm-Message-State: APjAAAUTNGukL986NT/QylVCse42Lo2BU7XKCeOZEXMZloGh28hA8x7H xT51cSdHuI2MithkJwrGMoEA6HHl X-Google-Smtp-Source: APXvYqzhx0C8QVyDdtmnXTBzvrkQ/qix4A9PLncU3OxOKzlPKzY1ZMxbBJXHsY8c8skjXFT0ebn0Iw== X-Received: by 2002:a19:f204:: with SMTP id q4mr6969539lfh.29.1567520564028; Tue, 03 Sep 2019 07:22:44 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:43 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 08/11] mmc: core: Fixup processing of SDIO IRQs during system suspend/resume Date: Tue, 3 Sep 2019 16:22:04 +0200 Message-Id: <20190903142207.5825-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> System suspend/resume of SDIO cards, with SDIO IRQs enabled and when using MMC_CAP2_SDIO_IRQ_NOTHREAD is unfortunate still suffering from a fragile behaviour. Some problems have been taken care of so far, but more issues remains. For example, calling the ->ack_sdio_irq() callback to let host drivers re-enable the SDIO IRQs is a bad idea, unless the IRQ have been consumed, which may not be the case during system suspend/resume. This may lead to that a host driver re-signals the same SDIO IRQ over and over again, causing a storm of IRQs and gives a ping-pong effect towards the sdio_irq_work(). Moreover, calling the ->enable_sdio_irq() callback at system resume to re-enable already enabled SDIO IRQs for the host, causes the runtime PM count for some host drivers to become in-balanced. This then leads to the host to remain runtime resumed, no matter if it's needed or not. To fix these problems, let's check if process_sdio_pending_irqs() actually consumed the SDIO IRQ, before we continue to ack the IRQ by invoking the ->ack_sdio_irq() callback. Additionally, there should be no need to re-enable SDIO IRQs as the host driver already knows if they were enabled at system suspend, thus also whether it needs to re-enable them at system resume. For this reason, drop the call to ->enable_sdio_irq() during system resume. In regards to these changes there is yet another issue, which is when there is an SDIO IRQ being signaled by the host driver, but after the SDIO card has been system suspended. Currently these IRQs are just thrown away, while we should at least make sure to try to consume them when the SDIO card has been system resumed. Fix this by calling sdio_signal_irq() after system resumed the SDIO card. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio.c | 2 +- drivers/mmc/core/sdio_irq.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Matthias Kaehlcke diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index c557f1519b77..3114d496495a 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -1015,7 +1015,7 @@ static int mmc_sdio_resume(struct mmc_host *host) if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD)) wake_up_process(host->sdio_irq_thread); else if (host->caps & MMC_CAP_SDIO_IRQ) - host->ops->enable_sdio_irq(host, 1); + sdio_signal_irq(host); } out: diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index d7965b53a6d2..900871073bd7 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -115,7 +115,8 @@ static void sdio_run_irqs(struct mmc_host *host) mmc_claim_host(host); if (host->sdio_irqs) { process_sdio_pending_irqs(host); - host->ops->ack_sdio_irq(host); + if (!host->sdio_irq_pending) + host->ops->ack_sdio_irq(host); } mmc_release_host(host); } From patchwork Tue Sep 3 14:22:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172802 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641544ocp; Tue, 3 Sep 2019 07:22:45 -0700 (PDT) X-Received: by 2002:a19:f204:: with SMTP id q4mr6969623lfh.29.1567520565562; Tue, 03 Sep 2019 07:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520565; cv=none; d=google.com; s=arc-20160816; b=cMtDwJkShSYhN/AoyZR/02BxEl/HrLx8FK5fbigyZsXRR8KscTQhsW32EszkqKJHIV 5YLFAEJQQtpgtkoWyW8oLP8vkqqv9h8kuuOdkMk6F+YocEUlKKbCVahUZpoDJCwzKvCe PnBqiN7dLt28dyCsiO7GWSjKoH3KwhQjgD1WAFj2jL+TT6arphf66rWVL2KExNJnQFJX DzI7Wz6YuLOXHnIPTku4No2yvuOqfULpE/EbyAr2OM4fmfEXPlcrSEu9HlFfEkZbYstR WIMGGMC3+2HoRM12pUTHUsAKWs1+55no2Q2ldLKptqY67tGEsoGE8ikl7tCVPfSQ/Lpg 0ffw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hUKvWKooE3Nr2LfWI7qknPBybhkMjg8O69FVSs9vXkc=; b=q5MFdnXaMQvx27DK03NKpDicWKLVIkZh14UV095j34U8zOtCGzD0hqXUZaBSH4G2ts ajKVKVpHFGCGnzvhvI4ynuYxY0mZzbe9MLpMJzv8i+6FYCjFiMfy7gYdxesUxTeFuQDH brkqXnFbzTeMzja3IPBPxMPlpdw+La/8uCJ6doWJGgBu7WPeDF8hmDzQzRG6UXP6y5mL QU2zYcTGyjPrKVfE7o7jKooXs5JfBawl7+NjipntY6UCtIU+VrJE55IXp+yuWguEGCLY 9AGBr/1ADdc0vINdLHDagTX50onN3eXUYZ7tB/czPzCboNbmOFC/Cun9z9L2oOdedAtn /Plg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IyCgQPw2; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p3sor2161286lfc.0.2019.09.03.07.22.45 for (Google Transport Security); Tue, 03 Sep 2019 07:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IyCgQPw2; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hUKvWKooE3Nr2LfWI7qknPBybhkMjg8O69FVSs9vXkc=; b=IyCgQPw2ykZcke64WeocrNRFfaD/9n4LX7jp4OolaJu1chstHr8JQY7az9MsM2LHfu 8LnV9+FB2P45atdwxzfs9q/98aYbBbqFB5/0BxMEdS//a2gDnHY/GYf8z0Qp5EBNSK85 IIJ7o+AfG0+am8hlLHi+fYcB7rdS3ni89UoSdaaIUQ7vTBikpGzly3mo3OcRApe7OwGQ twMGIlge9iU3ldpxwXFOFGJcklC/73gUGANUrHanqOveSb0DgprvK6HLjkK2NFnak9YP X3XrGDU2OW5ywt4hKN45BGBzSvIzXn5Pspth/FugIwTE4wJW1Otk2zU2/sS0ea0xxdFt askQ== 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=hUKvWKooE3Nr2LfWI7qknPBybhkMjg8O69FVSs9vXkc=; b=ud0o+1YFFuAgM48ZfZDO9L5jUUuKH3JO6BzR1Bs2SZZB46ew+/TPx2GG2HgNzcALDN PLQrR/hrF6daQg1zHksobCEIqlHoDdxihP07gipGhXD8Z979IYuXFxUDP4KxznlHTaQ7 h6syu0y3VcVkGJFtwUXFukNIpaVqkaShU70MnKtCdQu/fl704Xnm98lvDf2MIS1NEy/S B9syQc3w6YOjdo+Z4lHwBH/ZLRXX75WJBosZCZLk27fMyiCW649SU2UFnsFSQepcmwA+ 97BqCIrfby3BBHk5LT2/M8nBcfviJs86hTdF2+TCY6mGVfxh92agWJzO85xcKZXBhJm2 vbvw== X-Gm-Message-State: APjAAAVonCuEp9JFCCQxWAsbiBnEVqSfq5OLE02KyDfF5pNhPjWuTPUU nLPExxFvQ6RYXoHaMhJk3SSkA+lkL2u9VQ== X-Google-Smtp-Source: APXvYqxdOyp0rTA+keK8Vz0OkfEJsyNPg/rV68LgoYLikCASTYSTPK8ZKcshiuJ0b1rvVD46hW0z+g== X-Received: by 2002:ac2:5633:: with SMTP id b19mr4772155lff.103.1567520565203; Tue, 03 Sep 2019 07:22:45 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:44 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 09/11] mmc: sdhci: Drop redundant check in sdhci_ack_sdio_irq() Date: Tue, 3 Sep 2019 16:22:05 +0200 Message-Id: <20190903142207.5825-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> The sdhci_ack_sdio_irq() is called only when SDIO IRQs are enabled. Therefore, let's drop the redundant check of the internal SDHCI_SDIO_IRQ_ENABLED flag and just re-enable the IRQs immediately. Signed-off-by: Ulf Hansson --- drivers/mmc/host/sdhci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Matthias Kaehlcke diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c1ebc26846db..2a9be044448a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2161,8 +2161,7 @@ static void sdhci_ack_sdio_irq(struct mmc_host *mmc) unsigned long flags; spin_lock_irqsave(&host->lock, flags); - if (host->flags & SDHCI_SDIO_IRQ_ENABLED) - sdhci_enable_sdio_irq_nolock(host, true); + sdhci_enable_sdio_irq_nolock(host, true); spin_unlock_irqrestore(&host->lock, flags); } From patchwork Tue Sep 3 14:22:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172803 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641560ocp; Tue, 3 Sep 2019 07:22:46 -0700 (PDT) X-Received: by 2002:a2e:3e0d:: with SMTP id l13mr7485747lja.10.1567520566735; Tue, 03 Sep 2019 07:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520566; cv=none; d=google.com; s=arc-20160816; b=V9KN2IjfRnjk1pNTwO2HnqYetoeRyjuFJRHoHUiDIA6JazeaOgF5qG2MT9xsWWTNrS Rq/i7SbX9Gh5mMccLvMdBzZb1YLCDnQzJdLIiZptn6eEY/63nBEVuphRZkfT98NNKWJK z/kYruC8bDoj0Ir3W4uCvtQO3hDIFwkCnR/2Suy1MSlWaGfxGaJXOYR17LJp0UInevpM B6KMThyYVKUW1Bf1D2oC/EKNDUeh32UXkLZMgTo3Zm7yGkj2l0M+IBDGE+euLbibrdBA pmkiEwKLxUgebaOw4GwrTvBxh54t8c1AJaO0tFWUwudgvjsZ8f4U3PkV3l0COhIUJRBF nhmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oRUCHCrSXAlVd+d5h26u6KUeDoevWOErPZA9CCjpQxk=; b=SRvOCBL82+7WkVdmG13FGGenR/jXG3NJJkAO2jz8szHk0lZ2wh3xEZ8/HgikruA8mB MaL/Pzdpxfnz7yJZVFJPO7iz264bVUJTng28RRVJBfRQ8G8rqzXyHCiJGRNU4vtWigmO jUs2bi4ZC5xvGoETuFGKH5ZaNXOXuio+PDK/ICEOlBN718eIfklvpAeailyDRiJboWgM E7/UrJ8BieDpkOx3beiMndWC4mqav6EiHEpjJDvSWSl3eNH7gRf7jBa1teeHxH2QZrhq gm/q1QVW1JAdZflli1ACf8l/j7UrzChdgyr4Awe4VlbhgOv+UlOG92nbbttdenGpGTHX pLMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cuSTDxro; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a5sor4986962lfg.20.2019.09.03.07.22.46 for (Google Transport Security); Tue, 03 Sep 2019 07:22:46 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cuSTDxro; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oRUCHCrSXAlVd+d5h26u6KUeDoevWOErPZA9CCjpQxk=; b=cuSTDxro2oT3broDfM4Vhr93npdKcTrzQwf/hurN/LzTaOclC+JagWmOYz8XhLpzp1 WQfMy9rnaUZWsyQJ2l0461oXe37BJnCpWuYs2kyrijCXRdsx7onpMgb3djgBof//Yh6k TE7eq/LEiVO1FXLbK6yNgRwFuzlA8aZOe1WBgrM2i/W1seNF+h/tBzhoyQKVAb0XfH9x siDR1HffQVdt+yQmle0S3R6LFECw7C5/ni/D5ULuKwwCKg/MGpyU+NJaIhY+WcM6uNxw V5c/yQAX+33zQRNvcNGYfO3vCrMHdFTlGzCDKZtpZET7N3SUkhWtkU2A5MMP8Z0NmHvk /a7w== 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=oRUCHCrSXAlVd+d5h26u6KUeDoevWOErPZA9CCjpQxk=; b=FFhlI/C53iEoSvNSi22RBgeI302xC4k1dcxYGYa/pwqWFnpRZqhnJrarNDtviU8JCr bNQtU1r94oxB654Dul4c9QCL1wG938iBRcZBqs2oQZwJgjj0qWXHNq/Sb/FRz7u9eQtU Up6qSdf5XMMPjB6ETJGyh2KgMGzVi46h32EJWKFOQJH+oF/BlSgblgKh3KZtTMXtBrZW f+wXMgpJd4CyUf6Axx6eBp9bZBzgtzchnI9LaLPytwMo9+hTfIBkv+TvXBa9v/tgE3YQ xzwutzf8PWFQPoRdvr1/nWbT/tbyMpT1KeVczX3srlc2ydN+NhfIT4LBEsWvRvZZpfK6 1VhQ== X-Gm-Message-State: APjAAAXsoY+iSY6mGG4ayrapOX6d6ZbDYEKIPedjEBjM3Sr1o3lAzVIP 9yoNOb8iZ3LQVGlqjBmYrN3IMgiE X-Google-Smtp-Source: APXvYqxulXC0EVgK6/kIKcgM16qMgDbBItv63++f/7a5797d7tuL/bpKNSln0qr1e0rf25vagSHLrQ== X-Received: by 2002:a05:6512:499:: with SMTP id v25mr16750469lfq.30.1567520566370; Tue, 03 Sep 2019 07:22:46 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:45 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 10/11] mmc: sdhci: Drop redundant code for SDIO IRQs Date: Tue, 3 Sep 2019 16:22:06 +0200 Message-Id: <20190903142207.5825-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> Nowadays sdhci prevents runtime suspend when SDIO IRQs are enabled. However, some variants such as sdhci-esdhc-imx's, tries to allow runtime suspend while having the SDIO IRQs enabled, but without supporting remote wakeups. This support is a bit questionable, especially if the host device have a PM domain attached that can be power gated, but more importantly, the code have also become redundant (which was not the case when it was introduced). Rather than keeping the redundant code around, let's drop it and leave this to be revisited later on. Signed-off-by: Ulf Hansson --- drivers/mmc/host/sdhci-esdhc-imx.c | 34 +++++++++++++----------------- drivers/mmc/host/sdhci.c | 2 +- drivers/mmc/host/sdhci.h | 5 ----- 3 files changed, 16 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 776a94216248..1c988d6a2433 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -1666,12 +1666,10 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) if (host->tuning_mode != SDHCI_TUNING_MODE_3) mmc_retune_needed(host->mmc); - if (!sdhci_sdio_irq_enabled(host)) { - imx_data->actual_clock = host->mmc->actual_clock; - esdhc_pltfm_set_clock(host, 0); - clk_disable_unprepare(imx_data->clk_per); - clk_disable_unprepare(imx_data->clk_ipg); - } + imx_data->actual_clock = host->mmc->actual_clock; + esdhc_pltfm_set_clock(host, 0); + clk_disable_unprepare(imx_data->clk_per); + clk_disable_unprepare(imx_data->clk_ipg); clk_disable_unprepare(imx_data->clk_ahb); if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) @@ -1695,15 +1693,15 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) if (err) goto remove_pm_qos_request; - if (!sdhci_sdio_irq_enabled(host)) { - err = clk_prepare_enable(imx_data->clk_per); - if (err) - goto disable_ahb_clk; - err = clk_prepare_enable(imx_data->clk_ipg); - if (err) - goto disable_per_clk; - esdhc_pltfm_set_clock(host, imx_data->actual_clock); - } + err = clk_prepare_enable(imx_data->clk_per); + if (err) + goto disable_ahb_clk; + + err = clk_prepare_enable(imx_data->clk_ipg); + if (err) + goto disable_per_clk; + + esdhc_pltfm_set_clock(host, imx_data->actual_clock); err = sdhci_runtime_resume_host(host, 0); if (err) @@ -1715,11 +1713,9 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) return err; disable_ipg_clk: - if (!sdhci_sdio_irq_enabled(host)) - clk_disable_unprepare(imx_data->clk_ipg); + clk_disable_unprepare(imx_data->clk_ipg); disable_per_clk: - if (!sdhci_sdio_irq_enabled(host)) - clk_disable_unprepare(imx_data->clk_per); + clk_disable_unprepare(imx_data->clk_per); disable_ahb_clk: clk_disable_unprepare(imx_data->clk_ahb); remove_pm_qos_request: diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 2a9be044448a..a7df22ed65aa 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3046,7 +3046,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) spin_lock(&host->lock); - if (host->runtime_suspended && !sdhci_sdio_irq_enabled(host)) { + if (host->runtime_suspended) { spin_unlock(&host->lock); return IRQ_NONE; } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index cf3d1ed91909..8effaac61c3a 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -753,11 +753,6 @@ static inline void sdhci_read_caps(struct sdhci_host *host) __sdhci_read_caps(host, NULL, NULL, NULL); } -static inline bool sdhci_sdio_irq_enabled(struct sdhci_host *host) -{ - return !!(host->flags & SDHCI_SDIO_IRQ_ENABLED); -} - u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock, unsigned int *actual_clock); void sdhci_set_clock(struct sdhci_host *host, unsigned int clock); From patchwork Tue Sep 3 14:22:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172804 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641591ocp; Tue, 3 Sep 2019 07:22:48 -0700 (PDT) X-Received: by 2002:a2e:9a41:: with SMTP id k1mr8144738ljj.153.1567520568159; Tue, 03 Sep 2019 07:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520568; cv=none; d=google.com; s=arc-20160816; b=MleH1CsYku9RkiEQTonTM0oQICxVv63lYQkT92WF1KQANaVYUYYQYOxVNbsf8d4bGK 5VoJ888I+KO5ygW627KHmi8aWzfZ6tjqGyjidKIEi26sUCcBg+nBTYcKJPtbsbBqfqI/ 64mjgBswn69jB9Qk2pxaxjpCidFYq8SR4wKe42oBw/QNg3D+KfrOeT8R334zUy3FrhIH Wq7CkSCDn4dDbDifZnjt3pftaRVNHWho6dduww8pIc49GapYXfR7JJWVDRU8Q1zpqkZk 6urHYXvq9KYv8dsAz2jaqm/ni5xeNH1ITJCc/xF5QtvkWaWZ+G6Hazx7lB/Gv+BGOLEh e1vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nRD8RZZIfXxFxN/71F8TIreo7M10o8NGOL7lgd4hWxU=; b=WcjHEC+GSysbF6hivez6hyrEcArfKM2b9VGuRyZOIEBfbMVHBYoatrG3xtwzIO03SF DLld4S3k1TCxbcFd+vb7sSljt3j9Iz0IpdzFLbR5BXLcZpjTNaif2vBaDq2983HPLbPc cnK5Tne1zxzLbFREznCLM1LHWkCst6IrSLzq9F4joFR//DFDM1zktrlzGaUP+AvPft0f 9O2TFouMH8HafrV/U/Da+Xu8ODnCw1z9ZPCUezcaeuJqKrDat886sFfWQotJLF0VsL+Q h3QRgW25hvkmdQ7J9MmO5D2y5lzgsjvklxClSKY8lz6h22z6u80abI3g/tSnxo+4+sFP h1bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="J2D/ecsn"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r14sor4882148lfp.15.2019.09.03.07.22.47 for (Google Transport Security); Tue, 03 Sep 2019 07:22:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="J2D/ecsn"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nRD8RZZIfXxFxN/71F8TIreo7M10o8NGOL7lgd4hWxU=; b=J2D/ecsnkgDBU3gX4LMmTKbcJzk+6AjL8rx/Kjm2RA4Bpf1HLq5ZgxMvD4ooI7jbeO zwhtp/FEBOzXdDLSlByqRUC7VRwxF7xMgMlFf8m3RBZp0N4JgWe4fKxVyM+k7iJeNNVs bAeM/QQG8qs2PRoUhRDyHPrG61sV8f/dbndWhARzYr8iTyzTndoEVITYJ3HGDLRhI8G/ y3AWhLCI5OH9dZhYXg9X0sNfVNxMmjDANlm6XZU0Ghpuh+vDOEIXvyy92DalwjAe6bmL cLWVuDUK77glbB9x7RX+KX0jaoVqvuxsr59YmZhPhBOwIkIPdiQE44IOBox/NVJpOHXz jQWw== 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=nRD8RZZIfXxFxN/71F8TIreo7M10o8NGOL7lgd4hWxU=; b=osBwm2h9cusp1ZjcRBw5j8pvKxRzJv55bLTWbfc+H0SOuLf4b5kTZYrSXf+1pJm/7z ErT2b86vvmgDHOZN7Rzx7ee6FCdsjMzBNK8SbXnjJCk8yRlLWM0yIQ3BvU3QeZRR9AoA CGssPgGbO+6QkRXCGIZZ4qxZNYC0hQsF7qS4RKHFZlYwdjZdpGsmY4xcYxxHDHd7Mfmd 2QYGqI9CUawIL5Y49DC1YiIX0eLia0ltXcQZf1uJHD1hvaB9IueJsvYXUDo49xrw4aaj bIYQuLXj+ndZC7k0O0LNkB8FapLg/MhEaJquubBSVCEWDYxTmwMoTXSJbavxqGDFzPr6 CC8Q== X-Gm-Message-State: APjAAAV/KeWrIeblQjps0vuCe5YzEIaMiApYkNhFQol4cp/NS8fpGWi7 +uuYh+AyM+O2j5i8lGCvut8qrr14 X-Google-Smtp-Source: APXvYqzSHG0+TZa6KjRS808SzcPkET5qRVkq972VhJ8Mj2w5fbGg73wGEtlGxYnVldeA484PW/gp4A== X-Received: by 2002:ac2:514c:: with SMTP id q12mr7287750lfd.145.1567520567815; Tue, 03 Sep 2019 07:22:47 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:47 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 11/11] mmc: sdhci: Convert to use sdio_irq_enabled() Date: Tue, 3 Sep 2019 16:22:07 +0200 Message-Id: <20190903142207.5825-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> Instead of keeping track of whether SDIO IRQs have been enabled via an internal sdhci status flag, avoid the open-coding and convert into using sdio_irq_enabled(). Signed-off-by: Ulf Hansson --- drivers/mmc/host/sdhci.c | 7 +------ drivers/mmc/host/sdhci.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index a7df22ed65aa..4b4db41aec50 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2142,11 +2142,6 @@ void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) pm_runtime_get_noresume(host->mmc->parent); spin_lock_irqsave(&host->lock, flags); - if (enable) - host->flags |= SDHCI_SDIO_IRQ_ENABLED; - else - host->flags &= ~SDHCI_SDIO_IRQ_ENABLED; - sdhci_enable_sdio_irq_nolock(host, enable); spin_unlock_irqrestore(&host->lock, flags); @@ -3380,7 +3375,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset) host->runtime_suspended = false; /* Enable SDIO IRQ */ - if (host->flags & SDHCI_SDIO_IRQ_ENABLED) + if (sdio_irq_enabled(mmc)) sdhci_enable_sdio_irq_nolock(host, true); /* Enable Card Detection */ diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 8effaac61c3a..a29c4cd2d92e 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -512,7 +512,6 @@ struct sdhci_host { #define SDHCI_AUTO_CMD12 (1<<6) /* Auto CMD12 support */ #define SDHCI_AUTO_CMD23 (1<<7) /* Auto CMD23 support */ #define SDHCI_PV_ENABLED (1<<8) /* Preset value enabled */ -#define SDHCI_SDIO_IRQ_ENABLED (1<<9) /* SDIO irq enabled */ #define SDHCI_USE_64_BIT_DMA (1<<12) /* Use 64-bit DMA */ #define SDHCI_HS400_TUNING (1<<13) /* Tuning for HS400 */ #define SDHCI_SIGNALING_330 (1<<14) /* Host is capable of 3.3V signaling */