i2c: piix4: Request the SMBUS semaphore inside the mutex
PATCH 1/1 i2c: piix4: Request the SMBUS semaphore inside the mutex
SMBSLVCNT must be protected with the piix4_mutex_sb800 in order to avoid multiple buses accessing to the semaphore at the same time.
--- drivers/i2c/busses/i2c-piix4.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-piix4.c +7 -5
@@ -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; }
Signature · 1 line
2.11.0
Hi Ricardo,
Quoted 40 lines · Ricardo Ribalda Delgado
SMBSLVCNT must be protected with the
piix4_mutex_sb800in order to avoid multiple buses accessing to the semaphore at the same time.Reported-by Jean Delvare <[email protected]>Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/i2c/busses/i2c-piix4.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/i2c/busses/i2c-piix4.c +5
-3@@ -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 );
drivers/i2c/busses/i2c-piix4.c static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, · line 635
Quoted 10 lines
drivers/i2c/busses/i2c-piix4.c +2
-2-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.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Wolfram Sang
AppliedQuoted 5 lines · Ricardo Ribalda Delgado
SMBSLVCNT must be protected with the
piix4_mutex_sb800in order to avoid multiple buses accessing to the semaphore at the same time.Reported-by Jean Delvare <[email protected]>Signed-off-by Ricardo Ribalda Delgado <[email protected]>
Applied to for-current and added the same fixes tag as the patch to the resource size, thanks!
Jean,
Quoted 3 lines
Thanks for the quick fix.
Signed-off-by Jean Delvare <[email protected]>
I wonder: why do you use Signed-off instead of Reviewed-by recently?
Hi Wolfram,
Quoted 5 lines · Wolfram Sang
Quoted 3 lines
Thanks for the quick fix.
Signed-off-by Jean Delvare <[email protected]>I wonder: why do you use Signed-off instead of Reviewed-by recently?
I use Signed-off-by for drivers I maintain, and Reviewed-by for the rest.
But I can use whatever you prefer if that's a problem, I don't really care.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Quoted 3 lines
I use Signed-off-by for drivers I maintain, and Reviewed-by for the rest.
I see. I never noticed so far :)
Quoted 2 lines
But I can use whatever you prefer if that's a problem, I don't really care.
Patchwork collects Rev-by tags from threads and shows the number of tags in a list. This is helpful for me because I want to process already reviewed patches earlier.
So, Rev-by would in deed be much appreciated for a better workflow.
Thanks!