Re: [RFC 1/2] i2c: designware: Add missing locks

Andy Shevchenko
2021-12-23T15:51:32Z

On Wed, Dec 22, 2021 at 10:45:57AM +0100, Jan Dabros wrote:
> All accesses to controller's registers should be protected on
> probe, disable and xfer paths. This is needed for i2c bus controllers
> that are shared with but not controlled by kernel.

...

> + ret = i2c_dw_acquire_lock(dev);
> + if (ret)
> + return ret;
> +
> ret = regmap_read(dev->map, DW_IC_COMP_PARAM_1, &param);
> if (ret)
> return ret;
> + i2c_dw_release_lock(dev);

Not sure this part is fully correct. Please, fix the leakage.

...

> + ret = i2c_dw_acquire_lock(dev);
> + if (ret)
> + return;
>
> /* Disable controller */
> __i2c_dw_disable(dev);
> @@ -614,6 +624,8 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)
> /* Disable all interrupts */
> regmap_write(dev->map, DW_IC_INTR_MASK, 0);
> regmap_read(dev->map, DW_IC_CLR_INTR, &dummy);

> + i2c_dw_release_lock(dev);

Not enough context here, bu I believe there is the same issue(s).

--
With Best Regards,
Andy Shevchenko