Message ID | 20181012215218.5119-16-jose.souza@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/16] drm/i915: Properly set PCH as NOP when display is disabled | expand |
On Fri, 12 Oct 2018, José Roberto de Souza <jose.souza@intel.com> wrote: > Without this checks in this debugfs, it would try access memory and > resorces from display causing the driver to crash. Hum, need to consider this. It's an option to not register the display debugfs files at all in this case. Might be much neater. BR, Jani. > > Signed-off-by: José Roberto de Souza <jose.souza@intel.com> > --- > drivers/gpu/drm/i915/i915_debugfs.c | 64 +++++++++++++++++++++++++++++ > 1 file changed, 64 insertions(+) > > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c > index 00c551d3e409..7864bf233d99 100644 > --- a/drivers/gpu/drm/i915/i915_debugfs.c > +++ b/drivers/gpu/drm/i915/i915_debugfs.c > @@ -1636,6 +1636,9 @@ static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) > { > struct drm_i915_private *dev_priv = node_to_i915(m->private); > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > seq_printf(m, "FB tracking busy bits: 0x%08x\n", > dev_priv->fb_tracking.busy_bits); > > @@ -1653,6 +1656,9 @@ static int i915_fbc_status(struct seq_file *m, void *unused) > if (!HAS_FBC(dev_priv)) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > intel_runtime_pm_get(dev_priv); > mutex_lock(&fbc->lock); > > @@ -1729,6 +1735,9 @@ static int i915_ips_status(struct seq_file *m, void *unused) > if (!HAS_IPS(dev_priv)) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > intel_runtime_pm_get(dev_priv); > > seq_printf(m, "Enabled by kernel parameter: %s\n", > @@ -1753,6 +1762,9 @@ static int i915_sr_status(struct seq_file *m, void *unused) > struct drm_i915_private *dev_priv = node_to_i915(m->private); > bool sr_enabled = false; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > intel_runtime_pm_get(dev_priv); > intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); > > @@ -1891,6 +1903,9 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data) > struct drm_framebuffer *drm_fb; > int ret; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > ret = mutex_lock_interruptible(&dev->struct_mutex); > if (ret) > return ret; > @@ -2777,6 +2792,9 @@ i915_edp_psr_debug_set(void *data, u64 val) > if (!CAN_PSR(dev_priv)) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > DRM_DEBUG_KMS("Setting PSR debug to %llx\n", val); > > intel_runtime_pm_get(dev_priv); > @@ -3222,6 +3240,9 @@ static int i915_display_info(struct seq_file *m, void *unused) > struct drm_connector *connector; > struct drm_connector_list_iter conn_iter; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > intel_runtime_pm_get(dev_priv); > seq_printf(m, "CRTC info\n"); > seq_printf(m, "---------\n"); > @@ -3326,6 +3347,9 @@ static int i915_shared_dplls_info(struct seq_file *m, void *unused) > struct drm_device *dev = &dev_priv->drm; > int i; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > drm_modeset_lock_all(dev); > for (i = 0; i < dev_priv->num_shared_dpll; i++) { > struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; > @@ -3398,6 +3422,9 @@ static int i915_ipc_status_open(struct inode *inode, struct file *file) > if (!HAS_IPC(dev_priv)) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > return single_open(file, i915_ipc_status_show, dev_priv); > } > > @@ -3445,6 +3472,9 @@ static int i915_ddb_info(struct seq_file *m, void *unused) > if (INTEL_GEN(dev_priv) < 9) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > drm_modeset_lock_all(dev); > > ddb = &dev_priv->wm.skl_hw.ddb; > @@ -3553,6 +3583,9 @@ static int i915_drrs_status(struct seq_file *m, void *unused) > struct intel_crtc *intel_crtc; > int active_crtc_cnt = 0; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > drm_modeset_lock_all(dev); > for_each_intel_crtc(dev, intel_crtc) { > if (intel_crtc->base.state->active) { > @@ -3579,6 +3612,9 @@ static int i915_dp_mst_info(struct seq_file *m, void *unused) > struct drm_connector *connector; > struct drm_connector_list_iter conn_iter; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > drm_connector_list_iter_begin(dev, &conn_iter); > drm_for_each_connector_iter(connector, &conn_iter) { > if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) > @@ -3697,6 +3733,11 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data) > static int i915_displayport_test_active_open(struct inode *inode, > struct file *file) > { > + struct drm_i915_private *dev_priv = inode->i_private; > + > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > return single_open(file, i915_displayport_test_active_show, > inode->i_private); > } > @@ -3718,6 +3759,9 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data) > struct drm_connector_list_iter conn_iter; > struct intel_dp *intel_dp; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > drm_connector_list_iter_begin(dev, &conn_iter); > drm_for_each_connector_iter(connector, &conn_iter) { > struct intel_encoder *encoder; > @@ -3762,6 +3806,9 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data) > struct drm_connector_list_iter conn_iter; > struct intel_dp *intel_dp; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > drm_connector_list_iter_begin(dev, &conn_iter); > drm_for_each_connector_iter(connector, &conn_iter) { > struct intel_encoder *encoder; > @@ -3878,6 +3925,9 @@ static int pri_wm_latency_open(struct inode *inode, struct file *file) > if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > return single_open(file, pri_wm_latency_show, dev_priv); > } > > @@ -3888,6 +3938,9 @@ static int spr_wm_latency_open(struct inode *inode, struct file *file) > if (HAS_GMCH_DISPLAY(dev_priv)) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > return single_open(file, spr_wm_latency_show, dev_priv); > } > > @@ -3898,6 +3951,9 @@ static int cur_wm_latency_open(struct inode *inode, struct file *file) > if (HAS_GMCH_DISPLAY(dev_priv)) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > return single_open(file, cur_wm_latency_show, dev_priv); > } > > @@ -4645,6 +4701,11 @@ static ssize_t i915_hpd_storm_ctl_write(struct file *file, > > static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) > { > + struct drm_i915_private *dev_priv = inode->i_private; > + > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); > } > > @@ -4668,6 +4729,9 @@ static int i915_drrs_ctl_set(void *data, u64 val) > if (INTEL_GEN(dev_priv) < 7) > return -ENODEV; > > + if (!INTEL_INFO(dev_priv)->num_pipes) > + return -ENODEV; > + > drm_modeset_lock_all(dev); > for_each_intel_crtc(dev, intel_crtc) { > if (!intel_crtc->base.state->active ||
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 00c551d3e409..7864bf233d99 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -1636,6 +1636,9 @@ static int i915_frontbuffer_tracking(struct seq_file *m, void *unused) { struct drm_i915_private *dev_priv = node_to_i915(m->private); + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + seq_printf(m, "FB tracking busy bits: 0x%08x\n", dev_priv->fb_tracking.busy_bits); @@ -1653,6 +1656,9 @@ static int i915_fbc_status(struct seq_file *m, void *unused) if (!HAS_FBC(dev_priv)) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + intel_runtime_pm_get(dev_priv); mutex_lock(&fbc->lock); @@ -1729,6 +1735,9 @@ static int i915_ips_status(struct seq_file *m, void *unused) if (!HAS_IPS(dev_priv)) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + intel_runtime_pm_get(dev_priv); seq_printf(m, "Enabled by kernel parameter: %s\n", @@ -1753,6 +1762,9 @@ static int i915_sr_status(struct seq_file *m, void *unused) struct drm_i915_private *dev_priv = node_to_i915(m->private); bool sr_enabled = false; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + intel_runtime_pm_get(dev_priv); intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); @@ -1891,6 +1903,9 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data) struct drm_framebuffer *drm_fb; int ret; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + ret = mutex_lock_interruptible(&dev->struct_mutex); if (ret) return ret; @@ -2777,6 +2792,9 @@ i915_edp_psr_debug_set(void *data, u64 val) if (!CAN_PSR(dev_priv)) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + DRM_DEBUG_KMS("Setting PSR debug to %llx\n", val); intel_runtime_pm_get(dev_priv); @@ -3222,6 +3240,9 @@ static int i915_display_info(struct seq_file *m, void *unused) struct drm_connector *connector; struct drm_connector_list_iter conn_iter; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + intel_runtime_pm_get(dev_priv); seq_printf(m, "CRTC info\n"); seq_printf(m, "---------\n"); @@ -3326,6 +3347,9 @@ static int i915_shared_dplls_info(struct seq_file *m, void *unused) struct drm_device *dev = &dev_priv->drm; int i; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + drm_modeset_lock_all(dev); for (i = 0; i < dev_priv->num_shared_dpll; i++) { struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; @@ -3398,6 +3422,9 @@ static int i915_ipc_status_open(struct inode *inode, struct file *file) if (!HAS_IPC(dev_priv)) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + return single_open(file, i915_ipc_status_show, dev_priv); } @@ -3445,6 +3472,9 @@ static int i915_ddb_info(struct seq_file *m, void *unused) if (INTEL_GEN(dev_priv) < 9) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + drm_modeset_lock_all(dev); ddb = &dev_priv->wm.skl_hw.ddb; @@ -3553,6 +3583,9 @@ static int i915_drrs_status(struct seq_file *m, void *unused) struct intel_crtc *intel_crtc; int active_crtc_cnt = 0; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + drm_modeset_lock_all(dev); for_each_intel_crtc(dev, intel_crtc) { if (intel_crtc->base.state->active) { @@ -3579,6 +3612,9 @@ static int i915_dp_mst_info(struct seq_file *m, void *unused) struct drm_connector *connector; struct drm_connector_list_iter conn_iter; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort) @@ -3697,6 +3733,11 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data) static int i915_displayport_test_active_open(struct inode *inode, struct file *file) { + struct drm_i915_private *dev_priv = inode->i_private; + + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + return single_open(file, i915_displayport_test_active_show, inode->i_private); } @@ -3718,6 +3759,9 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data) struct drm_connector_list_iter conn_iter; struct intel_dp *intel_dp; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { struct intel_encoder *encoder; @@ -3762,6 +3806,9 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data) struct drm_connector_list_iter conn_iter; struct intel_dp *intel_dp; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { struct intel_encoder *encoder; @@ -3878,6 +3925,9 @@ static int pri_wm_latency_open(struct inode *inode, struct file *file) if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + return single_open(file, pri_wm_latency_show, dev_priv); } @@ -3888,6 +3938,9 @@ static int spr_wm_latency_open(struct inode *inode, struct file *file) if (HAS_GMCH_DISPLAY(dev_priv)) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + return single_open(file, spr_wm_latency_show, dev_priv); } @@ -3898,6 +3951,9 @@ static int cur_wm_latency_open(struct inode *inode, struct file *file) if (HAS_GMCH_DISPLAY(dev_priv)) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + return single_open(file, cur_wm_latency_show, dev_priv); } @@ -4645,6 +4701,11 @@ static ssize_t i915_hpd_storm_ctl_write(struct file *file, static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) { + struct drm_i915_private *dev_priv = inode->i_private; + + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); } @@ -4668,6 +4729,9 @@ static int i915_drrs_ctl_set(void *data, u64 val) if (INTEL_GEN(dev_priv) < 7) return -ENODEV; + if (!INTEL_INFO(dev_priv)->num_pipes) + return -ENODEV; + drm_modeset_lock_all(dev); for_each_intel_crtc(dev, intel_crtc) { if (!intel_crtc->base.state->active ||
Without this checks in this debugfs, it would try access memory and resorces from display causing the driver to crash. Signed-off-by: José Roberto de Souza <jose.souza@intel.com> --- drivers/gpu/drm/i915/i915_debugfs.c | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)