From: Greg KH <gregkh@linuxfoundation.org>
To: Rob Herring <robh@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
David Airlie <airlied@linux.ie>,
Emil Velikov <emil.l.velikov@gmail.com>,
dri-devel <dri-devel@lists.freedesktop.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Hans de Goede <hdegoede@redhat.com>,
Mark Brown <broonie@kernel.org>,
Gerd Hoffmann <kraxel@redhat.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH 9/9] drm/simplekms: Acquire memory aperture for framebuffer
Date: Tue, 30 Jun 2020 10:50:38 +0200 [thread overview]
Message-ID: <20200630085038.GC637809@kroah.com> (raw)
In-Reply-To: <CAL_JsqJRbF7fe+UXL83kLDd+Tj35d9QHSBtR07D8D=WOuYeCZQ@mail.gmail.com>
On Mon, Jun 29, 2020 at 08:13:51PM -0600, Rob Herring wrote:
> On Mon, Jun 29, 2020 at 10:04 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Jun 29, 2020 at 11:22:30AM +0200, Daniel Vetter wrote:
> > > On Thu, Jun 25, 2020 at 02:00:11PM +0200, Thomas Zimmermann wrote:
> > > > We register the simplekms device with the DRM platform helpers. A
> > > > native driver for the graphics hardware will kickout the simplekms
> > > > driver before taking over the device.
> > > >
> > > > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> > > > ---
> > > > drivers/gpu/drm/tiny/Kconfig | 1 +
> > > > drivers/gpu/drm/tiny/simplekms.c | 94 +++++++++++++++++++++++++++++++-
> > > > 2 files changed, 92 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> > > > index 50dbde8bdcb2..a47ed337a7fe 100644
> > > > --- a/drivers/gpu/drm/tiny/Kconfig
> > > > +++ b/drivers/gpu/drm/tiny/Kconfig
> > > > @@ -33,6 +33,7 @@ config DRM_SIMPLEKMS
> > > > depends on DRM
> > > > select DRM_GEM_SHMEM_HELPER
> > > > select DRM_KMS_HELPER
> > > > + select DRM_PLATFORM_HELPER
> > > > help
> > > > DRM driver for simple platform-provided framebuffers.
> > > >
> > > > diff --git a/drivers/gpu/drm/tiny/simplekms.c b/drivers/gpu/drm/tiny/simplekms.c
> > > > index ae5d3cbadbe8..a903a4e0100a 100644
> > > > --- a/drivers/gpu/drm/tiny/simplekms.c
> > > > +++ b/drivers/gpu/drm/tiny/simplekms.c
> > > > @@ -5,6 +5,7 @@
> > > > #include <linux/platform_data/simplefb.h>
> > > > #include <linux/platform_device.h>
> > > > #include <linux/regulator/consumer.h>
> > > > +#include <linux/spinlock.h>
> > > >
> > > > #include <drm/drm_atomic_state_helper.h>
> > > > #include <drm/drm_connector.h>
> > > > @@ -17,6 +18,7 @@
> > > > #include <drm/drm_gem_shmem_helper.h>
> > > > #include <drm/drm_managed.h>
> > > > #include <drm/drm_modeset_helper_vtables.h>
> > > > +#include <drm/drm_platform.h>
> > > > #include <drm/drm_probe_helper.h>
> > > > #include <drm/drm_simple_kms_helper.h>
> > > >
> > > > @@ -36,6 +38,12 @@
> > > > #define SIMPLEKMS_MODE(hd, vd) \
> > > > DRM_SIMPLE_MODE(hd, vd, RES_MM(hd), RES_MM(vd))
> > > >
> > > > +/*
> > > > + * Protects the platform device's drvdata against
> > > > + * concurrent manipulation.
> > > > + */
> > > > +static DEFINE_SPINLOCK(simplekms_drvdata_lock);
> > > > +
> > > > /*
> > > > * Helpers for simplefb
> > > > */
> > > > @@ -211,6 +219,7 @@ struct simplekms_device {
> > > > unsigned int pitch;
> > > >
> > > > /* memory management */
> > > > + struct drm_aperture *aperture;
> > > > struct resource *mem;
> > > > void __iomem *screen_base;
> > > >
> > > > @@ -224,6 +233,8 @@ static struct simplekms_device *simplekms_device_of_dev(struct drm_device *dev)
> > > > return container_of(dev, struct simplekms_device, dev);
> > > > }
> > > >
> > > > +static void simplekms_device_cleanup(struct simplekms_device *sdev);
> > > > +
> > > > /*
> > > > * Hardware
> > > > */
> > > > @@ -514,22 +525,72 @@ static int simplekms_device_init_fb(struct simplekms_device *sdev)
> > > > * Memory management
> > > > */
> > > >
> > > > +static void simplekms_aperture_kickout(struct drm_aperture *ap)
> > > > +{
> > > > + struct drm_device *dev = ap->dev;
> > > > + struct simplekms_device *sdev = simplekms_device_of_dev(dev);
> > > > + struct platform_device *pdev = sdev->pdev;
> > > > +
> > > > + if (WARN_ON(!sdev->aperture))
> > > > + return; /* BUG: driver already got kicked out */
> > > > +
> > > > + drm_dev_unregister(dev);
> > >
> > > >From a semantic pov I think the platform driver getting kicked out is more
> > > like a hotunplug, so drm_dev_unplug(dev); here is imo better.
> > >
> > > That then also gives you a nice drm_dev_enter/exit to sprinkle over the
> > > various driver callbacks, instead of the racy ->aperture check reinvented
> > > wheel here.
> > >
> > > I also wonder whether we couldn't go full driver model for these platform
> > > devices, and instead of this here call a core driver model function to
> > > force the unbding of the driver. Only change we'd need it that our
> > > ->remove hook uses drm_dev_unplug().
> >
> > Yes, please do that. Or, use the "virtual bus/device" code that some
> > people at Intel are still trying to get into mergable shape. See the
> > posts on the netdev list for those details.
> >
> > Don't use platform devices for anything that is not actually a platform
> > device (i.e. something described by hardware resources).
>
> Well, 'simple-framebuffer' is described by DT and includes h/w
> resources such as clocks. So this is a gray area. I'm not saying we
> couldn't use virtual bus for DT nodes, but we'll need some clear
> guidelines of when to use virtual vs. platform devices. No doubt I'll
> get a 'virtual bus' binding if folks are directed to make things a
> virtual device.
If it is described by DT, then I have no objection for it to be a
platform device.
thanks,
greg k-h
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-06-30 8:50 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 12:00 [RFC][PATCH 0/9] drm: Support simple-framebuffer devices and firmware fbs Thomas Zimmermann
2020-06-25 12:00 ` [PATCH 1/9] drm/format-helper: Pass destination pitch to drm_fb_memcpy_dstclip() Thomas Zimmermann
2020-06-29 8:40 ` Daniel Vetter
2020-09-25 14:55 ` Thomas Zimmermann
2020-09-26 16:42 ` Daniel Vetter
2020-09-28 7:22 ` Thomas Zimmermann
2020-09-28 8:53 ` Daniel Vetter
2020-09-28 9:13 ` Thomas Zimmermann
2020-09-29 9:19 ` Daniel Vetter
2020-09-29 9:39 ` Thomas Zimmermann
2020-09-29 11:32 ` Daniel Vetter
2020-09-28 10:24 ` Gerd Hoffmann
2020-09-28 13:42 ` Pekka Paalanen
2020-06-25 12:00 ` [PATCH 2/9] drm/format-helper: Add blitter functions Thomas Zimmermann
2020-06-29 8:46 ` Daniel Vetter
2020-06-25 12:00 ` [PATCH 3/9] drm: Add simplekms driver Thomas Zimmermann
2020-06-29 9:06 ` Daniel Vetter
2020-09-25 15:01 ` Thomas Zimmermann
2020-09-25 15:14 ` Maxime Ripard
2020-09-28 7:25 ` Thomas Zimmermann
2021-02-10 16:14 ` Thomas Zimmermann
2020-06-25 12:00 ` [PATCH 4/9] drm/simplekms: Add fbdev emulation Thomas Zimmermann
2020-06-29 9:11 ` Daniel Vetter
2020-06-25 12:00 ` [PATCH 5/9] drm/simplekms: Initialize framebuffer data from device-tree node Thomas Zimmermann
2020-06-30 2:36 ` Rob Herring
2020-06-25 12:00 ` [PATCH 6/9] drm/simplekms: Acquire clocks from DT device node Thomas Zimmermann
2020-06-25 13:34 ` Geert Uytterhoeven
2020-06-29 9:07 ` Daniel Vetter
2020-06-25 12:00 ` [PATCH 7/9] drm/simplekms: Acquire regulators " Thomas Zimmermann
2020-06-25 13:36 ` Geert Uytterhoeven
2020-06-25 12:00 ` [PATCH 8/9] drm: Add infrastructure for platform devices Thomas Zimmermann
2020-06-29 9:27 ` Daniel Vetter
2020-09-28 8:40 ` Thomas Zimmermann
2020-09-28 8:50 ` Daniel Vetter
2020-09-28 9:14 ` Thomas Zimmermann
2020-09-29 8:59 ` Thomas Zimmermann
2020-09-29 9:20 ` Daniel Vetter
2020-06-30 9:11 ` Daniel Vetter
2020-06-25 12:00 ` [PATCH 9/9] drm/simplekms: Acquire memory aperture for framebuffer Thomas Zimmermann
2020-06-29 9:22 ` Daniel Vetter
2020-06-29 16:04 ` Greg KH
2020-06-29 16:23 ` Mark Brown
2020-06-29 16:57 ` Greg KH
2020-06-30 2:13 ` Rob Herring
2020-06-30 8:50 ` Greg KH [this message]
2020-06-29 9:38 ` [RFC][PATCH 0/9] drm: Support simple-framebuffer devices and firmware fbs Hans de Goede
2020-06-30 9:06 ` Daniel Vetter
2020-06-30 9:13 ` Hans de Goede
2020-07-01 14:10 ` Thomas Zimmermann
2020-07-03 10:55 ` Hans de Goede
2020-07-03 11:42 ` Thomas Zimmermann
2020-07-03 12:58 ` Daniel Vetter
2020-07-03 14:11 ` Hans de Goede
2020-07-01 13:48 ` Thomas Zimmermann
2020-07-03 10:44 ` Hans de Goede
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=20200630085038.GC637809@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=airlied@linux.ie \
--cc=broonie@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=geert+renesas@glider.be \
--cc=hdegoede@redhat.com \
--cc=kraxel@redhat.com \
--cc=lgirdwood@gmail.com \
--cc=robh@kernel.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).