accel/habanalabs: fix SG table creation for dma-buf mapping
authorTomer Tayar <ttayar@habana.ai>
Thu, 17 Aug 2023 18:47:49 +0000 (21:47 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Mon, 9 Oct 2023 09:37:22 +0000 (12:37 +0300)
commitbb644f61970ad44147c9466b0cb99a028de02138
tree8242534346f3350cb74176b44edab030cee9f179
parentba24b5ec7847d4126fc37cabd4cef3579d9ca806
accel/habanalabs: fix SG table creation for dma-buf mapping

In some cases the calculated number of required entries for the dma-buf
SG table is wrong. For example, if the page size is larger than both the
dma max segment size of the importer device and from the exported side,
or if the exported size is part of a phys_pg_pack that is composed of
several pages.
In these cases, redundant entries will be added to the SG table.

Modify the method that the number of entries is calculated, and the way
they are prepared.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/accel/habanalabs/common/memory.c