All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Dave Airlie <airlied@linux.ie>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Xinliang Liu <xinliang.liu@linaro.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Tian Tao <tiantao6@hisilicon.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [RFC] drm/connector: Set the default callback function for drm_connector_funcs
Date: Fri, 8 Jan 2021 09:58:24 +0100	[thread overview]
Message-ID: <CAKMK7uG_T6HV_kc1_HiD0yXvUT1iXp-j6g9=PaB0MzcESw13vg@mail.gmail.com> (raw)
In-Reply-To: <d8e3cdca-79dd-2c41-27c1-b09a45670976@suse.de>

On Fri, Jan 8, 2021 at 9:12 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 08.01.21 um 08:54 schrieb Tian Tao:
> > The member functions of drm_connector_funcs are not specific to each
> > manufacturer's driver, so drm_connector_funcs is allowed to use default
> > values, which prevents all drivers from setting the same member
> > functions for drm_connector_funcs.
>
> I don't think that's a good idea.

Yeah this breaks the helper/core separation. We have occasionally move
functionality across that border, but this is the one place where
we're ok with a pile of duplication, since it helps in making sure
that the helper library (like the probe function you want to make the
default here) really stays an optional helper library and doesn't
become some kind of midlayer spaghetti mess.
-Daniel

>
> >
> > Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
> > ---
> >   drivers/gpu/drm/drm_connector.c                  | 7 ++++++-
> >   drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 1 -
> >   include/drm/drm_connector.h                      | 2 +-
> >   3 files changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index 98b6ec4..356d8a3 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -25,6 +25,7 @@
> >   #include <drm/drm_encoder.h>
> >   #include <drm/drm_utils.h>
> >   #include <drm/drm_print.h>
> > +#include <drm/drm_probe_helper.h>
> >   #include <drm/drm_drv.h>
> >   #include <drm/drm_file.h>
> >   #include <drm/drm_sysfs.h>
> > @@ -216,7 +217,7 @@ void drm_connector_free_work_fn(struct work_struct *work)
> >    */
> >   int drm_connector_init(struct drm_device *dev,
> >                      struct drm_connector *connector,
> > -                    const struct drm_connector_funcs *funcs,
> > +                    struct drm_connector_funcs *funcs,
>
> Drivers cannot legally declare the funcs instance as static const.
> Having static const allows for write protected pages.
>
> >                      int connector_type)
> >   {
> >       struct drm_mode_config *config = &dev->mode_config;
> > @@ -228,6 +229,10 @@ int drm_connector_init(struct drm_device *dev,
> >               (!funcs->atomic_destroy_state ||
> >                !funcs->atomic_duplicate_state));
> >
> > +     if (!funcs->fill_modes)
> > +             funcs->fill_modes = &drm_helper_probe_single_connector_modes;
>
> It's not clear that this is really the correct function for this driver.
>
> Best regards
> Thomas
>
> > +
> > +
> >       ret = __drm_mode_object_add(dev, &connector->base,
> >                                   DRM_MODE_OBJECT_CONNECTOR,
> >                                   false, drm_connector_free);
> > diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c
> > index c76f996..7d3b662 100644
> > --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c
> > +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c
> > @@ -64,7 +64,6 @@ static const struct drm_connector_helper_funcs
> >   };
> >
> >   static const struct drm_connector_funcs hibmc_connector_funcs = {
> > -     .fill_modes = drm_helper_probe_single_connector_modes,
> >       .destroy = hibmc_connector_destroy,
> >       .reset = drm_atomic_helper_connector_reset,
> >       .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index 1922b27..4810583 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -1561,7 +1561,7 @@ struct drm_connector {
> >
> >   int drm_connector_init(struct drm_device *dev,
> >                      struct drm_connector *connector,
> > -                    const struct drm_connector_funcs *funcs,
> > +                    struct drm_connector_funcs *funcs,
> >                      int connector_type);
> >   int drm_connector_init_with_ddc(struct drm_device *dev,
> >                               struct drm_connector *connector,
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2021-01-08  8:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08  7:54 [RFC] drm/connector: Set the default callback function for drm_connector_funcs Tian Tao
2021-01-08  8:12 ` Thomas Zimmermann
2021-01-08  8:58   ` Daniel Vetter [this message]
2021-01-08 13:07   ` Jani Nikula
2021-01-08 15:16 ` kernel test robot
2021-01-08 15:17 ` kernel test robot
2021-01-08 23:32 ` kernel test robot

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='CAKMK7uG_T6HV_kc1_HiD0yXvUT1iXp-j6g9=PaB0MzcESw13vg@mail.gmail.com' \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tiantao6@hisilicon.com \
    --cc=tzimmermann@suse.de \
    --cc=xinliang.liu@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.