Sun Dec 19 11:35:07 2021 UTC ()
amdgpu: Take a short pass over amdgpu.


(riastradh)
diff -r1.17 -r1.18 src/sys/external/bsd/drm2/amdgpu/files.amdgpu
diff -r1.5 -r1.6 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h
diff -r1.7 -r1.8 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_df_v3_6.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/os_types.h
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn21/amdgpu_dcn21_hubp.c
diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn21/amdgpu_dcn21_resource.c

cvs diff -r1.17 -r1.18 src/sys/external/bsd/drm2/amdgpu/files.amdgpu (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/amdgpu/files.amdgpu 2021/12/19 11:24:37 1.17
+++ src/sys/external/bsd/drm2/amdgpu/files.amdgpu 2021/12/19 11:35:06 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files.amdgpu,v 1.17 2021/12/19 11:24:37 riastradh Exp $ 1# $NetBSD: files.amdgpu,v 1.18 2021/12/19 11:35:06 riastradh Exp $
2 2
3version 20180827 3version 20180827
4 4
5define amdgpufbbus { } 5define amdgpufbbus { }
6device amdgpu: drmkms, drmkms_pci, drmkms_ttm, amdgpufbbus, firmload 6device amdgpu: drmkms, drmkms_pci, drmkms_ttm, amdgpufbbus, firmload
7attach amdgpu at pci 7attach amdgpu at pci
8 8
9defflag opt_amdgpu_cik.h AMDGPU_CIK 9defflag opt_amdgpu_cik.h AMDGPU_CIK
10 10
11device amdgpufb: amdgpufbbus, drmfb, drmfb_pci, wsemuldisplaydev 11device amdgpufb: amdgpufbbus, drmfb, drmfb_pci, wsemuldisplaydev
12attach amdgpufb at amdgpufbbus 12attach amdgpufb at amdgpufbbus
13makeoptions amdgpufb "CPPFLAGS.amdgpufb"+="${CPPFLAGS.amdgpu}" 13makeoptions amdgpufb "CPPFLAGS.amdgpufb"+="${CPPFLAGS.amdgpu}"
14 14
@@ -38,26 +38,34 @@ makeoptions amdgpu "CWARNFLAGS.amdgpu"+= @@ -38,26 +38,34 @@ makeoptions amdgpu "CWARNFLAGS.amdgpu"+=
38makeoptions amdgpu "CWARNFLAGS.amdgpu"+="-Wno-missing-prototypes" 38makeoptions amdgpu "CWARNFLAGS.amdgpu"+="-Wno-missing-prototypes"
39makeoptions amdgpu "CWARNFLAGS.amdgpu"+="-Wno-shadow" 39makeoptions amdgpu "CWARNFLAGS.amdgpu"+="-Wno-shadow"
40makeoptions amdgpu "CWARNFLAGS.amdgpu"+="-Wno-pointer-arith" 40makeoptions amdgpu "CWARNFLAGS.amdgpu"+="-Wno-pointer-arith"
41makeoptions amdgpu "CWARNFLAGS.amdgpu"+="-Wno-override-init" 41makeoptions amdgpu "CWARNFLAGS.amdgpu"+="-Wno-override-init"
42 42
43# Half the file strips const qualifier; file is small enough this is 43# Half the file strips const qualifier; file is small enough this is
44# not an issue. 44# not an issue.
45makeoptions amdgpu "CWARNFLAGS.amdgpu_arct_reg_init.c"+="-Wno-cast-qual" 45makeoptions amdgpu "CWARNFLAGS.amdgpu_arct_reg_init.c"+="-Wno-cast-qual"
46 46
47# -Wtype-limits raises warnings about code that is careful to avoid 47# -Wtype-limits raises warnings about code that is careful to avoid
48# overflow in arithmetic, which is the opposite of helpful. &@!#* 48# overflow in arithmetic, which is the opposite of helpful. &@!#*
49makeoptions amdgpu "CWARNFLAGS.amdgpu_bo_list.c"+="-Wno-type-limits" 49makeoptions amdgpu "CWARNFLAGS.amdgpu_bo_list.c"+="-Wno-type-limits"
50 50
 51ifdef amd64
 52makeoptions amdgpu "COPTS.amdgpu_dcn20_resource.c"+="-mhard-float -msse -msse2"
 53makeoptions amdgpu "COPTS.amdgpu_dcn21_resource.c"+="-mhard-float -msse -msse2"
 54makeoptions amdgpu "COPTS.amdgpu_dcn_calc_auto.c"+="-mhard-float -msse -msse2"
 55makeoptions amdgpu "COPTS.amdgpu_dcn_calc_math.c"+="-mhard-float -msse -msse2"
 56makeoptions amdgpu "COPTS.amdgpu_dcn_calcs.c"+="-mhard-float -msse -msse2"
 57endif
 58
51# Local additions. 59# Local additions.
52file external/bsd/drm2/amdgpu/amdgpu_module.c amdgpu 60file external/bsd/drm2/amdgpu/amdgpu_module.c amdgpu
53file external/bsd/drm2/amdgpu/amdgpu_pci.c amdgpu 61file external/bsd/drm2/amdgpu/amdgpu_pci.c amdgpu
54file external/bsd/drm2/amdgpu/amdgpufb.c amdgpufb 62file external/bsd/drm2/amdgpu/amdgpufb.c amdgpufb
55 63
56# Generated from amdgpu2netbsd. 64# Generated from amdgpu2netbsd.
57file external/bsd/drm2/dist/drm/amd/amdgpu/../acp/amdgpu_acp_hw.c amdgpu 65file external/bsd/drm2/dist/drm/amd/amdgpu/../acp/amdgpu_acp_hw.c amdgpu
58file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c amdgpu 66file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c amdgpu
59file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_color.c amdgpu 67file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_color.c amdgpu
60file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_hdcp.c amdgpu 68file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_hdcp.c amdgpu
61file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_helpers.c amdgpu 69file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_helpers.c amdgpu
62file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_irq.c amdgpu 70file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_irq.c amdgpu
63file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c amdgpu 71file external/bsd/drm2/dist/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c amdgpu

cvs diff -r1.5 -r1.6 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h 2021/12/18 23:44:58 1.5
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h 2021/12/19 11:35:06 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amdgpu.h,v 1.5 2021/12/18 23:44:58 riastradh Exp $ */ 1/* $NetBSD: amdgpu.h,v 1.6 2021/12/19 11:35:06 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2008 Advanced Micro Devices, Inc. 4 * Copyright 2008 Advanced Micro Devices, Inc.
5 * Copyright 2008 Red Hat Inc. 5 * Copyright 2008 Red Hat Inc.
6 * Copyright 2009 Jerome Glisse. 6 * Copyright 2009 Jerome Glisse.
7 * 7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a 8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"), 9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation 10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the 12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions: 13 * Software is furnished to do so, subject to the following conditions:
14 * 14 *
@@ -1254,28 +1254,32 @@ int amdgpu_cs_find_mapping(struct amdgpu @@ -1254,28 +1254,32 @@ int amdgpu_cs_find_mapping(struct amdgpu
1254 1254
1255#if defined(CONFIG_DRM_AMD_DC) 1255#if defined(CONFIG_DRM_AMD_DC)
1256int amdgpu_dm_display_resume(struct amdgpu_device *adev ); 1256int amdgpu_dm_display_resume(struct amdgpu_device *adev );
1257#else 1257#else
1258static inline int amdgpu_dm_display_resume(struct amdgpu_device *adev) { return 0; } 1258static inline int amdgpu_dm_display_resume(struct amdgpu_device *adev) { return 0; }
1259#endif 1259#endif
1260 1260
1261 1261
1262void amdgpu_register_gpu_instance(struct amdgpu_device *adev); 1262void amdgpu_register_gpu_instance(struct amdgpu_device *adev);
1263void amdgpu_unregister_gpu_instance(struct amdgpu_device *adev); 1263void amdgpu_unregister_gpu_instance(struct amdgpu_device *adev);
1264 1264
1265#include "amdgpu_object.h" 1265#include "amdgpu_object.h"
1266 1266
 1267#ifdef __NetBSD__ /* XXX amdgpu sysfs */
 1268#define AMDGPU_PMU_ATTR(_name, _object) CTASSERT(1)
 1269#else
1267/* used by df_v3_6.c and amdgpu_pmu.c */ 1270/* used by df_v3_6.c and amdgpu_pmu.c */
1268#define AMDGPU_PMU_ATTR(_name, _object) \ 1271#define AMDGPU_PMU_ATTR(_name, _object) \
1269static ssize_t \ 1272static ssize_t \
1270_name##_show(struct device *dev, \ 1273_name##_show(struct device *dev, \
1271 struct device_attribute *attr, \ 1274 struct device_attribute *attr, \
1272 char *page) \ 1275 char *page) \
1273{ \ 1276{ \
1274 BUILD_BUG_ON(sizeof(_object) >= PAGE_SIZE - 1); \ 1277 BUILD_BUG_ON(sizeof(_object) >= PAGE_SIZE - 1); \
1275 return sprintf(page, _object "\n"); \ 1278 return sprintf(page, _object "\n"); \
1276} \ 1279} \
1277 \ 1280 \
1278static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) 1281static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name)
 1282#endif
1279 1283
1280#endif 1284#endif
1281 1285

cvs diff -r1.7 -r1.8 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c 2021/12/18 23:44:58 1.7
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c 2021/12/19 11:35:07 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amdgpu_device.c,v 1.7 2021/12/18 23:44:58 riastradh Exp $ */ 1/* $NetBSD: amdgpu_device.c,v 1.8 2021/12/19 11:35:07 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2008 Advanced Micro Devices, Inc. 4 * Copyright 2008 Advanced Micro Devices, Inc.
5 * Copyright 2008 Red Hat Inc. 5 * Copyright 2008 Red Hat Inc.
6 * Copyright 2009 Jerome Glisse. 6 * Copyright 2009 Jerome Glisse.
7 * 7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a 8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"), 9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation 10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the 12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions: 13 * Software is furnished to do so, subject to the following conditions:
14 * 14 *
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE. 24 * OTHER DEALINGS IN THE SOFTWARE.
25 * 25 *
26 * Authors: Dave Airlie 26 * Authors: Dave Airlie
27 * Alex Deucher 27 * Alex Deucher
28 * Jerome Glisse 28 * Jerome Glisse
29 */ 29 */
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: amdgpu_device.c,v 1.7 2021/12/18 23:44:58 riastradh Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: amdgpu_device.c,v 1.8 2021/12/19 11:35:07 riastradh Exp $");
32 32
33#include <linux/power_supply.h> 33#include <linux/power_supply.h>
34#include <linux/kthread.h> 34#include <linux/kthread.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/console.h> 36#include <linux/console.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38 38
39#include <drm/drm_atomic_helper.h> 39#include <drm/drm_atomic_helper.h>
40#include <drm/drm_probe_helper.h> 40#include <drm/drm_probe_helper.h>
41#include <drm/amdgpu_drm.h> 41#include <drm/amdgpu_drm.h>
42#include <linux/vgaarb.h> 42#include <linux/vgaarb.h>
43#include <linux/vga_switcheroo.h> 43#include <linux/vga_switcheroo.h>
44#include <linux/efi.h> 44#include <linux/efi.h>
@@ -109,48 +109,52 @@ const char *amdgpu_asic_name[] = { @@ -109,48 +109,52 @@ const char *amdgpu_asic_name[] = {
109 "VEGAM", 109 "VEGAM",
110 "VEGA10", 110 "VEGA10",
111 "VEGA12", 111 "VEGA12",
112 "VEGA20", 112 "VEGA20",
113 "RAVEN", 113 "RAVEN",
114 "ARCTURUS", 114 "ARCTURUS",
115 "RENOIR", 115 "RENOIR",
116 "NAVI10", 116 "NAVI10",
117 "NAVI14", 117 "NAVI14",
118 "NAVI12", 118 "NAVI12",
119 "LAST", 119 "LAST",
120}; 120};
121 121
 122#ifndef __NetBSD__ /* XXX amdgpu sysfs */
 123
122/** 124/**
123 * DOC: pcie_replay_count 125 * DOC: pcie_replay_count
124 * 126 *
125 * The amdgpu driver provides a sysfs API for reporting the total number 127 * The amdgpu driver provides a sysfs API for reporting the total number
126 * of PCIe replays (NAKs) 128 * of PCIe replays (NAKs)
127 * The file pcie_replay_count is used for this and returns the total 129 * The file pcie_replay_count is used for this and returns the total
128 * number of replays as a sum of the NAKs generated and NAKs received 130 * number of replays as a sum of the NAKs generated and NAKs received
129 */ 131 */
130 132
131static ssize_t amdgpu_device_get_pcie_replay_count(struct device *dev, 133static ssize_t amdgpu_device_get_pcie_replay_count(struct device *dev,
132 struct device_attribute *attr, char *buf) 134 struct device_attribute *attr, char *buf)
133{ 135{
134 struct drm_device *ddev = dev_get_drvdata(dev); 136 struct drm_device *ddev = dev_get_drvdata(dev);
135 struct amdgpu_device *adev = ddev->dev_private; 137 struct amdgpu_device *adev = ddev->dev_private;
136 uint64_t cnt = amdgpu_asic_get_pcie_replay_count(adev); 138 uint64_t cnt = amdgpu_asic_get_pcie_replay_count(adev);
137 139
138 return snprintf(buf, PAGE_SIZE, "%llu\n", cnt); 140 return snprintf(buf, PAGE_SIZE, "%llu\n", cnt);
139} 141}
140 142
141static DEVICE_ATTR(pcie_replay_count, S_IRUGO, 143static DEVICE_ATTR(pcie_replay_count, S_IRUGO,
142 amdgpu_device_get_pcie_replay_count, NULL); 144 amdgpu_device_get_pcie_replay_count, NULL);
143 145
 146#endif /* __NetBSD__ */
 147
144static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev); 148static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev);
145 149
146/** 150/**
147 * amdgpu_device_supports_boco - Is the device a dGPU with HG/PX power control 151 * amdgpu_device_supports_boco - Is the device a dGPU with HG/PX power control
148 * 152 *
149 * @dev: drm_device pointer 153 * @dev: drm_device pointer
150 * 154 *
151 * Returns true if the device is a dGPU with HG/PX power control, 155 * Returns true if the device is a dGPU with HG/PX power control,
152 * otherwise return false. 156 * otherwise return false.
153 */ 157 */
154bool amdgpu_device_supports_boco(struct drm_device *dev) 158bool amdgpu_device_supports_boco(struct drm_device *dev)
155{ 159{
156 struct amdgpu_device *adev = dev->dev_private; 160 struct amdgpu_device *adev = dev->dev_private;
@@ -256,48 +260,58 @@ uint32_t amdgpu_mm_rreg(struct amdgpu_de @@ -256,48 +260,58 @@ uint32_t amdgpu_mm_rreg(struct amdgpu_de
256 * 260 *
257*/ 261*/
258 262
259/** 263/**
260 * amdgpu_mm_rreg8 - read a memory mapped IO register 264 * amdgpu_mm_rreg8 - read a memory mapped IO register
261 * 265 *
262 * @adev: amdgpu_device pointer 266 * @adev: amdgpu_device pointer
263 * @offset: byte aligned register offset 267 * @offset: byte aligned register offset
264 * 268 *
265 * Returns the 8 bit value from the offset specified. 269 * Returns the 8 bit value from the offset specified.
266 */ 270 */
267uint8_t amdgpu_mm_rreg8(struct amdgpu_device *adev, uint32_t offset) { 271uint8_t amdgpu_mm_rreg8(struct amdgpu_device *adev, uint32_t offset) {
268 if (offset < adev->rmmio_size) 272 if (offset < adev->rmmio_size)
 273#ifdef __NetBSD__
 274 return bus_space_read_1(adev->rmmiot, adev->rmmioh,
 275 adev->rmmio_base + offset);
 276#else
269 return (readb(adev->rmmio + offset)); 277 return (readb(adev->rmmio + offset));
 278#endif
270 BUG(); 279 BUG();
271} 280}
272 281
273/* 282/*
274 * MMIO register write with bytes helper functions 283 * MMIO register write with bytes helper functions
275 * @offset:bytes offset from MMIO start 284 * @offset:bytes offset from MMIO start
276 * @value: the value want to be written to the register 285 * @value: the value want to be written to the register
277 * 286 *
278*/ 287*/
279/** 288/**
280 * amdgpu_mm_wreg8 - read a memory mapped IO register 289 * amdgpu_mm_wreg8 - read a memory mapped IO register
281 * 290 *
282 * @adev: amdgpu_device pointer 291 * @adev: amdgpu_device pointer
283 * @offset: byte aligned register offset 292 * @offset: byte aligned register offset
284 * @value: 8 bit value to write 293 * @value: 8 bit value to write
285 * 294 *
286 * Writes the value specified to the offset specified. 295 * Writes the value specified to the offset specified.
287 */ 296 */
288void amdgpu_mm_wreg8(struct amdgpu_device *adev, uint32_t offset, uint8_t value) { 297void amdgpu_mm_wreg8(struct amdgpu_device *adev, uint32_t offset, uint8_t value) {
289 if (offset < adev->rmmio_size) 298 if (offset < adev->rmmio_size)
 299#ifdef __NetBSD__
 300 bus_space_write_1(adev->rmmiot, adev->rmmioh,
 301 adev->rmmio_base + offset, value);
 302#else
290 writeb(value, adev->rmmio + offset); 303 writeb(value, adev->rmmio + offset);
 304#endif
291 else 305 else
292 BUG(); 306 BUG();
293} 307}
294 308
295/** 309/**
296 * amdgpu_mm_wreg - write to a memory mapped IO register 310 * amdgpu_mm_wreg - write to a memory mapped IO register
297 * 311 *
298 * @adev: amdgpu_device pointer 312 * @adev: amdgpu_device pointer
299 * @reg: dword aligned register offset 313 * @reg: dword aligned register offset
300 * @v: 32 bit value to write to the register 314 * @v: 32 bit value to write to the register
301 * @acc_flags: access flags which require special behavior 315 * @acc_flags: access flags which require special behavior
302 * 316 *
303 * Writes the value specified to the offset specified. 317 * Writes the value specified to the offset specified.
@@ -457,47 +471,57 @@ void amdgpu_mm_wdoorbell(struct amdgpu_d @@ -457,47 +471,57 @@ void amdgpu_mm_wdoorbell(struct amdgpu_d
457 471
458/** 472/**
459 * amdgpu_mm_rdoorbell64 - read a doorbell Qword 473 * amdgpu_mm_rdoorbell64 - read a doorbell Qword
460 * 474 *
461 * @adev: amdgpu_device pointer 475 * @adev: amdgpu_device pointer
462 * @index: doorbell index 476 * @index: doorbell index
463 * 477 *
464 * Returns the value in the doorbell aperture at the 478 * Returns the value in the doorbell aperture at the
465 * requested doorbell index (VEGA10+). 479 * requested doorbell index (VEGA10+).
466 */ 480 */
467u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index) 481u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index)
468{ 482{
469 if (index < adev->doorbell.num_doorbells) { 483 if (index < adev->doorbell.num_doorbells) {
 484#ifdef __NetBSD__
 485 return bus_space_read_8(adev->doorbell.bst, adev->doorbell.bsh,
 486 4*index);
 487#else
470 return atomic64_read((atomic64_t *)(adev->doorbell.ptr + index)); 488 return atomic64_read((atomic64_t *)(adev->doorbell.ptr + index));
 489#endif
471 } else { 490 } else {
472 DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index); 491 DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", index);
473 return 0; 492 return 0;
474 } 493 }
475} 494}
476 495
477/** 496/**
478 * amdgpu_mm_wdoorbell64 - write a doorbell Qword 497 * amdgpu_mm_wdoorbell64 - write a doorbell Qword
479 * 498 *
480 * @adev: amdgpu_device pointer 499 * @adev: amdgpu_device pointer
481 * @index: doorbell index 500 * @index: doorbell index
482 * @v: value to write 501 * @v: value to write
483 * 502 *
484 * Writes @v to the doorbell aperture at the 503 * Writes @v to the doorbell aperture at the
485 * requested doorbell index (VEGA10+). 504 * requested doorbell index (VEGA10+).
486 */ 505 */
487void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v) 506void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v)
488{ 507{
489 if (index < adev->doorbell.num_doorbells) { 508 if (index < adev->doorbell.num_doorbells) {
 509#ifdef __NetBSD__
 510 bus_space_write_8(adev->doorbell.bst, adev->doorbell.bsh,
 511 4*index, v);
 512#else
490 atomic64_set((atomic64_t *)(adev->doorbell.ptr + index), v); 513 atomic64_set((atomic64_t *)(adev->doorbell.ptr + index), v);
 514#endif
491 } else { 515 } else {
492 DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index); 516 DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", index);
493 } 517 }
494} 518}
495 519
496/** 520/**
497 * amdgpu_invalid_rreg - dummy reg read function 521 * amdgpu_invalid_rreg - dummy reg read function
498 * 522 *
499 * @adev: amdgpu device pointer 523 * @adev: amdgpu device pointer
500 * @reg: offset of register 524 * @reg: offset of register
501 * 525 *
502 * Dummy register read function. Used for register blocks 526 * Dummy register read function. Used for register blocks
503 * that certain asics don't have (all asics). 527 * that certain asics don't have (all asics).
@@ -3242,31 +3266,33 @@ fence_driver_init: @@ -3242,31 +3266,33 @@ fence_driver_init:
3242 r = amdgpu_device_ip_late_init(adev); 3266 r = amdgpu_device_ip_late_init(adev);
3243 if (r) { 3267 if (r) {
3244 dev_err(adev->dev, "amdgpu_device_ip_late_init failed\n"); 3268 dev_err(adev->dev, "amdgpu_device_ip_late_init failed\n");
3245 amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_LATE_INIT_FAIL, 0, r); 3269 amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_LATE_INIT_FAIL, 0, r);
3246 goto failed; 3270 goto failed;
3247 } 3271 }
3248 3272
3249 /* must succeed. */ 3273 /* must succeed. */
3250 amdgpu_ras_resume(adev); 3274 amdgpu_ras_resume(adev);
3251 3275
3252 queue_delayed_work(system_wq, &adev->delayed_init_work, 3276 queue_delayed_work(system_wq, &adev->delayed_init_work,
3253 msecs_to_jiffies(AMDGPU_RESUME_MS)); 3277 msecs_to_jiffies(AMDGPU_RESUME_MS));
3254 3278
 3279#ifndef __NetBSD__ /* XXX amdgpu sysfs */
3255 r = device_create_file(adev->dev, &dev_attr_pcie_replay_count); 3280 r = device_create_file(adev->dev, &dev_attr_pcie_replay_count);
3256 if (r) { 3281 if (r) {
3257 dev_err(adev->dev, "Could not create pcie_replay_count"); 3282 dev_err(adev->dev, "Could not create pcie_replay_count");
3258 return r; 3283 return r;
3259 } 3284 }
 3285#endif
