From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Runyu Xiao <runyu.xiao@seu.edu.cn>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Karol Wrona" <k.wrona@samsung.com>,
"Kyungmin Park" <kyungmin.park@samsung.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, "Jianhao Xu" <jianhao.xu@seu.edu.cn>
Subject: Re: [PATCH] iio: ssp: Serialize watchdog timer state changes
Date: Wed, 30 Sep 2026 12:58:06 +0300 [thread overview]
Message-ID: <arzdLtzXQ4cvObrL@ashevche-desk.local> (raw)
In-Reply-To: <20260930070319.2933744-1-runyu.xiao@seu.edu.cn>
On Wed, Sep 30, 2026 at 03:03:19PM +0800, Runyu Xiao wrote:
> The SSP watchdog timer rearms itself from its callback, but the driver uses
> timer_delete_sync() when the last sensor is disabled and during suspend.
> Those operations do not prevent a concurrent enable or callback from
> rearming the timer after the deletion has completed. The final remove path
> also used timer_delete_sync(), which does not provide the shutdown
> guarantee needed before releasing the device state.
>
> Protect the watchdog state and enable reference count with a mutex. The
> callback checks a state flag before rearming. Reusable stops clear the flag
> before deleting the timer. Use timer_shutdown_sync() for the final remove
> path so that any later rearm attempt is rejected permanently.
>
> Cancel watchdog work after releasing wdt_lock because the reset work can
> wait for the threaded IRQ handler, which may synchronously wait for refresh
> work that re-enables sensors and takes wdt_lock. Remove the MFD children
> before destroying the locks because IIO child teardown can disable an
> active sensor.
...
> struct ssp_data {
> struct spi_device *spi;
> const struct ssp_sensorhub_info *sensorhub_info;
> struct timer_list wdt_timer;
> + struct mutex wdt_lock; /* protects watchdog timer state */
> + bool wdt_enabled;
> struct work_struct work_wdt;
> struct delayed_work work_refresh;
Does `pahole` agree with the given layout?
> _mod:
> + if (READ_ONCE(data->wdt_enabled))
What are we going to do if just after this wdt_enabled becomes false?
(Is it a possible case?)
> + mod_timer(&data->wdt_timer,
> + jiffies + msecs_to_jiffies(SSP_WDT_TIME));
> +}
Same Q to all the below. Hmm... It seems they are all protected by the mutex?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-09-30 9:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 7:03 Runyu Xiao
2026-09-30 9:58 ` Andy Shevchenko [this message]
2026-10-04 5:39 ` Runyu Xiao
2026-10-04 8:37 ` Andriy Shevchenko
2026-10-04 9:31 ` Runyu Xiao
2026-10-04 5:39 ` [PATCH v2] " Runyu Xiao
2026-10-04 8:40 ` Andriy Shevchenko
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=arzdLtzXQ4cvObrL@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=jic23@kernel.org \
--cc=k.wrona@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=runyu.xiao@seu.edu.cn \
--cc=stable@vger.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®