[PATCH v2 04/12] drm/amdgpu: use simpler remove_conflicting_pci_framebuffers()

2018-08-30 Thread Michał Mirosław
Signed-off-by: Michał Mirosław 
Acked-by: Alex Deucher 
Acked-by: Daniel Vetter 
---
 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

[PATCH v2 07/12] drm/mgag200: use simpler remove_conflicting_pci_framebuffers()

2018-08-30 Thread Michał Mirosław
Remove duplicated call, while at it.

Signed-off-by: Michał Mirosław 
Acked-by: Daniel Vetter 
---
 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, );
 }
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

[PATCH v2 03/12] fbdev: add remove_conflicting_pci_framebuffers()

2018-08-30 Thread Michał Mirosław
Almost all PCI drivers using remove_conflicting_framebuffers() wrap it
with the same code.

Signed-off-by: Michał Mirosław 
[for v1]
Acked-by: Bartlomiej Zolnierkiewicz 

---
v2: add kerneldoc for DRM helper
---
 drivers/video/fbdev/core/fbmem.c | 22 ++
 include/drm/drm_fb_helper.h  | 24 
 include/linux/fb.h   |  2 ++
 3 files changed, 48 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 0df148eb4699..927e016487e9 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -1802,6 +1803,27 @@ int remove_conflicting_framebuffers(struct 
apertures_struct *a,
 }
 EXPORT_SYMBOL(remove_conflicting_framebuffers);
 
+int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, 
const char *name)
+{
+   struct apertures_struct *ap;
+   bool primary = false;
+
+   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
+   remove_conflicting_framebuffers(ap, name, primary);
+   kfree(ap);
+   return 0;
+}
+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 1c1e53abb25d..6e1fc52d1b1b 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -587,4 +587,28 @@ drm_fb_helper_remove_conflicting_framebuffers(struct 
apertures_struct *a,
 #endif
 }
 
+/**
+ * drm_fb_helper_remove_conflicting_framebuffers - remove firmware 
framebuffers for PCI devices
+ * @pdev: PCI device being driven
+ * @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 is drives a primary
+ * display and so kicks out vga16fb.
+ */
+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

[PATCH v2 05/12] drm/bochs: use simpler remove_conflicting_pci_framebuffers()

2018-08-30 Thread Michał Mirosław
Signed-off-by: Michał Mirosław 
Acked-by: Daniel Vetter 
---
 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

[PATCH v2 02/12] fbdev: allow apertures == NULL in remove_conflicting_framebuffers()

2018-08-30 Thread Michał Mirosław
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 
[for v1]
Acked-by: Bartlomiej Zolnierkiewicz 

---
v2: added kerneldoc to corresponding DRM helper
---
 drivers/video/fbdev/core/fbmem.c | 14 ++
 include/drm/drm_fb_helper.h  | 10 ++
 2 files changed, 24 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(_lock);
ret = do_remove_conflicting_framebuffers(a, name, primary);
mutex_unlock(_lock);
 
+   if (do_free)
+   kfree(a);
+
return ret;
 }
 EXPORT_SYMBOL(remove_conflicting_framebuffers);
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index b069433e7fc1..1c1e53abb25d 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -566,6 +566,16 @@ static inline void 
drm_fb_helper_output_poll_changed(struct drm_device *dev)
 
 #endif
 
+/**
+ * drm_fb_helper_remove_conflicting_framebuffers - remove firmware 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 (eg. initialized by firmware)
+ * which use memory range described by @a. If @a is NULL all such devices are
+ * removed.
+ */
 static inline int
 drm_fb_helper_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

[PATCH v2 11/12] drm/sun4i: use simpler remove_conflicting_framebuffers(NULL)

2018-08-30 Thread Michał Mirosław
Use remove_conflicting_framebuffers(NULL) instead of duplicating it.

Signed-off-by: Michał Mirosław 
Acked-by: Maxime Ripard 
Acked-by: Daniel Vetter 
---
 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

