https://bugs.freedesktop.org/show_bug.cgi?id=104492
Bug ID: 104492
Summary: Compute Shader: Wrong alignment when assigning struct
value to structured SSBO
Product: Mesa
Version: 17.2
Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
Severity: normal
Priority: medium
Component: Drivers/Gallium/radeonsi
Assignee: dri-devel(a)lists.freedesktop.org
…
[View More] Reporter: florian.will(a)googlemail.com
QA Contact: dri-devel(a)lists.freedesktop.org
Created attachment 136547
--> https://bugs.freedesktop.org/attachment.cgi?id=136547&action=edit
Code to reproduce this issue. Requires SDL2.
Hi,
I'm trying to get the Banshee 3D engine
<https://github.com/BearishSun/BansheeEngine> working on my hardware (HD 7870)
using Mesa radeonsi (amdgpu kernel module). I use 17.2.4-0ubuntu1~17.10.1 from
the Ubuntu artful-proposed archive.
It uses a compute shader that reads a texture cube and writes 6 sets of
coefficients into a shader storage buffer object. Details are not important as
I have isolated the (probably) incorrect driver behaviour and created a much
simpler program that triggers the same issue.
In short: Let's say we have a GLSL struct and access the SSBO through a
dynamically-sized array of that struct type using the std430 layout, like this:
struct ResultRecord
{
float a[10];
float b[10];
float c[10];
float weight;
};
layout(std430) buffer gOutput
{
ResultRecord ssb[];
};
Then a simple assignment of a local variable of the same struct type to ssb[i]
writes the floats into incorrect buffer offsets, because b, c and "weight" are
placed as if the array elements in a, b and c were vec4-aligned instead of
float-aligned, tripling the size of a, b and c.
Code that triggers it is like this, which should hopefully be valid GLSL (and
makes more sense the way it is used in Banshee 3D):
ResultRecord result;
// ... populate result ...
ssb[gl_LocalInvocationIndex] = result;
The test program is available here and contains a (maybe too) detailed
explanation and three program variations that fix the issue:
https://gist.github.com/w-flo/b1a5791749eea5f36cb54628037ba2bf
But I'll also attach it to this bug report.
Looking at the RADEON_DUMP_SHADERS=1 output, I think that the bug is already
visible in the TGSI dump, as explained in the comment at the top of my
reproducer program. I'll attach the output (it's possibly based on an older
version of the reproducer).
--
You are receiving this mail because:
You are the assignee for the bug.
[View Less]
https://bugs.freedesktop.org/show_bug.cgi?id=104526
Frank <zyklon87(a)web.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
QA Contact|intel-3d-bugs(a)lists.freedes |dri-devel(a)lists.freedesktop
|ktop.org |.org
Assignee|intel-3d-bugs(a)lists.freedes |dri-devel(a)lists.freedesktop
|ktop.org |.org
…
[View More] Component|Drivers/DRI/i965 |Drivers/DRI/i915
--
You are receiving this mail because:
You are the assignee for the bug.
[View Less]
On Sat, Jan 6, 2018 at 6:00 PM, Hans de Goede <hdegoede(a)redhat.com> wrote:
> Hi,
>
>
> On 06-01-18 15:20, Alexander Kapshuk wrote:
>>
>> On Mon, Dec 25, 2017 at 04:42:59PM +0200, Alexander Kapshuk wrote:
>>>
>>> Sparse emitted the following warning:
>>> ../drivers/staging/vboxvideo/vbox_fb.c:173:27: warning: incorrect type in
>>> assignment (different address spaces)
>>> ../drivers/staging/vboxvideo/vbox_fb.c:173:27: …
[View More] expected char [noderef]
>>> <asn:2>*screen_base
>>> ../drivers/staging/vboxvideo/vbox_fb.c:173:27: got void *virtual
>>>
>>> The vbox_bo buffer object kernel mapping is handled by a call
>>> to ttm_bo_kmap() prior to the assignment of bo->kmap.virtual to
>>> info->screen_base of type char __iomem*.
>>> Casting bo->kmap.virtual to char __iomem* in this assignment fixes
>>> the warning.
>>>
>>> vboxvideo: Fix address space of expression removal sparse warning
>>>
>>> Sparse emitted the following warning:
>>> ../drivers/staging/vboxvideo/vbox_main.c:64:25: warning: cast removes
>>> address space of expression
>>>
>>> vbox->vbva_buffers iomapping is handled by calling vbox_accel_init()
>>> from vbox_hw_init().
>>> __force attribute is used in assignment to vbva to fix the warning.
>>>
>>> Signed-off-by: Alexander Kapshuk <alexander.kapshuk(a)gmail.com>
>>> ---
>>> drivers/staging/vboxvideo/vbox_fb.c | 2 +-
>>> drivers/staging/vboxvideo/vbox_main.c | 2 +-
>>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/staging/vboxvideo/vbox_fb.c
>>> b/drivers/staging/vboxvideo/vbox_fb.c
>>> index 8aed248db6e2..43c39eca4ae1 100644
>>> --- a/drivers/staging/vboxvideo/vbox_fb.c
>>> +++ b/drivers/staging/vboxvideo/vbox_fb.c
>>> @@ -170,7 +170,7 @@ static int vboxfb_create(struct drm_fb_helper
>>> *helper,
>>> drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width,
>>> sizes->fb_height);
>>>
>>> - info->screen_base = bo->kmap.virtual;
>>> + info->screen_base = (char __iomem *)bo->kmap.virtual;
>>> info->screen_size = size;
>>>
>>> #ifdef CONFIG_DRM_KMS_FB_HELPER
>
>
> This fix looks good to me.
>
>>> diff --git a/drivers/staging/vboxvideo/vbox_main.c
>>> b/drivers/staging/vboxvideo/vbox_main.c
>>> index 80bd039fa08e..973b3bcc04b1 100644
>>> --- a/drivers/staging/vboxvideo/vbox_main.c
>>> +++ b/drivers/staging/vboxvideo/vbox_main.c
>>> @@ -61,7 +61,7 @@ void vbox_enable_accel(struct vbox_private *vbox)
>>> if (vbox->vbva_info[i].vbva)
>>> continue;
>>>
>>> - vbva = (void *)vbox->vbva_buffers + i *
>>> VBVA_MIN_BUFFER_SIZE;
>>> + vbva = (void __force *)vbox->vbva_buffers + i *
>>> VBVA_MIN_BUFFER_SIZE;
>>> if (!vbva_enable(&vbox->vbva_info[i],
>>> vbox->guest_pool, vbva, i)) {
>>> /* very old host or driver error. */
>
>
> Hmm, isn't there a cleaner way to fix this ? Maybe make vbva_enable's
> argument (and the local vbva variable) of type u8 __iomem * too ?
>
> Regards,
>
> Hans
Hi Hans,
Thanks for your prompt response.
I had a good look at the vbva_enable() function's definition and to
the best of my knowledge, changing vbva's type from 'struct
vbva_buffer *' to 'u8 __iomem *' wouldn't work.
vbva_enable() relies on vbva's type being a pointer to 'struct vbva_buffer':
vbva's memory gets set to zero;
some of vbva's members are initialised to particular values;
vbva_ctx->vbva expects vbva to be a pointer to 'struct vbva_buffer' as well;
Or am I misreading this?
What are your thoughts on this?
Thanks.
Alexander.
[View Less]
Hi All,
So this patch, which I already submitted a while ago and back then it
got one comment from Chris Wilson:
> Basically you want a limit on the frequency of ... pcode access?
> As presented, you ultimately do not trust any write and the only
> solution is to disable all writes. No RPS whatsoever, run at max and
> hope rc6 works (maybe even decrease the rc6 threshold).
>
> One of the ideas we floated was moving the pcode access to a worker and
> ratelimiting the …
[View More]updates.
Has finally seen some testing by users affected by the infamous
"intel_idle.max_cstate=1 required to prevent crashes" bug:
https://bugzilla.kernel.org/show_bug.cgi?id=109051
And so far the reports are that it does help to make the users stable for
2/3 users and it not being effective for 1/3 users.
Now that we've some test results, I believe that it is worthwhile to get
this simple patch mainlined, hence this re-submission.
Regards,
Hans
[View Less]
Patches 1-4 fixes a few things that came up during the tinydrm review
but wasn't addressed at the time.
Noralf.
Noralf Trønnes (5):
drm/tinydrm/mi0283qt: Use common include order
drm/tinydrm/mi0283qt: Remove ili9341.h
drm/tinydrm/mi0283qt: Clarify error message
drm/tinydrm/mi0283qt: Let the display pipe handle power
drm/tinydrm: Embed the mode in tinydrm_connector
drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 34 ++++-------
drivers/gpu/drm/tinydrm/mi0283qt.c | 92 ++++++++…
[View More]++++++---------------
drivers/gpu/drm/tinydrm/mipi-dbi.c | 14 +++--
include/drm/tinydrm/ili9341.h | 54 -----------------
4 files changed, 65 insertions(+), 129 deletions(-)
delete mode 100644 include/drm/tinydrm/ili9341.h
--
2.14.2
[View Less]
Sparse emitted the following warning:
../drivers/staging/vboxvideo/vbox_fb.c:173:27: warning: incorrect type in assignment (different address spaces)
../drivers/staging/vboxvideo/vbox_fb.c:173:27: expected char [noderef] <asn:2>*screen_base
../drivers/staging/vboxvideo/vbox_fb.c:173:27: got void *virtual
The vbox_bo buffer object kernel mapping is handled by a call
to ttm_bo_kmap() prior to the assignment of bo->kmap.virtual to
info->screen_base of type char __iomem*.
Casting …
[View More]bo->kmap.virtual to char __iomem* in this assignment fixes
the warning.
vboxvideo: Fix address space of expression removal sparse warning
Sparse emitted the following warning:
../drivers/staging/vboxvideo/vbox_main.c:64:25: warning: cast removes address space of expression
vbox->vbva_buffers iomapping is handled by calling vbox_accel_init()
from vbox_hw_init().
__force attribute is used in assignment to vbva to fix the warning.
Signed-off-by: Alexander Kapshuk <alexander.kapshuk(a)gmail.com>
---
drivers/staging/vboxvideo/vbox_fb.c | 2 +-
drivers/staging/vboxvideo/vbox_main.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/vboxvideo/vbox_fb.c b/drivers/staging/vboxvideo/vbox_fb.c
index 8aed248db6e2..43c39eca4ae1 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -170,7 +170,7 @@ static int vboxfb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width,
sizes->fb_height);
- info->screen_base = bo->kmap.virtual;
+ info->screen_base = (char __iomem *)bo->kmap.virtual;
info->screen_size = size;
#ifdef CONFIG_DRM_KMS_FB_HELPER
diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c
index 80bd039fa08e..973b3bcc04b1 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -61,7 +61,7 @@ void vbox_enable_accel(struct vbox_private *vbox)
if (vbox->vbva_info[i].vbva)
continue;
- vbva = (void *)vbox->vbva_buffers + i * VBVA_MIN_BUFFER_SIZE;
+ vbva = (void __force *)vbox->vbva_buffers + i * VBVA_MIN_BUFFER_SIZE;
if (!vbva_enable(&vbox->vbva_info[i],
vbox->guest_pool, vbva, i)) {
/* very old host or driver error. */
--
2.13.6
[View Less]
https://bugs.freedesktop.org/show_bug.cgi?id=104216
--- Comment #7 from Germano Massullo <germano.massullo(a)gmail.com> ---
(In reply to Marek Olšák from comment #6)
> Have you tested the patch you linked?
Not yet
--
You are receiving this mail because:
You are the assignee for the bug.