Skip to contentSkip to conversation

drm/r128: drop use of drmP.h

PATCH In review Sam Ravnborg 2 participants 5 messages Jun 5, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover drm/r128: drop use of drmP.h

Drop use of the deprecated header file drmP.h
in the r128 driver.
Also drop dependencies to drm_os_linux.h

Sam

Sam Ravnborg (2):
drm/r128: drop drm_os_linux dependencies
drm/r128: drop use of drmP.h

 drivers/gpu/drm/r128/r128_cce.c   | 28 ++++++++++++++++++----------
 drivers/gpu/drm/r128/r128_drv.c   |  9 ++++++---
 drivers/gpu/drm/r128/r128_drv.h   | 16 +++++++++++-----
 drivers/gpu/drm/r128/r128_state.c | 25 ++++++++++++++++---------
 4 files changed, 51 insertions(+), 27 deletions(-)

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#1 lore raw

PATCH 1/2 drm/r128: drop drm_os_linux dependencies

Drop use of drm_os_linux macros.

Simple 1:1 replacements of
- DRM_UDELAY
- DRM_CURRENTPID
- DRM_READ
- DRM_WRITE

With this change we do not need to introduce the deprecated drm_os_linux.h header when we drop use of drmP.h.

Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/r128/r128_cce.c   | 16 ++++++++--------
 drivers/gpu/drm/r128/r128_drv.h   | 10 +++++-----
 drivers/gpu/drm/r128/r128_state.c | 16 ++++++++--------
 3 files changed, 21 insertions(+), 21 deletions(-)
drivers/gpu/drm/r128/r128_cce.c +8 -8
index b91af1bf531b..6f426bb06934 100644
@@ -85,7 +85,7 @@ static int r128_do_pixcache_flush(drm_r128_private_t *dev_priv)
 	for (i = 0; i < dev_priv->usec_timeout; i++) {
 		if (!(R128_READ(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY))
 			return 0;
-		DRM_UDELAY(1);
+		udelay(1);
 	}
 
 #if R128_FIFO_DEBUG
@@ -102,7 +102,7 @@ static int r128_do_wait_for_fifo(drm_r128_private_t *dev_priv, int entries)
 		int slots = R128_READ(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK;
 		if (slots >= entries)
 			return 0;
-		DRM_UDELAY(1);
+		udelay(1);
 	}
 
 #if R128_FIFO_DEBUG
@@ -124,7 +124,7 @@ static int r128_do_wait_for_idle(drm_r128_private_t *dev_priv)
 			r128_do_pixcache_flush(dev_priv);
 			return 0;
 		}
-		DRM_UDELAY(1);
+		udelay(1);
 	}
 
 #if R128_FIFO_DEBUG
@@ -211,7 +211,7 @@ int r128_do_cce_idle(drm_r128_private_t *dev_priv)
 				return r128_do_pixcache_flush(dev_priv);
 			}
 		}
-		DRM_UDELAY(1);
+		udelay(1);
 	}
 
 #if R128_FIFO_DEBUG
@@ -838,7 +838,7 @@ static struct drm_buf *r128_freelist_get(struct drm_device * dev)
 				return buf;
 			}
 		}
-		DRM_UDELAY(1);
+		udelay(1);
 	}
 
 	DRM_DEBUG("returning NULL!\n");
@@ -870,7 +870,7 @@ int r128_wait_ring(drm_r128_private_t *dev_priv, int n)
 		r128_update_ring_snapshot(dev_priv);
 		if (ring->space >= n)
 			return 0;
-		DRM_UDELAY(1);
+		udelay(1);
 	}
 
 	/* FIXME: This is being ignored... */
@@ -916,7 +916,7 @@ int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_p
 	 */
 	if (d->send_count != 0) {
 		DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
-			  DRM_CURRENTPID, d->send_count);
+			  task_pid_nr(current), d->send_count);
 		return -EINVAL;
 	}
 
