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: 13029738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 680F6C433FE for ; Thu, 3 Nov 2022 09:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbiKCJAt (ORCPT ); Thu, 3 Nov 2022 05:00:49 -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== Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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: 13029737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F18AC43217 for ; Thu, 3 Nov 2022 09:00:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231351AbiKCJAt (ORCPT ); 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== Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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