CHROMIUM: MALI: Set max dma segment size

BUG=b:142101848
TEST=build kernel with CONFIG_DMA_API_DEBUG, CONFIG_DMA_API_DEBUG_SG
     turned on, flash to kukui, and check that there's no warning on
     boot.

Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1905194
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
(cherry picked from commit 3a2dd0ffb7b719ca341f040d6f4ced4ff98c95d1)
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>

Change-Id: Ie1afcc95f0750d828189f5d6f5ef8f48fa4a5e96
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
diff --git a/drivers/gpu/arm/midgard/mali_kbase_device.c b/drivers/gpu/arm/midgard/mali_kbase_device.c
index a265082..92a445a 100644
--- a/drivers/gpu/arm/midgard/mali_kbase_device.c
+++ b/drivers/gpu/arm/midgard/mali_kbase_device.c
@@ -201,6 +201,19 @@
 	if (err)
 		goto dma_set_mask_failed;
 
+	if (!kbdev->dev->dma_parms) {
+		kbdev->dev->dma_parms = devm_kzalloc(kbdev->dev,
+				sizeof(*kbdev->dev->dma_parms), GFP_KERNEL);
+		if (!kbdev->dev->dma_parms) {
+			err = -ENOMEM;
+			goto dma_set_mask_failed;
+		}
+	}
+	err = dma_set_max_seg_size(kbdev->dev,
+			DMA_BIT_MASK(kbdev->gpu_props.mmu.pa_bits));
+	if (err)
+		goto dma_set_mask_failed;
+
 	kbdev->nr_hw_address_spaces = kbdev->gpu_props.num_address_spaces;
 
 	err = kbase_device_all_as_init(kbdev);