All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Dave Airlie <airlied@redhat.com>
Subject: Re: [PATCH v2 4/5] drm/ast: Fail probing if DCC channel could not be initialized
Date: Thu, 2 Jun 2022 12:34:26 +0200	[thread overview]
Message-ID: <CAMeQTsZVJ=8g6SUrc7Hadq60LJ8=fBOB3yUmC2b8iN3-cFkdQA@mail.gmail.com> (raw)
In-Reply-To: <78f8bd77-3dca-9cc6-b8e4-49d811d9dd47@suse.de>

On Thu, Jun 2, 2022 at 11:32 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi Patrik
>
> Am 02.06.22 um 09:42 schrieb Patrik Jakobsson:
> > On Thu, Jun 2, 2022 at 9:25 AM Patrik Jakobsson
> > <patrik.r.jakobsson@gmail.com> wrote:
> >>
> >> On Tue, May 31, 2022 at 1:15 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> >>>
> >>> Expect the hardware to provide a DDC channel. Fail probing if its
> >>> initialization fails.
> >>>
> >>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> >>
> >> It's funny how I just did the same thing to gma500. Great minds think alike ;)
> >>
> >> Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> >
> > I just realized that the ast_i2c_chan is never freed. Could be fixed
> > in a follow-up patch?
>
> In ast_i2c_create(), there's a call to drmm_add_action_or_reset(), which
> sets up ast_i2c_release(), which in turn kfree's the memory. Unless I'm
> totally missing something here.

Oh, I missed that. Then never mind :)

