devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: "Andy Gross" <agross@kernel.org>,
	"David Airlie" <airlied@gmail.com>,
	alsa-devel@alsa-project.org,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Andrzej Hajda" <andrzej.hajda@intel.com>,
	ath10k@lists.infradead.org, ath11k@lists.infradead.org,
	"Mark Brown" <broonie@kernel.org>,
	"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
	"Christian Gmeiner" <christian.gmeiner@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	devicetree@vger.kernel.org, dmaengine@vger.kernel.org,
	"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>,
	dri-devel@lists.freedesktop.org, "Emma Anholt" <emma@anholt.net>,
	etnaviv@lists.freedesktop.org, freedreno@lists.freedesktop.org,
	"Frank Rowand" <frowand.list@gmail.com>,
	iommu@lists.linux.dev,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Joerg Roedel" <joro@8bytes.org>,
	"Konrad Dybcio" <konrad.dybcio@linaro.org>,
	"Kalle Valo" <kvalo@kernel.org>,
	"Lucas Stach" <l.stach@pengutronix.de>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Russell King" <linux+etnaviv@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org,
	linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org,
	linux-wireless@vger.kernel.org,
	"Marijn Suijten" <marijn.suijten@somainline.org>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Mikko Perttunen" <mperttunen@nvidia.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Sinan Kaya" <okaya@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Abhinav Kumar" <quic_abhinavk@quicinc.com>,
	"Jeff Johnson" <quic_jjohnson@quicinc.com>,
	"Vikash Garodia" <quic_vgarodia@quicinc.com>,
	"Rob Clark" <robdclark@gmail.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Samuel Holland" <samuel@sholland.org>,
	"Sean Paul" <sean@poorly.run>,
	"Stanimir Varbanov" <stanimir.k.varbanov@gmail.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Takashi Iwai" <tiwai@suse.com>, "Vinod Koul" <vkoul@kernel.org>,
	"Chen-Yu Tsai" <wens@csie.org>, "Will Deacon" <will@kernel.org>,
	"Rafał Miłecki" <zajec5@gmail.com>,
	"Lu Baolu" <baolu.lu@linux.intel.com>,
	"Joerg Roedel" <jroedel@suse.de>,
	"Kevin Tian" <kevin.tian@intel.com>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Chen-Yu Tsai" <wenst@chromium.org>
Subject: Re: [PATCH] iommu: Remove the device_lock_assert() from __iommu_probe_device()
Date: Mon, 21 Aug 2023 09:51:13 -0300	[thread overview]
Message-ID: <ZONdwclGOBaxxqtq@nvidia.com> (raw)
In-Reply-To: <78114fd6-9b83-92ba-418f-6cc7bda9df9b@arm.com>

On Mon, Aug 21, 2023 at 12:06:40PM +0100, Robin Murphy wrote:
> On 2023-08-18 22:32, Jason Gunthorpe wrote:
> > It is subtle and was never documented or enforced, but there has always
> > been an assumption that of_dma_configure_id() is not concurrent. It makes
> > several calls into the iommu layer that require this, including
> > dev_iommu_get(). The majority of cases have been preventing concurrency
> > using the device_lock().
> > 
> > Thus the new lock debugging added exposes an existing problem in
> > drivers. On inspection this looks like a theoretical locking problem as
> > generally the cases are already assuming they are the exclusive (single
> > threaded) user of the target device.
> 
> Sorry to be blunt, but the only problem is that you've introduced an
> idealistic new locking scheme which failed to take into account how things
> currently actually work, and is broken and achieving nothing but causing
> problems.

That's pretty dramatic. I would have prefered this series have some
more testing before Joerg took it, but this is certainly not
"achieving nothing but causing problems". Introducing a real scheme
for how locking is supposed to work here is going to cause some
strain.  We've had a long period where the lack of any locking rules
has yielded a big mess held together with hope and dreams.

Of course there will be crazy stuff. If these 13 drivers are the only
problem then we've done pretty well.

And at the end we get *actual rules about how locking works* Wow!
Certainly not nothing.

What I want to hear from you is a concrete reason why device_lock() is
the *wrong* lock here. I can't think of any reason why we can't obtain
the device_lock in all the places that want to probe the iommu driver.

Nor, can I see a reason why it would be a bad choice of lock after all
the dma_configure logic is reworked someday.

> When their sole purpose was to improve the locking and make it
> easier to reason about, and now the latest "fix" is now to remove
> one of the assertions which forms the fundamental basis for that
> reasoning, then the point has clearly been lost.

I do not want to remove the assertion, I think the assertion should
stay so people running debug kernels on these drivers can get warnings
about the existing problems in these drivers.

It is removed mostly because we are at rc7, otherwise I'd play wack a
mole adding the device_lock and a nasty comment to the drivers. We can
tackle that in the next cycle and put the assertion back.

> All we've done is churned a dodgy and incomplete locking scheme into

Well, at least we agree what we have today is not great.

> And on the subject of idealism, the fact is that doing IOMMU configuration
> based on driver probe via bus->dma_configure is *fundamentally wrong* and
> breaking a bunch of other IOMMU API assumptions, so it is not a robust
> foundation to build anything upon in the first place. 

So now that Joerg has dropped it - what is your big idea to make the
locking actually work right?

Jason

  parent reply	other threads:[~2023-08-21 12:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 21:32 [PATCH] iommu: Remove the device_lock_assert() from __iommu_probe_device() Jason Gunthorpe
2023-08-18 22:47 ` Mark Brown
2023-08-21 11:06 ` Robin Murphy
2023-08-21 12:27   ` Joerg Roedel
2023-08-21 12:47     ` Jason Gunthorpe
2023-08-21 12:51   ` Jason Gunthorpe [this message]
2023-08-21 14:36     ` Joerg Roedel
2023-08-21 14:40       ` Jason Gunthorpe

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=ZONdwclGOBaxxqtq@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=agross@kernel.org \
    --cc=airlied@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=andrzej.hajda@intel.com \
    --cc=ath10k@lists.infradead.org \
    --cc=ath11k@lists.infradead.org \
    --cc=baolu.lu@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=christian.gmeiner@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emma@anholt.net \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=frowand.list@gmail.com \
    --cc=iommu@lists.linux.dev \
    --cc=jernej.skrabec@gmail.com \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=kevin.tian@intel.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=kvalo@kernel.org \
    --cc=l.stach@pengutronix.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux+etnaviv@armlinux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=marijn.suijten@somainline.org \
    --cc=mchehab@kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=mripard@kernel.org \
    --cc=okaya@kernel.org \
    --cc=perex@perex.cz \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_jjohnson@quicinc.com \
    --cc=quic_vgarodia@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=samuel@sholland.org \
    --cc=sean@poorly.run \
    --cc=stanimir.k.varbanov@gmail.com \
    --cc=thierry.reding@gmail.com \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    --cc=wens@csie.org \
    --cc=wenst@chromium.org \
    --cc=will@kernel.org \
    --cc=zajec5@gmail.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).