MHI Endpoint

============
 
 - Increment the rd_offset after writing the buffer to avoid MHI host accessing
   the incomplete/wrong buffer element.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEZ6VDKoFIy9ikWCeXVZ8R5v6RzvUFAmgkX2wACgkQVZ8R5v6R
 zvXKMAf6AmmnJrSKXBWkEP8LcPlO4Ml/qaQR6Iym50gpc4dARdZTDY0qMxFDwlgV
 Wl1Ppqgn3gdxfq85F2HTjlzXnpXzJPEmtQoQ4DdF0Lmv7T628cpwu24v7w2DOInZ
 flnT4kOpGxMuG6nzRdA0VJ8MYnOZzE9wvM2xNHsgLCDIMFi+iZAi1XsCE2RQc1SQ
 4/XqS/aDTlNkdUp5QcPERLn8mwpqlUmvg9ZBjBeczdZ+I0mnUHjr8sty/oaRVaNq
 CxRZpVN5w3SK1CNwtZTvgVvloRHD+EZxymx4k6zRTtL29PZaYOdI5g1+zcb2XnrC
 giSNTVym9FJhxuwqoVDYFmVRFIjp2w==
 =J7N1
 -----END PGP SIGNATURE-----

Merge tag 'mhi-fixes-for-v6.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mani/mhi into char-misc-next

Manivannan writes:

MHI Endpoint
============

- Increment the rd_offset after writing the buffer to avoid MHI host accessing
  the incomplete/wrong buffer element.

* tag 'mhi-fixes-for-v6.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mani/mhi:
  bus: mhi: ep: Update read pointer only after buffer is written
This commit is contained in:
Greg Kroah-Hartman 2025-05-21 14:10:37 +02:00
commit 2b0634cc1f

View File

@ -131,19 +131,23 @@ int mhi_ep_ring_add_element(struct mhi_ep_ring *ring, struct mhi_ring_element *e
}
old_offset = ring->rd_offset;
mhi_ep_ring_inc_index(ring);
dev_dbg(dev, "Adding an element to ring at offset (%zu)\n", ring->rd_offset);
buf_info.host_addr = ring->rbase + (old_offset * sizeof(*el));
buf_info.dev_addr = el;
buf_info.size = sizeof(*el);
ret = mhi_cntrl->write_sync(mhi_cntrl, &buf_info);
if (ret)
return ret;
mhi_ep_ring_inc_index(ring);
/* Update rp in ring context */
rp = cpu_to_le64(ring->rd_offset * sizeof(*el) + ring->rbase);
memcpy_toio((void __iomem *) &ring->ring_ctx->generic.rp, &rp, sizeof(u64));
buf_info.host_addr = ring->rbase + (old_offset * sizeof(*el));
buf_info.dev_addr = el;
buf_info.size = sizeof(*el);
return mhi_cntrl->write_sync(mhi_cntrl, &buf_info);
return ret;
}
void mhi_ep_ring_init(struct mhi_ep_ring *ring, enum mhi_ep_ring_type type, u32 id)