]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/amdkfd: Enable processes isolation on gfx9
authorAmber Lin <Amber.Lin@amd.com>
Mon, 29 Apr 2024 20:40:44 +0000 (16:40 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 21 Aug 2024 02:08:07 +0000 (22:08 -0400)
When amdgpu enable enforce_isolation, KFD enables single-process mode in
HWS and sets exec_cleaner_shader bit in MAP_PROCESS.

Signed-off-by: Amber Lin <Amber.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_ai.h
drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_aldebaran.h

index 00776f08351c30ca574f9ec125027c8a42eec407..1f9f5bfeaf8680128e043366f05eab871ec3c290 100644 (file)
@@ -37,11 +37,14 @@ static int pm_map_process_v9(struct packet_manager *pm,
        struct kfd_node *kfd = pm->dqm->dev;
        struct kfd_process_device *pdd =
                        container_of(qpd, struct kfd_process_device, qpd);
+       struct amdgpu_device *adev = kfd->adev;
 
        packet = (struct pm4_mes_map_process *)buffer;
        memset(buffer, 0, sizeof(struct pm4_mes_map_process));
        packet->header.u32All = pm_build_pm4_header(IT_MAP_PROCESS,
                                        sizeof(struct pm4_mes_map_process));
+       if (adev->enforce_isolation[kfd->node_id])
+               packet->bitfields2.exec_cleaner_shader = 1;
        packet->bitfields2.diq_enable = (qpd->is_debug) ? 1 : 0;
        packet->bitfields2.process_quantum = 10;
        packet->bitfields2.pasid = qpd->pqm->process->pasid;
@@ -89,14 +92,18 @@ static int pm_map_process_aldebaran(struct packet_manager *pm,
        struct pm4_mes_map_process_aldebaran *packet;
        uint64_t vm_page_table_base_addr = qpd->page_table_base;
        struct kfd_dev *kfd = pm->dqm->dev->kfd;
+       struct kfd_node *knode = pm->dqm->dev;
        struct kfd_process_device *pdd =
                        container_of(qpd, struct kfd_process_device, qpd);
        int i;
+       struct amdgpu_device *adev = kfd->adev;
 
        packet = (struct pm4_mes_map_process_aldebaran *)buffer;
        memset(buffer, 0, sizeof(struct pm4_mes_map_process_aldebaran));
        packet->header.u32All = pm_build_pm4_header(IT_MAP_PROCESS,
                        sizeof(struct pm4_mes_map_process_aldebaran));
+       if (adev->enforce_isolation[knode->node_id])
+               packet->bitfields2.exec_cleaner_shader = 1;
        packet->bitfields2.diq_enable = (qpd->is_debug) ? 1 : 0;
        packet->bitfields2.process_quantum = 10;
        packet->bitfields2.pasid = qpd->pqm->process->pasid;
@@ -144,17 +151,22 @@ static int pm_runlist_v9(struct packet_manager *pm, uint32_t *buffer,
 
        int concurrent_proc_cnt = 0;
        struct kfd_node *kfd = pm->dqm->dev;
+       struct amdgpu_device *adev = kfd->adev;
 
        /* Determine the number of processes to map together to HW:
         * it can not exceed the number of VMIDs available to the
         * scheduler, and it is determined by the smaller of the number
         * of processes in the runlist and kfd module parameter
         * hws_max_conc_proc.
+        * However, if enforce_isolation is set (toggle LDS/VGPRs/SGPRs
+        * cleaner between process switch), enable single-process mode
+        * in HWS.
         * Note: the arbitration between the number of VMIDs and
         * hws_max_conc_proc has been done in
         * kgd2kfd_device_init().
         */
-       concurrent_proc_cnt = min(pm->dqm->processes_count,
+       concurrent_proc_cnt = adev->enforce_isolation[kfd->node_id] ?
+                       1 : min(pm->dqm->processes_count,
                        kfd->max_proc_per_quantum);
 
        packet = (struct pm4_mes_runlist *)buffer;
index 8b6b2bd5c148fdbc3b35055c30da55c7e165ade9..cd8611401a664113ff0b95735508c1e5c27d870b 100644 (file)
@@ -145,8 +145,9 @@ struct pm4_mes_map_process {
 
        union {
                struct {
-                       uint32_t pasid:16;
-                       uint32_t reserved1:2;
+                       uint32_t pasid:16;              /* 0 - 15  */
+                       uint32_t reserved1:1;           /* 16      */
+                       uint32_t exec_cleaner_shader:1; /* 17      */
                        uint32_t debug_vmid:4;
                        uint32_t new_debug:1;
                        uint32_t reserved2:1;
index 38f5cb6a222ab16b4bf45c193844f670e1246616..e0ed62c4ade047aa76648204a76de6784e384106 100644 (file)
@@ -37,7 +37,7 @@ struct pm4_mes_map_process_aldebaran {
                struct {
                        uint32_t pasid:16;          /* 0 - 15  */
                        uint32_t single_memops:1;   /* 16      */
-                       uint32_t reserved1:1;       /* 17      */
+                       uint32_t exec_cleaner_shader:1;     /* 17      */
                        uint32_t debug_vmid:4;      /* 18 - 21 */
                        uint32_t new_debug:1;       /* 22      */
                        uint32_t tmz:1;             /* 23      */