From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 589D1C48BE8 for ; Mon, 24 Jun 2019 10:04:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D3DA20848 for ; Mon, 24 Jun 2019 10:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370681; bh=TZPaRkPROyoay+S6+8vlutN8XMG7y/b8GH5AwoiUKc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ieDBL3h2mIAbjE2B4lgz2q5x+SnrHwy+WHxtlFgoGb8ejrHwRdGqo1pIVCXGKZYER GbY49GLbn2erRjGcL9ibx5JYRSseboD81KgpXrt2jSgw5GLJoKwo+inCT0CP0y9/vY 8g75P7yxa0pAYcUFwCfDhSy8bG+8nPTOxCX2CgrA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729763AbfFXKEk (ORCPT ); Mon, 24 Jun 2019 06:04:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:36288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729743AbfFXKEh (ORCPT ); Mon, 24 Jun 2019 06:04:37 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F5BB205ED; Mon, 24 Jun 2019 10:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370676; bh=TZPaRkPROyoay+S6+8vlutN8XMG7y/b8GH5AwoiUKc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLpdph86UbZ3UNptUn7KNC8fwD7nQkp+fewC2ss0hintVf2keZpDs1AxeMauK1f/j jCooI52nJ+DoH8ZsiDImDgsiKk/0LL2x5Mg8sBQXWDPQ7ER3W49wd1+fHUVOm1ahBZ 1VqtbwJANN9qon+Mo4nmDOhLxkb1tiqQ01dGLWuY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Ulf Hansson Subject: [PATCH 4.19 15/90] mmc: core: Prevent processing SDIO IRQs when the card is suspended Date: Mon, 24 Jun 2019 17:56:05 +0800 Message-Id: <20190624092315.035472958@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092313.788773607@linuxfoundation.org> References: <20190624092313.788773607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ulf Hansson commit 83293386bc95cf5e9f0c0175794455835bd1cb4a upstream. Processing of SDIO IRQs must obviously be prevented while the card is system suspended, otherwise we may end up trying to communicate with an uninitialized SDIO card. Reports throughout the years shows that this is not only a theoretical problem, but a real issue. So, let's finally fix this problem, by keeping track of the state for the card and bail out before processing the SDIO IRQ, in case the card is suspended. Cc: stable@vger.kernel.org Reported-by: Douglas Anderson Tested-by: Douglas Anderson Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/sdio.c | 13 ++++++++++++- drivers/mmc/core/sdio_irq.c | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -934,6 +934,10 @@ static int mmc_sdio_pre_suspend(struct m */ static int mmc_sdio_suspend(struct mmc_host *host) { + /* Prevent processing of SDIO IRQs in suspended state. */ + mmc_card_set_suspended(host->card); + cancel_delayed_work_sync(&host->sdio_irq_work); + mmc_claim_host(host); if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) @@ -982,13 +986,20 @@ static int mmc_sdio_resume(struct mmc_ho err = sdio_enable_4bit_bus(host->card); } - if (!err && host->sdio_irqs) { + if (err) + goto out; + + /* Allow SDIO IRQs to be processed again. */ + mmc_card_clr_suspended(host->card); + + if (host->sdio_irqs) { 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); } +out: mmc_release_host(host); host->pm_flags &= ~MMC_PM_KEEP_POWER; --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -38,6 +38,10 @@ static int process_sdio_pending_irqs(str unsigned char pending; struct sdio_func *func; + /* Don't process SDIO IRQs if the card is suspended. */ + if (mmc_card_suspended(card)) + return 0; + /* * Optimization, if there is only 1 function interrupt registered * and we know an IRQ was signaled then call irq handler directly.