Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2196992iof; Tue, 7 Jun 2022 22:55:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAurW2QaqMGgeOk9giHhqGUWOLfEX1uWjk2m2oYwxI+HmpAPwQt1Arb+lrwD/4E2IG68Y4 X-Received: by 2002:a63:da56:0:b0:3fe:2bc7:a605 with SMTP id l22-20020a63da56000000b003fe2bc7a605mr1833288pgj.560.1654667733859; Tue, 07 Jun 2022 22:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667733; cv=none; d=google.com; s=arc-20160816; b=mzUPNWqKaMHOcaQq0LR7NpsEYFDeuW0YhUuJCmV3gaBEaY33PdrffCETR2/TTpCYov 62+stiT+nZMBh2AcPuKuDUaEImnXOweRNClDZCWyN7gs00m+OHw0cRsU6qTN0mk0toqW Tbvc+LvRRMrN+Gf3Gn5PC5Jrj+MsaF3Gt7BJOEqVZY8UJ3lFgrZC+AoQ8eppJ2cjiQ0N XWM8D1NGBjvHrzQmkphhL31VLQa5x9S86kkb8hhC7QjtmOKdLGy1Wm9ujCTRBitniO/Z 3T09xHCFvmaWIHHr5wHsBODLlpC8eUuknFiaOpoUxjmI26UrCTGL1W/EBLtO81L/WTJX SenQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hinhYNyhPV3D1/OKhE+klHqQ+xUIwecpWsXaxggSITA=; b=WKn9gOZzSGPgPBIcQhywaVpqcfCAGck6wit5dFe5b9Bs8lggEUqY6wq8lwJrjbkfT9 0drKxNfatnNtRX42UcBkgm0AaKNh37STCx3Ze3LANDXew/3dO0tt1Z2S8+tUExnD2zli 5q+NYwbfMYebABpkWfMyAe9IzWe99PImpZYwKu16DTVGEnmBGL+77KT/nHBlV1/U1ztw oJZNyz6fkfd6I3DAPhbknXCwidaF8bhNC9vo9PjCMlMcqKNy4f7JUQ6GXTnh8qHgVkxG GhZHaGPtgyYwO/N3F4PV4OXg4Jo90u64i1I60e/6hUoAL8EM9B6UUEQBWhHc5JouEuHP RTrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zr+DgC+I; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c25-20020a631c59000000b003fc907b0e16si27358713pgm.461.2022.06.07.22.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:55:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zr+DgC+I; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5BD1026F495; Tue, 7 Jun 2022 22:21:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbiFHA6R (ORCPT + 99 others); Tue, 7 Jun 2022 20:58:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382914AbiFGWEC (ORCPT ); Tue, 7 Jun 2022 18:04:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCA081957A3; Tue, 7 Jun 2022 12:15:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 78065618DF; Tue, 7 Jun 2022 19:15:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83820C385A5; Tue, 7 Jun 2022 19:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629320; bh=hY1OGFaYOAjKahsc3EgeshxdB0vb5pnbnAM/vdL5NOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zr+DgC+Iw2sgb8b1bzzUr2ujT3M+0L6H+jID69NkWNRAjq3SYDIyvW8DFKBhsE0G4 5a8QdnCEJJEvgV6NdZPRvKpDJaSmSt9kwg4On6z/VqAsEExW799mKquy8uPQPQpxIA 3ysxd40lfYUYs66N21q6tHUVg1ueMKdkAaFQxwH4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daire McNamara , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.18 632/879] PCI: microchip: Fix potential race in interrupt handling Date: Tue, 7 Jun 2022 19:02:30 +0200 Message-Id: <20220607165021.192548460@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daire McNamara [ Upstream commit 7013654af694f6e1a2e699a6450ea50d309dd0e5 ] Clear the MSI bit in ISTATUS_LOCAL register after reading it, but before reading and handling individual MSI bits from the ISTATUS_MSI register. This avoids a potential race where new MSI bits may be set on the ISTATUS_MSI register after it was read and be missed when the MSI bit in the ISTATUS_LOCAL register is cleared. ISTATUS_LOCAL is a read/write/clear register; the register's bits are set when the corresponding interrupt source is activated. Each source is independent and thus multiple sources may be active simultaneously. The processor can monitor and clear status bits. If one or more ISTATUS_LOCAL interrupt sources are active, the RootPort issues an interrupt towards the processor (on the AXI domain). Bit 28 of this register reports an MSI has been received by the RootPort. ISTATUS_MSI is a read/write/clear register. Bits 31-0 are asserted when an MSI with message number 31-0 is received by the RootPort. The processor must monitor and clear these bits. Effectively, Bit 28 of ISTATUS_LOCAL informs the processor that an MSI has arrived at the RootPort and ISTATUS_MSI informs the processor which MSI (in the range 0 - 31) needs handling. Reported by: Bjorn Helgaas Link: https://lore.kernel.org/linux-pci/20220127202000.GA126335@bhelgaas/ Link: https://lore.kernel.org/r/20220517141622.145581-1-daire.mcnamara@microchip.com Fixes: 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver") Signed-off-by: Daire McNamara Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin --- drivers/pci/controller/pcie-microchip-host.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c index 8175abed0f05..2c52a8cef726 100644 --- a/drivers/pci/controller/pcie-microchip-host.c +++ b/drivers/pci/controller/pcie-microchip-host.c @@ -419,6 +419,7 @@ static void mc_handle_msi(struct irq_desc *desc) status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); if (status & PM_MSI_INT_MSI_MASK) { + writel_relaxed(status & PM_MSI_INT_MSI_MASK, bridge_base_addr + ISTATUS_LOCAL); status = readl_relaxed(bridge_base_addr + ISTATUS_MSI); for_each_set_bit(bit, &status, msi->num_vectors) { ret = generic_handle_domain_irq(msi->dev_domain, bit); @@ -437,13 +438,8 @@ static void mc_msi_bottom_irq_ack(struct irq_data *data) void __iomem *bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; u32 bitpos = data->hwirq; - unsigned long status; writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); - status = readl_relaxed(bridge_base_addr + ISTATUS_MSI); - if (!status) - writel_relaxed(BIT(PM_MSI_INT_MSI_SHIFT), - bridge_base_addr + ISTATUS_LOCAL); } static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) -- 2.35.1