3260 3286
3261 if (IS_ENABLED(CONFIG_PERF_EVENTS)) 3287 if (IS_ENABLED(CONFIG_PERF_EVENTS))
3262 r = amdgpu_pmu_init(adev); 3288 r = amdgpu_pmu_init(adev);
3263 if (r) 3289 if (r)
3264 dev_err(adev->dev, "amdgpu_pmu_init failed\n"); 3290 dev_err(adev->dev, "amdgpu_pmu_init failed\n");
3265 3291
3266 return 0; 3292 return 0;
3267 3293
3268failed: 3294failed:
3269 amdgpu_vf_error_trans_all(adev); 3295 amdgpu_vf_error_trans_all(adev);
3270 if (boco) 3296 if (boco)
3271 vga_switcheroo_fini_domain_pm_ops(adev->dev); 3297 vga_switcheroo_fini_domain_pm_ops(adev->dev);
3272 3298

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_df_v3_6.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_df_v3_6.c 2021/12/18 23:44:58 1.2
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_df_v3_6.c 2021/12/19 11:35:07 1.3
@@ -1,53 +1,55 @@ @@ -1,53 +1,55 @@
1/* $NetBSD: amdgpu_df_v3_6.c,v 1.2 2021/12/18 23:44:58 riastradh Exp $ */ 1/* $NetBSD: amdgpu_df_v3_6.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2018 Advanced Micro Devices, Inc. 4 * Copyright 2018 Advanced Micro Devices, Inc.
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a 6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"), 7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation 8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the 10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions: 11 * Software is furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice shall be included in 13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software. 14 * all copies or substantial portions of the Software.
15 * 15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE. 22 * OTHER DEALINGS IN THE SOFTWARE.
23 * 23 *
24 */ 24 */
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: amdgpu_df_v3_6.c,v 1.2 2021/12/18 23:44:58 riastradh Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: amdgpu_df_v3_6.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $");
27 27
28#include "amdgpu.h" 28#include "amdgpu.h"
29#include "df_v3_6.h" 29#include "df_v3_6.h"
30 30
31#include "df/df_3_6_default.h" 31#include "df/df_3_6_default.h"
32#include "df/df_3_6_offset.h" 32#include "df/df_3_6_offset.h"
33#include "df/df_3_6_sh_mask.h" 33#include "df/df_3_6_sh_mask.h"
34 34
35#define DF_3_6_SMN_REG_INST_DIST 0x8 35#define DF_3_6_SMN_REG_INST_DIST 0x8
36#define DF_3_6_INST_CNT 8 36#define DF_3_6_INST_CNT 8
37 37
38static u32 df_v3_6_channel_number[] = {1, 2, 0, 4, 0, 8, 0, 38static u32 df_v3_6_channel_number[] = {1, 2, 0, 4, 0, 8, 0,
39 16, 32, 0, 0, 0, 2, 4, 8}; 39 16, 32, 0, 0, 0, 2, 4, 8};
40 40
 41#ifndef __NetBSD__ /* XXX amdgpu sysfs */
 42
41/* init df format attrs */ 43/* init df format attrs */
42AMDGPU_PMU_ATTR(event, "config:0-7"); 44AMDGPU_PMU_ATTR(event, "config:0-7");
43AMDGPU_PMU_ATTR(instance, "config:8-15"); 45AMDGPU_PMU_ATTR(instance, "config:8-15");
44AMDGPU_PMU_ATTR(umask, "config:16-23"); 46AMDGPU_PMU_ATTR(umask, "config:16-23");
45 47
46/* df format attributes */ 48/* df format attributes */
47static struct attribute *df_v3_6_format_attrs[] = { 49static struct attribute *df_v3_6_format_attrs[] = {
48 &pmu_attr_event.attr, 50 &pmu_attr_event.attr,
49 &pmu_attr_instance.attr, 51 &pmu_attr_instance.attr,
50 &pmu_attr_umask.attr, 52 &pmu_attr_umask.attr,
51 NULL 53 NULL
52}; 54};
53 55
@@ -91,26 +93,28 @@ static struct attribute *df_v3_6_event_a @@ -91,26 +93,28 @@ static struct attribute *df_v3_6_event_a
91/* df event attribute group */ 93/* df event attribute group */
92static struct attribute_group df_v3_6_event_attr_group = { 94static struct attribute_group df_v3_6_event_attr_group = {
93 .name = "events", 95 .name = "events",
94 .attrs = df_v3_6_event_attrs 96 .attrs = df_v3_6_event_attrs
95}; 97};
96 98
97/* df event attr groups */ 99/* df event attr groups */
98const struct attribute_group *df_v3_6_attr_groups[] = { 100const struct attribute_group *df_v3_6_attr_groups[] = {
99 &df_v3_6_format_attr_group, 101 &df_v3_6_format_attr_group,
100 &df_v3_6_event_attr_group, 102 &df_v3_6_event_attr_group,
101 NULL 103 NULL
102}; 104};
103 105
 106#endif /* __NetBSD__ */
 107
104static uint64_t df_v3_6_get_fica(struct amdgpu_device *adev, 108static uint64_t df_v3_6_get_fica(struct amdgpu_device *adev,
105 uint32_t ficaa_val) 109 uint32_t ficaa_val)
106{ 110{
107 unsigned long flags, address, data; 111 unsigned long flags, address, data;
108 uint32_t ficadl_val, ficadh_val; 112 uint32_t ficadl_val, ficadh_val;
109 113
110 address = adev->nbio.funcs->get_pcie_index_offset(adev); 114 address = adev->nbio.funcs->get_pcie_index_offset(adev);
111 data = adev->nbio.funcs->get_pcie_data_offset(adev); 115 data = adev->nbio.funcs->get_pcie_data_offset(adev);
112 116
113 spin_lock_irqsave(&adev->pcie_idx_lock, flags); 117 spin_lock_irqsave(&adev->pcie_idx_lock, flags);
114 WREG32(address, smnDF_PIE_AON_FabricIndirectConfigAccessAddress3); 118 WREG32(address, smnDF_PIE_AON_FabricIndirectConfigAccessAddress3);
115 WREG32(data, ficaa_val); 119 WREG32(data, ficaa_val);
116 120
@@ -236,50 +240,54 @@ static int df_v3_6_perfmon_arm_with_retr @@ -236,50 +240,54 @@ static int df_v3_6_perfmon_arm_with_retr
236 while (countdown) { 240 while (countdown) {
237 241
238 if (!df_v3_6_perfmon_arm_with_status(adev, lo_addr, lo_val, 242 if (!df_v3_6_perfmon_arm_with_status(adev, lo_addr, lo_val,
239 hi_addr, hi_val)) 243 hi_addr, hi_val))
240 break; 244 break;
241 245
242 countdown -= ARM_RETRY_USEC_INTERVAL; 246 countdown -= ARM_RETRY_USEC_INTERVAL;
243 udelay(ARM_RETRY_USEC_INTERVAL); 247 udelay(ARM_RETRY_USEC_INTERVAL);
244 } 248 }
245 249
246 return countdown > 0 ? 0 : -ETIME; 250 return countdown > 0 ? 0 : -ETIME;
247} 251}
248 252
 253#ifndef __NetBSD__ /* XXX amdgpu sysfs */
 254
