Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2464103rdb; Fri, 8 Dec 2023 08:51:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFf6qqlmnYpBZMtS6+smCVnREbkFAeHJWDLQ3rf/BcgZ2DsRv0gSxM/37mZxJfKyKTgw+0K X-Received: by 2002:a05:6a00:852:b0:6ce:2757:7865 with SMTP id q18-20020a056a00085200b006ce27577865mr1534946pfk.32.1702054275429; Fri, 08 Dec 2023 08:51:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702054275; cv=none; d=google.com; s=arc-20160816; b=ycjnw4tV6drvQLTv/o1fYjoZKLvwiXiBbS4AgN50iUXfxlXHm5edxCu+S9PGyXGaPX 1/N3a21At77i8xN92cH2aoCHf8B6nyedRdpiVi7tcwjk2tuVXs3v1tcBPbbU+rUPU5ES YtIAnQx2D78PaKbtFo2f9I52FXQATvAKif5XY+woK+XnvRdJXWUxuuO+QMkej14XVtvf 65EvV+HuJlr3jbY0AfYAS1dcDSAFMI14phn2EEy3ssweeTANyGvngecP/IxwiZoKaxIC WuwqK9t5Zsm1gICLAtjbk4XuYssZkElUYLKPcbDBi6Xa50CZ9sUyOMOzLuYBNcm6txiK Zq8Q== 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=Dp/gRztWF2uJblVMlq3mWz7QUHjGBPA8qIA67bjrt4s=; fh=EZbhsDocixSE0vFLzL7rkHlZ15ixcHpabCuzDszWgDY=; b=nuJ46vbDjb2tcZzPYE6r6qCLsmg1dW1gQLBxcurzTrgdMiM3tOMJ9BOdyfJg4DjhHP 8/TXdSiLUWteRGDSb0bVGJCgw5wJyCrmp7KsOtgRs3h7+vU+yJTSkzGmbAymB3LK0IxN e1pAAn3F5yBMku4zP5RxY5r3iHlSjOxCzjb3hLNTPFiEcZubgdmSZGKakgJ+eCVOWHVm yvHfh+Fq9S1Kq/igpgviD7QDOjWO2xltvMgJEXE9Igfgw2cbnvdk5JpwiBBU6Whp4LBx g4bJBGkRLJYmgTIhA4W8bKlx0wi6Hh3ueYihNgzwZbitFRcQFwusm49EfZ7LSqI1Jmn7 Vq8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BOCmgHjq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id n190-20020a6327c7000000b00589fcc39ef1si1819652pgn.365.2023.12.08.08.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:51:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BOCmgHjq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id C9D0680BD4ED; Fri, 8 Dec 2023 08:51:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233732AbjLHQut (ORCPT + 99 others); Fri, 8 Dec 2023 11:50:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235900AbjLHQui (ORCPT ); Fri, 8 Dec 2023 11:50:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D2B19A3 for ; Fri, 8 Dec 2023 08:50:41 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D4EDC433C8; Fri, 8 Dec 2023 16:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702054241; bh=wlUXwlsUbGMtEcjVD5Tfu+HjZX3PCSQZUuI9/7Iqr1U=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=BOCmgHjq9geZadOhgdjEmm/gLlEoc7P8m9wwz3PAXNl9ACl2u+7Msp41vwIdzW/Nv Mp6bOHVRDwVUScivRBMmlqKtLxsgkodvUR7cfXuKgspRMz++vreENJjgqU15gGaEVa TKcjvej3ywn56kfq4LrzQj+LF3/bDdO01eoyqWvPK1V41Cb8L29EPOpKqMtx4mVi/2 v1hWbPq7+8ztBoS70I8XQlBL7DG1QTbhXfTFd73MY4ZL4RTsFCrnyAXBYvRWlm2Y7D e87GXnpOAEdOreASny4i5cq9BillFMiY8J/ZYPpufp8Rsb1pO1R7LYM8PF/QSv82WP DKIRZ4R4bEzlw== Date: Fri, 8 Dec 2023 10:50:39 -0600 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 v6] pci: loongson: Workaround MIPS firmware MRRS settings Message-ID: <20231208165039.GA796094@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231201115028.84351-1-jiaxun.yang@flygoat.com> 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 howler.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 (howler.vger.email [0.0.0.0]); Fri, 08 Dec 2023 08:51:11 -0800 (PST) On Fri, Dec 01, 2023 at 11:50:28AM +0000, 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=217680 > Fixes: 8b3517f88ff2 ("PCI: loongson: Prevent LS7A MRRS increases") > Signed-off-by: Jiaxun Yang Applied to for-linus for v6.7, thanks! > --- > v4: Improve commit message > v5: > - Improve commit message and comments. > - Style fix from Huacai's off-list input. > v6: Fix a typo > --- > 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/controller/pci-loongson.c > index d45e7b8dc530..e181d99decf1 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 = 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) }, > + { 0, }, > + }; > + > + /* look for the matching bridge */ > + while (!pci_is_root_bus(bus)) { > + bridge = bus->self; > + bus = 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_set_min_mrrs_quirk); > +#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 = pci_find_host_bridge(pdev->bus); > > bridge->no_inc_mrrs = 1; > -- > 2.34.1 >