All of lore.kernel.org
 help / color / mirror / Atom feed
From: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
To: diogo.ivo@tecnico.ulisboa.pt, thierry.reding@gmail.com,
	airlied@redhat.com, daniel@ffwll.ch, jonathanh@nvidia.com
Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org
Subject: [PATCH 1/2] drm/tegra: add sector layout to SET/GET_TILING IOCTLs
Date: Fri, 20 Jan 2023 10:58:57 +0000	[thread overview]
Message-ID: <20230120105858.214440-2-diogo.ivo@tecnico.ulisboa.pt> (raw)
In-Reply-To: <20230120105858.214440-1-diogo.ivo@tecnico.ulisboa.pt>

Commit 7b6f846785f4 ("drm/tegra: Support sector layout on Tegra194")
updated struct tegra_bo_tiling with a new field conveying information
about the sector layout of the buffer object. Update the
SET/GET_TILING IOCTLs with this field so that userspace can set it
appropriately.

Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
---
 drivers/gpu/drm/tegra/drm.c  | 29 +++++++++++++++++++++++++++++
 include/uapi/drm/tegra_drm.h | 16 ++++++++++------
 2 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 6748ec1e0005..27afb7fa6259 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -612,6 +612,7 @@ static int tegra_gem_set_tiling(struct drm_device *drm, void *data,
 	enum tegra_bo_tiling_mode mode;
 	struct drm_gem_object *gem;
 	unsigned long value = 0;
+	enum tegra_bo_sector_layout layout;
 	struct tegra_bo *bo;
 
 	switch (args->mode) {
@@ -644,6 +645,19 @@ static int tegra_gem_set_tiling(struct drm_device *drm, void *data,
 		return -EINVAL;
 	}
 
+	switch (args->sector_layout) {
+	case DRM_TEGRA_GEM_SECTOR_LAYOUT_TEGRA:
+		layout = TEGRA_BO_SECTOR_LAYOUT_TEGRA;
+		break;
+
+	case DRM_TEGRA_GEM_SECTOR_LAYOUT_GPU:
+		layout = TEGRA_BO_SECTOR_LAYOUT_GPU;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
 	gem = drm_gem_object_lookup(file, args->handle);
 	if (!gem)
 		return -ENOENT;
@@ -652,6 +666,7 @@ static int tegra_gem_set_tiling(struct drm_device *drm, void *data,
 
 	bo->tiling.mode = mode;
 	bo->tiling.value = value;
+	bo->tiling.sector_layout = layout;
 
 	drm_gem_object_put(gem);
 
@@ -693,6 +708,20 @@ static int tegra_gem_get_tiling(struct drm_device *drm, void *data,
 		break;
 	}
 
+	switch (bo->tiling.sector_layout) {
+	case TEGRA_BO_SECTOR_LAYOUT_TEGRA:
+		args->sector_layout = DRM_TEGRA_GEM_SECTOR_LAYOUT_TEGRA;
+		break;
+
+	case TEGRA_BO_SECTOR_LAYOUT_GPU:
+		args->sector_layout = DRM_TEGRA_GEM_SECTOR_LAYOUT_GPU;
+		break;
+
+	default:
+		err = -EINVAL;
+		break;
+	}
+
 	drm_gem_object_put(gem);
 
 	return err;
diff --git a/include/uapi/drm/tegra_drm.h b/include/uapi/drm/tegra_drm.h
index 94cfc306d50a..811e21b1a60e 100644
--- a/include/uapi/drm/tegra_drm.h
+++ b/include/uapi/drm/tegra_drm.h
@@ -508,6 +508,9 @@ struct drm_tegra_submit {
 #define DRM_TEGRA_GEM_TILING_MODE_TILED 1
 #define DRM_TEGRA_GEM_TILING_MODE_BLOCK 2
 
+#define DRM_TEGRA_GEM_SECTOR_LAYOUT_TEGRA 0
+#define DRM_TEGRA_GEM_SECTOR_LAYOUT_GPU 1
+
 /**
  * struct drm_tegra_gem_set_tiling - parameters for the set tiling IOCTL
  */
@@ -543,11 +546,11 @@ struct drm_tegra_gem_set_tiling {
 	__u32 value;
 
 	/**
-	 * @pad:
+	 * @sector_layout:
 	 *
-	 * Structure padding that may be used in the future. Must be 0.
+	 * Specify low-level sector layout.
 	 */
-	__u32 pad;
+	__u32 sector_layout;
 };
 
 /**
@@ -578,11 +581,12 @@ struct drm_tegra_gem_get_tiling {
 	__u32 value;
 
 	/**
-	 * @pad:
+	 * @sector_layout:
 	 *
-	 * Structure padding that may be used in the future. Must be 0.
+	 * The sector layout parameter currently associated with the GEM object.
+	 * Set by the kernel upon successful completion of the IOCTL.
 	 */
-	__u32 pad;
+	__u32 sector_layout;
 };
 
 #define DRM_TEGRA_GEM_BOTTOM_UP		(1 << 0)
-- 
2.39.1


WARNING: multiple messages have this Message-ID (diff)
From: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
To: diogo.ivo@tecnico.ulisboa.pt, thierry.reding@gmail.com,
	airlied@redhat.com, daniel@ffwll.ch, jonathanh@nvidia.com
Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 1/2] drm/tegra: add sector layout to SET/GET_TILING IOCTLs
Date: Fri, 20 Jan 2023 10:58:57 +0000	[thread overview]
Message-ID: <20230120105858.214440-2-diogo.ivo@tecnico.ulisboa.pt> (raw)
In-Reply-To: <20230120105858.214440-1-diogo.ivo@tecnico.ulisboa.pt>

Commit 7b6f846785f4 ("drm/tegra: Support sector layout on Tegra194")
updated struct tegra_bo_tiling with a new field conveying information
about the sector layout of the buffer object. Update the
SET/GET_TILING IOCTLs with this field so that userspace can set it
appropriately.

Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
---
 drivers/gpu/drm/tegra/drm.c  | 29 +++++++++++++++++++++++++++++
 include/uapi/drm/tegra_drm.h | 16 ++++++++++------
 2 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 6748ec1e0005..27afb7fa6259 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -612,6 +612,7 @@ static int tegra_gem_set_tiling(struct drm_device *drm, void *data,
 	enum tegra_bo_tiling_mode mode;
 	struct drm_gem_object *gem;
 	unsigned long value = 0;
+	enum tegra_bo_sector_layout layout;
 	struct tegra_bo *bo;
 
 	switch (args->mode) {
@@ -644,6 +645,19 @@ static int tegra_gem_set_tiling(struct drm_device *drm, void *data,
 		return -EINVAL;
 	}
 
+	switch (args->sector_layout) {
+	case DRM_TEGRA_GEM_SECTOR_LAYOUT_TEGRA:
+		layout = TEGRA_BO_SECTOR_LAYOUT_TEGRA;
+		break;
+
+	case DRM_TEGRA_GEM_SECTOR_LAYOUT_GPU:
+		layout = TEGRA_BO_SECTOR_LAYOUT_GPU;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
 	gem = drm_gem_object_lookup(file, args->handle);
 	if (!gem)
 		return -ENOENT;
@@ -652,6 +666,7 @@ static int tegra_gem_set_tiling(struct drm_device *drm, void *data,
 
 	bo->tiling.mode = mode;
 	bo->tiling.value = value;
+	bo->tiling.sector_layout = layout;
 
 	drm_gem_object_put(gem);
 
@@ -693,6 +708,20 @@ static int tegra_gem_get_tiling(struct drm_device *drm, void *data,
 		break;
 	}
 
+	switch (bo->tiling.sector_layout) {
+	case TEGRA_BO_SECTOR_LAYOUT_TEGRA:
+		args->sector_layout = DRM_TEGRA_GEM_SECTOR_LAYOUT_TEGRA;
+		break;
+
+	case TEGRA_BO_SECTOR_LAYOUT_GPU:
+		args->sector_layout = DRM_TEGRA_GEM_SECTOR_LAYOUT_GPU;
+		break;
+
+	default:
+		err = -EINVAL;
+		break;
+	}
+
 	drm_gem_object_put(gem);
 
 	return err;
diff --git a/include/uapi/drm/tegra_drm.h b/include/uapi/drm/tegra_drm.h
index 94cfc306d50a..811e21b1a60e 100644
--- a/include/uapi/drm/tegra_drm.h
+++ b/include/uapi/drm/tegra_drm.h
@@ -508,6 +508,9 @@ struct drm_tegra_submit {
 #define DRM_TEGRA_GEM_TILING_MODE_TILED 1
 #define DRM_TEGRA_GEM_TILING_MODE_BLOCK 2
 
+#define DRM_TEGRA_GEM_SECTOR_LAYOUT_TEGRA 0
+#define DRM_TEGRA_GEM_SECTOR_LAYOUT_GPU 1
+
 /**
  * struct drm_tegra_gem_set_tiling - parameters for the set tiling IOCTL
  */
@@ -543,11 +546,11 @@ struct drm_tegra_gem_set_tiling {
 	__u32 value;
 
 	/**
-	 * @pad:
+	 * @sector_layout:
 	 *
-	 * Structure padding that may be used in the future. Must be 0.
+	 * Specify low-level sector layout.
 	 */
-	__u32 pad;
+	__u32 sector_layout;
 };
 
 /**
@@ -578,11 +581,12 @@ struct drm_tegra_gem_get_tiling {
 	__u32 value;
 
 	/**
-	 * @pad:
+	 * @sector_layout:
 	 *
-	 * Structure padding that may be used in the future. Must be 0.
+	 * The sector layout parameter currently associated with the GEM object.
+	 * Set by the kernel upon successful completion of the IOCTL.
 	 */
-	__u32 pad;
+	__u32 sector_layout;
 };
 
 #define DRM_TEGRA_GEM_BOTTOM_UP		(1 << 0)
-- 
2.39.1


  reply	other threads:[~2023-01-20 11:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 10:58 [PATCH 0/2] drm/tegra: handle implicit scanout modifiers Diogo Ivo
2023-01-20 10:58 ` Diogo Ivo
2023-01-20 10:58 ` Diogo Ivo [this message]
2023-01-20 10:58   ` [PATCH 1/2] drm/tegra: add sector layout to SET/GET_TILING IOCTLs Diogo Ivo
2023-01-20 10:58 ` [PATCH 2/2] drm/tegra: add scanout support for implicit tiling parameters Diogo Ivo
2023-01-20 10:58   ` Diogo Ivo
2023-01-30 19:43   ` kernel test robot
2023-01-30 19:43     ` kernel test robot
2023-01-24 14:25 ` [PATCH 0/2] drm/tegra: handle implicit scanout modifiers Thierry Reding
2023-01-24 14:25   ` Thierry Reding
2023-01-30 14:49   ` Diogo Ivo
2023-01-30 14:49     ` Diogo Ivo

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=20230120105858.214440-2-diogo.ivo@tecnico.ulisboa.pt \
    --to=diogo.ivo@tecnico.ulisboa.pt \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    /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.