Commit f5225a3
bus: mhi: ep: Fix chained transfer handling in read path
The mhi_ep_read_channel function incorrectly assumes the End of Transfer
(EOT) bit is present for each packet in a chained transactions, causing
it to advance mhi_chan->rd_offset beyond wr_offset during host-to-device
transfers when EOT has not yet arrived. This leads to access of unmapped
host memory, causing IOMMU faults and processing of stale TREs.
Modify the loop condition to ensure mhi_queue is not empty, allowing the
function to process only valid TREs up to the current write pointer to
prevent premature reads and ensure safe traversal of chained TREs.
Due to this change, buf_left needs to be removed from the while loop
condition to avoid exiting prematurely before reading the ring completely,
and also remove write_offset since it will always be zero because the new
cache buffer is allocated every time.
Fixes: 5301258 ("bus: mhi: ep: Add support for reading from the host")
Co-developed-by: Akhil Vinod <[email protected]>
Signed-off-by: Akhil Vinod <[email protected]>
Signed-off-by: Sumit Kumar <[email protected]>
[mani: reworded description slightly]
Signed-off-by: Manivannan Sadhasivam <[email protected]>
Reviewed-by: Krishna Chaitanya Chundru <[email protected]>
Cc: [email protected]
Link: https://patch.msgid.link/[email protected]1 parent d5411ed commit f5225a3
1 file changed
+12
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
411 | 410 | | |
412 | | - | |
413 | 411 | | |
414 | 412 | | |
415 | | - | |
416 | | - | |
417 | 413 | | |
418 | 414 | | |
419 | 415 | | |
| |||
426 | 422 | | |
427 | 423 | | |
428 | 424 | | |
429 | | - | |
| 425 | + | |
430 | 426 | | |
431 | 427 | | |
432 | 428 | | |
433 | 429 | | |
434 | 430 | | |
435 | | - | |
| 431 | + | |
436 | 432 | | |
437 | 433 | | |
438 | 434 | | |
439 | | - | |
440 | 435 | | |
441 | 436 | | |
442 | 437 | | |
443 | 438 | | |
444 | 439 | | |
445 | 440 | | |
446 | | - | |
| 441 | + | |
447 | 442 | | |
448 | 443 | | |
449 | 444 | | |
| |||
459 | 454 | | |
460 | 455 | | |
461 | 456 | | |
462 | | - | |
463 | 457 | | |
464 | 458 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 459 | + | |
469 | 460 | | |
470 | | - | |
471 | | - | |
| 461 | + | |
| 462 | + | |
472 | 463 | | |
473 | 464 | | |
474 | 465 | | |
| |||
502 | 493 | | |
503 | 494 | | |
504 | 495 | | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
514 | 501 | | |
515 | 502 | | |
516 | 503 | | |
| |||
0 commit comments