Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp956001pxb; Wed, 6 Apr 2022 05:16:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQ3IEsS+iXdej/rntJF4hYRtQxwSfkzCz2GB8mieehnkWhRIG4brm7fw8GPGEYY2NVL6X1 X-Received: by 2002:a17:902:ce82:b0:156:bb3c:3297 with SMTP id f2-20020a170902ce8200b00156bb3c3297mr8107638plg.159.1649247365846; Wed, 06 Apr 2022 05:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247365; cv=none; d=google.com; s=arc-20160816; b=JcQenE5oxubdf3gDEuvvlQdmmkhL6KJ/81rN6U84oKI1qmtY9gDQabVqYpXK31BdZS lqTdQJEoQg39BJIKHj82vFEPDBWM3fyDeDGGnQjH3s3jOeYg1TsVojDRjnHVhShn4WE/ UOekb9l966jF91rJxQSG4MQif7nwWeusekjiyZB/4XaMuqWDySRQtfp57gq+EQ1Wb099 QRxSTff8W5+F6P7z4g2HqvFtMRl0KgBkIVpcutfdQo5iCTTYe87gppLHjUL2hIH2EPrE aZfDnxwTUVeIaUmq+4q4Y796mI/ZnltEELHdiHZ1t5sTN2kq2nsYQmoU9gbhTWhk+FLe hYKw== 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=0CuEH+adyaHkZB/aQlNeXy+WXL8cEZ9JcXYiFomHtFE=; b=W7va56zmtkEMqMNdCprcwWJGFWU/49aNnrrNitCI01VkDsVn4JIk4RM+GHOEtc6kNo zbKn88He9P8vrE+pfMysNP3M3cy2ZJXYNuJz1sb+vZ+hBwM9QZYiokHZm5vVS2gP4Syj GTI3SftTeRQlEIUC1A/3Nb7CehH+48pQixHEkorpyMvGZ9ybZFvzXRIfTnZGiv/6qRPv Ib8qfcCPeNDFo44mSUiztpRNwm9QthcDvYhuE+Y7S2k4jjvVaiftU3rcJHQMUg9QfPmu MlSBCY1vIWll8FCQ5CgGZg/MlpRqQ1gwi4BYhON5LEMO478X9oFevrn6ZZoLyl4+57DU rYdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UhQOCf64; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j11-20020aa78dcb000000b004fa3a8e0082si13915087pfr.313.2022.04.06.05.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:16:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UhQOCf64; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A319F5A1C92; Wed, 6 Apr 2022 03:55:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1583438AbiDEXwq (ORCPT + 99 others); Tue, 5 Apr 2022 19:52:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349171AbiDEJtW (ORCPT ); Tue, 5 Apr 2022 05:49:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38AF5654C; Tue, 5 Apr 2022 02:42:02 -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 ams.source.kernel.org (Postfix) with ESMTPS id D9C56B818F3; Tue, 5 Apr 2022 09:42:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50B5DC385A1; Tue, 5 Apr 2022 09:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151719; bh=ZyfAF0AQcGqReNV3MXg6I9UNCdvxNdnyAwcYrBpVD+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UhQOCf64Sbrt36vugXg2mBNHooEqg4JBAbeQkIYh4jRhUmiLvXcXdekPjv6JfQGZj Y6nmfFg33xQ8NUXMHR/nJp4GBfHKP/RDS8U5G9lrTFBYL5cMqx17H5+gHVfVhsZvj6 7QSsho1r7ooSRW8iVgjQT2J7V3C2XEg90CRsLj3M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Helgaas , Mark Tomlinson , Bjorn Helgaas , Florian Fainelli , Rob Herring , Scott Branden , Sasha Levin Subject: [PATCH 5.15 517/913] PCI: Reduce warnings on possible RW1C corruption Date: Tue, 5 Apr 2022 09:26:19 +0200 Message-Id: <20220405070355.350912111@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 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=no 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: Mark Tomlinson [ Upstream commit 92c45b63ce22c8898aa41806e8d6692bcd577510 ] For hardware that only supports 32-bit writes to PCI there is the possibility of clearing RW1C (write-one-to-clear) bits. A rate-limited messages was introduced by fb2659230120, but rate-limiting is not the best choice here. Some devices may not show the warnings they should if another device has just produced a bunch of warnings. Also, the number of messages can be a nuisance on devices which are otherwise working fine. Change the ratelimit to a single warning per bus. This ensures no bus is 'starved' of emitting a warning and also that there isn't a continuous stream of warnings. It would be preferable to have a warning per device, but the pci_dev structure is not available here, and a lookup from devfn would be far too slow. Suggested-by: Bjorn Helgaas Fixes: fb2659230120 ("PCI: Warn on possible RW1C corruption for sub-32 bit config writes") Link: https://lore.kernel.org/r/20200806041455.11070-1-mark.tomlinson@alliedtelesis.co.nz Signed-off-by: Mark Tomlinson Signed-off-by: Bjorn Helgaas Reviewed-by: Florian Fainelli Reviewed-by: Rob Herring Acked-by: Scott Branden Signed-off-by: Sasha Levin --- drivers/pci/access.c | 9 ++++++--- include/linux/pci.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 46935695cfb9..8d0d1f61c650 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -160,9 +160,12 @@ int pci_generic_config_write32(struct pci_bus *bus, unsigned int devfn, * write happen to have any RW1C (write-one-to-clear) bits set, we * just inadvertently cleared something we shouldn't have. */ - dev_warn_ratelimited(&bus->dev, "%d-byte config write to %04x:%02x:%02x.%d offset %#x may corrupt adjacent RW1C bits\n", - size, pci_domain_nr(bus), bus->number, - PCI_SLOT(devfn), PCI_FUNC(devfn), where); + if (!bus->unsafe_warn) { + dev_warn(&bus->dev, "%d-byte config write to %04x:%02x:%02x.%d offset %#x may corrupt adjacent RW1C bits\n", + size, pci_domain_nr(bus), bus->number, + PCI_SLOT(devfn), PCI_FUNC(devfn), where); + bus->unsafe_warn = 1; + } mask = ~(((1 << (size * 8)) - 1) << ((where & 0x3) * 8)); tmp = readl(addr) & mask; diff --git a/include/linux/pci.h b/include/linux/pci.h index 152a4d74f87f..9d6e75222868 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -656,6 +656,7 @@ struct pci_bus { struct bin_attribute *legacy_io; /* Legacy I/O for this bus */ struct bin_attribute *legacy_mem; /* Legacy mem */ unsigned int is_added:1; + unsigned int unsafe_warn:1; /* warned about RW1C config write */ }; #define to_pci_bus(n) container_of(n, struct pci_bus, dev) -- 2.34.1