Compare commits

...

4 Commits

Author SHA1 Message Date
Andy Nguyen
5b0dc56c1b linux: fix cu unlock patches 2026-05-30 21:47:59 +02:00
Andy Nguyen
bcf718f3d5 linux: improve icc code 2026-05-30 21:40:20 +02:00
Andy Nguyen
52b956d985 config: enable NFT_QUEUE and NFT_TUNNEL 2026-05-29 22:49:47 +02:00
Andy Nguyen
e9424efb51 linux: add icc_device_power_* functions and fix black screen 2026-05-29 22:43:06 +02:00
2 changed files with 135 additions and 77 deletions

10
.config
View File

@@ -1408,8 +1408,8 @@ CONFIG_NFT_LIMIT=m
CONFIG_NFT_MASQ=m
CONFIG_NFT_REDIR=m
CONFIG_NFT_NAT=m
# CONFIG_NFT_TUNNEL is not set
# CONFIG_NFT_QUEUE is not set
CONFIG_NFT_TUNNEL=m
CONFIG_NFT_QUEUE=m
# CONFIG_NFT_QUOTA is not set
CONFIG_NFT_REJECT=m
CONFIG_NFT_REJECT_INET=m
@@ -2015,6 +2015,7 @@ CONFIG_PNPACPI=y
CONFIG_BLK_DEV=y
# CONFIG_BLK_DEV_NULL_BLK is not set
# CONFIG_BLK_DEV_FD is not set
CONFIG_CDROM=y
# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set
CONFIG_ZRAM=m
CONFIG_ZRAM_BACKEND_LZ4=y
@@ -2132,7 +2133,6 @@ CONFIG_SCSI_PROC_FS=y
#
CONFIG_BLK_DEV_SD=y
# CONFIG_CHR_DEV_ST is not set
CONFIG_CDROM=y
CONFIG_BLK_DEV_SR=y
CONFIG_CHR_DEV_SG=y
CONFIG_BLK_DEV_BSG=y
@@ -2171,7 +2171,7 @@ CONFIG_SATA_PMP=y
# CONFIG_SATA_AHCI is not set
# CONFIG_SATA_AHCI_PLATFORM is not set
# CONFIG_AHCI_DWC is not set
CONFIG_AHCI_SALINA=y
CONFIG_AHCI_SALINA=m
# CONFIG_SATA_INIC162X is not set
# CONFIG_SATA_ACARD_AHCI is not set
# CONFIG_SATA_SIL24 is not set
@@ -3121,6 +3121,7 @@ CONFIG_SENSORS_K10TEMP=m
# CONFIG_SENSORS_CHIPCAP2 is not set
# CONFIG_SENSORS_CORSAIR_CPRO is not set
# CONFIG_SENSORS_CORSAIR_PSU is not set
# CONFIG_SENSORS_DRIVETEMP is not set
# CONFIG_SENSORS_DS620 is not set
# CONFIG_SENSORS_DS1621 is not set
# CONFIG_SENSORS_DELL_SMM is not set
@@ -4272,6 +4273,7 @@ CONFIG_LEDS_CLASS_MULTICOLOR=m
CONFIG_LEDS_TRIGGERS=y
# CONFIG_LEDS_TRIGGER_TIMER is not set
# CONFIG_LEDS_TRIGGER_ONESHOT is not set
# CONFIG_LEDS_TRIGGER_DISK is not set
# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
# CONFIG_LEDS_TRIGGER_CPU is not set

View File

