On Fri, Apr 05, 2019 at 06:25:13AM -0700, Guenter Roeck wrote:
> On 4/5/19 1:46 AM, John Garry wrote:
> >On 05/04/2019 08:47, John Garry wrote:
> >>On 04/04/2019 19:33, Guenter Roeck wrote:
> >>>Super-IO accesses may fail on a system with no or unmapped LPC bus.
> >>>
> >
> >BTW, these may still require attention:
> >
> >sch56xx-common
> >smsc47m1
>
> Those two already call request_muxed_region() in superio_enter().
> Though error handling in the latter is less than perfect - I may send
> a patch to fix it.
>
... and that was because this patch has the wrong subject, and its error
handling is incomplete. I'll resend.
Guenter
> >w83627hf > vt1211
>
> I missed those two. Patches will follow.
>
> Thanks,
> Guenter
>
> >
> >Thanks,
> >John
> >
> >>>Also, other drivers may attempt to access the LPC bus at the same time,
> >>>resulting in undefined behavior.
> >>>
> >>>Use request_muxed_region() to ensure that IO access on the requested
> >>>address space is supported, and to ensure that access by multiple drivers
> >>>is synchronized.
> >>>
> >>>Fixes: 8d5d45fb1468 ("I2C: Move hwmon drivers (2/3)")
> >>>Reported-by: Kefeng Wang <[email protected]>
> >>>Reported-by: John Garry <[email protected]>
> >>>Cc: John Garry <[email protected]>
> >>
> >>Acked-by: John Garry <[email protected]>
> >>
> >>>Signed-off-by: Guenter Roeck <[email protected]>
> >>>---
> >>> drivers/hwmon/smsc47m1.c | 13 +++++++++++--
> >>> 1 file changed, 11 insertions(+), 2 deletions(-)
> >>>
> >>>diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
> >>>index c7b6a425e2c0..0736ca6a3aee 100644
> >>>--- a/drivers/hwmon/smsc47m1.c
> >>>+++ b/drivers/hwmon/smsc47m1.c
> >>>@@ -73,16 +73,21 @@ superio_inb(int reg)
> >>> /* logical device for fans is 0x0A */
> >>> #define superio_select() superio_outb(0x07, 0x0A)
> >>>
> >>>-static inline void
> >>>+static inline int
> >>> superio_enter(void)
> >>> {
> >>>+ if (!request_muxed_region(REG, 2, DRVNAME))
> >>>+ return -EBUSY;
> >>>+
> >>> outb(0x55, REG);
> >>>+ return 0;
> >>> }
> >>>
> >>> static inline void
> >>> superio_exit(void)
> >>> {
> >>> outb(0xAA, REG);
> >>>+ release_region(REG, 2);
> >>> }
> >>>
> >>> #define SUPERIO_REG_ACT 0x30
> >>>@@ -531,8 +536,12 @@ static int __init smsc47m1_find(struct
> >>>smsc47m1_sio_data *sio_data)
> >>> {
> >>> u8 val;
> >>> unsigned short addr;
> >>>+ int err;
> >>>+
> >>>+ err = superio_enter();
> >>>+ if (err)
> >>>+ return err;
> >>>
> >>>- superio_enter();
> >>> val = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
> >>>
> >>> /*
> >>>
> >>
> >
> >
> >
>