platform/kernel/linux-starfive.git
18 months agodrm/amdgpu: Use unique doorbell range per xcc
Lijo Lazar [Thu, 19 Jan 2023 09:17:22 +0000 (14:47 +0530)]
drm/amdgpu: Use unique doorbell range per xcc

Program different ranges in each XCC with MEC_DOORBELL_RANGE_LOWER/HIGHER.
Keeping the same range causes CPF in other XCCs also to be busy when an IB
packet is submitted to KCQ. Only the XCC which processes the packet
comes back to idle afterwards and this causes other CPs not be idle.
This in turn affects clockgating behavior as RLC doesn't get idle
interrupt.

LOWER/HIGHER covers only KIQ/KCQs which are per XCC queues. Assigning
different ranges doesn't seem to have any side effect as user queue ranges
are outside of this range. User queue tests - PM4 through KFD and AQL
through rocr - have the same results after this change.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Keep SDMAv4.4.2 active during reset
Lijo Lazar [Tue, 17 Jan 2023 11:24:49 +0000 (16:54 +0530)]
drm/amdgpu: Keep SDMAv4.4.2 active during reset

During ASIC wide reset, SDMA shouldn't be clockgated and be ready to
accept freeze requests from PMFW. For that, don't stop SDMA engine
during reset and keep the clocks active.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: Report XGMI IOLINKs for GFXIP9.4.3
Rajneesh Bhardwaj [Thu, 5 Jan 2023 16:39:34 +0000 (11:39 -0500)]
drm/amdkfd: Report XGMI IOLINKs for GFXIP9.4.3

GFXIP 9.4.3 could be in APU or carveout mode but we cannot use the
xgmi.connected_to_cpu flag to identify the iolinks type. Use appropriate
APU or Carveout mode based condition to report xgmi connection in kfd
topology.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: add num_xcps return
James Zhu [Tue, 10 Jan 2023 14:05:35 +0000 (09:05 -0500)]
drm/amdgpu: add num_xcps return

Add num_xcps return.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: increase AMDGPU_MAX_HWIP_RINGS
James Zhu [Tue, 10 Jan 2023 14:01:33 +0000 (09:01 -0500)]
drm/amdgpu: increase AMDGPU_MAX_HWIP_RINGS

[WA] Increase AMDGPU_MAX_HWIP_RINGS to 64 to support more compute
ring resource. Later need redesign with queue/prirority/scheduler
factors to reduce AMDGPU_MAX_HWIP_RINGS.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: vcn_v4_0_3 load vcn fw once for all AIDs
James Zhu [Tue, 20 Dec 2022 01:11:11 +0000 (20:11 -0500)]
drm/amdgpu: vcn_v4_0_3 load vcn fw once for all AIDs

Signed-off-by: James Zhu <James.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Populate VCN/JPEG harvest information
Lijo Lazar [Tue, 10 Jan 2023 04:22:53 +0000 (09:52 +0530)]
drm/amdgpu: Populate VCN/JPEG harvest information

Certain instances of VCN/JPEG IPs may not be usable. Fetch the information
from harvest table.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Correct dGPU MTYPE settings for gfx943
Graham Sider [Thu, 5 Jan 2023 15:58:07 +0000 (10:58 -0500)]
drm/amdgpu: Correct dGPU MTYPE settings for gfx943

Revert temporary dGPU VRAM MTYPE setting and align with expected
coherency protocol.

Signed-off-by: Graham Sider <Graham.Sider@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Remove SMU powergate message call for SDMA
Asad kamal [Tue, 3 Jan 2023 05:14:58 +0000 (13:14 +0800)]
drm/amdgpu: Remove SMU powergate message call for SDMA

SDMA v4.4.2 doesn't need explicit power gating control through PMFW

Signed-off-by: Asad kamal <asad.kamal@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: enable vcn/jpeg on vcn_v4_0_3
James Zhu [Sun, 18 Dec 2022 00:44:15 +0000 (19:44 -0500)]
drm/amdgpu: enable vcn/jpeg on vcn_v4_0_3

Enable vcn/jpeg on vcn_v4_0_3.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: enable indirect_sram mode on vcn_v4_0_3
James Zhu [Mon, 12 Dec 2022 18:14:05 +0000 (13:14 -0500)]
drm/amdgpu: enable indirect_sram mode on vcn_v4_0_3

Enable indirect_sram mode on vcn_v4_0_3.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: add unified queue support on vcn_v4_0_3
James Zhu [Sat, 17 Dec 2022 15:51:04 +0000 (10:51 -0500)]
drm/amdgpu: add unified queue support on vcn_v4_0_3

Add unified queue support on vcn_v4_0_3.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: add fwlog support on vcn_v4_0_3
James Zhu [Mon, 12 Dec 2022 17:31:23 +0000 (12:31 -0500)]
drm/amdgpu: add fwlog support on vcn_v4_0_3