@@ -506,10 +506,10 @@ index 20e6645ab737..bc98a92325b7 100644
obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
diff --git a/drivers/ata/ahci_salina.c b/drivers/ata/ahci_salina.c
new file mode 100644
index 000000000000..1ba1ba77f86d
index 000000000000..c020194eb44a
--- /dev/null
+++ b/drivers/ata/ahci_salina.c
@@ -0,0 +1,357 @@
@@ -0,0 +1,340 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * PlayStation 5 Salina SATA / BD-ROM AHCI host driver
@@ -530,30 +530,10 @@ index 000000000000..1ba1ba77f86d
+#include "ahci.h"
+#include "ahci_salina_phy.h"
+
+#define SALINA_ICC_POWER_SVC 0x05
+#define SALINA_ICC_POWER_SET 0x00
+#define PCI_DEVICE_ID_SPCIE 0x9107
+
+#define SALINA_ICC_DEV_BD 0x01
+
+static void salina_bd_icc_power_on(struct device *dev)
+{
+ u8 q[ICC_MSG_MAX_SIZE] = {0};
+ u8 r[ICC_MSG_MAX_SIZE] = {0};
+ struct icc_msg *m = (struct icc_msg *)q;
+ int rc;
+
+ m->service_id = SALINA_ICC_POWER_SVC;
+ m->msg_type = SALINA_ICC_POWER_SET;
+ m->length = 0x20;
+ m->data[0] = SALINA_ICC_DEV_BD;
+ m->data[1] = 0x01;
+
+ rc = icc_query(q, r);
+ if (rc == -ETIMEDOUT)
+ dev_info(dev, "BD drive already powered on\n");
+ else if (rc)
+ dev_warn(dev, "ICC BD power-on returned %d\n", rc);
+}
+
+struct salina_ahci {
+ struct salina_sata_phy phy;
+ struct pci_dev *glue;
@@ -563,7 +543,7 @@ index 000000000000..1ba1ba77f86d
+{
+ struct pci_dev *glue;
+
+ glue = pci_get_device(SALINA_VENDOR_ID, SALINA_GLUE_ID, NULL);
+ glue = pci_get_device(PCI_VENDOR_ID_SONY, PCI_DEVICE_ID_SPCIE, NULL);
+ if (!glue)
+ return -ENODEV;
+
@@ -612,7 +592,7 @@ index 000000000000..1ba1ba77f86d
+static int salina_pick_bar(u16 devid, u32 chip_id, unsigned int *abar,
+ u32 *port_off)
+{
+ bool is_9106 = (devid == SALINA_SATA_ID_B);
+ bool is_9106 = (devid == PCI_DEVICE_ID_AHCI_B);
+
+ if (!is_9106 && chip_id == SALINA_CHIP_SALINA2)
+ return -ENODEV;
@@ -646,6 +626,7 @@ index 000000000000..1ba1ba77f86d
+ struct salina_ahci *sa;
+ unsigned int abar, n_ports;
+ u32 chip_id;
+ u8 state;
+ int rc;
+
+ if (!spcie_is_initialized()) {
@@ -699,7 +680,9 @@ index 000000000000..1ba1ba77f86d
+ sa->phy.rx_tracelen = 0xff;
+ sa->phy.tx_tracelen = 0xff;
+
+ salina_bd_icc_power_on(dev);
+ icc_device_power_get(SALINA_ICC_DEV_BD, &state);
+ if (state != 1)
+ icc_device_power_control(SALINA_ICC_DEV_BD, 1);
+
+ rc = salina_sata_phy_init(&sa->phy);
+ if (rc) {
@@ -845,8 +828,8 @@ index 000000000000..1ba1ba77f86d
+static SIMPLE_DEV_PM_OPS(salina_ahci_pm, salina_ahci_suspend, salina_ahci_resume);
+
+static const struct pci_device_id salina_ahci_tbl[] = {
+ { PCI_DEVICE(SALINA_VENDOR_ID, SALINA_SATA_ID_A) },
+ { PCI_DEVICE(SALINA_VENDOR_ID, SALINA_SATA_ID_B) },
+ { PCI_DEVICE(PCI_VENDOR_ID_SONY, PCI_DEVICE_ID_AHCI_A) },
+ { PCI_DEVICE(PCI_VENDOR_ID_SONY, PCI_DEVICE_ID_AHCI_B) },
+ { }
+};
+MODULE_DEVICE_TABLE(pci, salina_ahci_tbl);
@@ -1058,10 +1041,10 @@ index 000000000000..c5e85ae102ea
+}
diff --git a/drivers/ata/ahci_salina_phy.h b/drivers/ata/ahci_salina_phy.h
new file mode 100644
index 000000000000..71a33382d920
index 000000000000..39cc76f39e06
--- /dev/null
+++ b/drivers/ata/ahci_salina_phy.h
@@ -0,0 +1,47 @@
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _SALINA_SATA_PHY_H
+#define _SALINA_SATA_PHY_H
@@ -1069,10 +1052,8 @@ index 000000000000..71a33382d920
+#include <linux/types.h>
+#include <linux/io.h>
+
+#define SALINA_VENDOR_ID 0x104d
+#define SALINA_SATA_ID_A 0x9105
+#define SALINA_SATA_ID_B 0x9106
+#define SALINA_GLUE_ID 0x9107
+#define PCI_DEVICE_ID_AHCI_A 0x9105
+#define PCI_DEVICE_ID_AHCI_B 0x9106
+
+#define SALINA_DEVID_A 0x9105104d
+#define SALINA_DEVID_B 0x9106104d
@@ -1347,7 +1328,7 @@ index 321310ba2c08..764da52902ac 100644
header = (const struct common_firmware_header *)
adev->sdma.instance[instance].fw->data;
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 8b60299b73ef..db803401a3be 100644
index 8b60299b73ef..7ecf928cae8e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -4202,6 +4202,14 @@ static void gfx_v10_0_check_gfxoff_flag(struct amdgpu_device *adev)
@@ -1425,7 +1406,7 @@ index 8b60299b73ef..db803401a3be 100644
amdgpu_gfx_cp_init_microcode(adev, AMDGPU_UCODE_ID_CP_MEC2);
amdgpu_gfx_cp_init_microcode(adev, AMDGPU_UCODE_ID_CP_MEC2_JT);
} else {
@@ -10104,6 +10131,24 @@ static u32 gfx_v10_0_get_cu_active_bitmap_per_sh(struct amdgpu_device *adev)
@@ -10104,6 +10130,21 @@ static u32 gfx_v10_0_get_cu_active_bitmap_per_sh(struct amdgpu_device *adev)
return cu_active_bitmap;
}
@@ -1439,27 +1420,22 @@ index 8b60299b73ef..db803401a3be 100644
+ * amdgpu.ps5_cu_unlock=0 (disable)
+ * amdgpu.ps5_cu_unlock=1 (probe)
+ */
+static int ps5_cu_unlock = 3;
+static int ps5_cu_unlock = 0;
+module_param(ps5_cu_unlock, int, 0444);
+MODULE_PARM_DESC(ps5_cu_unlock,
+ "PS5 harvested-CU unlock (0=off, 1=probe, 2=SE0/SH0, 3=all (default), 4=probe-all)");
+
+// PCI device ID of the silicon this unlock applies to.
+#define PS5_PCI_DEVID_RETAIL 0x13FB
+ "PS5 harvested-CU unlock (0=off (default), 1=probe, 2=SE0/SH0, 3=all, 4=probe-all)");
+
static int gfx_v10_0_get_cu_info(struct amdgpu_device *adev,
struct amdgpu_cu_info *cu_info)
{
@@ -10117,6 +10162,45 @@ static int gfx_v10_0_get_cu_info(struct amdgpu_device *adev,
@@ -10117,6 +10158,43 @@ static int gfx_v10_0_get_cu_info(struct amdgpu_device *adev,
amdgpu_gfx_parse_disable_cu(adev, disable_masks, 4, 2);
mutex_lock(&adev->grbm_idx_mutex);
+ /* PS5: unlock harvested CUs. CC alone updates enumeration but SPI
+ * still dispatches only to enabled WGPs; both writes are required
+ * (verified empirically on BC-250). */
+ if (ps5_cu_unlock > 0 &&
+ adev->pdev->vendor == PCI_VENDOR_ID_ATI &&
+ adev->pdev->device == PS5_PCI_DEVID_RETAIL) {
+ if (ps5_cu_unlock > 0) {
+ int ps5_se, ps5_sh;
+ for (ps5_se = 0; ps5_se < adev->gfx.config.max_shader_engines; ps5_se++) {
+ for (ps5_sh = 0; ps5_sh < adev->gfx.config.max_sh_per_se; ps5_sh++) {
@@ -5221,10 +5197,10 @@ index 000000000000..d2c25e461bf7
+#endif /* _AUTOSERVO_PARAM_H */
diff --git a/drivers/ps5/hdmi.c b/drivers/ps5/hdmi.c
new file mode 100644
index 000000000000..1193d840f5d6
index 000000000000..8f094490d677
--- /dev/null
+++ b/drivers/ps5/hdmi.c
@@ -0,0 +1,1226 @@
@@ -0,0 +1,1237 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
@@ -5747,8 +5723,8 @@ index 000000000000..1193d840f5d6
+
+void hdmiSystemResume(void)
+{
+ sceSetBackToUnpluggedSequence();
+ sceSetBackToWaitResolutionSequence();
+ // sceSetBackToUnpluggedSequence();
+ // sceSetBackToWaitResolutionSequence();
+ if (hdmi_ic_type == HDMI_IC_TYPE_FLAVA3) {
+ i2c_cmd_4_2();
+ // sceSetHdcpSequence1st();
@@ -6374,6 +6350,16 @@ index 000000000000..1193d840f5d6
+}
+EXPORT_SYMBOL(sceHdmiSetAudioMute);
+
+void sceHdmiOutputMode(void)
+{
+ i2c_init(4);
+ if (hdmi_ic_type == HDMI_IC_TYPE_FLAVA3) {
+ i2c_write(0x7005, 0x80);
+ }
+ i2c_exec();
+}
+EXPORT_SYMBOL(sceHdmiOutputMode);
+
+int getHdmiConfiguration(void)
+{
+ u8 buf[ICC_MSG_MAX_SIZE] = {};
@@ -6448,6 +6434,7 @@ index 000000000000..1193d840f5d6
+ fix_edid(&msg->data[4]);
+ real_edid = drm_edid_alloc(&msg->data[4], *(u16 *)&msg->data[2]);
+ pr_info("got real edid\n");
+ sceHdmiOutputMode();
+ }
+}
+EXPORT_SYMBOL(hdmi_notification_handler);
@@ -6947,10 +6934,10 @@ index 000000000000..4af890c842a7
+MODULE_LICENSE("GPL");
diff --git a/drivers/ps5/spcie.c b/drivers/ps5/spcie.c
new file mode 100644
index 000000000000..8a073f2f0f0a
index 000000000000..e02c074ee0b1
--- /dev/null
+++ b/drivers/ps5/spcie.c
@@ -0,0 +1,1084 @@
@@ -0,0 +1,1149 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
@@ -6960,6 +6947,7 @@ index 000000000000..8a073f2f0f0a
+#include <linux/ps5.h>
+#include <linux/dmi.h>
+#include <linux/delay.h>
+#include <linux/kfifo.h>
+#include "autoservo_param.h"
+
+#define PCI_DEVICE_ID_SPCIE 0x9107
@@ -7035,6 +7023,16 @@ index 000000000000..8a073f2f0f0a
+ void __iomem *pervasive0;
+};
+
+struct icc_notification {
+ u8 service_id;
+ u8 notification[ICC_MSG_MAX_SIZE];
+};
+
+#define ICC_NOTIFICATION_FIFO_SIZE 32
+static DEFINE_KFIFO(icc_notification_fifo, struct icc_notification, ICC_NOTIFICATION_FIFO_SIZE);
+static DEFINE_SPINLOCK(icc_notification_lock);
+static struct work_struct icc_notification_work;
+
+static struct spcie_dev *sdev;
+static struct spcie_icc_dev *icc_dev;
+
@@ -7118,16 +7116,12 @@ index 000000000000..8a073f2f0f0a
+
+ icc_send(query);
+
+ ret = wait_event_interruptible_timeout(icc_dev->wq, icc_dev->reply_ready,
+ ret = wait_event_timeout(icc_dev->wq, icc_dev->reply_ready,
+ msecs_to_jiffies(ICC_TIMEOUT_MSECS));
+ if (ret == 0) {
+ dev_err(&icc_dev->pdev->dev, "timeout\n");
+ mutex_unlock(&icc_dev->lock);
+ return -ETIMEDOUT;
+ } else if (ret < 0) {
+ dev_err(&icc_dev->pdev->dev, "interrupted\n");
+ mutex_unlock(&icc_dev->lock);
+ return -ETIMEDOUT;
+ }
+
+ memcpy(reply, icc_dev->reply, icc_dev->reply_length);
@@ -7360,6 +7354,42 @@ index 000000000000..8a073f2f0f0a
+}
+EXPORT_SYMBOL(icc_thermal_enable_notification);
+
+int icc_device_power_control(u8 device, u8 state)
+{
+ u8 buf[ICC_MSG_MAX_SIZE] = {};
+ struct icc_msg *msg = (struct icc_msg *)buf;
+
+ msg->service_id = ICC_SERVICE_ID_DEVICE;
+ msg->msg_type = 0;
+ msg->length = 0x20;
+ msg->data[0] = device;
+ msg->data[1] = state;
+
+ return icc_query(buf, buf);
+}
+EXPORT_SYMBOL(icc_device_power_control);
+
+int icc_device_power_get(u8 device, u8 *state)
+{
+ u8 buf[ICC_MSG_MAX_SIZE] = {};
+ struct icc_msg *msg = (struct icc_msg *)buf;
+ int ret;
+
+ msg->service_id = ICC_SERVICE_ID_DEVICE;
+ msg->msg_type = 1;
+ msg->length = 0x20;
+ msg->data[0] = device;
+
+ ret = icc_query(buf, buf);
+ if (ret)
+ return ret;
+
+ *state = msg->data[2];
+
+ return 0;
+}
+EXPORT_SYMBOL(icc_device_power_get);
+
+int icc_indicator_set_led(const u8 setting[], size_t setting_size)
+{
+ u8 buf[ICC_MSG_MAX_SIZE] = {};
@@ -7558,18 +7588,38 @@ index 000000000000..8a073f2f0f0a
+ }
+}
+
+static int icc_notification_handler(u8 service_id, u8 *buf)
+static void icc_notification_work_func(struct work_struct *work)
+{
+ struct icc_msg *msg = (struct icc_msg *)buf;
+ struct icc_msg *msg;
+ struct icc_notification entry;
+
+ if (service_id == ICC_SERVICE_ID_HDMI) {
+ hdmi_notification_handler(msg);
+ } else if (service_id == ICC_SERVICE_ID_BUTTON) {
+ button_notification_handler(msg);
+ while (kfifo_out_spinlocked(&icc_notification_fifo, &entry, 1, &icc_notification_lock)) {
+ msg = (struct icc_msg *)entry.notification;
+ if (entry.service_id == ICC_SERVICE_ID_HDMI) {
+ hdmi_notification_handler(msg);
+ } else if (entry.service_id == ICC_SERVICE_ID_BUTTON) {
+ button_notification_handler(msg);
+ } else {
+ pr_info("service id: %x\n", entry.service_id);
+ print_hex_dump(KERN_INFO, "event: ", DUMP_PREFIX_OFFSET, 16, 1,
+ msg->data, msg->length - sizeof(*msg), true);
+ }
+
+ }
+}
+
+static int icc_notification_handler(u8 service_id, u8 *notification)
+{
+ struct icc_msg *msg = (struct icc_msg *)notification;
+ struct icc_notification entry;
+
+ entry.service_id = service_id;
+ memcpy(entry.notification, msg, msg->length);
+
+ if (kfifo_in_spinlocked(&icc_notification_fifo, &entry, 1, &icc_notification_lock)) {
+ schedule_work(&icc_notification_work);
+ } else {
+ pr_info("service id: %x\n", service_id);
+ print_hex_dump(KERN_INFO, "event: ", DUMP_PREFIX_OFFSET, 16, 1,
+ msg->data, msg->length - sizeof(*msg), true);
+ pr_warn_ratelimited("icc notification buffer full\n");
+ }
+
+ return 0;
@@ -7612,7 +7662,7 @@ index 000000000000..8a073f2f0f0a
+ writel(ICC_ACK, icc_dev->icc_doorbell_base + ICC_REG_DOORBELL);
+
+ icc_dev->reply_ready = true;
+ wake_up_interruptible(&icc_dev->wq);
+ wake_up(&icc_dev->wq);
+ } else {
+ dev_err(&icc_dev->pdev->dev, "unknown query\n");
+ }
@@ -7682,6 +7732,8 @@ index 000000000000..8a073f2f0f0a
+
+ sdev->icc_dev = icc_dev;
+
+ INIT_WORK(&icc_notification_work, icc_notification_work_func);
+
+ mutex_init(&icc_dev->lock);
+ init_waitqueue_head(&icc_dev->wq);
+
@@ -8360,10 +8412,10 @@ index 2eedf44e6801..2785a47665be 100644
extern void dmi_setup(void);
diff --git a/include/linux/ps5.h b/include/linux/ps5.h
new file mode 100644
index 000000000000..7ed7adc99719
index 000000000000..4020a0b0c61c
--- /dev/null
+++ b/include/linux/ps5.h
@@ -0,0 +1,89 @@
@@ -0,0 +1,93 @@
+#ifndef _LINUX_PS5_H
+#define _LINUX_PS5_H
+
@@ -8390,18 +8442,18 @@ index 000000000000..7ed7adc99719
+ ICC_SERVICE_ID_NVS = 0x03,
+ ICC_SERVICE_ID_POWER = 0x04,
+ ICC_SERVICE_ID_DEVICE = 0x05,
+ ICC_SERVICE_ID_UNKNOWN1 = 0x07,
+ ICC_SERVICE_ID_UNKNOWN_07 = 0x07,
+ ICC_SERVICE_ID_BUTTON = 0x08,
+ ICC_SERVICE_ID_INDICATOR = 0x09,
+ ICC_SERVICE_ID_FAN = 0x0a,
+ ICC_SERVICE_ID_THERMAL = 0x0b,
+ ICC_SERVICE_ID_HDMI = 0x10,
+ ICC_SERVICE_ID_USBC = 0x12,
+ ICC_SERVICE_ID_UNKNOWN3 = 0x13,
+ ICC_SERVICE_ID_UNKNOWN_13 = 0x13,
+ ICC_SERVICE_ID_CRASH_REPORT = 0x14,
+ ICC_SERVICE_ID_BDDRIVE = 0x15,
+ ICC_SERVICE_ID_UNKNOWN4 = 0x8c,
+ ICC_SERVICE_ID_UNKNOWN5 = 0x8d,
+ ICC_SERVICE_ID_UNKNOWN_8C = 0x8c,
+ ICC_SERVICE_ID_UNKNOWN_8D = 0x8d,
+ ICC_SERVICE_ID_SC_CONFIG = 0x8e,
+ ICC_SERVICE_ID_FLOYD = 0x9a,
+};
@@ -8422,6 +8474,7 @@ index 000000000000..7ed7adc99719
+void sceHdmiSetAudioConfig(int channels);
+void sceHdmiDeviceSetVideoMute(int mute);
+void sceHdmiSetAudioMute(int mute);
+void sceHdmiOutputMode(void);
+int getHdmiConfiguration(void);
+bool isHdmiModeValid(const struct drm_display_mode *mode, int force_1080p);
+
@@ -8440,6 +8493,9 @@ index 000000000000..7ed7adc99719
+int icc_button_enable_all_notifications(u8 enable);
+int icc_thermal_enable_notification(u8 enable);
+
+int icc_device_power_control(u8 device, u8 state);
+int icc_device_power_get(u8 device, u8 *state);
+
+int icc_indicator_set_led(const u8 setting[], size_t setting_size);
+int icc_indicator_set_led_white(u8 level);
+