@@ -924,7 +924,7 @@ int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_p
 	 */
 	if (d->request_count < 0 || d->request_count > dma->buf_count) {
 		DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
-			  DRM_CURRENTPID, d->request_count, dma->buf_count);
+			  task_pid_nr(current), d->request_count, dma->buf_count);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/r128/r128_drv.h +5 -5
index 2de40d276116..115bb286dd2a 100644
@@ -397,10 +397,10 @@ extern long r128_compat_ioctl(struct file *filp, unsigned int cmd,
 
 #define R128_PCIGART_TABLE_SIZE         32768
 
-#define R128_READ(reg)		DRM_READ32(dev_priv->mmio, (reg))
-#define R128_WRITE(reg, val)	DRM_WRITE32(dev_priv->mmio, (reg), (val))
-#define R128_READ8(reg)		DRM_READ8(dev_priv->mmio, (reg))
-#define R128_WRITE8(reg, val)	DRM_WRITE8(dev_priv->mmio, (reg), (val))
+#define R128_READ(reg)		readl(((void __iomem *)dev_priv->mmio->handle) + (reg))
+#define R128_WRITE(reg, val)	writel(val, ((void __iomem *)dev_priv->mmio->handle) + (reg))
+#define R128_READ8(reg)		readb(((void __iomem *)dev_priv->mmio->handle) + (reg))
+#define R128_WRITE8(reg, val)	writeb(val, ((void __iomem *)dev_priv->mmio->handle) + (reg))
 
 #define R128_WRITE_PLL(addr, val)					\
 do {									\
@@ -445,7 +445,7 @@ do {									\
 			r128_update_ring_snapshot(dev_priv);		\
 			if (ring->space >= ring->high_mark)		\
 				goto __ring_space_done;			\
-			DRM_UDELAY(1);					\
+			udelay(1);					\
 		}							\
 		DRM_ERROR("ring space check failed!\n");		\
 		return -EBUSY;						\
drivers/gpu/drm/r128/r128_state.c +8 -8
index b9bfa806d346..2535ea8d2d9b 100644
@@ -824,7 +824,7 @@ static int r128_cce_dispatch_blit(struct drm_device *dev,
 
 	if (buf->file_priv != file_priv) {
 		DRM_ERROR("process %d using buffer owned by %p\n",
-			  DRM_CURRENTPID, buf->file_priv);
+			  task_pid_nr(current), buf->file_priv);
 		return -EINVAL;
 	}
 	if (buf->pending) {
@@ -1317,7 +1317,7 @@ static int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file *
 	DEV_INIT_TEST_WITH_RETURN(dev_priv);
 
 	DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n",
-		  DRM_CURRENTPID, vertex->idx, vertex->count, vertex->discard);
+		  task_pid_nr(current), vertex->idx, vertex->count, vertex->discard);
 
 	if (vertex->idx < 0 || vertex->idx >= dma->buf_count) {
 		DRM_ERROR("buffer index %d (of %d max)\n",
@@ -1338,7 +1338,7 @@ static int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file *
 
 	if (buf->file_priv != file_priv) {
 		DRM_ERROR("process %d using buffer owned by %p\n",
-			  DRM_CURRENTPID, buf->file_priv);
+			  task_pid_nr(current), buf->file_priv);
 		return -EINVAL;
 	}
 	if (buf->pending) {
@@ -1369,7 +1369,7 @@ static int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file
 
 	DEV_INIT_TEST_WITH_RETURN(dev_priv);
 
-	DRM_DEBUG("pid=%d buf=%d s=%d e=%d d=%d\n", DRM_CURRENTPID,
+	DRM_DEBUG("pid=%d buf=%d s=%d e=%d d=%d\n", task_pid_nr(current),
 		  elts->idx, elts->start, elts->end, elts->discard);
 
 	if (elts->idx < 0 || elts->idx >= dma->buf_count) {
@@ -1391,7 +1391,7 @@ static int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file
 
 	if (buf->file_priv != file_priv) {
 		DRM_ERROR("process %d using buffer owned by %p\n",
-			  DRM_CURRENTPID, buf->file_priv);
+			  task_pid_nr(current), buf->file_priv);
 		return -EINVAL;
 	}
 	if (buf->pending) {
@@ -1432,7 +1432,7 @@ static int r128_cce_blit(struct drm_device *dev, void *data, struct drm_file *fi
 
 	DEV_INIT_TEST_WITH_RETURN(dev_priv);
 
-	DRM_DEBUG("pid=%d index=%d\n", DRM_CURRENTPID, blit->idx);
+	DRM_DEBUG("pid=%d index=%d\n", task_pid_nr(current), blit->idx);
 
 	if (blit->idx < 0 || blit->idx >= dma->buf_count) {
 		DRM_ERROR("buffer index %d (of %d max)\n",
@@ -1532,7 +1532,7 @@ static int r128_cce_indirect(struct drm_device *dev, void *data, struct drm_file
 
 	if (buf->file_priv != file_priv) {
 		DRM_ERROR("process %d using buffer owned by %p\n",
-			  DRM_CURRENTPID, buf->file_priv);
+			  task_pid_nr(current), buf->file_priv);
 		return -EINVAL;
 	}
 	if (buf->pending) {
@@ -1579,7 +1579,7 @@ int r128_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv
 
 	DEV_INIT_TEST_WITH_RETURN(dev_priv);
 
-	DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
+	DRM_DEBUG("pid=%d\n", task_pid_nr(current));
 
 	switch (param->param) {
 	case R128_PARAM_IRQ_NR:
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 2/2 drm/r128: drop use of drmP.h

In reply to Sam Ravnborg

Drop use of the deprecated drmP.h header file. Replace it with relevant include files. Sort include files in files touched.

Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/r128/r128_cce.c   | 12 ++++++++++--
 drivers/gpu/drm/r128/r128_drv.c   |  9 ++++++---
 drivers/gpu/drm/r128/r128_drv.h   |  6 ++++++
 drivers/gpu/drm/r128/r128_state.c |  9 ++++++++-
 4 files changed, 30 insertions(+), 6 deletions(-)
drivers/gpu/drm/r128/r128_cce.c +10 -2
index 6f426bb06934..138af32480d4 100644
@@ -29,13 +29,21 @@
  *    Gareth Hughes <[email protected]>
  */
 
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
 #include <linux/firmware.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
-#include <linux/module.h>
+#include <linux/uaccess.h>
 
-#include <drm/drmP.h>
+#include <drm/drm_agpsupport.h>
+#include <drm/drm_device.h>
+#include <drm/drm_file.h>
+#include <drm/drm_irq.h>
+#include <drm/drm_print.h>
 #include <drm/r128_drm.h>
+
 #include "r128_drv.h"
 
 #define R128_FIFO_DEBUG		0
drivers/gpu/drm/r128/r128_drv.c +6 -3
index 4b1a505ab353..fd74f744604f 100644
@@ -31,11 +31,14 @@
 
 #include <linux/module.h>
 
-#include <drm/drmP.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_file.h>
+#include <drm/drm_pci.h>
+#include <drm/drm_pciids.h>
+#include <drm/drm_vblank.h>
 #include <drm/r128_drm.h>
-#include "r128_drv.h"
 
-#include <drm/drm_pciids.h>
+#include "r128_drv.h"
 
 static struct pci_device_id pciidlist[] = {
 	r128_PCI_IDS
drivers/gpu/drm/r128/r128_drv.h +6 -0
index 115bb286dd2a..ba8c30ed91d1 100644
@@ -35,8 +35,14 @@
 #ifndef __R128_DRV_H__
 #define __R128_DRV_H__
 
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/irqreturn.h>
+
 #include <drm/ati_pcigart.h>
+#include <drm/drm_ioctl.h>
 #include <drm/drm_legacy.h>
+#include <drm/r128_drm.h>
 
 /* General customization:
  */
drivers/gpu/drm/r128/r128_state.c +8 -1
index 2535ea8d2d9b..9d74c9d914cb 100644
@@ -28,8 +28,15 @@
  *    Gareth Hughes <[email protected]>
  */
 
-#include <drm/drmP.h>
+#include <linux/pci.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#include <drm/drm_device.h>
+#include <drm/drm_file.h>
+#include <drm/drm_print.h>
 #include <drm/r128_drm.h>
+
 #include "r128_drv.h"
 
 /* ================================================================
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 2/2
#3 lore raw
Quoted 7 lines · Sam Ravnborg

Drop use of the deprecated drmP.h header file. Replace it with relevant include files. Sort include files in files touched.

Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>

On both patches:

Again r128 is unmaintained, I think you can just go ahead and push. -Daniel

Quoted 100 lines
---
 drivers/gpu/drm/r128/r128_cce.c   | 12 ++++++++++--
 drivers/gpu/drm/r128/r128_drv.c   |  9 ++++++---
 drivers/gpu/drm/r128/r128_drv.h   |  6 ++++++
 drivers/gpu/drm/r128/r128_state.c |  9 ++++++++-
 4 files changed, 30 insertions(+), 6 deletions(-)
drivers/gpu/drm/r128/r128_cce.c +10 -2
index 6f426bb06934..138af32480d4 100644
@@ -29,13 +29,21 @@
  *    Gareth Hughes <[email protected]>
  */
 
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
 #include <linux/firmware.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
-#include <linux/module.h>
+#include <linux/uaccess.h>
 
-#include <drm/drmP.h>
+#include <drm/drm_agpsupport.h>
+#include <drm/drm_device.h>
+#include <drm/drm_file.h>
+#include <drm/drm_irq.h>
+#include <drm/drm_print.h>
 #include <drm/r128_drm.h>
+
 #include "r128_drv.h"
 
 #define R128_FIFO_DEBUG		0
drivers/gpu/drm/r128/r128_drv.c +6 -3
index 4b1a505ab353..fd74f744604f 100644
@@ -31,11 +31,14 @@
 
 #include <linux/module.h>
 
-#include <drm/drmP.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_file.h>
+#include <drm/drm_pci.h>
+#include <drm/drm_pciids.h>
+#include <drm/drm_vblank.h>
 #include <drm/r128_drm.h>
-#include "r128_drv.h"
 
-#include <drm/drm_pciids.h>
+#include "r128_drv.h"
 
 static struct pci_device_id pciidlist[] = {
 	r128_PCI_IDS
drivers/gpu/drm/r128/r128_drv.h +6 -0
index 115bb286dd2a..ba8c30ed91d1 100644
@@ -35,8 +35,14 @@
 #ifndef __R128_DRV_H__
 #define __R128_DRV_H__
 
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/irqreturn.h>
+
 #include <drm/ati_pcigart.h>
+#include <drm/drm_ioctl.h>
 #include <drm/drm_legacy.h>
+#include <drm/r128_drm.h>
 
 /* General customization:
  */
drivers/gpu/drm/r128/r128_state.c +8 -1
index 2535ea8d2d9b..9d74c9d914cb 100644
@@ -28,8 +28,15 @@
  *    Gareth Hughes <[email protected]>
  */
 
-#include <drm/drmP.h>
+#include <linux/pci.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#include <drm/drm_device.h>
+#include <drm/drm_file.h>
+#include <drm/drm_print.h>
 #include <drm/r128_drm.h>
+
 #include "r128_drv.h"
 
 /* ================================================================
Signature · 1 line
2.20.1
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Sam Ravnborg

Drop use of the deprecated drmP.h header file. Replace it with relevant include files. Sort include files in files touched.

Quoted 7 lines
Quoted 3 lines
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>

On both patches:

Thanks,
pushed to drm-misc-next.

Still a long way to go:

$ cd drivers/gpu/drm
$ git grep drmP | wc -l
492

So who is it that today uses drmP - list the 15 largest users:
(There are likely smarter ways to count it, but this works for me)

$ git grep drmP | cut -d '/' -f 1 | uniq -c | sort -n | tail -n 15
      8 arm
      8 via
      8 xen
      9 udl
     10 virtio
     11 meson
     12 mediatek
     13 vmwgfx
     15 rockchip
     16 sti
     18 sun4i
     24 exynos
     27 nouveau
    103 radeon
    110 amd

nouveau is already done, pending merge from their tree.
sti and exynos awaits review feedback. So this is another 67 uses gone.

When insanity hits me again I will try to focus on the unmaintained parts. Assuming someone else care about the maintained parts and will follow the example.

Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel