Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Marc Zyngier <maz@kernel.org>
Cc: Rob Herring <robh@kernel.org>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-pci@vger.kernel.org, Shawn Lin <shawn.lin@rock-chips.com>,
	linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
	Roh Herring <robh+dt@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	kernel-team@android.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT
Date: Sat, 15 Aug 2020 18:22:28 -0500
Message-ID: <20200815232228.GA1325245@bjorn-Precision-5520> (raw)
In-Reply-To: <20200815125112.462652-2-maz@kernel.org>

On Sat, Aug 15, 2020 at 01:51:11PM +0100, Marc Zyngier wrote:
> Recent changes to the DT PCI bus parsing made it mandatory for
> device tree nodes describing a PCI controller to have the
> 'device_type = "pci"' property for the node to be matched.
> 
> Although this follows the letter of the specification, it
> breaks existing device-trees that have been working fine
> for years.  Rockchip rk3399-based systems are a prime example
> of such collateral damage, and have stopped discovering their
> PCI bus.
> 
> In order to paper over the blunder, let's add a workaround
> to the pcie-rockchip driver, adding the missing property when
> none is found at boot time. A warning will hopefully nudge the
> user into updating their DT to a fixed version if they can, but
> the insentive is obviously pretty small.

s/insentive/incentive/ (Lorenzo or I can fix this up)

> Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
> Suggested-by: Roh Herring <robh+dt@kernel.org>

s/Roh/Rob/ (similarly)

> Signed-off-by: Marc Zyngier <maz@kernel.org>

This looks like a candidate for v5.9, since 2f96593ecc37 was merged
during the v5.9 merge window, right?

I wonder how many other DTs are similarly broken?  Maybe Rob's DT
checker has already looked?

> ---
>  drivers/pci/controller/pcie-rockchip-host.c | 29 +++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c
> index 0bb2fb3e8a0b..d7dd04430a99 100644
> --- a/drivers/pci/controller/pcie-rockchip-host.c
> +++ b/drivers/pci/controller/pcie-rockchip-host.c
> @@ -949,6 +949,35 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
>  	if (!dev->of_node)
>  		return -ENODEV;
>  
> +	/*
> +	 * Most rk3399 DTs are missing the 'device_type = "pci"' property,
> +	 * potentially leading to PCIe probing failure. Be kind to the
> +	 * users and fix it up for them. Upgrading is recommended.
> +	 */
> +	if (!of_find_property(dev->of_node, "device_type", NULL)) {
> +		const char dtype[] = "pci";
> +		struct property *prop;
> +
> +		dev_warn(dev, "Working around missing device_type property\n");
> +
> +		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> +		if (!prop)
> +			return -ENOMEM;
> +
> +		prop->name	= kstrdup("device_type", GFP_KERNEL);
> +		prop->value	= kstrdup(dtype, GFP_KERNEL);
> +		prop->length	= ARRAY_SIZE(dtype);
> +		if (!prop->name || !prop->value) {
> +			kfree(prop->name);
> +			kfree(prop->value);
> +			kfree(prop);
> +			return -ENOMEM;
> +		}
> +
> +		if (of_add_property(dev->of_node, prop))
> +			dev_warn(dev, "Failed to add property, probing may fail");
> +	}
> +
>  	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rockchip));
>  	if (!bridge)
>  		return -ENOMEM;
> -- 
> 2.27.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-15 12:51 [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Marc Zyngier
2020-08-15 12:51 ` [PATCH 1/2] PCI: rockchip: Work around missing device_type property in DT Marc Zyngier
2020-08-15 23:22   ` Bjorn Helgaas [this message]
2020-08-16 10:39     ` Marc Zyngier
2020-08-17 16:12       ` Rob Herring
2020-08-18  7:35         ` Marc Zyngier
2020-08-18 14:23           ` Rob Herring
2020-08-18 17:34             ` Marc Zyngier
2020-08-18 17:48               ` Saravana Kannan
2020-08-18 19:02                 ` Marc Zyngier
2020-08-18 19:06                   ` Rob Herring
2020-08-15 12:51 ` [PATCH 2/2] arm64: dts: rockchip: Fix PCIe DT properties Marc Zyngier
2021-01-09 15:39 ` (subset) [PATCH 0/2] PCI: rockchip: Fix PCIe probing in 5.9 Heiko Stuebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200815232228.GA1325245@bjorn-Precision-5520 \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=heiko@sntech.de \
    --cc=kernel-team@android.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=maz@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=shawn.lin@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git