From patchwork Wed Feb 28 21:32:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13575988 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 ECE3DC47DD9 for ; Wed, 28 Feb 2024 21:34:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A0A610E36D; Wed, 28 Feb 2024 21:34:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Wvo/Rb6d"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C4F110E284 for ; Wed, 28 Feb 2024 21:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709156048; x=1740692048; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+ACsMrM6XCjy13Tos0R3Pp75Uipg06AsnDFL1Afx9Po=; b=Wvo/Rb6dc83YpOhua7KctSqMMEzqBQpsf2vtMoF6Ge8RaW3uwmdYCPjA ucFSixRiYpWJ3ZDUbDmUkUXWRJMnWA1I4IGAerUIQwAjmIayQo7gvlRLD hRnZATPlsAZgl3kkCWV060kSBg3q2gxnTwUSsoVCv7+pIGjoCE8cyZ50q aIuAaP8sd/i8Qayw2LkLKHl5N3F18t1C9+W+Q6w3LURtdxlLP8ZoAQ08h dn+JPOzOkWJfpJohCNO6ajQopCzj2Q9ZoXCCrk4MFvOA2eg3k2yRVLrcO xNp9jUc0hoWRkDSV+FdcGkykS+o7eo2G7khBC46m8GNfxqm4BcOpBRpfA Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3753123" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3753123" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7623726" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:07 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Cc: Radhakrishna Sripada , Jani Nikula Subject: [PATCH v3 1/6] drm/i915: Pass size to oprom_get_vbt Date: Wed, 28 Feb 2024 13:32:30 -0800 Message-Id: <20240228213235.2495611-2-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> References: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" oprom_get_vbt will later be used to show the contents of vbt for which the size of vbt is needed. v2: Avoid overuse of *size and remove dummy size variable in intel_bios_init(Jani) Cc: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index fe52c06271ef..8ff0fdd5a828 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -3008,7 +3008,8 @@ static struct vbt_header *spi_oprom_get_vbt(struct drm_i915_private *i915) return NULL; } -static struct vbt_header *oprom_get_vbt(struct drm_i915_private *i915) +static struct vbt_header *oprom_get_vbt(struct drm_i915_private *i915, + size_t *sizep) { struct pci_dev *pdev = to_pci_dev(i915->drm.dev); void __iomem *p = NULL, *oprom; @@ -3057,6 +3058,9 @@ static struct vbt_header *oprom_get_vbt(struct drm_i915_private *i915) pci_unmap_rom(pdev, oprom); + if (sizep) + *sizep = vbt_size; + drm_dbg_kms(&i915->drm, "Found valid VBT in PCI ROM\n"); return vbt; @@ -3106,7 +3110,7 @@ void intel_bios_init(struct drm_i915_private *i915) } if (!vbt) { - oprom_vbt = oprom_get_vbt(i915); + oprom_vbt = oprom_get_vbt(i915, NULL); vbt = oprom_vbt; } From patchwork Wed Feb 28 21:32:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13575986 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 75BFCC47DD9 for ; Wed, 28 Feb 2024 21:34:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B611410E272; Wed, 28 Feb 2024 21:34:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="hGU6fwCE"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 308D510E272 for ; Wed, 28 Feb 2024 21:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709156048; x=1740692048; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=07JAZBsgzmaPPJ0m7ApvyNPuPFcrdTk0nvEUDIIe18g=; b=hGU6fwCEkLOR81Sop0exRowggIypqSR2D3I8Zae8aBEXMRpXZk67KmMh doeOd5yvrk+w+vEUQMdzElNgPgG2UHmFxi6bPHz/y0xcR7Ie3e8JfBmxp 4SzYQz0zpnv2DQnReneCSb00jf/38//3JwsgJvKfkBSxIR77vsIvf+xBB LmIqPcOEE8NRyxsTD/AdPoFe9ShxAHWPUzxYN3dwXBZqcrBVyBFN5syH1 tjqjh4VoU+YHVVo1fK9kh89o+2x/f9T+1wo58GebZ9qPhXt0TNFsZx1W6 A87HGJk4LzKHoaaSO9DXY9yNvHlYzcVOhca1fNDCuJx9nxZr728GcUCHT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3753124" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3753124" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7623729" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:07 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Cc: Radhakrishna Sripada , Jani Nikula Subject: [PATCH v3 2/6] drm/i915: Pass size to spi_oprom_get_vbt Date: Wed, 28 Feb 2024 13:32:31 -0800 Message-Id: <20240228213235.2495611-3-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> References: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" spi_oprom_get_vbt will later be used to show the contents of vbt for which the size of vbt is needed. Cc: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index 8ff0fdd5a828..2723f4319b5f 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -2957,7 +2957,8 @@ static u32 intel_spi_read(struct intel_uncore *uncore, u32 offset) return intel_uncore_read(uncore, PRIMARY_SPI_TRIGGER); } -static struct vbt_header *spi_oprom_get_vbt(struct drm_i915_private *i915) +static struct vbt_header *spi_oprom_get_vbt(struct drm_i915_private *i915, + size_t *size) { u32 count, data, found, store = 0; u32 static_region, oprom_offset; @@ -3000,6 +3001,9 @@ static struct vbt_header *spi_oprom_get_vbt(struct drm_i915_private *i915) drm_dbg_kms(&i915->drm, "Found valid VBT in SPI flash\n"); + if (size) + *size = vbt_size; + return (struct vbt_header *)vbt; err_free_vbt: @@ -3105,7 +3109,7 @@ void intel_bios_init(struct drm_i915_private *i915) * PCI mapping */ if (!vbt && IS_DGFX(i915)) { - oprom_vbt = spi_oprom_get_vbt(i915); + oprom_vbt = spi_oprom_get_vbt(i915, NULL); vbt = oprom_vbt; } From patchwork Wed Feb 28 21:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13575987 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4CD52C54E41 for ; Wed, 28 Feb 2024 21:34:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3EE410E284; Wed, 28 Feb 2024 21:34:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="L0ZaSrd+"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FBA410E284 for ; Wed, 28 Feb 2024 21:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709156049; x=1740692049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bo0CbZFnGhVlWG4S4t5rUlRXCNUdK+3JgMhJL1czYhA=; b=L0ZaSrd+1j0P3wQ9hQnOGzNY+odp1qJ3I/6lvFpYB0nQTRrvWPqxet7P JrKAMD04My59St7mrCiiP3zcT3d1YM/Hjw2ADomF0hWpB4ed/fiqWOcya hQSm5TC0jUgXPz8VnLArmrWQKDagzuy9eScAOpGARpbSHjROe4FG9+vO3 b9bUqESTGrTowYlOJrFfiYmeqPGg3udwYXqz6tF6cnHA0ixjN4pnUDWgr Qu5k97IbDzZHdWVwAt9v+ki+p74rbNsfD97DEdL6MKA0zKdyIBVdbuk9x UQa0fxq2vrPkDHOWGas+VacWKP58CpqIq0GN5h27tu65l+hLSbYA01TM6 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3753126" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3753126" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7623733" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:07 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Cc: Radhakrishna Sripada , Jani Nikula Subject: [PATCH v3 3/6] drm/i915: Move vbt read from firmware to intel_bios.c Date: Wed, 28 Feb 2024 13:32:32 -0800 Message-Id: <20240228213235.2495611-4-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> References: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" VBT read from firmware is currently nested within opregion vbt read. Extract it and place it together with other vbt read mechanisms and dis-associate vbt-firmware from opregion structure. v2: Return NULL in failure cases and use a null check in intel_bios_init(Jani) Cc: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 45 +++++++++++++++++- drivers/gpu/drm/i915/display/intel_opregion.c | 46 ------------------- 2 files changed, 44 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index 2723f4319b5f..a66fc79466bd 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -25,6 +25,8 @@ * */ +#include + #include #include #include @@ -2950,6 +2952,43 @@ bool intel_bios_is_valid_vbt(struct drm_i915_private *i915, return vbt; } +static struct vbt_header *firmware_get_vbt(struct drm_i915_private *i915, + size_t *size) +{ + struct vbt_header *vbt = NULL; + const struct firmware *fw = NULL; + const char *name = i915->display.params.vbt_firmware; + int ret; + + if (!name || !*name) + return NULL; + + ret = request_firmware(&fw, name, i915->drm.dev); + if (ret) { + drm_err(&i915->drm, + "Requesting VBT firmware \"%s\" failed (%d)\n", + name, ret); + return NULL; + } + + if (intel_bios_is_valid_vbt(i915, fw->data, fw->size)) { + vbt = kmemdup(fw->data, fw->size, GFP_KERNEL); + if (vbt) { + drm_dbg_kms(&i915->drm, + "Found valid VBT firmware \"%s\"\n", name); + if (size) + *size = fw->size; + } + } else { + drm_dbg_kms(&i915->drm, "Invalid VBT firmware \"%s\"\n", + name); + } + + release_firmware(fw); + + return vbt; +} + static u32 intel_spi_read(struct intel_uncore *uncore, u32 offset) { intel_uncore_write(uncore, PRIMARY_SPI_ADDRESS, offset); @@ -3102,7 +3141,11 @@ void intel_bios_init(struct drm_i915_private *i915) init_vbt_defaults(i915); - vbt = intel_opregion_get_vbt(i915, NULL); + oprom_vbt = firmware_get_vbt(i915, NULL); + vbt = oprom_vbt; + + if (!vbt) + vbt = intel_opregion_get_vbt(i915, NULL); /* * If the OpRegion does not have VBT, look in SPI flash through MMIO or diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c index fcbb083318a7..5d07a002edaa 100644 --- a/drivers/gpu/drm/i915/display/intel_opregion.c +++ b/drivers/gpu/drm/i915/display/intel_opregion.c @@ -27,7 +27,6 @@ #include #include -#include #include #include @@ -263,7 +262,6 @@ struct intel_opregion { struct opregion_asle *asle; struct opregion_asle_ext *asle_ext; void *rvda; - void *vbt_firmware; const void *vbt; u32 vbt_size; struct work_struct asle_work; @@ -869,46 +867,6 @@ static const struct dmi_system_id intel_no_opregion_vbt[] = { { } }; -static int intel_load_vbt_firmware(struct drm_i915_private *dev_priv) -{ - struct intel_opregion *opregion = dev_priv->display.opregion; - const struct firmware *fw = NULL; - const char *name = dev_priv->display.params.vbt_firmware; - int ret; - - if (!name || !*name) - return -ENOENT; - - ret = request_firmware(&fw, name, dev_priv->drm.dev); - if (ret) { - drm_err(&dev_priv->drm, - "Requesting VBT firmware \"%s\" failed (%d)\n", - name, ret); - return ret; - } - - if (intel_bios_is_valid_vbt(dev_priv, fw->data, fw->size)) { - opregion->vbt_firmware = kmemdup(fw->data, fw->size, GFP_KERNEL); - if (opregion->vbt_firmware) { - drm_dbg_kms(&dev_priv->drm, - "Found valid VBT firmware \"%s\"\n", name); - opregion->vbt = opregion->vbt_firmware; - opregion->vbt_size = fw->size; - ret = 0; - } else { - ret = -ENOMEM; - } - } else { - drm_dbg_kms(&dev_priv->drm, "Invalid VBT firmware \"%s\"\n", - name); - ret = -EINVAL; - } - - release_firmware(fw); - - return ret; -} - int intel_opregion_setup(struct drm_i915_private *dev_priv) { struct intel_opregion *opregion; @@ -1006,9 +964,6 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv) drm_dbg(&dev_priv->drm, "Mailbox #2 for backlight present\n"); } - if (intel_load_vbt_firmware(dev_priv) == 0) - goto out; - if (dmi_check_system(intel_no_opregion_vbt)) goto out; @@ -1312,7 +1267,6 @@ void intel_opregion_cleanup(struct drm_i915_private *i915) memunmap(opregion->header); if (opregion->rvda) memunmap(opregion->rvda); - kfree(opregion->vbt_firmware); kfree(opregion); i915->display.opregion = NULL; } From patchwork Wed Feb 28 21:32:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13575990 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 387C8C54E55 for ; Wed, 28 Feb 2024 21:34:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7FDCB10E3C6; Wed, 28 Feb 2024 21:34:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="XQGiF9pi"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6DD4D10E272 for ; Wed, 28 Feb 2024 21:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709156049; x=1740692049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vkQ0k/Wtb4CDVXQUvOyF9ROj6f9ZqOFIZ4sQiggKMLg=; b=XQGiF9pil6FWBJF4YeXBDI9UrHnYUpC+0j9YHm+Dfsm/DOACOnVqZF+8 M6oq5jDxfSMvp/su80e8HJpFHY/hTiu0zX1X4gBFDPs3LzbW+AXjdP9ot gkjgT++Bv1FgyuSCA/sBYnx3r3pD52fkcOBNTa80itMbiiVS9KtZrggCV L3H1WttqGX0sN525faMgkz89XIdAQdLN/ruPPpO3a4OqAkjERvcyvTDUK mvlelrA4qIJKKdMpJJJaqhk4le638Kj6JpvUNNhzl0GRmjxQ4n5mX73I0 tFSleTu4id3AzZabR7Qy8q6Rl38DBekAbqIlOpztRi5qvcrYF9TPMTWa4 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3753127" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3753127" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7623736" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:07 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Cc: Radhakrishna Sripada , Jani Nikula Subject: [PATCH v3 4/6] drm/i915: Extract opregion vbt presence check Date: Wed, 28 Feb 2024 13:32:33 -0800 Message-Id: <20240228213235.2495611-5-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> References: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We want to later change intel_opregion_get_vbt to duplicate the vbt memory if present, which would be an overkill when we just want to peek into the presence of opregion vbt. Carve out the presence check into its own function to use in places where only the presence of vbt is required. Suggested-by: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 3 +-- drivers/gpu/drm/i915/display/intel_opregion.c | 10 ++++++++++ drivers/gpu/drm/i915/display/intel_opregion.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index a66fc79466bd..c283a5a07010 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -3364,8 +3364,7 @@ bool intel_bios_is_lvds_present(struct drm_i915_private *i915, u8 *i2c_pin) * additional data. Trust that if the VBT was written into * the OpRegion then they have validated the LVDS's existence. */ - if (intel_opregion_get_vbt(i915, NULL)) - return true; + return intel_opregion_vbt_present(i915); } return false; diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c index 5d07a002edaa..58dfecb617b0 100644 --- a/drivers/gpu/drm/i915/display/intel_opregion.c +++ b/drivers/gpu/drm/i915/display/intel_opregion.c @@ -1131,6 +1131,16 @@ const struct drm_edid *intel_opregion_get_edid(struct intel_connector *intel_con return drm_edid; } +bool intel_opregion_vbt_present(struct drm_i915_private *i915) +{ + struct intel_opregion *opregion = i915->display.opregion; + + if (!opregion || !opregion->vbt) + return false; + + return true; +} + const void *intel_opregion_get_vbt(struct drm_i915_private *i915, size_t *size) { struct intel_opregion *opregion = i915->display.opregion; diff --git a/drivers/gpu/drm/i915/display/intel_opregion.h b/drivers/gpu/drm/i915/display/intel_opregion.h index 0bec224f711f..63573c38d735 100644 --- a/drivers/gpu/drm/i915/display/intel_opregion.h +++ b/drivers/gpu/drm/i915/display/intel_opregion.h @@ -53,6 +53,7 @@ int intel_opregion_notify_adapter(struct drm_i915_private *dev_priv, int intel_opregion_get_panel_type(struct drm_i915_private *dev_priv); const struct drm_edid *intel_opregion_get_edid(struct intel_connector *connector); +bool intel_opregion_vbt_present(struct drm_i915_private *i915); const void *intel_opregion_get_vbt(struct drm_i915_private *i915, size_t *size); bool intel_opregion_headless_sku(struct drm_i915_private *i915); From patchwork Wed Feb 28 21:32:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13575992 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 36CFCC5478C for ; Wed, 28 Feb 2024 21:34:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9ACC410E26F; Wed, 28 Feb 2024 21:34:24 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="CnwlQ3i0"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8F10410E36D for ; Wed, 28 Feb 2024 21:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709156049; x=1740692049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uaZeCg4qs7tXsglBTNiwB+kTCtzCjDwcRRjEZ3i5qsE=; b=CnwlQ3i09BpnRnwb9dy62wWrjN9OkKES5yv3idmF6LxZbQj8+ADz3A+A L+n+WZ1o/qe0A1Gdu0Wf1+xfpt/raDi8KbHMzc+nW+QpfH5H2rc5DOuZK AX1Kb151hQHLVfeAdSyI6UIfl8lLUUbRvQ3xOfgmlNFhHwZpnr0o1e4LB 4jCT9McYXKeZ9aIpIjAtQuVj4BVaGZumlgSqUDvmWMvkMFL4Nl6UL9Mvq k+pY0J+pZ7CklXqzPonYUCn0BscDVRncw82/s8yW0cr5plQwD3prkZtLx hEMal9PUaUawwemz9ZMXwx53PRV+svFRATDCwWtgBVaEclxZjL6kMCdTk g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3753128" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3753128" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7623739" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:07 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Cc: Radhakrishna Sripada , Jani Nikula Subject: [PATCH v3 5/6] drm/i915: Duplicate opregion vbt memory Date: Wed, 28 Feb 2024 13:32:34 -0800 Message-Id: <20240228213235.2495611-6-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> References: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" In the case of vbt residing in opregion, we simply remap the region into the kernel and pass the memory reference. Instead duplicate the memory to handle a saner cleanup in intel_bios_init. Cc: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 6 ++++-- drivers/gpu/drm/i915/display/intel_opregion.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index c283a5a07010..e5229c41dbf7 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -3144,8 +3144,10 @@ void intel_bios_init(struct drm_i915_private *i915) oprom_vbt = firmware_get_vbt(i915, NULL); vbt = oprom_vbt; - if (!vbt) - vbt = intel_opregion_get_vbt(i915, NULL); + if (!vbt) { + oprom_vbt = intel_opregion_get_vbt(i915, NULL); + vbt = oprom_vbt; + } /* * If the OpRegion does not have VBT, look in SPI flash through MMIO or diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c index 58dfecb617b0..68bd5101ec89 100644 --- a/drivers/gpu/drm/i915/display/intel_opregion.c +++ b/drivers/gpu/drm/i915/display/intel_opregion.c @@ -1151,7 +1151,7 @@ const void *intel_opregion_get_vbt(struct drm_i915_private *i915, size_t *size) if (size) *size = opregion->vbt_size; - return opregion->vbt; + return kmemdup(opregion->vbt, opregion->vbt_size, GFP_KERNEL); } bool intel_opregion_headless_sku(struct drm_i915_private *i915) From patchwork Wed Feb 28 21:32:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13575991 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 806D7C5478C for ; Wed, 28 Feb 2024 21:34:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCCD910E20E; Wed, 28 Feb 2024 21:34:21 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="RDD1238g"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E70710E284 for ; Wed, 28 Feb 2024 21:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709156049; x=1740692049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QrGtwNzhWbJQmj7eAHx6yQUFhoypdSSAHiGc8q9DWJ8=; b=RDD1238guCrvVSk4/AN4TuL1yQOD3W3Weau3UBk8xXrvN3Ynj108bxHs jpA7R0JplqzScuoxrrulUkIyTOOhgTIA4rUTOErn6O4QzLtWaGq0RNvAm jLJiGs6tNlbFGrjee8J0ddCWgMW9uiNb4SS02d3/r6Hlhzg3tZ5ytbwYE QYDJB7aDACqw5pJHNUVYmYLf2d4BeQCQKwO8eDk1erl8bu1cz6/yaFwT1 yV0LfKPwaTtucf8xFyZ/37/BSPq0J3vBGIITzTWk/DwWsxaLcIVUEhcGZ wCtpeq/ioF8JB7NQ3Sf2gT20tbaZ+gPQSeMerACTIPnWR0fDvQOcQdpJA A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3753131" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3753131" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="7623742" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 13:34:07 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Cc: Radhakrishna Sripada , Jani Nikula Subject: [PATCH v3 6/6] drm/i915: Show bios vbt when read from firmware/spi/oprom Date: Wed, 28 Feb 2024 13:32:35 -0800 Message-Id: <20240228213235.2495611-7-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> References: <20240228213235.2495611-1-radhakrishna.sripada@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Make debugfs vbt only shows valid vbt when read from ACPI opregion. Make it work when read from firmware/spi/pci oprom cases. v2: Extract getiing vbt from different sources to its own function. Protect sysfs write with vbt check(Jani) Cc: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 60 +++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index e5229c41dbf7..80d1bbcc68df 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -3116,6 +3116,29 @@ static struct vbt_header *oprom_get_vbt(struct drm_i915_private *i915, return NULL; } +static const struct vbt_header *intel_bios_get_vbt(struct drm_i915_private *i915, + size_t *sizep) +{ + const struct vbt_header *vbt = NULL; + + vbt = firmware_get_vbt(i915, sizep); + + if (!vbt) + vbt = intel_opregion_get_vbt(i915, sizep); + + /* + * If the OpRegion does not have VBT, look in SPI flash through MMIO or + * PCI mapping + */ + if (!vbt && IS_DGFX(i915)) + vbt = spi_oprom_get_vbt(i915, sizep); + + if (!vbt) + vbt = oprom_get_vbt(i915, sizep); + + return vbt; +} + /** * intel_bios_init - find VBT and initialize settings from the BIOS * @i915: i915 device instance @@ -3127,7 +3150,6 @@ static struct vbt_header *oprom_get_vbt(struct drm_i915_private *i915, void intel_bios_init(struct drm_i915_private *i915) { const struct vbt_header *vbt; - struct vbt_header *oprom_vbt = NULL; const struct bdb_header *bdb; INIT_LIST_HEAD(&i915->display.vbt.display_devices); @@ -3141,28 +3163,7 @@ void intel_bios_init(struct drm_i915_private *i915) init_vbt_defaults(i915); - oprom_vbt = firmware_get_vbt(i915, NULL); - vbt = oprom_vbt; - - if (!vbt) { - oprom_vbt = intel_opregion_get_vbt(i915, NULL); - vbt = oprom_vbt; - } - - /* - * If the OpRegion does not have VBT, look in SPI flash through MMIO or - * PCI mapping - */ - if (!vbt && IS_DGFX(i915)) { - oprom_vbt = spi_oprom_get_vbt(i915, NULL); - vbt = oprom_vbt; - } - - if (!vbt) { - oprom_vbt = oprom_get_vbt(i915, NULL); - vbt = oprom_vbt; - } - + vbt = intel_bios_get_vbt(i915, NULL); if (!vbt) goto out; @@ -3194,7 +3195,7 @@ void intel_bios_init(struct drm_i915_private *i915) parse_sdvo_device_mapping(i915); parse_ddi_ports(i915); - kfree(oprom_vbt); + kfree(vbt); } static void intel_bios_init_panel(struct drm_i915_private *i915, @@ -3724,13 +3725,12 @@ static int intel_bios_vbt_show(struct seq_file *m, void *unused) const void *vbt; size_t vbt_size; - /* - * FIXME: VBT might originate from other places than opregion, and then - * this would be incorrect. - */ - vbt = intel_opregion_get_vbt(i915, &vbt_size); - if (vbt) + vbt = intel_bios_get_vbt(i915, &vbt_size); + + if (vbt) { seq_write(m, vbt, vbt_size); + kfree(vbt); + } return 0; }