diff mbox

i2c: piix4: Fix request_region size

Message ID 20170127145930.13055-1-ricardo.ribalda@gmail.com
State Accepted
Headers show

Commit Message

Ricardo Ribalda Delgado Jan. 27, 2017, 2:59 p.m. UTC
Since '701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")' we
are using the SMBSLVCNT register at offset 0x8. We need to request it.

Fixes: 701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
Please note, not tested on hardware.
 drivers/i2c/busses/i2c-piix4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jean Delvare Jan. 28, 2017, 8:36 a.m. UTC | #1
Hi Ricardo,

On ven., 2017-01-27 at 15:59 +0100, Ricardo Ribalda Delgado wrote:
> Since '701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")'
> we
> are using the SMBSLVCNT register at offset 0x8. We need to request
> it.
> 
> Fixes: 701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
> Please note, not tested on hardware.
>  drivers/i2c/busses/i2c-piix4.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-
> piix4.c
> index e34d82e79b98..73cc6799cc59 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -58,7 +58,7 @@
>  #define SMBSLVDAT	(0xC + piix4_smba)
>  
>  /* count for request_region */
> -#define SMBIOSIZE	8
> +#define SMBIOSIZE	9
> 

Are you certain that all supported devices have this extra register?

>  
>  /* PCI Address Constants */
>  #define SMBBA		0x090

-- 
Jean Delvare
SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfram Sang Jan. 28, 2017, 11 a.m. UTC | #2
> >  /* count for request_region */
> > -#define SMBIOSIZE	8
> > +#define SMBIOSIZE	9
> > 
> 
> Are you certain that all supported devices have this extra register?

Isn't it better to have a potentially unused register mapped than a
potentially used register unmapped?
Jean Delvare Jan. 28, 2017, 11:13 a.m. UTC | #3
Hi Wolfram,

On Sat, 28 Jan 2017 12:00:21 +0100, Wolfram Sang wrote:
> 
> > >  /* count for request_region */
> > > -#define SMBIOSIZE	8
> > > +#define SMBIOSIZE	9
> > 
> > Are you certain that all supported devices have this extra register?
> 
> Isn't it better to have a potentially unused register mapped than a
> potentially used register unmapped?

My concern is that the region request could fail due to a conflict with
another device, if the physical I/O region is only 8 and we try to
request 9.
Ricardo Ribalda Delgado Jan. 30, 2017, 1:11 a.m. UTC | #4
Hi Jean and Wolfram



On Sat, Jan 28, 2017 at 12:13 PM, Jean Delvare <jdelvare@suse.de> wrote:
> Hi Wolfram,
>
> On Sat, 28 Jan 2017 12:00:21 +0100, Wolfram Sang wrote:
>>
>> > >  /* count for request_region */
>> > > -#define SMBIOSIZE        8
>> > > +#define SMBIOSIZE        9
>> >
>> > Are you certain that all supported devices have this extra register?
>>
>> Isn't it better to have a potentially unused register mapped than a
>> potentially used register unmapped

We have been  "lucky" that it is a ioport and not a mmap region,
otherwise we would have seen a nice oops :).

>
> My concern is that the region request could fail due to a conflict with
> another device, if the physical I/O region is only 8 and we try to
> request 9.

I do not think that this is the case, if you check the top of the file
you can see how there are many other definitions for registers. I
expect that SMBIOSIZE=8 is just the original author being
conservative.

Of course I cannot say that there is one platform where one extra
ioport can cause a conflict, but I believe that we must request all
the ports that we will use.


Regards!
>
> --
> Jean Delvare
> SUSE L3 Support
Jean Delvare Jan. 31, 2017, 1:42 p.m. UTC | #5
Hi Ricardo, Wolfram,

On Fri, 27 Jan 2017 15:59:30 +0100, Ricardo Ribalda Delgado wrote:
> Since '701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")' we
> are using the SMBSLVCNT register at offset 0x8. We need to request it.
> 
> Fixes: 701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
> Please note, not tested on hardware.
>  drivers/i2c/busses/i2c-piix4.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
> index e34d82e79b98..73cc6799cc59 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -58,7 +58,7 @@
>  #define SMBSLVDAT	(0xC + piix4_smba)
>  
>  /* count for request_region */
> -#define SMBIOSIZE	8
> +#define SMBIOSIZE	9
>  
>  /* PCI Address Constants */
>  #define SMBBA		0x090

I checked all the datasheets I have access to, and it should be good.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Wolfram Sang Feb. 9, 2017, 4:14 p.m. UTC | #6
On Fri, Jan 27, 2017 at 03:59:30PM +0100, Ricardo Ribalda Delgado wrote:
> Since '701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")' we
> are using the SMBSLVCNT register at offset 0x8. We need to request it.
> 
> Fixes: 701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>

Applied to for-current, thanks!
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index e34d82e79b98..73cc6799cc59 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -58,7 +58,7 @@ 
 #define SMBSLVDAT	(0xC + piix4_smba)
 
 /* count for request_region */
-#define SMBIOSIZE	8
+#define SMBIOSIZE	9
 
 /* PCI Address Constants */
 #define SMBBA		0x090