[PATCH v2 01/12] fbdev: show fbdev number for debugging

2018-08-30 Thread Michał Mirosław
Signed-off-by: Michał Mirosław 
Acked-by: Bartlomiej Zolnierkiewicz 
Acked-by: Daniel Vetter 
---
 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

[PATCH v2 10/12] drm/vc4: use simpler remove_conflicting_framebuffers(NULL)

2018-08-30 Thread Michał Mirosław
Use remove_conflicting_framebuffers(NULL) instead of open-coding it.

Signed-off-by: Michał Mirosław 
Acked-by: Eric Anholt 
Acked-by: Daniel Vetter 
---
 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

[PATCH v2 12/12] drm/tegra: kick out simplefb

2018-08-30 Thread Michał Mirosław
Kick out firmware fb when loading Tegra driver.

Signed-off-by: Michał Mirosław 
Acked-by: Daniel Vetter 
---
 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, 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

[PATCH v2 06/12] drm/cirrus: use simpler remove_conflicting_pci_framebuffers()

2018-08-30 Thread Michał Mirosław
Signed-off-by: Michał Mirosław 
Acked-by: Daniel Vetter 
---
 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

[PATCH v2 00/12] remove_conflicting_framebuffers() cleanup

2018-08-30 Thread Michał Mirosław
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

Michał Mirosław (12):
  fbdev: show fbdev number for debugging
  fbdev: allow apertures == NULL in 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 | 40 ++--
 include/drm/drm_fb_helper.h  | 34 
 include/linux/fb.h   |  2 ++
 13 files changed, 88 insertions(+), 172 deletions(-)

-- 
2.18.0

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

[PATCH v2 08/12] drm/radeon: use simpler remove_conflicting_pci_framebuffers()

2018-08-30 Thread Michał Mirosław
Signed-off-by: Michał Mirosław 
Acked-by: Alex Deucher 
Acked-by: Daniel Vetter 
---
 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

[PATCH v2 09/12] drm/virtio: use simpler remove_conflicting_pci_framebuffers()

2018-08-30 Thread Michał Mirosław
Signed-off-by: Michał Mirosław 
Acked-by: Daniel Vetter 
---
 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

Re: [PATCH] drm/bochs: Replace ttm_bo_unref with ttm_bo_put

2018-08-30 Thread Gerd Hoffmann
On Thu, Aug 30, 2018 at 08:14:02AM +0200, Thomas Zimmermann wrote:
> Hi Gerd
> 
> Am 09.08.2018 um 17:27 schrieb Gerd Hoffmann:
> >> diff --git a/drivers/gpu/drm/bochs/bochs_mm.c 
> >> b/drivers/gpu/drm/bochs/bochs_mm.c
> >> index 39cd08416773..c9c7097030ca 100644
> >> --- a/drivers/gpu/drm/bochs/bochs_mm.c
> >> +++ b/drivers/gpu/drm/bochs/bochs_mm.c
> >> @@ -430,7 +430,7 @@ static void bochs_bo_unref(struct bochs_bo **bo)
> >>return;
> >>  
> >>tbo = &((*bo)->bo);
> >> -  ttm_bo_unref();
> >> +  ttm_bo_put(tbo);
> > 
> > fails to build:
> > 
> >   CC [M]  drivers/gpu/drm/bochs/bochs_mm.o
> > /home/kraxel/projects/linux/drivers/gpu/drm/bochs/bochs_mm.c: In function 
> > ‘bochs_bo_unref’:
> > /home/kraxel/projects/linux/drivers/gpu/drm/bochs/bochs_mm.c:433:2: error: 
> > implicit declaration of function ‘ttm_bo_put’ 
> > [-Werror=implicit-function-declaration]
> >   ttm_bo_put(tbo);
> >   ^
> > cc1: some warnings being treated as errors
> 
> The required interfaces are now available in mainline. [1] I rebuilt to
> make sure it compiles.
> 
> Besides bochs, [2] the patches for qxl, [3] cirrus, [4] vmwgfx, [5][6]
> and virtio [7][8] should now build as well. They still apply cleanly
> AFAICT. Let me know if you prefer a new patch set instead.

