Received: by 10.192.165.148 with SMTP id m20csp2527278imm; Sun, 22 Apr 2018 08:54:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx49O4NBc1UxLo/TS9jbzfeGTzjdab1EvPJ5OjJCayHa44402L5aMSHp9AJhl09vz5BP6ktcu X-Received: by 10.167.131.146 with SMTP id u18mr17000041pfm.199.1524412466895; Sun, 22 Apr 2018 08:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524412466; cv=none; d=google.com; s=arc-20160816; b=J0cvZJ4Dcm3XJpRImLmhnh7sQnD3pPJceSm7s0tvVCbJyKzdpKhR4NbqMN86VdK9xC rVpdk5NWrZ5GOgiDaCIiHliEGKAoUT63revCW24sH4Yq9rHZD+Azh7nINZQ+/d4natTG BUR8ND9yVoDjThVWGWT2AV+GtB1mtdh7xm65Ha5cPXDwxMB44lCq0sVvP6gtxq2gFS8L +6NrSpVZbpfUNnA3WysrKDfvzA09YDX3ul1mW9PLk4LXDkNuWEA11eActc2Cn1ZW3Tfg gJTTvQlyNWRiUgj4+0QB8BGXIIEtIewE3vmojcEjjnibeANJ+TEFirNjmUF1sO89fL+G KUMQ== 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=p4FT/Q9voJtHr89/ZzKLFICjWsGq6YUUDh59Pyv7AYA=; b=iF3zxuosng1wfTua721tO9C8ALv4y/0X5Infd8duSXkswVnh0+6bRj6l/VjyXsAg2Z 2+fi0+hYIauATWXhsA1NJ6vTZdgBuEvm+hj0RdjKCBYTE9g6+y1ap8DKR7bsyUrS6+x8 EV572XnQP9DnKlmy2ZgPy9q1hIwst98hOQR9N60pYPrBZzF29HGtAvEItctGAeUIHebM gedSd56g8tkBj9J/12iIIJjun9w0YCXkNqEC0CYoJCGXjmWh/zqjjeIKeFYhnbHNFf/5 WweDqgAw9lrwTQDU5pwyK04rNndWB4TYa9qE5Kt67fxBn7eGPniMVJqp5JqJdISYzUJx WwtQ== 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 z2si8209935pgp.532.2018.04.22.08.54.12; Sun, 22 Apr 2018 08:54:26 -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 S1754627AbeDVPwx (ORCPT + 99 others); Sun, 22 Apr 2018 11:52:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47284 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753997AbeDVOAQ (ORCPT ); Sun, 22 Apr 2018 10:00:16 -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 7E5DB412; Sun, 22 Apr 2018 14:00:15 +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.16 132/196] mmc: jz4740: Fix race condition in IRQ mask update Date: Sun, 22 Apr 2018 15:52:32 +0200 Message-Id: <20180422135111.076017437@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@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.16-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 @@ -362,9 +362,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,