Add fwlog support on vcn_v4_0_3.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: increase MAX setting to hold more jpeg instances
James Zhu [Mon, 12 Dec 2022 17:29:04 +0000 (12:29 -0500)]
drm/amdgpu: increase MAX setting to hold more jpeg instances

vcn_v4_0_3 increased jpeg instances,
need increasing MAX resources setting accordlingly.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Use discovery to get XCC/SDMA mask
Lijo Lazar [Mon, 28 Nov 2022 06:32:14 +0000 (12:02 +0530)]
drm/amdgpu: Use discovery to get XCC/SDMA mask

Get information about active XCC and SDMAs from discovery table.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Make VRAM discovery read optional
Lijo Lazar [Thu, 1 Dec 2022 11:57:47 +0000 (17:27 +0530)]
drm/amdgpu: Make VRAM discovery read optional

When overridden with module param, directly read discovery info
from discovery binary instead of reading from VRAM.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Allocate GART table in RAM for AMD APU
Felix Kuehling [Tue, 29 Nov 2022 17:45:26 +0000 (12:45 -0500)]
drm/amdgpu: Allocate GART table in RAM for AMD APU

Some AMD APUs may not have a dedicated VRAM. On such platforms the GART
table should be allocated on the system memory. When real vram size is
zero, place the GART table in system memory and create an SG BO to make
it GPU accessible.

v2: fix includes

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
(rajneesh: removed set_memory_wc workaround)
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add FGCG logic for GFX v9.4.3
Lijo Lazar [Tue, 20 Dec 2022 08:51:57 +0000 (14:21 +0530)]
drm/amdgpu: Add FGCG logic for GFX v9.4.3

Add logic for fine grain clock gating logic for GFX v9.4.3. The feature
will be controlled using CG flags. Also, make a change so that RLC safe
mode entry/exit is done only once during CG update sequence.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Make UTCL2 snoop CPU caches
Rajneesh Bhardwaj [Tue, 20 Dec 2022 20:37:57 +0000 (15:37 -0500)]
drm/amdgpu: Make UTCL2 snoop CPU caches

On AMD APP APUs, to make UTCL2 snoop CPU caches, its not sufficient to
rely on xgmi connected flag so add the logic to use is_app_apu to
program the PDE_REQUEST_PHYSICAL bit correctly for gfxhub and mmhub
both.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agoamd/amdgpu: Set MTYPE_UC for access over PCIe
Amber Lin [Mon, 28 Nov 2022 16:26:02 +0000 (11:26 -0500)]
amd/amdgpu: Set MTYPE_UC for access over PCIe

For GFX v9_4_3, set MTYPE_UC for memory access over PCIe.

v4 - add missing indentation pointed out by Felix and add his
reviewed-by tag.
v3 - add missing logic for the svm path.
v2 - add amdgpu_xgmi_same_hive to separate access over xgmi from pcie

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Amber Lin <Amber.Lin@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix GFX v9.4.3 EOP buffer allocation
Lijo Lazar [Mon, 19 Dec 2022 12:09:42 +0000 (17:39 +0530)]
drm/amdgpu: Fix GFX v9.4.3 EOP buffer allocation

Each compute cluster gets 8 compute queues in GFX v9.4.3. Fix the EOP
buffer allocation so that compute queue on every XCC gets a unique
address.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Tested-and-Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix GFX 9.4.3 dma address capability
Lijo Lazar [Thu, 15 Dec 2022 07:43:29 +0000 (13:13 +0530)]
drm/amdgpu: Fix GFX 9.4.3 dma address capability

ASICs with GFX 9.4.3 support 48-bit addressing.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix semaphore release
Lijo Lazar [Wed, 14 Dec 2022 04:58:50 +0000 (10:28 +0530)]
drm/amdgpu: Fix semaphore release

Use the right register for semaphore release during invalidation.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: Setup current_logical_xcc_id in MQD
Mukul Joshi [Fri, 9 Dec 2022 14:03:01 +0000 (09:03 -0500)]
drm/amdkfd: Setup current_logical_xcc_id in MQD

Setup rolling current_logical_xcc_id in MQD for GFX9.4.3
to ensure each queue starts at a different place and prevent
hotspotting issues. Also, remove updating current_logical_xcc_id
during queue update.

Suggested-by: Joseph Greathouse <Joseph.Greathouse@amd.com>
Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Remove unnecessary return value check
Lijo Lazar [Thu, 1 Dec 2022 11:52:01 +0000 (17:22 +0530)]
drm/amdgpu: Remove unnecessary return value check

There is no need to check return value, as the function internally
used - amdgpu_discovery_read_binary_from_vram() - returns void.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: correct the vmhub index when page fault occurs
Le Ma [Fri, 9 Dec 2022 11:44:05 +0000 (19:44 +0800)]
drm/amdgpu: correct the vmhub index when page fault occurs

The AMDGPU_GFXHUB was bind to each xcc in the logical order.
Thus convert the node_id to logical xcc_id to index the
correct AMDGPU_GFXHUB. And "node_id / 4" can get the correct
AMDGPU_MMHUB0 index.

Signed-off-by: Le Ma <le.ma@amd.com>
Tested-by: Asad kamal <asad.kamal@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: Update packet manager for GFX9.4.3
Mukul Joshi [Thu, 8 Dec 2022 17:08:17 +0000 (12:08 -0500)]
drm/amdkfd: Update packet manager for GFX9.4.3

In GFX 9.4.3, there can be more than 8 SDMA engines.
As a result, extended_engine_sel and engine_sel fields
in MAP_QUEUES packet need to be updated to allow correct
mapping of SDMA queues to these SDMA engines.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: set MTYPE in PTE for GFXIP 9.4.3
Rajneesh Bhardwaj [Wed, 7 Dec 2022 05:29:40 +0000 (00:29 -0500)]
drm/amdgpu: set MTYPE in PTE for GFXIP 9.4.3

Apply the GFXIP 9.4.3 specific snoop and mtype settings for various
scenarios such as APU, APU in Carveout mode and dGPU mode.

Note: This is expected to change due to:
1 - NPS > 1 support in future
2 - Hardware bugs found during initial asic bringup.

Cc: Graham Sider <graham.sider@amd.com>
Cc: Hawking Zhang <hawking.zhang@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Use mask for active clusters
Lijo Lazar [Tue, 29 Nov 2022 08:30:37 +0000 (14:00 +0530)]
drm/amdgpu: Use mask for active clusters

Use a mask of available active clusters instead of using only the number
of active clusters.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Derive active clusters from SDMA
Lijo Lazar [Mon, 28 Nov 2022 05:47:15 +0000 (11:17 +0530)]
drm/amdgpu: Derive active clusters from SDMA

SDMA instances per active cluster and SDMA instance mask are used
to find the number of active clusters.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Move generic logic to soc config
Lijo Lazar [Mon, 28 Nov 2022 04:27:51 +0000 (09:57 +0530)]
drm/amdgpu: Move generic logic to soc config

Move soc specific configuration details to aqua vanjaram specific file.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix the KCQ hang when binding back
Shiwu Zhang [Fri, 18 Nov 2022 06:21:15 +0000 (14:21 +0800)]
drm/amdgpu: Fix the KCQ hang when binding back

Just like the KIQ, KCQ need to clear the doorbell related regs as well
to avoid hangs when to load driver again after unloading.

Signed-off-by: Shiwu Zhang <shiwu.zhang@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Skip TMR allocation if not required
Lijo Lazar [Thu, 24 Nov 2022 08:53:58 +0000 (14:23 +0530)]
drm/amdgpu: Skip TMR allocation if not required

On ASICs with PSPv13.0.6, TMR is reserved at boot time. There is no need
to allocate TMR region by driver. However, it's still required to send
SETUP_TMR command to PSP.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add XCP IP callback funcs for each IP
Lijo Lazar [Fri, 23 Sep 2022 11:45:15 +0000 (17:15 +0530)]
drm/amdgpu: Add XCP IP callback funcs for each IP

Initialize with the IP specific functions needed for GFXHUB, GFX and
SDMA.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add XCP functions for GFX v9.4.3
Lijo Lazar [Fri, 23 Sep 2022 11:18:43 +0000 (16:48 +0530)]
drm/amdgpu: Add XCP functions for GFX v9.4.3

Add functions to suspend/resume GFX instances belonging to an XCP.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add SDMA v4.4.2 XCP funcs
Lijo Lazar [Fri, 23 Sep 2022 10:10:15 +0000 (15:40 +0530)]
drm/amdgpu: Add SDMA v4.4.2 XCP funcs

Add functions required to suspend/resume instances of SDMA which
are part of an XCP.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add GFXHUB v1.2 XCP funcs
Lijo Lazar [Fri, 23 Sep 2022 09:50:08 +0000 (15:20 +0530)]
drm/amdgpu: Add GFXHUB v1.2 XCP funcs

Add functions required for suspend/resume of GFXHUB instances which are
part of an XCP.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Switch to SOC partition funcs
Lijo Lazar [Wed, 16 Nov 2022 11:45:47 +0000 (17:15 +0530)]
drm/amdgpu: Switch to SOC partition funcs

For GFXv9.4.3, use SOC level partition switch implementation rather than
keeping them at GFX IP level. Change the exisiting implementation in
GFX IP for keeping partition mode and restrict it to only GFX related
switch.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add soc config init for GC9.4.3 ASICs
Lijo Lazar [Fri, 23 Sep 2022 09:13:17 +0000 (14:43 +0530)]
drm/amdgpu: Add soc config init for GC9.4.3 ASICs

