dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: use dirty framebuffer helper
@ 2022-09-06 19:57 Hamza Mahfooz
  2022-09-08 13:14 ` Alex Deucher
  2022-09-19  6:44 ` Thomas Zimmermann
  0 siblings, 2 replies; 8+ messages in thread
From: Hamza Mahfooz @ 2022-09-06 19:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Guchun Chen, David Airlie, dri-devel, Pan, Xinhui, amd-gfx,
	Aurabindo Pillai, Sean Paul, Hamza Mahfooz, Alex Deucher,
	Christian König, Fernando Ramos

Currently, we aren't handling DRM_IOCTL_MODE_DIRTYFB. So, use
drm_atomic_helper_dirtyfb() as the dirty callback in the amdgpu_fb_funcs
struct.

Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index c20922a5af9f..5b09c8f4fe95 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -38,6 +38,7 @@
 #include <linux/pci.h>
 #include <linux/pm_runtime.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_damage_helper.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_fb_helper.h>
@@ -496,6 +497,7 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
 static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
 	.destroy = drm_gem_fb_destroy,
 	.create_handle = drm_gem_fb_create_handle,
+	.dirty = drm_atomic_helper_dirtyfb,
 };
 
 uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdgpu: use dirty framebuffer helper
  2022-09-06 19:57 [PATCH] drm/amdgpu: use dirty framebuffer helper Hamza Mahfooz
@ 2022-09-08 13:14 ` Alex Deucher
  2022-09-18 12:09   ` root
  2022-09-19  6:44 ` Thomas Zimmermann
  1 sibling, 1 reply; 8+ messages in thread
From: Alex Deucher @ 2022-09-08 13:14 UTC (permalink / raw)
  To: Hamza Mahfooz
  Cc: Guchun Chen, David Airlie, Pan, Xinhui, linux-kernel, dri-devel,
	Aurabindo Pillai, Sean Paul, amd-gfx, Alex Deucher,
	Christian König, Fernando Ramos

On Tue, Sep 6, 2022 at 3:58 PM Hamza Mahfooz <hamza.mahfooz@amd.com> wrote:
>
> Currently, we aren't handling DRM_IOCTL_MODE_DIRTYFB. So, use
> drm_atomic_helper_dirtyfb() as the dirty callback in the amdgpu_fb_funcs
> struct.
>
> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index c20922a5af9f..5b09c8f4fe95 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -38,6 +38,7 @@
>  #include <linux/pci.h>
>  #include <linux/pm_runtime.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_damage_helper.h>
>  #include <drm/drm_edid.h>
>  #include <drm/drm_gem_framebuffer_helper.h>
>  #include <drm/drm_fb_helper.h>
> @@ -496,6 +497,7 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
>  static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>         .destroy = drm_gem_fb_destroy,
>         .create_handle = drm_gem_fb_create_handle,
> +       .dirty = drm_atomic_helper_dirtyfb,
>  };
>
>  uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
> --
> 2.37.2
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdgpu: use dirty framebuffer helper
  2022-09-08 13:14 ` Alex Deucher
@ 2022-09-18 12:09   ` root
  2022-09-19  2:53     ` Arthur Marsh
  2022-09-19 16:33     ` [PATCH] " Alex Deucher
  0 siblings, 2 replies; 8+ messages in thread
From: root @ 2022-09-18 12:09 UTC (permalink / raw)
  To: alexdeucher
  Cc: guchun.chen, airlied, Xinhui.Pan, linux-kernel, amd-gfx,
	aurabindo.pillai, seanpaul, dri-devel, alexander.deucher,
	christian.koenig, greenfoo, hamza.mahfooz

Hi, I recently experienced lock-ups that only responded to magic sysreq 
reboots when the amdgpu module was loading on my pc (Athlon II X4 640 CPU,
with Radeon R7 250 - Cape Verde).

.config has:

CONFIG_DRM_AMDGPU=m
CONFIG_DRM_AMDGPU_SI=y
# CONFIG_DRM_AMDGPU_CIK is not set
# CONFIG_DRM_AMDGPU_USERPTR is not set

kernel command line has:

amdgpu.audio=1 amdgpu.si_support=1 radeon.si_support=0 page_owner=on \
amdgpu.gpu_recovery=1

Bisecting lead to:

commit 66f99628eb24409cb8feb5061f78283c8b65f820
Author: Hamza Mahfooz <hamza.mahfooz@amd.com>
Date:   Tue Sep 6 15:01:49 2022 -0400

    drm/amdgpu: use dirty framebuffer helper
    
    Currently, we aren't handling DRM_IOCTL_MODE_DIRTYFB. So, use
    drm_atomic_helper_dirtyfb() as the dirty callback in the amdgpu_fb_funcs
    struct.
    
    Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index c20922a5af9f..5b09c8f4fe95 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -38,6 +38,7 @@
 #include <linux/pci.h>
 #include <linux/pm_runtime.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_damage_helper.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_fb_helper.h>
@@ -496,6 +497,7 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
 static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
        .destroy = drm_gem_fb_destroy,
        .create_handle = drm_gem_fb_create_handle,
+       .dirty = drm_atomic_helper_dirtyfb,
 };
 
 uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,

After doing a git bisect reset, git pull and reverting the patch above, I
rebuilt the kernel and am successfully running with the amdgpu module loaded
and using the Radeon R7 250 GPU.

I am happy to supply any further configuration details.

Arthur Marsh.

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: drm/amdgpu: use dirty framebuffer helper
  2022-09-18 12:09   ` root
@ 2022-09-19  2:53     ` Arthur Marsh
  2022-09-19 16:33     ` [PATCH] " Alex Deucher
  1 sibling, 0 replies; 8+ messages in thread
From: Arthur Marsh @ 2022-09-19  2:53 UTC (permalink / raw)
  To: arthur.marsh
  Cc: guchun.chen, airlied, Xinhui.Pan, linux-kernel, amd-gfx,
	aurabindo.pillai, seanpaul, dri-devel, alexander.deucher,
	christian.koenig, greenfoo, hamza.mahfooz

I have done a delayed load of amdgpu with the 6.0-rc6 kernel using:

modprobe amdgpu si_support=1

and saved the dmesg output:

[  455.424263] udevd[414]: specified group 'sgx' unknown
[  455.514818] ACPI: bus type drm_connector registered
[  457.759316] [drm] amdgpu kernel modesetting enabled.
[  457.759491] amdgpu 0000:01:00.0: vgaarb: deactivate vga console
[  457.760459] Console: switching to colour dummy device 80x25
[  457.760689] [drm] initializing kernel modesetting (VERDE 0x1002:0x682B 0x1458:0x22CA 0x87).
[  457.760717] [drm] register mmio base: 0xFE8C0000
[  457.760720] [drm] register mmio size: 262144
[  457.760872] [drm] add ip block number 0 <si_common>
[  457.760887] [drm] add ip block number 1 <gmc_v6_0>
[  457.760890] [drm] add ip block number 2 <si_ih>
[  457.760893] [drm] add ip block number 3 <gfx_v6_0>
[  457.760896] [drm] add ip block number 4 <si_dma>
[  457.760898] [drm] add ip block number 5 <si_dpm>
[  457.760901] [drm] add ip block number 6 <dce_v6_0>
[  457.760903] [drm] add ip block number 7 <uvd_v3_1>
[  457.804366] [drm] BIOS signature incorrect 20 7
[  457.804376] resource sanity check: requesting [mem 0x000c0000-0x000dffff], which spans more than PCI Bus 0000:00 [mem 0x000d0000-0x000dffff window]
[  457.804383] caller pci_map_rom+0x68/0x1b0 mapping multiple BARs
[  457.804398] amdgpu 0000:01:00.0: No more image in the PCI ROM
[  457.805746] amdgpu 0000:01:00.0: amdgpu: Fetched VBIOS from ROM BAR
[  457.805752] amdgpu: ATOM BIOS: xxx-xxx-xxx
[  457.805775] amdgpu 0000:01:00.0: amdgpu: Trusted Memory Zone (TMZ) feature not supported
[  457.805781] amdgpu 0000:01:00.0: amdgpu: PCIE atomic ops is not supported
[  457.806204] [drm] PCIE gen 2 link speeds already enabled
[  457.806632] [drm] vm size is 64 GB, 2 levels, block size is 10-bit, fragment size is 9-bit
[  457.869590] amdgpu 0000:01:00.0: amdgpu: VRAM: 2048M 0x000000F400000000 - 0x000000F47FFFFFFF (2048M used)
[  457.869605] amdgpu 0000:01:00.0: amdgpu: GART: 1024M 0x000000FF00000000 - 0x000000FF3FFFFFFF
[  457.869622] [drm] Detected VRAM RAM=2048M, BAR=256M
[  457.869625] [drm] RAM width 128bits DDR3
[  457.869706] [drm] amdgpu: 2048M of VRAM memory ready
[  457.869710] [drm] amdgpu: 3979M of GTT memory ready.
[  457.869734] [drm] GART: num cpu pages 262144, num gpu pages 262144
[  457.870061] amdgpu 0000:01:00.0: amdgpu: PCIE GART of 1024M enabled (table at 0x000000F400A00000).
[  457.908024] [drm] Internal thermal controller with fan control
[  457.908045] [drm] amdgpu: dpm initialized
[  457.908126] [drm] AMDGPU Display Connectors
[  457.908128] [drm] Connector 0:
[  457.908131] [drm]   HDMI-A-1
[  457.908133] [drm]   HPD1
[  457.908135] [drm]   DDC: 0x194c 0x194c 0x194d 0x194d 0x194e 0x194e 0x194f 0x194f
[  457.908139] [drm]   Encoders:
[  457.908141] [drm]     DFP1: INTERNAL_UNIPHY
[  457.908144] [drm] Connector 1:
[  457.908145] [drm]   DVI-D-1
[  457.908147] [drm]   HPD2
[  457.908149] [drm]   DDC: 0x1950 0x1950 0x1951 0x1951 0x1952 0x1952 0x1953 0x1953
[  457.908153] [drm]   Encoders:
[  457.908155] [drm]     DFP2: INTERNAL_UNIPHY
[  457.908157] [drm] Connector 2:
[  457.908159] [drm]   VGA-1
[  457.908160] [drm]   DDC: 0x1970 0x1970 0x1971 0x1971 0x1972 0x1972 0x1973 0x1973
[  457.908164] [drm]   Encoders:
[  457.908166] [drm]     CRT1: INTERNAL_KLDSCP_DAC1
[  457.959506] [drm] Found UVD firmware Version: 64.0 Family ID: 13
[  458.497761] [drm] UVD initialized successfully.
[  458.498549] amdgpu 0000:01:00.0: amdgpu: SE 1, SH per SE 2, CU per SH 5, active_cu_number 8
[  458.836681] [drm] Initialized amdgpu 3.48.0 20150101 for 0000:01:00.0 on minor 0
[  458.909127] fbcon: amdgpudrmfb (fb0) is primary device
[  458.936086] Console: switching to colour frame buffer device 240x67
[  458.936126] BUG: kernel NULL pointer dereference, address: 0000000000000010
[  458.936128] #PF: supervisor read access in kernel mode
[  458.936130] #PF: error_code(0x0000) - not-present page
[  458.936132] PGD 0 P4D 0 
[  458.936134] Oops: 0000 [#1] PREEMPT SMP NOPTI
[  458.936137] CPU: 3 PID: 81 Comm: kworker/3:1 Not tainted 6.0.0-rc6 #5144
[  458.936140] Hardware name: System manufacturer System Product Name/M3A78 PRO, BIOS 1701    01/27/2011
[  458.936141] Workqueue: events drm_fb_helper_damage_work [drm_kms_helper]
[  458.936162] RIP: 0010:drm_atomic_helper_dirtyfb+0x13c/0x240 [drm_kms_helper]
[  458.936176] Code: 05 c0 02 00 00 4c 8d 7a f8 48 39 c2 74 58 49 8b 74 24 48 4d 8d 77 20 4c 89 f7 e8 0f b5 f5 ff 85 c0 75 4b 49 8b 87 58 02 00 00 <48> 39 68 10 75 bf 4c 89 fe 4c 89 e7 e8 23 bf f5 ff 48 3d 00 f0 ff
[  458.936178] RSP: 0018:ffffb75080db3da8 EFLAGS: 00010246
[  458.936180] RAX: 0000000000000000 RBX: ffff9dbae32e2880 RCX: 000000000000003b
[  458.936181] RDX: ffffb75080db3dd8 RSI: ffffb75080db3dd8 RDI: ffff9dbad6329c48
[  458.936182] RBP: ffff9dbae9b41100 R08: ffffb75080db3dd8 R09: ffff9dbae33e01f8
[  458.936184] R10: ffff9dbadf388028 R11: 0000000000000001 R12: ffff9dbad150e880
[  458.936185] R13: ffff9dbaee0d9980 R14: ffff9dbad6329c20 R15: ffff9dbad6329c00
[  458.936186] FS:  0000000000000000(0000) GS:ffff9dbbe7cc0000(0000) knlGS:0000000000000000
[  458.936188] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  458.936189] CR2: 0000000000000010 CR3: 000000012337c000 CR4: 00000000000006e0
[  458.936190] Call Trace:
[  458.936192]  <TASK>
[  458.936194]  drm_fb_helper_damage_work+0x1a4/0x2d0 [drm_kms_helper]
[  458.936208]  process_one_work+0x1ae/0x370
[  458.936213]  worker_thread+0x4d/0x3b0
[  458.936215]  ? _raw_spin_lock_irqsave+0x22/0x60
[  458.936219]  ? process_one_work+0x370/0x370
[  458.936221]  kthread+0xe3/0x110
[  458.936224]  ? kthread_complete_and_exit+0x20/0x20
[  458.936226]  ret_from_fork+0x22/0x30
[  458.936229]  </TASK>
[  458.936230] Modules linked in: amdgpu(+) gpu_sched drm_buddy drm_ttm_helper ttm drm_display_helper drm_kms_helper drm i2c_algo_bit fb_sys_fops syscopyarea sysfillrect sysimgblt bnep bluetooth jitterentropy_rng sha512_ssse3 sha512_generic hmac drbg ansi_cprng ecdh_generic ecc nfc rfkill snd_hrtimer cpufreq_userspace cpufreq_conservative cpufreq_powersave xt_dscp xt_tcpudp nft_compat x_tables binfmt_misc scsi_transport_iscsi nf_tables nfnetlink exfat max6650 hwmon_vid parport_pc ppdev lp parport edac_mce_amd snd_emu10k1_synth kvm_amd ccp snd_emux_synth rng_core snd_seq_midi_emul snd_seq_virmidi snd_seq_midi snd_seq_midi_event snd_seq kvm wmi_bmof snd_hda_codec_hdmi snd_emu10k1 irqbypass snd_hda_intel snd_intel_dspcfg snd_util_mem snd_hda_codec snd_ac97_codec snd_hda_core ac97_bus snd_hwdep snd_rawmidi snd_seq_device snd_pcm_oss snd_mixer_oss snd_pcm k10temp evdev pcspkr serio_raw emu10k1_gp gameport snd_timer snd wmi button asus_atk0110 acpi_cpufreq sp5100_tco soundcore ext4 crc16 mbcache
[  458.936286]  jbd2 btrfs blake2b_generic xor raid6_pq zstd_compress libcrc32c crc32c_generic uas usb_storage sg hid_generic sd_mod t10_pi usbhid hid sr_mod crc64_rocksoft crc64 cdrom ata_generic ohci_pci ahci pata_atiixp libahci r8169 libata firewire_ohci xhci_pci firewire_core crc_itu_t realtek ohci_hcd ehci_pci mdio_devres xhci_hcd ehci_hcd i2c_piix4 scsi_mod libphy scsi_common usbcore usb_common
[  458.936314] CR2: 0000000000000010
[  458.936315] ---[ end trace 0000000000000000 ]---
[  458.936317] RIP: 0010:drm_atomic_helper_dirtyfb+0x13c/0x240 [drm_kms_helper]
[  458.936330] Code: 05 c0 02 00 00 4c 8d 7a f8 48 39 c2 74 58 49 8b 74 24 48 4d 8d 77 20 4c 89 f7 e8 0f b5 f5 ff 85 c0 75 4b 49 8b 87 58 02 00 00 <48> 39 68 10 75 bf 4c 89 fe 4c 89 e7 e8 23 bf f5 ff 48 3d 00 f0 ff
[  458.936332] RSP: 0018:ffffb75080db3da8 EFLAGS: 00010246
[  458.936333] RAX: 0000000000000000 RBX: ffff9dbae32e2880 RCX: 000000000000003b
[  458.936335] RDX: ffffb75080db3dd8 RSI: ffffb75080db3dd8 RDI: ffff9dbad6329c48
[  458.936336] RBP: ffff9dbae9b41100 R08: ffffb75080db3dd8 R09: ffff9dbae33e01f8
[  458.936337] R10: ffff9dbadf388028 R11: 0000000000000001 R12: ffff9dbad150e880
[  458.936338] R13: ffff9dbaee0d9980 R14: ffff9dbad6329c20 R15: ffff9dbad6329c00
[  458.936339] FS:  0000000000000000(0000) GS:ffff9dbbe7cc0000(0000) knlGS:0000000000000000
[  458.936341] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  458.936342] CR2: 0000000000000010 CR3: 000000012337c000 CR4: 00000000000006e0
[  458.957983] amdgpu 0000:01:00.0: [drm] fb0: amdgpudrmfb frame buffer device

Regards,

Arthur Marsh.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdgpu: use dirty framebuffer helper
  2022-09-06 19:57 [PATCH] drm/amdgpu: use dirty framebuffer helper Hamza Mahfooz
  2022-09-08 13:14 ` Alex Deucher
@ 2022-09-19  6:44 ` Thomas Zimmermann
  2022-09-19 16:26   ` Alex Deucher
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Zimmermann @ 2022-09-19  6:44 UTC (permalink / raw)
  To: Hamza Mahfooz, linux-kernel
  Cc: Guchun Chen, David Airlie, Pan, Xinhui, amd-gfx,
	Aurabindo Pillai, Sean Paul, dri-devel, Alex Deucher,
	Christian König, Fernando Ramos


[-- Attachment #1.1: Type: text/plain, Size: 1800 bytes --]

Hi

Am 06.09.22 um 21:57 schrieb Hamza Mahfooz:
> Currently, we aren't handling DRM_IOCTL_MODE_DIRTYFB. So, use
> drm_atomic_helper_dirtyfb() as the dirty callback in the amdgpu_fb_funcs
> struct.

drm_atomic_helper_dirtyfb() creates a new atomic commit for the 
frambuffer's planes. Drivers can then updates these planes' output 
(e.g., writeback to video memory). I thought that amdgpu simply scans 
out from the framebuffer's memory regions in VRAM. So I'm curious why 
this patch is necessary.

Best regards
Thomas

> 
> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index c20922a5af9f..5b09c8f4fe95 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -38,6 +38,7 @@
>   #include <linux/pci.h>
>   #include <linux/pm_runtime.h>
>   #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_damage_helper.h>
>   #include <drm/drm_edid.h>
>   #include <drm/drm_gem_framebuffer_helper.h>
>   #include <drm/drm_fb_helper.h>
> @@ -496,6 +497,7 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
>   static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>   	.destroy = drm_gem_fb_destroy,
>   	.create_handle = drm_gem_fb_create_handle,
> +	.dirty = drm_atomic_helper_dirtyfb,
>   };
>   
>   uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdgpu: use dirty framebuffer helper
  2022-09-19  6:44 ` Thomas Zimmermann
@ 2022-09-19 16:26   ` Alex Deucher
  0 siblings, 0 replies; 8+ messages in thread
From: Alex Deucher @ 2022-09-19 16:26 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Guchun Chen, David Airlie, dri-devel, Pan, Xinhui, linux-kernel,
	amd-gfx, Aurabindo Pillai, Sean Paul, Hamza Mahfooz,
	Alex Deucher, Christian König, Fernando Ramos

On Mon, Sep 19, 2022 at 2:44 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 06.09.22 um 21:57 schrieb Hamza Mahfooz:
> > Currently, we aren't handling DRM_IOCTL_MODE_DIRTYFB. So, use
> > drm_atomic_helper_dirtyfb() as the dirty callback in the amdgpu_fb_funcs
> > struct.
>
> drm_atomic_helper_dirtyfb() creates a new atomic commit for the
> frambuffer's planes. Drivers can then updates these planes' output
> (e.g., writeback to video memory). I thought that amdgpu simply scans
> out from the framebuffer's memory regions in VRAM. So I'm curious why
> this patch is necessary.

I think in this particular case, the problem is that there are still
some asic which default to non-atomic code which is what is causing
the problem here.  Something like this would fix that:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 5b09c8f4fe95..f5e9dd454c54 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -497,6 +497,11 @@ bool amdgpu_display_ddc_probe(struct
amdgpu_connector *amdgpu_connector,
 static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
        .destroy = drm_gem_fb_destroy,
        .create_handle = drm_gem_fb_create_handle,
+};
+
+static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
+       .destroy = drm_gem_fb_destroy,
+       .create_handle = drm_gem_fb_create_handle,
        .dirty = drm_atomic_helper_dirtyfb,
 };

@@ -1102,7 +1107,10 @@ static int
amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
        if (ret)
                goto err;

-       ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
+       if (drm_drv_uses_atomic_modeset(adev_to_drm(adev)))
+               ret = drm_framebuffer_init(dev, &rfb->base,
&amdgpu_fb_funcs_atomic);
+       else
+               ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
        if (ret)
                goto err;

As for why we need the dirty callback, I think it's used for PSR.

Alex

>
> Best regards
> Thomas
>
> >
> > Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> > index c20922a5af9f..5b09c8f4fe95 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> > @@ -38,6 +38,7 @@
> >   #include <linux/pci.h>
> >   #include <linux/pm_runtime.h>
> >   #include <drm/drm_crtc_helper.h>
> > +#include <drm/drm_damage_helper.h>
> >   #include <drm/drm_edid.h>
> >   #include <drm/drm_gem_framebuffer_helper.h>
> >   #include <drm/drm_fb_helper.h>
> > @@ -496,6 +497,7 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
> >   static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
> >       .destroy = drm_gem_fb_destroy,
> >       .create_handle = drm_gem_fb_create_handle,
> > +     .dirty = drm_atomic_helper_dirtyfb,
> >   };
> >
> >   uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Ivo Totev

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdgpu: use dirty framebuffer helper
  2022-09-18 12:09   ` root
  2022-09-19  2:53     ` Arthur Marsh
@ 2022-09-19 16:33     ` Alex Deucher
  2022-09-20  3:14       ` Arthur Marsh
  1 sibling, 1 reply; 8+ messages in thread
From: Alex Deucher @ 2022-09-19 16:33 UTC (permalink / raw)
  To: root
  Cc: guchun.chen, airlied, Xinhui.Pan, linux-kernel, amd-gfx,
	aurabindo.pillai, seanpaul, dri-devel, alexander.deucher,
	christian.koenig, greenfoo, hamza.mahfooz

[-- Attachment #1: Type: text/plain, Size: 2298 bytes --]

On Sun, Sep 18, 2022 at 8:09 AM root <arthur.marsh@internode.on.net> wrote:
>
> Hi, I recently experienced lock-ups that only responded to magic sysreq
> reboots when the amdgpu module was loading on my pc (Athlon II X4 640 CPU,
> with Radeon R7 250 - Cape Verde).
>
> .config has:
>
> CONFIG_DRM_AMDGPU=m
> CONFIG_DRM_AMDGPU_SI=y
> # CONFIG_DRM_AMDGPU_CIK is not set
> # CONFIG_DRM_AMDGPU_USERPTR is not set
>
> kernel command line has:
>
> amdgpu.audio=1 amdgpu.si_support=1 radeon.si_support=0 page_owner=on \
> amdgpu.gpu_recovery=1
>
> Bisecting lead to:
>
> commit 66f99628eb24409cb8feb5061f78283c8b65f820
> Author: Hamza Mahfooz <hamza.mahfooz@amd.com>
> Date:   Tue Sep 6 15:01:49 2022 -0400
>
>     drm/amdgpu: use dirty framebuffer helper
>
>     Currently, we aren't handling DRM_IOCTL_MODE_DIRTYFB. So, use
>     drm_atomic_helper_dirtyfb() as the dirty callback in the amdgpu_fb_funcs
>     struct.
>
>     Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
>     Acked-by: Alex Deucher <alexander.deucher@amd.com>
>     Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index c20922a5af9f..5b09c8f4fe95 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -38,6 +38,7 @@
>  #include <linux/pci.h>
>  #include <linux/pm_runtime.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_damage_helper.h>
>  #include <drm/drm_edid.h>
>  #include <drm/drm_gem_framebuffer_helper.h>
>  #include <drm/drm_fb_helper.h>
> @@ -496,6 +497,7 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
>  static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>         .destroy = drm_gem_fb_destroy,
>         .create_handle = drm_gem_fb_create_handle,
> +       .dirty = drm_atomic_helper_dirtyfb,
>  };
>
>  uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
>
> After doing a git bisect reset, git pull and reverting the patch above, I
> rebuilt the kernel and am successfully running with the amdgpu module loaded
> and using the Radeon R7 250 GPU.
>
> I am happy to supply any further configuration details.

Does the attached patch help?

Alex


>
> Arthur Marsh.

[-- Attachment #2: 0001-drm-amdgpu-don-t-register-a-dirty-callback-for-non-a.patch --]
[-- Type: text/x-patch, Size: 1915 bytes --]

From 5e49c68c1ac1fbb98b1c84407485abfb7d309783 Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexander.deucher@amd.com>
Date: Mon, 19 Sep 2022 12:26:20 -0400
Subject: [PATCH] drm/amdgpu: don't register a dirty callback for non-atomic

Some asics still support non-atomic code paths.

Fixes: 66f99628eb2440 ("drm/amdgpu: use dirty framebuffer helper")
Reported-by: Arthur Marsh <arthur.marsh@internode.on.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 5b09c8f4fe95..23998f727c7f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -39,6 +39,7 @@
 #include <linux/pm_runtime.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_damage_helper.h>
+#include <drm/drm_drv.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_fb_helper.h>
@@ -497,6 +498,11 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
 static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
 	.destroy = drm_gem_fb_destroy,
 	.create_handle = drm_gem_fb_create_handle,
+};
+
+static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
+	.destroy = drm_gem_fb_destroy,
+	.create_handle = drm_gem_fb_create_handle,
 	.dirty = drm_atomic_helper_dirtyfb,
 };
 
@@ -1102,7 +1108,10 @@ static int amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
 	if (ret)
 		goto err;
 
-	ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
+	if (drm_drv_uses_atomic_modeset(dev))
+		ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs_atomic);
+	else
+		ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
 	if (ret)
 		goto err;
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/amdgpu: use dirty framebuffer helper
  2022-09-19 16:33     ` [PATCH] " Alex Deucher
@ 2022-09-20  3:14       ` Arthur Marsh
  0 siblings, 0 replies; 8+ messages in thread
From: Arthur Marsh @ 2022-09-20  3:14 UTC (permalink / raw)
  To: Alex Deucher
  Cc: guchun.chen, airlied, Xinhui.Pan, linux-kernel, amd-gfx,
	aurabindo.pillai, seanpaul, dri-devel, alexander.deucher,
	christian.koenig, greenfoo, hamza.mahfooz

Thanks, the patch applied against 6.0-rc6 kernel worked and the amdgpu module loaded and works on my Radeon R7 250 (Cape Verde) GPU.

Arthur Marsh. 

On 20 September 2022 2:03:54 am ACST, Alex Deucher <alexdeucher@gmail.com> wrote:
>On Sun, Sep 18, 2022 at 8:09 AM root <arthur.marsh@internode.on.net> wrote:
>>
>> Hi, I recently experienced lock-ups that only responded to magic sysreq
>> reboots when the amdgpu module was loading on my pc (Athlon II X4 640 CPU,
>> with Radeon R7 250 - Cape Verde).
>>
>> .config has:
>>
>> CONFIG_DRM_AMDGPU=m
>> CONFIG_DRM_AMDGPU_SI=y
>> # CONFIG_DRM_AMDGPU_CIK is not set
>> # CONFIG_DRM_AMDGPU_USERPTR is not set
>>
>> kernel command line has:
>>
>> amdgpu.audio=1 amdgpu.si_support=1 radeon.si_support=0 page_owner=on \
>> amdgpu.gpu_recovery=1
>>
>> Bisecting lead to:
>>
>> commit 66f99628eb24409cb8feb5061f78283c8b65f820
>> Author: Hamza Mahfooz <hamza.mahfooz@amd.com>
>> Date:   Tue Sep 6 15:01:49 2022 -0400
>>
>>     drm/amdgpu: use dirty framebuffer helper
>>
>>     Currently, we aren't handling DRM_IOCTL_MODE_DIRTYFB. So, use
>>     drm_atomic_helper_dirtyfb() as the dirty callback in the amdgpu_fb_funcs
>>     struct.
>>
>>     Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
>>     Acked-by: Alex Deucher <alexander.deucher@amd.com>
>>     Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> index c20922a5af9f..5b09c8f4fe95 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> @@ -38,6 +38,7 @@
>>  #include <linux/pci.h>
>>  #include <linux/pm_runtime.h>
>>  #include <drm/drm_crtc_helper.h>
>> +#include <drm/drm_damage_helper.h>
>>  #include <drm/drm_edid.h>
>>  #include <drm/drm_gem_framebuffer_helper.h>
>>  #include <drm/drm_fb_helper.h>
>> @@ -496,6 +497,7 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
>>  static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
>>         .destroy = drm_gem_fb_destroy,
>>         .create_handle = drm_gem_fb_create_handle,
>> +       .dirty = drm_atomic_helper_dirtyfb,
>>  };
>>
>>  uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
>>
>> After doing a git bisect reset, git pull and reverting the patch above, I
>> rebuilt the kernel and am successfully running with the amdgpu module loaded
>> and using the Radeon R7 250 GPU.
>>
>> I am happy to supply any further configuration details.
>
>Does the attached patch help?
>
>Alex
>
>
>>
>> Arthur Marsh.

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-09-20  3:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 19:57 [PATCH] drm/amdgpu: use dirty framebuffer helper Hamza Mahfooz
2022-09-08 13:14 ` Alex Deucher
2022-09-18 12:09   ` root
2022-09-19  2:53     ` Arthur Marsh
2022-09-19 16:33     ` [PATCH] " Alex Deucher
2022-09-20  3:14       ` Arthur Marsh
2022-09-19  6:44 ` Thomas Zimmermann
2022-09-19 16:26   ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).