From patchwork Thu May 30 10:01:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13680095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53633C25B74 for ; Thu, 30 May 2024 10:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=HFltt1hnd5eEZqlBjH+rsbojBg3PN4U5GMZRmkqUXQ4=; b=IrMQDkR+/EfGqv mRekTMS1v1ps/bVGOkDGuFoIpKg8h0fZY4ZDmbRk/5JGcx6WG2gTpg8+zPuXmqU+QTJ1qzBsByfcQ VRMhd9k9u1xRAhMKjV4/qe6AqzNVL+/GqrIfX8TcguLfkvavGBzHHADWsKbGBEpDYnczUSUGyfU6F cL/dD/TqEw7yz/ZnpYaAIUAQqwAi1ni2LC8FgZAX4NsaVXi4ZYwc4aTUIPJ1KrINM8blIrB7ML3mo s36OFxOTxoBEGxb/wcNqhxPpQiw5h+ayMZRS9HGGJWq91ECs5R5JL2JnD/r3t3I8Nu98iIzQYsKa8 qE04OvLfQisDgwBmL3CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCcbu-00000006ukp-0wjY; Thu, 30 May 2024 10:02:14 +0000 Received: from mgamail.intel.com ([198.175.65.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCcbs-00000006uji-0aYY for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 10:02:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717063332; x=1748599332; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1LP2rTo7NH0u3HUMgvoQtIkwfwWpjfpCFYaEhS+TgdI=; b=TDOBwbPU84iRW1WgGJQyLuWFe3deDO1LgwDpdDW3sdAx/oRLk22cnTXo SddAogpq2I2R+NQSNb1O/ARh0GjU7wV2ANN+wuUUQzwFC7sy40pEr+qjp jKVK3P33tXlaVE9M27pXe72aFrLxURpMpLQiRbNRfuI9V5+E6DqSX9G3j d+cY7zcTZk589yfUblgeMBJogJR9yxZebGdbCF0Sh1eAe+SVIbGLh+J8K sgq6C+JxzrHjzg5C2xLCSRcZT4HFj5JKuQLyT/GqEqRIKu3urlNnizc4z 78XJA5GG95nahbLiOsJLqCsYtUDNBT94OIxI3TSZEo9VF3kWytmctq4RD A==; X-CSE-ConnectionGUID: phGZTeMlQoqc7peUh4099A== X-CSE-MsgGUID: iC+5IWu0QViN0zXIkuCjOA== X-IronPort-AV: E=McAfee;i="6600,9927,11087"; a="24942803" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="24942803" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 03:02:07 -0700 X-CSE-ConnectionGUID: 899tdr+XSt+622yob0QDcA== X-CSE-MsgGUID: q2Tk505KSB+DoG7+DejYbQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40235059" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.246.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 03:02:04 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, Jani Nikula , stable@vger.kernel.org Subject: [PATCH 1/4] drm/exynos/vidi: fix memory leak in .get_modes() Date: Thu, 30 May 2024 13:01:51 +0300 Message-Id: <20240530100154.317683-1-jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_030212_246978_D3098CD5 X-CRM114-Status: GOOD ( 11.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The duplicated EDID is never freed. Fix it. Cc: stable@vger.kernel.org Signed-off-by: Jani Nikula --- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index fab135308b70..11a720fef32b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -309,6 +309,7 @@ static int vidi_get_modes(struct drm_connector *connector) struct vidi_context *ctx = ctx_from_connector(connector); struct edid *edid; int edid_len; + int count; /* * the edid data comes from user side and it would be set @@ -328,7 +329,11 @@ static int vidi_get_modes(struct drm_connector *connector) drm_connector_update_edid_property(connector, edid); - return drm_add_edid_modes(connector, edid); + count = drm_add_edid_modes(connector, edid); + + kfree(edid); + + return count; } static const struct drm_connector_helper_funcs vidi_connector_helper_funcs = { From patchwork Thu May 30 10:01:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13680096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE211C41513 for ; Thu, 30 May 2024 10:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CXUv45gubbfEIXy5SVPxtTJP475ZUOQgQz55W1W+1yo=; b=q2+8+4dTLxKJsF d47C9WrB9DVWhWTsCQlOazyjPIyjUdKjfTSMbwUbDhzr205QV1A4uLVZY2ZHcSZTMe0/HbRoZiMiS i0x86LOBJXcv15MWV1toQxwLspKVxYRSNdShtvfMBAGmctUuGkhBu5GnhwkOLCAnVV2kpwNaE7AYj BifkR2jMYsWoRO2JmkPIk6329GrP48dXyIlFURnU3NvP/jAvyZAhZSRWdXb9ru/Hw3U4R0Xkk/dYS BpYNd1n8KQJOsICTPER96RDEushyUQEE7CIzQAYgHhJ80RhwQHFoVtPSBfy5UqLQK4gW3Pux/6PC5 OB8cxiV+lZER868nLXdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCcc3-00000006uoU-255A; Thu, 30 May 2024 10:02:23 +0000 Received: from mgamail.intel.com ([198.175.65.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCcbt-00000006uji-3KmB for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 10:02:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717063334; x=1748599334; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m5WISLEMqfoNeM122Roua0nYgI5s4y5ndZ/g5kaDfME=; b=P5H0jgETax2iQqjafADarzSYf7ev2eC2GqP6R0/Smvdg5R2iL0HL0MYx bZe/lCOEpE1UJDiLs1CBgekFZ78uPzkSCklm6Z9urC+V5GT1MUQx21L5R SfEbADxh4JADpMjKJgKHBn/Aj9htSKSmcMAL7HPW5O9nh2xqAac7LB2Xw REFBqmg2L60NmJNDRnEcoMAu8mS2UbrahE5nPRgisBgJ1KoEvCn6/CyLd TQc88cry7/BdDzIY83a/IEj2F06aQN2fiy0aplnr8fSghefbqaTvX5AvZ 4/LpgCT/L58wCq9FTBGChvRQyXc1q1JEND/HFNS30xi5Objx2mS8cMZzM w==; X-CSE-ConnectionGUID: 2JECSo9DSR+46ruQwXtstg== X-CSE-MsgGUID: LmhyrZFoRcGF05S+0oS/KA== X-IronPort-AV: E=McAfee;i="6600,9927,11087"; a="24942818" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="24942818" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 03:02:13 -0700 X-CSE-ConnectionGUID: lxyK9rz0Q7+v/HD2lNqHwg== X-CSE-MsgGUID: +zGJSRRWTcuPnOqn7+gXGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40235103" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.246.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 03:02:10 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, Jani Nikula Subject: [PATCH 2/4] drm/exynos/vidi: use drm_edid_duplicate() Date: Thu, 30 May 2024 13:01:52 +0300 Message-Id: <20240530100154.317683-2-jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530100154.317683-1-jani.nikula@intel.com> References: <20240530100154.317683-1-jani.nikula@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_030213_949019_E2387BA7 X-CRM114-Status: GOOD ( 11.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Don't open code drm_edid_duplicate(). While at it, drop the error message on allocation failure. Signed-off-by: Jani Nikula --- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 11a720fef32b..f613df719a02 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -308,7 +308,6 @@ static int vidi_get_modes(struct drm_connector *connector) { struct vidi_context *ctx = ctx_from_connector(connector); struct edid *edid; - int edid_len; int count; /* @@ -320,12 +319,9 @@ static int vidi_get_modes(struct drm_connector *connector) return 0; } - edid_len = (1 + ctx->raw_edid->extensions) * EDID_LENGTH; - edid = kmemdup(ctx->raw_edid, edid_len, GFP_KERNEL); - if (!edid) { - DRM_DEV_DEBUG_KMS(ctx->dev, "failed to allocate edid\n"); + edid = drm_edid_duplicate(ctx->raw_edid); + if (!edid) return 0; - } drm_connector_update_edid_property(connector, edid); From patchwork Thu May 30 10:01:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13680097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F5EDC25B74 for ; Thu, 30 May 2024 10:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ypcukQ+FAqPqZoy2NQiLgpfrqGBdAQF4Saev8ACv0fg=; b=gqIRorlXcRHDfi Ow087F+OfACeNdZrLTkGWipkplBNkQq6egaZcQnaDjizfbiYxlG3SBngI5mPrtaoO7c1W/IRZ9foj f5+bSGHt/4iC9hGMmlriyfdinK/8I2NQcAN2DnkBOKQgt1Dt6jFi1U0KuaxhmC5BLbXsVmC3xQPXD JfsRAqNxYmABc6mHOr/5ZCVPb40PIT0Y91sJwDTGJEIhUglwI/LV/zrzrEw6J4kdzQZn5xr7M4A2U sxhr2IJ4fHSLNX601KSwHo+/ANBoYf/4WhfvYUUB5VpnNn6PhCdUbokT2nEIc+Sk9lty4uOrARSBh vNvS7wkorQqysWFLiVUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCccA-00000006ur3-1vfu; Thu, 30 May 2024 10:02:30 +0000 Received: from mgamail.intel.com ([198.175.65.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCcc7-00000006upb-1ENh for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 10:02:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717063347; x=1748599347; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TV8L7SOfK4ik4ni0oilI243+kNblJd3tywN/0cG5/qk=; b=eG28fZYphVzyT0Yv8rIz1O9XK6QDUtKHVczYikyM0oFCXj4fsjx2nART vm3yyAIfsDLiT5nEq5noRhuksR0mFO1V4lB6l1cer3KvA6S0RhKpM/O5W 9yo+A3Ff5DQxdAHEmq3wMnh5QjBCOhZPy7LWaDAGWohsM+6THjszaf9Dk +Sp0TC0SLcCse3qu7ZEYZqYaD47kVxp2MN6cGT4A2R0PqYoTR12oeDZd5 ME5OVHBXHklMyuZSitnEOUP6vVmQmrK0ppW34iF8bf2Nm2FJlym9kF+2V g1OaUcdS67+Gufheu4tHEMtI3xZhlDCAMCNt7Wfp4Czcj0huLqDQs/Ept g==; X-CSE-ConnectionGUID: oiHrtCRyTPez04FjD1wntA== X-CSE-MsgGUID: g955wUusTnigpwV+uG+snA== X-IronPort-AV: E=McAfee;i="6600,9927,11087"; a="24942843" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="24942843" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 03:02:27 -0700 X-CSE-ConnectionGUID: r/VNIMo/QmWVkH1yT9iFTg== X-CSE-MsgGUID: preaaPqTSQ2aCTnQMxZ0pg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40235192" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.246.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 03:02:17 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, Jani Nikula Subject: [PATCH 3/4] drm/exynos/vidi: simplify fake edid handling Date: Thu, 30 May 2024 13:01:53 +0300 Message-Id: <20240530100154.317683-3-jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530100154.317683-1-jani.nikula@intel.com> References: <20240530100154.317683-1-jani.nikula@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_030227_422297_2E56D2E3 X-CRM114-Status: GOOD ( 16.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Avoid assigning fake_edid_info to ctx->raw_edid. Always keep ctx->raw_edid either an allocated pointer or NULL. Defer fake_edid_info handling to .get_modes(). This should be functionally equivalent but slightly easier to follow. Signed-off-by: Jani Nikula --- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 40 +++++++----------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index f613df719a02..d93801ace79a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -195,12 +195,11 @@ static ssize_t vidi_store_connection(struct device *dev, if (ctx->connected > 1) return -EINVAL; - /* use fake edid data for test. */ - if (!ctx->raw_edid) - ctx->raw_edid = (struct edid *)fake_edid_info; - - /* if raw_edid isn't same as fake data then it can't be tested. */ - if (ctx->raw_edid != (struct edid *)fake_edid_info) { + /* + * Use fake edid data for test. If raw_edid is set then it can't be + * tested. + */ + if (ctx->raw_edid) { DRM_DEV_DEBUG_KMS(dev, "edid data is not fake data.\n"); return -EINVAL; } @@ -261,15 +260,9 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data, return -ENOMEM; } } else { - /* - * with connection = 0, free raw_edid - * only if raw edid data isn't same as fake data. - */ - if (ctx->raw_edid && ctx->raw_edid != - (struct edid *)fake_edid_info) { - kfree(ctx->raw_edid); - ctx->raw_edid = NULL; - } + /* with connection = 0, free raw_edid */ + kfree(ctx->raw_edid); + ctx->raw_edid = NULL; } ctx->connected = vidi->connection; @@ -310,16 +303,7 @@ static int vidi_get_modes(struct drm_connector *connector) struct edid *edid; int count; - /* - * the edid data comes from user side and it would be set - * to ctx->raw_edid through specific ioctl. - */ - if (!ctx->raw_edid) { - DRM_DEV_DEBUG_KMS(ctx->dev, "raw_edid is null.\n"); - return 0; - } - - edid = drm_edid_duplicate(ctx->raw_edid); + edid = drm_edid_duplicate(ctx->raw_edid ?: fake_edid_info); if (!edid) return 0; @@ -467,10 +451,8 @@ static void vidi_remove(struct platform_device *pdev) { struct vidi_context *ctx = platform_get_drvdata(pdev); - if (ctx->raw_edid != (struct edid *)fake_edid_info) { - kfree(ctx->raw_edid); - ctx->raw_edid = NULL; - } + kfree(ctx->raw_edid); + ctx->raw_edid = NULL; component_del(&pdev->dev, &vidi_component_ops); } From patchwork Thu May 30 10:01:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13680098 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51BE7C25B74 for ; Thu, 30 May 2024 10:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=10VChTQVJFlzu3zKUo/YUxRjf+lfa7/wBE/b49aV1sM=; b=oZy1YN9Al1NbNl niFiWNjY1VSK5mqZU7VPDRGWHnHTupAAbeIgm/WS8SGq0Gcxxg2OQ6UVxgWq7l/9ADimDiPuk++32 EWPe4mKbVViUEc5KnWcStmqZ8GoK6HrCLt5Rd7CG9S1tmTqGV5Ssscic6CgEkh5w61SqlOy4kRxGO O3uisM14IqEaYwoFMFVUSN5TTbaUmWGI6BJ9eCmyNLb5zkLkOfcvbct+gE4FqowKLkcMDjV55ujAV zIEuZcldBNC8rYWrl4qgGgEG1/ZxjgBS6fjyDjYF5f887QGBpKY3zG/XtyEg8fVDtyLZ5Fl39jr/B mSo+G0QFK7bSs7SPByGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCccO-00000006uyi-0K9L; Thu, 30 May 2024 10:02:44 +0000 Received: from mgamail.intel.com ([198.175.65.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCcc8-00000006upb-3dTY for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 10:02:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717063349; x=1748599349; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bdC56qRyRLu0SFAStyq2sOD2Am7JE6h4a5f09loTAGI=; b=F+5q5biqDeRNcE98PRUvoNFfYJszF0FlagiR/Ubjq5uWH3TVI4nylgHA 3HkZbsJtAjs2mhh7Me9g5x/vHWAydHMUq6JqtUeV865mEvdBM5lfZfXz9 0+0fTVMdNw/NReEXRwzc5/CKQjhOjr04zxDWkIxHY+Ij9F/5doT59K1tc PEfnu8/ZRbphHZggubYKwxvUhpT4XDCwd+PeHDCpWexS78gR883gUtB9v vc7Hfb+tD1gP2tETLKZ97hY59biR1VD6SMdI2kSWcpRnpvQsALoz9buBH rhySopYbpxFHXiOaQ+m75XsfemGs6oCmirHGkzqKYeolnd9ph0fK6OUq+ A==; X-CSE-ConnectionGUID: 0YXTKBG0S+Gv+AJp5vBGiQ== X-CSE-MsgGUID: fkeBs30NT9ubof5UBCUgcw== X-IronPort-AV: E=McAfee;i="6600,9927,11087"; a="24942848" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="24942848" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 03:02:27 -0700 X-CSE-ConnectionGUID: USdyqaMBRqC2tVPOYJnXLA== X-CSE-MsgGUID: aose0NSlSGSwexDzzAfp3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40235289" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.246.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 03:02:24 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, Jani Nikula Subject: [PATCH 4/4] drm/exynos/vidi: convert to struct drm_edid Date: Thu, 30 May 2024 13:01:54 +0300 Message-Id: <20240530100154.317683-4-jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530100154.317683-1-jani.nikula@intel.com> References: <20240530100154.317683-1-jani.nikula@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_030229_022626_73D4EDCA X-CRM114-Status: GOOD ( 17.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Prefer the struct drm_edid based functions for storing the EDID and updating the connector. It would be better if the vidi connection ioctl passed in the EDID size separately instead of relying on the extension count specified in the EDID, but that's what we have to rely on. Signed-off-by: Jani Nikula --- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 44 ++++++++++++++---------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index d93801ace79a..6de0cced6c9d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -41,7 +41,7 @@ struct vidi_context { struct exynos_drm_crtc *crtc; struct drm_connector connector; struct exynos_drm_plane planes[WINDOWS_NR]; - struct edid *raw_edid; + const struct drm_edid *raw_edid; unsigned int clkdiv; unsigned int connected; bool suspended; @@ -245,23 +245,27 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data, } if (vidi->connection) { - struct edid *raw_edid; + const struct drm_edid *drm_edid; + const struct edid *raw_edid; + size_t size; - raw_edid = (struct edid *)(unsigned long)vidi->edid; - if (!drm_edid_is_valid(raw_edid)) { + raw_edid = (const struct edid *)(unsigned long)vidi->edid; + size = (raw_edid->extensions + 1) * EDID_LENGTH; + + drm_edid = drm_edid_alloc(raw_edid, size); + if (!drm_edid) + return -ENOMEM; + + if (!drm_edid_valid(drm_edid)) { + drm_edid_free(drm_edid); DRM_DEV_DEBUG_KMS(ctx->dev, "edid data is invalid.\n"); return -EINVAL; } - ctx->raw_edid = drm_edid_duplicate(raw_edid); - if (!ctx->raw_edid) { - DRM_DEV_DEBUG_KMS(ctx->dev, - "failed to allocate raw_edid.\n"); - return -ENOMEM; - } + ctx->raw_edid = drm_edid; } else { /* with connection = 0, free raw_edid */ - kfree(ctx->raw_edid); + drm_edid_free(ctx->raw_edid); ctx->raw_edid = NULL; } @@ -300,18 +304,22 @@ static const struct drm_connector_funcs vidi_connector_funcs = { static int vidi_get_modes(struct drm_connector *connector) { struct vidi_context *ctx = ctx_from_connector(connector); - struct edid *edid; + const struct drm_edid *drm_edid; int count; - edid = drm_edid_duplicate(ctx->raw_edid ?: fake_edid_info); - if (!edid) + if (ctx->raw_edid) + drm_edid = drm_edid_dup(ctx->raw_edid); + else + drm_edid = drm_edid_alloc(fake_edid_info, sizeof(fake_edid_info)); + + if (!drm_edid) return 0; - drm_connector_update_edid_property(connector, edid); + drm_edid_connector_update(connector, drm_edid); - count = drm_add_edid_modes(connector, edid); + count = drm_edid_connector_add_modes(connector); - kfree(edid); + drm_edid_free(drm_edid); return count; } @@ -451,7 +459,7 @@ static void vidi_remove(struct platform_device *pdev) { struct vidi_context *ctx = platform_get_drvdata(pdev); - kfree(ctx->raw_edid); + drm_edid_free(ctx->raw_edid); ctx->raw_edid = NULL; component_del(&pdev->dev, &vidi_component_ops);