Add function to initialize soc configuration information for GC 9.4.3
ASICs. Use it to map IPs and other SOC related information once IP
configuration information is available through discovery.

For GC9.4.3 compute partition related callbacks are initialized as part
of configuration init.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add SOC partition funcs for GC v9.4.3
Lijo Lazar [Mon, 19 Sep 2022 12:04:02 +0000 (17:34 +0530)]
drm/amdgpu: Add SOC partition funcs for GC v9.4.3

Switching the partition mode configuration of ASIC is SOC
level function rather than something at GFX core level. Add
partition mode switch functions as SOC specific callbacks.
Implement the XCP manager callbacks needed for partition
switch for GC 9.4.3 based ASICs.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add initial version of XCP routines
Lijo Lazar [Fri, 16 Sep 2022 07:13:35 +0000 (12:43 +0530)]
drm/amdgpu: Add initial version of XCP routines

Within a device, an accelerator core partition can be constituted with
different IP instances. These partitions are spatial in nature. Number
of partitions which can exist at the same time depends on the 'partition
mode'. Add a manager entity which is responsible for switching between
different partition modes and maintaining partitions. It is also
responsible for suspend/resume of different partitions.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add sdma instance specific functions
Lijo Lazar [Wed, 14 Sep 2022 07:18:08 +0000 (12:48 +0530)]
drm/amdgpu: Add sdma instance specific functions

SDMA 4.4.2 supports multiple instances. Add functions to support
handling of each SDMA instance separately.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add xcc specific functions for gfxhub
Lijo Lazar [Wed, 14 Sep 2022 06:46:48 +0000 (12:16 +0530)]
drm/amdgpu: Add xcc specific functions for gfxhub

GFXHUB 1.2 supports multiple XCC instances. Add XCC specific functions
to handle XCC instances separately.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add xcc specific functions
Lijo Lazar [Wed, 16 Nov 2022 05:17:18 +0000 (10:47 +0530)]
drm/amdgpu: Add xcc specific functions

Add more XCC specific functions and use them from IP block functions.
RLC, CP functions are further split to have xcc specific versions.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Rename xcc specific functions
Lijo Lazar [Wed, 20 Jul 2022 08:15:30 +0000 (13:45 +0530)]
drm/amdgpu: Rename xcc specific functions

Add 'xcc' prefix to xcc specific functions to distinguish from IP block
functions.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Check APU supports true APP mode
Rajneesh Bhardwaj [Wed, 9 Nov 2022 04:04:30 +0000 (23:04 -0500)]
drm/amdgpu: Check APU supports true APP mode

On GPXIP 9.4.3 APU, in no carveout mode there is no real vram heap and
could be emulated by the driver over the interleaved NUMA system memory
and the APU could also  be in the carveout mode during early development
stage or otherwise for debugging purpose so introduce a new member in
amdgpu_gmc to figure out whether the APU is in the native mode as per
the production configuration. AMD_IS_APU cannot be used for Accelerated
Processing Platform APUs as it might be used in a different context on
previous generations or on small APUs.

Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Tested-by: Graham Sider <graham.sider@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: more GPU page fault info for GC v9.4.3
Philip Yang [Mon, 14 Nov 2022 22:35:43 +0000 (17:35 -0500)]
drm/amdgpu: more GPU page fault info for GC v9.4.3

Output IH cookie node_id and translate it to the corresponding AID id
and XCC id, to help debug the GPU page fault.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: remove partition attributes sys file for gfx_v9_4_3
Shiwu Zhang [Mon, 14 Nov 2022 07:52:19 +0000 (15:52 +0800)]
drm/amdgpu: remove partition attributes sys file for gfx_v9_4_3

For driver de-init like rmmod operations those partition specific
attributes need to be removed accordingly.

Signed-off-by: Shiwu Zhang <shiwu.zhang@amd.com>
Reviewed-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: fix kcq mqd_backup buffer double free for multi-XCD
Shiwu Zhang [Fri, 11 Nov 2022 07:54:52 +0000 (15:54 +0800)]
drm/amdgpu: fix kcq mqd_backup buffer double free for multi-XCD

For gfx_v9_4_3 and beyond, struct kiq has its own mqd_backup pointer
rather than using the last pointer from mec struct. Then the kfree
operation on the pointer from the mec struct should be removed otherwise
it will cause double free on the first kcq's mqd_backup buffer on XCD1.

Signed-off-by: Shiwu Zhang <shiwu.zhang@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Skip runtime db read for PSP 13.0.6
Lijo Lazar [Sat, 12 Nov 2022 11:00:40 +0000 (16:30 +0530)]
drm/amdgpu: Skip runtime db read for PSP 13.0.6

Skip reading runtime db information for PSP 13.0.6.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: fix vm context register assignment in mmhub v1.8
Le Ma [Sat, 12 Nov 2022 09:01:05 +0000 (17:01 +0800)]
drm/amdgpu: fix vm context register assignment in mmhub v1.8

Assign the vm context register addr per aid instance.

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Revert programming of CP_PSP_XCP_CTL
Lijo Lazar [Wed, 9 Nov 2022 14:17:38 +0000 (19:47 +0530)]
drm/amdgpu: Revert programming of CP_PSP_XCP_CTL

Programming of this register is taken care by PSP. Incorrect programming
causes CP not to detect its XCC.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reported-by: Alexander Turek <Alexander.Turek@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: detect current GPU memory partition mode
Rajneesh Bhardwaj [Tue, 5 Apr 2022 17:00:13 +0000 (13:00 -0400)]
drm/amdgpu: detect current GPU memory partition mode

 - Add helpers to detect the current GPU memory partition.
 - Add current memory partition mode sysfs node.

Tested-by: Ori Messinger <Ori.Messinger@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: init smuio funcs for smuio v13_0_3
Hawking Zhang [Tue, 23 Nov 2021 14:27:17 +0000 (22:27 +0800)]
drm/amdgpu: init smuio funcs for smuio v13_0_3

Add callbacks for SMUIO 13.0.3

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: implement smuio v13_0_3 callbacks
Rajneesh Bhardwaj [Wed, 13 Apr 2022 03:33:20 +0000 (23:33 -0400)]
drm/amdgpu: implement smuio v13_0_3 callbacks

Add smuio v13_0_3 callbacks for SMUIO.

Tested-by: Ori Messinger <Ori.Messinger@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: add smuio v13_0_3 ip headers
Hawking Zhang [Sun, 24 Apr 2022 07:23:08 +0000 (15:23 +0800)]
drm/amdgpu: add smuio v13_0_3 ip headers

Add smuio v13_0_3 register offset and shift masks
header files

