Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2118373rwb; Sun, 6 Aug 2023 10:09:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn0cs1o5uNLtpwgwz5R8wjl3GIp+qtIO7t1FLbOjhEXbOO728iNb4XbiRp0aPcZHFUOAiz X-Received: by 2002:a17:90a:1b0f:b0:263:6a7e:c239 with SMTP id q15-20020a17090a1b0f00b002636a7ec239mr5696524pjq.37.1691341764447; Sun, 06 Aug 2023 10:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691341764; cv=none; d=google.com; s=arc-20160816; b=Y3SWhrZASpn1+Y8LciiWWVEktAWnpiKGkyigERcV8QxfHfectI5sQ4hvgUl/bo9M9T vXTkt7CitN8YIEMM/kG3TKx05+dX5yXGljnt4N7rdduJnW2sw220bMR2oP8TfPFFtZve KQANkTwQ0uYhDlI+PZzkSq/dth0cLPhP2LTDxIdl+I/hyKb4bmHkgNB+XPWV6tBFxsbW pZEbHvyozgGcvsVU/6cRDkJGxny+rB1WE0dkkAT4ctK/7JA8pggO7DFJnewkDENqJ5rj 6DGp4WIARgBbbu264IO/t6GPK7jMC3dTO5XnxD/ie6YD38XIhdqcGsGt+aka4FPCkD5T py3Q== 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=/uKRW5RFNiTovT2wScs6RYfj6dKUWfTfYtmXPRpqZlc=; fh=4YqM302I8q1bHhVvATpyiRXVzZUyL9YwFph8WwGrHBc=; b=vS7gwkkE0ERvbXdf1UFOFvV2eGwXVDXw2NlipVRYAGFCyLkbawelZzFY6PVmkR70OZ XK8Urt1knAKVnUUG7zLxyVrYMTHKgWl3cVK7Tpk4p4m2PTlT0e89IMe2rIdHyW2jklJI AG8QW9B+W1gtwLZ/IwtrNCIx6ghiGE8ffY3YFhmGUiiCe9GtTMkyVwA2q8uUVpZr2e8U gay4DP6CzSpPGA/LCLFlNItsd63CEP5+eQp90hcAgiUpl1NJAN9RkL3mWK2pJUeq3FYq w8THFNde1sVcJfnALa8qt3YCN9YjzJrrUOjqkpcJgcC2iDm5mflFfGJxcA2iufSvP/J4 EaZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YTU8MC0+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a17090a4f0400b0026343b62cdasi4598199pjh.154.2023.08.06.10.09.12; Sun, 06 Aug 2023 10:09:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YTU8MC0+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230387AbjHFObC (ORCPT + 99 others); Sun, 6 Aug 2023 10:31:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjHFObB (ORCPT ); Sun, 6 Aug 2023 10:31:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC3AE49; Sun, 6 Aug 2023 07:30:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6087761058; Sun, 6 Aug 2023 14:30:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2137C433CA; Sun, 6 Aug 2023 14:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691332258; bh=JrZfNdw9wgAZfBMUuRYMyGJexeF+fKE8GZDmCA/BpeI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YTU8MC0+gH8TfbrhCBbJqavhqTyGGPF5Aj0sHrJy2mtO7ljXuMzZf24h7rzwkyUFx 1wef7z7KMC8U+vBOUBfugecKv0/UDYWO4DUMbrrcB9K10vJdsmA3o17DlUsNRnUYWX x0nR97kCUgpt236K1p6/yaQ4y2dEZksHu1+iD0d+muqLDVhNVzlE4TsnzSCzWHQPTX rBzFwzVi9siE+/ch+JgCHLJl6TcBxEb7mTfEdX5+spqRianM65dTpfwLlK3O4Oldx1 MEGPe3CngMeknvMdwpLV4oqEnz0zezluRumRkkxO6Y5Xwzy7oaObB70Ft911L0BEvR YU4yQzAQ6eUoQ== Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-52229f084beso5324284a12.2; Sun, 06 Aug 2023 07:30:58 -0700 (PDT) X-Gm-Message-State: AOJu0YxjPvNp2XUp7Fx4Rl3w2zu3W0B3TwdpN45LvYrv69zetn5Gsviv YpmJuvCMeiibexJ99kluAutEBB2R5c6vc/CCA3w= X-Received: by 2002:aa7:de96:0:b0:522:2aee:682c with SMTP id j22-20020aa7de96000000b005222aee682cmr5517074edv.2.1691332256931; Sun, 06 Aug 2023 07:30:56 -0700 (PDT) MIME-Version: 1.0 References: <20230725061008.1504292-1-jiaxun.yang@flygoat.com> In-Reply-To: From: Huacai Chen Date: Sun, 6 Aug 2023 22:30:45 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] pci: loongson: Workaround MIPS firmware MRRS settings To: Jiaxun Yang Cc: linux-pci@vger.kernel.org, bhelgaas@google.com, linux-kernel@vger.kernel.org, kw@linux.com, lpieralisi@kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Jiaxun, On Sun, Aug 6, 2023 at 10:20=E2=80=AFAM Jiaxun Yang wrote: > > > > =E5=9C=A8 2023/7/25 14:10, Jiaxun Yang =E5=86=99=E9=81=93: > > 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. > > > > 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 > > Ping? > I expect this patch to go through PCI fixes tree. Can we do it like this by modifying the existing loongson_mrrs_quirk()? 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); #ifdef CONFIG_MIPS set_pcie_ports_to_mrrs_256_to_emulate_the_firmware_behavior(); #endif bridge->no_inc_mrrs =3D 1; } > > Thanks > - Jiaxun > > > --- > > v2: Rename quirk name to: loongson_old_mrrs_quirk > > --- > > drivers/pci/controller/pci-loongson.c | 38 ++++++++++++++++++++++++++= + > > 1 file changed, 38 insertions(+) > > > > diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/contro= ller/pci-loongson.c > > index fe0f732f6e43..d0f68b102d10 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 =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; > > + /* > > + * There are still some wild MIPS Loongson firmware won't > > + * set MRRS properly. Limiting MRRS to 256 as MIPS Loongs= on > > + * 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_qui= rk); > > +#endif > > + > > static void loongson_pci_pin_quirk(struct pci_dev *pdev) > > { > > pdev->pin =3D 1 + (PCI_FUNC(pdev->devfn) & 3); >