249/* get the number of df counters available */ 255/* get the number of df counters available */
250static ssize_t df_v3_6_get_df_cntr_avail(struct device *dev, 256static ssize_t df_v3_6_get_df_cntr_avail(struct device *dev,
251 struct device_attribute *attr, 257 struct device_attribute *attr,
252 char *buf) 258 char *buf)
253{ 259{
254 struct amdgpu_device *adev; 260 struct amdgpu_device *adev;
255 struct drm_device *ddev; 261 struct drm_device *ddev;
256 int i, count; 262 int i, count;
257 263
258 ddev = dev_get_drvdata(dev); 264 ddev = dev_get_drvdata(dev);
259 adev = ddev->dev_private; 265 adev = ddev->dev_private;
260 count = 0; 266 count = 0;
261 267
262 for (i = 0; i < DF_V3_6_MAX_COUNTERS; i++) { 268 for (i = 0; i < DF_V3_6_MAX_COUNTERS; i++) {
263 if (adev->df_perfmon_config_assign_mask[i] == 0) 269 if (adev->df_perfmon_config_assign_mask[i] == 0)
264 count++; 270 count++;
265 } 271 }
266 272
267 return snprintf(buf, PAGE_SIZE, "%i\n", count); 273 return snprintf(buf, PAGE_SIZE, "%i\n", count);
268} 274}
269 275
270/* device attr for available perfmon counters */ 276/* device attr for available perfmon counters */
271static DEVICE_ATTR(df_cntr_avail, S_IRUGO, df_v3_6_get_df_cntr_avail, NULL); 277static DEVICE_ATTR(df_cntr_avail, S_IRUGO, df_v3_6_get_df_cntr_avail, NULL);
272 278
 279#endif /* __NetBSD__ */
 280
