From patchwork Mon Jun 24 09:55:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 167561 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4015144ilk; Mon, 24 Jun 2019 03:08:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1j/0Q5Zid9D5PMtNO1CY5gx8rCmYYRDoJ1nD3bjtL0K5Sxm++nhsRsIEVEsThQL5ERIg3 X-Received: by 2002:a17:90a:2430:: with SMTP id h45mr24656015pje.14.1561370889013; Mon, 24 Jun 2019 03:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561370889; cv=none; d=google.com; s=arc-20160816; b=e0LK6XGbQ0WruoJhBduvIwJRdU+5KepUbNwvZXOnNDBH1prOgX4IA2xNebvuJOALpc 8nZEYvjiqyWCMKpibW3o4K6EjfxVIrqSrzgzDOinQPYjOajUfE8LdUJhBG6liwxP6NuQ YOjsieYAs7s7Aw8d1ZiBkGhgpyvteFdUNMa1fFOJ2EaDVC2VO5dIYWhM2XZv2LUIKX8+ v2H9YGdPlopT3zEHpbOgmyeo0XpovNPCmKyWcQrdYF9/1YD5fWS4aKEKqT+WCHnvqVYl j2uaOj0nyztfJGGyyFAmE2zssPvdNCXyhpwMAKjqUUDq51NIkeFc3Tk79CuvHCRgiP6m ei0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z/MhzrMTn4GHcrfv+JzCYKnnnjATmbQFYlPQdARaJGc=; b=a8ao1PP5uSEeX2dz4xxiTc7nwdNbCDxOw3pZqQahCAq43Yw+XM8OPc6rwFz/n/vMqN 2DrVCbsJWaSPPJqPAyuUd6euH495lR7fjeoqWmZLwIsVNp8GvLP3u4BD44UBRnYM95dH 28n+3OhoInZGxvvC4dZ6EZxw8s6pDbsjX9PwIHS0J6ciwu0XOaqsri/epc4PtvAVGZ44 XKY7ZUaX1K2lIXWxkRpwm4gbAtmTpYURXXUMqVQ7fiTs/ZoFG12JHYHhsnnaLACQxUbw E4LBdPf2McjdGrLgTaSyWkGbgl1GnifuVi0aewItKdRxbvGlUx9cqg9e1oyda8/4nlBy OcZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Yl8j/nZE"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 b13si10183338pfb.162.2019.06.24.03.08.08; Mon, 24 Jun 2019 03:08:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Yl8j/nZE"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730398AbfFXKIH (ORCPT + 14 others); Mon, 24 Jun 2019 06:08:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:41186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730394AbfFXKIH (ORCPT ); Mon, 24 Jun 2019 06:08:07 -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 44406205C9; Mon, 24 Jun 2019 10:08:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370886; bh=DLekv5rXk36k0WrAZjh6c56wDEX98kHnt3AjZwK1BQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yl8j/nZE/6Fr1jFClst5j3FtWzQo9rHcjbRqPJ2vaQGUtHwhvWoGAbLAImMpVcEgc FC5Ddn6n1lBFSzbsgdIy4eow3GuOukWn3fRGoUPTtdSvY99tObB1MjesoPkvof+Y+8 cYTgO2nUvv/HnlNwgK21SWVCorbr4xcfCDQc3cHA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Ulf Hansson Subject: [PATCH 5.1 008/121] mmc: core: Prevent processing SDIO IRQs when the card is suspended Date: Mon, 24 Jun 2019 17:55:40 +0800 Message-Id: <20190624092321.072018764@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092320.652599624@linuxfoundation.org> References: <20190624092320.652599624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 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 @@ -941,6 +941,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)) @@ -989,13 +993,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.