linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Jason Gunthorpe <jgg@ziepe.ca>,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>
Cc: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com,
	robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	heiko@sntech.de, p.zabel@pengutronix.de, 	mchehab@kernel.org,
	iommu@lists.linux.dev, devicetree@vger.kernel.org,
		linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
		linux-rockchip@lists.infradead.org, kernel@collabora.com,
		linux-media@vger.kernel.org
Subject: Re: [PATCH v7 4/6] media: verisilicon: AV1: Restore IOMMU context before decoding a frame
Date: Fri, 29 Aug 2025 12:23:29 -0400	[thread overview]
Message-ID: <a216e7e218d874cf64b53f6eba2fc74fc551d2fe.camel@collabora.com> (raw)
In-Reply-To: <20250826124155.GD1899851@ziepe.ca>

[-- Attachment #1: Type: text/plain, Size: 4055 bytes --]

Le mardi 26 août 2025 à 09:41 -0300, Jason Gunthorpe a écrit :
> On Tue, Aug 26, 2025 at 11:52:37AM +0200, Benjamin Gaignard wrote:
> > 
> > Le 25/08/2025 à 20:31, Jason Gunthorpe a écrit :
> > > On Mon, Aug 25, 2025 at 01:50:16PM -0400, Nicolas Dufresne wrote:
> > > 
> > > > Jason, the point is that the iommu and the VPU are not separate devices, which
> > > > comes with side effects. On RKVDec side, the iommu configuration get resets
> > > > whenever a decoding error leads to a VPU "self reset". I can't remember who from
> > > > the iommu subsystem suggested that, but the empty domain method was agreed to be
> > > IDK, that seems really goofy too me an defiantly needs to be
> > > extensively documented this is restoring the default with some lore
> > > link of the original suggestion.
> > > 
> > > > the least invasive way to workaround that issue. I believe Detlev tried multiple
> > > > time to add APIs for that before the discussion lead to this path.
> > > You mean this:
> > > 
> > > https://lore.kernel.org/linux-iommu/20250318152049.14781-1-detlev.casanova@collabora.com/
> > > 
> > > Which came back with the same remark I would give:
> > > 
> > >   Please have some kind of proper reset notifier mechanism - in fact
> > >   with runtime PM could you not already invoke a suspend/resume cycle
> > >   via the device links?
> > 
> > when doing parallel decode suspend/resume are not invoked.
> 
> It was a proposal for an error recovery path.
> 
> > > Or another reasonable option:
> > > 
> > >    Or at worst just export a public interface for the other driver to
> > >    invoke rk_iommu_resume() directly.
> > > 
> > > Sigh.
> > 
> > An other solution which is working is to call iommu_flush_iotlb_all()
> > before decoding each frame.
> 
> That was already proposed and shot down, it makes no sense at all use
> to use flushing to reset the registers because the HW weirdly lost
> them, and flushing should never happen outside mapping contexts.
> 
> If the HW is really resetting the iommu registers after every frame
> that is really just painfully broken, and makes me wonder if it really
> should be an iommu subsystem driver at all if it is so tightly coupled
> to the computing HW. :\
> 
> Like we wouldn't try to put a GPU MMU into the iommu subsystem though
> they do fairly similar things.

I didn't mention, but this is obviously close to the same IOMMU wrapped inside
etnaviv (same company making it). Note that for media driver, drivers in the
iommu subsystem are very convenient, they just work usually (except when they
don't like with codecs). I'm pretty sure rkmmu is also used by Panfrost, so I
suppose not all GPU IOMMU lives in GPU drivers (I could be wrong). Its one
instance per block, but the same programming interface. Note that we do have an
in-driver iommu implementation in the RGA2 driver.

If we can agree on solutions for this problem, which seems slightly different on
RK compared to VSI IOMMU, it will be quite beneficial to not have to override
all the media allocation ops, and re-implement rkmmu, vsimmu in every driver
needing this block. The VSI mmu could be used similarly to how the rkmmu is
used, meaning we'd have to copy its implementation in every driver. If we could
find out more accuratly how this is suppose to work it would be great, I feel we
don't really understand what is going on yet. Once that done, we can port rkvdec
driver with the unified solution.

The empty domain approach was used since there was no solution that came out
over a year, and users these days expect concurrent decoding to work. So yes,
its not all pretty, but its the best we found until this type of hardware
behaviour gets an API for that is commonly agreed.

Main question is shall we block on merging the VSI IOMMU driver for that reason
? Its there anything in the IOMMU driver that still needs more work ?

cheers,
Nicolas

p.s. RK means Rockchip, VSI means Verisilicon, the company behind Vivante GPU

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  parent reply	other threads:[~2025-08-29 16:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25 15:34 [PATCH v7 0/6] Add support for Verisilicon IOMMU used by media codec blocks Benjamin Gaignard
2025-08-25 15:34 ` [PATCH v7 1/6] dt-bindings: vendor-prefixes: Add Verisilicon Benjamin Gaignard
2025-08-25 15:34 ` [PATCH v7 2/6] dt-bindings: iommu: verisilicon: Add binding for VSI IOMMU Benjamin Gaignard
2025-08-25 15:34 ` [PATCH v7 3/6] iommu: Add verisilicon IOMMU driver Benjamin Gaignard
2025-08-25 15:34 ` [PATCH v7 4/6] media: verisilicon: AV1: Restore IOMMU context before decoding a frame Benjamin Gaignard
2025-08-25 17:05   ` Jason Gunthorpe
2025-08-25 17:50     ` Nicolas Dufresne
2025-08-25 18:31       ` Jason Gunthorpe
2025-08-26  9:52         ` Benjamin Gaignard
2025-08-26 12:41           ` Jason Gunthorpe
2025-08-26 13:14             ` Benjamin Gaignard
2025-08-29 16:23             ` Nicolas Dufresne [this message]
2025-08-25 15:34 ` [PATCH v7 5/6] arm64: dts: rockchip: Add verisilicon IOMMU node on RK3588 Benjamin Gaignard
2025-08-25 15:34 ` [PATCH v7 6/6] arm64: defconfig: enable Verisilicon IOMMU Benjamin Gaignard
2025-08-26  8:25   ` Krzysztof Kozlowski
2025-08-26  9:53     ` Benjamin Gaignard
2025-08-26 10:05       ` Krzysztof Kozlowski

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=a216e7e218d874cf64b53f6eba2fc74fc551d2fe.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=heiko@sntech.de \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kernel@collabora.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /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).