Yes. builds now.  vmwgfx is not my cup of tea, but I'll pick up the
other ones (and can finally remove them from my patches mailbox) and let
you know in case I run into trouble.

cheers,
  Gerd

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

Re: [PATCH 0/2] Provide init/release functions for struct ttm_bo_global

2018-08-30 Thread Christian König

Hi Thomas,

Am 30.08.2018 um 08:34 schrieb Thomas Zimmermann:

Hi Christian,

I just wanted to ask if there's something else required to get this
patch set reviewed and landed.


I just need to find some time to review them.


On top of these two patches, I have a patch set that replaces the
driver-specific global-bo-and-mem combos with a single struct ttm_global
structure. It further merges struct drm_global into struct ttm_global
and implements it such that drivers can either share the global memory


That sounds good.


or create their private instance.


That doesn't sounds good. Drivers should not be allowed to create their 
own private instance of that.


Thanks for doing this,
Christian.


  It's also a step towards drm device
hotplug, which someone just asked.

Best regards
Thomas


Am 13.08.2018 um 12:33 schrieb Christian König:

Yes, please! I had it on my TODO list to clean that up for an eternity.

Actually I never understood why that should be driver work to setup TTM?

I mean can't we just have a module_init/module_exit for TTM?

Thanks,
Christian.

Am 13.08.2018 um 12:24 schrieb Thomas Zimmermann:

TTM uses global memory and BO for backing graphics buffers. These are
represented by struct ttm_mem_global and struct ttm_bo_global.

Currently, struct ttm_bo_global can only be initialized and released
through
struct ttm_bo_global_ref. This is a workaround for passing an instance of
ttm_mem_global to the BO global initialization code.

The use of struct ttm_bo_global_ref makes driver code unnecessary hard to
understand. At the same time drivers can use any combination of memory
and
BO for initializing the global instances. This can result in subtle bugs
when the order of initializing and releasing drivers changes.

As a first step for resolving these problems, the provided patch set
separates initialization and release of struct ttm_bo_global from
struct ttm_bo_global_ref.

The first patch only renames ttm_bo_global_{init/release}. Hopefully this
change can be applied at once for all drivers.

Future directions: All TTM-based drivers follow the same pattern for
setting
up the TTM. In a follow-up patch, this code can be moved into a single
place
and shared among drivers.

Thomas Zimmermann (2):
    drm/ttm: Rename ttm_bo_global_{init,release}() to
  ttm_bo_global_ref_*()
    drm/ttm: Provide ttm_bo_global_{init/release}() for struct
  ttm_bo_global

   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |  4 +-
   drivers/gpu/drm/ast/ast_ttm.c   |  4 +-
   drivers/gpu/drm/bochs/bochs_mm.c    |  4 +-
   drivers/gpu/drm/cirrus/cirrus_ttm.c |  4 +-
   drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  4 +-
   drivers/gpu/drm/mgag200/mgag200_ttm.c   |  4 +-
   drivers/gpu/drm/nouveau/nouveau_ttm.c   |  4 +-
   drivers/gpu/drm/qxl/qxl_ttm.c   |  4 +-
   drivers/gpu/drm/radeon/radeon_ttm.c |  4 +-
   drivers/gpu/drm/ttm/ttm_bo.c    | 12 ++---
   drivers/gpu/drm/virtio/virtgpu_ttm.c    |  4 +-
   drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c    |  4 +-
   drivers/staging/vboxvideo/vbox_ttm.c    |  4 +-
   include/drm/ttm/ttm_bo_driver.h | 53 -
   14 files changed, 70 insertions(+), 43 deletions(-)

--
2.18.0



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