dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: James Jones <jajones@nvidia.com>
Cc: dri-devel <dri-devel@lists.freedesktop.org>,
	Thierry Reding <treding@nvidia.com>,
	Karol Herbst <kherbst@redhat.com>
Subject: Re: [git pull] drm for 5.8-rc1
Date: Fri, 14 Aug 2020 15:40:38 +0200	[thread overview]
Message-ID: <20200814134038.GA556087@ulmo> (raw)
In-Reply-To: <0e882aa7-d0ea-19b0-a13d-4f7bc0d384aa@nvidia.com>


[-- Attachment #1.1: Type: text/plain, Size: 8825 bytes --]

On Wed, Aug 12, 2020 at 10:03:46AM -0700, James Jones wrote:
> On 8/12/20 5:37 AM, Ilia Mirkin wrote:
> > On Wed, Aug 12, 2020 at 8:24 AM Karol Herbst <kherbst@redhat.com> wrote:
> > > 
> > > On Wed, Aug 12, 2020 at 12:43 PM Karol Herbst <kherbst@redhat.com> wrote:
> > > > 
> > > > On Wed, Aug 12, 2020 at 12:27 PM Karol Herbst <kherbst@redhat.com> wrote:
> > > > > 
> > > > > On Wed, Aug 12, 2020 at 2:19 AM James Jones <jajones@nvidia.com> wrote:
> > > > > > 
> > > > > > Sorry for the slow reply here as well.  I've been in the process of
> > > > > > rebasing and reworking the userspace patches.  I'm not clear my changes
> > > > > > will address the Jetson Nano issue, but if you'd like to try them, the
> > > > > > latest userspace changes are available here:
> > > > > > 
> > > > > >     https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3724
> > > > > > 
> > > > > > And the tegra-drm kernel patches are here:
> > > > > > 
> > > > > > 
> > > > > > https://patchwork.ozlabs.org/project/linux-tegra/patch/20191217005205.2573-1-jajones@nvidia.com/
> > > > > > 
> > > > > > Those + the kernel changes addressed in this thread are everything I had
> > > > > > outstanding.
> > > > > > 
> > > > > 
> > > > > I don't know if that's caused by your changes or not, but now the
> > > > > assert I hit is a different one pointing out that
> > > > > nvc0_miptree_select_best_modifier fails in a certain case and returns
> > > > > MOD_INVALID... anyway, it seems like with your patches applied it's
> > > > > now way easier to debug and figure out what's going wrong, so maybe I
> > > > > can figure it out now :)
> > > > > 
> > > > 
> > > > collected some information which might help to track it down.
> > > > 
> > > > src/gallium/frontends/dri/dri2.c:648 is the assert hit: assert(*zsbuf)
> > > > 
> > > > templ is {reference = {count = 0}, width0 = 300, height0 = 300, depth0
> > > > = 1, array_size = 1, format = PIPE_FORMAT_Z24X8_UNORM, target =
> > > > PIPE_TEXTURE_2D, last_level = 0, nr_samples = 0, nr_storage_samples =
> > > > 0, usage = 0, bind = 1, flags = 0, next = 0x0, screen = 0x0}
> > > > 
> > > > inside tegra_screen_resource_create modifier says
> > > > DRM_FORMAT_MOD_INVALID as template->bind is 1
> > > > 
> > > > and nvc0_miptree_select_best_modifier returns DRM_FORMAT_MOD_INVALID,
> > > > so the call just returns NULL leading to the assert.
> > > > 
> > > > Btw, this is on Xorg-1.20.8-1.fc32.aarch64 with glxgears.
> > > > 
> > > 
> > > So I digged a bit deeper and here is what tripps it of:
> > > 
> > > when the context gets made current, the normal framebuffer validation
> > > and render buffer allocation is done, but we end up inside
> > > tegra_screen_resource_create at some point with PIPE_BIND_SCANOUT set
> > > in template->bind. Now the tegra driver forces the
> > > DRM_FORMAT_MOD_LINEAR modifier and calls into
> > > resource_create_with_modifiers.
> > > 
> > > If it wouldn't do that, nouveau would allocate a tiled buffer, with
> > > that it's linear and we at some point end up with an assert about a
> > > depth_stencil buffer being there even though it shouldn't. If I always
> > > use DRM_FORMAT_MOD_INVALID in tegra_screen_resource_create, things
> > > just work.
> > > 
> > > That's kind of the cause I pinpointed the issue down to. But I have no
> > > idea what's supposed to happen and what the actual bug is.
> > 
> > Yeah, the bug with tegra has always been "trying to render to linear
> > color + tiled depth", which the hardware plain doesn't support. (And
> > linear depth isn't a thing.)
> > 
> > Question is whether what it's doing necessary. PIPE_BIND_SCANOUT
> > (/linear) requirements are needed for DRI2 to work (well, maybe not in
> > theory, but at least in practice the nouveau ddx expects linear
> > buffers). However tegra operates on a more DRI3-like basis, so with
> > "client" allocations, tiled should work OK as long as there's
> > something in tegra to copy it to linear when necessary?
> 
> I can confirm the above: Our hardware can't render to linear depth buffers,
> nor can it mix linear color buffers with block linear depth buffers.
> 
> I think there's a misunderstanding on expected behavior of
> resource_create_with_modifiers() here too: tegra_screen_resource_create() is
> passing DRM_FORMAT_MOD_INVALID as the only modifier in non-scanout cases.
> Previously, I believe nouveau may have treated that as "no modifiers
> specified.  Fall back to internal layout selection logic", but in my patches
> I "fixed" it to match other drivers' behavior, in that allocation will fail
> if that is the only modifier in the list, since it is equivalent to passing
> in a list containing only unsupported modifiers.  To get fallback behavior,
> tegra_screen_resource_create() should pass in (NULL, 0) for (modifiers,
> count), or just call resource_create() on the underlying screen instead.
> 
> Beyond that, I can only offer my thoughts based on analysis of the code
> referenced here so far:
> 
> While I've learned from the origins of this thread applications/things
> external to Mesa in general shouldn't be querying format modifiers of
> buffers created without format modifiers, tegra is a Mesa internal component
> that already has some intimate knowledge of how the nouveau driver it sits
> on top of works.  Nouveau will always be able to construct and return a
> valid format modifier for unorm single sampled color buffers (and hopefully,
> anything that can scan out going forward), both before and after my patches
> I believe, regardless of how they were allocated.  After my patches, it
> should even work for things that can't scan out in theory.  Hence, looking
> at this without knowledge of what motivated the original changes, it seems
> like tegra_screen_resource_create should just naively forward the
> resource_create() call, relying on nouveau to select a layout and provide a
> valid modifier when queried for import.  As Karol notes, this works fine for
> at least this simple test case, and it's what nouveau itself would be doing
> with an equivalent callstack, excepting the modifier query, so I find it
> hard to believe it breaks some application behavior.  It'll also end up
> being equivalent (in end result, not quite semantically) to what
> dri3_alloc_render_buffer() was doing prior to the patch mentioned that broke
> things for Karol, so certainly for the DRI3 usage it's the right behavior.
> 
> Ilia, what in the nouveau DDX (As in Xfree86 DDX?) assumes linear buffers?
> It sounds like you don't think it will interact poorly with this path
> regardless?  Thierry, do you recall what motivated the force-linear code
> here?

