[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240523152810.GL69273@ziepe.ca>
Date: Thu, 23 May 2024 12:28:10 -0300
From: Jason Gunthorpe <jgg@...pe.ca>
To: Andrew Jones <ajones@...tanamicro.com>
Cc: Tomasz Jeznach <tjeznach@...osinc.com>, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Anup Patel <apatel@...tanamicro.com>, devicetree@...r.kernel.org,
Conor Dooley <conor+dt@...nel.org>,
Albert Ou <aou@...s.berkeley.edu>, linux@...osinc.com,
linux-kernel@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
Sebastien Boeuf <seb@...osinc.com>, iommu@...ts.linux.dev,
Palmer Dabbelt <palmer@...belt.com>,
Nick Kossifidis <mick@....forth.gr>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
linux-riscv@...ts.infradead.org,
Lu Baolu <baolu.lu@...ux.intel.com>
Subject: Re: [PATCH v5 7/7] iommu/riscv: Paging domain support
On Wed, May 22, 2024 at 10:07:14AM +0200, Andrew Jones wrote:
> On Tue, May 14, 2024 at 11:16:19AM GMT, Tomasz Jeznach wrote:
> ...
> > +static int riscv_iommu_bond_link(struct riscv_iommu_domain *domain,
> > + struct device *dev)
> > +{
> > + struct riscv_iommu_device *iommu = dev_to_iommu(dev);
> > + struct riscv_iommu_bond *bond;
> > + struct list_head *bonds;
> > +
> > + bond = kzalloc(sizeof(*bond), GFP_KERNEL);
> > + if (!bond)
> > + return -ENOMEM;
> > + bond->dev = dev;
> > +
> > + /*
> > + * List of devices attached to the domain is arranged based on
> > + * managed IOMMU device.
> > + */
> > +
> > + spin_lock(&domain->lock);
> > + list_for_each_rcu(bonds, &domain->bonds)
> > + if (dev_to_iommu(list_entry(bonds, struct riscv_iommu_bond, list)->dev) == iommu)
> > + break;
>
> We should wrap this list_for_each_rcu() in rcu_read_lock() and
> rcu_read_unlock().
Not quite this is the write side, it is holding the spinlock so it
doesn't need RCU. It should just call the normal list_for_each_entry()
Jason
Powered by blists - more mailing lists