[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230802-maimed-spotted-5fa1fe4be386@spud>
Date: Wed, 2 Aug 2023 21:25:15 +0100
From: Conor Dooley <conor@...nel.org>
To: Tomasz Jeznach <tjeznach@...osinc.com>
Cc: Zong Li <zong.li@...ive.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>,
Albert Ou <aou@...s.berkeley.edu>, linux@...osinc.com,
linux-kernel@...r.kernel.org, Sebastien Boeuf <seb@...osinc.com>,
iommu@...ts.linux.dev, Palmer Dabbelt <palmer@...belt.com>,
Nick Kossifidis <mick@....forth.gr>,
linux-riscv@...ts.infradead.org
Subject: Re: [PATCH 01/11] RISC-V: drivers/iommu: Add RISC-V IOMMU - Ziommu
support.
On Wed, Aug 02, 2023 at 01:15:22PM -0700, Tomasz Jeznach wrote:
> On Thu, Jul 27, 2023 at 7:42 PM Zong Li <zong.li@...ive.com> wrote:
> >
> > On Thu, Jul 20, 2023 at 3:34 AM Tomasz Jeznach <tjeznach@...osinc.com> wrote:
> > >
> > > +static int riscv_iommu_platform_probe(struct platform_device *pdev)
> > > +{
> > > + struct device *dev = &pdev->dev;
> > > + struct riscv_iommu_device *iommu = NULL;
> > > + struct resource *res = NULL;
> > > + int ret = 0;
> > > +
> > > + iommu = devm_kzalloc(dev, sizeof(*iommu), GFP_KERNEL);
> > > + if (!iommu)
> > > + return -ENOMEM;
> > > +
> > > + iommu->dev = dev;
> > > + dev_set_drvdata(dev, iommu);
> > > +
> > > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > + if (!res) {
> > > + dev_err(dev, "could not find resource for register region\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > > + iommu->reg = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> > > + if (IS_ERR(iommu->reg)) {
> > > + ret = dev_err_probe(dev, PTR_ERR(iommu->reg),
> > > + "could not map register region\n");
> > > + goto fail;
> > > + };
> > > +
> > > + iommu->reg_phys = res->start;
> > > +
> > > + ret = -ENODEV;
> > > +
> > > + /* Sanity check: Did we get the whole register space ? */
> > > + if ((res->end - res->start + 1) < RISCV_IOMMU_REG_SIZE) {
> > > + dev_err(dev, "device region smaller than register file (0x%llx)\n",
> > > + res->end - res->start);
> > > + goto fail;
> > > + }
> >
> > Could we assume that DT should be responsible for specifying the right size?
> >
>
> This only to validate DT provided info and driver expected register
> file size. Expectation is that DT will provide right size.
FWIW this check seems needless to me, it's not the kernels job to
validate the devicetree.
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists