Skip to contentSkip to conversation

drm/bochs: convert bochs driver to atomic mode-setting

PATCH In review John Hunter 2 participants 8 messages Jun 10, 2015 – Jun 11, 2015

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

PATCH 1/1 drm/bochs: convert bochs driver to atomic mode-setting

From: root <[email protected]>

convert the bochs driver to atomic mode-setting, referencing the patch serias of drm/exynos sent by Gustavo Padovan

---
Hi all, I am a GSoCer of this year, and my project is to convert bochs driver and cirrus driver to atomic mode-setting.

I converted the bochs driver to atomic mode-setting by referencing the patch serias of drm/exynos sent by Gustavo Padovan.

As far as I know, the convertion got some problem, and after I add the bochs driver when I boot the qemu VM, it just can not start up, works fine if I delete bochs-drm.ko from it's directory.

I am stuck here, I hope some one could review this patch and give some tips, so I can go on with by project.

---
 drivers/gpu/drm/bochs/bochs.h     |    2 +
 drivers/gpu/drm/bochs/bochs_drv.c |    2 +-
 drivers/gpu/drm/bochs/bochs_kms.c |  147 ++++++++++++++-----------------------
 drivers/gpu/drm/bochs/bochs_mm.c  |   10 +++
 4 files changed, 68 insertions(+), 93 deletions(-)
drivers/gpu/drm/bochs/bochs.h +2 -0
index 71f2687..3e16f63 100644
@@ -5,6 +5,8 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_fb_helper.h>
 
 #include <drm/drm_gem.h>
drivers/gpu/drm/bochs/bochs_drv.c +1 -1
index 98837bd..fc31643 100644
@@ -79,7 +79,7 @@ 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_ATOMIC,
 	.load			= bochs_load,
 	.unload			= bochs_unload,
 	.set_busid		= drm_pci_set_busid,
drivers/gpu/drm/bochs/bochs_kms.c +55 -92

227 lines not on this page · raw message

drivers/gpu/drm/bochs/bochs_mm.c +10 -0
index 66286ff..3cf05ac 100644
@@ -545,6 +545,16 @@ bochs_user_framebuffer_create(struct drm_device *dev,
 	return &bochs_fb->base;
 }
 
+static int bochs_atomic_commit(struct drm_device *dev,
+			struct drm_atomic_state *state,
+			bool async)
+{
+	/* no async */
+	return drm_atomic_helper_commit(dev, state, false);
+}
+
 const struct drm_mode_config_funcs bochs_mode_funcs = {
 	.fb_create = bochs_user_framebuffer_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = bochs_atomic_commit,
 };
Signature · 7 lines
1.7.10.4


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

Hi,

Quoted 3 lines

As far as I know, the convertion got some problem, and after I add the bochs driver when I boot the qemu VM, it just can not start up, works fine if I delete bochs-drm.ko from it's directory.

With fbdev enabled alot initialization happens with some important console lock taken, which has the effect that you don't see any kernel messages until it all succeeded. If it doesn't succeed you are stuck in the dark. Guess this is what happened ...

So, configure a serial console for your virtual machine. Turn off fbdev support (bochs_drm has a module option for that). That most likely gives you a clue where things blow up.

Then get X11 running.
kmscon is a nice test too.
When all this works try turning fbdev back on.

HTH,
Gerd

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

#2 lore raw

Thanks for the information, I will try that : )

Quoted 24 lines · Gerd Hoffmann

Hi,

Quoted 3 lines

As far as I know, the convertion got some problem, and after I add the bochs driver when I boot the qemu VM, it just can not start up, works fine if I delete bochs-drm.ko from it's directory.

With fbdev enabled alot initialization happens with some important console lock taken, which has the effect that you don't see any kernel messages until it all succeeded. If it doesn't succeed you are stuck in the dark. Guess this is what happened ...

So, configure a serial console for your virtual machine. Turn off fbdev support (bochs_drm has a module option for that). That most likely gives you a clue where things blow up.

Then get X11 running.
kmscon is a nice test too.
When all this works try turning fbdev back on.

HTH,
Gerd

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

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

#3 lore raw

Hi Gerd,
I have tried what you told me.
1. Turn off fbdev support:

    static bool enable_fbdev = *false*;

2. configure a serial console:
- add something like "*console=ttyS0, 9600n8*" to the grub menuentry
- add a start parameter to qemu when start the virtual machine "*-serial
pty*"
- got a redirected device like "*char device redirected to /dev/pts/2*"
- see the vritual machine's kernel messages in a host console by typing
"*cat /dev/pts/2*"

And stuck in dark but got the messages bellow:

saned disabled; edit /etc/default/saned
[ ok ] Starting network connection manager: NetworkManager. [ ok ] Starting Common Unix Printing System: cupsd.

The serial console messages also stop here, no other output.

I just don't know if I did the right thing, if I did something wrong, I would be appreaciate if
you show me.

Best Regards,
Zhao

Quoted 38 lines · John Hunter

Thanks for the information, I will try that : )

Quoted 15 lines · Gerd Hoffmann

Hi,

Quoted 3 lines

As far as I know, the convertion got some problem, and after I add the bochs driver when I boot the qemu VM, it just can not start up, works fine if I delete bochs-drm.ko from it's directory.

With fbdev enabled alot initialization happens with some important console lock taken, which has the effect that you don't see any kernel messages until it all succeeded. If it doesn't succeed you are stuck in the dark. Guess this is what happened ...

So, configure a serial console for your virtual machine. Turn off fbdev support (bochs_drm has a module option for that). That most likely gives you a clue where things blow up.

Quoted 9 lines

Then get X11 running.
kmscon is a nice test too.
When all this works try turning fbdev back on.

HTH,
Gerd

--
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

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

#4 lore raw
Quoted 4 lines · John Hunter

Hi Gerd,
I have tried what you told me.
1. Turn off fbdev support:

    static bool enable_fbdev = false;

Good.

Quoted 2 lines

2. configure a serial console:
- add something like "console=ttyS0, 9600n8" to the grub menuentry

Good.

You can use 115200 as line speed to speedup the console a bit.

Quoted 2 lines

- add a start parameter to qemu when start the virtual machine
"-serial pty"

'-serial stdio' might be more convenient.

Quoted 6 lines

saned disabled; edit /etc/default/saned
[ ok ] Starting network connection manager: NetworkManager. [ ok ] Starting Common Unix Printing System: cupsd.

The serial console messages also stop here, no other output.

Which guest is this? On modern linux distros (anything systemd-based) you should automatically get a login prompt on the serial line in case it is configured as console. Older systems need manual configuration for that. Could also be the system simply hangs here.

Try adding "ignore_loglevel" and "drm.debug=0x07" to the kernel command line.

HTH,
Gerd

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

#5 lore raw

Hi Gerd,
Here is what I got:

[  813.137939] [drm:drm_pci_init]
[  813.142780] [drm:drm_get_pci_dev]
[  813.156986] [drm:drm_minor_register]
[  813.212679] [drm:drm_minor_register] new minor registered 64
[  813.213341] [drm:drm_minor_register]
[  813.215081] [drm:drm_minor_register]
[  813.235736] [drm:drm_minor_register] new minor registered 0
[  813.252701] [drm] Found bochs VGA, ID 0xb0c0.
[  813.254993] [drm] Framebuffer size 8192 kB @ 0xfe000000, ioports @ 0x1ce.
[  813.271384] [TTM] Zone  kernel: Available graphics memory: 513150 kiB
[  813.272036] [TTM] Initializing pool allocator
[  813.279538] [TTM] Initializing DMA pool allocator
[  813.299800] [drm:drm_sysfs_connector_add] adding "Virtual-1" to sysfs
[  813.303164] [drm:drm_sysfs_hotplug_event] generating hotplug event
[  813.313079] [drm] Initialized bochs-drm 1.0.0 20130925 for 0000:00:02.0

on minor 0

If I remove the bochs-drm.ko from its place, then boot the virtual machine, after it runs,
copy the bochs-drm.ko to its original place, depmod the module, and modprobe
bochs-drm, it give the messages above. Seems like the bochs driver works, but
if I reboot with the bochs-drm.ko, it goes to dark, and the messages related to bochs
is same as above.

I guess the problem is because that I take no care of bochs_hw_setbase after remove
the bochs_crtc_mode_set_base, but I am not sure.

I will be appreciate if you can review the patch a bit and tell me where the problem
might be, and I will dig more into that.

I really can't get any clue.

If my question is stupid, forgive me, I will try to catch up :)

Best Regards,
Zhao

Quoted 41 lines · Gerd Hoffmann
Quoted 4 lines · John Hunter

Hi Gerd,
I have tried what you told me.
1. Turn off fbdev support:

    static bool enable_fbdev = false;

Good.

Quoted 2 lines

2. configure a serial console:
- add something like "console=ttyS0, 9600n8" to the grub menuentry

Good.

You can use 115200 as line speed to speedup the console a bit.

Quoted 2 lines

- add a start parameter to qemu when start the virtual machine
"-serial pty"

'-serial stdio' might be more convenient.

Quoted 6 lines

saned disabled; edit /etc/default/saned
[ ok ] Starting network connection manager: NetworkManager. [ ok ] Starting Common Unix Printing System: cupsd.

The serial console messages also stop here, no other output.

Which guest is this? On modern linux distros (anything systemd-based) you should automatically get a login prompt on the serial line in case it is configured as console. Older systems need manual configuration for that. Could also be the system simply hangs here.

Try adding "ignore_loglevel" and "drm.debug=0x07" to the kernel command line.

HTH,
Gerd

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

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

#6 lore raw
Quoted 22 lines · John Hunter

Hi Gerd,
Here is what I got:

[  813.137939] [drm:drm_pci_init] 
[  813.142780] [drm:drm_get_pci_dev] 
[  813.156986] [drm:drm_minor_register] 
[  813.212679] [drm:drm_minor_register] new minor registered 64
[  813.213341] [drm:drm_minor_register] 
[  813.215081] [drm:drm_minor_register] 
[  813.235736] [drm:drm_minor_register] new minor registered 0
[  813.252701] [drm] Found bochs VGA, ID 0xb0c0.
[  813.254993] [drm] Framebuffer size 8192 kB @ 0xfe000000, ioports @
0x1ce.
[  813.271384] [TTM] Zone  kernel: Available graphics memory: 513150
kiB
[  813.272036] [TTM] Initializing pool allocator
[  813.279538] [TTM] Initializing DMA pool allocator
[  813.299800] [drm:drm_sysfs_connector_add] adding "Virtual-1" to
sysfs
[  813.303164] [drm:drm_sysfs_hotplug_event] generating hotplug event
[  813.313079] [drm] Initialized bochs-drm 1.0.0 20130925 for
Quoted 1 line

0000:00:02.0 on minor 0

Looks good.

Quoted 9 lines

If I remove the bochs-drm.ko from its place, then boot the virtual machine, after it runs,
copy the bochs-drm.ko to its original place, depmod the module, and modprobe
bochs-drm, it give the messages above. Seems like the bochs driver works, but
if I reboot with the bochs-drm.ko, it goes to dark, and the messages related to bochs
is same as above.

Hmm, behavior should be the same no matter whenever it is loaded automatically at boot time or manually later on.

You can blacklist the module in modprobe.conf if you want prevent it from autoloading btw.

Quoted 3 lines

I guess the problem is because that I take no care of bochs_hw_setbase after remove
the bochs_crtc_mode_set_base, but I am not sure.

Possibly, programming the hardware needs to happen at some point ... Stick a printk in there to see whenever it is called or not.

But remember you don't have a framebuffer console because fbcon is turned off. So not having VTs is normal (and thats why you need the serial console ...)

What happens if you start X?

Quoted 3 lines

I will be appreciate if you can review the patch a bit and tell me where the problem
might be, and I will dig more into that.

Well, it's your gsoc project, not mine.

cheers,
Gerd

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

#7 lore raw
Quoted 59 lines · Gerd Hoffmann
Quoted 22 lines · John Hunter

Hi Gerd,
Here is what I got:

[  813.137939] [drm:drm_pci_init]
[  813.142780] [drm:drm_get_pci_dev]
[  813.156986] [drm:drm_minor_register]
[  813.212679] [drm:drm_minor_register] new minor registered 64
[  813.213341] [drm:drm_minor_register]
[  813.215081] [drm:drm_minor_register]
[  813.235736] [drm:drm_minor_register] new minor registered 0
[  813.252701] [drm] Found bochs VGA, ID 0xb0c0.
[  813.254993] [drm] Framebuffer size 8192 kB @ 0xfe000000, ioports @
0x1ce.
[  813.271384] [TTM] Zone  kernel: Available graphics memory: 513150
kiB
[  813.272036] [TTM] Initializing pool allocator
[  813.279538] [TTM] Initializing DMA pool allocator
[  813.299800] [drm:drm_sysfs_connector_add] adding "Virtual-1" to
sysfs
[  813.303164] [drm:drm_sysfs_hotplug_event] generating hotplug event
[  813.313079] [drm] Initialized bochs-drm 1.0.0 20130925 for
Quoted 1 line

0000:00:02.0 on minor 0

Looks good.

Quoted 9 lines

If I remove the bochs-drm.ko from its place, then boot the virtual machine, after it runs,
copy the bochs-drm.ko to its original place, depmod the module, and modprobe
bochs-drm, it give the messages above. Seems like the bochs driver works, but
if I reboot with the bochs-drm.ko, it goes to dark, and the messages related to bochs
is same as above.

Hmm, behavior should be the same no matter whenever it is loaded automatically at boot time or manually later on.

You can blacklist the module in modprobe.conf if you want prevent it from autoloading btw.

Thanks for the information

Quoted 3 lines

I guess the problem is because that I take no care of bochs_hw_setbase after remove
the bochs_crtc_mode_set_base, but I am not sure.

Possibly, programming the hardware needs to happen at some point ... Stick a printk in there to see whenever it is called or not.

But remember you don't have a framebuffer console because fbcon is turned off. So not having VTs is normal (and thats why you need the serial console ...)

What happens if you start X?

Quoted 8 lines

I think in the distro (debian 7) it runs X automatically

Quoted 3 lines

I will be appreciate if you can review the patch a bit and tell me where the problem
might be, and I will dig more into that.

Well, it's your gsoc project, not mine.

I guess I have asked a stupid question :) , sorry about that. Anyway, I will try to figure it out.

Quoted 2 lines

cheers,

Quoted 4 lines

Gerd

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

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