drm: qemu hardware patches
Subsystems (3)
Gerd Hoffmann
maintainercover drm: qemu hardware patches
Hi,
Here comes a collection of drm patches for qemu emulated virtual graphics cards. Small improvements for cirrus and qxl. A new kms driver for the qemu standard vga.
Patches 1-4 can be queued up for merge, unless someone finds bugs / problems in review of course.
Patches 5+6 have known issues and are still work-in-progress. I'm posing them for early review nevertheless.
git tree with these patches is here:
git://git.kraxel.org/linux qemu-drm
cheers,
Gerd
Gerd Hoffmann (6):
drm: add drm_set_preferred_mode
drm/cirrus: use drm_set_preferred_mode
drm/qxl: support 64bit surface bar
drm/qxl: add some surface memory logging
[wip] drm/qxl: request regions
[wip] drm/bochs: new driver
drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/bochs/Kconfig | 11 + drivers/gpu/drm/bochs/Makefile | 4 + drivers/gpu/drm/bochs/bochs.h | 167 +++++++++++ drivers/gpu/drm/bochs/bochs_drv.c | 179 ++++++++++++ drivers/gpu/drm/bochs/bochs_fbdev.c | 215 ++++++++++++++ drivers/gpu/drm/bochs/bochs_hw.c | 162 ++++++++++ drivers/gpu/drm/bochs/bochs_kms.c | 294 +++++++++++++++++++ drivers/gpu/drm/bochs/bochs_mm.c | 552 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/cirrus/cirrus_mode.c | 11 +- drivers/gpu/drm/drm_edid.c | 13 + drivers/gpu/drm/qxl/qxl_kms.c | 48 ++- drivers/gpu/drm/qxl/qxl_ttm.c | 2 + include/drm/drm_crtc.h | 2 + 15 files changed, 1647 insertions(+), 16 deletions(-) create mode 100644 drivers/gpu/drm/bochs/Kconfig create mode 100644 drivers/gpu/drm/bochs/Makefile create mode 100644 drivers/gpu/drm/bochs/bochs.h create mode 100644 drivers/gpu/drm/bochs/bochs_drv.c create mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c create mode 100644 drivers/gpu/drm/bochs/bochs_hw.c create mode 100644 drivers/gpu/drm/bochs/bochs_kms.c create mode 100644 drivers/gpu/drm/bochs/bochs_mm.c
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH 1/6 drm: add drm_set_preferred_mode
New helper function to set the preferred video mode. Can be called after drm_add_modes_noedid if you don't want the largest supported video mode be used by default.
--- drivers/gpu/drm/drm_edid.c | 13 +++++++++++++ include/drm/drm_crtc.h | 2 ++ 2 files changed, 15 insertions(+)
drivers/gpu/drm/drm_edid.c +13 -0
@@ -3286,6 +3286,19 @@ int drm_add_modes_noedid(struct drm_connector *connector, }EXPORT_SYMBOL (drm_add_modes_noedid); +void drm_set_preferred_mode (struct drm_connector *connector, +int hpref,int vpref) +{ +struct drm_display_mode *mode; + +list_for_each_entry (mode, &connector->probed_modes, head) { +if (drm_mode_width (mode) == hpref && +drm_mode_height (mode) == vpref) + mode->type |=DRM_MODE_TYPE_PREFERRED ; + } +} +EXPORT_SYMBOL (drm_set_preferred_mode); +/** * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with * data from a DRM display mode
include/drm/drm_crtc.h +2 -0
@@ -1108,6 +1108,8 @@ extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev, int GTF_2C, int GTF_K, int GTF_2J);extern int drm_add_modes_noedid (struct drm_connector *connector,int hdisplay,int vdisplay); +extern void drm_set_preferred_mode (struct drm_connector *connector, +int hpref,int vpref);extern int drm_edid_header_is_valid (const u8 *raw_edid);extern bool drm_edid_block_valid (u8 *raw_edid,int block,bool print_bad_edid);
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH 2/6 drm/cirrus: use drm_set_preferred_mode
In reply to Gerd HoffmannExplicitly set 1024x768 as default mode, so the display doesn't come up with the largest supported mode.
While being at it drop first three drm_add_modes_noedid calls. As drm_add_modes_noedid fills the mode list with modes from the database *up to* the specified size it is pretty pointless to call it multiple times with different sizes.
--- drivers/gpu/drm/cirrus/cirrus_mode.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/cirrus/cirrus_mode.c +5 -6
@@ -494,13 +494,12 @@ static struct drm_encoder *cirrus_encoder_init(struct drm_device *dev)int cirrus_vga_get_modes (struct drm_connector *connector) { -/* Just add a static list of modes */ -drm_add_modes_noedid (connector,640 ,480 ); -drm_add_modes_noedid (connector,800 ,600 ); -drm_add_modes_noedid (connector,1024 ,768 ); -drm_add_modes_noedid (connector,1280 ,1024 ); +int count; -return 4 ; +/* Just add a static list of modes */ + count =drm_add_modes_noedid (connector,1280 ,1024 ); +drm_set_preferred_mode (connector,1024 ,768 ); +return count; } static int cirrus_vga_mode_valid(struct drm_connector *connector,
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH 3/6 drm/qxl: support 64bit surface bar
In reply to Gerd Hoffmannqxl devices can have a 64bit surface bar, which is quite handy if you need a bit more surface memory. So try to use it if it is present. Note that this bar might be mapped above 4g.
QEMU command line to check that out:
qemu-system-x86_64 -m 4g \
-vga qxl -global qxl-vga.vram64_size_mb=512 \
$otheroptions--- drivers/gpu/drm/qxl/qxl_kms.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
drivers/gpu/drm/qxl/qxl_kms.c +25 -7
@@ -120,7 +120,7 @@ int qxl_device_init(struct qxl_device *qdev,struct pci_dev *pdev, unsigned long flags) { - int r; + int r, sb; qdev->dev = &pdev->dev; qdev->ddev = ddev;
@@ -136,21 +136,39 @@ int qxl_device_init(struct qxl_device *qdev, qdev->rom_base =pci_resource_start (pdev,2 ); qdev->rom_size =pci_resource_len (pdev,2 ); qdev->vram_base =pci_resource_start (pdev,0 ); - qdev->surfaceram_base =pci_resource_start (pdev,1 ); - qdev->surfaceram_size =pci_resource_len (pdev,1 ); qdev->io_base =pci_resource_start (pdev,3 ); qdev->vram_mapping =io_mapping_create_wc (qdev->vram_base,pci_resource_len (pdev,0 )); - qdev->surface_mapping =io_mapping_create_wc (qdev->surfaceram_base, qdev->surfaceram_size); -DRM_DEBUG_KMS ("qxl: vram %llx-%llx(%dM %dk), surface %llx-%llx(%dM %dk)\n" , + +if (pci_resource_len (pdev,4 ) >0 ) { +/* 64bit surface bar present */ + sb =4 ; + qdev->surfaceram_base =pci_resource_start (pdev, sb); + qdev->surfaceram_size =pci_resource_len (pdev, sb); + qdev->surface_mapping = +io_mapping_create_wc (qdev->surfaceram_base, + qdev->surfaceram_size); + } +if (qdev->surface_mapping ==NULL ) { +/* 64bit surface bar not present (or mapping failed) */ + sb =1 ; + qdev->surfaceram_base =pci_resource_start (pdev, sb); + qdev->surfaceram_size =pci_resource_len (pdev, sb); + qdev->surface_mapping = +io_mapping_create_wc (qdev->surfaceram_base, + qdev->surfaceram_size); + } + +DRM_DEBUG_KMS ("qxl: vram %llx-%llx(%dM %dk), surface %llx-%llx(%dM %dk, %s)\n" , (unsigned long long )qdev->vram_base, (unsigned long long )pci_resource_end (pdev,0 ), (int )pci_resource_len (pdev,0 ) /1024 /1024 , (int )pci_resource_len (pdev,0 ) /1024 , (unsigned long long )qdev->surfaceram_base, - (unsigned long long )pci_resource_end (pdev,1 ), + (unsigned long long )pci_resource_end (pdev, sb), (int )qdev->surfaceram_size /1024 /1024 , - (int )qdev->surfaceram_size /1024 ); + (int )qdev->surfaceram_size /1024 , + (sb ==4 ) ?"64bit" :"32bit" ); qdev->rom =ioremap (qdev->rom_base, qdev->rom_size);if (!qdev->rom) {
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH 4/6 drm/qxl: add some surface memory logging
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_kms.c | 10 +++++++--- drivers/gpu/drm/qxl/qxl_ttm.c | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/qxl/qxl_kms.c +7 -3
@@ -248,9 +248,13 @@ int qxl_device_init(struct qxl_device *qdev, qdev->surfaces_mem_slot =setup_slot (qdev,1 , (unsigned long )qdev->surfaceram_base, (unsigned long )qdev->surfaceram_base + qdev->surfaceram_size); -DRM_INFO ("main mem slot %d [%lx,%x)\n" , - qdev->main_mem_slot, - (unsigned long )qdev->vram_base, qdev->rom->ram_header_offset); +DRM_INFO ("main mem slot %d [%lx,%x]\n" , + qdev->main_mem_slot, + (unsigned long )qdev->vram_base, qdev->rom->ram_header_offset); +DRM_INFO ("surface mem slot %d [%lx,%lx]\n" , + qdev->surfaces_mem_slot, + (unsigned long )qdev->surfaceram_base, + (unsigned long )qdev->surfaceram_size); qdev->gc_queue =create_singlethread_workqueue ("qxl_gc" );
drivers/gpu/drm/qxl/qxl_ttm.c +2 -0
@@ -516,6 +516,8 @@ int qxl_ttm_init(struct qxl_device *qdev) (unsigned)qdev->vram_size / (1024 * 1024));DRM_INFO ("qxl: %luM of IO pages memory ready (VRAM domain)\n" , ((unsigned )num_io_pages *PAGE_SIZE ) / (1024 *1024 )); +DRM_INFO ("qxl: %uM of Surface memory size\n" , + (unsigned )qdev->surfaceram_size / (1024 *1024 ));if (unlikely (qdev->mman.bdev.dev_mapping ==NULL )) qdev->mman.bdev.dev_mapping = qdev->ddev->dev_mapping; r =qxl_ttm_debugfs_init (qdev);
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH 5/6 drm/qxl: request regions
In reply to Gerd HoffmannSo they show up in /proc/{iomem,ioports}.
No error checking (yet?). Doesn't make things
worse than they are now, but still not nice.
Known issue: Doesn't work for qxl-vram (vesafb conflict?).
--- drivers/gpu/drm/qxl/qxl_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/qxl/qxl_kms.c +6 -0
@@ -264,6 +264,11 @@ int qxl_device_init(struct qxl_device *qdev,if (r)return r; + r =pci_request_region (pdev,0 ,"qxl-vram" ); + r =pci_request_region (pdev,2 ,"qxl-rom" ); + r =pci_request_region (pdev,3 ,"qxl-io" ); + r =pci_request_region (pdev, sb,"qxl-surface" ); +return 0 ; }
@@ -289,6 +294,7 @@ static void qxl_device_fini(struct qxl_device *qdev) qdev->mode_info.modes =NULL ; qdev->mode_info.num_modes =0 ;qxl_debugfs_remove_files (qdev); +pci_release_regions (qdev->pdev); }int qxl_driver_unload (struct drm_device *dev)
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH 6/6 drm/bochs: new driver
In reply to Gerd HoffmannDRM driver for (virtual) vga cards using the bochs dispi interface, such as the qemu standard vga (qemu -vga std).
Don't bother supporting anything but 32bpp for now. Maybe add 16bpp later on.
Known issue: mmap(/dev/fb0) doesn't work.
--- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/bochs/Kconfig | 11 + drivers/gpu/drm/bochs/Makefile | 4 + drivers/gpu/drm/bochs/bochs.h | 167 +++++++++++ drivers/gpu/drm/bochs/bochs_drv.c | 179 ++++++++++++ drivers/gpu/drm/bochs/bochs_fbdev.c | 215 ++++++++++++++ drivers/gpu/drm/bochs/bochs_hw.c | 162 +++++++++++ drivers/gpu/drm/bochs/bochs_kms.c | 294 +++++++++++++++++++ drivers/gpu/drm/bochs/bochs_mm.c | 552 ++++++++++++++++++++++++++++++++++++ 10 files changed, 1587 insertions(+) create mode 100644 drivers/gpu/drm/bochs/Kconfig create mode 100644 drivers/gpu/drm/bochs/Makefile create mode 100644 drivers/gpu/drm/bochs/bochs.h create mode 100644 drivers/gpu/drm/bochs/bochs_drv.c create mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c create mode 100644 drivers/gpu/drm/bochs/bochs_hw.c create mode 100644 drivers/gpu/drm/bochs/bochs_kms.c create mode 100644 drivers/gpu/drm/bochs/bochs_mm.c
drivers/gpu/drm/Kconfig +2 -0
@@ -235,4 +235,6 @@ source "drivers/gpu/drm/tilcdc/Kconfig" source "drivers/gpu/drm/qxl/Kconfig" +source "drivers/gpu/drm/bochs/Kconfig" + source "drivers/gpu/drm/msm/Kconfig"
drivers/gpu/drm/Makefile +1 -0
@@ -54,5 +54,6 @@ obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/ obj-$(CONFIG_DRM_OMAP) += omapdrm/ obj-$(CONFIG_DRM_TILCDC) += tilcdc/ obj-$(CONFIG_DRM_QXL) += qxl/ +obj-$(CONFIG_DRM_BOCHS) += bochs/ obj-$(CONFIG_DRM_MSM) += msm/ obj-y += i2c/
drivers/gpu/drm/bochs/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +config DRM_BOCHS + tristate "DRM Support for bochs dispi vga interface (qemu stdvga)" + depends on DRM && PCI + select DRM_KMS_HELPER + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select DRM_TTM + help + Choose this option for qemu. + If M is selected the module will be called bochs-drm.
drivers/gpu/drm/bochs/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +ccflags-y := -Iinclude/drm +bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_fbdev.o bochs_hw.o + +obj-$(CONFIG_DRM_BOCHS) += bochs-drm.o
drivers/gpu/drm/bochs/bochs.h new file +167 -0
167 lines not on this page · raw message
drivers/gpu/drm/bochs/bochs_drv.c new file +179 -0
179 lines not on this page · raw message
drivers/gpu/drm/bochs/bochs_fbdev.c new file +215 -0
215 lines not on this page · raw message
drivers/gpu/drm/bochs/bochs_hw.c new file +162 -0
162 lines not on this page · raw message
drivers/gpu/drm/bochs/bochs_kms.c new file +294 -0
294 lines not on this page · raw message
drivers/gpu/drm/bochs/bochs_mm.c new file +552 -0
552 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 6 lines
Here comes a collection of drm patches for qemu emulated virtual graphics cards. Small improvements for cirrus and qxl. A new kms driver for the qemu standard vga.
Patches 1-4 can be queued up for merge, unless someone finds bugs / problems in review of course.
Hi Gerd,
I've merged 1-4, thanks for those.
Quoted 3 lines
Patches 5+6 have known issues and are still work-in-progress. I'm posing them for early review nevertheless.
Yeah I'm not really sure I like request_regions for drm drivers, yes its nice to see things, but the fact
that we always get in trouble with efifb and vesafb and that people seem to insist on later coming along
and supplying unhelpful patches to fix the lack of return checking, I generally just steer clear.
I'll try and find some time to look at the bochs driver, though is it really much more than we have with the
simple drm layer that David Herrmann is producing?
Dave.
Quoted 14 lines · Dave Airlie
Quoted 6 lines
Here comes a collection of drm patches for qemu emulated virtual graphics cards. Small improvements for cirrus and qxl. A new kms driver for the qemu standard vga.
Patches 1-4 can be queued up for merge, unless someone finds bugs / problems in review of course.
Hi Gerd,
I've merged 1-4, thanks for those.
Quoted 3 lines
Patches 5+6 have known issues and are still work-in-progress. I'm posing them for early review nevertheless.
Quoted 6 lines
Yeah I'm not really sure I like
request_regionsfor drm drivers, yes its nice to see things, but the fact
that we always get in trouble with efifb and vesafb and that people seem to insist on later coming along
and supplying unhelpful patches to fix the lack of return checking, I generally just steer clear.
We've recently started to request_region the intel graphics stolen block. Surprising how much gunk the core pci resource layer loves to put in there, so caught a few real bugs. Also it's a major pain to actually get it to work (some random platform has an off-by-one apparently and fun stuff like that). But I agree that for the mmio bars it's probably not worth the trouble due to vesafb/efifb bonghits.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Gerd Hoffmann
maintainerHi,
Quoted 3 lines
I'll try and find some time to look at the bochs driver, though is it really much more than we have with the
simple drm layer that David Herrmann is producing?
simpledrm is fixed resolution and depends on the firmware setting things up (from what I've seen a few weeks back), correct?
bochs doesn't need firmware help and can switch resolutions at runtime via xrandr just fine. It's more like cirrus-drm, except that there are not the nasty constrains dictated by real cirrus cards, such as the very limited amount of video memory and supporting 24 bpp only.
bochs-drm doesn't need to hop through the loops to shuffle around the framebuffer bo's. They are in vram no matter what, we have 16MB by default and qemu can be configured to make it larger if needed. Want a FullHD display? No problem. bochs-drm operates with 32bpp. The virtual hardware can do 8bpp and 16bpp too, but I didn't go the extra mile to support that as it looks pointless these days.
cheers,
Gerd