drm/bochs: cleanups, atomic modesetting, generic fbdev.
Subsystems (3)
v2 cover drm/bochs: cleanups, atomic modesetting, generic fbdev.
This series adds support for atomic modesetting to the bochs driver. It also switches over to the generic fbdev implementation and does some cleanups.
v2:
- some updates according to Oleksandr's review.
- fix ttm bo pin/unpin (new patch #15).
Gerd Hoffmann (15):
drm/bochs: encoder cleanup
drm/bochs: split bochs_hw_setmode
drm/bochs: atomic: add atomic_flush+atomic_enable callbacks. drm/bochs: atomic: add mode_set_nofb callback. drm/bochs: atomic: switch planes to atomic, wire up helpers. drm/bochs: atomic: use atomic set_config helper drm/bochs: atomic: use atomic page_flip helper drm/bochs: atomic: set DRIVER_ATOMIC
drm/bochs: remove old bochs_crtc_* functions drm/bochs: drop unused gpu_addr arg from bochs_bo_pin() drm/bochs: add basic prime support
drm/bochs: switch to generic drm fbdev emulation drm/bochs: drop old fbdev emulation code drm/bochs: move remaining fb bits to kms drm/bochs: reserve bo for pin/unpin
drivers/gpu/drm/bochs/bochs.h | 27 +++-- drivers/gpu/drm/bochs/bochs_drv.c | 30 ++--- drivers/gpu/drm/bochs/bochs_fbdev.c | 163 --------------------------- drivers/gpu/drm/bochs/bochs_hw.c | 19 ++-- drivers/gpu/drm/bochs/bochs_kms.c | 218 +++++++++++++++++------------------- drivers/gpu/drm/bochs/bochs_mm.c | 82 ++++++++++++-- drivers/gpu/drm/bochs/Makefile | 2 +- 7 files changed, 218 insertions(+), 323 deletions(-) delete mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/15 drm/bochs: encoder cleanup
Most unused callbacks can be NULL pointers these days. Drop a bunch of empty encoder callbacks.
--- drivers/gpu/drm/bochs/bochs_kms.c | 26 -------------------------- 1 file changed, 26 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -26
@@ -170,31 +170,6 @@ static void bochs_crtc_init(struct drm_device *dev)drm_crtc_helper_add (crtc, &bochs_helper_funcs); } -static void bochs_encoder_mode_set (struct drm_encoder *encoder, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode) -{ -} - -static void bochs_encoder_dpms (struct drm_encoder *encoder,int state) -{ -} - -static void bochs_encoder_prepare (struct drm_encoder *encoder) -{ -} - -static void bochs_encoder_commit (struct drm_encoder *encoder) -{ -} - -static const struct drm_encoder_helper_funcs bochs_encoder_helper_funcs = { - .dpms = bochs_encoder_dpms, - .mode_set = bochs_encoder_mode_set, - .prepare = bochs_encoder_prepare, - .commit = bochs_encoder_commit, -}; -static const struct drm_encoder_funcs bochs_encoder_encoder_funcs = { .destroy = drm_encoder_cleanup, };
@@ -207,7 +182,6 @@ static void bochs_encoder_init(struct drm_device *dev) encoder->possible_crtcs =0x1 ;drm_encoder_init (dev, encoder, &bochs_encoder_encoder_funcs,DRM_MODE_ENCODER_DAC ,NULL ); -drm_encoder_helper_add (encoder, &bochs_encoder_helper_funcs); }
Signature · 1 line
2.9.3
PATCH v2 1/15 drm/bochs: encoder cleanup
In reply to Gerd HoffmannMost unused callbacks can be NULL pointers these days. Drop a bunch of empty encoder callbacks.
--- drivers/gpu/drm/bochs/bochs_kms.c | 26 -------------------------- 1 file changed, 26 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -26
@@ -170,31 +170,6 @@ static void bochs_crtc_init(struct drm_device *dev)drm_crtc_helper_add (crtc, &bochs_helper_funcs); } -static void bochs_encoder_mode_set (struct drm_encoder *encoder, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode) -{ -} - -static void bochs_encoder_dpms (struct drm_encoder *encoder,int state) -{ -} - -static void bochs_encoder_prepare (struct drm_encoder *encoder) -{ -} - -static void bochs_encoder_commit (struct drm_encoder *encoder) -{ -} - -static const struct drm_encoder_helper_funcs bochs_encoder_helper_funcs = { - .dpms = bochs_encoder_dpms, - .mode_set = bochs_encoder_mode_set, - .prepare = bochs_encoder_prepare, - .commit = bochs_encoder_commit, -}; -static const struct drm_encoder_funcs bochs_encoder_encoder_funcs = { .destroy = drm_encoder_cleanup, };
@@ -207,7 +182,6 @@ static void bochs_encoder_init(struct drm_device *dev) encoder->possible_crtcs =0x1 ;drm_encoder_init (dev, encoder, &bochs_encoder_encoder_funcs,DRM_MODE_ENCODER_DAC ,NULL ); -drm_encoder_helper_add (encoder, &bochs_encoder_helper_funcs); }
Signature · 1 line
2.9.3
PATCH v2 2/15 drm/bochs: split bochs_hw_setmode
In reply to Gerd HoffmannCreate a separate bochs_hw_setformat function to configure the framebuffer format (actually just the byteorder).
--- drivers/gpu/drm/bochs/bochs.h | 5 +++-- drivers/gpu/drm/bochs/bochs_hw.c | 19 ++++++++++++------- drivers/gpu/drm/bochs/bochs_kms.c | 3 ++- 3 files changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/bochs/bochs.h +3 -2
@@ -121,8 +121,9 @@ int bochs_hw_init(struct drm_device *dev);void bochs_hw_fini (struct drm_device *dev);void bochs_hw_setmode (struct bochs_device *bochs, -struct drm_display_mode *mode, -const struct drm_format_info *format); +struct drm_display_mode *mode); +void bochs_hw_setformat (struct bochs_device *bochs, +const struct drm_format_info *format);void bochs_hw_setbase (struct bochs_device *bochs,int x,int y,u64 addr);int bochs_hw_load_edid (struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_hw.c +12 -7
@@ -204,8 +204,7 @@ void bochs_hw_fini(struct drm_device *dev) }void bochs_hw_setmode (struct bochs_device *bochs, -struct drm_display_mode *mode, -const struct drm_format_info *format) +struct drm_display_mode *mode) { bochs->xres = mode->hdisplay; bochs->yres = mode->vdisplay;
@@ -213,12 +212,8 @@ void bochs_hw_setmode(struct bochs_device *bochs, bochs->stride = mode->hdisplay * (bochs->bpp /8 ); bochs->yres_virtual = bochs->fb_size / bochs->stride; -DRM_DEBUG_DRIVER ("%dx%d @ %d bpp, format %c%c%c%c, vy %d\n" , +DRM_DEBUG_DRIVER ("%dx%d @ %d bpp, vy %d\n" , bochs->xres, bochs->yres, bochs->bpp, - (format->format >>0 ) &0xff , - (format->format >>8 ) &0xff , - (format->format >>16 ) &0xff , - (format->format >>24 ) &0xff , bochs->yres_virtual);bochs_vga_writeb (bochs,0x3c0 ,0x20 );/* unblank */
@@ -236,6 +231,16 @@ void bochs_hw_setmode(struct bochs_device *bochs,bochs_dispi_write (bochs,VBE_DISPI_INDEX_ENABLE ,VBE_DISPI_ENABLED |VBE_DISPI_LFB_ENABLED ); +} + +void bochs_hw_setformat (struct bochs_device *bochs, +const struct drm_format_info *format) +{ +DRM_DEBUG_DRIVER ("format %c%c%c%c\n" , + (format->format >>0 ) &0xff , + (format->format >>8 ) &0xff , + (format->format >>16 ) &0xff , + (format->format >>24 ) &0xff );switch (format->format) {case DRM_FORMAT_XRGB8888 :
drivers/gpu/drm/bochs/bochs_kms.c +2 -1
@@ -80,7 +80,8 @@ static int bochs_crtc_mode_set(struct drm_crtc *crtc,if (WARN_ON (crtc->primary->fb ==NULL ))return -EINVAL ; -bochs_hw_setmode (bochs, mode, crtc->primary->fb->format); +bochs_hw_setmode (bochs, mode); +bochs_hw_setformat (bochs, crtc->primary->fb->format);bochs_crtc_mode_set_base (crtc, x, y, old_fb);return 0 ; }
Signature · 1 line
2.9.3
PATCH v2 3/15 drm/bochs: atomic: add atomic_flush+atomic_enable callbacks.
In reply to Gerd HoffmannConversion to atomic modesetting, step one.
Add atomic crtc helper callbacks.
--- drivers/gpu/drm/bochs/bochs_kms.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +25 -0
@@ -115,6 +115,29 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,return 0 ; } +static void bochs_crtc_atomic_enable (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +} + +static void bochs_crtc_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +struct drm_device *dev = crtc->dev; +struct drm_pending_vblank_event *event; + +if (crtc->state && crtc->state->event) { +unsigned long irqflags; + +spin_lock_irqsave (&dev->event_lock, irqflags); + event = crtc->state->event; + crtc->state->event =NULL ; +drm_crtc_send_vblank_event (crtc, event); +spin_unlock_irqrestore (&dev->event_lock, irqflags); + } +} + +/* These provide the minimum set of functions required to handle a CRTC */ static const struct drm_crtc_funcs bochs_crtc_funcs = { .set_config = drm_crtc_helper_set_config,
@@ -128,6 +151,8 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = { .mode_set_base = bochs_crtc_mode_set_base, .prepare = bochs_crtc_prepare, .commit = bochs_crtc_commit, + .atomic_enable = bochs_crtc_atomic_enable, + .atomic_flush = bochs_crtc_atomic_flush, };static const uint32_t bochs_formats[] = {
Signature · 1 line
2.9.3
PATCH v2 3/15 drm/bochs: atomic: add atomic_flush+atomic_enable callbacks.
In reply to Gerd HoffmannConversion to atomic modesetting, step one.
Add atomic crtc helper callbacks.
--- drivers/gpu/drm/bochs/bochs_kms.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +25 -0
@@ -115,6 +115,29 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,return 0 ; } +static void bochs_crtc_atomic_enable (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +} + +static void bochs_crtc_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +struct drm_device *dev = crtc->dev; +struct drm_pending_vblank_event *event; + +if (crtc->state && crtc->state->event) { +unsigned long irqflags; + +spin_lock_irqsave (&dev->event_lock, irqflags); + event = crtc->state->event; + crtc->state->event =NULL ; +drm_crtc_send_vblank_event (crtc, event); +spin_unlock_irqrestore (&dev->event_lock, irqflags); + } +} + +/* These provide the minimum set of functions required to handle a CRTC */ static const struct drm_crtc_funcs bochs_crtc_funcs = { .set_config = drm_crtc_helper_set_config,
@@ -128,6 +151,8 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = { .mode_set_base = bochs_crtc_mode_set_base, .prepare = bochs_crtc_prepare, .commit = bochs_crtc_commit, + .atomic_enable = bochs_crtc_atomic_enable, + .atomic_flush = bochs_crtc_atomic_flush, };static const uint32_t bochs_formats[] = {
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 03/15] drm/bochs: atomic: add atomic_flush+atomic_enable callbacks.
Quoted 13 lines · Gerd Hoffmann
Conversion to atomic modesetting, step one.
Add atomic crtc helper callbacks.Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/bochs/bochs_kms.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/gpu/drm/bochs/bochs_kms.c +0
-0
drivers/gpu/drm/bochs/bochs_kms.c static int bochs_crtc_page_flip(struct drm_crtc *crtc, · line 121
Quoted 7 lines
drivers/gpu/drm/bochs/bochs_kms.c +4
-0@@ -115,6 +115,29 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,return 0 ; } +static void bochs_crtc_atomic_enable (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +}
A patch to make this optional in the helpers would be neat. -Daniel
Quoted 38 lines
drivers/gpu/drm/bochs/bochs_kms.c +21
-0+ +static void bochs_crtc_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +struct drm_device *dev = crtc->dev; +struct drm_pending_vblank_event *event; + +if (crtc->state && crtc->state->event) { +unsigned long irqflags; + +spin_lock_irqsave (&dev->event_lock, irqflags); + event = crtc->state->event; + crtc->state->event =NULL ; +drm_crtc_send_vblank_event (crtc, event); +spin_unlock_irqrestore (&dev->event_lock, irqflags); + } +} + +/* These provide the minimum set of functions required to handle a CRTC */ static const struct drm_crtc_funcs bochs_crtc_funcs = { .set_config = drm_crtc_helper_set_config,@@ -128,6 +151,8 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = { .mode_set_base = bochs_crtc_mode_set_base, .prepare = bochs_crtc_prepare, .commit = bochs_crtc_commit, + .atomic_enable = bochs_crtc_atomic_enable, + .atomic_flush = bochs_crtc_atomic_flush, };static const uint32_t bochs_formats[] = {Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v2 03/15] drm/bochs: atomic: add atomic_flush+atomic_enable callbacks.
In reply to Gerd HoffmannQuoted 13 lines · Gerd Hoffmann
Conversion to atomic modesetting, step one.
Add atomic crtc helper callbacks.Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/bochs/bochs_kms.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/gpu/drm/bochs/bochs_kms.c +0
-0
drivers/gpu/drm/bochs/bochs_kms.c static int bochs_crtc_page_flip(struct drm_crtc *crtc, · line 121
Quoted 7 lines
drivers/gpu/drm/bochs/bochs_kms.c +4
-0@@ -115,6 +115,29 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,return 0 ; } +static void bochs_crtc_atomic_enable (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +}
A patch to make this optional in the helpers would be neat. -Daniel
Quoted 38 lines
drivers/gpu/drm/bochs/bochs_kms.c +21
-0+ +static void bochs_crtc_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +struct drm_device *dev = crtc->dev; +struct drm_pending_vblank_event *event; + +if (crtc->state && crtc->state->event) { +unsigned long irqflags; + +spin_lock_irqsave (&dev->event_lock, irqflags); + event = crtc->state->event; + crtc->state->event =NULL ; +drm_crtc_send_vblank_event (crtc, event); +spin_unlock_irqrestore (&dev->event_lock, irqflags); + } +} + +/* These provide the minimum set of functions required to handle a CRTC */ static const struct drm_crtc_funcs bochs_crtc_funcs = { .set_config = drm_crtc_helper_set_config,@@ -128,6 +151,8 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = { .mode_set_base = bochs_crtc_mode_set_base, .prepare = bochs_crtc_prepare, .commit = bochs_crtc_commit, + .atomic_enable = bochs_crtc_atomic_enable, + .atomic_flush = bochs_crtc_atomic_flush, };static const uint32_t bochs_formats[] = {Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 4/15 drm/bochs: atomic: add mode_set_nofb callback.
In reply to Gerd HoffmannConversion to atomic modesetting, step two.
Add mode_set_nofb crtc helper callback.
--- drivers/gpu/drm/bochs/bochs_kms.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +9 -0
@@ -86,6 +86,14 @@ static int bochs_crtc_mode_set(struct drm_crtc *crtc,return 0 ; } +static void bochs_crtc_mode_set_nofb (struct drm_crtc *crtc) +{ +struct bochs_device *bochs = + container_of(crtc, struct bochs_device, crtc); + +bochs_hw_setmode (bochs, &crtc->mode); +} +static void bochs_crtc_prepare (struct drm_crtc *crtc) { }
@@ -149,6 +157,7 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = { .dpms = bochs_crtc_dpms, .mode_set = bochs_crtc_mode_set, .mode_set_base = bochs_crtc_mode_set_base, + .mode_set_nofb = bochs_crtc_mode_set_nofb, .prepare = bochs_crtc_prepare, .commit = bochs_crtc_commit, .atomic_enable = bochs_crtc_atomic_enable,
Signature · 1 line
2.9.3
PATCH v2 4/15 drm/bochs: atomic: add mode_set_nofb callback.
In reply to Gerd HoffmannConversion to atomic modesetting, step two.
Add mode_set_nofb crtc helper callback.
--- drivers/gpu/drm/bochs/bochs_kms.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +9 -0
@@ -86,6 +86,14 @@ static int bochs_crtc_mode_set(struct drm_crtc *crtc,return 0 ; } +static void bochs_crtc_mode_set_nofb (struct drm_crtc *crtc) +{ +struct bochs_device *bochs = + container_of(crtc, struct bochs_device, crtc); + +bochs_hw_setmode (bochs, &crtc->mode); +} +static void bochs_crtc_prepare (struct drm_crtc *crtc) { }
@@ -149,6 +157,7 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = { .dpms = bochs_crtc_dpms, .mode_set = bochs_crtc_mode_set, .mode_set_base = bochs_crtc_mode_set_base, + .mode_set_nofb = bochs_crtc_mode_set_nofb, .prepare = bochs_crtc_prepare, .commit = bochs_crtc_commit, .atomic_enable = bochs_crtc_atomic_enable,
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 5/15 drm/bochs: atomic: switch planes to atomic, wire up helpers.
In reply to Gerd HoffmannConversion to atomic modesetting, step three.
Wire up atomic helpers. Switch planes to atomic.
We are late to the party, the transitional helpers are gone, so this can't be splitted into smaller steps any more.
--- drivers/gpu/drm/bochs/bochs_fbdev.c | 3 ++ drivers/gpu/drm/bochs/bochs_kms.c | 70 +++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 3 deletions(-)
drivers/gpu/drm/bochs/bochs_fbdev.c +3 -0
@@ -6,6 +6,7 @@*/ #include "bochs.h" +#include <drm/drm_atomic_helper.h> #include <drm/drm_gem_framebuffer_helper.h> /* ---------------------------------------------------------------------- */
@@ -149,6 +150,8 @@ bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,const struct drm_mode_config_funcs bochs_mode_funcs = { .fb_create = bochs_gem_fb_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, };int bochs_fbdev_init (struct bochs_device *bochs)
drivers/gpu/drm/bochs/bochs_kms.c +67 -3
121 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 5/15 drm/bochs: atomic: switch planes to atomic, wire up helpers.
In reply to Gerd HoffmannConversion to atomic modesetting, step three.
Wire up atomic helpers. Switch planes to atomic.
We are late to the party, the transitional helpers are gone, so this can't be splitted into smaller steps any more.
--- drivers/gpu/drm/bochs/bochs_fbdev.c | 3 ++ drivers/gpu/drm/bochs/bochs_kms.c | 70 +++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 3 deletions(-)
drivers/gpu/drm/bochs/bochs_fbdev.c +3 -0
@@ -6,6 +6,7 @@*/ #include "bochs.h" +#include <drm/drm_atomic_helper.h> #include <drm/drm_gem_framebuffer_helper.h> /* ---------------------------------------------------------------------- */
@@ -149,6 +150,8 @@ bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,const struct drm_mode_config_funcs bochs_mode_funcs = { .fb_create = bochs_gem_fb_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, };int bochs_fbdev_init (struct bochs_device *bochs)
drivers/gpu/drm/bochs/bochs_kms.c +67 -3
121 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 6/15 drm/bochs: atomic: use atomic set_config helper
In reply to Gerd HoffmannConversion to atomic modesetting, step four.
Use atomic set_config helper for crtc.
--- drivers/gpu/drm/bochs/bochs_kms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
@@ -150,7 +150,7 @@ static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,/* These provide the minimum set of functions required to handle a CRTC */ static const struct drm_crtc_funcs bochs_crtc_funcs = { - .set_config = drm_crtc_helper_set_config, + .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, .page_flip = bochs_crtc_page_flip, .reset = drm_atomic_helper_crtc_reset,
Signature · 1 line
2.9.3
PATCH v2 7/15 drm/bochs: atomic: use atomic page_flip helper
In reply to Gerd HoffmannConversion to atomic modesetting, step five.
Use atomic page_flip helper for crtc.
--- drivers/gpu/drm/bochs/bochs_kms.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +1 -22
@@ -104,27 +104,6 @@ static void bochs_crtc_commit(struct drm_crtc *crtc) { } -static int bochs_crtc_page_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_pending_vblank_event *event, -uint32_t page_flip_flags, -struct drm_modeset_acquire_ctx *ctx) -{ -struct bochs_device *bochs = - container_of(crtc, struct bochs_device, crtc); -struct drm_framebuffer *old_fb = crtc->primary->fb; -unsigned long irqflags; - -drm_atomic_set_fb_for_plane (crtc->primary->state, fb); -bochs_crtc_mode_set_base (crtc,0 ,0 , old_fb); -if (event) { -spin_lock_irqsave (&bochs->dev->event_lock, irqflags); -drm_crtc_send_vblank_event (crtc, event); -spin_unlock_irqrestore (&bochs->dev->event_lock, irqflags); - } -return 0 ; -} -static void bochs_crtc_atomic_enable (struct drm_crtc *crtc,struct drm_crtc_state *old_crtc_state) {
@@ -152,7 +131,7 @@ static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,static const struct drm_crtc_funcs bochs_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, - .page_flip = bochs_crtc_page_flip, + .page_flip = drm_atomic_helper_page_flip, .reset = drm_atomic_helper_crtc_reset, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
Signature · 1 line
2.9.3
PATCH v2 7/15 drm/bochs: atomic: use atomic page_flip helper
In reply to Gerd HoffmannConversion to atomic modesetting, step five.
Use atomic page_flip helper for crtc.
--- drivers/gpu/drm/bochs/bochs_kms.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +1 -22
@@ -104,27 +104,6 @@ static void bochs_crtc_commit(struct drm_crtc *crtc) { } -static int bochs_crtc_page_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_pending_vblank_event *event, -uint32_t page_flip_flags, -struct drm_modeset_acquire_ctx *ctx) -{ -struct bochs_device *bochs = - container_of(crtc, struct bochs_device, crtc); -struct drm_framebuffer *old_fb = crtc->primary->fb; -unsigned long irqflags; - -drm_atomic_set_fb_for_plane (crtc->primary->state, fb); -bochs_crtc_mode_set_base (crtc,0 ,0 , old_fb); -if (event) { -spin_lock_irqsave (&bochs->dev->event_lock, irqflags); -drm_crtc_send_vblank_event (crtc, event); -spin_unlock_irqrestore (&bochs->dev->event_lock, irqflags); - } -return 0 ; -} -static void bochs_crtc_atomic_enable (struct drm_crtc *crtc,struct drm_crtc_state *old_crtc_state) {
@@ -152,7 +131,7 @@ static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,static const struct drm_crtc_funcs bochs_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, - .page_flip = bochs_crtc_page_flip, + .page_flip = drm_atomic_helper_page_flip, .reset = drm_atomic_helper_crtc_reset, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 8/15 drm/bochs: atomic: set DRIVER_ATOMIC
In reply to Gerd HoffmannConversion to atomic modesetting, final step.
Set the DRIVER_ATOMIC flag.
--- drivers/gpu/drm/bochs/bochs_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_drv.c +1 -1
@@ -81,7 +81,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 , .fops = &bochs_fops, .name ="bochs-drm" , .desc ="bochs dispi vga interface (qemu stdvga)" ,
Signature · 1 line
2.9.3
PATCH v2 8/15 drm/bochs: atomic: set DRIVER_ATOMIC
In reply to Gerd HoffmannConversion to atomic modesetting, final step.
Set the DRIVER_ATOMIC flag.
--- drivers/gpu/drm/bochs/bochs_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_drv.c +1 -1
@@ -81,7 +81,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 , .fops = &bochs_fops, .name ="bochs-drm" , .desc ="bochs dispi vga interface (qemu stdvga)" ,
Signature · 1 line
2.9.3
PATCH v2 9/15 drm/bochs: remove old bochs_crtc_* functions
In reply to Gerd HoffmannRemove the old, now unused crtc callbacks.
--- drivers/gpu/drm/bochs/bochs_kms.c | 81 --------------------------------------- 1 file changed, 81 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -81
@@ -20,74 +20,6 @@ MODULE_PARM_DESC(defy, "default y resolution");/* ---------------------------------------------------------------------- */ -static void bochs_crtc_dpms (struct drm_crtc *crtc,int mode) -{ -switch (mode) { -case DRM_MODE_DPMS_ON : -case DRM_MODE_DPMS_STANDBY : -case DRM_MODE_DPMS_SUSPEND : -case DRM_MODE_DPMS_OFF : -default : -return ; - } -} - -static int bochs_crtc_mode_set_base (struct drm_crtc *crtc,int x,int y, -struct drm_framebuffer *old_fb) -{ -struct bochs_device *bochs = - container_of(crtc, struct bochs_device, crtc); -struct bochs_bo *bo; -u64 gpu_addr =0 ; -int ret; - -if (old_fb) { - bo =gem_to_bochs_bo (old_fb->obj[0 ]); - ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); -if (ret) { -DRM_ERROR ("failed to reserve old_fb bo\n" ); - }else { -bochs_bo_unpin (bo); -ttm_bo_unreserve (&bo->bo); - } - } - -if (WARN_ON (crtc->primary->fb ==NULL )) -return -EINVAL ; - - bo =gem_to_bochs_bo (crtc->primary->fb->obj[0 ]); - ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); -if (ret) -return ret; - - ret =bochs_bo_pin (bo,TTM_PL_FLAG_VRAM , &gpu_addr); -if (ret) { -ttm_bo_unreserve (&bo->bo); -return ret; - } - -ttm_bo_unreserve (&bo->bo); -bochs_hw_setbase (bochs, x, y, gpu_addr); -return 0 ; -} - -static int bochs_crtc_mode_set (struct drm_crtc *crtc, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode, -int x,int y,struct drm_framebuffer *old_fb) -{ -struct bochs_device *bochs = - container_of(crtc, struct bochs_device, crtc); - -if (WARN_ON (crtc->primary->fb ==NULL )) -return -EINVAL ; - -bochs_hw_setmode (bochs, mode); -bochs_hw_setformat (bochs, crtc->primary->fb->format); -bochs_crtc_mode_set_base (crtc, x, y, old_fb); -return 0 ; -} -static void bochs_crtc_mode_set_nofb (struct drm_crtc *crtc) { struct bochs_device *bochs =
@@ -96,14 +28,6 @@ static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)bochs_hw_setmode (bochs, &crtc->mode); } -static void bochs_crtc_prepare (struct drm_crtc *crtc) -{ -} - -static void bochs_crtc_commit (struct drm_crtc *crtc) -{ -} -static void bochs_crtc_atomic_enable (struct drm_crtc *crtc,struct drm_crtc_state *old_crtc_state) {
@@ -138,12 +62,7 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = { };static const struct drm_crtc_helper_funcs bochs_helper_funcs = { - .dpms = bochs_crtc_dpms, - .mode_set = bochs_crtc_mode_set, - .mode_set_base = bochs_crtc_mode_set_base, .mode_set_nofb = bochs_crtc_mode_set_nofb, - .prepare = bochs_crtc_prepare, - .commit = bochs_crtc_commit, .atomic_enable = bochs_crtc_atomic_enable, .atomic_flush = bochs_crtc_atomic_flush, };
Signature · 1 line
2.9.3
PATCH v2 9/15 drm/bochs: remove old bochs_crtc_* functions
In reply to Gerd HoffmannRemove the old, now unused crtc callbacks.
--- drivers/gpu/drm/bochs/bochs_kms.c | 81 --------------------------------------- 1 file changed, 81 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -81
@@ -20,74 +20,6 @@ MODULE_PARM_DESC(defy, "default y resolution");/* ---------------------------------------------------------------------- */ -static void bochs_crtc_dpms (struct drm_crtc *crtc,int mode) -{ -switch (mode) { -case DRM_MODE_DPMS_ON : -case DRM_MODE_DPMS_STANDBY : -case DRM_MODE_DPMS_SUSPEND : -case DRM_MODE_DPMS_OFF : -default : -return ; - } -} - -static int bochs_crtc_mode_set_base (struct drm_crtc *crtc,int x,int y, -struct drm_framebuffer *old_fb) -{ -struct bochs_device *bochs = - container_of(crtc, struct bochs_device, crtc); -struct bochs_bo *bo; -u64 gpu_addr =0 ; -int ret; - -if (old_fb) { - bo =gem_to_bochs_bo (old_fb->obj[0 ]); - ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); -if (ret) { -DRM_ERROR ("failed to reserve old_fb bo\n" ); - }else { -bochs_bo_unpin (bo); -ttm_bo_unreserve (&bo->bo); - } - } - -if (WARN_ON (crtc->primary->fb ==NULL )) -return -EINVAL ; - - bo =gem_to_bochs_bo (crtc->primary->fb->obj[0 ]); - ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); -if (ret) -return ret; - - ret =bochs_bo_pin (bo,TTM_PL_FLAG_VRAM , &gpu_addr); -if (ret) { -ttm_bo_unreserve (&bo->bo); -return ret; - } - -ttm_bo_unreserve (&bo->bo); -bochs_hw_setbase (bochs, x, y, gpu_addr); -return 0 ; -} - -static int bochs_crtc_mode_set (struct drm_crtc *crtc, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode, -int x,int y,struct drm_framebuffer *old_fb) -{ -struct bochs_device *bochs = - container_of(crtc, struct bochs_device, crtc); - -if (WARN_ON (crtc->primary->fb ==NULL )) -return -EINVAL ; - -bochs_hw_setmode (bochs, mode); -bochs_hw_setformat (bochs, crtc->primary->fb->format); -bochs_crtc_mode_set_base (crtc, x, y, old_fb); -return 0 ; -} -static void bochs_crtc_mode_set_nofb (struct drm_crtc *crtc) { struct bochs_device *bochs =
@@ -96,14 +28,6 @@ static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)bochs_hw_setmode (bochs, &crtc->mode); } -static void bochs_crtc_prepare (struct drm_crtc *crtc) -{ -} - -static void bochs_crtc_commit (struct drm_crtc *crtc) -{ -} -static void bochs_crtc_atomic_enable (struct drm_crtc *crtc,struct drm_crtc_state *old_crtc_state) {
@@ -138,12 +62,7 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = { };static const struct drm_crtc_helper_funcs bochs_helper_funcs = { - .dpms = bochs_crtc_dpms, - .mode_set = bochs_crtc_mode_set, - .mode_set_base = bochs_crtc_mode_set_base, .mode_set_nofb = bochs_crtc_mode_set_nofb, - .prepare = bochs_crtc_prepare, - .commit = bochs_crtc_commit, .atomic_enable = bochs_crtc_atomic_enable, .atomic_flush = bochs_crtc_atomic_flush, };
Signature · 1 line
2.9.3
PATCH v2 10/15 drm/bochs: drop unused gpu_addr arg from bochs_bo_pin()
In reply to Gerd HoffmannIt's always NULL, so just remove it.
--- drivers/gpu/drm/bochs/bochs.h | 2 +- drivers/gpu/drm/bochs/bochs_fbdev.c | 2 +- drivers/gpu/drm/bochs/bochs_kms.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c | 11 +---------- 4 files changed, 4 insertions(+), 13 deletions(-)
drivers/gpu/drm/bochs/bochs.h +1 -1
@@ -142,7 +142,7 @@ int bochs_dumb_create(struct drm_file *file, struct drm_device *dev,int bochs_dumb_mmap_offset (struct drm_file *file,struct drm_device *dev,uint32_t handle,uint64_t *offset); -int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag,u64 *gpu_addr); +int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag);int bochs_bo_unpin (struct bochs_bo *bo);/* bochs_kms.c */
drivers/gpu/drm/bochs/bochs_fbdev.c +1 -1
@@ -81,7 +81,7 @@ static int bochsfb_create(struct drm_fb_helper *helper,if (ret)return ret; - ret =bochs_bo_pin (bo,TTM_PL_FLAG_VRAM ,NULL ); + ret =bochs_bo_pin (bo,TTM_PL_FLAG_VRAM );if (ret) {DRM_ERROR ("failed to pin fbcon\n" );ttm_bo_unreserve (&bo->bo);
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
@@ -96,7 +96,7 @@ static int bochs_plane_prepare_fb(struct drm_plane *plane,if (!new_state->fb)return 0 ; bo =gem_to_bochs_bo (new_state->fb->obj[0 ]); -return bochs_bo_pin (bo,TTM_PL_FLAG_VRAM ,NULL ); +return bochs_bo_pin (bo,TTM_PL_FLAG_VRAM ); } static void bochs_plane_cleanup_fb(struct drm_plane *plane,
drivers/gpu/drm/bochs/bochs_mm.c +1 -10
@@ -210,20 +210,13 @@ static void bochs_ttm_placement(struct bochs_bo *bo, int domain) bo->placement.num_busy_placement = c; } -static inline u64 bochs_bo_gpu_offset (struct bochs_bo *bo) -{ -return bo->bo.offset; -} - -int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag,u64 *gpu_addr) +int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag) {struct ttm_operation_ctx ctx = { false, false };int i, ret;if (bo->pin_count) { bo->pin_count++; -if (gpu_addr) - *gpu_addr =bochs_bo_gpu_offset (bo);return 0 ; }
@@ -235,8 +228,6 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr)return ret; bo->pin_count =1 ; -if (gpu_addr) - *gpu_addr =bochs_bo_gpu_offset (bo);return 0 ; }
Signature · 1 line
2.9.3
PATCH v2 10/15 drm/bochs: drop unused gpu_addr arg from bochs_bo_pin()
In reply to Gerd HoffmannIt's always NULL, so just remove it.
--- drivers/gpu/drm/bochs/bochs.h | 2 +- drivers/gpu/drm/bochs/bochs_fbdev.c | 2 +- drivers/gpu/drm/bochs/bochs_kms.c | 2 +- drivers/gpu/drm/bochs/bochs_mm.c | 11 +---------- 4 files changed, 4 insertions(+), 13 deletions(-)
drivers/gpu/drm/bochs/bochs.h +1 -1
@@ -142,7 +142,7 @@ int bochs_dumb_create(struct drm_file *file, struct drm_device *dev,int bochs_dumb_mmap_offset (struct drm_file *file,struct drm_device *dev,uint32_t handle,uint64_t *offset); -int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag,u64 *gpu_addr); +int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag);int bochs_bo_unpin (struct bochs_bo *bo);/* bochs_kms.c */
drivers/gpu/drm/bochs/bochs_fbdev.c +1 -1
@@ -81,7 +81,7 @@ static int bochsfb_create(struct drm_fb_helper *helper,if (ret)return ret; - ret =bochs_bo_pin (bo,TTM_PL_FLAG_VRAM ,NULL ); + ret =bochs_bo_pin (bo,TTM_PL_FLAG_VRAM );if (ret) {DRM_ERROR ("failed to pin fbcon\n" );ttm_bo_unreserve (&bo->bo);
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
@@ -96,7 +96,7 @@ static int bochs_plane_prepare_fb(struct drm_plane *plane,if (!new_state->fb)return 0 ; bo =gem_to_bochs_bo (new_state->fb->obj[0 ]); -return bochs_bo_pin (bo,TTM_PL_FLAG_VRAM ,NULL ); +return bochs_bo_pin (bo,TTM_PL_FLAG_VRAM ); } static void bochs_plane_cleanup_fb(struct drm_plane *plane,
drivers/gpu/drm/bochs/bochs_mm.c +1 -10
@@ -210,20 +210,13 @@ static void bochs_ttm_placement(struct bochs_bo *bo, int domain) bo->placement.num_busy_placement = c; } -static inline u64 bochs_bo_gpu_offset (struct bochs_bo *bo) -{ -return bo->bo.offset; -} - -int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag,u64 *gpu_addr) +int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag) {struct ttm_operation_ctx ctx = { false, false };int i, ret;if (bo->pin_count) { bo->pin_count++; -if (gpu_addr) - *gpu_addr =bochs_bo_gpu_offset (bo);return 0 ; }
@@ -235,8 +228,6 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr)return ret; bo->pin_count =1 ; -if (gpu_addr) - *gpu_addr =bochs_bo_gpu_offset (bo);return 0 ; }
Signature · 1 line
2.9.3
PATCH v2 11/15 drm/bochs: add basic prime support
In reply to Gerd HoffmannGeneric framebuffer emulation needs this.
--- drivers/gpu/drm/bochs/bochs.h | 11 +++++++ drivers/gpu/drm/bochs/bochs_drv.c | 15 +++++++++- drivers/gpu/drm/bochs/bochs_mm.c | 63 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs.h +11 -0
@@ -145,6 +145,17 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag);int bochs_bo_unpin (struct bochs_bo *bo); +int bochs_gem_prime_pin (struct drm_gem_object *obj); +void bochs_gem_prime_unpin (struct drm_gem_object *obj); +struct sg_table *bochs_gem_prime_get_sg_table (struct drm_gem_object *obj); +struct drm_gem_object *bochs_gem_prime_import_sg_table ( +struct drm_device *dev,struct dma_buf_attachment *attach, +struct sg_table *sgt); +void *bochs_gem_prime_vmap (struct drm_gem_object *obj); +void bochs_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr); +int bochs_gem_prime_mmap (struct drm_gem_object *obj, +struct vm_area_struct *vma); +/* bochs_kms.c */ int bochs_kms_init (struct bochs_device *bochs);void bochs_kms_fini (struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_drv.c +14 -1
@@ -81,7 +81,8 @@ static const struct file_operations bochs_fops = { };static struct drm_driver bochs_driver = { - .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_ATOMIC , + .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_ATOMIC | +DRIVER_PRIME , .fops = &bochs_fops, .name ="bochs-drm" , .desc ="bochs dispi vga interface (qemu stdvga)" ,
@@ -91,6 +92,18 @@ static struct drm_driver bochs_driver = { .gem_free_object_unlocked = bochs_gem_free_object, .dumb_create = bochs_dumb_create, .dumb_map_offset = bochs_dumb_mmap_offset, + + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_pin = bochs_gem_prime_pin, + .gem_prime_unpin = bochs_gem_prime_unpin, + .gem_prime_get_sg_table = bochs_gem_prime_get_sg_table, + .gem_prime_import_sg_table = bochs_gem_prime_import_sg_table, + .gem_prime_vmap = bochs_gem_prime_vmap, + .gem_prime_vunmap = bochs_gem_prime_vunmap, + .gem_prime_mmap = bochs_gem_prime_mmap, };/* ---------------------------------------------------------------------- */
drivers/gpu/drm/bochs/bochs_mm.c +63 -0
66 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 11/15 drm/bochs: add basic prime support
In reply to Gerd HoffmannGeneric framebuffer emulation needs this.
--- drivers/gpu/drm/bochs/bochs.h | 11 +++++++ drivers/gpu/drm/bochs/bochs_drv.c | 15 +++++++++- drivers/gpu/drm/bochs/bochs_mm.c | 63 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs.h +11 -0
@@ -145,6 +145,17 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,int bochs_bo_pin (struct bochs_bo *bo,u32 pl_flag);int bochs_bo_unpin (struct bochs_bo *bo); +int bochs_gem_prime_pin (struct drm_gem_object *obj); +void bochs_gem_prime_unpin (struct drm_gem_object *obj); +struct sg_table *bochs_gem_prime_get_sg_table (struct drm_gem_object *obj); +struct drm_gem_object *bochs_gem_prime_import_sg_table ( +struct drm_device *dev,struct dma_buf_attachment *attach, +struct sg_table *sgt); +void *bochs_gem_prime_vmap (struct drm_gem_object *obj); +void bochs_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr); +int bochs_gem_prime_mmap (struct drm_gem_object *obj, +struct vm_area_struct *vma); +/* bochs_kms.c */ int bochs_kms_init (struct bochs_device *bochs);void bochs_kms_fini (struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_drv.c +14 -1
@@ -81,7 +81,8 @@ static const struct file_operations bochs_fops = { };static struct drm_driver bochs_driver = { - .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_ATOMIC , + .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_ATOMIC | +DRIVER_PRIME , .fops = &bochs_fops, .name ="bochs-drm" , .desc ="bochs dispi vga interface (qemu stdvga)" ,
@@ -91,6 +92,18 @@ static struct drm_driver bochs_driver = { .gem_free_object_unlocked = bochs_gem_free_object, .dumb_create = bochs_dumb_create, .dumb_map_offset = bochs_dumb_mmap_offset, + + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_pin = bochs_gem_prime_pin, + .gem_prime_unpin = bochs_gem_prime_unpin, + .gem_prime_get_sg_table = bochs_gem_prime_get_sg_table, + .gem_prime_import_sg_table = bochs_gem_prime_import_sg_table, + .gem_prime_vmap = bochs_gem_prime_vmap, + .gem_prime_vunmap = bochs_gem_prime_vunmap, + .gem_prime_mmap = bochs_gem_prime_mmap, };/* ---------------------------------------------------------------------- */
drivers/gpu/drm/bochs/bochs_mm.c +63 -0
66 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 12/15 drm/bochs: switch to generic drm fbdev emulation
In reply to Gerd Hoffmann--- drivers/gpu/drm/bochs/bochs_drv.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/bochs/bochs_drv.c +1 -8
@@ -16,10 +16,6 @@ static int bochs_modeset = -1;module_param_named (modeset, bochs_modeset, int,0444 );MODULE_PARM_DESC (modeset,"enable/disable kernel modesetting" ); -static bool enable_fbdev = true; -module_param_named (fbdev, enable_fbdev, bool,0444 ); -MODULE_PARM_DESC (fbdev,"register fbdev device" ); -/* ---------------------------------------------------------------------- */ /* drm interface */
@@ -27,7 +23,6 @@ static void bochs_unload(struct drm_device *dev) {struct bochs_device *bochs = dev->dev_private; -bochs_fbdev_fini (bochs);bochs_kms_fini (bochs);bochs_mm_fini (bochs);bochs_hw_fini (dev);
@@ -58,9 +53,6 @@ static int bochs_load(struct drm_device *dev)if (ret) goto err; -if (enable_fbdev) -bochs_fbdev_init (bochs); -return 0 ; err:
@@ -178,6 +170,7 @@ static int bochs_pci_probe(struct pci_dev *pdev,if (ret) goto err_unload; +drm_fbdev_generic_setup (dev,32 );return ret; err_unload:
Signature · 1 line
2.9.3
PATCH v2 12/15 drm/bochs: switch to generic drm fbdev emulation
In reply to Gerd Hoffmann--- drivers/gpu/drm/bochs/bochs_drv.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/bochs/bochs_drv.c +1 -8
@@ -16,10 +16,6 @@ static int bochs_modeset = -1;module_param_named (modeset, bochs_modeset, int,0444 );MODULE_PARM_DESC (modeset,"enable/disable kernel modesetting" ); -static bool enable_fbdev = true; -module_param_named (fbdev, enable_fbdev, bool,0444 ); -MODULE_PARM_DESC (fbdev,"register fbdev device" ); -/* ---------------------------------------------------------------------- */ /* drm interface */
@@ -27,7 +23,6 @@ static void bochs_unload(struct drm_device *dev) {struct bochs_device *bochs = dev->dev_private; -bochs_fbdev_fini (bochs);bochs_kms_fini (bochs);bochs_mm_fini (bochs);bochs_hw_fini (dev);
@@ -58,9 +53,6 @@ static int bochs_load(struct drm_device *dev)if (ret) goto err; -if (enable_fbdev) -bochs_fbdev_init (bochs); -return 0 ; err:
@@ -178,6 +170,7 @@ static int bochs_pci_probe(struct pci_dev *pdev,if (ret) goto err_unload; +drm_fbdev_generic_setup (dev,32 );return ret; err_unload:
Signature · 1 line
2.9.3
PATCH v2 13/15 drm/bochs: drop old fbdev emulation code
In reply to Gerd HoffmannNot needed any more, bochs uses the generic emulation now.
--- drivers/gpu/drm/bochs/bochs.h | 9 --- drivers/gpu/drm/bochs/bochs_drv.c | 6 -- drivers/gpu/drm/bochs/bochs_fbdev.c | 137 ------------------------------------ 3 files changed, 152 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -9
@@ -80,12 +80,6 @@ struct bochs_device {struct ttm_bo_device bdev;bool initialized; } ttm; - -/* fbdev */ -struct { -struct drm_framebuffer *fb; -struct drm_fb_helper helper; - } fb; };struct bochs_bo {
@@ -161,7 +155,4 @@ int bochs_kms_init(struct bochs_device *bochs);void bochs_kms_fini (struct bochs_device *bochs);/* bochs_fbdev.c */ -int bochs_fbdev_init (struct bochs_device *bochs); -void bochs_fbdev_fini (struct bochs_device *bochs); -extern const struct drm_mode_config_funcs bochs_mode_funcs;
drivers/gpu/drm/bochs/bochs_drv.c +0 -6
@@ -106,12 +106,9 @@ static int bochs_pm_suspend(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -struct bochs_device *bochs = drm_dev->dev_private;drm_kms_helper_poll_disable (drm_dev); -drm_fb_helper_set_suspend_unlocked (&bochs->fb.helper,1 ); -return 0 ; }
@@ -119,12 +116,9 @@ static int bochs_pm_resume(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -struct bochs_device *bochs = drm_dev->dev_private;drm_helper_resume_force_mode (drm_dev); -drm_fb_helper_set_suspend_unlocked (&bochs->fb.helper,0 ); -drm_kms_helper_poll_enable (drm_dev);return 0 ; }
drivers/gpu/drm/bochs/bochs_fbdev.c +0 -137
146 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 13/15 drm/bochs: drop old fbdev emulation code
In reply to Gerd HoffmannNot needed any more, bochs uses the generic emulation now.
--- drivers/gpu/drm/bochs/bochs.h | 9 --- drivers/gpu/drm/bochs/bochs_drv.c | 6 -- drivers/gpu/drm/bochs/bochs_fbdev.c | 137 ------------------------------------ 3 files changed, 152 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -9
@@ -80,12 +80,6 @@ struct bochs_device {struct ttm_bo_device bdev;bool initialized; } ttm; - -/* fbdev */ -struct { -struct drm_framebuffer *fb; -struct drm_fb_helper helper; - } fb; };struct bochs_bo {
@@ -161,7 +155,4 @@ int bochs_kms_init(struct bochs_device *bochs);void bochs_kms_fini (struct bochs_device *bochs);/* bochs_fbdev.c */ -int bochs_fbdev_init (struct bochs_device *bochs); -void bochs_fbdev_fini (struct bochs_device *bochs); -extern const struct drm_mode_config_funcs bochs_mode_funcs;
drivers/gpu/drm/bochs/bochs_drv.c +0 -6
@@ -106,12 +106,9 @@ static int bochs_pm_suspend(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -struct bochs_device *bochs = drm_dev->dev_private;drm_kms_helper_poll_disable (drm_dev); -drm_fb_helper_set_suspend_unlocked (&bochs->fb.helper,1 ); -return 0 ; }
@@ -119,12 +116,9 @@ static int bochs_pm_resume(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); -struct bochs_device *bochs = drm_dev->dev_private;drm_helper_resume_force_mode (drm_dev); -drm_fb_helper_set_suspend_unlocked (&bochs->fb.helper,0 ); -drm_kms_helper_poll_enable (drm_dev);return 0 ; }
drivers/gpu/drm/bochs/bochs_fbdev.c +0 -137
146 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 14/15 drm/bochs: move remaining fb bits to kms
In reply to Gerd Hoffmannbochs_fbdev.c is almost empty now. Move the remaining framebuffer bits over to bochs_kms.c. Pure code motion. No functional change.
--- drivers/gpu/drm/bochs/bochs_fbdev.c | 29 ----------------------------- drivers/gpu/drm/bochs/bochs_kms.c | 17 +++++++++++++++++ drivers/gpu/drm/bochs/Makefile | 2 +- 3 files changed, 18 insertions(+), 30 deletions(-) delete mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c
drivers/gpu/drm/bochs/bochs_fbdev.c deleted +0 -29
@@ -1,29 +0,0 @@ -/* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -*/ - -#include "bochs.h" -#include <drm/drm_atomic_helper.h> -#include <drm/drm_gem_framebuffer_helper.h> - -/* ---------------------------------------------------------------------- */ - -static struct drm_framebuffer * -bochs_gem_fb_create (struct drm_device *dev,struct drm_file *file, -const struct drm_mode_fb_cmd2 *mode_cmd) -{ -if (mode_cmd->pixel_format !=DRM_FORMAT_XRGB8888 && - mode_cmd->pixel_format !=DRM_FORMAT_BGRX8888 ) -return ERR_PTR (-EINVAL ); - -return drm_gem_fb_create (dev, file, mode_cmd); -} - -const struct drm_mode_config_funcs bochs_mode_funcs = { - .fb_create = bochs_gem_fb_create, - .atomic_check = drm_atomic_helper_check, - .atomic_commit = drm_atomic_helper_commit, -};
drivers/gpu/drm/bochs/bochs_kms.c +17 -0
@@ -9,6 +9,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_plane_helper.h> #include <drm/drm_atomic_uapi.h> +#include <drm/drm_gem_framebuffer_helper.h> static int defx =1024 ;static int defy =768 ;
@@ -256,6 +257,22 @@ static void bochs_connector_init(struct drm_device *dev) } } +static struct drm_framebuffer * +bochs_gem_fb_create (struct drm_device *dev,struct drm_file *file, +const struct drm_mode_fb_cmd2 *mode_cmd) +{ +if (mode_cmd->pixel_format !=DRM_FORMAT_XRGB8888 && + mode_cmd->pixel_format !=DRM_FORMAT_BGRX8888 ) +return ERR_PTR (-EINVAL ); + +return drm_gem_fb_create (dev, file, mode_cmd); +} + +const struct drm_mode_config_funcs bochs_mode_funcs = { + .fb_create = bochs_gem_fb_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, +};int bochs_kms_init (struct bochs_device *bochs) {
drivers/gpu/drm/bochs/Makefile +1 -1
@@ -1,3 +1,3 @@ -bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_fbdev.o bochs_hw.o +bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_hw.o obj-$(CONFIG_DRM_BOCHS) += bochs-drm.o
Signature · 1 line
2.9.3
PATCH v2 14/15 drm/bochs: move remaining fb bits to kms
In reply to Gerd Hoffmannbochs_fbdev.c is almost empty now. Move the remaining framebuffer bits over to bochs_kms.c. Pure code motion. No functional change.
--- drivers/gpu/drm/bochs/bochs_fbdev.c | 29 ----------------------------- drivers/gpu/drm/bochs/bochs_kms.c | 17 +++++++++++++++++ drivers/gpu/drm/bochs/Makefile | 2 +- 3 files changed, 18 insertions(+), 30 deletions(-) delete mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c
drivers/gpu/drm/bochs/bochs_fbdev.c deleted +0 -29
@@ -1,29 +0,0 @@ -/* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -*/ - -#include "bochs.h" -#include <drm/drm_atomic_helper.h> -#include <drm/drm_gem_framebuffer_helper.h> - -/* ---------------------------------------------------------------------- */ - -static struct drm_framebuffer * -bochs_gem_fb_create (struct drm_device *dev,struct drm_file *file, -const struct drm_mode_fb_cmd2 *mode_cmd) -{ -if (mode_cmd->pixel_format !=DRM_FORMAT_XRGB8888 && - mode_cmd->pixel_format !=DRM_FORMAT_BGRX8888 ) -return ERR_PTR (-EINVAL ); - -return drm_gem_fb_create (dev, file, mode_cmd); -} - -const struct drm_mode_config_funcs bochs_mode_funcs = { - .fb_create = bochs_gem_fb_create, - .atomic_check = drm_atomic_helper_check, - .atomic_commit = drm_atomic_helper_commit, -};
drivers/gpu/drm/bochs/bochs_kms.c +17 -0
@@ -9,6 +9,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_plane_helper.h> #include <drm/drm_atomic_uapi.h> +#include <drm/drm_gem_framebuffer_helper.h> static int defx =1024 ;static int defy =768 ;
@@ -256,6 +257,22 @@ static void bochs_connector_init(struct drm_device *dev) } } +static struct drm_framebuffer * +bochs_gem_fb_create (struct drm_device *dev,struct drm_file *file, +const struct drm_mode_fb_cmd2 *mode_cmd) +{ +if (mode_cmd->pixel_format !=DRM_FORMAT_XRGB8888 && + mode_cmd->pixel_format !=DRM_FORMAT_BGRX8888 ) +return ERR_PTR (-EINVAL ); + +return drm_gem_fb_create (dev, file, mode_cmd); +} + +const struct drm_mode_config_funcs bochs_mode_funcs = { + .fb_create = bochs_gem_fb_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, +};int bochs_kms_init (struct bochs_device *bochs) {
drivers/gpu/drm/bochs/Makefile +1 -1
@@ -1,3 +1,3 @@ -bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_fbdev.o bochs_hw.o +bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_hw.o obj-$(CONFIG_DRM_BOCHS) += bochs-drm.o
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 15/15 drm/bochs: reserve bo for pin/unpin
In reply to Gerd HoffmannThe buffer object must be reserved before callingttm_bo_validate for pinning/unpinning.
--- drivers/gpu/drm/bochs/bochs_mm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/bochs/bochs_mm.c +8 -0
@@ -223,7 +223,11 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag)bochs_ttm_placement (bo, pl_flag);for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i].flags |=TTM_PL_FLAG_NO_EVICT ; + ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); +if (ret) +return ret; ret =ttm_bo_validate (&bo->bo, &bo->placement, &ctx); +ttm_bo_unreserve (&bo->bo);if (ret)return ret;
@@ -247,7 +251,11 @@ int bochs_bo_unpin(struct bochs_bo *bo)for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT ; + ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); +if (ret) +return ret; ret =ttm_bo_validate (&bo->bo, &bo->placement, &ctx); +ttm_bo_unreserve (&bo->bo);if (ret)return ret;
Signature · 1 line
2.9.3
PATCH v2 15/15 drm/bochs: reserve bo for pin/unpin
In reply to Gerd HoffmannThe buffer object must be reserved before callingttm_bo_validate for pinning/unpinning.
--- drivers/gpu/drm/bochs/bochs_mm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/bochs/bochs_mm.c +8 -0
@@ -223,7 +223,11 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag)bochs_ttm_placement (bo, pl_flag);for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i].flags |=TTM_PL_FLAG_NO_EVICT ; + ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); +if (ret) +return ret; ret =ttm_bo_validate (&bo->bo, &bo->placement, &ctx); +ttm_bo_unreserve (&bo->bo);if (ret)return ret;
@@ -247,7 +251,11 @@ int bochs_bo_unpin(struct bochs_bo *bo)for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT ; + ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); +if (ret) +return ret; ret =ttm_bo_validate (&bo->bo, &bo->placement, &ctx); +ttm_bo_unreserve (&bo->bo);if (ret)return ret;
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
Quoted 4 lines · Gerd Hoffmann
The buffer object must be reserved before calling
ttm_bo_validatefor pinning/unpinning.Signed-off-by Gerd Hoffmann <[email protected]>
Seems a bit a bisect fumble in your series here: legacy kms code reserved the ttm bo before calling boch_bo_pin/unpin, your atomic code doesn't. I think pushing this into bochs_bo_pin/unpin makes sense for atomic, but to avoid bisect fail I think you need to have these temporarily in your cleanup/prepare_plane functions too.
Looked through the entire series, this here is the only issue I think should be fixed before merging (making atomic_enable optional can be done as a follow-up if you feel like it). With that addressed on the series:
Quoted 39 lines
--- drivers/gpu/drm/bochs/bochs_mm.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/bochs/bochs_mm.c +8
-0@@ -223,7 +223,11 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag)bochs_ttm_placement (bo, pl_flag);for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i].flags |=TTM_PL_FLAG_NO_EVICT ; + ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); +if (ret) +return ret; ret =ttm_bo_validate (&bo->bo, &bo->placement, &ctx); +ttm_bo_unreserve (&bo->bo);if (ret)return ret;@@ -247,7 +251,11 @@ int bochs_bo_unpin(struct bochs_bo *bo)for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT ; + ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); +if (ret) +return ret; ret =ttm_bo_validate (&bo->bo, &bo->placement, &ctx); +ttm_bo_unreserve (&bo->bo);if (ret)return ret;Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
In reply to Gerd HoffmannQuoted 4 lines · Gerd Hoffmann
The buffer object must be reserved before calling
ttm_bo_validatefor pinning/unpinning.Signed-off-by Gerd Hoffmann <[email protected]>
Seems a bit a bisect fumble in your series here: legacy kms code reserved the ttm bo before calling boch_bo_pin/unpin, your atomic code doesn't. I think pushing this into bochs_bo_pin/unpin makes sense for atomic, but to avoid bisect fail I think you need to have these temporarily in your cleanup/prepare_plane functions too.
Looked through the entire series, this here is the only issue I think should be fixed before merging (making atomic_enable optional can be done as a follow-up if you feel like it). With that addressed on the series:
Quoted 39 lines
--- drivers/gpu/drm/bochs/bochs_mm.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/bochs/bochs_mm.c +8
-0@@ -223,7 +223,11 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag)bochs_ttm_placement (bo, pl_flag);for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i].flags |=TTM_PL_FLAG_NO_EVICT ; + ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); +if (ret) +return ret; ret =ttm_bo_validate (&bo->bo, &bo->placement, &ctx); +ttm_bo_unreserve (&bo->bo);if (ret)return ret;@@ -247,7 +251,11 @@ int bochs_bo_unpin(struct bochs_bo *bo)for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT ; + ret =ttm_bo_reserve (&bo->bo, true, false,NULL ); +if (ret) +return ret; ret =ttm_bo_validate (&bo->bo, &bo->placement, &ctx); +ttm_bo_unreserve (&bo->bo);if (ret)return ret;Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
Quoted 11 lines · Daniel Vetter
Quoted 4 lines · Gerd Hoffmann
The buffer object must be reserved before calling
ttm_bo_validatefor pinning/unpinning.Signed-off-by Gerd Hoffmann <[email protected]>Seems a bit a bisect fumble in your series here: legacy kms code reserved the ttm bo before calling boch_bo_pin/unpin, your atomic code doesn't. I think pushing this into bochs_bo_pin/unpin makes sense for atomic, but to avoid bisect fail I think you need to have these temporarily in your cleanup/prepare_plane functions too.
I think I've sorted that. Have some other changes too, will probably send v3 tomorrow.
Quoted 5 lines
Looked through the entire series, this here is the only issue I think should be fixed before merging (making
atomic_enableoptional can be done as a follow-up if you feel like it). With that addressed on the series:Acked-by Daniel Vetter <[email protected]>
Thanks.
While being at it: I'm also looking at dma-buf export and import support for the qemu drivers.
Right now both qxl and virtio have gem_prime_get_sg_table and gem_prime_import_sg_table handlers which throw a WARN_ONCE() and return an error.
If I understand things correctly it is valid to set all import/export callbacks (prime_handle_to_fd, prime_fd_to_handle, gem_prime_get_sg_table, gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertise DRIVER_PRIME to indicate the other prime callbacks are supported (so generic fbdev emulation can use gem_prime_vmap etc). Is that correct?
On exporting:
TTM_PL_TT should be easy, just pin the buffer, grab the pages list and feed that into drm_prime_pages_to_sg. Didn't try yet though. Is that approach correct?
Is it possible to export TTM_PL_VRAM objects (with backing storage being a pci memory bar)? If so, how?
On importing:
Importing into TTM_PL_TT object looks easy again, at least when the object is actually stored in RAM. What if not?
Importing into TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?
thanks,
Gerd
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
Quoted 32 lines · Gerd Hoffmann
Quoted 11 lines · Daniel Vetter
Quoted 4 lines · Gerd Hoffmann
The buffer object must be reserved before calling
ttm_bo_validatefor pinning/unpinning.Signed-off-by Gerd Hoffmann <[email protected]>Seems a bit a bisect fumble in your series here: legacy kms code reserved the ttm bo before calling boch_bo_pin/unpin, your atomic code doesn't. I think pushing this into bochs_bo_pin/unpin makes sense for atomic, but to avoid bisect fail I think you need to have these temporarily in your cleanup/prepare_plane functions too.
I think I've sorted that. Have some other changes too, will probably send v3 tomorrow.
Quoted 5 lines
Looked through the entire series, this here is the only issue I think should be fixed before merging (making
atomic_enableoptional can be done as a follow-up if you feel like it). With that addressed on the series:Acked-by Daniel Vetter <[email protected]>Thanks.
While being at it: I'm also looking at dma-buf export and import support for the qemu drivers.
Right now both qxl and virtio have
gem_prime_get_sg_tableandgem_prime_import_sg_tablehandlers which throw aWARN_ONCE()and return an error.
Quoted 6 lines
If I understand things correctly it is valid to set all import/export callbacks (
prime_handle_to_fd,prime_fd_to_handle,gem_prime_get_sg_table,gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertiseDRIVER_PRIMEto indicate the other prime callbacks are supported (so generic fbdev emulation can usegem_prime_vmapetc). Is that correct?
I'm not sure how much that's a good idea ... Never thought about it tbh. All the fbdev/dma-buf stuff has plenty of hacks and inconsistencies still, so I guess we can't make it much worse really.
Quoted 8 lines
On exporting:
TTM_PL_TTshould be easy, just pin the buffer, grab the pages list and feed that intodrm_prime_pages_to_sg. Didn't try yet though. Is that approach correct?Is it possible to export
TTM_PL_VRAMobjects (with backing storage being a pci memory bar)? If so, how?
Not really in general. amdgpu upcasts to amdgpu_bo (if it's amgpu BO) and then knows the internals so it can do a proper pci peer2peer mapping. Or at least there's been lots of patches floating around to make that happen.
I think other drivers migrate the bo out of VRAM.
Quoted 4 lines
On importing:
Importing into
TTM_PL_TTobject looks easy again, at least when the object is actually stored in RAM. What if not?
They are all supposed to be stored in RAM. Note that all current ttm importers totally break the abstraction, by taking the sg list, throwing the dma mapping away and assuming there's a struct page backing it. Would be good if we could stop spreading that abuse - the dma-buf interfaces have been modelled after the ttm bo interfaces, so shouldn't be too hard to wire this up correctly.
Quoted 3 lines
Importing into
TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?
Hm, since you ask about TTM concepts and not what this means in terms of dma-buf: As long as you upcast to the ttm_bo you can do whatever you want to really. But with plain dma-buf this doesn't work right now (least because ttm assumes it gets system RAM on import, in theory you could put the peer2peer dma mapping into the sg list and it should work).
-Daniel
Quoted 8 lines
thanks,
Gerd_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
Quoted 51 lines · Daniel Vetter
Quoted 32 lines · Gerd Hoffmann
Quoted 11 lines · Daniel Vetter
Quoted 4 lines · Gerd Hoffmann
The buffer object must be reserved before calling
ttm_bo_validatefor pinning/unpinning.Signed-off-by Gerd Hoffmann <[email protected]>Seems a bit a bisect fumble in your series here: legacy kms code reserved the ttm bo before calling boch_bo_pin/unpin, your atomic code doesn't. I think pushing this into bochs_bo_pin/unpin makes sense for atomic, but to avoid bisect fail I think you need to have these temporarily in your cleanup/prepare_plane functions too.
I think I've sorted that. Have some other changes too, will probably send v3 tomorrow.
Quoted 5 lines
Looked through the entire series, this here is the only issue I think should be fixed before merging (making
atomic_enableoptional can be done as a follow-up if you feel like it). With that addressed on the series:Acked-by Daniel Vetter <[email protected]>Thanks.
While being at it: I'm also looking at dma-buf export and import support for the qemu drivers.
Right now both qxl and virtio have
gem_prime_get_sg_tableandgem_prime_import_sg_tablehandlers which throw aWARN_ONCE()and return an error.Quoted 6 lines
If I understand things correctly it is valid to set all import/export callbacks (
prime_handle_to_fd,prime_fd_to_handle,gem_prime_get_sg_table,gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertiseDRIVER_PRIMEto indicate the other prime callbacks are supported (so generic fbdev emulation can usegem_prime_vmapetc). Is that correct?I'm not sure how much that's a good idea ... Never thought about it tbh. All the fbdev/dma-buf stuff has plenty of hacks and inconsistencies still, so I guess we can't make it much worse really.
Quoted 6 lines
On exporting:
TTM_PL_TTshould be easy, just pin the buffer, grab the pages list and feed that intodrm_prime_pages_to_sg. Didn't try yet though. Is that approach correct?
Quoted 7 lines
Quoted 2 lines
Is it possible to export
TTM_PL_VRAMobjects (with backing storage being a pci memory bar)? If so, how?Not really in general. amdgpu upcasts to
amdgpu_bo(if it's amgpu BO) and then knows the internals so it can do a proper pci peer2peer mapping. Or at least there's been lots of patches floating around to make that happen.
Here's Christian's WIP stuff for adding device memory support to dma-buf:
https://cgit.freedesktop.org/~deathsimple/linux/log/?h=p2p
Alex
Quoted 46 lines
I think other drivers migrate the bo out of VRAM.
Quoted 4 lines
On importing:
Importing into
TTM_PL_TTobject looks easy again, at least when the object is actually stored in RAM. What if not?They are all supposed to be stored in RAM. Note that all current ttm importers totally break the abstraction, by taking the sg list, throwing the dma mapping away and assuming there's a struct page backing it. Would be good if we could stop spreading that abuse - the dma-buf interfaces have been modelled after the ttm bo interfaces, so shouldn't be too hard to wire this up correctly.
Quoted 3 lines
Importing into
TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?Hm, since you ask about TTM concepts and not what this means in terms of dma-buf: As long as you upcast to the
ttm_boyou can do whatever you want to really. But with plain dma-buf this doesn't work right now (least because ttm assumes it gets system RAM on import, in theory you could put the peer2peer dma mapping into the sg list and it should work).
-DanielQuoted 8 lines
thanks,
Gerd_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
In reply to Daniel VetterQuoted 51 lines · Daniel Vetter
Quoted 32 lines · Gerd Hoffmann
Quoted 11 lines · Daniel Vetter
Quoted 4 lines · Gerd Hoffmann
The buffer object must be reserved before calling
ttm_bo_validatefor pinning/unpinning.Signed-off-by Gerd Hoffmann <[email protected]>Seems a bit a bisect fumble in your series here: legacy kms code reserved the ttm bo before calling boch_bo_pin/unpin, your atomic code doesn't. I think pushing this into bochs_bo_pin/unpin makes sense for atomic, but to avoid bisect fail I think you need to have these temporarily in your cleanup/prepare_plane functions too.
I think I've sorted that. Have some other changes too, will probably send v3 tomorrow.
Quoted 5 lines
Looked through the entire series, this here is the only issue I think should be fixed before merging (making
atomic_enableoptional can be done as a follow-up if you feel like it). With that addressed on the series:Acked-by Daniel Vetter <[email protected]>Thanks.
While being at it: I'm also looking at dma-buf export and import support for the qemu drivers.
Right now both qxl and virtio have
gem_prime_get_sg_tableandgem_prime_import_sg_tablehandlers which throw aWARN_ONCE()and return an error.Quoted 6 lines
If I understand things correctly it is valid to set all import/export callbacks (
prime_handle_to_fd,prime_fd_to_handle,gem_prime_get_sg_table,gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertiseDRIVER_PRIMEto indicate the other prime callbacks are supported (so generic fbdev emulation can usegem_prime_vmapetc). Is that correct?I'm not sure how much that's a good idea ... Never thought about it tbh. All the fbdev/dma-buf stuff has plenty of hacks and inconsistencies still, so I guess we can't make it much worse really.
Quoted 6 lines
On exporting:
TTM_PL_TTshould be easy, just pin the buffer, grab the pages list and feed that intodrm_prime_pages_to_sg. Didn't try yet though. Is that approach correct?
Quoted 7 lines
Quoted 2 lines
Is it possible to export
TTM_PL_VRAMobjects (with backing storage being a pci memory bar)? If so, how?Not really in general. amdgpu upcasts to
amdgpu_bo(if it's amgpu BO) and then knows the internals so it can do a proper pci peer2peer mapping. Or at least there's been lots of patches floating around to make that happen.
Here's Christian's WIP stuff for adding device memory support to dma-buf:
https://cgit.freedesktop.org/~deathsimple/linux/log/?h=p2p
Alex
Quoted 38 lines
I think other drivers migrate the bo out of VRAM.
Quoted 4 lines
On importing:
Importing into
TTM_PL_TTobject looks easy again, at least when the object is actually stored in RAM. What if not?They are all supposed to be stored in RAM. Note that all current ttm importers totally break the abstraction, by taking the sg list, throwing the dma mapping away and assuming there's a struct page backing it. Would be good if we could stop spreading that abuse - the dma-buf interfaces have been modelled after the ttm bo interfaces, so shouldn't be too hard to wire this up correctly.
Quoted 3 lines
Importing into
TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?Hm, since you ask about TTM concepts and not what this means in terms of dma-buf: As long as you upcast to the
ttm_boyou can do whatever you want to really. But with plain dma-buf this doesn't work right now (least because ttm assumes it gets system RAM on import, in theory you could put the peer2peer dma mapping into the sg list and it should work).
-DanielQuoted 8 lines
thanks,
Gerd_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
In reply to Daniel VetterHi,
Quoted 10 lines
Quoted 6 lines
If I understand things correctly it is valid to set all import/export callbacks (
prime_handle_to_fd,prime_fd_to_handle,gem_prime_get_sg_table,gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertiseDRIVER_PRIMEto indicate the other prime callbacks are supported (so generic fbdev emulation can usegem_prime_vmapetc). Is that correct?I'm not sure how much that's a good idea ... Never thought about it tbh. All the fbdev/dma-buf stuff has plenty of hacks and inconsistencies still, so I guess we can't make it much worse really.
Setting prime_handle_to_fd + prime_fd_to_handle to NULL has the effect that drm stops advertising DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.
Which looks better to me than telling userspace we support it then throw errors unconditionally when userspace tries to use that.
Quoted 7 lines
Quoted 2 lines
Is it possible to export
TTM_PL_VRAMobjects (with backing storage being a pci memory bar)? If so, how?Not really in general. amdgpu upcasts to
amdgpu_bo(if it's amgpu BO) and then knows the internals so it can do a proper pci peer2peer mapping. Or at least there's been lots of patches floating around to make that happen.
That is limited to bo sharing between two amdgpu devices, correct?
Quoted 1 line
I think other drivers migrate the bo out of VRAM.
Well, that doesn't look too useful. bochs and qxl virtual hardware can't access buffers outside VRAM. So, while I could migrate the buffers to RAM (via memcpy) when exporting they would at the same time become unusable for the GPU ...
Quoted 11 lines
Quoted 4 lines
On importing:
Importing into
TTM_PL_TTobject looks easy again, at least when the object is actually stored in RAM. What if not?They are all supposed to be stored in RAM. Note that all current ttm importers totally break the abstraction, by taking the sg list, throwing the dma mapping away and assuming there's a struct page backing it. Would be good if we could stop spreading that abuse - the dma-buf interfaces have been modelled after the ttm bo interfaces, so shouldn't be too hard to wire this up correctly.
Ok. With virtio-gpu (where objects are backed by RAM pages anyway) wiring this up should be easy.
But given there is no correct sample code I can look at it would be cool if you could give some more hints how this is supposed to work. The gem_prime_import_sg_table() callback gets a sg list passed in after all, so I probably would have tried to take the sg list too ...
Quoted 6 lines
Quoted 3 lines
Importing into
TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?Hm, since you ask about TTM concepts and not what this means in terms of dma-buf:
Ok, more details on the quesion:
dma-buf: whatever the driver gets passed into thegem_prime_import_sg_table() callback.
import into TTM_PL_VRAM: qemu driver which supports VRAM storage only (bochs, qxl), so the buffer has to be stored there if we want do something with it (like scanning out to a crtc).
Quoted 2 lines
As long as you upcast to the
ttm_boyou can do whatever you want to really.
Well, if the dma-buf comes from another device (say export vgem bo, then try import into bochs/qxl/virtio) I can't upcast.
When the dma-buf comes from the same device drm_gem_prime_import_dev() will notice and take a shortcut (skip import, just increase refcount instead), so I don't have to worry about that case in the gem_prime_import_sg_table() callback.
Quoted 4 lines
But with plain dma-buf this doesn't work right now
(least because ttm assumes it gets system RAM on import, in theory you could put the peer2peer dma mapping into the sg list and it should work).
Well, qemu display devices don't have peer2peer dma support. So I guess the answer is "doesn't work".
cheers,
Gerd
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
In reply to Daniel VetterHi,
Quoted 10 lines
Quoted 6 lines
If I understand things correctly it is valid to set all import/export callbacks (
prime_handle_to_fd,prime_fd_to_handle,gem_prime_get_sg_table,gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertiseDRIVER_PRIMEto indicate the other prime callbacks are supported (so generic fbdev emulation can usegem_prime_vmapetc). Is that correct?I'm not sure how much that's a good idea ... Never thought about it tbh. All the fbdev/dma-buf stuff has plenty of hacks and inconsistencies still, so I guess we can't make it much worse really.
Setting prime_handle_to_fd + prime_fd_to_handle to NULL has the effect that drm stops advertising DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.
Which looks better to me than telling userspace we support it then throw errors unconditionally when userspace tries to use that.
Quoted 7 lines
Quoted 2 lines
Is it possible to export
TTM_PL_VRAMobjects (with backing storage being a pci memory bar)? If so, how?Not really in general. amdgpu upcasts to
amdgpu_bo(if it's amgpu BO) and then knows the internals so it can do a proper pci peer2peer mapping. Or at least there's been lots of patches floating around to make that happen.
That is limited to bo sharing between two amdgpu devices, correct?
Quoted 1 line
I think other drivers migrate the bo out of VRAM.
Well, that doesn't look too useful. bochs and qxl virtual hardware can't access buffers outside VRAM. So, while I could migrate the buffers to RAM (via memcpy) when exporting they would at the same time become unusable for the GPU ...
Quoted 11 lines
Quoted 4 lines
On importing:
Importing into
TTM_PL_TTobject looks easy again, at least when the object is actually stored in RAM. What if not?They are all supposed to be stored in RAM. Note that all current ttm importers totally break the abstraction, by taking the sg list, throwing the dma mapping away and assuming there's a struct page backing it. Would be good if we could stop spreading that abuse - the dma-buf interfaces have been modelled after the ttm bo interfaces, so shouldn't be too hard to wire this up correctly.
Ok. With virtio-gpu (where objects are backed by RAM pages anyway) wiring this up should be easy.
But given there is no correct sample code I can look at it would be cool if you could give some more hints how this is supposed to work. The gem_prime_import_sg_table() callback gets a sg list passed in after all, so I probably would have tried to take the sg list too ...
Quoted 6 lines
Quoted 3 lines
Importing into
TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?Hm, since you ask about TTM concepts and not what this means in terms of dma-buf:
Ok, more details on the quesion:
dma-buf: whatever the driver gets passed into thegem_prime_import_sg_table() callback.
import into TTM_PL_VRAM: qemu driver which supports VRAM storage only (bochs, qxl), so the buffer has to be stored there if we want do something with it (like scanning out to a crtc).
Quoted 2 lines
As long as you upcast to the
ttm_boyou can do whatever you want to really.
Well, if the dma-buf comes from another device (say export vgem bo, then try import into bochs/qxl/virtio) I can't upcast.
When the dma-buf comes from the same device drm_gem_prime_import_dev() will notice and take a shortcut (skip import, just increase refcount instead), so I don't have to worry about that case in the gem_prime_import_sg_table() callback.
Quoted 4 lines
But with plain dma-buf this doesn't work right now
(least because ttm assumes it gets system RAM on import, in theory you could put the peer2peer dma mapping into the sg list and it should work).
Well, qemu display devices don't have peer2peer dma support. So I guess the answer is "doesn't work".
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
Quoted 49 lines · Gerd Hoffmann
Hi,
Quoted 10 lines
Quoted 6 lines
If I understand things correctly it is valid to set all import/export callbacks (
prime_handle_to_fd,prime_fd_to_handle,gem_prime_get_sg_table,gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertiseDRIVER_PRIMEto indicate the other prime callbacks are supported (so generic fbdev emulation can usegem_prime_vmapetc). Is that correct?I'm not sure how much that's a good idea ... Never thought about it tbh. All the fbdev/dma-buf stuff has plenty of hacks and inconsistencies still, so I guess we can't make it much worse really.
Setting
prime_handle_to_fd+prime_fd_to_handleto NULL has the effect that drm stops advertising DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.Which looks better to me than telling userspace we support it then throw errors unconditionally when userspace tries to use that.
Quoted 7 lines
Quoted 2 lines
Is it possible to export
TTM_PL_VRAMobjects (with backing storage being a pci memory bar)? If so, how?Not really in general. amdgpu upcasts to
amdgpu_bo(if it's amgpu BO) and then knows the internals so it can do a proper pci peer2peer mapping. Or at least there's been lots of patches floating around to make that happen.That is limited to bo sharing between two amdgpu devices, correct?
Quoted 1 line
I think other drivers migrate the bo out of VRAM.
Well, that doesn't look too useful. bochs and qxl virtual hardware can't access buffers outside VRAM. So, while I could migrate the buffers to RAM (via memcpy) when exporting they would at the same time become unusable for the GPU ...
Quoted 11 lines
Quoted 4 lines
On importing:
Importing into
TTM_PL_TTobject looks easy again, at least when the object is actually stored in RAM. What if not?They are all supposed to be stored in RAM. Note that all current ttm importers totally break the abstraction, by taking the sg list, throwing the dma mapping away and assuming there's a struct page backing it. Would be good if we could stop spreading that abuse - the dma-buf interfaces have been modelled after the ttm bo interfaces, so shouldn't be too hard to wire this up correctly.
Quoted 7 lines
Ok. With virtio-gpu (where objects are backed by RAM pages anyway) wiring this up should be easy.
But given there is no correct sample code I can look at it would be cool if you could give some more hints how this is supposed to work. The
gem_prime_import_sg_table()callback gets a sg list passed in after all, so I probably would have tried to take the sg list too ...
I'm not a fan of that helper either, that's really the broken part imo. i915 doesn't use it. It's a midlayer so that the nvidia blob can avoid directly touching the EXPORT_SYMBOL_GPL dma-buf symbols, afaiui there's really no other solid reason for it. What the new gem cma helpers does is imo much better (it still uses the import_sg_table midlayer, but oh well).
For ttm you'd need to make sure that all the various ttm cpu side access functions also all go through the relevant dma-buf interfaces, and not through the struct page list fished out of the sgt. That was at least the idea, long ago.
Quoted 16 lines
Quoted 6 lines
Quoted 3 lines
Importing into
TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?Hm, since you ask about TTM concepts and not what this means in terms of dma-buf:
Ok, more details on the quesion:
dma-buf: whatever the driver gets passed into the
gem_prime_import_sg_table()callback.import into
TTM_PL_VRAM: qemu driver which supports VRAM storage only (bochs, qxl), so the buffer has to be stored there if we want do something with it (like scanning out to a crtc).
Quoted 5 lines
Quoted 2 lines
As long as you upcast to the
ttm_boyou can do whatever you want to really.Well, if the dma-buf comes from another device (say export vgem bo, then try import into bochs/qxl/virtio) I can't upcast.
In that case you'll in practice only get system RAM, and you're not allowed to move it (dma-buf is meant to be zero-copy after all). If your hw can't scan these out directly, then userspace needs to arrange for a buffer copy into a native buffer somehow (that's how Xorg prime works at least I think). No idea whether your virtual gpus can make use of that directly. You might also get some pci peer2peer range in the future, but it's strictly opt-in (because there's too many dma-buf importers that just blindly assume there's a struct page behind the sgt).
Quoted 4 lines
When the dma-buf comes from the same device
drm_gem_prime_import_dev()will notice and take a shortcut (skip import, just increase refcount instead), so I don't have to worry about that case in thegem_prime_import_sg_table()callback.
You can also upcast if it's from the same driver, not just same device. -Daniel
Quoted 11 lines
Quoted 4 lines
But with plain dma-buf this doesn't work right now
(least because ttm assumes it gets system RAM on import, in theory you could put the peer2peer dma mapping into the sg list and it should work).Well, qemu display devices don't have peer2peer dma support. So I guess the answer is "doesn't work".
cheers,
Gerd
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
In reply to Gerd HoffmannQuoted 49 lines · Gerd Hoffmann
Hi,
Quoted 10 lines
Quoted 6 lines
If I understand things correctly it is valid to set all import/export callbacks (
prime_handle_to_fd,prime_fd_to_handle,gem_prime_get_sg_table,gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertiseDRIVER_PRIMEto indicate the other prime callbacks are supported (so generic fbdev emulation can usegem_prime_vmapetc). Is that correct?I'm not sure how much that's a good idea ... Never thought about it tbh. All the fbdev/dma-buf stuff has plenty of hacks and inconsistencies still, so I guess we can't make it much worse really.
Setting
prime_handle_to_fd+prime_fd_to_handleto NULL has the effect that drm stops advertising DRM_PRIME_CAP_{IMPORT,EXPORT} to userspace.Which looks better to me than telling userspace we support it then throw errors unconditionally when userspace tries to use that.
Quoted 7 lines
Quoted 2 lines
Is it possible to export
TTM_PL_VRAMobjects (with backing storage being a pci memory bar)? If so, how?Not really in general. amdgpu upcasts to
amdgpu_bo(if it's amgpu BO) and then knows the internals so it can do a proper pci peer2peer mapping. Or at least there's been lots of patches floating around to make that happen.That is limited to bo sharing between two amdgpu devices, correct?
Quoted 1 line
I think other drivers migrate the bo out of VRAM.
Well, that doesn't look too useful. bochs and qxl virtual hardware can't access buffers outside VRAM. So, while I could migrate the buffers to RAM (via memcpy) when exporting they would at the same time become unusable for the GPU ...
Quoted 11 lines
Quoted 4 lines
On importing:
Importing into
TTM_PL_TTobject looks easy again, at least when the object is actually stored in RAM. What if not?They are all supposed to be stored in RAM. Note that all current ttm importers totally break the abstraction, by taking the sg list, throwing the dma mapping away and assuming there's a struct page backing it. Would be good if we could stop spreading that abuse - the dma-buf interfaces have been modelled after the ttm bo interfaces, so shouldn't be too hard to wire this up correctly.
Quoted 7 lines
Ok. With virtio-gpu (where objects are backed by RAM pages anyway) wiring this up should be easy.
But given there is no correct sample code I can look at it would be cool if you could give some more hints how this is supposed to work. The
gem_prime_import_sg_table()callback gets a sg list passed in after all, so I probably would have tried to take the sg list too ...
I'm not a fan of that helper either, that's really the broken part imo. i915 doesn't use it. It's a midlayer so that the nvidia blob can avoid directly touching the EXPORT_SYMBOL_GPL dma-buf symbols, afaiui there's really no other solid reason for it. What the new gem cma helpers does is imo much better (it still uses the import_sg_table midlayer, but oh well).
For ttm you'd need to make sure that all the various ttm cpu side access functions also all go through the relevant dma-buf interfaces, and not through the struct page list fished out of the sgt. That was at least the idea, long ago.
Quoted 16 lines
Quoted 6 lines
Quoted 3 lines
Importing into
TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?Hm, since you ask about TTM concepts and not what this means in terms of dma-buf:
Ok, more details on the quesion:
dma-buf: whatever the driver gets passed into the
gem_prime_import_sg_table()callback.import into
TTM_PL_VRAM: qemu driver which supports VRAM storage only (bochs, qxl), so the buffer has to be stored there if we want do something with it (like scanning out to a crtc).
Quoted 5 lines
Quoted 2 lines
As long as you upcast to the
ttm_boyou can do whatever you want to really.Well, if the dma-buf comes from another device (say export vgem bo, then try import into bochs/qxl/virtio) I can't upcast.
In that case you'll in practice only get system RAM, and you're not allowed to move it (dma-buf is meant to be zero-copy after all). If your hw can't scan these out directly, then userspace needs to arrange for a buffer copy into a native buffer somehow (that's how Xorg prime works at least I think). No idea whether your virtual gpus can make use of that directly. You might also get some pci peer2peer range in the future, but it's strictly opt-in (because there's too many dma-buf importers that just blindly assume there's a struct page behind the sgt).
Quoted 4 lines
When the dma-buf comes from the same device
drm_gem_prime_import_dev()will notice and take a shortcut (skip import, just increase refcount instead), so I don't have to worry about that case in thegem_prime_import_sg_table()callback.
You can also upcast if it's from the same driver, not just same device. -Daniel
Quoted 11 lines
Quoted 4 lines
But with plain dma-buf this doesn't work right now
(least because ttm assumes it gets system RAM on import, in theory you could put the peer2peer dma mapping into the sg list and it should work).Well, qemu display devices don't have peer2peer dma support. So I guess the answer is "doesn't work".
cheers,
Gerd
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
In reply to Gerd HoffmannQuoted 32 lines · Gerd Hoffmann
Quoted 11 lines · Daniel Vetter
Quoted 4 lines · Gerd Hoffmann
The buffer object must be reserved before calling
ttm_bo_validatefor pinning/unpinning.Signed-off-by Gerd Hoffmann <[email protected]>Seems a bit a bisect fumble in your series here: legacy kms code reserved the ttm bo before calling boch_bo_pin/unpin, your atomic code doesn't. I think pushing this into bochs_bo_pin/unpin makes sense for atomic, but to avoid bisect fail I think you need to have these temporarily in your cleanup/prepare_plane functions too.
I think I've sorted that. Have some other changes too, will probably send v3 tomorrow.
Quoted 5 lines
Looked through the entire series, this here is the only issue I think should be fixed before merging (making
atomic_enableoptional can be done as a follow-up if you feel like it). With that addressed on the series:Acked-by Daniel Vetter <[email protected]>Thanks.
While being at it: I'm also looking at dma-buf export and import support for the qemu drivers.
Right now both qxl and virtio have
gem_prime_get_sg_tableandgem_prime_import_sg_tablehandlers which throw aWARN_ONCE()and return an error.
Quoted 6 lines
If I understand things correctly it is valid to set all import/export callbacks (
prime_handle_to_fd,prime_fd_to_handle,gem_prime_get_sg_table,gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertiseDRIVER_PRIMEto indicate the other prime callbacks are supported (so generic fbdev emulation can usegem_prime_vmapetc). Is that correct?
I'm not sure how much that's a good idea ... Never thought about it tbh. All the fbdev/dma-buf stuff has plenty of hacks and inconsistencies still, so I guess we can't make it much worse really.
Quoted 8 lines
On exporting:
TTM_PL_TTshould be easy, just pin the buffer, grab the pages list and feed that intodrm_prime_pages_to_sg. Didn't try yet though. Is that approach correct?Is it possible to export
TTM_PL_VRAMobjects (with backing storage being a pci memory bar)? If so, how?
Not really in general. amdgpu upcasts to amdgpu_bo (if it's amgpu BO) and then knows the internals so it can do a proper pci peer2peer mapping. Or at least there's been lots of patches floating around to make that happen.
I think other drivers migrate the bo out of VRAM.
Quoted 4 lines
On importing:
Importing into
TTM_PL_TTobject looks easy again, at least when the object is actually stored in RAM. What if not?
They are all supposed to be stored in RAM. Note that all current ttm importers totally break the abstraction, by taking the sg list, throwing the dma mapping away and assuming there's a struct page backing it. Would be good if we could stop spreading that abuse - the dma-buf interfaces have been modelled after the ttm bo interfaces, so shouldn't be too hard to wire this up correctly.
Quoted 3 lines
Importing into
TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?
Hm, since you ask about TTM concepts and not what this means in terms of dma-buf: As long as you upcast to the ttm_bo you can do whatever you want to really. But with plain dma-buf this doesn't work right now (least because ttm assumes it gets system RAM on import, in theory you could put the peer2peer dma mapping into the sg list and it should work).
-Daniel
Quoted 8 lines
thanks,
Gerd_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v2 15/15] drm/bochs: reserve bo for pin/unpin
In reply to Daniel VetterQuoted 11 lines · Daniel Vetter
Quoted 4 lines · Gerd Hoffmann
The buffer object must be reserved before calling
ttm_bo_validatefor pinning/unpinning.Signed-off-by Gerd Hoffmann <[email protected]>Seems a bit a bisect fumble in your series here: legacy kms code reserved the ttm bo before calling boch_bo_pin/unpin, your atomic code doesn't. I think pushing this into bochs_bo_pin/unpin makes sense for atomic, but to avoid bisect fail I think you need to have these temporarily in your cleanup/prepare_plane functions too.
I think I've sorted that. Have some other changes too, will probably send v3 tomorrow.
Quoted 5 lines
Looked through the entire series, this here is the only issue I think should be fixed before merging (making
atomic_enableoptional can be done as a follow-up if you feel like it). With that addressed on the series:Acked-by Daniel Vetter <[email protected]>
Thanks.
While being at it: I'm also looking at dma-buf export and import support for the qemu drivers.
Right now both qxl and virtio have gem_prime_get_sg_table and gem_prime_import_sg_table handlers which throw a WARN_ONCE() and return an error.
If I understand things correctly it is valid to set all import/export callbacks (prime_handle_to_fd, prime_fd_to_handle, gem_prime_get_sg_table, gem_prime_import_sg_table) to NULL when not supporting dma-buf import/export and still advertise DRIVER_PRIME to indicate the other prime callbacks are supported (so generic fbdev emulation can use gem_prime_vmap etc). Is that correct?
On exporting:
TTM_PL_TT should be easy, just pin the buffer, grab the pages list and feed that into drm_prime_pages_to_sg. Didn't try yet though. Is that approach correct?
Is it possible to export TTM_PL_VRAM objects (with backing storage being a pci memory bar)? If so, how?
On importing:
Importing into TTM_PL_TT object looks easy again, at least when the object is actually stored in RAM. What if not?
Importing into TTM_PL_VRAM: Impossible I think, without copying over the data. Should that be done? If so, how? Or is it better to just not support import then?
thanks,
Gerd