Skip to content

Commit 31a1fb3

Browse files
houlz0507Sasha Levin
authored andcommitted
accel/amdxdna: Fix tail-pointer polling in mailbox_get_msg()
[ Upstream commit cd77d5a ] In mailbox_get_msg(), mailbox_reg_read_non_zero() is called to poll for a non-zero tail pointer. This assumed that a zero value indicates an error. However, certain corner cases legitimately produce a zero tail pointer. To handle these cases, remove mailbox_reg_read_non_zero(). The zero tail pointer will be treated as a valid rewind event. Reviewed-by: Maciej Falkowski <maciej.falkowski@linux.intel.com> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://patch.msgid.link/20251204181603.793824-1-lizhi.hou@amd.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6ca4647 commit 31a1fb3

1 file changed

Lines changed: 1 addition & 18 deletions

File tree

drivers/accel/amdxdna/amdxdna_mailbox.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,6 @@ static u32 mailbox_reg_read(struct mailbox_channel *mb_chann, u32 mbox_reg)
112112
return readl(ringbuf_addr);
113113
}
114114

115-
static int mailbox_reg_read_non_zero(struct mailbox_channel *mb_chann, u32 mbox_reg, u32 *val)
116-
{
117-
struct xdna_mailbox_res *mb_res = &mb_chann->mb->res;
118-
void __iomem *ringbuf_addr = mb_res->mbox_base + mbox_reg;
119-
int ret, value;
120-
121-
/* Poll till value is not zero */
122-
ret = readx_poll_timeout(readl, ringbuf_addr, value,
123-
value, 1 /* us */, 100);
124-
if (ret < 0)
125-
return ret;
126-
127-
*val = value;
128-
return 0;
129-
}
130-
131115
static inline void
132116
mailbox_set_headptr(struct mailbox_channel *mb_chann, u32 headptr_val)
133117
{
@@ -288,8 +272,7 @@ static int mailbox_get_msg(struct mailbox_channel *mb_chann)
288272
u32 start_addr;
289273
int ret;
290274

291-
if (mailbox_reg_read_non_zero(mb_chann, mb_chann->res[CHAN_RES_I2X].mb_tail_ptr_reg, &tail))
292-
return -EINVAL;
275+
tail = mailbox_get_tailptr(mb_chann, CHAN_RES_I2X);
293276
head = mb_chann->i2x_head;
294277
ringbuf_size = mailbox_get_ringbuf_size(mb_chann, CHAN_RES_I2X);
295278
start_addr = mb_chann->res[CHAN_RES_I2X].rb_start_addr;

0 commit comments

Comments
 (0)