.. | .. |
---|
206 | 206 | struct rga_iommu_dma_cookie *cookie = domain->iova_cookie; |
---|
207 | 207 | struct iova_domain *iovad = &cookie->iovad; |
---|
208 | 208 | unsigned long shift, iova_len, iova = 0; |
---|
209 | | -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) |
---|
210 | | - dma_addr_t limit; |
---|
211 | | -#endif |
---|
212 | 209 | |
---|
213 | 210 | shift = iova_shift(iovad); |
---|
214 | 211 | iova_len = size >> shift; |
---|
| 212 | + |
---|
| 213 | +#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) |
---|
215 | 214 | /* |
---|
216 | 215 | * Freeing non-power-of-two-sized allocations back into the IOVA caches |
---|
217 | 216 | * will come back to bite us badly, so we have to waste a bit of space |
---|
.. | .. |
---|
220 | 219 | */ |
---|
221 | 220 | if (iova_len < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1))) |
---|
222 | 221 | iova_len = roundup_pow_of_two(iova_len); |
---|
| 222 | +#endif |
---|
223 | 223 | |
---|
224 | 224 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) |
---|
225 | 225 | dma_limit = min_not_zero(dma_limit, dev->bus_dma_limit); |
---|
.. | .. |
---|
231 | 231 | if (domain->geometry.force_aperture) |
---|
232 | 232 | dma_limit = min(dma_limit, (u64)domain->geometry.aperture_end); |
---|
233 | 233 | |
---|
234 | | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) |
---|
235 | | - iova = alloc_iova_fast(iovad, iova_len, dma_limit >> shift, true); |
---|
| 234 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 19, 111) && \ |
---|
| 235 | + LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) |
---|
| 236 | + iova = alloc_iova_fast(iovad, iova_len, |
---|
| 237 | + min_t(dma_addr_t, dma_limit >> shift, iovad->end_pfn), |
---|
| 238 | + true); |
---|
236 | 239 | #else |
---|
237 | | - limit = min_t(dma_addr_t, dma_limit >> shift, iovad->end_pfn); |
---|
238 | | - |
---|
239 | | - iova = alloc_iova_fast(iovad, iova_len, limit, true); |
---|
| 240 | + iova = alloc_iova_fast(iovad, iova_len, dma_limit >> shift, true); |
---|
240 | 241 | #endif |
---|
241 | 242 | |
---|
242 | 243 | return (dma_addr_t)iova << shift; |
---|
.. | .. |
---|
424 | 425 | if (dma_buf != NULL) { |
---|
425 | 426 | get_dma_buf(dma_buf); |
---|
426 | 427 | } else { |
---|
427 | | - pr_err("dma_buf is Invalid[%p]\n", dma_buf); |
---|
| 428 | + pr_err("dma_buf is invalid[%p]\n", dma_buf); |
---|
428 | 429 | return -EINVAL; |
---|
429 | 430 | } |
---|
430 | 431 | |
---|
431 | 432 | attach = dma_buf_attach(dma_buf, rga_dev); |
---|
432 | 433 | if (IS_ERR(attach)) { |
---|
433 | | - pr_err("Failed to attach dma_buf\n"); |
---|
434 | | - ret = -EINVAL; |
---|
| 434 | + ret = PTR_ERR(attach); |
---|
| 435 | + pr_err("Failed to attach dma_buf, ret[%d]\n", ret); |
---|
435 | 436 | goto err_get_attach; |
---|
436 | 437 | } |
---|
437 | 438 | |
---|
438 | 439 | sgt = dma_buf_map_attachment(attach, dir); |
---|
439 | 440 | if (IS_ERR(sgt)) { |
---|
440 | | - pr_err("Failed to map src attachment\n"); |
---|
441 | | - ret = -EINVAL; |
---|
| 441 | + ret = PTR_ERR(sgt); |
---|
| 442 | + pr_err("Failed to map attachment, ret[%d]\n", ret); |
---|
442 | 443 | goto err_get_sgt; |
---|
443 | 444 | } |
---|
444 | 445 | |
---|
.. | .. |
---|
474 | 475 | |
---|
475 | 476 | dma_buf = dma_buf_get(fd); |
---|
476 | 477 | if (IS_ERR(dma_buf)) { |
---|
477 | | - pr_err("dma_buf_get fail fd[%d]\n", fd); |
---|
478 | | - ret = -EINVAL; |
---|
| 478 | + ret = PTR_ERR(dma_buf); |
---|
| 479 | + pr_err("Fail to get dma_buf from fd[%d], ret[%d]\n", fd, ret); |
---|
479 | 480 | return ret; |
---|
480 | 481 | } |
---|
481 | 482 | |
---|
482 | 483 | attach = dma_buf_attach(dma_buf, rga_dev); |
---|
483 | 484 | if (IS_ERR(attach)) { |
---|
484 | | - pr_err("Failed to attach dma_buf\n"); |
---|
485 | | - ret = -EINVAL; |
---|
| 485 | + ret = PTR_ERR(attach); |
---|
| 486 | + pr_err("Failed to attach dma_buf, ret[%d]\n", ret); |
---|
486 | 487 | goto err_get_attach; |
---|
487 | 488 | } |
---|
488 | 489 | |
---|
489 | 490 | sgt = dma_buf_map_attachment(attach, dir); |
---|
490 | 491 | if (IS_ERR(sgt)) { |
---|
491 | | - pr_err("Failed to map src attachment\n"); |
---|
492 | | - ret = -EINVAL; |
---|
| 492 | + ret = PTR_ERR(sgt); |
---|
| 493 | + pr_err("Failed to map attachment, ret[%d]\n", ret); |
---|
493 | 494 | goto err_get_sgt; |
---|
494 | 495 | } |
---|
495 | 496 | |
---|