drivers: rtio: bugfix
fixes the following: - If a read SQE generates a CQE with an error before a buffer has been allocated, the flags of the sqe are not correctly translated into cqe flags. - rtio_cqe_get_mempool_buffer(...) sets the *buff to a non-zero value, even if no buffer is assigned Signed-off-by: Florian Weber <Florian.Weber@live.de>
This commit is contained in:
parent
f039ad57df
commit
b4667e0445
@ -1137,10 +1137,14 @@ static inline uint32_t rtio_cqe_compute_flags(struct rtio_iodev_sqe *iodev_sqe)
|
||||
if (iodev_sqe->sqe.op == RTIO_OP_RX && iodev_sqe->sqe.flags & RTIO_SQE_MEMPOOL_BUFFER) {
|
||||
struct rtio *r = iodev_sqe->r;
|
||||
struct sys_mem_blocks *mem_pool = r->block_pool;
|
||||
int blk_index = (iodev_sqe->sqe.rx.buf - mem_pool->buffer) >>
|
||||
mem_pool->info.blk_sz_shift;
|
||||
int blk_count = iodev_sqe->sqe.rx.buf_len >> mem_pool->info.blk_sz_shift;
|
||||
unsigned int blk_index = 0;
|
||||
unsigned int blk_count = 0;
|
||||
|
||||
if (iodev_sqe->sqe.rx.buf) {
|
||||
blk_index = (iodev_sqe->sqe.rx.buf - mem_pool->buffer) >>
|
||||
mem_pool->info.blk_sz_shift;
|
||||
blk_count = iodev_sqe->sqe.rx.buf_len >> mem_pool->info.blk_sz_shift;
|
||||
}
|
||||
flags = RTIO_CQE_FLAG_PREP_MEMPOOL(blk_index, blk_count);
|
||||
}
|
||||
#else
|
||||
@ -1173,15 +1177,21 @@ static inline int z_impl_rtio_cqe_get_mempool_buffer(const struct rtio *r, struc
|
||||
{
|
||||
#ifdef CONFIG_RTIO_SYS_MEM_BLOCKS
|
||||
if (RTIO_CQE_FLAG_GET(cqe->flags) == RTIO_CQE_FLAG_MEMPOOL_BUFFER) {
|
||||
int blk_idx = RTIO_CQE_FLAG_MEMPOOL_GET_BLK_IDX(cqe->flags);
|
||||
int blk_count = RTIO_CQE_FLAG_MEMPOOL_GET_BLK_CNT(cqe->flags);
|
||||
unsigned int blk_idx = RTIO_CQE_FLAG_MEMPOOL_GET_BLK_IDX(cqe->flags);
|
||||
unsigned int blk_count = RTIO_CQE_FLAG_MEMPOOL_GET_BLK_CNT(cqe->flags);
|
||||
uint32_t blk_size = rtio_mempool_block_size(r);
|
||||
|
||||
*buff = r->block_pool->buffer + blk_idx * blk_size;
|
||||
*buff_len = blk_count * blk_size;
|
||||
__ASSERT_NO_MSG(*buff >= r->block_pool->buffer);
|
||||
__ASSERT_NO_MSG(*buff <
|
||||
|
||||
if (blk_count > 0) {
|
||||
*buff = r->block_pool->buffer + blk_idx * blk_size;
|
||||
|
||||
__ASSERT_NO_MSG(*buff >= r->block_pool->buffer);
|
||||
__ASSERT_NO_MSG(*buff <
|
||||
r->block_pool->buffer + blk_size * r->block_pool->info.num_blocks);
|
||||
} else {
|
||||
*buff = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return -EINVAL;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user