Re: [PATCH v6 1/3] drm/doc/rfc: VM_BIND feature design document

2022-06-29 Thread Niranjana Vishwanathapura

On Wed, Jun 29, 2022 at 05:38:59PM -0700, Zanoni, Paulo R wrote:

On Sat, 2022-06-25 at 18:49 -0700, Niranjana Vishwanathapura wrote:

VM_BIND design document with description of intended use cases.

v2: Reduce the scope to simple Mesa use case.
v3: Expand documentation on dma-resv usage, TLB flushing and
execbuf3.
v4: Remove vm_bind tlb flush request support.
v5: Update TLB flushing documentation.
v6: Update out of order completion documentation.

Signed-off-by: Niranjana Vishwanathapura 
---
 Documentation/gpu/rfc/i915_vm_bind.rst | 246 +
 Documentation/gpu/rfc/index.rst|   4 +
 2 files changed, 250 insertions(+)
 create mode 100644 Documentation/gpu/rfc/i915_vm_bind.rst

diff --git a/Documentation/gpu/rfc/i915_vm_bind.rst 
b/Documentation/gpu/rfc/i915_vm_bind.rst
new file mode 100644
index ..032ee32b885c
--- /dev/null
+++ b/Documentation/gpu/rfc/i915_vm_bind.rst
@@ -0,0 +1,246 @@
+==
+I915 VM_BIND feature design and use cases
+==
+
+VM_BIND feature
+
+DRM_I915_GEM_VM_BIND/UNBIND ioctls allows UMD to bind/unbind GEM buffer
+objects (BOs) or sections of a BOs at specified GPU virtual addresses on a
+specified address space (VM). These mappings (also referred to as persistent
+mappings) will be persistent across multiple GPU submissions (execbuf calls)
+issued by the UMD, without user having to provide a list of all required
+mappings during each submission (as required by older execbuf mode).
+
+The VM_BIND/UNBIND calls allow UMDs to request a timeline out fence for
+signaling the completion of bind/unbind operation.
+
+VM_BIND feature is advertised to user via I915_PARAM_HAS_VM_BIND.


I915_PARAM_VM_BIND_VERSION


Thanks, will fix.





+User has to opt-in for VM_BIND mode of binding for an address space (VM)
+during VM creation time via I915_VM_CREATE_FLAGS_USE_VM_BIND extension.
+
+VM_BIND/UNBIND ioctl calls executed on different CPU threads concurrently are
+not ordered. Furthermore, parts of the VM_BIND/UNBIND operations can be done
+asynchronously, when valid out fence is specified.
+
+VM_BIND features include:
+
+* Multiple Virtual Address (VA) mappings can map to the same physical pages
+  of an object (aliasing).
+* VA mapping can map to a partial section of the BO (partial binding).
+* Support capture of persistent mappings in the dump upon GPU error.
+* Support for userptr gem objects (no special uapi is required for this).
+
+TLB flush consideration
+
+The i915 driver flushes the TLB for each submission and when an object's
+pages are released. The VM_BIND/UNBIND operation will not do any additional
+TLB flush. Any VM_BIND mapping added will be in the working set for subsequent
+submissions on that VM and will not be in the working set for currently running
+batches (which would require additional TLB flushes, which is not supported).
+
+Execbuf ioctl in VM_BIND mode
+---
+A VM in VM_BIND mode will not support older execbuf mode of binding.
+The execbuf ioctl handling in VM_BIND mode differs significantly from the
+older execbuf2 ioctl (See struct drm_i915_gem_execbuffer2).
+Hence, a new execbuf3 ioctl has been added to support VM_BIND mode. (See
+struct drm_i915_gem_execbuffer3). The execbuf3 ioctl will not accept any
+execlist. Hence, no support for implicit sync. It is expected that the below
+work will be able to support requirements of object dependency setting in all
+use cases:
+
+"dma-buf: Add an API for exporting sync files"
+(https://lwn.net/Articles/859290/)
+
+The new execbuf3 ioctl only works in VM_BIND mode and the VM_BIND mode only
+works with execbuf3 ioctl for submission. All BOs mapped on that VM (through
+VM_BIND call) at the time of execbuf3 call are deemed required for that
+submission.
+
+The execbuf3 ioctl directly specifies the batch addresses instead of as
+object handles as in execbuf2 ioctl. The execbuf3 ioctl will also not
+support many of the older features like in/out/submit fences, fence array,
+default gem context and many more (See struct drm_i915_gem_execbuffer3).


Just as a note: both Iris and Vulkan use some of these features, so
some rework will be required. From what I can see, all current behavior
we depend on will be supported in some way or another, so hopefully
we'll be fine.



+
+In VM_BIND mode, VA allocation is completely managed by the user instead of
+the i915 driver. Hence all VA assignment, eviction are not applicable in
+VM_BIND mode. Also, for determining object activeness, VM_BIND mode will not
+be using the i915_vma active reference tracking. It will instead use dma-resv
+object for that (See `VM_BIND dma_resv usage`_).
+
+So, a lot of existing code supporting execbuf2 ioctl, like relocations, VA
+evictions, vma lookup table, implicit sync, vma active reference tracking etc.,
+are not applicable for execbuf3 ioctl. Hence, all execbuf3 specific 

Re: [PATCH v6 3/3] drm/doc/rfc: VM_BIND uapi definition

2022-06-29 Thread Jason Ekstrand
On Sat, Jun 25, 2022 at 8:49 PM Niranjana Vishwanathapura <
niranjana.vishwanathap...@intel.com> wrote:

> VM_BIND and related uapi definitions
>
> v2: Reduce the scope to simple Mesa use case.
> v3: Expand VM_UNBIND documentation and add
> I915_GEM_VM_BIND/UNBIND_FENCE_VALID
> and I915_GEM_VM_BIND_TLB_FLUSH flags.
> v4: Remove I915_GEM_VM_BIND_TLB_FLUSH flag and add additional
> documentation for vm_bind/unbind.
> v5: Remove TLB flush requirement on VM_UNBIND.
> Add version support to stage implementation.
> v6: Define and use drm_i915_gem_timeline_fence structure for
> all timeline fences.
> v7: Rename I915_PARAM_HAS_VM_BIND to I915_PARAM_VM_BIND_VERSION.
> Update documentation on async vm_bind/unbind and versioning.
> Remove redundant vm_bind/unbind FENCE_VALID flag, execbuf3
> batch_count field and I915_EXEC3_SECURE flag.
>
> Signed-off-by: Niranjana Vishwanathapura <
> niranjana.vishwanathap...@intel.com>
> Reviewed-by: Daniel Vetter 
> ---
>  Documentation/gpu/rfc/i915_vm_bind.h | 280 +++
>  1 file changed, 280 insertions(+)
>  create mode 100644 Documentation/gpu/rfc/i915_vm_bind.h
>
> diff --git a/Documentation/gpu/rfc/i915_vm_bind.h
> b/Documentation/gpu/rfc/i915_vm_bind.h
> new file mode 100644
> index ..a93e08bceee6
> --- /dev/null
> +++ b/Documentation/gpu/rfc/i915_vm_bind.h
> @@ -0,0 +1,280 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2022 Intel Corporation
> + */
> +
> +/**
> + * DOC: I915_PARAM_VM_BIND_VERSION
> + *
> + * VM_BIND feature version supported.
> + * See typedef drm_i915_getparam_t param.
> + *
> + * Specifies the VM_BIND feature version supported.
> + * The following versions of VM_BIND have been defined:
> + *
> + * 0: No VM_BIND support.
> + *
> + * 1: In VM_UNBIND calls, the UMD must specify the exact mappings created
> + *previously with VM_BIND, the ioctl will not support unbinding
> multiple
> + *mappings or splitting them. Similarly, VM_BIND calls will not
> replace
> + *any existing mappings.
> + *
> + * 2: The restrictions on unbinding partial or multiple mappings is
> + *lifted, Similarly, binding will replace any mappings in the given
> range.
> + *
> + * See struct drm_i915_gem_vm_bind and struct drm_i915_gem_vm_unbind.
> + */
> +#define I915_PARAM_VM_BIND_VERSION 57
> +
> +/**
> + * DOC: I915_VM_CREATE_FLAGS_USE_VM_BIND
> + *
> + * Flag to opt-in for VM_BIND mode of binding during VM creation.
> + * See struct drm_i915_gem_vm_control flags.
> + *
> + * The older execbuf2 ioctl will not support VM_BIND mode of operation.
> + * For VM_BIND mode, we have new execbuf3 ioctl which will not accept any
> + * execlist (See struct drm_i915_gem_execbuffer3 for more details).
> + */
> +#define I915_VM_CREATE_FLAGS_USE_VM_BIND   (1 << 0)
> +
> +/* VM_BIND related ioctls */
> +#define DRM_I915_GEM_VM_BIND   0x3d
> +#define DRM_I915_GEM_VM_UNBIND 0x3e
> +#define DRM_I915_GEM_EXECBUFFER3   0x3f
> +
> +#define DRM_IOCTL_I915_GEM_VM_BIND DRM_IOWR(DRM_COMMAND_BASE
> + DRM_I915_GEM_VM_BIND, struct drm_i915_gem_vm_bind)
> +#define DRM_IOCTL_I915_GEM_VM_UNBIND   DRM_IOWR(DRM_COMMAND_BASE
> + DRM_I915_GEM_VM_UNBIND, struct drm_i915_gem_vm_bind)
> +#define DRM_IOCTL_I915_GEM_EXECBUFFER3 DRM_IOWR(DRM_COMMAND_BASE
> + DRM_I915_GEM_EXECBUFFER3, struct drm_i915_gem_execbuffer3)
> +
> +/**
> + * struct drm_i915_gem_timeline_fence - An input or output timeline fence.
> + *
> + * The operation will wait for input fence to signal.
> + *
> + * The returned output fence will be signaled after the completion of the
> + * operation.
> + */
> +struct drm_i915_gem_timeline_fence {
> +   /** @handle: User's handle for a drm_syncobj to wait on or signal.
> */
> +   __u32 handle;
> +
> +   /**
> +* @flags: Supported flags are:
> +*
> +* I915_TIMELINE_FENCE_WAIT:
> +* Wait for the input fence before the operation.
> +*
> +* I915_TIMELINE_FENCE_SIGNAL:
> +* Return operation completion fence as output.
> +*/
> +   __u32 flags;
> +#define I915_TIMELINE_FENCE_WAIT(1 << 0)
> +#define I915_TIMELINE_FENCE_SIGNAL  (1 << 1)
> +#define __I915_TIMELINE_FENCE_UNKNOWN_FLAGS (-(I915_TIMELINE_FENCE_SIGNAL
> << 1))
> +
> +   /**
> +* @value: A point in the timeline.
> +* Value must be 0 for a binary drm_syncobj. A Value of 0 for a
> +* timeline drm_syncobj is invalid as it turns a drm_syncobj into a
> +* binary one.
> +*/
> +   __u64 value;
> +};
> +
> +/**
> + * struct drm_i915_gem_vm_bind - VA to object mapping to bind.
> + *
> + * This structure is passed to VM_BIND ioctl and specifies the mapping of
> GPU
> + * virtual address (VA) range to the section of an object that should be
> bound
> + * in the device page table of the specified address space (VM).
> + * The VA range specified must be unique (ie., not 

[PATCH] drm/i915/reset: Handle reset timeouts under unrelated kernel hangs

2022-06-29 Thread Ashutosh Dixit
From: Chris Wilson 

When resuming after hibernate sometimes we see hangs in unrelated kernel
subsystems. These hangs often result in the following i915 trace:

i915 :00:02.0: [drm] *ERROR* \
intel_gt_reset_global timed out, cancelling all in-flight rendering

implying our reset task has been starved by the hanging kernel subsystem,
causing us to inappropiately declare the system as wedged beyond recovery.

The trace would be caused by our synchronize_srcu_expedited() taking more
than the allowed 5s due to the unrelated kernel hang. But we neither need
to perform that synchronisation inside the reset watchdog, nor do we need
such a short timeout before declaring the device as unrecoverable.

v2: Restore watchdog timeout to the previous 5 seconds (Ashutosh)

Bug: https://gitlab.freedesktop.org/drm/intel/-/issues/3575
Signed-off-by: Chris Wilson 
Signed-off-by: Ashutosh Dixit 
Reviewed-by: Ashutosh Dixit 
---
 drivers/gpu/drm/i915/gt/intel_reset.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_reset.c 
b/drivers/gpu/drm/i915/gt/intel_reset.c
index a5338c3fde7a..1cbe65a5b0fd 100644
--- a/drivers/gpu/drm/i915/gt/intel_reset.c
+++ b/drivers/gpu/drm/i915/gt/intel_reset.c
@@ -1262,9 +1262,6 @@ static void intel_gt_reset_global(struct intel_gt *gt,
intel_wedge_on_timeout(, gt, 5 * HZ) {
intel_display_prepare_reset(gt->i915);
 
-   /* Flush everyone using a resource about to be clobbered */
-   synchronize_srcu_expedited(>reset.backoff_srcu);
-
intel_gt_reset(gt, engine_mask, reason);
 
intel_display_finish_reset(gt->i915);
@@ -1373,6 +1370,9 @@ void intel_gt_handle_error(struct intel_gt *gt,
}
}
 
+   /* Flush everyone using a resource about to be clobbered */
+   synchronize_srcu_expedited(>reset.backoff_srcu);
+
intel_gt_reset_global(gt, engine_mask, msg);
 
if (!intel_uc_uses_guc_submission(>uc)) {
-- 
2.34.1



Re: [PATCH v2] gpu/drm/bridge/cadence: avoid flush_scheduled_work() usage

2022-06-29 Thread Tetsuo Handa
Ping?

On 2022/06/13 22:57, Tetsuo Handa wrote:
> Thus, how do we want to handle this race window?
> 
>   flush_delayed_work(>hdcp.check_work) followed by
>   flush_work(>hdcp.prop_work) (i.e. flush as much as possible) ?
> 
>   cancel_delayed_work_sync(>hdcp.check_work) followed by
>   cancel_work_sync(>hdcp.prop_work) (i.e. cancel as much as possible) ?
> 
>   do nothing (i.e. no need to flush or cancel mhdp->hdcp.check_work and 
> mhdp->hdcp.prop_work) ?
> 



Re: How to convert drivers/gpu/drm/i915/ to use local workqueue?

2022-06-29 Thread Tetsuo Handa
Ping?

On 2022/06/10 23:57, Tetsuo Handa wrote:
> Then, does this flush_scheduled_work() mean to wait all 
> schedule_work()/schedule_delayed_work()
> calls inside drivers/gpu/drm/i915/ directory?


RE: [PATCH 1/2] drm/exynos: MAINTAINERS: move Joonyoung Shim to credits

2022-06-29 Thread SR



> -Original Message-
> From: Krzysztof Kozlowski [mailto:krzysztof.kozlow...@linaro.org]
> Sent: Monday, June 27, 2022 1:33 AM
> To: Inki Dae ; Seung-Woo Kim
> ; Kyungmin Park ; David
> Airlie ; Daniel Vetter ; Rob Herring
> ; Krzysztof Kozlowski
> ; Alim Akhtar
;
> Kishon Vijay Abraham I ; Vinod Koul ;
> linux-ker...@vger.kernel.org; dri-devel@lists.freedesktop.org;
> devicet...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; linux-
> samsung-...@vger.kernel.org; linux-...@lists.infradead.org
> Cc: Krzysztof Kozlowski 
> Subject: [PATCH 1/2] drm/exynos: MAINTAINERS: move Joonyoung Shim to
> credits
> 
> Emails to Joonyoung Shim bounce ("550 5.1.1 Recipient address rejected:
> User unknown"), so move him to credits file.
> 

Applied.

Thanks,
Inki Dae

> Signed-off-by: Krzysztof Kozlowski 
> ---
>  CREDITS | 4 
>  MAINTAINERS | 1 -
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/CREDITS b/CREDITS
> index 7e85a53b6a88..91a564c17012 100644
> --- a/CREDITS
> +++ b/CREDITS
> @@ -3491,6 +3491,10 @@ D: wd33c93 SCSI driver (linux-m68k)
>  S: San Jose, California
>  S: USA
> 
> +N: Joonyoung Shim
> +E: y0922.s...@samsung.com
> +D: Samsung Exynos DRM drivers
> +
>  N: Robert Siemer
>  E: robert.sie...@gmx.de
>  P: 2048/C99A4289 2F DC 17 2E 56 62 01 C8  3D F2 AC 09 F2 E5 DD EE
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 19875f60ebb1..d208bf3b6f11 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6695,7 +6695,6 @@ F:  drivers/gpu/drm/bridge/
> 
>  DRM DRIVERS FOR EXYNOS
>  M:   Inki Dae 
> -M:   Joonyoung Shim 
>  M:   Seung-Woo Kim 
>  M:   Kyungmin Park 
>  L:   dri-devel@lists.freedesktop.org
> --
> 2.34.1




[Bug 215618] vblank related lockup during start of SteamVR using Valve Index HMD

2022-06-29 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=215618

Konstantin Pereiaslov (per...@perk11.info) changed:

   What|Removed |Added

 CC||per...@perk11.info

--- Comment #3 from Konstantin Pereiaslov (per...@perk11.info) ---
Getting the same issue as the original post most times when starting SteamVR
with Valve Index connected.

Linux perk11-home 5.18.6-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Jun 22 14:16:20
UTC 2022 x86_64 GNU/Linux


Jun 29 22:38:01 perk11-home kernel: [drm:dm_vblank_get_counter [amdgpu]]
*ERROR* dc_stream_state is NULL for crtc '1'!
Jun 29 22:38:01 perk11-home kernel: [drm:dm_crtc_get_scanoutpos [amdgpu]]
*ERROR* dc_stream_state is NULL for crtc '1'!
Jun 29 22:38:01 perk11-home kernel: [drm:dm_vblank_get_counter [amdgpu]]
*ERROR* dc_stream_state is NULL for crtc '1'!
Jun 29 22:38:01 perk11-home kernel: [ cut here ]
Jun 29 22:38:01 perk11-home kernel: amdgpu :0a:00.0:
drm_WARN_ON_ONCE(drm_drv_uses_atomic_modeset(dev))
Jun 29 22:38:01 perk11-home kernel: WARNING: CPU: 0 PID: 24962 at
drivers/gpu/drm/drm_vblank.c:728
drm_crtc_vblank_helper_get_vblank_timestamp_internal+0x343/0x350
Jun 29 22:38:01 perk11-home kernel: Modules linked in: cdc_acm xt_REDIRECT
xt_nat xt_tcpudp veth xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink
xt_addrtype iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4
br_netfilter bridge stp>
Jun 29 22:38:01 perk11-home kernel:  gpu_sched crypto_simd drm_ttm_helper
cryptd ttm snd_timer rapl snd drm_dp_helper tpm_crb soundcore pcspkr tpm_tis
tpm_tis_core ccp tpm joydev rng_core pinctrl_amd mac_hid sp5100_tco wmi k10temp
i2c_piix4 acpi_cpufre>
Jun 29 22:38:01 perk11-home kernel: CPU: 0 PID: 24962 Comm: VulkanVblankThr
Tainted: G   OE 5.18.6-1-MANJARO #1
b31d9f0a4836337638fdda8256aa2395a26153d9
Jun 29 22:38:01 perk11-home kernel: Hardware name: Gigabyte Technology Co.,
Ltd. X570 AORUS ELITE/X570 AORUS ELITE, BIOS F37a 02/16/2022
Jun 29 22:38:01 perk11-home kernel: RIP:
0010:drm_crtc_vblank_helper_get_vblank_timestamp_internal+0x343/0x350
Jun 29 22:38:01 perk11-home kernel: Code: 48 8b 5f 50 48 85 db 75 03 48 8b 1f
e8 46 5b 01 00 48 c7 c1 10 9b 14 b8 48 89 da 48 c7 c7 0c a0 0b b8 48 89 c6 e8
59 4e 3e 00 <0f> 0b e9 c7 fd ff ff e8 f1 fa 43 00 90 f3 0f 1e fa 0f 1f 44 00 00
Jun 29 22:38:01 perk11-home kernel: RSP: 0018:ba908622bb98 EFLAGS: 00010086
Jun 29 22:38:01 perk11-home kernel: RAX:  RBX: 9ec78170b600
RCX: 0027
Jun 29 22:38:01 perk11-home kernel: RDX: 9ed67ea216a8 RSI: 0001
RDI: 9ed67ea216a0
Jun 29 22:38:01 perk11-home kernel: RBP: ba908622bc08 R08: 
R09: ba908622b9a8
Jun 29 22:38:01 perk11-home kernel: R10: 0003 R11: 9ed6bf3248a8
R12: ba908622bc68
Jun 29 22:38:01 perk11-home kernel: R13: c0ea51e0 R14: 0003
R15: 9ec7a0ab41d8
Jun 29 22:38:01 perk11-home kernel: FS:  7f4f18238640()
GS:9ed67ea0() knlGS:
Jun 29 22:38:01 perk11-home kernel: CS:  0010 DS:  ES:  CR0:
80050033
Jun 29 22:38:01 perk11-home kernel: CR2: 7f4eb4001278 CR3: 0001b7dc8000
CR4: 00350ef0
Jun 29 22:38:01 perk11-home kernel: Call Trace:
Jun 29 22:38:01 perk11-home kernel:  
Jun 29 22:38:01 perk11-home kernel:  drm_get_last_vbltimestamp+0xaa/0xc0
Jun 29 22:38:01 perk11-home kernel:  drm_update_vblank_count+0x8f/0x3a0
Jun 29 22:38:01 perk11-home kernel:  drm_vblank_enable+0x14b/0x180
Jun 29 22:38:01 perk11-home kernel:  drm_vblank_get+0x97/0xe0
Jun 29 22:38:01 perk11-home kernel:  drm_crtc_queue_sequence_ioctl+0xf9/0x2d0
Jun 29 22:38:01 perk11-home kernel:  ? drm_ioctl+0x250/0x410
Jun 29 22:38:01 perk11-home kernel:  ? drm_crtc_get_sequence_ioctl+0x1a0/0x1a0
Jun 29 22:38:01 perk11-home kernel:  drm_ioctl_kernel+0xca/0x170
Jun 29 22:38:01 perk11-home kernel:  drm_ioctl+0x22e/0x410
Jun 29 22:38:01 perk11-home kernel:  ? drm_crtc_get_sequence_ioctl+0x1a0/0x1a0
Jun 29 22:38:01 perk11-home kernel:  amdgpu_drm_ioctl+0x4e/0x80 [amdgpu
87a94d2005d4986ad8a825609f070d6f446ae712]
Jun 29 22:38:01 perk11-home kernel:  __x64_sys_ioctl+0x91/0xc0
Jun 29 22:38:01 perk11-home kernel:  do_syscall_64+0x5f/0x90
Jun 29 22:38:01 perk11-home kernel:  ? exc_page_fault+0x74/0x170
Jun 29 22:38:01 perk11-home kernel:  entry_SYSCALL_64_after_hwframe+0x44/0xae
Jun 29 22:38:01 perk11-home kernel: RIP: 0033:0x7f4f2f3077af
Jun 29 22:38:01 perk11-home kernel: Code: 00 48 89 44 24 18 31 c0 48 8d 44 24
60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00
00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 18 48 8b 44 24 18 64 48 2b 04 25 28 00 00
Jun 29 22:38:01 perk11-home kernel: RSP: 002b:7f4f18237a80 EFLAGS: 0246
ORIG_RAX: 0010
Jun 29 22:38:01 perk11-home kernel: RAX: ffda RBX: 
RCX: 

[PATCH 5/5] ASoC: amd: enable machine driver build for Jadeite platform

2022-06-29 Thread Vijendar Mukunda
Enable machine driver build for Jadeite platform using ES8336 Codec.

Signed-off-by: Vijendar Mukunda 
---
 sound/soc/amd/Kconfig  | 11 +++
 sound/soc/amd/Makefile |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig
index 1381aec23048..da0c3dc357cf 100644
--- a/sound/soc/amd/Kconfig
+++ b/sound/soc/amd/Kconfig
@@ -23,6 +23,17 @@ config SND_SOC_AMD_CZ_RT5645_MACH
help
 This option enables machine driver for rt5645.
 
+config SND_SOC_AMD_ST_ES8336_MACH
+   tristate "AMD ST support for ES8336"
+   select SND_SOC_ACPI
+   select SND_SOC_ES8316
+   depends on SND_SOC_AMD_ACP && I2C && ACPI
+   help
+This option enables machine driver for Jadeite platform
+using es8336 codec.
+Say m if you have such a device.
+If unsure select "N".
+
 config SND_SOC_AMD_ACP3x
tristate "AMD Audio Coprocessor-v3.x support"
depends on X86 && PCI
diff --git a/sound/soc/amd/Makefile b/sound/soc/amd/Makefile
index 4b1f77930a4a..8823f6f28611 100644
--- a/sound/soc/amd/Makefile
+++ b/sound/soc/amd/Makefile
@@ -2,12 +2,14 @@
 acp_audio_dma-objs := acp-pcm-dma.o
 snd-soc-acp-da7219mx98357-mach-objs := acp-da7219-max98357a.o
 snd-soc-acp-rt5645-mach-objs := acp-rt5645.o
+snd-soc-acp-es8336-mach-objs := acp-es8336.o
 snd-soc-acp-rt5682-mach-objs := acp3x-rt5682-max9836.o
 snd-acp-config-objs := acp-config.o
 
 obj-$(CONFIG_SND_SOC_AMD_ACP) += acp_audio_dma.o
 obj-$(CONFIG_SND_SOC_AMD_CZ_DA7219MX98357_MACH) += 
snd-soc-acp-da7219mx98357-mach.o
 obj-$(CONFIG_SND_SOC_AMD_CZ_RT5645_MACH) += snd-soc-acp-rt5645-mach.o
+obj-$(CONFIG_SND_SOC_AMD_ST_ES8336_MACH) += snd-soc-acp-es8336-mach.o
 obj-$(CONFIG_SND_SOC_AMD_ACP3x) += raven/
 obj-$(CONFIG_SND_SOC_AMD_RV_RT5682_MACH) += snd-soc-acp-rt5682-mach.o
 obj-$(CONFIG_SND_SOC_AMD_RENOIR) += renoir/
-- 
2.25.1



[PATCH 4/5] ASoC: amd: add Machine driver for Jadeite platform

2022-06-29 Thread Vijendar Mukunda
Add Machine driver for Jadeite platform which uses ES8336 codec.

Signed-off-by: Vijendar Mukunda 
---
 sound/soc/amd/acp-es8336.c | 333 +
 1 file changed, 333 insertions(+)
 create mode 100644 sound/soc/amd/acp-es8336.c

diff --git a/sound/soc/amd/acp-es8336.c b/sound/soc/amd/acp-es8336.c
new file mode 100644
index ..f703da71b5ab
--- /dev/null
+++ b/sound/soc/amd/acp-es8336.c
@@ -0,0 +1,333 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Machine driver for AMD Stoney platform using ES8336 Codec
+ *
+ * Copyright 2022 Advanced Micro Devices, Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../codecs/es8316.h"
+#include "acp.h"
+
+#define DUAL_CHANNEL   2
+#define ST_PLAT_CLK 2400
+#define DRV_NAME "acp2x_mach"
+#define ST_JADEITE 1
+#define ST_ES8336_GPIO_QUIRK 1
+
+static unsigned long acp2x_machine_id;
+static struct snd_soc_jack st_jack;
+struct device *codec_dev;
+struct gpio_desc *gpio_pa;
+
+static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int 
event)
+{
+   if (SND_SOC_DAPM_EVENT_ON(event))
+   gpiod_set_value_cansleep(gpio_pa, true);
+   else
+   gpiod_set_value_cansleep(gpio_pa, false);
+
+   return 0;
+}
+
+static struct snd_soc_jack_pin st_es8316_jack_pins[] = {
+   {
+   .pin= "Headphone",
+   .mask   = SND_JACK_HEADPHONE,
+   },
+   {
+   .pin= "Headset Mic",
+   .mask   = SND_JACK_MICROPHONE,
+   },
+};
+
+static int st_es8336_hw_params(struct snd_pcm_substream *substream,
+  struct snd_pcm_hw_params *params)
+{
+   int ret = 0;
+   struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+   struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+
+   ret = snd_soc_dai_set_sysclk(codec_dai, 0, params_rate(params) * 256, 
SND_SOC_CLOCK_IN);
+   if (ret < 0) {
+   dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret);
+   return ret;
+   }
+   return ret;
+}
+
+static int st_es8336_init(struct snd_soc_pcm_runtime *rtd)
+{
+   int ret;
+   struct snd_soc_card *card;
+   struct snd_soc_component *codec;
+
+   codec = asoc_rtd_to_codec(rtd, 0)->component;
+   card = rtd->card;
+
+   ret = snd_soc_card_jack_new_pins(card, "Headset", SND_JACK_HEADSET | 
SND_JACK_BTN_0,
+_jack, st_es8316_jack_pins,
+ARRAY_SIZE(st_es8316_jack_pins));
+   if (ret) {
+   dev_err(card->dev, "HP jack creation failed %d\n", ret);
+   return ret;
+   }
+   snd_jack_set_key(st_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
+   ret = snd_soc_component_set_jack(codec, _jack, NULL);
+   if (ret) {
+   dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
+   return ret;
+   }
+   return 0;
+}
+
+static const unsigned int st_channels[] = {
+   DUAL_CHANNEL,
+};
+
+static const unsigned int st_rates[] = {
+   48000,
+};
+
+static const struct snd_pcm_hw_constraint_list st_constraints_rates = {
+   .count = ARRAY_SIZE(st_rates),
+   .list  = st_rates,
+   .mask = 0,
+};
+
+static const struct snd_pcm_hw_constraint_list st_constraints_channels = {
+   .count = ARRAY_SIZE(st_channels),
+   .list = st_channels,
+   .mask = 0,
+};
+
+static int st_es8336_codec_startup(struct snd_pcm_substream *substream)
+{
+   struct snd_pcm_runtime *runtime;
+   struct snd_soc_pcm_runtime *rtd;
+   struct snd_soc_card *card;
+   struct acp_platform_info *machine;
+
+   runtime = substream->runtime;
+   rtd = asoc_substream_to_rtd(substream);
+   card = rtd->card;
+   machine = snd_soc_card_get_drvdata(card);
+   runtime->hw.channels_max = DUAL_CHANNEL;
+   snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
+  _constraints_channels);
+   snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+  _constraints_rates);
+
+   machine->play_i2s_instance = I2S_MICSP_INSTANCE;
+   machine->cap_i2s_instance = I2S_MICSP_INSTANCE;
+   machine->capture_channel = CAP_CHANNEL0;
+   return 0;
+}
+
+static const struct snd_soc_ops st_es8336_ops = {
+   .hw_params = st_es8336_hw_params,
+   .startup = st_es8336_codec_startup,
+};
+
+SND_SOC_DAILINK_DEF(designware1,
+   DAILINK_COMP_ARRAY(COMP_CPU("designware-i2s.2.auto")));
+SND_SOC_DAILINK_DEF(codec,
+   DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ESSX8336:00", "ES8316 
HiFi")));
+SND_SOC_DAILINK_DEF(platform,
+  

[PATCH 3/5] ASoC: amd: add I2S MICSP instance support

2022-06-29 Thread Vijendar Mukunda
Add I2S MICSP instance support for Stoney variant.

Signed-off-by: Vijendar Mukunda 
---
 sound/soc/amd/acp-pcm-dma.c | 50 +++--
 sound/soc/amd/acp.h | 13 ++
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index 1cd2e70a57df..198358d28ea9 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -433,6 +433,7 @@ static void acp_dma_start(void __iomem *acp_mmio, u16 
ch_num, bool is_circular)
case I2S_TO_ACP_DMA_CH_NUM:
case ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM:
case I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM:
+   case ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM:
dma_ctrl |= ACP_DMA_CNTL_0__DMAChIOCEn_MASK;
break;
default:
@@ -710,6 +711,13 @@ static irqreturn_t dma_irq_handler(int irq, void *arg)
  acp_mmio, mmACP_EXTERNAL_INTR_STAT);
}
 
