Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp7843rdb; Wed, 1 Nov 2023 15:02:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjQjsIoxAnu3HtL8DwYEEDK9Uzg/6NUiQx5mI8PqGSK9yJt9EPDL9AXI8Fr2MeXlYhl3TD X-Received: by 2002:a05:6e02:3181:b0:359:3981:4b0e with SMTP id cb1-20020a056e02318100b0035939814b0emr6267088ilb.28.1698876169312; Wed, 01 Nov 2023 15:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698876169; cv=none; d=google.com; s=arc-20160816; b=LCwJUmSxx+uIy54429mbo5sUwQ3vJIP4u5Gk8pCEWcgc+2hyEkqWQvGR5dxAf6jFRe lnpmFzdk0t94KcTARYbK7AySs9KWiF0Hii40wuqyjMt3hL8p2qP6kVUZdrGvaSIlcXiz loF7rEy4QuPyHsrgLflV2U9xDyz5E+1pLV4qWZInLd5FOrpKqFH8unBiMaamC6KdcPgK OrdvVVkj6hN1W7IM9HXjOM6ipvwp3N4qp1CAu0Z1yXGkLqso9AQ9Dfk/FVt9HlJeYLbo bMv1wYYStCbkC7jBm7F7Ogi7NkcpqFCoTiLx+ugoroer0AGHfo37yWVlmc6vHWddaFBT W5PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=STR2ZEhA9cpZMqcxfZ6BPDLSX6EzWx02MDEUkJPnBeA=; fh=EZbhsDocixSE0vFLzL7rkHlZ15ixcHpabCuzDszWgDY=; b=PZ6XbRjcIgw0PIB/n/1CwxHSttrrI/nUU0UvlzBGkCOo2q31gSoV9WgHDUM866IOuc hoM0n4EY6CyRG9S6mqaqSq8AYS0yilvTmvNYWkneEVKHkPYAUXqVcZtJJpP/ZpC3oE1W ku323uE05n/WCkBdDNmo4by9nKdFnJ3tmDF2j1zZyRT9yOedLRu0R6oZ+ZHxo+3FM45j rggcRUEEiSn5DoV1VhRtXxcR2uNM4lOK8xc5OgvBDXKGnHxW2ADKDTNhnWzXKiEnZA0d 8OrIgRipUnpwKqhPk5duj0E5WfayHygHiZfdeg8HpNsJKVa4zIaElRMIKc5BxsCivCGN V+XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o2rfU4uL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bw30-20020a056a02049e00b0057745b2d018si827703pgb.390.2023.11.01.15.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 15:02:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o2rfU4uL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E3AD2808986C; Wed, 1 Nov 2023 15:02:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344241AbjKAWC2 (ORCPT + 99 others); Wed, 1 Nov 2023 18:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbjKAWC1 (ORCPT ); Wed, 1 Nov 2023 18:02:27 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21A0D110; Wed, 1 Nov 2023 15:02:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6417EC433C7; Wed, 1 Nov 2023 22:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698876144; bh=wnWLDQK0FBkzmPX13eahCC6CH20kSJCdKoocecCI93s=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=o2rfU4uLCVdKybijAOa0me8qs5gY1oB7W2Enq/sp2esf+Jwnr7SYLqwJxrGTyBLxD PJWsQWuazLx6iAm/0lrWgeCqJiP8CdebHo9Xh8OI2WNErazD88E4DtknZ+UPlwdekC OY2biJnnx4gnzeztqIxtutRc8ixr5jfaT3kGV4tLBLTz8359uadpWwuz9U13om4TrB sqIA0nmj6ahkuLNP2mlSe0icOjpJ3521K/HwMq8BKiOgf2IxFcMBypHivMxonTMaLo hk8FkX4RuaOEj0+s5j3zJP7NChiEuW1judgpJy9ImvWkRy6pgo4lIIrgY1qaQJByWx 9cciBOTffXTaw== Date: Wed, 1 Nov 2023 17:02:22 -0500 From: Bjorn Helgaas To: Jiaxun Yang Cc: linux-pci@vger.kernel.org, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, linux-kernel@vger.kernel.org, chenhuacai@kernel.org, stable@vger.kernel.org Subject: Re: [PATCH fixes v4] pci: loongson: Workaround MIPS firmware MRRS settings Message-ID: <20231101220222.GA99154@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231101114957.309902-1-jiaxun.yang@flygoat.com> X-Spam-Status: No, score=-1.6 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 01 Nov 2023 15:02:46 -0700 (PDT) On Wed, Nov 01, 2023 at 11:49:56AM +0000, Jiaxun Yang wrote: > This is a partial revert of commit 8b3517f88ff2 ("PCI: > loongson: Prevent LS7A MRRS increases") for MIPS based Loongson. Thanks for this patch. We're in the v6.7 merge window, so we won't start merging v6.8 content until v6.7-rc1 (probably Nov 12). > There are many MIPS based Loongson systems in wild that > shipped with firmware which does not set maximum MRRS properly. As far as I know, there's no requirement for firmware to set MRRS at all *except* for the "no_inc_mrrs" hack added by 8b3517f88ff2. That hack treats the current MRRS value as a limit to work around the Loongson bug that read requests larger than the limit cause a Completer Abort instead of multiple completions. > Limiting MRRS to 256 for all as MIPS Loongson comes with higher > MRRS support is considered rare. > > It must be done at device enablement stage because hardware will > reset MRRS to inavlid value if a device got disabled. s/inavlid/invalid/ This part isn't clear to me, though. What exactly does "device got disabled" mean? The device got reset? Power cycled? PCI_COMMAND_MASTER was cleared? PCI_FIXUP_ENABLE quirks are run during pci_enable_device(), which basically just turns on PCI_COMMAND_MEMORY and/or PCI_COMMAND_IO. If MRRS gets reset when PCI_COMMAND_MASTER is set or cleared, we don't have a quirk phase that runs during pci_set_master(), which is where PCI_COMMAND_MASTER gets set, so it's not clear that pci_enable_device() is the right place. > Cc: stable@vger.kernel.org > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217680 > Fixes: 8b3517f88ff2 ("PCI: loongson: Prevent LS7A MRRS increases") > Signed-off-by: Jiaxun Yang We'll look for an ack from the maintainer. Maybe that's you, since you added the driver in the first place? Or maybe it's Huacai? MAINTAINERS currently doesn't list anybody for drivers/pci/controller/pci-loongson.c, and it should. That should be a separate patch. > --- > v4: Improve commit message > > This is a partial revert of the origin quirk so there shouldn't > be any drama. > --- > drivers/pci/controller/pci-loongson.c | 38 +++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c > index d45e7b8dc530..d184d7b97e54 100644 > --- a/drivers/pci/controller/pci-loongson.c > +++ b/drivers/pci/controller/pci-loongson.c > @@ -108,6 +108,44 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, > DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, > DEV_LS7A_PCIE_PORT6, loongson_mrrs_quirk); > > +#ifdef CONFIG_MIPS > +static void loongson_old_mrrs_quirk(struct pci_dev *pdev) > +{ > + struct pci_bus *bus = pdev->bus; > + struct pci_dev *bridge; > + static const struct pci_device_id bridge_devids[] = { > + { PCI_VDEVICE(LOONGSON, DEV_LS2K_PCIE_PORT0) }, > + { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT0) }, > + { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT1) }, > + { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT2) }, > + { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT3) }, > + { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT4) }, > + { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT5) }, > + { PCI_VDEVICE(LOONGSON, DEV_LS7A_PCIE_PORT6) }, This looks like the same list of devices as for loongson_mrrs_quirk(). So I guess the idea is that we need loongson_mrrs_quirk() for Loongarch-based systems, and this loongson_old_mrrs_quirk() for MIPS-based systems? If so, maybe they could be #ifdef'd to show that, e.g., so that only one or the other is compiled? > + { 0, }, > + }; > + > + /* look for the matching bridge */ > + while (!pci_is_root_bus(bus)) { > + bridge = bus->self; > + bus = bus->parent; > + /* > + * There are still some wild MIPS Loongson firmware won't > + * set MRRS properly. Limiting MRRS to 256 as MIPS Loongson > + * comes with higher MRRS support is considered rare. > + */ > + if (pci_match_id(bridge_devids, bridge)) { > + if (pcie_get_readrq(pdev) > 256) { > + pci_info(pdev, "limiting MRRS to 256\n"); > + pcie_set_readrq(pdev, 256); > + } > + break; > + } > + } > +} > +DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, loongson_old_mrrs_quirk); > +#endif > + > static void loongson_pci_pin_quirk(struct pci_dev *pdev) > { > pdev->pin = 1 + (PCI_FUNC(pdev->devfn) & 3); > -- > 2.34.1 >