Received: by 10.192.165.148 with SMTP id m20csp2483863imm; Sun, 22 Apr 2018 08:00:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx48O/69GWGr4lfBzh6MRzFaRg2AA3Bruz9kDu8uUi+xZcZzMfJoS2RpYwPwHCN8SdybKZDE7 X-Received: by 2002:a17:902:6902:: with SMTP id j2-v6mr17337076plk.92.1524409252848; Sun, 22 Apr 2018 08:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409252; cv=none; d=google.com; s=arc-20160816; b=ZhwtAC5G1AiaY62xtXKawWowbnGrl9TvJHdSZpz1omDiqCS7FetkaR2CBNxDjv/00O VXvgLDWiW8Oxu/dQ/4PmRXajGlBXoq/fRuxZJRtL01W9nhErZngek72tn1NZmIfD/Drj d3rC4M7mrT+tf1fCLPLBkBntREIG4A9uwohbT8oqavsjJ5pMCot0bWXysGfwmlQpjwEl ZZzoKVHADIDVsjvzttrczvRwhjl9FP5L8dd5+Nvhcmo57YZjVJTH5Sm3Ooh5khHOxcKQ xNWth3cedEhcRuboHiOXJFAFszU8D/b7imG7psMcYARqovbaHD7M+E2zzPn6XBCES4VB jk8A== 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=Ah/zKAWXC5F8jLdPKmAB2GYjEy2PzCq8SH1rN8Vu8Z0=; b=jRFMYxVjW2GB4tnlb185AzTEiXoRt/nqjsId9V+xovMsnLBTftIsE1RD7+RqbmhGWs mIsynPxmjYQZXZCprF+0hUOUI48A87xbNZHlWFkkjR+W5+MsY7cUqHQ+34fbwyN8i8MD PbOn70NzRBgoqkRkprGsbDlTDNMyJjtS5AAQEeKwIjF/39711li2vaiKykS7o3LaaGls xZcpLrsNLS/UgUQBL6vudW30u1at8HuQberWXbxb/lMcQIFDVCWSVXx5/y1GwiKHJRTK tpF4G2tb/XVTTD57bS1KGFXzlnZBjsauYPJUZmMxLNaDwHE3KgLr9TDNMQ5Y2Usovx5G FG0A== 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 p5si8242735pfn.292.2018.04.22.08.00.38; Sun, 22 Apr 2018 08:00:52 -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 S1753619AbeDVO7i (ORCPT + 99 others); Sun, 22 Apr 2018 10:59:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55426 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756754AbeDVONB (ORCPT ); Sun, 22 Apr 2018 10:13:01 -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 81C11CE3; Sun, 22 Apr 2018 14:13:00 +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 4.9 50/95] mmc: jz4740: Fix race condition in IRQ mask update Date: Sun, 22 Apr 2018 15:53:19 +0200 Message-Id: <20180422135212.461676797@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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 4.9-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,