273static void df_v3_6_query_hashes(struct amdgpu_device *adev) 281static void df_v3_6_query_hashes(struct amdgpu_device *adev)
274{ 282{
275 u32 tmp; 283 u32 tmp;
276 284
277 adev->df.hash_status.hash_64k = false; 285 adev->df.hash_status.hash_64k = false;
278 adev->df.hash_status.hash_2m = false; 286 adev->df.hash_status.hash_2m = false;
279 adev->df.hash_status.hash_1g = false; 287 adev->df.hash_status.hash_1g = false;
280 288
281 if (adev->asic_type != CHIP_ARCTURUS) 289 if (adev->asic_type != CHIP_ARCTURUS)
282 return; 290 return;
283 291
284 /* encoding for hash-enabled on Arcturus */ 292 /* encoding for hash-enabled on Arcturus */
285 if (adev->df.funcs->get_fb_channel_number(adev) == 0xe) { 293 if (adev->df.funcs->get_fb_channel_number(adev) == 0xe) {
@@ -291,40 +299,46 @@ static void df_v3_6_query_hashes(struct  @@ -291,40 +299,46 @@ static void df_v3_6_query_hashes(struct
291 DF_CS_UMC_AON0_DfGlobalCtrl, 299 DF_CS_UMC_AON0_DfGlobalCtrl,
292 GlbHashIntlvCtl2M); 300 GlbHashIntlvCtl2M);
293 adev->df.hash_status.hash_1g = REG_GET_FIELD(tmp, 301 adev->df.hash_status.hash_1g = REG_GET_FIELD(tmp,
294 DF_CS_UMC_AON0_DfGlobalCtrl, 302 DF_CS_UMC_AON0_DfGlobalCtrl,
295 GlbHashIntlvCtl1G); 303 GlbHashIntlvCtl1G);
296 } 304 }
297} 305}
298 306
299/* init perfmons */ 307/* init perfmons */
300static void df_v3_6_sw_init(struct amdgpu_device *adev) 308static void df_v3_6_sw_init(struct amdgpu_device *adev)
301{ 309{
302 int i, ret; 310 int i, ret;
303 311
 312#ifdef __NetBSD__ /* XXX amdgpu sysfs */
 313 __USE(ret);
 314#else
304 ret = device_create_file(adev->dev, &dev_attr_df_cntr_avail); 315 ret = device_create_file(adev->dev, &dev_attr_df_cntr_avail);
305 if (ret) 316 if (ret)
306 DRM_ERROR("failed to create file for available df counters\n"); 317 DRM_ERROR("failed to create file for available df counters\n");
 318#endif
307 319
308 for (i = 0; i < AMDGPU_MAX_DF_PERFMONS; i++) 320 for (i = 0; i < AMDGPU_MAX_DF_PERFMONS; i++)
309 adev->df_perfmon_config_assign_mask[i] = 0; 321 adev->df_perfmon_config_assign_mask[i] = 0;
310 322
311 df_v3_6_query_hashes(adev); 323 df_v3_6_query_hashes(adev);
312} 324}
313 325
314static void df_v3_6_sw_fini(struct amdgpu_device *adev) 326static void df_v3_6_sw_fini(struct amdgpu_device *adev)
315{ 327{
316 328
 329#ifndef __NetBSD__ /* XXX amdgpu sysfs */
317 device_remove_file(adev->dev, &dev_attr_df_cntr_avail); 330 device_remove_file(adev->dev, &dev_attr_df_cntr_avail);
 331#endif
318 332
319} 333}
320 334
321static void df_v3_6_enable_broadcast_mode(struct amdgpu_device *adev, 335static void df_v3_6_enable_broadcast_mode(struct amdgpu_device *adev,
322 bool enable) 336 bool enable)
323{ 337{
324 u32 tmp; 338 u32 tmp;
325 339
326 if (enable) { 340 if (enable) {
327 tmp = RREG32_SOC15(DF, 0, mmFabricConfigAccessControl); 341 tmp = RREG32_SOC15(DF, 0, mmFabricConfigAccessControl);
328 tmp &= ~FabricConfigAccessControl__CfgRegInstAccEn_MASK; 342 tmp &= ~FabricConfigAccessControl__CfgRegInstAccEn_MASK;
329 WREG32_SOC15(DF, 0, mmFabricConfigAccessControl, tmp); 343 WREG32_SOC15(DF, 0, mmFabricConfigAccessControl, tmp);
330 } else 344 } else
@@ -475,27 +489,27 @@ static int df_v3_6_pmc_get_ctrl_settings @@ -475,27 +489,27 @@ static int df_v3_6_pmc_get_ctrl_settings
475 } 489 }
476 490
477 eventsel = DF_V3_6_GET_EVENT(config) & 0x3f; 491 eventsel = DF_V3_6_GET_EVENT(config) & 0x3f;
478 unitmask = DF_V3_6_GET_UNITMASK(config) & 0xf; 492 unitmask = DF_V3_6_GET_UNITMASK(config) & 0xf;
479 instance = DF_V3_6_GET_INSTANCE(config); 493 instance = DF_V3_6_GET_INSTANCE(config);
480 494
481 instance_10 = instance & 0x3; 495 instance_10 = instance & 0x3;
482 instance_5432 = (instance >> 2) & 0xf; 496 instance_5432 = (instance >> 2) & 0xf;
483 instance_76 = (instance >> 6) & 0x3; 497 instance_76 = (instance >> 6) & 0x3;
484 498
485 *lo_val = (unitmask << 8) | (instance_10 << 6) | eventsel | (1 << 22); 499 *lo_val = (unitmask << 8) | (instance_10 << 6) | eventsel | (1 << 22);
486 *hi_val = (instance_76 << 29) | instance_5432; 500 *hi_val = (instance_76 << 29) | instance_5432;
487 501
488 DRM_DEBUG_DRIVER("config=%llx addr=%08x:%08x val=%08x:%08x", 502 DRM_DEBUG_DRIVER("config=%"PRIx64" addr=%08x:%08x val=%08x:%08x",
489 config, *lo_base_addr, *hi_base_addr, *lo_val, *hi_val); 503 config, *lo_base_addr, *hi_base_addr, *lo_val, *hi_val);
490 504
491 return 0; 505 return 0;
492} 506}
493 507
494/* add df performance counters for read */ 508/* add df performance counters for read */
495static int df_v3_6_pmc_add_cntr(struct amdgpu_device *adev, 509static int df_v3_6_pmc_add_cntr(struct amdgpu_device *adev,
496 uint64_t config) 510 uint64_t config)
497{ 511{
498 int i, target_cntr; 512 int i, target_cntr;
499 513
500 target_cntr = df_v3_6_pmc_config_2_cntr(adev, config); 514 target_cntr = df_v3_6_pmc_config_2_cntr(adev, config);
501 515

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/os_types.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/amd/display/dc/os_types.h 2021/12/18 23:45:00 1.2
+++ src/sys/external/bsd/drm2/dist/drm/amd/display/dc/os_types.h 2021/12/19 11:35:07 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: os_types.h,v 1.2 2021/12/18 23:45:00 riastradh Exp $ */ 1/* $NetBSD: os_types.h,v 1.3 2021/12/19 11:35:07 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2012-16 Advanced Micro Devices, Inc. 4 * Copyright 2012-16 Advanced Micro Devices, Inc.
5 * Copyright 2019 Raptor Engineering, LLC 5 * Copyright 2019 Raptor Engineering, LLC
6 * 6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a 7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"), 8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation 9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the 11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions: 12 * Software is furnished to do so, subject to the following conditions:
13 * 13 *
14 * The above copyright notice and this permission notice shall be included in 14 * The above copyright notice and this permission notice shall be included in
@@ -44,29 +44,35 @@ @@ -44,29 +44,35 @@
44#define BIGENDIAN_CPU 44#define BIGENDIAN_CPU
45#elif defined(__LITTLE_ENDIAN) && !defined(LITTLEENDIAN_CPU) 45#elif defined(__LITTLE_ENDIAN) && !defined(LITTLEENDIAN_CPU)
46#define LITTLEENDIAN_CPU 46#define LITTLEENDIAN_CPU
47#endif 47#endif
48 48
49#undef FRAME_SIZE 49#undef FRAME_SIZE
50 50
51#define dm_output_to_console(fmt, ...) DRM_DEBUG_KMS(fmt, ##__VA_ARGS__) 51#define dm_output_to_console(fmt, ...) DRM_DEBUG_KMS(fmt, ##__VA_ARGS__)
52 52
53#define dm_error(fmt, ...) DRM_ERROR(fmt, ##__VA_ARGS__) 53#define dm_error(fmt, ...) DRM_ERROR(fmt, ##__VA_ARGS__)
54 54
55#if defined(CONFIG_DRM_AMD_DC_DCN) 55#if defined(CONFIG_DRM_AMD_DC_DCN)
56#if defined(CONFIG_X86) 56#if defined(CONFIG_X86)
 57#ifdef __NetBSD__
 58#include <x86/fpu.h>
 59#define DC_FP_START() fpu_kern_enter()
 60#define DC_FP_END() fpu_kern_leave()
 61#else
57#include <asm/fpu/api.h> 62#include <asm/fpu/api.h>
58#define DC_FP_START() kernel_fpu_begin() 63#define DC_FP_START() kernel_fpu_begin()
59#define DC_FP_END() kernel_fpu_end() 64#define DC_FP_END() kernel_fpu_end()
 65#endif
60#elif defined(CONFIG_PPC64) 66#elif defined(CONFIG_PPC64)
61#include <asm/switch_to.h> 67#include <asm/switch_to.h>
62#include <asm/cputable.h> 68#include <asm/cputable.h>
63#define DC_FP_START() { \ 69#define DC_FP_START() { \
64 if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \ 70 if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
65 preempt_disable(); \ 71 preempt_disable(); \
66 enable_kernel_vsx(); \ 72 enable_kernel_vsx(); \
67 } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \ 73 } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
68 preempt_disable(); \ 74 preempt_disable(); \
69 enable_kernel_altivec(); \ 75 enable_kernel_altivec(); \
70 } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \ 76 } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
71 preempt_disable(); \ 77 preempt_disable(); \
72 enable_kernel_fp(); \ 78 enable_kernel_fp(); \

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c 2021/12/18 23:45:01 1.2
+++ src/sys/external/bsd/drm2/dist/drm/amd/display/dc/calcs/amdgpu_dcn_calcs.c 2021/12/19 11:35:07 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amdgpu_dcn_calcs.c,v 1.2 2021/12/18 23:45:01 riastradh Exp $ */ 1/* $NetBSD: amdgpu_dcn_calcs.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright 2017 Advanced Micro Devices, Inc. 4 * Copyright 2017 Advanced Micro Devices, Inc.
5 * Copyright 2019 Raptor Engineering, LLC 5 * Copyright 2019 Raptor Engineering, LLC
6 * 6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a 7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"), 8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation 9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the 11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions: 12 * Software is furnished to do so, subject to the following conditions:
13 * 13 *
14 * The above copyright notice and this permission notice shall be included in 14 * The above copyright notice and this permission notice shall be included in
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE. 23 * OTHER DEALINGS IN THE SOFTWARE.
24 * 24 *
25 * Authors: AMD 25 * Authors: AMD
26 * 26 *
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn_calcs.c,v 1.2 2021/12/18 23:45:01 riastradh Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn_calcs.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $");
31 31
32#include "dm_services.h" 32#include "dm_services.h"
33#include "dc.h" 33#include "dc.h"
34#include "dcn_calcs.h" 34#include "dcn_calcs.h"
35#include "dcn_calc_auto.h" 35#include "dcn_calc_auto.h"
36#include "dal_asic_id.h" 36#include "dal_asic_id.h"
37#include "resource.h" 37#include "resource.h"
38#include "dcn10/dcn10_resource.h" 38#include "dcn10/dcn10_resource.h"
39#include "dcn10/dcn10_hubbub.h" 39#include "dcn10/dcn10_hubbub.h"
40#include "dml/dml1_display_rq_dlg_calc.h" 40#include "dml/dml1_display_rq_dlg_calc.h"
41 41
42#include "dcn_calc_math.h" 42#include "dcn_calc_math.h"
43 43
@@ -436,27 +436,27 @@ static void pipe_ctx_to_e2e_pipe_params  @@ -436,27 +436,27 @@ static void pipe_ctx_to_e2e_pipe_params
436 input->dest.vstartup_start = pipe->pipe_dlg_param.vstartup_start; 436 input->dest.vstartup_start = pipe->pipe_dlg_param.vstartup_start;
437 input->dest.vupdate_offset = pipe->pipe_dlg_param.vupdate_offset; 437 input->dest.vupdate_offset = pipe->pipe_dlg_param.vupdate_offset;
438 input->dest.vupdate_offset = pipe->pipe_dlg_param.vupdate_offset; 438 input->dest.vupdate_offset = pipe->pipe_dlg_param.vupdate_offset;
439 input->dest.vupdate_width = pipe->pipe_dlg_param.vupdate_width; 439 input->dest.vupdate_width = pipe->pipe_dlg_param.vupdate_width;
440 440
441} 441}
442 442
443static void dcn_bw_calc_rq_dlg_ttu( 443static void dcn_bw_calc_rq_dlg_ttu(
444 const struct dc *dc, 444 const struct dc *dc,
445 const struct dcn_bw_internal_vars *v, 445 const struct dcn_bw_internal_vars *v,
446 struct pipe_ctx *pipe, 446 struct pipe_ctx *pipe,
447 int in_idx) 447 int in_idx)
448{ 448{
449 struct display_mode_lib *dml = (struct display_mode_lib *)(&dc->dml); 449 struct display_mode_lib *dml = (struct display_mode_lib *)__UNCONST(&dc->dml);
450 struct _vcs_dpi_display_dlg_regs_st *dlg_regs = &pipe->dlg_regs; 450 struct _vcs_dpi_display_dlg_regs_st *dlg_regs = &pipe->dlg_regs;
451 struct _vcs_dpi_display_ttu_regs_st *ttu_regs = &pipe->ttu_regs; 451 struct _vcs_dpi_display_ttu_regs_st *ttu_regs = &pipe->ttu_regs;
452 struct _vcs_dpi_display_rq_regs_st *rq_regs = &pipe->rq_regs; 452 struct _vcs_dpi_display_rq_regs_st *rq_regs = &pipe->rq_regs;
453 struct _vcs_dpi_display_rq_params_st rq_param = {0}; 453 struct _vcs_dpi_display_rq_params_st rq_param = {0};
454 struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param = {0}; 454 struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param = {0};
455 struct _vcs_dpi_display_e2e_pipe_params_st input = { { { 0 } } }; 455 struct _vcs_dpi_display_e2e_pipe_params_st input = { { { 0 } } };
456 float total_active_bw = 0; 456 float total_active_bw = 0;
457 float total_prefetch_bw = 0; 457 float total_prefetch_bw = 0;
458 int total_flip_bytes = 0; 458 int total_flip_bytes = 0;
459 int i; 459 int i;
460 460
461 memset(dlg_regs, 0, sizeof(*dlg_regs)); 461 memset(dlg_regs, 0, sizeof(*dlg_regs));
462 memset(ttu_regs, 0, sizeof(*ttu_regs)); 462 memset(ttu_regs, 0, sizeof(*ttu_regs));

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn21/amdgpu_dcn21_hubp.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn21/amdgpu_dcn21_hubp.c 2021/12/18 23:45:03 1.2
+++ src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn21/amdgpu_dcn21_hubp.c 2021/12/19 11:35:07 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amdgpu_dcn21_hubp.c,v 1.2 2021/12/18 23:45:03 riastradh Exp $ */ 1/* $NetBSD: amdgpu_dcn21_hubp.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $ */
2 2
3/* 3/*
4* Copyright 2018 Advanced Micro Devices, Inc. 4* Copyright 2018 Advanced Micro Devices, Inc.
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a 6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"), 7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation 8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the 10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions: 11 * Software is furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice shall be included in 13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software. 14 * all copies or substantial portions of the Software.
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE. 22 * OTHER DEALINGS IN THE SOFTWARE.
23 * 23 *
24 * Authors: AMD 24 * Authors: AMD
25 * 25 *
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn21_hubp.c,v 1.2 2021/12/18 23:45:03 riastradh Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn21_hubp.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $");
30 30
31#include "dcn10/dcn10_hubp.h" 31#include "dcn10/dcn10_hubp.h"
32#include "dcn21_hubp.h" 32#include "dcn21_hubp.h"
33 33
34#include "dm_services.h" 34#include "dm_services.h"
35#include "reg_helper.h" 35#include "reg_helper.h"
36 36
37#include "dc_dmub_srv.h" 37#include "dc_dmub_srv.h"
38 38
39#define DC_LOGGER_INIT(logger) 39#define DC_LOGGER_INIT(logger)
40 40
41#define REG(reg)\ 41#define REG(reg)\
42 hubp21->hubp_regs->reg 42 hubp21->hubp_regs->reg
@@ -320,27 +320,27 @@ static void hubp21_apply_PLAT_54186_wa( @@ -320,27 +320,27 @@ static void hubp21_apply_PLAT_54186_wa(
320 ASSERT(patched_viewport_height && patched_viewport_height < 5000); 320 ASSERT(patched_viewport_height && patched_viewport_height < 5000);
321 ASSERT(patched_viewport_width && patched_viewport_width < 5000); 321 ASSERT(patched_viewport_width && patched_viewport_width < 5000);
322 322
323 REG_UPDATE_2(DCSURF_PRI_VIEWPORT_DIMENSION_C, 323 REG_UPDATE_2(DCSURF_PRI_VIEWPORT_DIMENSION_C,
324 PRI_VIEWPORT_WIDTH_C, patched_viewport_width, 324 PRI_VIEWPORT_WIDTH_C, patched_viewport_width,
325 PRI_VIEWPORT_HEIGHT_C, patched_viewport_height); 325 PRI_VIEWPORT_HEIGHT_C, patched_viewport_height);
326} 326}
327 327
328void hubp21_set_vm_system_aperture_settings(struct hubp *hubp, 328void hubp21_set_vm_system_aperture_settings(struct hubp *hubp,
329 struct vm_system_aperture_param *apt) 329 struct vm_system_aperture_param *apt)
330{ 330{
331 struct dcn21_hubp *hubp21 = TO_DCN21_HUBP(hubp); 331 struct dcn21_hubp *hubp21 = TO_DCN21_HUBP(hubp);
332 332
333 PHYSICAL_ADDRESS_LOC mc_vm_apt_default; 333 PHYSICAL_ADDRESS_LOC mc_vm_apt_default __unused;
334 PHYSICAL_ADDRESS_LOC mc_vm_apt_low; 334 PHYSICAL_ADDRESS_LOC mc_vm_apt_low;
335 PHYSICAL_ADDRESS_LOC mc_vm_apt_high; 335 PHYSICAL_ADDRESS_LOC mc_vm_apt_high;
336 336
337 // The format of default addr is 48:12 of the 48 bit addr 337 // The format of default addr is 48:12 of the 48 bit addr
338 mc_vm_apt_default.quad_part = apt->sys_default.quad_part >> 12; 338 mc_vm_apt_default.quad_part = apt->sys_default.quad_part >> 12;
339 339
340 // The format of high/low are 48:18 of the 48 bit addr 340 // The format of high/low are 48:18 of the 48 bit addr
341 mc_vm_apt_low.quad_part = apt->sys_low.quad_part >> 18; 341 mc_vm_apt_low.quad_part = apt->sys_low.quad_part >> 18;
342 mc_vm_apt_high.quad_part = apt->sys_high.quad_part >> 18; 342 mc_vm_apt_high.quad_part = apt->sys_high.quad_part >> 18;
343 343
344 REG_SET(DCN_VM_SYSTEM_APERTURE_LOW_ADDR, 0, 344 REG_SET(DCN_VM_SYSTEM_APERTURE_LOW_ADDR, 0,
345 MC_VM_SYSTEM_APERTURE_LOW_ADDR, mc_vm_apt_low.quad_part); 345 MC_VM_SYSTEM_APERTURE_LOW_ADDR, mc_vm_apt_low.quad_part);
346 346

cvs diff -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn21/amdgpu_dcn21_resource.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn21/amdgpu_dcn21_resource.c 2021/12/18 23:45:03 1.2
+++ src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn21/amdgpu_dcn21_resource.c 2021/12/19 11:35:07 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amdgpu_dcn21_resource.c,v 1.2 2021/12/18 23:45:03 riastradh Exp $ */ 1/* $NetBSD: amdgpu_dcn21_resource.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $ */
2 2
3/* 3/*
4* Copyright 2018 Advanced Micro Devices, Inc. 4* Copyright 2018 Advanced Micro Devices, Inc.
5 * Copyright 2019 Raptor Engineering, LLC 5 * Copyright 2019 Raptor Engineering, LLC
6 * 6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a 7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"), 8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation 9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the 11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions: 12 * Software is furnished to do so, subject to the following conditions:
13 * 13 *
14 * The above copyright notice and this permission notice shall be included in 14 * The above copyright notice and this permission notice shall be included in
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE. 23 * OTHER DEALINGS IN THE SOFTWARE.
24 * 24 *
25 * Authors: AMD 25 * Authors: AMD
26 * 26 *
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn21_resource.c,v 1.2 2021/12/18 23:45:03 riastradh Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn21_resource.c,v 1.3 2021/12/19 11:35:07 riastradh Exp $");
31 31
32#include <linux/slab.h> 32#include <linux/slab.h>
33 33
34#include "dm_services.h" 34#include "dm_services.h"
35#include "dc.h" 35#include "dc.h"
36 36
37#include "dcn21_init.h" 37#include "dcn21_init.h"
38 38
39#include "resource.h" 39#include "resource.h"
40#include "include/irq_service_interface.h" 40#include "include/irq_service_interface.h"
41#include "dcn20/dcn20_resource.h" 41#include "dcn20/dcn20_resource.h"
42 42
43#include "clk_mgr.h" 43#include "clk_mgr.h"
@@ -933,30 +933,32 @@ static void dcn21_resource_destruct(stru @@ -933,30 +933,32 @@ static void dcn21_resource_destruct(stru
933 } 933 }
934 934
935 for (i = 0; i < pool->base.res_cap->num_dwb; i++) { 935 for (i = 0; i < pool->base.res_cap->num_dwb; i++) {
936 if (pool->base.dwbc[i] != NULL) { 936 if (pool->base.dwbc[i] != NULL) {
937 kfree(TO_DCN20_DWBC(pool->base.dwbc[i])); 937 kfree(TO_DCN20_DWBC(pool->base.dwbc[i]));
938 pool->base.dwbc[i] = NULL; 938 pool->base.dwbc[i] = NULL;
939 } 939 }
940 if (pool->base.mcif_wb[i] != NULL) { 940 if (pool->base.mcif_wb[i] != NULL) {
941 kfree(TO_DCN20_MMHUBBUB(pool->base.mcif_wb[i])); 941 kfree(TO_DCN20_MMHUBBUB(pool->base.mcif_wb[i]));
942 pool->base.mcif_wb[i] = NULL; 942 pool->base.mcif_wb[i] = NULL;
943 } 943 }
944 } 944 }
945 945
 946#ifndef __NetBSD__ /* XXX amdgpu audio */
946 for (i = 0; i < pool->base.audio_count; i++) { 947 for (i = 0; i < pool->base.audio_count; i++) {
947 if (pool->base.audios[i]) 948 if (pool->base.audios[i])
948 dce_aud_destroy(&pool->base.audios[i]); 949 dce_aud_destroy(&pool->base.audios[i]);
949 } 950 }
 951#endif
950 952
951 for (i = 0; i < pool->base.clk_src_count; i++) { 953 for (i = 0; i < pool->base.clk_src_count; i++) {
952 if (pool->base.clock_sources[i] != NULL) { 954 if (pool->base.clock_sources[i] != NULL) {
953 dcn20_clock_source_destroy(&pool->base.clock_sources[i]); 955 dcn20_clock_source_destroy(&pool->base.clock_sources[i]);
954 pool->base.clock_sources[i] = NULL; 956 pool->base.clock_sources[i] = NULL;
955 } 957 }
956 } 958 }
957 959
958 if (pool->base.dp_clock_source != NULL) { 960 if (pool->base.dp_clock_source != NULL) {
959 dcn20_clock_source_destroy(&pool->base.dp_clock_source); 961 dcn20_clock_source_destroy(&pool->base.dp_clock_source);
960 pool->base.dp_clock_source = NULL; 962 pool->base.dp_clock_source = NULL;
961 } 963 }
962 964
@@ -1420,32 +1422,34 @@ static struct pp_smu_funcs *dcn21_pp_smu @@ -1420,32 +1422,34 @@ static struct pp_smu_funcs *dcn21_pp_smu
1420 } 1422 }
1421 1423
1422 return pp_smu; 1424 return pp_smu;
1423} 1425}
1424 1426
1425static void dcn21_pp_smu_destroy(struct pp_smu_funcs **pp_smu) 1427static void dcn21_pp_smu_destroy(struct pp_smu_funcs **pp_smu)
1426{ 1428{
1427 if (pp_smu && *pp_smu) { 1429 if (pp_smu && *pp_smu) {
1428 kfree(*pp_smu); 1430 kfree(*pp_smu);
1429 *pp_smu = NULL; 1431 *pp_smu = NULL;
1430 } 1432 }
1431} 1433}
1432 1434
 1435#ifndef __NetBSD__ /* XXX amdgpu audio */
1433static struct audio *dcn21_create_audio( 1436static struct audio *dcn21_create_audio(
1434 struct dc_context *ctx, unsigned int inst) 1437 struct dc_context *ctx, unsigned int inst)
1435{ 1438{
1436 return dce_audio_create(ctx, inst, 1439 return dce_audio_create(ctx, inst,
1437 &audio_regs[inst], &audio_shift, &audio_mask); 1440 &audio_regs[inst], &audio_shift, &audio_mask);
1438} 1441}
 1442#endif
1439 1443
1440static struct dc_cap_funcs cap_funcs = { 1444static struct dc_cap_funcs cap_funcs = {
1441 .get_dcc_compression_cap = dcn20_get_dcc_compression_cap 1445 .get_dcc_compression_cap = dcn20_get_dcc_compression_cap
1442}; 1446};
1443 1447
1444struct stream_encoder *dcn21_stream_encoder_create( 1448struct stream_encoder *dcn21_stream_encoder_create(
1445 enum engine_id eng_id, 1449 enum engine_id eng_id,
1446 struct dc_context *ctx) 1450 struct dc_context *ctx)
1447{ 1451{
1448 struct dcn10_stream_encoder *enc1 = 1452 struct dcn10_stream_encoder *enc1 =
1449 kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL); 1453 kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
1450 1454
1451 if (!enc1) 1455 if (!enc1)
@@ -1477,27 +1481,29 @@ static struct dce_hwseq *dcn21_hwseq_cre @@ -1477,27 +1481,29 @@ static struct dce_hwseq *dcn21_hwseq_cre
1477 1481
1478 if (hws) { 1482 if (hws) {
1479 hws->ctx = ctx; 1483 hws->ctx = ctx;
1480 hws->regs = &hwseq_reg; 1484 hws->regs = &hwseq_reg;
1481 hws->shifts = &hwseq_shift; 1485 hws->shifts = &hwseq_shift;
1482 hws->masks = &hwseq_mask; 1486 hws->masks = &hwseq_mask;
1483 hws->wa.DEGVIDCN21 = true; 1487 hws->wa.DEGVIDCN21 = true;
1484 } 1488 }
1485 return hws; 1489 return hws;
1486} 1490}
1487 1491
1488static const struct resource_create_funcs res_create_funcs = { 1492static const struct resource_create_funcs res_create_funcs = {
1489 .read_dce_straps = read_dce_straps, 1493 .read_dce_straps = read_dce_straps,
 1494#ifndef __NetBSD__ /* XXX amdgpu audio */
1490 .create_audio = dcn21_create_audio, 1495 .create_audio = dcn21_create_audio,
 1496#endif
1491 .create_stream_encoder = dcn21_stream_encoder_create, 1497 .create_stream_encoder = dcn21_stream_encoder_create,
1492 .create_hwseq = dcn21_hwseq_create, 1498 .create_hwseq = dcn21_hwseq_create,
1493}; 1499};
1494 1500
1495static const struct resource_create_funcs res_create_maximus_funcs = { 1501static const struct resource_create_funcs res_create_maximus_funcs = {
1496 .read_dce_straps = NULL, 1502 .read_dce_straps = NULL,
1497 .create_audio = NULL, 1503 .create_audio = NULL,
1498 .create_stream_encoder = NULL, 1504 .create_stream_encoder = NULL,
1499 .create_hwseq = dcn21_hwseq_create, 1505 .create_hwseq = dcn21_hwseq_create,
1500}; 1506};
1501 1507
1502static const struct encoder_feature_support link_enc_feature = { 1508static const struct encoder_feature_support link_enc_feature = {
1503 .max_hdmi_deep_color = COLOR_DEPTH_121212, 1509 .max_hdmi_deep_color = COLOR_DEPTH_121212,