From: Jean Delvare <jdelvare@suse.de>
To: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel
Subject: Re: [PATCH] i2c: piix4: Request the SMBUS semaphore inside the mutex
Date: Fri, 3 Feb 2017 16:17:39 +0100 [thread overview]
Message-ID: <20170203161739.7264f85b@endymion> (raw)
In-Reply-To: <20170202191516.4476-1-ricardo.ribalda@gmail.com>
Hi Ricardo,
On Thu, 2 Feb 2017 20:15:16 +0100, Ricardo Ribalda Delgado wrote:
> SMBSLVCNT must be protected with the piix4_mutex_sb800 in order to avoid
> multiple buses accessing to the semaphore at the same time.
>
> Reported-by: Jean Delvare <jdelvare@suse.de>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
> drivers/i2c/busses/i2c-piix4.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
> index 73cc6799cc59..c21ca7bf2efe 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -592,6 +592,8 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
> u8 port;
> int retval;
>
> + mutex_lock(&piix4_mutex_sb800);
> +
> /* Request the SMBUS semaphore, avoid conflicts with the IMC */
> smbslvcnt = inb_p(SMBSLVCNT);
> do {
> @@ -605,10 +607,10 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
> usleep_range(1000, 2000);
> } while (--retries);
> /* SMBus is still owned by the IMC, we give up */
> - if (!retries)
> + if (!retries) {
> + mutex_unlock(&piix4_mutex_sb800);
> return -EBUSY;
> -
> - mutex_lock(&piix4_mutex_sb800);
> + }
>
> outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX);
> smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
> @@ -623,11 +625,11 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
>
> outb_p(smba_en_lo, SB800_PIIX4_SMB_IDX + 1);
>
> - mutex_unlock(&piix4_mutex_sb800);
> -
> /* Release the semaphore */
> outb_p(smbslvcnt | 0x20, SMBSLVCNT);
>
> + mutex_unlock(&piix4_mutex_sb800);
> +
> return retval;
> }
>
Thanks for the quick fix.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2017-02-03 15:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 19:15 [PATCH] i2c: piix4: Request the SMBUS semaphore inside the mutex Ricardo Ribalda Delgado
2017-02-03 15:17 ` Jean Delvare [this message]
2017-02-09 16:09 ` Wolfram Sang
2017-02-09 17:31 ` Jean Delvare
2017-02-09 19:56 ` Wolfram Sang
2017-02-09 16:13 ` Wolfram Sang
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=20170203161739.7264f85b@endymion \
--to=jdelvare@suse.de \
--cc=andy.shevchenko@gmail.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel \
--cc=ricardo.ribalda@gmail.com \
--cc=wsa@the-dreams.de \
/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