drm/amdgpu: add amd_gnb_bus support
Subsystems (3)
PATCH 1/12 drm/amdgpu: add amd_gnb_bus support
From: Chunming Zhou <[email protected]>
This is used by the incoming ACP driver. The DMA engine for the i2s audio codec is part of the GPU.
This exposes an amd gnb bus for the i2s codec to
hang off of.
--- drivers/gpu/drm/Kconfig | 3 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/amd/bus/Kconfig | 7 + drivers/gpu/drm/amd/bus/Makefile | 4 + drivers/gpu/drm/amd/bus/amd_gnb_bus.c | 266 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/include/bus/amd_gnb_bus.h | 78 ++++++++ 6 files changed, 359 insertions(+) create mode 100644 drivers/gpu/drm/amd/bus/Kconfig create mode 100644 drivers/gpu/drm/amd/bus/Makefile create mode 100644 drivers/gpu/drm/amd/bus/amd_gnb_bus.c create mode 100644 drivers/gpu/drm/amd/include/bus/amd_gnb_bus.h
drivers/gpu/drm/Kconfig +3 -0
@@ -120,6 +120,8 @@ config DRM_RADEON source "drivers/gpu/drm/radeon/Kconfig" +source "drivers/gpu/drm/amd/bus/Kconfig" + config DRM_AMDGPU tristate "AMD GPU" depends on DRM && PCI
@@ -134,6 +136,7 @@ config DRM_AMDGPU select HWMON select BACKLIGHT_CLASS_DEVICE select INTERVAL_TREE + select DRM_AMD_GNB_BUS help Choose this option if you have a recent AMD Radeon graphics card.
drivers/gpu/drm/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_DRM_TDFX) += tdfx/ obj-$(CONFIG_DRM_R128) += r128/ obj-$(CONFIG_HSA_AMD) += amd/amdkfd/ obj-$(CONFIG_DRM_RADEON)+= radeon/ +obj-$(CONFIG_DRM_AMD_GNB_BUS) += amd/bus/ obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/ obj-$(CONFIG_DRM_MGA) += mga/ obj-$(CONFIG_DRM_I810) += i810/
drivers/gpu/drm/amd/bus/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +menu "AMD GNB BUS" + visible if 0 + +config DRM_AMD_GNB_BUS + tristate "AMD GNB bus - used for GNB IPs such as ACP and ISP" + +endmenu
drivers/gpu/drm/amd/bus/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/amd/include/bus/ + +obj-$(CONFIG_DRM_AMD_GNB_BUS) := amd_gnb_bus.o
drivers/gpu/drm/amd/bus/amd_gnb_bus.c new file +266 -0
266 lines not on this page · raw message
drivers/gpu/drm/amd/include/bus/amd_gnb_bus.h new file +78 -0
78 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/12 drm/amd: Add CGS interfaces
From: Chunming Zhou <[email protected]>
CGS (Common Graphics Services) is an AMD cross component abstraction layer to designed to better encapsulate specific IP block drivers so different teams can effectively work on differnet IP block drivers independently. It provides a common interface for things like accessing registers, allocating GPU memory, and registering interrupt sources. The plan is to eventually move more and more IP drivers to this interface. The first user is the ACP IP driver.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 327 ++++++++++++++++++ drivers/gpu/drm/amd/include/cgs_common.h | 563 +++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/include/cgs_linux.h | 135 ++++++++ 5 files changed, 1029 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c create mode 100644 drivers/gpu/drm/amd/include/cgs_common.h create mode 100644 drivers/gpu/drm/amd/include/cgs_linux.h
drivers/gpu/drm/amd/amdgpu/Makefile +3 -0
@@ -71,6 +71,9 @@ amdgpu-y += \ amdgpu_vce.o \ vce_v3_0.o +# add cgs +amdgpu-y += amdgpu_cgs.o + amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -42,6 +42,7 @@#include <ttm/ttm_module.h> #include <ttm/ttm_execbuf_util.h> +#include <drm/drmP.h> #include <drm/drm_gem.h> #include <drm/amdgpu_drm.h>
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c new file +327 -0
327 lines not on this page · raw message
drivers/gpu/drm/amd/include/cgs_common.h new file +563 -0
563 lines not on this page · raw message
drivers/gpu/drm/amd/include/cgs_linux.h new file +135 -0
135 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/12 drm/amdgpu: Implement mmio callbacks for CGS
In reply to Alex DeucherFrom: Chunming Zhou <[email protected]>
This implements the MMIO register accessors.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 45 ++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +38 -7
@@ -103,22 +103,38 @@ static int amdgpu_cgs_kunmap_gpu_mem(void *cgs_device, cgs_handle_t handle)static uint32_t amdgpu_cgs_read_register (void *cgs_device,unsigned offset) { -/* TODO */ -return 0 ; +CGS_FUNC_ADEV ; +return RREG32 (offset); }static void amdgpu_cgs_write_register (void *cgs_device,unsigned offset,uint32_t value) { -/* TODO */ -return ; +CGS_FUNC_ADEV ; +WREG32 (offset, value); }static uint32_t amdgpu_cgs_read_ind_register (void *cgs_device,enum cgs_ind_reg space,unsigned index) { -/* TODO */ +CGS_FUNC_ADEV ; +switch (space) { +case CGS_IND_REG__MMIO : +return RREG32_IDX (index); +case CGS_IND_REG__PCIE : +return RREG32_PCIE (index); +case CGS_IND_REG__SMC : +return RREG32_SMC (index); +case CGS_IND_REG__UVD_CTX : +return RREG32_UVD_CTX (index); +case CGS_IND_REG__DIDT : +return RREG32_DIDT (index); +case CGS_IND_REG__AUDIO_ENDPT : +DRM_ERROR ("audio endpt register access not implemented.\n" ); +return 0 ; + } +WARN (1 ,"Invalid indirect register space" );return 0 ; }
@@ -126,8 +142,23 @@ static void amdgpu_cgs_write_ind_register(void *cgs_device,enum cgs_ind_reg space, unsigned index, uint32_t value) { - /* TODO */ - return; +CGS_FUNC_ADEV ; +switch (space) { +case CGS_IND_REG__MMIO : +return WREG32_IDX (index, value); +case CGS_IND_REG__PCIE : +return WREG32_PCIE (index, value); +case CGS_IND_REG__SMC : +return WREG32_SMC (index, value); +case CGS_IND_REG__UVD_CTX : +return WREG32_UVD_CTX (index, value); +case CGS_IND_REG__DIDT : +return WREG32_DIDT (index, value); +case CGS_IND_REG__AUDIO_ENDPT : +DRM_ERROR ("audio endpt register access not implemented.\n" ); +return ; + } +WARN (1 ,"Invalid indirect register space" ); }static uint8_t amdgpu_cgs_read_pci_config_byte (void *cgs_device,unsigned addr)
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/12 drm/amdgpu: Implement the pciconfig callbacks for CGS
In reply to Alex DeucherFrom: Chunming Zhou <[email protected]>
This implements the pciconfig register accessors.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 40 +++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +28 -12
@@ -21,6 +21,7 @@* * */ +#include <linux/pci.h> #include "amdgpu.h" #include "cgs_linux.h"
@@ -163,42 +164,57 @@ static void amdgpu_cgs_write_ind_register(void *cgs_device,static uint8_t amdgpu_cgs_read_pci_config_byte (void *cgs_device,unsigned addr) { -/* TODO */ -return 0 ; +CGS_FUNC_ADEV ; +uint8_t val; +int ret =pci_read_config_byte (adev->pdev, addr, &val); +if (WARN (ret,"pci_read_config_byte error" )) +return 0 ; +return val; }static uint16_t amdgpu_cgs_read_pci_config_word (void *cgs_device,unsigned addr) { -/* TODO */ -return 0 ; +CGS_FUNC_ADEV ; +uint16_t val; +int ret =pci_read_config_word (adev->pdev, addr, &val); +if (WARN (ret,"pci_read_config_word error" )) +return 0 ; +return val; }static uint32_t amdgpu_cgs_read_pci_config_dword (void *cgs_device,unsigned addr) { -/* TODO */ -return 0 ; +CGS_FUNC_ADEV ; +uint32_t val; +int ret =pci_read_config_dword (adev->pdev, addr, &val); +if (WARN (ret,"pci_read_config_dword error" )) +return 0 ; +return val; }static void amdgpu_cgs_write_pci_config_byte (void *cgs_device,unsigned addr,uint8_t value) { -/* TODO */ -return ; +CGS_FUNC_ADEV ; +int ret =pci_write_config_byte (adev->pdev, addr, value); +WARN (ret,"pci_write_config_byte error" ); }static void amdgpu_cgs_write_pci_config_word (void *cgs_device,unsigned addr,uint16_t value) { -/* TODO */ -return ; +CGS_FUNC_ADEV ; +int ret =pci_write_config_word (adev->pdev, addr, value); +WARN (ret,"pci_write_config_word error" ); }static void amdgpu_cgs_write_pci_config_dword (void *cgs_device,unsigned addr,uint32_t value) { -/* TODO */ -return ; +CGS_FUNC_ADEV ; +int ret =pci_write_config_dword (adev->pdev, addr, value); +WARN (ret,"pci_write_config_dword error" ); } static const void *amdgpu_cgs_atom_get_data_table(void *cgs_device,
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/12 drm/amdgpu: Implement irq interfaces for CGS
In reply to Alex DeucherFrom: Chunming Zhou <[email protected]>
This implements the irq src registrar.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 81 ++++++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 5 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h | 1 + 5 files changed, 84 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +75 -6
@@ -290,26 +290,95 @@ static int amdgpu_cgs_set_camera_voltages(void *cgs_device, uint32_t mask,return -EPERM ; } +struct cgs_irq_params { +unsigned src_id; +cgs_irq_source_set_func_t set; +cgs_irq_handler_func_t handler; +void *private_data; +}; + +static int cgs_set_irq_state (struct amdgpu_device *adev, +struct amdgpu_irq_src *src, +unsigned type, +enum amdgpu_interrupt_state state) +{ +struct cgs_irq_params *irq_params = + (struct cgs_irq_params *)src->data; +if (!irq_params) +return -EINVAL ; +if (!irq_params->set) +return -EINVAL ; +return irq_params->set (irq_params->private_data, + irq_params->src_id, + type, + (int )state); +} + +static int cgs_process_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +struct cgs_irq_params *irq_params = + (struct cgs_irq_params *)source->data; +if (!irq_params) +return -EINVAL ; +if (!irq_params->handler) +return -EINVAL ; +return irq_params->handler (irq_params->private_data, + irq_params->src_id, + entry->iv_entry); +} + +static const struct amdgpu_irq_src_funcs cgs_irq_funcs = { + .set = cgs_set_irq_state, + .process = cgs_process_irq, +}; +static int amdgpu_cgs_add_irq_source (void *cgs_device,unsigned src_id,unsigned num_types,cgs_irq_source_set_func_t set,cgs_irq_handler_func_t handler,void *private_data) { -/* TODO */ -return 0 ; +CGS_FUNC_ADEV ; +int ret =0 ; +struct cgs_irq_params *irq_params; +struct amdgpu_irq_src *source = +kzalloc (sizeof (struct amdgpu_irq_src ),GFP_KERNEL ); +if (!source) +return -ENOMEM ; + irq_params = +kzalloc (sizeof (struct cgs_irq_params ),GFP_KERNEL ); +if (!irq_params) { +kfree (source); +return -ENOMEM ; + } + source->num_types = num_types; + source->funcs = &cgs_irq_funcs; + irq_params->src_id = src_id; + irq_params->set = set; + irq_params->handler = handler; + irq_params->private_data = private_data; + source->data = (void *)irq_params; + ret =amdgpu_irq_add_id (adev, src_id, source); +if (ret) { +kfree (irq_params); +kfree (source); + } + +return ret; }static int amdgpu_cgs_irq_get (void *cgs_device,unsigned src_id,unsigned type) { -/* TODO */ -return 0 ; +CGS_FUNC_ADEV ; +return amdgpu_irq_get (adev, adev->irq.sources[src_id], type); }static int amdgpu_cgs_irq_put (void *cgs_device,unsigned src_id,unsigned type) { -/* TODO */ -return 0 ; +CGS_FUNC_ADEV ; +return amdgpu_irq_put (adev, adev->irq.sources[src_id], type); }static const struct cgs_ops amdgpu_cgs_ops = {
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +2 -0
@@ -199,6 +199,8 @@ restart_ih:rmb ();while (adev->irq.ih.rptr != wptr) { + entry.iv_entry = (const uint32_t *) + &adev->irq.ih.ring[adev->irq.ih.rptr >>2 ];amdgpu_ih_decode_iv (adev, &entry); adev->irq.ih.rptr &= adev->irq.ih.ptr_mask;
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +1 -0
@@ -52,6 +52,7 @@ struct amdgpu_iv_entry {unsigned ring_id;unsigned vm_id;unsigned pas_id; +const uint32_t *iv_entry; }; int amdgpu_ih_ring_init(struct amdgpu_device *adev, unsigned ring_size,
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +5 -0
@@ -272,6 +272,11 @@ void amdgpu_irq_fini(struct amdgpu_device *adev)kfree (src->enabled_types); src->enabled_types =NULL ; +if (src->data) { +kfree (src->data); +kfree (src); + adev->irq.sources[i] =NULL ; + } } }
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h +1 -0
@@ -40,6 +40,7 @@ struct amdgpu_irq_src {unsigned num_types;atomic_t *enabled_types;const struct amdgpu_irq_src_funcs *funcs; +void *data; };/* provided by interrupt generating IP blocks */
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/12 drm/amdgpu: add atom interfaces for CGS
In reply to Alex DeucherFrom: Chunming Zhou <[email protected]>
This implements the interface for atombios command and data table access.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +22 -6
@@ -24,6 +24,7 @@#include <linux/pci.h> #include "amdgpu.h" #include "cgs_linux.h" +#include "atom.h" struct amdgpu_cgs_device {struct cgs_device base;
@@ -221,24 +222,39 @@ static const void *amdgpu_cgs_atom_get_data_table(void *cgs_device, unsigned table, uint16_t *size, uint8_t *frev, uint8_t *crev) { - /* TODO */ +CGS_FUNC_ADEV ; +uint16_t data_start; + +if (amdgpu_atom_parse_data_header ( + adev->mode_info.atom_context, table, size, + frev, crev, &data_start)) +return (uint8_t *)adev->mode_info.atom_context->bios + + data_start; +return NULL ; }static int amdgpu_cgs_atom_get_cmd_table_revs (void *cgs_device,unsigned table,uint8_t *frev,uint8_t *crev) { -/* TODO */ -return 0 ; +CGS_FUNC_ADEV ; + +if (amdgpu_atom_parse_cmd_header ( + adev->mode_info.atom_context, table, + frev, crev)) +return 0 ; + +return -EINVAL ; }static int amdgpu_cgs_atom_exec_cmd_table (void *cgs_device,unsigned table,void *args) { -/* TODO */ -return 0 ; -} +CGS_FUNC_ADEV ; +return amdgpu_atom_execute_table ( + adev->mode_info.atom_context, table, args); +}static int amdgpu_cgs_create_pm_request (void *cgs_device,cgs_handle_t *request) {
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/12 drm/amdgpu: implement cgs gpu memory callbacks
In reply to Alex DeucherFrom: Chunming Zhou <[email protected]>
This implements the cgs interface for allocating
GPU memory.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 238 ++++++++++++++++++++++++++++++-- 1 file changed, 226 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +226 -12
@@ -21,7 +21,11 @@* * */ +#include <linux/list.h> +#include <linux/slab.h> #include <linux/pci.h> +#include <drm/drmP.h> +#include <drm/amdgpu_drm.h> #include "amdgpu.h" #include "cgs_linux.h" #include "atom.h"
@@ -39,6 +43,30 @@ static int amdgpu_cgs_gpu_mem_info(void *cgs_device, enum cgs_gpu_mem_type type, uint64_t *mc_start, uint64_t *mc_size, uint64_t *mem_size) { +CGS_FUNC_ADEV ; +switch (type) { +case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__VISIBLE_FB : + *mc_start =0 ; + *mc_size = adev->mc.visible_vram_size; + *mem_size = adev->mc.visible_vram_size - adev->vram_pin_size; +break ; +case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__INVISIBLE_FB : + *mc_start = adev->mc.visible_vram_size; + *mc_size = adev->mc.real_vram_size - adev->mc.visible_vram_size; + *mem_size = *mc_size; +break ; +case CGS_GPU_MEM_TYPE__GART_CACHEABLE : +case CGS_GPU_MEM_TYPE__GART_WRITECOMBINE : + *mc_start = adev->mc.gtt_start; + *mc_size = adev->mc.gtt_size; + *mem_size = adev->mc.gtt_size - adev->gart_pin_size; +break ; +default : +return -EINVAL ; + } +return 0 ; }
@@ -47,11 +75,43 @@ static int amdgpu_cgs_gmap_kmem(void *cgs_device, void *kmem, uint64_t min_offset, uint64_t max_offset, cgs_handle_t *kmem_handle, uint64_t *mcaddr) { - return 0; +CGS_FUNC_ADEV ; +int ret; +struct amdgpu_bo *bo; +struct page *kmem_page =vmalloc_to_page (kmem); +int npages =ALIGN (size,PAGE_SIZE ) >>PAGE_SHIFT ; + +struct sg_table *sg =drm_prime_pages_to_sg (&kmem_page, npages); + ret =amdgpu_bo_create (adev, size,PAGE_SIZE , false, +AMDGPU_GEM_DOMAIN_GTT ,0 , sg, &bo); +if (ret) +return ret; + ret =amdgpu_bo_reserve (bo, false); +if (unlikely (ret !=0 )) +return ret; + +/* pin buffer into GTT */ + ret =amdgpu_bo_pin_restricted (bo,AMDGPU_GEM_DOMAIN_GTT , + min_offset, max_offset, mcaddr); +amdgpu_bo_unreserve (bo); + + *kmem_handle = (cgs_handle_t )bo; +return ret; }static int amdgpu_cgs_gunmap_kmem (void *cgs_device,cgs_handle_t kmem_handle) { +struct amdgpu_bo *obj = (struct amdgpu_bo *)kmem_handle; + +if (obj) { +int r =amdgpu_bo_reserve (obj, false); +if (likely (r ==0 )) { +amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); + } +amdgpu_bo_unref (&obj); + + }return 0 ; }
@@ -61,46 +121,200 @@ static int amdgpu_cgs_alloc_gpu_mem(void *cgs_device, uint64_t min_offset, uint64_t max_offset, cgs_handle_t *handle) { - return 0; +CGS_FUNC_ADEV ; +uint16_t flags =0 ; +int ret =0 ; +uint32_t domain =0 ; +struct amdgpu_bo *obj; +struct ttm_placement placement; +struct ttm_place place; + +if (min_offset > max_offset) { +BUG_ON (1 ); +return -EINVAL ; + } + +/* fail if the alignment is not a power of 2 */ +if (((align !=1 ) && (align & (align -1 ))) + || size ==0 || align ==0 ) +return -EINVAL ; + + +switch (type) { +case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__VISIBLE_FB : + flags =AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; + domain =AMDGPU_GEM_DOMAIN_VRAM ; +if (max_offset > adev->mc.real_vram_size) +return -EINVAL ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | +TTM_PL_FLAG_VRAM ; +break ; +case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__INVISIBLE_FB : + flags =AMDGPU_GEM_CREATE_NO_CPU_ACCESS ; + domain =AMDGPU_GEM_DOMAIN_VRAM ; +if (adev->mc.visible_vram_size < adev->mc.real_vram_size) { + place.fpfn = +max (min_offset, adev->mc.visible_vram_size) >>PAGE_SHIFT ; + place.lpfn = +min (max_offset, adev->mc.real_vram_size) >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | +TTM_PL_FLAG_VRAM ; + } + +break ; +case CGS_GPU_MEM_TYPE__GART_CACHEABLE : + domain =AMDGPU_GEM_DOMAIN_GTT ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_TT ; +break ; +case CGS_GPU_MEM_TYPE__GART_WRITECOMBINE : + flags =AMDGPU_GEM_CREATE_CPU_GTT_USWC ; + domain =AMDGPU_GEM_DOMAIN_GTT ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_TT | +TTM_PL_FLAG_UNCACHED ; +break ; +default : +return -EINVAL ; + } + + + *handle =0 ; + + placement.placement = &place; + placement.num_placement =1 ; + placement.busy_placement = &place; + placement.num_busy_placement =1 ; + + ret =amdgpu_bo_create_restricted (adev, size,PAGE_SIZE , + true, domain, flags, +NULL , &placement, &obj); +if (ret) { +DRM_ERROR ("(%d) bo create failed\n" , ret); +return ret; + } + *handle = (cgs_handle_t )obj; + +return ret; }static int amdgpu_cgs_import_gpu_mem (void *cgs_device,int dmabuf_fd,cgs_handle_t *handle) { -/* TODO */ +CGS_FUNC_ADEV ; +int r; +uint32_t dma_handle; +struct drm_gem_object *obj; +struct amdgpu_bo *bo; +struct drm_device *dev = adev->ddev; +struct drm_file *file_priv =NULL , *priv; + +mutex_lock (&dev->struct_mutex); +list_for_each_entry (priv, &dev->filelist, lhead) { +rcu_read_lock (); +if (priv->pid ==get_pid (task_pid (current))) + file_priv = priv; +rcu_read_unlock (); +if (file_priv) +break ; + } +mutex_unlock (&dev->struct_mutex); + r = dev->driver->prime_fd_to_handle (dev, + file_priv, dmabuf_fd, + &dma_handle); +spin_lock (&file_priv->table_lock); + +/* Check if we currently have a reference on the object */ + obj =idr_find (&file_priv->object_idr, dma_handle); +if (obj ==NULL ) { +spin_unlock (&file_priv->table_lock); +return -EINVAL ; + } +spin_unlock (&file_priv->table_lock); + bo =gem_to_amdgpu_bo (obj); + *handle = (cgs_handle_t )bo;return 0 ; }static int amdgpu_cgs_free_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + +if (obj) { +int r =amdgpu_bo_reserve (obj, false); +if (likely (r ==0 )) { +amdgpu_bo_kunmap (obj); +amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); + } +amdgpu_bo_unref (&obj); + + }return 0 ; }static int amdgpu_cgs_gmap_gpu_mem (void *cgs_device,cgs_handle_t handle,uint64_t *mcaddr) { -/* TODO */ -return 0 ; +int r; +u64 min_offset, max_offset; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + +WARN_ON_ONCE (obj->placement.num_placement >1 ); + + min_offset = obj->placements[0 ].fpfn <<PAGE_SHIFT ; + max_offset = obj->placements[0 ].lpfn <<PAGE_SHIFT ; + + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_pin_restricted (obj,AMDGPU_GEM_DOMAIN_GTT , + min_offset, max_offset, mcaddr); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_gunmap_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_kmap_gpu_mem (void *cgs_device,cgs_handle_t handle,void **map) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_kmap (obj, map); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_kunmap_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; +amdgpu_bo_kunmap (obj); +amdgpu_bo_unreserve (obj); +return r; }static uint32_t amdgpu_cgs_read_register (void *cgs_device,unsigned offset)
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
Quoted 6 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>
I don't see that review anywhere on a m-l ... where is it?
I stumbled over this patch because it adds a new dev->struct_mutex user (that should be a big warning sign) and then I somehow unrolled some giant chain of wtfs. Either I'm completely missing what this is used for or it probably should get reworked asap.
-Daniel
Quoted 317 lines
Signed-off-by Chunming Zhou <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 238 ++++++++++++++++++++++++++++++-- 1 file changed, 226 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +226
-12@@ -21,7 +21,11 @@* * */ +#include <linux/list.h> +#include <linux/slab.h> #include <linux/pci.h> +#include <drm/drmP.h> +#include <drm/amdgpu_drm.h> #include "amdgpu.h" #include "cgs_linux.h" #include "atom.h" @@ -39,6 +43,30 @@ static int amdgpu_cgs_gpu_mem_info(void *cgs_device, enum cgs_gpu_mem_type type, uint64_t *mc_start, uint64_t *mc_size, uint64_t *mem_size) { +CGS_FUNC_ADEV ; +switch (type) { +case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__VISIBLE_FB : + *mc_start =0 ; + *mc_size = adev->mc.visible_vram_size; + *mem_size = adev->mc.visible_vram_size - adev->vram_pin_size; +break ; +case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__INVISIBLE_FB : + *mc_start = adev->mc.visible_vram_size; + *mc_size = adev->mc.real_vram_size - adev->mc.visible_vram_size; + *mem_size = *mc_size; +break ; +case CGS_GPU_MEM_TYPE__GART_CACHEABLE : +case CGS_GPU_MEM_TYPE__GART_WRITECOMBINE : + *mc_start = adev->mc.gtt_start; + *mc_size = adev->mc.gtt_size; + *mem_size = adev->mc.gtt_size - adev->gart_pin_size; +break ; +default : +return -EINVAL ; + } +return 0 ; }@@ -47,11 +75,43 @@ static int amdgpu_cgs_gmap_kmem(void *cgs_device, void *kmem, uint64_t min_offset, uint64_t max_offset, cgs_handle_t *kmem_handle, uint64_t *mcaddr) { - return 0; +CGS_FUNC_ADEV ; +int ret; +struct amdgpu_bo *bo; +struct page *kmem_page =vmalloc_to_page (kmem); +int npages =ALIGN (size,PAGE_SIZE ) >>PAGE_SHIFT ; + +struct sg_table *sg =drm_prime_pages_to_sg (&kmem_page, npages); + ret =amdgpu_bo_create (adev, size,PAGE_SIZE , false, +AMDGPU_GEM_DOMAIN_GTT ,0 , sg, &bo); +if (ret) +return ret; + ret =amdgpu_bo_reserve (bo, false); +if (unlikely (ret !=0 )) +return ret; + +/* pin buffer into GTT */ + ret =amdgpu_bo_pin_restricted (bo,AMDGPU_GEM_DOMAIN_GTT , + min_offset, max_offset, mcaddr); +amdgpu_bo_unreserve (bo); + + *kmem_handle = (cgs_handle_t )bo; +return ret; }static int amdgpu_cgs_gunmap_kmem (void *cgs_device,cgs_handle_t kmem_handle) { +struct amdgpu_bo *obj = (struct amdgpu_bo *)kmem_handle; + +if (obj) { +int r =amdgpu_bo_reserve (obj, false); +if (likely (r ==0 )) { +amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); + } +amdgpu_bo_unref (&obj); + + }return 0 ; }@@ -61,46 +121,200 @@ static int amdgpu_cgs_alloc_gpu_mem(void *cgs_device, uint64_t min_offset, uint64_t max_offset, cgs_handle_t *handle) { - return 0; +CGS_FUNC_ADEV ; +uint16_t flags =0 ; +int ret =0 ; +uint32_t domain =0 ; +struct amdgpu_bo *obj; +struct ttm_placement placement; +struct ttm_place place; + +if (min_offset > max_offset) { +BUG_ON (1 ); +return -EINVAL ; + } + +/* fail if the alignment is not a power of 2 */ +if (((align !=1 ) && (align & (align -1 ))) + || size ==0 || align ==0 ) +return -EINVAL ; + + +switch (type) { +case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__VISIBLE_FB : + flags =AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; + domain =AMDGPU_GEM_DOMAIN_VRAM ; +if (max_offset > adev->mc.real_vram_size) +return -EINVAL ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | +TTM_PL_FLAG_VRAM ; +break ; +case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__INVISIBLE_FB : + flags =AMDGPU_GEM_CREATE_NO_CPU_ACCESS ; + domain =AMDGPU_GEM_DOMAIN_VRAM ; +if (adev->mc.visible_vram_size < adev->mc.real_vram_size) { + place.fpfn = +max (min_offset, adev->mc.visible_vram_size) >>PAGE_SHIFT ; + place.lpfn = +min (max_offset, adev->mc.real_vram_size) >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | +TTM_PL_FLAG_VRAM ; + } + +break ; +case CGS_GPU_MEM_TYPE__GART_CACHEABLE : + domain =AMDGPU_GEM_DOMAIN_GTT ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_TT ; +break ; +case CGS_GPU_MEM_TYPE__GART_WRITECOMBINE : + flags =AMDGPU_GEM_CREATE_CPU_GTT_USWC ; + domain =AMDGPU_GEM_DOMAIN_GTT ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_TT | +TTM_PL_FLAG_UNCACHED ; +break ; +default : +return -EINVAL ; + } + + + *handle =0 ; + + placement.placement = &place; + placement.num_placement =1 ; + placement.busy_placement = &place; + placement.num_busy_placement =1 ; + + ret =amdgpu_bo_create_restricted (adev, size,PAGE_SIZE , + true, domain, flags, +NULL , &placement, &obj); +if (ret) { +DRM_ERROR ("(%d) bo create failed\n" , ret); +return ret; + } + *handle = (cgs_handle_t )obj; + +return ret; }static int amdgpu_cgs_import_gpu_mem (void *cgs_device,int dmabuf_fd,cgs_handle_t *handle) { -/* TODO */ +CGS_FUNC_ADEV ; +int r; +uint32_t dma_handle; +struct drm_gem_object *obj; +struct amdgpu_bo *bo; +struct drm_device *dev = adev->ddev; +struct drm_file *file_priv =NULL , *priv; + +mutex_lock (&dev->struct_mutex); +list_for_each_entry (priv, &dev->filelist, lhead) { +rcu_read_lock (); +if (priv->pid ==get_pid (task_pid (current))) + file_priv = priv; +rcu_read_unlock (); +if (file_priv) +break ; + } +mutex_unlock (&dev->struct_mutex); + r = dev->driver->prime_fd_to_handle (dev, + file_priv, dmabuf_fd, + &dma_handle); +spin_lock (&file_priv->table_lock); + +/* Check if we currently have a reference on the object */ + obj =idr_find (&file_priv->object_idr, dma_handle); +if (obj ==NULL ) { +spin_unlock (&file_priv->table_lock); +return -EINVAL ; + } +spin_unlock (&file_priv->table_lock); + bo =gem_to_amdgpu_bo (obj); + *handle = (cgs_handle_t )bo;return 0 ; }static int amdgpu_cgs_free_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + +if (obj) { +int r =amdgpu_bo_reserve (obj, false); +if (likely (r ==0 )) { +amdgpu_bo_kunmap (obj); +amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); + } +amdgpu_bo_unref (&obj); + + }return 0 ; }static int amdgpu_cgs_gmap_gpu_mem (void *cgs_device,cgs_handle_t handle,uint64_t *mcaddr) { -/* TODO */ -return 0 ; +int r; +u64 min_offset, max_offset; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + +WARN_ON_ONCE (obj->placement.num_placement >1 ); + + min_offset = obj->placements[0 ].fpfn <<PAGE_SHIFT ; + max_offset = obj->placements[0 ].lpfn <<PAGE_SHIFT ; + + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_pin_restricted (obj,AMDGPU_GEM_DOMAIN_GTT , + min_offset, max_offset, mcaddr); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_gunmap_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_kmap_gpu_mem (void *cgs_device,cgs_handle_t handle,void **map) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_kmap (obj, map); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_kunmap_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; +amdgpu_bo_kunmap (obj); +amdgpu_bo_unreserve (obj); +return r; }static uint32_t amdgpu_cgs_read_register (void *cgs_device,unsigned offset)Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://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] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Quoted 5 lines
I stumbled over this patch because it adds a new
dev->struct_mutexuser (that should be a big warning sign) and then I somehow unrolled some giant chain of wtfs. Either I'm completely missing what this is used for or it probably should get reworked asap.
The CGS functions aren't used at the moment because none of the components depending on them made it into the kernel, but we wanted to keep it so that we can get reviews on the general idea and if necessary rework it.
In general it's an abstraction layer of device driver dependent functions which enables us to share more code internally.
We worked quite hard on trying to avoid the OS abstraction trap with this, but if you think this still won't work feel free to object.
Regards,
Christian.
Quoted 311 lines
-Daniel
Quoted 309 lines
Signed-off-by Chunming Zhou <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 238 ++++++++++++++++++++++++++++++-- 1 file changed, 226 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +226
-12@@ -21,7 +21,11 @@* * */ +#include <linux/list.h> +#include <linux/slab.h> #include <linux/pci.h> +#include <drm/drmP.h> +#include <drm/amdgpu_drm.h> #include "amdgpu.h" #include "cgs_linux.h" #include "atom.h" @@ -39,6 +43,30 @@ static int amdgpu_cgs_gpu_mem_info(void *cgs_device, enum cgs_gpu_mem_type type, uint64_t *mc_start, uint64_t *mc_size, uint64_t *mem_size) { +CGS_FUNC_ADEV ; +switch (type) { +case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__VISIBLE_FB : + *mc_start =0 ; + *mc_size = adev->mc.visible_vram_size; + *mem_size = adev->mc.visible_vram_size - adev->vram_pin_size; +break ; +case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__INVISIBLE_FB : + *mc_start = adev->mc.visible_vram_size; + *mc_size = adev->mc.real_vram_size - adev->mc.visible_vram_size; + *mem_size = *mc_size; +break ; +case CGS_GPU_MEM_TYPE__GART_CACHEABLE : +case CGS_GPU_MEM_TYPE__GART_WRITECOMBINE : + *mc_start = adev->mc.gtt_start; + *mc_size = adev->mc.gtt_size; + *mem_size = adev->mc.gtt_size - adev->gart_pin_size; +break ; +default : +return -EINVAL ; + } +return 0 ; }@@ -47,11 +75,43 @@ static int amdgpu_cgs_gmap_kmem(void *cgs_device, void *kmem, uint64_t min_offset, uint64_t max_offset, cgs_handle_t *kmem_handle, uint64_t *mcaddr) { - return 0; +CGS_FUNC_ADEV ; +int ret; +struct amdgpu_bo *bo; +struct page *kmem_page =vmalloc_to_page (kmem); +int npages =ALIGN (size,PAGE_SIZE ) >>PAGE_SHIFT ; + +struct sg_table *sg =drm_prime_pages_to_sg (&kmem_page, npages); + ret =amdgpu_bo_create (adev, size,PAGE_SIZE , false, +AMDGPU_GEM_DOMAIN_GTT ,0 , sg, &bo); +if (ret) +return ret; + ret =amdgpu_bo_reserve (bo, false); +if (unlikely (ret !=0 )) +return ret; + +/* pin buffer into GTT */ + ret =amdgpu_bo_pin_restricted (bo,AMDGPU_GEM_DOMAIN_GTT , + min_offset, max_offset, mcaddr); +amdgpu_bo_unreserve (bo); + + *kmem_handle = (cgs_handle_t )bo; +return ret; }static int amdgpu_cgs_gunmap_kmem (void *cgs_device,cgs_handle_t kmem_handle) { +struct amdgpu_bo *obj = (struct amdgpu_bo *)kmem_handle; + +if (obj) { +int r =amdgpu_bo_reserve (obj, false); +if (likely (r ==0 )) { +amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); + } +amdgpu_bo_unref (&obj); + + }return 0 ; }@@ -61,46 +121,200 @@ static int amdgpu_cgs_alloc_gpu_mem(void *cgs_device, uint64_t min_offset, uint64_t max_offset, cgs_handle_t *handle) { - return 0; +CGS_FUNC_ADEV ; +uint16_t flags =0 ; +int ret =0 ; +uint32_t domain =0 ; +struct amdgpu_bo *obj; +struct ttm_placement placement; +struct ttm_place place; + +if (min_offset > max_offset) { +BUG_ON (1 ); +return -EINVAL ; + } + +/* fail if the alignment is not a power of 2 */ +if (((align !=1 ) && (align & (align -1 ))) + || size ==0 || align ==0 ) +return -EINVAL ; + + +switch (type) { +case CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__VISIBLE_FB : + flags =AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; + domain =AMDGPU_GEM_DOMAIN_VRAM ; +if (max_offset > adev->mc.real_vram_size) +return -EINVAL ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | +TTM_PL_FLAG_VRAM ; +break ; +case CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB : +case CGS_GPU_MEM_TYPE__INVISIBLE_FB : + flags =AMDGPU_GEM_CREATE_NO_CPU_ACCESS ; + domain =AMDGPU_GEM_DOMAIN_VRAM ; +if (adev->mc.visible_vram_size < adev->mc.real_vram_size) { + place.fpfn = +max (min_offset, adev->mc.visible_vram_size) >>PAGE_SHIFT ; + place.lpfn = +min (max_offset, adev->mc.real_vram_size) >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | +TTM_PL_FLAG_VRAM ; + } + +break ; +case CGS_GPU_MEM_TYPE__GART_CACHEABLE : + domain =AMDGPU_GEM_DOMAIN_GTT ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_TT ; +break ; +case CGS_GPU_MEM_TYPE__GART_WRITECOMBINE : + flags =AMDGPU_GEM_CREATE_CPU_GTT_USWC ; + domain =AMDGPU_GEM_DOMAIN_GTT ; + place.fpfn = min_offset >>PAGE_SHIFT ; + place.lpfn = max_offset >>PAGE_SHIFT ; + place.flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_TT | +TTM_PL_FLAG_UNCACHED ; +break ; +default : +return -EINVAL ; + } + + + *handle =0 ; + + placement.placement = &place; + placement.num_placement =1 ; + placement.busy_placement = &place; + placement.num_busy_placement =1 ; + + ret =amdgpu_bo_create_restricted (adev, size,PAGE_SIZE , + true, domain, flags, +NULL , &placement, &obj); +if (ret) { +DRM_ERROR ("(%d) bo create failed\n" , ret); +return ret; + } + *handle = (cgs_handle_t )obj; + +return ret; }static int amdgpu_cgs_import_gpu_mem (void *cgs_device,int dmabuf_fd,cgs_handle_t *handle) { -/* TODO */ +CGS_FUNC_ADEV ; +int r; +uint32_t dma_handle; +struct drm_gem_object *obj; +struct amdgpu_bo *bo; +struct drm_device *dev = adev->ddev; +struct drm_file *file_priv =NULL , *priv; + +mutex_lock (&dev->struct_mutex); +list_for_each_entry (priv, &dev->filelist, lhead) { +rcu_read_lock (); +if (priv->pid ==get_pid (task_pid (current))) + file_priv = priv; +rcu_read_unlock (); +if (file_priv) +break ; + } +mutex_unlock (&dev->struct_mutex); + r = dev->driver->prime_fd_to_handle (dev, + file_priv, dmabuf_fd, + &dma_handle); +spin_lock (&file_priv->table_lock); + +/* Check if we currently have a reference on the object */ + obj =idr_find (&file_priv->object_idr, dma_handle); +if (obj ==NULL ) { +spin_unlock (&file_priv->table_lock); +return -EINVAL ; + } +spin_unlock (&file_priv->table_lock); + bo =gem_to_amdgpu_bo (obj); + *handle = (cgs_handle_t )bo;return 0 ; }static int amdgpu_cgs_free_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + +if (obj) { +int r =amdgpu_bo_reserve (obj, false); +if (likely (r ==0 )) { +amdgpu_bo_kunmap (obj); +amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); + } +amdgpu_bo_unref (&obj); + + }return 0 ; }static int amdgpu_cgs_gmap_gpu_mem (void *cgs_device,cgs_handle_t handle,uint64_t *mcaddr) { -/* TODO */ -return 0 ; +int r; +u64 min_offset, max_offset; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + +WARN_ON_ONCE (obj->placement.num_placement >1 ); + + min_offset = obj->placements[0 ].fpfn <<PAGE_SHIFT ; + max_offset = obj->placements[0 ].lpfn <<PAGE_SHIFT ; + + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_pin_restricted (obj,AMDGPU_GEM_DOMAIN_GTT , + min_offset, max_offset, mcaddr); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_gunmap_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_unpin (obj); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_kmap_gpu_mem (void *cgs_device,cgs_handle_t handle,void **map) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; + r =amdgpu_bo_kmap (obj, map); +amdgpu_bo_unreserve (obj); +return r; }static int amdgpu_cgs_kunmap_gpu_mem (void *cgs_device,cgs_handle_t handle) { -/* TODO */ -return 0 ; +int r; +struct amdgpu_bo *obj = (struct amdgpu_bo *)handle; + r =amdgpu_bo_reserve (obj, false); +if (unlikely (r !=0 )) +return r; +amdgpu_bo_kunmap (obj); +amdgpu_bo_unreserve (obj); +return r; }
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +0
-0static uint32_t amdgpu_cgs_read_register (void *cgs_device,unsigned offset)Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
Quoted 23 lines · Christian König
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Quoted 5 lines
I stumbled over this patch because it adds a new
dev->struct_mutexuser (that should be a big warning sign) and then I somehow unrolled some giant chain of wtfs. Either I'm completely missing what this is used for or it probably should get reworked asap.The CGS functions aren't used at the moment because none of the components depending on them made it into the kernel, but we wanted to keep it so that we can get reviews on the general idea and if necessary rework it.
Quoted 5 lines
In general it's an abstraction layer of device driver dependent functions which enables us to share more code internally.
We worked quite hard on trying to avoid the OS abstraction trap with this, but if you think this still won't work feel free to object.
The bit that made me look really is the import_gpu_mem thing, which seems to partially reinvent drm_prime.c. Given how tricky importing and import-caching is I'd really like to see that gone (and Alex said on irc he'd be ok with that).
The other stuff seems a lot more benign. For the irq abstraction specifically it might be worth looking at the irq_chip stuff linux core has, which is what's used to virtualize/abstract irq routing and handling. But for that stuff it's a balance thing really how much you reinvent wheels internally in the driver (e.g. i915 has it's own power_well stuff which is pretty much just powerdomains reinvented, with less features).
But really I can't tell without the users whether I'd expect this to be hurt longterm or not for you ;-) But the import stuff is hurt for me since you noodle around in drm internals. And specifically I'd like to make modern drivers completely struct_mutex free with the goal to untangle the last hold-outs of that lock in the drm core.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
Quoted 27 lines · Daniel Vetter
Quoted 26 lines · Christian König
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Quoted 5 lines
I stumbled over this patch because it adds a new
dev->struct_mutexuser (that should be a big warning sign) and then I somehow unrolled some giant chain of wtfs. Either I'm completely missing what this is used for or it probably should get reworked asap.The CGS functions aren't used at the moment because none of the components depending on them made it into the kernel, but we wanted to keep it so that we can get reviews on the general idea and if necessary rework it.
In general it's an abstraction layer of device driver dependent functions which enables us to share more code internally.
Quoted 8 lines
Quoted 2 lines
We worked quite hard on trying to avoid the OS abstraction trap with this, but if you think this still won't work feel free to object.
The bit that made me look really is the
import_gpu_memthing, which seems to partially reinventdrm_prime.c. Given how tricky importing and import-caching is I'd really like to see that gone (and Alex said on irc he'd be ok with that).
See attached patch. It was really only added for completeness. We don't have any users of it at the moment. If we end up needing the functionality in the future we can revisit it.
Quoted 7 lines
The other stuff seems a lot more benign. For the irq abstraction specifically it might be worth looking at the
irq_chipstuff linux core has, which is what's used to virtualize/abstract irq routing and handling. But for that stuff it's a balance thing really how much you reinvent wheels internally in the driver (e.g. i915 has it's ownpower_wellstuff which is pretty much just powerdomains reinvented, with less features).
I think that's one of the hardest things in the kernel: finding out if a solution already exists or not. We implemented our own version of mfd for our ACP audio block driver. Upon upsteaming we were alerted to mfd's existence and we converted the driver to use mfd. At the end of the day it was a lot of work for minimal gain, at least from a functionality perspective. I wish we had known about it sooner. I'll take a look at the irq_chip stuff. Thanks for the heads up!
Alex
Quoted 10 lines
But really I can't tell without the users whether I'd expect this to be hurt longterm or not for you ;-) But the import stuff is hurt for me since you noodle around in drm internals. And specifically I'd like to make modern drivers completely
struct_mutexfree with the goal to untangle the last hold-outs of that lock in the drm core.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
From 013170490a934731bb5fbc4cb8ee46421d2f240e Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Tue, 29 Sep 2015 10:35:45 -0400
Subject: [PATCH] drm/amdgpu/cgs: remove import_gpu_mem
It was added for completeness, but we don't have any users for it yet. Daniel Vetter noted that it may be racy. Remove it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 39 --------------------------------- drivers/gpu/drm/amd/include/cgs_linux.h | 17 -------------- 2 files changed, 56 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +0 -39
@@ -208,44 +208,6 @@ static int amdgpu_cgs_alloc_gpu_mem(void *cgs_device,return ret; } -static int amdgpu_cgs_import_gpu_mem (void *cgs_device,int dmabuf_fd, -cgs_handle_t *handle) -{ -CGS_FUNC_ADEV ; -int r; -uint32_t dma_handle; -struct drm_gem_object *obj; -struct amdgpu_bo *bo; -struct drm_device *dev = adev->ddev; -struct drm_file *file_priv =NULL , *priv; - -mutex_lock (&dev->struct_mutex); -list_for_each_entry (priv, &dev->filelist, lhead) { -rcu_read_lock (); -if (priv->pid ==get_pid (task_pid (current))) - file_priv = priv; -rcu_read_unlock (); -if (file_priv) -break ; - } -mutex_unlock (&dev->struct_mutex); - r = dev->driver->prime_fd_to_handle (dev, - file_priv, dmabuf_fd, - &dma_handle); -spin_lock (&file_priv->table_lock); - -/* Check if we currently have a reference on the object */ - obj =idr_find (&file_priv->object_idr, dma_handle); -if (obj ==NULL ) { -spin_unlock (&file_priv->table_lock); -return -EINVAL ; - } -spin_unlock (&file_priv->table_lock); - bo =gem_to_amdgpu_bo (obj); - *handle = (cgs_handle_t )bo; -return 0 ; -} -static int amdgpu_cgs_free_gpu_mem (void *cgs_device,cgs_handle_t handle) {struct amdgpu_bo *obj = (struct amdgpu_bo *)handle;
@@ -846,7 +808,6 @@ static const struct cgs_ops amdgpu_cgs_ops = { };static const struct cgs_os_ops amdgpu_cgs_os_ops = { - amdgpu_cgs_import_gpu_mem, amdgpu_cgs_add_irq_source, amdgpu_cgs_irq_get, amdgpu_cgs_irq_put
drivers/gpu/drm/amd/include/cgs_linux.h +0 -17
@@ -27,19 +27,6 @@#include "cgs_common.h" /** -* cgs_import_gpu_mem() - Import dmabuf handle -* @cgs_device: opaque device handle -* @dmabuf_fd: DMABuf file descriptor -* @handle: memory handle (output) -* -* Must be called in the process context that dmabuf_fd belongs to. -* -* Return: 0 on success, -errno otherwise -*/ -typedef int (*cgs_import_gpu_mem_t )(void *cgs_device,int dmabuf_fd, -cgs_handle_t *handle); - -/** * cgs_irq_source_set_func() - Callback for enabling/disabling interrupt sources * @private_data: private data provided to cgs_add_irq_source * @src_id: interrupt source ID
@@ -114,16 +101,12 @@ typedef int (*cgs_irq_get_t)(void *cgs_device, unsigned src_id, unsigned type);typedef int (*cgs_irq_put_t )(void *cgs_device,unsigned src_id,unsigned type);struct cgs_os_ops { -cgs_import_gpu_mem_t import_gpu_mem; -/* IRQ handling */ cgs_add_irq_source_t add_irq_source;cgs_irq_get_t irq_get;cgs_irq_put_t irq_put; }; -#define cgs_import_gpu_mem (dev,dmabuf_fd,handle) \ - CGS_OS_CALL(import_gpu_mem,dev,dmabuf_fd,handle)#define cgs_add_irq_source (dev,src_id,num_types,set,handler,private_data) \ CGS_OS_CALL(add_irq_source,dev,src_id,num_types,set,handler, \ private_data)
Signature · 1 line
1.8.3.1
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
Quoted 6 lines · Alex Deucher
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Christian König
Quoted 3 lines · Daniel Vetter
Quoted 2 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Can we get these reviews done publically? it's kinda hard to know how well someone
reviewed things if we have no external copy. Like did Jammy a) read the patch, and
slap Reviewed-by on it, or did he b) comment on some whitespace issues and slap R-b
on it, or c) did he suggest a bunch of changes and those changes were made and a new
version was produced and he r-b'ed that etc.
Quoted 8 lines
Quoted 7 lines
The other stuff seems a lot more benign. For the irq abstraction specifically it might be worth looking at the
irq_chipstuff linux core has, which is what's used to virtualize/abstract irq routing and handling. But for that stuff it's a balance thing really how much you reinvent wheels internally in the driver (e.g. i915 has it's ownpower_wellstuff which is pretty much just powerdomains reinvented, with less features).
Quoted 7 lines
I think that's one of the hardest things in the kernel: finding out if a solution already exists or not. We implemented our own version of mfd for our ACP audio block driver. Upon upsteaming we were alerted to mfd's existence and we converted the driver to use mfd. At the end of the day it was a lot of work for minimal gain, at least from a functionality perspective. I wish we had known about it sooner. I'll take a look at the
irq_chipstuff. Thanks for the heads up!
You say for minimal gain, but this is pretty much going to keep happening to you with the development model you have chosen, get used to rewriting things you consider finished and reviewed. I've said it before so I'll use this to reiterate, your patches are only starting the process when you post them, all the internal stuff you do is nice and all but it could all be done externally
if you guys weren't so stuck on internal IP review. Otherwise you should be taking
into account that this overhead will continue to exist in all your development, and adjust schedules to suit.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
Quoted 16 lines · Dave Airlie
Quoted 6 lines · Alex Deucher
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Christian König
Quoted 3 lines · Daniel Vetter
Quoted 2 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Quoted 10 lines
Can we get these reviews done publically? it's kinda hard to know how well someone
reviewed things if we have no external copy. Like did Jammy a) read the patch, and
slap Reviewed-by on it, or did he b) comment on some whitespace issues and slap R-b
on it, or c) did he suggest a bunch of changes and those changes were made and a new
version was produced and he r-b'ed that etc.
We are pushing for that and making steady progress, but things are slow to move internally.
Quoted 16 lines
Quoted 8 lines
Quoted 7 lines
The other stuff seems a lot more benign. For the irq abstraction specifically it might be worth looking at the
irq_chipstuff linux core has, which is what's used to virtualize/abstract irq routing and handling. But for that stuff it's a balance thing really how much you reinvent wheels internally in the driver (e.g. i915 has it's ownpower_wellstuff which is pretty much just powerdomains reinvented, with less features).Quoted 7 lines
I think that's one of the hardest things in the kernel: finding out if a solution already exists or not. We implemented our own version of mfd for our ACP audio block driver. Upon upsteaming we were alerted to mfd's existence and we converted the driver to use mfd. At the end of the day it was a lot of work for minimal gain, at least from a functionality perspective. I wish we had known about it sooner. I'll take a look at the
irq_chipstuff. Thanks for the heads up!
Quoted 10 lines
You say for minimal gain, but this is pretty much going to keep happening to you with the development model you have chosen, get used to rewriting things you consider finished and reviewed. I've said it before so I'll use this to reiterate, your patches are only starting the process when you post them, all the internal stuff you do is nice and all but it could all be done externally
if you guys weren't so stuck on internal IP review. Otherwise you should be taking
into account that this overhead will continue to exist in all your development, and adjust schedules to suit.
We do take that into account as evidenced by the multiple revisions of the ACP patch set for example. We know there may be a delta between short term deliverables and what eventually goes upstream and we take that into account. That doesn't change the overall amount of work involved. The fact is we didn't know about mfd so we didn't use it. I don't see how we could have avoided rewriting it if we didn't know about it in the first place. When we sent the patches out, we found out about it and made the appropriate changes. My point was just that we aren't the only ones this happens to.
Alex
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
Quoted 58 lines · Alex Deucher
Quoted 16 lines · Dave Airlie
Quoted 6 lines · Alex Deucher
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Christian König
Quoted 3 lines · Daniel Vetter
Quoted 2 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Quoted 10 lines
Can we get these reviews done publically? it's kinda hard to know how well someone
reviewed things if we have no external copy. Like did Jammy a) read the patch, and
slap Reviewed-by on it, or did he b) comment on some whitespace issues and slap R-b
on it, or c) did he suggest a bunch of changes and those changes were made and a new
version was produced and he r-b'ed that etc.We are pushing for that and making steady progress, but things are slow to move internally.
Quoted 16 lines
Quoted 8 lines
Quoted 7 lines
The other stuff seems a lot more benign. For the irq abstraction specifically it might be worth looking at the
irq_chipstuff linux core has, which is what's used to virtualize/abstract irq routing and handling. But for that stuff it's a balance thing really how much you reinvent wheels internally in the driver (e.g. i915 has it's ownpower_wellstuff which is pretty much just powerdomains reinvented, with less features).Quoted 7 lines
I think that's one of the hardest things in the kernel: finding out if a solution already exists or not. We implemented our own version of mfd for our ACP audio block driver. Upon upsteaming we were alerted to mfd's existence and we converted the driver to use mfd. At the end of the day it was a lot of work for minimal gain, at least from a functionality perspective. I wish we had known about it sooner. I'll take a look at the
irq_chipstuff. Thanks for the heads up!Quoted 10 lines
You say for minimal gain, but this is pretty much going to keep happening to you with the development model you have chosen, get used to rewriting things you consider finished and reviewed. I've said it before so I'll use this to reiterate, your patches are only starting the process when you post them, all the internal stuff you do is nice and all but it could all be done externally
if you guys weren't so stuck on internal IP review. Otherwise you should be taking
into account that this overhead will continue to exist in all your development, and adjust schedules to suit.
Quoted 9 lines
We do take that into account as evidenced by the multiple revisions of the ACP patch set for example. We know there may be a delta between short term deliverables and what eventually goes upstream and we take that into account. That doesn't change the overall amount of work involved. The fact is we didn't know about mfd so we didn't use it. I don't see how we could have avoided rewriting it if we didn't know about it in the first place. When we sent the patches out, we found out about it and made the appropriate changes. My point was just that we aren't the only ones this happens to.
Discussing early designs on irc helps a lot with that. But ime irc is one step further away from just dragging engineers onto the mailing list, and discussing new stuff on irc before patches get written instead of just review is one step more. That still leaves you with the problem with knowing whom to talk to, but for modularization we have at least Thierry Reding and Laurent Pinchart with a lot of soc experience outside of drm, they tend to know what's out there.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
Quoted 62 lines · Daniel Vetter
Quoted 52 lines · Alex Deucher
Quoted 14 lines · Dave Airlie
Quoted 6 lines · Alex Deucher
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Christian König
Quoted 3 lines · Daniel Vetter
Quoted 2 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Quoted 10 lines
Can we get these reviews done publically? it's kinda hard to know how well someone
reviewed things if we have no external copy. Like did Jammy a) read the patch, and
slap Reviewed-by on it, or did he b) comment on some whitespace issues and slap R-b
on it, or c) did he suggest a bunch of changes and those changes were made and a new
version was produced and he r-b'ed that etc.We are pushing for that and making steady progress, but things are slow to move internally.
Quoted 14 lines
Quoted 7 lines
Quoted 7 lines
The other stuff seems a lot more benign. For the irq abstraction specifically it might be worth looking at the
irq_chipstuff linux core has, which is what's used to virtualize/abstract irq routing and handling. But for that stuff it's a balance thing really how much you reinvent wheels internally in the driver (e.g. i915 has it's ownpower_wellstuff which is pretty much just powerdomains reinvented, with less features).Quoted 7 lines
I think that's one of the hardest things in the kernel: finding out if a solution already exists or not. We implemented our own version of mfd for our ACP audio block driver. Upon upsteaming we were alerted to mfd's existence and we converted the driver to use mfd. At the end of the day it was a lot of work for minimal gain, at least from a functionality perspective. I wish we had known about it sooner. I'll take a look at the
irq_chipstuff. Thanks for the heads up!Quoted 10 lines
You say for minimal gain, but this is pretty much going to keep happening to you with the development model you have chosen, get used to rewriting things you consider finished and reviewed. I've said it before so I'll use this to reiterate, your patches are only starting the process when you post them, all the internal stuff you do is nice and all but it could all be done externally
if you guys weren't so stuck on internal IP review. Otherwise you should be taking
into account that this overhead will continue to exist in all your development, and adjust schedules to suit.Quoted 9 lines
We do take that into account as evidenced by the multiple revisions of the ACP patch set for example. We know there may be a delta between short term deliverables and what eventually goes upstream and we take that into account. That doesn't change the overall amount of work involved. The fact is we didn't know about mfd so we didn't use it. I don't see how we could have avoided rewriting it if we didn't know about it in the first place. When we sent the patches out, we found out about it and made the appropriate changes. My point was just that we aren't the only ones this happens to.
Quoted 7 lines
Discussing early designs on irc helps a lot with that. But ime irc is one step further away from just dragging engineers onto the mailing list, and discussing new stuff on irc before patches get written instead of just review is one step more. That still leaves you with the problem with knowing whom to talk to, but for modularization we have at least Thierry Reding and Laurent Pinchart with a lot of soc experience outside of drm, they tend to know what's out there.
Yeah, completely agree.
Alex and I have spend a lot of time and effort with developers previously working on closed source code to enable them to contribute to the different open source projects.
Anybody who did something like that before knows that it certainly needs time for certain concepts to sink in. Especially thinks like stable interface and certain design criteria seem to be hard to get accepted.
So guys feel to criticize the code whenever you think it make sense and please do so as early as possible, e.g. on the first round of patches not after ten revisions.
We in turn try to get the code out as soon as possible, without keeping it stuck internally for too long.
Christian.
Quoted 1 line
-Daniel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
In reply to Dave AirlieQuoted 16 lines · Dave Airlie
Quoted 6 lines · Alex Deucher
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Christian König
Quoted 3 lines · Daniel Vetter
Quoted 2 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Quoted 9 lines
Can we get these reviews done publically? it's kinda hard to know how well someone
reviewed things if we have no external copy. Like did Jammy a) read the patch, and
slap Reviewed-by on it, or did he b) comment on some whitespace issues and slap R-b
on it, or c) did he suggest a bunch of changes and those changes were made and a new
version was produced and he r-b'ed that etc.
Yeah review in public is great. We can do that for almost everythingn since nowadays we have blanket approval for everything, except a short list of marketing relevant new features on new platforms. Occasionally the public review with mails don't work out though and then we have a big meeting, but even for those we try to summarize what we discussed and decided on the m-l.
But without blanket approval this won't work I think. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter
Reviewed-byRe: [PATCH 07/12] drm/amdgpu: implement cgs gpu memory callbacks
In reply to Alex DeucherQuoted 75 lines · Alex Deucher
Quoted 27 lines · Daniel Vetter
Quoted 26 lines · Christian König
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Alex Deucher
From: Chunming Zhou <[email protected]>
This implements the cgs interface for allocating
GPU memory.Reviewed-by Jammy Zhou <[email protected]>I don't see that review anywhere on a m-l ... where is it?
Jammy reviewed the stuff internally before we made it public, that's why you can't find it.
Quoted 5 lines
I stumbled over this patch because it adds a new
dev->struct_mutexuser (that should be a big warning sign) and then I somehow unrolled some giant chain of wtfs. Either I'm completely missing what this is used for or it probably should get reworked asap.The CGS functions aren't used at the moment because none of the components depending on them made it into the kernel, but we wanted to keep it so that we can get reviews on the general idea and if necessary rework it.
In general it's an abstraction layer of device driver dependent functions which enables us to share more code internally.
Quoted 8 lines
Quoted 2 lines
We worked quite hard on trying to avoid the OS abstraction trap with this, but if you think this still won't work feel free to object.
The bit that made me look really is the
import_gpu_memthing, which seems to partially reinventdrm_prime.c. Given how tricky importing and import-caching is I'd really like to see that gone (and Alex said on irc he'd be ok with that).See attached patch. It was really only added for completeness. We don't have any users of it at the moment. If we end up needing the functionality in the future we can revisit it.
Quoted 7 lines
The other stuff seems a lot more benign. For the irq abstraction specifically it might be worth looking at the
irq_chipstuff linux core has, which is what's used to virtualize/abstract irq routing and handling. But for that stuff it's a balance thing really how much you reinvent wheels internally in the driver (e.g. i915 has it's ownpower_wellstuff which is pretty much just powerdomains reinvented, with less features).I think that's one of the hardest things in the kernel: finding out if a solution already exists or not. We implemented our own version of mfd for our ACP audio block driver. Upon upsteaming we were alerted to mfd's existence and we converted the driver to use mfd. At the end of the day it was a lot of work for minimal gain, at least from a functionality perspective. I wish we had known about it sooner. I'll take a look at the
irq_chipstuff. Thanks for the heads up!Alex
Quoted 10 lines
But really I can't tell without the users whether I'd expect this to be hurt longterm or not for you ;-) But the import stuff is hurt for me since you noodle around in drm internals. And specifically I'd like to make modern drivers completely
struct_mutexfree with the goal to untangle the last hold-outs of that lock in the drm core.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.chFrom
013170490a934731bb5fbc4cb8ee46421d2f240eMon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Tue, 29 Sep 2015 10:35:45 -0400
Subject: [PATCH] drm/amdgpu/cgs: removeimport_gpu_mem
Quoted 5 lines
It was added for completeness, but we don't have any users for it yet. Daniel Vetter noted that it may be racy. Remove it.
Signed-off-by Alex Deucher <[email protected]>
Quoted 106 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 39 --------------------------------- drivers/gpu/drm/amd/include/cgs_linux.h | 17 -------------- 2 files changed, 56 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +0
-39@@ -208,44 +208,6 @@ static int amdgpu_cgs_alloc_gpu_mem(void *cgs_device,return ret; } -static int amdgpu_cgs_import_gpu_mem (void *cgs_device,int dmabuf_fd, -cgs_handle_t *handle) -{ -CGS_FUNC_ADEV ; -int r; -uint32_t dma_handle; -struct drm_gem_object *obj; -struct amdgpu_bo *bo; -struct drm_device *dev = adev->ddev; -struct drm_file *file_priv =NULL , *priv; - -mutex_lock (&dev->struct_mutex); -list_for_each_entry (priv, &dev->filelist, lhead) { -rcu_read_lock (); -if (priv->pid ==get_pid (task_pid (current))) - file_priv = priv; -rcu_read_unlock (); -if (file_priv) -break ; - } -mutex_unlock (&dev->struct_mutex); - r = dev->driver->prime_fd_to_handle (dev, - file_priv, dmabuf_fd, - &dma_handle); -spin_lock (&file_priv->table_lock); - -/* Check if we currently have a reference on the object */ - obj =idr_find (&file_priv->object_idr, dma_handle); -if (obj ==NULL ) { -spin_unlock (&file_priv->table_lock); -return -EINVAL ; - } -spin_unlock (&file_priv->table_lock); - bo =gem_to_amdgpu_bo (obj); - *handle = (cgs_handle_t )bo; -return 0 ; -} -static int amdgpu_cgs_free_gpu_mem (void *cgs_device,cgs_handle_t handle) {struct amdgpu_bo *obj = (struct amdgpu_bo *)handle;@@ -846,7 +808,6 @@ static const struct cgs_ops amdgpu_cgs_ops = { };static const struct cgs_os_ops amdgpu_cgs_os_ops = { - amdgpu_cgs_import_gpu_mem, amdgpu_cgs_add_irq_source, amdgpu_cgs_irq_get, amdgpu_cgs_irq_putdrivers/gpu/drm/amd/include/cgs_linux.h +0
-17@@ -27,19 +27,6 @@#include "cgs_common.h" /** -* cgs_import_gpu_mem() - Import dmabuf handle -* @cgs_device: opaque device handle -* @dmabuf_fd: DMABuf file descriptor -* @handle: memory handle (output) -* -* Must be called in the process context that dmabuf_fd belongs to. -* -* Return: 0 on success, -errno otherwise -*/ -typedef int (*cgs_import_gpu_mem_t )(void *cgs_device,int dmabuf_fd, -cgs_handle_t *handle); - -/** * cgs_irq_source_set_func() - Callback for enabling/disabling interrupt sources * @private_data: private data provided to cgs_add_irq_source * @src_id: interrupt source ID @@ -114,16 +101,12 @@ typedef int (*cgs_irq_get_t)(void *cgs_device, unsigned src_id, unsigned type);typedef int (*cgs_irq_put_t )(void *cgs_device,unsigned src_id,unsigned type);struct cgs_os_ops { -cgs_import_gpu_mem_t import_gpu_mem; -/* IRQ handling */ cgs_add_irq_source_t add_irq_source;cgs_irq_get_t irq_get;cgs_irq_put_t irq_put; }; -#define cgs_import_gpu_mem (dev,dmabuf_fd,handle) \ - CGS_OS_CALL(import_gpu_mem,dev,dmabuf_fd,handle)#define cgs_add_irq_source (dev,src_id,num_types,set,handler,private_data) \ CGS_OS_CALL(add_irq_source,dev,src_id,num_types,set,handler, \ private_data)Signature · 1 line
1.8.3.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/12 drm/amd: add ACP 2.x register headers
In reply to Alex DeucherFrom: Chunming Zhou <[email protected]>
These are register headers for the ACP (Audio CoProcessor) block on the GPU.
--- .../gpu/drm/amd/include/asic_reg/acp/acp_2_1_d.h | 437 ++++ .../drm/amd/include/asic_reg/acp/acp_2_1_enum.h | 1198 ++++++++++ .../drm/amd/include/asic_reg/acp/acp_2_1_sh_mask.h | 1568 +++++++++++++ .../gpu/drm/amd/include/asic_reg/acp/acp_2_2_d.h | 609 ++++++ .../drm/amd/include/asic_reg/acp/acp_2_2_enum.h | 1068 +++++++++ .../drm/amd/include/asic_reg/acp/acp_2_2_sh_mask.h | 2292 ++++++++++++++++++++ .../gpu/drm/amd/include/asic_reg/acp/acp_2_3_d.h | 582 +++++ .../drm/amd/include/asic_reg/acp/acp_2_3_enum.h | 1079 +++++++++ .../drm/amd/include/asic_reg/acp/acp_2_3_sh_mask.h | 2192 +++++++++++++++++++ 9 files changed, 11025 insertions(+) create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_1_d.h create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_1_enum.h create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_1_sh_mask.h create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_2_d.h create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_2_enum.h create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_2_sh_mask.h create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_3_d.h create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_3_enum.h create mode 100644 drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_3_sh_mask.h
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_1_d.h new file +437 -0
@@ -0,0 +1,437 @@ +/* +* ACP_2_1 Register documentation +* +* Copyright (C) 2014 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef ACP_2_1_D_H +#define ACP_2_1_D_H + +#define mmACP_DMA_CNTL_0 0x5000 +#define mmACP_DMA_CNTL_1 0x5001 +#define mmACP_DMA_CNTL_2 0x5002 +#define mmACP_DMA_CNTL_3 0x5003 +#define mmACP_DMA_CNTL_4 0x5004 +#define mmACP_DMA_CNTL_5 0x5005 +#define mmACP_DMA_CNTL_6 0x5006 +#define mmACP_DMA_CNTL_7 0x5007 +#define mmACP_DMA_CNTL_8 0x5008 +#define mmACP_DMA_CNTL_9 0x5009 +#define mmACP_DMA_CNTL_10 0x500a +#define mmACP_DMA_CNTL_11 0x500b +#define mmACP_DMA_CNTL_12 0x500c +#define mmACP_DMA_CNTL_13 0x500d +#define mmACP_DMA_CNTL_14 0x500e +#define mmACP_DMA_CNTL_15 0x500f +#define mmACP_DMA_DSCR_STRT_IDX_0 0x5010 +#define mmACP_DMA_DSCR_STRT_IDX_1 0x5011 +#define mmACP_DMA_DSCR_STRT_IDX_2 0x5012 +#define mmACP_DMA_DSCR_STRT_IDX_3 0x5013 +#define mmACP_DMA_DSCR_STRT_IDX_4 0x5014 +#define mmACP_DMA_DSCR_STRT_IDX_5 0x5015 +#define mmACP_DMA_DSCR_STRT_IDX_6 0x5016 +#define mmACP_DMA_DSCR_STRT_IDX_7 0x5017 +#define mmACP_DMA_DSCR_STRT_IDX_8 0x5018 +#define mmACP_DMA_DSCR_STRT_IDX_9 0x5019 +#define mmACP_DMA_DSCR_STRT_IDX_10 0x501a +#define mmACP_DMA_DSCR_STRT_IDX_11 0x501b +#define mmACP_DMA_DSCR_STRT_IDX_12 0x501c +#define mmACP_DMA_DSCR_STRT_IDX_13 0x501d +#define mmACP_DMA_DSCR_STRT_IDX_14 0x501e +#define mmACP_DMA_DSCR_STRT_IDX_15 0x501f +#define mmACP_DMA_DSCR_CNT_0 0x5020 +#define mmACP_DMA_DSCR_CNT_1 0x5021 +#define mmACP_DMA_DSCR_CNT_2 0x5022 +#define mmACP_DMA_DSCR_CNT_3 0x5023 +#define mmACP_DMA_DSCR_CNT_4 0x5024 +#define mmACP_DMA_DSCR_CNT_5 0x5025 +#define mmACP_DMA_DSCR_CNT_6 0x5026 +#define mmACP_DMA_DSCR_CNT_7 0x5027 +#define mmACP_DMA_DSCR_CNT_8 0x5028 +#define mmACP_DMA_DSCR_CNT_9 0x5029 +#define mmACP_DMA_DSCR_CNT_10 0x502a +#define mmACP_DMA_DSCR_CNT_11 0x502b +#define mmACP_DMA_DSCR_CNT_12 0x502c +#define mmACP_DMA_DSCR_CNT_13 0x502d +#define mmACP_DMA_DSCR_CNT_14 0x502e +#define mmACP_DMA_DSCR_CNT_15 0x502f +#define mmACP_DMA_PRIO_0 0x5030 +#define mmACP_DMA_PRIO_1 0x5031 +#define mmACP_DMA_PRIO_2 0x5032 +#define mmACP_DMA_PRIO_3 0x5033 +#define mmACP_DMA_PRIO_4 0x5034 +#define mmACP_DMA_PRIO_5 0x5035 +#define mmACP_DMA_PRIO_6 0x5036 +#define mmACP_DMA_PRIO_7 0x5037 +#define mmACP_DMA_PRIO_8 0x5038 +#define mmACP_DMA_PRIO_9 0x5039 +#define mmACP_DMA_PRIO_10 0x503a +#define mmACP_DMA_PRIO_11 0x503b +#define mmACP_DMA_PRIO_12 0x503c +#define mmACP_DMA_PRIO_13 0x503d +#define mmACP_DMA_PRIO_14 0x503e +#define mmACP_DMA_PRIO_15 0x503f +#define mmACP_DMA_CUR_DSCR_0 0x5040 +#define mmACP_DMA_CUR_DSCR_1 0x5041 +#define mmACP_DMA_CUR_DSCR_2 0x5042 +#define mmACP_DMA_CUR_DSCR_3 0x5043 +#define mmACP_DMA_CUR_DSCR_4 0x5044 +#define mmACP_DMA_CUR_DSCR_5 0x5045 +#define mmACP_DMA_CUR_DSCR_6 0x5046 +#define mmACP_DMA_CUR_DSCR_7 0x5047 +#define mmACP_DMA_CUR_DSCR_8 0x5048 +#define mmACP_DMA_CUR_DSCR_9 0x5049 +#define mmACP_DMA_CUR_DSCR_10 0x504a +#define mmACP_DMA_CUR_DSCR_11 0x504b +#define mmACP_DMA_CUR_DSCR_12 0x504c +#define mmACP_DMA_CUR_DSCR_13 0x504d +#define mmACP_DMA_CUR_DSCR_14 0x504e +#define mmACP_DMA_CUR_DSCR_15 0x504f +#define mmACP_DMA_CUR_TRANS_CNT_0 0x5050 +#define mmACP_DMA_CUR_TRANS_CNT_1 0x5051 +#define mmACP_DMA_CUR_TRANS_CNT_2 0x5052 +#define mmACP_DMA_CUR_TRANS_CNT_3 0x5053 +#define mmACP_DMA_CUR_TRANS_CNT_4 0x5054 +#define mmACP_DMA_CUR_TRANS_CNT_5 0x5055 +#define mmACP_DMA_CUR_TRANS_CNT_6 0x5056 +#define mmACP_DMA_CUR_TRANS_CNT_7 0x5057 +#define mmACP_DMA_CUR_TRANS_CNT_8 0x5058 +#define mmACP_DMA_CUR_TRANS_CNT_9 0x5059 +#define mmACP_DMA_CUR_TRANS_CNT_10 0x505a +#define mmACP_DMA_CUR_TRANS_CNT_11 0x505b +#define mmACP_DMA_CUR_TRANS_CNT_12 0x505c +#define mmACP_DMA_CUR_TRANS_CNT_13 0x505d +#define mmACP_DMA_CUR_TRANS_CNT_14 0x505e +#define mmACP_DMA_CUR_TRANS_CNT_15 0x505f +#define mmACP_DMA_ERR_STS_0 0x5060 +#define mmACP_DMA_ERR_STS_1 0x5061 +#define mmACP_DMA_ERR_STS_2 0x5062 +#define mmACP_DMA_ERR_STS_3 0x5063 +#define mmACP_DMA_ERR_STS_4 0x5064 +#define mmACP_DMA_ERR_STS_5 0x5065 +#define mmACP_DMA_ERR_STS_6 0x5066 +#define mmACP_DMA_ERR_STS_7 0x5067 +#define mmACP_DMA_ERR_STS_8 0x5068 +#define mmACP_DMA_ERR_STS_9 0x5069 +#define mmACP_DMA_ERR_STS_10 0x506a +#define mmACP_DMA_ERR_STS_11 0x506b +#define mmACP_DMA_ERR_STS_12 0x506c +#define mmACP_DMA_ERR_STS_13 0x506d +#define mmACP_DMA_ERR_STS_14 0x506e +#define mmACP_DMA_ERR_STS_15 0x506f +#define mmACP_DMA_DESC_BASE_ADDR 0x5070 +#define mmACP_DMA_DESC_MAX_NUM_DSCR 0x5071 +#define mmACP_DMA_CH_STS 0x5072 +#define mmACP_DMA_CH_GROUP 0x5073 +#define mmACP_DSP0_CACHE_OFFSET0 0x5078 +#define mmACP_DSP0_CACHE_SIZE0 0x5079 +#define mmACP_DSP0_CACHE_OFFSET1 0x507a +#define mmACP_DSP0_CACHE_SIZE1 0x507b +#define mmACP_DSP0_CACHE_OFFSET2 0x507c +#define mmACP_DSP0_CACHE_SIZE2 0x507d +#define mmACP_DSP0_CACHE_OFFSET3 0x507e +#define mmACP_DSP0_CACHE_SIZE3 0x507f +#define mmACP_DSP0_CACHE_OFFSET4 0x5080 +#define mmACP_DSP0_CACHE_SIZE4 0x5081 +#define mmACP_DSP0_CACHE_OFFSET5 0x5082 +#define mmACP_DSP0_CACHE_SIZE5 0x5083 +#define mmACP_DSP0_CACHE_OFFSET6 0x5084 +#define mmACP_DSP0_CACHE_SIZE6 0x5085 +#define mmACP_DSP0_CACHE_OFFSET7 0x5086 +#define mmACP_DSP0_CACHE_SIZE7 0x5087 +#define mmACP_DSP0_CACHE_OFFSET8 0x5088 +#define mmACP_DSP0_CACHE_SIZE8 0x5089 +#define mmACP_DSP0_NONCACHE_OFFSET0 0x508a +#define mmACP_DSP0_NONCACHE_SIZE0 0x508b +#define mmACP_DSP0_NONCACHE_OFFSET1 0x508c +#define mmACP_DSP0_NONCACHE_SIZE1 0x508d +#define mmACP_DSP0_DEBUG_PC 0x508e +#define mmACP_DSP0_NMI_SEL 0x508f +#define mmACP_DSP0_CLKRST_CNTL 0x5090 +#define mmACP_DSP0_RUNSTALL 0x5091 +#define mmACP_DSP0_OCD_HALT_ON_RST 0x5092 +#define mmACP_DSP0_WAIT_MODE 0x5093 +#define mmACP_DSP0_VECT_SEL 0x5094 +#define mmACP_DSP1_CACHE_OFFSET0 0x509d +#define mmACP_DSP1_CACHE_SIZE0 0x509e +#define mmACP_DSP1_CACHE_OFFSET1 0x509f +#define mmACP_DSP1_CACHE_SIZE1 0x50a0 +#define mmACP_DSP1_CACHE_OFFSET2 0x50a1 +#define mmACP_DSP1_CACHE_SIZE2 0x50a2 +#define mmACP_DSP1_CACHE_OFFSET3 0x50a3 +#define mmACP_DSP1_CACHE_SIZE3 0x50a4 +#define mmACP_DSP1_CACHE_OFFSET4 0x50a5 +#define mmACP_DSP1_CACHE_SIZE4 0x50a6 +#define mmACP_DSP1_CACHE_OFFSET5 0x50a7 +#define mmACP_DSP1_CACHE_SIZE5 0x50a8 +#define mmACP_DSP1_CACHE_OFFSET6 0x50a9 +#define mmACP_DSP1_CACHE_SIZE6 0x50aa +#define mmACP_DSP1_CACHE_OFFSET7 0x50ab +#define mmACP_DSP1_CACHE_SIZE7 0x50ac +#define mmACP_DSP1_CACHE_OFFSET8 0x50ad +#define mmACP_DSP1_CACHE_SIZE8 0x50ae +#define mmACP_DSP1_NONCACHE_OFFSET0 0x50af +#define mmACP_DSP1_NONCACHE_SIZE0 0x50b0 +#define mmACP_DSP1_NONCACHE_OFFSET1 0x50b1 +#define mmACP_DSP1_NONCACHE_SIZE1 0x50b2 +#define mmACP_DSP1_DEBUG_PC 0x50b3 +#define mmACP_DSP1_NMI_SEL 0x50b4 +#define mmACP_DSP1_CLKRST_CNTL 0x50b5 +#define mmACP_DSP1_RUNSTALL 0x50b6 +#define mmACP_DSP1_OCD_HALT_ON_RST 0x50b7 +#define mmACP_DSP1_WAIT_MODE 0x50b8 +#define mmACP_DSP1_VECT_SEL 0x50b9 +#define mmACP_DSP2_CACHE_OFFSET0 0x50c2 +#define mmACP_DSP2_CACHE_SIZE0 0x50c3 +#define mmACP_DSP2_CACHE_OFFSET1 0x50c4 +#define mmACP_DSP2_CACHE_SIZE1 0x50c5 +#define mmACP_DSP2_CACHE_OFFSET2 0x50c6 +#define mmACP_DSP2_CACHE_SIZE2 0x50c7 +#define mmACP_DSP2_CACHE_OFFSET3 0x50c8 +#define mmACP_DSP2_CACHE_SIZE3 0x50c9 +#define mmACP_DSP2_CACHE_OFFSET4 0x50ca +#define mmACP_DSP2_CACHE_SIZE4 0x50cb +#define mmACP_DSP2_CACHE_OFFSET5 0x50cc +#define mmACP_DSP2_CACHE_SIZE5 0x50cd +#define mmACP_DSP2_CACHE_OFFSET6 0x50ce +#define mmACP_DSP2_CACHE_SIZE6 0x50cf +#define mmACP_DSP2_CACHE_OFFSET7 0x50d0 +#define mmACP_DSP2_CACHE_SIZE7 0x50d1 +#define mmACP_DSP2_CACHE_OFFSET8 0x50d2 +#define mmACP_DSP2_CACHE_SIZE8 0x50d3 +#define mmACP_DSP2_NONCACHE_OFFSET0 0x50d4 +#define mmACP_DSP2_NONCACHE_SIZE0 0x50d5 +#define mmACP_DSP2_NONCACHE_OFFSET1 0x50d6 +#define mmACP_DSP2_NONCACHE_SIZE1 0x50d7 +#define mmACP_DSP2_DEBUG_PC 0x50d8 +#define mmACP_DSP2_NMI_SEL 0x50d9 +#define mmACP_DSP2_CLKRST_CNTL 0x50da +#define mmACP_DSP2_RUNSTALL 0x50db +#define mmACP_DSP2_OCD_HALT_ON_RST 0x50dc +#define mmACP_DSP2_WAIT_MODE 0x50dd +#define mmACP_DSP2_VECT_SEL 0x50de +#define mmACP_AXI2DAGB_ONION_CNTL 0x50e7 +#define mmACP_AXI2DAGB_ONION_ERR_STATUS_WR 0x50e8 +#define mmACP_AXI2DAGB_ONION_ERR_STATUS_RD 0x50e9 +#define mmACP_DAGB_Onion_TransPerf_Counter_Control 0x50ea +#define mmACP_DAGB_Onion_Wr_TransPerf_Counter_Current 0x50eb +#define mmACP_DAGB_Onion_Wr_TransPerf_Counter_Peak 0x50ec +#define mmACP_DAGB_Onion_Rd_TransPerf_Counter_Current 0x50ed +#define mmACP_DAGB_Onion_Rd_TransPerf_Counter_Peak 0x50ee +#define mmACP_AXI2DAGB_GARLIC_CNTL 0x50f3 +#define mmACP_AXI2DAGB_GARLIC_ERR_STATUS_WR 0x50f4 +#define mmACP_AXI2DAGB_GARLIC_ERR_STATUS_RD 0x50f5 +#define mmACP_DAGB_Garlic_TransPerf_Counter_Control 0x50f6 +#define mmACP_DAGB_Garlic_Wr_TransPerf_Counter_Current 0x50f7 +#define mmACP_DAGB_Garlic_Wr_TransPerf_Counter_Peak 0x50f8 +#define mmACP_DAGB_Garlic_Rd_TransPerf_Counter_Current 0x50f9 +#define mmACP_DAGB_Garlic_Rd_TransPerf_Counter_Peak 0x50fa +#define mmACP_DAGB_PAGE_SIZE_GRP_1 0x50ff +#define mmACP_DAGB_BASE_ADDR_GRP_1 0x5100 +#define mmACP_DAGB_PAGE_SIZE_GRP_2 0x5101 +#define mmACP_DAGB_BASE_ADDR_GRP_2 0x5102 +#define mmACP_DAGB_PAGE_SIZE_GRP_3 0x5103 +#define mmACP_DAGB_BASE_ADDR_GRP_3 0x5104 +#define mmACP_DAGB_PAGE_SIZE_GRP_4 0x5105 +#define mmACP_DAGB_BASE_ADDR_GRP_4 0x5106 +#define mmACP_DAGB_PAGE_SIZE_GRP_5 0x5107 +#define mmACP_DAGB_BASE_ADDR_GRP_5 0x5108 +#define mmACP_DAGB_PAGE_SIZE_GRP_6 0x5109 +#define mmACP_DAGB_BASE_ADDR_GRP_6 0x510a +#define mmACP_DAGB_PAGE_SIZE_GRP_7 0x510b +#define mmACP_DAGB_BASE_ADDR_GRP_7 0x510c +#define mmACP_DAGB_PAGE_SIZE_GRP_8 0x510d +#define mmACP_DAGB_BASE_ADDR_GRP_8 0x510e +#define mmACP_DAGB_ATU_CTRL 0x510f +#define mmACP_CONTROL 0x5131 +#define mmACP_STATUS 0x5133 +#define mmACP_SOFT_RESET 0x5134 +#define mmACP_PwrMgmt_CNTL 0x5135 +#define mmACP_CAC_INDICATOR_CONTROL 0x5136 +#define mmACP_SMU_MAILBOX 0x5137 +#define mmACP_FUTURE_REG_SCLK_0 0x5138 +#define mmACP_FUTURE_REG_SCLK_1 0x5139 +#define mmACP_FUTURE_REG_SCLK_2 0x513a +#define mmACP_FUTURE_REG_SCLK_3 0x513b +#define mmACP_FUTURE_REG_SCLK_4 0x513c +#define mmACP_DAGB_DEBUG_CNT_ENABLE 0x513d +#define mmACP_DAGBG_WR_ASK_CNT 0x513e +#define mmACP_DAGBG_WR_GO_CNT 0x513f +#define mmACP_DAGBG_WR_EXP_RESP_CNT 0x5140 +#define mmACP_DAGBG_WR_ACTUAL_RESP_CNT 0x5141 +#define mmACP_DAGBG_RD_ASK_CNT 0x5142 +#define mmACP_DAGBG_RD_GO_CNT 0x5143 +#define mmACP_DAGBG_RD_EXP_RESP_CNT 0x5144 +#define mmACP_DAGBG_RD_ACTUAL_RESP_CNT 0x5145 +#define mmACP_DAGBO_WR_ASK_CNT 0x5146 +#define mmACP_DAGBO_WR_GO_CNT 0x5147 +#define mmACP_DAGBO_WR_EXP_RESP_CNT 0x5148 +#define mmACP_DAGBO_WR_ACTUAL_RESP_CNT 0x5149 +#define mmACP_DAGBO_RD_ASK_CNT 0x514a +#define mmACP_DAGBO_RD_GO_CNT 0x514b +#define mmACP_DAGBO_RD_EXP_RESP_CNT 0x514c +#define mmACP_DAGBO_RD_ACTUAL_RESP_CNT 0x514d +#define mmACP_BRB_CONTROL 0x5156 +#define mmACP_EXTERNAL_INTR_ENB 0x5157 +#define mmACP_EXTERNAL_INTR_CNTL 0x5158 +#define mmACP_ERROR_SOURCE_STS 0x5159 +#define mmACP_DSP_SW_INTR_TRIG 0x515a +#define mmACP_DSP_SW_INTR_CNTL 0x515b +#define mmACP_DAGBG_TIMEOUT_CNTL 0x515c +#define mmACP_DAGBO_TIMEOUT_CNTL 0x515d +#define mmACP_EXTERNAL_INTR_STAT 0x515e +#define mmACP_DSP_SW_INTR_STAT 0x515f +#define mmACP_DSP0_INTR_CNTL 0x5160 +#define mmACP_DSP0_INTR_STAT 0x5161 +#define mmACP_DSP0_TIMEOUT_CNTL 0x5162 +#define mmACP_DSP1_INTR_CNTL 0x5163 +#define mmACP_DSP1_INTR_STAT 0x5164 +#define mmACP_DSP1_TIMEOUT_CNTL 0x5165 +#define mmACP_DSP2_INTR_CNTL 0x5166 +#define mmACP_DSP2_INTR_STAT 0x5167 +#define mmACP_DSP2_TIMEOUT_CNTL 0x5168 +#define mmACP_DSP0_EXT_TIMER_CNTL 0x5169 +#define mmACP_DSP1_EXT_TIMER_CNTL 0x516a +#define mmACP_DSP2_EXT_TIMER_CNTL 0x516b +#define mmACP_AXI2DAGB_SEM_0 0x516c +#define mmACP_AXI2DAGB_SEM_1 0x516d +#define mmACP_AXI2DAGB_SEM_2 0x516e +#define mmACP_AXI2DAGB_SEM_3 0x516f +#define mmACP_AXI2DAGB_SEM_4 0x5170 +#define mmACP_AXI2DAGB_SEM_5 0x5171 +#define mmACP_AXI2DAGB_SEM_6 0x5172 +#define mmACP_AXI2DAGB_SEM_7 0x5173 +#define mmACP_AXI2DAGB_SEM_8 0x5174 +#define mmACP_AXI2DAGB_SEM_9 0x5175 +#define mmACP_AXI2DAGB_SEM_10 0x5176 +#define mmACP_AXI2DAGB_SEM_11 0x5177 +#define mmACP_AXI2DAGB_SEM_12 0x5178 +#define mmACP_AXI2DAGB_SEM_13 0x5179 +#define mmACP_AXI2DAGB_SEM_14 0x517a +#define mmACP_AXI2DAGB_SEM_15 0x517b +#define mmACP_AXI2DAGB_SEM_16 0x517c +#define mmACP_AXI2DAGB_SEM_17 0x517d +#define mmACP_AXI2DAGB_SEM_18 0x517e +#define mmACP_AXI2DAGB_SEM_19 0x517f +#define mmACP_AXI2DAGB_SEM_20 0x5180 +#define mmACP_AXI2DAGB_SEM_21 0x5181 +#define mmACP_AXI2DAGB_SEM_22 0x5182 +#define mmACP_AXI2DAGB_SEM_23 0x5183 +#define mmACP_AXI2DAGB_SEM_24 0x5184 +#define mmACP_AXI2DAGB_SEM_25 0x5185 +#define mmACP_AXI2DAGB_SEM_26 0x5186 +#define mmACP_AXI2DAGB_SEM_27 0x5187 +#define mmACP_AXI2DAGB_SEM_28 0x5188 +#define mmACP_AXI2DAGB_SEM_29 0x5189 +#define mmACP_AXI2DAGB_SEM_30 0x518a +#define mmACP_AXI2DAGB_SEM_31 0x518b +#define mmACP_AXI2DAGB_SEM_32 0x518c +#define mmACP_AXI2DAGB_SEM_33 0x518d +#define mmACP_AXI2DAGB_SEM_34 0x518e +#define mmACP_AXI2DAGB_SEM_35 0x518f +#define mmACP_AXI2DAGB_SEM_36 0x5190 +#define mmACP_AXI2DAGB_SEM_37 0x5191 +#define mmACP_AXI2DAGB_SEM_38 0x5192 +#define mmACP_AXI2DAGB_SEM_39 0x5193 +#define mmACP_AXI2DAGB_SEM_40 0x5194 +#define mmACP_AXI2DAGB_SEM_41 0x5195 +#define mmACP_AXI2DAGB_SEM_42 0x5196 +#define mmACP_AXI2DAGB_SEM_43 0x5197 +#define mmACP_AXI2DAGB_SEM_44 0x5198 +#define mmACP_AXI2DAGB_SEM_45 0x5199 +#define mmACP_AXI2DAGB_SEM_46 0x519a +#define mmACP_AXI2DAGB_SEM_47 0x519b +#define mmACP_SRBM_Client_Base_Addr 0x519c +#define mmACP_SRBM_Client_RDDATA 0x519d +#define mmACP_SRBM_Cycle_Sts 0x519e +#define mmACP_SRBM_Targ_Idx_Addr 0x519f +#define mmACP_SRBM_Targ_Idx_Data 0x51a0 +#define mmACP_SEMA_ADDR_LOW 0x51a1 +#define mmACP_SEMA_ADDR_HIGH 0x51a2 +#define mmACP_SEMA_CMD 0x51a3 +#define mmACP_SEMA_STS 0x51a4 +#define mmACP_SEMA_REQ 0x51a5 +#define mmACP_FW_STATUS 0x51a6 +#define mmACP_FUTURE_REG_ACLK_0 0x51a7 +#define mmACP_FUTURE_REG_ACLK_1 0x51a8 +#define mmACP_FUTURE_REG_ACLK_2 0x51a9 +#define mmACP_FUTURE_REG_ACLK_3 0x51aa +#define mmACP_FUTURE_REG_ACLK_4 0x51ab +#define mmACP_TIMER 0x51ac +#define mmACP_TIMER_CNTL 0x51ad +#define mmACP_DSP0_TIMER 0x51ae +#define mmACP_DSP1_TIMER 0x51af +#define mmACP_DSP2_TIMER 0x51b0 +#define mmACP_SCRATCH_REG_BASE_ADDR 0x51ba +#define mmCC_ACP_EFUSE 0x51c8 +#define mmACP_PGFSM_RETAIN_REG 0x51c9 +#define mmACP_PGFSM_CONFIG_REG 0x51ca +#define mmACP_PGFSM_WRITE_REG 0x51cb +#define mmACP_PGFSM_READ_REG_0 0x51cc +#define mmACP_SCRATCH_REG_0 0x52c0 +#define mmACP_SCRATCH_REG_1 0x52c1 +#define mmACP_SCRATCH_REG_2 0x52c2 +#define mmACP_SCRATCH_REG_3 0x52c3 +#define mmACP_SCRATCH_REG_4 0x52c4 +#define mmACP_SCRATCH_REG_5 0x52c5 +#define mmACP_SCRATCH_REG_6 0x52c6 +#define mmACP_SCRATCH_REG_7 0x52c7 +#define mmACP_SCRATCH_REG_8 0x52c8 +#define mmACP_SCRATCH_REG_9 0x52c9 +#define mmACP_SCRATCH_REG_10 0x52ca +#define mmACP_SCRATCH_REG_11 0x52cb +#define mmACP_SCRATCH_REG_12 0x52cc +#define mmACP_SCRATCH_REG_13 0x52cd +#define mmACP_SCRATCH_REG_14 0x52ce +#define mmACP_SCRATCH_REG_15 0x52cf +#define mmACP_SCRATCH_REG_16 0x52d0 +#define mmACP_SCRATCH_REG_17 0x52d1 +#define mmACP_SCRATCH_REG_18 0x52d2 +#define mmACP_SCRATCH_REG_19 0x52d3 +#define mmACP_SCRATCH_REG_20 0x52d4 +#define mmACP_SCRATCH_REG_21 0x52d5 +#define mmACP_SCRATCH_REG_22 0x52d6 +#define mmACP_SCRATCH_REG_23 0x52d7 +#define mmACP_SCRATCH_REG_24 0x52d8 +#define mmACP_SCRATCH_REG_25 0x52d9 +#define mmACP_SCRATCH_REG_26 0x52da +#define mmACP_SCRATCH_REG_27 0x52db +#define mmACP_SCRATCH_REG_28 0x52dc +#define mmACP_SCRATCH_REG_29 0x52dd +#define mmACP_SCRATCH_REG_30 0x52de +#define mmACP_SCRATCH_REG_31 0x52df +#define mmACP_SCRATCH_REG_32 0x52e0 +#define mmACP_SCRATCH_REG_33 0x52e1 +#define mmACP_SCRATCH_REG_34 0x52e2 +#define mmACP_SCRATCH_REG_35 0x52e3 +#define mmACP_SCRATCH_REG_36 0x52e4 +#define mmACP_SCRATCH_REG_37 0x52e5 +#define mmACP_SCRATCH_REG_38 0x52e6 +#define mmACP_SCRATCH_REG_39 0x52e7 +#define mmACP_SCRATCH_REG_40 0x52e8 +#define mmACP_SCRATCH_REG_41 0x52e9 +#define mmACP_SCRATCH_REG_42 0x52ea +#define mmACP_SCRATCH_REG_43 0x52eb +#define mmACP_SCRATCH_REG_44 0x52ec +#define mmACP_SCRATCH_REG_45 0x52ed +#define mmACP_SCRATCH_REG_46 0x52ee +#define mmACP_SCRATCH_REG_47 0x52ef + +#endif /* ACP_2_1_D_H */
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_1_enum.h new file +1198 -0
1,198 lines not on this page · raw message
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_1_sh_mask.h new file +1568 -0
1,365 lines not on this page · raw message
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_2_d.h new file +609 -0
609 lines not on this page · raw message
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_2_enum.h new file +1068 -0
1,068 lines not on this page · raw message
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_2_sh_mask.h new file +2292 -0
2,292 lines not on this page · raw message
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_3_d.h new file +582 -0
582 lines not on this page · raw message
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_3_enum.h new file +1079 -0
1,079 lines not on this page · raw message
drivers/gpu/drm/amd/include/asic_reg/acp/acp_2_3_sh_mask.h new file +2192 -0
2,192 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Part of the diff is not shown here. View the raw message.
PATCH 9/12 drm/amd: add ACP driver support (v4)
In reply to Alex DeucherFrom: Maruthi Bayyavarapu <[email protected]>
This adds the ACP (Audio CoProcessor) IP driver and wires it up to the amdgpu driver. The ACP block provides the DMA engine and bus for the i2s codec which is supported by an alsa driver. This is required for audio on APUs that utilize an i2s codec.
v2: integrate i2s/az check patch
v3: s/amd_acp/amdgpu_acp/
v4: update copyright notice
--- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/amd/acp/Kconfig | 9 + drivers/gpu/drm/amd/acp/Makefile | 9 + drivers/gpu/drm/amd/acp/acp_hw.c | 964 +++++++++++++++++++++++++++ drivers/gpu/drm/amd/acp/acp_hw.h | 99 +++ drivers/gpu/drm/amd/acp/include/acp_gfx_if.h | 49 ++ drivers/gpu/drm/amd/acp/include/amd_acp.h | 196 ++++++ drivers/gpu/drm/amd/amdgpu/Makefile | 14 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 + drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 201 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h | 40 ++ drivers/gpu/drm/amd/amdgpu/vi.c | 12 + drivers/gpu/drm/amd/include/amd_shared.h | 1 + 13 files changed, 1606 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/acp/Kconfig create mode 100644 drivers/gpu/drm/amd/acp/Makefile create mode 100644 drivers/gpu/drm/amd/acp/acp_hw.c create mode 100644 drivers/gpu/drm/amd/acp/acp_hw.h create mode 100644 drivers/gpu/drm/amd/acp/include/acp_gfx_if.h create mode 100644 drivers/gpu/drm/amd/acp/include/amd_acp.h create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h
drivers/gpu/drm/Kconfig +2 -0
@@ -144,6 +144,8 @@ config DRM_AMDGPU source "drivers/gpu/drm/amd/amdgpu/Kconfig" +source "drivers/gpu/drm/amd/acp/Kconfig" + source "drivers/gpu/drm/nouveau/Kconfig" config DRM_I810
drivers/gpu/drm/amd/acp/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +menu "ACP Configuration" + +config DRM_AMD_ACP + bool "Enable ACP IP support" + default y + help + Choose this option to enable ACP IP support for AMD SOCs. + +endmenu
drivers/gpu/drm/amd/acp/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# +# Makefile for the ACP, which is a sub-component +# of AMDSOC/AMDGPU drm driver. +# It provides the HW control for ACP related functionalities. + +ccflags-y += -Idrivers/gpu/drm/amd/include/asic_reg/acp +subdir-ccflags-y += -I$(AMDACPPATH)/ -I$(AMDACPPATH)/include + +AMD_ACP_FILES := $(AMDACPPATH)/acp_hw.o
drivers/gpu/drm/amd/acp/acp_hw.c new file +964 -0
964 lines not on this page · raw message
drivers/gpu/drm/amd/acp/acp_hw.h new file +99 -0
99 lines not on this page · raw message
drivers/gpu/drm/amd/acp/include/acp_gfx_if.h new file +49 -0
49 lines not on this page · raw message
drivers/gpu/drm/amd/acp/include/amd_acp.h new file +196 -0
196 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/Makefile +13 -1
@@ -3,7 +3,9 @@ # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/amd/include/asic_reg \ - -Idrivers/gpu/drm/amd/include + -Idrivers/gpu/drm/amd/include \ + -Idrivers/gpu/drm/amd/include/bus \ + -Idrivers/gpu/drm/amd/acp/include amdgpu-y := amdgpu_drv.o
@@ -74,6 +76,16 @@ amdgpu-y += \ # add cgs amdgpu-y += amdgpu_cgs.o +# ACP componet +ifneq ($(CONFIG_DRM_AMD_ACP),) +amdgpu-y += amdgpu_acp.o + +AMDACPPATH := ../acp +include drivers/gpu/drm/amd/acp/Makefile + +amdgpu-y += $(AMD_ACP_FILES) +endif + amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +11 -0
@@ -53,6 +53,7 @@#include "amdgpu_irq.h" #include "amdgpu_ucode.h" #include "amdgpu_gds.h" +#include "amdgpu_acp.h" /* * Modules parameters.
@@ -1853,6 +1854,12 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx);extern int amdgpu_ctx_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); +/* +* CGS +*/ +void *amdgpu_cgs_create_device (struct amdgpu_device *adev); +void amdgpu_cgs_destroy_device (void *cgs_device); +/* * Core structure, functions and helpers.
@@ -1869,6 +1876,10 @@ struct amdgpu_device {struct pci_dev *pdev;struct rw_semaphore exclusive_lock; +#ifdef CONFIG_DRM_AMD_ACP +struct amdgpu_acp acp; +#endif +/* ASIC */ enum amdgpu_asic_type asic_type;uint32_t family;
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c new file +201 -0
201 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright 2015 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __AMDGPU_ACP_H__ +#define __AMDGPU_ACP_H__ + +#include "amd_gnb_bus.h" + +struct amdgpu_acp { +struct device *parent; +struct amd_gnb_bus_dev acp_pcm_dev; +void *cgs_device; +struct amd_acp_private *private; +}; + +extern const struct amd_ip_funcs acp_ip_funcs; + +#endif /* __AMDGPU_ACP_H__ */
drivers/gpu/drm/amd/amdgpu/vi.c +12 -0
@@ -71,6 +71,9 @@#include "uvd_v5_0.h" #include "uvd_v6_0.h" #include "vce_v3_0.h" +#if defined(CONFIG_DRM_AMD_ACP ) +#include "amdgpu_acp.h" +#endif /* * Indirect registers accessor
@@ -1167,6 +1170,15 @@ static const struct amdgpu_ip_block_version cz_ip_blocks[] = .rev = 0, .funcs = &vce_v3_0_ip_funcs, }, +#if defined(CONFIG_DRM_AMD_ACP ) + { + .type = AMD_IP_BLOCK_TYPE_ACP, + .major = 2, + .minor = 2, + .rev = 0, + .funcs = &acp_ip_funcs, + }, +#endif };int vi_set_ip_blocks (struct amdgpu_device *adev)
drivers/gpu/drm/amd/include/amd_shared.h +1 -0
@@ -33,6 +33,7 @@ enum amd_ip_block_type {AMD_IP_BLOCK_TYPE_SDMA ,AMD_IP_BLOCK_TYPE_UVD ,AMD_IP_BLOCK_TYPE_VCE , + AMD_IP_BLOCK_TYPE_ACP, }; enum amd_clockgating_state {
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/12 drm/amd: modify ACP DMA buffer position update logic
In reply to Alex DeucherFrom: Maruthi Srinivas Bayyavarapu <[email protected]>
The following are design changes for ACP DMA :
1. For capture usecase, DMA Interrupt on Complete is added for ACP_TO_SYSRAM_CH_NUM DMA channel
2. For playback usecase, the destination for DMA descriptors is reversed.
3. Finally, modified DMA buffer position update logic as per above changes.
--- drivers/gpu/drm/amd/acp/acp_hw.c | 142 ++++++++++++++++++++++----------------- drivers/gpu/drm/amd/acp/acp_hw.h | 19 ++---- 2 files changed, 86 insertions(+), 75 deletions(-)
drivers/gpu/drm/amd/acp/acp_hw.c +80 -62
@@ -40,7 +40,7 @@#include <linux/delay.h> #include <linux/errno.h> -#define VISLANDS30_IV_SRCID_ACP 0x000000a2 // 162 +#define VISLANDS30_IV_SRCID_ACP 0x000000a2#include "acp_gfx_if.h" #include "acp_hw.h"
@@ -91,10 +91,9 @@ static void config_acp_dma_channel(struct amd_acp_device *acp_dev, u8 ch_num,/* Initialize the dma descriptors location in SRAM and page size */ -static void acp_dma_descr_init (struct amd_acp_device *acp_dev) +static void acp_dma_descr_init (struct amd_acp_private *acp_prv) {u32 sram_pte_offset =0 ; -struct amd_acp_private *acp_prv = (struct amd_acp_private *)acp_dev;/* SRAM starts at 0x04000000. From that offset one page (4KB) left for * filling DMA descriptors.sram_pte_offset = 0x04001000 , used for
@@ -146,10 +145,11 @@ static void config_dma_descriptor_in_sram(struct amd_acp_device *acp_dev,/* Initialize the DMA descriptor information */ static void set_acp_sysmem_dma_descriptors (struct amd_acp_device *acp_dev, -u32 size,int direction,u32 pte_offset) +u32 size,int direction, +u32 pte_offset) { -u16 dma_dscr_idx =PLAYBACK_START_DMA_DESCR_CH12 ;u16 num_descr; +u16 dma_dscr_idx =PLAYBACK_START_DMA_DESCR_CH12 ;acp_dma_dscr_transfer_t dmadscr[2 ]; num_descr =2 ;
@@ -157,11 +157,13 @@ static void set_acp_sysmem_dma_descriptors(struct amd_acp_device *acp_dev, dmadscr[0 ].size_xfer_dir.val = (u32 )0x0 ;if (direction ==STREAM_PLAYBACK ) { dma_dscr_idx =PLAYBACK_START_DMA_DESCR_CH12 ; - dmadscr[0 ].dest =ACP_SHARED_RAM_BANK_38_ADDRESS ; + dmadscr[0 ].dest =ACP_SHARED_RAM_BANK_38_ADDRESS + (size /2 ); dmadscr[0 ].src =ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + (pte_offset *PAGE_SIZE_4K ); dmadscr[0 ].size_xfer_dir.s.trans_direction =ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM ; + dmadscr[0 ].size_xfer_dir.s.size = (size /2 ); + dmadscr[0 ].size_xfer_dir.s.ioc = (u32 )0x0 ; }else if (direction ==STREAM_CAPTURE ) { dma_dscr_idx =CAPTURE_START_DMA_DESCR_CH14 ; dmadscr[0 ].src =ACP_SHARED_RAM_BANK_47_ADDRESS ;
@@ -169,31 +171,31 @@ static void set_acp_sysmem_dma_descriptors(struct amd_acp_device *acp_dev, (pte_offset *PAGE_SIZE_4K ); dmadscr[0 ].size_xfer_dir.s.trans_direction =ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION ; + dmadscr[0 ].size_xfer_dir.s.size = size /2 ; + dmadscr[0 ].size_xfer_dir.s.ioc = (u32 )0x1 ; } -/* allot 1 period size per descriptor = total size (size) /2 -* => params_buffer_bytes(params)/params_periods(params); -*/ - dmadscr[0 ].size_xfer_dir.s.size = size /2 ; - - dmadscr[0 ].size_xfer_dir.s.ioc = (u32 )0x0 ; -config_dma_descriptor_in_sram (acp_dev, dma_dscr_idx, &dmadscr[0 ]); dmadscr[1 ].size_xfer_dir.val = (u32 )0x0 ; - dmadscr[1 ].dest = dmadscr[0 ].dest + dmadscr[0 ].size_xfer_dir.s.size; - dmadscr[1 ].src = dmadscr[0 ].src + dmadscr[0 ].size_xfer_dir.s.size; - dmadscr[1 ].size_xfer_dir.s.size = dmadscr[0 ].size_xfer_dir.s.size; - dmadscr[1 ].size_xfer_dir.s.ioc = (u32 )0x0 ; -if (direction ==STREAM_PLAYBACK ) { dma_dscr_idx =PLAYBACK_END_DMA_DESCR_CH12 ; + dmadscr[1 ].dest =ACP_SHARED_RAM_BANK_38_ADDRESS ; + dmadscr[1 ].src =ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + + (pte_offset *PAGE_SIZE_4K ) + (size /2 ); dmadscr[1 ].size_xfer_dir.s.trans_direction =ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM ; + dmadscr[1 ].size_xfer_dir.s.size = (size /2 ); + dmadscr[1 ].size_xfer_dir.s.ioc = (u32 )0x0 ; }else if (direction ==STREAM_CAPTURE ) { dma_dscr_idx =CAPTURE_END_DMA_DESCR_CH14 ; dmadscr[1 ].size_xfer_dir.s.trans_direction =ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION ; + dmadscr[1 ].size_xfer_dir.val = (u32 )0x0 ; + dmadscr[1 ].dest = dmadscr[0 ].dest + (size /2 ); + dmadscr[1 ].src = dmadscr[0 ].src + (size /2 ); + dmadscr[1 ].size_xfer_dir.s.size = (size /2 ); + dmadscr[1 ].size_xfer_dir.s.ioc = (u32 )0x1 ; }config_dma_descriptor_in_sram (acp_dev, dma_dscr_idx, &dmadscr[1 ]);
@@ -228,34 +230,38 @@ static void set_acp_to_i2s_dma_descriptors(struct amd_acp_device *acp_dev,* of data */ dmadscr[0 ].size_xfer_dir.val = (u32 )0x0 ; - dmadscr[0 ].size_xfer_dir.s.size = (size /2 ); - dmadscr[0 ].size_xfer_dir.s.ioc = (u32 )0x1 ;if (direction ==STREAM_PLAYBACK ) { dma_dscr_idx =PLAYBACK_START_DMA_DESCR_CH13 ; dmadscr[0 ].src =ACP_SHARED_RAM_BANK_38_ADDRESS ; dmadscr[0 ].size_xfer_dir.s.trans_direction =TO_ACP_I2S_1 ; + dmadscr[0 ].size_xfer_dir.s.size = (size /2 ); + dmadscr[0 ].size_xfer_dir.s.ioc = (u32 )0x1 ; }else if (direction ==STREAM_CAPTURE ) { dma_dscr_idx =CAPTURE_START_DMA_DESCR_CH15 ; dmadscr[0 ].dest =ACP_SHARED_RAM_BANK_47_ADDRESS ; - dmadscr[0 ].size_xfer_dir.s.trans_direction =0xa ; + dmadscr[0 ].size_xfer_dir.s.trans_direction =FROM_ACP_I2S_1 ; + dmadscr[0 ].size_xfer_dir.s.size = (size /2 ); + dmadscr[0 ].size_xfer_dir.s.ioc = (u32 )0x1 ; } +config_dma_descriptor_in_sram (acp_dev, dma_dscr_idx, &dmadscr[0 ]); dmadscr[1 ].size_xfer_dir.val = (u32 )0x0 ; - dmadscr[1 ].size_xfer_dir.s.size = (size /2 ); - dmadscr[1 ].size_xfer_dir.s.ioc = (u32 )0x1 ;if (direction ==STREAM_PLAYBACK ) { dma_dscr_idx =PLAYBACK_END_DMA_DESCR_CH13 ; - dmadscr[1 ].src = dmadscr[0 ].src + - dmadscr[0 ].size_xfer_dir.s.size; + dmadscr[1 ].src = dmadscr[0 ].src + (size /2 ); dmadscr[1 ].size_xfer_dir.s.trans_direction =TO_ACP_I2S_1 ; + dmadscr[1 ].size_xfer_dir.s.size = (size /2 ); + dmadscr[1 ].size_xfer_dir.s.ioc = (u32 )0x1 ; }else if (direction ==STREAM_CAPTURE ) { dma_dscr_idx =CAPTURE_END_DMA_DESCR_CH15 ; - dmadscr[1 ].dest = dmadscr[0 ].dest + - dmadscr[0 ].size_xfer_dir.s.size; - dmadscr[1 ].size_xfer_dir.s.trans_direction =0xa ; + dmadscr[1 ].dest = dmadscr[0 ].dest + (size /2 ); + dmadscr[1 ].size_xfer_dir.s.trans_direction =FROM_ACP_I2S_1 ; + dmadscr[1 ].size_xfer_dir.s.size = (size /2 ); + dmadscr[1 ].size_xfer_dir.s.ioc = (u32 )0x1 ; } +config_dma_descriptor_in_sram (acp_dev, dma_dscr_idx, &dmadscr[1 ]);/* Configure the DMA channel with the above descriptore */
@@ -284,8 +290,8 @@ static u16 get_dscr_idx(struct amd_acp_device *acp_dev, int direction) dscr_idx =cgs_read_register (acp_prv->cgs_device, mmACP_DMA_CUR_DSCR_13); dscr_idx = (dscr_idx ==PLAYBACK_START_DMA_DESCR_CH13 ) ? -PLAYBACK_END_DMA_DESCR_CH12 : -PLAYBACK_START_DMA_DESCR_CH12 ; +PLAYBACK_START_DMA_DESCR_CH12 : +PLAYBACK_END_DMA_DESCR_CH12 ; }else { dscr_idx =cgs_read_register (acp_prv->cgs_device, mmACP_DMA_CUR_DSCR_15);
@@ -470,7 +476,7 @@ static void configure_i2s_stream(struct amd_acp_device *acp_dev,/*Enable Transmit */ cgs_write_register (acp_prv->cgs_device, (mmACP_I2SSP_TER0 + (0x10 * - i2s_config->ch_reg)),1 ); + i2s_config->ch_reg)),1 ); }else {/* Receive configuration register for data width */ cgs_write_register(acp_prv->cgs_device,
@@ -479,11 +485,11 @@ static void configure_i2s_stream(struct amd_acp_device *acp_dev, i2s_config->xfer_resolution);cgs_write_register (acp_prv->cgs_device, (mmACP_I2SMICSP_RFCR0 + (0x10 * - i2s_config->ch_reg)),0x07 ); + i2s_config->ch_reg)),0x07 );/*Read interrupt mask register */ i2s_config->irq =cgs_read_register (acp_prv->cgs_device, (mmACP_I2SMICSP_IMR0 + - (0x10 * i2s_config->ch_reg))); + (0x10 * i2s_config->ch_reg)));/* TX FIFO Overrun,Empty interrupts */ cgs_write_register(acp_prv->cgs_device,
@@ -493,8 +499,7 @@ static void configure_i2s_stream(struct amd_acp_device *acp_dev,/*Enable Receive */ cgs_write_register (acp_prv->cgs_device, (mmACP_I2SMICSP_RER0 + (0x10 * - i2s_config->ch_reg)),1 ); - + i2s_config->ch_reg)),1 ); } }
@@ -545,16 +550,18 @@ static int acp_dma_start(struct amd_acp_device *acp_dev, dma_ctrl |= ACP_DMA_CNTL_0__DMAChRun_MASK;if ((ch_num ==ACP_TO_I2S_DMA_CH_NUM ) || + (ch_num ==ACP_TO_SYSRAM_CH_NUM ) || (ch_num ==I2S_TO_ACP_DMA_CH_NUM )) { dma_ctrl |= ACP_DMA_CNTL_0__DMAChIOCEn_MASK; -cgs_irq_get (acp_prv->cgs_device,VISLANDS30_IV_SRCID_ACP ,0 ); }else { dma_ctrl &= ~ACP_DMA_CNTL_0__DMAChIOCEn_MASK; }/* enable for ACP SRAM to/from I2S DMA channel */ -if (is_circular == true) +if (is_circular == true) { dma_ctrl |= ACP_DMA_CNTL_0__Circular_DMA_En_MASK; +cgs_irq_get (acp_prv->cgs_device,VISLANDS30_IV_SRCID_ACP ,0 ); + }else dma_ctrl &= ~ACP_DMA_CNTL_0__Circular_DMA_En_MASK;
@@ -562,7 +569,6 @@ static int acp_dma_start(struct amd_acp_device *acp_dev, dma_ctrl); status =STATUS_SUCCESS ; -return status; }
@@ -614,7 +620,8 @@ static int acp_dma_stop(struct amd_acp_device *acp_dev, u8 ch_num) dma_ctrl &= ~ACP_DMA_CNTL_0__DMAChRst_MASK;cgs_write_register (acp_prv->cgs_device, - (mmACP_DMA_CNTL_0 + ch_num), dma_ctrl); + (mmACP_DMA_CNTL_0 + ch_num), + dma_ctrl); status =STATUS_SUCCESS ;break ; }
@@ -631,47 +638,58 @@ static int acp_dma_stop(struct amd_acp_device *acp_dev, u8 ch_num)static int dma_irq_handler (void *prv_data) { -u16 play_intr, capture_intr; +u16 play_acp_i2s_intr, cap_i2s_acp_intr, cap_acp_sysram_intr;u16 dscr_idx, intr_flag; +u32 ext_intr_status;int priority_level =0x0 ;int dma_transfer_status =STATUS_UNSUCCESSFUL ;struct acp_irq_prv *idata = prv_data;struct amd_acp_device *acp_dev = idata->acp_dev; +struct amd_acp_private *acp_prv = (struct amd_acp_private *)acp_dev; intr_flag =acp_get_intr_flag (acp_dev); - play_intr = (intr_flag &BIT (ACP_TO_I2S_DMA_CH_NUM )); - capture_intr = (intr_flag &BIT (I2S_TO_ACP_DMA_CH_NUM )); -if (!play_intr && !capture_intr) { + play_acp_i2s_intr = (intr_flag &BIT (ACP_TO_I2S_DMA_CH_NUM )); + cap_i2s_acp_intr = (intr_flag &BIT (I2S_TO_ACP_DMA_CH_NUM )); + cap_acp_sysram_intr = (intr_flag &BIT (ACP_TO_SYSRAM_CH_NUM )); + +if (!play_acp_i2s_intr && !cap_i2s_acp_intr && !cap_acp_sysram_intr) {/* We registered for DMA Interrupt-On-Complete interrupts only. -* If we hit here, just return. */ -pr_info ("ACP:irq_handler: play_intr && capture_intr = false\n" ); +* If we hit here, log, acknowledge it and return. */ + ext_intr_status =cgs_read_register (acp_prv->cgs_device, + mmACP_EXTERNAL_INTR_STAT); +pr_info ("ACP: Not a DMA IOC irq: %x\n" , ext_intr_status);return 0 ; } -if (play_intr) { +if (play_acp_i2s_intr) { dscr_idx =get_dscr_idx (acp_dev,STREAM_PLAYBACK );config_acp_dma_channel (acp_dev,SYSRAM_TO_ACP_CH_NUM , dscr_idx,1 , priority_level); dma_transfer_status =acp_dma_start (acp_dev,SYSRAM_TO_ACP_CH_NUM , false); - idata->set_elapsed (idata->dev, play_intr, capture_intr); + idata->set_elapsed (idata->dev,1 ,0 );acp_ext_stat_clear_dmaioc (acp_dev,ACP_TO_I2S_DMA_CH_NUM ); } -if (capture_intr) { +if (cap_i2s_acp_intr) { dscr_idx =get_dscr_idx (acp_dev,STREAM_CAPTURE );config_acp_dma_channel (acp_dev,ACP_TO_SYSRAM_CH_NUM , dscr_idx,1 , priority_level); dma_transfer_status =acp_dma_start (acp_dev,ACP_TO_SYSRAM_CH_NUM , false); - idata->set_elapsed (idata->dev, play_intr, capture_intr);acp_ext_stat_clear_dmaioc (acp_dev,I2S_TO_ACP_DMA_CH_NUM ); } + +if (cap_acp_sysram_intr) { + idata->set_elapsed (idata->dev,0 ,1 ); +acp_ext_stat_clear_dmaioc (acp_dev,ACP_TO_SYSRAM_CH_NUM ); + } +return 0 ; }
@@ -737,7 +755,7 @@ static int acp_hw_init(struct amd_acp_device *acp_dev, void *iprv)cgs_write_register (acp_prv->cgs_device, mmACP_AXI2DAGB_GARLIC_CNTL,GARLIC_CNTL_DEFAULT ); -acp_dma_descr_init (acp_dev); +acp_dma_descr_init (acp_prv);/* DMA DSCR BASE ADDRESS IN SRAM */ cgs_write_register(acp_prv->cgs_device, mmACP_DMA_DESC_BASE_ADDR,
@@ -811,24 +829,24 @@ static u32 acp_update_dma_pointer(struct amd_acp_device *acp_dev, int direction,if (direction ==STREAM_PLAYBACK ) { dscr =cgs_read_register (acp_prv->cgs_device, mmACP_DMA_CUR_DSCR_13); - pos =cgs_read_register (acp_prv->cgs_device, - mmACP_DMA_CUR_TRANS_CNT_13); -/* dscr = either 2 or 3 only */ - mul = (dscr ==PLAYBACK_START_DMA_DESCR_CH13 ) ?1 :0 ; - pos = (mul * period_size) + pos; + + mul = (dscr ==PLAYBACK_START_DMA_DESCR_CH13 ) ?0 :1 ; + pos = (mul * period_size); + }else if (direction ==STREAM_CAPTURE ) { - dscr =cgs_read_register (acp_prv->cgs_device, - mmACP_DMA_CUR_DSCR_15); - pos =cgs_read_register (acp_prv->cgs_device, - mmACP_DMA_CUR_TRANS_CNT_15); dma_config =cgs_read_register (acp_prv->cgs_device, mmACP_DMA_CNTL_14);if (dma_config !=0 ) { - mul = (dscr ==CAPTURE_START_DMA_DESCR_CH15 ) ?1 :0 ; - pos = (mul * period_size) + pos; + dscr =cgs_read_register (acp_prv->cgs_device, + mmACP_DMA_CUR_DSCR_14); + mul = (dscr ==CAPTURE_START_DMA_DESCR_CH14 ) ?1 :2 ; + pos = (mul * period_size); } - } +if (pos >= (2 * period_size)) + pos =0 ; + + }return pos; }
drivers/gpu/drm/amd/acp/acp_hw.h +6 -13
@@ -22,7 +22,7 @@#define ACP_SHARED_RAM_BANK_38_ADDRESS 0x404A000/* Capture SRAM address (as a source in dma descriptor) */ -#define ACP_SHARED_RAM_BANK_47_ADDRESS 0x405C000 +#define ACP_SHARED_RAM_BANK_47_ADDRESS 0x4054000#define ACP_DMA_RESET_TIME 10000#define ACP_CLOCK_EN_TIME_OUT_VALUE 0x000000FF
@@ -35,6 +35,11 @@#define ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS 0x00000000#define ACP_INTERNAL_APERTURE_WINDOW_4_ADDRESS 0x01800000 +#define TO_ACP_I2S_1 0x2 +#define TO_ACP_I2S_2 0x4 +#define FROM_ACP_I2S_1 0xa +#define FROM_ACP_I2S_2 0xb +enum {STREAM_PLAYBACK =0 ,STREAM_CAPTURE ,
@@ -42,18 +47,6 @@ enum { };enum { - To_DAGB_O =0x0 , - To_DAGB_G, -TO_ACP_I2S_1 , -TO_BLUETOOTH , -TO_ACP_I2S_2 , -FROM_DAGB_O , -FROM_DAGB_G , -FROM_ACP_I2S_1 , -FROM_ACP_I2S_2 -}; - -enum {ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION =0x0 ,ACP_DMA_ATTRIBUTES_SHARED_MEM_TO_DAGB_GARLIC =0x1 ,ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM =0x8 ,
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 11/12 drm/amd: add ACP suspend/resume functionality
In reply to Alex DeucherFrom: Maruthi Srinivas Bayyavarapu <[email protected]>
ACP IP can be powered on and off during system wide suspend/resume transition. AMD ASoC PCM device will use this module during system suspend/resume and PCM device's runtime pm.
Also, updated code comments.
--- drivers/gpu/drm/amd/acp/acp_hw.c | 220 +++++++++++++++++++++++------- drivers/gpu/drm/amd/acp/acp_hw.h | 19 +++ drivers/gpu/drm/amd/acp/include/amd_acp.h | 18 +++ 3 files changed, 204 insertions(+), 53 deletions(-)
drivers/gpu/drm/amd/acp/acp_hw.c +167 -53
@@ -40,17 +40,16 @@#include <linux/delay.h> #include <linux/errno.h> -#define VISLANDS30_IV_SRCID_ACP 0x000000a2 -#include "acp_gfx_if.h" #include "acp_hw.h" #include "acp_2_2_d.h" #include "acp_2_2_sh_mask.h" +#define VISLANDS30_IV_SRCID_ACP 0x000000a2 +/* Configure a given dma channel parameters - enable/disble, * number of descriptors, priority */ -static void config_acp_dma_channel (struct amd_acp_device *acp_dev,u8 ch_num,u16 dscr_strt_idx,u16 num_dscrs,enum acp_dma_priority_level priority_level)
@@ -58,38 +57,30 @@ static void config_acp_dma_channel(struct amd_acp_device *acp_dev, u8 ch_num,u32 dma_ctrl;struct amd_acp_private *acp_prv = (struct amd_acp_private *)acp_dev; -/* read the dma control register and disable the channel run field */ +/* disable the channel run field */ dma_ctrl =cgs_read_register (acp_prv->cgs_device, mmACP_DMA_CNTL_0 + ch_num); -/* clear the dma channel control bits */ dma_ctrl &= ~ACP_DMA_CNTL_0__DMAChRun_MASK; -cgs_write_register (acp_prv->cgs_device, (mmACP_DMA_CNTL_0 + ch_num), dma_ctrl); -/* there is no transfer happening on this channel so -* program DMAChDscrStrIdx to the index number of the first descriptor -* to be processed. -*/ +/* program a DMA channel with first descriptor to be processed. */ cgs_write_register (acp_prv->cgs_device, (mmACP_DMA_DSCR_STRT_IDX_0 + ch_num), (ACP_DMA_DSCR_STRT_IDX_0__DMAChDscrStrtIdx_MASK & dscr_strt_idx)); -/* program DMAChDscrDscrCnt to the number of descriptors to be -* processed in the transfer -*/ +/* program a DMA channel with the number of descriptors to be +* processed in the transfer */ cgs_write_register (acp_prv->cgs_device, (mmACP_DMA_DSCR_CNT_0 + ch_num), (ACP_DMA_DSCR_CNT_0__DMAChDscrCnt_MASK & num_dscrs)); -/* set DMAChPrioLvl according to the priority */ +/* set DMA channel priority */ cgs_write_register (acp_prv->cgs_device, (mmACP_DMA_PRIO_0 + ch_num), priority_level); } - -/* Initialize the dma descriptors location in SRAM and page size */ static void acp_dma_descr_init (struct amd_acp_private *acp_prv) {
@@ -143,7 +134,9 @@ static void config_dma_descriptor_in_sram(struct amd_acp_device *acp_dev, descr_info->size_xfer_dir.val); } -/* Initialize the DMA descriptor information */ +/* Initialize the DMA descriptor information for transfer between +* system memory <-> ACP SRAM +*/ static void set_acp_sysmem_dma_descriptors (struct amd_acp_device *acp_dev,u32 size,int direction,u32 pte_offset)
@@ -215,7 +208,9 @@ static void set_acp_sysmem_dma_descriptors(struct amd_acp_device *acp_dev, } } -/* Initialize the i2s dma descriptors in SRAM */ +/* Initialize the DMA descriptor information for transfer between +* ACP SRAM <-> I2S +*/ static void set_acp_to_i2s_dma_descriptors (struct amd_acp_device *acp_dev,u32 size,int direction) {
@@ -226,9 +221,6 @@ static void set_acp_to_i2s_dma_descriptors(struct amd_acp_device *acp_dev, num_descr =2 ; -/* Let I2s Know the direction of transfer and source/destination -* of data -*/ dmadscr[0 ].size_xfer_dir.val = (u32 )0x0 ;if (direction ==STREAM_PLAYBACK ) { dma_dscr_idx =PLAYBACK_START_DMA_DESCR_CH13 ;
@@ -304,7 +296,7 @@ static u16 get_dscr_idx(struct amd_acp_device *acp_dev, int direction) } -/* Create page table entries in ACP SRAM for the allocated memory */ +/* Create page table entries in ACP SRAM for the allocated memory */ static void acp_pte_config (struct amd_acp_device *acp_dev,struct page *pg,u16 num_of_pages,u32 pte_offset) {
@@ -344,7 +336,6 @@ static void acp_pte_config(struct amd_acp_device *acp_dev, struct page *pg, } } -/* enables/disables ACP's external interrupt */ static void acp_enable_external_interrupts (struct amd_acp_device *acp_dev,int enable)
@@ -361,8 +352,8 @@ static void acp_enable_external_interrupts(struct amd_acp_device *acp_dev, mmACP_EXTERNAL_INTR_ENB, acp_ext_intr_enb); } -/* Clear (acknowledge) DMA 'Interrupt on Complete' (IOC) in ACP -* external interrupt status register +/* Clear (acknowledge) DMA 'Interrupt on Complete' (IOC) in ACP +* external interrupt status register */ static void acp_ext_stat_clear_dmaioc (struct amd_acp_device *acp_dev,u8 ch_num) {
@@ -382,7 +373,7 @@ static void acp_ext_stat_clear_dmaioc(struct amd_acp_device *acp_dev, u8 ch_num) } } -/* Check whether interrupt (IOC) is generated or not */ +/* Check whether ACP DMA interrupt (IOC) is generated or not */ static u16 acp_get_intr_flag (struct amd_acp_device *acp_dev) {u32 ext_intr_status;
@@ -412,7 +403,6 @@ static int irq_set_source(void *private_data, unsigned src_id, unsigned type, } } -static inline void i2s_clear_irqs (struct amd_acp_device *acp_dev,int direction) {
@@ -516,17 +506,17 @@ static void config_acp_dma(struct amd_acp_device *acp_dev,acp_pte_config (acp_dev, dma_config->pg, dma_config->num_of_pages, pte_offset); -/* Configure System memory to acp dma descriptors */ +/* Configure System memory <-> ACP SRAM DMA descriptors */ set_acp_sysmem_dma_descriptors (acp_dev, dma_config->size, dma_config->direction, pte_offset); -/* Configure acp to i2s dma descriptors */ +/* Configure ACP SRAM <-> I2S DMA descriptors */ set_acp_to_i2s_dma_descriptors (acp_dev, dma_config->size, dma_config->direction); } -/* Start a given dma channel */ +/* Start a given DMA channel transfer */ static int acp_dma_start (struct amd_acp_device *acp_dev,u16 ch_num,bool is_circular) {
@@ -572,7 +562,7 @@ static int acp_dma_start(struct amd_acp_device *acp_dev,return status; } -/* Stop a given dma channel number*/ +/* Stop a given DMA channel transfer */ static int acp_dma_stop (struct amd_acp_device *acp_dev,u8 ch_num) {int status =STATUS_UNSUCCESSFUL ;
@@ -584,7 +574,6 @@ static int acp_dma_stop(struct amd_acp_device *acp_dev, u8 ch_num)if (acp_dev ==NULL )return status; -/* register mask value to check the channel status bits */ dma_ctrl =cgs_read_register (acp_prv->cgs_device, mmACP_DMA_CNTL_0 + ch_num);
@@ -636,6 +625,7 @@ static int acp_dma_stop(struct amd_acp_device *acp_dev, u8 ch_num)return status; } +/* ACP DMA irq handler routine for playback, capture usecases */ static int dma_irq_handler (void *prv_data) {u16 play_acp_i2s_intr, cap_i2s_acp_intr, cap_acp_sysram_intr;
@@ -655,7 +645,7 @@ static int dma_irq_handler(void *prv_data)if (!play_acp_i2s_intr && !cap_i2s_acp_intr && !cap_acp_sysram_intr) {/* We registered for DMA Interrupt-On-Complete interrupts only. -* If we hit here, log, acknowledge it and return. */ +* If we hit here, log it and return. */ ext_intr_status =cgs_read_register (acp_prv->cgs_device, mmACP_EXTERNAL_INTR_STAT);pr_info ("ACP: Not a DMA IOC irq: %x\n" , ext_intr_status);
@@ -702,16 +692,92 @@ static int irq_handler(void *private_data, unsigned src_id,return -1 ; } +/* power off a tile/block within ACP */ +static void acp_suspend_tile (struct amd_acp_private *acp_prv,int tile) +{ +u32 val =0 ; +u32 timeout =0 ; + +if ((tile <ACP_TILE_P1 ) || (tile >ACP_TILE_DSP2 )) { +pr_err (" %s : Invalid ACP power tile index\n" , __func__); +return ; + } + + val =cgs_read_register (acp_prv->cgs_device, + mmACP_PGFSM_READ_REG_0 + tile); + val &=ACP_TILE_ON_MASK ; + +if (val ==0x0 ) { + val =cgs_read_register (acp_prv->cgs_device, + mmACP_PGFSM_RETAIN_REG); + val = val | (1 << tile); +cgs_write_register (acp_prv->cgs_device, mmACP_PGFSM_RETAIN_REG, + val); +cgs_write_register (acp_prv->cgs_device, mmACP_PGFSM_CONFIG_REG, +0x500 + tile); + + timeout =ACP_SOFT_RESET_DONE_TIME_OUT_VALUE ; +while (timeout--) { + val =cgs_read_register (acp_prv->cgs_device, + mmACP_PGFSM_READ_REG_0 + tile); + val = val &ACP_TILE_ON_MASK ; +if (val ==ACP_TILE_OFF_MASK ) +break ; + } + + val =cgs_read_register (acp_prv->cgs_device, + mmACP_PGFSM_RETAIN_REG); + + val |=ACP_TILE_OFF_RETAIN_REG_MASK ; +cgs_write_register (acp_prv->cgs_device, mmACP_PGFSM_RETAIN_REG, + val); + } + +} + +/* power on a tile/block within ACP */ +static void acp_resume_tile (struct amd_acp_private *acp_prv,int tile) +{ +u32 val =0 ; +u32 timeout =0 ; + +if ((tile <ACP_TILE_P1 ) || (tile >ACP_TILE_DSP2 )) { +pr_err (" %s : Invalid ACP power tile index\n" , __func__); +return ; + } + + val =cgs_read_register (acp_prv->cgs_device, + mmACP_PGFSM_READ_REG_0 + tile); + val = val &ACP_TILE_ON_MASK ; + +if (val !=0x0 ) { +cgs_write_register (acp_prv->cgs_device, mmACP_PGFSM_CONFIG_REG, +0x600 + tile); + timeout =ACP_SOFT_RESET_DONE_TIME_OUT_VALUE ; +while (timeout--) { + val =cgs_read_register (acp_prv->cgs_device, + mmACP_PGFSM_READ_REG_0 + tile); + val = val &ACP_TILE_ON_MASK ; +if (val ==0x0 ) +break ; + } + val =cgs_read_register (acp_prv->cgs_device, + mmACP_PGFSM_RETAIN_REG); +if (tile ==ACP_TILE_P1 ) + val = val & (ACP_TILE_P1_MASK ); +else if (tile ==ACP_TILE_P2 ) + val = val & (ACP_TILE_P2_MASK ); + +cgs_write_register (acp_prv->cgs_device, mmACP_PGFSM_RETAIN_REG, + val); + } +} +/* Initialize and bring ACP hardware to default state. */ -static int acp_hw_init (struct amd_acp_device *acp_dev,void *iprv) +static void acp_init (struct amd_acp_private *acp_prv) {u32 val;u32 timeout_value; -int acp_hw_init_status =STATUS_UNSUCCESSFUL ; -struct amd_acp_private *acp_prv = (struct amd_acp_private *)acp_dev; - -if (acp_dev ==NULL ) -return acp_hw_init_status;/* Assert Soft reset of ACP */ val =cgs_read_register (acp_prv->cgs_device, mmACP_SOFT_RESET);
@@ -728,7 +794,7 @@ static int acp_hw_init(struct amd_acp_device *acp_dev, void *iprv)break ; } -/* Enabling clock to ACP and waits until the clock is enabled */ +/* Enable clock to ACP and wait until the clock is enabled */ val =cgs_read_register (acp_prv->cgs_device, mmACP_CONTROL); val = val | ACP_CONTROL__ClkEn_MASK;cgs_write_register (acp_prv->cgs_device, mmACP_CONTROL, val);
@@ -757,7 +823,6 @@ static int acp_hw_init(struct amd_acp_device *acp_dev, void *iprv)acp_dma_descr_init (acp_prv); -/* DMA DSCR BASE ADDRESS IN SRAM */ cgs_write_register (acp_prv->cgs_device, mmACP_DMA_DESC_BASE_ADDR,ACP_SRAM_BASE_ADDRESS );
@@ -768,20 +833,34 @@ static int acp_hw_init(struct amd_acp_device *acp_dev, void *iprv)cgs_write_register (acp_prv->cgs_device, mmACP_EXTERNAL_INTR_CNTL, ACP_EXTERNAL_INTR_CNTL__DMAIOCMask_MASK); +pr_info ("ACP: Initialized.\n" ); + +} + +static int acp_hw_init (struct amd_acp_device *acp_dev,void *iprv) +{ +struct amd_acp_private *acp_prv = (struct amd_acp_private *)acp_dev; + +acp_init (acp_prv); +cgs_add_irq_source (acp_prv->cgs_device,VISLANDS30_IV_SRCID_ACP ,1 , - irq_set_source, irq_handler, iprv); + irq_set_source, irq_handler, iprv); + +/* Disable DSPs which are not used */ +acp_suspend_tile (acp_prv,ACP_TILE_DSP0 ); +acp_suspend_tile (acp_prv,ACP_TILE_DSP1 ); +acp_suspend_tile (acp_prv,ACP_TILE_DSP2 ); -pr_info ("ACP: Initialized.\n" );return STATUS_SUCCESS ; } -static void acp_hw_deinit (struct amd_acp_device *acp_dev) +/* Deintialize ACP */ +static void acp_deinit (struct amd_acp_private *acp_prv) {u32 val;u32 timeout_value; -struct amd_acp_private *acp_prv = (struct amd_acp_private *)acp_dev; -/* Assert Soft reset of ACP */ +/* Assert Soft reset of ACP */ val =cgs_read_register (acp_prv->cgs_device, mmACP_SOFT_RESET); val |= ACP_SOFT_RESET__SoftResetAud_MASK;
@@ -795,7 +874,7 @@ static void acp_hw_deinit(struct amd_acp_device *acp_dev)break ; } } -/** Disable ACP clock */ +/** Disable ACP clock */ val =cgs_read_register (acp_prv->cgs_device, mmACP_CONTROL); val &= ~ACP_CONTROL__ClkEn_MASK;cgs_write_register (acp_prv->cgs_device, mmACP_CONTROL, val);
@@ -812,9 +891,15 @@ static void acp_hw_deinit(struct amd_acp_device *acp_dev)pr_info ("ACP: De-Initialized.\n" ); } +static void acp_hw_deinit (struct amd_acp_device *acp_dev) +{ +struct amd_acp_private *acp_prv = (struct amd_acp_private *)acp_dev; + +acp_deinit (acp_prv); +} -/* Get the number of bytes consumed for SRAM_TO_I2S DMA -* channel during rendering +/* Update DMA postion in audio ring buffer at period level granularity. +* This will be used by ALSA PCM driver */ static u32 acp_update_dma_pointer (struct amd_acp_device *acp_dev,int direction,u32 period_size)
@@ -824,6 +909,7 @@ static u32 acp_update_dma_pointer(struct amd_acp_device *acp_dev, int direction,u32 mul;u32 dma_config;struct amd_acp_private *acp_prv = (struct amd_acp_private *)acp_dev; + pos =0 ;if (direction ==STREAM_PLAYBACK ) {
@@ -850,8 +936,8 @@ static u32 acp_update_dma_pointer(struct amd_acp_device *acp_dev, int direction,return pos; } -/* Wait for complete buffering to complete in HOST -* to SRAM DMA channel +/* Wait for initial buffering to complete in HOST to SRAM DMA channel +* for plaback usecase */ static void wait_for_prebuffer_finish (struct amd_acp_device *acp_dev) {
@@ -927,6 +1013,22 @@ static void configure_i2s(struct amd_acp_device *acp_dev,configure_i2s_stream (acp_dev, i2s_config); } +void amd_acp_pcm_suspend (struct amd_acp_device *acp_dev) +{ +struct amd_acp_private *acp_prv; + + acp_prv = (struct amd_acp_private *)acp_dev; +amd_acp_suspend (acp_prv); +} + +void amd_acp_pcm_resume (struct amd_acp_device *acp_dev) +{ +struct amd_acp_private *acp_prv; + + acp_prv = (struct amd_acp_private *)acp_dev; +amd_acp_resume (acp_prv); +} +int amd_acp_hw_init (void *cgs_device,unsigned acp_version_major,unsigned acp_version_minor,struct amd_acp_private **acp_private)
@@ -962,6 +1064,9 @@ int amd_acp_hw_init(void *cgs_device, (*acp_private)->public.i2s_start = i2s_start; (*acp_private)->public.i2s_stop = i2s_stop; + (*acp_private)->public.acp_suspend = amd_acp_pcm_suspend; + (*acp_private)->public.acp_resume = amd_acp_pcm_resume; +return 0 ; }
@@ -973,10 +1078,19 @@ int amd_acp_hw_fini(struct amd_acp_private *acp_private)void amd_acp_suspend (struct amd_acp_private *acp_private) { -/* TODO */ +acp_suspend_tile (acp_private,ACP_TILE_P2 ); +acp_suspend_tile (acp_private,ACP_TILE_P1 ); }void amd_acp_resume (struct amd_acp_private *acp_private) { -/* TODO */ +acp_resume_tile (acp_private,ACP_TILE_P1 ); +acp_resume_tile (acp_private,ACP_TILE_P2 ); + +acp_init (acp_private); + +/* Disable DSPs which are not going to be used */ +acp_suspend_tile (acp_private,ACP_TILE_DSP0 ); +acp_suspend_tile (acp_private,ACP_TILE_DSP1 ); +acp_suspend_tile (acp_private,ACP_TILE_DSP2 ); }
drivers/gpu/drm/amd/acp/acp_hw.h +19 -0
@@ -40,6 +40,25 @@#define FROM_ACP_I2S_1 0xa#define FROM_ACP_I2S_2 0xb +#define ACP_TILE_ON_MASK 0x03 +#define ACP_TILE_OFF_MASK 0x02 +#define ACP_TILE_ON_RETAIN_REG_MASK 0x1f +#define ACP_TILE_OFF_RETAIN_REG_MASK 0x20 + +#define ACP_TILE_P1_MASK 0x3e +#define ACP_TILE_P2_MASK 0x3d +#define ACP_TILE_DSP0_MASK 0x3b +#define ACP_TILE_DSP1_MASK 0x37 +#define ACP_TILE_DSP2_MASK 0x2f + +enum { +ACP_TILE_P1 =0 , +ACP_TILE_P2 , +ACP_TILE_DSP0 , +ACP_TILE_DSP1 , +ACP_TILE_DSP2 , +}; +enum {STREAM_PLAYBACK =0 ,STREAM_CAPTURE ,
drivers/gpu/drm/amd/acp/include/amd_acp.h +18 -0
@@ -189,8 +189,26 @@ struct amd_acp_device {*/ void (*i2s_stop)(struct amd_acp_device *acp_dev,int direction); +/** +* acp_suspend() - Power off ACP +* @acp_dev: acp device +* +* Switch off power tiles of ACP +*/ +void (*acp_suspend)(struct amd_acp_device *acp_dev); + +/** +* acp_resume() - Power on ACP +* @acp_dev: acp device +* +* Switch on power tiles of ACP +*/ + +void (*acp_resume)(struct amd_acp_device *acp_dev); +/* TODO: Need callback registration interface for asynchronous * notifications */ + };#endif /* _AMD_ACP_H */
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 12/12 drm/amd: remove amd gnb bus default runtime pm ops
In reply to Alex DeucherFrom: Maruthi Srinivas Bayyavarapu <[email protected]>
with the default gnb bus runtime pm ops, alsa pcm device attached to it is unable to get runtime suspended/resumed.
--- drivers/gpu/drm/amd/bus/amd_gnb_bus.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/gpu/drm/amd/bus/amd_gnb_bus.c +0 -5
@@ -142,11 +142,6 @@ static const struct dev_pm_ops amd_gnb_bus_device_pm_ops = { .thaw = amd_gnb_bus_device_pm_thaw, .poweroff = amd_gnb_bus_device_pm_poweroff, .restore = amd_gnb_bus_device_pm_restore, -SET_RUNTIME_PM_OPS ( - pm_generic_runtime_suspend, - pm_generic_runtime_resume, - pm_runtime_idle - ) };/* The bus should only be registered by the first amd_gnb, but further
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel