Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1468890rdb; Fri, 1 Dec 2023 19:01:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdHkXudb2hWp1HoS5Xqqrg+rB42tMzIhSPl7JqWpD4yAvoUKHbuf+5/NxqK51Ce/Kcef7u X-Received: by 2002:a81:b65f:0:b0:5d3:d439:aabe with SMTP id h31-20020a81b65f000000b005d3d439aabemr606880ywk.26.1701486087030; Fri, 01 Dec 2023 19:01:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701486086; cv=none; d=google.com; s=arc-20160816; b=osD8kE9GkkgNdPHWEv8ufKsT32NdCdc4RwY7LUwS+BBZxt5S8WCjOgGou+6uN5mAW/ ZaH8N1B+PfO6lUc2+srsoa2ExH63hJXrsrcSSZzlxEsJ4sj2AaAoGi//q8LCqKr9/xmH 1ZYsOCZ+j5EZnf+HCnq4TDD7wpHnu/KINxSqJ914hhQhROrYRZ4Hpnv+vhf6ssDMl5mm 6tgYfF54u0lZSVvb3M4l736dsfakdjH9wNCSMmkO56wxIwNU5pLQjpUakuct1hgLs+uw PzaMLXjqBffLHxSJoc+bueEj71cMdRHLUq/HkEbbIg/DzQsWrl5MGsUU2w4pQowz70+J 6MHQ== 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=vXMc0uCNj8JNqVAk1MWivqg6gqqa5U67fSg7kOnblFI=; fh=UGiw6TrY68HvFoSLLdxDP1QSBpOVKJY++wDKucDTMNc=; b=zVJesihDMq+InQLJizduZacAX7qt5na6VnK1fCMrju0PEagZ9KdHcZifQHJEdSdDHL X/+Zu7urfsDT8uY+JlcX9KM7IlD0l6AcoPz3N0EqAqCIqs9o0fsZ5j2XRCeTHeiZBkiZ k1ak5K3whSxf9R9R+bVdt9VRUU2Idlp6sMkvttUdZDewY+Kqki/jtn63ddRYnBlF1d59 JCxT9vlHq0ro8fwhFi3vZvathMd3oFkrLUhMNuyLu7qNHUxvkPJs0rL+ogCxvT3PHtDk d69so1EK1bepAevIE9KdxIv3XY1bum3BQMwpz9G82Ox21vvANXQhX9qhAgwp+9hylZlo 7snw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t7+z2dMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b13-20020a170903228d00b001cfd754d789si4433353plh.137.2023.12.01.19.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 19:01:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t7+z2dMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 8687F837B8B8; Fri, 1 Dec 2023 19:01:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbjLBDBE (ORCPT + 99 others); Fri, 1 Dec 2023 22:01:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjLBDBC (ORCPT ); Fri, 1 Dec 2023 22:01:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B58C299 for ; Fri, 1 Dec 2023 19:01:08 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 139B5C433CB; Sat, 2 Dec 2023 03:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701486068; bh=t27rEY+6maqfIT5T618pr60BoAoj4X+/LJupan5IS9A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=t7+z2dMD//OguANgbHD9kluXtwwk3uYqteeVY8cE6LOvF3jRYcYmb0IepHhduor69 iMw6hRQRbqTCF/WbOyJvRHLy8yd34cuWwxtZz+Q2cjSIv6FEnQCXMa25tn7WeWFz/W SVpjbwzj3bil5K1+ko8ziLkGe7Zea1juauRVejsjtDfS4yhJEkZeU8xkYTh132XmeE pBlBsPeCpxm6fGhklnYIfdHjOvXN0viatnRmpFjVTpEt8PPUGs9BtoV1LjkM4EeiAn PPBIPXJOVpQ9DvB7x3Srk5Eolb0L/whYasTc7Wpm8uN41ALkwK9o+5vnKYzTZ5zBoG IoDWj5iCy+/2A== Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-54b450bd014so3285593a12.3; Fri, 01 Dec 2023 19:01:08 -0800 (PST) X-Gm-Message-State: AOJu0YxvP/bd/ymWh2r1N1COYhfZJrkzCQUlxsWWIcDEr3rxLwInoAZl lkWMCONRLuTTN9PiQ7ge07qotC5H1a1Jmx4GPjU= X-Received: by 2002:a50:cd4c:0:b0:54a:f1db:c290 with SMTP id d12-20020a50cd4c000000b0054af1dbc290mr1741306edj.9.1701486066428; Fri, 01 Dec 2023 19:01:06 -0800 (PST) MIME-Version: 1.0 References: <20231201115028.84351-1-jiaxun.yang@flygoat.com> In-Reply-To: <20231201115028.84351-1-jiaxun.yang@flygoat.com> From: Huacai Chen Date: Sat, 2 Dec 2023 11:01:00 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6] 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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 01 Dec 2023 19:01:24 -0800 (PST) Acked-by: Huacai Chen On Fri, Dec 1, 2023 at 7:50=E2=80=AFPM 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. > 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/controll= er/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 =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_set_min_mrrs_q= uirk); > +#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 >