drm/msm: A5XX preemption
Subsystems (7)
cover drm/msm: A5XX preemption
This series of patches implements multiple ringbuffers and preemption for Adreno A5XX targets. Preemption allows a command to be interrupted at specific preemption points and execution switched to a different ringbuffer.
The software alogrithm uses preemption to enforce quality of service for priority levels - commands to a certain ring preempt the rings of lower priority. Note that priority is a software construct; the driver chooses a ring to switch to and the hardware executes. This is important because it shows that preemption can be used for things other than priority (timeslices for quality of service for example).
This initial series implements 4 ringbuffers to give sufficient coverage for the range of priority levels requested by the GLES and compute extensions. The targeted ringbuffer is specified in the command submission flags. The default ring is 0 (lowest priority).
Jordan
Jordan Crouse (11):
drm/msm: Make sure to detach the MMU during GPU cleanup drm/msm: Improve the zap shader
drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA drm/msm: Remove idle function hook
drm/msm: get an iova from the address space instead of an id drm/msm: Add a struct to pass configuration to msm_gpu_init() drm/msm: Remove memptrs->wptr
drm/msm: Support multiple ringbuffers
drm/msm: Shadow current pointer in the ring until command is complete drm/msm: Make the value of RB_CNTL (almost) generic drm/msm: Implement preemption for A5XX targets
drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 13 +- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 13 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 278 +++++++++++++++++----- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 106 +++++++++ drivers/gpu/drm/msm/adreno/a5xx_power.c | 11 +- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 367 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 215 +++++++++++------ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 42 ++-- drivers/gpu/drm/msm/dsi/dsi_host.c | 15 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 8 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 18 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h | 3 - drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c | 13 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 5 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 11 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 13 +- drivers/gpu/drm/msm/msm_drv.c | 43 ++-- drivers/gpu/drm/msm/msm_drv.h | 27 ++- drivers/gpu/drm/msm/msm_fb.c | 15 +- drivers/gpu/drm/msm/msm_fbdev.c | 10 +- drivers/gpu/drm/msm/msm_fence.c | 85 +++++-- drivers/gpu/drm/msm/msm_fence.h | 13 +- drivers/gpu/drm/msm/msm_gem.c | 124 +++++++--- drivers/gpu/drm/msm/msm_gem.h | 5 +- drivers/gpu/drm/msm/msm_gem_submit.c | 14 +- drivers/gpu/drm/msm/msm_gpu.c | 140 +++++++----- drivers/gpu/drm/msm/msm_gpu.h | 54 ++++- drivers/gpu/drm/msm/msm_kms.h | 3 + drivers/gpu/drm/msm/msm_ringbuffer.c | 14 +- drivers/gpu/drm/msm/msm_ringbuffer.h | 21 +- include/uapi/drm/msm_drm.h | 9 +- 33 files changed, 1324 insertions(+), 389 deletions(-) create mode 100644 drivers/gpu/drm/msm/adreno/a5xx_preempt.c
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): 1486402779-9024-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
PATCH v2 1/11 drm/msm: Make sure to detach the MMU during GPU cleanup
We should be detaching the MMU before destroying the address space. To do this cleanly, the detach has to happen in adreno_gpu_cleanup() because it needs access to structs in adreno_gpu.c. Plus it is better symmetry to have the attach and detach at the same code level.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 29 +++++++++++++++++++---------- drivers/gpu/drm/msm/msm_gpu.c | 3 --- 2 files changed, 19 insertions(+), 13 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +19 -10
@@ -421,18 +421,27 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,return 0 ; } -void adreno_gpu_cleanup (struct adreno_gpu *gpu) +void adreno_gpu_cleanup (struct adreno_gpu *adreno_gpu) { -if (gpu->memptrs_bo) { -if (gpu->memptrs) -msm_gem_put_vaddr (gpu->memptrs_bo); +struct msm_gpu *gpu = &adreno_gpu->base; + +if (adreno_gpu->memptrs_bo) { +if (adreno_gpu->memptrs) +msm_gem_put_vaddr (adreno_gpu->memptrs_bo); + +if (adreno_gpu->memptrs_iova) +msm_gem_put_iova (adreno_gpu->memptrs_bo, gpu->id); + +drm_gem_object_unreference_unlocked (adreno_gpu->memptrs_bo); + } +release_firmware (adreno_gpu->pm4); +release_firmware (adreno_gpu->pfp); -if (gpu->memptrs_iova) -msm_gem_put_iova (gpu->memptrs_bo, gpu->base.id); +msm_gpu_cleanup (gpu); -drm_gem_object_unreference_unlocked (gpu->memptrs_bo); +if (gpu->aspace) { + gpu->aspace->mmu->funcs->detach (gpu->aspace->mmu, + iommu_ports,ARRAY_SIZE (iommu_ports)); +msm_gem_address_space_destroy (gpu->aspace); } -release_firmware (gpu->pm4); -release_firmware (gpu->pfp); -msm_gpu_cleanup (&gpu->base); }
drivers/gpu/drm/msm/msm_gpu.c +0 -3
@@ -711,9 +711,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)msm_ringbuffer_destroy (gpu->rb); } -if (gpu->aspace) -msm_gem_address_space_destroy (gpu->aspace); -if (gpu->fctx)msm_fence_context_free (gpu->fctx); }
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 2/11 drm/msm: Improve the zap shader
In reply to a message not in the archiveSimply the code, use snprintf correctly and make sure that we memset the rest of the segment if the memory size in the ELF file is larger than the file size.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +30 -30
@@ -31,11 +31,11 @@ static inline bool _check_segment(const struct elf32_phdr *phdr) phdr->p_memsz); } -static int __pil_tz_load_image (struct platform_device *pdev, +static int zap_load_segments (struct platform_device *pdev,const struct firmware *mdt,const char *fwname,void *fwptr,size_t fw_size,unsigned long fw_min_addr) { -char str[64 ] = {0 }; +char filename[64 ];const struct elf32_hdr *ehdr = (struct elf32_hdr *) mdt->data;const struct elf32_phdr *phdrs = (struct elf32_phdr *) (ehdr +1 );const struct firmware *fw;
@@ -53,16 +53,18 @@ static int __pil_tz_load_image(struct platform_device *pdev, offset = (phdr->p_paddr - fw_min_addr);/* Request the file containing the segment */ -snprintf (str,sizeof (str) -1 ,"%s.b%02d" , fwname, i); +snprintf (filename,sizeof (filename),"%s.b%02d" , fwname, i); - ret =request_firmware (&fw, str, &pdev->dev); + ret =request_firmware (&fw, filename, &pdev->dev);if (ret) { -dev_err (&pdev->dev,"Failed to load segment %s\n" , str); +dev_err (&pdev->dev,"Failed to load segment %s\n" , + filename);break ; }if (offset + fw->size > fw_size) { -dev_err (&pdev->dev,"Segment %s is too big\n" , str); +dev_err (&pdev->dev,"Segment %s is too big\n" , + filename); ret = -EINVAL ;release_firmware (fw);break ;
@@ -70,15 +72,19 @@ static int __pil_tz_load_image(struct platform_device *pdev,/* Copy the segment into place */ memcpy (fwptr + offset, fw->data, fw->size); + +if (phdr->p_memsz > phdr->p_filesz) +memset (fwptr + fw->size,0 , + phdr->p_memsz - phdr->p_filesz);release_firmware (fw); }return ret; } -static int _pil_tz_load_image (struct platform_device *pdev) +static int zap_load_mdt (struct platform_device *pdev) { -char str[64 ] = {0 }; +char filename[64 ];const char *fwname;const struct elf32_hdr *ehdr;const struct elf32_phdr *phdrs;
@@ -86,7 +92,6 @@ static int _pil_tz_load_image(struct platform_device *pdev)phys_addr_t fw_min_addr, fw_max_addr;dma_addr_t fw_phys;size_t fw_size; -u32 pas_id;void *ptr;int i, ret;
@@ -95,11 +100,10 @@ static int _pil_tz_load_image(struct platform_device *pdev)if (!qcom_scm_is_available ()) {dev_err (&pdev->dev,"SCM is not available\n" ); -return -EINVAL ; +return -EPROBE_DEFER ; } ret =of_reserved_mem_device_init (&pdev->dev); -if (ret) {dev_err (&pdev->dev,"Unable to set up the reserved memory\n" );return ret;
@@ -112,17 +116,12 @@ static int _pil_tz_load_image(struct platform_device *pdev)return -EINVAL ; } -if (of_property_read_u32 (pdev->dev.of_node,"qcom,pas-id" , &pas_id)) { -dev_err (&pdev->dev,"Could not read the pas ID\n" ); -return -EINVAL ; - } - -snprintf (str,sizeof (str) -1 ,"%s.mdt" , fwname); +snprintf (filename,sizeof (filename),"%s.mdt" , fwname);/* Request the MDT file for the firmware */ - ret =request_firmware (&mdt, str, &pdev->dev); + ret =request_firmware (&mdt, filename, &pdev->dev);if (ret) { -dev_err (&pdev->dev,"Unable to load %s\n" , str); +dev_err (&pdev->dev,"Unable to load %s\n" , filename);return ret; }
@@ -151,7 +150,7 @@ static int _pil_tz_load_image(struct platform_device *pdev) fw_size = (size_t ) (fw_max_addr - fw_min_addr);/* Verify the MDT header */ - ret =qcom_scm_pas_init_image (pas_id, mdt->data, mdt->size); + ret =qcom_scm_pas_init_image (13 , mdt->data, mdt->size);if (ret) {dev_err (&pdev->dev,"Invalid firmware metadata\n" ); goto out;
@@ -163,18 +162,19 @@ static int _pil_tz_load_image(struct platform_device *pdev) goto out;/* Set up the newly allocated memory region */ - ret =qcom_scm_pas_mem_setup (pas_id, fw_phys, fw_size); + ret =qcom_scm_pas_mem_setup (13 , fw_phys, fw_size);if (ret) {dev_err (&pdev->dev,"Unable to set up firmware memory\n" ); goto out; } - ret =__pil_tz_load_image (pdev, mdt, fwname, ptr, fw_size, fw_min_addr); -if (!ret) { - ret =qcom_scm_pas_auth_and_reset (pas_id); -if (ret) -dev_err (&pdev->dev,"Unable to authorize the image\n" ); - } + ret =zap_load_segments (pdev, mdt, fwname, ptr, fw_size, fw_min_addr); +if (ret) + goto out; + + ret =qcom_scm_pas_auth_and_reset (13 ); +if (ret) +dev_err (&pdev->dev,"Unable to authorize the image\n" ); out:if (ret && ptr)
@@ -502,14 +502,14 @@ static int a5xx_zap_shader_init(struct msm_gpu *gpu)of_platform_populate (pdev->dev.of_node,NULL ,NULL , &pdev->dev);/* Find the sub-node for the zap shader */ - node =of_find_node_by_name (pdev->dev.of_node,"qcom,zap-shader" ); + node =of_get_child_by_name (pdev->dev.of_node,"zap-shader" );if (!node) { -DRM_ERROR ("%s: qcom,zap-shader not found in device tree\n" , +DRM_ERROR ("%s: zap-shader not found in device tree\n" , gpu->name);return -ENODEV ; } - ret =_pil_tz_load_image (of_find_device_by_node (node)); + ret =zap_load_mdt (of_find_device_by_node (node));if (ret)DRM_ERROR ("%s: Unable to load the zap shader\n" , gpu->name);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
v2 cover drm/msm: A5XX preemption
In reply to a message not in the archiveHere is v2 of the preemption series - Changes:
* Refactored API in DRM_IOCTL_MSM_GEM_INFO (Thanks Emil Velikov)
* Removed preemption worker and fixed atomics (Thanks Stephen Boyd)
* Various fixes and improvements based on testing
Thanks!
Jordan
Jordan Crouse (11):
drm/msm: Make sure to detach the MMU during GPU cleanup drm/msm: Improve the zap shader
drm/msm: Remove idle function hook
drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA drm/msm: get an iova from the address space instead of an id drm/msm: Add a struct to pass configuration to msm_gpu_init() drm/msm: Remove memptrs->wptr
drm/msm: Support multiple ringbuffers
drm/msm: Shadow current pointer in the ring until command is complete drm/msm: Make the value of RB_CNTL (almost) generic drm/msm: Implement preemption for A5XX targets
arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 +- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 13 +- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 13 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 292 +++++++++++++++++++------ drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 103 ++++++++- drivers/gpu/drm/msm/adreno/a5xx_power.c | 11 +- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 345 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 220 ++++++++++++------- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 44 ++-- drivers/gpu/drm/msm/dsi/dsi_host.c | 15 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 8 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 18 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c | 13 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 5 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 11 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 13 +- drivers/gpu/drm/msm/msm_drv.c | 36 ++-- drivers/gpu/drm/msm/msm_drv.h | 27 ++- drivers/gpu/drm/msm/msm_fb.c | 15 +- drivers/gpu/drm/msm/msm_fbdev.c | 10 +- drivers/gpu/drm/msm/msm_fence.c | 85 ++++++-- drivers/gpu/drm/msm/msm_fence.h | 13 +- drivers/gpu/drm/msm/msm_gem.c | 134 ++++++++---- drivers/gpu/drm/msm/msm_gem.h | 5 +- drivers/gpu/drm/msm/msm_gem_submit.c | 14 +- drivers/gpu/drm/msm/msm_gpu.c | 141 +++++++----- drivers/gpu/drm/msm/msm_gpu.h | 54 ++++- drivers/gpu/drm/msm/msm_kms.h | 3 + drivers/gpu/drm/msm/msm_ringbuffer.c | 14 +- drivers/gpu/drm/msm/msm_ringbuffer.h | 21 +- include/uapi/drm/msm_drm.h | 13 +- 34 files changed, 1322 insertions(+), 400 deletions(-) create mode 100644 drivers/gpu/drm/msm/adreno/a5xx_preempt.c
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 1/11 drm/msm: Make sure to detach the MMU during GPU cleanup
We should be detaching the MMU before destroying the address space. To do this cleanly, the detach has to happen in adreno_gpu_cleanup() because it needs access to structs in adreno_gpu.c. Plus it is better symmetry to have the attach and detach at the same code level.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 31 ++++++++++++++++++++----------- drivers/gpu/drm/msm/msm_gpu.c | 3 --- 2 files changed, 20 insertions(+), 14 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +20 -11
@@ -2,7 +2,7 @@* Copyright (C) 2013 Red Hat * Author: Rob Clark <[email protected]> * -* Copyright (c) 2014 The Linux Foundation. All rights reserved. +* Copyright (c) 2014,2017 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by
@@ -420,18 +420,27 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,return 0 ; } -void adreno_gpu_cleanup (struct adreno_gpu *gpu) +void adreno_gpu_cleanup (struct adreno_gpu *adreno_gpu) { -if (gpu->memptrs_bo) { -if (gpu->memptrs) -msm_gem_put_vaddr (gpu->memptrs_bo); +struct msm_gpu *gpu = &adreno_gpu->base; + +if (adreno_gpu->memptrs_bo) { +if (adreno_gpu->memptrs) +msm_gem_put_vaddr (adreno_gpu->memptrs_bo); + +if (adreno_gpu->memptrs_iova) +msm_gem_put_iova (adreno_gpu->memptrs_bo, gpu->id); + +drm_gem_object_unreference_unlocked (adreno_gpu->memptrs_bo); + } +release_firmware (adreno_gpu->pm4); +release_firmware (adreno_gpu->pfp); -if (gpu->memptrs_iova) -msm_gem_put_iova (gpu->memptrs_bo, gpu->base.id); +msm_gpu_cleanup (gpu); -drm_gem_object_unreference_unlocked (gpu->memptrs_bo); +if (gpu->aspace) { + gpu->aspace->mmu->funcs->detach (gpu->aspace->mmu, + iommu_ports,ARRAY_SIZE (iommu_ports)); +msm_gem_address_space_destroy (gpu->aspace); } -release_firmware (gpu->pm4); -release_firmware (gpu->pfp); -msm_gpu_cleanup (&gpu->base); }
drivers/gpu/drm/msm/msm_gpu.c +0 -3
@@ -710,9 +710,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)msm_ringbuffer_destroy (gpu->rb); } -if (gpu->aspace) -msm_gem_address_space_destroy (gpu->aspace); -if (gpu->fctx)msm_fence_context_free (gpu->fctx); }
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 1488905900-6603-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
PATCH v2 2/11 drm/msm: Improve the zap shader
Simply the code, use snprintf correct and make sure that we memset the rest of the segment if the memory size in the ELF file is larger than the file size.
--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 70 +++++++++++++++++------------------ 2 files changed, 37 insertions(+), 37 deletions(-)
arch/arm64/boot/dts/qcom/msm8996.dtsi +2 -2
@@ -915,8 +915,8 @@ }; }; - qcom,zap-shader { - compatible = "qcom,zap-shader"; + zap-shader { + compatible = "zap-shader"; memory-region = <&peripheral_reserved>; qcom,firmware = "a530_zap";
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +35 -35
160 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 3/11 drm/msm: Remove idle function hook
In reply to a message not in the archiveThere isn't any generic code that uses ->idle so remove it.
--- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 9 ++++----- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a5xx_power.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 1 - 6 files changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +2 -2
@@ -40,6 +40,7 @@extern bool hang_debug;static void a3xx_dump (struct msm_gpu *gpu); +static bool a3xx_idle (struct msm_gpu *gpu);static bool a3xx_me_init (struct msm_gpu *gpu) {
@@ -65,7 +66,7 @@ static bool a3xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 ); gpu->funcs->flush (gpu); -return gpu->funcs->idle (gpu); +return a3xx_idle (gpu); }static int a3xx_hw_init (struct msm_gpu *gpu)
@@ -448,7 +449,6 @@ static void a3xx_dump(struct msm_gpu *gpu) .last_fence = adreno_last_fence, .submit = adreno_submit, .flush = adreno_flush, - .idle = a3xx_idle, .irq = a3xx_irq, .destroy = a3xx_destroy,#ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +2 -2
@@ -31,6 +31,7 @@extern bool hang_debug;static void a4xx_dump (struct msm_gpu *gpu); +static bool a4xx_idle (struct msm_gpu *gpu);/* * a4xx_enable_hwcg() - Program the clock control registers
@@ -137,7 +138,7 @@ static bool a4xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 ); gpu->funcs->flush (gpu); -return gpu->funcs->idle (gpu); +return a4xx_idle (gpu); }static int a4xx_hw_init (struct msm_gpu *gpu)
@@ -538,7 +539,6 @@ static int a4xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) .last_fence = adreno_last_fence, .submit = adreno_submit, .flush = adreno_flush, - .idle = a4xx_idle, .irq = a4xx_irq, .destroy = a4xx_destroy,#ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +4 -5
@@ -391,7 +391,7 @@ static int a5xx_me_init(struct msm_gpu *gpu) gpu->funcs->flush (gpu); -return gpu->funcs->idle (gpu) ?0 : -EINVAL ; +return a5xx_idle (gpu) ?0 : -EINVAL ; } static struct drm_gem_object *a5xx_ucode_load_bo(struct msm_gpu *gpu,
@@ -699,7 +699,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)OUT_RING (gpu->rb,0x0F ); gpu->funcs->flush (gpu); -if (!gpu->funcs->idle (gpu)) +if (!a5xx_idle (gpu))return -EINVAL ; }
@@ -716,7 +716,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)OUT_RING (gpu->rb,0x00000000 ); gpu->funcs->flush (gpu); -if (!gpu->funcs->idle (gpu)) +if (!a5xx_idle (gpu))return -EINVAL ; }else {/* Print a warning so if we die, we know why */
@@ -790,7 +790,7 @@ static inline bool _a5xx_check_idle(struct msm_gpu *gpu) A5XX_RBBM_INT_0_MASK_MISC_HANG_DETECT); } -static bool a5xx_idle (struct msm_gpu *gpu) +bool a5xx_idle (struct msm_gpu *gpu) {/* wait for CP to drain ringbuffer: */ if (!adreno_idle (gpu))
@@ -1099,7 +1099,6 @@ static void a5xx_show(struct msm_gpu *gpu, struct seq_file *m) .last_fence = adreno_last_fence, .submit = a5xx_submit, .flush = adreno_flush, - .idle = a5xx_idle, .irq = a5xx_irq, .destroy = a5xx_destroy, .show = a5xx_show,
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -0
@@ -56,5 +56,6 @@ static inline int spin_usecs(struct msm_gpu *gpu, uint32_t usecs, return -ETIMEDOUT; } +bool a5xx_idle (struct msm_gpu *gpu);#endif /* __A5XX_GPU_H__ */
drivers/gpu/drm/msm/adreno/a5xx_power.c +1 -1
@@ -194,7 +194,7 @@ static int a5xx_gpmu_init(struct msm_gpu *gpu) gpu->funcs->flush (gpu); -if (!gpu->funcs->idle (gpu)) { +if (!a5xx_idle (gpu)) {DRM_ERROR ("%s: Unable to load GPMU firmware. GPMU will not be active\n" , gpu->name);return -EINVAL ;
drivers/gpu/drm/msm/msm_gpu.h +0 -1
@@ -50,7 +50,6 @@ struct msm_gpu_funcs {void (*submit)(struct msm_gpu *gpu,struct msm_gem_submit *submit,struct msm_file_private *ctx);void (*flush)(struct msm_gpu *gpu); -bool (*idle)(struct msm_gpu *gpu);irqreturn_t (*irq)(struct msm_gpu *irq);uint32_t (*last_fence)(struct msm_gpu *gpu);void (*recover)(struct msm_gpu *gpu);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 4/11 drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA
In reply to a message not in the archiveModify the 'pad' member of struct drm_msm_gem_info to 'hint'. If the user sets 'hint' to non-zero it means that they want a IOVA for the GEM object instead of a mmap() offset. Return the iova in the 'offset' member.
--- drivers/gpu/drm/msm/msm_drv.c | 23 +++++++++++++++++++++-- include/uapi/drm/msm_drm.h | 8 ++++++-- 2 files changed, 27 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +21 -2
@@ -695,6 +695,17 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,return ret; } +static int msm_ioctl_gem_info_iova (struct drm_device *dev, +struct drm_gem_object *obj,uint64_t *iova) +{ +struct msm_drm_private *priv = dev->dev_private; + +if (!priv->gpu) +return -EINVAL ; + +return msm_gem_get_iova (obj, priv->gpu->id, iova); +} +static int msm_ioctl_gem_info (struct drm_device *dev,void *data,struct drm_file *file) {
@@ -702,14 +713,22 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,struct drm_gem_object *obj;int ret =0 ; -if (args->pad) +if (args->flags & ~MSM_INFO_FLAGS )return -EINVAL ; obj =drm_gem_object_lookup (file, args->handle);if (!obj)return -ENOENT ; - args->offset =msm_gem_mmap_offset (obj); +if (args->flags &MSM_INFO_IOVA ) { +uint64_t iova; + + ret =msm_ioctl_gem_info_iova (dev, obj, &iova); +if (!ret) + args->offset = iova; + }else { + args->offset =msm_gem_mmap_offset (obj); + }drm_gem_object_unreference_unlocked (obj);
include/uapi/drm/msm_drm.h +6 -2
@@ -103,10 +103,14 @@ struct drm_msm_gem_new {__u32 handle;/* out */ }; +#define MSM_INFO_IOVA 0x01 + +#define MSM_INFO_FLAGS (MSM_INFO_IOVA) +struct drm_msm_gem_info {__u32 handle;/* in */ -__u32 pad; -__u64 offset;/* out, offset to pass to mmap() */ +__u32 flags;/* in - combination of MSM_INFO_* flags */ +__u64 offset;/* out, mmap() offset or iova */ };#define MSM_PREP_READ 0x01
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 5/11 drm/msm: get an iova from the address space instead of an id
In reply to a message not in the archiveIn the future we won't have a fixed set of addresses spaces. Instead of going through the effort of assigning a ID for each address space just use the address space itself as a token for getting / putting an iova.
This forces a few changes in the gem object however: instead of using a simple index into a list of domains, we need to maintain a list of them. Luckily the list will be pretty small; even with dynamic address spaces we wouldn't ever see more than two or three.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 8 +- drivers/gpu/drm/msm/adreno/a5xx_power.c | 5 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 6 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 15 +++- drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 8 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 18 ++-- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c | 13 +-- drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 5 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 11 +-- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 13 +-- drivers/gpu/drm/msm/msm_drv.c | 15 +--- drivers/gpu/drm/msm/msm_drv.h | 25 +++--- drivers/gpu/drm/msm/msm_fb.c | 15 ++-- drivers/gpu/drm/msm/msm_fbdev.c | 10 ++- drivers/gpu/drm/msm/msm_gem.c | 134 +++++++++++++++++++++--------- drivers/gpu/drm/msm/msm_gem.h | 4 +- drivers/gpu/drm/msm/msm_gem_submit.c | 4 +- drivers/gpu/drm/msm/msm_gpu.c | 8 +- drivers/gpu/drm/msm/msm_gpu.h | 1 - drivers/gpu/drm/msm/msm_kms.h | 3 + 22 files changed, 194 insertions(+), 135 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +4 -4
@@ -415,7 +415,7 @@ static struct drm_gem_object *a5xx_ucode_load_bo(struct msm_gpu *gpu, }if (iova) { -int ret =msm_gem_get_iova (bo, gpu->id, iova); +int ret =msm_gem_get_iova (bo, gpu->aspace, iova);if (ret) {drm_gem_object_unreference_unlocked (bo);
@@ -757,19 +757,19 @@ static void a5xx_destroy(struct msm_gpu *gpu)if (a5xx_gpu->pm4_bo) {if (a5xx_gpu->pm4_iova) -msm_gem_put_iova (a5xx_gpu->pm4_bo, gpu->id); +msm_gem_put_iova (a5xx_gpu->pm4_bo, gpu->aspace);drm_gem_object_unreference_unlocked (a5xx_gpu->pm4_bo); }if (a5xx_gpu->pfp_bo) {if (a5xx_gpu->pfp_iova) -msm_gem_put_iova (a5xx_gpu->pfp_bo, gpu->id); +msm_gem_put_iova (a5xx_gpu->pfp_bo, gpu->aspace);drm_gem_object_unreference_unlocked (a5xx_gpu->pfp_bo); }if (a5xx_gpu->gpmu_bo) {if (a5xx_gpu->gpmu_iova) -msm_gem_put_iova (a5xx_gpu->gpmu_bo, gpu->id); +msm_gem_put_iova (a5xx_gpu->gpmu_bo, gpu->aspace);drm_gem_object_unreference_unlocked (a5xx_gpu->gpmu_bo); }
drivers/gpu/drm/msm/adreno/a5xx_power.c +3 -2
@@ -301,7 +301,8 @@ void a5xx_gpmu_ucode_init(struct msm_gpu *gpu)if (IS_ERR (a5xx_gpu->gpmu_bo)) goto err; -if (msm_gem_get_iova (a5xx_gpu->gpmu_bo, gpu->id, &a5xx_gpu->gpmu_iova)) +if (msm_gem_get_iova (a5xx_gpu->gpmu_bo, gpu->aspace, + &a5xx_gpu->gpmu_iova)) goto err; ptr =msm_gem_get_vaddr (a5xx_gpu->gpmu_bo);
@@ -330,7 +331,7 @@ void a5xx_gpmu_ucode_init(struct msm_gpu *gpu) err:if (a5xx_gpu->gpmu_iova) -msm_gem_put_iova (a5xx_gpu->gpmu_bo, gpu->id); +msm_gem_put_iova (a5xx_gpu->gpmu_bo, gpu->aspace);if (a5xx_gpu->gpmu_bo)drm_gem_object_unreference_unlocked (a5xx_gpu->gpmu_bo);
drivers/gpu/drm/msm/adreno/adreno_gpu.c +3 -3
@@ -61,7 +61,7 @@ int adreno_hw_init(struct msm_gpu *gpu)DBG ("%s" , gpu->name); - ret =msm_gem_get_iova (gpu->rb->bo, gpu->id, &gpu->rb_iova); + ret =msm_gem_get_iova (gpu->rb->bo, gpu->aspace, &gpu->rb_iova);if (ret) { gpu->rb_iova =0 ;dev_err (gpu->dev->dev,"could not map ringbuffer: %d\n" , ret);
@@ -410,7 +410,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,return -ENOMEM ; } - ret =msm_gem_get_iova (adreno_gpu->memptrs_bo, gpu->id, + ret =msm_gem_get_iova (adreno_gpu->memptrs_bo, gpu->aspace, &adreno_gpu->memptrs_iova);if (ret) {dev_err (drm->dev,"could not map memptrs: %d\n" , ret);
@@ -429,7 +429,7 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)msm_gem_put_vaddr (adreno_gpu->memptrs_bo);if (adreno_gpu->memptrs_iova) -msm_gem_put_iova (adreno_gpu->memptrs_bo, gpu->id); +msm_gem_put_iova (adreno_gpu->memptrs_bo, gpu->aspace);drm_gem_object_unreference_unlocked (adreno_gpu->memptrs_bo); }
drivers/gpu/drm/msm/dsi/dsi_host.c +13 -2
@@ -28,6 +28,7 @@#include <linux/regmap.h> #include <video/mipi_display.h> +#include "msm_kms.h" #include "dsi.h" #include "dsi.xml.h" #include "sfpb.xml.h"
@@ -975,6 +976,7 @@ static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host)static int dsi_tx_buf_alloc (struct msm_dsi_host *msm_host,int size) {struct drm_device *dev = msm_host->dev; +struct msm_drm_private *priv = dev->dev_private;const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd;int ret;uint64_t iova;
@@ -991,7 +993,13 @@ static int dsi_tx_buf_alloc(struct msm_dsi_host *msm_host, int size)return ret; } - ret =msm_gem_get_iova_locked (msm_host->tx_gem_obj,0 , &iova); +if (!priv->kms) { +pr_err ("%s: No KMS is initalized\n" , __func__); +return -ENODEV ; + } + + ret =msm_gem_get_iova_locked (msm_host->tx_gem_obj, + priv->kms->aspace, &iova);mutex_unlock (&dev->struct_mutex);if (ret) {pr_err ("%s: failed to get iova, %d\n" , __func__, ret);
@@ -1023,9 +1031,12 @@ static int dsi_tx_buf_alloc(struct msm_dsi_host *msm_host, int size)static void dsi_tx_buf_free (struct msm_dsi_host *msm_host) {struct drm_device *dev = msm_host->dev; +struct msm_drm_private *priv = dev->dev_private;if (msm_host->tx_gem_obj) { -msm_gem_put_iova (msm_host->tx_gem_obj,0 ); +if (priv->kms) +msm_gem_put_iova (msm_host->tx_gem_obj, + priv->kms->aspace);mutex_lock (&dev->struct_mutex);msm_gem_free_object (msm_host->tx_gem_obj); msm_host->tx_gem_obj =NULL ;
drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c +5 -3
@@ -133,7 +133,7 @@ static void unref_cursor_worker(struct drm_flip_work *work, void *val) container_of(work, struct mdp4_crtc, unref_cursor_work);struct mdp4_kms *mdp4_kms =get_kms (&mdp4_crtc->base); -msm_gem_put_iova (val, mdp4_kms->id); +msm_gem_put_iova (val, mdp4_kms->base.base.aspace);drm_gem_object_unreference_unlocked (val); }
@@ -378,7 +378,8 @@ static void update_cursor(struct drm_crtc *crtc)if (next_bo) {/* take a obj ref + iova ref when we start scanning out: */ drm_gem_object_reference (next_bo); -msm_gem_get_iova_locked (next_bo, mdp4_kms->id, &iova); +msm_gem_get_iova_locked (next_bo, + mdp4_kms->base.base.aspace, &iova);/* enable cursor: */ mdp4_write(mdp4_kms, REG_MDP4_DMA_CURSOR_SIZE(dma),
@@ -435,7 +436,8 @@ static int mdp4_crtc_cursor_set(struct drm_crtc *crtc, }if (cursor_bo) { - ret =msm_gem_get_iova (cursor_bo, mdp4_kms->id, &iova); + ret =msm_gem_get_iova (cursor_bo, mdp4_kms->base.base.aspace, + &iova);if (ret) goto fail; }else {
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c +6 -12
@@ -160,7 +160,10 @@ static void mdp4_destroy(struct msm_kms *kms) {struct mdp4_kms *mdp4_kms =to_mdp4_kms (to_mdp_kms (kms));struct device *dev = mdp4_kms->dev->dev; -struct msm_gem_address_space *aspace = mdp4_kms->aspace; +struct msm_gem_address_space *aspace = kms->aspace; + +if (mdp4_kms->blank_cursor_iova) +msm_gem_put_iova (mdp4_kms->blank_cursor_bo, aspace);if (aspace) { aspace->mmu->funcs->detach(aspace->mmu,
@@ -168,8 +171,6 @@ static void mdp4_destroy(struct msm_kms *kms)msm_gem_address_space_destroy (aspace); } -if (mdp4_kms->blank_cursor_iova) -msm_gem_put_iova (mdp4_kms->blank_cursor_bo, mdp4_kms->id);drm_gem_object_unreference_unlocked (mdp4_kms->blank_cursor_bo);if (mdp4_kms->rpm_enabled)
@@ -536,7 +537,7 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) goto fail; } - mdp4_kms->aspace = aspace; + kms->aspace = aspace; ret = aspace->mmu->funcs->attach (aspace->mmu, iommu_ports,ARRAY_SIZE (iommu_ports));
@@ -548,13 +549,6 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) aspace =NULL ; } - mdp4_kms->id =msm_register_address_space (dev, aspace); -if (mdp4_kms->id <0 ) { - ret = mdp4_kms->id; -dev_err (dev->dev,"failed to register mdp4 iommu: %d\n" , ret); - goto fail; - } - ret =modeset_init (mdp4_kms);if (ret) {dev_err (dev->dev,"modeset_init failed: %d\n" , ret);
@@ -571,7 +565,7 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) goto fail; } - ret =msm_gem_get_iova (mdp4_kms->blank_cursor_bo, mdp4_kms->id, + ret =msm_gem_get_iova (mdp4_kms->blank_cursor_bo, kms->aspace, &mdp4_kms->blank_cursor_iova);if (ret) {dev_err (dev->dev,"could not pin blank-cursor bo: %d\n" , ret);
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h +0 -4
@@ -32,9 +32,6 @@ struct mdp4_kms {int rev; -/* mapper-id used to request GEM buffer mapped for scanout: */ -int id; -void __iomem *mmio;struct regulator *vdd;
@@ -43,7 +40,6 @@ struct mdp4_kms {struct clk *pclk;struct clk *lut_clk;struct clk *axi_clk; -struct msm_gem_address_space *aspace;struct mdp_irq error_handler;
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c +7 -6
@@ -109,7 +109,7 @@ static int mdp4_plane_prepare_fb(struct drm_plane *plane,return 0 ;DBG ("%s: prepare: FB[%u]" , mdp4_plane->name, fb->base.id); -return msm_framebuffer_prepare (fb, mdp4_kms->id); +return msm_framebuffer_prepare (fb, mdp4_kms->base.base.aspace); } static void mdp4_plane_cleanup_fb(struct drm_plane *plane,
@@ -123,7 +123,7 @@ static void mdp4_plane_cleanup_fb(struct drm_plane *plane,return ;DBG ("%s: cleanup: FB[%u]" , mdp4_plane->name, fb->base.id); -msm_framebuffer_cleanup (fb, mdp4_kms->id); +msm_framebuffer_cleanup (fb, mdp4_kms->base.base.aspace); }
@@ -161,6 +161,7 @@ static void mdp4_plane_set_scanout(struct drm_plane *plane, {struct mdp4_plane *mdp4_plane =to_mdp4_plane (plane);struct mdp4_kms *mdp4_kms =get_kms (plane); +struct msm_kms *kms = &mdp4_kms->base.base;enum mdp4_pipe pipe = mdp4_plane->pipe; mdp4_write(mdp4_kms, REG_MDP4_PIPE_SRC_STRIDE_A(pipe),
@@ -172,13 +173,13 @@ static void mdp4_plane_set_scanout(struct drm_plane *plane, MDP4_PIPE_SRC_STRIDE_B_P3(fb->pitches[3]));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP0_BASE (pipe), -msm_framebuffer_iova (fb, mdp4_kms->id,0 )); +msm_framebuffer_iova (fb, kms->aspace,0 ));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP1_BASE (pipe), -msm_framebuffer_iova (fb, mdp4_kms->id,1 )); +msm_framebuffer_iova (fb, kms->aspace,1 ));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP2_BASE (pipe), -msm_framebuffer_iova (fb, mdp4_kms->id,2 )); +msm_framebuffer_iova (fb, kms->aspace,2 ));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP3_BASE (pipe), -msm_framebuffer_iova (fb, mdp4_kms->id,3 )); +msm_framebuffer_iova (fb, kms->aspace,3 )); plane->fb = fb; }
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +3 -2
@@ -165,7 +165,7 @@ static void unref_cursor_worker(struct drm_flip_work *work, void *val) container_of(work, struct mdp5_crtc, unref_cursor_work);struct mdp5_kms *mdp5_kms =get_kms (&mdp5_crtc->base); -msm_gem_put_iova (val, mdp5_kms->id); +msm_gem_put_iova (val, mdp5_kms->base.base.aspace);drm_gem_object_unreference_unlocked (val); }
@@ -561,7 +561,8 @@ static int mdp5_crtc_cursor_set(struct drm_crtc *crtc,if (!cursor_bo)return -ENOENT ; - ret =msm_gem_get_iova (cursor_bo, mdp5_kms->id, &cursor_addr); + ret =msm_gem_get_iova (cursor_bo, mdp5_kms->base.base.aspace, + &cursor_addr);if (ret)return -EINVAL ;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +2 -9
@@ -159,7 +159,7 @@ static void mdp5_set_encoder_mode(struct msm_kms *kms,static void mdp5_kms_destroy (struct msm_kms *kms) {struct mdp5_kms *mdp5_kms =to_mdp5_kms (to_mdp_kms (kms)); -struct msm_gem_address_space *aspace = mdp5_kms->aspace; +struct msm_gem_address_space *aspace = kms->aspace;int i;for (i =0 ; i < mdp5_kms->num_hwpipes; i++)
@@ -734,7 +734,7 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev) goto fail; } - mdp5_kms->aspace = aspace; + kms->aspace = aspace; ret = aspace->mmu->funcs->attach (aspace->mmu, iommu_ports,ARRAY_SIZE (iommu_ports));
@@ -749,13 +749,6 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev) aspace =NULL ;; } - mdp5_kms->id =msm_register_address_space (dev, aspace); -if (mdp5_kms->id <0 ) { - ret = mdp5_kms->id; -dev_err (&pdev->dev,"failed to register mdp5 iommu: %d\n" , ret); - goto fail; - } - ret =modeset_init (mdp5_kms);if (ret) {dev_err (&pdev->dev,"modeset_init failed: %d\n" , ret);
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h +0 -4
@@ -48,10 +48,6 @@ struct mdp5_kms {struct mdp5_state *state;struct drm_modeset_lock state_lock; -/* mapper-id used to request GEM buffer mapped for scanout: */ -int id; -struct msm_gem_address_space *aspace; -struct mdp5_smp *smp;struct mdp5_ctl_manager *ctlm;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +7 -6
@@ -277,7 +277,7 @@ static int mdp5_plane_prepare_fb(struct drm_plane *plane,return 0 ;DBG ("%s: prepare: FB[%u]" , plane->name, fb->base.id); -return msm_framebuffer_prepare (fb, mdp5_kms->id); +return msm_framebuffer_prepare (fb, mdp5_kms->base.base.aspace); } static void mdp5_plane_cleanup_fb(struct drm_plane *plane,
@@ -290,7 +290,7 @@ static void mdp5_plane_cleanup_fb(struct drm_plane *plane,return ;DBG ("%s: cleanup: FB[%u]" , plane->name, fb->base.id); -msm_framebuffer_cleanup (fb, mdp5_kms->id); +msm_framebuffer_cleanup (fb, mdp5_kms->base.base.aspace); }#define FRAC_16_16 (mult, div) (((mult) << 16) / (div))
@@ -443,6 +443,7 @@ static void set_scanout_locked(struct drm_plane *plane, struct drm_framebuffer *fb) {struct mdp5_kms *mdp5_kms =get_kms (plane); +struct msm_kms *kms = &mdp5_kms->base.base;struct mdp5_hw_pipe *hwpipe =to_mdp5_plane_state (plane->state)->hwpipe;enum mdp5_pipe pipe = hwpipe->pipe;
@@ -455,13 +456,13 @@ static void set_scanout_locked(struct drm_plane *plane, MDP5_PIPE_SRC_STRIDE_B_P3(fb->pitches[3]));mdp5_write (mdp5_kms,REG_MDP5_PIPE_SRC0_ADDR (pipe), -msm_framebuffer_iova (fb, mdp5_kms->id,0 )); +msm_framebuffer_iova (fb, kms->aspace,0 ));mdp5_write (mdp5_kms,REG_MDP5_PIPE_SRC1_ADDR (pipe), -msm_framebuffer_iova (fb, mdp5_kms->id,1 )); +msm_framebuffer_iova (fb, kms->aspace,1 ));mdp5_write (mdp5_kms,REG_MDP5_PIPE_SRC2_ADDR (pipe), -msm_framebuffer_iova (fb, mdp5_kms->id,2 )); +msm_framebuffer_iova (fb, kms->aspace,2 ));mdp5_write (mdp5_kms,REG_MDP5_PIPE_SRC3_ADDR (pipe), -msm_framebuffer_iova (fb, mdp5_kms->id,3 )); +msm_framebuffer_iova (fb, kms->aspace,3 )); plane->fb = fb; }
drivers/gpu/drm/msm/msm_drv.c +1 -14
@@ -51,19 +51,6 @@ static void msm_fb_output_poll_changed(struct drm_device *dev) .atomic_state_free = msm_atomic_state_free, }; -int msm_register_address_space (struct drm_device *dev, -struct msm_gem_address_space *aspace) -{ -struct msm_drm_private *priv = dev->dev_private; - -if (WARN_ON (priv->num_aspaces >=ARRAY_SIZE (priv->aspace))) -return -EINVAL ; - - priv->aspace[priv->num_aspaces] = aspace; - -return priv->num_aspaces++; -} -#ifdef CONFIG_DRM_MSM_REGISTER_LOGGING static bool reglog = false;MODULE_PARM_DESC (reglog,"Enable register read/write logging" );
@@ -703,7 +690,7 @@ static int msm_ioctl_gem_info_iova(struct drm_device *dev,if (!priv->gpu)return -EINVAL ; -return msm_gem_get_iova (obj, priv->gpu->id, iova); +return msm_gem_get_iova (obj, priv->gpu->aspace, iova); } static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
drivers/gpu/drm/msm/msm_drv.h +14 -11
@@ -183,9 +183,6 @@ int msm_atomic_commit(struct drm_device *dev,void msm_atomic_state_clear (struct drm_atomic_state *state);void msm_atomic_state_free (struct drm_atomic_state *state); -int msm_register_address_space (struct drm_device *dev, -struct msm_gem_address_space *aspace); -void msm_gem_unmap_vma (struct msm_gem_address_space *aspace,struct msm_gem_vma *vma,struct sg_table *sgt); int msm_gem_map_vma(struct msm_gem_address_space *aspace,
@@ -208,13 +205,16 @@ int msm_gem_mmap_obj(struct drm_gem_object *obj,int msm_gem_mmap (struct file *filp,struct vm_area_struct *vma);int msm_gem_fault (struct vm_area_struct *vma,struct vm_fault *vmf);uint64_t msm_gem_mmap_offset (struct drm_gem_object *obj); -int msm_gem_get_iova_locked (struct drm_gem_object *obj,int id, -uint64_t *iova); -int msm_gem_get_iova (struct drm_gem_object *obj,int id,uint64_t *iova); -uint64_t msm_gem_iova (struct drm_gem_object *obj,int id); +int msm_gem_get_iova_locked (struct drm_gem_object *obj, +struct msm_gem_address_space *aspace,uint64_t *iova); +int msm_gem_get_iova (struct drm_gem_object *obj, +struct msm_gem_address_space *aspace,uint64_t *iova); +uint64_t msm_gem_iova (struct drm_gem_object *obj, +struct msm_gem_address_space *aspace);struct page **msm_gem_get_pages (struct drm_gem_object *obj);void msm_gem_put_pages (struct drm_gem_object *obj); -void msm_gem_put_iova (struct drm_gem_object *obj,int id); +void msm_gem_put_iova (struct drm_gem_object *obj, +struct msm_gem_address_space *aspace);int msm_gem_dumb_create (struct drm_file *file,struct drm_device *dev,struct drm_mode_create_dumb *args); int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
@@ -249,9 +249,12 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev,struct drm_gem_object *msm_gem_import (struct drm_device *dev,struct dma_buf *dmabuf,struct sg_table *sgt); -int msm_framebuffer_prepare (struct drm_framebuffer *fb,int id); -void msm_framebuffer_cleanup (struct drm_framebuffer *fb,int id); -uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb,int id,int plane); +int msm_framebuffer_prepare (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace); +void msm_framebuffer_cleanup (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace); +uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace,int plane);struct drm_gem_object *msm_framebuffer_bo (struct drm_framebuffer *fb,int plane);const struct msm_format *msm_framebuffer_format (struct drm_framebuffer *fb); struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
drivers/gpu/drm/msm/msm_fb.c +9 -6
@@ -84,14 +84,15 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)* should be fine, since only the scanout (mdpN) side of things needs * this, the gpu doesn't care about fb's. */ -int msm_framebuffer_prepare (struct drm_framebuffer *fb,int id) +int msm_framebuffer_prepare (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace) {struct msm_framebuffer *msm_fb =to_msm_framebuffer (fb);int ret, i, n =drm_format_num_planes (fb->pixel_format);uint64_t iova;for (i =0 ; i < n; i++) { - ret =msm_gem_get_iova (msm_fb->planes[i], id, &iova); + ret =msm_gem_get_iova (msm_fb->planes[i], aspace, &iova);DBG ("FB[%u]: iova[%d]: %08llx (%d)" , fb->base.id, i, iova, ret);if (ret)return ret;
@@ -100,21 +101,23 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb, int id)return 0 ; } -void msm_framebuffer_cleanup (struct drm_framebuffer *fb,int id) +void msm_framebuffer_cleanup (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace) {struct msm_framebuffer *msm_fb =to_msm_framebuffer (fb);int i, n =drm_format_num_planes (fb->pixel_format);for (i =0 ; i < n; i++) -msm_gem_put_iova (msm_fb->planes[i], id); +msm_gem_put_iova (msm_fb->planes[i], aspace); } -uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb,int id,int plane) +uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace,int plane) {struct msm_framebuffer *msm_fb =to_msm_framebuffer (fb);if (!msm_fb->planes[plane])return 0 ; -return msm_gem_iova (msm_fb->planes[plane], id) + fb->offsets[plane]; +return msm_gem_iova (msm_fb->planes[plane], aspace) + fb->offsets[plane]; }struct drm_gem_object *msm_framebuffer_bo (struct drm_framebuffer *fb,int plane)
drivers/gpu/drm/msm/msm_fbdev.c +9 -1
@@ -20,6 +20,7 @@#include "drm_crtc.h" #include "drm_fb_helper.h" #include "msm_gem.h" +#include "msm_kms.h" extern int msm_gem_mmap_obj (struct drm_gem_object *obj,struct vm_area_struct *vma);
@@ -78,6 +79,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper, {struct msm_fbdev *fbdev =to_msm_fbdev (helper);struct drm_device *dev = helper->dev; +struct msm_drm_private *priv = dev->dev_private;struct drm_framebuffer *fb =NULL ;struct fb_info *fbi =NULL ;struct drm_mode_fb_cmd2 mode_cmd = {0 };
@@ -129,7 +131,13 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,* in panic (ie. lock-safe, etc) we could avoid pinning the * buffer now: */ - ret =msm_gem_get_iova_locked (fbdev->bo,0 , &paddr); + +if (!priv->kms) { + ret = -ENODEV ; + goto fail_unlock; + } + + ret =msm_gem_get_iova_locked (fbdev->bo, priv->kms->aspace, &paddr);if (ret) {dev_err (dev->dev,"failed to get buffer obj iova: %d\n" , ret); goto fail_unlock;
drivers/gpu/drm/msm/msm_gem.c +97 -37
215 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gem.h +3 -1
@@ -35,7 +35,9 @@ struct msm_gem_address_space {struct msm_gem_vma {struct drm_mm_node node; +struct msm_gem_address_space *aspace;uint64_t iova; +struct list_head list; };struct msm_gem_object {
@@ -75,7 +77,7 @@ struct msm_gem_object {struct sg_table *sgt;void *vaddr; -struct msm_gem_vma domain[NUM_DOMAINS ]; +struct list_head domains;/* normally (resv == &_resv) except for imported bo's */ struct reservation_object *resv;
drivers/gpu/drm/msm/msm_gem_submit.c +2 -2
@@ -158,7 +158,7 @@ static void submit_unlock_unpin_bo(struct msm_gem_submit *submit, int i)struct msm_gem_object *msm_obj = submit->bos[i].obj;if (submit->bos[i].flags &BO_PINNED ) -msm_gem_put_iova (&msm_obj->base, submit->gpu->id); +msm_gem_put_iova (&msm_obj->base, submit->gpu->aspace);if (submit->bos[i].flags &BO_LOCKED )ww_mutex_unlock (&msm_obj->resv->lock);
@@ -246,7 +246,7 @@ static int submit_pin_objects(struct msm_gem_submit *submit)/* if locking succeeded, pin bo: */ ret =msm_gem_get_iova_locked (&msm_obj->base, - submit->gpu->id, &iova); + submit->gpu->aspace, &iova);if (ret)break ;
drivers/gpu/drm/msm/msm_gpu.c +3 -5
@@ -458,7 +458,7 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)struct msm_gem_object *msm_obj = submit->bos[i].obj;/* move to inactive: */ msm_gem_move_to_inactive (&msm_obj->base); -msm_gem_put_iova (&msm_obj->base, gpu->id); +msm_gem_put_iova (&msm_obj->base, gpu->aspace);drm_gem_object_unreference (&msm_obj->base); }
@@ -539,7 +539,7 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,/* submit takes a reference to the bo and iova until retired: */ drm_gem_object_reference (&msm_obj->base);msm_gem_get_iova_locked (&msm_obj->base, - submit->gpu->id, &iova); + submit->gpu->aspace, &iova);if (submit->bos[i].flags &MSM_SUBMIT_BO_WRITE )msm_gem_move_to_active (&msm_obj->base, gpu, true, submit->fence);
@@ -674,8 +674,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, }else {dev_info (drm->dev,"%s: no IOMMU, fallback to VRAM carveout!\n" , name); } - gpu->id =msm_register_address_space (drm, gpu->aspace); -/* Create ringbuffer: */ mutex_lock (&drm->struct_mutex);
@@ -706,7 +704,7 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)if (gpu->rb) {if (gpu->rb_iova) -msm_gem_put_iova (gpu->rb->bo, gpu->id); +msm_gem_put_iova (gpu->rb->bo, gpu->aspace);msm_ringbuffer_destroy (gpu->rb); }
drivers/gpu/drm/msm/msm_gpu.h +0 -1
@@ -98,7 +98,6 @@ struct msm_gpu {int irq;struct msm_gem_address_space *aspace; -int id;/* Power Control: */ struct regulator *gpu_reg, *gpu_cx;
drivers/gpu/drm/msm/msm_kms.h +3 -0
@@ -73,6 +73,9 @@ struct msm_kms {/* irq number to be passed on to drm_irq_install */ int irq; + +/* mapper-id used to request GEM buffer mapped for scanout: */ +struct msm_gem_address_space *aspace; };/**
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 6/11 drm/msm: Add a struct to pass configuration to msm_gpu_init()
In reply to a message not in the archiveThe amount of information that we need to pass into msm_gpu_init() is steadily increasing, so add a new struct to stabilize the function call and make it easier to add new configuration down the line.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 12 ++++++++++-- drivers/gpu/drm/msm/msm_gpu.c | 13 ++++++------- drivers/gpu/drm/msm/msm_gpu.h | 11 ++++++++++- 3 files changed, 26 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +10 -2
@@ -344,6 +344,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, struct adreno_gpu *adreno_gpu, const struct adreno_gpu_funcs *funcs) { struct adreno_platform_config *config = pdev->dev.platform_data; +struct msm_gpu_config adreno_gpu_config = {0 };struct msm_gpu *gpu = &adreno_gpu->base;int ret;
@@ -363,9 +364,16 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,DBG ("fast_rate=%u, slow_rate=%u, bus_freq=%u" , gpu->fast_rate, gpu->slow_rate, gpu->bus_freq); + adreno_gpu_config.ioname ="kgsl_3d0_reg_memory" ; + adreno_gpu_config.irqname ="kgsl_3d0_irq" ; + + adreno_gpu_config.va_start =SZ_16M ; + adreno_gpu_config.va_end =0xffffffff ; + + adreno_gpu_config.ringsz =RB_SIZE ; + ret =msm_gpu_init (drm, pdev, &adreno_gpu->base, &funcs->base, - adreno_gpu->info->name,"kgsl_3d0_reg_memory" ,"kgsl_3d0_irq" , -RB_SIZE ); + adreno_gpu->info->name, &adreno_gpu_config);if (ret)return ret;
drivers/gpu/drm/msm/msm_gpu.c +6 -7
@@ -569,7 +569,7 @@ static irqreturn_t irq_handler(int irq, void *data)int msm_gpu_init (struct drm_device *drm,struct platform_device *pdev,struct msm_gpu *gpu,const struct msm_gpu_funcs *funcs, -const char *name,const char *ioname,const char *irqname,int ringsz) +const char *name,struct msm_gpu_config *config) {struct iommu_domain *iommu;int i, ret;
@@ -605,14 +605,14 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,BUG_ON (ARRAY_SIZE (clk_names) !=ARRAY_SIZE (gpu->grp_clks));/* Map registers: */ - gpu->mmio =msm_ioremap (pdev, ioname, name); + gpu->mmio =msm_ioremap (pdev, config->ioname, name);if (IS_ERR (gpu->mmio)) { ret =PTR_ERR (gpu->mmio); goto fail; }/* Get Interrupt: */ - gpu->irq =platform_get_irq_byname (pdev, irqname); + gpu->irq =platform_get_irq_byname (pdev, config->irqname);if (gpu->irq <0 ) { ret = gpu->irq;dev_err (drm->dev,"failed to get irq: %d\n" , ret);
@@ -656,9 +656,8 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,*/ iommu =iommu_domain_alloc (&platform_bus_type);if (iommu) { -/* TODO 32b vs 64b address space.. */ - iommu->geometry.aperture_start =SZ_16M ; - iommu->geometry.aperture_end =0xffffffff ; + iommu->geometry.aperture_start = config->va_start; + iommu->geometry.aperture_end = config->va_end;dev_info (drm->dev,"%s: using IOMMU\n" , name); gpu->aspace = msm_gem_address_space_create(&pdev->dev,
@@ -677,7 +676,7 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,/* Create ringbuffer: */ mutex_lock (&drm->struct_mutex); - gpu->rb =msm_ringbuffer_new (gpu, ringsz); + gpu->rb =msm_ringbuffer_new (gpu, config->ringsz);mutex_unlock (&drm->struct_mutex);if (IS_ERR (gpu->rb)) { ret =PTR_ERR (gpu->rb);
drivers/gpu/drm/msm/msm_gpu.h +10 -1
@@ -28,6 +28,14 @@struct msm_gem_submit ;struct msm_gpu_perfcntr ; +struct msm_gpu_config { +const char *ioname; +const char *irqname; +uint64_t va_start; +uint64_t va_end; +unsigned int ringsz; +}; +/* So far, with hardware that I've seen to date, we can have: * + zero, one, or two z180 2d cores * + a3xx or a2xx 3d core, which share a common CP (the firmware
@@ -205,7 +213,8 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,int msm_gpu_init (struct drm_device *drm,struct platform_device *pdev,struct msm_gpu *gpu,const struct msm_gpu_funcs *funcs, -const char *name,const char *ioname,const char *irqname,int ringsz); +const char *name,struct msm_gpu_config *config); +void msm_gpu_cleanup (struct msm_gpu *gpu);struct msm_gpu *adreno_load_gpu (struct drm_device *dev);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 7/11 drm/msm: Remove memptrs->wptr
In reply to a message not in the archivememptrs->wptr seems to be unused. Remove it to avoid confusing the upcoming preemption code.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 --- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 - 2 files changed, 4 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +0 -3
@@ -123,7 +123,6 @@ void adreno_recover(struct msm_gpu *gpu)/* reset completed fence seqno: */ adreno_gpu->memptrs->fence = gpu->fctx->completed_fence; adreno_gpu->memptrs->rptr =0 ; - adreno_gpu->memptrs->wptr =0 ; gpu->funcs->pm_resume (gpu);
@@ -256,7 +255,6 @@ void adreno_show(struct msm_gpu *gpu, struct seq_file *m)seq_printf (m,"fence: %d/%d\n" , adreno_gpu->memptrs->fence, gpu->fctx->last_fence);seq_printf (m,"rptr: %d\n" ,get_rptr (adreno_gpu)); -seq_printf (m,"wptr: %d\n" , adreno_gpu->memptrs->wptr);seq_printf (m,"rb wptr: %d\n" ,get_wptr (gpu->rb)); gpu->funcs->pm_resume (gpu);
@@ -296,7 +294,6 @@ void adreno_dump_info(struct msm_gpu *gpu)printk ("fence: %d/%d\n" , adreno_gpu->memptrs->fence, gpu->fctx->last_fence);printk ("rptr: %d\n" ,get_rptr (adreno_gpu)); -printk ("wptr: %d\n" , adreno_gpu->memptrs->wptr);printk ("rb wptr: %d\n" ,get_wptr (gpu->rb)); }
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -1
@@ -86,7 +86,6 @@ struct adreno_info {struct adreno_rbmemptrs {volatile uint32_t rptr; -volatile uint32_t wptr;volatile uint32_t fence; };
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 8/11 drm/msm: Support multiple ringbuffers
In reply to a message not in the archiveAdd the infrastructure to support the idea of multiple ringbuffers. Assign each ringbuffer an id and use that as an index for the various ring specific operations.
The biggest delta is to support legacy fences. Each fence gets its own sequence number but the legacy functions expect to use a unique integer. To handle this we return a unique identifer for each submission but map it to a specific ring/sequence under the covers. Newer users use a dma_fence pointer anyway so they don't care about the actual sequence ID or ring.
The actual mechanics for multiple ringbuffers are very target specific so this code just allows for the possibility but still only defines one ringbuffer for each target family.
--- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 9 +- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 9 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 45 ++++----- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 2 +- drivers/gpu/drm/msm/adreno/a5xx_power.c | 6 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 156 +++++++++++++++++++++----------- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 36 +++++--- drivers/gpu/drm/msm/msm_drv.h | 2 + drivers/gpu/drm/msm/msm_fence.c | 85 ++++++++++++----- drivers/gpu/drm/msm/msm_fence.h | 13 ++- drivers/gpu/drm/msm/msm_gem.h | 1 + drivers/gpu/drm/msm/msm_gem_submit.c | 10 +- drivers/gpu/drm/msm/msm_gpu.c | 123 ++++++++++++++++--------- drivers/gpu/drm/msm/msm_gpu.h | 38 ++++++-- drivers/gpu/drm/msm/msm_ringbuffer.c | 13 ++- drivers/gpu/drm/msm/msm_ringbuffer.h | 8 +- include/uapi/drm/msm_drm.h | 5 + 17 files changed, 375 insertions(+), 186 deletions(-)
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +5 -4
@@ -44,7 +44,7 @@static bool a3xx_me_init (struct msm_gpu *gpu) { -struct msm_ringbuffer *ring = gpu->rb; +struct msm_ringbuffer *ring = gpu->rb[0 ];OUT_PKT3 (ring,CP_ME_INIT ,17 );OUT_RING (ring,0x000003f7 );
@@ -65,7 +65,7 @@ static bool a3xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 );OUT_RING (ring,0x00000000 ); - gpu->funcs->flush (gpu); + gpu->funcs->flush (gpu, ring);return a3xx_idle (gpu); }
@@ -339,7 +339,7 @@ static void a3xx_destroy(struct msm_gpu *gpu)static bool a3xx_idle (struct msm_gpu *gpu) {/* wait for ringbuffer to drain: */ -if (!adreno_idle (gpu)) +if (!adreno_idle (gpu, gpu->rb[0 ]))return false;/* then wait for GPU to finish: */
@@ -449,6 +449,7 @@ static void a3xx_dump(struct msm_gpu *gpu) .last_fence = adreno_last_fence, .submit = adreno_submit, .flush = adreno_flush, + .active_ring = adreno_active_ring, .irq = a3xx_irq, .destroy = a3xx_destroy,#ifdef CONFIG_DEBUG_FS
@@ -496,7 +497,7 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev) adreno_gpu->registers = a3xx_registers; adreno_gpu->reg_offsets = a3xx_register_offsets; - ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs); + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 );if (ret) goto fail;
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +5 -4
@@ -116,7 +116,7 @@ static void a4xx_enable_hwcg(struct msm_gpu *gpu)static bool a4xx_me_init (struct msm_gpu *gpu) { -struct msm_ringbuffer *ring = gpu->rb; +struct msm_ringbuffer *ring = gpu->rb[0 ];OUT_PKT3 (ring,CP_ME_INIT ,17 );OUT_RING (ring,0x000003f7 );
@@ -137,7 +137,7 @@ static bool a4xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 );OUT_RING (ring,0x00000000 ); - gpu->funcs->flush (gpu); + gpu->funcs->flush (gpu, ring);return a4xx_idle (gpu); }
@@ -337,7 +337,7 @@ static void a4xx_destroy(struct msm_gpu *gpu)static bool a4xx_idle (struct msm_gpu *gpu) {/* wait for ringbuffer to drain: */ -if (!adreno_idle (gpu)) +if (!adreno_idle (gpu, gpu->rb[0 ]))return false;/* then wait for GPU to finish: */
@@ -539,6 +539,7 @@ static int a4xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) .last_fence = adreno_last_fence, .submit = adreno_submit, .flush = adreno_flush, + .active_ring = adreno_active_ring, .irq = a4xx_irq, .destroy = a4xx_destroy,#ifdef CONFIG_DEBUG_FS
@@ -580,7 +581,7 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev) adreno_gpu->registers = a4xx_registers; adreno_gpu->reg_offsets = a4xx_register_offsets; - ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs); + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 );if (ret) goto fail;
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +24 -21
109 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -1
@@ -56,6 +56,6 @@ static inline int spin_usecs(struct msm_gpu *gpu, uint32_t usecs, return -ETIMEDOUT; } -bool a5xx_idle (struct msm_gpu *gpu); +bool a5xx_idle (struct msm_gpu *gpu,struct msm_ringbuffer *ring);#endif /* __A5XX_GPU_H__ */
drivers/gpu/drm/msm/adreno/a5xx_power.c +3 -3
@@ -173,7 +173,7 @@ static int a5xx_gpmu_init(struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a5xx_gpu *a5xx_gpu =to_a5xx_gpu (adreno_gpu); -struct msm_ringbuffer *ring = gpu->rb; +struct msm_ringbuffer *ring = gpu->rb[0 ];if (!a5xx_gpu->gpmu_dwords)return 0 ;
@@ -192,9 +192,9 @@ static int a5xx_gpmu_init(struct msm_gpu *gpu)OUT_PKT7 (ring,CP_SET_PROTECTED_MODE ,1 );OUT_RING (ring,1 ); - gpu->funcs->flush (gpu); + gpu->funcs->flush (gpu, ring); -if (!a5xx_idle (gpu)) { +if (!a5xx_idle (gpu, ring)) {DRM_ERROR ("%s: Unable to load GPMU firmware. GPMU will not be active\n" , gpu->name);return -EINVAL ;
drivers/gpu/drm/msm/adreno/adreno_gpu.c +102 -54
289 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/adreno_gpu.h +23 -13
@@ -81,12 +81,18 @@ struct adreno_info {const struct adreno_info *adreno_info (struct adreno_rev rev); -#define rbmemptr (adreno_gpu, member) \ +#define _sizeof (member) \ + sizeof(((struct adreno_rbmemptrs *) 0)->member[0]) + +#define _base (adreno_gpu, member) \ ((adreno_gpu)->memptrs_iova + offsetof(struct adreno_rbmemptrs, member)) +#define rbmemptr (adreno_gpu, index, member) \ + (_base((adreno_gpu), member) + ((index) * _sizeof(member))) +struct adreno_rbmemptrs { -volatile uint32_t rptr; -volatile uint32_t fence; +volatile uint32_t rptr[MSM_GPU_MAX_RINGS ]; +volatile uint32_t fence[MSM_GPU_MAX_RINGS ]; };struct adreno_gpu {
@@ -196,21 +202,25 @@ static inline int adreno_is_a530(struct adreno_gpu *gpu)int adreno_get_param (struct msm_gpu *gpu,uint32_t param,uint64_t *value);int adreno_hw_init (struct msm_gpu *gpu); -uint32_t adreno_last_fence (struct msm_gpu *gpu); +uint32_t adreno_last_fence (struct msm_gpu *gpu,struct msm_ringbuffer *ring); +uint32_t adreno_submitted_fence (struct msm_gpu *gpu, +struct msm_ringbuffer *ring);void adreno_recover (struct msm_gpu *gpu);void adreno_submit (struct msm_gpu *gpu,struct msm_gem_submit *submit,struct msm_file_private *ctx); -void adreno_flush (struct msm_gpu *gpu); -bool adreno_idle (struct msm_gpu *gpu); +void adreno_flush (struct msm_gpu *gpu,struct msm_ringbuffer *ring); +bool adreno_idle (struct msm_gpu *gpu,struct msm_ringbuffer *ring);#ifdef CONFIG_DEBUG_FS void adreno_show (struct msm_gpu *gpu,struct seq_file *m);#endif void adreno_dump_info (struct msm_gpu *gpu);void adreno_dump (struct msm_gpu *gpu); -void adreno_wait_ring (struct msm_gpu *gpu,uint32_t ndwords); +void adreno_wait_ring (struct msm_ringbuffer *ring,uint32_t ndwords); +struct msm_ringbuffer *adreno_active_ring (struct msm_gpu *gpu);int adreno_gpu_init (struct drm_device *drm,struct platform_device *pdev, -struct adreno_gpu *gpu,const struct adreno_gpu_funcs *funcs); +struct adreno_gpu *gpu,const struct adreno_gpu_funcs *funcs, +int nr_rings);void adreno_gpu_cleanup (struct adreno_gpu *gpu);
@@ -219,7 +229,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,static inline void OUT_PKT0 (struct msm_ringbuffer *ring,uint16_t regindx,uint16_t cnt) { -adreno_wait_ring (ring->gpu, cnt+1 ); +adreno_wait_ring (ring, cnt+1 );OUT_RING (ring,CP_TYPE0_PKT | ((cnt-1 ) <<16 ) | (regindx &0x7FFF )); }
@@ -227,14 +237,14 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,static inline void OUT_PKT2 (struct msm_ringbuffer *ring) { -adreno_wait_ring (ring->gpu,1 ); +adreno_wait_ring (ring,1 );OUT_RING (ring,CP_TYPE2_PKT ); }static inline void OUT_PKT3 (struct msm_ringbuffer *ring,uint8_t opcode,uint16_t cnt) { -adreno_wait_ring (ring->gpu, cnt+1 ); +adreno_wait_ring (ring, cnt+1 );OUT_RING (ring,CP_TYPE3_PKT | ((cnt-1 ) <<16 ) | ((opcode &0xFF ) <<8 )); }
@@ -256,14 +266,14 @@ static inline u32 PM4_PARITY(u32 val)static inline void OUT_PKT4 (struct msm_ringbuffer *ring,uint16_t regindx,uint16_t cnt) { -adreno_wait_ring (ring->gpu, cnt +1 ); +adreno_wait_ring (ring, cnt +1 );OUT_RING (ring,PKT4 (regindx, cnt)); }static inline void OUT_PKT7 (struct msm_ringbuffer *ring,uint8_t opcode,uint16_t cnt) { -adreno_wait_ring (ring->gpu, cnt +1 ); +adreno_wait_ring (ring, cnt +1 );OUT_RING (ring,CP_TYPE7_PKT | (cnt <<0 ) | (PM4_PARITY (cnt) <<15 ) | ((opcode &0x7F ) <<16 ) | (PM4_PARITY (opcode) <<23 )); }
drivers/gpu/drm/msm/msm_drv.h +2 -0
@@ -78,6 +78,8 @@ struct msm_vblank_ctrl {spinlock_t lock; }; +#define MSM_GPU_MAX_RINGS 1 +struct msm_drm_private {struct drm_device *dev;
drivers/gpu/drm/msm/msm_fence.c +64 -21
172 lines not on this page · raw message
drivers/gpu/drm/msm/msm_fence.h +8 -5
@@ -18,17 +18,18 @@#ifndef __MSM_FENCE_H__#define __MSM_FENCE_H__ +#include <linux/hashtable.h> #include "msm_drv.h" +#include "msm_ringbuffer.h" struct msm_fence_context {struct drm_device *dev;const char *name;unsigned context; -/* last_fence == completed_fence --> no pending work */ -uint32_t last_fence;/* last assigned fence */ -uint32_t completed_fence;/* last completed fence */ +u32 fence_id;wait_queue_head_t event;spinlock_t spinlock; + DECLARE_HASHTABLE(hash, 4); }; struct msm_fence_context * msm_fence_context_alloc(struct drm_device *dev,
@@ -39,8 +40,10 @@ int msm_wait_fence(struct msm_fence_context *fctx, uint32_t fence, ktime_t *timeout, bool interruptible);int msm_queue_fence_cb (struct msm_fence_context *fctx,struct msm_fence_cb *cb,uint32_t fence); -void msm_update_fence (struct msm_fence_context *fctx,uint32_t fence); +void msm_update_fence (struct msm_fence_context *fctx, +struct msm_ringbuffer *ring,uint32_t fence); -struct dma_fence *msm_fence_alloc (struct msm_fence_context *fctx); +struct dma_fence *msm_fence_alloc (struct msm_fence_context *fctx, +struct msm_ringbuffer *ring);#endif
drivers/gpu/drm/msm/msm_gem.h +1 -0
@@ -120,6 +120,7 @@ struct msm_gem_submit {struct dma_fence *fence;struct pid *pid;/* submitting process */ bool valid;/* true if no cmdstream patching needed */ +struct msm_ringbuffer *ring;unsigned int nr_cmds;unsigned int nr_bos;struct {
drivers/gpu/drm/msm/msm_gem_submit.c +8 -2
@@ -390,7 +390,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,struct sync_file *sync_file =NULL ;int out_fence_fd =-1 ;unsigned i; -int ret; +int ret, ring;if (!gpu)return -ENXIO ;
@@ -522,7 +522,13 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, submit->nr_cmds = i; - submit->fence =msm_fence_alloc (gpu->fctx); + ring =clamp_t (uint32_t, + (args->flags &MSM_SUBMIT_RING_MASK ) >>MSM_SUBMIT_RING_SHIFT , +0 , gpu->nr_rings -1 ); + + submit->ring = gpu->rb[ring]; + + submit->fence =msm_fence_alloc (gpu->fctx, submit->ring);if (IS_ERR (submit->fence)) { ret =PTR_ERR (submit->fence); submit->fence =NULL ;
drivers/gpu/drm/msm/msm_gpu.c +82 -41
205 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gpu.h +30 -8
@@ -33,7 +33,7 @@ struct msm_gpu_config {const char *irqname;uint64_t va_start;uint64_t va_end; -unsigned int ringsz; +unsigned int nr_rings; };/* So far, with hardware that I've seen to date, we can have:
@@ -57,9 +57,11 @@ struct msm_gpu_funcs {int (*pm_resume)(struct msm_gpu *gpu);void (*submit)(struct msm_gpu *gpu,struct msm_gem_submit *submit,struct msm_file_private *ctx); -void (*flush)(struct msm_gpu *gpu); +void (*flush)(struct msm_gpu *gpu,struct msm_ringbuffer *ring);irqreturn_t (*irq)(struct msm_gpu *irq); -uint32_t (*last_fence)(struct msm_gpu *gpu); +uint32_t (*last_fence)(struct msm_gpu *gpu, +struct msm_ringbuffer *ring); +struct msm_ringbuffer *(*active_ring)(struct msm_gpu *gpu);void (*recover)(struct msm_gpu *gpu);void (*destroy)(struct msm_gpu *gpu);#ifdef CONFIG_DEBUG_FS
@@ -85,9 +87,8 @@ struct msm_gpu {const struct msm_gpu_perfcntr *perfcntrs;uint32_t num_perfcntrs; -/* ringbuffer: */ -struct msm_ringbuffer *rb; -uint64_t rb_iova; +struct msm_ringbuffer *rb[MSM_GPU_MAX_RINGS ]; +int nr_rings;/* list of GEM active objects: */ struct list_head active_list;
@@ -126,15 +127,36 @@ struct msm_gpu {#define DRM_MSM_HANGCHECK_PERIOD 500/* in ms */ #define DRM_MSM_HANGCHECK_JIFFIES msecs_to_jiffies(DRM_MSM_HANGCHECK_PERIOD)struct timer_list hangcheck_timer; -uint32_t hangcheck_fence; +uint32_t hangcheck_fence[MSM_GPU_MAX_RINGS ];struct work_struct recover_work;struct list_head submit_list; }; +/* It turns out that all targets use the same ringbuffer size */ +#define MSM_GPU_RINGBUFFER_SZ SZ_32K + +static inline struct msm_ringbuffer *__get_ring (struct msm_gpu *gpu,int index) +{ +return (index <ARRAY_SIZE (gpu->rb) ? gpu->rb[index] :NULL ); +} + +#define FOR_EACH_RING (gpu, ring, index) \ + for (index = 0, ring = (gpu)->rb[0]; \ + index < (gpu)->nr_rings && index < ARRAY_SIZE((gpu)->rb); \ + index++, ring = __get_ring(gpu, index)) +static inline bool msm_gpu_active (struct msm_gpu *gpu) { -return gpu->fctx->last_fence > gpu->funcs->last_fence (gpu); +struct msm_ringbuffer *ring; +int i; + + FOR_EACH_RING(gpu, ring, i) { +if (ring->last_fence > gpu->funcs->last_fence (gpu, ring)) +return true; + } + +return false; }/* Perf-Counters:
drivers/gpu/drm/msm/msm_ringbuffer.c +6 -7
@@ -18,13 +18,13 @@#include "msm_ringbuffer.h" #include "msm_gpu.h" -struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int size) +struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int id) {struct msm_ringbuffer *ring;int ret; -if (WARN_ON (!is_power_of_2 (size))) -return ERR_PTR (-EINVAL ); +/* We assume everwhere that MSM_GPU_RINGBUFFER_SZ is a power of 2 */ +BUILD_BUG_ON (!is_power_of_2 (MSM_GPU_RINGBUFFER_SZ )); ring =kzalloc (sizeof (*ring),GFP_KERNEL );if (!ring) {
@@ -33,7 +33,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int size) } ring->gpu = gpu; - ring->bo =msm_gem_new (gpu->dev, size,MSM_BO_WC ); + ring->id = id; + ring->bo =msm_gem_new (gpu->dev,MSM_GPU_RINGBUFFER_SZ ,MSM_BO_WC );if (IS_ERR (ring->bo)) { ret =PTR_ERR (ring->bo); ring->bo =NULL ;
@@ -45,11 +46,9 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int size) ret =PTR_ERR (ring->start); goto fail; } - ring->end = ring->start + (size /4 ); + ring->end = ring->start + (MSM_GPU_RINGBUFFER_SZ >>2 ); ring->cur = ring->start; - ring->size = size; -return ring; fail:
drivers/gpu/drm/msm/msm_ringbuffer.h +6 -2
@@ -22,12 +22,16 @@struct msm_ringbuffer {struct msm_gpu *gpu; -int size; +int id;struct drm_gem_object *bo;uint32_t *start, *end, *cur; +uint64_t iova; +/* last_fence == completed_fence --> no pending work */ +uint32_t last_fence; +uint32_t completed_fence; }; -struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int size); +struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int id);void msm_ringbuffer_destroy (struct msm_ringbuffer *ring);/* ringbuffer helpers (the parts that are same for a3xx/a2xx/z180..) */
include/uapi/drm/msm_drm.h +5 -0
@@ -199,10 +199,15 @@ struct drm_msm_gem_submit_bo {#define MSM_SUBMIT_NO_IMPLICIT 0x80000000/* disable implicit sync */ #define MSM_SUBMIT_FENCE_FD_IN 0x40000000/* enable input fence_fd */ #define MSM_SUBMIT_FENCE_FD_OUT 0x20000000/* enable output fence_fd */ + +#define MSM_SUBMIT_RING_MASK 0x000F0000 +#define MSM_SUBMIT_RING_SHIFT 16 +#define MSM_SUBMIT_FLAGS ( \ MSM_SUBMIT_NO_IMPLICIT | \ MSM_SUBMIT_FENCE_FD_IN | \ MSM_SUBMIT_FENCE_FD_OUT | \ + MSM_SUBMIT_RING_MASK | \ 0)/* Each cmdstream submit consists of a table of buffers involved, and
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 9/11 drm/msm: Shadow current pointer in the ring until command is complete
In reply to a message not in the archiveAdd a shadow pointer to track the current command being written into the ring. Don't commit it as 'cur' until the command is submitted. Because 'cur' is used to construct the software copy of the wptr this ensures that somebody peeking in on the ring doesn't assume that a command is inflight while it is being written. This isn't a huge deal with a single ring (though technically the hangcheck could assume the system is prematurely busy when it isn't) but it will be rather important for preemption where the decision to preempt is based on a non-empty ringbuffer. Without a shadow an aggressive preemption scheme could assume that the ringbuffer is non empty and switch to it before the CPU is done writing the command and boom.
Even though preemption won't be supported for all targets because of the way the code is organized it is simpler to make this generic for all targets. The extra load for non-preemption targets should be minimal.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 9 +++++++-- drivers/gpu/drm/msm/msm_ringbuffer.c | 1 + drivers/gpu/drm/msm/msm_ringbuffer.h | 12 ++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +7 -2
@@ -144,6 +144,7 @@ void adreno_recover(struct msm_gpu *gpu)continue ; ring->cur = ring->start; + ring->next = ring->start;/* reset completed fence seqno, discard anything pending: */ adreno_gpu->memptrs->fence[ring->id] = ring->completed_fence;
@@ -240,12 +241,15 @@ void adreno_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring)struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);uint32_t wptr; +/* Copy the shadow to the actual register */ + ring->cur = ring->next; +/* * Mask wptr value that we calculate to fit in the HW range. This is * to account for the possibility that the last command fit exactly into * the ringbuffer and rb->next hasn't wrapped to zero yet */ - wptr =get_wptr (ring) % (MSM_GPU_RINGBUFFER_SZ >>2 ); + wptr = (ring->cur - ring->start) % (MSM_GPU_RINGBUFFER_SZ >>2 );/* ensure writes to ringbuffer have hit system memory: */ mb ();
@@ -366,7 +370,8 @@ static uint32_t ring_freewords(struct msm_ringbuffer *ring) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (ring->gpu);uint32_t size =MSM_GPU_RINGBUFFER_SZ >>2 ; -uint32_t wptr =get_wptr (ring); +/* Use ring->next to calculate free size */ +uint32_t wptr = ring->next - ring->start;uint32_t rptr =get_rptr (adreno_gpu, ring);return (rptr + (size -1 ) - wptr) % size; }
drivers/gpu/drm/msm/msm_ringbuffer.c +1 -0
@@ -47,6 +47,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id) goto fail; } ring->end = ring->start + (MSM_GPU_RINGBUFFER_SZ >>2 ); + ring->next = ring->start; ring->cur = ring->start;return ring;
drivers/gpu/drm/msm/msm_ringbuffer.h +8 -4
@@ -24,7 +24,7 @@ struct msm_ringbuffer {struct msm_gpu *gpu;int id;struct drm_gem_object *bo; -uint32_t *start, *end, *cur; +uint32_t *start, *end, *cur, *next;uint64_t iova;/* last_fence == completed_fence --> no pending work */ uint32_t last_fence;
@@ -39,9 +39,13 @@ struct msm_ringbuffer {static inline void OUT_RING (struct msm_ringbuffer *ring,uint32_t data) { -if (ring->cur == ring->end) - ring->cur = ring->start; - *(ring->cur++) = data; +/* +* ring->next points to the current command being written - it won't be +* committed as ring->cur until the flush +*/ +if (ring->next == ring->end) + ring->next = ring->start; + *(ring->next++) = data; }#endif /* __MSM_RINGBUFFER_H__ */
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 10/11 drm/msm: Make the value of RB_CNTL (almost) generic
In reply to a message not in the archiveWe use a global ringbuffer size and block size for all targets and at least for 5XX preemption we need to know the value the RB_CNTL in several locations so it makes sense to caculate it once and use it everywhere.
The only monkey wrench is that we need to disable the RPTR shadow for A430 targets but that only needs to be done once and doesn't affect A5XX so we can or in the value at init time.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 12 +++++++----- drivers/gpu/drm/msm/msm_gpu.h | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +7 -5
@@ -21,7 +21,6 @@#include "msm_gem.h" #include "msm_mmu.h" -#define RB_BLKSIZE 32int adreno_get_param (struct msm_gpu *gpu,uint32_t param,uint64_t *value) {
@@ -71,11 +70,14 @@ int adreno_hw_init(struct msm_gpu *gpu) } } -/* Setup REG_CP_RB_CNTL: */ +/* +* Setup REG_CP_RB_CNTL. The same value is used across targets (with +* the excpetion of A430 that disables the RPTR shadow) - the cacluation +* for the ringbuffer size and block size is moved to msm_gpu.h for the +* pre-processor to deal with and the A430 variant is ORed in here +*/ adreno_gpu_write (adreno_gpu,REG_ADRENO_CP_RB_CNTL , -/* size is log2(quad-words): */ -AXXX_CP_RB_CNTL_BUFSZ (ilog2 (MSM_GPU_RINGBUFFER_SZ /8 )) | -AXXX_CP_RB_CNTL_BLKSZ (ilog2 (RB_BLKSIZE /8 )) | +MSM_GPU_RB_CNTL_DEFAULT | (adreno_is_a430 (adreno_gpu) ?AXXX_CP_RB_CNTL_NO_UPDATE :0 ));/* Setup ringbuffer address - use ringbuffer[0] for GPU init */
drivers/gpu/drm/msm/msm_gpu.h +5 -0
@@ -135,6 +135,11 @@ struct msm_gpu {/* It turns out that all targets use the same ringbuffer size */ #define MSM_GPU_RINGBUFFER_SZ SZ_32K +#define MSM_GPU_RINGBUFFER_BLKSIZE 32 + +#define MSM_GPU_RB_CNTL_DEFAULT \ + (AXXX_CP_RB_CNTL_BUFSZ(ilog2(MSM_GPU_RINGBUFFER_SZ / 8)) | \ + AXXX_CP_RB_CNTL_BLKSZ(ilog2(MSM_GPU_RINGBUFFER_BLKSIZE / 8)))static inline struct msm_ringbuffer *__get_ring (struct msm_gpu *gpu,int index) {
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 11/11 drm/msm: Implement preemption for A5XX targets
In reply to a message not in the archiveImplement preemption for A5XX targets - this allows multiple ringbuffers for different priorities with automatic preemption of a lower priority ringbuffer if a higher one is ready.
--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 176 ++++++++++++++- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 102 ++++++++- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 345 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 15 +- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 7 +- drivers/gpu/drm/msm/msm_drv.h | 2 +- drivers/gpu/drm/msm/msm_ringbuffer.c | 2 + drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + 9 files changed, 634 insertions(+), 17 deletions(-) create mode 100644 drivers/gpu/drm/msm/adreno/a5xx_preempt.c
drivers/gpu/drm/msm/Makefile +1 -0
@@ -8,6 +8,7 @@ msm-y := \ adreno/a4xx_gpu.o \ adreno/a5xx_gpu.o \ adreno/a5xx_power.o \ + adreno/a5xx_preempt.o \ hdmi/hdmi.o \ hdmi/hdmi_audio.o \ hdmi/hdmi_bridge.o \
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +171 -5
271 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +101 -1
119 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +345 -0
345 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/adreno_gpu.c +6 -9
@@ -93,11 +93,6 @@ int adreno_hw_init(struct msm_gpu *gpu)return 0 ; } -static uint32_t get_wptr (struct msm_ringbuffer *ring) -{ -return ring->cur - ring->start; -} -/* Use this helper to read rptr, since a430 doesn't update rptr in memory */ static uint32_t get_rptr (struct adreno_gpu *adreno_gpu,struct msm_ringbuffer *ring)
@@ -145,6 +140,7 @@ void adreno_recover(struct msm_gpu *gpu)if (!ring)continue ; +/* No need for a lock here, nobody else is peeking in */ ring->cur = ring->start; ring->next = ring->start;
@@ -184,7 +180,7 @@ void adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,case MSM_SUBMIT_CMD_BUF :OUT_PKT3 (ring,adreno_is_a430 (adreno_gpu) ?CP_INDIRECT_BUFFER_PFE :CP_INDIRECT_BUFFER_PFD ,2 ); -OUT_RING (ring, submit->cmd[i].iova); +OUT_RING (ring,lower_32_bits (submit->cmd[i].iova));OUT_RING (ring, submit->cmd[i].size);OUT_PKT2 (ring);break ;
@@ -251,7 +247,7 @@ void adreno_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring)* to account for the possibility that the last command fit exactly into * the ringbuffer and rb->next hasn't wrapped to zero yet */ - wptr = (ring->cur - ring->start) % (MSM_GPU_RINGBUFFER_SZ >>2 ); + wptr =get_wptr (ring);/* ensure writes to ringbuffer have hit system memory: */ mb ();
@@ -269,8 +265,9 @@ bool adreno_idle(struct msm_gpu *gpu, struct msm_ringbuffer *ring)return true;/* TODO maybe we need to reset GPU here to recover from hang? */ -DRM_ERROR ("%s: timeout waiting to drain ringbuffer %d!\n" , gpu->name, - ring->id); +DRM_ERROR ("%s: timeout waiting to drain ringbuffer %d rptr/wptr = %X/%X\n" , + gpu->name, ring->id,get_rptr (adreno_gpu, ring), wptr); +return false; }
drivers/gpu/drm/msm/adreno/adreno_gpu.h +6 -1
@@ -2,7 +2,7 @@* Copyright (C) 2013 Red Hat * Author: Rob Clark <[email protected]> * -* Copyright (c) 2014 The Linux Foundation. All rights reserved. +* Copyright (c) 2014,2017 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by
@@ -332,6 +332,11 @@ static inline void adreno_gpu_write64(struct adreno_gpu *gpu,adreno_gpu_write (gpu, hi,upper_32_bits (data)); } +static inline uint32_t get_wptr (struct msm_ringbuffer *ring) +{ +return (ring->cur - ring->start) % (MSM_GPU_RINGBUFFER_SZ >>2 ); +} +/* * Given a register and a count, return a value to program into * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len
drivers/gpu/drm/msm/msm_drv.h +1 -1
@@ -78,7 +78,7 @@ struct msm_vblank_ctrl {spinlock_t lock; }; -#define MSM_GPU_MAX_RINGS 1 +#define MSM_GPU_MAX_RINGS 4struct msm_drm_private {
drivers/gpu/drm/msm/msm_ringbuffer.c +2 -0
@@ -50,6 +50,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id) ring->next = ring->start; ring->cur = ring->start; +spin_lock_init (&ring->lock); +return ring; fail:
drivers/gpu/drm/msm/msm_ringbuffer.h +1 -0
@@ -29,6 +29,7 @@ struct msm_ringbuffer {/* last_fence == completed_fence --> no pending work */ uint32_t last_fence;uint32_t completed_fence; +spinlock_t lock; };struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int id);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 3/11 drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA
In reply to Jordan CrouseModify the 'pad' member of struct drm_msm_gem_info to 'hint'. If the user sets 'hint' to non-zero it means that they want a IOVA for the GEM object instead of a mmap() offset. Return the iova in the 'offset' member.
--- drivers/gpu/drm/msm/msm_drv.c | 29 +++++++++++++++++++++++++---- include/uapi/drm/msm_drm.h | 4 ++-- 2 files changed, 27 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +25 -4
@@ -677,6 +677,17 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,return ret; } +static int msm_ioctl_gem_info_iova (struct drm_device *dev, +struct drm_gem_object *obj,uint64_t *iova) +{ +struct msm_drm_private *priv = dev->dev_private; + +if (!priv->gpu) +return -EINVAL ; + +return msm_gem_get_iova (obj, priv->gpu->aspace, iova); +} +static int msm_ioctl_gem_info (struct drm_device *dev,void *data,struct drm_file *file) {
@@ -684,14 +695,24 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,struct drm_gem_object *obj;int ret =0 ; -if (args->pad) -return -EINVAL ; - obj =drm_gem_object_lookup (file, args->handle);if (!obj)return -ENOENT ; - args->offset =msm_gem_mmap_offset (obj); +/* +* If the hint variable is set, it means that the user wants a IOVA for +* this buffer. Return the address from the GPU because that is +* probably what it is looking for +*/ +if (args->hint) { +uint64_t iova; + + ret =msm_ioctl_gem_info_iova (dev, obj, &iova); +if (!ret) + args->offset = iova; + }else { + args->offset =msm_gem_mmap_offset (obj); + }drm_gem_object_unreference_unlocked (obj);
include/uapi/drm/msm_drm.h +2 -2
@@ -105,8 +105,8 @@ struct drm_msm_gem_new {struct drm_msm_gem_info {__u32 handle;/* in */ -__u32 pad; -__u64 offset;/* out, offset to pass to mmap() */ +__u32 hint;/* in */ +__u64 offset;/* out, mmap() offset if hint is 0, iova if 1 */ };#define MSM_PREP_READ 0x01
Signature · 1 line
1.9.1
Re: [PATCH 03/11] drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA
Hi Jordan,
Quoted 17 lines · Jordan Crouse
Modify the 'pad' member of struct
drm_msm_gem_infoto 'hint'. If the user sets 'hint' to non-zero it means that they want a IOVA for the GEM object instead of ammap()offset. Return the iova in the 'offset' member.Signed-off-by Jordan Crouse <[email protected]>--- drivers/gpu/drm/msm/msm_drv.c | 29 +++++++++++++++++++++++++---- include/uapi/drm/msm_drm.h | 4 ++-- 2 files changed, 27 insertions(+), 6 deletions(-)drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -677,6 +677,17 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,return ret;
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, · line 687
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +8
-0} +static int msm_ioctl_gem_info_iova (struct drm_device *dev, +struct drm_gem_object *obj,uint64_t *iova) +{ +struct msm_drm_private *priv = dev->dev_private; + +if (!priv->gpu) +return -EINVAL ; +
Not too familiar with msm so perhaps a silly question: how can we trigger this ?
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_info(struct drm_device *dev, void *data, · line 689
Quoted 13 lines
drivers/gpu/drm/msm/msm_drv.c +3
-3+return msm_gem_get_iova (obj, priv->gpu->aspace, iova); +} +static int msm_ioctl_gem_info (struct drm_device *dev,void *data,struct drm_file *file) {@@ -684,14 +695,24 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,struct drm_gem_object *obj;int ret =0 ; -if (args->pad) -return -EINVAL ; -
Please keep the input validation before doing any work (the lookup below).
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_info(struct drm_device *dev, void *data, · line 707
Quoted 11 lines
drivers/gpu/drm/msm/msm_drv.c +6
-1obj =drm_gem_object_lookup (file, args->handle);if (!obj)return -ENOENT ; - args->offset =msm_gem_mmap_offset (obj); +/* +* If the hint variable is set, it means that the user wants a IOVA for +* this buffer. Return the address from the GPU because that is +* probably what it is looking for +*/ +if (args->hint) {
One could also rename hint to flags. Regardless of the name you can use hint/flags as a bitmask.
Quoted 16 lines
drivers/gpu/drm/msm/msm_drv.c +8
-0+uint64_t iova; + + ret =msm_ioctl_gem_info_iova (dev, obj, &iova); +if (!ret) + args->offset = iova; + }else { + args->offset =msm_gem_mmap_offset (obj); + }drm_gem_object_unreference_unlocked (obj);include/uapi/drm/msm_drm.h +0
-0
include/uapi/drm/msm_drm.h struct drm_msm_gem_new { · line 108
Quoted 6 lines
include/uapi/drm/msm_drm.h +1
-2@@ -105,8 +105,8 @@ struct drm_msm_gem_new {struct drm_msm_gem_info {__u32 handle;/* in */ -__u32 pad; -__u64 offset;/* out, offset to pass to mmap() */ +__u32 hint;/* in */
Please add explicit #define for the currently valid hints/flags.
include/uapi/drm/msm_drm.h struct drm_msm_gem_new { · line 109
Quoted 1 line
include/uapi/drm/msm_drm.h +1
-0+__u64 offset;/* out, mmap() offset if hint is 0, iova if 1 */
Other drivers have used anonymous unions to improve the naming, in such situations.
struct drm_msm_gem_info {
__u32 handle; /* in */
__u32 hint; /* in */
union { /* out */ __u64 offset; /* offset if hint is FOO */
__u64 iova; /* iova if hint is BAR */
};
};
Thanks
Emil
A message that is not in the archive (sent off-list or not yet received): CACvgo513+d19O2rzZ8NXEFgojUQkm2XPae-AdOXXReLM_a1euw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 03/11] drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA
Quoted 22 lines · Emil Velikov
Hi Jordan,
Quoted 19 lines · Jordan Crouse
Modify the 'pad' member of struct
drm_msm_gem_infoto 'hint'. If the user sets 'hint' to non-zero it means that they want a IOVA for the GEM object instead of ammap()offset. Return the iova in the 'offset' member.Signed-off-by Jordan Crouse <[email protected]>--- drivers/gpu/drm/msm/msm_drv.c | 29 +++++++++++++++++++++++++---- include/uapi/drm/msm_drm.h | 4 ++-- 2 files changed, 27 insertions(+), 6 deletions(-)drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -677,6 +677,17 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,return ret; }
Quoted 9 lines
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, · line 687
Quoted 8 lines
drivers/gpu/drm/msm/msm_drv.c +8
-0+static int msm_ioctl_gem_info_iova (struct drm_device *dev, +struct drm_gem_object *obj,uint64_t *iova) +{ +struct msm_drm_private *priv = dev->dev_private; + +if (!priv->gpu) +return -EINVAL ; +Not too familiar with msm so perhaps a silly question: how can we trigger this ?
if gpu has not loaded (for example, missing firmware, or kernel does not have iommu, etc)
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +3
-0+return msm_gem_get_iova (obj, priv->gpu->aspace, iova); +} +static int msm_ioctl_gem_info (struct drm_device *dev,void *data,struct drm_file *file) {@@ -684,14 +695,24 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,struct drm_gem_object *obj;int ret =0 ;
Quoted 4 lines
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_info(struct drm_device *dev, void *data, · line 689
Quoted 3 lines
drivers/gpu/drm/msm/msm_drv.c +0
-3-if (args->pad) -return -EINVAL ; -Please keep the input validation before doing any work (the lookup below).
+1 for making this args->flags and checking against GEM_INFO_VALID_FLAGS up front. We may want to use some of those other bits some day
Quoted 42 lines
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_info(struct drm_device *dev, void *data, · line 707
Quoted 11 lines
drivers/gpu/drm/msm/msm_drv.c +6
-1obj =drm_gem_object_lookup (file, args->handle);if (!obj)return -ENOENT ; - args->offset =msm_gem_mmap_offset (obj); +/* +* If the hint variable is set, it means that the user wants a IOVA for +* this buffer. Return the address from the GPU because that is +* probably what it is looking for +*/ +if (args->hint) {One could also rename hint to flags. Regardless of the name you can use hint/flags as a bitmask.
Quoted 16 lines
drivers/gpu/drm/msm/msm_drv.c +8
-0+uint64_t iova; + + ret =msm_ioctl_gem_info_iova (dev, obj, &iova); +if (!ret) + args->offset = iova; + }else { + args->offset =msm_gem_mmap_offset (obj); + }drm_gem_object_unreference_unlocked (obj);include/uapi/drm/msm_drm.h +0
-0include/uapi/drm/msm_drm.h struct drm_msm_gem_new { · line 108
Quoted 6 lines
include/uapi/drm/msm_drm.h +1
-2@@ -105,8 +105,8 @@ struct drm_msm_gem_new {struct drm_msm_gem_info {__u32 handle;/* in */ -__u32 pad; -__u64 offset;/* out, offset to pass to mmap() */ +__u32 hint;/* in */ Please add explicit #define for the currently valid hints/flags.
include/uapi/drm/msm_drm.h struct drm_msm_gem_new { · line 109
Quoted 1 line
include/uapi/drm/msm_drm.h +1
-0+__u64 offset;/* out, mmap() offset if hint is 0, iova if 1 */ Other drivers have used anonymous unions to improve the naming, in such situations.
Quoted 8 lines
struct
drm_msm_gem_info{__u32 handle; /* in */ __u32 hint; /* in */ union { /* out */
__u64offset; /* offset if hint is FOO */
__u64iova; /* iova if hint is BAR */
};
};
is anon union legit for uabi? I was under the impression that for some reason it was not. But I could be wrong.
BR,
-R
Quoted 7 lines
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
A message that is not in the archive (sent off-list or not yet received): CAF6AEGvUoW2695_HjgfGbpbPaSnOB2gfPa=3UMTDGvom+DxcwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 03/11] drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA
Quoted 33 lines · Rob Clark
Quoted 22 lines · Emil Velikov
Hi Jordan,
Quoted 19 lines · Jordan Crouse
Modify the 'pad' member of struct
drm_msm_gem_infoto 'hint'. If the user sets 'hint' to non-zero it means that they want a IOVA for the GEM object instead of ammap()offset. Return the iova in the 'offset' member.Signed-off-by Jordan Crouse <[email protected]>--- drivers/gpu/drm/msm/msm_drv.c | 29 +++++++++++++++++++++++++---- include/uapi/drm/msm_drm.h | 4 ++-- 2 files changed, 27 insertions(+), 6 deletions(-)drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -677,6 +677,17 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,return ret; }Quoted 9 lines
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, · line 687
Quoted 8 lines
drivers/gpu/drm/msm/msm_drv.c +8
-0+static int msm_ioctl_gem_info_iova (struct drm_device *dev, +struct drm_gem_object *obj,uint64_t *iova) +{ +struct msm_drm_private *priv = dev->dev_private; + +if (!priv->gpu) +return -EINVAL ; +Not too familiar with msm so perhaps a silly question: how can we trigger this ?
Quoted 3 lines
if gpu has not loaded (for example, missing firmware, or kernel does not have iommu, etc)
Thanks Rob. I was under the impression that in such cases the driver will/should fail to load.
Quoted 13 lines
Quoted 4 lines
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, · line 688
Quoted 1 line
drivers/gpu/drm/msm/msm_drv.c +1
-0+__u64 offset;/* out, mmap() offset if hint is 0, iova if 1 */ Other drivers have used anonymous unions to improve the naming, in such situations.
Quoted 8 lines
struct
drm_msm_gem_info{__u32 handle; /* in */ __u32 hint; /* in */ union { /* out */
__u64offset; /* offset if hint is FOO */
__u64iova; /* iova if hint is BAR */
};
};
Quoted 3 lines
is anon union legit for uabi? I was under the impression that for some reason it was not. But I could be wrong.
Haven't seen any wording against it and we do have a few instances in DRM UABI land.
Either way it was just an idea.
Regards,
Emil
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
Re: [PATCH 03/11] drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA
Quoted 34 lines · Emil Velikov
Quoted 33 lines · Rob Clark
Quoted 31 lines · Emil Velikov
Hi Jordan,
Quoted 17 lines · Jordan Crouse
Modify the 'pad' member of struct
drm_msm_gem_infoto 'hint'. If the user sets 'hint' to non-zero it means that they want a IOVA for the GEM object instead of ammap()offset. Return the iova in the 'offset' member.Signed-off-by Jordan Crouse <[email protected]>--- drivers/gpu/drm/msm/msm_drv.c | 29 +++++++++++++++++++++++++---- include/uapi/drm/msm_drm.h | 4 ++-- 2 files changed, 27 insertions(+), 6 deletions(-)drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -677,6 +677,17 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,return ret;drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, · line 687
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +8
-0} +static int msm_ioctl_gem_info_iova (struct drm_device *dev, +struct drm_gem_object *obj,uint64_t *iova) +{ +struct msm_drm_private *priv = dev->dev_private; + +if (!priv->gpu) +return -EINVAL ; +Not too familiar with msm so perhaps a silly question: how can we trigger this ?
Quoted 5 lines
Quoted 3 lines
if gpu has not loaded (for example, missing firmware, or kernel does not have iommu, etc)
Thanks Rob. I was under the impression that in such cases the driver will/should fail to load.
radeon/nouveau/i915 will all, iirc, fail to load. I made drm/msm defer to loading gpu until first open() since having to constantly rebuild initrd seemed annoying ;-)
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/gpu/drm/msm/msm_drv.c static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, · line 688
Quoted 1 line
drivers/gpu/drm/msm/msm_drv.c +1
-0+__u64 offset;/* out, mmap() offset if hint is 0, iova if 1 */ Other drivers have used anonymous unions to improve the naming, in such situations.
struct
drm_msm_gem_info{__u32 handle; /* in */ __u32 hint; /* in */ union { /* out */
__u64offset; /* offset if hint is FOO */
__u64iova; /* iova if hint is BAR */
};
};
Quoted 6 lines
Quoted 3 lines
is anon union legit for uabi? I was under the impression that for some reason it was not. But I could be wrong.
Haven't seen any wording against it and we do have a few instances in DRM UABI land.
Either way it was just an idea.
hmm, ok, if we are already using it in uabi (and not just ancient ioctls) then maybe I am wrong..
BR,
-R
Quoted 2 lines
Regards,
Emil
PATCH 4/11 drm/msm: Remove idle function hook
In reply to Jordan CrouseThere isn't any generic code that uses ->idle so remove it.
--- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 9 ++++----- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a5xx_power.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 1 - 6 files changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +2 -2
@@ -40,6 +40,7 @@extern bool hang_debug;static void a3xx_dump (struct msm_gpu *gpu); +static bool a3xx_idle (struct msm_gpu *gpu);static bool a3xx_me_init (struct msm_gpu *gpu) {
@@ -65,7 +66,7 @@ static bool a3xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 ); gpu->funcs->flush (gpu); -return gpu->funcs->idle (gpu); +return a3xx_idle (gpu); }static int a3xx_hw_init (struct msm_gpu *gpu)
@@ -448,7 +449,6 @@ static void a3xx_dump(struct msm_gpu *gpu) .last_fence = adreno_last_fence, .submit = adreno_submit, .flush = adreno_flush, - .idle = a3xx_idle, .irq = a3xx_irq, .destroy = a3xx_destroy,#ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +2 -2
@@ -31,6 +31,7 @@extern bool hang_debug;static void a4xx_dump (struct msm_gpu *gpu); +static bool a4xx_idle (struct msm_gpu *gpu);/* * a4xx_enable_hwcg() - Program the clock control registers
@@ -137,7 +138,7 @@ static bool a4xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 ); gpu->funcs->flush (gpu); -return gpu->funcs->idle (gpu); +return a4xx_idle (gpu); }static int a4xx_hw_init (struct msm_gpu *gpu)
@@ -538,7 +539,6 @@ static int a4xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) .last_fence = adreno_last_fence, .submit = adreno_submit, .flush = adreno_flush, - .idle = a4xx_idle, .irq = a4xx_irq, .destroy = a4xx_destroy,#ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +4 -5
@@ -391,7 +391,7 @@ static int a5xx_me_init(struct msm_gpu *gpu) gpu->funcs->flush (gpu); -return gpu->funcs->idle (gpu) ?0 : -EINVAL ; +return a5xx_idle (gpu) ?0 : -EINVAL ; } static struct drm_gem_object *a5xx_ucode_load_bo(struct msm_gpu *gpu,
@@ -699,7 +699,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)OUT_RING (gpu->rb,0x0F ); gpu->funcs->flush (gpu); -if (!gpu->funcs->idle (gpu)) +if (!a5xx_idle (gpu))return -EINVAL ; }
@@ -716,7 +716,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)OUT_RING (gpu->rb,0x00000000 ); gpu->funcs->flush (gpu); -if (!gpu->funcs->idle (gpu)) +if (!a5xx_idle (gpu))return -EINVAL ; }else {/* Print a warning so if we die, we know why */
@@ -790,7 +790,7 @@ static inline bool _a5xx_check_idle(struct msm_gpu *gpu) A5XX_RBBM_INT_0_MASK_MISC_HANG_DETECT); } -static bool a5xx_idle (struct msm_gpu *gpu) +bool a5xx_idle (struct msm_gpu *gpu) {/* wait for CP to drain ringbuffer: */ if (!adreno_idle (gpu))
@@ -1091,7 +1091,6 @@ static void a5xx_show(struct msm_gpu *gpu, struct seq_file *m) .last_fence = adreno_last_fence, .submit = a5xx_submit, .flush = adreno_flush, - .idle = a5xx_idle, .irq = a5xx_irq, .destroy = a5xx_destroy, .show = a5xx_show,
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -0
@@ -56,5 +56,6 @@ static inline int spin_usecs(struct msm_gpu *gpu, uint32_t usecs, return -ETIMEDOUT; } +bool a5xx_idle (struct msm_gpu *gpu);#endif /* __A5XX_GPU_H__ */
drivers/gpu/drm/msm/adreno/a5xx_power.c +1 -1
@@ -194,7 +194,7 @@ static int a5xx_gpmu_init(struct msm_gpu *gpu) gpu->funcs->flush (gpu); -if (!gpu->funcs->idle (gpu)) { +if (!a5xx_idle (gpu)) {DRM_ERROR ("%s: Unable to load GPMU firmware. GPMU will not be active\n" , gpu->name);return -EINVAL ;
drivers/gpu/drm/msm/msm_gpu.h +0 -1
@@ -50,7 +50,6 @@ struct msm_gpu_funcs {void (*submit)(struct msm_gpu *gpu,struct msm_gem_submit *submit,struct msm_file_private *ctx);void (*flush)(struct msm_gpu *gpu); -bool (*idle)(struct msm_gpu *gpu);irqreturn_t (*irq)(struct msm_gpu *irq);uint32_t (*last_fence)(struct msm_gpu *gpu);void (*recover)(struct msm_gpu *gpu);
Signature · 1 line
1.9.1
PATCH 5/11 drm/msm: get an iova from the address space instead of an id
In reply to Jordan CrouseIn the future we won't have a fixed set of addresses spaces. Instead of going through the effort of assigning a ID for each address space just use the address space itself as a token for getting / putting an iova.
This forces a few changes in the gem object however: instead of using a simple index into a list of domains, we need to maintain a list of them. Luckily the list will be pretty small; even with dynamic address spaces we wouldn't ever see more than two or three.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 8 +- drivers/gpu/drm/msm/adreno/a5xx_power.c | 5 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 6 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 15 +++- drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 8 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 18 ++--- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h | 3 - drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c | 13 ++-- drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 5 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 11 +-- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 13 ++-- drivers/gpu/drm/msm/msm_drv.c | 14 ---- drivers/gpu/drm/msm/msm_drv.h | 25 +++--- drivers/gpu/drm/msm/msm_fb.c | 15 ++-- drivers/gpu/drm/msm/msm_fbdev.c | 10 ++- drivers/gpu/drm/msm/msm_gem.c | 124 +++++++++++++++++++++--------- drivers/gpu/drm/msm/msm_gem.h | 4 +- drivers/gpu/drm/msm/msm_gem_submit.c | 4 +- drivers/gpu/drm/msm/msm_gpu.c | 8 +- drivers/gpu/drm/msm/msm_gpu.h | 1 - drivers/gpu/drm/msm/msm_kms.h | 3 + 22 files changed, 184 insertions(+), 133 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +4 -4
@@ -415,7 +415,7 @@ static struct drm_gem_object *a5xx_ucode_load_bo(struct msm_gpu *gpu, }if (iova) { -int ret =msm_gem_get_iova (bo, gpu->id, iova); +int ret =msm_gem_get_iova (bo, gpu->aspace, iova);if (ret) {drm_gem_object_unreference_unlocked (bo);
@@ -757,19 +757,19 @@ static void a5xx_destroy(struct msm_gpu *gpu)if (a5xx_gpu->pm4_bo) {if (a5xx_gpu->pm4_iova) -msm_gem_put_iova (a5xx_gpu->pm4_bo, gpu->id); +msm_gem_put_iova (a5xx_gpu->pm4_bo, gpu->aspace);drm_gem_object_unreference_unlocked (a5xx_gpu->pm4_bo); }if (a5xx_gpu->pfp_bo) {if (a5xx_gpu->pfp_iova) -msm_gem_put_iova (a5xx_gpu->pfp_bo, gpu->id); +msm_gem_put_iova (a5xx_gpu->pfp_bo, gpu->aspace);drm_gem_object_unreference_unlocked (a5xx_gpu->pfp_bo); }if (a5xx_gpu->gpmu_bo) {if (a5xx_gpu->gpmu_bo) -msm_gem_put_iova (a5xx_gpu->gpmu_bo, gpu->id); +msm_gem_put_iova (a5xx_gpu->gpmu_bo, gpu->aspace);drm_gem_object_unreference_unlocked (a5xx_gpu->gpmu_bo); }
drivers/gpu/drm/msm/adreno/a5xx_power.c +3 -2
@@ -301,7 +301,8 @@ void a5xx_gpmu_ucode_init(struct msm_gpu *gpu)if (IS_ERR (a5xx_gpu->gpmu_bo)) goto err; -if (msm_gem_get_iova (a5xx_gpu->gpmu_bo, gpu->id, &a5xx_gpu->gpmu_iova)) +if (msm_gem_get_iova (a5xx_gpu->gpmu_bo, gpu->aspace, + &a5xx_gpu->gpmu_iova)) goto err; ptr =msm_gem_get_vaddr (a5xx_gpu->gpmu_bo);
@@ -330,7 +331,7 @@ void a5xx_gpmu_ucode_init(struct msm_gpu *gpu) err:if (a5xx_gpu->gpmu_iova) -msm_gem_put_iova (a5xx_gpu->gpmu_bo, gpu->id); +msm_gem_put_iova (a5xx_gpu->gpmu_bo, gpu->aspace);if (a5xx_gpu->gpmu_bo)drm_gem_object_unreference_unlocked (a5xx_gpu->gpmu_bo);
drivers/gpu/drm/msm/adreno/adreno_gpu.c +3 -3
@@ -61,7 +61,7 @@ int adreno_hw_init(struct msm_gpu *gpu)DBG ("%s" , gpu->name); - ret =msm_gem_get_iova (gpu->rb->bo, gpu->id, &gpu->rb_iova); + ret =msm_gem_get_iova (gpu->rb->bo, gpu->aspace, &gpu->rb_iova);if (ret) { gpu->rb_iova =0 ;dev_err (gpu->dev->dev,"could not map ringbuffer: %d\n" , ret);
@@ -411,7 +411,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,return -ENOMEM ; } - ret =msm_gem_get_iova (adreno_gpu->memptrs_bo, gpu->id, + ret =msm_gem_get_iova (adreno_gpu->memptrs_bo, gpu->aspace, &adreno_gpu->memptrs_iova);if (ret) {dev_err (drm->dev,"could not map memptrs: %d\n" , ret);
@@ -430,7 +430,7 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)msm_gem_put_vaddr (adreno_gpu->memptrs_bo);if (adreno_gpu->memptrs_iova) -msm_gem_put_iova (adreno_gpu->memptrs_bo, gpu->id); +msm_gem_put_iova (adreno_gpu->memptrs_bo, gpu->aspace);drm_gem_object_unreference_unlocked (adreno_gpu->memptrs_bo); }
drivers/gpu/drm/msm/dsi/dsi_host.c +13 -2
@@ -28,6 +28,7 @@#include <linux/regmap.h> #include <video/mipi_display.h> +#include "msm_kms.h" #include "dsi.h" #include "dsi.xml.h" #include "sfpb.xml.h"
@@ -980,6 +981,7 @@ static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host)static int dsi_tx_buf_alloc (struct msm_dsi_host *msm_host,int size) {struct drm_device *dev = msm_host->dev; +struct msm_drm_private *priv = dev->dev_private;const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd;int ret;uint64_t iova;
@@ -996,7 +998,13 @@ static int dsi_tx_buf_alloc(struct msm_dsi_host *msm_host, int size)return ret; } - ret =msm_gem_get_iova_locked (msm_host->tx_gem_obj,0 , &iova); +if (!priv->kms) { +pr_err ("%s: No KMS is initalized\n" , __func__); +return -ENODEV ; + } + + ret =msm_gem_get_iova_locked (msm_host->tx_gem_obj, + priv->kms->aspace, &iova);mutex_unlock (&dev->struct_mutex);if (ret) {pr_err ("%s: failed to get iova, %d\n" , __func__, ret);
@@ -1028,9 +1036,12 @@ static int dsi_tx_buf_alloc(struct msm_dsi_host *msm_host, int size)static void dsi_tx_buf_free (struct msm_dsi_host *msm_host) {struct drm_device *dev = msm_host->dev; +struct msm_drm_private *priv = dev->dev_private;if (msm_host->tx_gem_obj) { -msm_gem_put_iova (msm_host->tx_gem_obj,0 ); +if (priv->kms) +msm_gem_put_iova (msm_host->tx_gem_obj, + priv->kms->aspace);mutex_lock (&dev->struct_mutex);msm_gem_free_object (msm_host->tx_gem_obj); msm_host->tx_gem_obj =NULL ;
drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c +5 -3
@@ -133,7 +133,7 @@ static void unref_cursor_worker(struct drm_flip_work *work, void *val) container_of(work, struct mdp4_crtc, unref_cursor_work);struct mdp4_kms *mdp4_kms =get_kms (&mdp4_crtc->base); -msm_gem_put_iova (val, mdp4_kms->id); +msm_gem_put_iova (val, mdp4_kms->base.base.aspace);drm_gem_object_unreference_unlocked (val); }
@@ -378,7 +378,8 @@ static void update_cursor(struct drm_crtc *crtc)if (next_bo) {/* take a obj ref + iova ref when we start scanning out: */ drm_gem_object_reference (next_bo); -msm_gem_get_iova_locked (next_bo, mdp4_kms->id, &iova); +msm_gem_get_iova_locked (next_bo, + mdp4_kms->base.base.aspace, &iova);/* enable cursor: */ mdp4_write(mdp4_kms, REG_MDP4_DMA_CURSOR_SIZE(dma),
@@ -435,7 +436,8 @@ static int mdp4_crtc_cursor_set(struct drm_crtc *crtc, }if (cursor_bo) { - ret =msm_gem_get_iova (cursor_bo, mdp4_kms->id, &iova); + ret =msm_gem_get_iova (cursor_bo, mdp4_kms->base.base.aspace, + &iova);if (ret) goto fail; }else {
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c +6 -12
@@ -160,7 +160,10 @@ static void mdp4_destroy(struct msm_kms *kms) {struct mdp4_kms *mdp4_kms =to_mdp4_kms (to_mdp_kms (kms));struct device *dev = mdp4_kms->dev->dev; -struct msm_gem_address_space *aspace = mdp4_kms->aspace; +struct msm_gem_address_space *aspace = kms->aspace; + +if (mdp4_kms->blank_cursor_iova) +msm_gem_put_iova (mdp4_kms->blank_cursor_bo, aspace);if (aspace) { aspace->mmu->funcs->detach(aspace->mmu,
@@ -168,8 +171,6 @@ static void mdp4_destroy(struct msm_kms *kms)msm_gem_address_space_destroy (aspace); } -if (mdp4_kms->blank_cursor_iova) -msm_gem_put_iova (mdp4_kms->blank_cursor_bo, mdp4_kms->id);drm_gem_object_unreference_unlocked (mdp4_kms->blank_cursor_bo);if (mdp4_kms->rpm_enabled)
@@ -540,7 +541,7 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) goto fail; } - mdp4_kms->aspace = aspace; + kms->aspace = aspace; ret = aspace->mmu->funcs->attach (aspace->mmu, iommu_ports,ARRAY_SIZE (iommu_ports));
@@ -552,13 +553,6 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) aspace =NULL ; } - mdp4_kms->id =msm_register_address_space (dev, aspace); -if (mdp4_kms->id <0 ) { - ret = mdp4_kms->id; -dev_err (dev->dev,"failed to register mdp4 iommu: %d\n" , ret); - goto fail; - } - ret =modeset_init (mdp4_kms);if (ret) {dev_err (dev->dev,"modeset_init failed: %d\n" , ret);
@@ -575,7 +569,7 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) goto fail; } - ret =msm_gem_get_iova (mdp4_kms->blank_cursor_bo, mdp4_kms->id, + ret =msm_gem_get_iova (mdp4_kms->blank_cursor_bo, kms->aspace, &mdp4_kms->blank_cursor_iova);if (ret) {dev_err (dev->dev,"could not pin blank-cursor bo: %d\n" , ret);
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h +0 -3
@@ -33,8 +33,6 @@ struct mdp4_kms {int rev;/* mapper-id used to request GEM buffer mapped for scanout: */ -int id; -void __iomem *mmio;struct regulator *vdd;
@@ -43,7 +41,6 @@ struct mdp4_kms {struct clk *pclk;struct clk *lut_clk;struct clk *axi_clk; -struct msm_gem_address_space *aspace;struct mdp_irq error_handler;
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c +7 -6
@@ -109,7 +109,7 @@ static int mdp4_plane_prepare_fb(struct drm_plane *plane,return 0 ;DBG ("%s: prepare: FB[%u]" , mdp4_plane->name, fb->base.id); -return msm_framebuffer_prepare (fb, mdp4_kms->id); +return msm_framebuffer_prepare (fb, mdp4_kms->base.base.aspace); } static void mdp4_plane_cleanup_fb(struct drm_plane *plane,
@@ -123,7 +123,7 @@ static void mdp4_plane_cleanup_fb(struct drm_plane *plane,return ;DBG ("%s: cleanup: FB[%u]" , mdp4_plane->name, fb->base.id); -msm_framebuffer_cleanup (fb, mdp4_kms->id); +msm_framebuffer_cleanup (fb, mdp4_kms->base.base.aspace); }
@@ -161,6 +161,7 @@ static void mdp4_plane_set_scanout(struct drm_plane *plane, {struct mdp4_plane *mdp4_plane =to_mdp4_plane (plane);struct mdp4_kms *mdp4_kms =get_kms (plane); +struct msm_kms *kms = &mdp4_kms->base.base;enum mdp4_pipe pipe = mdp4_plane->pipe; mdp4_write(mdp4_kms, REG_MDP4_PIPE_SRC_STRIDE_A(pipe),
@@ -172,13 +173,13 @@ static void mdp4_plane_set_scanout(struct drm_plane *plane, MDP4_PIPE_SRC_STRIDE_B_P3(fb->pitches[3]));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP0_BASE (pipe), -msm_framebuffer_iova (fb, mdp4_kms->id,0 )); +msm_framebuffer_iova (fb, kms->aspace,0 ));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP1_BASE (pipe), -msm_framebuffer_iova (fb, mdp4_kms->id,1 )); +msm_framebuffer_iova (fb, kms->aspace,1 ));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP2_BASE (pipe), -msm_framebuffer_iova (fb, mdp4_kms->id,2 )); +msm_framebuffer_iova (fb, kms->aspace,2 ));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP3_BASE (pipe), -msm_framebuffer_iova (fb, mdp4_kms->id,3 )); +msm_framebuffer_iova (fb, kms->aspace,3 )); plane->fb = fb; }
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +3 -2
@@ -165,7 +165,7 @@ static void unref_cursor_worker(struct drm_flip_work *work, void *val) container_of(work, struct mdp5_crtc, unref_cursor_work);struct mdp5_kms *mdp5_kms =get_kms (&mdp5_crtc->base); -msm_gem_put_iova (val, mdp5_kms->id); +msm_gem_put_iova (val, mdp5_kms->base.base.aspace);drm_gem_object_unreference_unlocked (val); }
@@ -520,7 +520,8 @@ static int mdp5_crtc_cursor_set(struct drm_crtc *crtc,if (!cursor_bo)return -ENOENT ; - ret =msm_gem_get_iova (cursor_bo, mdp5_kms->id, &cursor_addr); + ret =msm_gem_get_iova (cursor_bo, mdp5_kms->base.base.aspace, + &cursor_addr);if (ret)return -EINVAL ;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +2 -9
@@ -151,7 +151,7 @@ static int mdp5_set_split_display(struct msm_kms *kms,static void mdp5_kms_destroy (struct msm_kms *kms) {struct mdp5_kms *mdp5_kms =to_mdp5_kms (to_mdp_kms (kms)); -struct msm_gem_address_space *aspace = mdp5_kms->aspace; +struct msm_gem_address_space *aspace = kms->aspace;int i;for (i =0 ; i < mdp5_kms->num_hwpipes; i++)
@@ -707,7 +707,7 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev) goto fail; } - mdp5_kms->aspace = aspace; + kms->aspace = aspace; ret = aspace->mmu->funcs->attach (aspace->mmu, iommu_ports,ARRAY_SIZE (iommu_ports));
@@ -722,13 +722,6 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev) aspace =NULL ;; } - mdp5_kms->id =msm_register_address_space (dev, aspace); -if (mdp5_kms->id <0 ) { - ret = mdp5_kms->id; -dev_err (&pdev->dev,"failed to register mdp5 iommu: %d\n" , ret); - goto fail; - } - ret =modeset_init (mdp5_kms);if (ret) {dev_err (&pdev->dev,"modeset_init failed: %d\n" , ret);
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h +0 -4
@@ -48,10 +48,6 @@ struct mdp5_kms {struct mdp5_state *state;struct drm_modeset_lock state_lock; -/* mapper-id used to request GEM buffer mapped for scanout: */ -int id; -struct msm_gem_address_space *aspace; -struct mdp5_smp *smp;struct mdp5_ctl_manager *ctlm;
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +7 -6
@@ -259,7 +259,7 @@ static int mdp5_plane_prepare_fb(struct drm_plane *plane,return 0 ;DBG ("%s: prepare: FB[%u]" , plane->name, fb->base.id); -return msm_framebuffer_prepare (fb, mdp5_kms->id); +return msm_framebuffer_prepare (fb, mdp5_kms->base.base.aspace); } static void mdp5_plane_cleanup_fb(struct drm_plane *plane,
@@ -272,7 +272,7 @@ static void mdp5_plane_cleanup_fb(struct drm_plane *plane,return ;DBG ("%s: cleanup: FB[%u]" , plane->name, fb->base.id); -msm_framebuffer_cleanup (fb, mdp5_kms->id); +msm_framebuffer_cleanup (fb, mdp5_kms->base.base.aspace); } static int mdp5_plane_atomic_check(struct drm_plane *plane,
@@ -391,6 +391,7 @@ static void set_scanout_locked(struct drm_plane *plane, struct drm_framebuffer *fb) {struct mdp5_kms *mdp5_kms =get_kms (plane); +struct msm_kms *kms = &mdp5_kms->base.base;struct mdp5_hw_pipe *hwpipe =to_mdp5_plane_state (plane->state)->hwpipe;enum mdp5_pipe pipe = hwpipe->pipe;
@@ -403,13 +404,13 @@ static void set_scanout_locked(struct drm_plane *plane, MDP5_PIPE_SRC_STRIDE_B_P3(fb->pitches[3]));mdp5_write (mdp5_kms,REG_MDP5_PIPE_SRC0_ADDR (pipe), -msm_framebuffer_iova (fb, mdp5_kms->id,0 )); +msm_framebuffer_iova (fb, kms->aspace,0 ));mdp5_write (mdp5_kms,REG_MDP5_PIPE_SRC1_ADDR (pipe), -msm_framebuffer_iova (fb, mdp5_kms->id,1 )); +msm_framebuffer_iova (fb, kms->aspace,1 ));mdp5_write (mdp5_kms,REG_MDP5_PIPE_SRC2_ADDR (pipe), -msm_framebuffer_iova (fb, mdp5_kms->id,2 )); +msm_framebuffer_iova (fb, kms->aspace,2 ));mdp5_write (mdp5_kms,REG_MDP5_PIPE_SRC3_ADDR (pipe), -msm_framebuffer_iova (fb, mdp5_kms->id,3 )); +msm_framebuffer_iova (fb, kms->aspace,3 )); plane->fb = fb; }
drivers/gpu/drm/msm/msm_drv.c +0 -14
@@ -51,20 +51,6 @@ static void msm_fb_output_poll_changed(struct drm_device *dev) .atomic_state_free = msm_atomic_state_free, }; -int msm_register_address_space (struct drm_device *dev, -struct msm_gem_address_space *aspace) -{ -struct msm_drm_private *priv = dev->dev_private; -int idx = priv->num_aspaces++; - -if (WARN_ON (idx >=ARRAY_SIZE (priv->aspace))) -return -EINVAL ; - - priv->aspace[idx] = aspace; - -return idx; -} -#ifdef CONFIG_DRM_MSM_REGISTER_LOGGING static bool reglog = false;MODULE_PARM_DESC (reglog,"Enable register read/write logging" );
drivers/gpu/drm/msm/msm_drv.h +14 -11
@@ -183,9 +183,6 @@ int msm_atomic_commit(struct drm_device *dev,void msm_atomic_state_clear (struct drm_atomic_state *state);void msm_atomic_state_free (struct drm_atomic_state *state); -int msm_register_address_space (struct drm_device *dev, -struct msm_gem_address_space *aspace); -void msm_gem_unmap_vma (struct msm_gem_address_space *aspace,struct msm_gem_vma *vma,struct sg_table *sgt); int msm_gem_map_vma(struct msm_gem_address_space *aspace,
@@ -208,13 +205,16 @@ int msm_gem_mmap_obj(struct drm_gem_object *obj,int msm_gem_mmap (struct file *filp,struct vm_area_struct *vma);int msm_gem_fault (struct vm_area_struct *vma,struct vm_fault *vmf);uint64_t msm_gem_mmap_offset (struct drm_gem_object *obj); -int msm_gem_get_iova_locked (struct drm_gem_object *obj,int id, -uint64_t *iova); -int msm_gem_get_iova (struct drm_gem_object *obj,int id,uint64_t *iova); -uint64_t msm_gem_iova (struct drm_gem_object *obj,int id); +int msm_gem_get_iova_locked (struct drm_gem_object *obj, +struct msm_gem_address_space *aspace,uint64_t *iova); +int msm_gem_get_iova (struct drm_gem_object *obj, +struct msm_gem_address_space *aspace,uint64_t *iova); +uint64_t msm_gem_iova (struct drm_gem_object *obj, +struct msm_gem_address_space *aspace);struct page **msm_gem_get_pages (struct drm_gem_object *obj);void msm_gem_put_pages (struct drm_gem_object *obj); -void msm_gem_put_iova (struct drm_gem_object *obj,int id); +void msm_gem_put_iova (struct drm_gem_object *obj, +struct msm_gem_address_space *aspace);int msm_gem_dumb_create (struct drm_file *file,struct drm_device *dev,struct drm_mode_create_dumb *args); int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
@@ -249,9 +249,12 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev,struct drm_gem_object *msm_gem_import (struct drm_device *dev,struct dma_buf *dmabuf,struct sg_table *sgt); -int msm_framebuffer_prepare (struct drm_framebuffer *fb,int id); -void msm_framebuffer_cleanup (struct drm_framebuffer *fb,int id); -uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb,int id,int plane); +int msm_framebuffer_prepare (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace); +void msm_framebuffer_cleanup (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace); +uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace,int plane);struct drm_gem_object *msm_framebuffer_bo (struct drm_framebuffer *fb,int plane);const struct msm_format *msm_framebuffer_format (struct drm_framebuffer *fb); struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
drivers/gpu/drm/msm/msm_fb.c +9 -6
@@ -84,14 +84,15 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)* should be fine, since only the scanout (mdpN) side of things needs * this, the gpu doesn't care about fb's. */ -int msm_framebuffer_prepare (struct drm_framebuffer *fb,int id) +int msm_framebuffer_prepare (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace) {struct msm_framebuffer *msm_fb =to_msm_framebuffer (fb);int ret, i, n =drm_format_num_planes (fb->pixel_format);uint64_t iova;for (i =0 ; i < n; i++) { - ret =msm_gem_get_iova (msm_fb->planes[i], id, &iova); + ret =msm_gem_get_iova (msm_fb->planes[i], aspace, &iova);DBG ("FB[%u]: iova[%d]: %08llx (%d)" , fb->base.id, i, iova, ret);if (ret)return ret;
@@ -100,21 +101,23 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb, int id)return 0 ; } -void msm_framebuffer_cleanup (struct drm_framebuffer *fb,int id) +void msm_framebuffer_cleanup (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace) {struct msm_framebuffer *msm_fb =to_msm_framebuffer (fb);int i, n =drm_format_num_planes (fb->pixel_format);for (i =0 ; i < n; i++) -msm_gem_put_iova (msm_fb->planes[i], id); +msm_gem_put_iova (msm_fb->planes[i], aspace); } -uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb,int id,int plane) +uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb, +struct msm_gem_address_space *aspace,int plane) {struct msm_framebuffer *msm_fb =to_msm_framebuffer (fb);if (!msm_fb->planes[plane])return 0 ; -return msm_gem_iova (msm_fb->planes[plane], id) + fb->offsets[plane]; +return msm_gem_iova (msm_fb->planes[plane], aspace) + fb->offsets[plane]; }struct drm_gem_object *msm_framebuffer_bo (struct drm_framebuffer *fb,int plane)
drivers/gpu/drm/msm/msm_fbdev.c +9 -1
@@ -20,6 +20,7 @@#include "drm_crtc.h" #include "drm_fb_helper.h" #include "msm_gem.h" +#include "msm_kms.h" extern int msm_gem_mmap_obj (struct drm_gem_object *obj,struct vm_area_struct *vma);
@@ -78,6 +79,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper, {struct msm_fbdev *fbdev =to_msm_fbdev (helper);struct drm_device *dev = helper->dev; +struct msm_drm_private *priv = dev->dev_private;struct drm_framebuffer *fb =NULL ;struct fb_info *fbi =NULL ;struct drm_mode_fb_cmd2 mode_cmd = {0 };
@@ -129,7 +131,13 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,* in panic (ie. lock-safe, etc) we could avoid pinning the * buffer now: */ - ret =msm_gem_get_iova_locked (fbdev->bo,0 , &paddr); + +if (!priv->kms) { + ret = -ENODEV ; + goto fail_unlock; + } + + ret =msm_gem_get_iova_locked (fbdev->bo, priv->kms->aspace, &paddr);if (ret) {dev_err (dev->dev,"failed to get buffer obj iova: %d\n" , ret); goto fail_unlock;
drivers/gpu/drm/msm/msm_gem.c +88 -36
202 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gem.h +3 -1
@@ -35,7 +35,9 @@ struct msm_gem_address_space {struct msm_gem_vma {struct drm_mm_node node; +struct msm_gem_address_space *aspace;uint64_t iova; +struct list_head list; };struct msm_gem_object {
@@ -75,7 +77,7 @@ struct msm_gem_object {struct sg_table *sgt;void *vaddr; -struct msm_gem_vma domain[NUM_DOMAINS ]; +struct list_head domains;/* normally (resv == &_resv) except for imported bo's */ struct reservation_object *resv;
drivers/gpu/drm/msm/msm_gem_submit.c +2 -2
@@ -158,7 +158,7 @@ static void submit_unlock_unpin_bo(struct msm_gem_submit *submit, int i)struct msm_gem_object *msm_obj = submit->bos[i].obj;if (submit->bos[i].flags &BO_PINNED ) -msm_gem_put_iova (&msm_obj->base, submit->gpu->id); +msm_gem_put_iova (&msm_obj->base, submit->gpu->aspace);if (submit->bos[i].flags &BO_LOCKED )ww_mutex_unlock (&msm_obj->resv->lock);
@@ -246,7 +246,7 @@ static int submit_pin_objects(struct msm_gem_submit *submit)/* if locking succeeded, pin bo: */ ret =msm_gem_get_iova_locked (&msm_obj->base, - submit->gpu->id, &iova); + submit->gpu->aspace, &iova);if (ret)break ;
drivers/gpu/drm/msm/msm_gpu.c +3 -5
@@ -458,7 +458,7 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)struct msm_gem_object *msm_obj = submit->bos[i].obj;/* move to inactive: */ msm_gem_move_to_inactive (&msm_obj->base); -msm_gem_put_iova (&msm_obj->base, gpu->id); +msm_gem_put_iova (&msm_obj->base, gpu->aspace);drm_gem_object_unreference (&msm_obj->base); }
@@ -539,7 +539,7 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,/* submit takes a reference to the bo and iova until retired: */ drm_gem_object_reference (&msm_obj->base);msm_gem_get_iova_locked (&msm_obj->base, - submit->gpu->id, &iova); + submit->gpu->aspace, &iova);if (submit->bos[i].flags &MSM_SUBMIT_BO_WRITE )msm_gem_move_to_active (&msm_obj->base, gpu, true, submit->fence);
@@ -675,8 +675,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, }else {dev_info (drm->dev,"%s: no IOMMU, fallback to VRAM carveout!\n" , name); } - gpu->id =msm_register_address_space (drm, gpu->aspace); -/* Create ringbuffer: */ mutex_lock (&drm->struct_mutex);
@@ -707,7 +705,7 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)if (gpu->rb) {if (gpu->rb_iova) -msm_gem_put_iova (gpu->rb->bo, gpu->id); +msm_gem_put_iova (gpu->rb->bo, gpu->aspace);msm_ringbuffer_destroy (gpu->rb); }
drivers/gpu/drm/msm/msm_gpu.h +0 -1
@@ -98,7 +98,6 @@ struct msm_gpu {int irq;struct msm_gem_address_space *aspace; -int id;/* Power Control: */ struct regulator *gpu_reg, *gpu_cx;
drivers/gpu/drm/msm/msm_kms.h +3 -0
@@ -70,6 +70,9 @@ struct msm_kms {/* irq number to be passed on to drm_irq_install */ int irq; + +/* mapper-id used to request GEM buffer mapped for scanout: */ +struct msm_gem_address_space *aspace; };/**
Signature · 1 line
1.9.1
Re: [PATCH 05/11] drm/msm: get an iova from the address space instead of an id
Quoted 37 lines · Jordan Crouse
In the future we won't have a fixed set of addresses spaces. Instead of going through the effort of assigning a ID for each address space just use the address space itself as a token for getting / putting an iova.
This forces a few changes in the gem object however: instead of using a simple index into a list of domains, we need to maintain a list of them. Luckily the list will be pretty small; even with dynamic address spaces we wouldn't ever see more than two or three.
Signed-off-by Jordan Crouse <[email protected]>--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 8 +- drivers/gpu/drm/msm/adreno/a5xx_power.c | 5 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 6 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 15 +++- drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 8 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 18 ++--- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h | 3 - drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c | 13 ++-- drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 5 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 11 +-- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 13 ++-- drivers/gpu/drm/msm/msm_drv.c | 14 ---- drivers/gpu/drm/msm/msm_drv.h | 25 +++--- drivers/gpu/drm/msm/msm_fb.c | 15 ++-- drivers/gpu/drm/msm/msm_fbdev.c | 10 ++- drivers/gpu/drm/msm/msm_gem.c | 124 +++++++++++++++++++++--------- drivers/gpu/drm/msm/msm_gem.h | 4 +- drivers/gpu/drm/msm/msm_gem_submit.c | 4 +- drivers/gpu/drm/msm/msm_gpu.c | 8 +- drivers/gpu/drm/msm/msm_gpu.h | 1 - drivers/gpu/drm/msm/msm_kms.h | 3 + 22 files changed, 184 insertions(+), 133 deletions(-)
<snip>
Quoted 21 lines
drivers/gpu/drm/msm/msm_fbdev.c +2
-0@@ -20,6 +20,7 @@#include "drm_crtc.h" #include "drm_fb_helper.h" #include "msm_gem.h" +#include "msm_kms.h" extern int msm_gem_mmap_obj (struct drm_gem_object *obj,struct vm_area_struct *vma);@@ -78,6 +79,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper, {struct msm_fbdev *fbdev =to_msm_fbdev (helper);struct drm_device *dev = helper->dev; +struct msm_drm_private *priv = dev->dev_private;struct drm_framebuffer *fb =NULL ;struct fb_info *fbi =NULL ;struct drm_mode_fb_cmd2 mode_cmd = {0 };
drivers/gpu/drm/msm/msm_fbdev.c static int msm_fbdev_create(struct drm_fb_helper *helper, · line 138
Quoted 9 lines
drivers/gpu/drm/msm/msm_fbdev.c +5
-1@@ -129,7 +131,13 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,* in panic (ie. lock-safe, etc) we could avoid pinning the * buffer now: */ - ret =msm_gem_get_iova_locked (fbdev->bo,0 , &paddr); + +if (!priv->kms) { + ret = -ENODEV ; + goto fail_unlock; + }
This check isn't needed. As of now, we don't create a fbdev device if we don't have kms initialized.
Otherwise,
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/11 drm/msm: Add a struct to pass configuration to msm_gpu_init()
In reply to Jordan CrouseThe amount of information that we need to pass into msm_gpu_init() is steadily increasing, so add a new struct to stabilize the function call and make it easier to add new configuration down the line.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 12 ++++++++++-- drivers/gpu/drm/msm/msm_gpu.c | 13 ++++++------- drivers/gpu/drm/msm/msm_gpu.h | 11 ++++++++++- 3 files changed, 26 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +10 -2
@@ -344,6 +344,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, struct adreno_gpu *adreno_gpu, const struct adreno_gpu_funcs *funcs) { struct adreno_platform_config *config = pdev->dev.platform_data; +struct msm_gpu_config adreno_gpu_config = {0 };struct msm_gpu *gpu = &adreno_gpu->base;int ret;
@@ -364,9 +365,16 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,DBG ("fast_rate=%u, slow_rate=%u, bus_freq=%u" , gpu->fast_rate, gpu->slow_rate, gpu->bus_freq); + adreno_gpu_config.ioname ="kgsl_3d0_reg_memory" ; + adreno_gpu_config.irqname ="kgsl_3d0_irq" ; + + adreno_gpu_config.va_start =SZ_16M ; + adreno_gpu_config.va_end =0xffffffff ; + + adreno_gpu_config.ringsz =RB_SIZE ; + ret =msm_gpu_init (drm, pdev, &adreno_gpu->base, &funcs->base, - adreno_gpu->info->name,"kgsl_3d0_reg_memory" ,"kgsl_3d0_irq" , -RB_SIZE ); + adreno_gpu->info->name, &adreno_gpu_config);if (ret)return ret;
drivers/gpu/drm/msm/msm_gpu.c +6 -7
@@ -570,7 +570,7 @@ static irqreturn_t irq_handler(int irq, void *data)int msm_gpu_init (struct drm_device *drm,struct platform_device *pdev,struct msm_gpu *gpu,const struct msm_gpu_funcs *funcs, -const char *name,const char *ioname,const char *irqname,int ringsz) +const char *name,struct msm_gpu_config *config) {struct iommu_domain *iommu;int i, ret;
@@ -606,14 +606,14 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,BUG_ON (ARRAY_SIZE (clk_names) !=ARRAY_SIZE (gpu->grp_clks));/* Map registers: */ - gpu->mmio =msm_ioremap (pdev, ioname, name); + gpu->mmio =msm_ioremap (pdev, config->ioname, name);if (IS_ERR (gpu->mmio)) { ret =PTR_ERR (gpu->mmio); goto fail; }/* Get Interrupt: */ - gpu->irq =platform_get_irq_byname (pdev, irqname); + gpu->irq =platform_get_irq_byname (pdev, config->irqname);if (gpu->irq <0 ) { ret = gpu->irq;dev_err (drm->dev,"failed to get irq: %d\n" , ret);
@@ -657,9 +657,8 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,*/ iommu =iommu_domain_alloc (&platform_bus_type);if (iommu) { -/* TODO 32b vs 64b address space.. */ - iommu->geometry.aperture_start =SZ_16M ; - iommu->geometry.aperture_end =0xffffffff ; + iommu->geometry.aperture_start = config->va_start; + iommu->geometry.aperture_end = config->va_end;dev_info (drm->dev,"%s: using IOMMU\n" , name); gpu->aspace = msm_gem_address_space_create(&pdev->dev,
@@ -678,7 +677,7 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,/* Create ringbuffer: */ mutex_lock (&drm->struct_mutex); - gpu->rb =msm_ringbuffer_new (gpu, ringsz); + gpu->rb =msm_ringbuffer_new (gpu, config->ringsz);mutex_unlock (&drm->struct_mutex);if (IS_ERR (gpu->rb)) { ret =PTR_ERR (gpu->rb);
drivers/gpu/drm/msm/msm_gpu.h +10 -1
@@ -28,6 +28,14 @@struct msm_gem_submit ;struct msm_gpu_perfcntr ; +struct msm_gpu_config { +const char *ioname; +const char *irqname; +uint64_t va_start; +uint64_t va_end; +unsigned int ringsz; +}; +/* So far, with hardware that I've seen to date, we can have: * + zero, one, or two z180 2d cores * + a3xx or a2xx 3d core, which share a common CP (the firmware
@@ -205,7 +213,8 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,int msm_gpu_init (struct drm_device *drm,struct platform_device *pdev,struct msm_gpu *gpu,const struct msm_gpu_funcs *funcs, -const char *name,const char *ioname,const char *irqname,int ringsz); +const char *name,struct msm_gpu_config *config); +void msm_gpu_cleanup (struct msm_gpu *gpu);struct msm_gpu *adreno_load_gpu (struct drm_device *dev);
Signature · 1 line
1.9.1
PATCH 7/11 drm/msm: Remove memptrs->wptr
In reply to Jordan Crousememptrs->wptr seems to be unused. Remove it to avoid confusing the upcoming preemption code.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 --- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 - 2 files changed, 4 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +0 -3
@@ -123,7 +123,6 @@ void adreno_recover(struct msm_gpu *gpu)/* reset completed fence seqno: */ adreno_gpu->memptrs->fence = gpu->fctx->completed_fence; adreno_gpu->memptrs->rptr =0 ; - adreno_gpu->memptrs->wptr =0 ; gpu->funcs->pm_resume (gpu);
@@ -256,7 +255,6 @@ void adreno_show(struct msm_gpu *gpu, struct seq_file *m)seq_printf (m,"fence: %d/%d\n" , adreno_gpu->memptrs->fence, gpu->fctx->last_fence);seq_printf (m,"rptr: %d\n" ,get_rptr (adreno_gpu)); -seq_printf (m,"wptr: %d\n" , adreno_gpu->memptrs->wptr);seq_printf (m,"rb wptr: %d\n" ,get_wptr (gpu->rb)); gpu->funcs->pm_resume (gpu);
@@ -296,7 +294,6 @@ void adreno_dump_info(struct msm_gpu *gpu)printk ("fence: %d/%d\n" , adreno_gpu->memptrs->fence, gpu->fctx->last_fence);printk ("rptr: %d\n" ,get_rptr (adreno_gpu)); -printk ("wptr: %d\n" , adreno_gpu->memptrs->wptr);printk ("rb wptr: %d\n" ,get_wptr (gpu->rb)); }
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -1
@@ -85,7 +85,6 @@ struct adreno_info {struct adreno_rbmemptrs {volatile uint32_t rptr; -volatile uint32_t wptr;volatile uint32_t fence; };
Signature · 1 line
1.9.1
PATCH 8/11 drm/msm: Support multiple ringbuffers
In reply to Jordan CrouseAdd the infrastructure to support the idea of multiple ringbuffers. Assign each ringbuffer an id and use that as an index for the various ring specific operations.
The biggest delta is to support legacy fences. Each fence gets its own sequence number but the legacy functions expect to use a unique integer. To handle this we return a unique identifer for each submission but map it to a specific ring/sequence under the covers. Newer users use a dma_fence pointer anyway so they don't care about the actual sequence ID or ring.
The actual mechanics for multiple ringbuffers are very target specific so this code just allows for the possibility but still only defines one ringbuffer for each target family.
--- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 9 +- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 9 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 45 +++++----- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 2 +- drivers/gpu/drm/msm/adreno/a5xx_power.c | 6 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 155 +++++++++++++++++++++----------- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 36 +++++--- drivers/gpu/drm/msm/msm_drv.h | 2 + drivers/gpu/drm/msm/msm_fence.c | 85 +++++++++++++----- drivers/gpu/drm/msm/msm_fence.h | 13 +-- drivers/gpu/drm/msm/msm_gem.h | 1 + drivers/gpu/drm/msm/msm_gem_submit.c | 10 ++- drivers/gpu/drm/msm/msm_gpu.c | 122 ++++++++++++++++--------- drivers/gpu/drm/msm/msm_gpu.h | 38 ++++++-- drivers/gpu/drm/msm/msm_ringbuffer.c | 13 ++- drivers/gpu/drm/msm/msm_ringbuffer.h | 8 +- include/uapi/drm/msm_drm.h | 5 ++ 17 files changed, 373 insertions(+), 186 deletions(-)
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +5 -4
@@ -44,7 +44,7 @@static bool a3xx_me_init (struct msm_gpu *gpu) { -struct msm_ringbuffer *ring = gpu->rb; +struct msm_ringbuffer *ring = gpu->rb[0 ];OUT_PKT3 (ring,CP_ME_INIT ,17 );OUT_RING (ring,0x000003f7 );
@@ -65,7 +65,7 @@ static bool a3xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 );OUT_RING (ring,0x00000000 ); - gpu->funcs->flush (gpu); + gpu->funcs->flush (gpu, ring);return a3xx_idle (gpu); }
@@ -339,7 +339,7 @@ static void a3xx_destroy(struct msm_gpu *gpu)static bool a3xx_idle (struct msm_gpu *gpu) {/* wait for ringbuffer to drain: */ -if (!adreno_idle (gpu)) +if (!adreno_idle (gpu, gpu->rb[0 ]))return false;/* then wait for GPU to finish: */
@@ -449,6 +449,7 @@ static void a3xx_dump(struct msm_gpu *gpu) .last_fence = adreno_last_fence, .submit = adreno_submit, .flush = adreno_flush, + .active_ring = adreno_active_ring, .irq = a3xx_irq, .destroy = a3xx_destroy,#ifdef CONFIG_DEBUG_FS
@@ -496,7 +497,7 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev) adreno_gpu->registers = a3xx_registers; adreno_gpu->reg_offsets = a3xx_register_offsets; - ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs); + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 );if (ret) goto fail;
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +5 -4
@@ -116,7 +116,7 @@ static void a4xx_enable_hwcg(struct msm_gpu *gpu)static bool a4xx_me_init (struct msm_gpu *gpu) { -struct msm_ringbuffer *ring = gpu->rb; +struct msm_ringbuffer *ring = gpu->rb[0 ];OUT_PKT3 (ring,CP_ME_INIT ,17 );OUT_RING (ring,0x000003f7 );
@@ -137,7 +137,7 @@ static bool a4xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 );OUT_RING (ring,0x00000000 ); - gpu->funcs->flush (gpu); + gpu->funcs->flush (gpu, ring);return a4xx_idle (gpu); }
@@ -337,7 +337,7 @@ static void a4xx_destroy(struct msm_gpu *gpu)static bool a4xx_idle (struct msm_gpu *gpu) {/* wait for ringbuffer to drain: */ -if (!adreno_idle (gpu)) +if (!adreno_idle (gpu, gpu->rb[0 ]))return false;/* then wait for GPU to finish: */
@@ -539,6 +539,7 @@ static int a4xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) .last_fence = adreno_last_fence, .submit = adreno_submit, .flush = adreno_flush, + .active_ring = adreno_active_ring, .irq = a4xx_irq, .destroy = a4xx_destroy,#ifdef CONFIG_DEBUG_FS
@@ -580,7 +581,7 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev) adreno_gpu->registers = a4xx_registers; adreno_gpu->reg_offsets = a4xx_register_offsets; - ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs); + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 );if (ret) goto fail;
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +24 -21
108 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -1
@@ -56,6 +56,6 @@ static inline int spin_usecs(struct msm_gpu *gpu, uint32_t usecs, return -ETIMEDOUT; } -bool a5xx_idle (struct msm_gpu *gpu); +bool a5xx_idle (struct msm_gpu *gpu,struct msm_ringbuffer *ring);#endif /* __A5XX_GPU_H__ */
drivers/gpu/drm/msm/adreno/a5xx_power.c +3 -3
@@ -173,7 +173,7 @@ static int a5xx_gpmu_init(struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a5xx_gpu *a5xx_gpu =to_a5xx_gpu (adreno_gpu); -struct msm_ringbuffer *ring = gpu->rb; +struct msm_ringbuffer *ring = gpu->rb[0 ];if (!a5xx_gpu->gpmu_dwords)return 0 ;
@@ -192,9 +192,9 @@ static int a5xx_gpmu_init(struct msm_gpu *gpu)OUT_PKT7 (ring,CP_SET_PROTECTED_MODE ,1 );OUT_RING (ring,1 ); - gpu->funcs->flush (gpu); + gpu->funcs->flush (gpu, ring); -if (!a5xx_idle (gpu)) { +if (!a5xx_idle (gpu, ring)) {DRM_ERROR ("%s: Unable to load GPMU firmware. GPMU will not be active\n" , gpu->name);return -EINVAL ;
drivers/gpu/drm/msm/adreno/adreno_gpu.c +101 -54
288 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/adreno_gpu.h +23 -13
@@ -80,12 +80,18 @@ struct adreno_info {const struct adreno_info *adreno_info (struct adreno_rev rev); -#define rbmemptr (adreno_gpu, member) \ +#define _sizeof (member) \ + sizeof(((struct adreno_rbmemptrs *) 0)->member[0]) + +#define _base (adreno_gpu, member) \ ((adreno_gpu)->memptrs_iova + offsetof(struct adreno_rbmemptrs, member)) +#define rbmemptr (adreno_gpu, index, member) \ + (_base((adreno_gpu), member) + ((index) * _sizeof(member))) +struct adreno_rbmemptrs { -volatile uint32_t rptr; -volatile uint32_t fence; +volatile uint32_t rptr[MSM_GPU_MAX_RINGS ]; +volatile uint32_t fence[MSM_GPU_MAX_RINGS ]; };struct adreno_gpu {
@@ -198,21 +204,25 @@ static inline int adreno_is_a530(struct adreno_gpu *gpu)int adreno_get_param (struct msm_gpu *gpu,uint32_t param,uint64_t *value);int adreno_hw_init (struct msm_gpu *gpu); -uint32_t adreno_last_fence (struct msm_gpu *gpu); +uint32_t adreno_last_fence (struct msm_gpu *gpu,struct msm_ringbuffer *ring); +uint32_t adreno_submitted_fence (struct msm_gpu *gpu, +struct msm_ringbuffer *ring);void adreno_recover (struct msm_gpu *gpu);void adreno_submit (struct msm_gpu *gpu,struct msm_gem_submit *submit,struct msm_file_private *ctx); -void adreno_flush (struct msm_gpu *gpu); -bool adreno_idle (struct msm_gpu *gpu); +void adreno_flush (struct msm_gpu *gpu,struct msm_ringbuffer *ring); +bool adreno_idle (struct msm_gpu *gpu,struct msm_ringbuffer *ring);#ifdef CONFIG_DEBUG_FS void adreno_show (struct msm_gpu *gpu,struct seq_file *m);#endif void adreno_dump_info (struct msm_gpu *gpu);void adreno_dump (struct msm_gpu *gpu); -void adreno_wait_ring (struct msm_gpu *gpu,uint32_t ndwords); +void adreno_wait_ring (struct msm_ringbuffer *ring,uint32_t ndwords); +struct msm_ringbuffer *adreno_active_ring (struct msm_gpu *gpu);int adreno_gpu_init (struct drm_device *drm,struct platform_device *pdev, -struct adreno_gpu *gpu,const struct adreno_gpu_funcs *funcs); +struct adreno_gpu *gpu,const struct adreno_gpu_funcs *funcs, +int nr_rings);void adreno_gpu_cleanup (struct adreno_gpu *gpu);
@@ -221,7 +231,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,static inline void OUT_PKT0 (struct msm_ringbuffer *ring,uint16_t regindx,uint16_t cnt) { -adreno_wait_ring (ring->gpu, cnt+1 ); +adreno_wait_ring (ring, cnt+1 );OUT_RING (ring,CP_TYPE0_PKT | ((cnt-1 ) <<16 ) | (regindx &0x7FFF )); }
@@ -229,14 +239,14 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,static inline void OUT_PKT2 (struct msm_ringbuffer *ring) { -adreno_wait_ring (ring->gpu,1 ); +adreno_wait_ring (ring,1 );OUT_RING (ring,CP_TYPE2_PKT ); }static inline void OUT_PKT3 (struct msm_ringbuffer *ring,uint8_t opcode,uint16_t cnt) { -adreno_wait_ring (ring->gpu, cnt+1 ); +adreno_wait_ring (ring, cnt+1 );OUT_RING (ring,CP_TYPE3_PKT | ((cnt-1 ) <<16 ) | ((opcode &0xFF ) <<8 )); }
@@ -258,14 +268,14 @@ static inline u32 PM4_PARITY(u32 val)static inline void OUT_PKT4 (struct msm_ringbuffer *ring,uint16_t regindx,uint16_t cnt) { -adreno_wait_ring (ring->gpu, cnt +1 ); +adreno_wait_ring (ring, cnt +1 );OUT_RING (ring,PKT4 (regindx, cnt)); }static inline void OUT_PKT7 (struct msm_ringbuffer *ring,uint8_t opcode,uint16_t cnt) { -adreno_wait_ring (ring->gpu, cnt +1 ); +adreno_wait_ring (ring, cnt +1 );OUT_RING (ring,CP_TYPE7_PKT | (cnt <<0 ) | (PM4_PARITY (cnt) <<15 ) | ((opcode &0x7F ) <<16 ) | (PM4_PARITY (opcode) <<23 )); }
drivers/gpu/drm/msm/msm_drv.h +2 -0
@@ -78,6 +78,8 @@ struct msm_vblank_ctrl {spinlock_t lock; }; +#define MSM_GPU_MAX_RINGS 1 +struct msm_drm_private {struct drm_device *dev;
drivers/gpu/drm/msm/msm_fence.c +64 -21
172 lines not on this page · raw message
drivers/gpu/drm/msm/msm_fence.h +8 -5
@@ -18,17 +18,18 @@#ifndef __MSM_FENCE_H__#define __MSM_FENCE_H__ +#include <linux/hashtable.h> #include "msm_drv.h" +#include "msm_ringbuffer.h" struct msm_fence_context {struct drm_device *dev;const char *name;unsigned context; -/* last_fence == completed_fence --> no pending work */ -uint32_t last_fence;/* last assigned fence */ -uint32_t completed_fence;/* last completed fence */ +u32 fence_id;wait_queue_head_t event;spinlock_t spinlock; + DECLARE_HASHTABLE(hash, 4); }; struct msm_fence_context * msm_fence_context_alloc(struct drm_device *dev,
@@ -39,8 +40,10 @@ int msm_wait_fence(struct msm_fence_context *fctx, uint32_t fence, ktime_t *timeout, bool interruptible);int msm_queue_fence_cb (struct msm_fence_context *fctx,struct msm_fence_cb *cb,uint32_t fence); -void msm_update_fence (struct msm_fence_context *fctx,uint32_t fence); +void msm_update_fence (struct msm_fence_context *fctx, +struct msm_ringbuffer *ring,uint32_t fence); -struct dma_fence *msm_fence_alloc (struct msm_fence_context *fctx); +struct dma_fence *msm_fence_alloc (struct msm_fence_context *fctx, +struct msm_ringbuffer *ring);#endif
drivers/gpu/drm/msm/msm_gem.h +1 -0
@@ -120,6 +120,7 @@ struct msm_gem_submit {struct dma_fence *fence;struct pid *pid;/* submitting process */ bool valid;/* true if no cmdstream patching needed */ +struct msm_ringbuffer *ring;unsigned int nr_cmds;unsigned int nr_bos;struct {
drivers/gpu/drm/msm/msm_gem_submit.c +8 -2
@@ -389,7 +389,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,struct sync_file *sync_file =NULL ;int out_fence_fd =-1 ;unsigned i; -int ret; +int ret, ring;if (!gpu)return -ENXIO ;
@@ -521,7 +521,13 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, submit->nr_cmds = i; - submit->fence =msm_fence_alloc (gpu->fctx); + ring =clamp_t (uint32_t, + (args->flags &MSM_SUBMIT_RING_MASK ) >>MSM_SUBMIT_RING_SHIFT , +0 , gpu->nr_rings -1 ); + + submit->ring = gpu->rb[ring]; + + submit->fence =msm_fence_alloc (gpu->fctx, submit->ring);if (IS_ERR (submit->fence)) { ret =PTR_ERR (submit->fence); submit->fence =NULL ;
drivers/gpu/drm/msm/msm_gpu.c +81 -41
204 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gpu.h +30 -8
@@ -33,7 +33,7 @@ struct msm_gpu_config {const char *irqname;uint64_t va_start;uint64_t va_end; -unsigned int ringsz; +unsigned int nr_rings; };/* So far, with hardware that I've seen to date, we can have:
@@ -57,9 +57,11 @@ struct msm_gpu_funcs {int (*pm_resume)(struct msm_gpu *gpu);void (*submit)(struct msm_gpu *gpu,struct msm_gem_submit *submit,struct msm_file_private *ctx); -void (*flush)(struct msm_gpu *gpu); +void (*flush)(struct msm_gpu *gpu,struct msm_ringbuffer *ring);irqreturn_t (*irq)(struct msm_gpu *irq); -uint32_t (*last_fence)(struct msm_gpu *gpu); +uint32_t (*last_fence)(struct msm_gpu *gpu, +struct msm_ringbuffer *ring); +struct msm_ringbuffer *(*active_ring)(struct msm_gpu *gpu);void (*recover)(struct msm_gpu *gpu);void (*destroy)(struct msm_gpu *gpu);#ifdef CONFIG_DEBUG_FS
@@ -85,9 +87,8 @@ struct msm_gpu {const struct msm_gpu_perfcntr *perfcntrs;uint32_t num_perfcntrs; -/* ringbuffer: */ -struct msm_ringbuffer *rb; -uint64_t rb_iova; +struct msm_ringbuffer *rb[MSM_GPU_MAX_RINGS ]; +int nr_rings;/* list of GEM active objects: */ struct list_head active_list;
@@ -126,15 +127,36 @@ struct msm_gpu {#define DRM_MSM_HANGCHECK_PERIOD 500/* in ms */ #define DRM_MSM_HANGCHECK_JIFFIES msecs_to_jiffies(DRM_MSM_HANGCHECK_PERIOD)struct timer_list hangcheck_timer; -uint32_t hangcheck_fence; +uint32_t hangcheck_fence[MSM_GPU_MAX_RINGS ];struct work_struct recover_work;struct list_head submit_list; }; +/* It turns out that all targets use the same ringbuffer size */ +#define MSM_GPU_RINGBUFFER_SZ SZ_32K + +static inline struct msm_ringbuffer *__get_ring (struct msm_gpu *gpu,int index) +{ +return (index <ARRAY_SIZE (gpu->rb) ? gpu->rb[index] :NULL ); +} + +#define FOR_EACH_RING (gpu, ring, index) \ + for (index = 0, ring = (gpu)->rb[0]; \ + index < (gpu)->nr_rings && index < ARRAY_SIZE((gpu)->rb); \ + index++, ring = __get_ring(gpu, index)) +static inline bool msm_gpu_active (struct msm_gpu *gpu) { -return gpu->fctx->last_fence > gpu->funcs->last_fence (gpu); +struct msm_ringbuffer *ring; +int i; + + FOR_EACH_RING(gpu, ring, i) { +if (ring->last_fence > gpu->funcs->last_fence (gpu, ring)) +return true; + } + +return false; }/* Perf-Counters:
drivers/gpu/drm/msm/msm_ringbuffer.c +6 -7
@@ -18,13 +18,13 @@#include "msm_ringbuffer.h" #include "msm_gpu.h" -struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int size) +struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int id) {struct msm_ringbuffer *ring;int ret; -if (WARN_ON (!is_power_of_2 (size))) -return ERR_PTR (-EINVAL ); +/* We assume everwhere that MSM_GPU_RINGBUFFER_SZ is a power of 2 */ +BUILD_BUG_ON (!is_power_of_2 (MSM_GPU_RINGBUFFER_SZ )); ring =kzalloc (sizeof (*ring),GFP_KERNEL );if (!ring) {
@@ -33,7 +33,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int size) } ring->gpu = gpu; - ring->bo =msm_gem_new (gpu->dev, size,MSM_BO_WC ); + ring->id = id; + ring->bo =msm_gem_new (gpu->dev,MSM_GPU_RINGBUFFER_SZ ,MSM_BO_WC );if (IS_ERR (ring->bo)) { ret =PTR_ERR (ring->bo); ring->bo =NULL ;
@@ -45,11 +46,9 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int size) ret =PTR_ERR (ring->start); goto fail; } - ring->end = ring->start + (size /4 ); + ring->end = ring->start + (MSM_GPU_RINGBUFFER_SZ >>2 ); ring->cur = ring->start; - ring->size = size; -return ring; fail:
drivers/gpu/drm/msm/msm_ringbuffer.h +6 -2
@@ -22,12 +22,16 @@struct msm_ringbuffer {struct msm_gpu *gpu; -int size; +int id;struct drm_gem_object *bo;uint32_t *start, *end, *cur; +uint64_t iova; +/* last_fence == completed_fence --> no pending work */ +uint32_t last_fence; +uint32_t completed_fence; }; -struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int size); +struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int id);void msm_ringbuffer_destroy (struct msm_ringbuffer *ring);/* ringbuffer helpers (the parts that are same for a3xx/a2xx/z180..) */
include/uapi/drm/msm_drm.h +5 -0
@@ -195,10 +195,15 @@ struct drm_msm_gem_submit_bo {#define MSM_SUBMIT_NO_IMPLICIT 0x80000000/* disable implicit sync */ #define MSM_SUBMIT_FENCE_FD_IN 0x40000000/* enable input fence_fd */ #define MSM_SUBMIT_FENCE_FD_OUT 0x20000000/* enable output fence_fd */ + +#define MSM_SUBMIT_RING_MASK 0x000F0000 +#define MSM_SUBMIT_RING_SHIFT 16 +#define MSM_SUBMIT_FLAGS ( \ MSM_SUBMIT_NO_IMPLICIT | \ MSM_SUBMIT_FENCE_FD_IN | \ MSM_SUBMIT_FENCE_FD_OUT | \ + MSM_SUBMIT_RING_MASK | \ 0)/* Each cmdstream submit consists of a table of buffers involved, and
Signature · 1 line
1.9.1
PATCH 9/11 drm/msm: Shadow current pointer in the ring until command is complete
In reply to Jordan CrouseAdd a shadow pointer to track the current command being written into the ring. Don't commit it as 'cur' until the command is submitted. Because 'cur' is used to construct the software copy of the wptr this ensures that somebody peeking in on the ring doesn't assume that a command is inflight while it is being written. This isn't a huge deal with a single ring (though technically the hangcheck could assume the system is prematurely busy when it isn't) but it will be rather important for preemption where the decision to preempt is based on a non-empty ringbuffer. Without a shadow an aggressive preemption scheme could assume that the ringbuffer is non empty and switch to it before the CPU is done writing the command and boom.
Even though preemption won't be supported for all targets because of the way the code is organized it is simpler to make this generic for all targets. The extra load for non-preemption targets should be minimal.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 9 +++++++-- drivers/gpu/drm/msm/msm_ringbuffer.c | 1 + drivers/gpu/drm/msm/msm_ringbuffer.h | 12 ++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +7 -2
@@ -144,6 +144,7 @@ void adreno_recover(struct msm_gpu *gpu)continue ; ring->cur = ring->start; + ring->next = ring->start;/* reset completed fence seqno, discard anything pending: */ adreno_gpu->memptrs->fence[ring->id] = ring->completed_fence;
@@ -240,12 +241,15 @@ void adreno_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring)struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);uint32_t wptr; +/* Copy the shadow to the actual register */ + ring->cur = ring->next; +/* * Mask wptr value that we calculate to fit in the HW range. This is * to account for the possibility that the last command fit exactly into * the ringbuffer and rb->next hasn't wrapped to zero yet */ - wptr =get_wptr (ring) % (MSM_GPU_RINGBUFFER_SZ >>2 ); + wptr = (ring->cur - ring->start) % (MSM_GPU_RINGBUFFER_SZ >>2 );/* ensure writes to ringbuffer have hit system memory: */ mb ();
@@ -366,7 +370,8 @@ static uint32_t ring_freewords(struct msm_ringbuffer *ring) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (ring->gpu);uint32_t size =MSM_GPU_RINGBUFFER_SZ >>2 ; -uint32_t wptr =get_wptr (ring); +/* Use ring->next to calculate free size */ +uint32_t wptr = ring->next - ring->start;uint32_t rptr =get_rptr (adreno_gpu, ring);return (rptr + (size -1 ) - wptr) % size; }
drivers/gpu/drm/msm/msm_ringbuffer.c +1 -0
@@ -47,6 +47,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id) goto fail; } ring->end = ring->start + (MSM_GPU_RINGBUFFER_SZ >>2 ); + ring->next = ring->start; ring->cur = ring->start;return ring;
drivers/gpu/drm/msm/msm_ringbuffer.h +8 -4
@@ -24,7 +24,7 @@ struct msm_ringbuffer {struct msm_gpu *gpu;int id;struct drm_gem_object *bo; -uint32_t *start, *end, *cur; +uint32_t *start, *end, *cur, *next;uint64_t iova;/* last_fence == completed_fence --> no pending work */ uint32_t last_fence;
@@ -39,9 +39,13 @@ struct msm_ringbuffer {static inline void OUT_RING (struct msm_ringbuffer *ring,uint32_t data) { -if (ring->cur == ring->end) - ring->cur = ring->start; - *(ring->cur++) = data; +/* +* ring->next points to the current command being written - it won't be +* committed as ring->cur until the flush +*/ +if (ring->next == ring->end) + ring->next = ring->start; + *(ring->next++) = data; }#endif /* __MSM_RINGBUFFER_H__ */
Signature · 1 line
1.9.1
PATCH 10/11 drm/msm: Make the value of RB_CNTL (almost) generic
In reply to Jordan CrouseWe use a global ringbuffer size and block size for all targets and at least for 5XX preemption we need to know the value the RB_CNTL in several locations so it makes sense to caculate it once and use it everywhere.
The only monkey wrench is that we need to disable the RPTR shadow for A430 targets but that only needs to be done once and doesn't affect A5XX so we can or in the value at init time.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 12 +++++++----- drivers/gpu/drm/msm/msm_gpu.h | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +7 -5
@@ -21,7 +21,6 @@#include "msm_gem.h" #include "msm_mmu.h" -#define RB_BLKSIZE 32int adreno_get_param (struct msm_gpu *gpu,uint32_t param,uint64_t *value) {
@@ -71,11 +70,14 @@ int adreno_hw_init(struct msm_gpu *gpu) } } -/* Setup REG_CP_RB_CNTL: */ +/* +* Setup REG_CP_RB_CNTL. The same value is used across targets (with +* the excpetion of A430 that disables the RPTR shadow) - the cacluation +* for the ringbuffer size and block size is moved to msm_gpu.h for the +* pre-processor to deal with and the A430 variant is ORed in here +*/ adreno_gpu_write (adreno_gpu,REG_ADRENO_CP_RB_CNTL , -/* size is log2(quad-words): */ -AXXX_CP_RB_CNTL_BUFSZ (ilog2 (MSM_GPU_RINGBUFFER_SZ /8 )) | -AXXX_CP_RB_CNTL_BLKSZ (ilog2 (RB_BLKSIZE /8 )) | +MSM_GPU_RB_CNTL_DEFAULT | (adreno_is_a430 (adreno_gpu) ?AXXX_CP_RB_CNTL_NO_UPDATE :0 ));/* Setup ringbuffer address - use ringbuffer[0] for GPU init */
drivers/gpu/drm/msm/msm_gpu.h +5 -0
@@ -135,6 +135,11 @@ struct msm_gpu {/* It turns out that all targets use the same ringbuffer size */ #define MSM_GPU_RINGBUFFER_SZ SZ_32K +#define MSM_GPU_RINGBUFFER_BLKSIZE 32 + +#define MSM_GPU_RB_CNTL_DEFAULT \ + (AXXX_CP_RB_CNTL_BUFSZ(ilog2(MSM_GPU_RINGBUFFER_SZ / 8)) | \ + AXXX_CP_RB_CNTL_BLKSZ(ilog2(MSM_GPU_RINGBUFFER_BLKSIZE / 8)))static inline struct msm_ringbuffer *__get_ring (struct msm_gpu *gpu,int index) {
Signature · 1 line
1.9.1
PATCH 11/11 drm/msm: Implement preemption for A5XX targets
In reply to Jordan CrouseImplement preemption for A5XX targets - this allows multiple ringbuffers for different priorities with automatic preemption of a lower priority ringbuffer if a higher one is ready.
--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 172 +++++++++++++- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 105 +++++++++ drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 367 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 11 +- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 5 + drivers/gpu/drm/msm/msm_drv.h | 2 +- drivers/gpu/drm/msm/msm_ringbuffer.c | 2 + drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + 9 files changed, 654 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/msm/adreno/a5xx_preempt.c
drivers/gpu/drm/msm/Makefile +1 -0
@@ -8,6 +8,7 @@ msm-y := \ adreno/a4xx_gpu.o \ adreno/a5xx_gpu.o \ adreno/a5xx_power.o \ + adreno/a5xx_preempt.o \ hdmi/hdmi.o \ hdmi/hdmi_audio.o \ hdmi/hdmi_bridge.o \
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +168 -4
266 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +105 -0
119 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +367 -0
367 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/adreno_gpu.c +4 -7
@@ -93,11 +93,6 @@ int adreno_hw_init(struct msm_gpu *gpu)return 0 ; } -static uint32_t get_wptr (struct msm_ringbuffer *ring) -{ -return ring->cur - ring->start; -} -/* Use this helper to read rptr, since a430 doesn't update rptr in memory */ static uint32_t get_rptr (struct adreno_gpu *adreno_gpu,struct msm_ringbuffer *ring)
@@ -145,6 +140,7 @@ void adreno_recover(struct msm_gpu *gpu)if (!ring)continue ; +/* No need for a lock here, nobody else is peeking in */ ring->cur = ring->start; ring->next = ring->start;
@@ -269,8 +265,9 @@ bool adreno_idle(struct msm_gpu *gpu, struct msm_ringbuffer *ring)return true;/* TODO maybe we need to reset GPU here to recover from hang? */ -DRM_ERROR ("%s: timeout waiting to drain ringbuffer %d!\n" , gpu->name, - ring->id); +DRM_ERROR ("%s: timeout waiting to drain ringbuffer %d rptr/wptr = %X/%X\n" , + gpu->name, ring->id,get_rptr (adreno_gpu, ring), wptr); +return false; }
drivers/gpu/drm/msm/adreno/adreno_gpu.h +5 -0
@@ -334,6 +334,11 @@ static inline void adreno_gpu_write64(struct adreno_gpu *gpu,adreno_gpu_write (gpu, hi,upper_32_bits (data)); } +static inline uint32_t get_wptr (struct msm_ringbuffer *ring) +{ +return ring->cur - ring->start; +} +/* * Given a register and a count, return a value to program into * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len
drivers/gpu/drm/msm/msm_drv.h +1 -1
@@ -78,7 +78,7 @@ struct msm_vblank_ctrl {spinlock_t lock; }; -#define MSM_GPU_MAX_RINGS 1 +#define MSM_GPU_MAX_RINGS 4struct msm_drm_private {
drivers/gpu/drm/msm/msm_ringbuffer.c +2 -0
@@ -50,6 +50,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id) ring->next = ring->start; ring->cur = ring->start; +spin_lock_init (&ring->lock); +return ring; fail:
drivers/gpu/drm/msm/msm_ringbuffer.h +1 -0
@@ -29,6 +29,7 @@ struct msm_ringbuffer {/* last_fence == completed_fence --> no pending work */ uint32_t last_fence;uint32_t completed_fence; +spinlock_t lock; };struct msm_ringbuffer *msm_ringbuffer_new (struct msm_gpu *gpu,int id);
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): 1486402779-9024-12-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Re: [PATCH 11/11] drm/msm: Implement preemption for A5XX targets
Quoted 22 lines · Jordan Crouse
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +15
-0@@ -0,0 +1,367 @@ +/* +* Try to transition the preemption state from old to new. Return +* true on success or false if the original state wasn't 'old' +*/ +static inline bool try_preempt_state (struct a5xx_gpu *a5xx_gpu, +enum preempt_state old,enum preempt_state new) +{ +enum preempt_state cur =atomic_cmpxchg (&a5xx_gpu->preempt_state, + old, new); + +return (cur == old); +} + +/* +* Force the preemption state to the specified state. This is used in cases
drivers/gpu/drm/msm/adreno/a5xx_preempt.c line 78
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +10
-0+* where the current state is known and won't change +*/ +static inline void set_preempt_state (struct a5xx_gpu *gpu, +enum preempt_state new) +{ +/* atomic_set() doesn't automatically do barriers, so one before.. */ +smp_wmb (); +atomic_set (&gpu->preempt_state, new); +/* ... and one after*/ +smp_wmb ();
Should these smp_wmb()s be replaced with smp_mb__before_atomic() and smp_mb__after_atomic()? The latter is stronger (mb() instead of wmb()) but otherwise that's typically what is used with atomics. Also, it would be nice if the comments described what we're synchronizing with.
drivers/gpu/drm/msm/adreno/a5xx_preempt.c line 129
Quoted 12 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +12
-0+ +static void a5xx_preempt_worker (struct work_struct *work) +{ +struct a5xx_gpu *a5xx_gpu = + container_of(work, struct a5xx_gpu, preempt_work); +struct msm_gpu *gpu = &a5xx_gpu->base.base; +struct drm_device *dev = gpu->dev; +struct msm_drm_private *priv = dev->dev_private; + +if (atomic_read (&a5xx_gpu->preempt_state) ==PREEMPT_COMPLETE ) { +uint32_t status =gpu_read (gpu, +REG_A5XX_CP_CONTEXT_SWITCH_CNTL );
Why does this worker check the status again? The irq may fire but the hardware is still indicating "pending"? And why do we fork off this code to a workqueue? Can't we do this stuff in the irq handler or timer handler and drop this worker?
Quoted 27 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +22
-0+ +if (status ==0 ) { +del_timer (&a5xx_gpu->preempt_timer); + a5xx_gpu->cur_ring = a5xx_gpu->next_ring; + a5xx_gpu->next_ring =NULL ; + +update_wptr (gpu, a5xx_gpu->cur_ring); + +set_preempt_state (a5xx_gpu,PREEMPT_NONE ); +return ; + } + +dev_err (dev->dev,"%s: Preemption failed to complete\n" , + gpu->name); + }else if (atomic_read (&a5xx_gpu->preempt_state) ==PREEMPT_FAULTED ) +dev_err (dev->dev,"%s: preemption timed out\n" , gpu->name); +else +return ; + +/* Trigger recovery */ +queue_work (priv->wq, &gpu->recover_work); +}drivers/gpu/drm/msm/adreno/adreno_gpu.h +0
-0
drivers/gpu/drm/msm/adreno/adreno_gpu.h static inline void adreno_gpu_write64(struct adreno_gpu *gpu, · line 337
Quoted 4 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +1
-0@@ -334,6 +334,11 @@ static inline void adreno_gpu_write64(struct adreno_gpu *gpu,adreno_gpu_write (gpu, hi,upper_32_bits (data)); } +static inline uint32_t get_wptr (struct msm_ringbuffer *ring)
const struct msm_ringbuffer?
Quoted 8 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +4
-0+{ +return ring->cur - ring->start; +} +/* * Given a register and a count, return a value to program into * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len
Signature · 7 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
A message that is not in the archive (sent off-list or not yet received): 8696f3b7-1fbd-309a-1d68-b2f8ad89a30c-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Re: [PATCH 11/11] drm/msm: Implement preemption for A5XX targets
Quoted 30 lines · Stephen Boyd
Quoted 29 lines · Jordan Crouse
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +22
-0@@ -0,0 +1,367 @@ +/* +* Try to transition the preemption state from old to new. Return +* true on success or false if the original state wasn't 'old' +*/ +static inline bool try_preempt_state (struct a5xx_gpu *a5xx_gpu, +enum preempt_state old,enum preempt_state new) +{ +enum preempt_state cur =atomic_cmpxchg (&a5xx_gpu->preempt_state, + old, new); + +return (cur == old); +} + +/* +* Force the preemption state to the specified state. This is used in cases +* where the current state is known and won't change +*/ +static inline void set_preempt_state (struct a5xx_gpu *gpu, +enum preempt_state new) +{ +/* atomic_set() doesn't automatically do barriers, so one before.. */ +smp_wmb ();
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c line 78
Quoted 3 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +3
-0+atomic_set (&gpu->preempt_state, new); +/* ... and one after*/ +smp_wmb ();Should these smp_wmb()s be replaced with
smp_mb__before_atomic()andsmp_mb__after_atomic()? The latter is stronger (mb()instead ofwmb()) but otherwise that's typically what is used with atomics. Also, it would be nice if the comments described what we're synchronizing with.
Yep - _before/_after atomic are more correct to use here. We are synchronizing with other cores that are trying to check the state machine in try_preempt_state and in the interrupt handler. I'll clarify that.
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +9
-0+ +static void a5xx_preempt_worker (struct work_struct *work) +{ +struct a5xx_gpu *a5xx_gpu = + container_of(work, struct a5xx_gpu, preempt_work); +struct msm_gpu *gpu = &a5xx_gpu->base.base; +struct drm_device *dev = gpu->dev; +struct msm_drm_private *priv = dev->dev_private; +
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c line 129
Quoted 3 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +3
-0+if (atomic_read (&a5xx_gpu->preempt_state) ==PREEMPT_COMPLETE ) { +uint32_t status =gpu_read (gpu, +REG_A5XX_CP_CONTEXT_SWITCH_CNTL );Why does this worker check the status again? The irq may fire but the hardware is still indicating "pending"? And why do we fork off this code to a workqueue? Can't we do this stuff in the irq handler or timer handler and drop this worker?
That is a great point - I don't actually know if we need the helper here - I don't believe we need a mutex for anything at this point - the hang recovery will need one, but that gets scheduled anyway so the worker is unneeded.
Quoted 30 lines
Quoted 30 lines
drivers/gpu/drm/msm/adreno/a5xx_preempt.c new file +22
-0+ +if (status ==0 ) { +del_timer (&a5xx_gpu->preempt_timer); + a5xx_gpu->cur_ring = a5xx_gpu->next_ring; + a5xx_gpu->next_ring =NULL ; + +update_wptr (gpu, a5xx_gpu->cur_ring); + +set_preempt_state (a5xx_gpu,PREEMPT_NONE ); +return ; + } + +dev_err (dev->dev,"%s: Preemption failed to complete\n" , + gpu->name); + }else if (atomic_read (&a5xx_gpu->preempt_state) ==PREEMPT_FAULTED ) +dev_err (dev->dev,"%s: preemption timed out\n" , gpu->name); +else +return ; + +/* Trigger recovery */ +queue_work (priv->wq, &gpu->recover_work); +}drivers/gpu/drm/msm/adreno/adreno_gpu.h +0
-0@@ -334,6 +334,11 @@ static inline void adreno_gpu_write64(struct adreno_gpu *gpu,adreno_gpu_write (gpu, hi,upper_32_bits (data)); }
Quoted 3 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h static inline void adreno_gpu_write64(struct adreno_gpu *gpu, · line 337
Quoted 1 line
drivers/gpu/drm/msm/adreno/adreno_gpu.h +1
-0+static inline uint32_t get_wptr (struct msm_ringbuffer *ring)const struct
msm_ringbuffer?
msm_ringbuffer is actively being modified, so we would have to cast it - can't tell if there would be a compiler advantage or not.
Jordan
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
Re: [PATCH 11/11] drm/msm: Implement preemption for A5XX targets
Quoted 6 lines · Jordan Crouse
Quoted 1 line · Stephen Boyd
const struct
msm_ringbuffer?
msm_ringbufferis actively being modified, so we would have to cast it - can't tell if there would be a compiler advantage or not.
I just meant for this function. It keeps us from modifying ring in the function.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 11 lines · Jordan Crouse
This series of patches implements multiple ringbuffers and preemption for Adreno A5XX targets. Preemption allows a command to be interrupted at specific preemption points and execution switched to a different ringbuffer.
The software alogrithm uses preemption to enforce quality of service for priority levels - commands to a certain ring preempt the rings of lower priority. Note that priority is a software construct; the driver chooses a ring to switch to and the hardware executes. This is important because it shows that preemption can be used for things other than priority (timeslices for quality of service for example).
Quoted 4 lines
This initial series implements 4 ringbuffers to give sufficient coverage for the range of priority levels requested by the GLES and compute extensions. The targeted ringbuffer is specified in the command submission flags. The default ring is 0 (lowest priority).
Link to userspace part that implements these extensions? Also which gles/compute extensions are you talking about? Asking not just because of the open source userspace requirement, but also because we want to upstream a scheduler on the i915 side. Getting alignment on that across drm drivers would be sweet.
Adding intel-gfx, I'll poke the folks working on this too. -Daniel
Quoted 59 lines
Jordan
Jordan Crouse (11):
drm/msm: Make sure to detach the MMU during GPU cleanup drm/msm: Improve the zap shader
drm/msm: Add hint toDRM_IOCTL_MSM_GEM_INFOto return an object IOVA drm/msm: Remove idle function hook
drm/msm: get an iova from the address space instead of an id drm/msm: Add a struct to pass configuration tomsm_gpu_init()drm/msm: Removememptrs->wptr
drm/msm: Support multiple ringbuffers
drm/msm: Shadow current pointer in the ring until command is complete drm/msm: Make the value ofRB_CNTL(almost) generic drm/msm: Implement preemption for A5XX targetsdrivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 13 +- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 13 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 278 +++++++++++++++++----- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 106 +++++++++ drivers/gpu/drm/msm/adreno/a5xx_power.c | 11 +- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 367 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 215 +++++++++++------ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 42 ++-- drivers/gpu/drm/msm/dsi/dsi_host.c | 15 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 8 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 18 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h | 3 - drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c | 13 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 5 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 11 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 13 +- drivers/gpu/drm/msm/msm_drv.c | 43 ++-- drivers/gpu/drm/msm/msm_drv.h | 27 ++- drivers/gpu/drm/msm/msm_fb.c | 15 +- drivers/gpu/drm/msm/msm_fbdev.c | 10 +- drivers/gpu/drm/msm/msm_fence.c | 85 +++++-- drivers/gpu/drm/msm/msm_fence.h | 13 +- drivers/gpu/drm/msm/msm_gem.c | 124 +++++++--- drivers/gpu/drm/msm/msm_gem.h | 5 +- drivers/gpu/drm/msm/msm_gem_submit.c | 14 +- drivers/gpu/drm/msm/msm_gpu.c | 140 +++++++----- drivers/gpu/drm/msm/msm_gpu.h | 54 ++++- drivers/gpu/drm/msm/msm_kms.h | 3 + drivers/gpu/drm/msm/msm_ringbuffer.c | 14 +- drivers/gpu/drm/msm/msm_ringbuffer.h | 21 +- include/uapi/drm/msm_drm.h | 9 +- 33 files changed, 1324 insertions(+), 389 deletions(-) create mode 100644 drivers/gpu/drm/msm/adreno/a5xx_preempt.cSignature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi,
Quoted 11 lines · Daniel Vetter
Quoted 4 lines · Jordan Crouse
This initial series implements 4 ringbuffers to give sufficient coverage for the range of priority levels requested by the GLES and compute extensions. The targeted ringbuffer is specified in the command submission flags. The default ring is 0 (lowest priority).
Link to userspace part that implements these extensions? Also which gles/compute extensions are you talking about? Asking not just because of the open source userspace requirement, but also because we want to upstream a scheduler on the i915 side. Getting alignment on that across drm drivers would be sweet.
Assuming he meant EGL rather than GLES, this is the usual one:
https://www.khronos.org/registry/EGL/extensions/IMG/EGL_IMG_context_priority.txt
Cheers,
Daniel
Quoted 9 lines · Daniel Stone
Hi,
Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Jordan Crouse
This initial series implements 4 ringbuffers to give sufficient coverage for the range of priority levels requested by the GLES and compute extensions. The targeted ringbuffer is specified in the command submission flags. The default ring is 0 (lowest priority).
Quoted 9 lines
Quoted 5 lines
Link to userspace part that implements these extensions? Also which gles/compute extensions are you talking about? Asking not just because of the open source userspace requirement, but also because we want to upstream a scheduler on the i915 side. Getting alignment on that across drm drivers would be sweet.
Assuming he meant EGL rather than GLES, this is the usual one:
https://www.khronos.org/registry/EGL/extensions/IMG/EGL_IMG_context_priority.txt
There was an RFC for this from Chris.. not sure if it landed yet, but that is what I was planning to use from the userspace side.
Probably first step would be to enable this without preemption points. Although I think I have a reasonable idea how the preemption points work..
BR,
-R
Quoted 17 lines · Daniel Vetter
Quoted 11 lines · Jordan Crouse
This series of patches implements multiple ringbuffers and preemption for Adreno A5XX targets. Preemption allows a command to be interrupted at specific preemption points and execution switched to a different ringbuffer.
The software alogrithm uses preemption to enforce quality of service for priority levels - commands to a certain ring preempt the rings of lower priority. Note that priority is a software construct; the driver chooses a ring to switch to and the hardware executes. This is important because it shows that preemption can be used for things other than priority (timeslices for quality of service for example).
Quoted 4 lines
This initial series implements 4 ringbuffers to give sufficient coverage for the range of priority levels requested by the GLES and compute extensions. The targeted ringbuffer is specified in the command submission flags. The default ring is 0 (lowest priority).
Quoted 5 lines
Link to userspace part that implements these extensions? Also which gles/compute extensions are you talking about? Asking not just because of the open source userspace requirement, but also because we want to upstream a scheduler on the i915 side. Getting alignment on that across drm drivers would be sweet.
FWIW, we have had a GPU scheduler in amdgpu for several years now. We purposely tried to keep it largely separate from our driver so others could leverage it if they wanted to. See drivers/gpu/drm/amd/scheduler in the kernel.
Alex
Quoted 64 lines
Adding intel-gfx, I'll poke the folks working on this too. -Daniel
Quoted 52 lines
Jordan
Jordan Crouse (11):
drm/msm: Make sure to detach the MMU during GPU cleanup drm/msm: Improve the zap shader
drm/msm: Add hint toDRM_IOCTL_MSM_GEM_INFOto return an object IOVA drm/msm: Remove idle function hook
drm/msm: get an iova from the address space instead of an id drm/msm: Add a struct to pass configuration tomsm_gpu_init()drm/msm: Removememptrs->wptr
drm/msm: Support multiple ringbuffers
drm/msm: Shadow current pointer in the ring until command is complete drm/msm: Make the value ofRB_CNTL(almost) generic drm/msm: Implement preemption for A5XX targetsdrivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 13 +- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 13 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 278 +++++++++++++++++----- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 106 +++++++++ drivers/gpu/drm/msm/adreno/a5xx_power.c | 11 +- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 367 ++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 215 +++++++++++------ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 42 ++-- drivers/gpu/drm/msm/dsi/dsi_host.c | 15 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c | 8 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 18 +- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h | 3 - drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c | 13 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 5 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 11 +- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h | 4 - drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 13 +- drivers/gpu/drm/msm/msm_drv.c | 43 ++-- drivers/gpu/drm/msm/msm_drv.h | 27 ++- drivers/gpu/drm/msm/msm_fb.c | 15 +- drivers/gpu/drm/msm/msm_fbdev.c | 10 +- drivers/gpu/drm/msm/msm_fence.c | 85 +++++-- drivers/gpu/drm/msm/msm_fence.h | 13 +- drivers/gpu/drm/msm/msm_gem.c | 124 +++++++--- drivers/gpu/drm/msm/msm_gem.h | 5 +- drivers/gpu/drm/msm/msm_gem_submit.c | 14 +- drivers/gpu/drm/msm/msm_gpu.c | 140 +++++++----- drivers/gpu/drm/msm/msm_gpu.h | 54 ++++- drivers/gpu/drm/msm/msm_kms.h | 3 + drivers/gpu/drm/msm/msm_ringbuffer.c | 14 +- drivers/gpu/drm/msm/msm_ringbuffer.h | 21 +- include/uapi/drm/msm_drm.h | 9 +- 33 files changed, 1324 insertions(+), 389 deletions(-) create mode 100644 drivers/gpu/drm/msm/adreno/a5xx_preempt.cQuoted 7 lines
--
1.9.1_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel