Re: [PATCH 1/6] drm/nouveau: convert to using is_hdmi and has_audio from display info

2024-01-14 Thread Jani Nikula
On Sun, 14 Jan 2024, Ilia Mirkin  wrote:
> On Fri, Jan 12, 2024 at 11:50 AM Jani Nikula  wrote:
>>
>> Prefer the parsed results for is_hdmi and has_audio in display info over
>> calling drm_detect_hdmi_monitor() and drm_detect_monitor_audio(),
>> respectively.
>>
>> Conveniently, this also removes the need to use edid_blob_ptr.
>>
>> Cc: Karol Herbst 
>> Cc: Lyude Paul 
>> Cc: Danilo Krummrich 
>> Cc: nouv...@lists.freedesktop.org
>> Signed-off-by: Jani Nikula 
>> ---
>>  drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 
>>  drivers/gpu/drm/nouveau/dispnv50/head.c | 8 +---
>>  drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +-
>>  3 files changed, 6 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
>> b/drivers/gpu/drm/nouveau/dispnv50/disp.c
>> index 8d37a694b772..908b1042669c 100644
>> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
>> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
>> @@ -750,7 +750,7 @@ nv50_audio_enable(struct drm_encoder *encoder, struct 
>> nouveau_crtc *nv_crtc,
>> struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
>> struct nvif_outp *outp = _encoder->outp;
>>
>> -   if (!nv50_audio_supported(encoder) || 
>> !drm_detect_monitor_audio(nv_connector->edid))
>> +   if (!nv50_audio_supported(encoder) || 
>> !nv_connector->base.display_info.has_audio)
>> return;
>>
>> mutex_lock(>audio.lock);
>> @@ -1764,7 +1764,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, 
>> struct drm_atomic_state *sta
>> if ((disp->disp->object.oclass == GT214_DISP ||
>>  disp->disp->object.oclass >= GF110_DISP) &&
>> nv_encoder->dcb->type != DCB_OUTPUT_LVDS &&
>> -   drm_detect_monitor_audio(nv_connector->edid))
>> +   nv_connector->base.display_info.has_audio)
>> hda = true;
>>
>> if (!nvif_outp_acquired(outp))
>> @@ -1773,7 +1773,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, 
>> struct drm_atomic_state *sta
>> switch (nv_encoder->dcb->type) {
>> case DCB_OUTPUT_TMDS:
>> if (disp->disp->object.oclass != NV50_DISP &&
>> -   drm_detect_hdmi_monitor(nv_connector->edid))
>> +   !nv_connector->base.display_info.is_hdmi)
>
> This is backwards, no?

Good catch, thanks!

BR,
Jani.