+   if ((intr_flag & BIT(ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM)) != 0) {
+   valid_irq = true;
+   snd_pcm_period_elapsed(irq_data->play_i2s_micsp_stream);
+   acp_reg_write((intr_flag & 
BIT(ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM)) << 16,
+ acp_mmio, mmACP_EXTERNAL_INTR_STAT);
+   }
+
if ((intr_flag & BIT(ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM)) != 0) {
valid_irq = true;
snd_pcm_period_elapsed(irq_data->play_i2sbt_stream);
@@ -807,7 +815,8 @@ static int acp_dma_open(struct snd_soc_component *component,
 * stream is not closed
 */
if (!intr_data->play_i2ssp_stream && !intr_data->capture_i2ssp_stream &&
-   !intr_data->play_i2sbt_stream && !intr_data->capture_i2sbt_stream)
+   !intr_data->play_i2sbt_stream && !intr_data->capture_i2sbt_stream &&
+   !intr_data->play_i2s_micsp_stream)
acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
 
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -867,6 +876,9 @@ static int acp_dma_hw_params(struct snd_soc_component 
*component,
case I2S_BT_INSTANCE:
val |= ACP_I2S_BT_16BIT_RESOLUTION_EN;
break;
+   case I2S_MICSP_INSTANCE:
+   val |= ACP_I2S_MICSP_16BIT_RESOLUTION_EN;
+   break;
case I2S_SP_INSTANCE:
default:
val |= ACP_I2S_SP_16BIT_RESOLUTION_EN;
@@ -876,6 +888,7 @@ static int acp_dma_hw_params(struct snd_soc_component 
*component,
case I2S_BT_INSTANCE:
val |= ACP_I2S_BT_16BIT_RESOLUTION_EN;
break;
+   case I2S_MICSP_INSTANCE:
case I2S_SP_INSTANCE:
default:
val |= ACP_I2S_MIC_16BIT_RESOLUTION_EN;
@@ -901,6 +914,27 @@ static int acp_dma_hw_params(struct snd_soc_component 
*component,
mmACP_I2S_BT_TRANSMIT_BYTE_CNT_LOW;
adata->play_i2sbt_stream = substream;
break;
+   case I2S_MICSP_INSTANCE:
+   switch (adata->asic_type) {
+   case CHIP_STONEY:
+   rtd->pte_offset = ACP_ST_PLAYBACK_PTE_OFFSET;
+   break;
+   default:
+   rtd->pte_offset = ACP_PLAYBACK_PTE_OFFSET;
+   }
+   rtd->ch1 = SYSRAM_TO_ACP_MICSP_INSTANCE_CH_NUM;
+   rtd->ch2 = ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM;
+   rtd->sram_bank = ACP_SRAM_BANK_1_ADDRESS;
+   rtd->destination = TO_ACP_I2S_2;
+   rtd->dma_dscr_idx_1 = PLAYBACK_START_DMA_DESCR_CH4;
+   rtd->dma_dscr_idx_2 = PLAYBACK_START_DMA_DESCR_CH5;
+   rtd->byte_cnt_high_reg_offset =
+   mmACP_I2S_MICSP_TRANSMIT_BYTE_CNT_HIGH;
+   rtd->byte_cnt_low_reg_offset =
+   mmACP_I2S_MICSP_TRANSMIT_BYTE_CNT_LOW;
+
+   adata->play_i2s_micsp_stream = substream;
+   break;
case I2S_SP_INSTANCE:
default:
switch (adata->asic_type) {
@@ -939,6 +973,7 @@ static int acp_dma_hw_params(struct snd_soc_component 
*component,
rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_11;
adata->capture_i2sbt_stream = substream;
break;
+   case I2S_MICSP_INSTANCE:
case I2S_SP_INSTANCE:
default:

[PATCH 0/5] I2S driver changes for Jadeite platform

2022-06-29 Thread Vijendar Mukunda
Jadeite(JD) platform is Stoney APU varaint which uses I2S MICSP
instance and ES8336 Codec.
This patch series creates I2S platform devices for JD platform,
adds I2S MICSP instance support and Machine driver support

This patch set depends on:
--checkpatch warnings patch

--https://patchwork.kernel.org/project/alsa-devel/patch/20220627125834.481731-1-vijendar.muku...@amd.com/


Vijendar Mukunda (5):
  drm/amdgpu: add dmi check for jadeite platform
  drm/amdgpu: create I2S platform devices for Jadeite platform
  ASoC: amd: add I2S MICSP instance support
  ASoC: amd: add Machine driver for Jadeite platform
  ASoC: amd: enable machine driver build for Jadeite platform

 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 329 +++
 sound/soc/amd/Kconfig   |  11 +
 sound/soc/amd/Makefile  |   2 +
 sound/soc/amd/acp-es8336.c  | 333 
 sound/soc/amd/acp-pcm-dma.c |  50 +++-
 sound/soc/amd/acp.h |  13 +
 6 files changed, 627 insertions(+), 111 deletions(-)
 create mode 100644 sound/soc/amd/acp-es8336.c

-- 
2.25.1



[PATCH 2/5] drm/amdgpu: create I2S platform devices for Jadeite platform

2022-06-29 Thread Vijendar Mukunda
Jadeite platform uses I2S MICSP instance.
Create platform devices for DMA controller and I2S controller for
Jadeite platform.

Signed-off-by: Vijendar Mukunda 
Acked-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 293 +++-
 1 file changed, 184 insertions(+), 109 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
index af7b42056a89..d4b9fbc2654f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
@@ -266,125 +266,200 @@ static int acp_hw_init(void *handle)
adev->acp.acp_genpd->adev = adev;
 
pm_genpd_init(>acp.acp_genpd->gpd, NULL, false);
+   dmi_check_system(acp_quirk_table);
+   switch (acp_machine_id) {
+   case ST_JADEITE:
+   {
+   adev->acp.acp_cell = kcalloc(2, sizeof(struct mfd_cell),
+GFP_KERNEL);
+   if (!adev->acp.acp_cell) {
+   r = -ENOMEM;
+   goto failure;
+   }
 
-   adev->acp.acp_cell = kcalloc(ACP_DEVS, sizeof(struct mfd_cell), 
GFP_KERNEL);
-
-   if (!adev->acp.acp_cell) {
-   r = -ENOMEM;
-   goto failure;
-   }
-
-   adev->acp.acp_res = kcalloc(5, sizeof(struct resource), GFP_KERNEL);
-   if (!adev->acp.acp_res) {
-   r = -ENOMEM;
-   goto failure;
-   }
+   adev->acp.acp_res = kcalloc(3, sizeof(struct resource), 
GFP_KERNEL);
+   if (!adev->acp.acp_res) {
+   r = -ENOMEM;
+   goto failure;
+   }
 
-   i2s_pdata = kcalloc(3, sizeof(struct i2s_platform_data), GFP_KERNEL);
-   if (!i2s_pdata) {
-   r = -ENOMEM;
-   goto failure;
-   }
+   i2s_pdata = kcalloc(1, sizeof(struct i2s_platform_data), 
GFP_KERNEL);
+   if (!i2s_pdata) {
+   r = -ENOMEM;
+   goto failure;
+   }
 
-   switch (adev->asic_type) {
-   case CHIP_STONEY:
i2s_pdata[0].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
-   DW_I2S_QUIRK_16BIT_IDX_OVERRIDE;
+ DW_I2S_QUIRK_16BIT_IDX_OVERRIDE;
+   i2s_pdata[0].cap = DWC_I2S_PLAY | DWC_I2S_RECORD;
+   i2s_pdata[0].snd_rates = SNDRV_PCM_RATE_8000_96000;
+   i2s_pdata[0].i2s_reg_comp1 = ACP_I2S_COMP1_CAP_REG_OFFSET;
+   i2s_pdata[0].i2s_reg_comp2 = ACP_I2S_COMP2_CAP_REG_OFFSET;
+
+   adev->acp.acp_res[0].name = "acp2x_dma";
+   adev->acp.acp_res[0].flags = IORESOURCE_MEM;
+   adev->acp.acp_res[0].start = acp_base;
+   adev->acp.acp_res[0].end = acp_base + ACP_DMA_REGS_END;
+
+   adev->acp.acp_res[1].name = "acp2x_dw_i2s_play_cap";
+   adev->acp.acp_res[1].flags = IORESOURCE_MEM;
+   adev->acp.acp_res[1].start = acp_base + ACP_I2S_CAP_REGS_START;
+   adev->acp.acp_res[1].end = acp_base + ACP_I2S_CAP_REGS_END;
+
+   adev->acp.acp_res[2].name = "acp2x_dma_irq";
+   adev->acp.acp_res[2].flags = IORESOURCE_IRQ;
+   adev->acp.acp_res[2].start = amdgpu_irq_create_mapping(adev, 
162);
+   adev->acp.acp_res[2].end = adev->acp.acp_res[2].start;
+
+   adev->acp.acp_cell[0].name = "acp_audio_dma";
+   adev->acp.acp_cell[0].num_resources = 3;
+   adev->acp.acp_cell[0].resources = >acp.acp_res[0];
+   adev->acp.acp_cell[0].platform_data = >asic_type;
+   adev->acp.acp_cell[0].pdata_size = sizeof(adev->asic_type);
+
+   adev->acp.acp_cell[1].name = "designware-i2s";
+   adev->acp.acp_cell[1].num_resources = 1;
+   adev->acp.acp_cell[1].resources = >acp.acp_res[1];
+   adev->acp.acp_cell[1].platform_data = _pdata[0];
+   adev->acp.acp_cell[1].pdata_size = sizeof(struct 
i2s_platform_data);
+   r = mfd_add_hotplug_devices(adev->acp.parent, 
adev->acp.acp_cell, 2);
+   if (r)
+   goto failure;
+   r = device_for_each_child(adev->acp.parent, 
>acp.acp_genpd->gpd,
+ acp_genpd_add_device);
+   if (r)
+   goto failure;
break;
-   default:
-   i2s_pdata[0].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET;
}
-   i2s_pdata[0].cap = DWC_I2S_PLAY;
-   i2s_pdata[0].snd_rates = SNDRV_PCM_RATE_8000_96000;
-   i2s_pdata[0].i2s_reg_comp1 = ACP_I2S_COMP1_PLAY_REG_OFFSET;
-   i2s_pdata[0].i2s_reg_comp2 = ACP_I2S_COMP2_PLAY_REG_OFFSET;
-   switch (adev->asic_type) {
-   case CHIP_STONEY:
-   i2s_pdata[1].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
-   DW_I2S_QUIRK_COMP_PARAM1 |
- 

[PATCH 1/5] drm/amdgpu: add dmi check for jadeite platform

2022-06-29 Thread Vijendar Mukunda
DMI check is required to distinguish Jadeite platform from
Stoney base variant.
Add DMI check logic for Jadeite platform.

Signed-off-by: Vijendar Mukunda 
Acked-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 36 +
 1 file changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
index ba1605ff521f..af7b42056a89 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "amdgpu.h"
 #include "atom.h"
@@ -36,6 +38,7 @@
 
 #include "acp_gfx_if.h"
 
+#define ST_JADEITE 1
 #define ACP_TILE_ON_MASK   0x03
 #define ACP_TILE_OFF_MASK  0x02
 #define ACP_TILE_ON_RETAIN_REG_MASK0x1f
@@ -85,6 +88,8 @@
 #define ACP_DEVS   4
 #define ACP_SRC_ID 162
 
+static unsigned long acp_machine_id;
+
 enum {
ACP_TILE_P1 = 0,
ACP_TILE_P2,
@@ -184,6 +189,37 @@ static int acp_genpd_remove_device(struct device *dev, 
void *data)
return 0;
 }
 
+static int acp_quirk_cb(const struct dmi_system_id *id)
+{
+   acp_machine_id = ST_JADEITE;
+   return 1;
+}
+
+static const struct dmi_system_id acp_quirk_table[] = {
+   {
+   .callback = acp_quirk_cb,
+   .matches = {
+   DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMD"),
+   DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Jadeite"),
+   }
+   },
+   {
+   .callback = acp_quirk_cb,
+   .matches = {
+   DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "IP3 Technology 
CO.,Ltd."),
+   DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ASN1D"),
+   },
+   },
+   {
+   .callback = acp_quirk_cb,
+   .matches = {
+   DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Standard"),
+   DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ASN10"),
+   },
+   },
+   {}
+};
+
 /**
  * acp_hw_init - start and test ACP block
  *
-- 
2.25.1



Re: [Freedreno] [PATCH] drm/msm/dp: make eDP panel as the first connected connector

2022-06-29 Thread Abhinav Kumar




On 6/29/2022 6:57 PM, Rob Clark wrote:

On Wed, Jun 29, 2022 at 5:36 PM Doug Anderson  wrote:


Hi,

On Tue, Jun 28, 2022 at 1:14 PM Dmitry Baryshkov
 wrote:


On 28 June 2022 18:20:06 GMT+03:00, Kuogee Hsieh  
wrote:

Some userspace presumes that the first connected connector is the main
display, where it's supposed to display e.g. the login screen. For
laptops, this should be the main panel.

This patch call drm_helper_move_panel_connectors_to_head() after
drm_bridge_connector_init() to make sure eDP stay at head of
connected connector list. This fixes unexpected corruption happen
at eDP panel if eDP is not placed at head of connected connector
list.


The change itself is a good fix anyway. (And I'd ack it.) However I would like 
to understand why does it fix the corruption issue. What is we have eDP and 
DSI, with DSI ending up before the eDP? Would we see the issue?
Also could you please describe the mind of corruption you are observing?


I've spent a whole bunch of time poking at this and in the end my
conclusion is this:

1. The glitchyness seems to be a result of the Chrome OS userspace
somehow telling the kernel to do something wrong.

2. I believe (though I have no proof other than Kuogee's patch fixing
things) that the Chrome OS userspace is simply confused by the eDP
connector being second. This would imply that Kuogee's patch is
actually the right one.

3. It would be ideal if the Chrome OS userspace were fixed to handle
this, but it's an area of code that I've never looked at. It also
seems terribly low priority to fix since apparently other OSes have
similar problems (seems like this code was originally added by
RedHat?)


Specifically, I tested with a similar but "persistent" glitch that I
reproduced. The glitch Kuogee was digging into was a transitory glitch
on the eDP (internal) display when you plugged in a DP (external)
display. It would show up for a frame or two and then be fixed. I can
get a similar-looking glitch (vertical black and white bars) that
persists by doing these steps on a Chrome OS device (and Chrome OS
kernel):

a) Observe screen looks good.
b) Observe DP not connected.
c) Plug in DP
d) See transitory glitch on screen, then it all looks fine.
e) set_power_policy --ac_screen_dim_delay=5 --ac_screen_off_delay=10
f) Wait for screen to turn off
g) Unplug DP
h) Hit key on keyboard to wake device.
i) See glitchy.
j) Within 5 seconds: set_power_policy --ac_screen_dim_delay=5000
--ac_screen_off_delay=1

Once I'm in the persistent glitch:

* The "screenshot" command in Chrome OS shows corruption. Not exactly
black and white bars, but the image produced has distinct bands of
garbage.

* I can actually toggle between VT2 and the main screen (VT1). Note
that VT1/VT2 are not quite the normal Linux managed solution--I
believe they're handled by frecon. In any case, when I switch to VT2
it looks normal (I can see the login prompt). Then back to VT1 and the
vertical bars glitch. Back to VT2 and it's normal. Back to VT1 and the
glitch again. This implies (especially with the extra evidence of
screenshot) that the display controller hardware is all fine and that
it's the underlying data that's somehow messed up.


fwiw, from looking at this a bit w/ Doug, I think the "glitch" is
simply just an un-renderered buffer being interpreted by the display
controller as UBWC (because userspace tells it to)

BR,
-R


Acked and agree with the comments both of you have stated and looking at 
the corrupted buffers in the snapshot.


Hence,

Reviewed-by: Abhinav Kumar 




When I pick Kuogee's patch then this "persistent" glitch goes away
just like the transitory one does.

I'm going to go ahead and do:

Reviewed-by: Douglas Anderson 
Tested-by: Douglas Anderson 


Re: [PATCH] drm/msm/dp: make eDP panel as the first connected connector

2022-06-29 Thread Rob Clark
On Wed, Jun 29, 2022 at 5:36 PM Doug Anderson  wrote:
>
> Hi,
>
> On Tue, Jun 28, 2022 at 1:14 PM Dmitry Baryshkov
>  wrote:
> >
> > On 28 June 2022 18:20:06 GMT+03:00, Kuogee Hsieh  
> > wrote:
> > >Some userspace presumes that the first connected connector is the main
> > >display, where it's supposed to display e.g. the login screen. For
> > >laptops, this should be the main panel.
> > >
> > >This patch call drm_helper_move_panel_connectors_to_head() after
> > >drm_bridge_connector_init() to make sure eDP stay at head of
> > >connected connector list. This fixes unexpected corruption happen
> > >at eDP panel if eDP is not placed at head of connected connector
> > >list.
> >
> > The change itself is a good fix anyway. (And I'd ack it.) However I would 
> > like to understand why does it fix the corruption issue. What is we have 
> > eDP and DSI, with DSI ending up before the eDP? Would we see the issue?
> > Also could you please describe the mind of corruption you are observing?
>
> I've spent a whole bunch of time poking at this and in the end my
> conclusion is this:
>
> 1. The glitchyness seems to be a result of the Chrome OS userspace
> somehow telling the kernel to do something wrong.
>
> 2. I believe (though I have no proof other than Kuogee's patch fixing
> things) that the Chrome OS userspace is simply confused by the eDP
> connector being second. This would imply that Kuogee's patch is
> actually the right one.
>
> 3. It would be ideal if the Chrome OS userspace were fixed to handle
> this, but it's an area of code that I've never looked at. It also
> seems terribly low priority to fix since apparently other OSes have
> similar problems (seems like this code was originally added by
> RedHat?)
>
>
> Specifically, I tested with a similar but "persistent" glitch that I
> reproduced. The glitch Kuogee was digging into was a transitory glitch
> on the eDP (internal) display when you plugged in a DP (external)
> display. It would show up for a frame or two and then be fixed. I can
> get a similar-looking glitch (vertical black and white bars) that
> persists by doing these steps on a Chrome OS device (and Chrome OS
> kernel):
>
> a) Observe screen looks good.
> b) Observe DP not connected.
> c) Plug in DP
> d) See transitory glitch on screen, then it all looks fine.
> e) set_power_policy --ac_screen_dim_delay=5 --ac_screen_off_delay=10
> f) Wait for screen to turn off
> g) Unplug DP
> h) Hit key on keyboard to wake device.
> i) See glitchy.
> j) Within 5 seconds: set_power_policy --ac_screen_dim_delay=5000
> --ac_screen_off_delay=1
>
> Once I'm in the persistent glitch:
>
> * The "screenshot" command in Chrome OS shows corruption. Not exactly
> black and white bars, but the image produced has distinct bands of
> garbage.
>
> * I can actually toggle between VT2 and the main screen (VT1). Note
> that VT1/VT2 are not quite the normal Linux managed solution--I
> believe they're handled by frecon. In any case, when I switch to VT2
> it looks normal (I can see the login prompt). Then back to VT1 and the
> vertical bars glitch. Back to VT2 and it's normal. Back to VT1 and the
> glitch again. This implies (especially with the extra evidence of
> screenshot) that the display controller hardware is all fine and that
> it's the underlying data that's somehow messed up.

fwiw, from looking at this a bit w/ Doug, I think the "glitch" is
simply just an un-renderered buffer being interpreted by the display
controller as UBWC (because userspace tells it to)

BR,
-R

> When I pick Kuogee's patch then this "persistent" glitch goes away
> just like the transitory one does.
>
> I'm going to go ahead and do:
>
> Reviewed-by: Douglas Anderson 
> Tested-by: Douglas Anderson 


[PATCH v3 9/9] drm: selftest: convert drm_mm selftest to KUnit

2022-06-29 Thread Maíra Canal
From: Arthur Grillo 

Considering the current adoption of the KUnit framework, convert the
DRM mm selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Signed-off-by: Arthur Grillo 
Signed-off-by: Maíra Canal 
---
 Documentation/gpu/todo.rst|   11 -
 drivers/gpu/drm/Kconfig   |   20 -
 drivers/gpu/drm/Makefile  |1 -
 drivers/gpu/drm/selftests/Makefile|2 -
 drivers/gpu/drm/selftests/drm_mm_selftests.h  |   28 -
 drivers/gpu/drm/selftests/drm_selftest.c  |  109 --
 drivers/gpu/drm/selftests/drm_selftest.h  |   41 -
 drivers/gpu/drm/tests/Makefile|2 +-
 .../test-drm_mm.c => tests/drm_mm_test.c} | 1135 +++--
 9 files changed, 451 insertions(+), 898 deletions(-)
 delete mode 100644 drivers/gpu/drm/selftests/Makefile
 delete mode 100644 drivers/gpu/drm/selftests/drm_mm_selftests.h
 delete mode 100644 drivers/gpu/drm/selftests/drm_selftest.c
 delete mode 100644 drivers/gpu/drm/selftests/drm_selftest.h
 rename drivers/gpu/drm/{selftests/test-drm_mm.c => tests/drm_mm_test.c} (58%)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 513b20ccef1e..10bfb50908d1 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -617,17 +617,6 @@ Contact: Javier Martinez Canillas 
 
 Level: Intermediate
 
-Convert Kernel Selftests (kselftest) to KUnit tests when appropriate
-
-
-Many of the `Kselftest 
`_
-tests in DRM could be converted to Kunit tests instead, since that framework
-is more suitable for unit testing.
-
-Contact: Javier Martinez Canillas 
-
-Level: Starter
-
 Enable trinity for DRM
 --
 
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 06822ecf51c6..1c91e1e861a5 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -50,26 +50,6 @@ config DRM_DEBUG_MM
 
  If in doubt, say "N".
 
-config DRM_DEBUG_SELFTEST
-   tristate "kselftests for DRM"
-   depends on DRM
-   depends on DEBUG_KERNEL
-   select PRIME_NUMBERS
-   select DRM_DISPLAY_DP_HELPER
-   select DRM_DISPLAY_HELPER
-   select DRM_LIB_RANDOM
-   select DRM_KMS_HELPER
-   select DRM_BUDDY
-   select DRM_EXPORT_FOR_TESTS if m
-   default n
-   help
- This option provides kernel modules that can be used to run
- various selftests on parts of the DRM api. This option is not
- useful for distributions or general kernels, but only for kernel
- developers working on DRM and associated drivers.
-
- If in doubt, say "N".
-
 config DRM_KUNIT_TEST
tristate "KUnit tests for DRM" if !KUNIT_ALL_TESTS
depends on DRM && KUNIT
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index e7af358e6dda..25016dcab55e 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -75,7 +75,6 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
 # Drivers and the rest
 #
 
-obj-$(CONFIG_DRM_DEBUG_SELFTEST) += selftests/
 obj-$(CONFIG_DRM_KUNIT_TEST) += tests/
 
 obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o
diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
deleted file mode 100644
index a4ebecb8146b..
--- a/drivers/gpu/drm/selftests/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o
diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
b/drivers/gpu/drm/selftests/drm_mm_selftests.h
deleted file mode 100644
index 8c87c964176b..
--- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* List each unit test as selftest(name, function)
- *
- * The name is used as both an enum and expanded as igt__name to create
- * a module parameter. It must be unique and legal for a C identifier.
- *
- * Tests are executed in order by igt/drm_mm
- */
-selftest(sanitycheck, igt_sanitycheck) /* keep first (selfcheck for igt) */
-selftest(init, igt_init)
-selftest(debug, igt_debug)
-selftest(reserve, igt_reserve)
-selftest(insert, igt_insert)
-selftest(replace, igt_replace)
-selftest(insert_range, igt_insert_range)
-selftest(align, igt_align)
-selftest(frag, igt_frag)
-selftest(align32, igt_align32)
-selftest(align64, igt_align64)
-selftest(evict, igt_evict)
-selftest(evict_range, igt_evict_range)
-selftest(bottomup, igt_bottomup)
-selftest(lowest, igt_lowest)
-selftest(topdown, igt_topdown)
-selftest(highest, igt_highest)
-selftest(color, igt_color)
-selftest(color_evict, igt_color_evict)
-selftest(color_evict_range, igt_color_evict_range)
diff --git a/drivers/gpu/drm/selftests/drm_selftest.c 
b/drivers/gpu/drm/selftests/drm_selftest.c
deleted file mode 100644
index e29ed9faef5b..
--- 

[PATCH v3 8/9] drm: selftest: convert drm_buddy selftest to KUnit

2022-06-29 Thread Maíra Canal
Considering the current adoption of the KUnit framework, convert the
DRM buddy selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/selftests/Makefile|   2 +-
 .../gpu/drm/selftests/drm_buddy_selftests.h   |  15 -
 drivers/gpu/drm/selftests/test-drm_buddy.c| 994 --
 drivers/gpu/drm/tests/Makefile|   2 +-
 drivers/gpu/drm/tests/drm_buddy_test.c| 748 +
 5 files changed, 750 insertions(+), 1011 deletions(-)
 delete mode 100644 drivers/gpu/drm/selftests/drm_buddy_selftests.h
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_buddy.c
 create mode 100644 drivers/gpu/drm/tests/drm_buddy_test.c

diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index f7db628b60cb..a4ebecb8146b 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_buddy.o
+obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o
diff --git a/drivers/gpu/drm/selftests/drm_buddy_selftests.h 
b/drivers/gpu/drm/selftests/drm_buddy_selftests.h
deleted file mode 100644
index 455b756c4ae5..
--- a/drivers/gpu/drm/selftests/drm_buddy_selftests.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* List each unit test as selftest(name, function)
- *
- * The name is used as both an enum and expanded as igt__name to create
- * a module parameter. It must be unique and legal for a C identifier.
- *
- * Tests are executed in order by igt/drm_buddy
- */
-selftest(sanitycheck, igt_sanitycheck) /* keep first (selfcheck for igt) */
-selftest(buddy_alloc_limit, igt_buddy_alloc_limit)
-selftest(buddy_alloc_range, igt_buddy_alloc_range)
-selftest(buddy_alloc_optimistic, igt_buddy_alloc_optimistic)
-selftest(buddy_alloc_pessimistic, igt_buddy_alloc_pessimistic)
-selftest(buddy_alloc_smoke, igt_buddy_alloc_smoke)
-selftest(buddy_alloc_pathological, igt_buddy_alloc_pathological)
diff --git a/drivers/gpu/drm/selftests/test-drm_buddy.c 
b/drivers/gpu/drm/selftests/test-drm_buddy.c
deleted file mode 100644
index aca0c491040f..
--- a/drivers/gpu/drm/selftests/test-drm_buddy.c
+++ /dev/null
@@ -1,994 +0,0 @@
-// SPDX-License-Identifier: MIT
-/*
- * Copyright © 2019 Intel Corporation
- */
-
-#define pr_fmt(fmt) "drm_buddy: " fmt
-
-#include 
-#include 
-#include 
-
-#include 
-
-#include "../lib/drm_random.h"
-
-#define TESTS "drm_buddy_selftests.h"
-#include "drm_selftest.h"
-
-#define IGT_TIMEOUT(name__) \
-   unsigned long name__ = jiffies + MAX_SCHEDULE_TIMEOUT
-
-static unsigned int random_seed;
-
-static inline u64 get_size(int order, u64 chunk_size)
-{
-   return (1 << order) * chunk_size;
-}
-
-__printf(2, 3)
-static bool __igt_timeout(unsigned long timeout, const char *fmt, ...)
-{
-   va_list va;
-
-   if (!signal_pending(current)) {
-   cond_resched();
-   if (time_before(jiffies, timeout))
-   return false;
-   }
-
-   if (fmt) {
-   va_start(va, fmt);
-   vprintk(fmt, va);
-   va_end(va);
-   }
-
-   return true;
-}
-
-static inline const char *yesno(bool v)
-{
-   return v ? "yes" : "no";
-}
-
-static void __igt_dump_block(struct drm_buddy *mm,
-struct drm_buddy_block *block,
-bool buddy)
-{
-   pr_err("block info: header=%llx, state=%u, order=%d, offset=%llx 
size=%llx root=%s buddy=%s\n",
-  block->header,
-  drm_buddy_block_state(block),
-  drm_buddy_block_order(block),
-  drm_buddy_block_offset(block),
-  drm_buddy_block_size(mm, block),
-  yesno(!block->parent),
-  yesno(buddy));
-}
-
-static void igt_dump_block(struct drm_buddy *mm,
-  struct drm_buddy_block *block)
-{
-   struct drm_buddy_block *buddy;
-
-   __igt_dump_block(mm, block, false);
-
-   buddy = drm_get_buddy(block);
-   if (buddy)
-   __igt_dump_block(mm, buddy, true);
-}
-
-static int igt_check_block(struct drm_buddy *mm,
-  struct drm_buddy_block *block)
-{
-   struct drm_buddy_block *buddy;
-   unsigned int block_state;
-   u64 block_size;
-   u64 offset;
-   int err = 0;
-
-   block_state = drm_buddy_block_state(block);
-
-   if (block_state != DRM_BUDDY_ALLOCATED &&
-   block_state != DRM_BUDDY_FREE &&
-   block_state != DRM_BUDDY_SPLIT) {
-   pr_err("block state mismatch\n");
-   err = -EINVAL;
-   }
-
-   block_size = drm_buddy_block_size(mm, block);
-   offset = drm_buddy_block_offset(block);
-
-   if (block_size < mm->chunk_size) {
-   pr_err("block size smaller than min size\n");
-   

[PATCH v3 7/9] drm: selftest: convert drm_framebuffer selftest to KUnit

2022-06-29 Thread Maíra Canal
Considering the current adoption of the KUnit framework, convert the
DRM framebuffer selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/selftests/Makefile|  5 +--
 .../gpu/drm/selftests/drm_modeset_selftests.h |  9 --
 .../drm/selftests/test-drm_modeset_common.c   | 32 ---
 .../drm/selftests/test-drm_modeset_common.h   | 21 
 drivers/gpu/drm/tests/Makefile|  2 +-
 .../drm_framebuffer_test.c}   | 25 ++-
 6 files changed, 19 insertions(+), 75 deletions(-)
 delete mode 100644 drivers/gpu/drm/selftests/drm_modeset_selftests.h
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.c
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.h
 rename drivers/gpu/drm/{selftests/test-drm_framebuffer.c => 
tests/drm_framebuffer_test.c} (96%)

diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index 1539f55db9a7..f7db628b60cb 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,5 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-test-drm_modeset-y := test-drm_modeset_common.o test-drm_framebuffer.o
-
-obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o \
-   test-drm_buddy.o
+obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_buddy.o
diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h 
b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
deleted file mode 100644
index 40a29b8cf386..
--- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* List each unit test as selftest(name, function)
- *
- * The name is used as both an enum and expanded as igt__name to create
- * a module parameter. It must be unique and legal for a C identifier.
- *
- * Tests are executed in order by igt/drm_selftests_helper
- */
-selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create)
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.c 
b/drivers/gpu/drm/selftests/test-drm_modeset_common.c
deleted file mode 100644
index 2a7f93774006..
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Common file for modeset selftests.
- */
-
-#include 
-
-#include "test-drm_modeset_common.h"
-
-#define TESTS "drm_modeset_selftests.h"
-#include "drm_selftest.h"
-
-#include "drm_selftest.c"
-
-static int __init test_drm_modeset_init(void)
-{
-   int err;
-
-   err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL);
-
-   return err > 0 ? 0 : err;
-}
-
-static void __exit test_drm_modeset_exit(void)
-{
-}
-
-module_init(test_drm_modeset_init);
-module_exit(test_drm_modeset_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h 
b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
deleted file mode 100644
index 3feb2fea1a6b..
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef __TEST_DRM_MODESET_COMMON_H__
-#define __TEST_DRM_MODESET_COMMON_H__
-
-#include 
-#include 
-
-#define FAIL(test, msg, ...) \
-   do { \
-   if (test) { \
-   pr_err("%s/%u: " msg, __FUNCTION__, __LINE__, 
##__VA_ARGS__); \
-   return -EINVAL; \
-   } \
-   } while (0)
-
-#define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
-
-int igt_check_drm_framebuffer_create(void *ignored);
-
-#endif
diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile
index 5ffacd3eacf3..4cbfd9098d56 100644
--- a/drivers/gpu/drm/tests/Makefile
+++ b/drivers/gpu/drm/tests/Makefile
@@ -2,4 +2,4 @@
 
 obj-$(CONFIG_DRM_KUNIT_TEST) += drm_format_helper_test.o 
drm_damage_helper_test.o \
drm_cmdline_parser_test.o drm_rect_test.o drm_format_test.o 
drm_plane_helper_test.o \
-   drm_dp_mst_helper_test.o
+   drm_dp_mst_helper_test.o drm_framebuffer_test.o
diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c 
b/drivers/gpu/drm/tests/drm_framebuffer_test.c
similarity index 96%
rename from drivers/gpu/drm/selftests/test-drm_framebuffer.c
rename to drivers/gpu/drm/tests/drm_framebuffer_test.c
index f6d66285c5fc..a1b57703cd5a 100644
--- a/drivers/gpu/drm/selftests/test-drm_framebuffer.c
+++ b/drivers/gpu/drm/tests/drm_framebuffer_test.c
@@ -3,8 +3,7 @@
  * Test cases for the drm_framebuffer functions
  */
 
-#include 
-
+#include 
 #include 
 #include 
 #include 
@@ -12,8 +11,6 @@
 
 #include "../drm_crtc_internal.h"
 
-#include "test-drm_modeset_common.h"
-
 #define MIN_WIDTH 4
 #define MAX_WIDTH 4096
 #define MIN_HEIGHT 4
@@ -336,15 +333,27 @@ static int 

[PATCH v3 6/9] drm: selftest: convert drm_dp_mst_helper selftest to KUnit

2022-06-29 Thread Maíra Canal
Considering the current adoption of the KUnit framework, convert the
DRM DP MST helper selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Co-developed-by: Rubens Gomes Neto 
Signed-off-by: Rubens Gomes Neto 
Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/selftests/Makefile|  3 +-
 .../gpu/drm/selftests/drm_modeset_selftests.h |  2 -
 .../drm/selftests/test-drm_modeset_common.h   |  2 -
 drivers/gpu/drm/tests/Makefile|  3 +-
 .../drm_dp_mst_helper_test.c} | 84 ++-
 5 files changed, 49 insertions(+), 45 deletions(-)
 rename drivers/gpu/drm/{selftests/test-drm_dp_mst_helper.c => 
tests/drm_dp_mst_helper_test.c} (73%)

diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index 9e0ccb482841..1539f55db9a7 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-test-drm_modeset-y := test-drm_modeset_common.o test-drm_framebuffer.o \
-   test-drm_dp_mst_helper.o
+test-drm_modeset-y := test-drm_modeset_common.o test-drm_framebuffer.o
 
 obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o \
test-drm_buddy.o
diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h 
b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
index 22e467f6465a..40a29b8cf386 100644
--- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
@@ -7,5 +7,3 @@
  * Tests are executed in order by igt/drm_selftests_helper
  */
 selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create)
-selftest(dp_mst_calc_pbn_mode, igt_dp_mst_calc_pbn_mode)
-selftest(dp_mst_sideband_msg_req_decode, igt_dp_mst_sideband_msg_req_decode)
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h 
b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
index 790f3cf31f0d..3feb2fea1a6b 100644
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
+++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
@@ -17,7 +17,5 @@
 #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
 
 int igt_check_drm_framebuffer_create(void *ignored);
-int igt_dp_mst_calc_pbn_mode(void *ignored);
-int igt_dp_mst_sideband_msg_req_decode(void *ignored);
 
 #endif
diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile
index 4d44006a4f23..5ffacd3eacf3 100644
--- a/drivers/gpu/drm/tests/Makefile
+++ b/drivers/gpu/drm/tests/Makefile
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_DRM_KUNIT_TEST) += drm_format_helper_test.o 
drm_damage_helper_test.o \
-   drm_cmdline_parser_test.o drm_rect_test.o drm_format_test.o 
drm_plane_helper_test.o
+   drm_cmdline_parser_test.o drm_rect_test.o drm_format_test.o 
drm_plane_helper_test.o \
+   drm_dp_mst_helper_test.o
diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c 
b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
similarity index 73%
rename from drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
rename to drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
index 4caa9be900ac..62c6e0464b87 100644
--- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
+++ b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
@@ -5,15 +5,15 @@
 
 #define PREFIX_STR "[drm_dp_mst_helper]"
 
+#include 
 #include 
 
 #include 
 #include 
 
 #include "../display/drm_dp_mst_topology_internal.h"
-#include "test-drm_modeset_common.h"
 
-int igt_dp_mst_calc_pbn_mode(void *ignored)
+static void igt_dp_mst_calc_pbn_mode(struct kunit *test)
 {
int pbn, i;
const struct {
@@ -33,13 +33,11 @@ int igt_dp_mst_calc_pbn_mode(void *ignored)
pbn = drm_dp_calc_pbn_mode(test_params[i].rate,
   test_params[i].bpp,
   test_params[i].dsc);
-   FAIL(pbn != test_params[i].expected,
+   KUNIT_EXPECT_EQ_MSG(test, pbn, test_params[i].expected,
 "Expected PBN %d for clock %d bpp %d, got %d\n",
 test_params[i].expected, test_params[i].rate,
 test_params[i].bpp, pbn);
}
-
-   return 0;
 }
 
 static bool
@@ -176,66 +174,64 @@ sideband_msg_req_encode_decode(struct 
drm_dp_sideband_msg_req_body *in)
return result;
 }
 
-int igt_dp_mst_sideband_msg_req_decode(void *unused)
+static void igt_dp_mst_sideband_msg_req_decode(struct kunit *test)
 {
struct drm_dp_sideband_msg_req_body in = { 0 };
u8 data[] = { 0xff, 0x0, 0xdd };
int i;
 
-#define DO_TEST() FAIL_ON(!sideband_msg_req_encode_decode())
-
in.req_type = DP_ENUM_PATH_RESOURCES;
in.u.port_num.port_number = 5;
-   DO_TEST();
+   KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode());
 
in.req_type = DP_POWER_UP_PHY;
in.u.port_num.port_number 

[PATCH v3 5/9] drm: selftest: convert drm_plane_helper selftest to KUnit

2022-06-29 Thread Maíra Canal
Considering the current adoption of the KUnit framework, convert the
DRM plane helper selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Co-developed-by: Djakson C. G. Filho 
Signed-off-by: Djakson C. G. Filho 
Co-developed-by: Anderson Fraga 
Signed-off-by: Anderson Fraga 
Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/selftests/Makefile|   4 +-
 .../gpu/drm/selftests/drm_modeset_selftests.h |   1 -
 .../drm/selftests/test-drm_modeset_common.h   |   1 -
 drivers/gpu/drm/tests/Makefile|   2 +-
 .../drm_plane_helper_test.c}  | 103 ++
 5 files changed, 60 insertions(+), 51 deletions(-)
 rename drivers/gpu/drm/{selftests/test-drm_plane_helper.c => 
tests/drm_plane_helper_test.c} (62%)

diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index b7f252d886d0..9e0ccb482841 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
-test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \
-  test-drm_framebuffer.o test-drm_dp_mst_helper.o
+test-drm_modeset-y := test-drm_modeset_common.o test-drm_framebuffer.o \
+   test-drm_dp_mst_helper.o
 
 obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o \
test-drm_buddy.o
diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h 
b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
index 63061ef55eff..22e467f6465a 100644
--- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
@@ -6,7 +6,6 @@
  *
  * Tests are executed in order by igt/drm_selftests_helper
  */
-selftest(check_plane_state, igt_check_plane_state)
 selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create)
 selftest(dp_mst_calc_pbn_mode, igt_dp_mst_calc_pbn_mode)
 selftest(dp_mst_sideband_msg_req_decode, igt_dp_mst_sideband_msg_req_decode)
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h 
b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
index 5709d967a5c4..790f3cf31f0d 100644
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
+++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
@@ -16,7 +16,6 @@
 
 #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
 
-int igt_check_plane_state(void *ignored);
 int igt_check_drm_framebuffer_create(void *ignored);
 int igt_dp_mst_calc_pbn_mode(void *ignored);
 int igt_dp_mst_sideband_msg_req_decode(void *ignored);
diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile
index 1aa1627cb5e6..4d44006a4f23 100644
--- a/drivers/gpu/drm/tests/Makefile
+++ b/drivers/gpu/drm/tests/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_DRM_KUNIT_TEST) += drm_format_helper_test.o 
drm_damage_helper_test.o \
-   drm_cmdline_parser_test.o drm_rect_test.o drm_format_test.o
+   drm_cmdline_parser_test.o drm_rect_test.o drm_format_test.o 
drm_plane_helper_test.o
diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c 
b/drivers/gpu/drm/tests/drm_plane_helper_test.c
similarity index 62%
rename from drivers/gpu/drm/selftests/test-drm_plane_helper.c
rename to drivers/gpu/drm/tests/drm_plane_helper_test.c
index 64e8938ab194..7f27f1fce373 100644
--- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c
+++ b/drivers/gpu/drm/tests/drm_plane_helper_test.c
@@ -3,15 +3,12 @@
  * Test cases for the drm_plane_helper functions
  */
 
-#define pr_fmt(fmt) "drm_plane_helper: " fmt
-
+#include 
 #include 
 #include 
 #include 
 #include 
 
-#include "test-drm_modeset_common.h"
-
 static void set_src(struct drm_plane_state *plane_state,
unsigned src_x, unsigned src_y,
unsigned src_w, unsigned src_h)
@@ -74,7 +71,7 @@ static bool check_crtc_eq(struct drm_plane_state *plane_state,
return true;
 }
 
-int igt_check_plane_state(void *ignored)
+static void igt_check_plane_state(struct kunit *test)
 {
int ret;
 
@@ -109,10 +106,10 @@ int igt_check_plane_state(void *ignored)
  DRM_PLANE_HELPER_NO_SCALING,
  DRM_PLANE_HELPER_NO_SCALING,
  false, false);
-   FAIL(ret < 0, "Simple clipping check should pass\n");
-   FAIL_ON(!plane_state.visible);
-   FAIL_ON(!check_src_eq(_state, 0, 0, 1024 << 16, 768 << 16));
-   FAIL_ON(!check_crtc_eq(_state, 0, 0, 1024, 768));
+   KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Simple clipping check should 
pass\n");
+   KUNIT_EXPECT_TRUE(test, plane_state.visible);
+   KUNIT_EXPECT_TRUE(test, check_src_eq(_state, 0, 0, 1024 << 16, 
768 << 16));
+   KUNIT_EXPECT_TRUE(test, check_crtc_eq(_state, 0, 0, 1024, 768));
 
/* Rotated clipping + reflection, no 

[PATCH v3 4/9] drm: selftest: convert drm_format selftest to KUnit

2022-06-29 Thread Maíra Canal
Considering the current adoption of the KUnit framework, convert the
DRM format selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/selftests/Makefile|   3 +-
 .../gpu/drm/selftests/drm_modeset_selftests.h |   3 -
 drivers/gpu/drm/selftests/test-drm_format.c   | 280 -
 .../drm/selftests/test-drm_modeset_common.h   |   3 -
 drivers/gpu/drm/tests/Makefile|   2 +-
 drivers/gpu/drm/tests/drm_format_test.c   | 284 ++
 6 files changed, 286 insertions(+), 289 deletions(-)
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_format.c
 create mode 100644 drivers/gpu/drm/tests/drm_format_test.c

diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index 8a794914e328..b7f252d886d0 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \
-  test-drm_format.o test-drm_framebuffer.o \
- test-drm_dp_mst_helper.o
+  test-drm_framebuffer.o test-drm_dp_mst_helper.o
 
 obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o \
test-drm_buddy.o
diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h 
b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
index a3ca90307364..63061ef55eff 100644
--- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
@@ -7,9 +7,6 @@
  * Tests are executed in order by igt/drm_selftests_helper
  */
 selftest(check_plane_state, igt_check_plane_state)
-selftest(check_drm_format_block_width, igt_check_drm_format_block_width)
-selftest(check_drm_format_block_height, igt_check_drm_format_block_height)
-selftest(check_drm_format_min_pitch, igt_check_drm_format_min_pitch)
 selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create)
 selftest(dp_mst_calc_pbn_mode, igt_dp_mst_calc_pbn_mode)
 selftest(dp_mst_sideband_msg_req_decode, igt_dp_mst_sideband_msg_req_decode)
diff --git a/drivers/gpu/drm/selftests/test-drm_format.c 
b/drivers/gpu/drm/selftests/test-drm_format.c
deleted file mode 100644
index c5e212afa27a..
--- a/drivers/gpu/drm/selftests/test-drm_format.c
+++ /dev/null
@@ -1,280 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Test cases for the drm_format functions
- */
-
-#define pr_fmt(fmt) "drm_format: " fmt
-
-#include 
-#include 
-
-#include 
-
-#include "test-drm_modeset_common.h"
-
-int igt_check_drm_format_block_width(void *ignored)
-{
-   const struct drm_format_info *info = NULL;
-
-   /* Test invalid arguments */
-   FAIL_ON(drm_format_info_block_width(info, 0) != 0);
-   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
-   FAIL_ON(drm_format_info_block_width(info, 1) != 0);
-
-   /* Test 1 plane format */
-   info = drm_format_info(DRM_FORMAT_XRGB);
-   FAIL_ON(!info);
-   FAIL_ON(drm_format_info_block_width(info, 0) != 1);
-   FAIL_ON(drm_format_info_block_width(info, 1) != 0);
-   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
-
-   /* Test 2 planes format */
-   info = drm_format_info(DRM_FORMAT_NV12);
-   FAIL_ON(!info);
-   FAIL_ON(drm_format_info_block_width(info, 0) != 1);
-   FAIL_ON(drm_format_info_block_width(info, 1) != 1);
-   FAIL_ON(drm_format_info_block_width(info, 2) != 0);
-   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
-
-   /* Test 3 planes format */
-   info = drm_format_info(DRM_FORMAT_YUV422);
-   FAIL_ON(!info);
-   FAIL_ON(drm_format_info_block_width(info, 0) != 1);
-   FAIL_ON(drm_format_info_block_width(info, 1) != 1);
-   FAIL_ON(drm_format_info_block_width(info, 2) != 1);
-   FAIL_ON(drm_format_info_block_width(info, 3) != 0);
-   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
-
-   /* Test a tiled format */
-   info = drm_format_info(DRM_FORMAT_X0L0);
-   FAIL_ON(!info);
-   FAIL_ON(drm_format_info_block_width(info, 0) != 2);
-   FAIL_ON(drm_format_info_block_width(info, 1) != 0);
-   FAIL_ON(drm_format_info_block_width(info, -1) != 0);
-
-   return 0;
-}
-
-int igt_check_drm_format_block_height(void *ignored)
-{
-   const struct drm_format_info *info = NULL;
-
-   /* Test invalid arguments */
-   FAIL_ON(drm_format_info_block_height(info, 0) != 0);
-   FAIL_ON(drm_format_info_block_height(info, -1) != 0);
-   FAIL_ON(drm_format_info_block_height(info, 1) != 0);
-
-   /* Test 1 plane format */
-   info = drm_format_info(DRM_FORMAT_XRGB);
-   FAIL_ON(!info);
-   FAIL_ON(drm_format_info_block_height(info, 0) != 1);
-   FAIL_ON(drm_format_info_block_height(info, 1) != 0);
-   FAIL_ON(drm_format_info_block_height(info, -1) != 0);
-

[PATCH v3 3/9] drm: selftest: convert drm_rect selftest to KUnit

2022-06-29 Thread Maíra Canal
Considering the current adoption of the KUnit framework, convert the
DRM rect selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Co-developed-by: Carlos Veras 
Signed-off-by: Carlos Veras 
Co-developed-by: Matheus Vieira 
Signed-off-by: Matheus Vieira 
Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/selftests/Makefile|   2 +-
 .../gpu/drm/selftests/drm_modeset_selftests.h |   4 -
 .../drm/selftests/test-drm_modeset_common.h   |   4 -
 drivers/gpu/drm/tests/Makefile|   2 +-
 .../test-drm_rect.c => tests/drm_rect_test.c} | 124 +-
 5 files changed, 67 insertions(+), 69 deletions(-)
 rename drivers/gpu/drm/{selftests/test-drm_rect.c => tests/drm_rect_test.c} 
(53%)

diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index 8633bb9ea717..8a794914e328 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \
   test-drm_format.o test-drm_framebuffer.o \
- test-drm_dp_mst_helper.o test-drm_rect.o
+ test-drm_dp_mst_helper.o
 
 obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o \
test-drm_buddy.o
diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h 
b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
index 4787b3b70709..a3ca90307364 100644
--- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
@@ -6,10 +6,6 @@
  *
  * Tests are executed in order by igt/drm_selftests_helper
  */
-selftest(drm_rect_clip_scaled_div_by_zero, 
igt_drm_rect_clip_scaled_div_by_zero)
-selftest(drm_rect_clip_scaled_not_clipped, 
igt_drm_rect_clip_scaled_not_clipped)
-selftest(drm_rect_clip_scaled_clipped, igt_drm_rect_clip_scaled_clipped)
-selftest(drm_rect_clip_scaled_signed_vs_unsigned, 
igt_drm_rect_clip_scaled_signed_vs_unsigned)
 selftest(check_plane_state, igt_check_plane_state)
 selftest(check_drm_format_block_width, igt_check_drm_format_block_width)
 selftest(check_drm_format_block_height, igt_check_drm_format_block_height)
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h 
b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
index c29354e59cec..42a10d7da51c 100644
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
+++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
@@ -16,10 +16,6 @@
 
 #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
 
-int igt_drm_rect_clip_scaled_div_by_zero(void *ignored);
-int igt_drm_rect_clip_scaled_not_clipped(void *ignored);
-int igt_drm_rect_clip_scaled_clipped(void *ignored);
-int igt_drm_rect_clip_scaled_signed_vs_unsigned(void *ignored);
 int igt_check_plane_state(void *ignored);
 int igt_check_drm_format_block_width(void *ignored);
 int igt_check_drm_format_block_height(void *ignored);
diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile
index b3e73d674c67..f2eced30a955 100644
--- a/drivers/gpu/drm/tests/Makefile
+++ b/drivers/gpu/drm/tests/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_DRM_KUNIT_TEST) += drm_format_helper_test.o 
drm_damage_helper_test.o \
-   drm_cmdline_parser_test.o
+   drm_cmdline_parser_test.o drm_rect_test.o
diff --git a/drivers/gpu/drm/selftests/test-drm_rect.c 
b/drivers/gpu/drm/tests/drm_rect_test.c
similarity index 53%
rename from drivers/gpu/drm/selftests/test-drm_rect.c
rename to drivers/gpu/drm/tests/drm_rect_test.c
index 3a5ff38321f4..314dab502e7e 100644
--- a/drivers/gpu/drm/selftests/test-drm_rect.c
+++ b/drivers/gpu/drm/tests/drm_rect_test.c
@@ -3,15 +3,10 @@
  * Test cases for the drm_rect functions
  */
 
-#define pr_fmt(fmt) "drm_rect: " fmt
-
-#include 
-
+#include 
 #include 
 
-#include "test-drm_modeset_common.h"
-
-int igt_drm_rect_clip_scaled_div_by_zero(void *ignored)
+static void igt_drm_rect_clip_scaled_div_by_zero(struct kunit *test)
 {
struct drm_rect src, dst, clip;
bool visible;
@@ -24,20 +19,20 @@ int igt_drm_rect_clip_scaled_div_by_zero(void *ignored)
drm_rect_init(, 0, 0, 0, 0);
drm_rect_init(, 1, 1, 1, 1);
visible = drm_rect_clip_scaled(, , );
-   FAIL(visible, "Destination not be visible\n");
-   FAIL(drm_rect_visible(), "Source should not be visible\n");
+
+   KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination not be visible\n");
+   KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(), "Source should not 
be visible\n");
 
drm_rect_init(, 0, 0, 0, 0);
drm_rect_init(, 3, 3, 0, 0);
drm_rect_init(, 1, 1, 1, 1);
visible = drm_rect_clip_scaled(, , );
-   FAIL(visible, "Destination not be visible\n");
-   FAIL(drm_rect_visible(), "Source should not be visible\n");
 
-   return 0;
+   

[PATCH v3 2/9] drm: selftest: convert drm_cmdline_parser selftest to KUnit

2022-06-29 Thread Maíra Canal
Considering the current adoption of the KUnit framework, convert the
DRM cmdline parser selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Co-developed-by: Arthur Grillo 
Signed-off-by: Arthur Grillo 
Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/selftests/Makefile|2 +-
 .../gpu/drm/selftests/drm_cmdline_selftests.h |   68 -
 .../drm/selftests/test-drm_cmdline_parser.c   | 1141 -
 drivers/gpu/drm/tests/Makefile|3 +-
 .../gpu/drm/tests/drm_cmdline_parser_test.c   | 1078 
 5 files changed, 1081 insertions(+), 1211 deletions(-)
 delete mode 100644 drivers/gpu/drm/selftests/drm_cmdline_selftests.h
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
 create mode 100644 drivers/gpu/drm/tests/drm_cmdline_parser_test.c

diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index 7a1a732e0a1b..8633bb9ea717 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -3,5 +3,5 @@ test-drm_modeset-y := test-drm_modeset_common.o 
test-drm_plane_helper.o \
   test-drm_format.o test-drm_framebuffer.o \
  test-drm_dp_mst_helper.o test-drm_rect.o
 
-obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o 
test-drm_cmdline_parser.o \
+obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o \
test-drm_buddy.o
diff --git a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h 
b/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
deleted file mode 100644
index 29e367db6118..
--- a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* List each unit test as selftest(function)
- *
- * The name is used as both an enum and expanded as igt__name to create
- * a module parameter. It must be unique and legal for a C identifier.
- *
- * Tests are executed in order by igt/drm_mm
- */
-
-#define cmdline_test(test) selftest(test, test)
-
-cmdline_test(drm_cmdline_test_force_d_only)
-cmdline_test(drm_cmdline_test_force_D_only_dvi)
-cmdline_test(drm_cmdline_test_force_D_only_hdmi)
-cmdline_test(drm_cmdline_test_force_D_only_not_digital)
-cmdline_test(drm_cmdline_test_force_e_only)
-cmdline_test(drm_cmdline_test_margin_only)
-cmdline_test(drm_cmdline_test_interlace_only)
-cmdline_test(drm_cmdline_test_res)
-cmdline_test(drm_cmdline_test_res_missing_x)
-cmdline_test(drm_cmdline_test_res_missing_y)
-cmdline_test(drm_cmdline_test_res_bad_y)
-cmdline_test(drm_cmdline_test_res_missing_y_bpp)
-cmdline_test(drm_cmdline_test_res_vesa)
-cmdline_test(drm_cmdline_test_res_vesa_rblank)
-cmdline_test(drm_cmdline_test_res_rblank)
-cmdline_test(drm_cmdline_test_res_bpp)
-cmdline_test(drm_cmdline_test_res_bad_bpp)
-cmdline_test(drm_cmdline_test_res_refresh)
-cmdline_test(drm_cmdline_test_res_bad_refresh)
-cmdline_test(drm_cmdline_test_res_bpp_refresh)
-cmdline_test(drm_cmdline_test_res_bpp_refresh_interlaced)
-cmdline_test(drm_cmdline_test_res_bpp_refresh_margins)
-cmdline_test(drm_cmdline_test_res_bpp_refresh_force_off)
-cmdline_test(drm_cmdline_test_res_bpp_refresh_force_on_off)
-cmdline_test(drm_cmdline_test_res_bpp_refresh_force_on)
-cmdline_test(drm_cmdline_test_res_bpp_refresh_force_on_analog)
-cmdline_test(drm_cmdline_test_res_bpp_refresh_force_on_digital)
-cmdline_test(drm_cmdline_test_res_bpp_refresh_interlaced_margins_force_on)
-cmdline_test(drm_cmdline_test_res_margins_force_on)
-cmdline_test(drm_cmdline_test_res_vesa_margins)
-cmdline_test(drm_cmdline_test_res_invalid_mode)
-cmdline_test(drm_cmdline_test_res_bpp_wrong_place_mode)
-cmdline_test(drm_cmdline_test_name)
-cmdline_test(drm_cmdline_test_name_bpp)
-cmdline_test(drm_cmdline_test_name_refresh)
-cmdline_test(drm_cmdline_test_name_bpp_refresh)
-cmdline_test(drm_cmdline_test_name_refresh_wrong_mode)
-cmdline_test(drm_cmdline_test_name_refresh_invalid_mode)
-cmdline_test(drm_cmdline_test_name_option)
-cmdline_test(drm_cmdline_test_name_bpp_option)
-cmdline_test(drm_cmdline_test_rotate_0)
-cmdline_test(drm_cmdline_test_rotate_90)
-cmdline_test(drm_cmdline_test_rotate_180)
-cmdline_test(drm_cmdline_test_rotate_270)
-cmdline_test(drm_cmdline_test_rotate_multiple)
-cmdline_test(drm_cmdline_test_rotate_invalid_val)
-cmdline_test(drm_cmdline_test_rotate_truncated)
-cmdline_test(drm_cmdline_test_hmirror)
-cmdline_test(drm_cmdline_test_vmirror)
-cmdline_test(drm_cmdline_test_margin_options)
-cmdline_test(drm_cmdline_test_multiple_options)
-cmdline_test(drm_cmdline_test_invalid_option)
-cmdline_test(drm_cmdline_test_bpp_extra_and_option)
-cmdline_test(drm_cmdline_test_extra_and_option)
-cmdline_test(drm_cmdline_test_freestanding_options)
-cmdline_test(drm_cmdline_test_freestanding_force_e_and_options)
-cmdline_test(drm_cmdline_test_panel_orientation)
diff --git a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c 

[PATCH v3 1/9] drm: selftest: convert drm_damage_helper selftest to KUnit

2022-06-29 Thread Maíra Canal
Considering the current adoption of the KUnit framework, convert the
DRM damage helper selftest to the KUnit API.

Acked-by: Daniel Latypov 
Tested-by: David Gow 
Co-developed-by: Arthur Grillo 
Signed-off-by: Arthur Grillo 
Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/Kconfig   |   8 +-
 drivers/gpu/drm/selftests/Makefile|   3 +-
 .../gpu/drm/selftests/drm_modeset_selftests.h |  21 -
 .../drm/selftests/test-drm_damage_helper.c| 668 --
 .../drm/selftests/test-drm_modeset_common.h   |  21 -
 drivers/gpu/drm/tests/Makefile|   2 +-
 .../gpu/drm/tests/drm_damage_helper_test.c| 634 +
 7 files changed, 643 insertions(+), 714 deletions(-)
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_damage_helper.c
 create mode 100644 drivers/gpu/drm/tests/drm_damage_helper_test.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 6c2256e8474b..06822ecf51c6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -72,8 +72,14 @@ config DRM_DEBUG_SELFTEST
 
 config DRM_KUNIT_TEST
tristate "KUnit tests for DRM" if !KUNIT_ALL_TESTS
-   depends on DRM && KUNIT=y
+   depends on DRM && KUNIT
+   select PRIME_NUMBERS
+   select DRM_DISPLAY_DP_HELPER
+   select DRM_DISPLAY_HELPER
+   select DRM_LIB_RANDOM
select DRM_KMS_HELPER
+   select DRM_BUDDY
+   select DRM_EXPORT_FOR_TESTS if m
default KUNIT_ALL_TESTS
help
  This builds unit tests for DRM. This option is not useful for
diff --git a/drivers/gpu/drm/selftests/Makefile 
b/drivers/gpu/drm/selftests/Makefile
index 5ba5f9138c95..7a1a732e0a1b 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,8 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \
   test-drm_format.o test-drm_framebuffer.o \
- test-drm_damage_helper.o test-drm_dp_mst_helper.o \
- test-drm_rect.o
+ test-drm_dp_mst_helper.o test-drm_rect.o
 
 obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o 
test-drm_cmdline_parser.o \
test-drm_buddy.o
diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h 
b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
index 782e285ca383..4787b3b70709 100644
--- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
@@ -15,26 +15,5 @@ selftest(check_drm_format_block_width, 
igt_check_drm_format_block_width)
 selftest(check_drm_format_block_height, igt_check_drm_format_block_height)
 selftest(check_drm_format_min_pitch, igt_check_drm_format_min_pitch)
 selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create)
-selftest(damage_iter_no_damage, igt_damage_iter_no_damage)
-selftest(damage_iter_no_damage_fractional_src, 
igt_damage_iter_no_damage_fractional_src)
-selftest(damage_iter_no_damage_src_moved, igt_damage_iter_no_damage_src_moved)
-selftest(damage_iter_no_damage_fractional_src_moved, 
igt_damage_iter_no_damage_fractional_src_moved)
-selftest(damage_iter_no_damage_not_visible, 
igt_damage_iter_no_damage_not_visible)
-selftest(damage_iter_no_damage_no_crtc, igt_damage_iter_no_damage_no_crtc)
-selftest(damage_iter_no_damage_no_fb, igt_damage_iter_no_damage_no_fb)
-selftest(damage_iter_simple_damage, igt_damage_iter_simple_damage)
-selftest(damage_iter_single_damage, igt_damage_iter_single_damage)
-selftest(damage_iter_single_damage_intersect_src, 
igt_damage_iter_single_damage_intersect_src)
-selftest(damage_iter_single_damage_outside_src, 
igt_damage_iter_single_damage_outside_src)
-selftest(damage_iter_single_damage_fractional_src, 
igt_damage_iter_single_damage_fractional_src)
-selftest(damage_iter_single_damage_intersect_fractional_src, 
igt_damage_iter_single_damage_intersect_fractional_src)
-selftest(damage_iter_single_damage_outside_fractional_src, 
igt_damage_iter_single_damage_outside_fractional_src)
-selftest(damage_iter_single_damage_src_moved, 
igt_damage_iter_single_damage_src_moved)
-selftest(damage_iter_single_damage_fractional_src_moved, 
igt_damage_iter_single_damage_fractional_src_moved)
-selftest(damage_iter_damage, igt_damage_iter_damage)
-selftest(damage_iter_damage_one_intersect, 
igt_damage_iter_damage_one_intersect)
-selftest(damage_iter_damage_one_outside, igt_damage_iter_damage_one_outside)
-selftest(damage_iter_damage_src_moved, igt_damage_iter_damage_src_moved)
-selftest(damage_iter_damage_not_visible, igt_damage_iter_damage_not_visible)
 selftest(dp_mst_calc_pbn_mode, igt_dp_mst_calc_pbn_mode)
 selftest(dp_mst_sideband_msg_req_decode, igt_dp_mst_sideband_msg_req_decode)
diff --git a/drivers/gpu/drm/selftests/test-drm_damage_helper.c 
b/drivers/gpu/drm/selftests/test-drm_damage_helper.c
deleted file mode 100644
index 816e1464a98f..
--- 

[PATCH v3 0/9] drm: selftest: Convert to KUnit

2022-06-29 Thread Maíra Canal
Hi everyone,

Here is the v3 of the conversion of selftests to KUnit. Since the v2, there
have been minor fixes. drm_format_test received the biggest change: the
KUNIT_EXPECT_FALSE and KUNIT_EXPECT_TRUE macros were changed to KUNIT_EXPECT_EQ,
as suggested by Daniel.

Most of all, the patches were rebased on top of the recently applied patches
for drm_format_helper tests (8f456104915f), in order to avoid conflicts when
applying the tests.

Thanks for your attention and any feedback is welcomed!

Best Regards,
- Maíra Canal

v1 -> v2: 
https://lore.kernel.org/dri-devel/20220615135824.15522-1-maira.ca...@usp.br/T/

- The suites not longer end in _tests (David Gow).
- Remove the TODO entry involving the conversion of selftests to KUnit (Javier
Martinez Canillas).
- Change the filenames to match the documentation: use *_test.c (Javier Martinez
Canillas).
- Add MODULE_LICENSE to all tests (kernel test robot).
- Make use of a generic symbol to group all tests - DRM_KUNIT_TEST (Javier
Martinez Canillas).
- Add .kunitconfig on the first patch (it was on the second patch of the 
series).
- Straightforward conversion of the drm_cmdline_parser tests without functional
changes (Shuah Khan).
- Add David's Tested-by tags.

v2 -> v3: 
https://lore.kernel.org/dri-devel/20220621200926.257002-1-maira.ca...@usp.br/

- Rebase it on top of the drm-misc-next with drm_format_helper KUnit tests.
- Change KUNIT_EXPECT_FALSE to KUNIT_EXPECT_EQ on drm_format_test (Daniel 
Latypov).
- Add Daniel's Acked-by tag.

Arthur Grillo (1):
  drm: selftest: convert drm_mm selftest to KUnit

Maíra Canal (8):
  drm: selftest: convert drm_damage_helper selftest to KUnit
  drm: selftest: convert drm_cmdline_parser selftest to KUnit
  drm: selftest: convert drm_rect selftest to KUnit
  drm: selftest: convert drm_format selftest to KUnit
  drm: selftest: convert drm_plane_helper selftest to KUnit
  drm: selftest: convert drm_dp_mst_helper selftest to KUnit
  drm: selftest: convert drm_framebuffer selftest to KUnit
  drm: selftest: convert drm_buddy selftest to KUnit

 Documentation/gpu/todo.rst|   11 -
 drivers/gpu/drm/Kconfig   |   20 +-
 drivers/gpu/drm/Makefile  |1 -
 drivers/gpu/drm/selftests/Makefile|8 -
 .../gpu/drm/selftests/drm_buddy_selftests.h   |   15 -
 .../gpu/drm/selftests/drm_cmdline_selftests.h |   68 -
 drivers/gpu/drm/selftests/drm_mm_selftests.h  |   28 -
 .../gpu/drm/selftests/drm_modeset_selftests.h |   40 -
 drivers/gpu/drm/selftests/drm_selftest.c  |  109 --
 drivers/gpu/drm/selftests/drm_selftest.h  |   41 -
 drivers/gpu/drm/selftests/test-drm_buddy.c|  994 --
 .../drm/selftests/test-drm_cmdline_parser.c   | 1141 -
 .../drm/selftests/test-drm_damage_helper.c|  668 --
 drivers/gpu/drm/selftests/test-drm_format.c   |  280 
 .../drm/selftests/test-drm_modeset_common.c   |   32 -
 .../drm/selftests/test-drm_modeset_common.h   |   52 -
 drivers/gpu/drm/tests/Makefile|4 +-
 drivers/gpu/drm/tests/drm_buddy_test.c|  748 +++
 .../gpu/drm/tests/drm_cmdline_parser_test.c   | 1078 
 .../gpu/drm/tests/drm_damage_helper_test.c|  634 +
 .../drm_dp_mst_helper_test.c} |   84 +-
 drivers/gpu/drm/tests/drm_format_test.c   |  284 
 .../drm_framebuffer_test.c}   |   25 +-
 .../test-drm_mm.c => tests/drm_mm_test.c} | 1135 +++-
 .../drm_plane_helper_test.c}  |  103 +-
 .../test-drm_rect.c => tests/drm_rect_test.c} |  124 +-
 26 files changed, 3385 insertions(+), 4342 deletions(-)
 delete mode 100644 drivers/gpu/drm/selftests/Makefile
 delete mode 100644 drivers/gpu/drm/selftests/drm_buddy_selftests.h
 delete mode 100644 drivers/gpu/drm/selftests/drm_cmdline_selftests.h
 delete mode 100644 drivers/gpu/drm/selftests/drm_mm_selftests.h
 delete mode 100644 drivers/gpu/drm/selftests/drm_modeset_selftests.h
 delete mode 100644 drivers/gpu/drm/selftests/drm_selftest.c
 delete mode 100644 drivers/gpu/drm/selftests/drm_selftest.h
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_buddy.c
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_damage_helper.c
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_format.c
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.c
 delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.h
 create mode 100644 drivers/gpu/drm/tests/drm_buddy_test.c
 create mode 100644 drivers/gpu/drm/tests/drm_cmdline_parser_test.c
 create mode 100644 drivers/gpu/drm/tests/drm_damage_helper_test.c
 rename drivers/gpu/drm/{selftests/test-drm_dp_mst_helper.c => 
tests/drm_dp_mst_helper_test.c} (73%)
 create mode 100644 drivers/gpu/drm/tests/drm_format_test.c
 rename drivers/gpu/drm/{selftests/test-drm_framebuffer.c => 
tests/drm_framebuffer_test.c} (96%)
 rename 

Re: [PATCH v6 1/3] drm/doc/rfc: VM_BIND feature design document

2022-06-29 Thread Zanoni, Paulo R
On Sat, 2022-06-25 at 18:49 -0700, Niranjana Vishwanathapura wrote:
> VM_BIND design document with description of intended use cases.
> 
> v2: Reduce the scope to simple Mesa use case.
> v3: Expand documentation on dma-resv usage, TLB flushing and
> execbuf3.
> v4: Remove vm_bind tlb flush request support.
> v5: Update TLB flushing documentation.
> v6: Update out of order completion documentation.
> 
> Signed-off-by: Niranjana Vishwanathapura 
> ---
>  Documentation/gpu/rfc/i915_vm_bind.rst | 246 +
>  Documentation/gpu/rfc/index.rst|   4 +
>  2 files changed, 250 insertions(+)
>  create mode 100644 Documentation/gpu/rfc/i915_vm_bind.rst
> 
> diff --git a/Documentation/gpu/rfc/i915_vm_bind.rst 
> b/Documentation/gpu/rfc/i915_vm_bind.rst
> new file mode 100644
> index ..032ee32b885c
> --- /dev/null
> +++ b/Documentation/gpu/rfc/i915_vm_bind.rst
> @@ -0,0 +1,246 @@
> +==
> +I915 VM_BIND feature design and use cases
> +==
> +
> +VM_BIND feature
> +
> +DRM_I915_GEM_VM_BIND/UNBIND ioctls allows UMD to bind/unbind GEM buffer
> +objects (BOs) or sections of a BOs at specified GPU virtual addresses on a
> +specified address space (VM). These mappings (also referred to as persistent
> +mappings) will be persistent across multiple GPU submissions (execbuf calls)
> +issued by the UMD, without user having to provide a list of all required
> +mappings during each submission (as required by older execbuf mode).
> +
> +The VM_BIND/UNBIND calls allow UMDs to request a timeline out fence for
> +signaling the completion of bind/unbind operation.
> +
> +VM_BIND feature is advertised to user via I915_PARAM_HAS_VM_BIND.

I915_PARAM_VM_BIND_VERSION


> +User has to opt-in for VM_BIND mode of binding for an address space (VM)
> +during VM creation time via I915_VM_CREATE_FLAGS_USE_VM_BIND extension.
> +
> +VM_BIND/UNBIND ioctl calls executed on different CPU threads concurrently are
> +not ordered. Furthermore, parts of the VM_BIND/UNBIND operations can be done
> +asynchronously, when valid out fence is specified.
> +
> +VM_BIND features include:
> +
> +* Multiple Virtual Address (VA) mappings can map to the same physical pages
> +  of an object (aliasing).
> +* VA mapping can map to a partial section of the BO (partial binding).
> +* Support capture of persistent mappings in the dump upon GPU error.
> +* Support for userptr gem objects (no special uapi is required for this).
> +
> +TLB flush consideration
> +
> +The i915 driver flushes the TLB for each submission and when an object's
> +pages are released. The VM_BIND/UNBIND operation will not do any additional
> +TLB flush. Any VM_BIND mapping added will be in the working set for 
> subsequent
> +submissions on that VM and will not be in the working set for currently 
> running
> +batches (which would require additional TLB flushes, which is not supported).
> +
> +Execbuf ioctl in VM_BIND mode
> +---
> +A VM in VM_BIND mode will not support older execbuf mode of binding.
> +The execbuf ioctl handling in VM_BIND mode differs significantly from the
> +older execbuf2 ioctl (See struct drm_i915_gem_execbuffer2).
> +Hence, a new execbuf3 ioctl has been added to support VM_BIND mode. (See
> +struct drm_i915_gem_execbuffer3). The execbuf3 ioctl will not accept any
> +execlist. Hence, no support for implicit sync. It is expected that the below
> +work will be able to support requirements of object dependency setting in all
> +use cases:
> +
> +"dma-buf: Add an API for exporting sync files"
> +(https://lwn.net/Articles/859290/)
> +
> +The new execbuf3 ioctl only works in VM_BIND mode and the VM_BIND mode only
> +works with execbuf3 ioctl for submission. All BOs mapped on that VM (through
> +VM_BIND call) at the time of execbuf3 call are deemed required for that
> +submission.
> +
> +The execbuf3 ioctl directly specifies the batch addresses instead of as
> +object handles as in execbuf2 ioctl. The execbuf3 ioctl will also not
> +support many of the older features like in/out/submit fences, fence array,
> +default gem context and many more (See struct drm_i915_gem_execbuffer3).

Just as a note: both Iris and Vulkan use some of these features, so
some rework will be required. From what I can see, all current behavior
we depend on will be supported in some way or another, so hopefully
we'll be fine.


> +
> +In VM_BIND mode, VA allocation is completely managed by the user instead of
> +the i915 driver. Hence all VA assignment, eviction are not applicable in
> +VM_BIND mode. Also, for determining object activeness, VM_BIND mode will not
> +be using the i915_vma active reference tracking. It will instead use dma-resv
> +object for that (See `VM_BIND dma_resv usage`_).
> +
> +So, a lot of existing code supporting execbuf2 ioctl, like relocations, VA
> +evictions, vma lookup table, implicit sync, vma 

Re: [PATCH] drm/msm/dp: make eDP panel as the first connected connector

2022-06-29 Thread Doug Anderson
Hi,

On Tue, Jun 28, 2022 at 1:14 PM Dmitry Baryshkov
 wrote:
>
> On 28 June 2022 18:20:06 GMT+03:00, Kuogee Hsieh  
> wrote:
> >Some userspace presumes that the first connected connector is the main
> >display, where it's supposed to display e.g. the login screen. For
> >laptops, this should be the main panel.
> >
> >This patch call drm_helper_move_panel_connectors_to_head() after
> >drm_bridge_connector_init() to make sure eDP stay at head of
> >connected connector list. This fixes unexpected corruption happen
> >at eDP panel if eDP is not placed at head of connected connector
> >list.
>
> The change itself is a good fix anyway. (And I'd ack it.) However I would 
> like to understand why does it fix the corruption issue. What is we have eDP 
> and DSI, with DSI ending up before the eDP? Would we see the issue?
> Also could you please describe the mind of corruption you are observing?

I've spent a whole bunch of time poking at this and in the end my
conclusion is this:

1. The glitchyness seems to be a result of the Chrome OS userspace
somehow telling the kernel to do something wrong.

2. I believe (though I have no proof other than Kuogee's patch fixing
things) that the Chrome OS userspace is simply confused by the eDP
connector being second. This would imply that Kuogee's patch is
actually the right one.

3. It would be ideal if the Chrome OS userspace were fixed to handle
this, but it's an area of code that I've never looked at. It also
seems terribly low priority to fix since apparently other OSes have
similar problems (seems like this code was originally added by
RedHat?)


Specifically, I tested with a similar but "persistent" glitch that I
reproduced. The glitch Kuogee was digging into was a transitory glitch
on the eDP (internal) display when you plugged in a DP (external)
display. It would show up for a frame or two and then be fixed. I can
get a similar-looking glitch (vertical black and white bars) that
persists by doing these steps on a Chrome OS device (and Chrome OS
kernel):

a) Observe screen looks good.
b) Observe DP not connected.
c) Plug in DP
d) See transitory glitch on screen, then it all looks fine.
e) set_power_policy --ac_screen_dim_delay=5 --ac_screen_off_delay=10
f) Wait for screen to turn off
g) Unplug DP
h) Hit key on keyboard to wake device.
i) See glitchy.
j) Within 5 seconds: set_power_policy --ac_screen_dim_delay=5000
--ac_screen_off_delay=1

Once I'm in the persistent glitch:

* The "screenshot" command in Chrome OS shows corruption. Not exactly
black and white bars, but the image produced has distinct bands of
garbage.

* I can actually toggle between VT2 and the main screen (VT1). Note
that VT1/VT2 are not quite the normal Linux managed solution--I
believe they're handled by frecon. In any case, when I switch to VT2
it looks normal (I can see the login prompt). Then back to VT1 and the
vertical bars glitch. Back to VT2 and it's normal. Back to VT1 and the
glitch again. This implies (especially with the extra evidence of
screenshot) that the display controller hardware is all fine and that
it's the underlying data that's somehow messed up.

When I pick Kuogee's patch then this "persistent" glitch goes away
just like the transitory one does.

I'm going to go ahead and do:

Reviewed-by: Douglas Anderson 
Tested-by: Douglas Anderson 


Re: [PATCH v6 3/3] drm/doc/rfc: VM_BIND uapi definition

2022-06-29 Thread Zanoni, Paulo R
On Sat, 2022-06-25 at 18:49 -0700, Niranjana Vishwanathapura wrote:
> VM_BIND and related uapi definitions
> 
> v2: Reduce the scope to simple Mesa use case.
> v3: Expand VM_UNBIND documentation and add
> I915_GEM_VM_BIND/UNBIND_FENCE_VALID
> and I915_GEM_VM_BIND_TLB_FLUSH flags.
> v4: Remove I915_GEM_VM_BIND_TLB_FLUSH flag and add additional
> documentation for vm_bind/unbind.
> v5: Remove TLB flush requirement on VM_UNBIND.
> Add version support to stage implementation.
> v6: Define and use drm_i915_gem_timeline_fence structure for
> all timeline fences.
> v7: Rename I915_PARAM_HAS_VM_BIND to I915_PARAM_VM_BIND_VERSION.
> Update documentation on async vm_bind/unbind and versioning.
> Remove redundant vm_bind/unbind FENCE_VALID flag, execbuf3
> batch_count field and I915_EXEC3_SECURE flag.
> 
> Signed-off-by: Niranjana Vishwanathapura 
> Reviewed-by: Daniel Vetter 
> ---
>  Documentation/gpu/rfc/i915_vm_bind.h | 280 +++
>  1 file changed, 280 insertions(+)
>  create mode 100644 Documentation/gpu/rfc/i915_vm_bind.h
> 
> diff --git a/Documentation/gpu/rfc/i915_vm_bind.h 
> b/Documentation/gpu/rfc/i915_vm_bind.h
> new file mode 100644
> index ..a93e08bceee6
> --- /dev/null
> +++ b/Documentation/gpu/rfc/i915_vm_bind.h
> @@ -0,0 +1,280 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2022 Intel Corporation
> + */
> +
> +/**
> + * DOC: I915_PARAM_VM_BIND_VERSION
> + *
> + * VM_BIND feature version supported.
> + * See typedef drm_i915_getparam_t param.
> + *
> + * Specifies the VM_BIND feature version supported.
> + * The following versions of VM_BIND have been defined:
> + *
> + * 0: No VM_BIND support.
> + *
> + * 1: In VM_UNBIND calls, the UMD must specify the exact mappings created
> + *previously with VM_BIND, the ioctl will not support unbinding multiple
> + *mappings or splitting them. Similarly, VM_BIND calls will not replace
> + *any existing mappings.
> + *
> + * 2: The restrictions on unbinding partial or multiple mappings is
> + *lifted, Similarly, binding will replace any mappings in the given 
> range.
> + *
> + * See struct drm_i915_gem_vm_bind and struct drm_i915_gem_vm_unbind.
> + */
> +#define I915_PARAM_VM_BIND_VERSION   57
> +
> +/**
> + * DOC: I915_VM_CREATE_FLAGS_USE_VM_BIND
> + *
> + * Flag to opt-in for VM_BIND mode of binding during VM creation.
> + * See struct drm_i915_gem_vm_control flags.
> + *
> + * The older execbuf2 ioctl will not support VM_BIND mode of operation.
> + * For VM_BIND mode, we have new execbuf3 ioctl which will not accept any
> + * execlist (See struct drm_i915_gem_execbuffer3 for more details).
> + */
> +#define I915_VM_CREATE_FLAGS_USE_VM_BIND (1 << 0)
> +
> +/* VM_BIND related ioctls */
> +#define DRM_I915_GEM_VM_BIND 0x3d
> +#define DRM_I915_GEM_VM_UNBIND   0x3e
> +#define DRM_I915_GEM_EXECBUFFER3 0x3f
> +
> +#define DRM_IOCTL_I915_GEM_VM_BIND   DRM_IOWR(DRM_COMMAND_BASE + 
> DRM_I915_GEM_VM_BIND, struct drm_i915_gem_vm_bind)
> +#define DRM_IOCTL_I915_GEM_VM_UNBIND DRM_IOWR(DRM_COMMAND_BASE + 
> DRM_I915_GEM_VM_UNBIND, struct drm_i915_gem_vm_bind)
> +#define DRM_IOCTL_I915_GEM_EXECBUFFER3   
> DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER3, struct 
> drm_i915_gem_execbuffer3)
> +
> +/**
> + * struct drm_i915_gem_timeline_fence - An input or output timeline fence.
> + *
> + * The operation will wait for input fence to signal.
> + *
> + * The returned output fence will be signaled after the completion of the
> + * operation.
> + */
> +struct drm_i915_gem_timeline_fence {
> + /** @handle: User's handle for a drm_syncobj to wait on or signal. */
> + __u32 handle;
> +
> + /**
> +  * @flags: Supported flags are:
> +  *
> +  * I915_TIMELINE_FENCE_WAIT:
> +  * Wait for the input fence before the operation.
> +  *
> +  * I915_TIMELINE_FENCE_SIGNAL:
> +  * Return operation completion fence as output.
> +  */
> + __u32 flags;
> +#define I915_TIMELINE_FENCE_WAIT(1 << 0)
> +#define I915_TIMELINE_FENCE_SIGNAL  (1 << 1)
> +#define __I915_TIMELINE_FENCE_UNKNOWN_FLAGS (-(I915_TIMELINE_FENCE_SIGNAL << 
> 1))
> +
> + /**
> +  * @value: A point in the timeline.
> +  * Value must be 0 for a binary drm_syncobj. A Value of 0 for a
> +  * timeline drm_syncobj is invalid as it turns a drm_syncobj into a
> +  * binary one.
> +  */
> + __u64 value;
> +};
> +
> +/**
> + * struct drm_i915_gem_vm_bind - VA to object mapping to bind.
> + *
> + * This structure is passed to VM_BIND ioctl and specifies the mapping of GPU
> + * virtual address (VA) range to the section of an object that should be 
> bound
> + * in the device page table of the specified address space (VM).
> + * The VA range specified must be unique (ie., not currently bound) and can
> + * be mapped to whole object or a section of the object (partial binding).
> + * Multiple 

Re: [PATCH v5 1/9] dt-bindings: usb: Add Type-C switch binding

2022-06-29 Thread Stephen Boyd
Quoting Prashant Malani (2022-06-29 15:55:10)
> On Wed, Jun 29, 2022 at 2:58 PM Stephen Boyd  wrote:
> >
> > My understanding is there are 4 DP lanes on it6505 and two lanes are
> > connected to one usb-c-connector and the other two lanes are connected
> > to a different usb-c-connector. The IT6505 driver will send DP out on
> > the associated two DP lanes depending on which usb-c-connector has DP
> > pins assigned by the typec manager.
[...]
>
> We can adopt this binding, but from what I gathered in this thread, that
> shouldn't be done, because IT6505 isn't meant to be aware of Type-C
> connections at all.

How will the driver know which usb-c-connector to route DP to without
making the binding aware of typec connections?

> >
> > I think the difficulty comes from the combinatorial explosion of
> > possible configurations. As evidenced here, hardware engineers can take
> > a DP bridge and use it as a DP mux as long as the bridge has lane
> > control. Or they can take a device like anx7625 and ignore the USB
> > aspect and use the internal crosspoint switch as a DP mux. The anx7625
> > part could be a MIPI-to-DP display bridge plus mux that is connected to
> > two dp-connectors, in which case typec isn't even involved, but we could
> > mux between two dp connectors.
>
> Each containing a single DP lane, right?

Yes.

> I think that will not be a valid configuration, since there is only 1 HPD
> pin (so it's assuming both DP lanes go to the same DP sink).

HPD can be signalled out of band, or not at all (no-hpd). I suspect it's
valid to ignore/disconnect the HPD pin here and start/stop DP when, for
example, the HPD pin toggles within a dp-connector. HPD could be
signaled directly to the kernel via an out of band gpio going from the
dp-connector to the SoC. In this case HPD for each dp-connector could be
a different gpio and the driver may be required to arbitrate between the
two dp-connectors with some 'first to signal wins' logic or something.

>
> But yes, your larger point is valid: h/w engineers can repurpose these
> bridges in ways the datasheet doesn't originally anticipate.

Yeah, I'm also trying to say that devices with typec logic may not be
used for typec purposes.

>
> >
> > Also, the typec framework would like to simply walk the graph from the
> > usb-c-connector looking for nodes that have 'mode-switch' or
> > 'orientation-switch' properties and treat those devices as the typec
> > switches for the connector. This means that we have to add these typec
> > properties like 'mode-switch' to something like the IT6505 bridge
> > binding, which is a little awkward. I wonder if those properties aren't
> > really required. Would it be sufficient if the framework could walk the
> > graph and look for registered typec switches in the kernel that have a
> > matching of_node?
>
> My interpretation of the current mode-switch search code [1] is that
> a top level property of "mode-switch" is required.

Yeah that's how it is right now, but does it have to stay that way?
Could the code search the graph and look for a matching node that's
registered with the typec framework? The goal is to avoid adding typec
properties like 'mode-switch' to bindings like bridge converters that
aren't expected to work with typec. Hopefully the binding can be written
with the output pins in mind and what modes on those pins the hardware
supports (e.g. two lanes on anx7625 can't be split apart whereas on
it6505 each pair can be used directly).


Re: [PATCH v7 03/14] mm: handling Non-LRU pages returned by vm_normal_pages

2022-06-29 Thread Andrew Morton
On Wed, 29 Jun 2022 11:59:26 +0200 David Hildenbrand  wrote:

> On 29.06.22 05:54, Alex Sierra wrote:
> > With DEVICE_COHERENT, we'll soon have vm_normal_pages() return
> > device-managed anonymous pages that are not LRU pages. Although they
> > behave like normal pages for purposes of mapping in CPU page, and for
> > COW. They do not support LRU lists, NUMA migration or THP.
> > 
> > Callers to follow_page that expect LRU pages, are also checked for
> > device zone pages due to DEVICE_COHERENT type.
> 
> Can we rephrase that to (because zeropage)
> 
> "Callers to follow_page() currently don't expect ZONE_DEVICE pages,
> however, with DEVICE_COHERENT we might now return ZONE_DEVICE. Check for
> ZONE_DEVICE pages in applicable users of follow_page() as well."

I made that change to my copy.

> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -624,6 +624,13 @@ struct page *vm_normal_page(struct vm_area_struct 
> > *vma, unsigned long addr,
> > if (is_zero_pfn(pfn))
> > return NULL;
> > if (pte_devmap(pte))
> > +/*
> > + * NOTE: New uers of ZONE_DEVICE will not set pte_devmap() and will have
> 
> s/uers/users/
> 
> > + * refcounts incremented on their struct pages when they are inserted into
> > + * PTEs, thus they are safe to return here. Legacy ZONE_DEVICE pages that 
> > set
> > + * pte_devmap() do not have refcounts. Example of legacy ZONE_DEVICE is
> > + * MEMORY_DEVICE_FS_DAX type in pmem or virtio_fs drivers.
> > + */

And let's regularize that comment placement?

--- a/mm/memory.c~mm-handling-non-lru-pages-returned-by-vm_normal_pages-fix
+++ a/mm/memory.c
@@ -632,16 +632,16 @@ struct page *vm_normal_page(struct vm_ar
return NULL;
if (is_zero_pfn(pfn))
return NULL;
+   /*
+* NOTE: New users of ZONE_DEVICE will not set pte_devmap()
+* and will have refcounts incremented on their struct pages
+* when they are inserted into PTEs, thus they are safe to
+* return here. Legacy ZONE_DEVICE pages that set pte_devmap()
+* do not have refcounts. Example of legacy ZONE_DEVICE is
+* MEMORY_DEVICE_FS_DAX type in pmem or virtio_fs drivers.
+*/
if (pte_devmap(pte))
-/*
- * NOTE: New uers of ZONE_DEVICE will not set pte_devmap() and will have
- * refcounts incremented on their struct pages when they are inserted into
- * PTEs, thus they are safe to return here. Legacy ZONE_DEVICE pages that set
- * pte_devmap() do not have refcounts. Example of legacy ZONE_DEVICE is
- * MEMORY_DEVICE_FS_DAX type in pmem or virtio_fs drivers.
- */
return NULL;
-
print_bad_pte(vma, addr, pte, NULL);
return NULL;
}
_



Re: [PATCH v7 01/14] mm: rename is_pinnable_pages to is_pinnable_longterm_pages

2022-06-29 Thread Andrew Morton
On Wed, 29 Jun 2022 18:08:40 -0400 Felix Kuehling  
wrote:

> >
> > I'd have called it "is_longterm_pinnable_page", but I am not a native
> > speaker, so no strong opinion :)
> 
> I think only the patch title has the name backwards. The code uses 
> is_longterm_pinnable_page.

Patch title was quite buggy ;) I made it "mm: rename is_pinnable_page()
to is_longterm_pinnable_page()" in my copy.




Re: [PATCH v6 02/22] drm/gem: Move mapping of imported dma-bufs to drm_gem_mmap_obj()

2022-06-29 Thread Dmitry Osipenko
On 6/29/22 11:43, Thomas Hellström (Intel) wrote:
> 
> On 6/29/22 10:22, Dmitry Osipenko wrote:
>> On 6/29/22 09:40, Thomas Hellström (Intel) wrote:
>>> On 5/27/22 01:50, Dmitry Osipenko wrote:
 Drivers that use drm_gem_mmap() and drm_gem_mmap_obj() helpers don't
 handle imported dma-bufs properly, which results in mapping of
 something
 else than the imported dma-buf. For example, on NVIDIA Tegra we get a
 hard
 lockup when userspace writes to the memory mapping of a dma-buf that
 was
 imported into Tegra's DRM GEM.

 To fix this bug, move mapping of imported dma-bufs to
 drm_gem_mmap_obj().
 Now mmaping of imported dma-bufs works properly for all DRM drivers.
>>> Same comment about Fixes: as in patch 1,
 Cc: sta...@vger.kernel.org
 Signed-off-by: Dmitry Osipenko 
 ---
    drivers/gpu/drm/drm_gem.c  | 3 +++
    drivers/gpu/drm/drm_gem_shmem_helper.c | 9 -
    drivers/gpu/drm/tegra/gem.c    | 4 
    3 files changed, 7 insertions(+), 9 deletions(-)

 diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
 index 86d670c71286..7c0b025508e4 100644
 --- a/drivers/gpu/drm/drm_gem.c
 +++ b/drivers/gpu/drm/drm_gem.c
 @@ -1038,6 +1038,9 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj,
 unsigned long obj_size,
    if (obj_size < vma->vm_end - vma->vm_start)
    return -EINVAL;
    +    if (obj->import_attach)
 +    return dma_buf_mmap(obj->dma_buf, vma, 0);
>>> If we start enabling mmaping of imported dma-bufs on a majority of
>>> drivers in this way, how do we ensure that user-space is not blindly
>>> using the object mmap without calling the needed DMA_BUF_IOCTL_SYNC
>>> which is needed before and after cpu access of mmap'ed dma-bufs?
>>>
>>> I was under the impression (admittedly without looking) that the few
>>> drivers that actually called into dma_buf_mmap() had some private
>>> user-mode driver code in place that ensured this happened.
>> Since it's a userspace who does the mapping, then it should be a
>> responsibility of userspace to do all the necessary syncing.
> 
> Sure, but nothing prohibits user-space to ignore the syncing thinking
> "It works anyway", testing those drivers where the syncing is a NOP. And
> when a driver that finally needs syncing is tested it's too late to fix
> all broken user-space.
> 
>>   I'm not
>> sure whether anyone in userspace really needs to map imported dma-bufs
>> in practice. Nevertheless, this use-case is broken and should be fixed
>> by either allowing to do the mapping or prohibiting it.
>>
> Then I'd vote for prohibiting it, at least for now. And for the future
> moving forward we could perhaps revisit the dma-buf need for syncing,
> requiring those drivers that actually need it to implement emulated
> coherent memory which can be done not too inefficiently (vmwgfx being
> one example).

Alright, I'll change it to prohibit the mapping. This indeed should be a
better option.

-- 
Best regards,
Dmitry


Re: [PATCH v5 1/9] dt-bindings: usb: Add Type-C switch binding

2022-06-29 Thread Prashant Malani
On Wed, Jun 29, 2022 at 2:58 PM Stephen Boyd  wrote:
>
> > What device controls the switching in this case? Again, block diagrams
> > please if you want advice on what the binding should look like.
>
> My understanding is there are 4 DP lanes on it6505 and two lanes are
> connected to one usb-c-connector and the other two lanes are connected
> to a different usb-c-connector. The IT6505 driver will send DP out on
> the associated two DP lanes depending on which usb-c-connector has DP
> pins assigned by the typec manager.
>
>  +---+
>  |   |
>   ++/+ usb-c |
>   | IT6505 |   / /---+   |
>   |+ lane 0 --/ /|   |
>   |+ lane 1 ---/ +---+
>  DPI -+|
>   || +---+
>   || |   |
>   |+ lane 2 -+ usb-c |
>   |+ lane 3 -+   |
>   || |   |
>   ++ +---+
>
> The bridge is a mux that steers DP to one or the other usb-c-connector
> based on what the typec manager decides.
>
> I would expect this to be described with the existing port binding in
> the it6505 node. The binding would need to be extended to describe the
> output side.
>
> bridge@5c {
> compatible = "ite,it6505";

We'll need a top level "mode-switch" property here.
> ...
>
> ports {
> #address-cells = <1>;
> #size-cells = <0>;
>
> port@0 {
> reg = <0>;
> it6505_in: endpoint {
> remote-endpoint = <_out>;
> };
> };
>
> port@1 {
> #address-cells = <1>;
> #size-cells = <0>;
> reg = <1>;
>
> it6505_out_lanes_01: endpoint@0 {
> reg = <0>
> data-lanes = <0 1>;
> remote-endpoint = <>;
> };
>
> it6505_out_lanes_23: endpoint@1 {
> reg = <1>
> data-lanes = <2 3>;
> remote-endpoint = <>;
> };
> };
> };
> };
>
> usb-c-connector {
> compatible = "usb-c-connector";
> 
> ports {
> #address-cells = <1>;
> #size-cells = <0>;
>
> port@1 {
> reg = <1>;
> typec0: endpoint {
> remote-endpoint = <_out_lanes_01>;
> };
> };
> };
> };

We can adopt this binding, but from what I gathered in this thread, that
shouldn't be done, because IT6505 isn't meant to be aware of Type-C
connections at all.

>
> I don't see the benefit to making a genericish binding for typec
> switches, even if the hardware has typec awareness like anx7625. It
> looks like the graph binding can already handle what we need. By putting
> it in the top-level ports node we have one way to describe the
> input/output of the device instead of describing it in the top-level in
> the display connector case and the child typec switch node in the usb c
> connector case.

Ack, I'll drop the generic binding for future revisions.

>
> I think the difficulty comes from the combinatorial explosion of
> possible configurations. As evidenced here, hardware engineers can take
> a DP bridge and use it as a DP mux as long as the bridge has lane
> control. Or they can take a device like anx7625 and ignore the USB
> aspect and use the internal crosspoint switch as a DP mux. The anx7625
> part could be a MIPI-to-DP display bridge plus mux that is connected to
> two dp-connectors, in which case typec isn't even involved, but we could
> mux between two dp connectors.

Each containing a single DP lane, right?
I think that will not be a valid configuration, since there is only 1 HPD
pin (so it's assuming both DP lanes go to the same DP sink).

But yes, your larger point is valid: h/w engineers can repurpose these
bridges in ways the datasheet doesn't originally anticipate.

>
> Also, the typec framework would like to simply walk the graph from the
> usb-c-connector looking for nodes that have 'mode-switch' or
> 'orientation-switch' properties and treat those devices as the typec
> switches for the connector. This means that we have to add these typec
> properties like 'mode-switch' to something like the IT6505 bridge
> binding, which is a 

[PATCH v3 09/11] drm/msm/dsi_phy_14nm: Replace parent names with clk_hw pointers

2022-06-29 Thread Marijn Suijten
parent_hw pointers are easier to manage and cheaper to use than
repeatedly formatting the parent name and subsequently leaving the clk
framework to perform lookups based on that name.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c | 40 ++
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c
index e10ba1b09b2f..1a855351654c 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c
@@ -764,14 +764,14 @@ static int dsi_14nm_set_usecase(struct msm_dsi_phy *phy)
 
 static struct clk_hw *pll_14nm_postdiv_register(struct dsi_pll_14nm *pll_14nm,
const char *name,
-   const char *parent_name,
+   const struct clk_hw *parent_hw,
unsigned long flags,
u8 shift)
 {
struct dsi_pll_14nm_postdiv *pll_postdiv;
struct device *dev = _14nm->phy->pdev->dev;
struct clk_init_data postdiv_init = {
-   .parent_names = (const char *[]) { parent_name },
+   .parent_hws = (const struct clk_hw *[]) { parent_hw },
.num_parents = 1,
.name = name,
.flags = flags,
@@ -800,23 +800,23 @@ static struct clk_hw *pll_14nm_postdiv_register(struct 
dsi_pll_14nm *pll_14nm,
 
 static int pll_14nm_register(struct dsi_pll_14nm *pll_14nm, struct clk_hw 
**provided_clocks)
 {
-   char clk_name[32], parent[32], vco_name[32];
+   char clk_name[32];
struct clk_init_data vco_init = {
.parent_data = &(const struct clk_parent_data) {
.fw_name = "ref",
},
.num_parents = 1,
-   .name = vco_name,
+   .name = clk_name,
.flags = CLK_IGNORE_UNUSED,
.ops = _ops_dsi_pll_14nm_vco,
};
struct device *dev = _14nm->phy->pdev->dev;
-   struct clk_hw *hw;
+   struct clk_hw *hw, *n1_postdiv, *n1_postdivby2;
int ret;
 
DBG("DSI%d", pll_14nm->phy->id);
 
-   snprintf(vco_name, sizeof(vco_name), "dsi%dvco_clk", pll_14nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%dvco_clk", pll_14nm->phy->id);
pll_14nm->clk_hw.init = _init;
 
ret = devm_clk_hw_register(dev, _14nm->clk_hw);
@@ -824,48 +824,46 @@ static int pll_14nm_register(struct dsi_pll_14nm 
*pll_14nm, struct clk_hw **prov
return ret;
 
snprintf(clk_name, sizeof(clk_name), "dsi%dn1_postdiv_clk", 
pll_14nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%dvco_clk", pll_14nm->phy->id);
 
/* N1 postdiv, bits 0-3 in REG_DSI_14nm_PHY_CMN_CLK_CFG0 */
-   hw = pll_14nm_postdiv_register(pll_14nm, clk_name, parent,
-  CLK_SET_RATE_PARENT, 0);
-   if (IS_ERR(hw))
-   return PTR_ERR(hw);
+   n1_postdiv = pll_14nm_postdiv_register(pll_14nm, clk_name,
+   _14nm->clk_hw, CLK_SET_RATE_PARENT, 0);
+   if (IS_ERR(n1_postdiv))
+   return PTR_ERR(n1_postdiv);
 
snprintf(clk_name, sizeof(clk_name), "dsi%dpllbyte", pll_14nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%dn1_postdiv_clk", 
pll_14nm->phy->id);
 
/* DSI Byte clock = VCO_CLK / N1 / 8 */
-   hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent,
-  CLK_SET_RATE_PARENT, 1, 8);
+   hw = devm_clk_hw_register_fixed_factor_parent_hw(dev, clk_name,
+   n1_postdiv, CLK_SET_RATE_PARENT, 1, 8);
if (IS_ERR(hw))
return PTR_ERR(hw);
 
provided_clocks[DSI_BYTE_PLL_CLK] = hw;
 
snprintf(clk_name, sizeof(clk_name), "dsi%dn1_postdivby2_clk", 
pll_14nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%dn1_postdiv_clk", 
pll_14nm->phy->id);
 
/*
 * Skip the mux for now, force DSICLK_SEL to 1, Add a /2 divider
 * on the way. Don't let it set parent.
 */
-   hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent, 0, 1, 2);
-   if (IS_ERR(hw))
-   return PTR_ERR(hw);
+   n1_postdivby2 = devm_clk_hw_register_fixed_factor_parent_hw(dev,
+   clk_name, n1_postdiv, 0, 1, 2);
+   if (IS_ERR(n1_postdivby2))
+   return PTR_ERR(n1_postdivby2);
 
snprintf(clk_name, sizeof(clk_name), "dsi%dpll", pll_14nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%dn1_postdivby2_clk", 
pll_14nm->phy->id);
 
/* DSI pixel clock = VCO_CLK / N1 / 2 / N2
 * This is the output of N2 post-divider, bits 4-7 in
 * REG_DSI_14nm_PHY_CMN_CLK_CFG0. Don't 

[PATCH v3 06/11] drm/msm/dsi/phy: Replace hardcoded char-array length with sizeof()

2022-06-29 Thread Marijn Suijten
Now that the last DSI PHY PLL driver (dsi_phy_28nm_8960) has been
converted to use a simple stack-local char-array instead of a
devm_kzalloc heap allocation we can safely call sizeof() on every string
variable (that's now a sized array instead of a pointer) passed into
snprintf instead of hardcoding the size.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c| 36 +--
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c| 18 +-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c| 24 ++---
 .../gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c   |  8 ++---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 34 +-
 5 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
index 56892036e419..8bd7b97b1b9b 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
@@ -591,15 +591,15 @@ static int pll_10nm_register(struct dsi_pll_10nm 
*pll_10nm, struct clk_hw **prov
 
DBG("DSI%d", pll_10nm->phy->id);
 
-   snprintf(vco_name, 32, "dsi%dvco_clk", pll_10nm->phy->id);
+   snprintf(vco_name, sizeof(vco_name), "dsi%dvco_clk", pll_10nm->phy->id);
pll_10nm->clk_hw.init = _init;
 
ret = devm_clk_hw_register(dev, _10nm->clk_hw);
if (ret)
return ret;
 
-   snprintf(clk_name, 32, "dsi%d_pll_out_div_clk", pll_10nm->phy->id);
-   snprintf(parent, 32, "dsi%dvco_clk", pll_10nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_out_div_clk", 
pll_10nm->phy->id);
+   snprintf(parent, sizeof(parent), "dsi%dvco_clk", pll_10nm->phy->id);
 
hw = devm_clk_hw_register_divider(dev, clk_name, parent,
CLK_SET_RATE_PARENT, pll_10nm->phy->pll_base +
@@ -610,8 +610,8 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm, 
struct clk_hw **prov
goto fail;
}
 
-   snprintf(clk_name, 32, "dsi%d_pll_bit_clk", pll_10nm->phy->id);
-   snprintf(parent, 32, "dsi%d_pll_out_div_clk", pll_10nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_bit_clk", 
pll_10nm->phy->id);
+   snprintf(parent, sizeof(parent), "dsi%d_pll_out_div_clk", 
pll_10nm->phy->id);
 
/* BIT CLK: DIV_CTRL_3_0 */
hw = devm_clk_hw_register_divider(dev, clk_name, parent,
@@ -623,8 +623,8 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm, 
struct clk_hw **prov
goto fail;
}
 
-   snprintf(clk_name, 32, "dsi%d_phy_pll_out_byteclk", pll_10nm->phy->id);
-   snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%d_phy_pll_out_byteclk", 
pll_10nm->phy->id);
+   snprintf(parent, sizeof(parent), "dsi%d_pll_bit_clk", 
pll_10nm->phy->id);
 
/* DSI Byte clock = VCO_CLK / OUT_DIV / BIT_DIV / 8 */
hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent,
@@ -636,8 +636,8 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm, 
struct clk_hw **prov
 
provided_clocks[DSI_BYTE_PLL_CLK] = hw;
 
-   snprintf(clk_name, 32, "dsi%d_pll_by_2_bit_clk", pll_10nm->phy->id);
-   snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_by_2_bit_clk", 
pll_10nm->phy->id);
+   snprintf(parent, sizeof(parent), "dsi%d_pll_bit_clk", 
pll_10nm->phy->id);
 
hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent,
   0, 1, 2);
@@ -646,8 +646,8 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm, 
struct clk_hw **prov
goto fail;
}
 
-   snprintf(clk_name, 32, "dsi%d_pll_post_out_div_clk", pll_10nm->phy->id);
-   snprintf(parent, 32, "dsi%d_pll_out_div_clk", pll_10nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_post_out_div_clk", 
pll_10nm->phy->id);
+   snprintf(parent, sizeof(parent), "dsi%d_pll_out_div_clk", 
pll_10nm->phy->id);
 
hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent,
   0, 1, 4);
@@ -656,11 +656,11 @@ static int pll_10nm_register(struct dsi_pll_10nm 
*pll_10nm, struct clk_hw **prov
goto fail;
}
 
-   snprintf(clk_name, 32, "dsi%d_pclk_mux", pll_10nm->phy->id);
-   snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->phy->id);
-   snprintf(parent2, 32, "dsi%d_pll_by_2_bit_clk", pll_10nm->phy->id);
-   snprintf(parent3, 32, "dsi%d_pll_out_div_clk", pll_10nm->phy->id);
-   snprintf(parent4, 32, "dsi%d_pll_post_out_div_clk", pll_10nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%d_pclk_mux", 
pll_10nm->phy->id);
+   snprintf(parent, sizeof(parent), "dsi%d_pll_bit_clk", 
pll_10nm->phy->id);
+   snprintf(parent2, sizeof(parent2), 

[PATCH v3 07/11] drm/msm/dsi_phy_28nm_8960: Replace parent names with clk_hw pointers

2022-06-29 Thread Marijn Suijten
parent_hw pointers are easier to manage and cheaper to use than
repeatedly formatting the parent name and subsequently leaving the clk
framework to perform lookups based on that name.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
index 3deb306f4cc4..69c1b2d8333c 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
@@ -383,7 +383,7 @@ static int dsi_28nm_pll_restore_state(struct msm_dsi_phy 
*phy)
 
 static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, struct clk_hw 
**provided_clocks)
 {
-   char clk_name[32], parent_name[32], vco_name[32];
+   char clk_name[32];
struct clk_init_data vco_init = {
.parent_data = &(const struct clk_parent_data) {
.fw_name = "ref",
@@ -404,8 +404,8 @@ static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, 
struct clk_hw **prov
if (!bytediv)
return -ENOMEM;
 
-   snprintf(vco_name, sizeof(vco_name), "dsi%dvco_clk", pll_28nm->phy->id);
-   vco_init.name = vco_name;
+   snprintf(clk_name, sizeof(clk_name), "dsi%dvco_clk", pll_28nm->phy->id);
+   vco_init.name = clk_name;
 
pll_28nm->clk_hw.init = _init;
 
@@ -417,13 +417,14 @@ static int pll_28nm_register(struct dsi_pll_28nm 
*pll_28nm, struct clk_hw **prov
bytediv->hw.init = _init;
bytediv->reg = pll_28nm->phy->pll_base + 
REG_DSI_28nm_8960_PHY_PLL_CTRL_9;
 
-   snprintf(parent_name, sizeof(parent_name), "dsi%dvco_clk", 
pll_28nm->phy->id);
snprintf(clk_name, sizeof(clk_name), "dsi%dpllbyte", pll_28nm->phy->id 
+ 1);
 
bytediv_init.name = clk_name;
bytediv_init.ops = _bytediv_ops;
bytediv_init.flags = CLK_SET_RATE_PARENT;
-   bytediv_init.parent_names = (const char * const *) _name;
+   bytediv_init.parent_hws = (const struct clk_hw*[]){
+   _28nm->clk_hw,
+   };
bytediv_init.num_parents = 1;
 
/* DIV2 */
@@ -434,8 +435,8 @@ static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, 
struct clk_hw **prov
 
snprintf(clk_name, sizeof(clk_name), "dsi%dpll", pll_28nm->phy->id + 1);
/* DIV3 */
-   hw = devm_clk_hw_register_divider(dev, clk_name, parent_name, 0,
-   pll_28nm->phy->pll_base +
+   hw = devm_clk_hw_register_divider_parent_hw(dev, clk_name,
+   _28nm->clk_hw, 0, pll_28nm->phy->pll_base +
REG_DSI_28nm_8960_PHY_PLL_CTRL_10,
0, 8, 0, NULL);
if (IS_ERR(hw))
-- 
2.37.0



[PATCH v3 10/11] drm/msm/dsi_phy_10nm: Replace parent names with clk_hw pointers

2022-06-29 Thread Marijn Suijten
parent_hw pointers are easier to manage and cheaper to use than
repeatedly formatting the parent name and subsequently leaving the clk
framework to perform lookups based on that name.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c | 79 ++
 1 file changed, 36 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
index 8bd7b97b1b9b..ae57f95edf63 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
@@ -574,24 +574,24 @@ static int dsi_10nm_set_usecase(struct msm_dsi_phy *phy)
  */
 static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm, struct clk_hw 
**provided_clocks)
 {
-   char clk_name[32], parent[32], vco_name[32];
-   char parent2[32], parent3[32], parent4[32];
+   char clk_name[32];
struct clk_init_data vco_init = {
.parent_data = &(const struct clk_parent_data) {
.fw_name = "ref",
},
.num_parents = 1,
-   .name = vco_name,
+   .name = clk_name,
.flags = CLK_IGNORE_UNUSED,
.ops = _ops_dsi_pll_10nm_vco,
};
struct device *dev = _10nm->phy->pdev->dev;
-   struct clk_hw *hw;
+   struct clk_hw *hw, *pll_out_div, *pll_bit, *pll_by_2_bit;
+   struct clk_hw *pll_post_out_div, *pclk_mux;
int ret;
 
DBG("DSI%d", pll_10nm->phy->id);
 
-   snprintf(vco_name, sizeof(vco_name), "dsi%dvco_clk", pll_10nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%dvco_clk", pll_10nm->phy->id);
pll_10nm->clk_hw.init = _init;
 
ret = devm_clk_hw_register(dev, _10nm->clk_hw);
@@ -599,36 +599,34 @@ static int pll_10nm_register(struct dsi_pll_10nm 
*pll_10nm, struct clk_hw **prov
return ret;
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_out_div_clk", 
pll_10nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%dvco_clk", pll_10nm->phy->id);
 
-   hw = devm_clk_hw_register_divider(dev, clk_name, parent,
-   CLK_SET_RATE_PARENT, pll_10nm->phy->pll_base +
+   pll_out_div = devm_clk_hw_register_divider_parent_hw(dev, clk_name,
+   _10nm->clk_hw, CLK_SET_RATE_PARENT,
+   pll_10nm->phy->pll_base +
REG_DSI_10nm_PHY_PLL_PLL_OUTDIV_RATE,
0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
-   if (IS_ERR(hw)) {
-   ret = PTR_ERR(hw);
+   if (IS_ERR(pll_out_div)) {
+   ret = PTR_ERR(pll_out_div);
goto fail;
}
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_bit_clk", 
pll_10nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%d_pll_out_div_clk", 
pll_10nm->phy->id);
 
/* BIT CLK: DIV_CTRL_3_0 */
-   hw = devm_clk_hw_register_divider(dev, clk_name, parent,
-   CLK_SET_RATE_PARENT,
+   pll_bit = devm_clk_hw_register_divider_parent_hw(dev, clk_name,
+   pll_out_div, CLK_SET_RATE_PARENT,
pll_10nm->phy->base + REG_DSI_10nm_PHY_CMN_CLK_CFG0,
0, 4, CLK_DIVIDER_ONE_BASED, _10nm->postdiv_lock);
-   if (IS_ERR(hw)) {
-   ret = PTR_ERR(hw);
+   if (IS_ERR(pll_bit)) {
+   ret = PTR_ERR(pll_bit);
goto fail;
}
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_phy_pll_out_byteclk", 
pll_10nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%d_pll_bit_clk", 
pll_10nm->phy->id);
 
/* DSI Byte clock = VCO_CLK / OUT_DIV / BIT_DIV / 8 */
-   hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent,
-  CLK_SET_RATE_PARENT, 1, 8);
+   hw = devm_clk_hw_register_fixed_factor_parent_hw(dev, clk_name,
+   pll_bit, CLK_SET_RATE_PARENT, 1, 8);
if (IS_ERR(hw)) {
ret = PTR_ERR(hw);
goto fail;
@@ -637,48 +635,43 @@ static int pll_10nm_register(struct dsi_pll_10nm 
*pll_10nm, struct clk_hw **prov
provided_clocks[DSI_BYTE_PLL_CLK] = hw;
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_by_2_bit_clk", 
pll_10nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%d_pll_bit_clk", 
pll_10nm->phy->id);
 
-   hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent,
-  0, 1, 2);
-   if (IS_ERR(hw)) {
-   ret = PTR_ERR(hw);
+   pll_by_2_bit = devm_clk_hw_register_fixed_factor_parent_hw(dev,
+   clk_name, pll_bit, 0, 1, 2);
+   if (IS_ERR(pll_by_2_bit)) {
+   ret = PTR_ERR(pll_by_2_bit);
goto fail;
}
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_post_out_div_clk", 

[PATCH v3 04/11] drm/msm/dsi/phy: Reindent and reflow multiline function calls

2022-06-29 Thread Marijn Suijten
Patch 613cbd1da3c9 ("drm/msm/dsi: use devm_clk_*register to registe DSI
PHY clocks") introduced the devm_ prefix to clk_hw registration calls,
without updating the indentation of the arguments on the following
lines.

Similarly e55b3fc8 ("drm/msm/dsi: drop PLL accessor functions")
moved from pll_write to dsi_phy_write without updating the indentation
of followup arguments either.

Preparing for a series that heavily touches the clk calls, reflow and
reindent function calls that are adhering to an 80-char column limit by
spanning multiple lines.  Where function names are very long the
arguments are indented with a fixed number of two tab characters instead
of aligning with the opening parenthesis of the function call.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c| 96 +--
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c|  9 +-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c| 73 +++---
 .../gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c   | 63 ++--
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 84 
 5 files changed, 161 insertions(+), 164 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
index 08b015ea1b1e..56892036e419 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c
@@ -188,19 +188,19 @@ static void dsi_pll_ssc_commit(struct dsi_pll_10nm *pll, 
struct dsi_pll_config *
pr_debug("SSC is enabled\n");
 
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_SSC_STEPSIZE_LOW_1,
- config->ssc_stepsize & 0xff);
+ config->ssc_stepsize & 0xff);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_SSC_STEPSIZE_HIGH_1,
- config->ssc_stepsize >> 8);
+ config->ssc_stepsize >> 8);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_SSC_DIV_PER_LOW_1,
- config->ssc_div_per & 0xff);
+ config->ssc_div_per & 0xff);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_SSC_DIV_PER_HIGH_1,
- config->ssc_div_per >> 8);
+ config->ssc_div_per >> 8);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_SSC_DIV_ADJPER_LOW_1,
- config->ssc_adj_per & 0xff);
+ config->ssc_adj_per & 0xff);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_SSC_DIV_ADJPER_HIGH_1,
- config->ssc_adj_per >> 8);
+ config->ssc_adj_per >> 8);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_SSC_CONTROL,
- SSC_EN | (config->ssc_center ? SSC_CENTER : 0));
+ SSC_EN | (config->ssc_center ? SSC_CENTER : 0));
}
 }
 
@@ -215,16 +215,19 @@ static void dsi_pll_config_hzindep_reg(struct 
dsi_pll_10nm *pll)
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_FEEDBACK_DIVIDER, 0x4e);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_CALIBRATION_SETTINGS, 0x40);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_BAND_SEL_CAL_SETTINGS_THREE,
- 0xba);
-   dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_FREQ_DETECT_SETTINGS_ONE, 
0x0c);
+ 0xba);
+   dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_FREQ_DETECT_SETTINGS_ONE,
+ 0x0c);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_OUTDIV, 0x00);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_CORE_OVERRIDE, 0x00);
-   dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PLL_DIGITAL_TIMERS_TWO, 0x08);
+   dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PLL_DIGITAL_TIMERS_TWO,
+ 0x08);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PLL_PROP_GAIN_RATE_1, 0x08);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PLL_BAND_SET_RATE_1, 0xc0);
-   dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PLL_INT_GAIN_IFILT_BAND_1, 
0xfa);
+   dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PLL_INT_GAIN_IFILT_BAND_1,
+ 0xfa);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PLL_FL_INT_GAIN_PFILT_BAND_1,
- 0x4c);
+ 0x4c);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PLL_LOCK_OVERRIDE, 0x80);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_PFILT, 0x29);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_IFILT, 0x3f);
@@ -236,18 +239,18 @@ static void dsi_pll_commit(struct dsi_pll_10nm *pll, 
struct dsi_pll_config *conf
 
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_CORE_INPUT_OVERRIDE, 0x12);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_DECIMAL_DIV_START_1,
- config->decimal_div_start);
+ config->decimal_div_start);
dsi_phy_write(base + REG_DSI_10nm_PHY_PLL_FRAC_DIV_START_LOW_1,
- config->frac_div_start & 

[PATCH v3 11/11] drm/msm/dsi_phy_7nm: Replace parent names with clk_hw pointers

2022-06-29 Thread Marijn Suijten
parent_hw pointers are easier to manage and cheaper to use than
repeatedly formatting the parent name and subsequently leaving the clk
framework to perform lookups based on that name.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 70 +++
 1 file changed, 34 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c
index 6a58dd62bac5..c1710a8824e7 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c
@@ -588,24 +588,24 @@ static int dsi_7nm_set_usecase(struct msm_dsi_phy *phy)
  */
 static int pll_7nm_register(struct dsi_pll_7nm *pll_7nm, struct clk_hw 
**provided_clocks)
 {
-   char clk_name[32], parent[32], vco_name[32];
-   char parent2[32];
+   char clk_name[32];
struct clk_init_data vco_init = {
.parent_data = &(const struct clk_parent_data) {
.fw_name = "ref",
},
.num_parents = 1,
-   .name = vco_name,
+   .name = clk_name,
.flags = CLK_IGNORE_UNUSED,
.ops = _ops_dsi_pll_7nm_vco,
};
struct device *dev = _7nm->phy->pdev->dev;
-   struct clk_hw *hw;
+   struct clk_hw *hw, *pll_out_div, *pll_bit, *pll_by_2_bit;
+   struct clk_hw *pll_post_out_div, *phy_pll_out_dsi_parent;
int ret;
 
DBG("DSI%d", pll_7nm->phy->id);
 
-   snprintf(vco_name, sizeof(vco_name), "dsi%dvco_clk", pll_7nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%dvco_clk", pll_7nm->phy->id);
pll_7nm->clk_hw.init = _init;
 
ret = devm_clk_hw_register(dev, _7nm->clk_hw);
@@ -613,36 +613,34 @@ static int pll_7nm_register(struct dsi_pll_7nm *pll_7nm, 
struct clk_hw **provide
return ret;
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_out_div_clk", 
pll_7nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%dvco_clk", pll_7nm->phy->id);
 
-   hw = devm_clk_hw_register_divider(dev, clk_name, parent,
-   CLK_SET_RATE_PARENT, pll_7nm->phy->pll_base +
+   pll_out_div = devm_clk_hw_register_divider_parent_hw(dev, clk_name,
+   _7nm->clk_hw, CLK_SET_RATE_PARENT,
+   pll_7nm->phy->pll_base +
REG_DSI_7nm_PHY_PLL_PLL_OUTDIV_RATE,
0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
-   if (IS_ERR(hw)) {
-   ret = PTR_ERR(hw);
+   if (IS_ERR(pll_out_div)) {
+   ret = PTR_ERR(pll_out_div);
goto fail;
}
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_bit_clk", 
pll_7nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%d_pll_out_div_clk", 
pll_7nm->phy->id);
 
/* BIT CLK: DIV_CTRL_3_0 */
-   hw = devm_clk_hw_register_divider(dev, clk_name, parent,
-   CLK_SET_RATE_PARENT,
+   pll_bit = devm_clk_hw_register_divider_parent_hw(dev, clk_name,
+   pll_out_div, CLK_SET_RATE_PARENT,
pll_7nm->phy->base + REG_DSI_7nm_PHY_CMN_CLK_CFG0,
0, 4, CLK_DIVIDER_ONE_BASED, _7nm->postdiv_lock);
-   if (IS_ERR(hw)) {
-   ret = PTR_ERR(hw);
+   if (IS_ERR(pll_bit)) {
+   ret = PTR_ERR(pll_bit);
goto fail;
}
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_phy_pll_out_byteclk", 
pll_7nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%d_pll_bit_clk", pll_7nm->phy->id);
 
/* DSI Byte clock = VCO_CLK / OUT_DIV / BIT_DIV / 8 */
-   hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent,
-   CLK_SET_RATE_PARENT, 1,
+   hw = devm_clk_hw_register_fixed_factor_parent_hw(dev, clk_name,
+   pll_bit, CLK_SET_RATE_PARENT, 1,
pll_7nm->phy->cphy_mode ? 7 : 8);
if (IS_ERR(hw)) {
ret = PTR_ERR(hw);
@@ -652,24 +650,24 @@ static int pll_7nm_register(struct dsi_pll_7nm *pll_7nm, 
struct clk_hw **provide
provided_clocks[DSI_BYTE_PLL_CLK] = hw;
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_by_2_bit_clk", 
pll_7nm->phy->id);
-   snprintf(parent, sizeof(parent), "dsi%d_pll_bit_clk", pll_7nm->phy->id);
 
-   hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent,
-  0, 1, 2);
-   if (IS_ERR(hw)) {
-   ret = PTR_ERR(hw);
+   pll_by_2_bit = devm_clk_hw_register_fixed_factor_parent_hw(dev,
+   clk_name, pll_bit, 0, 1, 2);
+   if (IS_ERR(pll_by_2_bit)) {
+   ret = PTR_ERR(pll_by_2_bit);
goto fail;
}
 
snprintf(clk_name, sizeof(clk_name), "dsi%d_pll_post_out_div_clk", 
pll_7nm->phy->id);
-   snprintf(parent, sizeof(parent), 

[PATCH v3 08/11] drm/msm/dsi_phy_28nm: Replace parent names with clk_hw pointers

2022-06-29 Thread Marijn Suijten
parent_hw pointers are easier to manage and cheaper to use than
repeatedly formatting the parent name and subsequently leaving the clk
framework to perform lookups based on that name.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c | 50 ++
 1 file changed, 23 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
index 7d3cabeca743..04411fefb808 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
@@ -519,17 +519,17 @@ static int dsi_28nm_pll_restore_state(struct msm_dsi_phy 
*phy)
 
 static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, struct clk_hw 
**provided_clocks)
 {
-   char clk_name[32], parent1[32], parent2[32], vco_name[32];
+   char clk_name[32];
struct clk_init_data vco_init = {
.parent_data = &(const struct clk_parent_data) {
.fw_name = "ref", .name = "xo",
},
.num_parents = 1,
-   .name = vco_name,
+   .name = clk_name,
.flags = CLK_IGNORE_UNUSED,
};
struct device *dev = _28nm->phy->pdev->dev;
-   struct clk_hw *hw;
+   struct clk_hw *hw, *analog_postdiv, *indirect_path_div2, *byte_mux;
int ret;
 
DBG("%d", pll_28nm->phy->id);
@@ -539,32 +539,30 @@ static int pll_28nm_register(struct dsi_pll_28nm 
*pll_28nm, struct clk_hw **prov
else
vco_init.ops = _ops_dsi_pll_28nm_vco_hpm;
 
-   snprintf(vco_name, sizeof(vco_name), "dsi%dvco_clk", pll_28nm->phy->id);
+   snprintf(clk_name, sizeof(clk_name), "dsi%dvco_clk", pll_28nm->phy->id);
pll_28nm->clk_hw.init = _init;
ret = devm_clk_hw_register(dev, _28nm->clk_hw);
if (ret)
return ret;
 
snprintf(clk_name, sizeof(clk_name), "dsi%danalog_postdiv_clk", 
pll_28nm->phy->id);
-   snprintf(parent1, sizeof(parent1), "dsi%dvco_clk", pll_28nm->phy->id);
-   hw = devm_clk_hw_register_divider(dev, clk_name, parent1,
-   CLK_SET_RATE_PARENT, pll_28nm->phy->pll_base +
+   analog_postdiv = devm_clk_hw_register_divider_parent_hw(dev, clk_name,
+   _28nm->clk_hw, CLK_SET_RATE_PARENT,
+   pll_28nm->phy->pll_base +
REG_DSI_28nm_PHY_PLL_POSTDIV1_CFG,
0, 4, 0, NULL);
-   if (IS_ERR(hw))
-   return PTR_ERR(hw);
+   if (IS_ERR(analog_postdiv))
+   return PTR_ERR(analog_postdiv);
 
snprintf(clk_name, sizeof(clk_name), "dsi%dindirect_path_div2_clk", 
pll_28nm->phy->id);
-   snprintf(parent1, sizeof(parent1), "dsi%danalog_postdiv_clk", 
pll_28nm->phy->id);
-   hw = devm_clk_hw_register_fixed_factor(dev, clk_name, parent1,
-   CLK_SET_RATE_PARENT, 1, 2);
-   if (IS_ERR(hw))
-   return PTR_ERR(hw);
+   indirect_path_div2 = devm_clk_hw_register_fixed_factor_parent_hw(dev,
+   clk_name, analog_postdiv, CLK_SET_RATE_PARENT, 1, 2);
+   if (IS_ERR(indirect_path_div2))
+   return PTR_ERR(indirect_path_div2);
 
snprintf(clk_name, sizeof(clk_name), "dsi%dpll", pll_28nm->phy->id);
-   snprintf(parent1, sizeof(parent1), "dsi%dvco_clk", pll_28nm->phy->id);
-   hw = devm_clk_hw_register_divider(dev, clk_name, parent1, 0,
-   pll_28nm->phy->pll_base +
+   hw = devm_clk_hw_register_divider_parent_hw(dev, clk_name,
+   _28nm->clk_hw, 0, pll_28nm->phy->pll_base +
REG_DSI_28nm_PHY_PLL_POSTDIV3_CFG,
0, 8, 0, NULL);
if (IS_ERR(hw))
@@ -572,20 +570,18 @@ static int pll_28nm_register(struct dsi_pll_28nm 
*pll_28nm, struct clk_hw **prov
provided_clocks[DSI_PIXEL_PLL_CLK] = hw;
 
snprintf(clk_name, sizeof(clk_name), "dsi%dbyte_mux", 
pll_28nm->phy->id);
-   snprintf(parent1, sizeof(parent1), "dsi%dvco_clk", pll_28nm->phy->id);
-   snprintf(parent2, sizeof(parent2), "dsi%dindirect_path_div2_clk", 
pll_28nm->phy->id);
-   hw = devm_clk_hw_register_mux(dev, clk_name,
-   ((const char *[]){
-   parent1, parent2,
+   byte_mux = devm_clk_hw_register_mux_parent_hws(dev, clk_name,
+   ((const struct clk_hw *[]){
+   _28nm->clk_hw,
+   indirect_path_div2,
}), 2, CLK_SET_RATE_PARENT, pll_28nm->phy->pll_base +
REG_DSI_28nm_PHY_PLL_VREG_CFG, 1, 1, 0, NULL);
-   if (IS_ERR(hw))
-   return PTR_ERR(hw);
+   if (IS_ERR(byte_mux))
+   return PTR_ERR(byte_mux);
 
snprintf(clk_name, sizeof(clk_name), "dsi%dpllbyte", pll_28nm->phy->id);
-   

[PATCH v3 00/11] drm/msm/dsi_phy: Replace parent names with clk_hw pointers

2022-06-29 Thread Marijn Suijten
parent_hw pointers are easier to manage and cheaper to use than
repeatedly formatting the parent name and subsequently leaving the clk
framework to perform lookups based on that name.

This series starts out by adding extra constructors for divider, mux and
fixed-factor clocks that have parent_hw(s) pointer argument(s) instead
of some DT index or name.  Followed by individual patches performing the
conversion, one DSI PHY at a time.

dsi_phy_28nm_8960 includes an extra fixup to replace "eternal"
devm_kzalloc allocations (for the lifetime of the device) with
stack-local char arrays, like all the other DSI PHY drivers.

(Questions from v1 cover letter regarding the future of these drivers
 is omitted for brevity.)

And with enough future improvements out of the way, let's round out this
patch-series by stating that it has been successfully tested on:

- Sony Nile Discovery (Xperia XA2 Ultra): 14nm;
- Sony Seine PDX201 (Xperia 10II): 14nm;
- Sony Loire Suzu (Xperia X): 28nm.

And no diff is observed in debugfs's clk_summary.

Unfortunately all other devices in my collection with a 7/10nm DSI PHY
have a DSC panel which we have yet to get working.

Changes since v2:
- in fixed-factor:
  - Reorder if - else if change to consume less diff;
  - Go over 80-char column lint when adding new arguments to function
calls, instead of reflowing all arguments to adhere to this limit;
also consuming less diff.

v2: 
https://lore.kernel.org/linux-arm-msm/20220601220747.1145095-1-marijn.suij...@somainline.org/

Changes since v1:

- Moved indentation changes to separate patch (Dmitry);
- dsi_phy_28nm_8960: move clock name allocation removal prior to
  parent_hw refactor;
- Remove vco_name stack-local char array in favour of reusing clk_name
  (Dmitry);
- Inserted additional patch to replace hardcoded char-array length
  constant 32 with sizeof(clk_name).

v1: 
https://lore.kernel.org/linux-arm-msm/20220523213837.1016542-1-marijn.suij...@somainline.org/T/#u

Marijn Suijten (11):
  clk: divider: Introduce devm_clk_hw_register_divider_parent_hw()
  clk: mux: Introduce devm_clk_hw_register_mux_parent_hws()
  clk: fixed-factor: Introduce *clk_hw_register_fixed_factor_parent_hw()
  drm/msm/dsi/phy: Reindent and reflow multiline function calls
  drm/msm/dsi_phy_28nm_8960: Use stack memory for temporary clock names
  drm/msm/dsi/phy: Replace hardcoded char-array length with sizeof()
  drm/msm/dsi_phy_28nm_8960: Replace parent names with clk_hw pointers
  drm/msm/dsi_phy_28nm: Replace parent names with clk_hw pointers
  drm/msm/dsi_phy_14nm: Replace parent names with clk_hw pointers
  drm/msm/dsi_phy_10nm: Replace parent names with clk_hw pointers
  drm/msm/dsi_phy_7nm: Replace parent names with clk_hw pointers

 drivers/clk/clk-fixed-factor.c|  45 -
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_10nm.c| 165 +-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c|  55 +++---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c| 117 ++---
 .../gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c   |  90 +-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 156 -
 include/linux/clk-provider.h  |  34 
 7 files changed, 351 insertions(+), 311 deletions(-)

-- 
2.37.0



[PATCH v3 03/11] clk: fixed-factor: Introduce *clk_hw_register_fixed_factor_parent_hw()

2022-06-29 Thread Marijn Suijten
Add the devres and non-devres variant of
clk_hw_register_fixed_factor_parent_hw() for registering a fixed factor
clock with clk_hw parent pointer instead of parent name.

Signed-off-by: Marijn Suijten 
---
 drivers/clk/clk-fixed-factor.c | 45 ++
 include/linux/clk-provider.h   |  8 ++
 2 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index e6b36247c16b..f734e34735a9 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -78,7 +78,8 @@ static void devm_clk_hw_register_fixed_factor_release(struct 
device *dev, void *
 
 static struct clk_hw *
 __clk_hw_register_fixed_factor(struct device *dev, struct device_node *np,
-   const char *name, const char *parent_name, int index,
+   const char *name, const char *parent_name,
+   const struct clk_hw *parent_hw, int index,
unsigned long flags, unsigned int mult, unsigned int div,
bool devm)
 {
@@ -110,6 +111,8 @@ __clk_hw_register_fixed_factor(struct device *dev, struct 
device_node *np,
init.flags = flags;
if (parent_name)
init.parent_names = _name;
+   else if (parent_hw)
+   init.parent_hws = _hw;
else
init.parent_data = 
init.num_parents = 1;
@@ -148,16 +151,48 @@ struct clk_hw 
*devm_clk_hw_register_fixed_factor_index(struct device *dev,
const char *name, unsigned int index, unsigned long flags,
unsigned int mult, unsigned int div)
 {
-   return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, index,
+   return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, NULL, 
index,
  flags, mult, div, true);
 }
 EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor_index);
 
+/**
+ * devm_clk_hw_register_fixed_factor_parent_hw - Register a fixed factor clock 
with
+ * pointer to parent clock
+ * @dev: device that is registering this clock
+ * @name: name of this clock
+ * @parent_hw: pointer to parent clk
+ * @flags: fixed factor flags
+ * @mult: multiplier
+ * @div: divider
+ *
+ * Return: Pointer to fixed factor clk_hw structure that was registered or
+ * an error pointer.
+ */
+struct clk_hw *devm_clk_hw_register_fixed_factor_parent_hw(struct device *dev,
+   const char *name, const struct clk_hw *parent_hw,
+   unsigned long flags, unsigned int mult, unsigned int div)
+{
+   return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, parent_hw,
+ -1, flags, mult, div, true);
+}
+EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor_parent_hw);
+
+struct clk_hw *clk_hw_register_fixed_factor_parent_hw(struct device *dev,
+   const char *name, const struct clk_hw *parent_hw,
+   unsigned long flags, unsigned int mult, unsigned int div)
+{
+   return __clk_hw_register_fixed_factor(dev, NULL, name, NULL,
+ parent_hw, -1, flags, mult, div,
+ false);
+}
+EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor_parent_hw);
+
 struct clk_hw *clk_hw_register_fixed_factor(struct device *dev,
const char *name, const char *parent_name, unsigned long flags,
unsigned int mult, unsigned int div)
 {
-   return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, -1,
+   return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, 
NULL, -1,
  flags, mult, div, false);
 }
 EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor);
@@ -204,7 +239,7 @@ struct clk_hw *devm_clk_hw_register_fixed_factor(struct 
device *dev,
const char *name, const char *parent_name, unsigned long flags,
unsigned int mult, unsigned int div)
 {
-   return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, -1,
+   return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, 
NULL, -1,
flags, mult, div, true);
 }
 EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor);
@@ -231,7 +266,7 @@ static struct clk_hw *_of_fixed_factor_clk_setup(struct 
device_node *node)
 
of_property_read_string(node, "clock-output-names", _name);
 
-   hw = __clk_hw_register_fixed_factor(NULL, node, clk_name, NULL, 0,
+   hw = __clk_hw_register_fixed_factor(NULL, node, clk_name, NULL, NULL, 0,
0, mult, div, false);
if (IS_ERR(hw)) {
/*
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 3a76a67241e8..1615010aa0ec 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -1032,6 +1032,14 @@ struct clk_hw *devm_clk_hw_register_fixed_factor(struct 
device *dev,
 struct clk_hw 

[PATCH v3 05/11] drm/msm/dsi_phy_28nm_8960: Use stack memory for temporary clock names

2022-06-29 Thread Marijn Suijten
The clock names formatted into the hw_clk's init structure are only used
for the duration of the registration function where they are kstrdup'ed,
making it unnecessary to keep the allocations alive for the duration of
the device (through devm).

Just like the other DSI PHY PLL clock trees, use a stack-local char
array and save on memory outside of the pll_28nm_register function.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
index af630b8eb9f3..24bac401b210 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
@@ -383,7 +383,7 @@ static int dsi_28nm_pll_restore_state(struct msm_dsi_phy 
*phy)
 
 static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, struct clk_hw 
**provided_clocks)
 {
-   char *clk_name, *parent_name, *vco_name;
+   char clk_name[32], parent_name[32], vco_name[32];
struct clk_init_data vco_init = {
.parent_data = &(const struct clk_parent_data) {
.fw_name = "ref",
@@ -404,18 +404,6 @@ static int pll_28nm_register(struct dsi_pll_28nm 
*pll_28nm, struct clk_hw **prov
if (!bytediv)
return -ENOMEM;
 
-   vco_name = devm_kzalloc(dev, 32, GFP_KERNEL);
-   if (!vco_name)
-   return -ENOMEM;
-
-   parent_name = devm_kzalloc(dev, 32, GFP_KERNEL);
-   if (!parent_name)
-   return -ENOMEM;
-
-   clk_name = devm_kzalloc(dev, 32, GFP_KERNEL);
-   if (!clk_name)
-   return -ENOMEM;
-
snprintf(vco_name, 32, "dsi%dvco_clk", pll_28nm->phy->id);
vco_init.name = vco_name;
 
-- 
2.37.0



[PATCH v3 01/11] clk: divider: Introduce devm_clk_hw_register_divider_parent_hw()

2022-06-29 Thread Marijn Suijten
Add the devres variant of clk_hw_register_divider_parent_hw() for
registering a divider clock with clk_hw parent pointer instead of parent
name.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 include/linux/clk-provider.h | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 72d937c03a3e..f3f2ae1229f8 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -831,6 +831,25 @@ struct clk *clk_register_divider_table(struct device *dev, 
const char *name,
__devm_clk_hw_register_divider((dev), NULL, (name), (parent_name), 
NULL,   \
  NULL, (flags), (reg), (shift), (width), \
  (clk_divider_flags), NULL, (lock))
+/**
+ * devm_clk_hw_register_divider_parent_hw - register a divider clock with the 
clock framework
+ * @dev: device registering this clock
+ * @name: name of this clock
+ * @parent_hw: pointer to parent clk
+ * @flags: framework-specific flags
+ * @reg: register address to adjust divider
+ * @shift: number of bits to shift the bitfield
+ * @width: width of the bitfield
+ * @clk_divider_flags: divider-specific flags for this clock
+ * @lock: shared register lock for this clock
+ */
+#define devm_clk_hw_register_divider_parent_hw(dev, name, parent_hw, flags,   \
+  reg, shift, width, \
+  clk_divider_flags, lock)   \
+   __devm_clk_hw_register_divider((dev), NULL, (name), NULL, \
+  (parent_hw), NULL, (flags), (reg), \
+  (shift), (width), (clk_divider_flags), \
+  NULL, (lock))
 /**
  * devm_clk_hw_register_divider_table - register a table based divider clock
  * with the clock framework (devres variant)
-- 
2.37.0



[PATCH v3 02/11] clk: mux: Introduce devm_clk_hw_register_mux_parent_hws()

2022-06-29 Thread Marijn Suijten
Add the devres variant of clk_hw_register_mux_hws() for registering a
mux clock with clk_hw parent pointers instead of parent names.

Signed-off-by: Marijn Suijten 
Reviewed-by: Dmitry Baryshkov 
---
 include/linux/clk-provider.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index f3f2ae1229f8..3a76a67241e8 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -980,6 +980,13 @@ struct clk *clk_register_mux_table(struct device *dev, 
const char *name,
  (parent_names), NULL, NULL, (flags), (reg), \
  (shift), BIT((width)) - 1, (clk_mux_flags), \
  NULL, (lock))
+#define devm_clk_hw_register_mux_parent_hws(dev, name, parent_hws,   \
+   num_parents, flags, reg, shift,   \
+   width, clk_mux_flags, lock)   \
+   __devm_clk_hw_register_mux((dev), NULL, (name), (num_parents), NULL,  \
+  (parent_hws), NULL, (flags), (reg),\
+  (shift), BIT((width)) - 1, \
+  (clk_mux_flags), NULL, (lock))
 
 int clk_mux_val_to_index(struct clk_hw *hw, const u32 *table, unsigned int 
flags,
 unsigned int val);
-- 
2.37.0



Re: [PATCH v2] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init

2022-06-29 Thread Dmitry Osipenko
On 6/2/22 13:42, Miaoqian Lin wrote:
> Since drm_prime_pages_to_sg() function return error pointers.
> The drm_gem_shmem_get_sg_table() function returns error pointers too.
> Using IS_ERR() to check the return value to fix this.
> 
> Fixes: 2f2aa13724d5 ("drm/virtio: move virtio_gpu_mem_entry initialization to 
> new function")
> Signed-off-by: Miaoqian Lin 
> ---
> changes in v2:
> - Update Fixes tag.
> - rebase the working tree.
> v1 Link: 
> https://lore.kernel.org/all/20211222072649.18169-1-linmq...@gmail.com/
> ---
>  drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c 
> b/drivers/gpu/drm/virtio/virtgpu_object.c
> index f293e6ad52da..1cc8f3fc8e4b 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_object.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_object.c
> @@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(struct 
> virtio_gpu_device *vgdev,
>* since virtio_gpu doesn't support dma-buf import from other devices.
>*/
>   shmem->pages = drm_gem_shmem_get_sg_table(>base);
> - if (!shmem->pages) {
> + if (IS_ERR(shmem->pages)) {
>   drm_gem_shmem_unpin(>base);
> - return -EINVAL;
> + return PTR_ERR(shmem->pages);
>   }
>  
>   if (use_dma_api) {

Sorry for noticing this late. This patch is incorrect because
shmem->pages must be NULLed on error, otherwise
virtio_gpu_cleanup_object() will crash :/

I also had a patch that fixes this problem [1] and it did it properly. I
see that this patch is in -next already, so will update my patch to fix
the fix now.

[1]
https://vanko.io/project/dri-devel/patch/20220526235040.678984-6-dmitry.osipe...@collabora.com/

-- 
Best regards,
Dmitry


Re: [PATCH v7 01/14] mm: rename is_pinnable_pages to is_pinnable_longterm_pages

2022-06-29 Thread David Hildenbrand
On 30.06.22 00:08, Felix Kuehling wrote:
> On 2022-06-29 03:33, David Hildenbrand wrote:
>> On 29.06.22 05:54, Alex Sierra wrote:
>>> is_pinnable_page() and folio_is_pinnable() were renamed to
>>> is_longterm_pinnable_page() and folio_is_longterm_pinnable()
>>> respectively. These functions are used in the FOLL_LONGTERM flag
>>> context.
>> Subject talks about "*_pages"
>>
>>
>> Can you elaborate why the move from mm.h to memremap.h is justified?
> 
> Patch 2 adds is_device_coherent_page in memremap.h and updates 
> is_longterm_pinnable_page to call is_device_coherent_page. memremap.h 
> cannot include mm.h because it is itself included by mm.h. So the choice 
> was to move is_longterm_pinnable_page to memremap.h, or move 
> is_device_coherent_page and all its dependencies to mm.h. The latter 
> would have been a bigger change.

I really don't think something mm generic that compiles without
ZONE_DEVICE belongs into memremap.h. Please find a cleaner way to get
this done.

-- 
Thanks,

David / dhildenb



Re: [PATCH v7 01/14] mm: rename is_pinnable_pages to is_pinnable_longterm_pages

2022-06-29 Thread Felix Kuehling

On 2022-06-29 03:33, David Hildenbrand wrote:

On 29.06.22 05:54, Alex Sierra wrote:

is_pinnable_page() and folio_is_pinnable() were renamed to
is_longterm_pinnable_page() and folio_is_longterm_pinnable()
respectively. These functions are used in the FOLL_LONGTERM flag
context.

Subject talks about "*_pages"


Can you elaborate why the move from mm.h to memremap.h is justified?


Patch 2 adds is_device_coherent_page in memremap.h and updates 
is_longterm_pinnable_page to call is_device_coherent_page. memremap.h 
cannot include mm.h because it is itself included by mm.h. So the choice 
was to move is_longterm_pinnable_page to memremap.h, or move 
is_device_coherent_page and all its dependencies to mm.h. The latter 
would have been a bigger change.





I'd have called it "is_longterm_pinnable_page", but I am not a native
speaker, so no strong opinion :)


I think only the patch title has the name backwards. The code uses 
is_longterm_pinnable_page.


Regards,
  Felix







Re: [PATCH v5 1/9] dt-bindings: usb: Add Type-C switch binding

2022-06-29 Thread Stephen Boyd
Quoting Rob Herring (2022-06-29 10:58:52)
> On Wed, Jun 29, 2022 at 9:01 AM Pin-yen Lin  wrote:
> > >
> > > Yes it6505 is just a protocol converter. But in our use case, the output 
> > > DP
> > > lines are connected to the Type-C ports and the chip has to know which
> > > port has DP Alt mode enabled. Does this justify a child node here?
> > >
> > > Does it make more sense if we we eliminate the usb-switch node here
> > > and list the ports in the top level?
>
> In the it6505 node? No, the it6505 h/w knows nothing about Type-C
> switching so neither should its binding.
>
> What device controls the switching in this case? Again, block diagrams
> please if you want advice on what the binding should look like.

My understanding is there are 4 DP lanes on it6505 and two lanes are
connected to one usb-c-connector and the other two lanes are connected
to a different usb-c-connector. The IT6505 driver will send DP out on
the associated two DP lanes depending on which usb-c-connector has DP
pins assigned by the typec manager.

 +---+
 |   |
  ++/+ usb-c |
  | IT6505 |   / /---+   |
  |+ lane 0 --/ /|   |
  |+ lane 1 ---/ +---+
 DPI -+|
  || +---+
  || |   |
  |+ lane 2 -+ usb-c |
  |+ lane 3 -+   |
  || |   |
  ++ +---+

The bridge is a mux that steers DP to one or the other usb-c-connector
based on what the typec manager decides.

I would expect this to be described with the existing port binding in
the it6505 node. The binding would need to be extended to describe the
output side.

bridge@5c {
compatible = "ite,it6505";
...

ports {
#address-cells = <1>;
#size-cells = <0>;

port@0 {
reg = <0>;
it6505_in: endpoint {
remote-endpoint = <_out>;
};
};

port@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <1>;

it6505_out_lanes_01: endpoint@0 {
reg = <0>
data-lanes = <0 1>;
remote-endpoint = <>;
};

it6505_out_lanes_23: endpoint@1 {
reg = <1>
data-lanes = <2 3>;
remote-endpoint = <>;
};
};
};
};

usb-c-connector {
compatible = "usb-c-connector";

ports {
#address-cells = <1>;
#size-cells = <0>;

port@1 {
reg = <1>;
typec0: endpoint {
remote-endpoint = <_out_lanes_01>;
};
};
};
};

Note: port@1 in usb-c-connector above is for superspeed lines, which
technically DP reuses. But we can also shove USB3 superspeed lines over
the other two superspeed pins in the usb-c-connector pinout. Probably
port@1 should have two endpoints so we can connect usb superspeed lines
there in addition to DP lines.

Another use case would be to have the IT6505 send 4 lanes of DP to a
dp-connector. Or send one lane of DP to 4 dp-connectors? Sounds awful but
possible if this bridge can drive one lane DP out on any DP output lane.

bridge@5c {
compatible = "ite,it6505";
...

ports {
#address-cells = <1>;
#size-cells = <0>;

port@0 {
reg = <0>;
it6505_in: endpoint {
remote-endpoint = <_out>;
};
};

port@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <1>;

it6505_out_lane_0: endpoint@0 {
reg = <0>
data-lanes = <0>;
remote-endpoint = <>;
};

it6505_out_lane_1: endpoint@1 {
reg = <1>
data-lanes = <1>;
remote-endpoint = <>;
};

it6505_out_lane_2: endpoint@2 {
reg = <2>
data-lanes = <2>;
  

Re: [PATCH 6/6] i2c: Make remove callback return void

2022-06-29 Thread Luca Ceresoli
Hi,

[keeping only individuals and lists in Cc to avoid bounces]

On 28/06/22 16:03, Uwe Kleine-König wrote:
> From: Uwe Kleine-König 
> 
> The value returned by an i2c driver's remove function is mostly ignored.
> (Only an error message is printed if the value is non-zero that the
> error is ignored.)
> 
> So change the prototype of the remove function to return no value. This
> way driver authors are not tempted to assume that passing an error to
> the upper layer is a good idea. All drivers are adapted accordingly.
> There is no intended change of behaviour, all callbacks were prepared to
> return 0 before.
> 
> Signed-off-by: Uwe Kleine-König 

For versaclock:

> diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
> index e7be3e54b9be..657493ecce4c 100644
> --- a/drivers/clk/clk-versaclock5.c
> +++ b/drivers/clk/clk-versaclock5.c
> @@ -1138,7 +1138,7 @@ static int vc5_probe(struct i2c_client *client)
>   return ret;
>  }
>  
> -static int vc5_remove(struct i2c_client *client)
> +static void vc5_remove(struct i2c_client *client)
>  {
>   struct vc5_driver_data *vc5 = i2c_get_clientdata(client);
>  
> @@ -1146,8 +1146,6 @@ static int vc5_remove(struct i2c_client *client)
>  
>   if (vc5->chip_info->flags & VC5_HAS_INTERNAL_XTAL)
>   clk_unregister_fixed_rate(vc5->pin_xin);
> -
> - return 0;
>  }
>  
>  static int __maybe_unused vc5_suspend(struct device *dev)

Reviewed-by: Luca Ceresoli 
Reviewed-by: Luca Ceresoli 

-- 
Luca


[PATCH 2/2] drm/msm/gpu: Add GEM debug label to devcore

2022-06-29 Thread Rob Clark
From: Rob Clark 

When trying to understand an iova fault devcore, once you figure out
which buffer we accessed beyond the end of, it is useful to see the
buffer's debug label.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 1 +
 drivers/gpu/drm/msm/msm_gpu.c   | 4 
 drivers/gpu/drm/msm/msm_gpu.h   | 1 +
 3 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index dff33f0558f3..382fb7f9e497 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -824,6 +824,7 @@ void adreno_show(struct msm_gpu *gpu, struct msm_gpu_state 
*state,
drm_printf(p, "  - iova: 0x%016llx\n",
state->bos[i].iova);
drm_printf(p, "size: %zd\n", state->bos[i].size);
+   drm_printf(p, "name: %-32s\n", state->bos[i].name);
 
adreno_show_object(p, >bos[i].data,
state->bos[i].size, >bos[i].encoded);
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 293f3380fafe..fba85f894314 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -229,6 +229,10 @@ static void msm_gpu_crashstate_get_bo(struct msm_gpu_state 
*state,
state_bo->size = obj->base.size;
state_bo->iova = iova;
 
+   BUILD_BUG_ON(sizeof(state_bo->name) != sizeof(obj->name));
+
+   memcpy(state_bo->name, obj->name, sizeof(state_bo->name));
+
if (full) {
void *ptr;
 
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index b837785cdb04..4816caed22d0 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -476,6 +476,7 @@ struct msm_gpu_state_bo {
size_t size;
void *data;
bool encoded;
+   char name[32];
 };
 
 struct msm_gpu_state {
-- 
2.36.1



[PATCH 1/2] drm/msm/gpu: Capture all BO addr+size in devcore

2022-06-29 Thread Rob Clark
From: Rob Clark 

It is useful to know what buffers userspace thinks are associated with
the submit, even if we don't care to capture their content.  This brings
things more inline with $debugfs/rd cmdstream dumping.

Signed-off-by: Rob Clark 
---
 drivers/gpu/drm/msm/msm_gpu.c | 36 ---
 1 file changed, 8 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index bdee6ea51b73..293f3380fafe 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -221,7 +221,7 @@ static void msm_gpu_devcoredump_free(void *data)
 }
 
 static void msm_gpu_crashstate_get_bo(struct msm_gpu_state *state,
-   struct msm_gem_object *obj, u64 iova, u32 flags)
+   struct msm_gem_object *obj, u64 iova, bool full)
 {
struct msm_gpu_state_bo *state_bo = >bos[state->nr_bos];
 
@@ -229,8 +229,7 @@ static void msm_gpu_crashstate_get_bo(struct msm_gpu_state 
*state,
state_bo->size = obj->base.size;
state_bo->iova = iova;
 
-   /* Only store data for non imported buffer objects marked for read */
-   if ((flags & MSM_SUBMIT_BO_READ) && !obj->base.import_attach) {
+   if (full) {
void *ptr;
 
state_bo->data = kvmalloc(obj->base.size, GFP_KERNEL);
@@ -276,34 +275,15 @@ static void msm_gpu_crashstate_capture(struct msm_gpu 
*gpu,
state->fault_info = gpu->fault_info;
 
if (submit) {
-   int i, nr = 0;
-
-   /* count # of buffers to dump: */
-   for (i = 0; i < submit->nr_bos; i++)
-   if (should_dump(submit, i))
-   nr++;
-   /* always dump cmd bo's, but don't double count them: */
-   for (i = 0; i < submit->nr_cmds; i++)
-   if (!should_dump(submit, submit->cmd[i].idx))
-   nr++;
-
-   state->bos = kcalloc(nr,
+   int i;
+
+   state->bos = kcalloc(submit->nr_bos,
sizeof(struct msm_gpu_state_bo), GFP_KERNEL);
 
for (i = 0; state->bos && i < submit->nr_bos; i++) {
-   if (should_dump(submit, i)) {
-   msm_gpu_crashstate_get_bo(state, 
submit->bos[i].obj,
-   submit->bos[i].iova, 
submit->bos[i].flags);
-   }
-   }
-
-   for (i = 0; state->bos && i < submit->nr_cmds; i++) {
-   int idx = submit->cmd[i].idx;
-
-   if (!should_dump(submit, submit->cmd[i].idx)) {
-   msm_gpu_crashstate_get_bo(state, 
submit->bos[idx].obj,
-   submit->bos[idx].iova, 
submit->bos[idx].flags);
-   }
+   msm_gpu_crashstate_get_bo(state, submit->bos[i].obj,
+ submit->bos[i].iova,
+ should_dump(submit, i));
}
}
 
-- 
2.36.1



[PATCH 0/2] drm/msm: A couple GPU devcore enhancements

2022-06-29 Thread Rob Clark
From: Rob Clark 

A couple things useful for debugging iova faults:

1. caputre all buffer addresses and sizes even if we don't capture their
   contents.
2. capture the GEM buffer debug labels

Rob Clark (2):
  drm/msm/gpu: Capture all BO addr+size in devcore
  drm/msm/gpu: Add GEM debug label to devcore

 drivers/gpu/drm/msm/adreno/adreno_gpu.c |  1 +
 drivers/gpu/drm/msm/msm_gpu.c   | 40 -
 drivers/gpu/drm/msm/msm_gpu.h   |  1 +
 3 files changed, 14 insertions(+), 28 deletions(-)

-- 
2.36.1



[PATCH] Revert "drivers/video/backlight/platform_lcd.c: add support for device tree based probe"

2022-06-29 Thread Rob Herring
This reverts commit 52e842432f36d5b15227d0ee0d2aa3d2bc3cc0b2.

The DT support never would have worked because there's no platform_data
providing ops. There's not any documented binding for it either.

Cc: Jingoo Han 
Signed-off-by: Rob Herring 
---
 drivers/video/backlight/platform_lcd.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/video/backlight/platform_lcd.c 
b/drivers/video/backlight/platform_lcd.c
index b2bfbf070200..dc37494baf42 100644
--- a/drivers/video/backlight/platform_lcd.c
+++ b/drivers/video/backlight/platform_lcd.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -133,19 +132,10 @@ static int platform_lcd_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(platform_lcd_pm_ops, platform_lcd_suspend,
platform_lcd_resume);
 
-#ifdef CONFIG_OF
-static const struct of_device_id platform_lcd_of_match[] = {
-   { .compatible = "platform-lcd" },
-   {},
-};
-MODULE_DEVICE_TABLE(of, platform_lcd_of_match);
-#endif
-
 static struct platform_driver platform_lcd_driver = {
.driver = {
.name   = "platform-lcd",
.pm = _lcd_pm_ops,
-   .of_match_table = of_match_ptr(platform_lcd_of_match),
},
.probe  = platform_lcd_probe,
 };
-- 
2.34.1



drm-misc-next: WARNING: at drivers/gpu/drm/vc4/vc4_hdmi_regs.h:487

2022-06-29 Thread Stefan Wahren

Hi Maxime,

i tested todays drm-misc-next 9db35bb349 with Raspberry Pi 3 B Plus 
(arm/multi_v7_defconfig, mainline DTB) and get the following warning in 
the kernel logs:


[   25.698459] vc4-drm soc:gpu: bound 3f40.hvs (ops vc4_hvs_ops [vc4])
[   25.698657] [ cut here ]
[   25.698660] WARNING: CPU: 1 PID: 153 at 
drivers/gpu/drm/vc4/vc4_hdmi_regs.h:487 vc4_hdmi_reset+0x3e0/0x4e0 [vc4]
[   25.698757] Modules linked in: brcmutil vc4(+) snd_soc_core ac97_bus 
sha256_generic libsha256 snd_pcm_dmaengine sha256_arm snd_pcm cfg80211 
snd_timer hci_uart btbcm snd soundcore bluetooth raspberrypi_hwmon 
drm_cma_helper ecdh_generic ecc libaes bcm2835_thermal microchip lan78xx 
crc32_arm_ce
[   25.698831] CPU: 1 PID: 153 Comm: systemd-udevd Not tainted 
5.19.0-rc2-00085-g9db35bb349a0 #2

[   25.698839] Hardware name: BCM2835
[   25.698850]  unwind_backtrace from show_stack+0x10/0x14
[   25.698866]  show_stack from dump_stack_lvl+0x40/0x4c
[   25.698879]  dump_stack_lvl from __warn+0xcc/0x144
[   25.698890]  __warn from warn_slowpath_fmt+0x5c/0xb4
[   25.698900]  warn_slowpath_fmt from vc4_hdmi_reset+0x3e0/0x4e0 [vc4]
[   25.698996]  vc4_hdmi_reset [vc4] from 
vc4_hdmi_runtime_resume+0x4c/0x64 [vc4]
[   25.699165]  vc4_hdmi_runtime_resume [vc4] from 
vc4_hdmi_bind+0x208/0x994 [vc4]

[   25.699333]  vc4_hdmi_bind [vc4] from component_bind_all+0x100/0x230
[   25.699428]  component_bind_all from vc4_drm_bind+0x1a8/0x280 [vc4]
[   25.699518]  vc4_drm_bind [vc4] from 
try_to_bring_up_aggregate_device+0x160/0x1bc
[   25.699610]  try_to_bring_up_aggregate_device from 
component_master_add_with_match+0xc4/0xf8
[   25.699622]  component_master_add_with_match from 
vc4_platform_drm_probe+0xa0/0xc0 [vc4]

[   25.699712]  vc4_platform_drm_probe [vc4] from platform_probe+0x5c/0xbc
[   25.699802]  platform_probe from really_probe.part.0+0x9c/0x2b0
[   25.699812]  really_probe.part.0 from __driver_probe_device+0xa8/0x13c
[   25.699823]  __driver_probe_device from driver_probe_device+0x34/0x108
[   25.699834]  driver_probe_device from __driver_attach+0xb4/0x17c
[   25.699846]  __driver_attach from bus_for_each_dev+0x70/0xb0
[   25.699856]  bus_for_each_dev from bus_add_driver+0x164/0x1f0
[   25.699867]  bus_add_driver from driver_register+0x88/0x11c
[   25.699878]  driver_register from do_one_initcall+0x40/0x1d4
[   25.699890]  do_one_initcall from do_init_module+0x44/0x1d4
[   25.699901]  do_init_module from sys_finit_module+0xbc/0xf8
[   25.699909]  sys_finit_module from __sys_trace_return+0x0/0x10
[   25.699918] Exception stack(0xf568dfa8 to 0xf568dff0)
[   25.699926] dfa0:   6a09f700  0016 
b6dee8e0  b6def3f4
[   25.699934] dfc0: 6a09f700   017b 0053b9a8 
0052a1dc 0053af10 

[   25.699940] dfe0: be8e5160 be8e5150 b6de59d8 b6ed5ae0
[   25.699944] ---[ end trace  ]---

I was able to bisect the warning to the following commit:

drm/vc4: hdmi: Move HDMI reset to pm_resume

The BCM2835-37 found in the RaspberryPi 0 to 3 have a power domain
attached to the HDMI block, handled in Linux through runtime_pm.

That power domain is shared with the VEC block, so even if we put our
runtime_pm reference in the HDMI driver it would keep being on. If the
VEC is disabled though, the power domain would be disabled and we would
lose any initialization done in our bind implementation.

That initialization involves calling the reset function and initializing
the CEC registers.

Let's move the initialization to our runtime_resume implementation so
that we initialize everything properly if we ever need to.

Fixes: c86b41214362 ("drm/vc4: hdmi: Move the HSM clock enable to 
runtime_pm")

Signed-off-by: Dave Stevenson 
Link: https://lore.kernel.org/r/20220613144800.326124-24-max...@cerno.tech
Signed-off-by: Maxime Ripard 



Re: [PATCH 6/6] i2c: Make remove callback return void

2022-06-29 Thread Greg Kroah-Hartman
On Tue, Jun 28, 2022 at 04:03:12PM +0200, Uwe Kleine-König wrote:
> From: Uwe Kleine-König 
> 
> The value returned by an i2c driver's remove function is mostly ignored.
> (Only an error message is printed if the value is non-zero that the
> error is ignored.)
> 
> So change the prototype of the remove function to return no value. This
> way driver authors are not tempted to assume that passing an error to
> the upper layer is a good idea. All drivers are adapted accordingly.
> There is no intended change of behaviour, all callbacks were prepared to
> return 0 before.
> 
> Signed-off-by: Uwe Kleine-König 

Acked-by: Greg Kroah-Hartman 


Re: [PATCH v2 7/8] dma-buf: remove useless FMODE_LSEEK flag

2022-06-29 Thread Sumit Semwal
On Mon, 27 Jun 2022 at 14:38, Daniel Vetter  wrote:
>
> On Sat, Jun 25, 2022 at 01:01:14PM +0200, Jason A. Donenfeld wrote:
> > This is already set by anon_inode_getfile(), since dma_buf_fops has
> > non-NULL ->llseek, so we don't need to set it here too.
> >
> > Suggested-by: Al Viro 
> > Cc: Sumit Semwal 
> > Cc: Christian König 
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Jason A. Donenfeld 
>
> I'm assuming this is part of a vfs cleanup and lands through that tree?
> For that:
>
> Acked-by: Daniel Vetter 
FWIW, please feel free to add
Acked-by: Sumit Semwal 

>
> > ---
> >  drivers/dma-buf/dma-buf.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> > index 32f55640890c..3f08e0b960ec 100644
> > --- a/drivers/dma-buf/dma-buf.c
> > +++ b/drivers/dma-buf/dma-buf.c
> > @@ -549,7 +549,6 @@ struct dma_buf *dma_buf_export(const struct 
> > dma_buf_export_info *exp_info)
> >   goto err_dmabuf;
> >   }
> >
> > - file->f_mode |= FMODE_LSEEK;
> >   dmabuf->file = file;
> >
> >   mutex_init(>lock);
> > --
> > 2.35.1
> >
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch


Best,
Sumit.


Re: [PATCH 6/6] i2c: Make remove callback return void

2022-06-29 Thread Miguel Ojeda
On Tue, Jun 28, 2022 at 4:08 PM Uwe Kleine-König
 wrote:
>
>  drivers/auxdisplay/ht16k33.c  | 4 +---
>  drivers/auxdisplay/lcd2s.c| 3 +--

Acked-by: Miguel Ojeda 

Cheers,
Miguel


Re: [PATCH 6/6] i2c: Make remove callback return void

2022-06-29 Thread Hans Verkuil
On 28/06/2022 16:03, Uwe Kleine-König wrote:
> From: Uwe Kleine-König 
> 
> The value returned by an i2c driver's remove function is mostly ignored.
> (Only an error message is printed if the value is non-zero that the
> error is ignored.)
> 
> So change the prototype of the remove function to return no value. This
> way driver authors are not tempted to assume that passing an error to
> the upper layer is a good idea. All drivers are adapted accordingly.
> There is no intended change of behaviour, all callbacks were prepared to
> return 0 before.
> 
> Signed-off-by: Uwe Kleine-König 

For all drivers under drivers/media and drivers/staging/media:

Reviewed-by: Hans Verkuil 

Nice change! I like it.

Hans

> ---
>  Documentation/i2c/writing-clients.rst | 2 +-
>  arch/arm/mach-davinci/board-dm644x-evm.c  | 3 +--
>  arch/arm/mach-davinci/board-dm646x-evm.c  | 3 +--
>  arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c| 3 +--
>  drivers/auxdisplay/ht16k33.c  | 4 +---
>  drivers/auxdisplay/lcd2s.c| 3 +--
>  drivers/char/ipmi/ipmb_dev_int.c  | 4 +---
>  drivers/char/ipmi/ipmi_ipmb.c | 4 +---
>  drivers/char/ipmi/ipmi_ssif.c | 6 ++
>  drivers/char/tpm/st33zp24/i2c.c   | 4 +---
>  drivers/char/tpm/tpm_i2c_atmel.c  | 3 +--
>  drivers/char/tpm/tpm_i2c_infineon.c   | 4 +---
>  drivers/char/tpm/tpm_i2c_nuvoton.c| 3 +--
>  drivers/char/tpm/tpm_tis_i2c_cr50.c   | 6 ++
>  drivers/clk/clk-cdce706.c | 3 +--
>  drivers/clk/clk-cs2000-cp.c   | 4 +---
>  drivers/clk/clk-si514.c   | 3 +--
>  drivers/clk/clk-si5341.c  | 4 +---
>  drivers/clk/clk-si5351.c  | 4 +---
>  drivers/clk/clk-si570.c   | 3 +--
>  drivers/clk/clk-versaclock5.c | 4 +---
>  drivers/crypto/atmel-ecc.c| 6 ++
>  drivers/crypto/atmel-sha204a.c| 6 ++
>  drivers/extcon/extcon-rt8973a.c   | 4 +---
>  drivers/gpio/gpio-adp5588.c   | 4 +---
>  drivers/gpio/gpio-max7300.c   | 4 +---
>  drivers/gpio/gpio-pca953x.c   | 4 +---
>  drivers/gpio/gpio-pcf857x.c   | 4 +---
>  drivers/gpio/gpio-tpic2810.c  | 4 +---
>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c  | 4 +---
>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c| 4 +---
>  drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c| 4 +---
>  drivers/gpu/drm/bridge/analogix/anx7625.c | 4 +---
>  drivers/gpu/drm/bridge/chrontel-ch7033.c  | 4 +---
>  drivers/gpu/drm/bridge/cros-ec-anx7688.c  | 4 +---
>  drivers/gpu/drm/bridge/ite-it6505.c   | 4 +---
>  drivers/gpu/drm/bridge/ite-it66121.c  | 4 +---
>  drivers/gpu/drm/bridge/lontium-lt8912b.c  | 3 +--
>  drivers/gpu/drm/bridge/lontium-lt9211.c   | 4 +---
>  drivers/gpu/drm/bridge/lontium-lt9611.c   | 4 +---
>  drivers/gpu/drm/bridge/lontium-lt9611uxc.c| 4 +---
>  drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c  | 8 ++--
>  drivers/gpu/drm/bridge/nxp-ptn3460.c  | 4 +---
>  drivers/gpu/drm/bridge/parade-ps8622.c| 4 +---
>  drivers/gpu/drm/bridge/parade-ps8640.c| 4 +---
>  drivers/gpu/drm/bridge/sii902x.c  | 4 +---
>  drivers/gpu/drm/bridge/sii9234.c  | 4 +---
>  drivers/gpu/drm/bridge/sil-sii8620.c  | 4 +---
>  drivers/gpu/drm/bridge/tc358767.c | 4 +---
>  drivers/gpu/drm/bridge/tc358768.c | 4 +---
>  drivers/gpu/drm/bridge/tc358775.c | 4 +---
>  drivers/gpu/drm/bridge/ti-sn65dsi83.c | 4 +---
>  drivers/gpu/drm/bridge/ti-tfp410.c| 4 +---
>  drivers/gpu/drm/i2c/ch7006_drv.c  | 4 +---
>  drivers/gpu/drm/i2c/tda9950.c | 4 +---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 3 +--
>  drivers/gpu/drm/panel/panel-olimex-lcd-olinuxino.c| 4 +---
>  drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 4 +---
>  drivers/gpu/drm/solomon/ssd130x-i2c.c | 4 +---
>  drivers/hid/i2c-hid/i2c-hid-core.c| 4 +---
>  drivers/hid/i2c-hid/i2c-hid.h | 2 +-
> 

Re: [PATCH 6/6] i2c: Make remove callback return void

2022-06-29 Thread Marek Behún
On Tue, 28 Jun 2022 16:03:12 +0200
Uwe Kleine-König  wrote:

> From: Uwe Kleine-König 
> 
> The value returned by an i2c driver's remove function is mostly ignored.
> (Only an error message is printed if the value is non-zero that the
> error is ignored.)
> 
> So change the prototype of the remove function to return no value. This
> way driver authors are not tempted to assume that passing an error to
> the upper layer is a good idea. All drivers are adapted accordingly.
> There is no intended change of behaviour, all callbacks were prepared to
> return 0 before.
> 
> Signed-off-by: Uwe Kleine-König 

For

>  drivers/leds/leds-turris-omnia.c  | 4 +---

Acked-by: Marek Behún 


Re: [PATCH 6/6] i2c: Make remove callback return void

2022-06-29 Thread Heikki Krogerus
On Tue, Jun 28, 2022 at 04:03:12PM +0200, Uwe Kleine-König wrote:
> diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
> index cd47c3597e19..2a58185fb14c 100644
> --- a/drivers/usb/typec/hd3ss3220.c
> +++ b/drivers/usb/typec/hd3ss3220.c
> @@ -245,14 +245,12 @@ static int hd3ss3220_probe(struct i2c_client *client,
>   return ret;
>  }
>  
> -static int hd3ss3220_remove(struct i2c_client *client)
> +static void hd3ss3220_remove(struct i2c_client *client)
>  {
>   struct hd3ss3220 *hd3ss3220 = i2c_get_clientdata(client);
>  
>   typec_unregister_port(hd3ss3220->port);
>   usb_role_switch_put(hd3ss3220->role_sw);
> -
> - return 0;
>  }
>  
>  static const struct of_device_id dev_ids[] = {
> diff --git a/drivers/usb/typec/mux/fsa4480.c b/drivers/usb/typec/mux/fsa4480.c
> index 6184f5367190..d6495e533e58 100644
> --- a/drivers/usb/typec/mux/fsa4480.c
> +++ b/drivers/usb/typec/mux/fsa4480.c
> @@ -181,14 +181,12 @@ static int fsa4480_probe(struct i2c_client *client)
>   return 0;
>  }
>  
> -static int fsa4480_remove(struct i2c_client *client)
> +static void fsa4480_remove(struct i2c_client *client)
>  {
>   struct fsa4480 *fsa = i2c_get_clientdata(client);
>  
>   typec_mux_unregister(fsa->mux);
>   typec_switch_unregister(fsa->sw);
> -
> - return 0;
>  }
>  
>  static const struct i2c_device_id fsa4480_table[] = {
> diff --git a/drivers/usb/typec/mux/pi3usb30532.c 
> b/drivers/usb/typec/mux/pi3usb30532.c
> index 6ce9f282594e..1cd388b55c30 100644
> --- a/drivers/usb/typec/mux/pi3usb30532.c
> +++ b/drivers/usb/typec/mux/pi3usb30532.c
> @@ -160,13 +160,12 @@ static int pi3usb30532_probe(struct i2c_client *client)
>   return 0;
>  }
>  
> -static int pi3usb30532_remove(struct i2c_client *client)
> +static void pi3usb30532_remove(struct i2c_client *client)
>  {
>   struct pi3usb30532 *pi = i2c_get_clientdata(client);
>  
>   typec_mux_unregister(pi->mux);
>   typec_switch_unregister(pi->sw);
> - return 0;
>  }
>  
>  static const struct i2c_device_id pi3usb30532_table[] = {
> diff --git a/drivers/usb/typec/rt1719.c b/drivers/usb/typec/rt1719.c
> index f1b698edd7eb..ea8b700b0ceb 100644
> --- a/drivers/usb/typec/rt1719.c
> +++ b/drivers/usb/typec/rt1719.c
> @@ -930,14 +930,12 @@ static int rt1719_probe(struct i2c_client *i2c)
>   return ret;
>  }
>  
> -static int rt1719_remove(struct i2c_client *i2c)
> +static void rt1719_remove(struct i2c_client *i2c)
>  {
>   struct rt1719_data *data = i2c_get_clientdata(i2c);
>  
>   typec_unregister_port(data->port);
>   usb_role_switch_put(data->role_sw);
> -
> - return 0;
>  }
>  
>  static const struct of_device_id __maybe_unused rt1719_device_table[] = {
> diff --git a/drivers/usb/typec/stusb160x.c b/drivers/usb/typec/stusb160x.c
> index e7745d1c2a5c..8638f1d39896 100644
> --- a/drivers/usb/typec/stusb160x.c
> +++ b/drivers/usb/typec/stusb160x.c
> @@ -801,7 +801,7 @@ static int stusb160x_probe(struct i2c_client *client)
>   return ret;
>  }
>  
> -static int stusb160x_remove(struct i2c_client *client)
> +static void stusb160x_remove(struct i2c_client *client)
>  {
>   struct stusb160x *chip = i2c_get_clientdata(client);
>  
> @@ -823,8 +823,6 @@ static int stusb160x_remove(struct i2c_client *client)
>  
>   if (chip->main_supply)
>   regulator_disable(chip->main_supply);
> -
> - return 0;
>  }
>  
>  static int __maybe_unused stusb160x_suspend(struct device *dev)
> diff --git a/drivers/usb/typec/tcpm/fusb302.c 
> b/drivers/usb/typec/tcpm/fusb302.c
> index 96c55eaf3f80..5e9348f28d50 100644
> --- a/drivers/usb/typec/tcpm/fusb302.c
> +++ b/drivers/usb/typec/tcpm/fusb302.c
> @@ -1771,7 +1771,7 @@ static int fusb302_probe(struct i2c_client *client,
>   return ret;
>  }
>  
> -static int fusb302_remove(struct i2c_client *client)
> +static void fusb302_remove(struct i2c_client *client)
>  {
>   struct fusb302_chip *chip = i2c_get_clientdata(client);
>  
> @@ -1783,8 +1783,6 @@ static int fusb302_remove(struct i2c_client *client)
>   fwnode_handle_put(chip->tcpc_dev.fwnode);
>   destroy_workqueue(chip->wq);
>   fusb302_debugfs_exit(chip);
> -
> - return 0;
>  }
>  
>  static int fusb302_pm_suspend(struct device *dev)
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index f33e08eb7670..c48fca60bb06 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -869,7 +869,7 @@ static int tcpci_probe(struct i2c_client *client,
>   return 0;
>  }
>  
> -static int tcpci_remove(struct i2c_client *client)
> +static void tcpci_remove(struct i2c_client *client)
>  {
>   struct tcpci_chip *chip = i2c_get_clientdata(client);
>   int err;
> @@ -880,8 +880,6 @@ static int tcpci_remove(struct i2c_client *client)
>   dev_warn(>dev, "Failed to disable irqs (%pe)\n", 
> ERR_PTR(err));
>  
>   tcpci_unregister_port(chip->tcpci);
> -
> - return 0;
>  }
>  
> 

Re: [PATCH v2 26/27] dyndbg: 4 new trace-events: pr_debug, dev_dbg, drm_{,dev}debug

2022-06-29 Thread Steven Rostedt


Sorry for the late review. I finally got some time to look at this.

On Mon, 16 May 2022 16:56:39 -0600
Jim Cromie  wrote:


> diff --git a/include/trace/events/drm.h b/include/trace/events/drm.h
> new file mode 100644
> index ..6de80dd68620
> --- /dev/null
> +++ b/include/trace/events/drm.h
> @@ -0,0 +1,68 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM drm
> +
> +#if !defined(_TRACE_DRM_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_DRM_H
> +
> +#include 
> +
> +/* drm_debug() was called, pass its args */
> +TRACE_EVENT(drm_debug,
> + TP_PROTO(int drm_debug_category, struct va_format *vaf),
> +
> + TP_ARGS(drm_debug_category, vaf),
> +
> + TP_STRUCT__entry(
> + __field(int, drm_debug_category)
> + __dynamic_array(char, msg, 256)
> + ),
> +
> + TP_fast_assign(
> + int len;
> +
> + __entry->drm_debug_category = drm_debug_category;
> + vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va);
> +
> + len = strlen(__get_str(msg));
> + if (len > 0 && (__get_str(msg)[len - 1] == '\n'))
> + len -= 1;
> + __get_str(msg)[len] = 0;
> + ),
> +
> + TP_printk("%s", __get_str(msg))
> +);
> +
> +/* drm_devdbg() was called, pass its args, preserving order */
> +TRACE_EVENT(drm_devdbg,
> + TP_PROTO(const struct device *dev, int drm_debug_category, struct 
> va_format *vaf),
> +
> + TP_ARGS(dev, drm_debug_category, vaf),
> +
> + TP_STRUCT__entry(
> + __field(const struct device*, dev)
> + __field(int, drm_debug_category)
> + __dynamic_array(char, msg, 256)

You do not want to hardcode the 256 here. That will cause 256 bytes to be
reserved on the buffer, and you will not get that back. Might as well make
it a static array, as you also add 4 bytes to for the offset and size.

I think you want (haven't tested it)

__dynamic_array(char, msg, get_msg_size(vaf))

Where you have:

static unsigned int get_msg_size(struct va_format *vaf)
{
va_list aq;
unsigned int ret;

va_copy(aq, vaf->va);
ret = vsnprintf(NULL, 0, vaf->fmt, aq);
va_end(aq);

return min(ret + 1, 256);
}

What is in the last parameter of __dynamic_array() is used to calculate the
size needed to store the dynamic array.

Hmm, looking at other users of __dynamic_array(), this appears to be a
constant problem. I need to document this better.

-- Steve


> + ),
> +
> + TP_fast_assign(
> + int len;
> +
> + __entry->drm_debug_category = drm_debug_category;
> + __entry->dev = dev;
> + vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va);
> +
> + len = strlen(__get_str(msg));
> + if (len > 0 && (__get_str(msg)[len - 1] == '\n'))
> + len -= 1;
> + __get_str(msg)[len] = 0;
> + ),
> +
> + TP_printk("cat:%d, %s %s", __entry->drm_debug_category,
> +   dev_name(__entry->dev), __get_str(msg))
> +);
> +
> +#endif /* _TRACE_DRM_H */
> +


Re: [PATCH v6 3/4] fbcon: Prevent that screen size is smaller than font size

2022-06-29 Thread Helge Deller
On 6/29/22 09:03, Geert Uytterhoeven wrote:
> Hi Helge,
>
> On Tue, Jun 28, 2022 at 10:52 PM Helge Deller  wrote:
>> On 6/28/22 10:39, Geert Uytterhoeven wrote:
>>> On Sun, Jun 26, 2022 at 12:33 PM Helge Deller  wrote:
 We need to prevent that users configure a screen size which is smaller 
 than the
 currently selected font size. Otherwise rendering chars on the screen will
 access memory outside the graphics memory region.

 This patch adds a new function fbcon_modechange_possible() which
 implements this check and which later may be extended with other checks
 if necessary.  The new function is called from the FBIOPUT_VSCREENINFO
 ioctl handler in fbmem.c, which will return -EINVAL if userspace asked
 for a too small screen size.

 Signed-off-by: Helge Deller 
 Reviewed-by: Daniel Vetter 
 Cc: sta...@vger.kernel.org # v5.4+
>>>
>>> Thanks for your patch, which is now commit f0b6a66d33ca6e7e ("fbcon:
>>> Prevent that screen size is smaller than font size") in fbdev/for-next
>
 --- a/drivers/video/fbdev/core/fbmem.c
 +++ b/drivers/video/fbdev/core/fbmem.c
 @@ -1112,7 +1112,9 @@ static long do_fb_ioctl(struct fb_info *info, 
 unsigned int cmd,
 return -EFAULT;
 console_lock();
 lock_fb_info(info);
 -   ret = fb_set_var(info, );
 +   ret = fbcon_modechange_possible(info, );
>>>
>>> Again, this should be done (if done at all) after the call to
>>> fb_ops.check_var(), as it breaks the FBIOPUT_VSCREENINFO rounding rule.
>>>
>>> What if the user just wants to display graphics, not text?
>>
>> Yes, I need to go back to an older version here too and check that
>> the test is only run on text consoles.
>> That check was dropped, due feedback that you could switch
>> back from graphics (e.g. X11) to text console at any timeso the
>> check for text-only is not correct.
>>
>>> Can't the text console be disabled instead?
>>
>> I think the solution is to return failure if switching back to text mode 
>> isn't possible if
>> fonts are bigger than the screen resolution. That will be another patch.
>
> Isn't the font a per-VC setting? Hence can't you change resolution,
> switch to a different VC, and run into this?
>
> I think the only real solution is to set the number of text columns
> and/or rows to zero, and make sure that is handled correctly.

I agree, there doesn't seem to be a simple solution.
On the other hand, such usecase seems very unlikely.
If you have a proposal for a pacth I'd welcome it.

Anyway, I've just sent out a new patch series. It does not include any patch
for this theoretical problem yet.

Helge


[PATCH] drm/vc4: change vc4_dma_range_matches from a global to static

2022-06-29 Thread Tom Rix
sparse reports
drivers/gpu/drm/vc4/vc4_drv.c:270:27: warning: symbol 'vc4_dma_range_matches' 
was not declared. Should it be static?

vc4_dma_range_matches is only used in vc4_drv.c, so it's storage class specifier
should be static.

Fixes: da8e393e23ef ("drm/vc4: drv: Adopt the dma configuration from the HVS or 
V3D component")
Signed-off-by: Tom Rix 
---
 drivers/gpu/drm/vc4/vc4_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 2b014b6332a6..292d1b6a01b6 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -267,7 +267,7 @@ static void vc4_match_add_drivers(struct device *dev,
}
 }
 
-const struct of_device_id vc4_dma_range_matches[] = {
+static const struct of_device_id vc4_dma_range_matches[] = {
{ .compatible = "brcm,bcm2711-hvs" },
{ .compatible = "brcm,bcm2835-hvs" },
{ .compatible = "brcm,bcm2835-v3d" },
-- 
2.27.0



[PATCH 5/5] fbcon: Use fbcon_info_from_console() in fbcon_modechange_possible()

2022-06-29 Thread Helge Deller
Use the fbcon_info_from_console() wrapper which was added to kernel
v5.19 with commit 409d6c95f9c6 ("fbcon: Introduce wrapper for console->fb_info 
lookup").

Signed-off-by: Helge Deller 
---
 drivers/video/fbdev/core/fbcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 278c065722b7..ec1cfc6c2451 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2752,7 +2752,7 @@ int fbcon_modechange_possible(struct fb_info *info, 
struct fb_var_screeninfo *va
for (i = first_fb_vc; i <= last_fb_vc; i++) {
vc = vc_cons[i].d;
if (!vc || vc->vc_mode != KD_TEXT ||
-  registered_fb[con2fb_map[i]] != info)
+  fbcon_info_from_console(i) != info)
continue;

if (vc->vc_font.width  > FBCON_SWAP(var->rotate, var->xres, 
var->yres) ||
--
2.35.3



[PATCH 1/5] fbcon: Disallow setting font bigger than screen size

2022-06-29 Thread Helge Deller
Prevent that users set a font size which is bigger than the physical screen.
It's unlikely this may happen (because screens are usually much larger than the
fonts and each font char is limited to 32x32 pixels), but it may happen on
smaller screens/LCD displays.

Signed-off-by: Helge Deller 
Reviewed-by: Daniel Vetter 
Cc: sta...@vger.kernel.org # v4.14+
---
 drivers/video/fbdev/core/fbcon.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index c4e91715ef00..e162d5e753e5 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2469,6 +2469,11 @@ static int fbcon_set_font(struct vc_data *vc, struct 
console_font *font,
if (charcount != 256 && charcount != 512)
return -EINVAL;

+   /* font bigger than screen resolution ? */
+   if (font->width  > FBCON_SWAP(info->var.rotate, info->var.xres, 
info->var.yres) ||
+   font->height > FBCON_SWAP(info->var.rotate, info->var.yres, 
info->var.xres))
+   return -EINVAL;
+
/* Make sure drawing engine can handle the font */
if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
!(info->pixmap.blit_y & (1 << (font->height - 1
--
2.35.3



[PATCH 4/5] fbmem: Prevent invalid virtual screen sizes in fb_set_var()

2022-06-29 Thread Helge Deller
Prevent that drivers configure a virtual screen resolution smaller than
the physical screen resolution.  This is important, because otherwise we
may access memory outside of the graphics memory area.

Signed-off-by: Helge Deller 
Cc: sta...@vger.kernel.org # v5.4+
---
 drivers/video/fbdev/core/fbmem.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 324f726739c4..222d94e2e0a2 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1006,6 +1006,12 @@ fb_set_var(struct fb_info *info, struct 
fb_var_screeninfo *var)
if (var->xres < 8 || var->yres < 8)
return -EINVAL;

+   /* make sure virtual resolution >= physical resolution */
+   if (WARN_ON(var->xres_virtual < var->xres))
+   var->xres_virtual = var->xres;
+   if (WARN_ON(var->yres_virtual < var->yres))
+   var->yres_virtual = var->yres;
+
/* Too huge resolution causes multiplication overflow. */
if (check_mul_overflow(var->xres, var->yres, ) ||
check_mul_overflow(var->xres_virtual, var->yres_virtual, ))
--
2.35.3



[PATCH 3/5] fbcon: Prevent that screen size is smaller than font size

2022-06-29 Thread Helge Deller
We need to prevent that users configure a screen size which is smaller than the
currently selected font size. Otherwise rendering chars on the screen will
access memory outside the graphics memory region.

This patch adds a new function fbcon_modechange_possible() which
implements this check and which later may be extended with other checks
if necessary.  The new function is called from the FBIOPUT_VSCREENINFO
ioctl handler in fbmem.c, which will return -EINVAL if userspace asked
for a too small screen size.

Signed-off-by: Helge Deller 
Cc: sta...@vger.kernel.org # v5.4+
---
 drivers/video/fbdev/core/fbcon.c | 28 
 drivers/video/fbdev/core/fbmem.c |  4 +++-
 include/linux/fbcon.h|  4 
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index e162d5e753e5..278c065722b7 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2736,6 +2736,34 @@ void fbcon_update_vcs(struct fb_info *info, bool all)
 }
 EXPORT_SYMBOL(fbcon_update_vcs);

+/* let fbcon check if it supports a new screen resolution */
+int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screeninfo 
*var)
+{
+   struct fbcon_ops *ops = info->fbcon_par;
+   struct vc_data *vc;
+   int i;
+
+   WARN_CONSOLE_UNLOCKED();
+
+   if (!ops || ops->currcon < 0)
+   return -EINVAL;
+
+   /* prevent setting a screen size which is smaller than font size */
+   for (i = first_fb_vc; i <= last_fb_vc; i++) {
+   vc = vc_cons[i].d;
+   if (!vc || vc->vc_mode != KD_TEXT ||
+  registered_fb[con2fb_map[i]] != info)
+   continue;
+
+   if (vc->vc_font.width  > FBCON_SWAP(var->rotate, var->xres, 
var->yres) ||
+   vc->vc_font.height > FBCON_SWAP(var->rotate, var->yres, 
var->xres))
+   return -EINVAL;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(fbcon_modechange_possible);
+
 int fbcon_mode_deleted(struct fb_info *info,
   struct fb_videomode *mode)
 {
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index e645b96d2700..324f726739c4 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -,7 +,9 @@ static long do_fb_ioctl(struct fb_info *info, unsigned 
int cmd,
var.xres_virtual = var.xres;
if (var.yres_virtual < var.yres)
var.yres_virtual = var.yres;
-   ret = fb_set_var(info, );
+   ret = fbcon_modechange_possible(info, );
+   if (!ret)
+   ret = fb_set_var(info, );
if (!ret)
fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL);
unlock_fb_info(info);
diff --git a/include/linux/fbcon.h b/include/linux/fbcon.h
index ff5596dd30f8..2382dec6d6ab 100644
--- a/include/linux/fbcon.h
+++ b/include/linux/fbcon.h
@@ -15,6 +15,8 @@ void fbcon_new_modelist(struct fb_info *info);
 void fbcon_get_requirement(struct fb_info *info,
   struct fb_blit_caps *caps);
 void fbcon_fb_blanked(struct fb_info *info, int blank);
+int  fbcon_modechange_possible(struct fb_info *info,
+  struct fb_var_screeninfo *var);
 void fbcon_update_vcs(struct fb_info *info, bool all);
 void fbcon_remap_all(struct fb_info *info);
 int fbcon_set_con2fb_map_ioctl(void __user *argp);
@@ -33,6 +35,8 @@ static inline void fbcon_new_modelist(struct fb_info *info) {}
 static inline void fbcon_get_requirement(struct fb_info *info,
 struct fb_blit_caps *caps) {}
 static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {}
+static inline int  fbcon_modechange_possible(struct fb_info *info,
+   struct fb_var_screeninfo *var) { return 0; }
 static inline void fbcon_update_vcs(struct fb_info *info, bool all) {}
 static inline void fbcon_remap_all(struct fb_info *info) {}
 static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0; }
--
2.35.3



[PATCH 2/5] fbcon: Fix up user-provided virtual screen size

2022-06-29 Thread Helge Deller
The virtual screen size can't be smaller than the physical screen size.
Based on the general rule that we round up user-provided input if
neccessary, adjust the virtual screen size as well if needed.

Signed-off-by: Helge Deller 
Cc: sta...@vger.kernel.org # v5.4+
---
 drivers/video/fbdev/core/fbmem.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index afa2863670f3..e645b96d2700 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1106,6 +1106,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned 
int cmd,
return -EFAULT;
console_lock();
lock_fb_info(info);
+   /* adjust virtual screen size if user missed it */
+   if (var.xres_virtual < var.xres)
+   var.xres_virtual = var.xres;
+   if (var.yres_virtual < var.yres)
+   var.yres_virtual = var.yres;
ret = fb_set_var(info, );
if (!ret)
fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL);
--
2.35.3



[PATCH 0/5] fbcon: Fixes for screen resolution changes - round 2

2022-06-29 Thread Helge Deller
This series fixes possible out-of-bound memory accesses when users trigger
screen resolutions changes with invalid input parameters, e.g. reconfigures
screen which is smaller than the current font size, or if the virtual screen
size is smaller than the physical screen size.

Helge Deller (5):
  fbcon: Disallow setting font bigger than screen size
  fbcon: Fix up user-provided virtual screen size
  fbcon: Prevent that screen size is smaller than font size
  fbmem: Prevent invalid virtual screen sizes in fb_set_var()
  fbcon: Use fbcon_info_from_console() in fbcon_modechange_possible()

 drivers/video/fbdev/core/fbcon.c | 33 
 drivers/video/fbdev/core/fbmem.c | 15 ++-
 include/linux/fbcon.h|  4 
 3 files changed, 51 insertions(+), 1 deletion(-)

--
2.35.3



Re: [PATCH 6/6] i2c: Make remove callback return void

2022-06-29 Thread Chanwoo Choi
Hi Uwe,

On 22. 6. 28. 23:03, Uwe Kleine-König wrote:
> static const struct of_device_id atmel_sha204a_dt_ids[] = {
> diff --git a/drivers/extcon/extcon-rt8973a.c b/drivers/extcon/extcon-rt8973a.c
> index 40c07f4d656e..d1c674f3f2b9 100644
> --- a/drivers/extcon/extcon-rt8973a.c
> +++ b/drivers/extcon/extcon-rt8973a.c
> @@ -647,13 +647,11 @@ static int rt8973a_muic_i2c_probe(struct i2c_client 
> *i2c,
>   return 0;
>  }
>  
> -static int rt8973a_muic_i2c_remove(struct i2c_client *i2c)
> +static void rt8973a_muic_i2c_remove(struct i2c_client *i2c)
>  {
>   struct rt8973a_muic_info *info = i2c_get_clientdata(i2c);
>  
>   regmap_del_irq_chip(info->irq, info->irq_data);
> -
> - return 0;
>  }
>  
>  static const struct of_device_id rt8973a_dt_match[] = {
> diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c
> index e388e75103f4..acb673dc9005 100644
> --- a/drivers/gpio/gpio-adp5588.c
> +++ b/drivers/gpio/gpio-adp5588.c
> @@ -411,14 +411,12 @@ static int adp5588_gpio_probe(struct i2c_client *client)
>   return 0;
>  }

Reviewed-by: Chanwoo Choi 

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi


[pull] amdgpu drm-fixes-5.19

2022-06-29 Thread Alex Deucher
Hi Dave, Daniel,

Fixes for 5.19.

The following changes since commit 76f0544428aced9e2f0d50ac7429e0f3064658cd:

  Merge tag 'drm-msm-fixes-2022-06-28' of 
https://gitlab.freedesktop.org/drm/msm into drm-fixes (2022-06-29 14:16:46 
+1000)

are available in the Git repository at:

  https://gitlab.freedesktop.org/agd5f/linux.git 
tags/amd-drm-fixes-5.19-2022-06-29

for you to fetch changes up to a775e4e4941bf2f326aa36c58f67bd6c96cac717:

  Revert "drm/amdgpu/display: set vblank_disable_immediate for DC" (2022-06-29 
14:50:52 -0400)


amd-drm-fixes-5.19-2022-06-29:

amdgpu:
- GPU recovery fix
- Fix integer type usage in fourcc header for AMD modifiers
- KFD TLB flush fix for gfx9 APUs
- Display fix


Alex Deucher (2):
  drm/amdgpu: fix adev variable used in amdgpu_device_gpu_recover()
  Revert "drm/amdgpu/display: set vblank_disable_immediate for DC"

Carlos Llamas (1):
  drm/fourcc: fix integer type usage in uapi header

Ruili Ji (1):
  drm/amdgpu: To flush tlb for MMHUB of RAVEN series

 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c| 3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c   | 1 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ---
 include/uapi/drm/drm_fourcc.h | 4 ++--
 5 files changed, 6 insertions(+), 7 deletions(-)


Re: linux-next: Tree for Jun 29 (gpu/drm/amd/display/dc/)

2022-06-29 Thread Alex Deucher
On Wed, Jun 29, 2022 at 3:05 PM Randy Dunlap  wrote:
>
>
>
> On 6/29/22 00:23, Stephen Rothwell wrote:
> > Hi all,
> >
> > Changes since 20220628:
> >
>
> on i386:
>
> ld: drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.o: in function 
> `dcn32_init_clocks':
> dcn32_clk_mgr.c:(.text+0x70d): undefined reference to `__nedf2'
> ld: dcn32_clk_mgr.c:(.text+0x9bf): undefined reference to `__floatunsidf'
> ld: dcn32_clk_mgr.c:(.text+0xa03): undefined reference to `__muldf3'
> ld: dcn32_clk_mgr.c:(.text+0xa37): undefined reference to `__muldf3'
> ld: drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.o: in function 
> `dcn32_calculate_cab_allocation':
> dcn32_hwseq.c:(.text+0xda): undefined reference to `__umoddi3'
> ld: dcn32_hwseq.c:(.text+0x112): undefined reference to `__umoddi3'
> ld: dcn32_hwseq.c:(.text+0x16d): undefined reference to `__umoddi3'
>

Siqueira is working on this.  Patch should be available soon.

Alex


>
> Full randconfig file is attached.
>
>
> --
> ~Randy


[PATCH] drm/mediatek: ensure bridge disable happends before suspend

2022-06-29 Thread Hsin-Yi Wang
Make sure bridge_disable will be called before suspend by calling
drm_mode_config_helper_suspend() in .prepare callback.

Signed-off-by: Hsin-Yi Wang 
---
The issue is found if suspend is called via VT2 in several MTK SoC (eg.
MT8173, MT8183, MT8186) chromebook boards with eDP bridge:
bridge disable is called through mtk-drm's suspend, and it needs to be
called before bridge pm runtime suspend.
So we move the hook to .prepare() and .complete().
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 13a1bbe7ead7f..a42812e490007 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -828,8 +828,7 @@ static int mtk_drm_remove(struct platform_device *pdev)
return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int mtk_drm_sys_suspend(struct device *dev)
+static int mtk_drm_sys_prepare(struct device *dev)
 {
struct mtk_drm_private *private = dev_get_drvdata(dev);
struct drm_device *drm = private->drm;
@@ -840,20 +839,21 @@ static int mtk_drm_sys_suspend(struct device *dev)
return ret;
 }
 
-static int mtk_drm_sys_resume(struct device *dev)
+static void mtk_drm_sys_complete(struct device *dev)
 {
struct mtk_drm_private *private = dev_get_drvdata(dev);
struct drm_device *drm = private->drm;
int ret;
 
ret = drm_mode_config_helper_resume(drm);
-
-   return ret;
+   if (ret)
+   dev_err(dev, "Failed to resume\n");
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(mtk_drm_pm_ops, mtk_drm_sys_suspend,
-mtk_drm_sys_resume);
+static const struct dev_pm_ops mtk_drm_pm_ops = {
+   .prepare = mtk_drm_sys_prepare,
+   .complete = mtk_drm_sys_complete,
+};
 
 static struct platform_driver mtk_drm_platform_driver = {
.probe  = mtk_drm_probe,
-- 
2.37.0.rc0.161.g10f37bed90-goog



Re: linux-next: Tree for Jun 29 (gpu/drm/amd/display/dc/)

2022-06-29 Thread Randy Dunlap


On 6/29/22 00:23, Stephen Rothwell wrote:
> Hi all,
> 
> Changes since 20220628:
> 

on i386:

ld: drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.o: in function 
`dcn32_init_clocks':
dcn32_clk_mgr.c:(.text+0x70d): undefined reference to `__nedf2'
ld: dcn32_clk_mgr.c:(.text+0x9bf): undefined reference to `__floatunsidf'
ld: dcn32_clk_mgr.c:(.text+0xa03): undefined reference to `__muldf3'
ld: dcn32_clk_mgr.c:(.text+0xa37): undefined reference to `__muldf3'
ld: drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.o: in function 
`dcn32_calculate_cab_allocation':
dcn32_hwseq.c:(.text+0xda): undefined reference to `__umoddi3'
ld: dcn32_hwseq.c:(.text+0x112): undefined reference to `__umoddi3'
ld: dcn32_hwseq.c:(.text+0x16d): undefined reference to `__umoddi3'


Full randconfig file is attached.


-- 
~Randy

config-r4302.gz
Description: application/gzip


Re: [PATCH v7 02/14] mm: add zone device coherent type memory support

2022-06-29 Thread David Hildenbrand
On 29.06.22 05:54, Alex Sierra wrote:
> Device memory that is cache coherent from device and CPU point of view.
> This is used on platforms that have an advanced system bus (like CAPI
> or CXL). Any page of a process can be migrated to such memory. However,
> no one should be allowed to pin such memory so that it can always be
> evicted.
> 
> Signed-off-by: Alex Sierra 
> Acked-by: Felix Kuehling 
> Reviewed-by: Alistair Popple 
> [hch: rebased ontop of the refcount changes,
>   removed is_dev_private_or_coherent_page]
> Signed-off-by: Christoph Hellwig 

>From what I can tell, this looks good to me

Acked-by: David Hildenbrand 

-- 
Thanks,

David / dhildenb



Re: [PATCH] drm/fb-helper: Fix out-of-bounds access

2022-06-29 Thread Geert Uytterhoeven

Hi Thomas,

On Tue, 21 Jun 2022, Thomas Zimmermann wrote:

Clip memory range to screen-buffer size to avoid out-of-bounds access
in fbdev deferred I/O's damage handling.

Fbdev's deferred I/O can only track pages. From the range of pages, the
damage handler computes the clipping rectangle for the display update.
If the fbdev screen buffer ends near the beginning of a page, that page
could contain more scanlines. The damage handler would then track these
non-existing scanlines as dirty and provoke an out-of-bounds access
during the screen update. Hence, clip the maximum memory range to the
size of the screen buffer.

While at it, rename the variables min/max to min_off/max_off in
drm_fb_helper_deferred_io(). This avoids confusion with the macros of
the same name.

Reported-by: Nuno Gonçalves 
Signed-off-by: Thomas Zimmermann 
Tested-by: Nuno Gonçalves 
Fixes: 67b723f5b742 ("drm/fb-helper: Calculate damaged area in separate helper")


Thanks for your patch, which is now commit ae25885bdf59fde4
("drm/fb-helper: Fix out-of-bounds access") in drm-misc/for-linux-next.

I had seen the crash before, but thought it was a bug in my wip
atari-drm driver.  When diving deeper today, and consequently looking
for recent changes to the damage helper, I found this commit in
linux-next.

With your patch instead of my own workaround I used this morning, [1]
still works fine, so:
Tested-by: Geert Uytterhoeven .
Reviewed-by: Geert Uytterhoeven .

[1] [PATCH] drm/fb-helper: Remove helpers to change frame buffer config
https://lore.kernel.org/all/20220629105658.1373770-1-ge...@linux-m68k.org

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Re: [PATCH v5 1/9] dt-bindings: usb: Add Type-C switch binding

2022-06-29 Thread Rob Herring
On Wed, Jun 29, 2022 at 9:01 AM Pin-yen Lin  wrote:
>
> On Wed, Jun 29, 2022 at 10:33 PM Pin-yen Lin  wrote:
> >
> > On Wed, Jun 29, 2022 at 2:23 AM Rob Herring  wrote:
> > >
> > > On Mon, Jun 27, 2022 at 02:43:39PM -0700, Prashant Malani wrote:
> > > > Hello Rob,
> > > >
> > > > On Mon, Jun 27, 2022 at 2:04 PM Rob Herring  wrote:
> > > > >
> > > > > On Wed, Jun 22, 2022 at 05:34:30PM +, Prashant Malani wrote:
> > > > > > Introduce a binding which represents a component that can control 
> > > > > > the
> > > > > > routing of USB Type-C data lines as well as address data line
> > > > > > orientation (based on CC lines' orientation).
> > > > > >
> > > > > > Reviewed-by: Krzysztof Kozlowski 
> > > > > > Reviewed-by: AngeloGioacchino Del Regno 
> > > > > > 
> > > > > > Reviewed-by: Nícolas F. R. A. Prado 
> > > > > > Tested-by: Nícolas F. R. A. Prado 
> > > > > > Signed-off-by: Prashant Malani 
> > > > > > ---
> > > > > >
> > > > > > Changes since v4:
> > > > > > - Added Reviewed-by tags.
> > > > > > - Patch moved to 1/9 position (since Patch v4 1/7 and 2/7 were
> > > > > >   applied to usb-next)
> > > > > >
> > > > > > Changes since v3:
> > > > > > - No changes.
> > > > > >
> > > > > > Changes since v2:
> > > > > > - Added Reviewed-by and Tested-by tags.
> > > > > >
> > > > > > Changes since v1:
> > > > > > - Removed "items" from compatible.
> > > > > > - Fixed indentation in example.
> > > > > >
> > > > > >  .../devicetree/bindings/usb/typec-switch.yaml | 74 
> > > > > > +++
> > > > > >  1 file changed, 74 insertions(+)
> > > > > >  create mode 100644 
> > > > > > Documentation/devicetree/bindings/usb/typec-switch.yaml
> > > > > >
> > > > > > diff --git 
> > > > > > a/Documentation/devicetree/bindings/usb/typec-switch.yaml 
> > > > > > b/Documentation/devicetree/bindings/usb/typec-switch.yaml
> > > > > > new file mode 100644
> > > > > > index ..78b0190c8543
> > > > > > --- /dev/null
> > > > > > +++ b/Documentation/devicetree/bindings/usb/typec-switch.yaml
> > > > > > @@ -0,0 +1,74 @@
> > > > > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > > > > > +%YAML 1.2
> > > > > > +---
> > > > > > +$id: http://devicetree.org/schemas/usb/typec-switch.yaml#
> > > > > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > > > > +
> > > > > > +title: USB Type-C Switch
> > > > > > +
> > > > > > +maintainers:
> > > > > > +  - Prashant Malani 
> > > > > > +
> > > > > > +description:
> > > > > > +  A USB Type-C switch represents a component which routes USB 
> > > > > > Type-C data
> > > > > > +  lines to various protocol host controllers (e.g USB, VESA 
> > > > > > DisplayPort,
> > > > > > +  Thunderbolt etc.) depending on which mode the Type-C port, port 
> > > > > > partner
> > > > > > +  and cable are operating in. It can also modify lane routing 
> > > > > > based on
> > > > > > +  the orientation of a connected Type-C peripheral.
> > > > > > +
> > > > > > +properties:
> > > > > > +  compatible:
> > > > > > +const: typec-switch
> > > > > > +
> > > > > > +  mode-switch:
> > > > > > +type: boolean
> > > > > > +description: Specify that this switch can handle alternate 
> > > > > > mode switching.
> > > > > > +
> > > > > > +  orientation-switch:
> > > > > > +type: boolean
> > > > > > +description: Specify that this switch can handle orientation 
> > > > > > switching.
> > > > > > +
> > > > > > +  ports:
> > > > > > +$ref: /schemas/graph.yaml#/properties/ports
> > > > > > +description: OF graph binding modelling data lines to the 
> > > > > > Type-C switch.
> > > > > > +
> > > > > > +properties:
> > > > > > +  port@0:
> > > > > > +$ref: /schemas/graph.yaml#/properties/port
> > > > > > +description: Link between the switch and a Type-C 
> > > > > > connector.
> > > > > > +
> > > > > > +required:
> > > > > > +  - port@0
> > > > > > +
> > > > > > +required:
> > > > > > +  - compatible
> > > > > > +  - ports
> > > > > > +
> > > > > > +anyOf:
> > > > > > +  - required:
> > > > > > +  - mode-switch
> > > > > > +  - required:
> > > > > > +  - orientation-switch
> > > > > > +
> > > > > > +additionalProperties: true
> > > > > > +
> > > > > > +examples:
> > > > > > +  - |
> > > > > > +drm-bridge {
> > > > > > +usb-switch {
> > > > > > +compatible = "typec-switch";
> > > > >
> > > > > Unless this child is supposed to represent what the parent output is
> > > > > connected to, this is just wrong as, at least for the it6505 chip, it
> > > > > doesn't know anything about Type-C functionality. The bridge is
> > > > > just a protocol converter AFAICT.
> > > >
> > > > I'll let Pin-Yen comment on the specifics of the it6505 chip.
> > >
> > > We're all waiting...
> >
> > Yes it6505 is just a protocol converter. But in our use case, the output DP
> > lines are connected to the Type-C ports and the chip has to know which
> > port has DP Alt mode enabled. Does this justify a child node here?
> >
> 

Re: [PATCH v3 11/13] drm/i915/ttm: handle blitter failure on DG2

2022-06-29 Thread Thomas Hellström



On 6/29/22 18:28, Matthew Auld wrote:

On 29/06/2022 17:11, Thomas Hellström wrote:

Hi, Matthew,

On 6/29/22 14:14, Matthew Auld wrote:

If the move or clear operation somehow fails, and the memory underneath
is not cleared, like when moving to lmem, then we currently fallback to
memcpy or memset. However with small-BAR systems this fallback might no
longer be possible. For now we use the set_wedged sledgehammer if we
ever encounter such a scenario, and mark the object as borked to plug
any holes where access to the memory underneath can happen. Add some
basic selftests to exercise this.

v2:
   - In the selftests make sure we grab the runtime pm around the 
reset.
 Also make sure we grab the reset lock before checking if the 
device
 is wedged, since the wedge might still be in-progress and hence 
the

 bit might not be set yet.
   - Don't wedge or put the object into an unknown state, if the 
request

 construction fails (or similar). Just returning an error and
 skipping the fallback should be safe here.
   - Make sure we wedge each gt. (Thomas)
   - Peek at the unknown_state in io_reserve, that way we don't have to
 export or hand roll the fault_wait_for_idle. (Thomas)
   - Add the missing read-side barriers for the unknown_state. (Thomas)
   - Some kernel-doc fixes. (Thomas)

Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Lionel Landwerlin 
Cc: Tvrtko Ursulin 
Cc: Jon Bloomfield 
Cc: Daniel Vetter 
Cc: Jordan Justen 
Cc: Kenneth Graunke 
Cc: Akeem G Abodunrin 
---
  drivers/gpu/drm/i915/gem/i915_gem_object.c    |  21 +++
  drivers/gpu/drm/i915/gem/i915_gem_object.h    |   1 +
  .../gpu/drm/i915/gem/i915_gem_object_types.h  |  18 +++
  drivers/gpu/drm/i915/gem/i915_gem_ttm.c   |  26 +++-
  drivers/gpu/drm/i915/gem/i915_gem_ttm.h   |   3 +
  drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c  |  88 +--
  drivers/gpu/drm/i915/gem/i915_gem_ttm_move.h  |   1 +
  .../drm/i915/gem/selftests/i915_gem_migrate.c | 141 
+++---

  .../drm/i915/gem/selftests/i915_gem_mman.c    |  69 +
  drivers/gpu/drm/i915/i915_vma.c   |  25 ++--
  10 files changed, 346 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c 
b/drivers/gpu/drm/i915/gem/i915_gem_object.c

index 06b1b188ce5a..642a5d59ce26 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -783,10 +783,31 @@ int i915_gem_object_wait_moving_fence(struct 
drm_i915_gem_object *obj,

  intr, MAX_SCHEDULE_TIMEOUT);
  if (!ret)
  ret = -ETIME;
+    else if (ret > 0 && i915_gem_object_has_unknown_state(obj))
+    ret = -EIO;
  return ret < 0 ? ret : 0;
  }
+/**
+ * i915_gem_object_has_unknown_state - Return true if the object 
backing pages are
+ * in an unknown_state. This means that userspace must NEVER be 
allowed to touch

+ * the pages, with either the GPU or CPU.
+ *
+ * ONLY valid to be called after ensuring that all kernel fences 
have signalled

+ * (in particular the fence for moving/clearing the object).
+ */
+bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object 
*obj)

+{
+    /*
+ * The below barrier pairs with the dma_fence_signal() in
+ * __memcpy_work(). We should only sample the unknown_state 
after all

+ * the kernel fences have signalled.
+ */
+    smp_rmb();
+    return obj->mm.unknown_state;
+}
+
  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftests/huge_gem_object.c"
  #include "selftests/huge_pages.c"
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object.h

index e11d82a9f7c3..0bf3ee27a2a8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -524,6 +524,7 @@ int i915_gem_object_get_moving_fence(struct 
drm_i915_gem_object *obj,

   struct dma_fence **fence);
  int i915_gem_object_wait_moving_fence(struct drm_i915_gem_object 
*obj,

    bool intr);
+bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object 
*obj);
  void i915_gem_object_set_cache_coherency(struct 
drm_i915_gem_object *obj,

   unsigned int cache_level);
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h

index 2c88bdb8ff7c..5cf36a130061 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -547,6 +547,24 @@ struct drm_i915_gem_object {
   */
  bool ttm_shrinkable;
+    /**
+ * @unknown_state: Indicate that the object is effectively
+ * borked. This is write-once and set if we somehow 
encounter a

+ * fatal error when moving/clearing the pages, and we are not
+ * able to fallback to memcpy/memset, like on small-BAR 
systems.

+ * The GPU should also be wedged (or in the process) at this
+  

Re: [PATCH v3 09/13] drm/i915/selftests: skip the mman tests for stolen

2022-06-29 Thread Matthew Auld

On 29/06/2022 17:22, Thomas Hellström wrote:


On 6/29/22 14:14, Matthew Auld wrote:

It's not supported, and just skips later anyway. With small-BAR things
get more complicated since all of stolen is likely not even CPU
accessible, hence not passing I915_BO_ALLOC_GPU_ONLY just results in the
object create failing.

Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Lionel Landwerlin 
Cc: Tvrtko Ursulin 
Cc: Jon Bloomfield 
Cc: Daniel Vetter 
Cc: Jordan Justen 
Cc: Kenneth Graunke 
Cc: Akeem G Abodunrin 
---
  drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 12 
  1 file changed, 12 insertions(+)


This reminds me,

Is there a problem for fbdev (and hence things like plymouth) if the 
initial fbdev image ends up as a stolen memory object which in turn ends 
up not being mappable? I remember we discussed this before but can't 
recall what the answer was.


On discrete the initial-fb looks to be allocated directly from lmem (at 
least on the machines I've seen in CI). See 7fe7c2a679dc ("drm/i915: 
fixup the initial fb base on DGFX"). And from what I could tell the 
offset in lmem is always at the beginning somewhere, which makes sense 
given stuff like small-BAR. But yeah, the create_at() helper should 
complain if someone tried to allocate the initial-fb or similar outside 
the mappable part. IIRC the only user of stolen-lmem is fbc, but that 
doesn't seem to need CPU access.




Anyway, for this patch

Reviewed-by: Thomas Hellström 







diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c 
b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c

index 5bc93a1ce3e3..388c85b0f764 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
@@ -979,6 +979,9 @@ static int igt_mmap(void *arg)
  };
  int i;
+    if (mr->private)
+    continue;
+
  for (i = 0; i < ARRAY_SIZE(sizes); i++) {
  struct drm_i915_gem_object *obj;
  int err;
@@ -1435,6 +1438,9 @@ static int igt_mmap_access(void *arg)
  struct drm_i915_gem_object *obj;
  int err;
+    if (mr->private)
+    continue;
+
  obj = __i915_gem_object_create_user(i915, PAGE_SIZE, , 1);
  if (obj == ERR_PTR(-ENODEV))
  continue;
@@ -1580,6 +1586,9 @@ static int igt_mmap_gpu(void *arg)
  struct drm_i915_gem_object *obj;
  int err;
+    if (mr->private)
+    continue;
+
  obj = __i915_gem_object_create_user(i915, PAGE_SIZE, , 1);
  if (obj == ERR_PTR(-ENODEV))
  continue;
@@ -1727,6 +1736,9 @@ static int igt_mmap_revoke(void *arg)
  struct drm_i915_gem_object *obj;
  int err;
+    if (mr->private)
+    continue;
+
  obj = __i915_gem_object_create_user(i915, PAGE_SIZE, , 1);
  if (obj == ERR_PTR(-ENODEV))
  continue;


Re: [PATCH v3 11/13] drm/i915/ttm: handle blitter failure on DG2

2022-06-29 Thread Matthew Auld

On 29/06/2022 17:11, Thomas Hellström wrote:

Hi, Matthew,

On 6/29/22 14:14, Matthew Auld wrote:

If the move or clear operation somehow fails, and the memory underneath
is not cleared, like when moving to lmem, then we currently fallback to
memcpy or memset. However with small-BAR systems this fallback might no
longer be possible. For now we use the set_wedged sledgehammer if we
ever encounter such a scenario, and mark the object as borked to plug
any holes where access to the memory underneath can happen. Add some
basic selftests to exercise this.

v2:
   - In the selftests make sure we grab the runtime pm around the reset.
 Also make sure we grab the reset lock before checking if the device
 is wedged, since the wedge might still be in-progress and hence the
 bit might not be set yet.
   - Don't wedge or put the object into an unknown state, if the request
 construction fails (or similar). Just returning an error and
 skipping the fallback should be safe here.
   - Make sure we wedge each gt. (Thomas)
   - Peek at the unknown_state in io_reserve, that way we don't have to
 export or hand roll the fault_wait_for_idle. (Thomas)
   - Add the missing read-side barriers for the unknown_state. (Thomas)
   - Some kernel-doc fixes. (Thomas)

Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Lionel Landwerlin 
Cc: Tvrtko Ursulin 
Cc: Jon Bloomfield 
Cc: Daniel Vetter 
Cc: Jordan Justen 
Cc: Kenneth Graunke 
Cc: Akeem G Abodunrin 
---
  drivers/gpu/drm/i915/gem/i915_gem_object.c    |  21 +++
  drivers/gpu/drm/i915/gem/i915_gem_object.h    |   1 +
  .../gpu/drm/i915/gem/i915_gem_object_types.h  |  18 +++
  drivers/gpu/drm/i915/gem/i915_gem_ttm.c   |  26 +++-
  drivers/gpu/drm/i915/gem/i915_gem_ttm.h   |   3 +
  drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c  |  88 +--
  drivers/gpu/drm/i915/gem/i915_gem_ttm_move.h  |   1 +
  .../drm/i915/gem/selftests/i915_gem_migrate.c | 141 +++---
  .../drm/i915/gem/selftests/i915_gem_mman.c    |  69 +
  drivers/gpu/drm/i915/i915_vma.c   |  25 ++--
  10 files changed, 346 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c 
b/drivers/gpu/drm/i915/gem/i915_gem_object.c

index 06b1b188ce5a..642a5d59ce26 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -783,10 +783,31 @@ int i915_gem_object_wait_moving_fence(struct 
drm_i915_gem_object *obj,

  intr, MAX_SCHEDULE_TIMEOUT);
  if (!ret)
  ret = -ETIME;
+    else if (ret > 0 && i915_gem_object_has_unknown_state(obj))
+    ret = -EIO;
  return ret < 0 ? ret : 0;
  }
+/**
+ * i915_gem_object_has_unknown_state - Return true if the object 
backing pages are
+ * in an unknown_state. This means that userspace must NEVER be 
allowed to touch

+ * the pages, with either the GPU or CPU.
+ *
+ * ONLY valid to be called after ensuring that all kernel fences have 
signalled

+ * (in particular the fence for moving/clearing the object).
+ */
+bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object *obj)
+{
+    /*
+ * The below barrier pairs with the dma_fence_signal() in
+ * __memcpy_work(). We should only sample the unknown_state after 
all

+ * the kernel fences have signalled.
+ */
+    smp_rmb();
+    return obj->mm.unknown_state;
+}
+
  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftests/huge_gem_object.c"
  #include "selftests/huge_pages.c"
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object.h

index e11d82a9f7c3..0bf3ee27a2a8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -524,6 +524,7 @@ int i915_gem_object_get_moving_fence(struct 
drm_i915_gem_object *obj,

   struct dma_fence **fence);
  int i915_gem_object_wait_moving_fence(struct drm_i915_gem_object *obj,
    bool intr);
+bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object *obj);
  void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object 
*obj,

   unsigned int cache_level);
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h

index 2c88bdb8ff7c..5cf36a130061 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -547,6 +547,24 @@ struct drm_i915_gem_object {
   */
  bool ttm_shrinkable;
+    /**
+ * @unknown_state: Indicate that the object is effectively
+ * borked. This is write-once and set if we somehow encounter a
+ * fatal error when moving/clearing the pages, and we are not
+ * able to fallback to memcpy/memset, like on small-BAR systems.
+ * The GPU should also be wedged (or in the process) at this
+ * point.
+ *
+ * Only valid to 

Re: [PATCH v2 00/96] Refactor non_legacy_dai_naming flag

2022-06-29 Thread Mark Brown
On Thu, 23 Jun 2022 13:51:14 +0100, Charles Keepax wrote:
> Historically, the legacy DAI naming scheme was applied to platform
> drivers and the newer scheme to CODEC drivers. During componentisation
> the core lost the knowledge of if a driver was a CODEC or platform, they
> were all now components. To continue to support the legacy naming on
> older platform drivers a flag was added to the snd_soc_component_driver
> structure, non_legacy_dai_naming, to indicate to use the new scheme and
> this was applied to all CODECs as part of the migration.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[01/96] ASoC: soc-component: Add legacy_dai_naming flag
commit: 1c348f748b4dd7711c5564a8fce0842529498dff
[02/96] soundwire: intel: Migrate to new style legacy DAI naming flag
commit: ca68202098a4416501cc9b5d68a54de22d754766
[03/96] drm/vc4: Migrate to new style legacy DAI naming flag
commit: db827cb34ca38f4106f7c667bea3bbb48bc73552
[04/96] ASoC: img: Migrate to new style legacy DAI naming flag
commit: 5f9d69986014945b826c712081678446c1f10fd7
[05/96] ASoC: spear: Migrate to new style legacy DAI naming flag
commit: eeb021ee8fab0baae82e3784664666fd6b826e89
[06/96] ASoC: jz4740-i2c: Migrate to new style legacy DAI naming flag
commit: 2bebc3b622c3c300eb3a3f603473429d8264c3b6
[07/96] ASoC: ep93xx: Migrate to new style legacy DAI naming flag
commit: fe58b58330434ffad5fa0bc97e177aa93a9a6222
[08/96] ASoC: stm32: Migrate to new style legacy DAI naming flag
commit: 36f07985f81b7482dceb8e650d2ce1f094d1
[09/96] ASoC: bcm: Migrate to new style legacy DAI naming flag
commit: b9a0db0ae5247d92f379107a9c479f881914999d
[10/96] ASoC: sh: Migrate to new style legacy DAI naming flag
commit: f712ff57a27090baff61f92bdb6521e8781d5e6b
[11/96] ASoC: tegra: Migrate to new style legacy DAI naming flag
commit: 3172582c10540d4bf1caac1c39c903793648db8f
[12/96] ASoC: hisilicon: Migrate to new style legacy DAI naming flag
commit: bf6dacb784f0efb5a225f6560d693fa71c7fda64
[13/96] ASoC: xilinx: Migrate to new style legacy DAI naming flag
commit: bd486b070b1e24b38b3d6d7e33abffe4a18e3296
[14/96] ASoC: sunxi: Migrate to new style legacy DAI naming flag
commit: f450b5dbce413b276e6c9215b40868b905c7b634
[15/96] ASoC: Intel: Migrate to new style legacy DAI naming flag
commit: 725cf3bc6009b7fa156b73982eddf23c71767fbb
[16/96] ASoC: meson: Migrate to new style legacy DAI naming flag
commit: d8572da099247860e97b27a7fddc9d80a71b8c25
[17/96] ASoC: sti-uniperf: Migrate to new style legacy DAI naming flag
commit: ad483da7b0a17fdf4df0bd75b2cf29b5650ca2f7
[18/96] ASoC: amd: Migrate to new style legacy DAI naming flag
commit: 0bc1e7d1fc3c50cf1eb62cd3c8d2b73c5f6d83fe
[19/96] ASoC: atmel: Migrate to new style legacy DAI naming flag
commit: 7593e00807fb62e9f5e7367fc2500428cc317ff0
[20/96] ASoC: fsl: Migrate to new style legacy DAI naming flag
commit: 1e63fcc74ace9824f3529eeabbb8f1881a7d3800
[21/96] ASoC: xtensa: Migrate to new style legacy DAI naming flag
commit: f257dea1c589fa3f558502b3ac7b1c09699a73ab
[22/96] ASoC: adi: Migrate to new style legacy DAI naming flag
commit: 9a34161a0bc90df825694195659d894e80afe7a3
[23/96] ASoC: dwc: Migrate to new style legacy DAI naming flag
commit: e740ef3d9418db78ac7a8a24071933f9146af6e4
[24/96] ASoC: qcom: Migrate to new style legacy DAI naming flag
commit: 8135d0290a9a1f1f752bb374f93a017b2074d09b
[25/96] ASoC: test-component: Migrate to new style legacy DAI naming flag
commit: d73130ba523b88a3edb097ae3eb9f93df844b5e2
[26/96] ASoC: rockchip: Migrate to new style legacy DAI naming flag
commit: d48a77173534df90788075e76fa88c52b7395a1e
[27/96] ASoC: au1x: Migrate to new style legacy DAI naming flag
commit: 8e750817a1943b49d81c633f48370bce93bab98c
[28/96] ASoC: pxa: Migrate to new style legacy DAI naming flag
commit: 05603f15b67a517c05ee2e2298e9accb8b7f1794
[29/96] ASoC: sof: Migrate to new style legacy DAI naming flag
commit: a718ba30038402e6daa311c566d9be39e4ab3f05
[30/96] ASoC: ux500: Migrate to new style legacy DAI naming flag
commit: 768be0d633d9ff668a7ca4ba3b8e3eebea328cb8
[31/96] ASoC: ti: Migrate to new style legacy DAI naming flag
commit: 39c84e77da04f66f20fc54c6c6f49a5863bace5d
[32/96] ASoC: mxs-saif: Migrate to new style legacy DAI naming flag
commit: 4cc4e22843e9bec6e9083d85e8a0bfed85fe5423
[33/96] ASoC: samsung: Migrate to new style legacy DAI naming flag
commit: f7bfa516a39a111a5d3b6473cdac20ee6075358c
[34/96] ASoC: core: Switch core to new DAI naming flag
commit: 129f055a2144ab588a43c2e66d21a1f55ce54f81
[35/96] media: TDA1997x: Remove now redundant non_legacy_dai_naming flag
commit: 55b566ded44db29e9c1ab61623c60ade4600301e
[36/96] ASoC: fsl: Remove now redundant non_legacy_dai_naming 

Re: [PATCH 00/96] Refactor non_legacy_dai_naming flag

2022-06-29 Thread Mark Brown
On Thu, 16 Jun 2022 15:32:53 +0100, Charles Keepax wrote:
> Historically, the legacy DAI naming scheme was applied to platform
> drivers and the newer scheme to CODEC drivers. During componentisation
> the core lost the knowledge of if a driver was a CODEC or platform, they
> were all now components. To continue to support the legacy naming on
> older platform drivers a flag was added to the snd_soc_component_driver
> structure, non_legacy_dai_naming, to indicate to use the new scheme and
> this was applied to all CODECs as part of the migration.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[01/96] ASoC: soc-component: Add legacy_dai_naming flag
commit: 1c348f748b4dd7711c5564a8fce0842529498dff
[02/96] soundwire: intel: Migrate to new style legacy DAI naming flag
commit: ca68202098a4416501cc9b5d68a54de22d754766
[03/96] drm/vc4: Migrate to new style legacy DAI naming flag
commit: db827cb34ca38f4106f7c667bea3bbb48bc73552
[04/96] ASoC: img: Migrate to new style legacy DAI naming flag
commit: 5f9d69986014945b826c712081678446c1f10fd7
[05/96] ASoC: spear: Migrate to new style legacy DAI naming flag
commit: eeb021ee8fab0baae82e3784664666fd6b826e89
[06/96] ASoC: jz4740-i2c: Migrate to new style legacy DAI naming flag
commit: 2bebc3b622c3c300eb3a3f603473429d8264c3b6
[07/96] ASoC: ep93xx: Migrate to new style legacy DAI naming flag
commit: fe58b58330434ffad5fa0bc97e177aa93a9a6222
[08/96] ASoC: stm32: Migrate to new style legacy DAI naming flag
commit: 36f07985f81b7482dceb8e650d2ce1f094d1
[09/96] ASoC: bcm: Migrate to new style legacy DAI naming flag
commit: b9a0db0ae5247d92f379107a9c479f881914999d
[10/96] ASoC: sh: Migrate to new style legacy DAI naming flag
commit: f712ff57a27090baff61f92bdb6521e8781d5e6b
[11/96] ASoC: tegra: Migrate to new style legacy DAI naming flag
commit: 3172582c10540d4bf1caac1c39c903793648db8f
[12/96] ASoC: hisilicon: Migrate to new style legacy DAI naming flag
commit: bf6dacb784f0efb5a225f6560d693fa71c7fda64
[13/96] ASoC: xilinx: Migrate to new style legacy DAI naming flag
commit: bd486b070b1e24b38b3d6d7e33abffe4a18e3296
[14/96] ASoC: sunxi: Migrate to new style legacy DAI naming flag
commit: f450b5dbce413b276e6c9215b40868b905c7b634
[15/96] ASoC: Intel: Migrate to new style legacy DAI naming flag
commit: 725cf3bc6009b7fa156b73982eddf23c71767fbb
[16/96] ASoC: meson: Migrate to new style legacy DAI naming flag
commit: d8572da099247860e97b27a7fddc9d80a71b8c25
[17/96] ASoC: sti-uniperf: Migrate to new style legacy DAI naming flag
commit: ad483da7b0a17fdf4df0bd75b2cf29b5650ca2f7
[18/96] ASoC: amd: Migrate to new style legacy DAI naming flag
commit: 0bc1e7d1fc3c50cf1eb62cd3c8d2b73c5f6d83fe
[19/96] ASoC: atmel: Migrate to new style legacy DAI naming flag
commit: 7593e00807fb62e9f5e7367fc2500428cc317ff0
[20/96] ASoC: fsl: Migrate to new style legacy DAI naming flag
commit: 1e63fcc74ace9824f3529eeabbb8f1881a7d3800
[21/96] ASoC: xtensa: Migrate to new style legacy DAI naming flag
commit: f257dea1c589fa3f558502b3ac7b1c09699a73ab
[22/96] ASoC: adi: Migrate to new style legacy DAI naming flag
commit: 9a34161a0bc90df825694195659d894e80afe7a3
[23/96] ASoC: dwc: Migrate to new style legacy DAI naming flag
commit: e740ef3d9418db78ac7a8a24071933f9146af6e4
[24/96] ASoC: qcom: Migrate to new style legacy DAI naming flag
commit: 8135d0290a9a1f1f752bb374f93a017b2074d09b
[25/96] ASoC: test-component: Migrate to new style legacy DAI naming flag
commit: d73130ba523b88a3edb097ae3eb9f93df844b5e2
[26/96] ASoC: rockchip: Migrate to new style legacy DAI naming flag
commit: d48a77173534df90788075e76fa88c52b7395a1e
[27/96] ASoC: au1x: Migrate to new style legacy DAI naming flag
commit: 8e750817a1943b49d81c633f48370bce93bab98c
[28/96] ASoC: pxa: Migrate to new style legacy DAI naming flag
commit: 05603f15b67a517c05ee2e2298e9accb8b7f1794
[29/96] ASoC: sof: Migrate to new style legacy DAI naming flag
commit: a718ba30038402e6daa311c566d9be39e4ab3f05
[30/96] ASoC: ux500: Migrate to new style legacy DAI naming flag
commit: 768be0d633d9ff668a7ca4ba3b8e3eebea328cb8
[31/96] ASoC: ti: Migrate to new style legacy DAI naming flag
commit: 39c84e77da04f66f20fc54c6c6f49a5863bace5d
[32/96] ASoC: mxs-saif: Migrate to new style legacy DAI naming flag
commit: 4cc4e22843e9bec6e9083d85e8a0bfed85fe5423
[33/96] ASoC: samsung: Migrate to new style legacy DAI naming flag
commit: f7bfa516a39a111a5d3b6473cdac20ee6075358c
[34/96] ASoC: core: Switch core to new DAI naming flag
commit: 129f055a2144ab588a43c2e66d21a1f55ce54f81
[35/96] media: TDA1997x: Remove now redundant non_legacy_dai_naming flag
commit: 55b566ded44db29e9c1ab61623c60ade4600301e
[36/96] ASoC: fsl: Remove now redundant non_legacy_dai_naming 

Re: [PATCH v3 09/13] drm/i915/selftests: skip the mman tests for stolen

2022-06-29 Thread Thomas Hellström



On 6/29/22 14:14, Matthew Auld wrote:

It's not supported, and just skips later anyway. With small-BAR things
get more complicated since all of stolen is likely not even CPU
accessible, hence not passing I915_BO_ALLOC_GPU_ONLY just results in the
object create failing.

Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Lionel Landwerlin 
Cc: Tvrtko Ursulin 
Cc: Jon Bloomfield 
Cc: Daniel Vetter 
Cc: Jordan Justen 
Cc: Kenneth Graunke 
Cc: Akeem G Abodunrin 
---
  drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 12 
  1 file changed, 12 insertions(+)


This reminds me,

Is there a problem for fbdev (and hence things like plymouth) if the 
initial fbdev image ends up as a stolen memory object which in turn ends 
up not being mappable? I remember we discussed this before but can't 
recall what the answer was.


Anyway, for this patch

Reviewed-by: Thomas Hellström 







diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c 
b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
index 5bc93a1ce3e3..388c85b0f764 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
@@ -979,6 +979,9 @@ static int igt_mmap(void *arg)
};
int i;
  
+		if (mr->private)

+   continue;
+
for (i = 0; i < ARRAY_SIZE(sizes); i++) {
struct drm_i915_gem_object *obj;
int err;
@@ -1435,6 +1438,9 @@ static int igt_mmap_access(void *arg)
struct drm_i915_gem_object *obj;
int err;
  
+		if (mr->private)

+   continue;
+
obj = __i915_gem_object_create_user(i915, PAGE_SIZE, , 1);
if (obj == ERR_PTR(-ENODEV))
continue;
@@ -1580,6 +1586,9 @@ static int igt_mmap_gpu(void *arg)
struct drm_i915_gem_object *obj;
int err;
  
+		if (mr->private)

+   continue;
+
obj = __i915_gem_object_create_user(i915, PAGE_SIZE, , 1);
if (obj == ERR_PTR(-ENODEV))
continue;
@@ -1727,6 +1736,9 @@ static int igt_mmap_revoke(void *arg)
struct drm_i915_gem_object *obj;
int err;
  
+		if (mr->private)

+   continue;
+
obj = __i915_gem_object_create_user(i915, PAGE_SIZE, , 1);
if (obj == ERR_PTR(-ENODEV))
continue;


Re: [PATCH v3 13/13] drm/i915: turn on small BAR support

2022-06-29 Thread Thomas Hellström



On 6/29/22 14:14, Matthew Auld wrote:

With the uAPI in place we should now have enough in place to ensure a
working system on small BAR configurations.

v2: (Nirmoy & Thomas):
   - s/full BAR/Resizable BAR/ which is hopefully more easily
 understood by users.

Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Lionel Landwerlin 
Cc: Tvrtko Ursulin 
Cc: Jon Bloomfield 
Cc: Daniel Vetter 
Cc: Jordan Justen 
Cc: Kenneth Graunke 
Cc: Akeem G Abodunrin 
---
  drivers/gpu/drm/i915/gt/intel_region_lmem.c | 10 --
  1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_region_lmem.c 
b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
index d09b996a9759..fa7b86f83e7b 100644
--- a/drivers/gpu/drm/i915/gt/intel_region_lmem.c
+++ b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
@@ -112,12 +112,6 @@ static struct intel_memory_region *setup_lmem(struct 
intel_gt *gt)
flat_ccs_base = intel_gt_mcr_read_any(gt, 
XEHP_FLAT_CCS_BASE_ADDR);
flat_ccs_base = (flat_ccs_base >> XEHP_CCS_BASE_SHIFT) * SZ_64K;
  
-		/* FIXME: Remove this when we have small-bar enabled */

-   if (pci_resource_len(pdev, 2) < lmem_size) {
-   drm_err(>drm, "System requires small-BAR support, 
which is currently unsupported on this kernel\n");
-   return ERR_PTR(-EINVAL);
-   }
-
if (GEM_WARN_ON(lmem_size < flat_ccs_base))
return ERR_PTR(-EIO);
  
@@ -170,6 +164,10 @@ static struct intel_memory_region *setup_lmem(struct intel_gt *gt)

drm_info(>drm, "Local memory available: %pa\n",
 _size);
  
+	if (io_size < lmem_size)

+   drm_info(>drm, "Using a reduced BAR size of %lluMiB. Consider 
enabling 'Resizable BAR' or similar, if available in the BIOS.\n",
+(u64)io_size >> 20);
+


Reviewed-by: Thomas Hellström 




Re: [PATCH v3 11/13] drm/i915/ttm: handle blitter failure on DG2

2022-06-29 Thread Thomas Hellström

Hi, Matthew,

On 6/29/22 14:14, Matthew Auld wrote:

If the move or clear operation somehow fails, and the memory underneath
is not cleared, like when moving to lmem, then we currently fallback to
memcpy or memset. However with small-BAR systems this fallback might no
longer be possible. For now we use the set_wedged sledgehammer if we
ever encounter such a scenario, and mark the object as borked to plug
any holes where access to the memory underneath can happen. Add some
basic selftests to exercise this.

v2:
   - In the selftests make sure we grab the runtime pm around the reset.
 Also make sure we grab the reset lock before checking if the device
 is wedged, since the wedge might still be in-progress and hence the
 bit might not be set yet.
   - Don't wedge or put the object into an unknown state, if the request
 construction fails (or similar). Just returning an error and
 skipping the fallback should be safe here.
   - Make sure we wedge each gt. (Thomas)
   - Peek at the unknown_state in io_reserve, that way we don't have to
 export or hand roll the fault_wait_for_idle. (Thomas)
   - Add the missing read-side barriers for the unknown_state. (Thomas)
   - Some kernel-doc fixes. (Thomas)

Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Lionel Landwerlin 
Cc: Tvrtko Ursulin 
Cc: Jon Bloomfield 
Cc: Daniel Vetter 
Cc: Jordan Justen 
Cc: Kenneth Graunke 
Cc: Akeem G Abodunrin 
---
  drivers/gpu/drm/i915/gem/i915_gem_object.c|  21 +++
  drivers/gpu/drm/i915/gem/i915_gem_object.h|   1 +
  .../gpu/drm/i915/gem/i915_gem_object_types.h  |  18 +++
  drivers/gpu/drm/i915/gem/i915_gem_ttm.c   |  26 +++-
  drivers/gpu/drm/i915/gem/i915_gem_ttm.h   |   3 +
  drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c  |  88 +--
  drivers/gpu/drm/i915/gem/i915_gem_ttm_move.h  |   1 +
  .../drm/i915/gem/selftests/i915_gem_migrate.c | 141 +++---
  .../drm/i915/gem/selftests/i915_gem_mman.c|  69 +
  drivers/gpu/drm/i915/i915_vma.c   |  25 ++--
  10 files changed, 346 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c 
b/drivers/gpu/drm/i915/gem/i915_gem_object.c
index 06b1b188ce5a..642a5d59ce26 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -783,10 +783,31 @@ int i915_gem_object_wait_moving_fence(struct 
drm_i915_gem_object *obj,
intr, MAX_SCHEDULE_TIMEOUT);
if (!ret)
ret = -ETIME;
+   else if (ret > 0 && i915_gem_object_has_unknown_state(obj))
+   ret = -EIO;
  
  	return ret < 0 ? ret : 0;

  }
  
+/**

+ * i915_gem_object_has_unknown_state - Return true if the object backing pages 
are
+ * in an unknown_state. This means that userspace must NEVER be allowed to 
touch
+ * the pages, with either the GPU or CPU.
+ *
+ * ONLY valid to be called after ensuring that all kernel fences have signalled
+ * (in particular the fence for moving/clearing the object).
+ */
+bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object *obj)
+{
+   /*
+* The below barrier pairs with the dma_fence_signal() in
+* __memcpy_work(). We should only sample the unknown_state after all
+* the kernel fences have signalled.
+*/
+   smp_rmb();
+   return obj->mm.unknown_state;
+}
+
  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftests/huge_gem_object.c"
  #include "selftests/huge_pages.c"
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index e11d82a9f7c3..0bf3ee27a2a8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -524,6 +524,7 @@ int i915_gem_object_get_moving_fence(struct 
drm_i915_gem_object *obj,
 struct dma_fence **fence);
  int i915_gem_object_wait_moving_fence(struct drm_i915_gem_object *obj,
  bool intr);
+bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object *obj);
  
  void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,

 unsigned int cache_level);
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index 2c88bdb8ff7c..5cf36a130061 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -547,6 +547,24 @@ struct drm_i915_gem_object {
 */
bool ttm_shrinkable;
  
+		/**

+* @unknown_state: Indicate that the object is effectively
+* borked. This is write-once and set if we somehow encounter a
+* fatal error when moving/clearing the pages, and we are not
+* able to fallback to memcpy/memset, like on small-BAR systems.
+* The GPU should also be 

Re: [PATCH] drm: Create support for Write-Only property blob

2022-06-29 Thread Mark Yacoub
Hi Jani, let me know if you need more info or more changes are needed. Thanks!

On Wed, May 25, 2022 at 3:31 PM Mark Yacoub  wrote:
>
> Hi Jani, thanks for your review. I got all the user space
> implementation ready to see it in context.
>
> libdrm patch to wrap this functionality:
> https://www.spinics.net/lists/dri-devel/msg347318.html
>
> Chromium user space implementation making direct use of the new prop flag:
> crrev.com/c/3655850
> The first call made to such functionality is in
> https://chromium-review.googlesource.com/c/chromium/src/+/3655850/2/ui/display/manager/content_protection_key_manager.cc#137
> where the call stack flows to the libdrm wrapper call at
> https://chromium-review.googlesource.com/c/chromium/src/+/3655850/2/ui/ozone/platform/drm/gpu/drm_display.cc#203
>
> I also wrote an IGT test to verify the intended behavior:
> https://patchwork.freedesktop.org/patch/487331/?series=104373=1
>
> Let me know if I would need to update the commit message with any of
> the aforementioned context.
>
> Thanks!
> -Mark Yacoub
>
> On Tue, May 17, 2022 at 3:53 AM Jani Nikula  
> wrote:
> >
> > On Tue, 10 May 2022, Mark Yacoub  wrote:
> > > [Why]
> > > User space might need to inject data into the kernel without allowing it
> > > to be read again by any user space.
> > > An example of where this is particularly useful is secret keys fetched
> > > by user space and injected into the kernel to enable content protection.
> >
> > I think we're going to need more than an example in the commit
> > message. See Documentation/gpu/drm-uapi.rst.
> >
> > BR,
> > Jani.
> >
> >
> > >
> > > [How]
> > > Create a DRM_MODE_CREATE_BLOB_WRITE_ONLY flag used by user space to
> > > create a blob and mark the blob as write only.
> > > On reading back the blob, data will be not be copied if it's a write
> > > only blob
> > >
> > > Signed-off-by: Mark Yacoub 
> > >
> > > ---
> > >  drivers/gpu/drm/drm_property.c | 3 ++-
> > >  include/drm/drm_property.h | 2 ++
> > >  include/uapi/drm/drm_mode.h| 6 ++
> > >  3 files changed, 10 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/gpu/drm/drm_property.c 
> > > b/drivers/gpu/drm/drm_property.c
> > > index dfec479830e4..afedf7109d00 100644
> > > --- a/drivers/gpu/drm/drm_property.c
> > > +++ b/drivers/gpu/drm/drm_property.c
> > > @@ -765,7 +765,7 @@ int drm_mode_getblob_ioctl(struct drm_device *dev,
> > >   if (!blob)
> > >   return -ENOENT;
> > >
> > > - if (out_resp->length == blob->length) {
> > > + if (out_resp->length == blob->length && !blob->is_write_only) {
> > >   if (copy_to_user(u64_to_user_ptr(out_resp->data),
> > >blob->data,
> > >blob->length)) {
> > > @@ -800,6 +800,7 @@ int drm_mode_createblob_ioctl(struct drm_device *dev,
> > >   ret = -EFAULT;
> > >   goto out_blob;
> > >   }
> > > + blob->is_write_only = out_resp->flags & 
> > > DRM_MODE_CREATE_BLOB_WRITE_ONLY;
> > >
> > >   /* Dropping the lock between create_blob and our access here is safe
> > >* as only the same file_priv can remove the blob; at this point, 
> > > it is
> > > diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h
> > > index 65bc9710a470..700782f021b9 100644
> > > --- a/include/drm/drm_property.h
> > > +++ b/include/drm/drm_property.h
> > > @@ -205,6 +205,7 @@ struct drm_property {
> > >   *   _mode_config.property_blob_list.
> > >   * @head_file: entry on the per-file blob list in _file.blobs list.
> > >   * @length: size of the blob in bytes, invariant over the lifetime of 
> > > the object
> > > + * @is_write_only: user space can't read the blob data.
> > >   * @data: actual data, embedded at the end of this structure
> > >   *
> > >   * Blobs are used to store bigger values than what fits directly into 
> > > the 64
> > > @@ -219,6 +220,7 @@ struct drm_property_blob {
> > >   struct list_head head_global;
> > >   struct list_head head_file;
> > >   size_t length;
> > > + bool is_write_only;
> > >   void *data;
> > >  };
> > >
> > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > index 0a0d56a6158e..de192d3813e9 100644
> > > --- a/include/uapi/drm/drm_mode.h
> > > +++ b/include/uapi/drm/drm_mode.h
> > > @@ -1107,6 +1107,9 @@ struct drm_format_modifier {
> > >   __u64 modifier;
> > >  };
> > >
> > > +#define DRM_MODE_CREATE_BLOB_WRITE_ONLY  
> > >   \
> > > + (1 << 0) /* data of the blob can't be read by user space */
> > > +
> > >  /**
> > >   * struct drm_mode_create_blob - Create New blob property
> > >   *
> > > @@ -1120,6 +1123,9 @@ struct drm_mode_create_blob {
> > >   __u32 length;
> > >   /** @blob_id: Return: new property ID. */
> > >   __u32 blob_id;
> > > + /** Flags for special handling. */
> > > + __u32 flags;
> > > + __u32 pad;
> > >  };
> > >
> > >  /**
> >
> > --
> > Jani Nikula, 

Re: [PATCH] drm/bridge: anx7625: use pm_runtime_force_suspend(resume)

2022-06-29 Thread Hsin-Yi Wang
On Tue, Jun 28, 2022 at 6:46 PM Hsin-Yi Wang  wrote:
>
> There's no need to check for IRQ or disable it in suspend.
>
> Use pm_runtime_force_suspend(resume) to make sure anx7625 is powered off
> correctly. Make the system suspend/resume and pm runtime suspend/resume
> more consistant.
>
> Signed-off-by: Hsin-Yi Wang 
> ---
The patch is re-sent again with other anx7625 patches in this series:
https://lore.kernel.org/lkml/20220629160550.433980-1-hsi...@chromium.org/


>  drivers/gpu/drm/bridge/analogix/anx7625.c | 33 ++-
>  1 file changed, 2 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index 3710fa9ee0acd..09688a1076037 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -2542,38 +2542,9 @@ static int __maybe_unused 
> anx7625_runtime_pm_resume(struct device *dev)
> return 0;
>  }
>
> -static int __maybe_unused anx7625_resume(struct device *dev)
> -{
> -   struct anx7625_data *ctx = dev_get_drvdata(dev);
> -
> -   if (!ctx->pdata.intp_irq)
> -   return 0;
> -
> -   if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
> -   enable_irq(ctx->pdata.intp_irq);
> -   anx7625_runtime_pm_resume(dev);
> -   }
> -
> -   return 0;
> -}
> -
> -static int __maybe_unused anx7625_suspend(struct device *dev)
> -{
> -   struct anx7625_data *ctx = dev_get_drvdata(dev);
> -
> -   if (!ctx->pdata.intp_irq)
> -   return 0;
> -
> -   if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
> -   anx7625_runtime_pm_suspend(dev);
> -   disable_irq(ctx->pdata.intp_irq);
> -   }
> -
> -   return 0;
> -}
> -
>  static const struct dev_pm_ops anx7625_pm_ops = {
> -   SET_SYSTEM_SLEEP_PM_OPS(anx7625_suspend, anx7625_resume)
> +   SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> +   pm_runtime_force_resume)
> SET_RUNTIME_PM_OPS(anx7625_runtime_pm_suspend,
>anx7625_runtime_pm_resume, NULL)
>  };
> --
> 2.37.0.rc0.161.g10f37bed90-goog
>


[PATCH 4/4] drm/bridge: anx7625: Add wait_hpd_asserted() callback

2022-06-29 Thread Hsin-Yi Wang
Move hpd polling check into wait_hpd_asserted() callback. For the cases
that aux transfer function wasn't used, do hpd polling check after pm
runtime resume, which will power on the bridge.

Signed-off-by: Hsin-Yi Wang 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 33 ++-
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 59ddeba33652b..ea5a0b86fe52a 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1443,23 +1443,24 @@ static int anx7625_read_hpd_status_p0(struct 
anx7625_data *ctx)
return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, SYSTEM_STSTUS);
 }
 
-static void anx7625_hpd_polling(struct anx7625_data *ctx)
+static int _anx7625_hpd_polling(struct anx7625_data *ctx,
+unsigned long wait_us)
 {
int ret, val;
struct device *dev = >client->dev;
 
/* Interrupt mode, no need poll HPD status, just return */
if (ctx->pdata.intp_irq)
-   return;
+   return 0;
 
ret = readx_poll_timeout(anx7625_read_hpd_status_p0,
 ctx, val,
 ((val & HPD_STATUS) || (val < 0)),
-5000,
-5000 * 100);
+wait_us / 100,
+wait_us);
if (ret) {
DRM_DEV_ERROR(dev, "no hpd.\n");
-   return;
+   return ret;
}
 
DRM_DEV_DEBUG_DRIVER(dev, "system status: 0x%x. HPD raise up.\n", val);
@@ -1472,6 +1473,23 @@ static void anx7625_hpd_polling(struct anx7625_data *ctx)
 
if (!ctx->pdata.panel_bridge && ctx->bridge_attached)
drm_helper_hpd_irq_event(ctx->bridge.dev);
+
+   return 0;
+}
+
+static int anx7625_wait_hpd_asserted(struct drm_dp_aux *aux,
+unsigned long wait_us)
+{
+   struct anx7625_data *ctx = container_of(aux, struct anx7625_data, aux);
+   struct device *dev = >client->dev;
+   int ret;
+
+   pm_runtime_get_sync(dev);
+   ret = _anx7625_hpd_polling(ctx, wait_us);
+   pm_runtime_mark_last_busy(dev);
+   pm_runtime_put_autosuspend(dev);
+
+   return ret;
 }
 
 static void anx7625_remove_edid(struct anx7625_data *ctx)
@@ -1741,6 +1759,7 @@ static struct edid *anx7625_get_edid(struct anx7625_data 
*ctx)
}
 
pm_runtime_get_sync(dev);
+   _anx7625_hpd_polling(ctx, 5000 * 100);
edid_num = sp_tx_edid_read(ctx, p_edid->edid_raw_data);
pm_runtime_put_sync(dev);
 
@@ -2378,6 +2397,7 @@ static void anx7625_bridge_atomic_enable(struct 
drm_bridge *bridge,
ctx->connector = connector;
 
pm_runtime_get_sync(dev);
+   _anx7625_hpd_polling(ctx, 5000 * 100);
 
anx7625_dp_start(ctx);
 }
@@ -2497,7 +2517,6 @@ static int __maybe_unused 
anx7625_runtime_pm_resume(struct device *dev)
mutex_lock(>lock);
 
anx7625_power_on_init(ctx);
-   anx7625_hpd_polling(ctx);
 
mutex_unlock(>lock);
 
@@ -2589,6 +2608,7 @@ static int anx7625_i2c_probe(struct i2c_client *client,
platform->aux.name = "anx7625-aux";
platform->aux.dev = dev;
platform->aux.transfer = anx7625_aux_transfer;
+   platform->aux.wait_hpd_asserted = anx7625_wait_hpd_asserted;
drm_dp_aux_init(>aux);
 
if (anx7625_register_i2c_dummy_clients(platform, client) != 0) {
@@ -2617,6 +2637,7 @@ static int anx7625_i2c_probe(struct i2c_client *client,
if (!platform->pdata.low_power_mode) {
anx7625_disable_pd_protocol(platform);
pm_runtime_get_sync(dev);
+   _anx7625_hpd_polling(platform, 5000 * 100);
}
 
/* Add work function */
-- 
2.37.0.rc0.161.g10f37bed90-goog



[PATCH 2/4] drm/bridge: anx7625: Use pm_runtime_force_suspend(resume)

2022-06-29 Thread Hsin-Yi Wang
There's no need to check for IRQ or disable it in suspend.

Use pm_runtime_force_suspend(resume) to make sure anx7625 is powered off
correctly. Make the system suspend/resume and pm runtime suspend/resume
more consistant.

Signed-off-by: Hsin-Yi Wang 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 33 ++-
 1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index f89e8151475f7..478f5af381c7d 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -2504,38 +2504,9 @@ static int __maybe_unused 
anx7625_runtime_pm_resume(struct device *dev)
return 0;
 }
 
-static int __maybe_unused anx7625_resume(struct device *dev)
-{
-   struct anx7625_data *ctx = dev_get_drvdata(dev);
-
-   if (!ctx->pdata.intp_irq)
-   return 0;
-
-   if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
-   enable_irq(ctx->pdata.intp_irq);
-   anx7625_runtime_pm_resume(dev);
-   }
-
-   return 0;
-}
-
-static int __maybe_unused anx7625_suspend(struct device *dev)
-{
-   struct anx7625_data *ctx = dev_get_drvdata(dev);
-
-   if (!ctx->pdata.intp_irq)
-   return 0;
-
-   if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
-   anx7625_runtime_pm_suspend(dev);
-   disable_irq(ctx->pdata.intp_irq);
-   }
-
-   return 0;
-}
-
 static const struct dev_pm_ops anx7625_pm_ops = {
-   SET_SYSTEM_SLEEP_PM_OPS(anx7625_suspend, anx7625_resume)
+   SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+   pm_runtime_force_resume)
SET_RUNTIME_PM_OPS(anx7625_runtime_pm_suspend,
   anx7625_runtime_pm_resume, NULL)
 };
-- 
2.37.0.rc0.161.g10f37bed90-goog



[PATCH 1/4] drm/bridge: anx7625: Convert to devm_i2c_new_dummy_device()

2022-06-29 Thread Hsin-Yi Wang
Simplify the resource management.

Signed-off-by: Hsin-Yi Wang 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 96 +++
 1 file changed, 27 insertions(+), 69 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 3710fa9ee0acd..f89e8151475f7 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -2436,82 +2436,44 @@ static const struct drm_bridge_funcs 
anx7625_bridge_funcs = {
 static int anx7625_register_i2c_dummy_clients(struct anx7625_data *ctx,
  struct i2c_client *client)
 {
-   int err = 0;
+   struct device *dev = >client->dev;
 
-   ctx->i2c.tx_p0_client = i2c_new_dummy_device(client->adapter,
-TX_P0_ADDR >> 1);
+   ctx->i2c.tx_p0_client = devm_i2c_new_dummy_device(dev, client->adapter,
+   TX_P0_ADDR >> 1);
if (IS_ERR(ctx->i2c.tx_p0_client))
return PTR_ERR(ctx->i2c.tx_p0_client);
 
-   ctx->i2c.tx_p1_client = i2c_new_dummy_device(client->adapter,
-TX_P1_ADDR >> 1);
-   if (IS_ERR(ctx->i2c.tx_p1_client)) {
-   err = PTR_ERR(ctx->i2c.tx_p1_client);
-   goto free_tx_p0;
-   }
+   ctx->i2c.tx_p1_client = devm_i2c_new_dummy_device(dev, client->adapter,
+   TX_P1_ADDR >> 1);
+   if (IS_ERR(ctx->i2c.tx_p1_client))
+   return PTR_ERR(ctx->i2c.tx_p1_client);
 
-   ctx->i2c.tx_p2_client = i2c_new_dummy_device(client->adapter,
-TX_P2_ADDR >> 1);
-   if (IS_ERR(ctx->i2c.tx_p2_client)) {
-   err = PTR_ERR(ctx->i2c.tx_p2_client);
-   goto free_tx_p1;
-   }
+   ctx->i2c.tx_p2_client = devm_i2c_new_dummy_device(dev, client->adapter,
+   TX_P2_ADDR >> 1);
+   if (IS_ERR(ctx->i2c.tx_p2_client))
+   return PTR_ERR(ctx->i2c.tx_p2_client);
 
-   ctx->i2c.rx_p0_client = i2c_new_dummy_device(client->adapter,
-RX_P0_ADDR >> 1);
-   if (IS_ERR(ctx->i2c.rx_p0_client)) {
-   err = PTR_ERR(ctx->i2c.rx_p0_client);
-   goto free_tx_p2;
-   }
+   ctx->i2c.rx_p0_client = devm_i2c_new_dummy_device(dev, client->adapter,
+   RX_P0_ADDR >> 1);
+   if (IS_ERR(ctx->i2c.rx_p0_client))
+   return PTR_ERR(ctx->i2c.rx_p0_client);
 
-   ctx->i2c.rx_p1_client = i2c_new_dummy_device(client->adapter,
-RX_P1_ADDR >> 1);
-   if (IS_ERR(ctx->i2c.rx_p1_client)) {
-   err = PTR_ERR(ctx->i2c.rx_p1_client);
-   goto free_rx_p0;
-   }
+   ctx->i2c.rx_p1_client = devm_i2c_new_dummy_device(dev, client->adapter,
+   RX_P1_ADDR >> 1);
+   if (IS_ERR(ctx->i2c.rx_p1_client))
+   return PTR_ERR(ctx->i2c.rx_p1_client);
 
-   ctx->i2c.rx_p2_client = i2c_new_dummy_device(client->adapter,
-RX_P2_ADDR >> 1);
-   if (IS_ERR(ctx->i2c.rx_p2_client)) {
-   err = PTR_ERR(ctx->i2c.rx_p2_client);
-   goto free_rx_p1;
-   }
+   ctx->i2c.rx_p2_client = devm_i2c_new_dummy_device(dev, client->adapter,
+   RX_P2_ADDR >> 1);
+   if (IS_ERR(ctx->i2c.rx_p2_client))
+   return PTR_ERR(ctx->i2c.rx_p2_client);
 
-   ctx->i2c.tcpc_client = i2c_new_dummy_device(client->adapter,
-   TCPC_INTERFACE_ADDR >> 1);
-   if (IS_ERR(ctx->i2c.tcpc_client)) {
-   err = PTR_ERR(ctx->i2c.tcpc_client);
-   goto free_rx_p2;
-   }
+   ctx->i2c.tcpc_client = devm_i2c_new_dummy_device(dev, client->adapter,
+   TCPC_INTERFACE_ADDR >> 1);
+   if (IS_ERR(ctx->i2c.tcpc_client))
+   return PTR_ERR(ctx->i2c.tcpc_client);
 
return 0;
-
-free_rx_p2:
-   i2c_unregister_device(ctx->i2c.rx_p2_client);
-free_rx_p1:
-   i2c_unregister_device(ctx->i2c.rx_p1_client);
-free_rx_p0:
-   i2c_unregister_device(ctx->i2c.rx_p0_client);
-free_tx_p2:
-   i2c_unregister_device(ctx->i2c.tx_p2_client);
-free_tx_p1:
-   i2c_unregister_device(ctx->i2c.tx_p1_client);
-free_tx_p0:
-   i2c_unregister_device(ctx->i2c.tx_p0_client);
-
-   return err;
-}
-
-static void anx7625_unregister_i2c_dummy_clients(struct anx7625_data *ctx)
-{
-   i2c_unregister_device(ctx->i2c.tx_p0_client);
-   i2c_unregister_device(ctx->i2c.tx_p1_client);
-   i2c_unregister_device(ctx->i2c.tx_p2_client);
-

[PATCH 3/4] drm/bridge: anx7625: Fix NULL pointer crash when using edp-panel

2022-06-29 Thread Hsin-Yi Wang
Move devm_of_dp_aux_populate_ep_devices() after pm runtime and i2c setup
to avoid NULL pointer crash.

edp-panel probe (generic_edp_panel_probe) calls pm_runtime_get_sync() to
read EDID. At this time, bridge should have pm runtime enabled and i2c
clients ready.

Fixes: adca62ec370c ("drm/bridge: anx7625: Support reading edid through aux 
channel")
Signed-off-by: Hsin-Yi Wang 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 478f5af381c7d..59ddeba33652b 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -2590,14 +2590,6 @@ static int anx7625_i2c_probe(struct i2c_client *client,
platform->aux.dev = dev;
platform->aux.transfer = anx7625_aux_transfer;
drm_dp_aux_init(>aux);
-   devm_of_dp_aux_populate_ep_devices(>aux);
-
-   ret = anx7625_parse_dt(dev, pdata);
-   if (ret) {
-   if (ret != -EPROBE_DEFER)
-   DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
-   goto free_wq;
-   }
 
if (anx7625_register_i2c_dummy_clients(platform, client) != 0) {
ret = -ENOMEM;
@@ -2613,6 +2605,15 @@ static int anx7625_i2c_probe(struct i2c_client *client,
if (ret)
goto free_wq;
 
+   devm_of_dp_aux_populate_ep_devices(>aux);
+
+   ret = anx7625_parse_dt(dev, pdata);
+   if (ret) {
+   if (ret != -EPROBE_DEFER)
+   DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
+   goto free_wq;
+   }
+
if (!platform->pdata.low_power_mode) {
anx7625_disable_pd_protocol(platform);
pm_runtime_get_sync(dev);
-- 
2.37.0.rc0.161.g10f37bed90-goog



[PATCH 0/4] anx7625: Cleanup, fixes, and implement wait_hpd_asserted

2022-06-29 Thread Hsin-Yi Wang
This series contains:
Cleanup:
- Convert to use devm_i2c_new_dummy_device()
- Use pm_runtime_force_suspend(resume)
Fixes:
- Fix NULL pointer crash when using edp-panel
and Impelment wait_hpd_asserted() callback.

The patches are not related to each other, but they are all
anx7625 patches so they are all stacked in this series.

Hsin-Yi Wang (4):
  drm/bridge: anx7625: Convert to devm_i2c_new_dummy_device()
  drm/bridge: anx7625: Use pm_runtime_force_suspend(resume)
  drm/bridge: anx7625: Fix NULL pointer crash when using edp-panel
  drm/bridge: anx7625: Add wait_hpd_asserted() callback

 drivers/gpu/drm/bridge/analogix/anx7625.c | 179 --
 1 file changed, 65 insertions(+), 114 deletions(-)

-- 
2.37.0.rc0.161.g10f37bed90-goog



Re: [PATCH 5/6] drm/i915/gt: Serialize GRDOM access between multiple engine resets

2022-06-29 Thread Tvrtko Ursulin



On 29/06/2022 16:30, Mauro Carvalho Chehab wrote:

On Tue, 28 Jun 2022 16:49:23 +0100
Tvrtko Ursulin  wrote:


.. which for me means a different patch 1, followed by patch 6 (moved
to be patch 2) would be ideal stable material.

Then we have the current patch 2 which is open/unknown (to me at least).

And the rest seem like optimisations which shouldn't be tagged as fixes.

Apart from patch 5 which should be cc: stable, but no fixes as agreed.

Could you please double check if what I am suggesting here is feasible
to implement and if it is just send those minimal patches out alone?


Tested and porting just those 3 patches are enough to fix the Broadwell
bug.

So, I submitted a v2 of this series with just those. They all need to
be backported to stable.


I would really like to give even a smaller fix a try. Something like, although 
not even compile tested:

commit 4d5e94aef164772f4d85b3b4c1a46eac9a2bd680
Author: Chris Wilson 
Date:   Wed Jun 29 16:25:24 2022 +0100

drm/i915/gt: Serialize TLB invalidates with GT resets

Avoid trying to invalidate the TLB in the middle of performing an

engine reset, as this may result in the reset timing out. Currently,
the TLB invalidate is only serialised by its own mutex, forgoing the
uncore lock, but we can take the uncore->lock as well to serialise
the mmio access, thereby serialising with the GDRST.

Tested on a NUC5i7RYB, BIOS RYBDWi35.86A.0380.2019.0517.1530 with

i915 selftest/hangcheck.

Cc: sta...@vger.kernel.org

Fixes: 7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store")
Reported-by: Mauro Carvalho Chehab 
Tested-by: Mauro Carvalho Chehab 
Reviewed-by: Mauro Carvalho Chehab 
Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Acked-by: Thomas Hellström 
Reviewed-by: Andi Shyti 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Tvrtko Ursulin 

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index 8da3314bb6bf..aaadd0b02043 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -952,7 +952,23 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
mutex_lock(>tlb_invalidate_lock);
intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
 
+   spin_lock_irq(>lock); /* serialise invalidate with GT reset */

+
+   for_each_engine(engine, gt, id) {
+   struct reg_and_bit rb;
+
+   rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num);
+   if (!i915_mmio_reg_offset(rb.reg))
+   continue;
+
+   intel_uncore_write_fw(uncore, rb.reg, rb.bit);
+   }
+
+   spin_unlock_irq(>lock);
+
for_each_engine(engine, gt, id) {
+   struct reg_and_bit rb;
+
/*
 * HW architecture suggest typical invalidation time at 40us,
 * with pessimistic cases up to 100us and a recommendation to
@@ -960,13 +976,11 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
 */
const unsigned int timeout_us = 100;
const unsigned int timeout_ms = 4;
-   struct reg_and_bit rb;
 
rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num);

if (!i915_mmio_reg_offset(rb.reg))
continue;
 
-   intel_uncore_write_fw(uncore, rb.reg, rb.bit);

if (__intel_wait_for_register_fw(uncore,
 rb.reg, rb.bit, 0,
 timeout_us, timeout_ms,

If this works it would be least painful to backport. The other improvements can 
then be devoid of the fixes tag.


I still think that other TLB patches are needed/desired upstream, but
I'll submit them on a separate series. Let's fix the regression first ;-)


Yep, that's exactly right.

Regards,

Tvrtko


Re: [PATCH v2 1/2] drm/msm/a6xx: Add support for a new 7c3 sku

2022-06-29 Thread Rob Clark
On Tue, Jun 28, 2022 at 10:32 PM Akhil P Oommen
 wrote:
>
> On 6/29/2022 9:59 AM, Bjorn Andersson wrote:
> > On Tue 10 May 02:53 CDT 2022, Akhil P Oommen wrote:
> >
> >> Add a new sku to the fuse map of 7c3 gpu.
> >>
> >> Signed-off-by: Akhil P Oommen 
> > Is this series still needed/wanted? I've been waiting for patch 1 to be
> > merged in the driver so that I can pick up the dts change.

It just missed the previous merge window by a couple of days.. I was
planning to pick it up for the upcoming merge window

but I don't think the dt bit should depend on the driver bit in this case

> >
> > Regards,
> > Bjorn
> Internally, this sku is on hold. So we can drop this series for now. I
> will resend it if required in future.

ok, I'll hold off for now

BR,
-R

> -Akhil.
>
> >
> >> ---
> >>
> >> (no changes since v1)
> >>
> >>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 ++
> >>   1 file changed, 2 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
> >> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >> index 841e47a..61bb21d 100644
> >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> >> @@ -1771,6 +1771,8 @@ static u32 adreno_7c3_get_speed_bin(u32 fuse)
> >>  return 0;
> >>  else if (fuse == 190)
> >>  return 1;
> >> +else if (fuse == 96)
> >> +return 2;
> >>
> >>  return UINT_MAX;
> >>   }
> >> --
> >> 2.7.4
> >>
>


Re: [PATCH v3 11/14] power: supply: mt6370: Add Mediatek MT6370 charger driver

2022-06-29 Thread ChiaEn Wu
Hi Andy,

Sorry for the late reply, I have some questions to ask you below. Thanks!

Andy Shevchenko  於 2022年6月24日 週五 凌晨2:56寫道:
>
> On Thu, Jun 23, 2022 at 2:00 PM ChiaEn Wu  wrote:
> >
> > From: ChiaEn Wu 
> >
> > Add Mediatek MT6370 charger driver.
>
> ...
>
> > +config CHARGER_MT6370
> > +   tristate "Mediatek MT6370 Charger Driver"
> > +   depends on MFD_MT6370
> > +   depends on REGULATOR
> > +   select LINEAR_RANGES
> > +   help
> > + Say Y here to enable MT6370 Charger Part.
> > + The device supports High-Accuracy Voltage/Current Regulation,
> > + Average Input Current Regulation, Battery Temperature Sensing,
> > + Over-Temperature Protection, DPDM Detection for BC1.2.
>
> Module name?
>
> ...
>
> > +#include 
>
> This usually goes after linux/*
>
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
>
> > +#include 
>
>
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
>
> ...
>
> > +#define MT6370_MIVR_IBUS_TH10  /* 100 mA */
>
> Instead of comment, add proper units.
>
> ...
>
> > +   MT6370_USB_STAT_DCP,
> > +   MT6370_USB_STAT_CDP,
> > +   MT6370_USB_STAT_MAX,
>
> No comma for a terminator line.
>
> ...
>
> > +static inline u32 mt6370_chg_val_to_reg(const struct mt6370_chg_range 
> > *range,
> > +   u32 val)
> > +static inline u32 mt6370_chg_reg_to_val(const struct mt6370_chg_range 
> > *range,
> > +   u8 reg)
>
> I'm wondering if you can use the
> https://elixir.bootlin.com/linux/v5.19-rc3/source/include/linux/linear_range.h
> APIs.

Thanks for your helpful comments!
I will refine it in the next patch!

>
> ...
>
> > +   int ret = 0;
>
> This seems a redundant assignment, see below.
>
> > +   rcfg->ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(of),
> > +"enable", 0,
>
> For index == 0 don't use _index API.
>
> > +GPIOD_OUT_LOW |
> > +
> > GPIOD_FLAGS_BIT_NONEXCLUSIVE,
> > +rdesc->name);
> > +   if (IS_ERR(rcfg->ena_gpiod)) {
> > +   dev_err(priv->dev, "Failed to requeset OTG EN Pin\n");
>
> request
>
> > +   rcfg->ena_gpiod = NULL;
>
> So, use _optional and return any errors you got.

These days, I tried to use various APIs in , and also
try to use _optional APIs.
But my OTG regulator node is a child node of the charger node, like below.

// copy-paste from our mfd dt-binding example
charger {
  compatible = "mediatek,mt6370-charger";
  interrupts = <48>, <68>, <6>;
  interrupt-names = "attach_i", "uvp_d_evt", "mivr";
  io-channels = <_adc MT6370_CHAN_IBUS>;

  mt6370_otg_vbus: usb-otg-vbus-regulator {
regulator-name = "mt6370-usb-otg-vbus";
regulator-min-microvolt = <435>;
regulator-max-microvolt = <580>;
regulator-min-microamp = <50>;
regulator-max-microamp = <300>;
  };
};

Hence, if I use _optional APIs, it will always get NULL.
And, If I use 'gpiod_get_from_of_node' here, this API will only parse
the 'enable' property, not 'enable-gpio' or 'enable-gpios', we need to
add the '-gpio' suffix before we use this API.

Only 'fwnode_gpiod_get_index' can match this case. Although fwnode
parsing is not preferred, 'of_parse_cb' already can guarantee the
callback will only be used by the regulator of_node parsing.

>
> > +   } else {
> > +   val = MT6370_OPA_MODE_MASK | MT6370_OTG_PIN_EN_MASK;
> > +   ret = regmap_update_bits(priv->regmap, MT6370_REG_CHG_CTRL1,
> > +val, val);
> > +   if (ret)
> > +   dev_err(priv->dev, "Failed to set otg bits\n");
> > +   }
>
> ...
>
> > +   irq_num = platform_get_irq_byname(pdev, irq_name);
>
> > +
>
> Unwanted blank line.
>
> > +   if (irq_num < 0) {
>
> > +   dev_err(priv->dev, "Failed to get platform resource\n");
>
> Isn't it printed by the call?
>
> > +   } else {
> > +   if (en)
> > +   enable_irq(irq_num);
> > +   else
> > +   disable_irq_nosync(irq_num);
> > +   }
>
> ...
>
> > +toggle_cfo_exit:
>
> The useless label.
>
> > +   return ret;
> > +}
>
> ...
>
> > +   ret = mt6370_chg_get_online(priv, val);
> > +   if (!val->intval) {
>
> No error check?

I replace "mt6370_chg_get_online()" with "power_supply_get_property()"
and add some error check.
Could it meet your 

Re: [PATCH 5/6] drm/i915/gt: Serialize GRDOM access between multiple engine resets

2022-06-29 Thread Mauro Carvalho Chehab
On Tue, 28 Jun 2022 16:49:23 +0100
Tvrtko Ursulin  wrote:

>.. which for me means a different patch 1, followed by patch 6 (moved 
> to be patch 2) would be ideal stable material.
> 
> Then we have the current patch 2 which is open/unknown (to me at least).
> 
> And the rest seem like optimisations which shouldn't be tagged as fixes.
> 
> Apart from patch 5 which should be cc: stable, but no fixes as agreed.
> 
> Could you please double check if what I am suggesting here is feasible 
> to implement and if it is just send those minimal patches out alone?

Tested and porting just those 3 patches are enough to fix the Broadwell
bug.

So, I submitted a v2 of this series with just those. They all need to
be backported to stable.

I still think that other TLB patches are needed/desired upstream, but
I'll submit them on a separate series. Let's fix the regression first ;-)

Regards,
Mauro


[PATCH v2 3/3] drm/i915/gt: Serialize TLB invalidates with GT resets

2022-06-29 Thread Mauro Carvalho Chehab
From: Chris Wilson 

Avoid trying to invalidate the TLB in the middle of performing an
engine reset, as this may result in the reset timing out. Currently,
the TLB invalidate is only serialised by its own mutex, forgoing the
uncore lock, but we can take the uncore->lock as well to serialise
the mmio access, thereby serialising with the GDRST.

Tested on a NUC5i7RYB, BIOS RYBDWi35.86A.0380.2019.0517.1530 with
i915 selftest/hangcheck.

Cc: sta...@vger.kernel.org
Fixes: 7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store")
Reported-by: Mauro Carvalho Chehab 
Tested-by: Mauro Carvalho Chehab 
Reviewed-by: Mauro Carvalho Chehab 
Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Acked-by: Thomas Hellström 
Reviewed-by: Andi Shyti 
Signed-off-by: Mauro Carvalho Chehab 
---

See [PATCH v2 0/3] at: 
https://lore.kernel.org/all/cover.1656516220.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/intel_gt.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index 30c60cd960e8..7e57a90b4095 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -952,6 +952,8 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
mutex_lock(>tlb_invalidate_lock);
intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
 
+   spin_lock_irq(>lock); /* seralise invalidate with GT reset */
+
awake = 0;
for_each_engine(engine, gt, id) {
struct reg_and_bit rb;
@@ -967,6 +969,8 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
awake |= engine->mask;
}
 
+   spin_unlock_irq(>lock);
+
for_each_engine_masked(engine, gt, awake, tmp) {
struct reg_and_bit rb;
 
-- 
2.36.1



[PATCH v2 0/3] Fix TLB invalidate issues with Broadwell

2022-06-29 Thread Mauro Carvalho Chehab
i915 selftest hangcheck is causing the i915 driver timeouts, as reported
by Intel CI bot:

http://gfx-ci.fi.intel.com/cibuglog-ng/issuefilterassoc/24297?query_key=42a999f48fa6ecce068bc8126c069be7c31153b4

When such test runs, the only output is:

[   68.811639] i915: Performing live selftests with 
st_random_seed=0xe138eac7 st_timeout=500
[   68.811792] i915: Running hangcheck
[   68.811859] i915: Running 
intel_hangcheck_live_selftests/igt_hang_sanitycheck
[   68.816910] i915 :00:02.0: [drm] Cannot find any crtc or sizes
[   68.841597] i915: Running 
intel_hangcheck_live_selftests/igt_reset_nop
[   69.346347] igt_reset_nop: 80 resets
[   69.362695] i915: Running 
intel_hangcheck_live_selftests/igt_reset_nop_engine
[   69.863559] igt_reset_nop_engine(rcs0): 709 resets
[   70.364924] igt_reset_nop_engine(bcs0): 903 resets
[   70.866005] igt_reset_nop_engine(vcs0): 659 resets
[   71.367934] igt_reset_nop_engine(vcs1): 549 resets
[   71.869259] igt_reset_nop_engine(vecs0): 553 resets
[   71.882592] i915: Running 
intel_hangcheck_live_selftests/igt_reset_idle_engine
[   72.383554] rcs0: Completed 16605 idle resets
[   72.884599] bcs0: Completed 18641 idle resets
[   73.385592] vcs0: Completed 17517 idle resets
[   73.886658] vcs1: Completed 15474 idle resets
[   74.387600] vecs0: Completed 17983 idle resets
[   74.387667] i915: Running 
intel_hangcheck_live_selftests/igt_reset_active_engine
[   74.889017] rcs0: Completed 747 active resets
[   75.174240] intel_engine_reset(bcs0) failed, err:-110
[   75.174301] bcs0: Completed 525 active resets

After that, the machine just silently hangs.

Bisecting the issue, the patch that introduced the regression is:

7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store")

Reverting it fix the issues, but introduce other problems, as TLB
won't be invalidated anymore. So, instead, let's fix the root cause.

It turns that the TLB flush logic ends conflicting with i915 reset,
which is called during selftest hangcheck. So, the TLB cache should
be serialized, but other TLB fix patches are required for this one
to work.

Tested on an Intel NUC5i7RYB with an i7-5557U Broadwell CPU.

v2:

- Reduced to bare minimum fixes, as this shoud be backported deeply
  into stable.

Chris Wilson (3):
  drm/i915/gt: Ignore TLB invalidations on idle engines
  drm/i915/gt: Serialize GRDOM access between multiple engine resets
  drm/i915/gt: Serialize TLB invalidates with GT resets

 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 10 +++---
 drivers/gpu/drm/i915/gt/intel_gt.c| 30 +-
 drivers/gpu/drm/i915/gt/intel_gt_pm.h |  3 ++
 drivers/gpu/drm/i915/gt/intel_reset.c | 37 +--
 4 files changed, 60 insertions(+), 20 deletions(-)

-- 
2.36.1




[PATCH v2 1/3] drm/i915/gt: Ignore TLB invalidations on idle engines

2022-06-29 Thread Mauro Carvalho Chehab
From: Chris Wilson 

As an extension of the current skip TLB invalidations,
check if the device is powered down prior to any engine activity,
as, on such cases, all the TLBs were already invalidated, so an
explicit TLB invalidation is not needed.

This becomes more significant with GuC, as it can only do so when
the connection to the GuC is awake.

Cc: sta...@vger.kernel.org
Signed-off-by: Chris Wilson 
Cc: Fei Yang 
Reviewed-by: Andi Shyti 
Acked-by: Thomas Hellström 
Signed-off-by: Mauro Carvalho Chehab 
---

See [PATCH v2 0/3] at: 
https://lore.kernel.org/all/cover.1656516220.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 10 +
 drivers/gpu/drm/i915/gt/intel_gt.c| 26 +--
 drivers/gpu/drm/i915/gt/intel_gt_pm.h |  3 +++
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c 
b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index 97c820eee115..6835279943df 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -6,14 +6,15 @@
 
 #include 
 
+#include "gt/intel_gt.h"
+#include "gt/intel_gt_pm.h"
+
 #include "i915_drv.h"
 #include "i915_gem_object.h"
 #include "i915_scatterlist.h"
 #include "i915_gem_lmem.h"
 #include "i915_gem_mman.h"
 
-#include "gt/intel_gt.h"
-
 void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
 struct sg_table *pages,
 unsigned int sg_page_sizes)
@@ -217,10 +218,11 @@ __i915_gem_object_unset_pages(struct drm_i915_gem_object 
*obj)
 
if (test_and_clear_bit(I915_BO_WAS_BOUND_BIT, >flags)) {
struct drm_i915_private *i915 = to_i915(obj->base.dev);
+   struct intel_gt *gt = to_gt(i915);
intel_wakeref_t wakeref;
 
-   with_intel_runtime_pm_if_active(>runtime_pm, wakeref)
-   intel_gt_invalidate_tlbs(to_gt(i915));
+   with_intel_gt_pm_if_awake(gt, wakeref)
+   intel_gt_invalidate_tlbs(gt);
}
 
return pages;
diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index 8da3314bb6bf..30c60cd960e8 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -12,6 +12,7 @@
 
 #include "i915_drv.h"
 #include "intel_context.h"
+#include "intel_engine_pm.h"
 #include "intel_engine_regs.h"
 #include "intel_ggtt_gmch.h"
 #include "intel_gt.h"
@@ -924,6 +925,7 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
struct drm_i915_private *i915 = gt->i915;
struct intel_uncore *uncore = gt->uncore;
struct intel_engine_cs *engine;
+   intel_engine_mask_t awake, tmp;
enum intel_engine_id id;
const i915_reg_t *regs;
unsigned int num = 0;
@@ -947,12 +949,27 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
 
GEM_TRACE("\n");
 
-   assert_rpm_wakelock_held(>runtime_pm);
-
mutex_lock(>tlb_invalidate_lock);
intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
 
+   awake = 0;
for_each_engine(engine, gt, id) {
+   struct reg_and_bit rb;
+
+   if (!intel_engine_pm_is_awake(engine))
+   continue;
+
+   rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num);
+   if (!i915_mmio_reg_offset(rb.reg))
+   continue;
+
+   intel_uncore_write_fw(uncore, rb.reg, rb.bit);
+   awake |= engine->mask;
+   }
+
+   for_each_engine_masked(engine, gt, awake, tmp) {
+   struct reg_and_bit rb;
+
/*
 * HW architecture suggest typical invalidation time at 40us,
 * with pessimistic cases up to 100us and a recommendation to
@@ -960,13 +977,8 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
 */
const unsigned int timeout_us = 100;
const unsigned int timeout_ms = 4;
-   struct reg_and_bit rb;
 
rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num);
-   if (!i915_mmio_reg_offset(rb.reg))
-   continue;
-
-   intel_uncore_write_fw(uncore, rb.reg, rb.bit);
if (__intel_wait_for_register_fw(uncore,
 rb.reg, rb.bit, 0,
 timeout_us, timeout_ms,
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h 
b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
index bc898df7a48c..a334787a4939 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
@@ -55,6 +55,9 @@ static inline void intel_gt_pm_might_put(struct intel_gt *gt)
for (tmp = 1, intel_gt_pm_get(gt); tmp; \
 intel_gt_pm_put(gt), tmp = 0)
 
+#define with_intel_gt_pm_if_awake(gt, wf) \
+   for (wf = 

  1   2   3   >