From: Mario Limonciello <mario.limonciello@amd.com>
To: <amd-gfx@lists.freedesktop.org>,
Alex Deucher <alexander.deucher@amd.com>,
Harry Wentland <harry.wentland@amd.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Hans de Goede <hdegoede@redhat.com>
Cc: "open list:ACPI" <linux-acpi@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
"open list:DRM DRIVERS" <dri-devel@lists.freedesktop.org>,
Melissa Wen <mwen@igalia.com>,
"Mark Pearson" <mpearson-lenovo@squebb.ca>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH v3 4/5] drm/nouveau: Use drm_get_acpi_edid() helper
Date: Thu, 1 Feb 2024 16:11:18 -0600 [thread overview]
Message-ID: <20240201221119.42564-5-mario.limonciello@amd.com> (raw)
In-Reply-To: <20240201221119.42564-1-mario.limonciello@amd.com>
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 <mario.limonciello@amd.com>
---
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;
--
2.34.1
next prev parent reply other threads:[~2024-02-01 22:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 22:11 [PATCH v3 0/5] Add support for fetching EDID from ACPI _DDC Mario Limonciello
2024-02-01 22:11 ` [PATCH v3 1/5] ACPI: video: Handle fetching EDID that is longer than 256 bytes Mario Limonciello
2024-02-02 16:07 ` Rafael J. Wysocki
2024-02-02 16:09 ` Mario Limonciello
2024-02-06 19:43 ` Rafael J. Wysocki
2024-02-01 22:11 ` [PATCH v3 2/5] drm: Add drm_get_acpi_edid() helper Mario Limonciello
2024-02-02 10:24 ` Pranjal Ramajor Asha Kanojiya
2024-02-02 10:29 ` Jani Nikula
2024-02-02 15:19 ` Mario Limonciello
2024-02-01 22:11 ` [PATCH v3 3/5] drm/amd: Fetch the EDID from _DDC if available for eDP Mario Limonciello
2024-02-03 12:53 ` kernel test robot
2024-02-01 22:11 ` Mario Limonciello [this message]
2024-02-01 22:11 ` [PATCH v3 5/5] drm: Drop unneeded selects in DRM drivers Mario Limonciello
2024-02-02 10:12 ` Pranjal Ramajor Asha Kanojiya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240201221119.42564-5-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=hdegoede@redhat.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--cc=mwen@igalia.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).