This would've clearly been a good opportunity to leave a comment as to
why this was, but the one that's in place in
tegra_screen_resource_create() doesn't do a good job of conveying what
I was thinking at the time.

This is now all a very long time ago, so I don't recall the exact
details. However the intention at the time was to pass the invalid
modifier in the default case because I wanted Nouveau to pick whatever
it wanted, assuming that we could deal with all modifiers that it could
throw at us for display. At least at the time that was true, and I do
think you're correct that Nouveau used to treat DRM_FORMAT_MOD_INVALID
as "don't care" and then tegra_screen_import_resource() would query the
modifier from Nouveau. I don't think I ever ran into the situation where
Nouveau would use a modifier that we couldn't deal with (i.e. one of the
"legacy" modifiers after your patch).

I /think/ the linear requirement, judging by the comment, was to support
certain cases that I was running into that didn't support modifiers at
all, so I think the assumption was that they wouldn't be able to create
the framebuffer with DRM_IOCTL_MODE_ADDFB2 and hence pitch-linear would
have to be assumed.

I vaguely recall that this might have been with kmscube and/or certain
versions of the X server (I also seem to have a vague memory that glamor
being used might have been responsible for this happening or not).

Given that many things have now changed it might be worth rerunning all
of those use-cases again and trace what types of resources are being
created in the process and maybe make this a little saner.

> As to why this works for Thierry and not Karol, that's confusing.  Are you
> both using the same X11 DDX (modesetting I assume?) and X server versions?
> Could it be a difference in client-side DRI library code somehow?

It looks like Karol might have found a commit that fixes this in the X
server git. I'll run a couple of tests to see if I can reproduce with a
version prior to that "fix".

Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-08-14 13:40 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02  6:06 [git pull] drm for 5.8-rc1 Dave Airlie
2020-06-02 21:21 ` Linus Torvalds
2020-06-02 21:22   ` Linus Torvalds
2020-06-02 21:56   ` Linus Torvalds
2020-06-03  7:18     ` Thomas Zimmermann
2020-06-03  7:43       ` Daniel Vetter
2020-06-02 22:14 ` Linus Torvalds
2020-06-02 23:03   ` Dave Airlie
2020-06-02 22:20 ` pr-tracker-bot
2020-06-03 20:13 ` Jason Gunthorpe
2020-06-04  8:10   ` Christian König
2020-06-30 23:08 ` Kirill A. Shutemov
2020-07-01  4:40   ` James Jones
2020-07-01  7:57     ` Kirill A. Shutemov
2020-07-01  7:59       ` Kirill A. Shutemov
2020-07-01 19:45         ` James Jones
2020-07-02  7:36           ` Daniel Vetter
2020-07-02  7:59           ` Pekka Paalanen
2020-07-02  8:22           ` Daniel Stone
2020-07-02 21:14             ` James Jones
2020-07-03  6:01               ` James Jones
2020-07-03  7:16                 ` Daniel Vetter
2020-07-13  1:37                   ` Dave Airlie
2020-07-14 14:31                     ` James Jones
2020-08-04  8:58                       ` Karol Herbst
2020-08-12  0:19                         ` James Jones
2020-08-12 10:27                           ` Karol Herbst
2020-08-12 10:43                             ` Karol Herbst
2020-08-12 12:24                               ` Karol Herbst
2020-08-12 12:37                                 ` Ilia Mirkin
2020-08-12 17:03                                   ` James Jones
2020-08-12 17:10                                     ` Karol Herbst
2020-08-12 17:19                                       ` James Jones
2020-08-12 17:40                                         ` Alyssa Rosenzweig
2020-08-12 18:24                                           ` James Jones
2020-08-12 18:51                                             ` Karol Herbst
2020-08-13 13:00                                               ` Karol Herbst
2020-08-13 15:39                                                 ` Karol Herbst
2020-08-13 17:19                                                   ` Karol Herbst
2020-08-13 17:45                                                     ` James Jones
2020-08-13 17:48                                                       ` Karol Herbst
2020-08-14 13:57                                                         ` Thierry Reding
2020-08-14 13:59                                                           ` Karol Herbst
2020-08-14 14:10                                                             ` Thierry Reding
2020-08-14 14:05                                                       ` Thierry Reding
2020-08-14 14:44                                                         ` Karol Herbst
2020-08-14 15:34                                                           ` Thierry Reding
2020-08-14 15:40                                                             ` Karol Herbst
2020-08-14 16:06                                                               ` Thierry Reding
2020-08-14 16:12                                                                 ` Karol Herbst
2020-08-14 16:22                                                                   ` Thierry Reding
2020-08-14 17:17                                                                     ` Daniel Stone
2020-08-14 17:25                                                                       ` Daniel Vetter
2020-08-18 14:37                                                                         ` Thierry Reding
2020-09-01  7:13                                                                           ` Daniel Vetter
2020-09-01 10:42                                                                             ` Daniel Stone
2020-09-01 10:59                                                                             ` Karol Herbst
2020-09-01 14:42                                                                               ` James Jones
2020-08-14 14:08                                                   ` Thierry Reding
2020-08-14 14:45                                                     ` Karol Herbst
2020-08-14 15:24                                                       ` Thierry Reding
2020-08-14 15:43                                                         ` Karol Herbst
2020-08-14 13:54                                                 ` Thierry Reding
2020-08-14 13:40                                     ` Thierry Reding [this message]
2020-08-14 13:56                                       ` Karol Herbst
2020-08-12 15:05                               ` Thierry Reding
2020-08-12 15:20                                 ` Karol Herbst
2020-08-12 15:49                                   ` Karol Herbst
2020-07-01 11:24     ` Karol Herbst
2020-07-01 15:51       ` James Jones
2020-07-01 16:01         ` Daniel Vetter
2020-07-01 17:04           ` Karol Herbst
2020-07-01 17:37             ` James Jones
2020-07-01 18:08               ` Karol Herbst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200814134038.GA556087@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jajones@nvidia.com \
    --cc=kherbst@redhat.com \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).