Linux virtualization list
 help / color / mirror / Atom feed
* [PATCH v3 02/13] fbdev: allow apertures == NULL in remove_conflicting_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, Jonathan Hunter, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Interpret (otherwise-invalid) NULL apertures argument to mean all-memory
range. This will allow to remove several duplicates of this code
from drivers in following patches.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

---
v2: added kerneldoc to corresponding DRM helper
v3: split kerneldoc to another patch
---
 drivers/video/fbdev/core/fbmem.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 30a18d4c9de4..0df148eb4699 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1779,11 +1779,25 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
 				    const char *name, bool primary)
 {
 	int ret;
+	bool do_free = false;
+
+	if (!a) {
+		a = alloc_apertures(1);
+		if (!a)
+			return -ENOMEM;
+
+		a->ranges[0].base = 0;
+		a->ranges[0].size = ~0;
+		do_free = true;
+	}
 
 	mutex_lock(&registration_lock);
 	ret = do_remove_conflicting_framebuffers(a, name, primary);
 	mutex_unlock(&registration_lock);
 
+	if (do_free)
+		kfree(a);
+
 	return ret;
 }
 EXPORT_SYMBOL(remove_conflicting_framebuffers);
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 01/13] fbdev: show fbdev number for debugging
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, Jonathan Hunter, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/video/fbdev/core/fbmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index f741ba8df01b..30a18d4c9de4 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1618,8 +1618,8 @@ static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
 			(primary && gen_aper && gen_aper->count &&
 			 gen_aper->ranges[0].base == VGA_FB_PHYS)) {
 
-			printk(KERN_INFO "fb: switching to %s from %s\n",
-			       name, registered_fb[i]->fix.id);
+			printk(KERN_INFO "fb%d: switching to %s from %s\n",
+			       i, name, registered_fb[i]->fix.id);
 			ret = do_unregister_framebuffer(registered_fb[i]);
 			if (ret)
 				return ret;
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 03/13] fbdev: add kerneldoc do remove_conflicting_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, Jonathan Hunter, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Document remove_conflicting_framebuffers() behaviour.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/video/fbdev/core/fbmem.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 0df148eb4699..2de93b5014e3 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1775,6 +1775,16 @@ int unlink_framebuffer(struct fb_info *fb_info)
 }
 EXPORT_SYMBOL(unlink_framebuffer);
 
+/**
+ * remove_conflicting_framebuffers - remove firmware-configured framebuffers
+ * @a: memory range, users of which are to be removed
+ * @name: requesting driver name
+ * @primary: also kick vga16fb if present
+ *
+ * This function removes framebuffer devices (initialized by firmware/bootloader)
+ * which use memory range described by @a. If @a is NULL all such devices are
+ * removed.
+ */
 int remove_conflicting_framebuffers(struct apertures_struct *a,
 				    const char *name, bool primary)
 {
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 04/13] fbdev: add remove_conflicting_pci_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, Jonathan Hunter, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Almost all PCI drivers using remove_conflicting_framebuffers() wrap it
with the same code.

---
v2: add kerneldoc for DRM helper
v3: propagate remove_conflicting_framebuffers() return value
  + move kerneldoc to where function is implemented

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/video/fbdev/core/fbmem.c | 35 ++++++++++++++++++++++++++++++++
 include/drm/drm_fb_helper.h      | 12 +++++++++++
 include/linux/fb.h               |  2 ++
 3 files changed, 49 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 2de93b5014e3..cd96b1c62bbe 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -34,6 +34,7 @@
 #include <linux/fb.h>
 #include <linux/fbcon.h>
 #include <linux/mem_encrypt.h>
+#include <linux/pci.h>
 
 #include <asm/fb.h>
 
@@ -1812,6 +1813,40 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
 }
 EXPORT_SYMBOL(remove_conflicting_framebuffers);
 
+/**
+ * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices
+ * @pdev: PCI device
+ * @resource_id: index of PCI BAR configuring framebuffer memory
+ * @name: requesting driver name
+ *
+ * This function removes framebuffer devices (eg. initialized by firmware)
+ * using memory range configured for @pdev's BAR @resource_id.
+ *
+ * The function assumes that PCI device with shadowed ROM drives a primary
+ * display and so kicks out vga16fb.
+ */
+int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const char *name)
+{
+	struct apertures_struct *ap;
+	bool primary = false;
+	int err;
+
+	ap = alloc_apertures(1);
+	if (!ap)
+		return -ENOMEM;
+
+	ap->ranges[0].base = pci_resource_start(pdev, res_id);
+	ap->ranges[0].size = pci_resource_len(pdev, res_id);
+#ifdef CONFIG_X86
+	primary = pdev->resource[PCI_ROM_RESOURCE].flags &
+					IORESOURCE_ROM_SHADOW;
+#endif
+	err = remove_conflicting_framebuffers(ap, name, primary);
+	kfree(ap);
+	return err;
+}
+EXPORT_SYMBOL(remove_conflicting_pci_framebuffers);
+
 /**
  *	register_framebuffer - registers a frame buffer device
  *	@fb_info: frame buffer info structure
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index b069433e7fc1..20ea856db900 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -577,4 +577,16 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
 #endif
 }
 
+static inline int
+drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
+						  int resource_id,
+						  const char *name)
+{
+#if IS_REACHABLE(CONFIG_FB)
+	return remove_conflicting_pci_framebuffers(pdev, resource_id, name);
+#else
+	return 0;
+#endif
+}
+
 #endif
diff --git a/include/linux/fb.h b/include/linux/fb.h
index aa74a228bb92..abeffd55b66a 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -632,6 +632,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 extern int register_framebuffer(struct fb_info *fb_info);
 extern int unregister_framebuffer(struct fb_info *fb_info);
 extern int unlink_framebuffer(struct fb_info *fb_info);
+extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id,
+					       const char *name);
 extern int remove_conflicting_framebuffers(struct apertures_struct *a,
 					   const char *name, bool primary);
 extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 06/13] drm/bochs: use simpler remove_conflicting_pci_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, virtualization, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, Jonathan Hunter,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/bochs/bochs_drv.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
index 7b20318483e4..c61b40c72b62 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -143,22 +143,6 @@ static const struct dev_pm_ops bochs_pm_ops = {
 /* ---------------------------------------------------------------------- */
 /* pci interface                                                          */
 
-static int bochs_kick_out_firmware_fb(struct pci_dev *pdev)
-{
-	struct apertures_struct *ap;
-
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
-	drm_fb_helper_remove_conflicting_framebuffers(ap, "bochsdrmfb", false);
-	kfree(ap);
-
-	return 0;
-}
-
 static int bochs_pci_probe(struct pci_dev *pdev,
 			   const struct pci_device_id *ent)
 {
@@ -171,7 +155,7 @@ static int bochs_pci_probe(struct pci_dev *pdev,
 		return -ENOMEM;
 	}
 
-	ret = bochs_kick_out_firmware_fb(pdev);
+	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "bochsdrmfb");
 	if (ret)
 		return ret;
 
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 05/13] drm/amdgpu: use simpler remove_conflicting_pci_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, Jonathan Hunter, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 0b19482b36b8..9b6e037719db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -560,28 +560,6 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
 
 static struct drm_driver kms_driver;
 
