From: "Nirujogi, Pratap" <pnirujog@amd.com>
To: Ricardo Ribalda <ribalda@chromium.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Bryan O'Donoghue <bod@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
Bin Du <bin.du@amd.com>,
Nirujogi Pratap <pratap.nirujogi@amd.com>,
Sultan Alsawaf <sultan@kerneltoast.com>,
Svetoslav Stoilov <Svetoslav.Stoilov@amd.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Abylay Ospan <aospan@amazon.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 5/9] media: platform: amd: use refcount_t instead of atomic_t
Date: Mon, 29 Jun 2026 11:51:09 -0400 [thread overview]
Message-ID: <8bb876da-5691-4471-8813-b12d07ca8ca4@amd.com> (raw)
In-Reply-To: <20260629-cocci-7-2-v1-5-5884c80ee3b6@chromium.org>
On 6/29/2026 7:30 AM, Ricardo Ribalda wrote:
> [You don't often get email from ribalda@chromium.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> We are using the refcnt variable for refcounting. Use the refcount_t
> type instead, as it has support for saturation and underflow.
>
> This also makes cocci happier, as it will fix the following warning:
> ./platform/amd/isp4/isp4_subdev.c:394:6-25: WARNING: atomic_dec_and_test variation before object free at line 395.
>
> Fixes: 4c5feef6a62c ("media: platform: amd: Add isp4 fw and hw interface")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/platform/amd/isp4/isp4_interface.c | 4 ++--
> drivers/media/platform/amd/isp4/isp4_interface.h | 2 +-
> drivers/media/platform/amd/isp4/isp4_subdev.c | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/amd/isp4/isp4_interface.c b/drivers/media/platform/amd/isp4/isp4_interface.c
> index 8d73f66bb42c..00a817909292 100644
> --- a/drivers/media/platform/amd/isp4/isp4_interface.c
> +++ b/drivers/media/platform/amd/isp4/isp4_interface.c
> @@ -375,7 +375,7 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id,
> return -ENOMEM;
>
> /* Get two references: one for the resp thread, one for us */
> - atomic_set(&ele->refcnt, 2);
> + refcount_set(&ele->refcnt, 2);
> init_completion(&ele->cmd_done);
> }
>
> @@ -455,7 +455,7 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id,
>
> put_ele_ref:
> /* Don't free the command if we didn't put the last reference */
> - if (ele && atomic_dec_return(&ele->refcnt))
> + if (ele && !refcount_dec_and_test(&ele->refcnt))
> ele = NULL;
>
> free_ele:
> diff --git a/drivers/media/platform/amd/isp4/isp4_interface.h b/drivers/media/platform/amd/isp4/isp4_interface.h
> index ce3ac9b9e5cd..04db71cd54e6 100644
> --- a/drivers/media/platform/amd/isp4/isp4_interface.h
> +++ b/drivers/media/platform/amd/isp4/isp4_interface.h
> @@ -68,7 +68,7 @@ struct isp4if_cmd_element {
> u32 seq_num;
> u32 cmd_id;
> struct completion cmd_done;
> - atomic_t refcnt;
> + refcount_t refcnt;
> };
>
> struct isp4_interface {
> diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c b/drivers/media/platform/amd/isp4/isp4_subdev.c
> index 48deea79ce6c..2a8bc1207843 100644
> --- a/drivers/media/platform/amd/isp4/isp4_subdev.c
> +++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
> @@ -391,7 +391,7 @@ static void isp4sd_fw_resp_cmd_done(struct isp4_subdev *isp_subdev,
>
> if (ele) {
> complete(&ele->cmd_done);
> - if (atomic_dec_and_test(&ele->refcnt))
> + if (refcount_dec_and_test(&ele->refcnt))
> kfree(ele);
> }
> }
>
> --
> 2.55.0.rc0.799.gd6f94ed593-goog
>
Reviewed-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
Thanks,
Pratap
next prev parent reply other threads:[~2026-06-29 15:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 11:30 [PATCH 0/9] media: Fix all missing cocci warnings Ricardo Ribalda
2026-06-29 11:30 ` [PATCH 1/9] media: em28xx-video: Remove unneeded semicolons Ricardo Ribalda
2026-06-29 11:30 ` [PATCH 2/9] media: iris: Replace ternary conditionals with max() Ricardo Ribalda
2026-06-29 13:51 ` Bryan O'Donoghue
2026-06-29 11:30 ` [PATCH 3/9] media: vimc: Fix prototype of vimc_sensor_update_frame_timing Ricardo Ribalda
2026-06-29 11:30 ` [PATCH 4/9] media: vimc: Ensure that pixel_rate fits in 32 bits Ricardo Ribalda
2026-07-25 4:23 ` Faizel K B
2026-07-26 22:15 ` Ricardo Ribalda
2026-07-28 0:25 ` Faizel K B
2026-06-29 11:30 ` [PATCH 5/9] media: platform: amd: use refcount_t instead of atomic_t Ricardo Ribalda
2026-06-29 15:51 ` Nirujogi, Pratap [this message]
2026-06-30 6:06 ` Bin Du
2026-06-29 11:30 ` [PATCH 6/9] media: dvb-frontends/helene: Rename priv variable Ricardo Ribalda
2026-06-29 11:30 ` [PATCH 7/9] media: drivers/media/dvb-core: Split dvb_frontend_open() Ricardo Ribalda
2026-06-29 11:30 ` [PATCH 8/9] media: drivers/media/dvb-core: Refactor dvb_frontend_open locking Ricardo Ribalda
2026-06-29 11:30 ` [PATCH 9/9] media: drivers/media/dvb-core: CodeStyle for dvb_frontend_open() Ricardo Ribalda
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=8bb876da-5691-4471-8813-b12d07ca8ca4@amd.com \
--to=pnirujog@amd.com \
--cc=Svetoslav.Stoilov@amd.com \
--cc=abhinav.kumar@linux.dev \
--cc=aospan@amazon.com \
--cc=bin.du@amd.com \
--cc=bod@kernel.org \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=pratap.nirujogi@amd.com \
--cc=ribalda@chromium.org \
--cc=sakari.ailus@linux.intel.com \
--cc=skhan@linuxfoundation.org \
--cc=stable@vger.kernel.org \
--cc=sultan@kerneltoast.com \
--cc=vikash.garodia@oss.qualcomm.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
all inboxes | Powered by JetHome®