From: Konrad Dybcio <konradybcio@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>, Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Orson Zhai <orsonzhai@gmail.com>,
Chunyan Zhang <zhang.lyra@gmail.com>,
David Woodhouse <dwmw2@infradead.org>,
Will Deacon <will@kernel.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, iommu@lists.linux.dev,
linux-sunxi@lists.linux.dev,
Alex Williamson <alex.williamson@redhat.com>,
Samuel Holland <samuel@sholland.org>,
Heiko Stuebner <heiko@sntech.de>
Subject: Re: [PATCH v2 9/10] iommu: Complete the locking for dev->iommu_group
Date: Wed, 9 Aug 2023 14:55:48 +0200 [thread overview]
Message-ID: <47692e15-3b3d-4d42-91dc-a1bd0f436039@kernel.org> (raw)
In-Reply-To: <9-v2-b0417f84403e+11f-iommu_group_locking_jgg@nvidia.com>
On 31.07.2023 19:50, Jason Gunthorpe wrote:
> Revise the locking for dev->iommu_group so that it has three safe ways to
> access it:
>
> - It is read by a probe'd device driver. So long as a device driver is
> probed the dev->iommu_group will be guaranteed stable without further
> locking.
>
> - Read under the device_lock(), this primarily protects against
> parallel probe of the same device, and parallel probe/remove
>
> - Read/Write under the global dev_iommu_group_lock. This is used during
> probe time discovery of groups. Device drivers will scan unlocked
> portions of the device tree to locate an already existing group. These
> scans can access the dev->iommu_group under the global lock to single
> thread determining and installing the group. This ensures that groups
> are reliably formed.
>
> Narrow the scope of the global dev_iommu_group_lock to be only during the
> dev->iommu_group setup, and not for the entire probing.
>
> Prior patches removed the various races inherent to the probe process by
> consolidating all the work under the group->mutex. In this configuration
> it is fine if two devices race to the group_device step of a new
> iommu_group, the group->mutex locking will ensure the group_device and
> domain setup part remains properly ordered.
>
> Add the missing locking on the remove paths. For iommu_deinit_device() it
> is necessary to hold the dev_iommu_group_lock due to possible races during
> probe error unwind.
>
> Fully lock the iommu_group_add/remove_device() path so we can use lockdep
> assertions. Other than lockdep this is redundant, VFIO no-iommu doesn't
> use group clustering.
>
> For iommu_release_device() it is redundant, as we expect no external
> references to the struct device by this point, but it is harmless so
> add the missing lock to allow lockdep assertions to work.
>
> This resolves the remarks of the comment in __iommu_probe_device().
>
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> ---
Hello, this patch breaks booting on at least one Qualcomm platform using
the SMMUv2 driver w/ qcom impl. The board hangs right after SMMU probe.
Reverting it makes the platform boot again.
Konrad
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-08-09 12:56 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-31 17:50 [PATCH v2 00/10] Refine the locking for dev->iommu_group Jason Gunthorpe
2023-07-31 17:50 ` [PATCH v2 01/10] iommu: Remove useless group refcounting Jason Gunthorpe
2023-08-02 1:33 ` Tian, Kevin
2023-07-31 17:50 ` [PATCH v2 02/10] iommu: Add a lockdep assertion for remaining dev->iommu_group reads Jason Gunthorpe
2023-08-02 1:34 ` Tian, Kevin
2023-08-08 16:22 ` Robin Murphy
2023-08-08 16:54 ` Jason Gunthorpe
2023-07-31 17:50 ` [PATCH v2 03/10] iommu: Add generic_single_device_group() Jason Gunthorpe
2023-08-02 1:35 ` Tian, Kevin
2023-07-31 17:50 ` [PATCH v2 04/10] iommu/sun50i: Convert to generic_single_device_group() Jason Gunthorpe
2023-07-31 17:50 ` [PATCH v2 05/10] iommu/sprd: " Jason Gunthorpe
2023-07-31 17:50 ` [PATCH v2 06/10] iommu/rockchip: " Jason Gunthorpe
[not found] ` <CGME20230809131935eucas1p247866f51cde0952d764c92f10a41c90c@eucas1p2.samsung.com>
2023-08-09 13:19 ` Marek Szyprowski
2023-08-09 13:51 ` Jason Gunthorpe
2023-08-09 14:02 ` Marek Szyprowski
2023-07-31 17:50 ` [PATCH v2 07/10] iommu/ipmmu-vmsa: " Jason Gunthorpe
2023-07-31 17:50 ` [PATCH v2 08/10] iommu/omap: " Jason Gunthorpe
2023-07-31 17:50 ` [PATCH v2 09/10] iommu: Complete the locking for dev->iommu_group Jason Gunthorpe
2023-08-02 1:36 ` Tian, Kevin
2023-08-09 12:55 ` Konrad Dybcio [this message]
2023-07-31 17:50 ` [PATCH v2 10/10] iommu/intel: Fix missing locking for show_device_domain_translation() Jason Gunthorpe
2023-08-02 1:37 ` Tian, Kevin
2023-08-07 12:54 ` [PATCH v2 00/10] Refine the locking for dev->iommu_group Joerg Roedel
2023-08-08 10:31 ` Chen-Yu Tsai
2023-08-08 12:24 ` Jason Gunthorpe
[not found] ` <CGME20230808123250eucas1p19d12a9ae0e530c123ba625189f593b36@eucas1p1.samsung.com>
2023-08-08 12:32 ` Marek Szyprowski
2023-08-08 13:00 ` Jason Gunthorpe
2023-08-08 13:08 ` Marek Szyprowski
2023-08-08 13:25 ` Jason Gunthorpe
2023-08-08 14:02 ` Marek Szyprowski
2023-08-08 14:30 ` Jason Gunthorpe
2023-08-08 14:51 ` Marek Szyprowski
2023-08-09 6:23 ` Chen-Yu Tsai
[not found] ` <CGME20230808130032eucas1p1b0f2d07f110f9913b30019b12e1d2841@eucas1p1.samsung.com>
2023-08-08 13:00 ` Marek Szyprowski
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=47692e15-3b3d-4d42-91dc-a1bd0f436039@kernel.org \
--to=konradybcio@kernel.org \
--cc=alex.williamson@redhat.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=dwmw2@infradead.org \
--cc=heiko@sntech.de \
--cc=iommu@lists.linux.dev \
--cc=jernej.skrabec@gmail.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=orsonzhai@gmail.com \
--cc=robin.murphy@arm.com \
--cc=samuel@sholland.org \
--cc=wens@csie.org \
--cc=will@kernel.org \
--cc=zhang.lyra@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).