-static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev)
-{
-	struct apertures_struct *ap;
-	bool primary = false;
-
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
-
-#ifdef CONFIG_X86
-	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
-#endif
-	drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary);
-	kfree(ap);
-
-	return 0;
-}
-
-
 static int amdgpu_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *ent)
 {
@@ -609,7 +587,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 		return ret;
 
 	/* Get rid of things like offb */
-	ret = amdgpu_kick_out_firmware_fb(pdev);
+	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "amdgpudrmfb");
 	if (ret)
 		return ret;
 
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 07/13] drm/cirrus: use simpler remove_conflicting_pci_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, virtualization, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, Jonathan Hunter,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/cirrus/cirrus_drv.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 69c4e352dd78..85ed8657c862 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -42,33 +42,12 @@ static const struct pci_device_id pciidlist[] = {
 };
 
 
-static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
-{
-	struct apertures_struct *ap;
-	bool primary = false;
-
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
-
-#ifdef CONFIG_X86
-	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
-#endif
-	drm_fb_helper_remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary);
-	kfree(ap);
-
-	return 0;
-}
-
 static int cirrus_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *ent)
 {
 	int ret;
 
-	ret = cirrus_kick_out_firmware_fb(pdev);
+	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "cirrusdrmfb");
 	if (ret)
 		return ret;
 
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 09/13] drm/radeon: use simpler remove_conflicting_pci_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, Jonathan Hunter, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/radeon/radeon_drv.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index b28288a781ef..36c98a0ec991 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -311,27 +311,6 @@ static struct drm_driver kms_driver;
 
 bool radeon_device_is_virtual(void);
 
-static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
-{
-	struct apertures_struct *ap;
-	bool primary = false;
-
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
-
-#ifdef CONFIG_X86
-	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
-#endif
-	drm_fb_helper_remove_conflicting_framebuffers(ap, "radeondrmfb", primary);
-	kfree(ap);
-
-	return 0;
-}
-
 static int radeon_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *ent)
 {
@@ -341,7 +320,7 @@ static int radeon_pci_probe(struct pci_dev *pdev,
 		return -EPROBE_DEFER;
 
 	/* Get rid of things like offb */
-	ret = radeon_kick_out_firmware_fb(pdev);
+	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "radeondrmfb");
 	if (ret)
 		return ret;
 
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 08/13] drm/mgag200: use simpler remove_conflicting_pci_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, Jonathan Hunter, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Remove duplicated call, while at it.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/mgag200/mgag200_drv.c  | 21 +--------------------
 drivers/gpu/drm/mgag200/mgag200_main.c |  9 ---------
 2 files changed, 1 insertion(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 74cdde2ee474..ac6af4bd9df6 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -42,29 +42,10 @@ static const struct pci_device_id pciidlist[] = {
 
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
-static void mgag200_kick_out_firmware_fb(struct pci_dev *pdev)
-{
-	struct apertures_struct *ap;
-	bool primary = false;
-
-	ap = alloc_apertures(1);
-	if (!ap)
-		return;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
-
-#ifdef CONFIG_X86
-	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
-#endif
-	drm_fb_helper_remove_conflicting_framebuffers(ap, "mgag200drmfb", primary);
-	kfree(ap);
-}
-
 
 static int mga_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	mgag200_kick_out_firmware_fb(pdev);
+	drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "mgag200drmfb");
 
 	return drm_get_pci_dev(pdev, ent, &driver);
 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 780f983b0294..79d54103d470 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -124,20 +124,11 @@ static int mga_probe_vram(struct mga_device *mdev, void __iomem *mem)
 static int mga_vram_init(struct mga_device *mdev)
 {
 	void __iomem *mem;
-	struct apertures_struct *aper = alloc_apertures(1);
-	if (!aper)
-		return -ENOMEM;
 
 	/* BAR 0 is VRAM */
 	mdev->mc.vram_base = pci_resource_start(mdev->dev->pdev, 0);
 	mdev->mc.vram_window = pci_resource_len(mdev->dev->pdev, 0);
 
-	aper->ranges[0].base = mdev->mc.vram_base;
-	aper->ranges[0].size = mdev->mc.vram_window;
-
-	drm_fb_helper_remove_conflicting_framebuffers(aper, "mgafb", true);
-	kfree(aper);
-
 	if (!devm_request_mem_region(mdev->dev->dev, mdev->mc.vram_base, mdev->mc.vram_window,
 				"mgadrmfb_vram")) {
 		DRM_ERROR("can't reserve VRAM\n");
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 10/13] drm/virtio: use simpler remove_conflicting_pci_framebuffers()
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, virtualization, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, Jonathan Hunter,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
index 7df8d0c9026a..115ed546ca4e 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
@@ -28,26 +28,6 @@
 
 #include "virtgpu_drv.h"
 
-static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev)
-{
-	struct apertures_struct *ap;
-	bool primary;
-
-	ap = alloc_apertures(1);
-	if (!ap)
-		return;
-
-	ap->ranges[0].base = pci_resource_start(pci_dev, 0);
-	ap->ranges[0].size = pci_resource_len(pci_dev, 0);
-
-	primary = pci_dev->resource[PCI_ROM_RESOURCE].flags
-		& IORESOURCE_ROM_SHADOW;
-
-	drm_fb_helper_remove_conflicting_framebuffers(ap, "virtiodrmfb", primary);
-
-	kfree(ap);
-}
-
 int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
 {
 	struct drm_device *dev;
@@ -69,7 +49,9 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
 			 pname);
 		dev->pdev = pdev;
 		if (vga)
-			virtio_pci_kick_out_firmware_fb(pdev);
+			drm_fb_helper_remove_conflicting_pci_framebuffers(pdev,
+									  0,
+									  "virtiodrmfb");
 
 		snprintf(unique, sizeof(unique), "pci:%s", pname);
 		ret = drm_dev_set_unique(dev, unique);
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 11/13] drm/vc4: use simpler remove_conflicting_framebuffers(NULL)
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz, David Airlie,
	amd-gfx, Jonathan Hunter, Eric Anholt, Thierry Reding,
	Alex Deucher, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Use remove_conflicting_framebuffers(NULL) instead of open-coding it.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/vc4/vc4_drv.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 94b99c90425a..96bb90325995 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -246,24 +246,6 @@ static void vc4_match_add_drivers(struct device *dev,
 	}
 }
 
