Skip to contentSkip to conversation

drm/mediatek: stop iterating dma addresses when sg_dma_len() == 0

PATCH Applied Anand K Mistry 2 participants 11 messages Apr 20, 2020 – May 9, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/mediatek: stop iterating dma addresses when sg_dma_len() == 0

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +3 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
 	expected = sg_dma_address(sg->sgl);
 	for_each_sg(sg->sgl, s, sg->nents, i) {
+		if (!sg_dma_len(s))
+			break;
+
 		if (sg_dma_address(s) != expected) {
 			DRM_ERROR("sg_table is not contiguous");
 			ret = -EINVAL;
Signature · 7 lines
2.26.1.301.g55bc3eb7cb9-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#1 lore raw

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 15 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

Regards,
Chun-Kuang.

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

Quoted 4 lines

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 20 lines · Chun-Kuang Hu

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 16 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/

So breaking on the first sg_dma_len(sg) == 0 appears to be (one of) the documented approach.

Quoted 16 lines

Regards,
Chun-Kuang.

Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Reviewed-by
#3 lore raw

Hi, Anand,

Anand K. Mistry <[email protected]> 於 2020年4月28日 週二 上午9:54寫道:

Quoted 38 lines · Chun-Kuang Hu
Quoted 20 lines

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 16 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/

Quoted 3 lines

So breaking on the first sg_dma_len(sg) == 0 appears to be (one of) the documented approach.

Okay, you're right. So

Quoted 12 lines
Quoted 12 lines

Regards,
Chun-Kuang.

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer
#4 lore raw

Hi, Anand,

Chun-Kuang Hu <[email protected]> 於 2020年4月29日 週三 上午12:37寫道:

Quoted 16 lines

Hi, Anand,

Anand K. Mistry <[email protected]> 於 2020年4月28日 週二 上午9:54寫道:

Quoted 12 lines · Chun-Kuang Hu
Quoted 10 lines

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 6 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

Author should sign off this patch, please give a sign off tag by author.

Regards,
Chun-Kuang.

Quoted 26 lines
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/

Quoted 24 lines
Quoted 3 lines

So breaking on the first sg_dma_len(sg) == 0 appears to be (one of) the documented approach.

Okay, you're right. So

Quoted 16 lines
Quoted 16 lines

Regards,
Chun-Kuang.

Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
Quoted 15 lines · Chun-Kuang Hu

Hi, Anand,

Chun-Kuang Hu <[email protected]> 於 2020年4月29日 週三 上午12:37寫道:

Quoted 11 lines

Hi, Anand,

Anand K. Mistry <[email protected]> 於 2020年4月28日 週二 上午9:54寫道:

Quoted 7 lines · Chun-Kuang Hu
Quoted 5 lines

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

Author should sign off this patch, please give a sign off tag by author.

Sorry, email issues meant i sent the patch from a different account. Should I re-send the
patch from the same account as the sign-off line? I'm still working my way through the kernel patch process.

Quoted 54 lines

Regards,
Chun-Kuang.

Quoted 50 lines
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/

Quoted 3 lines

So breaking on the first sg_dma_len(sg) == 0 appears to be (one of) the documented approach.

Okay, you're right. So

Quoted 16 lines
Quoted 16 lines

Regards,
Chun-Kuang.

Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#6 lore raw

Hi, Anand:

Anand Mistry <[email protected]> 於 2020年5月6日 週三 下午7:03寫道:

Quoted 21 lines · Chun-Kuang Hu
Quoted 19 lines

Hi, Anand,

Chun-Kuang Hu <[email protected]> 於 2020年4月29日 週三 上午12:37寫道:

Quoted 15 lines

Hi, Anand,

Anand K. Mistry <[email protected]> 於 2020年4月28日 週二 上午9:54寫道:

Quoted 11 lines · Chun-Kuang Hu
Quoted 9 lines

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 5 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Author should sign off this patch, please give a sign off tag by author.

Sorry, email issues meant i sent the patch from a different account. Should I re-send the
patch from the same account as the sign-off line? I'm still working my way through the kernel patch process.

If you want to use chromium account, you could simply reply this email with a sign-off-by tag of chromium account.

Regards,
Chun-Kuang.

Quoted 50 lines
Quoted 50 lines

Regards,
Chun-Kuang.

Quoted 46 lines
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/

Quoted 3 lines

So breaking on the first sg_dma_len(sg) == 0 appears to be (one of) the documented approach.

Okay, you're right. So

Quoted 12 lines
Quoted 12 lines

Regards,
Chun-Kuang.

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 29 lines · Chun-Kuang Hu

Hi, Anand:

Anand Mistry <[email protected]> 於 2020年5月6日 週三 下午7:03寫道:

Quoted 25 lines · Chun-Kuang Hu
Quoted 22 lines

Hi, Anand,

Chun-Kuang Hu <[email protected]> 於 2020年4月29日 週三 上午12:37寫道:

Quoted 16 lines

Hi, Anand,

Anand K. Mistry <[email protected]> 於 2020年4月28日 週二 上午9:54寫道:

Quoted 12 lines · Chun-Kuang Hu
Quoted 10 lines

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 6 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

Author should sign off this patch, please give a sign off tag by author.

Quoted 8 lines
Quoted 5 lines

Sorry, email issues meant i sent the patch from a different account. Should I re-send the
patch from the same account as the sign-off line? I'm still working my way through the kernel patch process.

If you want to use chromium account, you could simply reply this email with a sign-off-by tag of chromium account.

Ack. This is fine for now. I'll try doing it better with the next patch.

Quoted 58 lines

Regards,
Chun-Kuang.

Quoted 54 lines
Quoted 54 lines

Regards,
Chun-Kuang.

Quoted 50 lines
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/

Quoted 3 lines

So breaking on the first sg_dma_len(sg) == 0 appears to be (one of) the documented approach.

Okay, you're right. So

Quoted 16 lines
Quoted 16 lines

Regards,
Chun-Kuang.

Quoted 12 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#8 lore raw
In reply to Chun-Kuang Hu
Quoted 6 lines · Chun-Kuang Hu

Hi, Anand:

Anand Mistry <[email protected]> 於 2020年5月6日 週三 下午7:03寫道:

Quoted 2 lines

On Wed, May 6, 2020 at 10:25 AM Chun-Kuang Hu <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines

Hi, Anand,

Chun-Kuang Hu <[email protected]> 於 2020年4月29日 週三 上午12:37寫道:

Quoted 6 lines

Hi, Anand,

Anand K. Mistry <[email protected]> 於 2020年4月28日 週二 上午9:54寫道:

Quoted 2 lines

On Sun, 26 Apr 2020 at 18:04, Chun-Kuang Hu <

Quoted 6 lines · [email protected]> wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 2 lines

If dma_map_sg() merges pages when creating the mapping, only

the first

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

entries will have a valid sg_dma_address() and sg_dma_len(),

followed by

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

entries with sg_dma_len() == 0.

Author should sign off this patch, please give a sign off tag by

author.

Quoted 9 lines
Quoted 6 lines

Sorry, email issues meant i sent the patch from a different account. Should I re-send the
patch from the same account as the sign-off line? I'm still working my way through the kernel patch process.

If you want to use chromium account, you could simply reply this email with a sign-off-by tag of chromium account.

Ack. As path of least resistance, here:

Quoted 5 lines

Regards,
Chun-Kuang.

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Regards,
Chun-Kuang.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Review

Quoted 5 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/mediatek/mtk_drm_gem.c

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object

Quoted 4 lines

index b04a3c2b111e09..f8fd8b98c30e3d 100644

drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
@@ -224,6 +224,9 @@ struct drm_gem_object

*mtk_gem_prime_import_sg_table(struct drm_device *dev,

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object · line 227

Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been

done

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

* to get bus addresses of each of the SG entries and their

lengths.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg)

which

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

* is 0.
*/

So breaking on the first sg_dma_len(sg) == 0 appears to be (one

of)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

the documented approach.

Okay, you're right. So

Quoted 1 line
Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Regards,
Chun-Kuang.

Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -0
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not

contiguous");

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -1
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Applied
#9 lore raw

Hi, Anand:

Anand Mistry <[email protected]> 於 2020年5月7日 週四 下午7:56寫道:

Quoted 37 lines · Chun-Kuang Hu
Quoted 35 lines

Hi, Anand:

Anand Mistry <[email protected]> 於 2020年5月6日 週三 下午7:03寫道:

Quoted 30 lines · Chun-Kuang Hu
Quoted 15 lines

Hi, Anand,

Chun-Kuang Hu <[email protected]> 於 2020年4月29日 週三 上午12:37寫道:

Quoted 11 lines

Hi, Anand,

Anand K. Mistry <[email protected]> 於 2020年4月28日 週二 上午9:54寫道:

Quoted 7 lines · Chun-Kuang Hu
Quoted 5 lines

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

Author should sign off this patch, please give a sign off tag by author.

Sorry, email issues meant i sent the patch from a different account. Should I re-send the
patch from the same account as the sign-off line? I'm still working my way through the kernel patch process.

Quoted 7 lines
Quoted 2 lines

If you want to use chromium account, you could simply reply this email with a sign-off-by tag of chromium account.

Ack. As path of least resistance, here:

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

Quoted 55 lines
Quoted 55 lines

Regards,
Chun-Kuang.

Quoted 50 lines
Quoted 50 lines

Regards,
Chun-Kuang.

Quoted 46 lines
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
index b04a3c2b111e09..f8fd8b98c30e3d 100644
@@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
 
Quoted 6 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/

Quoted 3 lines

So breaking on the first sg_dma_len(sg) == 0 appears to be (one of) the documented approach.

Okay, you're right. So

Quoted 12 lines
Quoted 12 lines

Regards,
Chun-Kuang.

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
+
                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;
--

2.26.1.301.g55bc3eb7cb9-goog

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw
In reply to Chun-Kuang Hu
Quoted 21 lines · Chun-Kuang Hu

Hi, Anand:

Anand K Mistry <[email protected]> 於 2020年4月20日 週一 下午2:09寫道:

Review

Quoted 11 lines

If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0.

---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/mediatek/mtk_drm_gem.c

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object

Quoted 4 lines

index b04a3c2b111e09..f8fd8b98c30e3d 100644

drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -0
@@ -224,6 +224,9 @@ struct drm_gem_object

*mtk_gem_prime_import_sg_table(struct drm_device *dev,

Quoted 1 line
Quoted 7 lines

drivers/gpu/drm/mediatek/mtk_drm_gem.c struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · line 228

Quoted 4 lines
        expected = sg_dma_address(sg->sgl);
        for_each_sg(sg->sgl, s, sg->nents, i) {
drivers/gpu/drm/mediatek/mtk_drm_gem.c +2 -0
+               if (!sg_dma_len(s))
+                       break;

I think this should be 'continue'

scatterlist.h has the comment:
/*
* These macros should be used after a dma_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries dma_map_sg
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/

So breaking on the first sg_dma_len(sg) == 0 appears to be (one of) the documented approach.

Quoted 16 lines

Regards,
Chun-Kuang.

Quoted 12 lines

+

                if (sg_dma_address(s) != expected) {
                        DRM_ERROR("sg_table is not contiguous");
                        ret = -EINVAL;

--
2.26.1.301.g55bc3eb7cb9-goog

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel