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,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 016F4C48BE8 for ; Mon, 24 Jun 2019 10:01:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE3DF20848 for ; Mon, 24 Jun 2019 10:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370464; bh=JLVeObjHjzNKx1lln9DG18Z8xT0aOW4ZUEfxrfdGs3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ScLbT6TRZU+xfeFBZ3bjin8Pae5Pyx6I1cXq9gYvC6GhFaBC3O1WOczGbKi6c/Ikq 4iS04/Wh9CO5bX7z1VPpuJMgqBcYSLrceKp5BvnjRveXjGM96QIgKpAN/rwwTyfAgr xXRoc53w0+IETmgIqgY5IOJzurzuEvHpH3wZ8bKQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729134AbfFXJ7G (ORCPT ); Mon, 24 Jun 2019 05:59:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:57950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729120AbfFXJ7C (ORCPT ); Mon, 24 Jun 2019 05:59:02 -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 7E7AB205ED; Mon, 24 Jun 2019 09:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370342; bh=JLVeObjHjzNKx1lln9DG18Z8xT0aOW4ZUEfxrfdGs3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GjrDDwEdYBiiUqJcGF3XMFRjIo3rJn8kIRyNSpp6Y5CSWTruAbdK6EbY8Y11I45d0 jrDItPkNsDK07iSoXrbtzKJn3noim3xxd2ZxrZx4/3mNiB7zIbbIxLzzXEmbofenf+ T3cOuRDe7cvHSiWP+0Dg1MSIlQDAJYMYjjgn64o4= 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.14 05/51] mmc: core: Prevent processing SDIO IRQs when the card is suspended Date: Mon, 24 Jun 2019 17:56:23 +0800 Message-Id: <20190624092306.562108995@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092305.919204959@linuxfoundation.org> References: <20190624092305.919204959@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -907,6 +907,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)) @@ -962,13 +966,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.