From patchwork Tue Feb 20 22:31:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13564637 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 B48D6C48BC4 for ; Tue, 20 Feb 2024 22:33:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9391910E595; Tue, 20 Feb 2024 22:33:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="RDeV0c9o"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id C3BBF10E595 for ; Tue, 20 Feb 2024 22:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708468396; x=1740004396; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=RGZyOa8jAkZuIos3TEYhftWLCjool+Aa9oSV9PQY00k=; b=RDeV0c9oC3M5cpN/mSFhXGdmY31Hik4LVNS88Gqqf/sBDkM6KS0gXfhS jTxYaSzpsamg4mn8Kz2YH/rtXZwW9kc9PJZ2LFaIv38uzASpn/aIT00dX 6kmeraSaOY+aH5huwtCH5TboShGFXQ+RLqtnB6F+1HrRoZQGNWJfu5Ooy VEzsxpzLRZyeIF6saHr/Y+DI5p31A2ZIKcjHl/o38+C5QwCrD9uKq6MmR EZtSQ2ii5Y2xU6gpRTdWkROBdsdE4jJ12Ppzo/72HesI3np+MVN5jumZT jbYCFDXX1LzEfpsZUMKK5WcM0bVu7ABn5XlgWfme7bjYeegOsNhxbA39k g==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="14006864" X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="14006864" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 14:32:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="4869885" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 14:32:57 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 1/4] drm/i915: Pass size to oprom_get_vbt Date: Tue, 20 Feb 2024 14:31:26 -0800 Message-Id: <20240220223129.3822480-2-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220223129.3822480-1-radhakrishna.sripada@intel.com> References: <20240220223129.3822480-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. Cc: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index fe52c06271ef..ceb6e4145c62 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -3008,38 +3008,39 @@ 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 *size) { struct pci_dev *pdev = to_pci_dev(i915->drm.dev); void __iomem *p = NULL, *oprom; struct vbt_header *vbt; u16 vbt_size; - size_t i, size; + size_t i; - oprom = pci_map_rom(pdev, &size); + oprom = pci_map_rom(pdev, size); if (!oprom) return NULL; /* Scour memory looking for the VBT signature. */ - for (i = 0; i + 4 < size; i += 4) { + for (i = 0; i + 4 < *size; i += 4) { if (ioread32(oprom + i) != *((const u32 *)"$VBT")) continue; p = oprom + i; - size -= i; + *size -= i; break; } if (!p) goto err_unmap_oprom; - if (sizeof(struct vbt_header) > size) { + if (sizeof(struct vbt_header) > *size) { drm_dbg(&i915->drm, "VBT header incomplete\n"); goto err_unmap_oprom; } vbt_size = ioread16(p + offsetof(struct vbt_header, vbt_size)); - if (vbt_size > size) { + if (vbt_size > *size) { drm_dbg(&i915->drm, "VBT incomplete (vbt_size overflows)\n"); goto err_unmap_oprom; @@ -3082,6 +3083,7 @@ 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; + size_t size; INIT_LIST_HEAD(&i915->display.vbt.display_devices); INIT_LIST_HEAD(&i915->display.vbt.bdb_blocks); @@ -3106,7 +3108,7 @@ void intel_bios_init(struct drm_i915_private *i915) } if (!vbt) { - oprom_vbt = oprom_get_vbt(i915); + oprom_vbt = oprom_get_vbt(i915, &size); vbt = oprom_vbt; } From patchwork Tue Feb 20 22:31:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13564635 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 C02FCC48BC4 for ; Tue, 20 Feb 2024 22:33:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 81AA710E387; Tue, 20 Feb 2024 22:33:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="eJe6nNvZ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9699210E387 for ; Tue, 20 Feb 2024 22:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708468395; x=1740004395; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=/FLoFJoTm4FGWdBiONijIx5khEiZjtaOTufl/9ipSHc=; b=eJe6nNvZrMxzzLO5guklT3YEnWn/hErt0SQWJSgmBR8X+SeVapP6c6LW EP7Aokdii2oRKksEXQDOX2ZoIseWXVfHhWr+d+BozZKGcQN0vrttWPjil tfrj9W7eQBFrLLFnUU3YMSmackiUhnPTa8nhSKAINcpvSwMyThAOsEb8L uSa3xllxTetJgCmltxUiMMcs/xqFhaGBf95MmeMsjRgkJehFhWHtEwSjW iTrKyHInxBmaB1IENoBdc5xuaA7sLIKD7v2U3O+lH9/UWp08BF3m/UtDQ 4707UQfKO2D+nYf3up3OOIH/3XiygiOryWGjURClAU8hP3g6SjSDZWm7u A==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="14006866" X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="14006866" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 14:32:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="4869886" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 14:32:57 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 2/4] drm/i915: Pass size to spi_oprom_get_vbt Date: Tue, 20 Feb 2024 14:31:27 -0800 Message-Id: <20240220223129.3822480-3-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220223129.3822480-1-radhakrishna.sripada@intel.com> References: <20240220223129.3822480-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 Reviewed-by: Jani Nikula --- 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 ceb6e4145c62..2624a4528b21 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: @@ -3103,7 +3107,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 Tue Feb 20 22:31:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13564634 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 9BA10C48BC3 for ; Tue, 20 Feb 2024 22:33:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D102C10E19B; Tue, 20 Feb 2024 22:33:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="KxDojBPw"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DD2910E19B for ; Tue, 20 Feb 2024 22:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708468393; x=1740004393; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Z2Rzg7eNd4dl3CMg4Slqb9Ygm6MxBpQJ8aSM1ZwIjIk=; b=KxDojBPw5WNEulZnqEaZsZMqFk03YqKk49YT5+WGRHKcIi/cpWeGMxCk uBuvOzKMAqoCK1TE+189926j8zvjofANpWePxeucj8apc+Xpb0DNv0caF p6o1EQ4vHTQOdtc9+/8+l7vOddwqQhibsI9k9GoQQvEYGWOnvAtG+09xU DJjCis7jZtI+RYFa12vM1I3hUaJaigrpuiSHtmEP+qVUtoEoieUKPmPuO aMcuhWaZooRMYCZ0AGfH/oVpvVxjEZ53jULXp19JmUap9soTgF9z/HGiL NJuQokf3mt/oVs4zly/xYhbVfucagCSCs4e9sL9DSwnxb4A95mf8TDuqq g==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="14006867" X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="14006867" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 14:32:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="4869887" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 14:32:57 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 3/4] drm/i915: Move vbt read from firmware to intel_bios.c Date: Tue, 20 Feb 2024 14:31:28 -0800 Message-Id: <20240220223129.3822480-4-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220223129.3822480-1-radhakrishna.sripada@intel.com> References: <20240220223129.3822480-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. Cc: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 48 ++++++++++++++++++- drivers/gpu/drm/i915/display/intel_opregion.c | 46 ------------------ 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index 2624a4528b21..4cd338ed362d 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,47 @@ 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 vbt; + + ret = request_firmware(&fw, name, i915->drm.dev); + if (ret) { + drm_err(&i915->drm, + "Requesting VBT firmware \"%s\" failed (%d)\n", + name, ret); + return vbt; + } + + 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); + *size = fw->size; + } else { + drm_err(&i915->drm, + "Requesting VBT firmware \"%s\" failed (%d)\n", + name, ENOMEM); + vbt = NULL; + } + } 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); @@ -3100,7 +3143,10 @@ void intel_bios_init(struct drm_i915_private *i915) init_vbt_defaults(i915); - vbt = intel_opregion_get_vbt(i915, NULL); + vbt = firmware_get_vbt(i915, &size); + + 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 Tue Feb 20 22:31:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripada, Radhakrishna" X-Patchwork-Id: 13564636 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 6180DC54764 for ; Tue, 20 Feb 2024 22:33:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D110E10E593; Tue, 20 Feb 2024 22:33:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="lliDO3HA"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A3D210E387 for ; Tue, 20 Feb 2024 22:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708468395; x=1740004395; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=wxIGuKJCVVRc7klIrzomcasDjqrtoDGFPXYyqCtVIf8=; b=lliDO3HA3Z61aL7Za5sz//u5OZzA31sFaWcJo1sN/UMtAbFLDrbud0DN 1WKaMkH5ut9uVx3hRGDbJJVQMPlH2LRW/0MXHuK9TvyK/JdSiK46+v2/T LSCzVUZYOMJouILXPlZfiI9ET8lJbFhuyIWVYlnO2zo5Frmh7Fyf8IaxV DhF7ZwsfUZKOaw3DqvldU0sXobJU17OiVxCHVi2oxIbqTsIJKEzmxKpUT 4VAostpgzxdvi7q3KoM9cuqChJ9362FDjl0wwpWSPNxU04mLdx6sHnvE9 Oj/tBKH0vINoZPiMw5dRtaIL9M8EWA0ILK0B6hJ72CMSskSZS85KfQ5cd w==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="14006868" X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="14006868" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 14:33:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="4869888" Received: from invictus.jf.intel.com ([10.165.21.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 14:32:58 -0800 From: Radhakrishna Sripada To: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 4/4] drm/i915: Show bios vbt when read from firmware/spi/oprom Date: Tue, 20 Feb 2024 14:31:29 -0800 Message-Id: <20240220223129.3822480-5-radhakrishna.sripada@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220223129.3822480-1-radhakrishna.sripada@intel.com> References: <20240220223129.3822480-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. Cc: Jani Nikula Signed-off-by: Radhakrishna Sripada --- drivers/gpu/drm/i915/display/intel_bios.c | 30 +++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index 4cd338ed362d..b9b4ebc0ecd6 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -3723,14 +3723,30 @@ static int intel_bios_vbt_show(struct seq_file *m, void *unused) struct drm_i915_private *i915 = m->private; const void *vbt; size_t vbt_size; + bool need_cleanup = false; - /* - * 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) - seq_write(m, vbt, vbt_size); + vbt = firmware_get_vbt(i915, &vbt_size); + + if (!vbt) + vbt = intel_opregion_get_vbt(i915, &vbt_size); + + if (!vbt && IS_DGFX(i915)) { + vbt = spi_oprom_get_vbt(i915, &vbt_size); + need_cleanup = true; + } + + if (!vbt) { + vbt = oprom_get_vbt(i915, &vbt_size); + need_cleanup = true; + } + + if (!vbt) + return 0; + + seq_write(m, vbt, vbt_size); + + if (need_cleanup) + kfree(vbt); return 0; }