From: Wolfram Sang <wsa@the-dreams.de>
To: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
Cc: Thor Thayer <thor.thayer@linux.intel.com>,
linux-i2c@vger.kernel.org, tomonori.sakita@sord.co.jp
Subject: Re: [PATCH] i2c: altera: Fix race between xfer_msg and isr thread
Date: Sun, 26 Apr 2020 10:30:31 +0200 [thread overview]
Message-ID: <20200426083030.GI1262@kunai> (raw)
In-Reply-To: <20200410.100640.1949609603287475131.atsushi.nemoto@sord.co.jp>
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]
On Fri, Apr 10, 2020 at 10:06:40AM +0900, Atsushi Nemoto wrote:
> Use a mutex to protect access to idev->msg_len, idev->buf, etc. which
> are modified by both altr_i2c_xfer_msg() and altr_i2c_isr().
>
> Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
> ---
> drivers/i2c/busses/i2c-altera.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-altera.c b/drivers/i2c/busses/i2c-altera.c
> index 20ef63820c77..3db7d77c5a1e 100644
> --- a/drivers/i2c/busses/i2c-altera.c
> +++ b/drivers/i2c/busses/i2c-altera.c
> @@ -70,6 +70,7 @@
> * @isr_mask: cached copy of local ISR enables.
> * @isr_status: cached copy of local ISR status.
> * @lock: spinlock for IRQ synchronization.
> + * @mutex: mutex for IRQ thread.
I think the name 'mutex' is too unspecific. (Same goes for 'lock' above
which is not part of your patch, obviously.)
> */
> struct altr_i2c_dev {
> void __iomem *base;
> @@ -86,6 +87,7 @@ struct altr_i2c_dev {
> u32 isr_mask;
> u32 isr_status;
> spinlock_t lock; /* IRQ synchronization */
> + struct mutex mutex;
> };
Has it been checked if we really need both, the spinlock and the mutex?
From a glimpse, it looks like the spinlock became obsolete now.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-04-26 8:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-10 1:06 [PATCH] i2c: altera: Fix race between xfer_msg and isr thread Atsushi Nemoto
2020-04-16 19:49 ` Thor Thayer
2020-04-26 8:30 ` Wolfram Sang [this message]
2020-04-26 10:39 ` Atsushi Nemoto
2020-05-08 13:10 ` Atsushi Nemoto
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=20200426083030.GI1262@kunai \
--to=wsa@the-dreams.de \
--cc=atsushi.nemoto@sord.co.jp \
--cc=linux-i2c@vger.kernel.org \
--cc=thor.thayer@linux.intel.com \
--cc=tomonori.sakita@sord.co.jp \
/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