[Openpvrsgx-devgroup] [PATCH] drm: pvrsgx: implement pvr_ioctl_unpriv

Ivaylo Dimitrov ivo.g.dimitrov.75 at gmail.com
Sat Nov 13 11:13:10 CET 2021


This is needed for userspace to decide if driver has already been
initialized


Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75 at gmail.com>
---
 drivers/gpu/drm/pvrsgx/pvr-drv.c | 24 +++++++++++++++++++++++-
 drivers/gpu/drm/pvrsgx/pvr-drv.h | 14 ++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/pvrsgx/pvr-drv.c b/drivers/gpu/drm/pvrsgx/pvr-drv.c
index 62e75d0..eb5f49c 100644
--- a/drivers/gpu/drm/pvrsgx/pvr-drv.c
+++ b/drivers/gpu/drm/pvrsgx/pvr-drv.c
@@ -123,9 +123,31 @@ static int pvr_ioctl_drm_is_master(struct drm_device *dev, void *arg, struct drm
 
 static int pvr_ioctl_unpriv(struct drm_device *dev, void *arg, struct drm_file *filp)
 {
+	int ret = 0;
+
 	dev_dbg(dev->dev, "%s: dev: %px arg: %px filp: %px\n", __func__, dev, arg, filp);
 
-	return 0;
+	if (arg == NULL)
+	{
+		ret = -EFAULT;
+	}
+	else
+	{
+		struct pvr_unpriv *unpriv = (struct pvr_unpriv *)arg;
+
+		switch (unpriv->cmd)
+		{
+			case PVR_UNPRIV_INIT_SUCCESFUL:
+				unpriv->res = PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL) ? 1 : 0;
+				break;
+
+			default:
+				ret = -EFAULT;
+		}
+
+	}
+
+	return ret;
 }
 
 static int pvr_ioctl_dbgdrv(struct drm_device *dev, void *arg, struct drm_file *filp)
diff --git a/drivers/gpu/drm/pvrsgx/pvr-drv.h b/drivers/gpu/drm/pvrsgx/pvr-drv.h
index 054f69d..fdb8348 100644
--- a/drivers/gpu/drm/pvrsgx/pvr-drv.h
+++ b/drivers/gpu/drm/pvrsgx/pvr-drv.h
@@ -18,6 +18,8 @@ struct pvr_unpriv {
 	u32 res;
 };
 
+#define PVR_UNPRIV_INIT_SUCCESFUL 0
+
 #define DRM_PVR_SRVKM		0x0
 #define DRM_PVR_DISP		0x1
 #define DRM_PVR_BC		0x2
@@ -53,6 +55,17 @@ struct pvr_unpriv {
 #define SGX_OCP_DEBUG_STATUS_0		0x10c
 #define SGX_OCP_DEBUG_STATUS_1		0x110	/* Only on omap4470 and later */
 
+typedef enum _PVRSRV_INIT_SERVER_STATE_
+{
+	PVRSRV_INIT_SERVER_Unspecified		= -1,
+	PVRSRV_INIT_SERVER_RUNNING			= 0,
+	PVRSRV_INIT_SERVER_RAN				= 1,
+	PVRSRV_INIT_SERVER_SUCCESSFUL		= 2,
+	PVRSRV_INIT_SERVER_NUM				= 3,
+	PVRSRV_INIT_SERVER_FORCE_I32 = 0x7fffffff
+
+} PVRSRV_INIT_SERVER_STATE, *PPVRSRV_INIT_SERVER_STATE;
+
 struct pvr;
 
 u32 pvr_sgx_readl(struct pvr *ddata, unsigned short offset);
@@ -69,3 +82,4 @@ struct pvr_unpriv {
 int PVRSRVDriverSuspend(struct platform_device *pdev, pm_message_t state);
 int PVRSRVDriverResume(struct platform_device *pdev);
 void PVRSRVDriverShutdown(struct platform_device *pdev);
+int PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_STATE eInitServerState);
-- 
1.9.1



More information about the openpvrsgx-devgroup mailing list