From: Nicolin Chen <nicolinc@nvidia.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: <will@kernel.org>, <robin.murphy@arm.com>, <joro@8bytes.org>,
<jgg@nvidia.com>, <thierry.reding@gmail.com>, <vdumpa@nvidia.com>,
<jonathanh@nvidia.com>, <linux-kernel@vger.kernel.org>,
<iommu@lists.linux.dev>, <linux-arm-kernel@lists.infradead.org>,
<linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v14 08/10] iommu/arm-smmu-v3: Add in-kernel support for NVIDIA Tegra241 (Grace) CMDQV
Date: Wed, 4 Sep 2024 08:17:11 -0700 [thread overview]
Message-ID: <Zth59xLYZ4skc4yb@Asurada-Nvidia> (raw)
In-Reply-To: <38b6ed33-886f-4ec7-9196-1728f1d8c1b3@stanley.mountain>
Hi Dan,
On Wed, Sep 04, 2024 at 10:29:26AM +0300, Dan Carpenter wrote:
> I was reviewing Smatch warnings:
>
> drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c:616 tegra241_cmdqv_init_vintf()
> error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing?
>
> The problem is that we're calling ida_alloc_max() where max is always zero.
>
> > +static int tegra241_cmdqv_init_vintf(struct tegra241_cmdqv *cmdqv, u16 max_idx,
> > + struct tegra241_vintf *vintf)
> > +{
> > +
> > + u16 idx;
> > + int ret;
> > +
> > + ret = ida_alloc_max(&cmdqv->vintf_ids, max_idx, GFP_KERNEL);
> > + if (ret < 0)
> > + return ret;
> > + idx = ret;
>
> max_idx is always zero so idx is always zero.
There is a followup series adding support for max[1, max_vintf].
And I guess that would make Smatch happy. I'd personally prefer
keep this by ignoring the Smatch warning. But if you think the
common practice is to drop it and add back, I'd be okay with it.
> > +
> > + vintf->idx = idx;
> > + vintf->cmdqv = cmdqv;
> > + vintf->base = cmdqv->base + TEGRA241_VINTF(idx);
> > +
> > + vintf->lvcmdqs = kcalloc(cmdqv->num_lvcmdqs_per_vintf,
> > + sizeof(*vintf->lvcmdqs), GFP_KERNEL);
> > + if (!vintf->lvcmdqs) {
> > + ida_free(&cmdqv->vintf_ids, idx);
> > + return -ENOMEM;
> > + }
> > +
> > + cmdqv->vintfs[idx] = vintf;
>
> We only use the first element of this array.
>
> > + return ret;
> > +}
>
> We could get rid of the ida_ stuff and change the cmdqv->vintfs[] array to a
> pointer. It would simplify the code.
As mentioned above, a following series is adding other vintfs.
There is no warning/error to this array, I'd prefer we keep it
as is.
Thanks
Nicolin
next prev parent reply other threads:[~2024-09-04 15:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 22:34 [PATCH v14 00/10] Add Tegra241 (Grace) CMDQV Support (part 1/2) Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 01/10] iommu/arm-smmu-v3: Issue a batch of commands to the same cmdq Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 02/10] iommu/arm-smmu-v3: Pass in cmdq pointer to arm_smmu_cmdq_build_sync_cmd Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 03/10] iommu/arm-smmu-v3: Pass in cmdq pointer to arm_smmu_cmdq_init Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 04/10] iommu/arm-smmu-v3: Make symbols public for CONFIG_TEGRA241_CMDQV Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 05/10] iommu/arm-smmu-v3: Add ARM_SMMU_OPT_TEGRA241_CMDQV Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 06/10] iommu/arm-smmu-v3: Add acpi_smmu_iort_probe_model for impl Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 07/10] iommu/arm-smmu-v3: Add struct arm_smmu_impl_ops Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 08/10] iommu/arm-smmu-v3: Add in-kernel support for NVIDIA Tegra241 (Grace) CMDQV Nicolin Chen
2024-09-04 7:29 ` Dan Carpenter
2024-09-04 15:17 ` Nicolin Chen [this message]
2024-09-04 17:12 ` Dan Carpenter
2024-09-04 17:39 ` Nicolin Chen
2024-09-04 18:47 ` Dan Carpenter
2024-08-29 22:34 ` [PATCH v14 09/10] iommu/arm-smmu-v3: Start a new batch if new command is not supported Nicolin Chen
2024-08-29 22:34 ` [PATCH v14 10/10] iommu/tegra241-cmdqv: Limit CMDs for VCMDQs of a guest owned VINTF Nicolin Chen
2024-08-30 16:12 ` [PATCH v14 00/10] Add Tegra241 (Grace) CMDQV Support (part 1/2) Will Deacon
2024-08-30 16:31 ` Nicolin Chen
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=Zth59xLYZ4skc4yb@Asurada-Nvidia \
--to=nicolinc@nvidia.com \
--cc=dan.carpenter@linaro.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=thierry.reding@gmail.com \
--cc=vdumpa@nvidia.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