* [PATCH] accel/qaic: Fix the for loop used to walk SG table
@ 2024-10-04 19:32 Jeffrey Hugo
2024-10-11 7:25 ` Jacek Lawrynowicz
2024-10-12 21:03 ` Jeffrey Hugo
0 siblings, 2 replies; 3+ messages in thread
From: Jeffrey Hugo @ 2024-10-04 19:32 UTC (permalink / raw)
To: quic_carlv
Cc: ogabbay, linux-arm-msm, dri-devel, jacek.lawrynowicz,
Pranjal Ramajor Asha Kanojiya, Jeffrey Hugo
From: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
Only for_each_sgtable_dma_sg() should be used to walk through a SG table
to grab correct bus address and length pair after calling DMA MAP API on
a SG table as DMA MAP APIs updates the SG table and for_each_sgtable_sg()
walks through the original SG table.
Fixes: ff13be830333 ("accel/qaic: Add datapath")
Fixes: 129776ac2e38 ("accel/qaic: Add control path")
Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
---
drivers/accel/qaic/qaic_control.c | 2 +-
drivers/accel/qaic/qaic_data.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/accel/qaic/qaic_control.c b/drivers/accel/qaic/qaic_control.c
index 9e8a8cbadf6b..d8bdab69f800 100644
--- a/drivers/accel/qaic/qaic_control.c
+++ b/drivers/accel/qaic/qaic_control.c
@@ -496,7 +496,7 @@ static int encode_addr_size_pairs(struct dma_xfer *xfer, struct wrapper_list *wr
nents = sgt->nents;
nents_dma = nents;
*size = QAIC_MANAGE_EXT_MSG_LENGTH - msg_hdr_len - sizeof(**out_trans);
- for_each_sgtable_sg(sgt, sg, i) {
+ for_each_sgtable_dma_sg(sgt, sg, i) {
*size -= sizeof(*asp);
/* Save 1K for possible follow-up transactions. */
if (*size < SZ_1K) {
diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index e86e71c1cdd8..c20eb63750f5 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -184,7 +184,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl
nents = 0;
size = size ? size : PAGE_SIZE;
- for (sg = sgt_in->sgl; sg; sg = sg_next(sg)) {
+ for_each_sgtable_dma_sg(sgt_in, sg, j) {
len = sg_dma_len(sg);
if (!len)
@@ -221,7 +221,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl
/* copy relevant sg node and fix page and length */
sgn = sgf;
- for_each_sgtable_sg(sgt, sg, j) {
+ for_each_sgtable_dma_sg(sgt, sg, j) {
memcpy(sg, sgn, sizeof(*sg));
if (sgn == sgf) {
sg_dma_address(sg) += offf;
@@ -301,7 +301,7 @@ static int encode_reqs(struct qaic_device *qdev, struct bo_slice *slice,
* fence.
*/
dev_addr = req->dev_addr;
- for_each_sgtable_sg(slice->sgt, sg, i) {
+ for_each_sgtable_dma_sg(slice->sgt, sg, i) {
slice->reqs[i].cmd = cmd;
slice->reqs[i].src_addr = cpu_to_le64(slice->dir == DMA_TO_DEVICE ?
sg_dma_address(sg) : dev_addr);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] accel/qaic: Fix the for loop used to walk SG table
2024-10-04 19:32 [PATCH] accel/qaic: Fix the for loop used to walk SG table Jeffrey Hugo
@ 2024-10-11 7:25 ` Jacek Lawrynowicz
2024-10-12 21:03 ` Jeffrey Hugo
1 sibling, 0 replies; 3+ messages in thread
From: Jacek Lawrynowicz @ 2024-10-11 7:25 UTC (permalink / raw)
To: Jeffrey Hugo, quic_carlv
Cc: ogabbay, linux-arm-msm, dri-devel, Pranjal Ramajor Asha Kanojiya
Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
On 10/4/2024 9:32 PM, Jeffrey Hugo wrote:
> From: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
>
> Only for_each_sgtable_dma_sg() should be used to walk through a SG table
> to grab correct bus address and length pair after calling DMA MAP API on
> a SG table as DMA MAP APIs updates the SG table and for_each_sgtable_sg()
> walks through the original SG table.
>
> Fixes: ff13be830333 ("accel/qaic: Add datapath")
> Fixes: 129776ac2e38 ("accel/qaic: Add control path")
> Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
> Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
> Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
> ---
> drivers/accel/qaic/qaic_control.c | 2 +-
> drivers/accel/qaic/qaic_data.c | 6 +++---
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/accel/qaic/qaic_control.c b/drivers/accel/qaic/qaic_control.c
> index 9e8a8cbadf6b..d8bdab69f800 100644
> --- a/drivers/accel/qaic/qaic_control.c
> +++ b/drivers/accel/qaic/qaic_control.c
> @@ -496,7 +496,7 @@ static int encode_addr_size_pairs(struct dma_xfer *xfer, struct wrapper_list *wr
> nents = sgt->nents;
> nents_dma = nents;
> *size = QAIC_MANAGE_EXT_MSG_LENGTH - msg_hdr_len - sizeof(**out_trans);
> - for_each_sgtable_sg(sgt, sg, i) {
> + for_each_sgtable_dma_sg(sgt, sg, i) {
> *size -= sizeof(*asp);
> /* Save 1K for possible follow-up transactions. */
> if (*size < SZ_1K) {
> diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
> index e86e71c1cdd8..c20eb63750f5 100644
> --- a/drivers/accel/qaic/qaic_data.c
> +++ b/drivers/accel/qaic/qaic_data.c
> @@ -184,7 +184,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl
> nents = 0;
>
> size = size ? size : PAGE_SIZE;
> - for (sg = sgt_in->sgl; sg; sg = sg_next(sg)) {
> + for_each_sgtable_dma_sg(sgt_in, sg, j) {
> len = sg_dma_len(sg);
>
> if (!len)
> @@ -221,7 +221,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl
>
> /* copy relevant sg node and fix page and length */
> sgn = sgf;
> - for_each_sgtable_sg(sgt, sg, j) {
> + for_each_sgtable_dma_sg(sgt, sg, j) {
> memcpy(sg, sgn, sizeof(*sg));
> if (sgn == sgf) {
> sg_dma_address(sg) += offf;
> @@ -301,7 +301,7 @@ static int encode_reqs(struct qaic_device *qdev, struct bo_slice *slice,
> * fence.
> */
> dev_addr = req->dev_addr;
> - for_each_sgtable_sg(slice->sgt, sg, i) {
> + for_each_sgtable_dma_sg(slice->sgt, sg, i) {
> slice->reqs[i].cmd = cmd;
> slice->reqs[i].src_addr = cpu_to_le64(slice->dir == DMA_TO_DEVICE ?
> sg_dma_address(sg) : dev_addr);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] accel/qaic: Fix the for loop used to walk SG table
2024-10-04 19:32 [PATCH] accel/qaic: Fix the for loop used to walk SG table Jeffrey Hugo
2024-10-11 7:25 ` Jacek Lawrynowicz
@ 2024-10-12 21:03 ` Jeffrey Hugo
1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Hugo @ 2024-10-12 21:03 UTC (permalink / raw)
To: quic_carlv
Cc: ogabbay, linux-arm-msm, dri-devel, jacek.lawrynowicz,
Pranjal Ramajor Asha Kanojiya
On 10/4/2024 1:32 PM, Jeffrey Hugo wrote:
> From: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
>
> Only for_each_sgtable_dma_sg() should be used to walk through a SG table
> to grab correct bus address and length pair after calling DMA MAP API on
> a SG table as DMA MAP APIs updates the SG table and for_each_sgtable_sg()
> walks through the original SG table.
>
> Fixes: ff13be830333 ("accel/qaic: Add datapath")
> Fixes: 129776ac2e38 ("accel/qaic: Add control path")
> Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
> Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
> Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Pushed to drm-misc-fixes.
-Jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-12 21:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-04 19:32 [PATCH] accel/qaic: Fix the for loop used to walk SG table Jeffrey Hugo
2024-10-11 7:25 ` Jacek Lawrynowicz
2024-10-12 21:03 ` Jeffrey Hugo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox