dma_addr_t xfer_dma, resp_dma, ibi_status_dma, ibi_data_dma;
unsigned int xfer_entries, ibi_status_entries, ibi_chunks_total;
unsigned int xfer_struct_sz, resp_struct_sz, ibi_status_sz, ibi_chunk_sz;
- unsigned int done_ptr, ibi_chunk_ptr, xfer_space;
+ unsigned int xfer_alloc_sz, done_ptr, ibi_chunk_ptr, xfer_space;
struct hci_xfer **src_xfers;
struct completion op_done;
};
rh = &rings->headers[i];
if (rh->xfer)
- dma_free_coherent(rings->sysdev,
- rh->xfer_struct_sz * rh->xfer_entries,
- rh->xfer, rh->xfer_dma);
- if (rh->resp)
- dma_free_coherent(rings->sysdev,
- rh->resp_struct_sz * rh->xfer_entries,
- rh->resp, rh->resp_dma);
+ dma_free_coherent(rings->sysdev, rh->xfer_alloc_sz, rh->xfer, rh->xfer_dma);
kfree(rh->src_xfers);
if (rh->ibi_status)
dma_free_coherent(rings->sysdev,
dev_dbg(&hci->master.dev,
"xfer_struct_sz = %d, resp_struct_sz = %d",
rh->xfer_struct_sz, rh->resp_struct_sz);
- xfers_sz = rh->xfer_struct_sz * rh->xfer_entries;
+ xfers_sz = round_up(rh->xfer_struct_sz * rh->xfer_entries, 4);
resps_sz = rh->resp_struct_sz * rh->xfer_entries;
+ rh->xfer_alloc_sz = xfers_sz + resps_sz;
- rh->xfer = dma_alloc_coherent(rings->sysdev, xfers_sz,
+ rh->xfer = dma_alloc_coherent(rings->sysdev, rh->xfer_alloc_sz,
&rh->xfer_dma, GFP_KERNEL);
- rh->resp = dma_alloc_coherent(rings->sysdev, resps_sz,
- &rh->resp_dma, GFP_KERNEL);
rh->src_xfers =
kzalloc_objs(*rh->src_xfers, rh->xfer_entries);
ret = -ENOMEM;
- if (!rh->xfer || !rh->resp || !rh->src_xfers)
+ if (!rh->xfer || !rh->src_xfers)
goto err_out;
+ rh->resp = rh->xfer + xfers_sz;
+ rh->resp_dma = rh->xfer_dma + xfers_sz;
/* IBIs */