From: Jani Nikula <jani.nikula@intel.com>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
uma.shankar@intel.com
Subject: Re: [PATCH] drm/i915/gmch: find bridge device locally
Date: Thu, 13 Nov 2025 17:26:08 +0200 [thread overview]
Message-ID: <5368b8ef955fb7615cc35458ff8ce4ee2dbc3c30@intel.com> (raw)
In-Reply-To: <aRX0aqq9p9vVJep6@intel.com>
On Thu, 13 Nov 2025, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Thu, Nov 13, 2025 at 03:38:06PM +0200, Jani Nikula wrote:
>> We don't really need the cached i915->gmch.pdev reference. Look up the
>> bridge device locally, and remove the final dependency on struct
>> drm_i915_private and i915_drv.h.
>>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>> drivers/gpu/drm/i915/display/intel_gmch.c | 25 ++++++++++++++++-------
>> 1 file changed, 18 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_gmch.c b/drivers/gpu/drm/i915/display/intel_gmch.c
>> index 475f2b6ce39e..9bf36f02a062 100644
>> --- a/drivers/gpu/drm/i915/display/intel_gmch.c
>> +++ b/drivers/gpu/drm/i915/display/intel_gmch.c
>> @@ -9,7 +9,6 @@
>> #include <drm/drm_print.h>
>> #include <drm/intel/i915_drm.h>
>>
>> -#include "i915_drv.h"
>> #include "intel_display_core.h"
>> #include "intel_display_types.h"
>> #include "intel_gmch.h"
>> @@ -17,18 +16,26 @@
>>
>> static int intel_gmch_vga_set_state(struct intel_display *display, bool enable_decode)
>> {
>> - struct drm_i915_private *i915 = to_i915(display->drm);
>> - struct pci_dev *bridge = i915->gmch.pdev;
>> + struct pci_dev *pdev = to_pci_dev(display->drm->dev);
>> + struct pci_dev *bridge;
>> unsigned int reg = DISPLAY_VER(display) >= 6 ? SNB_GMCH_CTRL : INTEL_GMCH_CTRL;
>> u16 gmch_ctrl;
>> + int ret = 0;
>> +
>> + bridge = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 0, PCI_DEVFN(0, 0));
>> + if (!bridge) {
>> + drm_err(display->drm, "bridge device not found\n");
>> + return -EIO;
>> + }
>>
>> if (pci_read_config_word(bridge, reg, &gmch_ctrl)) {
>
> I think you could just use pci_bus_{read,write}_config_word() and then
> you don't need the pci_dev reference. That's what I've used in the
> overlay workaround code as well.
Oh, neat, seems cleaner.
> I was pondering how this even works on discrete GPUs, but there it
> seems the GPU PCI device is devfn=0.0 sitting on its own bus. So it
> seems that it should work. Well, work in the sense that it accesses
> the correct register. But in reality this code is complete nonsense
> as this register is locked by the BIOS and so can't actually be
> written by the driver.
>
> The alternative approach would be to use the actual GPU PCI device
> on SNB+ since the GGC register is also mirrored there (and I think
> also mirrored in MCHBAR, so we could also use MMIO to access it
> instead). I suppose it's technically the mirror that we're accessing
> on dGPUs here always. On integrated we could choose to use either one.
I'm just trying to dodge *that* specific part of the mess during the
refactoring! ;D
BR,
Jani.
>
>> drm_err(display->drm, "failed to read control word\n");
>> - return -EIO;
>> + ret = -EIO;
>> + goto out;
>> }
>>
>> if (!!(gmch_ctrl & INTEL_GMCH_VGA_DISABLE) == !enable_decode)
>> - return 0;
>> + goto out;
>>
>> if (enable_decode)
>> gmch_ctrl &= ~INTEL_GMCH_VGA_DISABLE;
>> @@ -37,10 +44,14 @@ static int intel_gmch_vga_set_state(struct intel_display *display, bool enable_d
>>
>> if (pci_write_config_word(bridge, reg, gmch_ctrl)) {
>> drm_err(display->drm, "failed to write control word\n");
>> - return -EIO;
>> + ret = -EIO;
>> + goto out;
>> }
>>
>> - return 0;
>> +out:
>> + pci_dev_put(bridge);
>> +
>> + return ret;
>> }
>>
>> unsigned int intel_gmch_vga_set_decode(struct pci_dev *pdev, bool enable_decode)
>> --
>> 2.47.3
--
Jani Nikula, Intel
next prev parent reply other threads:[~2025-11-13 15:26 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 9:57 [PATCH 0/8] drm/i915: start dissolving soc/ Jani Nikula
2025-11-13 9:57 ` [PATCH 1/8] drm/i915/edram: extract i915_edram.[ch] for edram detection Jani Nikula
2025-11-13 9:57 ` [PATCH 2/8] drm/i915: split out i915_freq.[ch] Jani Nikula
2025-11-13 9:58 ` [PATCH 3/8] drm/i915: move intel_dram.[ch] from soc/ to display/ Jani Nikula
2025-11-13 9:58 ` [PATCH 4/8] drm/xe: remove MISSING_CASE() from compat i915_utils.h Jani Nikula
2025-11-13 9:58 ` [PATCH 5/8] drm/i915/dram: convert to struct intel_display Jani Nikula
2025-11-13 13:39 ` Ville Syrjälä
2025-11-13 13:45 ` Jani Nikula
2025-11-13 9:58 ` [PATCH 6/8] drm/i915: move dram_info " Jani Nikula
2025-11-13 9:58 ` [PATCH 7/8] drm/i915: move intel_rom.[ch] from soc/ to display/ Jani Nikula
2025-11-13 9:58 ` [PATCH 8/8] drm/xe: remove remaining platform checks from compat i915_drv.h Jani Nikula
2025-11-13 13:29 ` [PATCH 0/8] drm/i915: start dissolving soc/ Jani Nikula
2025-11-13 13:44 ` Jani Nikula
2025-11-13 13:37 ` [PATCH] drm/i915/gmch: split out i915_gmch.[ch] from soc Jani Nikula
2025-11-13 13:37 ` [PATCH] drm/i915: move intel_gmch.[ch] from soc/ to display/ Jani Nikula
2025-11-13 13:53 ` Ville Syrjälä
2025-11-13 15:22 ` Jani Nikula
2025-11-13 13:37 ` [PATCH] drm/i915/gmch: convert intel_gmch.c to struct intel_display Jani Nikula
2025-11-13 13:38 ` [PATCH] drm/i915/gmch: find bridge device locally Jani Nikula
2025-11-13 15:08 ` Ville Syrjälä
2025-11-13 15:26 ` Jani Nikula [this message]
2025-11-13 13:38 ` [PATCH] drm/xe: use the same vga decode code as i915 Jani Nikula
2025-11-14 22:23 ` kernel test robot
2025-11-13 23:21 ` ✗ i915.CI.BAT: failure for " Patchwork
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=5368b8ef955fb7615cc35458ff8ce4ee2dbc3c30@intel.com \
--to=jani.nikula@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=uma.shankar@intel.com \
--cc=ville.syrjala@linux.intel.com \
/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