Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1927517rdb; Sun, 19 Nov 2023 17:08:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGW/Tw7OH3A0XtCOD7mq+lNQGywUvRaKtblsWJAJMuiFkk15tPb31WPrUxXs0GYM5l4fCsE X-Received: by 2002:a05:6a20:748c:b0:185:d125:ea70 with SMTP id p12-20020a056a20748c00b00185d125ea70mr7344123pzd.19.1700442489871; Sun, 19 Nov 2023 17:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700442489; cv=none; d=google.com; s=arc-20160816; b=EXetEvwFbREN88e+ZrwmgjH7JTzR0qrX9wB43DXtBe6tDow60QA0YWc/Ao+AW4K7zV Clxl+/7+0JZJWow8kK02JqDeZ5dyzvuWnr7D4tro19HpC5U5lZaw8l5QufBLzAsCo/gp df34o8NTFitz9fhfSVue5wCJMIFoB1jvDFlKzq0P09OLgVgOSoczngqnn+1O0RHj5Fee 8psdjzA6UyH0sTXCzudpe4r4xjlBYXUr3kPyx2tTxdj867kw4nIByOBAvZQX68LD1s+e jtylJSxuCYakIoxNcIzNcG/vft18G+hhtlUGva8UVRB6nimjZHS29oaEi/ljCIlbBnH/ JLaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=c6HTzQ0g/d+j2wEZtjSwa+WIQiBPWqT9rTnjyixMU0Y=; fh=UGiw6TrY68HvFoSLLdxDP1QSBpOVKJY++wDKucDTMNc=; b=T7b91cXIaklII5vsKpg9mAnRAD9XXOobuvoN7y1b54EWuX69guCMbP566ArPjeog6p V3RnP3bZjyo+LynogW8ffnhyCUGZwiEW8rY8QsKdIiuVh+XQhHVabgPgVrl/oHglrtVs YO+8pGXPQdiMZ1+XUXGWS6VT/uFteD4HaLz+hfyTA/tGDd/K0nKT98Bjfji3eH+fQApu D/mTv2mSoBoiI2rGP3SJLQ7PWcYgbZOYYVAKjv4D6QcYd3WuzItMvmZXrx+fGEbTmcKh uBkl2Oao/z0cK91n/NmodkMEsTr1RcR8ziRfRQluFUiPwe1p4p+YaIplI7o6xELY1cVo 813A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="PR1N5A/T"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f9-20020a056a001ac900b006cb93f13d52si1338579pfv.120.2023.11.19.17.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 17:08:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="PR1N5A/T"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 564C580968B1; Sun, 19 Nov 2023 17:08:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbjKTBAr (ORCPT + 99 others); Sun, 19 Nov 2023 20:00:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjKTBAr (ORCPT ); Sun, 19 Nov 2023 20:00:47 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D63F0F2; Sun, 19 Nov 2023 17:00:43 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59D89C433C7; Mon, 20 Nov 2023 01:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700442043; bh=qKD5+xB13L+yKxPbKXW2Cb8GqEggWGwNhQxiXp/d6Mg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=PR1N5A/TRYt+FdNBdT/aQljkYnTiuZl8FfAHUL2HtCFdsajLwd7pxreAzZy6E93Hi J+xQ3kEIgG3y5h0iB7E+F9BrmRDW7PvXL1KKvfFso9BTNL/ZKT1rW339I0qG3CN5yi cHGL8UH5UMAvU0M7dL1l6tzZ2sD+1St4yEVMadjo1qCPJThr6gDxYY6dgPYqYW6IPY 0MFOnZXcqC92UPzz7HBkyWi/qPDq6vftiIA7j9AVfnIQr1HYsj2Mqu+mRpSp1oumKH KzwIjqaySyDumhLRiJ3zkpxstwahynpBU7R1PWuA6h1vl8hZRmmimzdfc0zF0kYk9C UrYGRSJKMZ2PQ== Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4083f61322fso12079095e9.1; Sun, 19 Nov 2023 17:00:43 -0800 (PST) X-Gm-Message-State: AOJu0YzBbWooPEfHZU/1LRtZVIkwuA3b3UD8HMF7oGSs9scWMSkt3QYl iK03ZThmbpjQTXHwFcNVeRL6aHoliXYlJsXCklo= X-Received: by 2002:a5d:6105:0:b0:32d:9b32:8a7e with SMTP id v5-20020a5d6105000000b0032d9b328a7emr3191978wrt.71.1700442041805; Sun, 19 Nov 2023 17:00:41 -0800 (PST) MIME-Version: 1.0 References: <20231119215635.52810-1-jiaxun.yang@flygoat.com> In-Reply-To: <20231119215635.52810-1-jiaxun.yang@flygoat.com> From: Huacai Chen Date: Mon, 20 Nov 2023 09:00:34 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] pci: loongson: Workaround MIPS firmware MRRS settings To: Jiaxun Yang Cc: linux-pci@vger.kernel.org, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 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 fry.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 (fry.vger.email [0.0.0.0]); Sun, 19 Nov 2023 17:08:03 -0800 (PST) LGTM, so Acked-by: Huacai Chen On Mon, Nov 20, 2023 at 5:56=E2=80=AFAM Jiaxun Yang wrote: > > This is a partial revert of commit 8b3517f88ff2 ("PCI: > loongson: Prevent LS7A MRRS increases") for MIPS based Loongson. > > There are many MIPS based Loongson systems in wild that > shipped with firmware which does not set maximum MRRS properly. > > 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 MRRS setting > may get lost if the parent bridge lost PCI_COMMAND_MASTER, and > we are only sure parent bridge is enabled at this point. > > Cc: stable@vger.kernel.org > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D217680 > Fixes: 8b3517f88ff2 ("PCI: loongson: Prevent LS7A MRRS increases") > Signed-off-by: Jiaxun Yang > --- > v4: Improve commit message > v5: > - Improve commit message and comments. > - Style fix from Huacai's off-list input. > --- > drivers/pci/controller/pci-loongson.c | 47 ++++++++++++++++++++++++--- > 1 file changed, 42 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controll= er/pci-loongson.c > index d45e7b8dc530..128cc95b236f 100644 > --- a/drivers/pci/controller/pci-loongson.c > +++ b/drivers/pci/controller/pci-loongson.c > @@ -80,13 +80,50 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, > DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, > DEV_LS7A_LPC, system_bus_quirk); > > +/* > + * Some Loongson PCIe ports have h/w limitations of maximum read > + * request size. They can't handle anything larger than this. > + * Sane firmware will set proper MRRS at boot, so we only need > + * no_inc_mrrs for bridges. However, some MIPS Loongson firmware > + * won't set MRRS properly, and we have to enforce maximum safe > + * MRRS, which is 256 bytes. > + */ > +#ifdef CONFIG_MIPS > +static void loongson_set_min_mrrs_quirk(struct pci_dev *pdev) > +{ > + struct pci_bus *bus =3D pdev->bus; > + struct pci_dev *bridge; > + static const struct pci_device_id bridge_devids[] =3D { > + { 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) }, > + { 0, }, > + }; > + > + /* look for the matching bridge */ > + while (!pci_is_root_bus(bus)) { > + bridge =3D bus->self; > + bus =3D bus->parent; > + > + 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_mrrs_quirk_old= ); > +#endif > + > static void loongson_mrrs_quirk(struct pci_dev *pdev) > { > - /* > - * Some Loongson PCIe ports have h/w limitations of maximum read > - * request size. They can't handle anything larger than this. So > - * force this limit on any devices attached under these ports. > - */ > struct pci_host_bridge *bridge =3D pci_find_host_bridge(pdev->bus= ); > > bridge->no_inc_mrrs =3D 1; > -- > 2.34.1 >