From: Rob Herring <robh@kernel.org>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: frowand.list@gmail.com, daniel@ffwll.ch, deller@gmx.de,
sam@ravnborg.org, linux@roeck-us.net, mpe@ellerman.id.au,
benh@kernel.crashing.org, paulus@samba.org, javierm@redhat.com,
devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org,
dri-devel@lists.freedesktop.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 1/2] of: Create platform devices for OF framebuffers
Date: Tue, 19 Apr 2022 08:30:23 -0500 [thread overview]
Message-ID: <Yl65by+ZjQdK8nIv@robh.at.kernel.org> (raw)
In-Reply-To: <20220419100405.12600-2-tzimmermann@suse.de>
On Tue, Apr 19, 2022 at 12:04:04PM +0200, Thomas Zimmermann wrote:
> Create a platform device for each OF-declared framebuffer and have
> offb bind to these devices. Allows for real hot-unplugging and other
> drivers besides offb.
>
> Originally, offb created framebuffer devices while initializing its
> module by parsing the OF device tree. No actual Linux device was set
> up. This tied OF framebuffers to offb and makes writing other drivers
> for the OF framebuffers complicated. The absence of a Linux device
> further prevented real hot-unplugging. Adding a distinct platform
> device for each OF framebuffer solves both problems. Specifically, a
> DRM driver can now provide graphics output for modern userspace.
>
> Some of the offb init code is now located in the OF initialization.
> There's now also an implementation of of_platform_default_populate_init(),
> which was missing before. The OF side creates different devices for
> either OF display nodes or BootX displays as they require different
> handling by the driver. The offb drivers picks up each type of device
> and runs the appropriate fbdev initialization.
>
> Tested with OF display nodes on qemu's ppc64le target.
>
> v2:
> * run PPC code as part of existing initialization (Rob)
> * add a few more error warnings (Javier)
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> ---
> drivers/of/platform.c | 88 ++++++++++++++++++++++++++--------
> drivers/video/fbdev/offb.c | 98 +++++++++++++++++++++++++-------------
> 2 files changed, 132 insertions(+), 54 deletions(-)
>
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index a16b74f32aa9..738ba2e2838c 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -507,7 +507,6 @@ int of_platform_default_populate(struct device_node *root,
> }
> EXPORT_SYMBOL_GPL(of_platform_default_populate);
>
> -#ifndef CONFIG_PPC
> static const struct of_device_id reserved_mem_matches[] = {
> { .compatible = "qcom,rmtfs-mem" },
> { .compatible = "qcom,cmd-db" },
> @@ -520,33 +519,81 @@ static const struct of_device_id reserved_mem_matches[] = {
>
> static int __init of_platform_default_populate_init(void)
> {
> - struct device_node *node;
> -
As both if/else clauses need 'node', I'd keep this declared here.
> device_links_supplier_sync_state_pause();
>
> if (!of_have_populated_dt())
> return -ENODEV;
>
> - /*
> - * Handle certain compatibles explicitly, since we don't want to create
> - * platform_devices for every node in /reserved-memory with a
> - * "compatible",
> - */
> - for_each_matching_node(node, reserved_mem_matches)
> - of_platform_device_create(node, NULL, NULL);
> + if (IS_ENABLED(CONFIG_PPC)) {
> + struct device_node *boot_display = NULL;
> + struct device_node *node;
> + struct platform_device *dev;
> + int ret;
> +
> + /* Check if we have a MacOS display without a node spec */
> + if (of_get_property(of_chosen, "linux,bootx-noscreen", NULL)) {
> + /*
> + * The old code tried to work out which node was the MacOS
> + * display based on the address. I'm dropping that since the
> + * lack of a node spec only happens with old BootX versions
> + * (users can update) and with this code, they'll still get
> + * a display (just not the palette hacks).
> + */
> + dev = platform_device_alloc("bootx-noscreen", 0);
> + if (WARN_ON(!dev))
> + return -ENOMEM;
> + ret = platform_device_add(dev);
> + if (WARN_ON(ret)) {
> + platform_device_put(dev);
> + return ret;
> + }
> + }
>
> - node = of_find_node_by_path("/firmware");
> - if (node) {
> - of_platform_populate(node, NULL, NULL, NULL);
> - of_node_put(node);
> - }
> + /*
> + * For OF framebuffers, first create the device for the boot display,
> + * then for the other framebuffers. Only fail for the boot display;
> + * ignore errors for the rest.
> + */
> + for_each_node_by_type(node, "display") {
> + if (!of_get_property(node, "linux,opened", NULL) ||
> + !of_get_property(node, "linux,boot-display", NULL))
> + continue;
> + dev = of_platform_device_create(node, "of-display", NULL);
> + if (WARN_ON(!dev))
> + return -ENOMEM;
> + boot_display = node;
> + break;
> + }
> + for_each_node_by_type(node, "display") {
> + if (!of_get_property(node, "linux,opened", NULL) || node == boot_display)
> + continue;
> + of_platform_device_create(node, "of-display", NULL);
> + }
>
> - node = of_get_compatible_child(of_chosen, "simple-framebuffer");
> - of_platform_device_create(node, NULL, NULL);
> - of_node_put(node);
> + } else {
> + struct device_node *node;
> +
> + /*
> + * Handle certain compatibles explicitly, since we don't want to create
> + * platform_devices for every node in /reserved-memory with a
> + * "compatible",
> + */
> + for_each_matching_node(node, reserved_mem_matches)
> + of_platform_device_create(node, NULL, NULL);
>
> - /* Populate everything else. */
> - of_platform_default_populate(NULL, NULL, NULL);
> + node = of_find_node_by_path("/firmware");
> + if (node) {
> + of_platform_populate(node, NULL, NULL, NULL);
> + of_node_put(node);
> + }
> +
> + node = of_get_compatible_child(of_chosen, "simple-framebuffer");
> + of_platform_device_create(node, NULL, NULL);
> + of_node_put(node);
In v1, you supported "simple-framebuffer" on PPC. Don't we want to allow
that? Maybe no one cares ATM, but that could change. Either way:
Reviewed-by: Rob Herring <robh@kernel.org>
> +
> + /* Populate everything else. */
> + of_platform_default_populate(NULL, NULL, NULL);
> + }
>
> return 0;
> }
> @@ -558,7 +605,6 @@ static int __init of_platform_sync_state_init(void)
> return 0;
> }
> late_initcall_sync(of_platform_sync_state_init);
> -#endif
>
> int of_platform_device_destroy(struct device *dev, void *data)
> {
next prev parent reply other threads:[~2022-04-19 13:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-19 10:04 [PATCH v2 0/2] of: Register platform device for each framebuffer Thomas Zimmermann
2022-04-19 10:04 ` [PATCH v2 1/2] of: Create platform devices for OF framebuffers Thomas Zimmermann
2022-04-19 13:30 ` Rob Herring [this message]
2022-04-19 13:41 ` Thomas Zimmermann
2022-04-19 10:04 ` [PATCH v2 2/2] fbdev: Warn in hot-unplug workaround for framebuffers without device Thomas Zimmermann
2022-04-20 7:35 ` Javier Martinez Canillas
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=Yl65by+ZjQdK8nIv@robh.at.kernel.org \
--to=robh@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=daniel@ffwll.ch \
--cc=deller@gmx.de \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=frowand.list@gmail.com \
--cc=javierm@redhat.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=sam@ravnborg.org \
--cc=tzimmermann@suse.de \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).