From: Daniel Stone <daniels@collabora.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 5/7] drm: Introduce blob_lock
Date: Mon, 20 Apr 2015 19:22:54 +0100 [thread overview]
Message-ID: <1429554176-9865-6-git-send-email-daniels@collabora.com> (raw)
In-Reply-To: <1429554176-9865-1-git-send-email-daniels@collabora.com>
Create a new global blob_lock mutex, which protects the blob property
list from insertion and/or deletion.
Signed-off-by: Daniel Stone <daniels@collabora.com>
---
drivers/gpu/drm/drm_crtc.c | 18 +++++++++++++++---
include/drm/drm_crtc.h | 3 +++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index ed9341d..9947078 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4214,25 +4214,34 @@ drm_property_create_blob(struct drm_device *dev, size_t length,
if (!blob)
return NULL;
+ blob->length = length;
+
+ memcpy(blob->data, data, length);
+
+ mutex_lock(&dev->mode_config.blob_lock);
+
ret = drm_mode_object_get(dev, &blob->base, DRM_MODE_OBJECT_BLOB);
if (ret) {
kfree(blob);
+ mutex_unlock(&dev->mode_config.blob_lock);
return NULL;
}
- blob->length = length;
+ list_add_tail(&blob->head, &dev->mode_config.property_blob_list);
- memcpy(blob->data, data, length);
+ mutex_unlock(&dev->mode_config.blob_lock);
- list_add_tail(&blob->head, &dev->mode_config.property_blob_list);
return blob;
}
static void drm_property_destroy_blob(struct drm_device *dev,
struct drm_property_blob *blob)
{
+ mutex_lock(&dev->mode_config.blob_lock);
drm_mode_object_put(dev, &blob->base);
list_del(&blob->head);
+ mutex_unlock(&dev->mode_config.blob_lock);
+
kfree(blob);
}
@@ -4339,6 +4348,7 @@ int drm_mode_getblob_ioctl(struct drm_device *dev,
return -EINVAL;
drm_modeset_lock_all(dev);
+ mutex_lock(&dev->mode_config.blob_lock);
blob = drm_property_blob_find(dev, out_resp->blob_id);
if (!blob) {
ret = -ENOENT;
@@ -4355,6 +4365,7 @@ int drm_mode_getblob_ioctl(struct drm_device *dev,
out_resp->length = blob->length;
done:
+ mutex_unlock(&dev->mode_config.blob_lock);
drm_modeset_unlock_all(dev);
return ret;
}
@@ -5488,6 +5499,7 @@ void drm_mode_config_init(struct drm_device *dev)
drm_modeset_lock_init(&dev->mode_config.connection_mutex);
mutex_init(&dev->mode_config.idr_mutex);
mutex_init(&dev->mode_config.fb_lock);
+ mutex_init(&dev->mode_config.blob_lock);
INIT_LIST_HEAD(&dev->mode_config.fb_list);
INIT_LIST_HEAD(&dev->mode_config.crtc_list);
INIT_LIST_HEAD(&dev->mode_config.connector_list);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b009d70..43a3758 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1049,6 +1049,7 @@ struct drm_mode_group {
* @poll_running: track polling status for this device
* @output_poll_work: delayed work for polling in process context
* @property_blob_list: list of all the blob property objects
+ * @blob_lock: mutex for blob property allocation and management
* @*_property: core property tracking
* @preferred_depth: preferred RBG pixel depth, used by fb helpers
* @prefer_shadow: hint to userspace to prefer shadow-fb rendering
@@ -1104,6 +1105,8 @@ struct drm_mode_config {
bool delayed_event;
struct delayed_work output_poll_work;
+ struct mutex blob_lock;
+
/* pointers to standard properties */
struct list_head property_blob_list;
struct drm_property *edid_property;
--
2.3.5
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-04-20 18:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-20 18:22 [PATCH 0/7] User-created blob properties Daniel Stone
2015-04-20 18:22 ` [PATCH 1/7] drm/atomic: Don't open-code CRTC state destroy Daniel Stone
2015-04-20 18:22 ` [PATCH 2/7] drm/atomic: Early-exit from CRTC dup state Daniel Stone
2015-05-07 9:05 ` Daniel Vetter
2015-04-20 18:22 ` [PATCH 3/7] drm: Don't leak path blob property when updating Daniel Stone
2015-04-20 18:22 ` [PATCH 4/7] drm: Introduce helper for replacing blob properties Daniel Stone
2015-04-20 18:22 ` Daniel Stone [this message]
2015-04-20 18:22 ` [PATCH 6/7] drm: Add reference counting to " Daniel Stone
2015-05-07 9:14 ` Daniel Vetter
2015-04-20 18:22 ` [PATCH 7/7] drm/mode: Add user blob-creation ioctl Daniel Stone
2015-05-07 7:53 ` Maarten Lankhorst
2015-05-07 8:34 ` [PATCH 0/7] User-created blob properties Daniel Vetter
2015-05-07 9:15 ` Daniel Stone
2015-05-09 14:52 ` [PATCH v2] " Daniel Stone
2015-05-09 14:52 ` [PATCH 1/4] drm: Remove extraneous parameter from kerneldoc Daniel Stone
2015-05-11 9:09 ` Daniel Vetter
2015-05-11 22:49 ` Daniel Stone
2015-05-09 14:52 ` [PATCH 2/4] drm: Allow creating blob properties without copy Daniel Stone
2015-05-09 14:52 ` [PATCH 3/4] drm: Return error value from blob creation Daniel Stone
2015-05-09 14:52 ` [PATCH 4/4] drm/mode: Add user blob-creation ioctl Daniel Stone
2015-05-11 9:11 ` Daniel Vetter
2015-05-11 22:46 ` [PATCH 7/7] " Daniel Stone
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=1429554176-9865-6-git-send-email-daniels@collabora.com \
--to=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox