Received: by 10.192.165.148 with SMTP id m20csp2456870imm; Sun, 22 Apr 2018 07:26:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx48/ktGDdWm3wEZKOzey89MFrHIedZa1qBh1TnNAThrlLDDw1c7Xlfo0YtfeF0KH/Z+188Fa X-Received: by 10.99.95.130 with SMTP id t124mr14502662pgb.150.1524407168805; Sun, 22 Apr 2018 07:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524407168; cv=none; d=google.com; s=arc-20160816; b=KiZg+LiUJXkmLmexS08PJ8p5lupXcjFYLg7Hnkey9pf7oujCteUjwyztymDyAFPgR8 jJMpJivYW5SUqr4MkejybFxm1mT6Rt1Yki4EaSGFJVOuasmzDms9lYFHtwdL6cpR/EGM ArJlRK+9Jbd2NdR3cNngWmze85pDrCBZpZkaRPDWyTmbRjclATx/VRaaVETh37FGfLzb 8ok35dBdPZnS/2zJHJWvt27EkEbyltZG+anl6AJpq7DRzD96rCV+OGWj2OPSgLzWHgYt d/LBf/c2LthD7rPgvn3YxltY1pNq/ABILE1T9IITjxDdpxlxHqeW1RIQ6X3ML4zAWhAQ N/8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2Z9F8fuRHYm8G7KbhzM7naaPUNWLKuHDI3ZnyO6+FVo=; b=f4hMa+v6GjtlhYnSXVskah2yDX0DOQXlZFK9Irb0+TEihx/eUZQOZrQT6wvgl0Jrpi UiC9775+mbzlYbr7wnusZ5qiAhKn3ZQcViqVHk37gkd2XNvFtTywxQ3EVhXaBKbHjI2G xKiWEUrqAt8lRmMiA9plUZttdqP34UUcMGT2KcVKLkWGf2Tg1H5rNEt8d4RsouetCLBn PsjXot7ZOtXvdN0i7su6vq7eso+QgBMaOhCnUDeK+7zxsMhQj/8WKVorulC10lCtr8Hu 88rPkszQ2ksdsQoN4tAV5DRebVn67dyO3CIK3q0HJjOIwNCltSoSgQjdmqVz7buYnTH5 eP4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 j5si7761788pgt.196.2018.04.22.07.25.54; Sun, 22 Apr 2018 07:26:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757786AbeDVOYJ (ORCPT + 99 others); Sun, 22 Apr 2018 10:24:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33306 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757687AbeDVOWN (ORCPT ); Sun, 22 Apr 2018 10:22:13 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0A74098C; Sun, 22 Apr 2018 14:22:11 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathieu Malaterre , Alex Smith , Ulf Hansson Subject: [PATCH 3.18 26/52] mmc: jz4740: Fix race condition in IRQ mask update Date: Sun, 22 Apr 2018 15:53:59 +0200 Message-Id: <20180422135316.672332055@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135315.254787616@linuxfoundation.org> References: <20180422135315.254787616@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alex Smith commit a04f0017c22453613d5f423326b190c61e3b4f98 upstream. A spinlock is held while updating the internal copy of the IRQ mask, but not while writing it to the actual IMASK register. After the lock is released, an IRQ can occur before the IMASK register is written. If handling this IRQ causes the mask to be changed, when the handler returns back to the middle of the first mask update, a stale value will be written to the mask register. If this causes an IRQ to become unmasked that cannot have its status cleared by writing a 1 to it in the IREG register, e.g. the SDIO IRQ, then we can end up stuck with the same IRQ repeatedly being fired but not handled. Normally the MMC IRQ handler attempts to clear any unexpected IRQs by writing IREG, but for those that cannot be cleared in this way then the IRQ will just repeatedly fire. This was resulting in lockups after a while of using Wi-Fi on the CI20 (GitHub issue #19). Resolve by holding the spinlock until after the IMASK register has been updated. Cc: stable@vger.kernel.org Link: https://github.com/MIPS/CI20_linux/issues/19 Fixes: 61bfbdb85687 ("MMC: Add support for the controller on JZ4740 SoCs.") Tested-by: Mathieu Malaterre Signed-off-by: Alex Smith Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/jz4740_mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -368,9 +368,9 @@ static void jz4740_mmc_set_irq_enabled(s host->irq_mask &= ~irq; else host->irq_mask |= irq; - spin_unlock_irqrestore(&host->lock, flags); writew(host->irq_mask, host->base + JZ_REG_MMC_IMASK); + spin_unlock_irqrestore(&host->lock, flags); } static void jz4740_mmc_clock_enable(struct jz4740_mmc_host *host,