On Wed, Oct 8, 2025 at 3:06 PM Yao, Jia <[email protected]> wrote: > > Hi Pingfan, > > You're welcome. I guess you are referring to the following code, > > static void pci_device_shutdown(struct device *dev) > { > struct pci_dev *pci_dev = to_pci_dev(dev); > struct pci_driver *drv = pci_dev->driver; > > pm_runtime_resume(dev); > > if (drv && drv->shutdown) > drv->shutdown(pci_dev); > > /* > * If this is a kexec reboot, turn off Bus Master bit on the > * device to tell it to not continue to do DMA. Don't touch > * devices in D3cold or unknown states. > * If it is not a kexec reboot, firmware will hit the PCI > * devices with big hammer and stop their DMA any way. > */ > if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot)) > pci_clear_master(pci_dev); > } > > but it just disables the i915 device as a DMA master, not prevent DMA > access to i915 device. >
That is not all of my questions. Let me rephrase my question in a different way: which device accesses i915's memory? And does it send i915 to an insane state, which can not be recovered in the second kernel? Thanks, Pingfan > Thanks, > Jia > > -----Original Message----- > From: Pingfan Liu <[email protected]> > Sent: Tuesday, October 7, 2025 10:18 PM > To: Yao, Jia <[email protected]> > Cc: [email protected]; Zuo, Alex <[email protected]>; Lin, > Shuicheng <[email protected]>; Askar Safin <[email protected]>; > Chris Wilson <[email protected]> > Subject: Re: [PATCH v2] drm/i915: Setting/clearing the memory access bit when > en/disabling i915 > > Hi Jia, > > Thanks for the patch, please see the comments below. > > On Wed, Oct 8, 2025 at 4:25 AM Jia Yao <[email protected]> wrote: > > > > Make i915's PCI device management more robust by always > > setting/clearing the memory access bit when enabling/disabling the > > device, and by consolidating this logic into helper functions. > > > > It fixes kexec reboot issue by disabling memory access before shutting > > down the device, which can block unsafe and unwanted access from DMA. > > > > PCI_COMMAND_MEMORY blocks the access to i915 PCI_COMMAND_MASTER blocks i915 > from accessing the system memory. > > In the case of kexec-reboot, I think PCI_COMMAND_MASTER has been set on all > pci devices. So I can not figure out how clearing PCI_COMMAND_MEMORY can help > in this case. > > Can you explain a little bit? > > Thanks, > > Pingfan > > > v2: > > - follow brace style > > > > Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14598 > > Cc: Alex Zuo <[email protected]> > > Cc: Shuicheng Lin <[email protected]> > > Cc: Askar Safin <[email protected]> > > Cc: Pingfan Liu <[email protected]> > > Suggested-by: Chris Wilson <[email protected]> > > Signed-off-by: Jia Yao <[email protected]> > > --- > > drivers/gpu/drm/i915/i915_driver.c | 35 > > +++++++++++++++++++++++++++--- > > 1 file changed, 32 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/i915_driver.c > > b/drivers/gpu/drm/i915/i915_driver.c > > index b46cb54ef5dc..766f85726b67 100644 > > --- a/drivers/gpu/drm/i915/i915_driver.c > > +++ b/drivers/gpu/drm/i915/i915_driver.c > > @@ -118,6 +118,33 @@ > > > > static const struct drm_driver i915_drm_driver; > > > > +static int i915_enable_device(struct pci_dev *pdev) { > > + u32 cmd; > > + int ret; > > + > > + ret = pci_enable_device(pdev); > > + if (ret) > > + return ret; > > + > > + pci_read_config_dword(pdev, PCI_COMMAND, &cmd); > > + if (!(cmd & PCI_COMMAND_MEMORY)) > > + pci_write_config_dword(pdev, PCI_COMMAND, cmd | > > + PCI_COMMAND_MEMORY); > > + > > + return 0; > > +} > > + > > +static void i915_disable_device(struct pci_dev *pdev) { > > + u32 cmd; > > + > > + pci_read_config_dword(pdev, PCI_COMMAND, &cmd); > > + if (cmd & PCI_COMMAND_MEMORY) > > + pci_write_config_dword(pdev, PCI_COMMAND, cmd & > > + ~PCI_COMMAND_MEMORY); > > + > > + pci_disable_device(pdev); > > +} > > + > > static int i915_workqueues_init(struct drm_i915_private *dev_priv) { > > /* > > @@ -788,7 +815,7 @@ int i915_driver_probe(struct pci_dev *pdev, const > > struct pci_device_id *ent) > > struct intel_display *display; > > int ret; > > > > - ret = pci_enable_device(pdev); > > + ret = i915_enable_device(pdev); > > if (ret) { > > pr_err("Failed to enable graphics device: %pe\n", > > ERR_PTR(ret)); > > return ret; > > @@ -796,7 +823,7 @@ int i915_driver_probe(struct pci_dev *pdev, const > > struct pci_device_id *ent) > > > > i915 = i915_driver_create(pdev, ent); > > if (IS_ERR(i915)) { > > - pci_disable_device(pdev); > > + i915_disable_device(pdev); > > return PTR_ERR(i915); > > } > > > > @@ -885,7 +912,7 @@ int i915_driver_probe(struct pci_dev *pdev, const > > struct pci_device_id *ent) > > enable_rpm_wakeref_asserts(&i915->runtime_pm); > > i915_driver_late_release(i915); > > out_pci_disable: > > - pci_disable_device(pdev); > > + i915_disable_device(pdev); > > i915_probe_error(i915, "Device initialization failed (%d)\n", ret); > > return ret; > > } > > @@ -1003,6 +1030,7 @@ void i915_driver_shutdown(struct > > drm_i915_private *i915) > > > > intel_dmc_suspend(display); > > > > + intel_pxp_fini(i915); > > i915_gem_suspend(i915); > > > > /* > > @@ -1020,6 +1048,7 @@ void i915_driver_shutdown(struct drm_i915_private > > *i915) > > enable_rpm_wakeref_asserts(&i915->runtime_pm); > > > > intel_runtime_pm_driver_last_release(&i915->runtime_pm); > > + i915_disable_device(to_pci_dev(i915->drm.dev)); > > } > > > > static bool suspend_to_idle(struct drm_i915_private *dev_priv) > > -- > > 2.34.1 > > >
