Skip to content

Commit

Permalink
Add support for AMD GPU on MacBookPro16,4
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaGarg8 committed Dec 21, 2023
1 parent af35129 commit 0eb18a3
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 17 deletions.
30 changes: 14 additions & 16 deletions 2010-efi-libstub-add-support-for-the-apple_set_os-protoco.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ See also this patch for GRUB by Andreas Heider <[email protected]>:
https://lists.gnu.org/archive/html/grub-devel/2013-12/msg00442.html
---
.../admin-guide/kernel-parameters.txt | 2 ++
.../firmware/efi/libstub/efi-stub-helper.c | 3 ++
drivers/firmware/efi/libstub/efistub.h | 15 ++++++++++
drivers/firmware/efi/libstub/x86-stub.c | 28 +++++++++++++++++++
.../firmware/efi/libstub/efi-stub-helper.c | 3 +++
drivers/firmware/efi/libstub/efistub.h | 14 ++++++++++
drivers/firmware/efi/libstub/x86-stub.c | 27 +++++++++++++++++++
include/linux/efi.h | 1 +
5 files changed, 49 insertions(+)
5 files changed, 47 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 0a1731a0f..176d3641a 100644
index 41644336e..cbd4697a5 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -399,6 +399,8 @@
Expand Down Expand Up @@ -51,7 +51,7 @@ index bfa30625f..3d99acc1a 100644
efi_no5lvl = true;
} else if (!strcmp(param, "efi") && val) {
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 212687c30..2a53c5268 100644
index 212687c30..21b414d09 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -38,6 +38,7 @@ extern bool efi_nochunk;
Expand All @@ -62,7 +62,7 @@ index 212687c30..2a53c5268 100644

extern const efi_system_table_t *efi_system_table;

@@ -825,6 +826,20 @@ union apple_properties_protocol {
@@ -825,6 +826,19 @@ union apple_properties_protocol {
} mixed_mode;
};

Expand All @@ -78,16 +78,15 @@ index 212687c30..2a53c5268 100644
+ u32 set_os_vendor;
+ } mixed_mode;
+};
+
+
typedef u32 efi_tcg2_event_log_format;

#define INITRD_EVENT_TAG_ID 0x8F3B22ECU
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index 9d5df683f..de899f592 100644
index 70b325a2f..2131f8543 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -223,6 +223,31 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
@@ -223,6 +223,30 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
}
}

Expand All @@ -114,21 +113,20 @@ index 9d5df683f..de899f592 100644
+ efi_err("Failed to set OS version via apple_set_os\n");
+ }
+}
+
+
void efi_adjust_memory_range_protection(unsigned long start,
unsigned long size)
{
@@ -317,6 +342,9 @@ static void setup_quirks(struct boot_params *boot_params)
if (!memcmp(fw_vendor, apple, sizeof(apple))) {
if (IS_ENABLED(CONFIG_APPLE_PROPERTIES))
retrieve_apple_device_properties(boot_params);
@@ -321,6 +345,9 @@ static void setup_quirks(struct boot_params *boot_params)
if (IS_ENABLED(CONFIG_APPLE_PROPERTIES) &&
!memcmp(efistub_fw_vendor(), apple, sizeof(apple)))
retrieve_apple_device_properties(boot_params);
+
+ if (efi_apple_set_os)
+ apple_set_os();
}
}

/*
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 80b21d1c6..f1e58e027 100644
--- a/include/linux/efi.h
Expand Down
137 changes: 137 additions & 0 deletions 7003-drm-amd-display-add-nv12-bounding-box.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
From 4d06551ba0b50702c9e23881d96107404ffe25a3 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Wed, 20 Dec 2023 12:33:45 -0500
Subject: [PATCH 1/2] drm/amd/display: add nv12 bounding box

This was included in gpu_info firmware, move it into the
driver for consistency with other nv1x parts.

Signed-off-by: Alex Deucher <[email protected]>
---
.../drm/amd/display/dc/dml/dcn20/dcn20_fpu.c | 110 +++++++++++++++++-
1 file changed, 109 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c
index ec77b2b41ba3..d2271e308fa0 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c
@@ -440,7 +440,115 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv14_soc = {
.use_urgent_burst_bw = 0
};

-struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv12_soc = { 0 };
+struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv12_soc = {
+ .clock_limits = {
+ {
+ .state = 0,
+ .dcfclk_mhz = 560.0,
+ .fabricclk_mhz = 560.0,
+ .dispclk_mhz = 513.0,
+ .dppclk_mhz = 513.0,
+ .phyclk_mhz = 540.0,
+ .socclk_mhz = 560.0,
+ .dscclk_mhz = 171.0,
+ .dram_speed_mts = 1069.0,
+ },
+ {
+ .state = 1,
+ .dcfclk_mhz = 694.0,
+ .fabricclk_mhz = 694.0,
+ .dispclk_mhz = 642.0,
+ .dppclk_mhz = 642.0,
+ .phyclk_mhz = 600.0,
+ .socclk_mhz = 694.0,
+ .dscclk_mhz = 214.0,
+ .dram_speed_mts = 1324.0,
+ },
+ {
+ .state = 2,
+ .dcfclk_mhz = 875.0,
+ .fabricclk_mhz = 875.0,
+ .dispclk_mhz = 734.0,
+ .dppclk_mhz = 734.0,
+ .phyclk_mhz = 810.0,
+ .socclk_mhz = 875.0,
+ .dscclk_mhz = 245.0,
+ .dram_speed_mts = 1670.0,
+ },
+ {
+ .state = 3,
+ .dcfclk_mhz = 1000.0,
+ .fabricclk_mhz = 1000.0,
+ .dispclk_mhz = 1100.0,
+ .dppclk_mhz = 1100.0,
+ .phyclk_mhz = 810.0,
+ .socclk_mhz = 1000.0,
+ .dscclk_mhz = 367.0,
+ .dram_speed_mts = 2000.0,
+ },
+ {
+ .state = 4,
+ .dcfclk_mhz = 1200.0,
+ .fabricclk_mhz = 1200.0,
+ .dispclk_mhz = 1284.0,
+ .dppclk_mhz = 1284.0,
+ .phyclk_mhz = 810.0,
+ .socclk_mhz = 1200.0,
+ .dscclk_mhz = 428.0,
+ .dram_speed_mts = 2000.0,
+ },
+ {
+ .state = 5,
+ .dcfclk_mhz = 1200.0,
+ .fabricclk_mhz = 1200.0,
+ .dispclk_mhz = 1284.0,
+ .dppclk_mhz = 1284.0,
+ .phyclk_mhz = 810.0,
+ .socclk_mhz = 1200.0,
+ .dscclk_mhz = 428.0,
+ .dram_speed_mts = 2000.0,
+ },
+ },
+
+ .num_states = 5,
+ .sr_exit_time_us = 1.9,
+ .sr_enter_plus_exit_time_us = 4.4,
+ .urgent_latency_us = 3.0,
+ .urgent_latency_pixel_data_only_us = 4.0,
+ .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
+ .urgent_latency_vm_data_only_us = 4.0,
+ .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
+ .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
+ .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
+ .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 40.0,
+ .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 40.0,
+ .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 40.0,
+ .max_avg_sdp_bw_use_normal_percent = 40.0,
+ .max_avg_dram_bw_use_normal_percent = 40.0,
+ .writeback_latency_us = 12.0,
+ .ideal_dram_bw_after_urgent_percent = 40.0,
+ .max_request_size_bytes = 256,
+ .dram_channel_width_bytes = 16,
+ .fabric_datapath_to_dcn_data_return_bytes = 64,
+ .dcn_downspread_percent = 0.5,
+ .downspread_percent = 0.5,
+ .dram_page_open_time_ns = 50.0,
+ .dram_rw_turnaround_time_ns = 17.5,
+ .dram_return_buffer_per_channel_bytes = 8192,
+ .round_trip_ping_latency_dcfclk_cycles = 131,
+ .urgent_out_of_order_return_per_channel_bytes = 4096,
+ .channel_interleave_bytes = 256,
+ .num_banks = 8,
+ .num_chans = 16,
+ .vmm_page_size_bytes = 4096,
+ .dram_clock_change_latency_us = 45.0,
+ .writeback_dram_clock_change_latency_us = 23.0,
+ .return_bus_width_bytes = 64,
+ .dispclk_dppclk_vco_speed_mhz = 3850,
+ .xfc_bus_transport_time_us = 20,
+ .xfc_xbuf_latency_tolerance_us = 50,
+ .use_urgent_burst_bw = 0,
+};

struct _vcs_dpi_ip_params_st dcn2_1_ip = {
.odm_capable = 1,
--
2.42.0

37 changes: 37 additions & 0 deletions 7004-drm-amdgpu-skip-gpu_info-fw-loading-on-navi12.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From 197a96dc2d0c294232bfc1a0f5d31e4658f99f2b Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Wed, 20 Dec 2023 12:36:08 -0500
Subject: [PATCH 2/2] drm/amdgpu: skip gpu_info fw loading on navi12

It's no longer required.

Signed-off-by: Alex Deucher <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 8dee52ce26d0..93cf73d6fa11 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2188,15 +2188,8 @@ static int amdgpu_device_parse_gpu_info_fw(struct amdgpu_device *adev)

adev->firmware.gpu_info_fw = NULL;

- if (adev->mman.discovery_bin) {
- /*
- * FIXME: The bounding box is still needed by Navi12, so
- * temporarily read it from gpu_info firmware. Should be dropped
- * when DAL no longer needs it.
- */
- if (adev->asic_type != CHIP_NAVI12)
- return 0;
- }
+ if (adev->mman.discovery_bin)
+ return 0;

switch (adev->asic_type) {
default:
--
2.42.0

2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
KVER=6.6.1
KVER=6.6.8

0 comments on commit 0eb18a3

Please sign in to comment.