Skip to contentSkip to conversation

Tell userspace if scanning out of an imported PRIME buffer is safe.

PATCH New [email protected] 10 participants 27 messages Apr 4, 2017 – Apr 17, 2017

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

PATCH 1/1 Tell userspace if scanning out of an imported PRIME buffer is safe.

My past set of patches fix nouveau, radeon, and amdgpu breaking dma-buf sharing when trying to scanout of an imported PRIME buffer. Driver-agnostic userspace can't safely try to scanout of such a buffer, though, because the failure-mode is that subsequent rendering isn't shown on screen.

This adds a DRM_CAP_PRIME_SCANOUT for userspace to detect when it's safe and sensible to try and scanout of an imported PRIME buffer.

I know that i915 can do this, and nouveau/radeon/amdgpu can't (at the moment). I do not know which other drivers might be able to support the DRIVER_PRIME_SCANOUT feature. Suggestions welcome!

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

#1 lore raw

PATCH 1/2 drm: Add DRM_CAP_PRIME_SCANOUT.

From: Christopher James Halse Rogers <[email protected]>

Until recently, on (at least) nouveau, radeon, and amdgpu attempting to scanout of an imported dma-buf would silently result in the dma-buf sharing being broken.

While the hardware is capable of scanning out of imported dma-bufs (at least in some circumstances), these drivers do not currently implement it, so attempts to scan out of such buffers will never succeed.

Add a userspace-visible drm capability and associated driver_feature so that userspace can discover when scanning out of an imported dma-buf can work.

---
 drivers/gpu/drm/drm_ioctl.c |  3 +++
 include/drm/drm_drv.h       |  1 +
 include/uapi/drm/drm.h      | 21 +++++++++++++++++++++
 3 files changed, 25 insertions(+)
drivers/gpu/drm/drm_ioctl.c +3 -0
index a7c61c23685a..79ccf638668e 100644
@@ -285,6 +285,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_ADDFB2_MODIFIERS:
 		req->value = dev->mode_config.allow_fb_modifiers;
 		break;
+	case DRM_CAP_PRIME_SCANOUT:
+		req->value = drm_core_check_feature(dev, DRIVER_PRIME_SCANOUT);
+		break;
 	default:
 		return -EINVAL;
 	}
include/drm/drm_drv.h +1 -0
index 5699f42195fe..32cc0d956d7e 100644
@@ -53,6 +53,7 @@ struct drm_mode_create_dumb;
 #define DRIVER_RENDER			0x8000
 #define DRIVER_ATOMIC			0x10000
 #define DRIVER_KMS_LEGACY_CONTEXT	0x20000
