From patchwork Thu Nov 3 09:00:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Peibao X-Patchwork-Id: 14766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp404110wru; Thu, 3 Nov 2022 02:03:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56TcTzltIRd8K1uKVr88HDCcqvm2KSsY/WVJBFE4bWTHs/NDIlN33Cp3HOl+hOw1iodDQw X-Received: by 2002:a05:6402:1d4a:b0:461:d375:7927 with SMTP id dz10-20020a0564021d4a00b00461d3757927mr29605149edb.18.1667466212316; Thu, 03 Nov 2022 02:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667466212; cv=none; d=google.com; s=arc-20160816; b=pKXhOPW74mQVuQLoaESxGJ+vlsybb8sk8eOEIo5fzHHhXZznb2GKvHeiedd4UfQkHa /hS+SaFokYMG3eDel6iQr1LyAiRvNQA6oskuIUwYcmRK6kpQaXBOjuS3ADiZfUA56Mxe dcfwg1OGq+kBj2ZHKPUZI4ry5VFJtYjpqgagoTcCOc7a95i0T2QqNobNBgoP/K+JEfIB xi3LNsu7upb6OXanpGK5q6xuvi2gfoEDdcN6LJ5aAgYOU5fzQIQxIN+IUq5UmICdNqTG lx+gfnD3Lr1vkU+dHnxatoj8pIfAegWCi4BrjHgq6l0pJ1YhB2KCO1qWLpikPN8cJdL8 g11g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Rut/52ZQF6Z/WNoUNGqEa7rCuEqpo9Erc3G1/lQGnX0=; b=QdElIlZ2Z2iOXuETwd+Drp5nuKC+EzBH2P82ZE8QeHXUh3mlCf/2A7gaCxrdfHsLcC KclMdsoIN9qxh7KFs00J1GJsMye6HaHXOK6e1KI3hDruKIZ94BpHUk2Do0vWV5HIkmVC EQuYlMzyP9Axl4tU7bZpXpSLX6BtsdnHOFJVDarFm65csHlRee7LsHGBxRj2Ze5Jg95m +GfFAommCQhcUpZuUDerWUY+fww7x5l6kgOZEXb1YyzlJqhDXo2iMNXSobxV3yar1SWL oH58Jb+1YgN4g4PdOoUU85oCdQCt3EAU7hWwMvL8mR6G68cD7wrAoQe+TXdlhAzGf+NG g6uw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm15-20020a170907948f00b00783d5a873dcsi671380ejc.341.2022.11.03.02.03.08; Thu, 03 Nov 2022 02:03:32 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231428AbiKCJAy (ORCPT + 99 others); Thu, 3 Nov 2022 05:00:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230376AbiKCJAs (ORCPT ); Thu, 3 Nov 2022 05:00:48 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FF1C5F66; Thu, 3 Nov 2022 02:00:46 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.77]) by gateway (Coremail) with SMTP id _____8Axjrc9g2Nj3zAEAA--.9608S3; Thu, 03 Nov 2022 17:00:45 +0800 (CST) Received: from loongson-PC.loongson.cn (unknown [10.20.42.77]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxoOI4g2NjSJMLAA--.33260S2; Thu, 03 Nov 2022 17:00:44 +0800 (CST) From: Liu Peibao To: Bjorn Helgaas , Rob Herring , Krzysztof Kozlowski , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Jiaxun Yang Cc: chenhuacai@loongson.cn, lvjianmin@loongson.cn, zhuyinbo@loongson.cn, liupeibao@loongson.cn, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] PCI: loongson: add skip-scan property for child DT node Date: Thu, 3 Nov 2022 17:00:39 +0800 Message-Id: <20221103090040.836-1-liupeibao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxoOI4g2NjSJMLAA--.33260S2 X-CM-SenderInfo: xolx1vpled0qxorr0wxvrqhubq/1tbiAQATCmNiXeMWTAADs+ X-Coremail-Antispam: 1Uk129KBjvJXoWxZF15JFW7Zr1xtw48tFyxZrb_yoW5ZryxpF W5Aay3Kr48Kr1IgwnYq3yUCr1a9an7Z3s3JFZ7C3sFgr9Iv340gry8JF1Yy3ySkrW8WF4a qryqgr48CF4UAF7anT9S1TB71UUUUjUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bfAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAa w2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44 I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2 jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY1x0262 kKe7AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km 07C267AKxVWUXVWUAwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r 1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWU JVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r 1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUv cSsGvfC2KfnxnUUI43ZEXa7IU8HKZJUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748465051051951237?= X-GMAIL-MSGID: =?utf-8?q?1748465051051951237?= The PCI Controller of 2k1000 could not mask devices by setting vender id & device id in configuration space header as invalid values. When there are pins shareble between the platform device and PCI device, if the platform device is preferred, we should not scan this PCI device. In the above scene, add "skip-scan" property in DT node of this PCI device. Signed-off-by: Liu Peibao --- drivers/pci/controller/pci-loongson.c | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c index 05c50408f13b..4b97963977c7 100644 --- a/drivers/pci/controller/pci-loongson.c +++ b/drivers/pci/controller/pci-loongson.c @@ -40,11 +40,21 @@ struct loongson_pci_data { struct pci_ops *ops; }; +#ifdef CONFIG_OF +struct mask_entry { + struct list_head entry; + unsigned int devfn; +}; +#endif + struct loongson_pci { void __iomem *cfg0_base; void __iomem *cfg1_base; struct platform_device *pdev; const struct loongson_pci_data *data; +#ifdef CONFIG_OF + struct list_head masklist; +#endif }; /* Fixup wrong class code in PCIe bridges */ @@ -194,6 +204,20 @@ static void __iomem *pci_loongson_map_bus(struct pci_bus *bus, return NULL; } +#ifdef CONFIG_OF + /* Don't access devices in masklist */ + if (pci_is_root_bus(bus)) { + struct list_head *list; + struct mask_entry *entry; + + list_for_each(list, &priv->masklist) { + entry = list_entry(list, struct mask_entry, entry); + if (devfn == entry->devfn) + return NULL; + } + } +#endif + /* CFG0 can only access standard space */ if (where < PCI_CFG_SPACE_SIZE && priv->cfg0_base) return cfg0_map(priv, bus, devfn, where); @@ -206,6 +230,41 @@ static void __iomem *pci_loongson_map_bus(struct pci_bus *bus, } #ifdef CONFIG_OF +/* + * The PCI Controller of 2k1000 could not mask devices by + * setting vender id & device id in configuration space + * header as invalid values. When there are pins shareble + * between the platform device and PCI device, if the + * platform device is preferred, we should not scan this + * PCI device. In the above scene, add "skip-scan" property + * in the device tree node of this PCI device. + */ +static int setup_masklist(struct loongson_pci *priv) +{ + struct device *dev = &priv->pdev->dev; + struct device_node *dn, *parent = dev->of_node; + struct mask_entry *entry; + int devfn; + + INIT_LIST_HEAD(&priv->masklist); + + for_each_child_of_node(parent, dn) { + if (of_property_read_bool(dn, "skip-scan")) { + devfn = of_pci_get_devfn(dn); + if (devfn < 0) + continue; + + entry = devm_kzalloc(dev, sizeof(entry), GFP_KERNEL); + if (!entry) + return -ENOMEM; + + entry->devfn = devfn; + list_add_tail(&entry->entry, &priv->masklist); + } + } + + return 0; +} static int loongson_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { @@ -305,6 +364,9 @@ static int loongson_pci_probe(struct platform_device *pdev) } } + if (setup_masklist(priv)) + return -ENOMEM; + bridge->sysdata = priv; bridge->ops = priv->data->ops; bridge->map_irq = loongson_map_irq; From patchwork Thu Nov 3 09:00:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Peibao X-Patchwork-Id: 14765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp403659wru; Thu, 3 Nov 2022 02:02:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6UHu3Fqg1ax9tSJSbfYJYmQmQS+gBLsuZr4Z0rCrAJW8ToeYUX/DdXrC1U2YXuIdGc2249 X-Received: by 2002:a05:6402:31f4:b0:461:604d:2607 with SMTP id dy20-20020a05640231f400b00461604d2607mr29792225edb.330.1667466157769; Thu, 03 Nov 2022 02:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667466157; cv=none; d=google.com; s=arc-20160816; b=x1KfYSrzoepQC6WpTUO3NYQVyCjg40P/mZi8UIbrGZpQrpg56xcmMDhuSBbaVdRHna dsxfTj0Vb1SHYaArYsCuZADW09Hi0liEIXpzamESHHdV22zb/qXJBOWH9VA1euhpOMdl 9KR246p+xJ8gVwJYH2i0rHjZwNf35TTxeNjpTiaIGU3iEPlqnMq9vrgN5RZk5OKWcoqh ePUiBPHimOcl3FVtQEjXermXKpHsyPsHvuKsfh3+tEBlygFl7fGCMo3vyKlZu93AtI15 /JDRbUOXbNid/BdKEIYW2SW+dyBoZJXAABjHRI4DWx2KoFQJRJza1Qrzs74EpIgUoK6e etLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=r59tEPX2N87T2tkA5rtb9LKVlJeQhfVRrRTjwU2cuQ0=; b=qD+JbBsBsuIUpzsDqvyUVHMHza8OeWzLLiSXvARL3Mligg/p8qqCWPmxhwgwLXRXhP xT5tdKbiL3zpkTVEmcUE3xgal9zg0XUEyOIkvJjZOIzYuqajbNpnk6gJNpXAS6rNe4CF eHgiH599u9nc/x6aIRbPnCqZ9YeasKekTqJf+DQbszf8r7Xe4Z4sqgCg+BH1VZsyquqt vz4vQjFdPSuFW0ZW+TgVqmLni1prn8DGDYQOZCeviebYX2unWUAhQlH1OsGeY6dMcQr2 /+FYCLwe6sxHVHUZ+HOo9Z2RhnMficEmbjAwtJdT6UHoON5RqC82DqW/rl8PYpTP1Cmj nMpg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a056402090b00b0045928479b71si679589edz.405.2022.11.03.02.02.11; Thu, 03 Nov 2022 02:02:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231372AbiKCJAt (ORCPT + 99 others); Thu, 3 Nov 2022 05:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbiKCJAs (ORCPT ); Thu, 3 Nov 2022 05:00:48 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FC0B5583; Thu, 3 Nov 2022 02:00:46 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.77]) by gateway (Coremail) with SMTP id _____8DxPLc9g2Nj5TAEAA--.2861S3; Thu, 03 Nov 2022 17:00:45 +0800 (CST) Received: from loongson-PC.loongson.cn (unknown [10.20.42.77]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxoOI4g2NjSJMLAA--.33260S3; Thu, 03 Nov 2022 17:00:45 +0800 (CST) From: Liu Peibao To: Bjorn Helgaas , Rob Herring , Krzysztof Kozlowski , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Jiaxun Yang Cc: chenhuacai@loongson.cn, lvjianmin@loongson.cn, zhuyinbo@loongson.cn, liupeibao@loongson.cn, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] dt-bindings: PCI: loongson: Add skip-scan property for child node Date: Thu, 3 Nov 2022 17:00:40 +0800 Message-Id: <20221103090040.836-2-liupeibao@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221103090040.836-1-liupeibao@loongson.cn> References: <20221103090040.836-1-liupeibao@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxoOI4g2NjSJMLAA--.33260S3 X-CM-SenderInfo: xolx1vpled0qxorr0wxvrqhubq/1tbiAQATCmNiXeMWaAAAsZ X-Coremail-Antispam: 1Uk129KBjvdXoWrZr1fJw48Xw1fKr1DZw17trb_yoW3XrbE9a 4xAFn5CFs8JF1Fgws0vr48tF15Z3yI93WkuFn5JF1kCa4IvrZ8KF97A3s8CF47Cr4UuF15 u397GrWDAFsrGjkaLaAFLSUrUUUU0b8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY A7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3w AFIxvE14AKwVWUAVWUZwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK 6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j6F4UM28EF7 xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2kK e7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI 0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280 aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkF7I0En4 kS14v26r126r1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI 1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_Jr Wlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j 6ryUMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr 0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUv cSsGvfC2KfnxnUUI43ZEXa7IU8Gii3UUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748464993695545066?= X-GMAIL-MSGID: =?utf-8?q?1748464993695545066?= Add the newly added "skip-scan" property for child node. Signed-off-by: Liu Peibao --- Documentation/devicetree/bindings/pci/loongson.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/loongson.yaml b/Documentation/devicetree/bindings/pci/loongson.yaml index a8324a9bd002..5c2fe9bf2c78 100644 --- a/Documentation/devicetree/bindings/pci/loongson.yaml +++ b/Documentation/devicetree/bindings/pci/loongson.yaml @@ -32,6 +32,13 @@ properties: minItems: 1 maxItems: 3 + child-node: + type: object + properties: + skip-scan: + description: avoid scanning this device. + type: boolean + required: - compatible