dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Cohen <cohens-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: adelva-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	Steve Cohen <cohens-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	pdhaval-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Subject: [PATCH 1/3] drm: add driver hook for create blob limitations
Date: Thu,  7 Nov 2019 14:39:12 -0500	[thread overview]
Message-ID: <1573155554-16248-2-git-send-email-cohens@codeaurora.org> (raw)
In-Reply-To: <1573155554-16248-1-git-send-email-cohens-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>

Allow drivers with blob limitations to run checks before blobs
are created. This can be used to limit how much memory can be
allocated based on driver requirements.

Signed-off-by: Steve Cohen <cohens@codeaurora.org>
---
 drivers/gpu/drm/drm_property.c | 7 +++++++
 include/drm/drm_drv.h          | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index 892ce63..507a8a1 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -793,6 +793,13 @@ int drm_mode_createblob_ioctl(struct drm_device *dev,
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return -EOPNOTSUPP;
 
+	if (dev->driver->createblob_check) {
+		ret = dev->driver->createblob_check(
+				dev, out_resp->length, file_priv);
+		if (ret)
+			return ret;
+	}
+
 	blob = drm_property_create_blob(dev, out_resp->length, NULL);
 	if (IS_ERR(blob))
 		return PTR_ERR(blob);
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 8976afe..73b39b89 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -776,6 +776,15 @@ struct drm_driver {
 	int (*dma_quiescent) (struct drm_device *);
 	int (*context_dtor) (struct drm_device *dev, int context);
 	int dev_priv_size;
+
+	/**
+	 * @createblob_check: driver check for creating blob properties
+	 *
+	 * Hook for checking blob limitations imposed by drivers
+	 */
+	int (*createblob_check) (struct drm_device *dev,
+				 size_t length,
+				 struct drm_file *file_priv);
 };
 
 extern unsigned int drm_debug;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

WARNING: multiple messages have this Message-ID (diff)
From: Steve Cohen <cohens@codeaurora.org>
To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org,
	linux-arm-msm@vger.kernel.org
Cc: adelva@google.com, Steve Cohen <cohens@codeaurora.org>,
	pdhaval@codeaurora.org, seanpaul@chromium.org
Subject: [PATCH 1/3] drm: add driver hook for create blob limitations
Date: Thu,  7 Nov 2019 14:39:12 -0500	[thread overview]
Message-ID: <1573155554-16248-2-git-send-email-cohens@codeaurora.org> (raw)
Message-ID: <20191107193912.Cje_i0dps6-f3zlq3ZQygN5IzELS1kwVmv851n4fx4E@z> (raw)
In-Reply-To: <1573155554-16248-1-git-send-email-cohens@codeaurora.org>

Allow drivers with blob limitations to run checks before blobs
are created. This can be used to limit how much memory can be
allocated based on driver requirements.

Signed-off-by: Steve Cohen <cohens@codeaurora.org>
---
 drivers/gpu/drm/drm_property.c | 7 +++++++
 include/drm/drm_drv.h          | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index 892ce63..507a8a1 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -793,6 +793,13 @@ int drm_mode_createblob_ioctl(struct drm_device *dev,
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return -EOPNOTSUPP;
 
+	if (dev->driver->createblob_check) {
+		ret = dev->driver->createblob_check(
+				dev, out_resp->length, file_priv);
+		if (ret)
+			return ret;
+	}
+
 	blob = drm_property_create_blob(dev, out_resp->length, NULL);
 	if (IS_ERR(blob))
 		return PTR_ERR(blob);
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 8976afe..73b39b89 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -776,6 +776,15 @@ struct drm_driver {
 	int (*dma_quiescent) (struct drm_device *);
 	int (*context_dtor) (struct drm_device *dev, int context);
 	int dev_priv_size;
+
+	/**
+	 * @createblob_check: driver check for creating blob properties
+	 *
+	 * Hook for checking blob limitations imposed by drivers
+	 */
+	int (*createblob_check) (struct drm_device *dev,
+				 size_t length,
+				 struct drm_file *file_priv);
 };
 
 extern unsigned int drm_debug;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-11-07 19:39 UTC|newest]

Thread overview: 13+ 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 ` Steve Cohen
     [not found] ` <1573155554-16248-1-git-send-email-cohens-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2019-11-07 19:39   ` Steve Cohen [this message]
2019-11-07 19:39     ` [PATCH 1/3] drm: add driver hook for create blob limitations Steve Cohen
2019-11-07 19:39   ` [PATCH 2/3] drm/msm: add support for createblob_check driver hook Steve Cohen
2019-11-07 19:39     ` Steve Cohen
2019-11-07 19:39   ` [PATCH 3/3] drm/msm/dpu: check blob limitations during create blob ioctl Steve Cohen
2019-11-07 19:39     ` Steve Cohen
2019-11-08  8:34   ` [PATCH 0/3] allow DRM drivers to limit creation of blobs Daniel Vetter
2019-11-08  8:34     ` Daniel Vetter
     [not found]     ` <20191108083448.GU23790-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-11-09  0:01       ` cohens-sgV2jX0FEOL9JmXXK+q4OQ
2019-11-09  0:01         ` cohens
2019-11-10 20:57         ` Daniel Vetter

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=1573155554-16248-2-git-send-email-cohens@codeaurora.org \
    --to=cohens-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
    --cc=adelva-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pdhaval-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.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