You've already forked linux-t2-patches
mirror of
https://github.com/t2linux/linux-t2-patches.git
synced 2026-04-30 13:52:11 -07:00
6.11
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
From f893444f7c842f97f3707897ba29f2c8dd77c8df Mon Sep 17 00:00:00 2001
|
||||
From: Kerem Karabay <kekrby@gmail.com>
|
||||
Date: Mon, 7 Aug 2023 20:29:27 +0300
|
||||
Subject: [PATCH 10/12] USB: core: add 'shutdown' callback to usb_driver
|
||||
|
||||
This simplifies running code on shutdown for USB drivers.
|
||||
|
||||
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
|
||||
---
|
||||
drivers/usb/core/driver.c | 14 ++++++++++++++
|
||||
drivers/usb/storage/uas.c | 5 ++---
|
||||
include/linux/usb.h | 3 +++
|
||||
3 files changed, 19 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
|
||||
index f58a0299f..dc0f86376 100644
|
||||
--- a/drivers/usb/core/driver.c
|
||||
+++ b/drivers/usb/core/driver.c
|
||||
@@ -514,6 +514,19 @@ static int usb_unbind_interface(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void usb_shutdown_interface(struct device *dev)
|
||||
+{
|
||||
+ struct usb_interface *intf = to_usb_interface(dev);
|
||||
+ struct usb_driver *driver;
|
||||
+
|
||||
+ if (!dev->driver)
|
||||
+ return;
|
||||
+
|
||||
+ driver = to_usb_driver(dev->driver);
|
||||
+ if (driver->shutdown)
|
||||
+ driver->shutdown(intf);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* usb_driver_claim_interface - bind a driver to an interface
|
||||
* @driver: the driver to be bound
|
||||
@@ -1053,6 +1066,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner,
|
||||
new_driver->driver.bus = &usb_bus_type;
|
||||
new_driver->driver.probe = usb_probe_interface;
|
||||
new_driver->driver.remove = usb_unbind_interface;
|
||||
+ new_driver->driver.shutdown = usb_shutdown_interface;
|
||||
new_driver->driver.owner = owner;
|
||||
new_driver->driver.mod_name = mod_name;
|
||||
new_driver->driver.dev_groups = new_driver->dev_groups;
|
||||
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
|
||||
index 2583ee981..591fa0379 100644
|
||||
--- a/drivers/usb/storage/uas.c
|
||||
+++ b/drivers/usb/storage/uas.c
|
||||
@@ -1221,9 +1221,8 @@ static void uas_disconnect(struct usb_interface *intf)
|
||||
* hang on reboot when the device is still in uas mode. Note the reset is
|
||||
* necessary as some devices won't revert to usb-storage mode without it.
|
||||
*/
|
||||
-static void uas_shutdown(struct device *dev)
|
||||
+static void uas_shutdown(struct usb_interface *intf)
|
||||
{
|
||||
- struct usb_interface *intf = to_usb_interface(dev);
|
||||
struct usb_device *udev = interface_to_usbdev(intf);
|
||||
struct Scsi_Host *shost = usb_get_intfdata(intf);
|
||||
struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata;
|
||||
@@ -1246,7 +1245,7 @@ static struct usb_driver uas_driver = {
|
||||
.suspend = uas_suspend,
|
||||
.resume = uas_resume,
|
||||
.reset_resume = uas_reset_resume,
|
||||
- .driver.shutdown = uas_shutdown,
|
||||
+ .shutdown = uas_shutdown,
|
||||
.id_table = uas_usb_ids,
|
||||
};
|
||||
|
||||
diff --git a/include/linux/usb.h b/include/linux/usb.h
|
||||
index 25f8e62a3..5f3ae2186 100644
|
||||
--- a/include/linux/usb.h
|
||||
+++ b/include/linux/usb.h
|
||||
@@ -1194,6 +1194,7 @@ struct usbdrv_wrap {
|
||||
* post_reset method is called.
|
||||
* @post_reset: Called by usb_reset_device() after the device
|
||||
* has been reset
|
||||
+ * @shutdown: Called at shut-down time to quiesce the device.
|
||||
* @id_table: USB drivers use ID table to support hotplugging.
|
||||
* Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
|
||||
* or your driver's probe function will never get called.
|
||||
@@ -1245,6 +1246,8 @@ struct usb_driver {
|
||||
int (*pre_reset)(struct usb_interface *intf);
|
||||
int (*post_reset)(struct usb_interface *intf);
|
||||
|
||||
+ void (*shutdown)(struct usb_interface *intf);
|
||||
+
|
||||
const struct usb_device_id *id_table;
|
||||
const struct attribute_group **dev_groups;
|
||||
|
||||
--
|
||||
2.42.0
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
From 394ba612f9419ec5bfebbffb72212fd3b2094986 Mon Sep 17 00:00:00 2001
|
||||
From: Orlando Chamberlain <orlandoch.dev@gmail.com>
|
||||
Date: Wed, 3 Jul 2024 17:54:11 +0000
|
||||
Subject: HID: apple: Add support for magic keyboard backlight on T2 Macs
|
||||
|
||||
Unlike T2 Macs with Butterfly keyboard, who have their keyboard backlight
|
||||
on the USB device the T2 Macs with Magic keyboard have their backlight on
|
||||
the Touchbar backlight device (05ac:8102).
|
||||
|
||||
Support for Butterfly keyboards has already been added in
|
||||
commit 9018eacbe623 ("HID: apple: Add support for keyboard backlight on
|
||||
certain T2 Macs.") This patch adds support for the Magic keyboards.
|
||||
|
||||
Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
|
||||
Co-developed-by: Aditya Garg <gargaditya08@live.com>
|
||||
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||
Link: https://patch.msgid.link/E1D444EA-7FD0-42DA-B198-50B0F03298FB@live.com
|
||||
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
|
||||
---
|
||||
drivers/hid/hid-apple.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 87 insertions(+)
|
||||
|
||||
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||
index bd022e0043569c..6dedb84d7cc397 100644
|
||||
--- a/drivers/hid/hid-apple.c
|
||||
+++ b/drivers/hid/hid-apple.c
|
||||
@@ -8,6 +8,8 @@
|
||||
* Copyright (c) 2006-2007 Jiri Kosina
|
||||
* Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
|
||||
* Copyright (c) 2019 Paul Pawlowski <paul@mrarm.io>
|
||||
+ * Copyright (c) 2023 Orlando Chamberlain <orlandoch.dev@gmail.com>
|
||||
+ * Copyright (c) 2024 Aditya Garg <gargaditya08@live.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -23,6 +25,7 @@
|
||||
#include <linux/timer.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/leds.h>
|
||||
+#include <dt-bindings/leds/common.h>
|
||||
|
||||
#include "hid-ids.h"
|
||||
|
||||
@@ -38,12 +41,17 @@
|
||||
#define APPLE_RDESC_BATTERY BIT(9)
|
||||
#define APPLE_BACKLIGHT_CTL BIT(10)
|
||||
#define APPLE_IS_NON_APPLE BIT(11)
|
||||
+#define APPLE_MAGIC_BACKLIGHT BIT(12)
|
||||
|
||||
#define APPLE_FLAG_FKEY 0x01
|
||||
|
||||
#define HID_COUNTRY_INTERNATIONAL_ISO 13
|
||||
#define APPLE_BATTERY_TIMEOUT_MS 60000
|
||||
|
||||
+#define HID_USAGE_MAGIC_BL 0xff00000f
|
||||
+#define APPLE_MAGIC_REPORT_ID_POWER 3
|
||||
+#define APPLE_MAGIC_REPORT_ID_BRIGHTNESS 1
|
||||
+
|
||||
static unsigned int fnmode = 3;
|
||||
module_param(fnmode, uint, 0644);
|
||||
MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
|
||||
@@ -81,6 +89,12 @@ struct apple_sc_backlight {
|
||||
struct hid_device *hdev;
|
||||
};
|
||||
|
||||
+struct apple_magic_backlight {
|
||||
+ struct led_classdev cdev;
|
||||
+ struct hid_report *brightness;
|
||||
+ struct hid_report *power;
|
||||
+};
|
||||
+
|
||||
struct apple_sc {
|
||||
struct hid_device *hdev;
|
||||
unsigned long quirks;
|
||||
@@ -822,6 +836,66 @@ cleanup_and_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static void apple_magic_backlight_report_set(struct hid_report *rep, s32 value, u8 rate)
|
||||
+{
|
||||
+ rep->field[0]->value[0] = value;
|
||||
+ rep->field[1]->value[0] = 0x5e; /* Mimic Windows */
|
||||
+ rep->field[1]->value[0] |= rate << 8;
|
||||
+
|
||||
+ hid_hw_request(rep->device, rep, HID_REQ_SET_REPORT);
|
||||
+}
|
||||
+
|
||||
+static void apple_magic_backlight_set(struct apple_magic_backlight *backlight,
|
||||
+ int brightness, char rate)
|
||||
+{
|
||||
+ apple_magic_backlight_report_set(backlight->power, brightness ? 1 : 0, rate);
|
||||
+ if (brightness)
|
||||
+ apple_magic_backlight_report_set(backlight->brightness, brightness, rate);
|
||||
+}
|
||||
+
|
||||
+static int apple_magic_backlight_led_set(struct led_classdev *led_cdev,
|
||||
+ enum led_brightness brightness)
|
||||
+{
|
||||
+ struct apple_magic_backlight *backlight = container_of(led_cdev,
|
||||
+ struct apple_magic_backlight, cdev);
|
||||
+
|
||||
+ apple_magic_backlight_set(backlight, brightness, 1);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int apple_magic_backlight_init(struct hid_device *hdev)
|
||||
+{
|
||||
+ struct apple_magic_backlight *backlight;
|
||||
+ struct hid_report_enum *report_enum;
|
||||
+
|
||||
+ /*
|
||||
+ * Ensure this usb endpoint is for the keyboard backlight, not touchbar
|
||||
+ * backlight.
|
||||
+ */
|
||||
+ if (hdev->collection[0].usage != HID_USAGE_MAGIC_BL)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ backlight = devm_kzalloc(&hdev->dev, sizeof(*backlight), GFP_KERNEL);
|
||||
+ if (!backlight)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ report_enum = &hdev->report_enum[HID_FEATURE_REPORT];
|
||||
+ backlight->brightness = report_enum->report_id_hash[APPLE_MAGIC_REPORT_ID_BRIGHTNESS];
|
||||
+ backlight->power = report_enum->report_id_hash[APPLE_MAGIC_REPORT_ID_POWER];
|
||||
+
|
||||
+ if (!backlight->brightness || !backlight->power)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ backlight->cdev.name = ":white:" LED_FUNCTION_KBD_BACKLIGHT;
|
||||
+ backlight->cdev.max_brightness = backlight->brightness->field[0]->logical_maximum;
|
||||
+ backlight->cdev.brightness_set_blocking = apple_magic_backlight_led_set;
|
||||
+
|
||||
+ apple_magic_backlight_set(backlight, 0, 0);
|
||||
+
|
||||
+ return devm_led_classdev_register(&hdev->dev, &backlight->cdev);
|
||||
+
|
||||
+}
|
||||
+
|
||||
static int apple_probe(struct hid_device *hdev,
|
||||
const struct hid_device_id *id)
|
||||
{
|
||||
@@ -860,7 +934,18 @@ static int apple_probe(struct hid_device *hdev,
|
||||
if (quirks & APPLE_BACKLIGHT_CTL)
|
||||
apple_backlight_init(hdev);
|
||||
|
||||
+ if (quirks & APPLE_MAGIC_BACKLIGHT) {
|
||||
+ ret = apple_magic_backlight_init(hdev);
|
||||
+ if (ret)
|
||||
+ goto out_err;
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
+
|
||||
+out_err:
|
||||
+ del_timer_sync(&asc->battery_timer);
|
||||
+ hid_hw_stop(hdev);
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
static void apple_remove(struct hid_device *hdev)
|
||||
@@ -1073,6 +1158,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY },
|
||||
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021),
|
||||
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
||||
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT),
|
||||
+ .driver_data = APPLE_MAGIC_BACKLIGHT },
|
||||
|
||||
{ }
|
||||
};
|
||||
--
|
||||
cgit 1.2.3-korg
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
From 0dad9ee3c13930fe8122f2efc936fcd1c277a00d Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Mon, 1 Jul 2024 18:29:59 +0200
|
||||
Subject: efistub/smbios: Simplify SMBIOS enumeration API
|
||||
|
||||
Update the efi_get_smbios_string() macro to take a pointer to the entire
|
||||
record struct rather than the header. This removes the need to pass the
|
||||
type explicitly, as it can be inferred from the typed pointer. Also,
|
||||
drop 'type' from the prototype of __efi_get_smbios_string(), as it is
|
||||
never referenced.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
---
|
||||
drivers/firmware/efi/libstub/arm64.c | 3 +--
|
||||
drivers/firmware/efi/libstub/efistub.h | 9 ++++-----
|
||||
drivers/firmware/efi/libstub/smbios.c | 4 ++--
|
||||
3 files changed, 7 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c
|
||||
index 446e35eaf3d943..e57cd3de0a00f4 100644
|
||||
--- a/drivers/firmware/efi/libstub/arm64.c
|
||||
+++ b/drivers/firmware/efi/libstub/arm64.c
|
||||
@@ -39,8 +39,7 @@ static bool system_needs_vamap(void)
|
||||
static char const emag[] = "eMAG";
|
||||
|
||||
default:
|
||||
- version = efi_get_smbios_string(&record->header, 4,
|
||||
- processor_version);
|
||||
+ version = efi_get_smbios_string(record, processor_version);
|
||||
if (!version || (strncmp(version, altra, sizeof(altra) - 1) &&
|
||||
strncmp(version, emag, sizeof(emag) - 1)))
|
||||
break;
|
||||
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
|
||||
index 27abb4ce029173..d33ccbc4a2c630 100644
|
||||
--- a/drivers/firmware/efi/libstub/efistub.h
|
||||
+++ b/drivers/firmware/efi/libstub/efistub.h
|
||||
@@ -1204,14 +1204,13 @@ struct efi_smbios_type4_record {
|
||||
u16 thread_enabled;
|
||||
};
|
||||
|
||||
-#define efi_get_smbios_string(__record, __type, __name) ({ \
|
||||
- int off = offsetof(struct efi_smbios_type ## __type ## _record, \
|
||||
- __name); \
|
||||
- __efi_get_smbios_string((__record), __type, off); \
|
||||
+#define efi_get_smbios_string(__record, __field) ({ \
|
||||
+ __typeof__(__record) __rec = __record; \
|
||||
+ __efi_get_smbios_string(&__rec->header, &__rec->__field); \
|
||||
})
|
||||
|
||||
const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record,
|
||||
- u8 type, int offset);
|
||||
+ const u8 *offset);
|
||||
|
||||
void efi_remap_image(unsigned long image_base, unsigned alloc_size,
|
||||
unsigned long code_size);
|
||||
diff --git a/drivers/firmware/efi/libstub/smbios.c b/drivers/firmware/efi/libstub/smbios.c
|
||||
index c217de2cc8d56d..520c9079717a30 100644
|
||||
--- a/drivers/firmware/efi/libstub/smbios.c
|
||||
+++ b/drivers/firmware/efi/libstub/smbios.c
|
||||
@@ -38,7 +38,7 @@ const struct efi_smbios_record *efi_get_smbios_record(u8 type)
|
||||
}
|
||||
|
||||
const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record,
|
||||
- u8 type, int offset)
|
||||
+ const u8 *offset)
|
||||
{
|
||||
const u8 *strtable;
|
||||
|
||||
@@ -46,7 +46,7 @@ const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record,
|
||||
return NULL;
|
||||
|
||||
strtable = (u8 *)record + record->length;
|
||||
- for (int i = 1; i < ((u8 *)record)[offset]; i++) {
|
||||
+ for (int i = 1; i < *offset; i++) {
|
||||
int len = strlen(strtable);
|
||||
|
||||
if (!len)
|
||||
--
|
||||
cgit 1.2.3-korg
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
From 84810a21ecab70568586217f185998bcf34b450e Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Mon, 1 Jul 2024 09:35:33 +0200
|
||||
Subject: x86/efistub: Enable SMBIOS protocol handling for x86
|
||||
|
||||
The smbios.c source file is not currently included in the x86 build, and
|
||||
before we can do so, it needs some tweaks to build correctly in
|
||||
combination with the EFI mixed mode support.
|
||||
|
||||
Reviewed-by: Lukas Wunner <lukas@wunner.de>
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
---
|
||||
drivers/firmware/efi/libstub/Makefile | 2 +-
|
||||
drivers/firmware/efi/libstub/smbios.c | 39 ++++++++++++++++++++++-------------
|
||||
include/linux/efi.h | 4 ++--
|
||||
3 files changed, 28 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
|
||||
index 06f0428a723cb8..1f32d6cf98d691 100644
|
||||
--- a/drivers/firmware/efi/libstub/Makefile
|
||||
+++ b/drivers/firmware/efi/libstub/Makefile
|
||||
@@ -76,7 +76,7 @@ lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o string.o intrinsics.o systable.o \
|
||||
|
||||
lib-$(CONFIG_ARM) += arm32-stub.o
|
||||
lib-$(CONFIG_ARM64) += kaslr.o arm64.o arm64-stub.o smbios.o
|
||||
-lib-$(CONFIG_X86) += x86-stub.o
|
||||
+lib-$(CONFIG_X86) += x86-stub.o smbios.o
|
||||
lib-$(CONFIG_X86_64) += x86-5lvl.o
|
||||
lib-$(CONFIG_RISCV) += kaslr.o riscv.o riscv-stub.o
|
||||
lib-$(CONFIG_LOONGARCH) += loongarch.o loongarch-stub.o
|
||||
diff --git a/drivers/firmware/efi/libstub/smbios.c b/drivers/firmware/efi/libstub/smbios.c
|
||||
index 520c9079717a30..f31410d7e7e180 100644
|
||||
--- a/drivers/firmware/efi/libstub/smbios.c
|
||||
+++ b/drivers/firmware/efi/libstub/smbios.c
|
||||
@@ -6,20 +6,31 @@
|
||||
|
||||
#include "efistub.h"
|
||||
|
||||
-typedef struct efi_smbios_protocol efi_smbios_protocol_t;
|
||||
-
|
||||
-struct efi_smbios_protocol {
|
||||
- efi_status_t (__efiapi *add)(efi_smbios_protocol_t *, efi_handle_t,
|
||||
- u16 *, struct efi_smbios_record *);
|
||||
- efi_status_t (__efiapi *update_string)(efi_smbios_protocol_t *, u16 *,
|
||||
- unsigned long *, u8 *);
|
||||
- efi_status_t (__efiapi *remove)(efi_smbios_protocol_t *, u16);
|
||||
- efi_status_t (__efiapi *get_next)(efi_smbios_protocol_t *, u16 *, u8 *,
|
||||
- struct efi_smbios_record **,
|
||||
- efi_handle_t *);
|
||||
-
|
||||
- u8 major_version;
|
||||
- u8 minor_version;
|
||||
+typedef union efi_smbios_protocol efi_smbios_protocol_t;
|
||||
+
|
||||
+union efi_smbios_protocol {
|
||||
+ struct {
|
||||
+ efi_status_t (__efiapi *add)(efi_smbios_protocol_t *, efi_handle_t,
|
||||
+ u16 *, struct efi_smbios_record *);
|
||||
+ efi_status_t (__efiapi *update_string)(efi_smbios_protocol_t *, u16 *,
|
||||
+ unsigned long *, u8 *);
|
||||
+ efi_status_t (__efiapi *remove)(efi_smbios_protocol_t *, u16);
|
||||
+ efi_status_t (__efiapi *get_next)(efi_smbios_protocol_t *, u16 *, u8 *,
|
||||
+ struct efi_smbios_record **,
|
||||
+ efi_handle_t *);
|
||||
+
|
||||
+ u8 major_version;
|
||||
+ u8 minor_version;
|
||||
+ };
|
||||
+ struct {
|
||||
+ u32 add;
|
||||
+ u32 update_string;
|
||||
+ u32 remove;
|
||||
+ u32 get_next;
|
||||
+
|
||||
+ u8 major_version;
|
||||
+ u8 minor_version;
|
||||
+ } mixed_mode;
|
||||
};
|
||||
|
||||
const struct efi_smbios_record *efi_get_smbios_record(u8 type)
|
||||
diff --git a/include/linux/efi.h b/include/linux/efi.h
|
||||
index 418e555459da7c..2a539816a4362d 100644
|
||||
--- a/include/linux/efi.h
|
||||
+++ b/include/linux/efi.h
|
||||
@@ -74,10 +74,10 @@ typedef void *efi_handle_t;
|
||||
*/
|
||||
typedef guid_t efi_guid_t __aligned(__alignof__(u32));
|
||||
|
||||
-#define EFI_GUID(a, b, c, d...) (efi_guid_t){ { \
|
||||
+#define EFI_GUID(a, b, c, d...) ((efi_guid_t){ { \
|
||||
(a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
|
||||
(b) & 0xff, ((b) >> 8) & 0xff, \
|
||||
- (c) & 0xff, ((c) >> 8) & 0xff, d } }
|
||||
+ (c) & 0xff, ((c) >> 8) & 0xff, d } })
|
||||
|
||||
/*
|
||||
* Generic EFI table header
|
||||
--
|
||||
cgit 1.2.3-korg
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
From d68cc8abc357c05ca1567458965f009add8bab69 Mon Sep 17 00:00:00 2001
|
||||
From: Aditya Garg <gargaditya08@live.com>
|
||||
Date: Sun, 30 Jun 2024 19:24:54 +0000
|
||||
Subject: x86/efistub: Call Apple set_os protocol on dual GPU Intel Macs
|
||||
|
||||
0c18184de990 ("platform/x86: apple-gmux: support MMIO gmux on T2 Macs")
|
||||
brought support for T2 Macs in apple-gmux. But in order to use dual GPU,
|
||||
the integrated GPU has to be enabled. On such dual GPU EFI Macs, the EFI
|
||||
stub needs to report that it is booting macOS in order to prevent the
|
||||
firmware from disabling the iGPU.
|
||||
|
||||
This patch is also applicable for some non T2 Intel Macs.
|
||||
|
||||
Based on this patch for GRUB by Andreas Heider <andreas@heider.io>:
|
||||
https://lists.gnu.org/archive/html/grub-devel/2013-12/msg00442.html
|
||||
|
||||
Credits also goto Kerem Karabay <kekrby@gmail.com> for helping porting
|
||||
the patch to the Linux kernel.
|
||||
|
||||
Cc: Orlando Chamberlain <orlandoch.dev@gmail.com>
|
||||
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||
[ardb: limit scope using list of DMI matches provided by Lukas and Orlando]
|
||||
Reviewed-by: Lukas Wunner <lukas@wunner.de>
|
||||
Tested-by: Aditya Garg <gargaditya08@live.com>
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
---
|
||||
drivers/firmware/efi/libstub/x86-stub.c | 71 +++++++++++++++++++++++++++++++--
|
||||
include/linux/efi.h | 1 +
|
||||
2 files changed, 69 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
|
||||
index 68df27bd71c9b4..51b7185f8707ff 100644
|
||||
--- a/drivers/firmware/efi/libstub/x86-stub.c
|
||||
+++ b/drivers/firmware/efi/libstub/x86-stub.c
|
||||
@@ -225,6 +225,68 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
|
||||
}
|
||||
}
|
||||
|
||||
+static bool apple_match_product_name(void)
|
||||
+{
|
||||
+ static const char type1_product_matches[][15] = {
|
||||
+ "MacBookPro11,3",
|
||||
+ "MacBookPro11,5",
|
||||
+ "MacBookPro13,3",
|
||||
+ "MacBookPro14,3",
|
||||
+ "MacBookPro15,1",
|
||||
+ "MacBookPro15,3",
|
||||
+ "MacBookPro16,1",
|
||||
+ "MacBookPro16,4",
|
||||
+ };
|
||||
+ const struct efi_smbios_type1_record *record;
|
||||
+ const u8 *product;
|
||||
+
|
||||
+ record = (struct efi_smbios_type1_record *)efi_get_smbios_record(1);
|
||||
+ if (!record)
|
||||
+ return false;
|
||||
+
|
||||
+ product = efi_get_smbios_string(record, product_name);
|
||||
+ if (!product)
|
||||
+ return false;
|
||||
+
|
||||
+ for (int i = 0; i < ARRAY_SIZE(type1_product_matches); i++) {
|
||||
+ if (!strcmp(product, type1_product_matches[i]))
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static void apple_set_os(void)
|
||||
+{
|
||||
+ struct {
|
||||
+ unsigned long version;
|
||||
+ efi_status_t (__efiapi *set_os_version)(const char *);
|
||||
+ efi_status_t (__efiapi *set_os_vendor)(const char *);
|
||||
+ } *set_os;
|
||||
+ efi_status_t status;
|
||||
+
|
||||
+ if (!efi_is_64bit() || !apple_match_product_name())
|
||||
+ return;
|
||||
+
|
||||
+ status = efi_bs_call(locate_protocol, &APPLE_SET_OS_PROTOCOL_GUID, NULL,
|
||||
+ (void **)&set_os);
|
||||
+ if (status != EFI_SUCCESS)
|
||||
+ return;
|
||||
+
|
||||
+ if (set_os->version >= 2) {
|
||||
+ status = set_os->set_os_vendor("Apple Inc.");
|
||||
+ if (status != EFI_SUCCESS)
|
||||
+ efi_err("Failed to set OS vendor via apple_set_os\n");
|
||||
+ }
|
||||
+
|
||||
+ if (set_os->version > 0) {
|
||||
+ /* The version being set doesn't seem to matter */
|
||||
+ status = set_os->set_os_version("Mac OS X 10.9");
|
||||
+ if (status != EFI_SUCCESS)
|
||||
+ efi_err("Failed to set OS version via apple_set_os\n");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
efi_status_t efi_adjust_memory_range_protection(unsigned long start,
|
||||
unsigned long size)
|
||||
{
|
||||
@@ -335,9 +397,12 @@ static const efi_char16_t apple[] = L"Apple";
|
||||
|
||||
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 (!memcmp(efistub_fw_vendor(), apple, sizeof(apple))) {
|
||||
+ if (IS_ENABLED(CONFIG_APPLE_PROPERTIES))
|
||||
+ retrieve_apple_device_properties(boot_params);
|
||||
+
|
||||
+ apple_set_os();
|
||||
+ }
|
||||
}
|
||||
|
||||
/*
|
||||
diff --git a/include/linux/efi.h b/include/linux/efi.h
|
||||
index 2a539816a4362d..3a6c04a9f9aadc 100644
|
||||
--- a/include/linux/efi.h
|
||||
+++ b/include/linux/efi.h
|
||||
@@ -385,6 +385,7 @@ void efi_native_runtime_setup(void);
|
||||
#define EFI_MEMORY_ATTRIBUTES_TABLE_GUID EFI_GUID(0xdcfa911d, 0x26eb, 0x469f, 0xa2, 0x20, 0x38, 0xb7, 0xdc, 0x46, 0x12, 0x20)
|
||||
#define EFI_CONSOLE_OUT_DEVICE_GUID EFI_GUID(0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
|
||||
#define APPLE_PROPERTIES_PROTOCOL_GUID EFI_GUID(0x91bd12fe, 0xf6c3, 0x44fb, 0xa5, 0xb7, 0x51, 0x22, 0xab, 0x30, 0x3a, 0xe0)
|
||||
+#define APPLE_SET_OS_PROTOCOL_GUID EFI_GUID(0xc5c5da95, 0x7d5c, 0x45e6, 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77)
|
||||
#define EFI_TCG2_PROTOCOL_GUID EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
|
||||
#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25)
|
||||
#define EFI_LOAD_FILE_PROTOCOL_GUID EFI_GUID(0x56ec3091, 0x954c, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
|
||||
--
|
||||
cgit 1.2.3-korg
|
||||
|
||||
@@ -11,22 +11,22 @@ Signed-off-by: Ashish Arora <ashisharora.linux@outlook.com>
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c
|
||||
index 112aa04..8fb8bcc 100644
|
||||
index 49a1ac4f549195..c8c10a6104c4e9 100644
|
||||
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
|
||||
@@ -217,10 +217,10 @@ static int intelfb_create(struct drm_fb_helper *helper,
|
||||
return ret;
|
||||
@@ -199,10 +199,10 @@ static int intelfb_create(struct drm_fb_helper *helper,
|
||||
ifbdev->fb = NULL;
|
||||
|
||||
if (intel_fb &&
|
||||
- (sizes->fb_width > intel_fb->base.width ||
|
||||
- sizes->fb_height > intel_fb->base.height)) {
|
||||
+ (sizes->fb_width != intel_fb->base.width ||
|
||||
+ sizes->fb_height != intel_fb->base.height)) {
|
||||
if (fb &&
|
||||
- (sizes->fb_width > fb->base.width ||
|
||||
- sizes->fb_height > fb->base.height)) {
|
||||
+ (sizes->fb_width != fb->base.width ||
|
||||
+ sizes->fb_height != fb->base.height)) {
|
||||
drm_dbg_kms(&dev_priv->drm,
|
||||
- "BIOS fb too small (%dx%d), we require (%dx%d),"
|
||||
+ "BIOS fb not valid (%dx%d), we require (%dx%d),"
|
||||
" releasing it\n",
|
||||
intel_fb->base.width, intel_fb->base.height,
|
||||
fb->base.width, fb->base.height,
|
||||
sizes->fb_width, sizes->fb_height);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
From 3d4a4a3d62815f90fc65a827a3e2de96c4571350 Mon Sep 17 00:00:00 2001
|
||||
From: Orlando Chamberlain <orlandoch.dev@gmail.com>
|
||||
Date: Fri, 7 Jul 2024 23:41:23 +1100
|
||||
Subject: [PATCH 1/1] acpi video: force native for some T2 macbooks
|
||||
|
||||
The intel backlight is needed for these, previously users had nothing in
|
||||
/sys/class/backlight.
|
||||
|
||||
Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
|
||||
---
|
||||
drivers/acpi/video_detect.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
|
||||
index 442396f6ed1f..baf7264d7b94 100644
|
||||
--- a/drivers/acpi/video_detect.c
|
||||
+++ b/drivers/acpi/video_detect.c
|
||||
@@ -513,6 +513,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
|
||||
DMI_MATCH(DMI_PRODUCT_NAME, "iMac12,2"),
|
||||
},
|
||||
},
|
||||
+ {
|
||||
+ .callback = video_detect_force_native,
|
||||
+ /* Apple MacBook Air 9,1 */
|
||||
+ .matches = {
|
||||
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
|
||||
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir9,1"),
|
||||
+ },
|
||||
+ },
|
||||
{
|
||||
/* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */
|
||||
.callback = video_detect_force_native,
|
||||
@@ -522,6 +530,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
|
||||
DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro12,1"),
|
||||
},
|
||||
},
|
||||
+ {
|
||||
+ .callback = video_detect_force_native,
|
||||
+ /* Apple MacBook Pro 16,2 */
|
||||
+ .matches = {
|
||||
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
|
||||
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
|
||||
+ },
|
||||
+ },
|
||||
{
|
||||
.callback = video_detect_force_native,
|
||||
/* Dell Inspiron N4010 */
|
||||
--
|
||||
2.42.1
|
||||
|
||||
+191
-342
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
||||
CURRENT_HASH=0667dbff17e88f0c7b9951d1738218787ea75822
|
||||
RELEASE_VER=0.3.11-1
|
||||
CURRENT_HASH=707d91b48603ce0832d863945bb845df799945af
|
||||
RELEASE_VER=0.3.10-2
|
||||
|
||||
Reference in New Issue
Block a user