提交 17ba1e87 编写于 作者: J Jan Dabros 提交者: Wolfram Sang

i2c: designware: Fix improper usage of readl

Kernel test robot reported incorrect type in argument 1 of readl(), but
more importantly it brought attention that MMIO accessor shouldn't be
used in this case, since req->hdr.status is part of a command-response
buffer in system memory.

Since its value may be altered by PSP outside of the scope of current
thread (somehow similar to IRQ handler case), we need to use
READ_ONCE() to ensure compiler won't optimize this call.

Fix also 'status' variable type to reflect that corresponding field in
command-response buffer is platform-independent u32.

Fixes: 78d5e9e2 ("i2c: designware: Add AMD PSP I2C bus support")
Signed-off-by: NJan Dabros <jsd@semihalf.com>
Reported-by: Nkernel test robot <lkp@intel.com>
Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: NWolfram Sang <wsa@kernel.org>
上级 d8703554
......@@ -160,9 +160,10 @@ static int psp_send_cmd(struct psp_i2c_req *req)
/* Helper to verify status returned by PSP */
static int check_i2c_req_sts(struct psp_i2c_req *req)
{
int status;
u32 status;
status = readl(&req->hdr.status);
/* Status field in command-response buffer is updated by PSP */
status = READ_ONCE(req->hdr.status);
switch (status) {
case PSP_I2C_REQ_STS_OK:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册