+#define DRIVER_PRIME_SCANOUT		0x40000
 
 /**
  * struct drm_driver - DRM driver structure
include/uapi/drm/drm.h +21 -0
index b2c52843bc70..c57213cdb702 100644
@@ -647,6 +647,27 @@ struct drm_gem_open {
 #define DRM_CAP_CURSOR_HEIGHT		0x9
 #define DRM_CAP_ADDFB2_MODIFIERS	0x10
 #define DRM_CAP_PAGE_FLIP_TARGET	0x11
+/**
+ * DRM_CAP_PRIME_SCANOUT
+ *
+ * The PRIME_SCANOUT capability returns whether the driver might be capable
+ * of scanning out of an imported PRIME buffer.
+ *
+ * This does not guarantee that any imported buffer can be scanned out, as
+ * there may be specific requirements that a given buffer might not satisfy.
+ *
+ * If this capability is false then imported PRIME buffers will definitely
+ * never be suitable for scanout.
+ *
+ * Note: Prior to the introduction of this capability, bugs in drivers would
+ * allow userspace to attempt to scan out of imported PRIME buffers. This would
+ * work once, but move the buffer into an inconsistent state where rendering from
+ * the exporting GPU would no longer be seen by the importing GPU.
+ *
+ * It is unsafe for driver-agnostic code to attempt to scan out of an imported
+ * PRIME buffer in the absense of this capability.
+ */
+#define DRM_CAP_PRIME_SCANOUT		0x12
 
 /** DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {
Signature · 6 lines
2.11.0

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

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 5 lines · On Tue, Apr 04, 2017 at 06:13:20PM +1000, [email protected] wrote:

From: Christopher James Halse Rogers <[email protected]>

Until recently, on (at least) nouveau, radeon, and amdgpu attempting to scanout of an imported dma-buf would silently result in the dma-buf sharing being broken.

Quoted 7 lines

While the hardware is capable of scanning out of imported dma-bufs (at least in some circumstances), these drivers do not currently implement it, so attempts to scan out of such buffers will never succeed.

Add a userspace-visible drm capability and associated driver_feature so that userspace can discover when scanning out of an imported dma-buf can work.

This seems like an awful specific special case. Why can't you do the entire dance upfront, i.e. import buffer, addfb2? None of that has any visible effect, and it will also allow you to check runtime constraints which can't be covered with this here.
-Daniel

Quoted 71 lines
---
 drivers/gpu/drm/drm_ioctl.c |  3 +++
 include/drm/drm_drv.h       |  1 +
 include/uapi/drm/drm.h      | 21 +++++++++++++++++++++
 3 files changed, 25 insertions(+)
drivers/gpu/drm/drm_ioctl.c +3 -0
index a7c61c23685a..79ccf638668e 100644
@@ -285,6 +285,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_ADDFB2_MODIFIERS:
 		req->value = dev->mode_config.allow_fb_modifiers;
 		break;
+	case DRM_CAP_PRIME_SCANOUT:
+		req->value = drm_core_check_feature(dev, DRIVER_PRIME_SCANOUT);
+		break;
 	default:
 		return -EINVAL;
 	}
include/drm/drm_drv.h +1 -0
index 5699f42195fe..32cc0d956d7e 100644
@@ -53,6 +53,7 @@ struct drm_mode_create_dumb;
 #define DRIVER_RENDER			0x8000
 #define DRIVER_ATOMIC			0x10000
 #define DRIVER_KMS_LEGACY_CONTEXT	0x20000
+#define DRIVER_PRIME_SCANOUT		0x40000
 
 /**
  * struct drm_driver - DRM driver structure
include/uapi/drm/drm.h +21 -0
index b2c52843bc70..c57213cdb702 100644
@@ -647,6 +647,27 @@ struct drm_gem_open {
 #define DRM_CAP_CURSOR_HEIGHT		0x9
 #define DRM_CAP_ADDFB2_MODIFIERS	0x10
 #define DRM_CAP_PAGE_FLIP_TARGET	0x11
+/**
+ * DRM_CAP_PRIME_SCANOUT
+ *
+ * The PRIME_SCANOUT capability returns whether the driver might be capable
+ * of scanning out of an imported PRIME buffer.
+ *
+ * This does not guarantee that any imported buffer can be scanned out, as
+ * there may be specific requirements that a given buffer might not satisfy.
+ *
+ * If this capability is false then imported PRIME buffers will definitely
+ * never be suitable for scanout.
+ *
+ * Note: Prior to the introduction of this capability, bugs in drivers would
+ * allow userspace to attempt to scan out of imported PRIME buffers. This would
+ * work once, but move the buffer into an inconsistent state where rendering from
+ * the exporting GPU would no longer be seen by the importing GPU.
+ *
+ * It is unsafe for driver-agnostic code to attempt to scan out of an imported
+ * PRIME buffer in the absense of this capability.
+ */
+#define DRM_CAP_PRIME_SCANOUT		0x12
 
 /** DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {
Signature · 6 lines
2.11.0

_______________________________________________
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
#3 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Hi,

Quoted 10 lines · Daniel Vetter
Quoted 9 lines · On Tue, Apr 04, 2017 at 06:13:20PM +1000, [email protected] wrote:

Until recently, on (at least) nouveau, radeon, and amdgpu attempting to scanout of an imported dma-buf would silently result in the dma-buf sharing being broken.

While the hardware is capable of scanning out of imported dma-bufs (at least in some circumstances), these drivers do not currently implement it, so attempts to scan out of such buffers will never succeed.

Add a userspace-visible drm capability and associated driver_feature so that userspace can discover when scanning out of an imported dma-buf can work.

Quoted 6 lines
Quoted 1 line

This seems like an awful specific special case. Why can't you do the entire dance upfront, i.e. import buffer, addfb2? None of that has any visible effect, and it will also allow you to check runtime constraints which can't be covered with this here.

Oh, that already happens. Chris sent out a series which fixes bugs for PRIME import across a few drivers, mostly ones which need to pin scanout buffers to dedicated memory. So this cap is basically DRM_CAP_PRIME_SCANOUT_ISNT_BUGGY. FWIW, I'm fairly skeptical about adding caps which essentially declare the absence of bugs like this.

Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

In reply to Daniel Vetter
Quoted 17 lines · Daniel Vetter
Quoted 3 lines · On Tue, Apr 04, 2017 at 06:13:20PM +1000, [email protected] wrote:

From: Christopher James Halse Rogers <[email protected]>

Until recently, on (at least) nouveau, radeon, and amdgpu attempting

to scanout of an

Quoted 1 line

imported dma-buf would silently result in the dma-buf sharing being

broken.

Quoted 2 lines

While the hardware is capable of scanning out of imported dma-bufs

(at least in some circumstances),

Quoted 1 line

these drivers do not currently implement it, so attempts to scan out

of such buffers will never succeed.

Quoted 2 lines

Add a userspace-visible drm capability and associated driver_feature

so that userspace can discover

Quoted 2 lines

when scanning out of an imported dma-buf can work.

Quoted 8 lines
Quoted 1 line
Signed-off-by Christopher James Halse Rogers

<[email protected]>

This seems like an awful specific special case. Why can't you do the entire dance upfront, i.e. import buffer, addfb2? None of that has any visible effect, and it will also allow you to check runtime constraints which can't be covered with this here.
-Daniel

No, because addfb2 doesn't (or, rather, didn't) actually check any runtime constraints.

The problem only appeared when the buffer is actually *used* in a modeset - otherwise I could do a (reasonably) cheap import/addfb/render on exporter/read out on importer dance to detect it.

To be clear - this is trying to solve the problem “how can I tell if it's safe to addfb/pageflip rather than do a GL copy to a GPU-local buffer and flip from that?”.

If I could guarantee that I'd only ever run on 4.13-or-later kernels (I think that's when the previous patches will land?), then this would indeed be mostly unnecessary. It would save me a bunch of addfb calls that would predictably fail, but they're cheap.

Quoted 61 lines

Review

Quoted 8 lines
---
 drivers/gpu/drm/drm_ioctl.c |  3 +++
 include/drm/drm_drv.h       |  1 +
 include/uapi/drm/drm.h      | 21 +++++++++++++++++++++
 3 files changed, 25 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_ioctl.c

drivers/gpu/drm/drm_ioctl.c static int drm_getcap(struct drm_device *dev,

Quoted 4 lines

index a7c61c23685a..79ccf638668e 100644

drivers/gpu/drm/drm_ioctl.c +0 -0
@@ -285,6 +285,9 @@ static int drm_getcap(struct drm_device *dev,

void *data, struct drm_file *file_

Quoted 26 lines
drivers/gpu/drm/drm_ioctl.c +3 -0
 	case DRM_CAP_ADDFB2_MODIFIERS:
 		req->value = dev->mode_config.allow_fb_modifiers;
 		break;
+	case DRM_CAP_PRIME_SCANOUT:
+		req->value = drm_core_check_feature(dev, DRIVER_PRIME_SCANOUT);
+		break;
 	default:
 		return -EINVAL;
 	}
include/drm/drm_drv.h +1 -0
index 5699f42195fe..32cc0d956d7e 100644
@@ -53,6 +53,7 @@ struct drm_mode_create_dumb;
 #define DRIVER_RENDER			0x8000
 #define DRIVER_ATOMIC			0x10000
 #define DRIVER_KMS_LEGACY_CONTEXT	0x20000
+#define DRIVER_PRIME_SCANOUT		0x40000
 
 /**
  * struct drm_driver - DRM driver structure
include/uapi/drm/drm.h +0 -0
index b2c52843bc70..c57213cdb702 100644

include/uapi/drm/drm.h struct drm_gem_open { · line 653

Quoted 7 lines
include/uapi/drm/drm.h +4 -0
@@ -647,6 +647,27 @@ struct drm_gem_open {
 #define DRM_CAP_CURSOR_HEIGHT		0x9
 #define DRM_CAP_ADDFB2_MODIFIERS	0x10
 #define DRM_CAP_PAGE_FLIP_TARGET	0x11
+/**
+ * DRM_CAP_PRIME_SCANOUT
+ *
+ * The PRIME_SCANOUT capability returns whether the driver might be

capable

include/uapi/drm/drm.h struct drm_gem_open {

Quoted 3 lines
include/uapi/drm/drm.h +3 -0
+ * of scanning out of an imported PRIME buffer.
+ *
+ * This does not guarantee that any imported buffer can be scanned

out, as

include/uapi/drm/drm.h struct drm_gem_open { · line 657

Quoted 1 line
include/uapi/drm/drm.h +1 -0
+ * there may be specific requirements that a given buffer might not

satisfy.

include/uapi/drm/drm.h struct drm_gem_open { · line 659

Quoted 2 lines
include/uapi/drm/drm.h +2 -0
+ *
+ * If this capability is false then imported PRIME buffers will

definitely

include/uapi/drm/drm.h struct drm_gem_open {

Quoted 3 lines
include/uapi/drm/drm.h +3 -0
+ * never be suitable for scanout.
+ *
+ * Note: Prior to the introduction of this capability, bugs in

drivers would

Quoted 21 lines

include/uapi/drm/drm.h struct drm_gem_open { · line 663

Quoted 1 line
include/uapi/drm/drm.h +1 -0
+ * allow userspace to attempt to scan out of imported PRIME buffers.

This would

include/uapi/drm/drm.h struct drm_gem_open { · line 664

Quoted 1 line
include/uapi/drm/drm.h +1 -0
+ * work once, but move the buffer into an inconsistent state where

rendering from

include/uapi/drm/drm.h struct drm_gem_open {

Quoted 3 lines
include/uapi/drm/drm.h +3 -0
+ * the exporting GPU would no longer be seen by the importing GPU.
+ *
+ * It is unsafe for driver-agnostic code to attempt to scan out of

an imported

Quoted 13 lines
include/uapi/drm/drm.h +3 -0
+ * PRIME buffer in the absense of this capability.
+ */
+#define DRM_CAP_PRIME_SCANOUT		0x12
 
 /** DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {
Signature · 6 lines
2.11.0

_______________________________________________
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

#5 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Am Dienstag, den 04.04.2017, 20:27 +1000 schrieb Christopher James Halse Rogers:

Quoted 35 lines · Daniel Vetter
Quoted 17 lines · On Tue, Apr 04, 2017 at 06:13:20PM +1000, [email protected] wrote:
Quoted 3 lines

From: Christopher James Halse Rogers <[email protected]>

Until recently, on (at least) nouveau, radeon, and amdgpu attempting

to scanout of an

Quoted 1 line

imported dma-buf would silently result in the dma-buf sharing being

broken.

Quoted 2 lines

While the hardware is capable of scanning out of imported dma-bufs

(at least in some circumstances),

Quoted 1 line

these drivers do not currently implement it, so attempts to scan out

of such buffers will never succeed.

Quoted 2 lines

Add a userspace-visible drm capability and associated driver_feature

so that userspace can discover

Quoted 2 lines

when scanning out of an imported dma-buf can work.

Quoted 8 lines
Quoted 1 line
Signed-off-by Christopher James Halse Rogers

<[email protected]>

This seems like an awful specific special case. Why can't you do the entire dance upfront, i.e. import buffer, addfb2? None of that has any visible effect, and it will also allow you to check runtime constraints which can't be covered with this here.
-Daniel

No, because addfb2 doesn't (or, rather, didn't) actually check any runtime constraints.

The problem only appeared when the buffer is actually *used* in a modeset - otherwise I could do a (reasonably) cheap import/addfb/render on exporter/read out on importer dance to detect it.

Quoted 8 lines

To be clear - this is trying to solve the problem “how can I tell if it's safe to addfb/pageflip rather than do a GL copy to a GPU-local buffer and flip from that?”.

If I could guarantee that I'd only ever run on 4.13-or-later kernels (I think that's when the previous patches will land?), then this would indeed be mostly unnecessary. It would save me a bunch of addfb calls that would predictably fail, but they're cheap.

I don't think we ever had caps for "things are working now, as they are supposed to". i915 wasn't properly synchronizing on foreign fences for a long time, yet we didn't gain a cap for "cross device sync works now".

If your distro use-case relies on those things working it's probably best to just backport the relevant fixes.

Regards,
Lucas

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

#6 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 11 lines · Lucas Stach
Quoted 4 lines

If I could guarantee that I'd only ever run on 4.13-or-later kernels (I think that's when the previous patches will land?), then this would indeed be mostly unnecessary. It would save me a bunch of addfb calls that would predictably fail, but they're cheap.

I don't think we ever had caps for "things are working now, as they are supposed to". i915 wasn't properly synchronizing on foreign fences for a long time, yet we didn't gain a cap for "cross device sync works now".

If your distro use-case relies on those things working it's probably best to just backport the relevant fixes.

The even better solution for this is to push the backports through upstream -stable kernels. This stuff here is simple enough that we can do it. Same could have been done for the fairly minimal fencing fixes for i915 (at least some of them, the ones in the page-flip).

Otherwise we'll end up with tons IM_NOT_BUGGY and IM_SLIGHTLY_LESS_BUGGY and IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely inconsistent and they just all add to the confusion. They're just bugs, lets treat them like that.
-Daniel

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
#7 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 19 lines · Daniel Vetter
Quoted 11 lines · Lucas Stach
Quoted 4 lines

If I could guarantee that I'd only ever run on 4.13-or-later kernels (I think that's when the previous patches will land?), then this would indeed be mostly unnecessary. It would save me a bunch of addfb calls that would predictably fail, but they're cheap.

I don't think we ever had caps for "things are working now, as they are supposed to". i915 wasn't properly synchronizing on foreign fences for a long time, yet we didn't gain a cap for "cross device sync works now".

If your distro use-case relies on those things working it's probably best to just backport the relevant fixes.

The even better solution for this is to push the backports through upstream -stable kernels. This stuff here is simple enough that we can do it. Same could have been done for the fairly minimal fencing fixes for i915 (at least some of them, the ones in the page-flip).

Quoted 7 lines

Otherwise we'll end up with tons IM_NOT_BUGGY and IM_SLIGHTLY_LESS_BUGGY and IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely inconsistent and they just all add to the confusion. They're just bugs, lets treat them like that.

It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout of GTT, so the lack of this cap indicates that there's no point in trying to call addfb2.

But calling addfb2 and it failing is not expensive, so this is rather niche.

In practice I can just restrict attempting to scanout of imported buffers to i915, as that's the only driver that it'll work on. By the time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes should be old enough that I don't need to care about unfixed kernels.

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

#8 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 34 lines · Christopher James Halse Rogers
Quoted 19 lines · Daniel Vetter
Quoted 11 lines · Lucas Stach
Quoted 4 lines

If I could guarantee that I'd only ever run on 4.13-or-later kernels (I think that's when the previous patches will land?), then this would indeed be mostly unnecessary. It would save me a bunch of addfb calls that would predictably fail, but they're cheap.

I don't think we ever had caps for "things are working now, as they are supposed to". i915 wasn't properly synchronizing on foreign fences for a long time, yet we didn't gain a cap for "cross device sync works now".

If your distro use-case relies on those things working it's probably best to just backport the relevant fixes.

The even better solution for this is to push the backports through upstream -stable kernels. This stuff here is simple enough that we can do it. Same could have been done for the fairly minimal fencing fixes for i915 (at least some of them, the ones in the page-flip).

Quoted 7 lines

Otherwise we'll end up with tons IM_NOT_BUGGY and IM_SLIGHTLY_LESS_BUGGY and IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely inconsistent and they just all add to the confusion. They're just bugs, lets treat them like that.

It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout of GTT, so the lack of this cap indicates that there's no point in trying to call addfb2.

Quoted 6 lines

But calling addfb2 and it failing is not expensive, so this is rather niche.

In practice I can just restrict attempting to scanout of imported buffers to i915, as that's the only driver that it'll work on. By the time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes should be old enough that I don't need to care about unfixed kernels.

"I'll only run on i915" sounds like a rather risky assumption. You're sure no one will install ubuntu on e.g. rasperry with Eric's shiny new pl111 driver?

I really think that if you want to rely on this, backporting the fixes is perfectly fine.
-Daniel

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
#9 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 62 lines · Daniel Vetter
Quoted 54 lines · Christopher James Halse Rogers
Quoted 1 line · Daniel Vetter

On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach

<[email protected]>

Quoted 2 lines
Quoted 1 line · wrote:
Quoted 1 line

If I could guarantee that I'd only ever run on 4.13-or-later

kernels

Quoted 1 line
Quoted 1 line
Quoted 1 line

(I think that's when the previous patches will land?), then

this would

Quoted 1 line
Quoted 1 line
Quoted 1 line

indeed be mostly unnecessary. It would save me a bunch of

addfb calls

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

that would predictably fail, but they're cheap.

I don't think we ever had caps for "things are working now, as

they are

Quoted 1 line
Quoted 1 line

supposed to". i915 wasn't properly synchronizing on foreign

fences for a

Quoted 1 line
Quoted 1 line

long time, yet we didn't gain a cap for "cross device sync

works now".

Quoted 2 lines
Quoted 2 lines

If your distro use-case relies on those things working it's

probably

Quoted 4 lines
Quoted 1 line

best to just backport the relevant fixes.

The even better solution for this is to push the backports through upstream -stable kernels. This stuff here is simple enough that

we can

Quoted 1 line

do it. Same could have been done for the fairly minimal fencing

fixes

Quoted 4 lines

for i915 (at least some of them, the ones in the page-flip).

Otherwise we'll end up with tons IM_NOT_BUGGY and
IM_SLIGHTLY_LESS_BUGGY and

IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT

Quoted 2 lines

flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely

inconsistent and

Quoted 1 line

they just all add to the confusion. They're just bugs, lets treat

them

Quoted 2 lines

like that.

It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the
relevant
hardware allegedly supports it, nouveau/radeon/amdgpu don't do
scanout of
GTT, so the lack of this cap indicates that there's no point in
trying to
call addfb2.

But calling addfb2 and it failing is not expensive, so this is
rather niche.

Quoted 6 lines

In practice I can just restrict attempting to scanout of imported
buffers
to i915, as that's the only driver that it'll work on. By the time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes
should be old
enough that I don't need to care about unfixed kernels.

Quoted 6 lines

"I'll only run on i915" sounds like a rather risky assumption. You're sure no one will install ubuntu on e.g. rasperry with Eric's shiny new pl111 driver?

I really think that if you want to rely on this, backporting the fixes is perfectly fine.

Oh, no! I mean *check* that I'm running on i915, and only use the no-copy path if I am.

Backporting the patches would indeed be sensible. I guess I should have CC: stable'd at the time.

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

#10 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

In reply to Christopher James Halse Rogers

Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James Halse Rogers:

Quoted 50 lines · Daniel Vetter

On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach <[email protected]> wrote:
>> If I could guarantee that I'd only ever run on 4.13-or-later kernels
>> (I think that's when the previous patches will land?), then this would
>> indeed be mostly unnecessary. It would save me a bunch of addfb calls
>> that would predictably fail, but they're cheap. >
> I don't think we ever had caps for "things are working now, as they are
> supposed to". i915 wasn't properly synchronizing on foreign fences for a
> long time, yet we didn't gain a cap for "cross device sync works now".
>
> If your distro use-case relies on those things working it's probably
> best to just backport the relevant fixes.

The even better solution for this is to push the backports through
upstream -stable kernels. This stuff here is simple enough that we can
do it. Same could have been done for the fairly minimal fencing fixes
for i915 (at least some of them, the ones in the page-flip).

Otherwise we'll end up with tons IM_NOT_BUGGY and IM_SLIGHTLY_LESS_BUGGY and IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely inconsistent and
they just all add to the confusion. They're just bugs, lets treat them
like that.

It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout of GTT, so the lack of this cap indicates that there's no point in trying to call addfb2.

Quoted 9 lines

But calling addfb2 and it failing is not expensive, so this is rather niche.

In practice I can just restrict attempting to scanout of imported buffers to i915, as that's the only driver that it'll work on. By the time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes should be old enough that I don't need to care about unfixed kernels.

So given that most discreet hardware won't ever be able to scanout from GTT (latency and iso requirements will be hard to meet), can't we just fix the case of the broken prime sharing when migrating to VRAM?

I'm thinking about attaching an exclusive fence to the dma-buf when the migration to VRAM happens, then when the GPU is done with the buffer we can either write back any changes to GTT, or just drop the fence in case the GPU didn't modify the buffer.

Regards,
Lucas

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

#11 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 61 lines · Lucas Stach

Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James Halse Rogers:

Quoted 50 lines · Daniel Vetter

On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach <[email protected]> wrote:
>> If I could guarantee that I'd only ever run on 4.13-or-later kernels
>> (I think that's when the previous patches will land?), then this would
>> indeed be mostly unnecessary. It would save me a bunch of addfb calls
>> that would predictably fail, but they're cheap. >
> I don't think we ever had caps for "things are working now, as they are
> supposed to". i915 wasn't properly synchronizing on foreign fences for a
> long time, yet we didn't gain a cap for "cross device sync works now".
>
> If your distro use-case relies on those things working it's probably
> best to just backport the relevant fixes.

The even better solution for this is to push the backports through
upstream -stable kernels. This stuff here is simple enough that we can
do it. Same could have been done for the fairly minimal fencing fixes
for i915 (at least some of them, the ones in the page-flip).

Otherwise we'll end up with tons IM_NOT_BUGGY and IM_SLIGHTLY_LESS_BUGGY and IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely inconsistent and
they just all add to the confusion. They're just bugs, lets treat them
like that.

It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout of GTT, so the lack of this cap indicates that there's no point in trying to call addfb2.

Quoted 9 lines

But calling addfb2 and it failing is not expensive, so this is rather niche.

In practice I can just restrict attempting to scanout of imported buffers to i915, as that's the only driver that it'll work on. By the time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes should be old enough that I don't need to care about unfixed kernels.

Quoted 8 lines

So given that most discreet hardware won't ever be able to scanout from GTT (latency and iso requirements will be hard to meet), can't we just fix the case of the broken prime sharing when migrating to VRAM?

I'm thinking about attaching an exclusive fence to the dma-buf when the migration to VRAM happens, then when the GPU is done with the buffer we can either write back any changes to GTT, or just drop the fence in case the GPU didn't modify the buffer.

We could, but someone needs to type the code for it. There's also the problem that you need to migrate back, and then doing all that behind userspaces back might not be the best idea.
-Daniel

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
#12 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:

Quoted 66 lines · Lucas Stach
Quoted 65 lines

Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James Halse Rogers:

Quoted 50 lines · Daniel Vetter

On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach <[email protected]> wrote:
>> If I could guarantee that I'd only ever run on 4.13-or-later kernels
>> (I think that's when the previous patches will land?), then this would
>> indeed be mostly unnecessary. It would save me a bunch of addfb calls
>> that would predictably fail, but they're cheap. >
> I don't think we ever had caps for "things are working now, as they are
> supposed to". i915 wasn't properly synchronizing on foreign fences for a
> long time, yet we didn't gain a cap for "cross device sync works now".
>
> If your distro use-case relies on those things working it's probably
> best to just backport the relevant fixes.

The even better solution for this is to push the backports through
upstream -stable kernels. This stuff here is simple enough that we can
do it. Same could have been done for the fairly minimal fencing fixes
for i915 (at least some of them, the ones in the page-flip).

Otherwise we'll end up with tons IM_NOT_BUGGY and IM_SLIGHTLY_LESS_BUGGY and IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely inconsistent and
they just all add to the confusion. They're just bugs, lets treat them
like that.

It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout of GTT, so the lack of this cap indicates that there's no point in trying to call addfb2.

Quoted 9 lines

But calling addfb2 and it failing is not expensive, so this is rather niche.

In practice I can just restrict attempting to scanout of imported buffers to i915, as that's the only driver that it'll work on. By the time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes should be old enough that I don't need to care about unfixed kernels.

So given that most discreet hardware won't ever be able to scanout from GTT (latency and iso requirements will be hard to meet), can't we just fix the case of the broken prime sharing when migrating to VRAM?

Quoted 8 lines
Quoted 4 lines

I'm thinking about attaching an exclusive fence to the dma-buf when the migration to VRAM happens, then when the GPU is done with the buffer we can either write back any changes to GTT, or just drop the fence in case the GPU didn't modify the buffer.

We could, but someone needs to type the code for it. There's also the problem that you need to migrate back, and then doing all that behind userspaces back might not be the best idea.

Drivers with separate VRAM and GTT are already doing a lot of migration behind the userspaces back. The only issue with dma-buf migration to VRAM is that you probably don't want to migrate the pages, but duplicate them in VRAM, doubling memory consumption with possible OOM. But then you could alloc the memory on addfb where you are able to return proper errors.

I guess what I'm saying is that userspace really should check if addfb for imported buffers works and base its decisions on that, not some arbitrary "is this driver XY" or "does it have magic DRM_CAP". This way we can enable transparent VRAM migration (making addfb on them work) if someone is interested in this, without further changes to the UAPI.

Regards,
Lucas

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

#13 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 51 lines · Lucas Stach

Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:

Quoted 2 lines · Lucas Stach
Quoted 1 line

Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James

Halse

Quoted 4 lines
Quoted 4 lines

Rogers:

Quoted 3 lines

On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines

On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach <[email protected]> wrote:
>> If I could guarantee that I'd only ever run on 4.13-or-later kernels
>> (I think that's when the previous patches will land?),

then

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines

this would
>> indeed be mostly unnecessary. It would save me a bunch of addfb calls
>> that would predictably fail, but they're cheap. >
> I don't think we ever had caps for "things are working now, as they are
> supposed to". i915 wasn't properly synchronizing on foreign fences for a
> long time, yet we didn't gain a cap for "cross device sync works now".
>
> If your distro use-case relies on those things working it's probably
> best to just backport the relevant fixes.

The even better solution for this is to push the backports through
upstream -stable kernels. This stuff here is simple enough that we can
do it. Same could have been done for the fairly minimal fencing fixes
for i915 (at least some of them, the ones in the page-flip).

Otherwise we'll end up with tons IM_NOT_BUGGY and IM_SLIGHTLY_LESS_BUGGY and IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely inconsistent and
they just all add to the confusion. They're just bugs, lets treat them
like that.

Quoted 20 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant hardware allegedly supports it, nouveau/radeon/amdgpu don't do

scanout

Quoted 16 lines
Quoted 16 lines
Quoted 4 lines

of GTT, so the lack of this cap indicates that there's no point in trying to call addfb2.

Quoted 9 lines

But calling addfb2 and it failing is not expensive, so this is rather niche.

In practice I can just restrict attempting to scanout of imported buffers to i915, as that's the only driver that it'll work on. By the time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes should be old enough that I don't need to care about unfixed kernels.

So given that most discreet hardware won't ever be able to scanout from GTT (latency and iso requirements will be hard to meet), can't we just fix the case of the broken prime sharing when migrating to VRAM?

At least some nouveau and AMD devs seem to think that their hardware is capable of doing it. Shrug.

Quoted 11 lines
Quoted 4 lines
Quoted 4 lines

I'm thinking about attaching an exclusive fence to the dma-buf when the migration to VRAM happens, then when the GPU is done with the buffer we can either write back any changes to GTT, or just drop the fence in

case

Quoted 5 lines
Quoted 1 line

the GPU didn't modify the buffer.

We could, but someone needs to type the code for it. There's also the problem that you need to migrate back, and then doing all that behind userspaces back might not be the best idea.

Quoted 7 lines

Drivers with separate VRAM and GTT are already doing a lot of migration behind the userspaces back. The only issue with dma-buf migration to VRAM is that you probably don't want to migrate the pages, but duplicate them in VRAM, doubling memory consumption with possible OOM. But then you could alloc the memory on addfb where you are able to return proper errors.

I would *love* for the driver to copy the pages for me into VRAM for scanout, rather than me having to spin up an EGL context and run the trivial blitting shader across an EGLImage.

Are you offering to do it? :)

I'll still need to, for the short term, assume that only i915 can do this without breaking, though.

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

#14 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Am 05.04.2017 um 13:13 schrieb Christopher James Halse Rogers:

Quoted 87 lines · On Wed, Apr 5, 2017 at 8:14 PM Lucas Stach <[email protected]…

Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:
> On Wed, Apr 05, 2017 at 10:15:44AM +0200, Lucas Stach wrote:
> > Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James Halse
> > Rogers:
> > >
> > >
> > > On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter <[email protected] <mailto:[email protected]>> wrote:
> > >
> > > On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach
> > > <[email protected]
<mailto:[email protected]>> wrote:
> > > >> If I could guarantee that I'd only ever run on
> > > 4.13-or-later kernels
> > > >> (I think that's when the previous patches will
land?), then
> > > this would
> > > >> indeed be mostly unnecessary. It would save me a
bunch of
> > > addfb calls
> > > >> that would predictably fail, but they're cheap.
> > > >
> > > > I don't think we ever had caps for "things are
working now,
> > > as they are
> > > > supposed to". i915 wasn't properly synchronizing
on foreign
> > > fences for a
> > > > long time, yet we didn't gain a cap for "cross
device sync
> > > works now".
> > > >
> > > > If your distro use-case relies on those things
working it's
> > > probably
> > > > best to just backport the relevant fixes.
> > >
> > > The even better solution for this is to push the
backports
> > > through
> > > upstream -stable kernels. This stuff here is simple
enough
> > > that we can
> > > do it. Same could have been done for the fairly minimal
> > > fencing fixes
> > > for i915 (at least some of them, the ones in the
page-flip).
> > >
> > > Otherwise we'll end up with tons IM_NOT_BUGGY and
> > > IM_SLIGHTLY_LESS_BUGGY and
> > > IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
> > > flags where no one at all knows what they mean,
usage between
> > > different drivers and different userspace is entirely
> > > inconsistent and
> > > they just all add to the confusion. They're just
bugs, lets
> > > treat them
> > > like that.
> > >
> > >
> > > It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant
> > > hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout
> > > of GTT, so the lack of this cap indicates that there's no point in
> > > trying to call addfb2.
> > >
> > >
> > > But calling addfb2 and it failing is not expensive, so this is rather
> > > niche.
> > >
> > >
> > > In practice I can just restrict attempting to scanout of imported
> > > buffers to i915, as that's the only driver that it'll work on. By the
> > > time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes
> > > should be old enough that I don't need to care about unfixed kernels.
> > >

Quoted 8 lines

> > So given that most discreet hardware won't ever be able to scanout from
> > GTT (latency and iso requirements will be hard to meet), can't we just
> > fix the case of the broken prime sharing when migrating to VRAM?

At least some nouveau and AMD devs seem to think that their hardware is capable of doing it. Shrug.

Wow, wait a second. Recent AMD GPU can scanout from system memory, that's true.

But you need to met quite a bunch of special allocation requirements to do this.

When we are talking about sharing between AMD GPUs, (e.g. both exporter and importer are AMD hardware) than that might work.

But I think it's unrealistic that an imported BO (created by an external driver stack) will ever meet those requirements.

Christian.

Quoted 31 lines
Quoted 3 lines
Quoted 3 lines

I'm thinking about attaching an exclusive fence to the dma-buf

when the
> > migration to VRAM happens, then when the GPU is done with the buffer we
> > can either write back any changes to GTT, or just drop the fence in case
> > the GPU didn't modify the buffer.
>
> We could, but someone needs to type the code for it. There's also the
> problem that you need to migrate back, and then doing all that behind
> userspaces back might not be the best idea.

Drivers with separate VRAM and GTT are already doing a lot of migration
behind the userspaces back. The only issue with dma-buf migration to VRAM is that you probably don't want to migrate the pages, but duplicate
them in VRAM, doubling memory consumption with possible OOM. But then you could alloc the memory on addfb where you are able to return proper
errors.

I would *love* for the driver to copy the pages for me into VRAM for scanout, rather than me having to spin up an EGL context and run the trivial blitting shader across an EGLImage.

Are you offering to do it? :)

Quoted 7 lines

I'll still need to, for the short term, assume that only i915 can do this without breaking, though.

_______________________________________________
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

#15 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 96 lines · Christian König

Am 05.04.2017 um 13:13 schrieb Christopher James Halse Rogers:

Quoted 95 lines

On Wed, Apr 5, 2017 at 8:14 PM Lucas Stach <[email protected] <mailto:[email protected]>> wrote:

Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:
> On Wed, Apr 05, 2017 at 10:15:44AM +0200, Lucas Stach wrote:
> > Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James Halse
> > Rogers:
> > >
> > >
> > > On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter <[email protected] <mailto:[email protected]>> wrote:
> > >
> > > On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach
> > > <[email protected]
<mailto:[email protected]>> wrote:
> > > >> If I could guarantee that I'd only ever run on
> > > 4.13-or-later kernels
> > > >> (I think that's when the previous patches will
land?), then
> > > this would
> > > >> indeed be mostly unnecessary. It would save me a
bunch of
> > > addfb calls
> > > >> that would predictably fail, but they're cheap.
> > > >
> > > > I don't think we ever had caps for "things are
working now,
> > > as they are
> > > > supposed to". i915 wasn't properly synchronizing
on foreign
> > > fences for a
> > > > long time, yet we didn't gain a cap for "cross
device sync
> > > works now".
> > > >
> > > > If your distro use-case relies on those things
working it's
> > > probably
> > > > best to just backport the relevant fixes.
> > >
> > > The even better solution for this is to push the
backports
> > > through
> > > upstream -stable kernels. This stuff here is simple
enough
> > > that we can
> > > do it. Same could have been done for the fairly minimal
> > > fencing fixes
> > > for i915 (at least some of them, the ones in the
page-flip).
> > >
> > > Otherwise we'll end up with tons IM_NOT_BUGGY and
> > > IM_SLIGHTLY_LESS_BUGGY and
> > > IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
> > > flags where no one at all knows what they mean,
usage between
> > > different drivers and different userspace is entirely
> > > inconsistent and
> > > they just all add to the confusion. They're just
bugs, lets
> > > treat them
> > > like that.
> > >
> > >
> > > It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant
> > > hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout
> > > of GTT, so the lack of this cap indicates that there's no point in
> > > trying to call addfb2.
> > >
> > >
> > > But calling addfb2 and it failing is not expensive, so this is rather
> > > niche.
> > >
> > >
> > > In practice I can just restrict attempting to scanout of imported
> > > buffers to i915, as that's the only driver that it'll work on. By the
> > > time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes
> > > should be old enough that I don't need to care about unfixed kernels.
> > >
> > So given that most discreet hardware won't ever be able to scanout from
> > GTT (latency and iso requirements will be hard to meet), can't we just
> > fix the case of the broken prime sharing when migrating to VRAM?

Quoted 5 lines
Quoted 2 lines

At least some nouveau and AMD devs seem to think that their hardware is capable of doing it. Shrug.

Wow, wait a second. Recent AMD GPU can scanout from system memory, that's true.

Even discrete GPUs, or only APUs?

Quoted 8 lines

But you need to met quite a bunch of special allocation requirements to do this.

When we are talking about sharing between AMD GPUs, (e.g. both exporter and importer are AMD hardware) than that might work.

But I think it's unrealistic that an imported BO (created by an external driver stack) will ever meet those requirements.

Indeed. Also, none of the GPUs supported by the radeon driver support this.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#16 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Am 10.04.2017 um 10:52 schrieb Michel Dänzer:

Quoted 97 lines · Christian König
Quoted 96 lines

Am 05.04.2017 um 13:13 schrieb Christopher James Halse Rogers:

Quoted 95 lines

On Wed, Apr 5, 2017 at 8:14 PM Lucas Stach <[email protected] <mailto:[email protected]>> wrote:

Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:
> On Wed, Apr 05, 2017 at 10:15:44AM +0200, Lucas Stach wrote:
> > Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James Halse
> > Rogers:
> > >
> > >
> > > On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter <[email protected] <mailto:[email protected]>> wrote:
> > >
> > > On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach
> > > <[email protected]
<mailto:[email protected]>> wrote:
> > > >> If I could guarantee that I'd only ever run on
> > > 4.13-or-later kernels
> > > >> (I think that's when the previous patches will
land?), then
> > > this would
> > > >> indeed be mostly unnecessary. It would save me a
bunch of
> > > addfb calls
> > > >> that would predictably fail, but they're cheap.
> > > >
> > > > I don't think we ever had caps for "things are
working now,
> > > as they are
> > > > supposed to". i915 wasn't properly synchronizing
on foreign
> > > fences for a
> > > > long time, yet we didn't gain a cap for "cross
device sync
> > > works now".
> > > >
> > > > If your distro use-case relies on those things
working it's
> > > probably
> > > > best to just backport the relevant fixes.
> > >
> > > The even better solution for this is to push the
backports
> > > through
> > > upstream -stable kernels. This stuff here is simple
enough
> > > that we can
> > > do it. Same could have been done for the fairly minimal
> > > fencing fixes
> > > for i915 (at least some of them, the ones in the
page-flip).
> > >
> > > Otherwise we'll end up with tons IM_NOT_BUGGY and
> > > IM_SLIGHTLY_LESS_BUGGY and
> > > IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
> > > flags where no one at all knows what they mean,
usage between
> > > different drivers and different userspace is entirely
> > > inconsistent and
> > > they just all add to the confusion. They're just
bugs, lets
> > > treat them
> > > like that.
> > >
> > >
> > > It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant
> > > hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout
> > > of GTT, so the lack of this cap indicates that there's no point in
> > > trying to call addfb2.
> > >
> > >
> > > But calling addfb2 and it failing is not expensive, so this is rather
> > > niche.
> > >
> > >
> > > In practice I can just restrict attempting to scanout of imported
> > > buffers to i915, as that's the only driver that it'll work on. By the
> > > time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes
> > > should be old enough that I don't need to care about unfixed kernels.
> > >
> > So given that most discreet hardware won't ever be able to scanout from
> > GTT (latency and iso requirements will be hard to meet), can't we just
> > fix the case of the broken prime sharing when migrating to VRAM?

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At least some nouveau and AMD devs seem to think that their hardware is capable of doing it. Shrug.

Wow, wait a second. Recent AMD GPU can scanout from system memory, that's true.

Even discrete GPUs, or only APUs?

Good question. The crux is that you need to match certain bandwith and latency limitations or otherwise you get a flickering picture.

If I understood the documentation correctly that should even work with dGPUs in theory, but nobody is testing/validating this.

Long story short I wouldn't try it without feedback from the hardware/DC guys. They are the designated experts for this.

Regards,
Christian.

Quoted 5 lines
Quoted 5 lines

But you need to met quite a bunch of special allocation requirements to do this.

Quoted 8 lines
Quoted 5 lines

When we are talking about sharing between AMD GPUs, (e.g. both exporter and importer are AMD hardware) than that might work.

But I think it's unrealistic that an imported BO (created by an external driver stack) will ever meet those requirements.

Indeed. Also, none of the GPUs supported by the radeon driver support this.

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

#17 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 112 lines · Christian König

Am 10.04.2017 um 10:52 schrieb Michel Dänzer:

Quoted 102 lines · Christian König
Quoted 100 lines

Am 05.04.2017 um 13:13 schrieb Christopher James Halse Rogers:

Quoted 98 lines

On Wed, Apr 5, 2017 at 8:14 PM Lucas Stach <[email protected] <mailto:[email protected]>> wrote:

Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:
> On Wed, Apr 05, 2017 at 10:15:44AM +0200, Lucas Stach wrote:
> > Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James Halse
> > Rogers:
> > >
> > >
> > > On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter <[email protected] <mailto:[email protected]>> wrote:
> > >
> > > On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach
> > > <[email protected]
<mailto:[email protected]>> wrote:
> > > >> If I could guarantee that I'd only ever run on
> > > 4.13-or-later kernels
> > > >> (I think that's when the previous patches will
land?), then
> > > this would
> > > >> indeed be mostly unnecessary. It would save me a
bunch of
> > > addfb calls
> > > >> that would predictably fail, but they're cheap.
> > > >
> > > > I don't think we ever had caps for "things are
working now,
> > > as they are
> > > > supposed to". i915 wasn't properly synchronizing
on foreign
> > > fences for a
> > > > long time, yet we didn't gain a cap for "cross
device sync
> > > works now".
> > > >
> > > > If your distro use-case relies on those things
working it's
> > > probably
> > > > best to just backport the relevant fixes.
> > >
> > > The even better solution for this is to push the
backports
> > > through
> > > upstream -stable kernels. This stuff here is simple
enough
> > > that we can
> > > do it. Same could have been done for the fairly
minimal
> > > fencing fixes
> > > for i915 (at least some of them, the ones in the
page-flip).
> > >
> > > Otherwise we'll end up with tons IM_NOT_BUGGY and
> > > IM_SLIGHTLY_LESS_BUGGY and
> > > IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
> > > flags where no one at all knows what they mean,
usage between
> > > different drivers and different userspace is entirely
> > > inconsistent and
> > > they just all add to the confusion. They're just
bugs, lets
> > > treat them
> > > like that.
> > >
> > >
> > > It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant
> > > hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout
> > > of GTT, so the lack of this cap indicates that there's no point in
> > > trying to call addfb2.
> > >
> > >
> > > But calling addfb2 and it failing is not expensive, so this is rather
> > > niche.
> > >
> > >
> > > In practice I can just restrict attempting to scanout of imported
> > > buffers to i915, as that's the only driver that it'll work on. By the
> > > time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes
> > > should be old enough that I don't need to care about unfixed kernels.
> > >
> > So given that most discreet hardware won't ever be able to scanout from
> > GTT (latency and iso requirements will be hard to meet), can't we just
> > fix the case of the broken prime sharing when migrating to
VRAM?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

At least some nouveau and AMD devs seem to think that their hardware is capable of doing it. Shrug.

Wow, wait a second. Recent AMD GPU can scanout from system memory, that's true.

Even discrete GPUs, or only APUs?

Quoted 8 lines

Good question. The crux is that you need to match certain bandwith and latency limitations or otherwise you get a flickering picture.

If I understood the documentation correctly that should even work with dGPUs in theory, but nobody is testing/validating this.

Long story short I wouldn't try it without feedback from the hardware/DC guys. They are the designated experts for this.

It's only been validated on APUs.

Alex

Quoted 20 lines

Regards,
Christian.

Quoted 5 lines
Quoted 5 lines

But you need to met quite a bunch of special allocation requirements to do this.

Quoted 10 lines
Quoted 5 lines

When we are talking about sharing between AMD GPUs, (e.g. both exporter and importer are AMD hardware) than that might work.

But I think it's unrealistic that an imported BO (created by an external driver stack) will ever meet those requirements.

Indeed. Also, none of the GPUs supported by the radeon driver support this.

Quoted 4 lines

_______________________________________________
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

#18 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

In reply to Lucas Stach
Quoted 81 lines · On Wed, 5 Apr 2017 at 20:14 Lucas Stach <[email protected]> wrote:

Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:

Quoted 2 lines · Lucas Stach
Quoted 1 line

Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James

Halse

Quoted 4 lines
Quoted 4 lines

Rogers:

Quoted 3 lines

On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines

On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach <[email protected]> wrote:
>> If I could guarantee that I'd only ever run on 4.13-or-later kernels
>> (I think that's when the previous patches will land?),

then

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines

this would
>> indeed be mostly unnecessary. It would save me a bunch of addfb calls
>> that would predictably fail, but they're cheap. >
> I don't think we ever had caps for "things are working now, as they are
> supposed to". i915 wasn't properly synchronizing on foreign fences for a
> long time, yet we didn't gain a cap for "cross device sync works now".
>
> If your distro use-case relies on those things working it's probably
> best to just backport the relevant fixes.

The even better solution for this is to push the backports through
upstream -stable kernels. This stuff here is simple enough that we can
do it. Same could have been done for the fairly minimal fencing fixes
for i915 (at least some of them, the ones in the page-flip).

Otherwise we'll end up with tons IM_NOT_BUGGY and IM_SLIGHTLY_LESS_BUGGY and IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
flags where no one at all knows what they mean, usage between different drivers and different userspace is entirely inconsistent and
they just all add to the confusion. They're just bugs, lets treat them
like that.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant hardware allegedly supports it, nouveau/radeon/amdgpu don't do

scanout

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

of GTT, so the lack of this cap indicates that there's no point in trying to call addfb2.

But calling addfb2 and it failing is not expensive, so this is rather niche.

In practice I can just restrict attempting to scanout of imported buffers to i915, as that's the only driver that it'll work on. By the time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes should be old enough that I don't need to care about unfixed kernels.

Quoted 7 lines
Quoted 7 lines

So given that most discreet hardware won't ever be able to scanout from GTT (latency and iso requirements will be hard to meet), can't we just fix the case of the broken prime sharing when migrating to VRAM?

I'm thinking about attaching an exclusive fence to the dma-buf when the migration to VRAM happens, then when the GPU is done with the buffer we can either write back any changes to GTT, or just drop the fence in

case

Quoted 5 lines
Quoted 1 line

the GPU didn't modify the buffer.

We could, but someone needs to type the code for it. There's also the problem that you need to migrate back, and then doing all that behind userspaces back might not be the best idea.

Quoted 6 lines

Drivers with separate VRAM and GTT are already doing a lot of migration behind the userspaces back. The only issue with dma-buf migration to VRAM is that you probably don't want to migrate the pages, but duplicate them in VRAM, doubling memory consumption with possible OOM. But then you could alloc the memory on addfb where you are able to return proper errors.

Hm. So, on a first inspection, this looks like something I could actually cook up.

Looking at amdgpu it seems like the thing to do would be to associate a shadow-bo in VRAM for the imported dma-buf in the addfb call, then pin-and-copy-to the shadow bo in the places where the bo is currently pinned.

Is this approach likely to be acceptable?

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

#19 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 112 lines · Christopher James Halse Rogers

On Wed, 5 Apr 2017 at 20:14 Lucas Stach <[email protected] <mailto:[email protected]>> wrote:

Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:
> On Wed, Apr 05, 2017 at 10:15:44AM +0200, Lucas Stach wrote:
> > Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher James Halse
> > Rogers:
> > >
> > >
> > > On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter <[email protected] <mailto:[email protected]>> wrote:
> > >
> > > On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach
> > > <[email protected]
<mailto:[email protected]>> wrote:
> > > >> If I could guarantee that I'd only ever run on
> > > 4.13-or-later kernels
> > > >> (I think that's when the previous patches will
land?), then
> > > this would
> > > >> indeed be mostly unnecessary. It would save me a
bunch of
> > > addfb calls
> > > >> that would predictably fail, but they're cheap.
> > > >
> > > > I don't think we ever had caps for "things are
working now,
> > > as they are
> > > > supposed to". i915 wasn't properly synchronizing on
foreign
> > > fences for a
> > > > long time, yet we didn't gain a cap for "cross
device sync
> > > works now".
> > > >
> > > > If your distro use-case relies on those things
working it's
> > > probably
> > > > best to just backport the relevant fixes.
> > >
> > > The even better solution for this is to push the backports
> > > through
> > > upstream -stable kernels. This stuff here is simple enough
> > > that we can
> > > do it. Same could have been done for the fairly minimal
> > > fencing fixes
> > > for i915 (at least some of them, the ones in the
page-flip).
> > >
> > > Otherwise we'll end up with tons IM_NOT_BUGGY and
> > > IM_SLIGHTLY_LESS_BUGGY and
> > > IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
> > > flags where no one at all knows what they mean, usage
between
> > > different drivers and different userspace is entirely
> > > inconsistent and
> > > they just all add to the confusion. They're just bugs,
lets
> > > treat them
> > > like that.
> > >
> > >
> > > It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the relevant
> > > hardware allegedly supports it, nouveau/radeon/amdgpu don't do scanout
> > > of GTT, so the lack of this cap indicates that there's no point in > > > trying to call addfb2.
> > >
> > >
> > > But calling addfb2 and it failing is not expensive, so this is rather
> > > niche.
> > >
> > >
> > > In practice I can just restrict attempting to scanout of imported > > > buffers to i915, as that's the only driver that it'll work on. By the
> > > time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes > > > should be old enough that I don't need to care about unfixed kernels.
> > >
> > So given that most discreet hardware won't ever be able to scanout from
> > GTT (latency and iso requirements will be hard to meet), can't we just
> > fix the case of the broken prime sharing when migrating to VRAM? > >
> > I'm thinking about attaching an exclusive fence to the dma-buf when the
> > migration to VRAM happens, then when the GPU is done with the buffer we
> > can either write back any changes to GTT, or just drop the fence in case
> > the GPU didn't modify the buffer.
>
> We could, but someone needs to type the code for it. There's also the > problem that you need to migrate back, and then doing all that behind > userspaces back might not be the best idea.

Drivers with separate VRAM and GTT are already doing a lot of migration behind the userspaces back. The only issue with dma-buf migration to VRAM is that you probably don't want to migrate the pages, but duplicate them in VRAM, doubling memory consumption with possible OOM. But then you could alloc the memory on addfb where you are able to return proper errors.

Hm. So, on a first inspection, this looks like something I could actually cook up.

Quoted 6 lines

Looking at amdgpu it seems like the thing to do would be to associate a shadow-bo in VRAM for the imported dma-buf in the addfb call, then pin-and-copy-to the shadow bo in the places where the bo is currently pinned.

Is this approach likely to be acceptable?

It would break e.g. with DRI2 flips, because they replace the screen pixmap buffer with the buffer we're flipping to. If the app stops flipping while such a shadow BO is being scanned out, later draws to the screen pixmap won't become visible.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#20 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 146 lines · Michel Dänzer
Quoted 11 lines · Christopher James Halse Rogers

On Wed, 5 Apr 2017 at 20:14 Lucas Stach <[email protected] <mailto:[email protected]>> wrote:

    Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:
    > On Wed, Apr 05, 2017 at 10:15:44AM +0200, Lucas Stach wrote:
    > > Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher
    James Halse
    > > Rogers:
    > > >
    > > >
    > > > On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter

<[email protected]

Quoted 11 lines

<mailto:[email protected]>> wrote:
> > >
> > > On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach
> > > <[email protected]
<mailto:[email protected]>> wrote:
> > > >> If I could guarantee that I'd only ever run on
> > > 4.13-or-later kernels
> > > >> (I think that's when the previous patches will
land?), then
> > > this would
> > > >> indeed be mostly unnecessary. It would save me a

Quoted 8 lines

bunch of
> > > addfb calls
> > > >> that would predictably fail, but they're cheap.
> > > >
> > > > I don't think we ever had caps for "things are
working now,
> > > as they are
> > > > supposed to". i915 wasn't properly synchronizing

on

Quoted 11 lines

foreign
> > > fences for a
> > > > long time, yet we didn't gain a cap for "cross
device sync
> > > works now".
> > > >
> > > > If your distro use-case relies on those things
working it's
> > > probably
> > > > best to just backport the relevant fixes.
> > >

Quoted 1 line

> > > The even better solution for this is to push the

backports

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

through
upstream -stable kernels. This stuff here is simple

enough

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

that we can
do it. Same could have been done for the fairly

minimal

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

fencing fixes
for i915 (at least some of them, the ones in the

page-flip).
> > >
> > > Otherwise we'll end up with tons IM_NOT_BUGGY and
> > > IM_SLIGHTLY_LESS_BUGGY and
> > > IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
> > > flags where no one at all knows what they mean,

usage

Quoted 2 lines

between
> > > different drivers and different userspace is

entirely

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

inconsistent and
they just all add to the confusion. They're just

bugs,

Quoted 6 lines

lets
> > > treat them
> > > like that.
> > >
> > >
> > > It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while

the

Quoted 2 lines

relevant
> > > hardware allegedly supports it, nouveau/radeon/amdgpu don't

do

Quoted 2 lines

scanout
> > > of GTT, so the lack of this cap indicates that there's no

point in

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

trying to call addfb2.

But calling addfb2 and it failing is not expensive, so this

is

Quoted 5 lines
    rather
    > > > niche.
    > > >
    > > >
    > > > In practice I can just restrict attempting to scanout of

imported

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

buffers to i915, as that's the only driver that it'll work

on.

Quoted 2 lines

By the
> > > time nouveau/radeon/amdgpu get patches to scanout of GTT

the fixes

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

should be old enough that I don't need to care about

unfixed

Quoted 5 lines

kernels.
> > >
> > So given that most discreet hardware won't ever be able to scanout from
> > GTT (latency and iso requirements will be hard to meet),

can't

Quoted 2 lines

we just
> > fix the case of the broken prime sharing when migrating to

VRAM?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I'm thinking about attaching an exclusive fence to the

dma-buf

Quoted 4 lines

when the
> > migration to VRAM happens, then when the GPU is done with the buffer we
> > can either write back any changes to GTT, or just drop the

fence

Quoted 4 lines

in case
> > the GPU didn't modify the buffer.
>
> We could, but someone needs to type the code for it. There's

also the

Quoted 1 line
Quoted 1 line

problem that you need to migrate back, and then doing all that

behind

Quoted 3 lines
Quoted 1 line

userspaces back might not be the best idea.

Drivers with separate VRAM and GTT are already doing a lot of

migration

Quoted 1 line

behind the userspaces back. The only issue with dma-buf migration

to

Quoted 1 line

VRAM is that you probably don't want to migrate the pages, but

duplicate

Quoted 1 line

them in VRAM, doubling memory consumption with possible OOM. But

then

Quoted 1 line

you could alloc the memory on addfb where you are able to return

proper

Quoted 7 lines

errors.

Hm. So, on a first inspection, this looks like something I could actually cook up.

Looking at amdgpu it seems like the thing to do would be to associate

a

Quoted 4 lines

shadow-bo in VRAM for the imported dma-buf in the addfb call, then pin-and-copy-to the shadow bo in the places where the bo is currently pinned.

Quoted 7 lines
Quoted 1 line

Is this approach likely to be acceptable?

It would break e.g. with DRI2 flips, because they replace the screen pixmap buffer with the buffer we're flipping to. If the app stops flipping while such a shadow BO is being scanned out, later draws to the
screen pixmap won't become visible.

This shadow BO would only ever be used for imported dma-bufs. This would change the behaviour from “addfb fails” to “you get a shadow BO”. (And, pre-patch, from “addfb succeeds but you never see any new rendering”).

I don't think any DRI2 implementation hits this, because of it did it would already be broken.

(On paternity leave, so I'll be intermittent in following this up)

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

#21 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Quoted 27 lines · Christopher James Halse Rogers
Quoted 19 lines · Michel Dänzer
Quoted 18 lines · Christopher James Halse Rogers
Quoted 6 lines · On Wed, 5 Apr 2017 at 20:14 Lucas Stach <[email protected]…

Drivers with separate VRAM and GTT are already doing a lot of migration behind the userspaces back. The only issue with dma-buf migration to VRAM is that you probably don't want to migrate the pages, but duplicate them in VRAM, doubling memory consumption with possible OOM. But then you could alloc the memory on addfb where you are able to return proper errors.

Hm. So, on a first inspection, this looks like something I could actually cook up.

Looking at amdgpu it seems like the thing to do would be to associate a shadow-bo in VRAM for the imported dma-buf in the addfb call, then pin-and-copy-to the shadow bo in the places where the bo is currently pinned.

Quoted 6 lines
Quoted 1 line

Is this approach likely to be acceptable?

It would break e.g. with DRI2 flips, because they replace the screen pixmap buffer with the buffer we're flipping to. If the app stops flipping while such a shadow BO is being scanned out, later draws to the screen pixmap won't become visible.

Quoted 7 lines

This shadow BO would only ever be used for imported dma-bufs. This would change the behaviour from “addfb fails” to “you get a shadow BO”. (And, pre-patch, from “addfb succeeds but you never see any new rendering”).

I don't think any DRI2 implementation hits this, because of it did it would already be broken.

You're right, I got it backwards. I guess this could work.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#22 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

In reply to Christopher James Halse Rogers

Hi,

Quoted 6 lines · Christopher James Halse Rogers
Quoted 4 lines · Daniel Vetter

This seems like an awful specific special case. Why can't you do the entire dance upfront, i.e. import buffer, addfb2? None of that has any visible effect, and it will also allow you to check runtime constraints which can't be covered with this here.

Quoted 7 lines

No, because addfb2 doesn't (or, rather, didn't) actually check any runtime constraints.

The problem only appeared when the buffer is actually *used* in a modeset - otherwise I could do a (reasonably) cheap import/addfb/render on exporter/read out on importer dance to detect it.

To be clear - this is trying to solve the problem “how can I tell if it's safe to addfb/pageflip rather than do a GL copy to a GPU-local buffer and flip from that?”.

If I could guarantee that I'd only ever run on 4.13-or-later kernels (I think that's when the previous patches will land?), then this would indeed be mostly unnecessary. It would save me a bunch of addfb calls that would predictably fail, but they're cheap.

Yeah, the ABI is that AddFB2 should fail hard on something which can never be used as a framebuffer. The fact it didn't is a bug rather than a behavioural change per se ...

Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#23 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Am 04.04.2017 um 12:43 schrieb Daniel Stone:

Quoted 11 lines

Hi,

Quoted 7 lines · Christopher James Halse Rogers
Quoted 4 lines · Daniel Vetter

This seems like an awful specific special case. Why can't you do the entire dance upfront, i.e. import buffer, addfb2? None of that has any visible effect, and it will also allow you to check runtime constraints which can't be covered with this here.

No, because addfb2 doesn't (or, rather, didn't) actually check any runtime constraints.

Quoted 8 lines
Quoted 5 lines

The problem only appeared when the buffer is actually *used* in a modeset - otherwise I could do a (reasonably) cheap import/addfb/render on exporter/read out on importer dance to detect it.

To be clear - this is trying to solve the problem “how can I tell if it's safe to addfb/pageflip rather than do a GL copy to a GPU-local buffer and flip from that?”.

If I could guarantee that I'd only ever run on 4.13-or-later kernels (I think that's when the previous patches will land?), then this would indeed be mostly unnecessary. It would save me a bunch of addfb calls that would predictably fail, but they're cheap.

Yeah, the ABI is that AddFB2 should fail hard on something which can never be used as a framebuffer. The fact it didn't is a bug rather than a behavioural change per se ...

I agree on that, but the problem Christopher tries to solve looks a bit different from my perspective.

He wants to know if a driver can scan out from a foreign BO or if he needs to copy the content.

The problem I see with this patch is that the kernel doesn't look like the right place for this decision to make.

Regards,
Christian.

Quoted 7 lines

Cheers,
Daniel
_______________________________________________
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

#24 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Hi,

Quoted 5 lines · Christian König

Am 04.04.2017 um 12:43 schrieb Daniel Stone:

Quoted 3 lines

Yeah, the ABI is that AddFB2 should fail hard on something which can never be used as a framebuffer. The fact it didn't is a bug rather than a behavioural change per se ...

Quoted 8 lines

I agree on that, but the problem Christopher tries to solve looks a bit different from my perspective.

He wants to know if a driver can scan out from a foreign BO or if he needs to copy the content.

The problem I see with this patch is that the kernel doesn't look like the right place for this decision to make.

Any number of constraints exist there: 'can I use any completely arbitrary dmabuf from anywhere?' doesn't express the full range. AddFB can fail for other totally legitimate reasons, so to me it makes the most sense to centralise the checks there.

Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#25 lore raw

Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.

Am 04.04.2017 um 13:32 schrieb Daniel Stone:

Quoted 10 lines

Hi,

Quoted 7 lines · Christian König

Am 04.04.2017 um 12:43 schrieb Daniel Stone:

Quoted 3 lines

Yeah, the ABI is that AddFB2 should fail hard on something which can never be used as a framebuffer. The fact it didn't is a bug rather than a behavioural change per se ...

I agree on that, but the problem Christopher tries to solve looks a bit different from my perspective.

Quoted 7 lines
Quoted 5 lines

He wants to know if a driver can scan out from a foreign BO or if he needs to copy the content.

The problem I see with this patch is that the kernel doesn't look like the right place for this decision to make.

Any number of constraints exist there: 'can I use any completely arbitrary dmabuf from anywhere?' doesn't express the full range.

Yes, completely agree.

Quoted 2 lines

AddFB can fail for other totally legitimate reasons, so to me it makes the most sense to centralise the checks there.

Sorry, sounds like I wasn't clear on this. Removing the check in was *not* what I've wanted to suggest.

The kernel of course needs to check if what userspace requested makes sense and fail with a proper error message if it doesn't.

But the negotiation if two kernel drivers can work with each others data formats for each use case is not something I would want to push into the kernel. For this we simply have to many and to complex constraints on this.

In other words if you have an AMD APU with integrated graphics and an AMD dGPU it is likely that both can understand what the other puts into its buffer, even when it is completely AMD specific. The AMD user space drivers already have code to handle such cases.

But when we have a combination of Intel+AMD or Intel+NVidia we need way more negotiation between the two driver stacks then just the placement of buffers.

Regards,
Christian.

Quoted 3 lines

Cheers,
Daniel

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

#26 lore raw

PATCH 2/2 drm/i915: support DRIVER_PRIME_SCANOUT.

In reply to [email protected]

From: Christopher James Halse Rogers <[email protected]>

---
 drivers/gpu/drm/i915/i915_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +1 -1
index e703556eba99..0fbf8e4b7119 100644
@@ -2575,7 +2575,7 @@ static struct drm_driver driver = {
 	 */
 	.driver_features =
 	    DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME |
-	    DRIVER_RENDER | DRIVER_MODESET,
+	    DRIVER_RENDER | DRIVER_MODESET | DRIVER_PRIME_SCANOUT,
 	.open = i915_driver_open,
 	.lastclose = i915_driver_lastclose,
 	.preclose = i915_driver_preclose,
Signature · 6 lines
2.11.0

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