From: Thomas Zimmermann <tzimmermann@suse.de>
To: jfalempe@redhat.com, airlied@redhat.com,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
airlied@gmail.com, jani.nikula@linux.intel.com
Cc: dri-devel@lists.freedesktop.org,
Thomas Zimmermann <tzimmermann@suse.de>,
stable@vger.kernel.org
Subject: [PATCH 02/10] drm/mgag200: Bind I2C lifetime to DRM device
Date: Mon, 13 May 2024 14:51:07 +0200 [thread overview]
Message-ID: <20240513125620.6337-3-tzimmermann@suse.de> (raw)
In-Reply-To: <20240513125620.6337-1-tzimmermann@suse.de>
Managed cleanup with devm_add_action_or_reset() will release the I2C
adapter when the underlying Linux device goes away. But the connector
still refers to it, so this cleanup leaves behind a stale pointer
in struct drm_connector.ddc.
Bind the lifetime of the I2C adapter to the connector's lifetime by
using DRM's managed release. When the DRM device goes away (after
the Linux device) DRM will first clean up the connector and then
clean up the I2C adapter.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: b279df242972 ("drm/mgag200: Switch I2C code to managed cleanup")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Jocelyn Falempe <jfalempe@redhat.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.0+
---
drivers/gpu/drm/mgag200/mgag200_i2c.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/mgag200/mgag200_i2c.c b/drivers/gpu/drm/mgag200/mgag200_i2c.c
index 1029fef590f9b..4caeb68f3010c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_i2c.c
+++ b/drivers/gpu/drm/mgag200/mgag200_i2c.c
@@ -31,6 +31,8 @@
#include <linux/i2c.h>
#include <linux/pci.h>
+#include <drm/drm_managed.h>
+
#include "mgag200_drv.h"
static int mga_i2c_read_gpio(struct mga_device *mdev)
@@ -86,7 +88,7 @@ static int mga_gpio_getscl(void *data)
return (mga_i2c_read_gpio(mdev) & i2c->clock) ? 1 : 0;
}
-static void mgag200_i2c_release(void *res)
+static void mgag200_i2c_release(struct drm_device *dev, void *res)
{
struct mga_i2c_chan *i2c = res;
@@ -125,5 +127,5 @@ int mgag200_i2c_init(struct mga_device *mdev, struct mga_i2c_chan *i2c)
if (ret)
return ret;
- return devm_add_action_or_reset(dev->dev, mgag200_i2c_release, i2c);
+ return drmm_add_action_or_reset(dev, mgag200_i2c_release, i2c);
}
--
2.45.0
next prev parent reply other threads:[~2024-05-13 12:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-13 12:51 [PATCH 00/10] drm/mgag200: Refactor DDC code Thomas Zimmermann
2024-05-13 12:51 ` [PATCH 01/10] drm/mgag200: Set DDC timeout in milliseconds Thomas Zimmermann
2024-05-13 12:51 ` Thomas Zimmermann [this message]
2024-05-13 12:51 ` [PATCH 03/10] drm/mgag200: Store pointer to struct mga_device in struct mga_i2c_chan Thomas Zimmermann
2024-05-13 12:51 ` [PATCH 04/10] drm/mgag200: Allocate instance of struct mga_i2c_chan dynamically Thomas Zimmermann
2024-05-13 12:51 ` [PATCH 05/10] drm/mgag200: Inline mgag200_i2c_init() Thomas Zimmermann
2024-05-13 12:51 ` [PATCH 06/10] drm/mgag200: Replace struct mga_i2c_chan with struct mgag200_ddc Thomas Zimmermann
2024-05-13 12:51 ` [PATCH 07/10] drm/mgag200: Rename mgag200_i2c.c to mgag200_ddc.c Thomas Zimmermann
2024-05-13 12:51 ` [PATCH 08/10] drm/mgag200: Rename struct i2c_algo_bit_data callbacks Thomas Zimmermann
2024-05-13 12:51 ` [PATCH 09/10] drm/mgag200: Acquire I/O-register lock in DDC code Thomas Zimmermann
2024-05-13 12:51 ` [PATCH 10/10] drm/mgag200: Use drm_connector_helper_get_modes() Thomas Zimmermann
2024-05-16 9:14 ` [PATCH 00/10] drm/mgag200: Refactor DDC code Jocelyn Falempe
2024-05-16 10:50 ` 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=20240513125620.6337-3-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jfalempe@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=stable@vger.kernel.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.