From: "Vadillo, Miguel" <miguel.vadillo@intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: <linux-media@vger.kernel.org>, <mchehab@kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-api@vger.kernel.org>,
<sakari.ailus@linux.intel.com>, <hansg@kernel.org>,
<laurent.pinchart@ideasonboard.com>, <mehdi.djait@bootlin.com>,
<mika.westerberg@linux.intel.com>, <srini@kernel.org>,
<arun.t@intel.com>
Subject: Re: [PATCH] media: i2c: cvs: Add NVMem-based firmware update support
Date: Mon, 5 Oct 2026 10:53:43 -0700 [thread overview]
Message-ID: <9147f6b3-1afc-4939-b34c-424fb7dd11eb@intel.com> (raw)
In-Reply-To: <ar9XxEb6Kjvd6HXb@ashevche-desk.local>
On 10/2/26 12:05 AM, Andy Shevchenko wrote:
> On Thu, Oct 01, 2026 at 04:03:50PM -0700, Vadillo, Miguel wrote:
>> On 10/1/26 11:32 AM, Andy Shevchenko wrote:
>>> On Wed, Sep 30, 2026 at 11:21:42AM -0700, Miguel Vadillo wrote:
>
> ...
>
>>>> + mutex_lock(&ctx->lock);
>>>
>>> Why not guard()()? Also how ACQUIRE() macros are co-habit with goto:s?
>>
>> You are right scoped_guard() should be the case here and to get rid of the
>> gotos, this could be done like:
>> ...
>> scoped_guard(mutex, &ctx->lock) {
>
> Why scoped_guard()? If you need something to be outside of the regular
> guard()(), but double check that it's indeed the case, refactor to have to
> functions, one with guard()() in it and one that wraps it.
Fair question.
AFAICS, only the KOBJ_CHANGE uevent has to stay outside the lock: fwupd
reacts to it by reading nvm_version / nvm_authenticate, and those take
ctx->lock.
V2 can remove them and keep only the guard()(). cvs_nvm_authenticate()
holds the lock with guard(), nvm_authenticate_store() wraps it and emits
the uevent after it returns.
This also simplifies the error handling.
The other three scoped_guard() users (cvs_nvm_active_read(),
nvm_version_show(), device_id_show()) only did a memcpy() or
sysfs_emit() afterwards, so they had no reason either. All can be plain
guard()() in V2.
>
>> switch (val) {
>> ...
>> }
>>
>> nvm->auth_status = -ret;
>> }
>
>> if (ret)
>> return ret;
>>
>> if (do_uevent)
>> kobject_uevent(&dev->kobj, KOBJ_CHANGE);
>>
>> return count;
>
> ...
>
>>>> struct icvs {
>>>> struct i2c_client *i2c_client;
>>>
>>>> int irq;
>>>> wait_queue_head_t hostwake_event;
>>>> bool hostwake_event_arg;
>>>> + struct icvs_nvm nvm;
>>>> };
>>>
>>> Is `pahole` happy with the layout?
>>
>> Yes. struct icvs_nvm is itself hole-free and fits in one cacheline.
>> That being said, there seems to be other holes in the full struct from the
>> existing implementation, this order could make it better
>> ...
>
> Better by `pahole` doesn't always mean better in all aspects. You have to also
> check it in conjunction with the output of `bloat-o-meter`. And in some
> (performance-critical) cases with the runtime performance tests.
Fair enough. Measured, the reorder is code-size neutral:
add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
Total: Before=14547, After=14547, chg +0.00%
text/data/bss are identical too. So it saves 16 bytes per device
instance (1304 -> 1288) at no text cost, but struct icvs is
devm_kzalloc()'d once per device and never touched on a hot path, so
AFAICS there is nothing to measure at runtime. This could be a separate
patch as cleanup (?)
--
regards,
Miguel
>
>> struct media_pad pads[ICVS_CSI_NUM_PADS];
>> struct device_link *ipu_link;
>> unsigned long quirks;
>> struct gpio_desc *rst;
>> struct gpio_desc *req;
>> struct gpio_desc *resp;
>> wait_queue_head_t hostwake_event;
>> struct icvs_nvm nvm;
>> struct icvs_dev_capabilities caps;
>> u32 nr_of_lanes;
>> enum icvs_resources res;
>> int irq;
>> bool prefix;
>> bool hostwake_event_arg;
>>
>> but maybe send as a separate patch since it is not related to the patch
>> intent (?)
>
prev parent reply other threads:[~2026-10-05 17:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 18:21 Miguel Vadillo
2026-10-01 18:32 ` Andy Shevchenko
2026-10-01 23:03 ` Vadillo, Miguel
2026-10-02 7:05 ` Andy Shevchenko
2026-10-05 17:53 ` Vadillo, Miguel [this message]
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=9147f6b3-1afc-4939-b34c-424fb7dd11eb@intel.com \
--to=miguel.vadillo@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arun.t@intel.com \
--cc=hansg@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mehdi.djait@bootlin.com \
--cc=mika.westerberg@linux.intel.com \
--cc=sakari.ailus@linux.intel.com \
--cc=srini@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
all inboxes | Powered by JetHome®