-static void vc4_kick_out_firmware_fb(void)
-{
-	struct apertures_struct *ap;
-
-	ap = alloc_apertures(1);
-	if (!ap)
-		return;
-
-	/* Since VC4 is a UMA device, the simplefb node may have been
-	 * located anywhere in memory.
-	 */
-	ap->ranges[0].base = 0;
-	ap->ranges[0].size = ~0;
-
-	drm_fb_helper_remove_conflicting_framebuffers(ap, "vc4drmfb", false);
-	kfree(ap);
-}
-
 static int vc4_drm_bind(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -296,7 +278,7 @@ static int vc4_drm_bind(struct device *dev)
 	if (ret)
 		goto gem_destroy;
 
-	vc4_kick_out_firmware_fb();
+	drm_fb_helper_remove_conflicting_framebuffers(NULL, "vc4drmfb", false);
 
 	ret = drm_dev_register(drm, 0);
 	if (ret < 0)
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 12/13] drm/sun4i: use simpler remove_conflicting_framebuffers(NULL)
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, linux-tegra, Bartlomiej Zolnierkiewicz,
	Maxime Ripard, Eric Anholt, amd-gfx, Jonathan Hunter,
	David Airlie, Thierry Reding, Alex Deucher, Dave Airlie,
	virtualization, linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Use remove_conflicting_framebuffers(NULL) instead of duplicating it.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 50d19605c38f..555b5db8036f 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -60,22 +60,6 @@ static struct drm_driver sun4i_drv_driver = {
 	/* Frame Buffer Operations */
 };
 
