Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
From: Steve Cohen <cohens@codeaurora.org>
To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org,
	linux-arm-msm@vger.kernel.org
Cc: pdhaval@codeaurora.org, seanpaul@chromium.org, adelva@google.com,
	Steve Cohen <cohens@codeaurora.org>
Subject: [PATCH 2/3] drm/msm: add support for createblob_check driver hook
Date: Thu,  7 Nov 2019 14:39:13 -0500
Message-ID: <1573155554-16248-3-git-send-email-cohens@codeaurora.org> (raw)
In-Reply-To: <1573155554-16248-1-git-send-email-cohens@codeaurora.org>

Allow msm_kms devices to register a hook to check blob count
and blob size limitations before a new blob is created.

Signed-off-by: Steve Cohen <cohens@codeaurora.org>
---
 drivers/gpu/drm/msm/msm_drv.c | 25 +++++++++++++++++++++++++
 drivers/gpu/drm/msm/msm_kms.h |  1 +
 2 files changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index c84f0a8..d0b0419 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -680,6 +680,30 @@ static void msm_disable_vblank(struct drm_device *dev, unsigned int pipe)
 	vblank_ctrl_queue_work(priv, pipe, false);
 }
 
+static int msm_createblob_check (struct drm_device *dev, size_t length,
+		struct drm_file *file_priv)
+{
+	struct msm_drm_private *priv = dev->dev_private;
+	struct msm_kms *kms = priv->kms;
+	unsigned int count = 0;
+	struct drm_property_blob *blob;
+
+	if (!kms)
+		return -EINVAL;
+
+	if (!kms->funcs->createblob_check)
+		return 0;
+
+	mutex_lock(&dev->mode_config.blob_lock);
+	list_for_each_entry(blob, &file_priv->blobs, head_file) {
+		if (count < UINT_MAX)
+			count++;
+	}
+	mutex_unlock(&dev->mode_config.blob_lock);
+
+	return kms->funcs->createblob_check(count, length);
+}
+
 /*
  * DRM ioctls:
  */
@@ -1011,6 +1035,7 @@ static struct drm_driver msm_driver = {
 	.gem_prime_vmap     = msm_gem_prime_vmap,
 	.gem_prime_vunmap   = msm_gem_prime_vunmap,
 	.gem_prime_mmap     = msm_gem_prime_mmap,
+	.createblob_check   = msm_createblob_check,
 #ifdef CONFIG_DEBUG_FS
 	.debugfs_init       = msm_debugfs_init,
 #endif
diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h
index 1cbef6b..8a7e581 100644
--- a/drivers/gpu/drm/msm/msm_kms.h
+++ b/drivers/gpu/drm/msm/msm_kms.h
@@ -126,6 +126,7 @@ struct msm_kms_funcs {
 	/* debugfs: */
 	int (*debugfs_init)(struct msm_kms *kms, struct drm_minor *minor);
 #endif
+	int (*createblob_check)(unsigned int count, size_t length);
 };
 
 struct msm_kms;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


  parent reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07 19:39 [PATCH 0/3] allow DRM drivers to limit creation of blobs Steve Cohen
2019-11-07 19:39 ` [PATCH 1/3] drm: add driver hook for create blob limitations Steve Cohen
2019-11-07 19:39 ` Steve Cohen [this message]
2019-11-07 19:39 ` [PATCH 3/3] drm/msm/dpu: check blob limitations during create blob ioctl Steve Cohen
2019-11-08  8:34 ` [PATCH 0/3] allow DRM drivers to limit creation of blobs Daniel Vetter
2019-11-09  0:01   ` cohens
2019-11-10 20:57     ` Daniel Vetter

Reply instructions:

You may reply publically 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=1573155554-16248-3-git-send-email-cohens@codeaurora.org \
    --to=cohens@codeaurora.org \
    --cc=adelva@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=pdhaval@codeaurora.org \
    --cc=seanpaul@chromium.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

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git