>
>> nv50_hdmi_enable(encoder, nv_crtc, nv_connector, 
>> state, mode, hda);
>>
>> if (nv_encoder->outp.or.link & 1) {
>> @@ -1786,7 +1786,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, 
>> struct drm_atomic_state *sta
>>  */
>> if (mode->clock >= 165000 &&
>> nv_encoder->dcb->duallink_possible &&
>> -   !drm_detect_hdmi_monitor(nv_connector->edid))
>> +   !nv_connector->base.display_info.is_hdmi)
>> proto = 
>> NV507D_SOR_SET_CONTROL_PROTOCOL_DUAL_TMDS;
>> } else {
>> proto = 
>> NV507D_SOR_SET_CONTROL_PROTOCOL_SINGLE_TMDS_B;
>> diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c 
>> b/drivers/gpu/drm/nouveau/dispnv50/head.c
>> index 83355dbc15ee..d7c74cc43ba5 100644
>> --- a/drivers/gpu/drm/nouveau/dispnv50/head.c
>> +++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
>> @@ -127,14 +127,8 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,
>> struct drm_display_mode *omode = >state.adjusted_mode;
>> struct drm_display_mode *umode = >state.mode;
>> int mode = asyc->scaler.mode;
>> -   struct edid *edid;
>> int umode_vdisplay, omode_hdisplay, omode_vdisplay;
>>
>> -   if (connector->edid_blob_ptr)
>> -   edid = (struct edid *)connector->edid_blob_ptr->data;
>> -   else
>> -   edid = NULL;
>> -
>> if (!asyc->scaler.full) {
>> if (mode == DRM_MODE_SCALE_NONE)
>> omode = umode;
>> @@ -162,7 +156,7 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,
>>  */
>> if ((asyc->scaler.underscan.mode == UNDERSCAN_ON ||
>> (asyc->scaler.underscan.mode == UNDERSCAN_AUTO &&
>> -drm_detect_hdmi_monitor(edid {
>> +connector->display_info.is_hdmi))) {
>> u32 bX = asyc->scaler.underscan.hborder;
>> u32 bY = asyc->scaler.underscan.vborder;
>> u32 r = (asyh->view.oH << 19) / asyh->view.oW;
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c 
>> b/drivers/gpu/drm/nouveau/nouveau_connector.c
>> index 856b3ef5edb8..938832a6af15 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
>> @@ -1034,7 +1034,7 @@ get_tmds_link_bandwidth(struct drm_connector 
>> *connector)
>> unsigned duallink_scale =
>> nouveau_duallink && 

[git pull] drm fixes for 6.8-rc1

2024-01-14 Thread Dave Airlie
Hi Linus,

Hopefully you get your power back at some point, this is just a wrap
up of fixes from the last few days. It has the proper fix to the
i915/xe collision, we can clean up what you did later once rc1 lands.

Otherwise it's a few other i915, a v3d, rockchip and a nouveau fix to
make GSP load on some original Turing GPUs.

I have some amdgpu fixes lined up, but they broke clang build here, so
I'll wait to send those until AMD can fix it.

Dave.

drm-next-2024-01-15-1:
drm fixes for 6.8-rc1

i915:
- Fixes for kernel-doc warnings enforced in linux-next
- Another build warning fix for string formatting of intel_wakeref_t
- Display fixes for DP DSC BPC and C20 PLL state verification

v3d:
- register readout fix

rockchip:
- two build warning fixes

nouveau:
- fix GSP loading on Turing with different nvdec configuration
The following changes since commit b76c01f1d950425924ee1c1377760de3c024ef78:

  Merge tag 'drm-intel-gt-next-2023-12-15' of
git://anongit.freedesktop.org/drm/drm-intel into drm-next (2024-01-10
11:36:47 +1000)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm tags/drm-next-2024-01-15-1

for you to fetch changes up to 205e18c13545ab43cc4fe4930732b4feef551198:

  nouveau/gsp: handle engines in runl without nonstall interrupts.
(2024-01-15 16:04:48 +1000)


drm fixes for 6.8-rc1

i915:
- Fixes for kernel-doc warnings enforced in linux-next
- Another build warning fix for string formatting of intel_wakeref_t
- Display fixes for DP DSC BPC and C20 PLL state verification

v3d:
- register readout fix

rockchip:
- two build warning fixes

nouveau:
- fix GSP loading on Turing with different nvdec configuration


Ankit Nautiyal (1):
  drm/i915/dp: Fix the max DSC bpc supported by source

Cristian Ciocaltea (2):
  drm/rockchip: vop2: Drop superfluous include
  drm/rockchip: vop2: Drop unused if_dclk_rate variable

Dave Airlie (3):
  Merge tag 'drm-intel-next-fixes-2024-01-11' of
git://anongit.freedesktop.org/drm/drm-intel into drm-next
  Merge tag 'drm-misc-next-fixes-2024-01-11' of
git://anongit.freedesktop.org/drm/drm-misc into drm-next
  nouveau/gsp: handle engines in runl without nonstall interrupts.

Imre Deak (1):
  drm/i915/dp: Fix the PSR debugfs entries wrt. MST connectors

Jani Nikula (1):
  drm/i915: don't make assumptions about intel_wakeref_t type

Maíra Canal (1):
  drm/v3d: Fix support for register debugging on the RPi 4

Mika Kahola (1):
  drm/i915/display: Fix C20 pll selection for state verification

Randy Dunlap (4):
  drm/i915/gem: reconcile Excess struct member kernel-doc warnings
  drm/i915/gt: reconcile Excess struct member kernel-doc warnings
  drm/i915/guc: reconcile Excess struct member kernel-doc warnings
  drm/i915/perf: reconcile Excess struct member kernel-doc warnings

 drivers/gpu/drm/i915/display/intel_cx0_phy.c   | 25 +---
 drivers/gpu/drm/i915/display/intel_display_power.c |  4 +-
 drivers/gpu/drm/i915/display/intel_dp.c|  2 +-
 drivers/gpu/drm/i915/display/intel_psr.c   | 10 +--
 drivers/gpu/drm/i915/gem/i915_gem_context_types.h  |  4 +-
 drivers/gpu/drm/i915/gt/intel_gsc.h|  7 +-
 drivers/gpu/drm/i915/gt/uc/intel_guc.h | 75 --
 drivers/gpu/drm/i915/i915_perf_types.h |  9 ++-
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/ga100.c   |  4 ++
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c|  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/gsp/base.c |  8 +--
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c   |  4 +-
 drivers/gpu/drm/v3d/v3d_debugfs.c  | 20 +++---
 13 files changed, 96 insertions(+), 78 deletions(-)


[PATCH v3] drm: Check output polling initialized before disabling

2024-01-14 Thread Shradha Gupta
In drm_kms_helper_poll_disable() check if output polling
support is initialized before disabling polling. If not flag
this as a warning.
Additionally in drm_mode_config_helper_suspend() and
drm_mode_config_helper_resume() calls, that re the callers of these
functions, avoid invoking them if polling is not initialized.
For drivers like hyperv-drm, that do not initialize connector
polling, if suspend is called without this check, it leads to
suspend failure with following stack
[  770.719392] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) 
done.
[  770.720592] printk: Suspending console(s) (use no_console_suspend to debug)
[  770.948823] [ cut here ]
[  770.948824] WARNING: CPU: 1 PID: 17197 at kernel/workqueue.c:3162 
__flush_work.isra.0+0x212/0x230
[  770.948831] Modules linked in: rfkill nft_counter xt_conntrack xt_owner udf 
nft_compat crc_itu_t nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib 
nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat 
nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip_set nf_tables nfnetlink 
vfat fat mlx5_ib ib_uverbs ib_core mlx5_core intel_rapl_msr intel_rapl_common 
kvm_amd ccp mlxfw kvm psample hyperv_drm tls drm_shmem_helper drm_kms_helper 
irqbypass pcspkr syscopyarea sysfillrect sysimgblt hv_balloon hv_utils joydev 
drm fuse xfs libcrc32c pci_hyperv pci_hyperv_intf sr_mod sd_mod cdrom t10_pi sg 
hv_storvsc scsi_transport_fc hv_netvsc serio_raw hyperv_keyboard hid_hyperv 
crct10dif_pclmul crc32_pclmul crc32c_intel hv_vmbus ghash_clmulni_intel 
dm_mirror dm_region_hash dm_log dm_mod
[  770.948863] CPU: 1 PID: 17197 Comm: systemd-sleep Not tainted 
5.14.0-362.2.1.el9_3.x86_64 #1
[  770.948865] Hardware name: Microsoft Corporation Virtual Machine/Virtual 
Machine, BIOS Hyper-V UEFI Release v4.1 05/09/2022
[  770.948866] RIP: 0010:__flush_work.isra.0+0x212/0x230
[  770.948869] Code: 8b 4d 00 4c 8b 45 08 89 ca 48 c1 e9 04 83 e2 08 83 e1 0f 
83 ca 02 89 c8 48 0f ba 6d 00 03 e9 25 ff ff ff 0f 0b e9 4e ff ff ff <0f> 0b 45 
31 ed e9 44 ff ff ff e8 8f 89 b2 00 66 66 2e 0f 1f 84 00
[  770.948870] RSP: 0018:af4ac213fb10 EFLAGS: 00010246
[  770.948871] RAX:  RBX:  RCX: 8c992857
[  770.948872] RDX: 0001 RSI: 0001 RDI: 9aad82b00330
[  770.948873] RBP: 9aad82b00330 R08:  R09: 9aad87ee3d10
[  770.948874] R10: 0200 R11:  R12: 9aad82b00330
[  770.948874] R13: 0001 R14:  R15: 0001
[  770.948875] FS:  7ff1b2f6bb40() GS:9aaf37d0() 
knlGS:
[  770.948878] CS:  0010 DS:  ES:  CR0: 80050033
[  770.948878] CR2: 555f345cb666 CR3: 0001462dc005 CR4: 00370ee0
[  770.948879] Call Trace:
[  770.948880]  
[  770.948881]  ? show_trace_log_lvl+0x1c4/0x2df
[  770.948884]  ? show_trace_log_lvl+0x1c4/0x2df
[  770.948886]  ? __cancel_work_timer+0x103/0x190
[  770.948887]  ? __flush_work.isra.0+0x212/0x230
[  770.948889]  ? __warn+0x81/0x110
[  770.948891]  ? __flush_work.isra.0+0x212/0x230
[  770.948892]  ? report_bug+0x10a/0x140
[  770.948895]  ? handle_bug+0x3c/0x70
[  770.948898]  ? exc_invalid_op+0x14/0x70
[  770.948899]  ? asm_exc_invalid_op+0x16/0x20
[  770.948903]  ? __flush_work.isra.0+0x212/0x230
[  770.948905]  __cancel_work_timer+0x103/0x190
[  770.948907]  ? _raw_spin_unlock_irqrestore+0xa/0x30
[  770.948910]  drm_kms_helper_poll_disable+0x1e/0x40 [drm_kms_helper]
[  770.948923]  drm_mode_config_helper_suspend+0x1c/0x80 [drm_kms_helper]
[  770.948933]  ? __pfx_vmbus_suspend+0x10/0x10 [hv_vmbus]
[  770.948942]  hyperv_vmbus_suspend+0x17/0x40 [hyperv_drm]
[  770.948944]  ? __pfx_vmbus_suspend+0x10/0x10 [hv_vmbus]
[  770.948951]  dpm_run_callback+0x4c/0x140
[  770.948954]  __device_suspend_noirq+0x74/0x220
[  770.948956]  dpm_noirq_suspend_devices+0x148/0x2a0
[  770.948958]  dpm_suspend_end+0x54/0xe0
[  770.948960]  create_image+0x14/0x290
[  770.948963]  hibernation_snapshot+0xd6/0x200
[  770.948964]  hibernate.cold+0x8b/0x1fb
[  770.948967]  state_store+0xcd/0xd0
[  770.948969]  kernfs_fop_write_iter+0x124/0x1b0
[  770.948973]  new_sync_write+0xff/0x190
[  770.948976]  vfs_write+0x1ef/0x280
[  770.948978]  ksys_write+0x5f/0xe0
[  770.948979]  do_syscall_64+0x5c/0x90
[  770.948981]  ? syscall_exit_work+0x103/0x130
[  770.948983]  ? syscall_exit_to_user_mode+0x12/0x30
[  770.948985]  ? do_syscall_64+0x69/0x90
[  770.948986]  ? do_syscall_64+0x69/0x90
[  770.948987]  ? do_user_addr_fault+0x1d6/0x6a0
[  770.948989]  ? do_syscall_64+0x69/0x90
[  770.948990]  ? exc_page_fault+0x62/0x150
[  770.948992]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
[  770.948995] RIP: 0033:0x7ff1b293eba7
[  770.949010] Code: 0b 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 
f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 
f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
[  

Re: [PATCH AUTOSEL 4.14 3/6] drm/crtc: Fix uninit-value bug in drm_mode_setcrtc

2024-01-14 Thread Sasha Levin

On Tue, Dec 19, 2023 at 10:44:02AM +0200, Jani Nikula wrote:

On Mon, 18 Dec 2023, Sasha Levin  wrote:

From: Ziqi Zhao 

[ Upstream commit 3823119b9c2b5f9e9b760336f75bc989b805cde6 ]

The connector_set contains uninitialized values when allocated with
kmalloc_array. However, in the "out" branch, the logic assumes that any
element in connector_set would be equal to NULL if failed to
initialize, which causes the bug reported by Syzbot. The fix is to use
an extra variable to keep track of how many connectors are initialized
indeed, and use that variable to decrease any refcounts in the "out"
branch.

Reported-by: syzbot+4fad2e57beb6397ab...@syzkaller.appspotmail.com
Signed-off-by: Ziqi Zhao 
Reported-and-tested-by: syzbot+4fad2e57beb6397ab...@syzkaller.appspotmail.com
Tested-by: Harshit Mogalapalli 
Link: https://lore.kernel.org/r/20230721161446.8602-1-astraj...@yahoo.com
Signed-off-by: Maxime Ripard 
Signed-off-by: Sasha Levin 


This commit fixes an uninitialized value, but introduces a new
one. Please backport 6e455f5dcdd1 ("drm/crtc: fix uninitialized variable
use") from v6.7-rc6 to go with it.


I'll take 6e455f5dcdd1 too, thanks!

--
Thanks,
Sasha


Re: [pull] amdgpu, amdkfd drm-fixes-6.8

2024-01-14 Thread Dave Airlie
/home/airlied/devel/kernel/dim/src/drivers/gpu/drm/amd/amdgpu/../display/dc/link/protocols/link_dp_dpia_bw.c:548:24:
error: arithmetic between different enumeration types ('const enum
dc_link_rate' and 'const enum dc_lane_count')
[-Werror,-Wenum-enum-conversion]
link_cap->link_rate * link_cap->lane_count *
LINK_RATE_REF_FREQ_IN_KHZ * 8;
~~~ ^ 
1 error generated.

clang said no.

Dave.

On Sat, 13 Jan 2024 at 03:57, Alex Deucher  wrote:
>
> Hi Dave, Sima,
>
> Fixes for 6.8.
>
> The following changes since commit e54478fbdad20f2c58d0a4f99d01299ed8e7fe9c:
>
>   Merge tag 'amd-drm-next-6.8-2024-01-05' of 
> https://gitlab.freedesktop.org/agd5f/linux into drm-next (2024-01-09 09:07:50 
> +1000)
>
> are available in the Git repository at:
>
>   https://gitlab.freedesktop.org/agd5f/linux.git 
> tags/amd-drm-fixes-6.8-2024-01-12
>
> for you to fetch changes up to 3b23fd46e2af68b47902caa3f88d60f73c5d85f7:
>
>   drm/amd/pm: Fix smuv13.0.6 current clock reporting (2024-01-11 23:33:37 
> -0500)
>
> 
> amd-drm-fixes-6.8-2024-01-12:
>
> amdgpu:
> - SubVP fixes
> - VRR fixes
> - USB4 fixes
> - DCN 3.5 fixes
> - GFX11 harvesting fix
> - RAS fixes
> - Misc small fixes
> - KFD dma-buf import fixes
> - Power reporting fixes
> - ATHUB 3.3 fix
> - SR-IOV fix
> - Add missing fw release for fiji
> - GFX 11.5 fix
> - Debugging module parameter fix
> - SMU 13.0.6 fixes
>
> amdkfd:
> - Fix lockdep warnings
> - Fix sparse __rcu warnings
> - Bump interface version so userspace knows that the kernel supports dma-bufs 
> exported from KFD
>   Most of the fixes for this went into 6.7, but the last fix is in this PR
> - HMM fix
> - SVM fix
>
> 
> Alex Deucher (4):
>   drm/amdgpu: fix avg vs input power reporting on smu7
>   drm/amdgpu: fall back to INPUT power for AVG power via INFO IOCTL
>   drm/amdgpu/pm: clarify debugfs pm output
>   drm/amdgpu: drop exp hw support check for GC 9.4.3
>
> Aric Cyr (1):
>   drm/amd/display: 3.2.266
>
> Candice Li (2):
>   drm/amdgpu: Drop unnecessary sentences about CE and deferred error.
>   drm/amdgpu: Support poison error injection via ras_ctrl debugfs
>
> Charlene Liu (1):
>   drm/amd/display: Update z8 latency
>
> Dafna Hirschfeld (1):
>   drm/amdkfd: fixes for HMM mem allocation
>
> Daniel Miess (1):
>   Revert "drm/amd/display: Fix conversions between bytes and KB"
>
> Felix Kuehling (4):
>   drm/amdkfd: Fix lock dependency warning
>   drm/amdkfd: Fix sparse __rcu annotation warnings
>   drm/amdgpu: Auto-validate DMABuf imports in compute VMs
>   drm/amdkfd: Bump KFD ioctl version
>
> George Shen (1):
>   drm/amd/display: Disconnect phantom pipe OPP from OPTC being disabled
>
> Hawking Zhang (1):
>   drm/amdgpu: Packed socket_id to ras feature mask
>
> Ivan Lipski (1):
>   Revert "drm/amd/display: fix bandwidth validation failure on DCN 2.1"
>
> James Zhu (1):
>   drm/amdgpu: make a correction on comment
>
> Le Ma (3):
>   Revert "drm/amdgpu: add param to specify fw bo location for front-door 
> loading"
>   drm/amdgpu: add debug flag to place fw bo on vram for frontdoor loading
>   drm/amdgpu: move debug options init prior to amdgpu device init
>
> Lijo Lazar (2):
>   drm/amd/pm: Add error log for smu v13.0.6 reset
>   drm/amd/pm: Fix smuv13.0.6 current clock reporting
>
> Likun Gao (1):
>   drm/amdgpu: correct the cu count for gfx v11
>
> Martin Leung (2):
>   drm/amd/display: revert "for FPO & SubVP/DRR config program vmin/max"
>   drm/amd/display: revert "Optimize VRR updates to only necessary ones"
>
> Martin Tsai (1):
>   drm/amd/display: To adjust dprefclk by down spread percentage
>
> Meenakshikumar Somasundaram (1):
>   drm/amd/display: Dpia hpd status not in sync after S4
>
> Melissa Wen (1):
>   drm/amd/display: cleanup inconsistent indenting in amdgpu_dm_color
>
> Peichen Huang (1):
>   drm/amd/display: Request usb4 bw for mst streams
>
> Philip Yang (1):
>   drm/amdkfd: Fix lock dependency warning with srcu
>
> Srinivasan Shanmugam (6):
>   drm/amd/powerplay: Fix kzalloc parameter 'ATOM_Tonga_PPM_Table' in 
> 'get_platform_power_management_table()'
>   drm/amdgpu: Fix with right return code '-EIO' in 
> 'amdgpu_gmc_vram_checking()'
>   drm/amdgpu: Fix unsigned comparison with less than zero in 
> vpe_u1_8_from_fraction()
>   drm/amdgpu: Release 'adev->pm.fw' before return in 
> 'amdgpu_device_need_post()'
>   drm/amd/display: Fix variable deferencing before NULL check in 
> edp_setup_replay()
>   drm/amdkfd: Fix 'node' NULL check in 'svm_range_get_range_boundaries()'
>
> Victor Lu (1):
>   drm/amdgpu: Do not program VM_L2_CNTL under SRIOV
>
> Yifan Zhang (3):
>   drm/amdgpu: update headers for nbio v7.11
>   

[PATCH] drm/amd/display: remove kernel-doc misuses in dmub_replay.c

2024-01-14 Thread Randy Dunlap
Change non-kernel-doc comments from "/**" to common "/*" to prevent
kernel-doc warnings:

dmub_replay.c:262: warning: This comment starts with '/**', but isn't a 
kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
 * Set REPLAY power optimization flags and coasting vtotal.
dmub_replay.c:284: warning: This comment starts with '/**', but isn't a 
kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
 * send Replay general cmd to DMUB.

Signed-off-by: Randy Dunlap 
Cc: Harry Wentland 
Cc: Leo Li 
Cc: Rodrigo Siqueira 
Cc: amd-...@lists.freedesktop.org
Cc: Alex Deucher 
Cc: Christian König 
Cc: "Pan, Xinhui" 
Cc: Tom Chung 
Cc: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/amd/display/dc/dce/dmub_replay.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -- a/drivers/gpu/drm/amd/display/dc/dce/dmub_replay.c 
b/drivers/gpu/drm/amd/display/dc/dce/dmub_replay.c
--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_replay.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_replay.c
@@ -258,7 +258,7 @@ static void dmub_replay_residency(struct
*residency = 0;
 }
 
-/**
+/*
  * Set REPLAY power optimization flags and coasting vtotal.
  */
 static void dmub_replay_set_power_opt_and_coasting_vtotal(struct dmub_replay 
*dmub,
@@ -280,7 +280,7 @@ static void dmub_replay_set_power_opt_an
dc_wake_and_execute_dmub_cmd(dc, , DM_DMUB_WAIT_TYPE_WAIT);
 }
 
-/**
+/*
  * send Replay general cmd to DMUB.
  */
 static void dmub_replay_send_cmd(struct dmub_replay *dmub,


Re: [git pull] drm for 6.8

2024-01-14 Thread Dave Airlie
On Sat, 13 Jan 2024 at 05:33, Linus Torvalds
 wrote:
>
> On Wed, 10 Jan 2024 at 11:49, Dave Airlie  wrote:
> >
> > Let me know if there are any issues,
>
> Your testing is seriously lacking.
>
> This doesn't even build. The reason seems to be that commit
> b49e894c3fd8 ("drm/i915: Replace custom intel runtime_pm tracker with
> ref_tracker library") changed the 'intel_wakeref_t' type from a
> 'depot_stack_handle_t' to 'unsigned long', and as a result did this:
>
> -   drm_dbg(>drm, "async_put_wakeref %u\n",
> +   drm_dbg(>drm, "async_put_wakeref %lu\n",
> power_domains->async_put_wakeref);
>
> meanwhile, the Xe driver has this:
>
>   drivers/gpu/drm/xe/compat-i915-headers/intel_wakeref.h:
> typedef bool intel_wakeref_t;
>
> which has never been valid, but now the build fails with

This was a bad cross of trees, the fix was in a pull request in my
inbox about an hour after I sent the PR, it just wasn't marked urgent
and it passes all my usual test builds.

It turns out there is a Kconfig bug without EXPERT that was masking
this in my builds, hope to get that fix in soon.


>
>   drivers/gpu/drm/i915/display/intel_display_power.c: In function
> ‘print_async_put_domains_state’:
>   drivers/gpu/drm/i915/display/intel_display_power.c:408:29: error:
> format ‘%lu’ expects argument of type ‘long unsigned int’, but
> argument 5 has type ‘int’ [-Werror=format=]
>
> because the drm header files have this disgusting thing where a
> *header* file includes a *C* file:
>
>   In file included from ./include/drm/drm_mm.h:51,
>  from drivers/gpu/drm/xe/xe_bo_types.h:11,
>  from drivers/gpu/drm/xe/xe_bo.h:11,
>  from
> ./drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h:11,
>  from ./drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h:15,
>  from drivers/gpu/drm/i915/display/intel_display_power.c:8:
>
> nasty.


>
> I made it build by fixing that broken Xe compat header file, but this
> is definitely *NOT* how things should have worked. How did this ever
> get to me without any kind of build testing?
>
> And why the %^!@$% does a header file include a C file? That's wrong
> regardless of this bug.

Huh? display_power.c includes i915_drv.h includes i915_gem_object.h
include xe_bo.h include xe_bo_types.h include drm_mm.h?

I'm not seeing the c in h, you reading that backtrace correctly?

It was built test in a few scenarios by different people and in CI,
but it does appear the Kconfig screwup was masking people from seeing
the actual bug. We had a report a few days ago and a fix was posted,
just not marked as urgent and since I never saw the build fails here I
didn't escalate it.

Dave.


[PATCH v1 4/4] backlight: hx8357: Utilise temporary variable for struct device

2024-01-14 Thread Andy Shevchenko
We have a temporary variable to keep pointer to struct device.
Utilise it inside the ->probe() implementation.

Signed-off-by: Andy Shevchenko 
---
 drivers/video/backlight/hx8357.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index fbe02fd73272..e4dc76f25f8e 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -574,7 +574,7 @@ static int hx8357_probe(struct spi_device *spi)
hx8357_init init;
int i, ret;
 
-   lcd = devm_kzalloc(>dev, sizeof(*lcd), GFP_KERNEL);
+   lcd = devm_kzalloc(dev, sizeof(*lcd), GFP_KERNEL);
if (!lcd)
return -ENOMEM;
 
@@ -604,8 +604,7 @@ static int hx8357_probe(struct spi_device *spi)
gpiod_set_consumer_name(lcd->im_pins->desc[i], 
"im_pins");
}
 
-   lcdev = devm_lcd_device_register(>dev, "mxsfb", >dev, lcd,
-   _ops);
+   lcdev = devm_lcd_device_register(dev, "mxsfb", dev, lcd, _ops);
if (IS_ERR(lcdev)) {
ret = PTR_ERR(lcdev);
return ret;
@@ -618,7 +617,7 @@ static int hx8357_probe(struct spi_device *spi)
if (ret)
return dev_err_probe(dev, ret, "Couldn't initialize panel\n");
 
-   dev_info(>dev, "Panel probed\n");
+   dev_info(dev, "Panel probed\n");
 
return 0;
 }
-- 
2.43.0.rc1.1.gbec44491f096



[PATCH v1 1/4] backlight: hx8357: Make use of device properties

2024-01-14 Thread Andy Shevchenko
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Include mod_devicetable.h explicitly to replace the dropped of.h
which included mod_devicetable.h indirectly.

Signed-off-by: Andy Shevchenko 
---
 drivers/video/backlight/hx8357.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index bf18337ff0c2..c7fd10d55c5d 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -8,9 +8,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
-#include 
+#include 
 #include 
 
 #define HX8357_NUM_IM_PINS 3
@@ -564,6 +564,8 @@ static struct lcd_ops hx8357_ops = {
.get_power  = hx8357_get_power,
 };
 
+typedef int (*hx8357_init)(struct lcd_device *);
+
 static const struct of_device_id hx8357_dt_ids[] = {
{
.compatible = "himax,hx8357",
@@ -582,7 +584,7 @@ static int hx8357_probe(struct spi_device *spi)
struct device *dev = >dev;
struct lcd_device *lcdev;
struct hx8357_data *lcd;
-   const struct of_device_id *match;
+   hx8357_init init;
int i, ret;
 
lcd = devm_kzalloc(>dev, sizeof(*lcd), GFP_KERNEL);
@@ -597,8 +599,8 @@ static int hx8357_probe(struct spi_device *spi)
 
lcd->spi = spi;
 
-   match = of_match_device(hx8357_dt_ids, >dev);
-   if (!match || !match->data)
+   init = device_get_match_data(dev);
+   if (!init)
return -EINVAL;
 
lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
@@ -627,7 +629,7 @@ static int hx8357_probe(struct spi_device *spi)
 
hx8357_lcd_reset(lcdev);
 
-   ret = ((int (*)(struct lcd_device *))match->data)(lcdev);
+   ret = init(lcdev);
if (ret) {
dev_err(>dev, "Couldn't initialize panel\n");
return ret;
-- 
2.43.0.rc1.1.gbec44491f096



[PATCH v1 2/4] backlight: hx8357: Move OF table closer to its consumer

2024-01-14 Thread Andy Shevchenko
Move OF table near to the user.

While at it, drop comma at terminator entry.

Signed-off-by: Andy Shevchenko 
---
 drivers/video/backlight/hx8357.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index c7fd10d55c5d..8709d9141cfb 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -566,19 +566,6 @@ static struct lcd_ops hx8357_ops = {
 
 typedef int (*hx8357_init)(struct lcd_device *);
 
-static const struct of_device_id hx8357_dt_ids[] = {
-   {
-   .compatible = "himax,hx8357",
-   .data = hx8357_lcd_init,
-   },
-   {
-   .compatible = "himax,hx8369",
-   .data = hx8369_lcd_init,
-   },
-   {},
-};
-MODULE_DEVICE_TABLE(of, hx8357_dt_ids);
-
 static int hx8357_probe(struct spi_device *spi)
 {
struct device *dev = >dev;
@@ -640,6 +627,19 @@ static int hx8357_probe(struct spi_device *spi)
return 0;
 }
 
+static const struct of_device_id hx8357_dt_ids[] = {
+   {
+   .compatible = "himax,hx8357",
+   .data = hx8357_lcd_init,
+   },
+   {
+   .compatible = "himax,hx8369",
+   .data = hx8369_lcd_init,
+   },
+   {}
+};
+MODULE_DEVICE_TABLE(of, hx8357_dt_ids);
+
 static struct spi_driver hx8357_driver = {
.probe  = hx8357_probe,
.driver = {
-- 
2.43.0.rc1.1.gbec44491f096



[PATCH v1 3/4] backlight: hx8357: Make use of dev_err_probe()

2024-01-14 Thread Andy Shevchenko
Simplify the error handling in probe function by switching from
dev_err() to dev_err_probe().

Signed-off-by: Andy Shevchenko 
---
 drivers/video/backlight/hx8357.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index 8709d9141cfb..fbe02fd73272 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -579,10 +579,8 @@ static int hx8357_probe(struct spi_device *spi)
return -ENOMEM;
 
ret = spi_setup(spi);
-   if (ret < 0) {
-   dev_err(>dev, "SPI setup failed.\n");
-   return ret;
-   }
+   if (ret < 0)
+   return dev_err_probe(dev, ret, "SPI setup failed.\n");
 
lcd->spi = spi;
 
@@ -617,10 +615,8 @@ static int hx8357_probe(struct spi_device *spi)
hx8357_lcd_reset(lcdev);
 
ret = init(lcdev);
-   if (ret) {
-   dev_err(>dev, "Couldn't initialize panel\n");
-   return ret;
-   }
+   if (ret)
+   return dev_err_probe(dev, ret, "Couldn't initialize panel\n");
 
dev_info(>dev, "Panel probed\n");
 
-- 
2.43.0.rc1.1.gbec44491f096



[PATCH v1 0/4] backlight: hx8357: Clean up and make OF-independent

2024-01-14 Thread Andy Shevchenko
A few ad-hoc cleanups and one patch to make driver OF-independent.

Andy Shevchenko (4):
  backlight: hx8357: Make use of device properties
  backlight: hx8357: Move OF table closer to its consumer
  backlight: hx8357: Make use of dev_err_probe()
  backlight: hx8357: Utilise temporary variable for struct device

 drivers/video/backlight/hx8357.c | 57 +++-
 1 file changed, 27 insertions(+), 30 deletions(-)

-- 
2.43.0.rc1.1.gbec44491f096



[PATCH] drm/i915/guc: Remove usage of the deprecated ida_simple_xx() API

2024-01-14 Thread Christophe JAILLET
ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_range() is inclusive. So a -1 has been added when needed.

Signed-off-by: Christophe JAILLET 
---
 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index a259f1118c5a..73ce21ddf682 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -2156,11 +2156,10 @@ static int new_guc_id(struct intel_guc *guc, struct 
intel_context *ce)
  
order_base_2(ce->parallel.number_children
   + 1));
else
-   ret = ida_simple_get(>submission_state.guc_ids,
-NUMBER_MULTI_LRC_GUC_ID(guc),
-guc->submission_state.num_guc_ids,
-GFP_KERNEL | __GFP_RETRY_MAYFAIL |
-__GFP_NOWARN);
+   ret = ida_alloc_range(>submission_state.guc_ids,
+ NUMBER_MULTI_LRC_GUC_ID(guc),
+ guc->submission_state.num_guc_ids - 1,
+ GFP_KERNEL | __GFP_RETRY_MAYFAIL | 
__GFP_NOWARN);
if (unlikely(ret < 0))
return ret;
 
@@ -2183,8 +2182,8 @@ static void __release_guc_id(struct intel_guc *guc, 
struct intel_context *ce)
   + 1));
} else {
--guc->submission_state.guc_ids_in_use;
-   ida_simple_remove(>submission_state.guc_ids,
- ce->guc_id.id);
+   ida_free(>submission_state.guc_ids,
+ce->guc_id.id);
}
clr_ctx_id_mapping(guc, ce->guc_id.id);
set_context_guc_id_invalid(ce);
-- 
2.43.0



[PATCH] drm/amdgpu: Remove usage of the deprecated ida_simple_xx() API

2024-01-14 Thread Christophe JAILLET
ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_range() is inclusive. So a -1 has been added when needed.

Signed-off-by: Christophe JAILLET 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
index ddd0891da116..3d7fcdeaf8cf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
@@ -62,9 +62,8 @@ int amdgpu_pasid_alloc(unsigned int bits)
int pasid = -EINVAL;
 
for (bits = min(bits, 31U); bits > 0; bits--) {
-   pasid = ida_simple_get(_pasid_ida,
-  1U << (bits - 1), 1U << bits,
-  GFP_KERNEL);
+   pasid = ida_alloc_range(_pasid_ida, 1U << (bits - 1),
+   (1U << bits) - 1, GFP_KERNEL);
if (pasid != -ENOSPC)
break;
}
@@ -82,7 +81,7 @@ int amdgpu_pasid_alloc(unsigned int bits)
 void amdgpu_pasid_free(u32 pasid)
 {
trace_amdgpu_pasid_freed(pasid);
-   ida_simple_remove(_pasid_ida, pasid);
+   ida_free(_pasid_ida, pasid);
 }
 
 static void amdgpu_pasid_free_cb(struct dma_fence *fence,
-- 
2.43.0



[PATCH] drm/xe/guc: Remove usage of the deprecated ida_simple_xx() API

2024-01-14 Thread Christophe JAILLET
ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_max() is inclusive. So a -1 has been added when needed.

Signed-off-by: Christophe JAILLET 
---
 drivers/gpu/drm/xe/xe_guc_submit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c 
b/drivers/gpu/drm/xe/xe_guc_submit.c
index 21ac68e3246f..11ffacd1dd58 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -311,7 +311,7 @@ static void __release_guc_id(struct xe_guc *guc, struct 
xe_exec_queue *q, u32 xa
  q->guc->id - GUC_ID_START_MLRC,
  order_base_2(q->width));
else
-   ida_simple_remove(>submission_state.guc_ids, q->guc->id);
+   ida_free(>submission_state.guc_ids, q->guc->id);
 }
 
 static int alloc_guc_id(struct xe_guc *guc, struct xe_exec_queue *q)
@@ -335,8 +335,8 @@ static int alloc_guc_id(struct xe_guc *guc, struct 
xe_exec_queue *q)
ret = bitmap_find_free_region(bitmap, GUC_ID_NUMBER_MLRC,
  order_base_2(q->width));
} else {
-   ret = ida_simple_get(>submission_state.guc_ids, 0,
-GUC_ID_NUMBER_SLRC, GFP_NOWAIT);
+   ret = ida_alloc_max(>submission_state.guc_ids,
+   GUC_ID_NUMBER_SLRC - 1, GFP_NOWAIT);
}
if (ret < 0)
return ret;
-- 
2.43.0



[PATCH v1 1/1] backlight: hx8357: Fix potential NULL pointer dereference

2024-01-14 Thread Andy Shevchenko
The "im" pins are optional. Add missing check in the hx8357_probe().

Reported-by: Dan Carpenter 
Closes: 
https://lore.kernel.org/r/642e1230-3358-4006-a17f-3f297897ae74@moroto.mountain
Fixes: 7d84a63a39b7 ("backlight: hx8357: Convert to agnostic GPIO API")
Signed-off-by: Andy Shevchenko 
---
 drivers/video/backlight/hx8357.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index d7298376cf74..bf18337ff0c2 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -609,11 +609,13 @@ static int hx8357_probe(struct spi_device *spi)
lcd->im_pins = devm_gpiod_get_array_optional(dev, "im", GPIOD_OUT_LOW);
if (IS_ERR(lcd->im_pins))
return dev_err_probe(dev, PTR_ERR(lcd->im_pins), "failed to 
request im GPIOs\n");
-   if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS)
-   return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n");
+   if (lcd->im_pins) {
+   if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS)
+   return dev_err_probe(dev, -EINVAL, "not enough im 
GPIOs\n");
 
-   for (i = 0; i < HX8357_NUM_IM_PINS; i++)
-   gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins");
+   for (i = 0; i < HX8357_NUM_IM_PINS; i++)
+   gpiod_set_consumer_name(lcd->im_pins->desc[i], 
"im_pins");
+   }
 
lcdev = devm_lcd_device_register(>dev, "mxsfb", >dev, lcd,
_ops);
-- 
2.43.0.rc1.1.gbec44491f096



Re: [PATCH AUTOSEL 6.1 5/5] nouveau: fix disp disabling with GSP

2024-01-14 Thread Sasha Levin

On Tue, Jan 09, 2024 at 06:51:25AM +1000, David Airlie wrote:

NAK for backporting this to anything, it is just a fix for 6.7


Dropped it from everywhere, thanks!

--
Thanks,
Sasha


[PATCH v4 1/1] drm/tests: Add KUnit tests for drm_mode_create_dvi_i_properties()

2024-01-14 Thread Dipam Turkar
Introduce unit tests for the drm_mode_create_dvi_i_properties() function to 
ensure
the proper creation of DVI-I specific connector properties and success if 
called 
multiple times.

Signed-off-by: Dipam Turkar 
---
 drivers/gpu/drm/tests/drm_connector_test.c | 58 ++
 1 file changed, 58 insertions(+)

diff --git a/drivers/gpu/drm/tests/drm_connector_test.c 
b/drivers/gpu/drm/tests/drm_connector_test.c
index c66aa2dc8d9d..217c0988171e 100644
--- a/drivers/gpu/drm/tests/drm_connector_test.c
+++ b/drivers/gpu/drm/tests/drm_connector_test.c
@@ -4,6 +4,9 @@
  */
 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -70,7 +73,62 @@ static struct kunit_suite 
drm_get_tv_mode_from_name_test_suite = {
.test_cases = drm_get_tv_mode_from_name_tests,
 };
 
+/*
+ * Test that drm_mode_create_dvi_i_properties() succeeds and
+ * DVI-I subconnector and select subconectors properties have
+ * been created.
+ */
+static void drm_test_mode_create_dvi_i_properties(struct kunit *test)
+{
+   struct drm_device *drm;
+   struct device *dev;
+
+   dev = drm_kunit_helper_alloc_device(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
+
+   drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, 
DRIVER_MODESET);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
+
+   KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);
+   KUNIT_EXPECT_NOT_ERR_OR_NULL(test, 
drm->mode_config.dvi_i_select_subconnector_property);
+   KUNIT_EXPECT_NOT_ERR_OR_NULL(test, 
drm->mode_config.dvi_i_subconnector_property);
+}
+
+/*
+ * Test that drm_mode_create_dvi_i_properties() doesn't fail if called twice.
+ */
+static void drm_test_mode_create_dvi_i_properties_repeated(struct kunit *test)
+{
+   struct drm_device *drm;
+   struct device *dev;
+
+   dev = drm_kunit_helper_alloc_device(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
+
+   drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, 
DRIVER_MODESET);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
+
+   KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);
+   KUNIT_EXPECT_NOT_ERR_OR_NULL(test, 
drm->mode_config.dvi_i_select_subconnector_property);
+   KUNIT_EXPECT_NOT_ERR_OR_NULL(test, 
drm->mode_config.dvi_i_subconnector_property);
+
+   /* Expect the function to return 0 if called twice. */
+   KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);
+}
+
+static struct kunit_case drm_mode_create_dvi_i_properties_tests[] = {
+   KUNIT_CASE(drm_test_mode_create_dvi_i_properties),
+   KUNIT_CASE(drm_test_mode_create_dvi_i_properties_repeated),
+   { }
+};
+
+static struct kunit_suite drm_mode_create_dvi_i_properties_test_suite = {
+   .name = "drm_mode_create_dvi_i_properties",
+   .test_cases = drm_mode_create_dvi_i_properties_tests,
+};
+
 kunit_test_suite(drm_get_tv_mode_from_name_test_suite);
+kunit_test_suite(drm_mode_create_dvi_i_properties_test_suite);
 
 MODULE_AUTHOR("Maxime Ripard ");
 MODULE_LICENSE("GPL");
-- 
2.34.1