-static void sun4i_remove_framebuffers(void)
-{
-	struct apertures_struct *ap;
-
-	ap = alloc_apertures(1);
-	if (!ap)
-		return;
-
-	/* The framebuffer can be located anywhere in RAM */
-	ap->ranges[0].base = 0;
-	ap->ranges[0].size = ~0;
-
-	drm_fb_helper_remove_conflicting_framebuffers(ap, "sun4i-drm-fb", false);
-	kfree(ap);
-}
-
 static int sun4i_drv_bind(struct device *dev)
 {
 	struct drm_device *drm;
@@ -118,7 +102,7 @@ static int sun4i_drv_bind(struct device *dev)
 	drm->irq_enabled = true;
 
 	/* Remove early framebuffers (ie. simplefb) */
-	sun4i_remove_framebuffers();
+	drm_fb_helper_remove_conflicting_framebuffers(NULL, "sun4i-drm-fb", false);
 
 	/* Create our framebuffer */
 	ret = sun4i_framebuffer_init(drm);
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* [PATCH v3 13/13] drm/tegra: kick out simplefb
From: Michał Mirosław @ 2018-09-01 14:08 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, David Airlie, Eric Anholt,
	amd-gfx, Jonathan Hunter, Alex Deucher, Thierry Reding,
	linux-tegra, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

Kick out firmware fb when loading Tegra driver.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/tegra/drm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 7afe2f635f74..b51ec138fed2 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -1203,6 +1203,10 @@ static int host1x_drm_probe(struct host1x_device *dev)
 
 	dev_set_drvdata(&dev->dev, drm);
 
+	err = drm_fb_helper_remove_conflicting_framebuffers(NULL, "tegradrmfb", false);
+	if (err < 0)
+		goto unref;
+
 	err = drm_dev_register(drm, 0);
 	if (err < 0)
 		goto unref;
-- 
2.18.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related

* Re: [PATCH v3 00/13] remove_conflicting_framebuffers() cleanup
From: Daniel Vetter @ 2018-09-03  7:43 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, David Airlie, amd-gfx,
	Jonathan Hunter, Alex Deucher, Thierry Reding, dri-devel,
	linux-tegra, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <cover.1535810304.git.mirq-linux@rere.qmqm.pl>

On Sat, Sep 01, 2018 at 04:08:41PM +0200, Michał Mirosław wrote:
> This series cleans up duplicated code for replacing firmware FB
> driver with proper DRI driver and adds handover support to
> Tegra driver.
> 
> This is a sligtly updated version of a series sent on 24 Nov 2017.
> 
> ---
> v2:
>  - rebased on current drm-next
>  - dropped staging/sm750fb changes
>  - added kernel docs for DRM helpers
> v3:
>  - move kerneldoc to fbdev, where functions are implemented
>  - split kerneldoc for remove_conflicting_framebuffers()

Ah, that's not quite what I had in mind. I think having the docs (also) in
the drm helpers would be good, since that's where drm people will look,
and that's the function they'll call. I just wanted you to split the fbdev
and drm parts into 2 patches (since those are two different maintainers).

Anyway, this is ok too, so imo ready for merging. If you can resurrect the
drm docs (with a patch title of "drm/fb-helper: document fbdev remove
functions" or similar) that would be great.

Only thing we need for merging now is the ack from Bartlomiej.
-Daniel

>  - propagate return value in remove_conflicting_pci_framebuffers()
> 
> ---
> Michał Mirosław (13):
>   fbdev: show fbdev number for debugging
>   fbdev: allow apertures == NULL in remove_conflicting_framebuffers()
>   fbdev: add kerneldoc do remove_conflicting_framebuffers()
>   fbdev: add remove_conflicting_pci_framebuffers()
>   drm/amdgpu: use simpler remove_conflicting_pci_framebuffers()
>   drm/bochs: use simpler remove_conflicting_pci_framebuffers()
>   drm/cirrus: use simpler remove_conflicting_pci_framebuffers()
>   drm/mgag200: use simpler remove_conflicting_pci_framebuffers()
>   drm/radeon: use simpler remove_conflicting_pci_framebuffers()
>   drm/virtio: use simpler remove_conflicting_pci_framebuffers()
>   drm/vc4: use simpler remove_conflicting_framebuffers(NULL)
>   drm/sun4i: use simpler remove_conflicting_framebuffers(NULL)
>   drm/tegra: kick out simplefb
> 
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  | 24 +--------
>  drivers/gpu/drm/bochs/bochs_drv.c        | 18 +------
>  drivers/gpu/drm/cirrus/cirrus_drv.c      | 23 +--------
>  drivers/gpu/drm/mgag200/mgag200_drv.c    | 21 +-------
>  drivers/gpu/drm/mgag200/mgag200_main.c   |  9 ----
>  drivers/gpu/drm/radeon/radeon_drv.c      | 23 +--------
>  drivers/gpu/drm/sun4i/sun4i_drv.c        | 18 +------
>  drivers/gpu/drm/tegra/drm.c              |  4 ++
>  drivers/gpu/drm/vc4/vc4_drv.c            | 20 +-------
>  drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 ++-------
>  drivers/video/fbdev/core/fbmem.c         | 63 +++++++++++++++++++++++-
>  include/drm/drm_fb_helper.h              | 12 +++++
>  include/linux/fb.h                       |  2 +
>  13 files changed, 89 insertions(+), 172 deletions(-)
> 
> -- 
> 2.18.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* [PATCH 4/5] drm/bochs: fix DRM_FORMAT_* handling for big endian machines.
From: Gerd Hoffmann @ 2018-09-03 10:57 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, open list,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU
In-Reply-To: <20180903105756.24912-1-kraxel@redhat.com>

Use DRM_FORMAT_HOST_XRGB8888, so we are using the correct format code
on bigendian machines.  Also add DRIVER_PREFER_HOST_BYTE_ORDER driver
feature flag so drm_mode_addfb() asks for the correct format code.

Create our own plane and use drm_crtc_init_with_planes() instead of
depending on the default created by drm_crtc_init().  That way the plane
format list is correct on bigendian machines.

With this patch applied both ADDFB and ADDFB2 ioctls work correctly in
the bochs-drm.ko driver on big endian machines.  Without the patch only
ADDFB (which still seems to be used by the majority of userspace) works
correctly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/bochs/bochs_drv.c   |  3 ++-
 drivers/gpu/drm/bochs/bochs_fbdev.c |  5 ++---
 drivers/gpu/drm/bochs/bochs_kms.c   | 33 ++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/bochs/bochs_mm.c    |  2 +-
 4 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
index 7b20318483..fa84a3c841 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -81,7 +81,8 @@ static const struct file_operations bochs_fops = {
 };
 
 static struct drm_driver bochs_driver = {
-	.driver_features	= DRIVER_GEM | DRIVER_MODESET,
+	.driver_features	= (DRIVER_GEM | DRIVER_MODESET |
+				   DRIVER_PREFER_HOST_BYTE_ORDER),
 	.load			= bochs_load,
 	.unload			= bochs_unload,
 	.fops			= &bochs_fops,
diff --git a/drivers/gpu/drm/bochs/bochs_fbdev.c b/drivers/gpu/drm/bochs/bochs_fbdev.c
index 14eb8d0d5a..bf728790fa 100644
--- a/drivers/gpu/drm/bochs/bochs_fbdev.c
+++ b/drivers/gpu/drm/bochs/bochs_fbdev.c
@@ -64,9 +64,8 @@ static int bochsfb_create(struct drm_fb_helper *helper,
 
 	mode_cmd.width = sizes->surface_width;
 	mode_cmd.height = sizes->surface_height;
-	mode_cmd.pitches[0] = mode_cmd.width * ((sizes->surface_bpp + 7) / 8);
-	mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
-							  sizes->surface_depth);
+	mode_cmd.pitches[0] = sizes->surface_width * 4;
+	mode_cmd.pixel_format = DRM_FORMAT_HOST_XRGB8888;
 	size = mode_cmd.pitches[0] * mode_cmd.height;
 
 	/* alloc, pin & map bo */
diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index ca5a9afdd5..2662cdcf2d 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -129,12 +129,43 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
 	.commit = bochs_crtc_commit,
 };
 
+static const uint32_t bochs_formats[] = {
+	DRM_FORMAT_HOST_XRGB8888,
+};
+
+static struct drm_plane *bochs_primary_plane(struct drm_device *dev)
+{
+	struct drm_plane *primary;
+	int ret;
+
+	primary = kzalloc(sizeof(*primary), GFP_KERNEL);
+	if (primary == NULL) {
+		DRM_DEBUG_KMS("Failed to allocate primary plane\n");
+		return NULL;
+	}
+
+	ret = drm_universal_plane_init(dev, primary, 0,
+				       &drm_primary_helper_funcs,
+				       bochs_formats,
+				       ARRAY_SIZE(bochs_formats),
+				       NULL,
+				       DRM_PLANE_TYPE_PRIMARY, NULL);
+	if (ret) {
+		kfree(primary);
+		primary = NULL;
+	}
+
+	return primary;
+}
+
 static void bochs_crtc_init(struct drm_device *dev)
 {
 	struct bochs_device *bochs = dev->dev_private;
 	struct drm_crtc *crtc = &bochs->crtc;
+	struct drm_plane *primary = bochs_primary_plane(dev);
 
-	drm_crtc_init(dev, crtc, &bochs_crtc_funcs);
+	drm_crtc_init_with_planes(dev, crtc, primary, NULL,
+				  &bochs_crtc_funcs, NULL);
 	drm_crtc_helper_add(crtc, &bochs_helper_funcs);
 }
 
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index c9c7097030..fdf151fbdb 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -506,7 +506,7 @@ bochs_user_framebuffer_create(struct drm_device *dev,
 	       (mode_cmd->pixel_format >> 16) & 0xff,
 	       (mode_cmd->pixel_format >> 24) & 0xff);
 
-	if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888)
+	if (mode_cmd->pixel_format != DRM_FORMAT_HOST_XRGB8888)
 		return ERR_PTR(-ENOENT);
 
 	obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
-- 
2.9.3

^ permalink raw reply related

* [PATCH 5/5] drm/virtio: fix DRM_FORMAT_* handling
From: Gerd Hoffmann @ 2018-09-03 10:57 UTC (permalink / raw)
  To: dri-devel; +Cc: David Airlie, open list, open list:VIRTIO GPU DRIVER
In-Reply-To: <20180903105756.24912-1-kraxel@redhat.com>

Use DRM_FORMAT_HOST_XRGB8888, so we are using the correct format code
on bigendian machines.  Also add DRIVER_PREFER_HOST_BYTE_ORDER driver
feature flag so drm_mode_addfb() asks for the correct format code.

Both DRM_FORMAT_* and VIRTIO_GPU_FORMAT_* are defined to be little
endian, so using a different mapping on bigendian machines is wrong.
It's there because of broken drm_mode_addfb() behavior.  So with
drm_mode_addfb() being fixed we can fix this too.

While wading through the code I've noticed we have a little issue in
virtio:  We attach a format to the bo when it is created
(DRM_IOCTL_MODE_CREATE_DUMB), not when we map it as framebuffer
(DRM_IOCTL_MODE_ADDFB).  Easy way out:  Support a single format only.
Pick DRM_FORMAT_HOST_XRGB8888, it is the only one actually used in
practice.  Drop unused mappings in virtio_gpu_translate_format().

With this patch applied both ADDFB and ADDFB2 ioctls work correctly in
the virtio-gpu.ko driver on big endian machines.  Without the patch only
ADDFB (which still seems to be used by the majority of userspace) works
correctly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/virtio/virtgpu_display.c |  4 +++
 drivers/gpu/drm/virtio/virtgpu_drv.c     |  4 ++-
 drivers/gpu/drm/virtio/virtgpu_fb.c      |  2 +-
 drivers/gpu/drm/virtio/virtgpu_gem.c     |  7 +++--
 drivers/gpu/drm/virtio/virtgpu_plane.c   | 54 ++------------------------------
 5 files changed, 15 insertions(+), 56 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 25503b9335..f6c4af1db4 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -306,6 +306,10 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,
 	struct virtio_gpu_framebuffer *virtio_gpu_fb;
 	int ret;
 
+	if (mode_cmd->pixel_format != DRM_FORMAT_HOST_XRGB8888 &&
+	    mode_cmd->pixel_format != DRM_FORMAT_HOST_ARGB8888)
+		return ERR_PTR(-ENOENT);
+
 	/* lookup object associated with res handle */
 	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
 	if (!obj)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
index d9287c144f..4b28f41ac1 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -114,7 +114,9 @@ static const struct file_operations virtio_gpu_driver_fops = {
 };
 
 static struct drm_driver driver = {
-	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER | DRIVER_ATOMIC,
+	.driver_features = (DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
+			    DRIVER_RENDER | DRIVER_ATOMIC |
+			    DRIVER_PREFER_HOST_BYTE_ORDER),
 	.load = virtio_gpu_driver_load,
 	.unload = virtio_gpu_driver_unload,
 	.open = virtio_gpu_driver_open,
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index a121b1c795..9d87ebd645 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -233,7 +233,7 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
 	mode_cmd.width = sizes->surface_width;
 	mode_cmd.height = sizes->surface_height;
 	mode_cmd.pitches[0] = mode_cmd.width * 4;
-	mode_cmd.pixel_format = drm_mode_legacy_fb_format(32, 24);
+	mode_cmd.pixel_format = DRM_FORMAT_HOST_XRGB8888;
 
 	format = virtio_gpu_translate_format(mode_cmd.pixel_format);
 	if (format == 0)
diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c
index 0f2768eaca..82c817f37c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_gem.c
+++ b/drivers/gpu/drm/virtio/virtgpu_gem.c
@@ -90,7 +90,10 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	uint32_t resid;
 	uint32_t format;
 
-	pitch = args->width * ((args->bpp + 1) / 8);
+	if (args->bpp != 32)
+		return -EINVAL;
+
+	pitch = args->width * 4;
 	args->size = pitch * args->height;
 	args->size = ALIGN(args->size, PAGE_SIZE);
 
@@ -99,7 +102,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	if (ret)
 		goto fail;
 
-	format = virtio_gpu_translate_format(DRM_FORMAT_XRGB8888);
+	format = virtio_gpu_translate_format(DRM_FORMAT_HOST_XRGB8888);
 	virtio_gpu_resource_id_get(vgdev, &resid);
 	virtio_gpu_cmd_create_resource(vgdev, resid, format,
 				       args->width, args->height);
diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
index dc5b5b2b7a..3221d50b9a 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -28,22 +28,11 @@
 #include <drm/drm_atomic_helper.h>
 
 static const uint32_t virtio_gpu_formats[] = {
-	DRM_FORMAT_XRGB8888,
-	DRM_FORMAT_ARGB8888,
-	DRM_FORMAT_BGRX8888,
-	DRM_FORMAT_BGRA8888,
-	DRM_FORMAT_RGBX8888,
-	DRM_FORMAT_RGBA8888,
-	DRM_FORMAT_XBGR8888,
-	DRM_FORMAT_ABGR8888,
+	DRM_FORMAT_HOST_XRGB8888,
 };
 
 static const uint32_t virtio_gpu_cursor_formats[] = {
-#ifdef __BIG_ENDIAN
-	DRM_FORMAT_BGRA8888,
-#else
-	DRM_FORMAT_ARGB8888,
-#endif
+	DRM_FORMAT_HOST_ARGB8888,
 };
 
 uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
@@ -51,32 +40,6 @@ uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
 	uint32_t format;
 
 	switch (drm_fourcc) {
-#ifdef __BIG_ENDIAN
-	case DRM_FORMAT_XRGB8888:
-		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_ARGB8888:
-		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_BGRX8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
-		break;
-	case DRM_FORMAT_BGRA8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
-		break;
-	case DRM_FORMAT_RGBX8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
-		break;
-	case DRM_FORMAT_RGBA8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
-		break;
-	case DRM_FORMAT_XBGR8888:
-		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_ABGR8888:
-		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
-		break;
-#else
 	case DRM_FORMAT_XRGB8888:
 		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
 		break;
@@ -89,19 +52,6 @@ uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
 	case DRM_FORMAT_BGRA8888:
 		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
 		break;
-	case DRM_FORMAT_RGBX8888:
-		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_RGBA8888:
-		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_XBGR8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
-		break;
-	case DRM_FORMAT_ABGR8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
-		break;
-#endif
 	default:
 		/*
 		 * This should not happen, we handle everything listed
-- 
2.9.3

^ permalink raw reply related

* Re: [PATCH v3 00/13] remove_conflicting_framebuffers() cleanup
From: Bartlomiej Zolnierkiewicz @ 2018-09-03 11:31 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-fbdev, David Airlie, amd-gfx, Michał Mirosław,
	Alex Deucher, Thierry Reding, dri-devel, linux-tegra, Dave Airlie,
	Maxime Ripard, Jonathan Hunter, virtualization, linux-arm-kernel
In-Reply-To: <20180903074315.GB21634@phenom.ffwll.local>

On Monday, September 03, 2018 09:43:15 AM Daniel Vetter wrote:
> On Sat, Sep 01, 2018 at 04:08:41PM +0200, Michał Mirosław wrote:
> > This series cleans up duplicated code for replacing firmware FB
> > driver with proper DRI driver and adds handover support to
> > Tegra driver.
> > 
> > This is a sligtly updated version of a series sent on 24 Nov 2017.
> > 
> > ---
> > v2:
> >  - rebased on current drm-next
> >  - dropped staging/sm750fb changes
> >  - added kernel docs for DRM helpers
> > v3:
> >  - move kerneldoc to fbdev, where functions are implemented
> >  - split kerneldoc for remove_conflicting_framebuffers()
> 
> Ah, that's not quite what I had in mind. I think having the docs (also) in
> the drm helpers would be good, since that's where drm people will look,
> and that's the function they'll call. I just wanted you to split the fbdev
> and drm parts into 2 patches (since those are two different maintainers).
> 
> Anyway, this is ok too, so imo ready for merging. If you can resurrect the
> drm docs (with a patch title of "drm/fb-helper: document fbdev remove
> functions" or similar) that would be great.
> 
> Only thing we need for merging now is the ack from Bartlomiej.

For the whole patchset:

Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

> -Daniel
> 
> >  - propagate return value in remove_conflicting_pci_framebuffers()
> > 
> > ---
> > Michał Mirosław (13):
> >   fbdev: show fbdev number for debugging
> >   fbdev: allow apertures == NULL in remove_conflicting_framebuffers()
> >   fbdev: add kerneldoc do remove_conflicting_framebuffers()
> >   fbdev: add remove_conflicting_pci_framebuffers()
> >   drm/amdgpu: use simpler remove_conflicting_pci_framebuffers()
> >   drm/bochs: use simpler remove_conflicting_pci_framebuffers()
> >   drm/cirrus: use simpler remove_conflicting_pci_framebuffers()
> >   drm/mgag200: use simpler remove_conflicting_pci_framebuffers()
> >   drm/radeon: use simpler remove_conflicting_pci_framebuffers()
> >   drm/virtio: use simpler remove_conflicting_pci_framebuffers()
> >   drm/vc4: use simpler remove_conflicting_framebuffers(NULL)
> >   drm/sun4i: use simpler remove_conflicting_framebuffers(NULL)
> >   drm/tegra: kick out simplefb
> > 
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  | 24 +--------
> >  drivers/gpu/drm/bochs/bochs_drv.c        | 18 +------
> >  drivers/gpu/drm/cirrus/cirrus_drv.c      | 23 +--------
> >  drivers/gpu/drm/mgag200/mgag200_drv.c    | 21 +-------
> >  drivers/gpu/drm/mgag200/mgag200_main.c   |  9 ----
> >  drivers/gpu/drm/radeon/radeon_drv.c      | 23 +--------
> >  drivers/gpu/drm/sun4i/sun4i_drv.c        | 18 +------
> >  drivers/gpu/drm/tegra/drm.c              |  4 ++
> >  drivers/gpu/drm/vc4/vc4_drv.c            | 20 +-------
> >  drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 ++-------
> >  drivers/video/fbdev/core/fbmem.c         | 63 +++++++++++++++++++++++-
> >  include/drm/drm_fb_helper.h              | 12 +++++
> >  include/linux/fb.h                       |  2 +
> >  13 files changed, 89 insertions(+), 172 deletions(-)

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH v3 04/13] fbdev: add remove_conflicting_pci_framebuffers()
From: Daniel Vetter @ 2018-09-03 16:16 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, David Airlie, amd-gfx,
	Jonathan Hunter, Alex Deucher, Thierry Reding, dri-devel,
	linux-tegra, Dave Airlie, Maxime Ripard, virtualization,
	linux-arm-kernel
In-Reply-To: <7db1c278276de420eb45a1b71d06b5eb6bbd49ef.1535810304.git.mirq-linux@rere.qmqm.pl>

On Sat, Sep 01, 2018 at 04:08:45PM +0200, Michał Mirosław wrote:
> Almost all PCI drivers using remove_conflicting_framebuffers() wrap it
> with the same code.
> 
> ---

This cuts away the sob. Just fyi.
-Daniel

> v2: add kerneldoc for DRM helper
> v3: propagate remove_conflicting_framebuffers() return value
>   + move kerneldoc to where function is implemented
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/video/fbdev/core/fbmem.c | 35 ++++++++++++++++++++++++++++++++
>  include/drm/drm_fb_helper.h      | 12 +++++++++++
>  include/linux/fb.h               |  2 ++
>  3 files changed, 49 insertions(+)
> 
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 2de93b5014e3..cd96b1c62bbe 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -34,6 +34,7 @@
>  #include <linux/fb.h>
>  #include <linux/fbcon.h>
>  #include <linux/mem_encrypt.h>
> +#include <linux/pci.h>
>  
>  #include <asm/fb.h>
>  
> @@ -1812,6 +1813,40 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
>  }
>  EXPORT_SYMBOL(remove_conflicting_framebuffers);
>  
> +/**
> + * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices
> + * @pdev: PCI device
> + * @resource_id: index of PCI BAR configuring framebuffer memory
> + * @name: requesting driver name
> + *
> + * This function removes framebuffer devices (eg. initialized by firmware)
> + * using memory range configured for @pdev's BAR @resource_id.
> + *
> + * The function assumes that PCI device with shadowed ROM drives a primary
> + * display and so kicks out vga16fb.
> + */
> +int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const char *name)
> +{
> +	struct apertures_struct *ap;
> +	bool primary = false;
> +	int err;
> +
> +	ap = alloc_apertures(1);
> +	if (!ap)
> +		return -ENOMEM;
> +
> +	ap->ranges[0].base = pci_resource_start(pdev, res_id);
> +	ap->ranges[0].size = pci_resource_len(pdev, res_id);
> +#ifdef CONFIG_X86
> +	primary = pdev->resource[PCI_ROM_RESOURCE].flags &
> +					IORESOURCE_ROM_SHADOW;
> +#endif
> +	err = remove_conflicting_framebuffers(ap, name, primary);
> +	kfree(ap);
> +	return err;
> +}
> +EXPORT_SYMBOL(remove_conflicting_pci_framebuffers);
> +
>  /**
>   *	register_framebuffer - registers a frame buffer device
>   *	@fb_info: frame buffer info structure
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index b069433e7fc1..20ea856db900 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -577,4 +577,16 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
>  #endif
>  }
>  
> +static inline int
> +drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
> +						  int resource_id,
> +						  const char *name)
> +{
> +#if IS_REACHABLE(CONFIG_FB)
> +	return remove_conflicting_pci_framebuffers(pdev, resource_id, name);
> +#else
> +	return 0;
> +#endif
> +}
> +
>  #endif
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index aa74a228bb92..abeffd55b66a 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -632,6 +632,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
>  extern int register_framebuffer(struct fb_info *fb_info);
>  extern int unregister_framebuffer(struct fb_info *fb_info);
>  extern int unlink_framebuffer(struct fb_info *fb_info);
> +extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id,
> +					       const char *name);
>  extern int remove_conflicting_framebuffers(struct apertures_struct *a,
>  					   const char *name, bool primary);
>  extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
> -- 
> 2.18.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH v3 00/13] remove_conflicting_framebuffers() cleanup
From: Daniel Vetter @ 2018-09-03 16:26 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: linux-fbdev, David Airlie, dri-devel, Michał Mirosław,
	Alex Deucher, Thierry Reding, amd-gfx, Daniel Vetter, linux-tegra,
	Dave Airlie, Maxime Ripard, Jonathan Hunter, virtualization,
	linux-arm-kernel
In-Reply-To: <1705932.lAR3QV8q47@amdc3058>

On Mon, Sep 03, 2018 at 01:31:34PM +0200, Bartlomiej Zolnierkiewicz wrote:
> On Monday, September 03, 2018 09:43:15 AM Daniel Vetter wrote:
> > On Sat, Sep 01, 2018 at 04:08:41PM +0200, Michał Mirosław wrote:
> > > This series cleans up duplicated code for replacing firmware FB
> > > driver with proper DRI driver and adds handover support to
> > > Tegra driver.
> > > 
> > > This is a sligtly updated version of a series sent on 24 Nov 2017.
> > > 
> > > ---
> > > v2:
> > >  - rebased on current drm-next
> > >  - dropped staging/sm750fb changes
> > >  - added kernel docs for DRM helpers
> > > v3:
> > >  - move kerneldoc to fbdev, where functions are implemented
> > >  - split kerneldoc for remove_conflicting_framebuffers()
> > 
> > Ah, that's not quite what I had in mind. I think having the docs (also) in
> > the drm helpers would be good, since that's where drm people will look,
> > and that's the function they'll call. I just wanted you to split the fbdev
> > and drm parts into 2 patches (since those are two different maintainers).
> > 
> > Anyway, this is ok too, so imo ready for merging. If you can resurrect the
> > drm docs (with a patch title of "drm/fb-helper: document fbdev remove
> > functions" or similar) that would be great.
> > 
> > Only thing we need for merging now is the ack from Bartlomiej.
> 
> For the whole patchset:
> 
> Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

Thanks, entire patch set applied to drm-misc-next for 4.20.
-Daniel

> 
> > -Daniel
> > 
> > >  - propagate return value in remove_conflicting_pci_framebuffers()
> > > 
> > > ---
> > > Michał Mirosław (13):
> > >   fbdev: show fbdev number for debugging
> > >   fbdev: allow apertures == NULL in remove_conflicting_framebuffers()
> > >   fbdev: add kerneldoc do remove_conflicting_framebuffers()
> > >   fbdev: add remove_conflicting_pci_framebuffers()
> > >   drm/amdgpu: use simpler remove_conflicting_pci_framebuffers()
> > >   drm/bochs: use simpler remove_conflicting_pci_framebuffers()
> > >   drm/cirrus: use simpler remove_conflicting_pci_framebuffers()
> > >   drm/mgag200: use simpler remove_conflicting_pci_framebuffers()
> > >   drm/radeon: use simpler remove_conflicting_pci_framebuffers()
> > >   drm/virtio: use simpler remove_conflicting_pci_framebuffers()
> > >   drm/vc4: use simpler remove_conflicting_framebuffers(NULL)
> > >   drm/sun4i: use simpler remove_conflicting_framebuffers(NULL)
> > >   drm/tegra: kick out simplefb
> > > 
> > >  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  | 24 +--------
> > >  drivers/gpu/drm/bochs/bochs_drv.c        | 18 +------
> > >  drivers/gpu/drm/cirrus/cirrus_drv.c      | 23 +--------
> > >  drivers/gpu/drm/mgag200/mgag200_drv.c    | 21 +-------
> > >  drivers/gpu/drm/mgag200/mgag200_main.c   |  9 ----
> > >  drivers/gpu/drm/radeon/radeon_drv.c      | 23 +--------
> > >  drivers/gpu/drm/sun4i/sun4i_drv.c        | 18 +------
> > >  drivers/gpu/drm/tegra/drm.c              |  4 ++
> > >  drivers/gpu/drm/vc4/vc4_drv.c            | 20 +-------
> > >  drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 ++-------
> > >  drivers/video/fbdev/core/fbmem.c         | 63 +++++++++++++++++++++++-
> > >  include/drm/drm_fb_helper.h              | 12 +++++
> > >  include/linux/fb.h                       |  2 +
> > >  13 files changed, 89 insertions(+), 172 deletions(-)
> 
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* [PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
From: Gleb Fotengauer-Malinovskiy @ 2018-09-03 17:59 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, David S. Miller, kvm,
	virtualization, netdev, linux-kernel

The _IOC_READ flag fits this ioctl request more because this request
actually only writes to, but doesn't read from userspace.
See NOTEs in include/uapi/asm-generic/ioctl.h for more information.

Fixes: 429711aec282 ("vhost: switch to use new message format")
Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
---
 include/uapi/linux/vhost.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index b1e22c40c4b6..84c3de89696a 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -176,7 +176,7 @@ struct vhost_memory {
 #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
 
 #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
-#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64)
+#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
 
 /* VHOST_NET specific defines */
 

-- 
glebfm

^ permalink raw reply related

* Re: [PATCH] drm/virtio: track virtual output state
From: Dave Airlie @ 2018-09-03 23:42 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Dave Airlie, LKML, dri-devel, open list:VIRTIO CORE, NET...
In-Reply-To: <20180813152855.12863-1-kraxel@redhat.com>

On Tue, 14 Aug 2018 at 01:30, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Track whenever an virtual output (crtc) is enabled or disabled.
>
> On atomic updates check for both framebuffer being present and crtc
> being enabled to figure whenever the output is active or not.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_drv.h     | 1 +
>  drivers/gpu/drm/virtio/virtgpu_display.c | 4 ++++
>  drivers/gpu/drm/virtio/virtgpu_plane.c   | 2 +-
>  3 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
> index 65605e207b..d46f10e656 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.h
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
> @@ -114,6 +114,7 @@ struct virtio_gpu_output {
>         struct virtio_gpu_update_cursor cursor;
>         int cur_x;
>         int cur_y;
> +       bool enabled;
>  };
>  #define drm_crtc_to_virtio_gpu_output(x) \
>         container_of(x, struct virtio_gpu_output, crtc)
> diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
> index 25503b9335..9f1e0a669d 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_display.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
> @@ -109,6 +109,9 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)
>  static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
>                                           struct drm_crtc_state *old_state)
>  {
> +       struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
> +
> +       output->enabled = true;
>  }
>
>  static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
> @@ -119,6 +122,7 @@ static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
>         struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
>
>         virtio_gpu_cmd_set_scanout(vgdev, output->index, 0, 0, 0, 0, 0);
> +       output->enabled = false;
>  }
>
>  static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
> index dc5b5b2b7a..88f2fb8c61 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
> @@ -152,7 +152,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
>         if (WARN_ON(!output))
>                 return;
>
> -       if (plane->state->fb) {
> +       if (plane->state->fb && output->enabled) {
>                 vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
>                 bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
>                 handle = bo->hw_res_handle;
> --
> 2.9.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply

* Re: [virtio-dev] [PATCH 2/2] drm/virtio: add iommu support.
From: Dave Airlie @ 2018-09-03 23:50 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Dave Airlie, virtio-dev, LKML, dri-devel,
	open list:VIRTIO CORE, NET...
In-Reply-To: <20180829122026.27012-3-kraxel@redhat.com>

For the series,

Reviewed-by: Dave Airlie <airlied@redhat.com>
On Wed, 29 Aug 2018 at 22:20, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Use the dma mapping api and properly add iommu mappings for
> objects, unless virtio is in iommu quirk mode.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_drv.h |  1 +
>  drivers/gpu/drm/virtio/virtgpu_vq.c  | 46 +++++++++++++++++++++++++++++-------
>  2 files changed, 38 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
> index cbbff01077..ec9a38f995 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.h
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
> @@ -57,6 +57,7 @@ struct virtio_gpu_object {
>         uint32_t hw_res_handle;
>
>         struct sg_table *pages;
> +       uint32_t mapped;
>         void *vmap;
>         bool dumb;
>         struct ttm_place                placement_code;
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index af24e91267..bf631d32d4 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -424,7 +424,8 @@ void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
>  }
>
>  static void virtio_gpu_cmd_resource_inval_backing(struct virtio_gpu_device *vgdev,
> -                                                 uint32_t resource_id)
> +                                                 uint32_t resource_id,
> +                                                 struct virtio_gpu_fence **fence)
>  {
>         struct virtio_gpu_resource_detach_backing *cmd_p;
>         struct virtio_gpu_vbuffer *vbuf;
> @@ -435,7 +436,7 @@ static void virtio_gpu_cmd_resource_inval_backing(struct virtio_gpu_device *vgde
>         cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING);
>         cmd_p->resource_id = cpu_to_le32(resource_id);
>
> -       virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
> +       virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, &cmd_p->hdr, fence);
>  }
>
>  void virtio_gpu_cmd_set_scanout(struct virtio_gpu_device *vgdev,
> @@ -848,9 +849,10 @@ int virtio_gpu_object_attach(struct virtio_gpu_device *vgdev,
>                              uint32_t resource_id,
>                              struct virtio_gpu_fence **fence)
>  {
> +       bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev);
>         struct virtio_gpu_mem_entry *ents;
>         struct scatterlist *sg;
> -       int si;
> +       int si, nents;
>
>         if (!obj->pages) {
>                 int ret;
> @@ -860,23 +862,33 @@ int virtio_gpu_object_attach(struct virtio_gpu_device *vgdev,
>                         return ret;
>         }
>
> +       if (use_dma_api) {
> +               obj->mapped = dma_map_sg(vgdev->vdev->dev.parent,
> +                                        obj->pages->sgl, obj->pages->nents,
> +                                        DMA_TO_DEVICE);
> +               nents = obj->mapped;
> +       } else {
> +               nents = obj->pages->nents;
> +       }
> +
>         /* gets freed when the ring has consumed it */
> -       ents = kmalloc_array(obj->pages->nents,
> -                            sizeof(struct virtio_gpu_mem_entry),
> +       ents = kmalloc_array(nents, sizeof(struct virtio_gpu_mem_entry),
>                              GFP_KERNEL);
>         if (!ents) {
>                 DRM_ERROR("failed to allocate ent list\n");
>                 return -ENOMEM;
>         }
>
> -       for_each_sg(obj->pages->sgl, sg, obj->pages->nents, si) {
> -               ents[si].addr = cpu_to_le64(sg_phys(sg));
> +       for_each_sg(obj->pages->sgl, sg, nents, si) {
> +               ents[si].addr = cpu_to_le64(use_dma_api
> +                                           ? sg_dma_address(sg)
> +                                           : sg_phys(sg));
>                 ents[si].length = cpu_to_le32(sg->length);
>                 ents[si].padding = 0;
>         }
>
>         virtio_gpu_cmd_resource_attach_backing(vgdev, resource_id,
> -                                              ents, obj->pages->nents,
> +                                              ents, nents,
>                                                fence);
>         obj->hw_res_handle = resource_id;
>         return 0;
> @@ -885,7 +897,23 @@ int virtio_gpu_object_attach(struct virtio_gpu_device *vgdev,
>  void virtio_gpu_object_detach(struct virtio_gpu_device *vgdev,
>                               struct virtio_gpu_object *obj)
>  {
> -       virtio_gpu_cmd_resource_inval_backing(vgdev, obj->hw_res_handle);
> +       bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev);
> +       struct virtio_gpu_fence *fence;
> +
> +       if (use_dma_api && obj->mapped) {
> +               /* detach backing and wait for the host process it ... */
> +               virtio_gpu_cmd_resource_inval_backing(vgdev, obj->hw_res_handle, &fence);
> +               dma_fence_wait(&fence->f, true);
> +               dma_fence_put(&fence->f);
> +
> +               /* ... then tear down iommu mappings */
> +               dma_unmap_sg(vgdev->vdev->dev.parent,
> +                            obj->pages->sgl, obj->mapped,
> +                            DMA_TO_DEVICE);
> +               obj->mapped = 0;
> +       } else {
> +               virtio_gpu_cmd_resource_inval_backing(vgdev, obj->hw_res_handle, NULL);
> +       }
>  }
>
>  void virtio_gpu_cursor_ping(struct virtio_gpu_device *vgdev,
> --
> 2.9.3
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
>

^ permalink raw reply

* Re: [PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
From: Michael S. Tsirkin @ 2018-09-04  2:22 UTC (permalink / raw)
  To: Gleb Fotengauer-Malinovskiy
  Cc: kvm, netdev, linux-kernel, virtualization, David S. Miller
In-Reply-To: <20180903175906.GA11529@glebfm.cloud.tilaa.com>

On Mon, Sep 03, 2018 at 08:59:13PM +0300, Gleb Fotengauer-Malinovskiy wrote:
> The _IOC_READ flag fits this ioctl request more because this request
> actually only writes to, but doesn't read from userspace.
> See NOTEs in include/uapi/asm-generic/ioctl.h for more information.
> 
> Fixes: 429711aec282 ("vhost: switch to use new message format")
> Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>

Hmm it does make sense, and it's not too late to fix this up.
Jason, what's your take on this? Was _IOW intentional?


> ---
>  include/uapi/linux/vhost.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> index b1e22c40c4b6..84c3de89696a 100644
> --- a/include/uapi/linux/vhost.h
> +++ b/include/uapi/linux/vhost.h
> @@ -176,7 +176,7 @@ struct vhost_memory {
>  #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
>  
>  #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
> -#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64)
> +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
>  
>  /* VHOST_NET specific defines */
>  
> 
> -- 
> glebfm

^ permalink raw reply

* Re: [PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
From: Jason Wang @ 2018-09-04  3:08 UTC (permalink / raw)
  To: Michael S. Tsirkin, Gleb Fotengauer-Malinovskiy
  Cc: netdev, linux-kernel, David S. Miller, kvm, virtualization
In-Reply-To: <20180903222127-mutt-send-email-mst@kernel.org>



On 2018年09月04日 10:22, Michael S. Tsirkin wrote:
> On Mon, Sep 03, 2018 at 08:59:13PM +0300, Gleb Fotengauer-Malinovskiy wrote:
>> The _IOC_READ flag fits this ioctl request more because this request
>> actually only writes to, but doesn't read from userspace.
>> See NOTEs in include/uapi/asm-generic/ioctl.h for more information.
>>
>> Fixes: 429711aec282 ("vhost: switch to use new message format")
>> Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
> Hmm it does make sense, and it's not too late to fix this up.
> Jason, what's your take on this? Was _IOW intentional?

My bad, not intentional. And I agree that fixing this is not too late.

So

Acked-by: Jason Wang <jasowang@redhat.com>

>
>> ---
>>   include/uapi/linux/vhost.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
>> index b1e22c40c4b6..84c3de89696a 100644
>> --- a/include/uapi/linux/vhost.h
>> +++ b/include/uapi/linux/vhost.h
>> @@ -176,7 +176,7 @@ struct vhost_memory {
>>   #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
>>   
>>   #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
>> -#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64)
>> +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
>>   
>>   /* VHOST_NET specific defines */
>>   
>>
>> -- 
>> glebfm

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply

* Re: [PATCH] vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition
From: Michael S. Tsirkin @ 2018-09-04  3:11 UTC (permalink / raw)
  To: Jason Wang
  Cc: kvm, netdev, Gleb Fotengauer-Malinovskiy, linux-kernel,
	virtualization, David S. Miller
In-Reply-To: <a9ea89ac-4816-96a1-7de4-caf9884da876@redhat.com>

On Tue, Sep 04, 2018 at 11:08:40AM +0800, Jason Wang wrote:
> 
> 
> On 2018年09月04日 10:22, Michael S. Tsirkin wrote:
> > On Mon, Sep 03, 2018 at 08:59:13PM +0300, Gleb Fotengauer-Malinovskiy wrote:
> > > The _IOC_READ flag fits this ioctl request more because this request
> > > actually only writes to, but doesn't read from userspace.
> > > See NOTEs in include/uapi/asm-generic/ioctl.h for more information.
> > > 
> > > Fixes: 429711aec282 ("vhost: switch to use new message format")
> > > Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
> > Hmm it does make sense, and it's not too late to fix this up.
> > Jason, what's your take on this? Was _IOW intentional?
> 
> My bad, not intentional. And I agree that fixing this is not too late.
> 
> So
> 
> Acked-by: Jason Wang <jasowang@redhat.com>


OK then

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> > 
> > > ---
> > >   include/uapi/linux/vhost.h | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> > > index b1e22c40c4b6..84c3de89696a 100644
> > > --- a/include/uapi/linux/vhost.h
> > > +++ b/include/uapi/linux/vhost.h
> > > @@ -176,7 +176,7 @@ struct vhost_memory {
> > >   #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
> > >   #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
> > > -#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64)
> > > +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
> > >   /* VHOST_NET specific defines */
> > > 
> > > -- 
> > > glebfm
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox