Skip to content

Commit a175eca

Browse files
committed
Merge tag 'drm-fixes-2022-07-01' of git://anongit.freedesktop.org/drm/drm
Pull drm fixes from Dave Airlie: "Bit quieter this week, the main thing is it pulls in the fixes for the sysfb resource issue you were seeing. these had been queued for next so should have had some decent testing. Otherwise amdgpu, i915 and msm each have a few fixes, and vc4 has one. fbdev: - sysfb fixes/conflicting fb fixes amdgpu: - GPU recovery fix - Fix integer type usage in fourcc header for AMD modifiers - KFD TLB flush fix for gfx9 APUs - Display fix i915: - Fix ioctl argument error return - Fix d3cold disable to allow PCI upstream bridge D3 transition - Fix setting cache_dirty for dma-buf objects on discrete msm: - Fix to increment vsync_cnt before calling drm_crtc_handle_vblank so that userspace sees the value *after* it is incremented if waiting for vblank events - Fix to reset drm_dev to NULL in dp_display_unbind to avoid a crash in probe/bind error paths - Fix to resolve the smatch error of de-referencing before NULL check in dpu_encoder_phys_wb.c - Fix error return to userspace if fence-id allocation fails in submit ioctl vc4: - NULL ptr dereference fix" * tag 'drm-fixes-2022-07-01' of git://anongit.freedesktop.org/drm/drm: Revert "drm/amdgpu/display: set vblank_disable_immediate for DC" drm/amdgpu: To flush tlb for MMHUB of RAVEN series drm/fourcc: fix integer type usage in uapi header drm/amdgpu: fix adev variable used in amdgpu_device_gpu_recover() fbdev: Disable sysfb device registration when removing conflicting FBs firmware: sysfb: Add sysfb_disable() helper function firmware: sysfb: Make sysfb_create_simplefb() return a pdev pointer drm/msm/gem: Fix error return on fence id alloc fail drm/i915: tweak the ordering in cpu_write_needs_clflush drm/i915/dgfx: Disable d3cold at gfx root port drm/i915/gem: add missing else drm/vc4: perfmon: Fix variable dereferenced before check drm/msm/dpu: Fix variable dereferenced before check drm/msm/dp: reset drm_dev to NULL at dp_display_unbind() drm/msm/dpu: Increment vsync_cnt before waking up userspace
2 parents 5e83793 + b8f0009 commit a175eca

File tree

18 files changed

+136
-62
lines changed

18 files changed

+136
-62
lines changed

Documentation/driver-api/firmware/other_interfaces.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ EDD Interfaces
1313
.. kernel-doc:: drivers/firmware/edd.c
1414
:internal:
1515

16+
Generic System Framebuffers Interface
17+
-------------------------------------
18+
19+
.. kernel-doc:: drivers/firmware/sysfb.c
20+
:export:
21+
1622
Intel Stratix10 SoC Service Layer
1723
---------------------------------
1824
Some features of the Intel Stratix10 SoC require a level of privilege

drivers/firmware/sysfb.c

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,59 @@
3434
#include <linux/screen_info.h>
3535
#include <linux/sysfb.h>
3636

37+
static struct platform_device *pd;
38+
static DEFINE_MUTEX(disable_lock);
39+
static bool disabled;
40+
41+
static bool sysfb_unregister(void)
42+
{
43+
if (IS_ERR_OR_NULL(pd))
44+
return false;
45+
46+
platform_device_unregister(pd);
47+
pd = NULL;
48+
49+
return true;
50+
}
51+
52+
/**
53+
* sysfb_disable() - disable the Generic System Framebuffers support
54+
*
55+
* This disables the registration of system framebuffer devices that match the
56+
* generic drivers that make use of the system framebuffer set up by firmware.
57+
*
58+
* It also unregisters a device if this was already registered by sysfb_init().
59+
*
60+
* Context: The function can sleep. A @disable_lock mutex is acquired to serialize
61+
* against sysfb_init(), that registers a system framebuffer device.
62+
*/
63+
void sysfb_disable(void)
64+
{
65+
mutex_lock(&disable_lock);
66+
sysfb_unregister();
67+
disabled = true;
68+
mutex_unlock(&disable_lock);
69+
}
70+
EXPORT_SYMBOL_GPL(sysfb_disable);
71+
3772
static __init int sysfb_init(void)
3873
{
3974
struct screen_info *si = &screen_info;
4075
struct simplefb_platform_data mode;
41-
struct platform_device *pd;
4276
const char *name;
4377
bool compatible;
44-
int ret;
78+
int ret = 0;
79+
80+
mutex_lock(&disable_lock);
81+
if (disabled)
82+
goto unlock_mutex;
4583

4684
/* try to create a simple-framebuffer device */
4785
compatible = sysfb_parse_mode(si, &mode);
4886
if (compatible) {
49-
ret = sysfb_create_simplefb(si, &mode);
50-
if (!ret)
51-
return 0;
87+
pd = sysfb_create_simplefb(si, &mode);
88+
if (!IS_ERR(pd))
89+
goto unlock_mutex;
5290
}
5391

5492
/* if the FB is incompatible, create a legacy framebuffer device */
@@ -60,8 +98,10 @@ static __init int sysfb_init(void)
6098
name = "platform-framebuffer";
6199

62100
pd = platform_device_alloc(name, 0);
63-
if (!pd)
64-
return -ENOMEM;
101+
if (!pd) {
102+
ret = -ENOMEM;
103+
goto unlock_mutex;
104+
}
65105

66106
sysfb_apply_efi_quirks(pd);
67107

@@ -73,9 +113,11 @@ static __init int sysfb_init(void)
73113
if (ret)
74114
goto err;
75115

76-
return 0;
116+
goto unlock_mutex;
77117
err:
78118
platform_device_put(pd);
119+
unlock_mutex:
120+
mutex_unlock(&disable_lock);
79121
return ret;
80122
}
81123

drivers/firmware/sysfb_simplefb.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ __init bool sysfb_parse_mode(const struct screen_info *si,
5757
return false;
5858
}
5959

60-
__init int sysfb_create_simplefb(const struct screen_info *si,
61-
const struct simplefb_platform_data *mode)
60+
__init struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
61+
const struct simplefb_platform_data *mode)
6262
{
6363
struct platform_device *pd;
6464
struct resource res;
@@ -76,7 +76,7 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
7676
base |= (u64)si->ext_lfb_base << 32;
7777
if (!base || (u64)(resource_size_t)base != base) {
7878
printk(KERN_DEBUG "sysfb: inaccessible VRAM base\n");
79-
return -EINVAL;
79+
return ERR_PTR(-EINVAL);
8080
}
8181

8282
/*
@@ -93,7 +93,7 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
9393
length = mode->height * mode->stride;
9494
if (length > size) {
9595
printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n");
96-
return -EINVAL;
96+
return ERR_PTR(-EINVAL);
9797
}
9898
length = PAGE_ALIGN(length);
9999

@@ -104,11 +104,11 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
104104
res.start = base;
105105
res.end = res.start + length - 1;
106106
if (res.end <= res.start)
107-
return -EINVAL;
107+
return ERR_PTR(-EINVAL);
108108

109109
pd = platform_device_alloc("simple-framebuffer", 0);
110110
if (!pd)
111-
return -ENOMEM;
111+
return ERR_PTR(-ENOMEM);
112112

113113
sysfb_apply_efi_quirks(pd);
114114

@@ -124,10 +124,10 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
124124
if (ret)
125125
goto err_put_device;
126126

127-
return 0;
127+
return pd;
128128

129129
err_put_device:
130130
platform_device_put(pd);
131131

132-
return ret;
132+
return ERR_PTR(ret);
133133
}

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,8 @@ int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
714714
{
715715
bool all_hub = false;
716716

717-
if (adev->family == AMDGPU_FAMILY_AI)
717+
if (adev->family == AMDGPU_FAMILY_AI ||
718+
adev->family == AMDGPU_FAMILY_RV)
718719
all_hub = true;
719720

720721
return amdgpu_gmc_flush_gpu_tlb_pasid(adev, pasid, flush_type, all_hub);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5164,7 +5164,7 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,
51645164
*/
51655165
amdgpu_unregister_gpu_instance(tmp_adev);
51665166

5167-
drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true);
5167+
drm_fb_helper_set_suspend_unlocked(adev_to_drm(tmp_adev)->fb_helper, true);
51685168

51695169
/* disable ras on ALL IPs */
51705170
if (!need_emergency_restart &&

drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
320320
if (!amdgpu_device_has_dc_support(adev)) {
321321
if (!adev->enable_virtual_display)
322322
/* Disable vblank IRQs aggressively for power-saving */
323+
/* XXX: can this be enabled for DC? */
323324
adev_to_drm(adev)->vblank_disable_immediate = true;
324325

325326
r = drm_vblank_init(adev_to_drm(adev), adev->mode_info.num_crtc);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4259,9 +4259,6 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
42594259
}
42604260
}
42614261

4262-
/* Disable vblank IRQs aggressively for power-saving. */
4263-
adev_to_drm(adev)->vblank_disable_immediate = true;
4264-
42654262
/* loops over all connectors on the board */
42664263
for (i = 0; i < link_cnt; i++) {
42674264
struct dc_link *link = NULL;

drivers/gpu/drm/i915/gem/i915_gem_context.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,9 @@ static int set_proto_ctx_param(struct drm_i915_file_private *fpriv,
933933
case I915_CONTEXT_PARAM_PERSISTENCE:
934934
if (args->size)
935935
ret = -EINVAL;
936-
ret = proto_context_set_persistence(fpriv->dev_priv, pc,
937-
args->value);
936+
else
937+
ret = proto_context_set_persistence(fpriv->dev_priv, pc,
938+
args->value);
938939
break;
939940

940941
case I915_CONTEXT_PARAM_PROTECTED_CONTENT:

drivers/gpu/drm/i915/gem/i915_gem_domain.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ bool i915_gem_cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
3535
if (obj->cache_dirty)
3636
return false;
3737

38-
if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
39-
return true;
40-
4138
if (IS_DGFX(i915))
4239
return false;
4340

41+
if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
42+
return true;
43+
4444
/* Currently in use by HW (display engine)? Keep flushed. */
4545
return i915_gem_object_is_framebuffer(obj);
4646
}

drivers/gpu/drm/i915/i915_driver.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ static int i915_set_dma_info(struct drm_i915_private *i915)
530530
static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
531531
{
532532
struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
533+
struct pci_dev *root_pdev;
533534
int ret;
534535

535536
if (i915_inject_probe_failure(dev_priv))
@@ -641,6 +642,15 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
641642

642643
intel_bw_init_hw(dev_priv);
643644

645+
/*
646+
* FIXME: Temporary hammer to avoid freezing the machine on our DGFX
647+
* This should be totally removed when we handle the pci states properly
648+
* on runtime PM and on s2idle cases.
649+
*/
650+
root_pdev = pcie_find_root_port(pdev);
651+
if (root_pdev)
652+
pci_d3cold_disable(root_pdev);
653+
644654
return 0;
645655

646656
err_msi:
@@ -664,11 +674,16 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
664674
static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
665675
{
666676
struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
677+
struct pci_dev *root_pdev;
667678

668679
i915_perf_fini(dev_priv);
669680

670681
if (pdev->msi_enabled)
671682
pci_disable_msi(pdev);
683+
684+
root_pdev = pcie_find_root_port(pdev);
685+
if (root_pdev)
686+
pci_d3cold_enable(root_pdev);
672687
}
673688

674689
/**
@@ -1193,14 +1208,6 @@ static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation)
11931208
goto out;
11941209
}
11951210

1196-
/*
1197-
* FIXME: Temporary hammer to avoid freezing the machine on our DGFX
1198-
* This should be totally removed when we handle the pci states properly
1199-
* on runtime PM and on s2idle cases.
1200-
*/
1201-
if (suspend_to_idle(dev_priv))
1202-
pci_d3cold_disable(pdev);
1203-
12041211
pci_disable_device(pdev);
12051212
/*
12061213
* During hibernation on some platforms the BIOS may try to access
@@ -1365,8 +1372,6 @@ static int i915_drm_resume_early(struct drm_device *dev)
13651372

13661373
pci_set_master(pdev);
13671374

1368-
pci_d3cold_enable(pdev);
1369-
13701375
disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
13711376

13721377
ret = vlv_resume_prepare(dev_priv, false);
@@ -1543,7 +1548,6 @@ static int intel_runtime_suspend(struct device *kdev)
15431548
{
15441549
struct drm_i915_private *dev_priv = kdev_to_i915(kdev);
15451550
struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
1546-
struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
15471551
int ret;
15481552

15491553
if (drm_WARN_ON_ONCE(&dev_priv->drm, !HAS_RUNTIME_PM(dev_priv)))
@@ -1589,12 +1593,6 @@ static int intel_runtime_suspend(struct device *kdev)
15891593
drm_err(&dev_priv->drm,
15901594
"Unclaimed access detected prior to suspending\n");
15911595

1592-
/*
1593-
* FIXME: Temporary hammer to avoid freezing the machine on our DGFX
1594-
* This should be totally removed when we handle the pci states properly
1595-
* on runtime PM and on s2idle cases.
1596-
*/
1597-
pci_d3cold_disable(pdev);
15981596
rpm->suspended = true;
15991597

16001598
/*
@@ -1633,7 +1631,6 @@ static int intel_runtime_resume(struct device *kdev)
16331631
{
16341632
struct drm_i915_private *dev_priv = kdev_to_i915(kdev);
16351633
struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
1636-
struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
16371634
int ret;
16381635

16391636
if (drm_WARN_ON_ONCE(&dev_priv->drm, !HAS_RUNTIME_PM(dev_priv)))
@@ -1646,7 +1643,6 @@ static int intel_runtime_resume(struct device *kdev)
16461643

16471644
intel_opregion_notify_adapter(dev_priv, PCI_D0);
16481645
rpm->suspended = false;
1649-
pci_d3cold_enable(pdev);
16501646
if (intel_uncore_unclaimed_mmio(&dev_priv->uncore))
16511647
drm_dbg(&dev_priv->drm,
16521648
"Unclaimed access during suspend, bios?\n");

0 commit comments

Comments
 (0)