v2: update headers (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: retire render backend setup from gfx_v9_4_3
Hawking Zhang [Mon, 7 Nov 2022 03:11:29 +0000 (11:11 +0800)]
drm/amdgpu: retire render backend setup from gfx_v9_4_3

gfx v9_4_3 only support compute. render backend
doesn't need to be involved in any compute shader
execution.

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amd/amdgpu: Update debugfs for XCC support (v3)
Tom St Denis [Tue, 11 Oct 2022 13:52:58 +0000 (09:52 -0400)]
drm/amd/amdgpu: Update debugfs for XCC support (v3)

This patch updates the 'regs2' interface for MMIO
registers to add a new IOCTL command for a 'v2' state
data that includes the XCC ID.

This patch then updates amdgpu_gfx_select_se_sh()
and amdgpu_gfx_select_me_pipe_q() (and the implementations
in the gfx drivers) to support an additional parameter.

This patch then creates a new debugfs interface "gprwave"
which is a merge of shader GPR and wave status access.  This
new inteface uses an IOCTL to select banks as well as XCC identity.

(v2) Fix missing xcc_id in wave_ind function

(v3) Fix pm runtime calls and mutex locking

(v4) Fix bad label

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add SDMA v4.4.2 golden settings
Lijo Lazar [Mon, 31 Oct 2022 05:16:05 +0000 (10:46 +0530)]
drm/amdgpu: Add SDMA v4.4.2 golden settings

Add programming of SDMA golden settings for v4.4.2

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: init gfx_v9_4_3 external_rev_id
Hawking Zhang [Sun, 23 Oct 2022 12:27:59 +0000 (20:27 +0800)]
drm/amdgpu: init gfx_v9_4_3 external_rev_id

it is used for user space driver to identify gfx_v9_4_3 chip

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix interrupt handling in GFX v9.4.3
Lijo Lazar [Fri, 14 Oct 2022 07:36:18 +0000 (13:06 +0530)]
drm/amdgpu: Fix interrupt handling in GFX v9.4.3

IH follows a different identification scheme for its clients. Get the
right mapping of xcc instance from IH node id.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Le Ma <le.ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: consolidate the access helpers in nbio v7_9
Le Ma [Thu, 22 Sep 2022 07:46:54 +0000 (15:46 +0800)]
drm/amdgpu: consolidate the access helpers in nbio v7_9

Use WREG32_SOC15_EXT to write registers with address larger than 32bit.

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: add helpers to access registers on different AIDs
Le Ma [Tue, 27 Sep 2022 09:51:33 +0000 (17:51 +0800)]
drm/amdgpu: add helpers to access registers on different AIDs

SMN address which is larger than 32bit has different indications
through bit[34:32] on different AIDs.

v2: put smn addressing of different AIDs into asic specific place
v3: change to ext_id/ext_offset naming

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: parse base address from new ip discovery with 64bit ip base address
Le Ma [Tue, 27 Sep 2022 09:26:27 +0000 (17:26 +0800)]
drm/amdgpu: parse base address from new ip discovery with 64bit ip base address

Truncate the 64bit base address from ip discovery and only store lower 32bit
ip base in reg_offset[].

Bits > 32 follows ASIC specific format, thus just discard them and handle it
within specific ASIC.

By this way reg_offset[] and related helpers can stay unchanged.

v2: make comments more generic

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: upgrade amdgpu_discovery struct ip to ip_v4
Le Ma [Wed, 7 Sep 2022 13:17:03 +0000 (21:17 +0800)]
drm/amdgpu: upgrade amdgpu_discovery struct ip to ip_v4

version 4 supports 64bit ip base address

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: do some register access cleanup in nbio v7_9
Le Ma [Tue, 20 Sep 2022 07:14:48 +0000 (15:14 +0800)]
drm/amdgpu: do some register access cleanup in nbio v7_9

Use WREG_SOC15x() instead of WREG32(SOC15_REG_OFFSET())

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: extend max instances
Le Ma [Wed, 14 Sep 2022 07:07:23 +0000 (15:07 +0800)]
drm/amdgpu: extend max instances

Number of instances is extended.

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: increase DISCOVERY_TMR_SIZE
Le Ma [Tue, 6 Sep 2022 07:22:44 +0000 (15:22 +0800)]
drm/amdgpu: increase DISCOVERY_TMR_SIZE

New ip_discovery binary size is increased.

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: update ip discovery header to v4
Le Ma [Wed, 31 Aug 2022 09:11:59 +0000 (17:11 +0800)]
drm/amdgpu: update ip discovery header to v4

version 4 supports 64bit ip base address

Signed-off-by: Le Ma <le.ma@amd.com>
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: switch to aqua_vanjaram_doorbell_index_init
Le Ma [Tue, 24 May 2022 11:44:27 +0000 (19:44 +0800)]
drm/amdgpu: switch to aqua_vanjaram_doorbell_index_init

New doorbell index assignment is used by aqua_vanjaram.

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Use SDMA instance table for aqua vanjaram
Lijo Lazar [Wed, 29 Jun 2022 15:34:39 +0000 (21:04 +0530)]
drm/amdgpu: Use SDMA instance table for aqua vanjaram

For aqua vanjaram, add mapping for logical to physical
instances.

v2:
Register accesses on bare metal should be based on physical
instance. Use GET_INST() to get physical instance.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add mask for SDMA instances
Lijo Lazar [Wed, 29 Jun 2022 10:56:49 +0000 (16:26 +0530)]
drm/amdgpu: Add mask for SDMA instances

Add a mask of SDMA instances available for use. On certain ASIC configs,
not all SDMA instances are available for software use.

v2:
Change sdma mask type to uint32_t (Le)

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add IP instance map for aqua vanjaram
Lijo Lazar [Wed, 29 Jun 2022 10:15:06 +0000 (15:45 +0530)]
drm/amdgpu: Add IP instance map for aqua vanjaram

Add XCC logical to physical instance map for aqua vanjaram

v2:
Keep look up table only for required IPs, for others return
default mapping (Felix).

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: add new doorbell assignment table for aqua_vanjaram
Le Ma [Mon, 25 Apr 2022 14:19:58 +0000 (22:19 +0800)]
drm/amdgpu: add new doorbell assignment table for aqua_vanjaram

Four basic reasons as below to do the change:
  1. number of ring expand a lot on aqua_vanjaram, and adjustment on old
     assignment cannot make each ring in a continuous doorbell space.
  2. the SDMA doorbell index should not exceed 0x1FF on aqua_vanjaram due to
     regDOORBELLx_CTRL_ENTRY.BIF_DOORBELLx_RANGE_OFFSET_ENTRY field width.
  3. re-design the doorbell assignment and unify the calculation as
     "start + ring/inst id" will make the code much concise.
  4. only defining the START/END makes the table look simple

v2: (Lijo)
  1. replace name
  2. use num_inst_per_aid/sdma_doorbell_range instead of hardcoding

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix register access on GC v9.4.3
Lijo Lazar [Mon, 19 Sep 2022 12:38:25 +0000 (18:08 +0530)]
drm/amdgpu: Fix register access on GC v9.4.3

In GC v9.4.3 there are multiple XCCs. It's required to use
physical instance number to get the right register offset. Use
GET_INST API for that.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix programming of initial XCP mode
Lijo Lazar [Thu, 6 Oct 2022 09:55:08 +0000 (15:25 +0530)]
drm/amdgpu: Fix programming of initial XCP mode

On initialization set the partition mode correctly to SPX (default) or
any other user specified partition mode. Use switch_compute_partition
API so that all settings are initialized correctly.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: Update interrupt handling for GFX9.4.3
Mukul Joshi [Fri, 30 Sep 2022 13:16:21 +0000 (09:16 -0400)]
drm/amdkfd: Update interrupt handling for GFX9.4.3

Update interrupt handling in CPX mode for GFX9.4.3 by using the
VMID space instead of SDMA client id to determine if an interrupt
should be processed by a KFD node. This is especially needed for
handling retry faults from MMHUB.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix failure when switching to DPX mode
Mukul Joshi [Thu, 29 Sep 2022 16:07:49 +0000 (12:07 -0400)]
drm/amdgpu: Fix failure when switching to DPX mode

Fix the if condition which causes dynamic repartitioning
to fail when trying to switch to DPX mode.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Amber Lin <Amber.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: Use instance table for GFX 9.4.3
Mukul Joshi [Tue, 13 Sep 2022 19:13:18 +0000 (15:13 -0400)]
drm/amdkfd: Use instance table for GFX 9.4.3

For GFX 9.4.3, use the logical to physical mapping table,
to get the correct XCD instance when accessing registers on
bare metal.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Amber Lin <Amber.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix SWS on multi-XCD GPU
Amber Lin [Tue, 12 Apr 2022 19:37:15 +0000 (15:37 -0400)]
drm/amdgpu: Fix SWS on multi-XCD GPU

GFX_9_4_3 supports multi-XCDs and multi-AIDs in one GPU device. SWS needs
to program IH_VMID_x_LUT with specified XCC instance and corresponded
AID instance.

Signed-off-by: Amber Lin <Amber.Lin@amd.com>
Reviewed-by: Mukul Joshi <mukul.joshi@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: drop redundant csb init for gfx943
Le Ma [Thu, 25 Aug 2022 07:51:43 +0000 (15:51 +0800)]
drm/amdgpu: drop redundant csb init for gfx943

It's not required for compute pipeline and will cause soft lockup on emulation
due to long-time writing.

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: adjust s2a entry register for sdma doorbell trans decoding
Le Ma [Wed, 24 Aug 2022 09:41:47 +0000 (17:41 +0800)]
drm/amdgpu: adjust s2a entry register for sdma doorbell trans decoding

Use s2a entry 5/6 registers to decode sdma doorbell trans on different AIDs,
which aligns the entry table in SHUB spec, and leave entry 4 dedicated for VCN
doorbell to avoid conflict.

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: Update SMI events for GFX9.4.3
Mukul Joshi [Tue, 9 Aug 2022 18:56:53 +0000 (14:56 -0400)]
drm/amdkfd: Update SMI events for GFX9.4.3

On GFX 9.4.3, there can be multiple KFD nodes. As a result,
SMI events for SVM, queue evict/restore should be raised for
each node independently.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Use status register for partition mode
Lijo Lazar [Mon, 8 Aug 2022 05:50:36 +0000 (11:20 +0530)]
drm/amdgpu: Use status register for partition mode

Program partition status register to reflect the current partition mode.
Partition capability register is for capability and is a one-time setting.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: pass kfd_node ref to svm migration api
Alex Sierra [Tue, 24 May 2022 15:22:12 +0000 (10:22 -0500)]
drm/amdkfd: pass kfd_node ref to svm migration api

This work is required for GC 9.4.3, previous to support memory
partitions per node at SVM. When multiple partition is configured,
every BO should be allocated inside one specific partition which
corresponds to the current amdgpu_device and kfd_node.

v2: squash in compilation fix (Alex)
v3: squash in fix for pre-gfx 9.4.3 (Alex)
v4: squash in best_loc fix (Alex)

Signed-off-by: Alex Sierra <alex.sierra@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Conform to SET_UCONFIG_REG spec
Lijo Lazar [Fri, 29 Jul 2022 09:26:59 +0000 (14:56 +0530)]
drm/amdgpu: Conform to SET_UCONFIG_REG spec

The packet expects only 16 bits register offset. Hence pass register
offset which is local to each XCC.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu/vcn: add vcn multiple AIDs support
James Zhu [Mon, 11 Jul 2022 15:06:46 +0000 (11:06 -0400)]
drm/amdgpu/vcn: add vcn multiple AIDs support

add vcn multiple AIDs support.

v2: squash in FW setting fix (Alex)

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu/vcn: update clock gate setting for VCN 4.0.3
James Zhu [Mon, 11 Jul 2022 15:05:05 +0000 (11:05 -0400)]
drm/amdgpu/vcn: update clock gate setting for VCN 4.0.3

Update clock gate setting.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu/jpeg: add JPEG multiple AIDs support
James Zhu [Sat, 2 Jul 2022 23:53:36 +0000 (19:53 -0400)]
drm/amdgpu/jpeg: add JPEG multiple AIDs support

Add JPEG multiple AIDs support.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu/nbio: add vcn doorbell multiple AIDs support
James Zhu [Sat, 2 Jul 2022 23:39:34 +0000 (19:39 -0400)]
drm/amdgpu/nbio: add vcn doorbell multiple AIDs support

Update vcn doorbell range to support multiple AIDs.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Acked-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Fix GRBM programming sequence
Lijo Lazar [Wed, 6 Jul 2022 08:20:45 +0000 (13:50 +0530)]
drm/amdgpu: Fix GRBM programming sequence

It needs to be done only for XCC instances in non-AID0. Use the physical
instance to determine non-AID0 XCC instances.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Use instance table for sdma 4.4.2
Lijo Lazar [Wed, 29 Jun 2022 15:34:39 +0000 (21:04 +0530)]
drm/amdgpu: Use instance table for sdma 4.4.2

For ASICs with sdma IP v4.4.2, add mapping for logical to physical
instances.

v2:
Register accesses on bare metal should be based on physical
instance. Use GET_INST() to get physical instance.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add mask for SDMA instances
Lijo Lazar [Wed, 29 Jun 2022 10:56:49 +0000 (16:26 +0530)]
drm/amdgpu: Add mask for SDMA instances

Add a mask of SDMA instances available for use. On certain ASIC configs,
not all SDMA instances are available for software use.

v2:
Change sdma mask type to uint32_t (Le)

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Use instance lookup table for GC 9.4.3
Lijo Lazar [Tue, 5 Jul 2022 04:26:41 +0000 (09:56 +0530)]
drm/amdgpu: Use instance lookup table for GC 9.4.3

Register accesses need to be based on physical instance on bare metal.
Pass the right instance using logical to physical instance lookup
table before accessing registers. Add a macro GET_INST to get the right
physical instance of an IP corresponding to a logical instance.

v2: fix gfx_v9_4_3_check_rlcg_range() (Alex)

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: Add map of logical to physical inst
Lijo Lazar [Wed, 29 Jun 2022 09:29:04 +0000 (14:59 +0530)]
drm/amdgpu: Add map of logical to physical inst

Add a map for logical to physical instances of an IP. For ex: on some device
configurations, the first logical XCC may not be the first physical XCC.
Software may continue to access in logical IP instance order. The map
provides a convenient way to get to the actual physical instance.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Le Ma <Le.Ma@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: Add device repartition support
Mukul Joshi [Fri, 10 Jun 2022 13:41:29 +0000 (09:41 -0400)]
drm/amdkfd: Add device repartition support

GFX9.4.3 will support dynamic repartitioning of the GPU through sysfs.
Add device repartitioning support in KFD to repartition GPU from one
mode to other.

v2: squash in fix ("drm/amdkfd: Fix warning kgd2kfd_unlock_kfd defined but not used")

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: Rework kfd_locked handling
Mukul Joshi [Tue, 31 May 2022 18:39:36 +0000 (14:39 -0400)]
drm/amdkfd: Rework kfd_locked handling

Currently, even if kfd_locked is set, a process is first
created and then removed to work around a race condition
in updating kfd_locked flag. Rework kfd_locked handling to
ensure no processes is created if kfd_locked is set. This
is achieved by updating kfd_locked under kfd_processes_mutex.
With this there is no need for kfd_locked to be an atomic
counter. Instead, it can be a regular integer.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: configure the doorbell settings for sdma on non-AID0
Le Ma [Sat, 2 Apr 2022 12:21:35 +0000 (20:21 +0800)]
drm/amdgpu: configure the doorbell settings for sdma on non-AID0

Configure the sdma doorbell settings on NBIF0 and SYSHUB of each AID

v2: fetch aid_id from amdgpu_sdma_instance (Lijo)

Signed-off-by: Le Ma <le.ma@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdgpu: add indirect r/w interface for smn address greater than 32bits
Le Ma [Sat, 2 Apr 2022 11:39:59 +0000 (19:39 +0800)]
drm/amdgpu: add indirect r/w interface for smn address greater than 32bits

On multiple AIDs platform, bit[34:32] in SMD address is leveraged to access
nonAID0 register smn address and new PCI_INDEX_HI register is introduced
to access the higher bits.

v2: rebase on latest register accessors (Alex)

Signed-off-by: Le Ma <le.ma@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
18 months agodrm/amdkfd: EOP Removal - Handle size 0 correctly
David Belanger [Wed, 16 Feb 2022 17:07:28 +0000 (12:07 -0500)]
drm/amdkfd: EOP Removal - Handle size 0 correctly

On GC 9.4.3, we are removing the EOP buffer.
If we specify 0 for the size, CP_HQD_EOP_CONTROL ends up with
incorrect value as order_size_2 calculations does not handle 0.

Fix it by using zero for the MQD entry for EOP size 0.

v2: Reworked code with a conditional assignment and fixed style issues.

Signed-off-by: David Belanger <david.belanger@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>