Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp153490pxa; Fri, 31 Jul 2020 08:35:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxp+A3L6wlnunri9Lcdgx0pY9fr0obm3TSYM0H+deiieBGrazuK5RzpZsaMhkzTRkPkgk4 X-Received: by 2002:aa7:da48:: with SMTP id w8mr4340921eds.329.1596209749407; Fri, 31 Jul 2020 08:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596209749; cv=none; d=google.com; s=arc-20160816; b=FcQx9BavGoAkn3dLxUhZg388yS7QhNPjJ1TRul73c6QDYIOQkwalAd5wZF9k6kYj/Z zkipC4dlcgH3i5zAJ1cLZzkhCpfBe/Cmta07TLqAx1Bh/A5Sw9/XwXTjfiXw6J5BncjY Ye86YUnFLso+D6WHJcw/Yuqwy5udm17wRuHrnw8UcsnK509jvG9Q/UpfAxTJpmLwF0zQ lbqDW2c6bzOUml6swVcyO1pWg0A3qoOvZNXiSfXe/XyA0RUXA98+xva9ZjE3llfR7uGJ 1rTMdu3jwOqQmMuMbcZ9w1vBjwpKrlra+o6VWpFic1OzL6XblgoMZ7RXxUzKiUMSl6Nh 1pjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J7pM1+5jSnBNNwkAN/IMC3fqo/nlZVODCaK8DO7mPqA=; b=1KuFZWlHZOPgwOgtkSIPx9dUdgTa7q7k+XAwnJJUVyMA2RJ6+X3WbgP+6nGqXnVzSS V8HfUU2F1XmAF/YpcOcsE+sy1toAOkTWtrKtJZ7EKvx6FmCj+R0mO/HmcDgQWrfuB3GS ZfaPn123qpqNMgL4Ki/yziuBdjBMEECkFDfe9xIGZ3ipfA6BYkvMYL6+e8YwuV1GtotB gIq0jZ/jwA1NzjLvWFsHufHRe1H2WNa/8354sT7WFRTn8bFVGYY8pBadxOOe0V9JHQgP ubS63KrzBIq3EV6DUVA+bNY3ldz7GuXjSN16wvRWmO7RVJpG99WCFbT2j/TA6SvdGQMb r0Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H+3Nm7MB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si5113696edy.72.2020.07.31.08.35.26; Fri, 31 Jul 2020 08:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H+3Nm7MB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731504AbgGaPci (ORCPT + 99 others); Fri, 31 Jul 2020 11:32:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:51626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgGaPch (ORCPT ); Fri, 31 Jul 2020 11:32:37 -0400 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 763BD2245C; Fri, 31 Jul 2020 15:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596209556; bh=wYzf+2brtM3bwigWDhYjt0sg7jxC8tK4H51bPDfvYJk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=H+3Nm7MBMWlmBuU09BMx36oPZGaIrk7x2MdF652Y3zm0mrPT2XLC4yh/7y+d4nfsu KFf9txu4PstMlhhHGqbmZaRSyqjwHqr3CyLx8HD5cQ9rQ1vVYYElkiG1Vo5yu3V7XN KZf/uJCoc8iC3Gvx0L/XW7zyNkVsLRpttC7IZjfs= Received: by mail-oi1-f170.google.com with SMTP id k4so27056218oik.2; Fri, 31 Jul 2020 08:32:36 -0700 (PDT) X-Gm-Message-State: AOAM533Xpnla2IrELpV3NP/1/X1UFYj4Uv8+Htw79pBDnPHI0y/W6mpJ re6p4CFMilkQ4xhRJidLjncVSctHMIUGhEp5ow== X-Received: by 2002:aca:4844:: with SMTP id v65mr3474230oia.152.1596209555800; Fri, 31 Jul 2020 08:32:35 -0700 (PDT) MIME-Version: 1.0 References: <20200731033956.6058-1-mark.tomlinson@alliedtelesis.co.nz> <20200731033956.6058-2-mark.tomlinson@alliedtelesis.co.nz> In-Reply-To: <20200731033956.6058-2-mark.tomlinson@alliedtelesis.co.nz> From: Rob Herring Date: Fri, 31 Jul 2020 09:32:24 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] PCI: Reduce warnings on possible RW1C corruption To: Mark Tomlinson Cc: Ray Jui , Bjorn Helgaas , Scott Branden , Florian Fainelli , Lorenzo Pieralisi , PCI , "linux-kernel@vger.kernel.org" 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 On Thu, Jul 30, 2020 at 9:40 PM Mark Tomlinson wrote: > > 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. > > This patch changes 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. If we don't want to just warn when a 8 or 16 bit access occurs (I'm not sure if 32-bit only accesses is possible or common. Seems like PCI_COMMAND would always get written?), then a simple way to do this is just move this out of line and do something like this where the bus or device is created/registered: if (bus->ops->write == pci_generic_config_write32) warn() > > Suggested-by: Bjorn Helgaas > Fixes: fb2659230120 ("PCI: Warn on possible RW1C corruption for sub-32 bit config writes") > Signed-off-by: Mark Tomlinson > --- > 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 79c4a2ef269a..ab85cb7df9b6 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 = true; > + } > > 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 34c1c4f45288..5b6ab593ae09 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -613,6 +613,7 @@ struct pci_bus { > unsigned char primary; /* Number of primary bridge */ > unsigned char max_bus_speed; /* enum pci_bus_speed */ > unsigned char cur_bus_speed; /* enum pci_bus_speed */ > + bool unsafe_warn; /* warned about RW1C config write */ Make this a bitfield next to 'is_added'. > #ifdef CONFIG_PCI_DOMAINS_GENERIC > int domain_nr; > #endif > -- > 2.28.0 >