Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tzung-Bi Shih" <tzungbi@kernel.org>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v16 1/4] revocable: Revocable resource management
Date: Tue, 01 Dec 2026 13:17:41 +0000	[thread overview]
Message-ID: <sashiko-outbox-243373@kernel.org> (raw)
In-Reply-To: <20261201130303.14530-2-tzungbi@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] revocable: exclusive context lock annotations used for shared
  srcu_struct
- [Low] revocable: missing Return section in revocable_init() kernel-doc
  comment
--

commit 50e7a51b025e8180202192107f613bdccc5a9f5b
Author: Tzung-Bi Shih <tzungbi@kernel.org>

revocable: Revocable resource management

This commit introduces an SRCU-based revocable resource management primitive
that provides safe access to resources that can be asynchronously removed.

> diff --git a/drivers/base/revocable.c b/drivers/base/revocable.c
> new file mode 100644
> index 0000000000000..a7fcda012f3c6
> --- /dev/null
> +++ b/drivers/base/revocable.c
> @@ -0,0 +1,305 @@
[ ... ]
> +/**
> + * revocable_init() - Initialize struct revocable.
> + * @rev: The pointer of resource provider.
> + * @res: The pointer of resource.
> + *
> + * This initializes a resource provider handle embedded within another struct.
> + */
> +int revocable_init(struct revocable *rev, void *res)

[Severity: Low]
revocable_init() returns an int, but its kernel-doc comment has no Return:
section, causing scripts/kernel-doc to warn when run with -Wreturn (such as
during W=2 builds).

[ ... ]

> diff --git a/include/linux/revocable.h b/include/linux/revocable.h
> new file mode 100644
> index 0000000000000..577ee1a8dc17e
> --- /dev/null
> +++ b/include/linux/revocable.h
> @@ -0,0 +1,220 @@
[ ... ]
> +void *revocable_try_access(struct revocable_handle *rh)
> +	__acquires(&rh->rev->srcu);
> +void revocable_withdraw_access(struct revocable_handle *rh)
> +	__releases(&rh->rev->srcu);
> +
> +DEFINE_FREE(access_rev, struct revocable_handle *, if (_T) {
> +	revocable_withdraw_access(_T);
> +	revocable_handle_destroy(_T);
> +})
> +
> +#define _revocable_try_access_with(_rev, _rh, _res)				\
> +	struct revocable_handle _rh;						\
> +	struct revocable_handle *__UNIQUE_ID(name) __free(access_rev) = &_rh;	\
> +										\
> +	revocable_handle_init(_rev, &_rh);					\
> +	_res = revocable_try_access(&_rh)

[Severity: Low]
Should revocable_try_access() and revocable_withdraw_access() use
__acquires_shared(&rh->rev->srcu) and __releases_shared(&rh->rev->srcu) here
and in drivers/base/revocable.c?

srcu_read_lock() and srcu_read_unlock() acquire and release srcu_struct in
shared mode (__acquires_shared / __releases_shared), so the exclusive
__acquires and __releases annotations trigger Clang -Wthread-safety warnings
when context analysis is enabled.

In addition, _revocable_try_access_with() and
_revocable_try_access_with_scoped() call revocable_try_access(&_rh) directly
in the caller's scope while relying on DEFINE_FREE(access_rev, ...) to release
the SRCU read lock at scope exit.  Because DEFINE_FREE() generates
__free_access_rev() with __context_unsafe and no release annotation, Clang
context analysis reports &_rh.rev->srcu as still held at the end of the caller
scope.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201130303.14530-1-tzungbi@kernel.org?part=1

  reply	other threads:[~2026-12-01 13:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 13:02 [PATCH v16 0/4] drivers/base: Introduce revocable Tzung-Bi Shih
2026-12-01 13:03 ` [PATCH v16 1/4] revocable: Revocable resource management Tzung-Bi Shih
2026-12-01 13:17   ` sashiko-bot [this message]
2026-12-01 13:03 ` [PATCH v16 2/4] revocable: Add KUnit test cases Tzung-Bi Shih
2026-12-01 13:03 ` [PATCH v16 3/4] gpio: Leverage revocable for accessing struct gpio_chip Tzung-Bi Shih
2026-12-01 13:03 ` [PATCH v16 4/4] reset: Leverage revocable for accessing struct reset_controller_dev Tzung-Bi Shih
2026-12-01 13:15   ` sashiko-bot

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=sashiko-outbox-243373@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tzungbi@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