From patchwork Tue Jan 30 19:26:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 768887 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30B987B3D4; Tue, 30 Jan 2024 19:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706642804; cv=fail; b=P0vJumxF72OHwZtteNKUHwzM09ln90mcEUZ3diIwUo0Hsxb2/aunxubHwedbPykZvjEB2eoEk8lh7mVxO8eDyvCx/3HdceBo+tdpMCaTBKOPjjOozfUKXb8lMA16/jh7U3HOkwBUn92xzRhK1ycqSzfgBnhzGDGpN69K8rG6NXw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706642804; c=relaxed/simple; bh=HFvf+79QPYY5ESPgxglG8MrZ7sgz42v949aZyJbBYco=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CaUtI0fC1FCixl2qr97Y+zjlNznSuOpZB19SeI3SSap+R7D3BT/b1kMLIsdEciXUZp9Vh+7jQEVIkroQZoDebqj+4b5ixVoW14Y9J+3XRp270/UCTXASWs4Lcr+pqBSZUIV1N3AXCmVe28zuA0qGgPIqV5wAW0swOSGxaqD+8aM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Lx7QSYTp; arc=fail smtp.client-ip=40.107.223.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Lx7QSYTp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J9rvqWZb8n01NdPaoMzz0VAZkMsT9remw+AUULwx45OBIwaRMJWZpMBZTkTSWGbQ4ppsdiD9SS9JSqlKMD14J+ODCtGXV7Q8neq2uKjjuSlvUvBYd176AVTSIMcao5ZyB4V6ElLZcuN+lymzaRKzLv7pc5He9R1h92SiVClso6MbealH+KGphdvov/go1U4UpyrftxzRgGcAAa0OXdVyVaNbsQIlpqJpS1cn8B1QV079bSxMe02tDMb07QjpCfodKr46J+1UGYIqWIDG/CXl2zPaqQHA8oNt0vueog7lWtYwW38k6HBFqSAVBxl9KRwJe0rTPkc3gm8y5NnCzfvg8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a3+VTX+hgPPjNjj8MiC6pwK3XabNvZpzXJgEJU5lRY0=; b=lgkoAZwrt2f9SVtSRdM9nsr3CEWjGDHojuZ6n2RN8AhYxwbFbpSz4iSYyGtDpAlaxGvGh2s3w6fEQfu/4k5KX4rSmwjuDu4aqZOVMugE1nwR94zIhNNUoMztmor5GTd0/Q5wI8YeusY1nE60cRHrbRHNKdnebit2if4N0ATks5/GfjpGGrZsLV4/8e3YpS1WMkk29a4z3VZuA1mk1Rva+llL5cliiBzZiQt0C4KPuEr3Dol5eaIPTEK629bop5no2Kjps14/HCF5lE09Ewtu+HdfsQ/kJmLJS5OI8gTeFBlLaYPNkg3ybZ0pd/9RNizLopnHNQEplVJEqbuorol8dA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a3+VTX+hgPPjNjj8MiC6pwK3XabNvZpzXJgEJU5lRY0=; b=Lx7QSYTpVDFnGr1go+M5CnYFuXrSKLXClIZhYAH959CBkVJV1r0+VEJ5msG65Cx9dMaQ1VDAKbE+lj6farN2SyfzhqtjUteuQ1SDAwoOtGqIobHVKR2QTVKnHX68z4UQeiFtGwvm764ScDIu46znLsYe0/+gH18WJymg6f8ieFE= Received: from MW3PR05CA0016.namprd05.prod.outlook.com (2603:10b6:303:2b::21) by CY8PR12MB8361.namprd12.prod.outlook.com (2603:10b6:930:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34; Tue, 30 Jan 2024 19:26:39 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:303:2b:cafe::6a) by MW3PR05CA0016.outlook.office365.com (2603:10b6:303:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22 via Frontend Transport; Tue, 30 Jan 2024 19:26:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Tue, 30 Jan 2024 19:26:38 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 30 Jan 2024 13:26:36 -0600 From: Mario Limonciello To: , Alex Deucher , Harry Wentland , "Rafael J . Wysocki" , Hans de Goede CC: "open list:ACPI" , open list , "open list:DRM DRIVERS" , Melissa Wen , "Mark Pearson" , Mario Limonciello Subject: [PATCH v2 1/4] ACPI: video: Handle fetching EDID that is longer than 256 bytes Date: Tue, 30 Jan 2024 13:26:05 -0600 Message-ID: <20240130192608.11666-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240130192608.11666-1-mario.limonciello@amd.com> References: <20240130192608.11666-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E7:EE_|CY8PR12MB8361:EE_ X-MS-Office365-Filtering-Correlation-Id: e2f66816-19cc-4261-f1ba-08dc21c96147 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nev1TcG/QWrnsWEnmekabktGdXD6URCIjf5I+nk/oP22X8ZTVfDynyEqhqyzfrrCl2uXD9pK6RGw5P8mq4Hibifg6bwGqlr2wTBwMrrVoR5Q1tzayJpNjtLPZt2/TAqxqliJLK8XmlYfNlNJpCIySjqA+Fl5n9+C7gslvfkmMWATdvRMUmvuDl8GB3ZoJE7UXig0a5tJh95v2wuIr52Dh1UDkyu3JOXUJYzQwgHJ9IESGkj11f8MpTucB5x9977jqfUHrlGvY96tysBiIaByhtUK59Ve+1Wf5soiA1KERkjoFexFW62DeuBe3HitPXzlLpdHgWMFpoiPQJj0cAKTpoOPQHgkPLAfHo+74fCnYSwD3/W0DQPfZreAS/SHLBPaQFm3NNihl4dXGWpNG/B2zGS3C8I9zSBoR1e0Oot0rNA3H9ZcBdsWGcqRw5EyzO1Fx/irGv6J5wtQIiZRZTixv2s7E6iOuOo6oTh2wQPxu9vDq4pKU6tSh6Y8hDO1uIdqFs70vd+A0R6aRu5WFXTJHtmCBdR96HsaxOMOG1bAeL2Motnlm0l10HFpBJ3WQlcyfKYUhC8fpM82KmYjY5y7C59PjB0wpvpm/15l1iC10wlWR8TUVrrBiRZkDxrW+QK6i21UChJ0QiJo74MdnNp4D/hu75cEwJsu9eGIE8fDeg6o8YdG2a0AkKPRFRLFEzNcex/tN4CkzMBBcViStcOI2InqfrpmmI8hXhWQmMtjFh+IKRl8C98zBPK5clQ55mHSvkydXJ63qhdcI0HtRbd5scPpF+wLM02z7sBFeh77obU= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(230922051799003)(82310400011)(451199024)(64100799003)(186009)(1800799012)(36840700001)(46966006)(40470700004)(36756003)(4326008)(8676002)(8936002)(110136005)(2906002)(86362001)(5660300002)(44832011)(70206006)(54906003)(70586007)(316002)(966005)(83380400001)(36860700001)(6666004)(47076005)(356005)(82740400003)(81166007)(7696005)(478600001)(26005)(2616005)(16526019)(1076003)(336012)(426003)(41300700001)(40460700003)(40480700001)(148743002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2024 19:26:38.2297 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2f66816-19cc-4261-f1ba-08dc21c96147 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8361 The ACPI specification allows for an EDID to be up to 512 bytes but the _DDC EDID fetching code will only try up to 256 bytes. Modify the code to instead start at 512 bytes and work it's way down instead. As _DDC is now called up to 4 times on a machine debugging messages are noisier than necessary. Decrease from info to debug. Link: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/Apx_B_Video_Extensions/output-device-specific-methods.html#ddc-return-the-edid-for-this-device Signed-off-by: Mario Limonciello --- v1->v2: * Use for loop for acpi_video_get_edid() * Use one of Rafael's suggestions for acpi_video_device_EDID() * Decrease message level too I was going to split this separately, but decided to keep it in the same series in case there is any decision to change the interface to acpi_video_get_edid() at the same series. --- drivers/acpi/acpi_video.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 4afdda9db019..3bfd013e09d2 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -625,12 +625,9 @@ acpi_video_device_EDID(struct acpi_video_device *device, if (!device) return -ENODEV; - if (length == 128) - arg0.integer.value = 1; - else if (length == 256) - arg0.integer.value = 2; - else + if (!length || (length % 128)) return -EINVAL; + arg0.integer.value = length / 128; status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer); if (ACPI_FAILURE(status)) @@ -641,7 +638,8 @@ acpi_video_device_EDID(struct acpi_video_device *device, if (obj && obj->type == ACPI_TYPE_BUFFER) *edid = obj; else { - acpi_handle_info(device->dev->handle, "Invalid _DDC data\n"); + acpi_handle_debug(device->dev->handle, + "Invalid _DDC data for length %ld\n", length); status = -EFAULT; kfree(obj); } @@ -1447,7 +1445,6 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id, for (i = 0; i < video->attached_count; i++) { video_device = video->attached_array[i].bind_info; - length = 256; if (!video_device) continue; @@ -1478,18 +1475,14 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id, continue; } - status = acpi_video_device_EDID(video_device, &buffer, length); - - if (ACPI_FAILURE(status) || !buffer || - buffer->type != ACPI_TYPE_BUFFER) { - length = 128; + for (length = 512; length > 0; length -= 128) { status = acpi_video_device_EDID(video_device, &buffer, length); - if (ACPI_FAILURE(status) || !buffer || - buffer->type != ACPI_TYPE_BUFFER) { - continue; - } + if (ACPI_SUCCESS(status)) + break; } + if (!length) + continue; *edid = buffer->buffer.pointer; return length; From patchwork Tue Jan 30 19:26:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 768114 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC4D27B3CF; Tue, 30 Jan 2024 19:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706642804; cv=fail; b=Nc2mvcqajtReKBGLwyoUNsmVa4sqO7OU4t+RKz5590D2H9LfXGK1SWMhQnZ3vUt9Pg9HKhvtJjZpGmozGzkDt+nubjwg8wrqk2gfhX2ZlgyCQzBbxcKNfeUnIk2eHw9udffSYB0yPd/o4eDxaiAqkdCZCxZ4HdqAy+U9xoWlehk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706642804; c=relaxed/simple; bh=OsQ13b47E9eGFpCjlGDKy0SMaXKVoEb0+UMEZ5SIFXI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lSS37NJ1VlcpZ5DCNrWdj1oOCKuVx1xqpH5Mu9RqFTFAYS4JGWvycLN3hhzUpYzhU4+V2TIy2EVCqQgiUmWJ36aB9q1lmpGLU1PZZjoZaW/KmPkd5snWxsMfjSDNpdJaPVmXmSRxkzXLEx6k87G+Bw7FTmziYyEkKVLHzwk0laA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=K88CVW/l; arc=fail smtp.client-ip=40.107.223.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="K88CVW/l" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cQI2ncC6amPfVbK7823viQWi6+6Oc+XYgoRtH9ozp/lTpl5fIg7CtsjdAIbmdUtu01PeNZlP732pOjAwyjNi1wbaItsRkNUJEfLSuV7bkLEG3H/Da6J2js5z5l4UNWQL2opTvTEIaEaFz2CIce1IXiHbzkUmDkeMALbLILbMSM0SNpYnnC8iBC9xwoHMnnn27RS2VoGp9MS2P6RUZdY9Arq530v+VNUDVlRKLeFD7939dt8BkmcFrIL0wEsPpW4zpRvHy2D8bpTzLmqs40ry3byCZLF6FdWQYLd5jRI+sz3xANFlGcYpva4qjLhhmPreaL1S4GHLfLh0/i5QZ6cl6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GUV/SfNT6YO2D0Y8SkwnLSND4pHgedqZa4AKzXhj4as=; b=l+bNIEhNYcjQSva/llFGQYp8eY6hMnXp46cBkCXaKB5ZYY03q1tWQXa1YFr6iIyx3oQC/NiPbnT66f/AKkbzckONmEz+d2tM5x4CkRWz2SYHkcALyn2XfGn44E0gIzO2sNCMmqrLzVVhWZYhOchLxEDWCAMeAmTflNwBHqgGy7BcNnM/Fy/MwyD61UN13PQIASWWK0H1CtMxCHNUdzVz9ab1vXBRIZGaq/bCqYS7ZiDOF/s+7DdV7K9QiPoqgGs7/MCA3phETyQLoKip3ts4mZbP1LPQwKOY7uQtukfauKEYcv3bZS/Ao2dtH9rl9j1BIFmMuHTmH/hgHcCiB+JMLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GUV/SfNT6YO2D0Y8SkwnLSND4pHgedqZa4AKzXhj4as=; b=K88CVW/lakgcgW+Uyf9H4ZWqdD39QIxoltMl8tQqad49CY0Xh4ZclmXKXFPlaNQaGv1AFFVgXLp20aIrsnflR2Iyye7WZmkFjEWXygyssVqmUkV+2V+WvZCkCzrhDLqYXqfTwOJfCayNMMc8TtbzcA+G93ZdEyIA0cGXfK6S8hg= Received: from MW3PR05CA0015.namprd05.prod.outlook.com (2603:10b6:303:2b::20) by MW6PR12MB7088.namprd12.prod.outlook.com (2603:10b6:303:238::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22; Tue, 30 Jan 2024 19:26:39 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:303:2b:cafe::76) by MW3PR05CA0015.outlook.office365.com (2603:10b6:303:2b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22 via Frontend Transport; Tue, 30 Jan 2024 19:26:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Tue, 30 Jan 2024 19:26:39 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 30 Jan 2024 13:26:36 -0600 From: Mario Limonciello To: , Alex Deucher , Harry Wentland , "Rafael J . Wysocki" , Hans de Goede CC: "open list:ACPI" , open list , "open list:DRM DRIVERS" , Melissa Wen , "Mark Pearson" , Mario Limonciello Subject: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper Date: Tue, 30 Jan 2024 13:26:06 -0600 Message-ID: <20240130192608.11666-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240130192608.11666-1-mario.limonciello@amd.com> References: <20240130192608.11666-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E7:EE_|MW6PR12MB7088:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e792278-c82b-49cf-4a40-08dc21c96223 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Toe45ZrHu4YA2zS4UxWxGODsDJ63kC+gz3bM737SObEsbJsurxI5SJTs2wf0F3hz3Z0mTgeBBddRQsu+JRLyz2OhuetUfpwnB7mnhd6aN68t3owEpuLd5vqs0cXPV1CsuFhYKMtrFwSmHhhJIaWqnv4awuoMa1Dvc+pMesrfrrgJn8M+McaQndWFjAYUiMvVSeExGDoip7Jsnmd1rle0XtPKuN3Hr5szHI+0kKgA+9OopMlgHzabQisDDzMTY+rNHeHHk5YC8I+oZNKLudqw2W61XnIeG5bkvjzlucwqJq5Fx4WcFsakK6Ofyb07zNQ9XR9sK6GJM7oV2v/B9EZ6DXMMqweVJtg24plWVcITLWBSaHeVPt2GSeJCMp72Q1UEtJGp1Ui2EQvvdZz0VaOQvatGfuuWM5TOutWyhxGwr66d460zczC2blwSAYTqpFolqUezGKcS4O2mT46XrbcSaipVShyhKAA9kQBCD5/Vv77r94mkUVKPNKvCcGhEpX8F8qPJnjrAfwYOxGE5CA9gcU9KsM+rdxwG0arqizwTqiXXcDHv3DsI7wFP6bfzuUk4Y+YxSMKa7yND0Jk9FAO2awpFFKSVegmHuFkCHgSVEXAfWHI1/x0OtlrAABdWFykYSvnEjJyWLThT1X1Sx0tPrrW+PaN4gE2kuIjYokqWZcsQ/3LBPjH9KPKNpz943Xu9W0gVhKWt+JjR/BhQzC2PZ7PGiXI54RNZnnYzQ2IJAGEpQG331rBNN+WLPvGcC6A/Ip4ofEcVF8BBHH+/NuSM6w== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(376002)(136003)(39860400002)(396003)(230922051799003)(186009)(64100799003)(1800799012)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(66899024)(36860700001)(478600001)(110136005)(356005)(44832011)(86362001)(81166007)(2906002)(70206006)(54906003)(70586007)(316002)(36756003)(4326008)(8676002)(82740400003)(5660300002)(8936002)(41300700001)(7696005)(426003)(336012)(40460700003)(40480700001)(83380400001)(47076005)(2616005)(16526019)(1076003)(26005)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2024 19:26:39.6828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e792278-c82b-49cf-4a40-08dc21c96223 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB7088 Some manufacturers have intentionally put an EDID that differs from the EDID on the internal panel on laptops. Drivers can call this helper to attempt to fetch the EDID from the BIOS's ACPI _DDC method. Signed-off-by: Mario Limonciello --- v1->v2: * Split code from previous amdgpu specific helper to generic drm helper. --- drivers/gpu/drm/Kconfig | 4 +++ drivers/gpu/drm/drm_edid.c | 73 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 1 + 3 files changed, 78 insertions(+) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 2520db0b776e..0065dcb63745 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -21,6 +21,10 @@ menuconfig DRM select KCMP select VIDEO_CMDLINE select VIDEO_NOMODESET + select ACPI_VIDEO if ACPI + select BACKLIGHT_CLASS_DEVICE if ACPI + select INPUT if ACPI + select ACPI_WMI if X86 help Kernel-level support for the Direct Rendering Infrastructure (DRI) introduced in XFree86 4.0. If you say Y here, you need to select diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 69c68804023f..1fbbeaa664b2 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -28,6 +28,7 @@ * DEALINGS IN THE SOFTWARE. */ +#include #include #include #include @@ -2188,6 +2189,47 @@ drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len) return ret == xfers ? 0 : -1; } +/** + * drm_do_probe_acpi_edid() - get EDID information via ACPI _DDC + * @data: struct drm_device + * @buf: EDID data buffer to be filled + * @block: 128 byte EDID block to start fetching from + * @len: EDID data buffer length to fetch + * + * Try to fetch EDID information by calling acpi_video_get_edid() function. + * + * Return: 0 on success or error code on failure. + */ +static int +drm_do_probe_acpi_edid(void *data, u8 *buf, unsigned int block, size_t len) +{ + struct drm_device *ddev = data; + struct acpi_device *acpidev = ACPI_COMPANION(ddev->dev); + unsigned char start = block * EDID_LENGTH; + void *edid; + int r; + + if (!acpidev) + return -ENODEV; + + /* fetch the entire edid from BIOS */ + r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, &edid); + if (r < 0) { + DRM_DEBUG_KMS("Failed to get EDID from ACPI: %d\n", r); + return -EINVAL; + } + if (len > r || start > r || start + len > r) { + r = EINVAL; + goto cleanup; + } + + memcpy(buf, edid + start, len); + r = 0; +cleanup: + kfree(edid); + return r; +} + static void connector_bad_edid(struct drm_connector *connector, const struct edid *edid, int num_blocks) { @@ -2643,6 +2685,37 @@ struct edid *drm_get_edid(struct drm_connector *connector, } EXPORT_SYMBOL(drm_get_edid); +/** + * drm_get_acpi_edid - get EDID data, if available + * @connector: connector we're probing + * + * Use the BIOS to attempt to grab EDID data if possible. If found, + * attach it to the connector. + * + * Return: Pointer to valid EDID or NULL if we couldn't find any. + */ +struct edid *drm_get_acpi_edid(struct drm_connector *connector) +{ + struct edid *edid = NULL; + + switch (connector->connector_type) { + case DRM_MODE_CONNECTOR_LVDS: + case DRM_MODE_CONNECTOR_eDP: + break; + default: + return NULL; + } + + if (connector->force == DRM_FORCE_OFF) + return NULL; + + edid = _drm_do_get_edid(connector, drm_do_probe_acpi_edid, connector->dev, NULL); + + drm_connector_update_edid_property(connector, edid); + return edid; +} +EXPORT_SYMBOL(drm_get_acpi_edid); + /** * drm_edid_read_custom - Read EDID data using given EDID block read function * @connector: Connector to use diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 518d1b8106c7..60fbdc06badc 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -412,6 +412,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, void *data); struct edid *drm_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter); +struct edid *drm_get_acpi_edid(struct drm_connector *connector); u32 drm_edid_get_panel_id(struct i2c_adapter *adapter); struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, struct i2c_adapter *adapter); From patchwork Tue Jan 30 19:26:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 768886 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2079.outbound.protection.outlook.com [40.107.223.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C90AE69DE4; Tue, 30 Jan 2024 19:26:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706642807; cv=fail; b=RrqLHjSkoS65/kZ2gKR6O7/EKxaheEW6Yqzn8wAdeE7WZby5qGUIuyPp01zNP8QrhxrFl4MS3oV35VH96j8gllxHsMQjjQnQuLJklvx2mdm+015Dn/iRezZzWXOII5UQGJyJksajuTZzK5bNY8ZUd4mvruOxH7bs+GySWVCvnfM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706642807; c=relaxed/simple; bh=r3ILdclr4WwDh6gwGivDJDrcSUz9fgW4v02IFnQ4XcM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HAWIJUvNvxPuOZVzRpRGCwDxuI7bz/GmmG0abUEtHa/vFa2NWAILCod3DODjmJ5mKUKCd5gxAMmT9+a9fcfpb3WNJhKGM67YY61YzCWNuGR13YSjWPGX0n5164PAL0TezY+DPQIBhlWwdNndnn5pS3417q3jnYk8xOiOx7Ez9Bw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=mpaWPdgB; arc=fail smtp.client-ip=40.107.223.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="mpaWPdgB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D/gPDtNo+V+Bzen+QrtpWvlm75k3/7kzQrCQ3cFJ/C8MHBvvmY9a37bDHC/ddRY2HlfzylXFACnEVo1x4DqH8zM4wPQ54ofPFlQ/NDdtm7b+5uM5LroaVKOYzBakIhU3sdSJisF+Tz8LX5gw95ZITMXcDKjL0nJlpCiXPbYBhsF8U4tbVLVAQcGKDBaDUm64uPt2DPjEMFZrJjznLiEQwo0ptaVuYgAJgoScQUHNh2X3zkdVrnZPc+lTz/fFwSOapmnbouXHaXC/SkoNVIySx3nunAHrDrGTsTZyJpxtTsF4bob6x272By3DVGseocR4BDj1hVngw9piB9ihlrAXmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WvdY9+EfGzsWnuaI1pRPOqi6JEPcNDV0fXiaLf5JpnE=; b=JRU4lNcEt3I+kxNgWRurnXnVvOac9DT5MB+WrVSih9Vwnt1Fw5cp5BuD3TBuQmVF0gIjLAgd5Q1alM+oBKMP09zwdXUwXSBe7+hKqgIvc9Gfg4sz+FsLkedXuQsdAzTlRYRlqHqrgXsbL6DLv6Z6ixxc5mANR5LoPNsGOmlJDh/pSuQpXGtWj7kzE83Sxb8D741taGVBYFLgM80kNWG42TNstVrRxRcnlEP+u/ctvmHmxhv/CMAcBvDuWFTuZqyiW9OAjL2FHRnmoUZiSJECocrC93W0kyLYG5cGI6jiefsJVAOSwYaGoSpm6EV9F+3U61RQnzfAaHG6lOY0A3swwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WvdY9+EfGzsWnuaI1pRPOqi6JEPcNDV0fXiaLf5JpnE=; b=mpaWPdgBdO6Wb2nt7ylxZ4qDZn0QYIbxk2NJxpv4ULZz7j1oOR2i4UbpMHqh/U9DDPAheRgXGVYnwXiMTvb7IwNLxmP6i4tPzwrh7X0i/vNtNm+vhxtfMxcYbJdjch7GQVFsq5wrHV/nZyGWrBLhj+BycJ2m00bYlrtbuO/85Lk= Received: from MW3PR05CA0024.namprd05.prod.outlook.com (2603:10b6:303:2b::29) by CY5PR12MB6250.namprd12.prod.outlook.com (2603:10b6:930:22::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.32; Tue, 30 Jan 2024 19:26:40 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:303:2b:cafe::4a) by MW3PR05CA0024.outlook.office365.com (2603:10b6:303:2b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.23 via Frontend Transport; Tue, 30 Jan 2024 19:26:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Tue, 30 Jan 2024 19:26:40 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 30 Jan 2024 13:26:37 -0600 From: Mario Limonciello To: , Alex Deucher , Harry Wentland , "Rafael J . Wysocki" , Hans de Goede CC: "open list:ACPI" , open list , "open list:DRM DRIVERS" , Melissa Wen , "Mark Pearson" , Mario Limonciello Subject: [PATCH v2 3/4] drm/amd: Fetch the EDID from _DDC if available for eDP Date: Tue, 30 Jan 2024 13:26:07 -0600 Message-ID: <20240130192608.11666-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240130192608.11666-1-mario.limonciello@amd.com> References: <20240130192608.11666-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E7:EE_|CY5PR12MB6250:EE_ X-MS-Office365-Filtering-Correlation-Id: 23b07ffb-3c9d-4640-92ec-08dc21c962ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tlcuxJmHDXKNaWhoV68zxYzlE9hWzNIHLTuhxxAGpf+NQrHCYG8KJehxwzMUR2DUnttx0bwKT6rdwNqsuZ8JnkRc7332qkakGcj8kGUt/z3w1kgLhC3PFOTy97DjH3jKlFnGtk4jZmrX4HoP04mhKb54sgCzpwC5hDgA0b+SWUhkvyLG0RE+7cfPFSPACSExKNbTrF7pww29/bMyofjZ1613K31hsgByQ3xr0+WnZX/uU655p2UrsXzjgmJ0R82uEd6WbFuwZUN1hTPb7bGZ2zovPH6ESXKj9Pda93TYiriFQzckfP+OA25Ay+SAF9pI8EosB2Qt+NQiddybGcJ3E+CitpUmaya61lxgbzxRyHmNGQ/8/VuhCgTJMkmTvYhO+zIPxfqmezrB/okniWmTSos62rtKl/N930GXSW9Lxwt9rjQcfMOI/dq+jHqweiDRD/wvClW3DByoonCd63UjwD3CE/liayHkiF6JQm/dO36+GZR7rlBsDqNdOrMSzwX6Q2BfVPLOgAgQ9dfcM9ZzwlT/YSL8VkyiKNUPDLneLEjwgox3WtIq3pSwJDuqCjQAYVliRp88BdCF9t90x+LkEFhFH3JUQLHcEY1CGjVsbL1Gib6SKs3nLREWh1sQEW0SgNt5D2uxDLqLREwpvMR4gZs6LNkvBi1eYIm82RMffdXKoor4eXIniPcqY4E2OTUcddZHjfcNkJi+xkrRg8+Ug6reNrHOz0yqsGTYjpL2BJl4ZhAK0AFSE6LpU9+8xj4YLy5WEM5QHl0Jg74r8lG+vA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(376002)(39860400002)(136003)(230922051799003)(82310400011)(64100799003)(186009)(451199024)(1800799012)(46966006)(36840700001)(40470700004)(41300700001)(81166007)(82740400003)(356005)(40460700003)(40480700001)(316002)(36860700001)(110136005)(47076005)(7696005)(70206006)(8676002)(54906003)(70586007)(8936002)(44832011)(26005)(336012)(426003)(86362001)(5660300002)(2616005)(478600001)(4326008)(2906002)(6666004)(36756003)(1076003)(16526019)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2024 19:26:40.0734 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23b07ffb-3c9d-4640-92ec-08dc21c962ad X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6250 Some manufacturers have intentionally put an EDID that differs from the EDID on the internal panel on laptops. Attempt to fetch this EDID if it exists and prefer it over the EDID that is provided by the panel. Signed-off-by: Mario Limonciello --- v2: * Use drm helper which will run more validation * Move eDP check to DRM helper * Add module parameter --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 8 ++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 9 ++++++--- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 3d8a48f46b01..5d5be3e20687 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -217,6 +217,7 @@ extern int amdgpu_smartshift_bias; extern int amdgpu_use_xgmi_p2p; extern int amdgpu_mtype_local; extern bool enforce_isolation; +extern bool acpi_edid; #ifdef CONFIG_HSA_AMD extern int sched_policy; extern bool debug_evictions; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c index 9caba10315a8..6aa8cc431abe 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c @@ -278,6 +278,10 @@ static void amdgpu_connector_get_edid(struct drm_connector *connector) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); + /* if the BIOS specifies the EDID via _DDC, prefer this */ + if (acpi_edid && !amdgpu_connector->edid) + amdgpu_connector->edid = drm_get_acpi_edid(connector); + if (amdgpu_connector->edid) return; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index cc69005f5b46..be7a4da85a8b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -166,6 +166,7 @@ uint amdgpu_sdma_phase_quantum = 32; char *amdgpu_disable_cu; char *amdgpu_virtual_display; bool enforce_isolation; +bool acpi_edid = true; /* * OverDrive(bit 14) disabled by default * GFX DCS(bit 19) disabled by default @@ -990,6 +991,13 @@ MODULE_PARM_DESC(wbrf, "Enable Wifi RFI interference mitigation (0 = disabled, 1 = enabled, -1 = auto(default)"); module_param_named(wbrf, amdgpu_wbrf, int, 0444); +/** + * DOC: acpi_edid (bool) + * Try to fetch EDID for eDP display from BIOS using ACPI _DDC method. + */ +module_param(acpi_edid, bool, 0444); +MODULE_PARM_DESC(acpi_edid, "Fetch EDID for eDP display from BIOS"); + /* These devices are not supported by amdgpu. * They are supported by the mach64, r128, radeon drivers */ diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 202c6ad443a3..688d615c6687 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6589,7 +6589,11 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector) struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct dc_link *dc_link = aconnector->dc_link; struct dc_sink *dc_em_sink = aconnector->dc_em_sink; - struct edid *edid; + struct edid *edid = NULL; + + /* prefer ACPI over panel for eDP */ + if (acpi_edid) + edid = drm_get_acpi_edid(connector); /* * Note: drm_get_edid gets edid in the following order: @@ -6597,7 +6601,9 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector) * 2) firmware EDID if set via edid_firmware module parameter * 3) regular DDC read. */ - edid = drm_get_edid(connector, &amdgpu_connector->ddc_bus->aux.ddc); + if (!edid) + edid = drm_get_edid(connector, &amdgpu_connector->ddc_bus->aux.ddc); + if (!edid) { DRM_ERROR("No EDID found on connector: %s.\n", connector->name); return; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index 85b7f58a7f35..cc39b1c14aa8 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -899,7 +899,7 @@ enum dc_edid_status dm_helpers_read_local_edid( struct i2c_adapter *ddc; int retry = 3; enum dc_edid_status edid_status; - struct edid *edid; + struct edid *edid = NULL; if (link->aux_mode) ddc = &aconnector->dm_dp_aux.aux.ddc; @@ -910,8 +910,11 @@ enum dc_edid_status dm_helpers_read_local_edid( * do check sum and retry to make sure read correct edid. */ do { - - edid = drm_get_edid(&aconnector->base, ddc); + /* prefer ACPI over panel for eDP */ + if (acpi_edid) + edid = drm_get_acpi_edid(connector); + if (!edid) + edid = drm_get_edid(&aconnector->base, ddc); /* DP Compliance Test 4.2.2.6 */ if (link->aux_mode && connector->edid_corrupt) From patchwork Tue Jan 30 19:26:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 768113 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2060.outbound.protection.outlook.com [40.107.101.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D64F383BA; Tue, 30 Jan 2024 19:26:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706642806; cv=fail; b=cnjPUGo4obXXLNjDsVx7OEuu1DQUZVJQCXYgj0faFZolQWTi1mjAM2gr1u7JZ1Zu4qHOh+jr9yjV2EJP9HV0+Vt4uiKQR88G8ukdsHn3+6tXOFOBVW0XoFNjuvRMS5jhbWbDrc/iCHDljJtgaz7M3Fkt9bcv020KUo3Y6ZDXG2c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706642806; c=relaxed/simple; bh=T3LmFWo2v7tWAa06puHfhCWf78ACpMFVubmrqtoL1Hg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gnDBlM2wp2pJ/M19mKq9+3lvAxBL1UqmuaumHmZ/MpxbmdQRx+XIuQF6GB34uqve+pmo09clEHBWummkfiYRlKZtW5R/L/gc+ud4DaI8DhQ3Tj2RNNVwWRGwy1TdewwmewYxK8amrE4Sa+9yECZF2f+p4NiiugI1rXJG21SRoCI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Dmkmo4ak; arc=fail smtp.client-ip=40.107.101.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Dmkmo4ak" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iHVKsblFPLsIlEYp5zWqWTXZ4UxmCvYrdlfI3QnwCPSxqiGJurVLjkBhjAFVd/qkiDw4BptpRh6oRI/W6mkLg3AU3gmc4Gv2QMpNSUIcjg75lrDolQq6C4P1TpOS4XOxKzqZsjlw+ctZjOnewtGi67hk1A3MtjYb5NZpy+0IEOoSQQMzTcOXL2Ccv04siJLA8XPoS7SM+6UredtqWpFEBPpq4E2FcQvJ+RotdP8A1DVznEhI+Sye1fx8DJRVInocya6KdMmusLeL/GJpldcqj2X98X7b3lS8N15EM7hvGI83BF59p86ofKuacrd+RTcvv8rxB0AoSmWLUzAeFO6zzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vGjorbt8i1WoJyt0gsOHV4IXlJIyyELkjxtpx80Lwfc=; b=PKDplR2nEseUNrGbDI3dIhDWwxT79554Tila8Cev+8k6wEI6+/Qnk+ms1vmHqDmzPdk5lnXMarfG+LTVeNtlsAkSRYub332c9WDuxUhnIfSQjOsWVvCbsJshaBPjfYfdJ4H93/wMJSK9GLoKmgTodj6k0Pn3GJVEgMEp+J9md4Qv4w5MZSWzVv6WW/QADjmTDZPTuXpFx4UC0IDGXrEOOzvzmWq2LjXn+FrnNe12iEYH2L4+4+54Ii1MHN5DWFmjb8ARMhiOzHkLWY/KlM4hhwsYyAI/NWoZi6EPnuR16TwoBBPf+oSAZt07GxqEOIOK2XZQqjkSzhMylKRvw4b1jw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vGjorbt8i1WoJyt0gsOHV4IXlJIyyELkjxtpx80Lwfc=; b=Dmkmo4akEabyCHd3c2nmJlbMntaLNQ6w6RDLiiZdRcGLUASWklMj+ZzbQrx0F3uyb6nTecRVHf3MQ9sForRnIKwmTR88n5n6V17/JfvnEYsFiJ6FfDKKZC/B5396tY1TD8oKV/jF32dakkJ7OpGtdJnN3iHYFPeYUsYZX8Ask58= Received: from MW3PR05CA0022.namprd05.prod.outlook.com (2603:10b6:303:2b::27) by SJ2PR12MB7823.namprd12.prod.outlook.com (2603:10b6:a03:4c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.33; Tue, 30 Jan 2024 19:26:41 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:303:2b:cafe::60) by MW3PR05CA0022.outlook.office365.com (2603:10b6:303:2b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22 via Frontend Transport; Tue, 30 Jan 2024 19:26:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Tue, 30 Jan 2024 19:26:41 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 30 Jan 2024 13:26:37 -0600 From: Mario Limonciello To: , Alex Deucher , Harry Wentland , "Rafael J . Wysocki" , Hans de Goede CC: "open list:ACPI" , open list , "open list:DRM DRIVERS" , Melissa Wen , "Mark Pearson" , Mario Limonciello Subject: [PATCH v2 4/4] drm/nouveau: Use drm_get_acpi_edid() helper Date: Tue, 30 Jan 2024 13:26:08 -0600 Message-ID: <20240130192608.11666-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240130192608.11666-1-mario.limonciello@amd.com> References: <20240130192608.11666-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E7:EE_|SJ2PR12MB7823:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cb3eb7d-1312-4a82-b5d1-08dc21c96311 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MjEVcpnR/btjaHx/kdfzcGqwrJ8cXlkGTysLIiebtQ5aT4ccZkN35fdnbmp1XZ5ItikvuBfPwOfM9XRBOEzjfum1ZOBkrSQ7+FHrBVPq2EsZUTC9s0HJcomO3vkGtqP6u2qAS5CSxuI8xRW2qs8nXpr+vXy8QnxgX1bwiBUnVNNf3566uoqkyWSagqLiSe6XWa9qNHnVEeZ12mq6XW5LysgTrfwzU3gmWl5bVs7SBa3KEsfDdo8hpOr0Fflrbf3k/apsXy4ykNZDuWVraeMxjizT4qqRcP4UQOewXH3n9DYfLQ1LbWUjHrHy/HVjwEJbY9H+aeAYNbXggE6Mfuo6p8NJ/9RPW7FIb+LiOt9quCLZ9pPCJN5q6NBLXyaq1nda6L3EpOxkXKD6H3k64yJ/a1TmUuX3U47NLNpe9+FeQFt1AJZjCpZKPyFnTeMKWwvK/wXbR/hEYJANP6VL9l1mnTO9O3XIDz/roBWreX3afb6jpS9P1DgwZaOGScFAB9bH9jK7L0MnQ+kJFz2goYs/PKjHSgXDGccNeqoQ8FbyguN9TtCWVepVfGAPnRyboPRRXCXOEgpjuEP8QI2d8OsvM7oPWJovX9XyZ5vTkYH8GeVzW9sB2+Hj4LT8K6ekuTHW8TxPDml+ATFzGwr+QkrZ2Z+STh851x8dwI1VVDxV6hfXPdZMFC6oTK+nTjNLMHownamkeUQPYkhwd8mgVF2vbFe4qHLASM9xZwSK7ZOypI+CumwB1+7G50THgiQqOjXQjSd3uH0GDyeTyzFFUYzNXA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(376002)(136003)(346002)(230922051799003)(451199024)(82310400011)(186009)(1800799012)(64100799003)(46966006)(40470700004)(36840700001)(426003)(16526019)(1076003)(41300700001)(2616005)(336012)(26005)(40460700003)(40480700001)(316002)(6666004)(54906003)(36756003)(110136005)(7696005)(36860700001)(83380400001)(478600001)(47076005)(356005)(82740400003)(81166007)(70586007)(8936002)(86362001)(2906002)(44832011)(4326008)(70206006)(5660300002)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2024 19:26:41.1672 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8cb3eb7d-1312-4a82-b5d1-08dc21c96311 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7823 Rather than inventing a wrapper to acpi_video_get_edid() use the one provided by drm. This fixes two problems: 1. A memory leak that the memory provided by the ACPI call was never freed. 2. Validation of the BIOS provided blob. Signed-off-by: Mario Limonciello --- v1->v2: * New patch --- drivers/gpu/drm/nouveau/nouveau_acpi.c | 27 --------------------- drivers/gpu/drm/nouveau/nouveau_acpi.h | 2 -- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c index 8f0c69aad248..de9daafb3fbb 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c @@ -360,33 +360,6 @@ void nouveau_unregister_dsm_handler(void) {} void nouveau_switcheroo_optimus_dsm(void) {} #endif -void * -nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) -{ - struct acpi_device *acpidev; - int type, ret; - void *edid; - - switch (connector->connector_type) { - case DRM_MODE_CONNECTOR_LVDS: - case DRM_MODE_CONNECTOR_eDP: - type = ACPI_VIDEO_DISPLAY_LCD; - break; - default: - return NULL; - } - - acpidev = ACPI_COMPANION(dev->dev); - if (!acpidev) - return NULL; - - ret = acpi_video_get_edid(acpidev, type, -1, &edid); - if (ret < 0) - return NULL; - - return kmemdup(edid, EDID_LENGTH, GFP_KERNEL); -} - bool nouveau_acpi_video_backlight_use_native(void) { return acpi_video_backlight_use_native(); diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.h b/drivers/gpu/drm/nouveau/nouveau_acpi.h index e39dd8b94b8b..6a3def8e6cca 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.h +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.h @@ -10,7 +10,6 @@ bool nouveau_is_v1_dsm(void); void nouveau_register_dsm_handler(void); void nouveau_unregister_dsm_handler(void); void nouveau_switcheroo_optimus_dsm(void); -void *nouveau_acpi_edid(struct drm_device *, struct drm_connector *); bool nouveau_acpi_video_backlight_use_native(void); void nouveau_acpi_video_register_backlight(void); #else @@ -19,7 +18,6 @@ static inline bool nouveau_is_v1_dsm(void) { return false; }; static inline void nouveau_register_dsm_handler(void) {} static inline void nouveau_unregister_dsm_handler(void) {} static inline void nouveau_switcheroo_optimus_dsm(void) {} -static inline void *nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return NULL; } static inline bool nouveau_acpi_video_backlight_use_native(void) { return true; } static inline void nouveau_acpi_video_register_backlight(void) {} #endif diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 856b3ef5edb8..746571d4cac0 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -713,7 +713,7 @@ nouveau_connector_detect_lvds(struct drm_connector *connector, bool force) * valid - it's not (rh#613284) */ if (nv_encoder->dcb->lvdsconf.use_acpi_for_edid) { - edid = nouveau_acpi_edid(dev, connector); + edid = drm_get_acpi_edid(connector); if (edid) { status = connector_status_connected; goto out;