From: Rob Herring <robh+dt@kernel.org>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Frank Rowand <frowand.list@gmail.com>,
Daniel Vetter <daniel@ffwll.ch>, Helge Deller <deller@gmx.de>,
Sam Ravnborg <sam@ravnborg.org>,
Guenter Roeck <linux@roeck-us.net>,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
devicetree@vger.kernel.org,
Linux Fbdev development list <linux-fbdev@vger.kernel.org>,
dri-devel <dri-devel@lists.freedesktop.org>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH 1/2] of: Create platform devices for OF framebuffers
Date: Wed, 13 Apr 2022 13:53:01 -0500 [thread overview]
Message-ID: <CAL_JsqKGXNJFPe3wt4O8ns1xzopNg4AtWYcZWDbtaP+F22omrw@mail.gmail.com> (raw)
In-Reply-To: <CAL_JsqJdYjd=P4Nhd9E+=OjOb2A-=_txBUtWsDL1FWqZ0phD+g@mail.gmail.com>
eOn Wed, Apr 13, 2022 at 1:46 PM Rob Herring <robh+dt@kernel.org> wrote:
>
> On Wed, Apr 13, 2022 at 12:58 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> >
> > Hi
> >
> > Am 13.04.22 um 14:51 schrieb Rob Herring:
> > > On Wed, Apr 13, 2022 at 4:24 AM Thomas Zimmermann <tzimmermann@suse.de> 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
> > >> prevented real hot-unplugging. Adding a distinct platform device for
> > >> each OF framebuffer solves both problems. Specifically, a DRM drivers
> > >> can now provide graphics output with 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.
> > >>
> > >> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> > >> ---
> > >> drivers/of/platform.c | 73 ++++++++++++++++++++++++++--
> > >> drivers/video/fbdev/offb.c | 98 +++++++++++++++++++++++++-------------
> > >> 2 files changed, 134 insertions(+), 37 deletions(-)
> > >>
> > >> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> > >> index a16b74f32aa9..4c63b9a73587 100644
> > >> --- a/drivers/of/platform.c
> > >> +++ b/drivers/of/platform.c
> > >> @@ -447,6 +447,60 @@ int of_platform_bus_probe(struct device_node *root,
> > >> }
> > >> EXPORT_SYMBOL(of_platform_bus_probe);
> > >>
> > >> +static int __init of_platform_populate_framebuffers(void)
> > >> +{
> > >> + struct device_node *boot_display = NULL;
> > >> + struct device_node *node;
> > >> + struct platform_device *dev;
> > >> + int ret;
> > >> +
> > >> + node = of_get_compatible_child(of_chosen, "simple-framebuffer");
> > >> + of_platform_device_create(node, NULL, NULL);
> > >> + of_node_put(node);
> > >> +
> > >
> > > The rest is PPC only, so bail out here if !PPC.
> > >
> > >> + /* 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;
> > >> + }
> > >> + }
> > >> +
> > >> + /*
> > >> + * 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);
> > >> + }
> > >> +
> > >> + return 0;
> > >> +}
> > >> +
> > >> /**
> > >> * of_platform_populate() - Populate platform_devices from device tree data
> > >> * @root: parent of the first level to probe or NULL for the root of the tree
> > >> @@ -541,9 +595,7 @@ static int __init of_platform_default_populate_init(void)
> > >> of_node_put(node);
> > >> }
> > >>
> > >> - node = of_get_compatible_child(of_chosen, "simple-framebuffer");
> > >> - of_platform_device_create(node, NULL, NULL);
> > >> - of_node_put(node);
> > >> + of_platform_populate_framebuffers();
> > >>
> > >> /* Populate everything else. */
> > >> of_platform_default_populate(NULL, NULL, NULL);
> > >
> > > I'm pretty sure it's just this call that's the problem for PPC though
> > > none of the above existed when adding this caused a regression. Can we
> > > remove the ifdef and just make this call conditional on
> > > !IS_ENABLED(CONFIG_PPC).
> >
> > Together with the changes in of_platform_populate_framebuffers(), the
> > code is more or less an "if-else" depending on PPC. I'll drop
> > of_platform_populate_framebuffers() from the patch and make a separate
> > implementation of of_platform_default_populate_init for PPC. Seems like
> > the easiest solution to me.
>
> That just moves us farther from PPC ever using
> of_platform_default_populate_init(). But I don't know that anyone in
> PPC cares about that, so fine I guess.
Actually, no. Make it work with IS_ENABLED(CONFIG_PPC) rather than an
#ifdef. Currently, I don't have to build this (or any of drivers/of/)
for PPC because it is IS_ENABLED(CONFIG_PPC) everywhere. Yes, there's
an #ifdef already, but there's not an #else and no PPC only code
compiled.
Rob
next prev parent reply other threads:[~2022-04-13 18:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 9:24 [PATCH 0/2] of: Register platform device for each framebuffer Thomas Zimmermann
2022-04-13 9:24 ` [PATCH 1/2] of: Create platform devices for OF framebuffers Thomas Zimmermann
2022-04-13 10:45 ` Javier Martinez Canillas
2022-04-13 10:49 ` Thomas Zimmermann
2022-04-13 12:51 ` Rob Herring
2022-04-13 17:58 ` Thomas Zimmermann
2022-04-13 18:02 ` Javier Martinez Canillas
2022-04-13 18:46 ` Rob Herring
2022-04-13 18:53 ` Rob Herring [this message]
2022-04-18 18:09 ` Thomas Zimmermann
2022-04-13 9:24 ` [PATCH 2/2] fbdev: Remove hot-unplug workaround for framebuffers without device Thomas Zimmermann
2022-04-13 10:50 ` Javier Martinez Canillas
2022-04-13 16:05 ` Daniel Vetter
2022-04-13 18:09 ` Thomas Zimmermann
2022-04-19 7:22 ` 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=CAL_JsqKGXNJFPe3wt4O8ns1xzopNg4AtWYcZWDbtaP+F22omrw@mail.gmail.com \
--to=robh+dt@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=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).