>
> Best regards
> Thomas
>
> >
> >>
> >>
> >>> ---
> >>>   drivers/gpu/drm/ast/ast_drv.h  |  2 --
> >>>   drivers/gpu/drm/ast/ast_i2c.c  |  7 ++++---
> >>>   drivers/gpu/drm/ast/ast_mode.c | 38 ++++++++++++++++------------------
> >>>   3 files changed, 22 insertions(+), 25 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
> >>> index 3055b0be7b67..2a55fc7303b9 100644
> >>> --- a/drivers/gpu/drm/ast/ast_drv.h
> >>> +++ b/drivers/gpu/drm/ast/ast_drv.h
> >>> @@ -132,7 +132,6 @@ struct ast_i2c_chan {
> >>>
> >>>   struct ast_vga_connector {
> >>>          struct drm_connector base;
> >>> -       struct ast_i2c_chan *i2c;
> >>>   };
> >>>
> >>>   static inline struct ast_vga_connector *
> >>> @@ -143,7 +142,6 @@ to_ast_vga_connector(struct drm_connector *connector)
> >>>
> >>>   struct ast_sil164_connector {
> >>>          struct drm_connector base;
> >>> -       struct ast_i2c_chan *i2c;
> >>>   };
> >>>
> >>>   static inline struct ast_sil164_connector *
> >>> diff --git a/drivers/gpu/drm/ast/ast_i2c.c b/drivers/gpu/drm/ast/ast_i2c.c
> >>> index 93e91c36d649..1d039ff1396e 100644
> >>> --- a/drivers/gpu/drm/ast/ast_i2c.c
> >>> +++ b/drivers/gpu/drm/ast/ast_i2c.c
> >>> @@ -117,7 +117,7 @@ struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev)
> >>>
> >>>          i2c = kzalloc(sizeof(struct ast_i2c_chan), GFP_KERNEL);
> >>>          if (!i2c)
> >>> -               return NULL;
> >>> +               return ERR_PTR(-ENOMEM);
> >>>
> >>>          i2c->adapter.owner = THIS_MODULE;
> >>>          i2c->adapter.class = I2C_CLASS_DDC;
> >>> @@ -143,10 +143,11 @@ struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev)
> >>>
> >>>          ret = drmm_add_action_or_reset(dev, ast_i2c_release, i2c);
> >>>          if (ret)
> >>> -               return NULL;
> >>> +               return ERR_PTR(ret);
> >>> +
> >>>          return i2c;
> >>>
> >>>   out_kfree:
> >>>          kfree(i2c);
> >>> -       return NULL;
> >>> +       return ERR_PTR(ret);
> >>>   }
> >>> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> >>> index bbc566c4c768..5f273b5dd769 100644
> >>> --- a/drivers/gpu/drm/ast/ast_mode.c
> >>> +++ b/drivers/gpu/drm/ast/ast_mode.c
> >>> @@ -1334,19 +1334,18 @@ static int ast_vga_connector_init(struct drm_device *dev,
> >>>                                    struct ast_vga_connector *ast_vga_connector)
> >>>   {
> >>>          struct drm_connector *connector = &ast_vga_connector->base;
> >>> +       struct ast_i2c_chan *i2c;
> >>>          int ret;
> >>>
> >>> -       ast_vga_connector->i2c = ast_i2c_create(dev);
> >>> -       if (!ast_vga_connector->i2c)
> >>> -               drm_err(dev, "failed to add ddc bus for connector\n");
> >>> +       i2c = ast_i2c_create(dev);
> >>> +       if (IS_ERR(i2c)) {
> >>> +               ret = PTR_ERR(i2c);
> >>> +               drm_err(dev, "failed to add ddc bus for connector; ret=%d\n", ret);
> >>> +               return ret;
> >>> +       }
> >>>
> >>> -       if (ast_vga_connector->i2c)
> >>> -               ret = drm_connector_init_with_ddc(dev, connector, &ast_vga_connector_funcs,
> >>> -                                                 DRM_MODE_CONNECTOR_VGA,
> >>> -                                                 &ast_vga_connector->i2c->adapter);
> >>> -       else
> >>> -               ret = drm_connector_init(dev, connector, &ast_vga_connector_funcs,
> >>> -                                        DRM_MODE_CONNECTOR_VGA);
> >>> +       ret = drm_connector_init_with_ddc(dev, connector, &ast_vga_connector_funcs,
> >>> +                                         DRM_MODE_CONNECTOR_VGA, &i2c->adapter);
> >>>          if (ret)
> >>>                  return ret;
> >>>
> >>> @@ -1406,19 +1405,18 @@ static int ast_sil164_connector_init(struct drm_device *dev,
> >>>                                       struct ast_sil164_connector *ast_sil164_connector)
> >>>   {
> >>>          struct drm_connector *connector = &ast_sil164_connector->base;
> >>> +       struct ast_i2c_chan *i2c;
> >>>          int ret;
> >>>
> >>> -       ast_sil164_connector->i2c = ast_i2c_create(dev);
> >>> -       if (!ast_sil164_connector->i2c)
> >>> -               drm_err(dev, "failed to add ddc bus for connector\n");
> >>> +       i2c = ast_i2c_create(dev);
> >>> +       if (IS_ERR(i2c)) {
> >>> +               ret = PTR_ERR(i2c);
> >>> +               drm_err(dev, "failed to add ddc bus for connector; ret=%d\n", ret);
> >>> +               return ret;
> >>> +       }
> >>>
> >>> -       if (ast_sil164_connector->i2c)
> >>> -               ret = drm_connector_init_with_ddc(dev, connector, &ast_sil164_connector_funcs,
> >>> -                                                 DRM_MODE_CONNECTOR_DVII,
> >>> -                                                 &ast_sil164_connector->i2c->adapter);
> >>> -       else
> >>> -               ret = drm_connector_init(dev, connector, &ast_sil164_connector_funcs,
> >>> -                                        DRM_MODE_CONNECTOR_DVII);
> >>> +       ret = drm_connector_init_with_ddc(dev, connector, &ast_sil164_connector_funcs,
> >>> +                                         DRM_MODE_CONNECTOR_DVII, &i2c->adapter);
> >>>          if (ret)
> >>>                  return ret;
> >>>
> >>> --
> >>> 2.36.1
> >>>
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Ivo Totev

  reply	other threads:[~2022-06-02 10:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31 11:14 [PATCH v2 0/5] drm/ast: Connector cleanups and polling Thomas Zimmermann
2022-05-31 11:14 ` [PATCH v2 1/5] drm/ast: Support multiple outputs Thomas Zimmermann
2022-06-02  7:24   ` Patrik Jakobsson
2022-06-02 11:01     ` Thomas Zimmermann
2022-05-31 11:14 ` [PATCH v2 2/5] drm/ast: Fix updating the connector's EDID property Thomas Zimmermann
2022-06-02  7:24   ` Patrik Jakobsson
2022-06-07  8:13     ` Thomas Zimmermann
2022-06-07  9:08       ` Patrik Jakobsson
2022-05-31 11:15 ` [PATCH v2 3/5] drm/ast: Support output polling Thomas Zimmermann
2022-06-02  7:25   ` Patrik Jakobsson
2022-06-02 11:00     ` Thomas Zimmermann
2022-06-07 10:03   ` Jani Nikula
2022-06-07 10:50     ` Thomas Zimmermann
2022-05-31 11:15 ` [PATCH v2 4/5] drm/ast: Fail probing if DCC channel could not be initialized Thomas Zimmermann
2022-06-02  7:25   ` Patrik Jakobsson
2022-06-02  7:42     ` Patrik Jakobsson
2022-06-02  9:32       ` Thomas Zimmermann
2022-06-02 10:34         ` Patrik Jakobsson [this message]
2022-05-31 11:15 ` [PATCH v2 5/5] drm/ast: Remove struct ast_{vga,sil164}_connector Thomas Zimmermann
2022-06-02  7:25   ` Patrik Jakobsson
2022-05-31 11:16 ` [PATCH v2 0/5] drm/ast: Connector cleanups and polling Thomas Zimmermann

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='CAMeQTsZVJ=8g6SUrc7Hadq60LJ8=fBOB3yUmC2b8iN3-cFkdQA@mail.gmail.com' \
    --to=patrik.r.jakobsson@gmail.com \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.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 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.