Re: [PATCH v15 00/16] drm: Add Samsung MIPI DSIM bridge

2023-03-06 Thread Jagan Teki
Hi Marek,

On Tue, Mar 7, 2023 at 4:11 AM Marek Szyprowski
 wrote:
>
> Dear Jagan,
>
> On 06.03.2023 18:24, Jagan Teki wrote:
> > On Mon, Mar 6, 2023 at 4:32 PM Marek Szyprowski
> >  wrote:
> >> On 04.03.2023 19:59, Jagan Teki wrote:
> >>> On Sat, Mar 4, 2023 at 3:56 AM Marek Szyprowski
> >>>  wrote:
>  On 03.03.2023 15:51, Jagan Teki wrote:
> > This series supports common bridge support for Samsung MIPI DSIM
> > which is used in Exynos and i.MX8MM SoC's.
> >
> > The final bridge supports both the Exynos and i.MX8M Mini/Nano/Plus.
> >
> > Inki Dae: please note that this series added on top of exynos-drm-next
> > since few exynos dsi changes are not been part of drm-misc-next.
> > Request you to pick these via exynos-drm-next, or let me know if you
> > have any comments?
>  I gave it a try on Exynos TM2e and unfortunately it nukes again:
> 
>  exynos-drm exynos-drm: bound 1397.hdmi (ops hdmi_component_ops)
>  Unable to handle kernel paging request at virtual address 
>  003d454d414e5675
>  ...
>  [003d454d414e5675] address between user and kernel address ranges
>  Internal error: Oops: 9604 [#1] PREEMPT SMP
>  Modules linked in:
>  CPU: 4 PID: 9 Comm: kworker/u16:0 Not tainted 6.2.0-next-20230303+ #13341
>  Hardware name: Samsung TM2E board (DT)
>  Workqueue: events_unbound deferred_probe_work_func
>  pstate: 00c5 (nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
>  pc : drm_connector_list_iter_next+0x58/0x100
>  lr : drm_connector_list_iter_next+0x2c/0x100
>  sp : 8bbab910
>  ...
>  Call trace:
>  drm_connector_list_iter_next+0x58/0x100
>  drm_mode_config_reset+0xfc/0x144
>  exynos_drm_bind+0x160/0x1b8
>  try_to_bring_up_aggregate_device+0x168/0x1d4
>  __component_add+0xa8/0x170
>  component_add+0x14/0x20
>  hdmi_probe+0x3fc/0x6d4
>  platform_probe+0x68/0xd8
>  really_probe+0x148/0x2b4
>  __driver_probe_device+0x78/0xe0
>  driver_probe_device+0xd8/0x160
>  __device_attach_driver+0xb8/0x138
>  bus_for_each_drv+0x84/0xe0
>  __device_attach+0xa8/0x1b0
>  device_initial_probe+0x14/0x20
>  bus_probe_device+0xb0/0xb4
>  deferred_probe_work_func+0x8c/0xc8
>  process_one_work+0x288/0x6c8
>  worker_thread+0x24c/0x450
>  kthread+0x118/0x11c
>  ret_from_fork+0x10/0x20
> >>> This looks not related to dsi to me since there is no exynos_drm_dsi
> >>> call in the trace. look hdmi related. Moreover, I think the exynos dsi
> >>> worked well on v10 and I couldn't find any potential differences in
> >>> terms of call flow change.
> >>> https://gitlab.com/openedev/kernel/-/commits/imx8mm-dsi-v10
> >> Well, the issue is definitely related to this patchset. On Friday, due
> >> to other kernel messages, I missed the most important part of the log:
> >>
> >> [drm] Exynos DRM: using 1380.decon device for DMA mapping operations
> >> exynos-drm exynos-drm: bound 1380.decon (ops decon_component_ops)
> >> exynos-drm exynos-drm: bound 1388.decon (ops decon_component_ops)
> >> exynos-dsi 1390.dsi: [drm:samsung_dsim_host_attach] Attached s6e3hf2
> >> device
> >> exynos-dsi 1390.dsi: request interrupt failed with -22
> >> panel-samsung-s6e3ha2: probe of 1390.dsi.0 failed with error -22
> >> exynos-drm exynos-drm: bound 1390.dsi (ops exynos_dsi_component_ops)
> >> exynos-drm exynos-drm: bound 1393.mic (ops exynos_mic_component_ops)
> >>
> >> It looks that the are at least 2 issues. The first one related to TE
> >> interrupt registration, the second is broken error path, which should
> >> free allocated resources and stop DRM from binding/initialization.
> >>
> >> This patch fixes the issue (TE gpio/interrupt is optional!):
> >>
> >> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c
> >> b/drivers/gpu/drm/bridge/samsung-dsim.c
> >> index b4a5348b763c..ed83495fe105 100644
> >> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> >> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> >> @@ -1518,7 +1518,9 @@ static int samsung_dsim_register_te_irq(struct
> >> samsung_dsim *dsi, struct device
> >>   int ret;
> >>
> >>   dsi->te_gpio = devm_gpiod_get_optional(dev, "te", GPIOD_IN);
> >> -   if (IS_ERR(dsi->te_gpio))
> >> +   if (!dsi->te_gpio)
> >> +   return 0;
> >> +   else if (IS_ERR(dsi->te_gpio))
> > I think I missed this change from v10 where Marek V commented to move
> > this in dsim instead of in Exynos. anyway, I will correct this.
> >
> >>   return dev_err_probe(dev, PTR_ERR(dsi->te_gpio),
> >> "failed to get te GPIO\n");
> >>
> >>   te_gpio_irq = gpiod_to_irq(dsi->te_gpio);
> >>
> >>
> >> The error path in samsung_dsim_host_attach() after
> >> samsung_dsim_register_te_irq() failure is wrong. It lacks cleaning up
> >> the allocated resources (removing 

Re: [Intel-gfx] [PATCH v3 0/2] Fix error propagation amongst request

2023-03-06 Thread Gwan-gyeong Mun

Hi Andi,

After applying these two patches, deadlock is being detected in the call 
stack below. Please review whether the patch to update the 
intel_context_migrate_copy() part affected the deadlock.



https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_114451v1/bat-dg2-8/igt@i915_module_l...@load.html#dmesg-warnings1037

<4> [33.070967] 
<4> [33.070968] WARNING: possible recursive locking detected
<4> [33.070969] 6.2.0-Patchwork_114451v1-g8589fd9227ca+ #1 Not tainted
<4> [33.070970] 
<4> [33.070971] i915_module_loa/948 is trying to acquire lock:
<4> [33.070972] 8881127f0478 (migrate){+.+.}-{3:3}, at: 
i915_request_create+0x1c6/0x230 [i915]

<4> [33.071215]
but task is already holding lock:
<4> [33.071235] 8881127f0478 (migrate){+.+.}-{3:3}, at: 
intel_context_migrate_copy+0x1b3/0xa80 [i915]

<4> [33.071484]
other info that might help us debug this:
<4> [33.071504]  Possible unsafe locking scenario:
<4> [33.071522]CPU0
<4> [33.071532]
<4> [33.071541]   lock(migrate);
<4> [33.071554]   lock(migrate);
<4> [33.071567]
 *** DEADLOCK ***
<4> [33.071585]  May be due to missing lock nesting notation
<4> [33.071606] 3 locks held by i915_module_loa/948:
<4> [33.071622]  #0: c90001eb7b70 
(reservation_ww_class_acquire){+.+.}-{0:0}, at: 
i915_gem_do_execbuffer+0xae2/0x21c0 [i915]
<4> [33.071893]  #1: 8881127b9c28 
(reservation_ww_class_mutex){+.+.}-{3:3}, at: 
__intel_context_do_pin_ww+0x7a/0xa30 [i915]
<4> [33.072133]  #2: 8881127f0478 (migrate){+.+.}-{3:3}, at: 
intel_context_migrate_copy+0x1b3/0xa80 [i915]

<4> [33.072384]
stack backtrace:
<4> [33.072399] CPU: 7 PID: 948 Comm: i915_module_loa Not tainted 
6.2.0-Patchwork_114451v1-g8589fd9227ca+ #1
<4> [33.072428] Hardware name: Intel Corporation CoffeeLake Client 
Platform/CoffeeLake S UDIMM RVP, BIOS CNLSFWR1.R00.X220.B00.2103302221 
03/30/2021

<4> [33.072465] Call Trace:
<4> [33.072475]  
<4> [33.072486]  dump_stack_lvl+0x5b/0x85
<4> [33.072503]  __lock_acquire.cold+0x158/0x33b
<4> [33.072524]  lock_acquire+0xd6/0x310
<4> [33.072541]  ? i915_request_create+0x1c6/0x230 [i915]
<4> [33.072812]  __mutex_lock+0x95/0xf40
<4> [33.072829]  ? i915_request_create+0x1c6/0x230 [i915]
<4> [33.073093]  ? rcu_read_lock_sched_held+0x55/0x80
<4> [33.073112]  ? __mutex_lock+0x133/0xf40
<4> [33.073128]  ? i915_request_create+0x1c6/0x230 [i915]
<4> [33.073388]  ? intel_context_migrate_copy+0x1b3/0xa80 [i915]
<4> [33.073619]  ? i915_request_create+0x1c6/0x230 [i915]
<4> [33.073876]  i915_request_create+0x1c6/0x230 [i915]
<4> [33.074135]  intel_context_migrate_copy+0x1d0/0xa80 [i915]
<4> [33.074360]  __i915_ttm_move+0x7a8/0x940 [i915]
<4> [33.074538]  ? _raw_spin_unlock_irqrestore+0x41/0x70
<4> [33.074552]  ? dma_resv_iter_next+0x91/0xb0
<4> [33.074564]  ? dma_resv_iter_first+0x42/0xb0
<4> [33.074576]  ? i915_deps_add_resv+0x4c/0xc0 [i915]
<4> [33.074744]  i915_ttm_move+0x2ac/0x430 [i915]
<4> [33.074910]  ttm_bo_handle_move_mem+0xb5/0x140 [ttm]
<4> [33.074930]  ttm_bo_validate+0xe9/0x1a0 [ttm]
<4> [33.074947]  __i915_ttm_get_pages+0x4e/0x190 [i915]
<4> [33.075112]  i915_ttm_get_pages+0xf3/0x160 [i915]
<4> [33.075280]  i915_gem_object_get_pages+0x36/0xb0 [i915]
<4> [33.075446]  __i915_gem_object_get_pages+0x95/0xa0 [i915]
<4> [33.075608]  i915_vma_get_pages+0xfa/0x160 [i915]
<4> [33.075779]  i915_vma_pin_ww+0xdc/0xb50 [i915]
<4> [33.075953]  eb_validate_vmas+0x1c6/0xac0 [i915]
<4> [33.076114]  i915_gem_do_execbuffer+0xb2a/0x21c0 [i915]
<4> [33.076276]  ? __stack_depot_save+0x3f/0x4e0
<4> [33.076292]  ? 0x8100
<4> [33.076301]  ? _raw_spin_unlock_irq+0x41/0x50
<4> [33.076312]  ? lockdep_hardirqs_on+0xc3/0x140
<4> [33.076325]  ? set_track_update+0x25/0x50
<4> [33.076338]  ? __lock_acquire+0x5f2/0x2130
<4> [33.076356]  i915_gem_execbuffer2_ioctl+0x123/0x2e0 [i915]
<4> [33.076519]  ? __pfx_i915_gem_execbuffer2_ioctl+0x10/0x10 [i915]
<4> [33.076679]  drm_ioctl_kernel+0xb4/0x150
<4> [33.076692]  drm_ioctl+0x21d/0x420
<4> [33.076703]  ? __pfx_i915_gem_execbuffer2_ioctl+0x10/0x10 [i915]
<4> [33.076864]  ? __vm_munmap+0xd3/0x170
<4> [33.076877]  __x64_sys_ioctl+0x76/0xb0
<4> [33.076889]  do_syscall_64+0x3c/0x90
<4> [33.076900]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
<4> [33.076913] RIP: 0033:0x7f304aa903ab
<4> [33.076923] Code: 0f 1e fa 48 8b 05 e5 7a 0d 00 64 c7 00 26 00 00 00 
48 c7 c0 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 
05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d b5 7a 0d 00 f7 d8 64 89 01 48
<4> [33.076957] RSP: 002b:7fffb1424cf8 EFLAGS: 0246 ORIG_RAX: 
0010
<4> [33.076975] RAX: ffda RBX: 7fffb1424da0 RCX: 
7f304aa903ab
<4> [33.076990] RDX: 7fffb1424da0 RSI: 40406469 RDI: 
0005
<4> [33.077004] RBP: 40406469 R08: 0005 R09: 
00013000
<4> [33.077019] R10: 0001 R11: 0246 R12: 
0001
<4> [33.077034] 

Re: [Intel-gfx] [PATCH 1/3] drm/i915: Set I915_BO_ALLOC_USER for framebuffer

2023-03-06 Thread Das, Nirmoy



On 3/6/2023 6:30 PM, Ville Syrjälä wrote:

On Mon, Mar 06, 2023 at 05:22:19PM +0100, Das, Nirmoy wrote:

On 3/6/2023 3:21 PM, Ville Syrjälä wrote:

On Mon, Mar 06, 2023 at 11:28:48AM +0100, Nirmoy Das wrote:

Framebuffer is exposed to userspace so set I915_BO_ALLOC_USER
flag for it. This also make sure that ttm allocates offset
for lmem objects.

I have no idea what that means.

Sorry for poor explanation.

Without I915_BO_ALLOC_USER, ttm will assume the obj as kernel buffer and
will not allocate fake offset which I needed for fb_mmap callback to work.

So that's the fake vm_pgoff thing? Doesn't that exist just so
mmap() through /dev/dri* can be passed a "gem handle"?
With fbdev mmap we already know which BO we want to map so
why would any of that stuff even be needed?



I was mainly concentrating on  using drm mmap API to achieve fb_mmap 
which eventually will call i915_gem_mmap()


and expects a  fake offset for the obj. I see your point: fb_mmap can be 
done without using drm mmap API which should be much simple . I will 
look into this and resend.



Thanks,

Nirmoy


Regards,
Nirmoy


Signed-off-by: Nirmoy Das 
---
   drivers/gpu/drm/i915/display/intel_dpt.c   | 4 +++-
   drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++-
   drivers/gpu/drm/i915/display/intel_plane_initial.c | 3 ++-
   3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c 
b/drivers/gpu/drm/i915/display/intel_dpt.c
index ad1a37b515fb..2e6238881860 100644
--- a/drivers/gpu/drm/i915/display/intel_dpt.c
+++ b/drivers/gpu/drm/i915/display/intel_dpt.c
@@ -254,7 +254,9 @@ intel_dpt_create(struct intel_framebuffer *fb)
   
   	size = round_up(size * sizeof(gen8_pte_t), I915_GTT_PAGE_SIZE);
   
-	dpt_obj = i915_gem_object_create_lmem(i915, size, I915_BO_ALLOC_CONTIGUOUS);

+   dpt_obj = i915_gem_object_create_lmem(i915, size,
+ I915_BO_ALLOC_CONTIGUOUS |
+ I915_BO_ALLOC_USER);
if (IS_ERR(dpt_obj) && i915_ggtt_has_aperture(to_gt(i915)->ggtt))
dpt_obj = i915_gem_object_create_stolen(i915, size);
if (IS_ERR(dpt_obj) && !HAS_LMEM(i915)) {
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index 3659350061a7..98ae3a3a986a 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -163,7 +163,8 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
obj = ERR_PTR(-ENODEV);
if (HAS_LMEM(dev_priv)) {
obj = i915_gem_object_create_lmem(dev_priv, size,
- I915_BO_ALLOC_CONTIGUOUS);
+ I915_BO_ALLOC_CONTIGUOUS |
+ I915_BO_ALLOC_USER);
} else {
/*
 * If the FB is too big, just don't use it since fbdev is not 
very
diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c 
b/drivers/gpu/drm/i915/display/intel_plane_initial.c
index bb6ea7de5c61..4a3680f6a3f5 100644
--- a/drivers/gpu/drm/i915/display/intel_plane_initial.c
+++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c
@@ -110,7 +110,8 @@ initial_plane_vma(struct drm_i915_private *i915,
size * 2 > i915->dsm.usable_size)
return NULL;
   
-	obj = i915_gem_object_create_region_at(mem, phys_base, size, 0);

+   obj = i915_gem_object_create_region_at(mem, phys_base, size,
+  I915_BO_ALLOC_USER);
if (IS_ERR(obj))
return NULL;
   
--

2.39.0


[Bug 217110] GPU Lockup on Radeon Pitcairn - VAAPI related

2023-03-06 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=217110

Artem S. Tashkinov (a...@gmx.com) changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |ANSWERED

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

[Bug 217141] [amdgpu] ring gfx_0.0.0 timeout steam deck AMD APU

2023-03-06 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=217141

Artem S. Tashkinov (a...@gmx.com) changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |ANSWERED

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

Re: [PATCH v6 32/57] nouveau: adapt NV_DEBUG, NV_ATOMIC to use DRM.debug

2023-03-06 Thread jim . cromie
On Mon, Mar 6, 2023 at 11:50 AM Timur Tabi  wrote:
>
> On Sun, Sep 4, 2022 at 4:48 PM Jim Cromie  wrote:
> >
> > These 2 macros used drm_debug_enabled() on DRM_UT_{DRIVER,ATOMIC}
> > respectively, replace those with drm_dbg_##cat invocations.
> >
> > this results in new class'd prdbg callsites:
> >
> > :#> grep nouveau /proc/dynamic_debug/control | grep class | wc
> > 1161130   15584
> > :#> grep nouveau /proc/dynamic_debug/control | grep class | grep DRIVER | wc
> >  74 7049709
> > :#> grep nouveau /proc/dynamic_debug/control | grep class | grep ATOMIC | wc
> >  31 3074237
> > :#> grep nouveau /proc/dynamic_debug/control | grep class | grep KMS | wc
> >  11 1191638
> >
> > the KMS entries are due to existing uses of drm_dbg_kms().
> >
> > Signed-off-by: Jim Cromie 
>
> Has this patch set been forgotten?  It was posted six months ago and
> there's no sign that it was picked up.

Not forgotten, but chicken-egg problems with initializing prdbgs/drm-dbgs
in drm.ko & dependent drivers pushed it down in priority.
I have a fix for them, which needs Jasons "lets use notifier-chain" patches,
which is now in Luis' modules-next.

After that fix lands, I can revisit this one.

> The changes to drm_debug_enabled have impacted NV_DEBUG and NV_ATOMIC
> and something needs to be fixed.  I posted a simpler patch a few weeks
> ago, but maybe Jim's is better.

I couldnt find it on lore, can you post a link ?

But I do recall something about chatty logs, caused by

#define drm_debug_enabled_instrumented(category)\
({  \
pr_debug("todo: is this frequent enough to optimize ?\n"); \
drm_debug_enabled_raw(category);\
})

If thats the case, it does seem to be frequent enough to silence.

Before you do so, could you turn on the "mfl" flags,
and count occurrences of each callsite ?

echo module nouveau +mfl > /proc/dynamic_debug/control

the numbers and duration of enablement would inform any optimization,
including those available in the subject patchset.

thanks,
Jim


[PATCH] accel: Link to compute accelerator subsystem intro

2023-03-06 Thread Bagas Sanjaya
Commit 2c204f3d53218d ("accel: add dedicated minor for accelerator
devices") adds link to accelerator nodes section of DRM internals doc
(Documentation/gpu/drm-internals.rst), but the target doesn't exist.
Instead, there is only an introduction doc for computer accelerator
subsytem.

Link to that doc until there is documentation of accelerator internals.

Fixes: 2c204f3d53218d ("accel: add dedicated minor for accelerator devices")
Signed-off-by: Bagas Sanjaya 
---

 This comes from discussion on Dylan Le's attempted fix, where Jeffrey
 Hugo suspected that the proper target should be accelerator subsystem
 doc [2].

 [1]: 
https://lore.kernel.org/linux-doc/7799513f0fb5aee27b64752c037980471be669c5.1677120686.git.s...@dylanle.dev/
 [2]: 
https://lore.kernel.org/linux-doc/CAOCk7NrAKZ2G-VbQW3MJUZmkKkO1Ccrs2wo12kg6QHysH-d=y...@mail.gmail.com/

 include/drm/drm_file.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 0d1f853092ab8a..ecffe24e2b1b0a 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -408,7 +408,8 @@ static inline bool drm_is_render_client(const struct 
drm_file *file_priv)
  * Returns true if this is an open file of the compute acceleration node, i.e.
  * _file.minor of @file_priv is a accel minor.
  *
- * See also the :ref:`section on accel nodes `.
+ * See also :doc:`Introduction to compute accelerators subsystem
+ * `.
  */
 static inline bool drm_is_accel_client(const struct drm_file *file_priv)
 {

base-commit: 5c8cf1664f288098a971a1d1e65716a2b6a279e1
-- 
An old man doll... just what I always wanted! - Clara



Re: [PATCH v3] dma-buf: cma_heap: Check for device max segment size when attaching

2023-03-06 Thread John Stultz
On Mon, Mar 6, 2023 at 8:52 AM Andrew Davis  wrote:
>
> Although there is usually not such a limitation (and when there is it is
> often only because the driver forgot to change the super small default),
> it is still correct here to break scatterlist element into chunks of
> dma_max_mapping_size().

Hey Andrew!
  Thanks for sending this out!

So *why* is it "correct here to break scatterlist element into chunks
of  dma_max_mapping_size()." ?

> This might cause some issues for users with misbehaving drivers. If
> bisecting has landed you on this commit, make sure your drivers both set
> dma_set_max_seg_size() and are checking for contiguousness correctly.

Why is this change worth the risk? (If this is really likely to break
folks, should we maybe provide warnings initially instead? Maybe
falling back to the old code if we can catch the failure?)

I don't really object to the change, just want to make sure the commit
message is more clear on why we should make this change, what the
benefit will be along with the potential downsides.

thanks
-john


[PATCH v2 2/2] media: Adjust column width for pdfdocs

2023-03-06 Thread Akira Yokosawa
The column width specifiers added in commit 8d0e3fc61abd ("media:
Add 2-10-10-10 RGB formats") don't suffice for column 1 and too
wide for column 2.

Adjust them to get a good looking table.

Fixes: 8d0e3fc61abd ("media: Add 2-10-10-10 RGB formats")
Cc: Tomi Valkeinen 
Signed-off-by: Akira Yokosawa 
---
new to v2

 Documentation/userspace-api/media/v4l/pixfmt-rgb.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst 
b/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst
index ea545ed1aeaa..d9d7b7621d8c 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst
@@ -778,7 +778,7 @@ number of bits for each component.
 \tiny
 \setlength{\tabcolsep}{2pt}
 
-.. tabularcolumns:: 
|p{2.8cm}|p{2.0cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|
+.. tabularcolumns:: 
|p{3.2cm}|p{0.8cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|
 
 
 .. flat-table:: RGB Formats 10 Bits Per Color Component
-- 
2.25.1




[PATCH v2 1/2] media: Fix building pdfdocs

2023-03-06 Thread Akira Yokosawa
From: Tomi Valkeinen 

Commit 8d0e3fc61abd ("media: Add 2-10-10-10 RGB formats") added
documentation for a few new RGB formats. The table has column-width
specifiers for 34 columns used in pdfdocs build.

However, the new table has a couple of rows with 35 columns which
confused Sphinx's latex builder. The resulting .tex file causes
an error in a later stage of a pdfdocs build.

Remove the trailing empty dash lines to fix the issue.

Fixes: 8d0e3fc61abd ("media: Add 2-10-10-10 RGB formats")
Reported-by: Akira Yokosawa 
Link: https://lore.kernel.org/r/12250823-8445-5854-dfb8-b92c0ff08...@gmail.com/
Signed-off-by: Tomi Valkeinen 
Tested-by: Akira Yokosawa 
Reviewed-by: Laurent Pinchart 
Acked-by: Mauro Carvalho Chehab 
  [akiyks: explain the cause of build error]
Signed-off-by: Akira Yokosawa 
---
Hi all,

Now that this fix missed v6.3-rc1, I went forward and amended the
Changelog to explain what was wrong in the offending commit.
I see that docs-next is ready for fixes to v6.3-rc1, but when the -media
tree gets ready, this can be picked by Mauro.
Either route is fine by me.
I'd really like to have this issue fixed sooner rather than later.

As a follow-up, patch 2/2 adjusts the column width specifiers.

Thanks, Akira
--
v2: Changelog: explain the root cause,
rebased on v6.3-rc1,
picked tags from v1 thread.
v1: 
https://lore.kernel.org/r/20230208082916.68377-1-tomi.valkei...@ideasonboard.com/

Documentation/userspace-api/media/v4l/pixfmt-rgb.rst | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst 
b/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst
index d330aeb4d3eb..ea545ed1aeaa 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst
@@ -868,7 +868,6 @@ number of bits for each component.
   - r\ :sub:`4`
   - r\ :sub:`3`
   - r\ :sub:`2`
-  -
 * .. _V4L2-PIX-FMT-RGBA1010102:
 
   - ``V4L2_PIX_FMT_RGBA1010102``
@@ -909,7 +908,6 @@ number of bits for each component.
   - r\ :sub:`4`
   - r\ :sub:`3`
   - r\ :sub:`2`
-  -
 * .. _V4L2-PIX-FMT-ARGB2101010:
 
   - ``V4L2_PIX_FMT_ARGB2101010``
@@ -950,7 +948,6 @@ number of bits for each component.
   - r\ :sub:`6`
   - r\ :sub:`5`
   - r\ :sub:`4`
-  -
 
 .. raw:: latex
 

base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
-- 
2.25.1



Re: [PATCH 97/99] fbdev/vt8623fb: Duplicate video-mode option string

2023-03-06 Thread kernel test robot
Hi Thomas,

I love your patch! Yet something to improve:

[auto build test ERROR on drm-misc/drm-misc-next]
[cannot apply to deller-parisc/for-next staging/staging-testing 
staging/staging-next staging/staging-linus linus/master v6.3-rc1 next-20230306]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:
https://lore.kernel.org/r/20230306160016.4459-98-tzimmermann%40suse.de
patch subject: [PATCH 97/99] fbdev/vt8623fb: Duplicate video-mode option string
config: x86_64-randconfig-a016-20230306 
(https://download.01.org/0day-ci/archive/20230307/202303070859.8y5urjpt-...@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project 
f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/819a7fd9e1404efc4f2140bcb4c7e39643b7e4ab
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
git checkout 819a7fd9e1404efc4f2140bcb4c7e39643b7e4ab
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 
O=build_dir ARCH=x86_64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 
O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202303070859.8y5urjpt-...@intel.com/

All errors (new ones prefixed by >>):

>> drivers/video/fbdev/vt8623fb.c:938:4: error: 'break' statement not in loop 
>> or switch statement
   break;
   ^
   drivers/video/fbdev/vt8623fb.c:940:4: error: 'break' statement not in loop 
or switch statement
   break;
   ^
   2 errors generated.


vim +/break +938 drivers/video/fbdev/vt8623fb.c

   924  
   925  if (fb_modesetting_disabled("vt8623fb"))
   926  return -ENODEV;
   927  
   928  #ifndef MODULE
   929  if (fb_get_options("vt8623fb", ))
   930  return -ENODEV;
   931  
   932  if (option && *option) {
   933  static char mode_option_buf[256];
   934  int ret;
   935  
   936  ret = snprintf(mode_option_buf, 
sizeof(mode_option_buf), "%s", option);
   937  if (WARN(ret < 0, "vt8623fb: ignoring invalid option, 
ret=%d\n", ret))
 > 938  break;
   939  if (WARN(ret >= sizeof(mode_option_buf), "vt8623fb: 
option too long\n"))
   940  break;
   941  mode_option = mode_option_buf;
   942  }
   943  #endif
   944  
   945  pr_debug("vt8623fb: initializing\n");
   946  return pci_register_driver(_pci_driver);
   947  }
   948  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Re: [PATCH RESEND] drm/nouveau/hwmon: Use sysfs_emit in show function callsbacks

2023-03-06 Thread Lyude Paul
Reviewed-by: Lyude Paul 

Will push upstream in a moment

On Thu, 2023-03-02 at 01:05 +0530, Deepak R Varma wrote:
> According to Documentation/filesystems/sysfs.rst, the show() callback
> function of kobject attributes should strictly use sysfs_emit() instead
> of sprintf() family functions. So, make this change.
> Issue identified using the coccinelle device_attr_show.cocci script.
> 
> Signed-off-by: Deepak R Varma 
> ---
> Note:
>Resending the patch for review and feedback. No functional changes.
> 
> 
>  drivers/gpu/drm/nouveau/nouveau_hwmon.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c 
> b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
> index a7db7c31064b..e844be49e11e 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
> @@ -41,7 +41,7 @@ static ssize_t
>  nouveau_hwmon_show_temp1_auto_point1_pwm(struct device *d,
>struct device_attribute *a, char *buf)
>  {
> - return snprintf(buf, PAGE_SIZE, "%d\n", 100);
> + return sysfs_emit(buf, "%d\n", 100);
>  }
>  static SENSOR_DEVICE_ATTR(temp1_auto_point1_pwm, 0444,
> nouveau_hwmon_show_temp1_auto_point1_pwm, NULL, 0);
> @@ -54,8 +54,8 @@ nouveau_hwmon_temp1_auto_point1_temp(struct device *d,
>   struct nouveau_drm *drm = nouveau_drm(dev);
>   struct nvkm_therm *therm = nvxx_therm(>client.device);
>  
> - return snprintf(buf, PAGE_SIZE, "%d\n",
> -   therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000);
> + return sysfs_emit(buf, "%d\n",
> +   therm->attr_get(therm, 
> NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000);
>  }
>  static ssize_t
>  nouveau_hwmon_set_temp1_auto_point1_temp(struct device *d,
> @@ -87,8 +87,8 @@ nouveau_hwmon_temp1_auto_point1_temp_hyst(struct device *d,
>   struct nouveau_drm *drm = nouveau_drm(dev);
>   struct nvkm_therm *therm = nvxx_therm(>client.device);
>  
> - return snprintf(buf, PAGE_SIZE, "%d\n",
> -  therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000);
> + return sysfs_emit(buf, "%d\n",
> +   therm->attr_get(therm, 
> NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000);
>  }
>  static ssize_t
>  nouveau_hwmon_set_temp1_auto_point1_temp_hyst(struct device *d,

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat



Re: [Intel-gfx] [PATCH 3/3] drm/i915/dg1: Move Wa_1806527549 to the right function

2023-03-06 Thread Lucas De Marchi

On Mon, Mar 06, 2023 at 03:17:50PM -0800, Matt Roper wrote:

On Mon, Mar 06, 2023 at 12:49:54PM -0800, Lucas De Marchi wrote:

dg1_ctx_workarounds_init() is DG1-only, while
gen12_ctx_workarounds_init() is shared with other platforms. Move the
workaround to the former so there is no additional platform check
needed.

Signed-off-by: Lucas De Marchi 
---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c 
b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index 389bfcd299af..f68fe64f63a6 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -707,8 +707,6 @@ static void gen12_ctx_gt_tuning_init(struct intel_engine_cs 
*engine,
 static void gen12_ctx_workarounds_init(struct intel_engine_cs *engine,
   struct i915_wa_list *wal)
 {
-   struct drm_i915_private *i915 = engine->i915;
-
gen12_ctx_gt_tuning_init(engine, wal);

/*
@@ -742,10 +740,6 @@ static void gen12_ctx_workarounds_init(struct 
intel_engine_cs *engine,
   FF_MODE2_GS_TIMER_MASK,
   FF_MODE2_GS_TIMER_224,
   0, false);
-
-   if (!IS_DG1(i915))


I think you missed the "!" here.  I.e., this workaround applies to all
the "gen12" platforms *except* DG1.


oops, thanks for catching that.  I'll drop this last patch.

Lucas De Marchi




Matt


-   /* Wa_1806527549 */
-   wa_masked_en(wal, HIZ_CHICKEN, HZ_DEPTH_TEST_LE_GE_OPT_DISABLE);
 }

 static void dg1_ctx_workarounds_init(struct intel_engine_cs *engine,
@@ -760,6 +754,9 @@ static void dg1_ctx_workarounds_init(struct intel_engine_cs 
*engine,
/* Wa_22010493298 */
wa_masked_en(wal, HIZ_CHICKEN,
 DG1_HZ_READ_SUPPRESSION_OPTIMIZATION_DISABLE);
+
+   /* Wa_1806527549 */
+   wa_masked_en(wal, HIZ_CHICKEN, HZ_DEPTH_TEST_LE_GE_OPT_DISABLE);
 }

 static void dg2_ctx_workarounds_init(struct intel_engine_cs *engine,
--
2.39.0



--
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


Re: [Intel-gfx] [PATCH 3/3] drm/i915/dg1: Move Wa_1806527549 to the right function

2023-03-06 Thread Matt Roper
On Mon, Mar 06, 2023 at 12:49:54PM -0800, Lucas De Marchi wrote:
> dg1_ctx_workarounds_init() is DG1-only, while
> gen12_ctx_workarounds_init() is shared with other platforms. Move the
> workaround to the former so there is no additional platform check
> needed.
> 
> Signed-off-by: Lucas De Marchi 
> ---
>  drivers/gpu/drm/i915/gt/intel_workarounds.c | 9 +++--
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c 
> b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> index 389bfcd299af..f68fe64f63a6 100644
> --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
> +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> @@ -707,8 +707,6 @@ static void gen12_ctx_gt_tuning_init(struct 
> intel_engine_cs *engine,
>  static void gen12_ctx_workarounds_init(struct intel_engine_cs *engine,
>  struct i915_wa_list *wal)
>  {
> - struct drm_i915_private *i915 = engine->i915;
> -
>   gen12_ctx_gt_tuning_init(engine, wal);
>  
>   /*
> @@ -742,10 +740,6 @@ static void gen12_ctx_workarounds_init(struct 
> intel_engine_cs *engine,
>  FF_MODE2_GS_TIMER_MASK,
>  FF_MODE2_GS_TIMER_224,
>  0, false);
> -
> - if (!IS_DG1(i915))

I think you missed the "!" here.  I.e., this workaround applies to all
the "gen12" platforms *except* DG1.


Matt

> - /* Wa_1806527549 */
> - wa_masked_en(wal, HIZ_CHICKEN, HZ_DEPTH_TEST_LE_GE_OPT_DISABLE);
>  }
>  
>  static void dg1_ctx_workarounds_init(struct intel_engine_cs *engine,
> @@ -760,6 +754,9 @@ static void dg1_ctx_workarounds_init(struct 
> intel_engine_cs *engine,
>   /* Wa_22010493298 */
>   wa_masked_en(wal, HIZ_CHICKEN,
>DG1_HZ_READ_SUPPRESSION_OPTIMIZATION_DISABLE);
> +
> + /* Wa_1806527549 */
> + wa_masked_en(wal, HIZ_CHICKEN, HZ_DEPTH_TEST_LE_GE_OPT_DISABLE);
>  }
>  
>  static void dg2_ctx_workarounds_init(struct intel_engine_cs *engine,
> -- 
> 2.39.0
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


Re: [Intel-gfx] [PATCH 2/3] drm/i915: Move DG2 tuning to the right function

2023-03-06 Thread Matt Roper
On Mon, Mar 06, 2023 at 12:49:53PM -0800, Lucas De Marchi wrote:
> Use gt_tuning_settings() for the recommended tunings rather than the one
> for workarounds.
> 
> Signed-off-by: Lucas De Marchi 

Reviewed-by: Matt Roper 

> ---
>  drivers/gpu/drm/i915/gt/intel_workarounds.c | 11 +++
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c 
> b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> index eb6cc4867d67..389bfcd299af 100644
> --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
> +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> @@ -1653,13 +1653,6 @@ dg2_gt_workarounds_init(struct intel_gt *gt, struct 
> i915_wa_list *wal)
>   /* Wa_14014830051:dg2 */
>   wa_mcr_write_clr(wal, SARB_CHICKEN1, COMP_CKN_IN);
>  
> - /*
> -  * The following are not actually "workarounds" but rather
> -  * recommended tuning settings documented in the bspec's
> -  * performance guide section.
> -  */
> - wa_mcr_write_or(wal, XEHP_SQCM, EN_32B_ACCESS);
> -
>   /* Wa_14015795083 */
>   wa_write_clr(wal, GEN7_MISCCPCTL, GEN12_DOP_CLOCK_GATE_RENDER_ENABLE);
>  
> @@ -1752,8 +1745,10 @@ static void gt_tuning_settings(struct intel_gt *gt, 
> struct i915_wa_list *wal)
>   wa_mcr_masked_en(wal, XEHPC_LNCFMISCCFGREG0, XEHPC_HOSTCACHEEN);
>   }
>  
> - if (IS_DG2(gt->i915))
> + if (IS_DG2(gt->i915)) {
>   wa_mcr_write_or(wal, XEHP_L3SCQREG7, 
> BLEND_FILL_CACHING_OPT_DIS);
> + wa_mcr_write_or(wal, XEHP_SQCM, EN_32B_ACCESS);
> + }
>  }
>  
>  static void
> -- 
> 2.39.0
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


Re: [Intel-gfx] [PATCH 1/3] drm/i915: Remove redundant check for DG1

2023-03-06 Thread Matt Roper
On Mon, Mar 06, 2023 at 12:49:52PM -0800, Lucas De Marchi wrote:
> dg1_gt_workarounds_init() is only ever called for DG1, so there is no
> point checking it again.
> 
> Signed-off-by: Lucas De Marchi 

Reviewed-by: Matt Roper 

> ---
>  drivers/gpu/drm/i915/gt/intel_workarounds.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c 
> b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> index 32aa1647721a..eb6cc4867d67 100644
> --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
> +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> @@ -1472,21 +1472,15 @@ gen12_gt_workarounds_init(struct intel_gt *gt, struct 
> i915_wa_list *wal)
>  static void
>  dg1_gt_workarounds_init(struct intel_gt *gt, struct i915_wa_list *wal)
>  {
> - struct drm_i915_private *i915 = gt->i915;
> -
>   gen12_gt_workarounds_init(gt, wal);
>  
>   /* Wa_1409420604:dg1 */
> - if (IS_DG1(i915))
> - wa_mcr_write_or(wal,
> - SUBSLICE_UNIT_LEVEL_CLKGATE2,
> - CPSSUNIT_CLKGATE_DIS);
> + wa_mcr_write_or(wal, SUBSLICE_UNIT_LEVEL_CLKGATE2,
> + CPSSUNIT_CLKGATE_DIS);
>  
>   /* Wa_1408615072:dg1 */
>   /* Empirical testing shows this register is unaffected by engine reset. 
> */
> - if (IS_DG1(i915))
> - wa_write_or(wal, UNSLICE_UNIT_LEVEL_CLKGATE2,
> - VSUNIT_CLKGATE_DIS_TGL);
> + wa_write_or(wal, UNSLICE_UNIT_LEVEL_CLKGATE2, VSUNIT_CLKGATE_DIS_TGL);
>  }
>  
>  static void
> -- 
> 2.39.0
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


linux-next: manual merge of the drm-intel tree with Linus' tree

2023-03-06 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the drm-intel tree got a conflict in:

  drivers/gpu/drm/i915/i915_driver.c

between commit:

  2293a73ad4f3 ("drm/i915: Remove unused variable")

from Linus' tree and commit:

  e5e43d3363d7 ("drm/i915/display: Pass drm_i915_private as param to i915 
funcs")

from the drm-intel tree.

I fixed it up (the latter commit means that the variable removed in
the former is still needed - see below ) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/i915/i915_driver.c
index cf1c0970ecb4,4a2dc43791c3..
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@@ -936,9 -930,12 +930,11 @@@ static int i915_driver_open(struct drm_
   */
  static void i915_driver_lastclose(struct drm_device *dev)
  {
-   intel_fbdev_restore_mode(dev);
+   struct drm_i915_private *i915 = to_i915(dev);
+ 
+   intel_fbdev_restore_mode(i915);
  
 -  if (HAS_DISPLAY(i915))
 -  vga_switcheroo_process_delayed_switch();
 +  vga_switcheroo_process_delayed_switch();
  }
  
  static void i915_driver_postclose(struct drm_device *dev, struct drm_file 
*file)


pgpO3PQmnVdip.pgp
Description: OpenPGP digital signature


Re: [PATCH v15 00/16] drm: Add Samsung MIPI DSIM bridge

2023-03-06 Thread Marek Szyprowski
Dear Jagan,

On 06.03.2023 18:24, Jagan Teki wrote:
> On Mon, Mar 6, 2023 at 4:32 PM Marek Szyprowski
>  wrote:
>> On 04.03.2023 19:59, Jagan Teki wrote:
>>> On Sat, Mar 4, 2023 at 3:56 AM Marek Szyprowski
>>>  wrote:
 On 03.03.2023 15:51, Jagan Teki wrote:
> This series supports common bridge support for Samsung MIPI DSIM
> which is used in Exynos and i.MX8MM SoC's.
>
> The final bridge supports both the Exynos and i.MX8M Mini/Nano/Plus.
>
> Inki Dae: please note that this series added on top of exynos-drm-next
> since few exynos dsi changes are not been part of drm-misc-next.
> Request you to pick these via exynos-drm-next, or let me know if you
> have any comments?
 I gave it a try on Exynos TM2e and unfortunately it nukes again:

 exynos-drm exynos-drm: bound 1397.hdmi (ops hdmi_component_ops)
 Unable to handle kernel paging request at virtual address 003d454d414e5675
 ...
 [003d454d414e5675] address between user and kernel address ranges
 Internal error: Oops: 9604 [#1] PREEMPT SMP
 Modules linked in:
 CPU: 4 PID: 9 Comm: kworker/u16:0 Not tainted 6.2.0-next-20230303+ #13341
 Hardware name: Samsung TM2E board (DT)
 Workqueue: events_unbound deferred_probe_work_func
 pstate: 00c5 (nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : drm_connector_list_iter_next+0x58/0x100
 lr : drm_connector_list_iter_next+0x2c/0x100
 sp : 8bbab910
 ...
 Call trace:
 drm_connector_list_iter_next+0x58/0x100
 drm_mode_config_reset+0xfc/0x144
 exynos_drm_bind+0x160/0x1b8
 try_to_bring_up_aggregate_device+0x168/0x1d4
 __component_add+0xa8/0x170
 component_add+0x14/0x20
 hdmi_probe+0x3fc/0x6d4
 platform_probe+0x68/0xd8
 really_probe+0x148/0x2b4
 __driver_probe_device+0x78/0xe0
 driver_probe_device+0xd8/0x160
 __device_attach_driver+0xb8/0x138
 bus_for_each_drv+0x84/0xe0
 __device_attach+0xa8/0x1b0
 device_initial_probe+0x14/0x20
 bus_probe_device+0xb0/0xb4
 deferred_probe_work_func+0x8c/0xc8
 process_one_work+0x288/0x6c8
 worker_thread+0x24c/0x450
 kthread+0x118/0x11c
 ret_from_fork+0x10/0x20
>>> This looks not related to dsi to me since there is no exynos_drm_dsi
>>> call in the trace. look hdmi related. Moreover, I think the exynos dsi
>>> worked well on v10 and I couldn't find any potential differences in
>>> terms of call flow change.
>>> https://gitlab.com/openedev/kernel/-/commits/imx8mm-dsi-v10
>> Well, the issue is definitely related to this patchset. On Friday, due
>> to other kernel messages, I missed the most important part of the log:
>>
>> [drm] Exynos DRM: using 1380.decon device for DMA mapping operations
>> exynos-drm exynos-drm: bound 1380.decon (ops decon_component_ops)
>> exynos-drm exynos-drm: bound 1388.decon (ops decon_component_ops)
>> exynos-dsi 1390.dsi: [drm:samsung_dsim_host_attach] Attached s6e3hf2
>> device
>> exynos-dsi 1390.dsi: request interrupt failed with -22
>> panel-samsung-s6e3ha2: probe of 1390.dsi.0 failed with error -22
>> exynos-drm exynos-drm: bound 1390.dsi (ops exynos_dsi_component_ops)
>> exynos-drm exynos-drm: bound 1393.mic (ops exynos_mic_component_ops)
>>
>> It looks that the are at least 2 issues. The first one related to TE
>> interrupt registration, the second is broken error path, which should
>> free allocated resources and stop DRM from binding/initialization.
>>
>> This patch fixes the issue (TE gpio/interrupt is optional!):
>>
>> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c
>> b/drivers/gpu/drm/bridge/samsung-dsim.c
>> index b4a5348b763c..ed83495fe105 100644
>> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
>> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
>> @@ -1518,7 +1518,9 @@ static int samsung_dsim_register_te_irq(struct
>> samsung_dsim *dsi, struct device
>>   int ret;
>>
>>   dsi->te_gpio = devm_gpiod_get_optional(dev, "te", GPIOD_IN);
>> -   if (IS_ERR(dsi->te_gpio))
>> +   if (!dsi->te_gpio)
>> +   return 0;
>> +   else if (IS_ERR(dsi->te_gpio))
> I think I missed this change from v10 where Marek V commented to move
> this in dsim instead of in Exynos. anyway, I will correct this.
>
>>   return dev_err_probe(dev, PTR_ERR(dsi->te_gpio),
>> "failed to get te GPIO\n");
>>
>>   te_gpio_irq = gpiod_to_irq(dsi->te_gpio);
>>
>>
>> The error path in samsung_dsim_host_attach() after
>> samsung_dsim_register_te_irq() failure is wrong. It lacks cleaning up
>> the allocated resources (removing the bridge, detaing the dsi device).
> This is because of the same discussion of moving TE GPIO in dsim instead 
> exynos.

Well, I'm not very happy about adding more and more features/changes to 
this single patch. I think that once we got the first version that was 
working on both 

Re: [PATCH 01/99] lib: Add option iterator

2023-03-06 Thread Randy Dunlap
Hi,

On 3/6/23 07:58, Thomas Zimmermann wrote:
> Add struct option_iter and helpers that walk over individual options
> of an option string. Add documentation.
> 
> Kernel parameters often have the format of
> 
>   param=opt1,opt2:val,opt3
> 
> where the option string contains a number of comma-separated options.
> Drivers usually use strsep() in a loop to extract individual options
> from the string. Each call to strsep() modifies the given string, so
> callers have to duplicate kernel parameters that are to be parsed
> multiple times.
> 
> The new struct option_iter and its helpers wrap this code behind a
> clean interface. Drivers can iterate over the options without having
> to know the details of the option-string format. The iterator handles
> string memory internally without modifying the original options.
> 
> Signed-off-by: Thomas Zimmermann 
> ---
>  Documentation/core-api/kernel-api.rst |  9 +++
>  include/linux/cmdline.h   | 29 
>  lib/Makefile  |  2 +-
>  lib/cmdline_iter.c| 97 +++
>  4 files changed, 136 insertions(+), 1 deletion(-)
>  create mode 100644 include/linux/cmdline.h
>  create mode 100644 lib/cmdline_iter.c
> 
> diff --git a/Documentation/core-api/kernel-api.rst 
> b/Documentation/core-api/kernel-api.rst
> index 62f961610773..cdc7ba8decf9 100644
> --- a/Documentation/core-api/kernel-api.rst
> +++ b/Documentation/core-api/kernel-api.rst
> @@ -93,9 +93,18 @@ Bitmap Operations
>  Command-line Parsing
>  
>  
> +.. kernel-doc:: lib/cmdline_iter.c
> +   :doc: overview
> +
>  .. kernel-doc:: lib/cmdline.c
> :export:
>  
> +.. kernel-doc:: lib/cmdline_iter.c
> +   :export:
> +
> +.. kernel-doc:: include/linux/cmdline.h
> +   :internal:
> +
>  Sorting
>  ---
>  
> diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
> new file mode 100644
> index ..5d7e648e98a5
> --- /dev/null
> +++ b/include/linux/cmdline.h
> @@ -0,0 +1,29 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef LINUX_CMDLINE_H
> +#define LINUX_CMDLINE_H
> +
> +/**
> + * struct option_iter - Iterates over string of kernel or module options
> + */
> +struct option_iter {
> + char *optbuf;
> + char *next_opt;
> +};
> +
> +void option_iter_init(struct option_iter *iter, const char *options);
> +void option_iter_release(struct option_iter *iter);
> +const char *option_iter_incr(struct option_iter *iter);
> +
> +/**
> + * option_iter_next - Loop condition to move over options
> + * @iter_:   the iterator
> + * @opt_:the name of the option variable
> + *
> + * Iterates over option strings as part of a while loop and
> + * stores the current option in opt_.
> + */
> +#define option_iter_next(iter_, opt_) \
> + (((opt_) = option_iter_incr(iter_)) != NULL)
> +
> +#endif

> diff --git a/lib/cmdline_iter.c b/lib/cmdline_iter.c
> new file mode 100644
> index ..d9371dfea08b
> --- /dev/null
> +++ b/lib/cmdline_iter.c
> @@ -0,0 +1,97 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * DOC: overview
> + *
> + * A kernel parameter's option string can contain multiple comma-separated
> + * options. Modules can parse an option string with struct _iter and
> + * its helpers. After obtaining the string, initialize and instance of the

  an instance

> + * option iterator and loop iver its content as show below.

   over

> + *
> + * .. code-block:: c
> + *
> + *   const char *options = ...; // provided option string
> + *
> + *   struct option_iter iter;
> + *   const char *opt;
> + *
> + *   option_iter_init(, options);
> + *
> + *   while (option_iter_next(, )) {
> + *   if (!strcmp(opt, "foo"))
> + *   ...
> + *   else (strcmp(opt, "bar"))
> + *   ...
> + *   else
> + *   pr_warn("unknown option %s\n", opt);
> + *   }
> + *
> + *   option_iter_release();
> + *
> + * The call to option_iter_init() initializes the iterator instance
> + * from the option string. The while loop walks over the individual
> + * options in the sting and returns each in the second argument. The
> + * returned memory is owned by the iterator instance and callers may
> + * not modify or free it. The call to option_iter_release() frees all
> + * resources of the iterator. This process does not modify the original
> + * option string. If the option string contains an empty option (i.e.,
> + * two commas next to each other), option_iter_next() skips the empty
> + * option automatically.

Is that latter skipping over a ",," automatically something that you have
observed as needed?
I can imagine a driver or module wanting to know that an empty string
was entered (i.e., ",,").

> + */
> +
> +/**
> + * option_iter_init - Initializes an option iterator
> + * @iter:the iterator to initialize

Re: [Intel-gfx] [PATCH v2 2/2] drm/i915/guc: Fix missing return code checks in submission init

2023-03-06 Thread Ceraolo Spurio, Daniele




On 2/17/2023 2:33 PM, john.c.harri...@intel.com wrote:

From: John Harrison 

The CI results for the 'fast request' patch set (enables error return
codes for fire-and-forget H2G messages) hit an issue with the KMD
sending context submission requests on an invalid context. That was
caused by a fault injection probe failing the context creation of a
kernel context. However, there was no return code checking on any of
the kernel context registration paths. So the driver kept going and
tried to use the kernel context for the record defaults process.

This would not cause any actual problems. The invalid requests would
be rejected by GuC and ultimately the start up sequence would
correctly wedge due to the context creation failure. But fixing the
issue correctly rather ignoring it means we won't get CI complaining
when the fast request patch lands and enables the extra error checking.

So fix it by checking for errors and aborting as appropriate when
creating kernel contexts. While at it, clean up some other submission
init related failure cleanup paths. Also, rename guc_init_lrc_mapping
to guc_init_submission as the former name hasn't been valid in a long
time.

v2: Add another wrapper to keep the flow balanced (Daniele)

Signed-off-by: John Harrison 


Reviewed-by: Daniele Ceraolo Spurio 

Daniele


---
  .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 97 ++-
  .../gpu/drm/i915/gt/uc/intel_guc_submission.h |  2 +-
  drivers/gpu/drm/i915/gt/uc/intel_uc.c |  7 +-
  3 files changed, 80 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index a04d7049a2c2f..88e881b100cf0 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -1441,7 +1441,7 @@ static int guc_action_enable_usage_stats(struct intel_guc 
*guc)
return intel_guc_send(guc, action, ARRAY_SIZE(action));
  }
  
-static void guc_init_engine_stats(struct intel_guc *guc)

+static int guc_init_engine_stats(struct intel_guc *guc)
  {
struct intel_gt *gt = guc_to_gt(guc);
intel_wakeref_t wakeref;
@@ -1454,6 +1454,13 @@ static void guc_init_engine_stats(struct intel_guc *guc)
guc_err(guc, "Failed to enable usage stats: %pe\n", 
ERR_PTR(ret));
else
guc_enable_busyness_worker(guc);
+
+   return ret;
+}
+
+static void guc_fini_engine_stats(struct intel_guc *guc)
+{
+   guc_cancel_busyness_worker(guc);
  }
  
  void intel_guc_busyness_park(struct intel_gt *gt)

@@ -4109,9 +4116,11 @@ static void guc_set_default_submission(struct 
intel_engine_cs *engine)
engine->submit_request = guc_submit_request;
  }
  
-static inline void guc_kernel_context_pin(struct intel_guc *guc,

- struct intel_context *ce)
+static inline int guc_kernel_context_pin(struct intel_guc *guc,
+struct intel_context *ce)
  {
+   int ret;
+
/*
 * Note: we purposefully do not check the returns below because
 * the registration can only fail if a reset is just starting.
@@ -4119,16 +4128,24 @@ static inline void guc_kernel_context_pin(struct 
intel_guc *guc,
 * isn't happening and even it did this code would be run again.
 */
  
-	if (context_guc_id_invalid(ce))

-   pin_guc_id(guc, ce);
+   if (context_guc_id_invalid(ce)) {
+   ret = pin_guc_id(guc, ce);
+
+   if (ret < 0)
+   return ret;
+   }
  
  	if (!test_bit(CONTEXT_GUC_INIT, >flags))

guc_context_init(ce);
  
-	try_context_registration(ce, true);

+   ret = try_context_registration(ce, true);
+   if (ret)
+   unpin_guc_id(guc, ce);
+
+   return ret;
  }
  
-static inline void guc_init_lrc_mapping(struct intel_guc *guc)

+static inline int guc_init_submission(struct intel_guc *guc)
  {
struct intel_gt *gt = guc_to_gt(guc);
struct intel_engine_cs *engine;
@@ -4155,9 +4172,17 @@ static inline void guc_init_lrc_mapping(struct intel_guc 
*guc)
struct intel_context *ce;
  
  		list_for_each_entry(ce, >pinned_contexts_list,

-   pinned_contexts_link)
-   guc_kernel_context_pin(guc, ce);
+   pinned_contexts_link) {
+   int ret = guc_kernel_context_pin(guc, ce);
+
+   if (ret) {
+   /* No point in trying to clean up as i915 will 
wedge on failure */
+   return ret;
+   }
+   }
}
+
+   return 0;
  }
  
  static void guc_release(struct intel_engine_cs *engine)

@@ -4400,31 +4425,57 @@ static int guc_init_global_schedule_policy(struct 
intel_guc *guc)
return ret;
  }
  
-void 

Re: [PATCH 00/22] drm/dma-helper: Add dedicated fbdev emulation

2023-03-06 Thread Linus Walleij
On Wed, Mar 1, 2023 at 4:31 PM Thomas Zimmermann  wrote:

> Add fbdev emulation that is optimized for DMA helpers, as used by most
> drivers. It operates directly on GEM DMA buffers in system memory.
> Memory pages are mmap'ed directly to userspace. No implicit shadow
> buffers need to be allocated; as can happen with the generic fbdev
> emulation. Convert drivers that fulfil the requirements.
>
> Tested with fbcon and IGT on vc4.
>
> Future direction: providing a dedicated fbdev emulation for GEM DMA
> helpers will allow us to remove this case from the generic fbdev code.
> The latter can then be simplified.

1) I love your work.

2) Why isn't this DRM driver changed?
drivers/gpu/drm/mcde/mcde_drv.c
AFAICT it also uses GEM buffers in system memory.

3) This one:
drivers/gpu/drm/pl111/pl111_drv.c
is also very similar, but can sometimes use a dedicated
RAM memory for allocations using CMA, does that make
it not a candidate?

They aren't much different in how they work from the TVE200.

Yours,
Linus Walleij


Re: [PATCH 20/22] drm/tve200: Use GEM DMA fbdev emulation

2023-03-06 Thread Linus Walleij
On Wed, Mar 1, 2023 at 4:31 PM Thomas Zimmermann  wrote:

> Use the fbdev emulation that is optimized for DMA helpers. Avoids
> possible shadow buffering and makes the code simpler.
>
> Signed-off-by: Thomas Zimmermann 

That sounds neat:
Acked-by: Linus Walleij 

Yours,
Linus Walleij


Re: [Intel-gfx] [PATCH v2 1/2] drm/i915/guc: Improve clean up of busyness stats worker

2023-03-06 Thread Ceraolo Spurio, Daniele




On 2/17/2023 2:33 PM, john.c.harri...@intel.com wrote:

From: John Harrison 

The stats worker thread management was mis-matched between
enable/disable call sites. Fix those up. Also, abstract the
cancel/enable code into a helper function rather than replicating in
multiple places.

v2: Rename the helpers and wrap the enable as well as the cancel
(review feedback from Daniele).

Signed-off-by: John Harrison 


Reviewed-by: Daniele Ceraolo Spurio 

Daniele


---
  .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 38 +++
  1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index be495e657d66b..a04d7049a2c2f 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -1352,6 +1352,16 @@ static ktime_t guc_engine_busyness(struct 
intel_engine_cs *engine, ktime_t *now)
return ns_to_ktime(total);
  }
  
+static void guc_enable_busyness_worker(struct intel_guc *guc)

+{
+   mod_delayed_work(system_highpri_wq, >timestamp.work, 
guc->timestamp.ping_delay);
+}
+
+static void guc_cancel_busyness_worker(struct intel_guc *guc)
+{
+   cancel_delayed_work_sync(>timestamp.work);
+}
+
  static void __reset_guc_busyness_stats(struct intel_guc *guc)
  {
struct intel_gt *gt = guc_to_gt(guc);
@@ -1360,7 +1370,7 @@ static void __reset_guc_busyness_stats(struct intel_guc 
*guc)
unsigned long flags;
ktime_t unused;
  
-	cancel_delayed_work_sync(>timestamp.work);

+   guc_cancel_busyness_worker(guc);
  
  	spin_lock_irqsave(>timestamp.lock, flags);
  
@@ -1416,8 +1426,7 @@ static void guc_timestamp_ping(struct work_struct *wrk)
  
  	intel_gt_reset_unlock(gt, srcu);
  
-	mod_delayed_work(system_highpri_wq, >timestamp.work,

-guc->timestamp.ping_delay);
+   guc_enable_busyness_worker(guc);
  }
  
  static int guc_action_enable_usage_stats(struct intel_guc *guc)

@@ -1436,16 +1445,15 @@ static void guc_init_engine_stats(struct intel_guc *guc)
  {
struct intel_gt *gt = guc_to_gt(guc);
intel_wakeref_t wakeref;
+   int ret;
  
-	mod_delayed_work(system_highpri_wq, >timestamp.work,

-guc->timestamp.ping_delay);
-
-   with_intel_runtime_pm(>i915->runtime_pm, wakeref) {
-   int ret = guc_action_enable_usage_stats(guc);
+   with_intel_runtime_pm(>i915->runtime_pm, wakeref)
+   ret = guc_action_enable_usage_stats(guc);
  
-		if (ret)

-   guc_err(guc, "Failed to enable usage stats: %pe\n", 
ERR_PTR(ret));
-   }
+   if (ret)
+   guc_err(guc, "Failed to enable usage stats: %pe\n", 
ERR_PTR(ret));
+   else
+   guc_enable_busyness_worker(guc);
  }
  
  void intel_guc_busyness_park(struct intel_gt *gt)

@@ -1460,7 +1468,7 @@ void intel_guc_busyness_park(struct intel_gt *gt)
 * and causes an unclaimed register access warning. Cancel the worker
 * synchronously here.
 */
-   cancel_delayed_work_sync(>timestamp.work);
+   guc_cancel_busyness_worker(guc);
  
  	/*

 * Before parking, we should sample engine busyness stats if we need to.
@@ -1487,8 +1495,7 @@ void intel_guc_busyness_unpark(struct intel_gt *gt)
spin_lock_irqsave(>timestamp.lock, flags);
guc_update_pm_timestamp(guc, );
spin_unlock_irqrestore(>timestamp.lock, flags);
-   mod_delayed_work(system_highpri_wq, >timestamp.work,
-guc->timestamp.ping_delay);
+   guc_enable_busyness_worker(guc);
  }
  
  static inline bool

@@ -4408,11 +4415,12 @@ void intel_guc_submission_enable(struct intel_guc *guc)
guc_init_global_schedule_policy(guc);
  }
  
+/* Note: By the time we're here, GuC may have already been reset */

  void intel_guc_submission_disable(struct intel_guc *guc)
  {
struct intel_gt *gt = guc_to_gt(guc);
  
-	/* Note: By the time we're here, GuC may have already been reset */

+   guc_cancel_busyness_worker(guc);
  
  	/* Disable and route to host */

if (GRAPHICS_VER(gt->i915) >= 12)




[PATCH v3 7/8] accel/qaic: Add qaic driver to the build system

2023-03-06 Thread Jeffrey Hugo
Now that we have all the components of a minimum QAIC which can boot and
run an AIC100 device, add the infrastructure that allows the QAIC driver
to be built.

Signed-off-by: Jeffrey Hugo 
Reviewed-by: Carl Vanderlip 
Reviewed-by: Pranjal Ramajor Asha Kanojiya 
---
 drivers/accel/Kconfig   |  1 +
 drivers/accel/Makefile  |  1 +
 drivers/accel/qaic/Kconfig  | 23 +++
 drivers/accel/qaic/Makefile | 13 +
 4 files changed, 38 insertions(+)
 create mode 100644 drivers/accel/qaic/Kconfig
 create mode 100644 drivers/accel/qaic/Makefile

diff --git a/drivers/accel/Kconfig b/drivers/accel/Kconfig
index c437206..64065fb 100644
--- a/drivers/accel/Kconfig
+++ b/drivers/accel/Kconfig
@@ -26,5 +26,6 @@ menuconfig DRM_ACCEL
 
 source "drivers/accel/habanalabs/Kconfig"
 source "drivers/accel/ivpu/Kconfig"
+source "drivers/accel/qaic/Kconfig"
 
 endif
diff --git a/drivers/accel/Makefile b/drivers/accel/Makefile
index f22fd44..ab3df93 100644
--- a/drivers/accel/Makefile
+++ b/drivers/accel/Makefile
@@ -2,3 +2,4 @@
 
 obj-$(CONFIG_DRM_ACCEL_HABANALABS) += habanalabs/
 obj-$(CONFIG_DRM_ACCEL_IVPU)   += ivpu/
+obj-$(CONFIG_DRM_ACCEL_QAIC)   += qaic/
diff --git a/drivers/accel/qaic/Kconfig b/drivers/accel/qaic/Kconfig
new file mode 100644
index 000..a9f8662
--- /dev/null
+++ b/drivers/accel/qaic/Kconfig
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Qualcomm Cloud AI accelerators driver
+#
+
+config DRM_ACCEL_QAIC
+   tristate "Qualcomm Cloud AI accelerators"
+   depends on DRM_ACCEL
+   depends on PCI && HAS_IOMEM
+   depends on MHI_BUS
+   depends on MMU
+   select CRC32
+   help
+ Enables driver for Qualcomm's Cloud AI accelerator PCIe cards that are
+ designed to accelerate Deep Learning inference workloads.
+
+ The driver manages the PCIe devices and provides an IOCTL interface
+ for users to submit workloads to the devices.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called qaic.
diff --git a/drivers/accel/qaic/Makefile b/drivers/accel/qaic/Makefile
new file mode 100644
index 000..d5f4952
--- /dev/null
+++ b/drivers/accel/qaic/Makefile
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for Qualcomm Cloud AI accelerators driver
+#
+
+obj-$(CONFIG_DRM_ACCEL_QAIC)   := qaic.o
+
+qaic-y := \
+   mhi_controller.o \
+   mhi_qaic_ctrl.o \
+   qaic_control.o \
+   qaic_data.o \
+   qaic_drv.o
-- 
2.7.4



[PATCH v3 6/8] accel/qaic: Add mhi_qaic_cntl

2023-03-06 Thread Jeffrey Hugo
From: Pranjal Ramajor Asha Kanojiya 

Some of the MHI channels for an AIC100 device need to be routed to
userspace so that userspace can communicate directly with QSM. The MHI
bus does not support this, and while the WWAN subsystem does (for the same
reasons), AIC100 is not a WWAN device. Also, MHI is not something that
other accelerators are expected to share, thus an accel subsystem function
that meets this usecase is unlikely.

Create a QAIC specific MHI userspace shim that exposes these channels.

Start with QAIC_SAHARA which is required to boot AIC100 and is consumed by
the kickstart application as documented in aic100.rst

Each AIC100 instance (currently, up to 16) in a system will create a
chardev for QAIC_SAHARA. This chardev will be found as
/dev/_QAIC_SAHARA
For example - /dev/mhi0_QAIC_SAHARA

Signed-off-by: Pranjal Ramajor Asha Kanojiya 
Signed-off-by: Jeffrey Hugo 
Reviewed-by: Carl Vanderlip 
Reviewed-by: Stanislaw Gruszka 
---
 drivers/accel/qaic/mhi_qaic_ctrl.c | 581 +
 drivers/accel/qaic/mhi_qaic_ctrl.h |  11 +
 2 files changed, 592 insertions(+)
 create mode 100644 drivers/accel/qaic/mhi_qaic_ctrl.c
 create mode 100644 drivers/accel/qaic/mhi_qaic_ctrl.h

diff --git a/drivers/accel/qaic/mhi_qaic_ctrl.c 
b/drivers/accel/qaic/mhi_qaic_ctrl.c
new file mode 100644
index 000..f97279fd
--- /dev/null
+++ b/drivers/accel/qaic/mhi_qaic_ctrl.c
@@ -0,0 +1,581 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights 
reserved. */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mhi_qaic_ctrl.h"
+#include "qaic.h"
+
+#define MHI_QAIC_CTRL_DRIVER_NAME  "mhi_qaic_ctrl"
+#define MHI_QAIC_CTRL_MAX_MINORS   128
+#define MHI_MAX_MTU0x
+static DEFINE_XARRAY_ALLOC(mqc_xa);
+static struct class *mqc_dev_class;
+static int mqc_dev_major;
+
+/**
+ * struct mqc_buf - Buffer structure used to receive data from device
+ * @data: Address of data to read from
+ * @odata: Original address returned from *alloc() API. Used to free this buf.
+ * @len: Length of data in byte
+ * @node: This buffer will be part of list managed in struct mqc_dev
+ */
+struct mqc_buf {
+   void *data;
+   void *odata;
+   size_t len;
+   struct list_head node;
+};
+
+/**
+ * struct mqc_dev - MHI QAIC Control Device
+ * @minor: MQC device node minor number
+ * @mhi_dev: Associated mhi device object
+ * @mtu: Max TRE buffer length
+ * @enabled: Flag to track the state of the MQC device
+ * @lock: Mutex lock to serialize access to open_count
+ * @read_lock: Mutex lock to serialize readers
+ * @write_lock: Mutex lock to serialize writers
+ * @ul_wq: Wait queue for writers
+ * @dl_wq: Wait queue for readers
+ * @dl_queue_lock: Spin lock to serialize access to download queue
+ * @dl_queue: Queue of downloaded buffers
+ * @open_count: Track open counts
+ * @ref_count: Reference count for this structure
+ */
+struct mqc_dev {
+   uint32_t minor;
+   struct mhi_device *mhi_dev;
+   size_t mtu;
+   bool enabled;
+   struct mutex lock;
+   struct mutex read_lock;
+   struct mutex write_lock;
+   wait_queue_head_t ul_wq;
+   wait_queue_head_t dl_wq;
+   spinlock_t dl_queue_lock;
+   struct list_head dl_queue;
+   unsigned int open_count;
+   struct kref ref_count;
+};
+
+static void mqc_dev_release(struct kref *ref)
+{
+   struct mqc_dev *mqcdev = container_of(ref, struct mqc_dev, ref_count);
+
+   mutex_destroy(>read_lock);
+   mutex_destroy(>write_lock);
+   mutex_destroy(>lock);
+   kfree(mqcdev);
+}
+
+static int mhi_qaic_ctrl_fill_dl_queue(struct mqc_dev *mqcdev)
+{
+   struct mhi_device *mhi_dev = mqcdev->mhi_dev;
+   struct mqc_buf *ctrlbuf;
+   int rx_budget;
+   int ret = 0;
+   void *data;
+
+   rx_budget = mhi_get_free_desc_count(mhi_dev, DMA_FROM_DEVICE);
+   if (rx_budget < 0)
+   return -EIO;
+
+   while (rx_budget--) {
+   data = kzalloc(mqcdev->mtu + sizeof(*ctrlbuf), GFP_KERNEL);
+   if (!data)
+   return -ENOMEM;
+
+   ctrlbuf = data + mqcdev->mtu;
+   ctrlbuf->odata = data;
+
+   ret = mhi_queue_buf(mhi_dev, DMA_FROM_DEVICE, data, 
mqcdev->mtu, MHI_EOT);
+   if (ret) {
+   kfree(data);
+   dev_err(_dev->dev, "Failed to queue buffer\n");
+   return ret;
+   }
+   }
+
+   return ret;
+}
+
+static int mhi_qaic_ctrl_dev_start_chan(struct mqc_dev *mqcdev)
+{
+   struct device *dev = >mhi_dev->dev;
+   int ret = 0;
+
+   ret = mutex_lock_interruptible(>lock);
+   if (ret)
+   return ret;
+   if (!mqcdev->enabled) {
+   ret = -ENODEV;
+   goto release_dev_lock;
+   }
+   if (!mqcdev->open_count) {

[PATCH v3 1/8] accel/qaic: Add documentation for AIC100 accelerator driver

2023-03-06 Thread Jeffrey Hugo
The Qualcomm Cloud AI 100 (AIC100) device is an Artificial Intelligence
accelerator PCIe card. It contains a number of components both in the
SoC and on the card which facilitate running workloads:

QSM: management processor
NSPs: workload compute units
DMA Bridge: dedicated data mover for the workloads
MHI: multiplexed communication channels
DDR: workload storage and memory

The Linux kernel driver for AIC100 is called "QAIC" and is located in the
accel subsystem.

Signed-off-by: Jeffrey Hugo 
Reviewed-by: Carl Vanderlip 
Reviewed-by: Pranjal Ramajor Asha Kanojiya 
---
 Documentation/accel/index.rst   |   1 +
 Documentation/accel/qaic/aic100.rst | 501 
 Documentation/accel/qaic/index.rst  |  13 +
 Documentation/accel/qaic/qaic.rst   | 169 
 4 files changed, 684 insertions(+)
 create mode 100644 Documentation/accel/qaic/aic100.rst
 create mode 100644 Documentation/accel/qaic/index.rst
 create mode 100644 Documentation/accel/qaic/qaic.rst

diff --git a/Documentation/accel/index.rst b/Documentation/accel/index.rst
index 2b43c9a..e94a016 100644
--- a/Documentation/accel/index.rst
+++ b/Documentation/accel/index.rst
@@ -8,6 +8,7 @@ Compute Accelerators
:maxdepth: 1
 
introduction
+   qaic/index
 
 .. only::  subproject and html
 
diff --git a/Documentation/accel/qaic/aic100.rst 
b/Documentation/accel/qaic/aic100.rst
new file mode 100644
index 000..7ed95bb
--- /dev/null
+++ b/Documentation/accel/qaic/aic100.rst
@@ -0,0 +1,501 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+===
+ Qualcomm Cloud AI 100 (AIC100)
+===
+
+Overview
+
+
+The Qualcomm Cloud AI 100/AIC100 family of products (including SA9000P - part 
of
+Snapdragon Ride) are PCIe adapter cards which contain a dedicated SoC ASIC for
+the purpose of efficiently running Artificial Intelligence (AI) Deep Learning
+inference workloads. They are AI accelerators.
+
+The PCIe interface of AIC100 is capable of PCIe Gen4 speeds over eight lanes
+(x8). An individual SoC on a card can have up to 16 NSPs for running workloads.
+Each SoC has an A53 management CPU. On card, there can be up to 32 GB of DDR.
+
+Multiple AIC100 cards can be hosted in a single system to scale overall
+performance. AIC100 cards are multi-user capable and able to execute workloads
+from multiple users in a concurrent manner.
+
+Hardware Description
+
+
+An AIC100 card consists of an AIC100 SoC, on-card DDR, and a set of misc
+peripherals (PMICs, etc).
+
+An AIC100 card can either be a PCIe HHHL form factor (a traditional PCIe card),
+or a Dual M.2 card. Both use PCIe to connect to the host system.
+
+As a PCIe endpoint/adapter, AIC100 uses the standard VendorID(VID)/
+DeviceID(DID) combination to uniquely identify itself to the host. AIC100
+uses the standard Qualcomm VID (0x17cb). All AIC100 SKUs use the same
+AIC100 DID (0xa100).
+
+AIC100 does not implement FLR (function level reset).
+
+AIC100 implements MSI but does not implement MSI-X. AIC100 requires 17 MSIs to
+operate (1 for MHI, 16 for the DMA Bridge).
+
+As a PCIe device, AIC100 utilizes BARs to provide host interfaces to the device
+hardware. AIC100 provides 3, 64-bit BARs.
+
+* The first BAR is 4K in size, and exposes the MHI interface to the host.
+
+* The second BAR is 2M in size, and exposes the DMA Bridge interface to the
+  host.
+
+* The third BAR is variable in size based on an individual AIC100's
+  configuration, but defaults to 64K. This BAR currently has no purpose.
+
+From the host perspective, AIC100 has several key hardware components -
+
+* MHI (Modem Host Interface)
+* QSM (QAIC Service Manager)
+* NSPs (Neural Signal Processor)
+* DMA Bridge
+* DDR
+
+MHI
+---
+
+AIC100 has one MHI interface over PCIe. MHI itself is documented at
+Documentation/mhi/index.rst MHI is the mechanism the host uses to communicate
+with the QSM. Except for workload data via the DMA Bridge, all interaction with
+the device occurs via MHI.
+
+QSM
+---
+
+QAIC Service Manager. This is an ARM A53 CPU that runs the primary
+firmware of the card and performs on-card management tasks. It also
+communicates with the host via MHI. Each AIC100 has one of
+these.
+
+NSP
+---
+
+Neural Signal Processor. Each AIC100 has up to 16 of these. These are
+the processors that run the workloads on AIC100. Each NSP is a Qualcomm Hexagon
+(Q6) DSP with HVX and HMX. Each NSP can only run one workload at a time, but
+multiple NSPs may be assigned to a single workload. Since each NSP can only run
+one workload, AIC100 is limited to 16 concurrent workloads. Workload
+"scheduling" is under the purview of the host. AIC100 does not automatically
+timeslice.
+
+DMA Bridge
+--
+
+The DMA Bridge is custom DMA engine that manages the flow of data
+in and out of workloads. AIC100 has one of these. The DMA Bridge has 16
+channels, each consisting of a set of request/response FIFOs. Each active
+workload is assigned 

[PATCH v3 8/8] MAINTAINERS: Add entry for QAIC driver

2023-03-06 Thread Jeffrey Hugo
Add MAINTAINERS entry for the Qualcomm Cloud AI 100 driver.

Signed-off-by: Jeffrey Hugo 
Reviewed-by: Carl Vanderlip 
Reviewed-by: Pranjal Ramajor Asha Kanojiya 
---
 MAINTAINERS | 9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b0db911..feb2974 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17253,6 +17253,15 @@ F: Documentation/devicetree/bindings/clock/qcom,*
 F: drivers/clk/qcom/
 F: include/dt-bindings/clock/qcom,*
 
+QUALCOMM CLOUD AI (QAIC) DRIVER
+M: Jeffrey Hugo 
+L: linux-arm-...@vger.kernel.org
+L: dri-devel@lists.freedesktop.org
+S: Supported
+F: Documentation/accel/qaic/
+F: drivers/accel/qaic/
+F: include/uapi/drm/qaic_accel.h
+
 QUALCOMM CORE POWER REDUCTION (CPR) AVS DRIVER
 M: Bjorn Andersson 
 M: Konrad Dybcio 
-- 
2.7.4



[PATCH v3 5/8] accel/qaic: Add datapath

2023-03-06 Thread Jeffrey Hugo
Add the datapath component that manages BOs and submits them to running
workloads on the qaic device via the dma_bridge hardware. This allows
QAIC clients to interact with their workloads (run inferences) via the
following ioctls along with mmap():

DRM_IOCTL_QAIC_CREATE_BO
DRM_IOCTL_QAIC_MMAP_BO
DRM_IOCTL_QAIC_ATTACH_SLICE_BO
DRM_IOCTL_QAIC_EXECUTE_BO
DRM_IOCTL_QAIC_PARTIAL_EXECUTE_BO
DRM_IOCTL_QAIC_WAIT_BO
DRM_IOCTL_QAIC_PERF_STATS_BO

Signed-off-by: Jeffrey Hugo 
Reviewed-by: Carl Vanderlip 
Reviewed-by: Pranjal Ramajor Asha Kanojiya 
---
 drivers/accel/qaic/qaic_data.c | 1878 
 1 file changed, 1878 insertions(+)
 create mode 100644 drivers/accel/qaic/qaic_data.c

diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
new file mode 100644
index 000..6cb6a3b
--- /dev/null
+++ b/drivers/accel/qaic/qaic_data.c
@@ -0,0 +1,1878 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. */
+/* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights 
reserved. */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "qaic.h"
+
+#define SEM_VAL_MASK   GENMASK_ULL(11, 0)
+#define SEM_INDEX_MASK GENMASK_ULL(4, 0)
+#define BULK_XFER  BIT(3)
+#define GEN_COMPLETION BIT(4)
+#define INBOUND_XFER   1
+#define OUTBOUND_XFER  2
+#define REQHP_OFF  0x0 /* we read this */
+#define REQTP_OFF  0x4 /* we write this */
+#define RSPHP_OFF  0x8 /* we write this */
+#define RSPTP_OFF  0xc /* we read this */
+
+#define ENCODE_SEM(val, index, sync, cmd, flags)   \
+   ({  \
+   FIELD_PREP(GENMASK(11, 0), (val)) | \
+   FIELD_PREP(GENMASK(20, 16), (index)) |  \
+   FIELD_PREP(BIT(22), (sync)) |   \
+   FIELD_PREP(GENMASK(26, 24), (cmd)) |\
+   FIELD_PREP(GENMASK(30, 29), (flags)) |  \
+   FIELD_PREP(BIT(31), (cmd) ? 1 : 0); \
+   })
+#define NUM_EVENTS 128
+#define NUM_DELAYS 10
+
+static unsigned int wait_exec_default_timeout = 5000; /* 5 sec default */
+module_param(wait_exec_default_timeout, uint, 0600);
+
+static unsigned int datapath_poll_interval_us = 100; /* 100 usec default */
+module_param(datapath_poll_interval_us, uint, 0600);
+
+struct dbc_req {
+   /*
+* A request ID is assigned to each memory handle going in DMA queue.
+* As a single memory handle can enqueue multiple elements in DMA queue
+* all of them will have the same request ID.
+*/
+   __le16  req_id;
+   /* Future use */
+   __u8seq_id;
+   /*
+* Special encoded variable
+* 70 - Do not force to generate MSI after DMA is completed
+*  1 - Force to generate MSI after DMA is completed
+* 6:5  Reserved
+* 41 - Generate completion element in the response queue
+*  0 - No Completion Code
+* 30 - DMA request is a Link list transfer
+*  1 - DMA request is a Bulk transfer
+* 2Reserved
+* 1:0  00 - No DMA transfer involved
+*  01 - DMA transfer is part of inbound transfer
+*  10 - DMA transfer has outbound transfer
+*  11 - NA
+*/
+   __u8cmd;
+   __le32  resv;
+   /* Source address for the transfer */
+   __le64  src_addr;
+   /* Destination address for the transfer */
+   __le64  dest_addr;
+   /* Length of transfer request */
+   __le32  len;
+   __le32  resv2;
+   /* Doorbell address */
+   __le64  db_addr;
+   /*
+* Special encoded variable
+* 71 - Doorbell(db) write
+*  0 - No doorbell write
+* 6:2  Reserved
+* 1:0  00 - 32 bit access, db address must be aligned to 32bit-boundary
+*  01 - 16 bit access, db address must be aligned to 16bit-boundary
+*  10 - 8 bit access, db address must be aligned to 8bit-boundary
+*  11 - Reserved
+*/
+   __u8db_len;
+   __u8resv3;
+   __le16  resv4;
+   /* 32 bit data written to doorbell address */
+   __le32  db_data;
+   /*
+* Special encoded variable
+* All the fields of sem_cmdX are passed from user and all are ORed
+* together to form sem_cmd.
+* 0:11 Semaphore value
+* 15:12Reserved
+* 20:16Semaphore index
+* 21   Reserved
+* 22   Semaphore Sync
+* 23   Reserved
+* 26:24Semaphore 

[PATCH v3 4/8] accel/qaic: Add control path

2023-03-06 Thread Jeffrey Hugo
Add the control path component that talks to the management processor (QSM)
to load workloads onto the AIC100 device. This implements the KMD portion
of the NNC protocol over the QAIC_CONTROL MHI channel and the
DRM_IOCTL_QAIC_MANAGE IOCTL to userspace. With this functionality, QAIC
clients are able to load, run, and cleanup their workloads on the device
but not interact with the workloads (run inferences).

Signed-off-by: Jeffrey Hugo 
Reviewed-by: Carl Vanderlip 
Reviewed-by: Pranjal Ramajor Asha Kanojiya 
---
 drivers/accel/qaic/qaic_control.c | 1496 +
 1 file changed, 1496 insertions(+)
 create mode 100644 drivers/accel/qaic/qaic_control.c

diff --git a/drivers/accel/qaic/qaic_control.c 
b/drivers/accel/qaic/qaic_control.c
new file mode 100644
index 000..2643747
--- /dev/null
+++ b/drivers/accel/qaic/qaic_control.c
@@ -0,0 +1,1496 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. */
+/* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights 
reserved. */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "qaic.h"
+
+#define MANAGE_MAGIC_NUMBER((__force __le32)0x43494151) /* "QAIC" 
in little endian */
+#define QAIC_DBC_Q_GAP SZ_256
+#define QAIC_DBC_Q_BUF_ALIGN   SZ_4K
+#define QAIC_MANAGE_EXT_MSG_LENGTH SZ_64K /* Max DMA message length */
+#define QAIC_WRAPPER_MAX_SIZE  SZ_4K
+#define QAIC_MHI_RETRY_WAIT_MS 100
+#define QAIC_MHI_RETRY_MAX 20
+
+static unsigned int control_resp_timeout = 60; /* 60 sec default */
+module_param(control_resp_timeout, uint, 0600);
+
+struct manage_msg {
+   u32 len;
+   u32 count;
+   u8 data[];
+};
+
+/*
+ * wire encoding structures for the manage protocol.
+ * All fields are little endian on the wire
+ */
+struct _msg_hdr {
+   __le32 crc32; /* crc of everything following this field in the message 
*/
+   __le32 magic_number;
+   __le32 sequence_number;
+   __le32 len; /* length of this message */
+   __le32 count; /* number of transactions in this message */
+   __le32 handle; /* unique id to track the resources consumed */
+   __le32 partition_id; /* partition id for the request (signed)*/
+   __le32 padding; /* must be 0 */
+} __packed;
+
+struct _msg {
+   struct _msg_hdr hdr;
+   u8 data[];
+} __packed;
+
+struct _trans_hdr {
+   __le32 type;
+   __le32 len;
+} __packed;
+
+/* Each message sent from driver to device are organized in a list of 
wrapper_msg */
+struct wrapper_msg {
+   struct list_head list;
+   struct kref ref_count;
+   u32 len; /* length of data to transfer */
+   struct wrapper_list *head;
+   union {
+   struct _msg msg;
+   struct _trans_hdr trans;
+   };
+};
+
+struct wrapper_list {
+   struct list_head list;
+   spinlock_t lock;
+};
+
+struct _trans_passthrough {
+   struct _trans_hdr hdr;
+   u8 data[];
+} __packed;
+
+struct _addr_size_pair {
+   __le64 addr;
+   __le64 size;
+} __packed;
+
+struct _trans_dma_xfer {
+   struct _trans_hdr hdr;
+   __le32 tag;
+   __le32 count;
+   __le32 dma_chunk_id;
+   __le32 padding;
+   struct _addr_size_pair data[];
+} __packed;
+
+/* Initiated by device to continue the DMA xfer of a large piece of data */
+struct _trans_dma_xfer_cont {
+   struct _trans_hdr hdr;
+   __le32 dma_chunk_id;
+   __le32 padding;
+   __le64 xferred_size;
+} __packed;
+
+struct _trans_activate_to_dev {
+   struct _trans_hdr hdr;
+   __le64 req_q_addr;
+   __le64 rsp_q_addr;
+   __le32 req_q_size;
+   __le32 rsp_q_size;
+   __le32 buf_len;
+   __le32 options; /* unused, but BIT(16) has meaning to the device */
+} __packed;
+
+struct _trans_activate_from_dev {
+   struct _trans_hdr hdr;
+   __le32 status;
+   __le32 dbc_id;
+   __le64 options; /* unused */
+} __packed;
+
+struct _trans_deactivate_from_dev {
+   struct _trans_hdr hdr;
+   __le32 status;
+   __le32 dbc_id;
+} __packed;
+
+struct _trans_terminate_to_dev {
+   struct _trans_hdr hdr;
+   __le32 handle;
+   __le32 padding;
+} __packed;
+
+struct _trans_terminate_from_dev {
+   struct _trans_hdr hdr;
+   __le32 status;
+   __le32 padding;
+} __packed;
+
+struct _trans_status_to_dev {
+   struct _trans_hdr hdr;
+} __packed;
+
+struct _trans_status_from_dev {
+   struct _trans_hdr hdr;
+   __le16 major;
+   __le16 minor;
+   __le32 status;
+   __le64 status_flags;
+} __packed;
+
+struct _trans_validate_part_to_dev {
+   struct _trans_hdr hdr;
+   __le32 part_id;
+   __le32 padding;
+} __packed;
+
+struct 

[PATCH v3 2/8] accel/qaic: Add uapi and core driver file

2023-03-06 Thread Jeffrey Hugo
Add the QAIC driver uapi file and core driver file that binds to the PCIe
device. The core driver file also creates the accel device and manages
all the interconnections between the different parts of the driver.

The driver can be built as a module. If so, it will be called "qaic.ko".

Signed-off-by: Jeffrey Hugo 
Reviewed-by: Carl Vanderlip 
Reviewed-by: Pranjal Ramajor Asha Kanojiya 
---
 drivers/accel/qaic/qaic.h | 282 ++
 drivers/accel/qaic/qaic_drv.c | 648 ++
 include/uapi/drm/qaic_accel.h | 397 ++
 3 files changed, 1327 insertions(+)
 create mode 100644 drivers/accel/qaic/qaic.h
 create mode 100644 drivers/accel/qaic/qaic_drv.c
 create mode 100644 include/uapi/drm/qaic_accel.h

diff --git a/drivers/accel/qaic/qaic.h b/drivers/accel/qaic/qaic.h
new file mode 100644
index 000..996a68f
--- /dev/null
+++ b/drivers/accel/qaic/qaic.h
@@ -0,0 +1,282 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights 
reserved.
+ */
+
+#ifndef _QAIC_H_
+#define _QAIC_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define QAIC_DBC_BASE  SZ_128K
+#define QAIC_DBC_SIZE  SZ_4K
+
+#define QAIC_NO_PARTITION  -1
+
+#define QAIC_DBC_OFF(i)((i) * QAIC_DBC_SIZE + QAIC_DBC_BASE)
+
+#define to_qaic_bo(obj) container_of(obj, struct qaic_bo, base)
+
+extern bool poll_datapath;
+
+struct qaic_user {
+   /* Uniquely identifies this user for the device */
+   int handle;
+   struct kref ref_count;
+   /* Char device opened by this user */
+   struct qaic_drm_device  *qddev;
+   /* Node in list of users that opened this drm device */
+   struct list_headnode;
+   /* SRCU used to synchronize this user during cleanup */
+   struct srcu_struct  qddev_lock;
+   atomic_tchunk_id;
+};
+
+struct dma_bridge_chan {
+   /* Pointer to device strcut maintained by driver */
+   struct qaic_device  *qdev;
+   /* ID of this DMA bridge channel(DBC) */
+   unsigned intid;
+   /* Synchronizes access to xfer_list */
+   spinlock_t  xfer_lock;
+   /* Base address of request queue */
+   void*req_q_base;
+   /* Base address of response queue */
+   void*rsp_q_base;
+   /*
+* Base bus address of request queue. Response queue bus address can be
+* calculated by adding request queue size to this variable
+*/
+   dma_addr_t  dma_addr;
+   /* Total size of request and response queue in byte */
+   u32 total_size;
+   /* Capacity of request/response queue */
+   u32 nelem;
+   /* The user that opened this DBC */
+   struct qaic_user*usr;
+   /*
+* Request ID of next memory handle that goes in request queue. One
+* memory handle can enqueue more than one request elements, all
+* this requests that belong to same memory handle have same request ID
+*/
+   u16 next_req_id;
+   /* true: DBC is in use; false: DBC not in use */
+   boolin_use;
+   /*
+* Base address of device registers. Used to read/write request and
+* response queue's head and tail pointer of this DBC.
+*/
+   void __iomem*dbc_base;
+   /* Head of list where each node is a memory handle queued in request 
queue */
+   struct list_headxfer_list;
+   /* Synchronizes DBC readers during cleanup */
+   struct srcu_struct  ch_lock;
+   /*
+* When this DBC is released, any thread waiting on this wait queue is
+* woken up
+*/
+   wait_queue_head_t   dbc_release;
+   /* Head of list where each node is a bo associated with this DBC */
+   struct list_headbo_lists;
+   /* The irq line for this DBC. Used for polling */
+   unsigned intirq;
+   /* Polling work item to simulate interrupts */
+   struct work_struct  poll_work;
+};
+
+struct qaic_device {
+   /* Pointer to base PCI device struct of our physical device */
+   struct pci_dev  *pdev;
+   /* Req. ID of request that will be queued next in MHI control device */
+   u32 next_seq_num;
+   /* Base address of bar 0 */
+   void __iomem*bar_0;
+   /* Base address of bar 2 */
+   void __iomem*bar_2;
+   /* Controller structure for MHI devices */
+   struct mhi_controller   *mhi_cntl;
+   /* MHI control channel device */
+   struct mhi_device   *cntl_ch;
+   /* 

[PATCH v3 0/8] QAIC accel driver

2023-03-06 Thread Jeffrey Hugo
This series introduces a driver under the accel subsystem (QAIC -
Qualcomm AIC) for the Qualcomm Cloud AI 100 product (AIC100).  AIC100 is
a PCIe adapter card that hosts a dedicated machine learning inference
accelerator.

Depends on "accel: Build sub-directories based on config options" found at
https://lore.kernel.org/all/20230301162508.3963484-1-stanislaw.grus...@linux.intel.com/

The previous version (v2) can be found at:
https://lore.kernel.org/all/1675698105-19025-1-git-send-email-quic_jh...@quicinc.com/

v3:
-Various style updates and word smithing
-Remove unused function declarations
-Drop iommu workaround for sg lists and outdated reserve_pages()
-Remove unnecessary includes
-Refactor qaic_pci_probe()
-Use FIELD_PREP for ENCODE_SEM
-Gate qaic subdirectory on the kconfig symbol
-Add dri-devel@lists.freedesktop.org to MAINTAINERS entry
-Rename copy_sgt()
-Correct guard macro for qaic.h and cplusplus macro
-Add comment in qaic_mhi_remove
-Fix qaic_open use after free
-Use devm allocs in qaic_mhi_register_controller()
-Remove partition device ioctl.

v2:
-Addressed comments from RFC
-Reduced the code to the core minimum by dropping telemetery, etc
-Conversion to accel subsystem
-Dropped versioning
-Add mhi_qaic_cntl component
-Restructure the documentation
-Pull in a few fixes from the downstream tree

Jeffrey Hugo (7):
  accel/qaic: Add documentation for AIC100 accelerator driver
  accel/qaic: Add uapi and core driver file
  accel/qaic: Add MHI controller
  accel/qaic: Add control path
  accel/qaic: Add datapath
  accel/qaic: Add qaic driver to the build system
  MAINTAINERS: Add entry for QAIC driver

Pranjal Ramajor Asha Kanojiya (1):
  accel/qaic: Add mhi_qaic_cntl

 Documentation/accel/index.rst   |1 +
 Documentation/accel/qaic/aic100.rst |  501 ++
 Documentation/accel/qaic/index.rst  |   13 +
 Documentation/accel/qaic/qaic.rst   |  169 
 MAINTAINERS |9 +
 drivers/accel/Kconfig   |1 +
 drivers/accel/Makefile  |1 +
 drivers/accel/qaic/Kconfig  |   23 +
 drivers/accel/qaic/Makefile |   13 +
 drivers/accel/qaic/mhi_controller.c |  563 +++
 drivers/accel/qaic/mhi_controller.h |   16 +
 drivers/accel/qaic/mhi_qaic_ctrl.c  |  581 +++
 drivers/accel/qaic/mhi_qaic_ctrl.h  |   11 +
 drivers/accel/qaic/qaic.h   |  282 ++
 drivers/accel/qaic/qaic_control.c   | 1496 
 drivers/accel/qaic/qaic_data.c  | 1878 +++
 drivers/accel/qaic/qaic_drv.c   |  648 
 include/uapi/drm/qaic_accel.h   |  397 
 18 files changed, 6603 insertions(+)
 create mode 100644 Documentation/accel/qaic/aic100.rst
 create mode 100644 Documentation/accel/qaic/index.rst
 create mode 100644 Documentation/accel/qaic/qaic.rst
 create mode 100644 drivers/accel/qaic/Kconfig
 create mode 100644 drivers/accel/qaic/Makefile
 create mode 100644 drivers/accel/qaic/mhi_controller.c
 create mode 100644 drivers/accel/qaic/mhi_controller.h
 create mode 100644 drivers/accel/qaic/mhi_qaic_ctrl.c
 create mode 100644 drivers/accel/qaic/mhi_qaic_ctrl.h
 create mode 100644 drivers/accel/qaic/qaic.h
 create mode 100644 drivers/accel/qaic/qaic_control.c
 create mode 100644 drivers/accel/qaic/qaic_data.c
 create mode 100644 drivers/accel/qaic/qaic_drv.c
 create mode 100644 include/uapi/drm/qaic_accel.h

-- 
2.7.4



[PATCH v3 3/8] accel/qaic: Add MHI controller

2023-03-06 Thread Jeffrey Hugo
An AIC100 device contains a MHI interface with a number of different
channels for controlling different aspects of the device. The MHI
controller works with the MHI bus to enable and drive that interface.

AIC100 uses the BHI protocol in PBL to load SBL. The MHI controller
expects the SBL to be located at /lib/firmware/qcom/aic100/sbl.bin and
expects the MHI bus to manage the process of loading and sending SBL to
the device.

Signed-off-by: Jeffrey Hugo 
Reviewed-by: Carl Vanderlip 
Reviewed-by: Pranjal Ramajor Asha Kanojiya 
---
 drivers/accel/qaic/mhi_controller.c | 563 
 drivers/accel/qaic/mhi_controller.h |  16 +
 2 files changed, 579 insertions(+)
 create mode 100644 drivers/accel/qaic/mhi_controller.c
 create mode 100644 drivers/accel/qaic/mhi_controller.h

diff --git a/drivers/accel/qaic/mhi_controller.c 
b/drivers/accel/qaic/mhi_controller.c
new file mode 100644
index 000..f16dbb7
--- /dev/null
+++ b/drivers/accel/qaic/mhi_controller.c
@@ -0,0 +1,563 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. */
+/* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights 
reserved. */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mhi_controller.h"
+#include "qaic.h"
+
+#define MAX_RESET_TIME_SEC 25
+
+static unsigned int mhi_timeout = 2000; /* 2 sec default */
+module_param(mhi_timeout, uint, 0600);
+
+static struct mhi_channel_config aic100_channels[] = {
+   {
+   .name = "QAIC_LOOPBACK",
+   .num = 0,
+   .num_elements = 32,
+   .local_elements = 0,
+   .event_ring = 0,
+   .dir = DMA_TO_DEVICE,
+   .ee_mask = MHI_CH_EE_AMSS,
+   .pollcfg = 0,
+   .doorbell = MHI_DB_BRST_DISABLE,
+   .lpm_notify = false,
+   .offload_channel = false,
+   .doorbell_mode_switch = false,
+   .auto_queue = false,
+   .wake_capable = false,
+   },
+   {
+   .name = "QAIC_LOOPBACK",
+   .num = 1,
+   .num_elements = 32,
+   .local_elements = 0,
+   .event_ring = 0,
+   .dir = DMA_FROM_DEVICE,
+   .ee_mask = MHI_CH_EE_AMSS,
+   .pollcfg = 0,
+   .doorbell = MHI_DB_BRST_DISABLE,
+   .lpm_notify = false,
+   .offload_channel = false,
+   .doorbell_mode_switch = false,
+   .auto_queue = false,
+   .wake_capable = false,
+   },
+   {
+   .name = "QAIC_SAHARA",
+   .num = 2,
+   .num_elements = 32,
+   .local_elements = 0,
+   .event_ring = 0,
+   .dir = DMA_TO_DEVICE,
+   .ee_mask = MHI_CH_EE_SBL,
+   .pollcfg = 0,
+   .doorbell = MHI_DB_BRST_DISABLE,
+   .lpm_notify = false,
+   .offload_channel = false,
+   .doorbell_mode_switch = false,
+   .auto_queue = false,
+   .wake_capable = false,
+   },
+   {
+   .name = "QAIC_SAHARA",
+   .num = 3,
+   .num_elements = 32,
+   .local_elements = 0,
+   .event_ring = 0,
+   .dir = DMA_FROM_DEVICE,
+   .ee_mask = MHI_CH_EE_SBL,
+   .pollcfg = 0,
+   .doorbell = MHI_DB_BRST_DISABLE,
+   .lpm_notify = false,
+   .offload_channel = false,
+   .doorbell_mode_switch = false,
+   .auto_queue = false,
+   .wake_capable = false,
+   },
+   {
+   .name = "QAIC_DIAG",
+   .num = 4,
+   .num_elements = 32,
+   .local_elements = 0,
+   .event_ring = 0,
+   .dir = DMA_TO_DEVICE,
+   .ee_mask = MHI_CH_EE_AMSS,
+   .pollcfg = 0,
+   .doorbell = MHI_DB_BRST_DISABLE,
+   .lpm_notify = false,
+   .offload_channel = false,
+   .doorbell_mode_switch = false,
+   .auto_queue = false,
+   .wake_capable = false,
+   },
+   {
+   .name = "QAIC_DIAG",
+   .num = 5,
+   .num_elements = 32,
+   .local_elements = 0,
+   .event_ring = 0,
+   .dir = DMA_FROM_DEVICE,
+   .ee_mask = MHI_CH_EE_AMSS,
+   .pollcfg = 0,
+   .doorbell = MHI_DB_BRST_DISABLE,
+   .lpm_notify = false,
+   .offload_channel = false,
+   .doorbell_mode_switch = false,
+   .auto_queue = false,
+   .wake_capable = false,
+   },
+   {
+   .name = "QAIC_SSR",
+   .num = 6,
+   .num_elements = 32,
+   

Re: [PATCH v3] drm/virtio: Fix handling CONFIG_DRM_VIRTIO_GPU_KMS option

2023-03-06 Thread Emil Velikov
On 2023/03/06, Dmitry Osipenko wrote:
> On 3/6/23 19:39, Dmitry Osipenko wrote:
> > VirtIO-GPU got a new config option for disabling KMS. There were two
> > problems left unnoticed during review when the new option was added:
> > 
> > 1. The IS_ENABLED(CONFIG_DRM_VIRTIO_GPU_KMS) check in the code was
> > inverted, hence KMS was disabled when it should be enabled and vice versa.
> > 
> > 2. The disabled KMS crashed kernel with a NULL dereference in
> > drm_kms_helper_hotplug_event(), which shall not be invoked with a
> > disabled KMS.
> > 
> > Fix the inverted config option check in the code and skip handling the
> > VIRTIO_GPU_EVENT_DISPLAY sent by host when KMS is disabled in guest to fix
> > the crash.
> > 
> > Acked-by: Gerd Hoffmann 
> > Fixes: 72122c69d717 ("drm/virtio: Add option to disable KMS support")
> > Signed-off-by: Dmitry Osipenko 
> > ---
> 
> Added r-b from Emil and applied to misc-next
> 

For anyone wondering: I've sent that in private, adding here for posterity

Reviewed-by: Emil Velikov 

-Emil


Re: [PATCH 08/99] fbdev/arkfb: Duplicate video-mode option string

2023-03-06 Thread kernel test robot
Hi Thomas,

I love your patch! Yet something to improve:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v6.3-rc1 next-20230306]
[cannot apply to deller-parisc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:
https://lore.kernel.org/r/20230306160016.4459-9-tzimmermann%40suse.de
patch subject: [PATCH 08/99] fbdev/arkfb: Duplicate video-mode option string
config: x86_64-randconfig-a016-20230306 
(https://download.01.org/0day-ci/archive/20230307/202303070537.699fzdem-...@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project 
f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/f8a56fb51ff846d7daca02280ac0355e1a82264e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
git checkout f8a56fb51ff846d7daca02280ac0355e1a82264e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 
O=build_dir ARCH=x86_64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 
O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202303070537.699fzdem-...@intel.com/

All errors (new ones prefixed by >>):

>> drivers/video/fbdev/arkfb.c:1205:4: error: 'continue' statement not in loop 
>> statement
   continue;
   ^
   drivers/video/fbdev/arkfb.c:1207:4: error: 'continue' statement not in loop 
statement
   continue;
   ^
   2 errors generated.


vim +/continue +1205 drivers/video/fbdev/arkfb.c

  1191  
  1192  if (fb_modesetting_disabled("arkfb"))
  1193  return -ENODEV;
  1194  
  1195  #ifndef MODULE
  1196  if (fb_get_options("arkfb", ))
  1197  return -ENODEV;
  1198  
  1199  if (option && *option) {
  1200  static char mode_option_buf[256];
  1201  int ret;
  1202  
  1203  ret = snprintf(mode_option_buf, 
sizeof(mode_option_buf), "%s", option);
  1204  if (WARN(ret < 0, "arkfb: ignoring invalid option, 
ret=%d\n", ret))
> 1205  continue;
  1206  if (WARN(ret >= sizeof(mode_option_buf), "arkfb: option 
too long\n"))
  1207  continue;
  1208  mode_option = mode_option_buf;
  1209  }
  1210  #endif
  1211  
  1212  pr_debug("arkfb: initializing\n");
  1213  return pci_register_driver(_pci_driver);
  1214  }
  1215  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Re: [Intel-gfx] [Intel-xe] [PATCH] drm/xe/display: Do not use i915 frontbuffer tracking implementation

2023-03-06 Thread Ville Syrjälä
On Mon, Mar 06, 2023 at 09:23:50PM +0100, Maarten Lankhorst wrote:
> Hey,
> 
> On 2023-03-06 16:23, Souza, Jose wrote:
> > On Mon, 2023-03-06 at 15:16 +0100, Maarten Lankhorst wrote:
> >> As a fallback if we decide not to merge the frontbuffer tracking, allow
> >> i915 to keep its own implementation, and do the right thing in Xe.
> >>
> >> The frontbuffer tracking for Xe is still done per-fb, while i915 can
> >> keep doing the weird intel_frontbuffer + i915_active thing without
> >> blocking Xe.
> > Please also disable PSR and FBC with this or at least add a way for users 
> > to disable those features.
> > Without frontbuffer tracker those two features will break in some cases.
> 
> FBC and PSR work completely as expected. I don't remove frontbuffer 
> tracking; I only remove the GEM parts.
> 
> Explicit invalidation using pageflip or CPU rendering + DirtyFB continue 
> to work, as I validated on my laptop with FBC.

Neither of which are relevant to the removal of the gem hooks.

Like I already said ~10 times in the last meeting, we need a proper
testcase. Here's a rough idea what it should do:

prepare a batch with
1. spinner
2. something that clobbers the fb

Then
1. grab reference crc
2. execbuffer
3. dirtyfb
4. wait long enough for fbc to recompress
5. terminate spinner
6. gem_sync
7. grab crc and compare with reference

No idea what the current status of PSR+CRC is, so not sure
whether we can actually test PSR or not.

-- 
Ville Syrjälä
Intel


[PATCH 3/3] drm/i915/dg1: Move Wa_1806527549 to the right function

2023-03-06 Thread Lucas De Marchi
dg1_ctx_workarounds_init() is DG1-only, while
gen12_ctx_workarounds_init() is shared with other platforms. Move the
workaround to the former so there is no additional platform check
needed.

Signed-off-by: Lucas De Marchi 
---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c 
b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index 389bfcd299af..f68fe64f63a6 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -707,8 +707,6 @@ static void gen12_ctx_gt_tuning_init(struct intel_engine_cs 
*engine,
 static void gen12_ctx_workarounds_init(struct intel_engine_cs *engine,
   struct i915_wa_list *wal)
 {
-   struct drm_i915_private *i915 = engine->i915;
-
gen12_ctx_gt_tuning_init(engine, wal);
 
/*
@@ -742,10 +740,6 @@ static void gen12_ctx_workarounds_init(struct 
intel_engine_cs *engine,
   FF_MODE2_GS_TIMER_MASK,
   FF_MODE2_GS_TIMER_224,
   0, false);
-
-   if (!IS_DG1(i915))
-   /* Wa_1806527549 */
-   wa_masked_en(wal, HIZ_CHICKEN, HZ_DEPTH_TEST_LE_GE_OPT_DISABLE);
 }
 
 static void dg1_ctx_workarounds_init(struct intel_engine_cs *engine,
@@ -760,6 +754,9 @@ static void dg1_ctx_workarounds_init(struct intel_engine_cs 
*engine,
/* Wa_22010493298 */
wa_masked_en(wal, HIZ_CHICKEN,
 DG1_HZ_READ_SUPPRESSION_OPTIMIZATION_DISABLE);
+
+   /* Wa_1806527549 */
+   wa_masked_en(wal, HIZ_CHICKEN, HZ_DEPTH_TEST_LE_GE_OPT_DISABLE);
 }
 
 static void dg2_ctx_workarounds_init(struct intel_engine_cs *engine,
-- 
2.39.0



[PATCH 1/3] drm/i915: Remove redundant check for DG1

2023-03-06 Thread Lucas De Marchi
dg1_gt_workarounds_init() is only ever called for DG1, so there is no
point checking it again.

Signed-off-by: Lucas De Marchi 
---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c 
b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index 32aa1647721a..eb6cc4867d67 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -1472,21 +1472,15 @@ gen12_gt_workarounds_init(struct intel_gt *gt, struct 
i915_wa_list *wal)
 static void
 dg1_gt_workarounds_init(struct intel_gt *gt, struct i915_wa_list *wal)
 {
-   struct drm_i915_private *i915 = gt->i915;
-
gen12_gt_workarounds_init(gt, wal);
 
/* Wa_1409420604:dg1 */
-   if (IS_DG1(i915))
-   wa_mcr_write_or(wal,
-   SUBSLICE_UNIT_LEVEL_CLKGATE2,
-   CPSSUNIT_CLKGATE_DIS);
+   wa_mcr_write_or(wal, SUBSLICE_UNIT_LEVEL_CLKGATE2,
+   CPSSUNIT_CLKGATE_DIS);
 
/* Wa_1408615072:dg1 */
/* Empirical testing shows this register is unaffected by engine reset. 
*/
-   if (IS_DG1(i915))
-   wa_write_or(wal, UNSLICE_UNIT_LEVEL_CLKGATE2,
-   VSUNIT_CLKGATE_DIS_TGL);
+   wa_write_or(wal, UNSLICE_UNIT_LEVEL_CLKGATE2, VSUNIT_CLKGATE_DIS_TGL);
 }
 
 static void
-- 
2.39.0



[PATCH 2/3] drm/i915: Move DG2 tuning to the right function

2023-03-06 Thread Lucas De Marchi
Use gt_tuning_settings() for the recommended tunings rather than the one
for workarounds.

Signed-off-by: Lucas De Marchi 
---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c 
b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index eb6cc4867d67..389bfcd299af 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -1653,13 +1653,6 @@ dg2_gt_workarounds_init(struct intel_gt *gt, struct 
i915_wa_list *wal)
/* Wa_14014830051:dg2 */
wa_mcr_write_clr(wal, SARB_CHICKEN1, COMP_CKN_IN);
 
-   /*
-* The following are not actually "workarounds" but rather
-* recommended tuning settings documented in the bspec's
-* performance guide section.
-*/
-   wa_mcr_write_or(wal, XEHP_SQCM, EN_32B_ACCESS);
-
/* Wa_14015795083 */
wa_write_clr(wal, GEN7_MISCCPCTL, GEN12_DOP_CLOCK_GATE_RENDER_ENABLE);
 
@@ -1752,8 +1745,10 @@ static void gt_tuning_settings(struct intel_gt *gt, 
struct i915_wa_list *wal)
wa_mcr_masked_en(wal, XEHPC_LNCFMISCCFGREG0, XEHPC_HOSTCACHEEN);
}
 
-   if (IS_DG2(gt->i915))
+   if (IS_DG2(gt->i915)) {
wa_mcr_write_or(wal, XEHP_L3SCQREG7, 
BLEND_FILL_CACHING_OPT_DIS);
+   wa_mcr_write_or(wal, XEHP_SQCM, EN_32B_ACCESS);
+   }
 }
 
 static void
-- 
2.39.0



Re: [Intel-xe] [PATCH] drm/xe/display: Do not use i915 frontbuffer tracking implementation

2023-03-06 Thread Maarten Lankhorst

Hey,

On 2023-03-06 16:23, Souza, Jose wrote:

On Mon, 2023-03-06 at 15:16 +0100, Maarten Lankhorst wrote:

As a fallback if we decide not to merge the frontbuffer tracking, allow
i915 to keep its own implementation, and do the right thing in Xe.

The frontbuffer tracking for Xe is still done per-fb, while i915 can
keep doing the weird intel_frontbuffer + i915_active thing without
blocking Xe.

Please also disable PSR and FBC with this or at least add a way for users to 
disable those features.
Without frontbuffer tracker those two features will break in some cases.


FBC and PSR work completely as expected. I don't remove frontbuffer 
tracking; I only remove the GEM parts.


Explicit invalidation using pageflip or CPU rendering + DirtyFB continue 
to work, as I validated on my laptop with FBC.



Signed-off-by: Maarten Lankhorst 
---
  .../gpu/drm/i915/display/intel_display_types.h  | 12 
  drivers/gpu/drm/i915/display/intel_drrs.c   |  1 +
  drivers/gpu/drm/i915/display/intel_fb.c |  8 +---
  drivers/gpu/drm/i915/display/intel_fbdev.c  |  2 +-
  .../gpu/drm/i915/display/intel_frontbuffer.c| 17 +
  .../gpu/drm/i915/display/intel_frontbuffer.h| 12 ++--
  drivers/gpu/drm/i915/display/intel_psr.c|  1 +
  .../gpu/drm/i915/display/skl_universal_plane.c  |  2 ++
  8 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index f2918bb07107..a4a57aa24422 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -133,7 +133,11 @@ struct intel_fb_view {
  
  struct intel_framebuffer {

struct drm_framebuffer base;
+#ifdef I915
struct intel_frontbuffer *frontbuffer;
+#else
+   atomic_t bits;
+#endif
  
  	/* Params to remap the FB pages and program the plane registers in each view. */

struct intel_fb_view normal_view;
@@ -2074,10 +2078,18 @@ static inline u32 intel_plane_ggtt_offset(const struct 
intel_plane_state *plane_
  #endif
  }
  
+#ifdef I915

  static inline struct intel_frontbuffer *
  to_intel_frontbuffer(struct drm_framebuffer *fb)
  {
return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL;
  }
+#else
+static inline struct intel_framebuffer *
+to_intel_frontbuffer(struct drm_framebuffer *fb)
+{
+   return fb ? to_intel_framebuffer(fb) : NULL;
+}
+#endif
  
  #endif /*  __INTEL_DISPLAY_TYPES_H__ */

diff --git a/drivers/gpu/drm/i915/display/intel_drrs.c 
b/drivers/gpu/drm/i915/display/intel_drrs.c
index 5b9e3814..3503d112387d 100644
--- a/drivers/gpu/drm/i915/display/intel_drrs.c
+++ b/drivers/gpu/drm/i915/display/intel_drrs.c
@@ -9,6 +9,7 @@
  #include "intel_de.h"
  #include "intel_display_types.h"
  #include "intel_drrs.h"
+#include "intel_frontbuffer.h"
  #include "intel_panel.h"
  
  /**

diff --git a/drivers/gpu/drm/i915/display/intel_fb.c 
b/drivers/gpu/drm/i915/display/intel_fb.c
index 8c357a4098f6..e67c71f9b29d 100644
--- a/drivers/gpu/drm/i915/display/intel_fb.c
+++ b/drivers/gpu/drm/i915/display/intel_fb.c
@@ -1846,6 +1846,8 @@ static void intel_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
  #ifdef I915
if (intel_fb_uses_dpt(fb))
intel_dpt_destroy(intel_fb->dpt_vm);
+
+   intel_frontbuffer_put(intel_fb->frontbuffer);
  #else
if (intel_fb_obj(fb)->flags & XE_BO_CREATE_PINNED_BIT) {
struct xe_bo *bo = intel_fb_obj(fb);
@@ -1857,8 +1859,6 @@ static void intel_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
}
  #endif
  
-	intel_frontbuffer_put(intel_fb->frontbuffer);

-
kfree(intel_fb);
  }
  
@@ -1966,9 +1966,9 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,

obj->flags |= XE_BO_SCANOUT_BIT;
}
ttm_bo_unreserve(>ttm);
-#endif
  
  	atomic_set(_fb->bits, 0);

+#endif
  
  	if (!drm_any_plane_has_format(_priv->drm,

  mode_cmd->pixel_format,
@@ -2085,7 +2085,9 @@ int intel_framebuffer_init(struct intel_framebuffer 
*intel_fb,
return 0;
  
  err:

+#ifdef I915
intel_frontbuffer_put(intel_fb->frontbuffer);
+#endif
return ret;
  }
  
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c

index 75d8029185f0..2682b26b511f 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -82,7 +82,7 @@ struct intel_fbdev {
  
  static struct intel_frontbuffer *to_frontbuffer(struct intel_fbdev *ifbdev)

  {
-   return ifbdev->fb->frontbuffer;
+   return to_intel_frontbuffer(>fb->base);
  }
  
  static void intel_fbdev_invalidate(struct intel_fbdev *ifbdev)

diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c 
b/drivers/gpu/drm/i915/display/intel_frontbuffer.c
index 17a7aa8b28c2..64fe73d2ac4d 100644
--- 

Re: [PATCH v2 RESEND] drm/amdgpu: register a vga_switcheroo client for MacBooks with apple-gmux

2023-03-06 Thread Alex Deucher
Applied.  Thanks!

Alex

On Fri, Mar 3, 2023 at 6:35 AM Orlando Chamberlain
 wrote:
>
> Commit 3840c5bcc245 ("drm/amdgpu: disentangle runtime pm and
> vga_switcheroo") made amdgpu only register a vga_switcheroo client for
> GPU's with PX, however AMD GPUs in dual gpu Apple Macbooks do need to
> register, but don't have PX. Instead of AMD's PX, they use apple-gmux.
>
> Use apple_gmux_detect() to identify these gpus, and
> pci_is_thunderbolt_attached() to ensure eGPUs connected to Dual GPU
> Macbooks don't register with vga_switcheroo.
>
> Fixes: 3840c5bcc245 ("drm/amdgpu: disentangle runtime pm and vga_switcheroo")
> Link: 
> https://lore.kernel.org/amd-gfx/20230210044826.9834-10-orlandoch@gmail.com/
> Signed-off-by: Orlando Chamberlain 
> ---
> v1->v2: Use apple_gmux_detect()
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 -
>  1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 2f28a8c02f64..ef8b996f0622 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -35,6 +35,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include 
>  #include 
> @@ -3919,12 +3920,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,
> if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
> vga_client_register(adev->pdev, amdgpu_device_vga_set_decode);
>
> -   if (amdgpu_device_supports_px(ddev)) {
> -   px = true;
> +   px = amdgpu_device_supports_px(ddev);
> +
> +   if (px || (!pci_is_thunderbolt_attached(adev->pdev) &&
> +   apple_gmux_detect(NULL, NULL)))
> vga_switcheroo_register_client(adev->pdev,
>_switcheroo_ops, px);
> +
> +   if (px)
> vga_switcheroo_init_domain_pm_ops(adev->dev, 
> >vga_pm_domain);
> -   }
>
> if (adev->gmc.xgmi.pending_reset)
> queue_delayed_work(system_wq, _info.delayed_reset_work,
> @@ -4029,6 +4033,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
>  void amdgpu_device_fini_sw(struct amdgpu_device *adev)
>  {
> int idx;
> +   bool px;
>
> amdgpu_fence_driver_sw_fini(adev);
> amdgpu_device_ip_fini(adev);
> @@ -4048,10 +4053,16 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
>
> kfree(adev->bios);
> adev->bios = NULL;
> -   if (amdgpu_device_supports_px(adev_to_drm(adev))) {
> +
> +   px = amdgpu_device_supports_px(adev_to_drm(adev));
> +
> +   if (px || (!pci_is_thunderbolt_attached(adev->pdev) &&
> +   apple_gmux_detect(NULL, NULL)))
> vga_switcheroo_unregister_client(adev->pdev);
> +
> +   if (px)
> vga_switcheroo_fini_domain_pm_ops(adev->dev);
> -   }
> +
> if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
> vga_client_unregister(adev->pdev);
>
> --
> 2.39.1
>


Re: [PATCH 22/99] fbdev/fsl-diu-fb: Duplicate video-mode option string

2023-03-06 Thread Timur Tabi
On Mon, Mar 6, 2023 at 10:01 AM Thomas Zimmermann  wrote:
>
> Assume that the driver does not own the option string or its substrings
> and hence duplicate the option string for the video mode. The driver only
> parses the option string once as part of module initialization, so use
> a static buffer to store the duplicated mode option. Linux automatically
> frees the memory upon releasing the module.

So after module_init is finished, mode_option_buf[] no longer exists?

> +   static char mode_option_buf[256];
> +   int ret;
> +
> +   ret = snprintf(mode_option_buf, 
> sizeof(mode_option_buf), "%s", opt);
> +   if (WARN(ret < 0, "fsl-diu-fb: ignoring invalid 
> option, ret=%d\n", ret))
> +   continue;
> +   if (WARN(ret >= sizeof(mode_option_buf), "fsl-diu-fb: 
> option too long\n"))
> +   continue;
> +   fb_mode = mode_option_buf;

If so, then I'm not sure that's going to work.  fb_mode is used after
module_init, in install_fb(), which is called by fsl_diu_probe().


[PATCH v3] dt-bindings: display: mediatek: Fix the duplicated fallback

2023-03-06 Thread Alexandre Mergnat
The item which have the mediatek,mt8192-disp-ccorr const compatible already
exist above. Remove duplicated fallback.

Fixes: 137272ef1b0f ("dt-bindings: display: mediatek: Fix the fallback for 
mediatek,mt8186-disp-ccorr")
Signed-off-by: Alexandre Mergnat 
---
Fix MTK color correction binding

The fallback compatible has been duplicated in the 137272ef1b0f commit.

To: Chun-Kuang Hu 
To: Philipp Zabel 
To: David Airlie 
To: Daniel Vetter 
To: Rob Herring 
To: Krzysztof Kozlowski 
To: Matthias Brugger 
To: AngeloGioacchino Del Regno 
To: Allen-KH Cheng 
Cc: Rob Herring 
Cc: dri-devel@lists.freedesktop.org
Cc: linux-media...@lists.infradead.org
Cc: devicet...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
---
Changes in v3:
- Re-order compatible.
- Link to v2: 
https://lore.kernel.org/r/20230306-ccorr-binding-fix-v2-0-4822939a8...@baylibre.com

Changes in v2:
- Fix commit title.
- Link to v1: 
https://lore.kernel.org/r/20230306-ccorr-binding-fix-v1-0-177d81d60...@baylibre.com
---
 .../devicetree/bindings/display/mediatek/mediatek,ccorr.yaml | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml 
b/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
index b04820c95b22..bda86e6857f5 100644
--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
@@ -27,13 +27,10 @@ properties:
   - const: mediatek,mt8192-disp-ccorr
   - items:
   - enum:
+  - mediatek,mt8186-disp-ccorr
   - mediatek,mt8188-disp-ccorr
   - mediatek,mt8195-disp-ccorr
   - const: mediatek,mt8192-disp-ccorr
-  - items:
-  - enum:
-  - mediatek,mt8186-disp-ccorr
-  - const: mediatek,mt8192-disp-ccorr
 
   reg:
 maxItems: 1

---
base-commit: add072536971d7ce891fde3cdbf68c55e7cfa95a
change-id: 20230306-ccorr-binding-fix-718c6d725088

Best regards,
-- 
Alexandre Mergnat 


[PATCH] Fixes dt-bindings: display: mediatek: Fix the fallback for mediatek,mt8186-disp-ccorr

2023-03-06 Thread Alexandre Mergnat
The item which have the mediatek,mt8192-disp-ccorr const compatible already
exist above. Remove duplicated fallback.

Fixes: 137272ef1b0f ("dt-bindings: display: mediatek: Fix the fallback for 
mediatek,mt8186-disp-ccorr")

Signed-off-by: Alexandre Mergnat 
---
Fix MTK color correction binding

The fallback compatible has been duplicated in the 137272ef1b0f commit.

To: Chun-Kuang Hu 
To: Philipp Zabel 
To: David Airlie 
To: Daniel Vetter 
To: Rob Herring 
To: Krzysztof Kozlowski 
To: Matthias Brugger 
To: AngeloGioacchino Del Regno 
To: Allen-KH Cheng 
Cc: Rob Herring 
Cc: dri-devel@lists.freedesktop.org
Cc: linux-media...@lists.infradead.org
Cc: devicet...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
---
 Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml | 3 ---
 1 file changed, 3 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml 
b/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
index b04820c95b22..3aaf44719786 100644
--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
@@ -29,9 +29,6 @@ properties:
   - enum:
   - mediatek,mt8188-disp-ccorr
   - mediatek,mt8195-disp-ccorr
-  - const: mediatek,mt8192-disp-ccorr
-  - items:
-  - enum:
   - mediatek,mt8186-disp-ccorr
   - const: mediatek,mt8192-disp-ccorr
 

---
base-commit: add072536971d7ce891fde3cdbf68c55e7cfa95a
change-id: 20230306-ccorr-binding-fix-718c6d725088

Best regards,
-- 
Alexandre Mergnat 


[PATCH] drm/amd/display: remove an unnecessary NULL check

2023-03-06 Thread Danila Chernetsov
The 'pipe' can't be NULL because it points to an element of array.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixed: 7cf2c840c6b5 (drm/amd/display: Commit validation set from state)
Signed-off-by: Danila Chernetsov 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 0cb8d1f934d1..d3b850372eb3 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1854,7 +1854,7 @@ static enum dc_status dc_commit_state_no_check(struct dc 
*dc, struct dc_state *c
for (k = 0; k < MAX_PIPES; k++) {
pipe = >res_ctx.pipe_ctx[k];
 
-   for (l = 0 ; pipe && l < context->stream_count; l++)  {
+   for (l = 0 ; l < context->stream_count; l++)  {
if (context->streams[l] &&
context->streams[l] == pipe->stream &&
dc->hwss.setup_stereo)
-- 
2.25.1



[regression] RPI4B drm vc4: no crtc or sizes since 5.17 (works in 5.16; and still broken in at least 6.1)

2023-03-06 Thread AL13N

Hi,

I have a RPI4B connected on 2nd HDMI port (furthest away from power) to 
a 4K TV, which works until 5.16, from 5.17 there is no X (or plymouth), 
the cause of no X is that EDID gives nothing, and in the journal; there 
is "Cannot find any crct or sizes". Only the kernel is changed for this.


In 5.16 instead of this message there is a bunch of hex lines prefixed 
with BAD.


It is still broken in 6.1 at the very least.

I donno if this is related to this part, but I wanted to try a newer 
kernel, because the RPI4 seems to do all the video decoding in software 
and cannot seem to handle it.



logs:
vc4-drm gpu: bound fef05700.hdmi (ops vc4_hdmi_ops [vc4])
vc4-drm gpu: bound fe004000.txp (ops vc4_txp_ops [vc4])
vc4-drm gpu: bound fe206000.pixelvalve (ops vc4_crtc_ops [vc4])
vc4-drm gpu: bound fe207000.pixelvalve (ops vc4_crtc_ops [vc4])
vc4-drm gpu: bound fe20a000.pixelvalve (ops vc4_crtc_ops [vc4])
vc4-drm gpu: bound fe216000.pixelvalve (ops vc4_crtc_ops [vc4])
vc4-drm gpu: bound fec12000.pixelvalve (ops vc4_crtc_ops [vc4])
checking generic (3ea81000 12c000) vs hw (0 )
fb0: switching to vc4 from simple
Console: switching to colour dummy device 80x25
[drm] Initialized vc4 0.0.0 20140616 for gpu on minor 0
vc4-drm gpu: [drm] Cannot find any crtc or sizes


[PATCH v2] dt-bindings: display: mediatek: Fix the duplicated fallback

2023-03-06 Thread Alexandre Mergnat
The item which have the mediatek,mt8192-disp-ccorr const compatible already
exist above. Remove duplicated fallback.

Fixes: 137272ef1b0f ("dt-bindings: display: mediatek: Fix the fallback for 
mediatek,mt8186-disp-ccorr")
Signed-off-by: Alexandre Mergnat 
---
Fix MTK color correction binding

The fallback compatible has been duplicated in the 137272ef1b0f commit.

To: Chun-Kuang Hu 
To: Philipp Zabel 
To: David Airlie 
To: Daniel Vetter 
To: Rob Herring 
To: Krzysztof Kozlowski 
To: Matthias Brugger 
To: AngeloGioacchino Del Regno 
To: Allen-KH Cheng 
Cc: Rob Herring 
Cc: dri-devel@lists.freedesktop.org
Cc: linux-media...@lists.infradead.org
Cc: devicet...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
---
Changes in v2:
- Fix commit title.
- Link to v1: 
https://lore.kernel.org/r/20230306-ccorr-binding-fix-v1-0-177d81d60...@baylibre.com
---
 Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml | 3 ---
 1 file changed, 3 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml 
b/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
index b04820c95b22..3aaf44719786 100644
--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,ccorr.yaml
@@ -29,9 +29,6 @@ properties:
   - enum:
   - mediatek,mt8188-disp-ccorr
   - mediatek,mt8195-disp-ccorr
-  - const: mediatek,mt8192-disp-ccorr
-  - items:
-  - enum:
   - mediatek,mt8186-disp-ccorr
   - const: mediatek,mt8192-disp-ccorr
 

---
base-commit: add072536971d7ce891fde3cdbf68c55e7cfa95a
change-id: 20230306-ccorr-binding-fix-718c6d725088

Best regards,
-- 
Alexandre Mergnat 


Re: [PATCH 29/99] fbdev/grvga: Parse option string with struct option_iter

2023-03-06 Thread kernel test robot
Hi Thomas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on staging/staging-testing staging/staging-next 
staging/staging-linus linus/master v6.3-rc1 next-20230306]
[cannot apply to deller-parisc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:
https://lore.kernel.org/r/20230306160016.4459-30-tzimmermann%40suse.de
patch subject: [PATCH 29/99] fbdev/grvga: Parse option string with struct 
option_iter
config: sparc-allyesconfig 
(https://download.01.org/0day-ci/archive/20230307/202303070324.h15vdbvs-...@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/0d11862a5c27c6992c00d209c68a7c014f27165a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
git checkout 0d11862a5c27c6992c00d209c68a7c014f27165a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=sparc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=sparc SHELL=/bin/bash drivers/video/fbdev/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202303070324.h15vdbvs-...@intel.com/

All warnings (new ones prefixed by >>):

   drivers/video/fbdev/grvga.c: In function 'grvga_probe':
>> drivers/video/fbdev/grvga.c:363:48: warning: passing argument 1 of 
>> 'grvga_parse_custom' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
 363 | if (grvga_parse_custom(this_opt, >var) 
< 0) {
 |^~~~
   drivers/video/fbdev/grvga.c:266:37: note: expected 'char *' but argument is 
of type 'const char *'
 266 | static int grvga_parse_custom(char *options,
 |   ~~^~~


vim +363 drivers/video/fbdev/grvga.c

a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 327  
48c68c4f1b5424 drivers/video/grvga.c   Greg Kroah-Hartman2012-12-21 
 328  static int grvga_probe(struct platform_device *dev)
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 329  {
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 330struct fb_info *info;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 331int retval = -ENOMEM;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 332unsigned long virtual_start;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 333unsigned long grvga_fix_addr = 0;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 334unsigned long physical_start = 0;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 335unsigned long grvga_mem_size = 0;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 336struct grvga_par *par = NULL;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 337char *options = NULL, *mode_opt = NULL;
0d11862a5c27c6 drivers/video/fbdev/grvga.c Thomas Zimmermann 2023-03-06 
 338struct option_iter iter;
0d11862a5c27c6 drivers/video/fbdev/grvga.c Thomas Zimmermann 2023-03-06 
 339const char *this_opt;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 340  
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 341info = framebuffer_alloc(sizeof(struct grvga_par), >dev);
0adcdbcb179624 drivers/video/fbdev/grvga.c Bartlomiej Zolnierkiewicz 2019-06-28 
 342if (!info)
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 343return -ENOMEM;
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 344  
a4b8f97a8fdeb9 drivers/video/grvga.c   Kristoffer Glembo 2011-07-05 
 345/* Expecting: "grvga: modestring, [addr:], [size:]
a4b8f97a8fdeb9 drivers/video/grvga.c   

Re: [PATCH] drm/amd/display: change several dcn30 variables storage-class-specifier to static

2023-03-06 Thread Alex Deucher
Applied.  Thanks!

Alex

On Sun, Mar 5, 2023 at 7:52 AM Tom Rix  wrote:
>
> smatch reports these similar problems in dcn30
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_dwb.c:223:25:
>   warning: symbol 'dcn30_dwbc_funcs' was not declared. Should it be static?
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_mmhubbub.c:214:28:
>   warning: symbol 'dcn30_mmhubbub_funcs' was not declared. Should it be 
> static?
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_mpc.c:1402:24:
>   warning: symbol 'dcn30_mpc_funcs' was not declared. Should it be static?
>
> All of these are only used in their definition file, so they should be static
>
> Signed-off-by: Tom Rix 
> ---
>  drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb.c  | 2 +-
>  drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mmhubbub.c | 2 +-
>  drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c  | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb.c 
> b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb.c
> index f14f69616692..0d98918bf0fc 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb.c
> @@ -220,7 +220,7 @@ void dwb3_set_denorm(struct dwbc *dwbc, struct 
> dc_dwb_params *params)
>  }
>
>
> -const struct dwbc_funcs dcn30_dwbc_funcs = {
> +static const struct dwbc_funcs dcn30_dwbc_funcs = {
> .get_caps   = dwb3_get_caps,
> .enable = dwb3_enable,
> .disable= dwb3_disable,
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mmhubbub.c 
> b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mmhubbub.c
> index 7a93eff183d9..6f2a0d5d963b 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mmhubbub.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mmhubbub.c
> @@ -211,7 +211,7 @@ static void mmhubbub3_config_mcif_arb(struct mcif_wb 
> *mcif_wb,
> REG_UPDATE(MCIF_WB_ARBITRATION_CONTROL, 
> MCIF_WB_CLIENT_ARBITRATION_SLICE,  params->arbitration_slice);
>  }
>
> -const struct mcif_wb_funcs dcn30_mmhubbub_funcs = {
> +static const struct mcif_wb_funcs dcn30_mmhubbub_funcs = {
> .warmup_mcif= mmhubbub3_warmup_mcif,
> .enable_mcif= mmhubbub2_enable_mcif,
> .disable_mcif   = mmhubbub2_disable_mcif,
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c 
> b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c
> index ad1c1b703874..6cf40c1332bc 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c
> @@ -1399,7 +1399,7 @@ static void mpc3_set_mpc_mem_lp_mode(struct mpc *mpc)
> }
>  }
>
> -const struct mpc_funcs dcn30_mpc_funcs = {
> +static const struct mpc_funcs dcn30_mpc_funcs = {
> .read_mpcc_state = mpc1_read_mpcc_state,
> .insert_plane = mpc1_insert_plane,
> .remove_mpcc = mpc1_remove_mpcc,
> --
> 2.27.0
>


Re: [PATCH] drm/amd/display: change several dcn20 variables storage-class-specifier to static

2023-03-06 Thread Alex Deucher
Applied.  Thanks!

Alex

On Sat, Mar 4, 2023 at 11:22 AM Tom Rix  wrote:
>
> smatch reports these similar problems in dcn20
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_dsc.c:53:24:
>   warning: symbol 'dcn20_dsc_funcs' was not declared. Should it be static?
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_dwb.c:304:25:
>   warning: symbol 'dcn20_dwbc_funcs' was not declared. Should it be static?
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_mmhubbub.c:300:28:
>   warning: symbol 'dcn20_mmhubbub_funcs' was not declared. Should it be 
> static?
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_mpc.c:545:24:
>   warning: symbol 'dcn20_mpc_funcs' was not declared. Should it be static?
>
> All of these are only used in their definition file, so they should be static
>
> Signed-off-by: Tom Rix 
> ---
>  drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c  | 2 +-
>  drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb.c  | 2 +-
>  drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mmhubbub.c | 2 +-
>  drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c  | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c 
> b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c
> index 42344aec60d6..5bd698cd6d20 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c
> @@ -50,7 +50,7 @@ static void dsc2_enable(struct display_stream_compressor 
> *dsc, int opp_pipe);
>  static void dsc2_disable(struct display_stream_compressor *dsc);
>  static void dsc2_disconnect(struct display_stream_compressor *dsc);
>
> -const struct dsc_funcs dcn20_dsc_funcs = {
> +static const struct dsc_funcs dcn20_dsc_funcs = {
> .dsc_get_enc_caps = dsc2_get_enc_caps,
> .dsc_read_state = dsc2_read_state,
> .dsc_validate_stream = dsc2_validate_stream,
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb.c 
> b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb.c
> index f1490e97b6ce..f8667be57046 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb.c
> @@ -301,7 +301,7 @@ void dwb2_set_scaler(struct dwbc *dwbc, struct 
> dc_dwb_params *params)
>
>  }
>
> -const struct dwbc_funcs dcn20_dwbc_funcs = {
> +static const struct dwbc_funcs dcn20_dwbc_funcs = {
> .get_caps   = dwb2_get_caps,
> .enable = dwb2_enable,
> .disable= dwb2_disable,
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mmhubbub.c 
> b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mmhubbub.c
> index ccd91792991b..259a98e4ee2c 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mmhubbub.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mmhubbub.c
> @@ -297,7 +297,7 @@ void mcifwb2_dump_frame(struct mcif_wb *mcif_wb,
> dump_info->size = dest_height * (mcif_params->luma_pitch + 
> mcif_params->chroma_pitch);
>  }
>
> -const struct mcif_wb_funcs dcn20_mmhubbub_funcs = {
> +static const struct mcif_wb_funcs dcn20_mmhubbub_funcs = {
> .enable_mcif= mmhubbub2_enable_mcif,
> .disable_mcif   = mmhubbub2_disable_mcif,
> .config_mcif_buf= mmhubbub2_config_mcif_buf,
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c 
> b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c
> index 116f67a0b989..5da6e44f284a 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c
> @@ -542,7 +542,7 @@ static struct mpcc *mpc2_get_mpcc_for_dpp(struct mpc_tree 
> *tree, int dpp_id)
> return NULL;
>  }
>
> -const struct mpc_funcs dcn20_mpc_funcs = {
> +static const struct mpc_funcs dcn20_mpc_funcs = {
> .read_mpcc_state = mpc1_read_mpcc_state,
> .insert_plane = mpc1_insert_plane,
> .remove_mpcc = mpc1_remove_mpcc,
> --
> 2.27.0
>


Re: [PATCH] drm/amd/display: change several dcn201 variables storage-class-specifier to static

2023-03-06 Thread Alex Deucher
Applied.  Thanks!

Alex

On Sat, Mar 4, 2023 at 10:26 AM Tom Rix  wrote:
>
> smatch reports these similar problems in dcn201
> drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c:165:22:
>   warning: symbol 'dcn201_funcs' was not declared. Should it be static?
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_resource.c:77:30:
>   warning: symbol 'dcn201_ip' was not declared. Should it be static?
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_resource.c:139:37:
>   warning: symbol 'dcn201_soc' was not declared. Should it be static?
> drivers/gpu/drm/amd/amdgpu/../display/dc/dcn201/dcn201_mpc.c:79:24:
>   warning: symbol 'dcn201_mpc_funcs' was not declared. Should it be static?
>
> All of these are only used in their definition file, so they should be static
>
> Signed-off-by: Tom Rix 
> ---
>  .../gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c| 2 +-
>  drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.c| 2 +-
>  drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c   | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c 
> b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c
> index f0577dcd1af6..811720749faf 100644
> --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c
> +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn201/dcn201_clk_mgr.c
> @@ -162,7 +162,7 @@ static void dcn201_update_clocks(struct clk_mgr 
> *clk_mgr_base,
> }
>  }
>
> -struct clk_mgr_funcs dcn201_funcs = {
> +static struct clk_mgr_funcs dcn201_funcs = {
> .get_dp_ref_clk_frequency = dce12_get_dp_ref_freq_khz,
> .update_clocks = dcn201_update_clocks,
> .init_clocks = dcn201_init_clocks,
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.c 
> b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.c
> index 95c4c55f067c..1af03a86ec9b 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_mpc.c
> @@ -76,7 +76,7 @@ static void mpc201_init_mpcc(struct mpcc *mpcc, int 
> mpcc_inst)
> mpcc->shared_bottom = false;
>  }
>
> -const struct mpc_funcs dcn201_mpc_funcs = {
> +static const struct mpc_funcs dcn201_mpc_funcs = {
> .read_mpcc_state = mpc1_read_mpcc_state,
> .insert_plane = mpc1_insert_plane,
> .remove_mpcc = mpc1_remove_mpcc,
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c 
> b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
> index 407d995bfa99..cd46701398d9 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
> @@ -74,7 +74,7 @@
>  #define MIN_DISP_CLK_KHZ 10
>  #define MIN_DPP_CLK_KHZ 10
>
> -struct _vcs_dpi_ip_params_st dcn201_ip = {
> +static struct _vcs_dpi_ip_params_st dcn201_ip = {
> .gpuvm_enable = 0,
> .hostvm_enable = 0,
> .gpuvm_max_page_table_levels = 4,
> @@ -136,7 +136,7 @@ struct _vcs_dpi_ip_params_st dcn201_ip = {
> .number_of_cursors = 1,
>  };
>
> -struct _vcs_dpi_soc_bounding_box_st dcn201_soc = {
> +static struct _vcs_dpi_soc_bounding_box_st dcn201_soc = {
> .clock_limits = {
> {
> .state = 0,
> --
> 2.27.0
>


Re: [Intel-xe] [PATCH] drm/xe/display: Do not use i915 frontbuffer tracking implementation

2023-03-06 Thread Rodrigo Vivi
On Mon, Mar 06, 2023 at 03:23:08PM +, Souza, Jose wrote:
> On Mon, 2023-03-06 at 15:16 +0100, Maarten Lankhorst wrote:
> > As a fallback if we decide not to merge the frontbuffer tracking, allow
> > i915 to keep its own implementation, and do the right thing in Xe.
> > 
> > The frontbuffer tracking for Xe is still done per-fb, while i915 can
> > keep doing the weird intel_frontbuffer + i915_active thing without
> > blocking Xe.
> 
> Please also disable PSR and FBC with this or at least add a way for users to 
> disable those features.
> Without frontbuffer tracker those two features will break in some cases.

I'm afraid we cannot have this solution then. We will need FBC and PSR.
Should we then add a new IOCTL where userspace can request the PSR/FBC,
and then commit to always use the drity_fb calls on any frontbuffer update?

> 
> > 
> > Signed-off-by: Maarten Lankhorst 
> > ---
> >  .../gpu/drm/i915/display/intel_display_types.h  | 12 
> >  drivers/gpu/drm/i915/display/intel_drrs.c   |  1 +
> >  drivers/gpu/drm/i915/display/intel_fb.c |  8 +---
> >  drivers/gpu/drm/i915/display/intel_fbdev.c  |  2 +-
> >  .../gpu/drm/i915/display/intel_frontbuffer.c| 17 +
> >  .../gpu/drm/i915/display/intel_frontbuffer.h| 12 ++--
> >  drivers/gpu/drm/i915/display/intel_psr.c|  1 +
> >  .../gpu/drm/i915/display/skl_universal_plane.c  |  2 ++
> >  8 files changed, 45 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
> > b/drivers/gpu/drm/i915/display/intel_display_types.h
> > index f2918bb07107..a4a57aa24422 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> > @@ -133,7 +133,11 @@ struct intel_fb_view {
> >  
> >  struct intel_framebuffer {
> > struct drm_framebuffer base;
> > +#ifdef I915
> > struct intel_frontbuffer *frontbuffer;
> > +#else
> > +   atomic_t bits;
> > +#endif
> >  
> > /* Params to remap the FB pages and program the plane registers in each 
> > view. */
> > struct intel_fb_view normal_view;
> > @@ -2074,10 +2078,18 @@ static inline u32 intel_plane_ggtt_offset(const 
> > struct intel_plane_state *plane_
> >  #endif
> >  }
> >  
> > +#ifdef I915
> >  static inline struct intel_frontbuffer *
> >  to_intel_frontbuffer(struct drm_framebuffer *fb)
> >  {
> > return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL;
> >  }
> > +#else
> > +static inline struct intel_framebuffer *
> > +to_intel_frontbuffer(struct drm_framebuffer *fb)
> > +{
> > +   return fb ? to_intel_framebuffer(fb) : NULL;
> > +}
> > +#endif
> >  
> >  #endif /*  __INTEL_DISPLAY_TYPES_H__ */
> > diff --git a/drivers/gpu/drm/i915/display/intel_drrs.c 
> > b/drivers/gpu/drm/i915/display/intel_drrs.c
> > index 5b9e3814..3503d112387d 100644
> > --- a/drivers/gpu/drm/i915/display/intel_drrs.c
> > +++ b/drivers/gpu/drm/i915/display/intel_drrs.c
> > @@ -9,6 +9,7 @@
> >  #include "intel_de.h"
> >  #include "intel_display_types.h"
> >  #include "intel_drrs.h"
> > +#include "intel_frontbuffer.h"
> >  #include "intel_panel.h"
> >  
> >  /**
> > diff --git a/drivers/gpu/drm/i915/display/intel_fb.c 
> > b/drivers/gpu/drm/i915/display/intel_fb.c
> > index 8c357a4098f6..e67c71f9b29d 100644
> > --- a/drivers/gpu/drm/i915/display/intel_fb.c
> > +++ b/drivers/gpu/drm/i915/display/intel_fb.c
> > @@ -1846,6 +1846,8 @@ static void intel_user_framebuffer_destroy(struct 
> > drm_framebuffer *fb)
> >  #ifdef I915
> > if (intel_fb_uses_dpt(fb))
> > intel_dpt_destroy(intel_fb->dpt_vm);
> > +
> > +   intel_frontbuffer_put(intel_fb->frontbuffer);
> >  #else
> > if (intel_fb_obj(fb)->flags & XE_BO_CREATE_PINNED_BIT) {
> > struct xe_bo *bo = intel_fb_obj(fb);
> > @@ -1857,8 +1859,6 @@ static void intel_user_framebuffer_destroy(struct 
> > drm_framebuffer *fb)
> > }
> >  #endif
> >  
> > -   intel_frontbuffer_put(intel_fb->frontbuffer);
> > -
> > kfree(intel_fb);
> >  }
> >  
> > @@ -1966,9 +1966,9 @@ int intel_framebuffer_init(struct intel_framebuffer 
> > *intel_fb,
> > obj->flags |= XE_BO_SCANOUT_BIT;
> > }
> > ttm_bo_unreserve(>ttm);
> > -#endif
> >  
> > atomic_set(_fb->bits, 0);
> > +#endif
> >  
> > if (!drm_any_plane_has_format(_priv->drm,
> >   mode_cmd->pixel_format,
> > @@ -2085,7 +2085,9 @@ int intel_framebuffer_init(struct intel_framebuffer 
> > *intel_fb,
> > return 0;
> >  
> >  err:
> > +#ifdef I915
> > intel_frontbuffer_put(intel_fb->frontbuffer);
> > +#endif
> > return ret;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
> > b/drivers/gpu/drm/i915/display/intel_fbdev.c
> > index 75d8029185f0..2682b26b511f 100644
> > --- a/drivers/gpu/drm/i915/display/intel_fbdev.c
> > +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
> > @@ -82,7 +82,7 @@ struct intel_fbdev {
> >  
> >  static struct 

Re: IMX8MM: assign panel to mipi_dsi in a device tree

2023-03-06 Thread Patrick Boettcher
On Mon, 6 Mar 2023 09:43:22 +0100
Frieder Schrempf  wrote:
>This is the NXP vendor kernel which differs a lot from mainline,
>especially in the graphics/display area. You probably won't get much
>support from this list as most people here (including me) would advise
>against using the vendor kernel at all.

Understandable, I did the same at the time when I was working in media
and DVB was still a thing.

>Probably they are working and probably you can get your setup working,
>too, somehow. But you would need to ask for help in the NXP community
>or elsewhere. The other option is to switch to mainline (recommended)
>and use Jagan's patches for DSIM support that are about to be
>upstreamed.

Thanks for your feedback. Unfortunately my client wants to stick with
the vendor kernel, so my only chance is to see whether it works with
upstream mainline and if so, at least I know the hardware is OK.

Why oh why do we have vendor kernels? In small-system's Linux there
sooo many vendor kernels. Very hard to understand. It's 2023.

The answers to a similar problem I found in the NXP community board
was: go look at the driver source and see what's wrong.

Thanks again for your answers.

best regards,
--
Patrick.



Re: [PATCH] dt-bindings: yamllint: Require a space after a comment '#'

2023-03-06 Thread Stephen Boyd
Quoting Rob Herring (2023-03-03 13:42:23)
> Enable yamllint to check the prefered commenting style of requiring a
> space after a comment character '#'. Fix the cases in the tree which
> have a warning with this enabled. Most cases just need a space after the
> '#'. A couple of cases with comments which were not intended to be
> comments are revealed. Those were in ti,sa2ul.yaml, ti,cal.yaml, and
> brcm,bcmgenet.yaml.
> 
> Signed-off-by: Rob Herring 

Reviewed-by: Stephen Boyd 

> diff --git a/Documentation/devicetree/bindings/clock/qcom,a53pll.yaml 
> b/Documentation/devicetree/bindings/clock/qcom,a53pll.yaml
> index 525ebaa93c85..64bfd0f5d4d0 100644
> --- a/Documentation/devicetree/bindings/clock/qcom,a53pll.yaml
> +++ b/Documentation/devicetree/bindings/clock/qcom,a53pll.yaml
> @@ -45,14 +45,14 @@ required:
>  additionalProperties: false
>  
>  examples:
> -  #Example 1 - A53 PLL found on MSM8916 devices
> +  # Example 1 - A53 PLL found on MSM8916 devices
>- |
>  a53pll: clock@b016000 {
>  compatible = "qcom,msm8916-a53pll";
>  reg = <0xb016000 0x40>;
>  #clock-cells = <0>;
>  };
> -  #Example 2 - A53 PLL found on IPQ6018 devices
> +  # Example 2 - A53 PLL found on IPQ6018 devices
>- |
>  a53pll_ipq: clock-controller@b116000 {
>  compatible = "qcom,ipq6018-a53pll";


Re: [PATCH 10/99] fbdev/atafb: Parse option string with struct option_iter

2023-03-06 Thread kernel test robot
Hi Thomas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on staging/staging-testing staging/staging-next 
staging/staging-linus linus/master v6.3-rc1 next-20230306]
[cannot apply to deller-parisc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:
https://lore.kernel.org/r/20230306160016.4459-11-tzimmermann%40suse.de
patch subject: [PATCH 10/99] fbdev/atafb: Parse option string with struct 
option_iter
config: m68k-allyesconfig 
(https://download.01.org/0day-ci/archive/20230307/202303070232.fcaufe3z-...@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/c5b52a9aafa2bf0107e27c7c2aa66bee9a449521
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
git checkout c5b52a9aafa2bf0107e27c7c2aa66bee9a449521
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=m68k SHELL=/bin/bash drivers/video/fbdev/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202303070232.fcaufe3z-...@intel.com/

All warnings (new ones prefixed by >>):

   drivers/video/fbdev/atafb.c: In function 'ext_setcolreg':
   drivers/video/fbdev/atafb.c:2187:31: warning: variable 'tmp' set but not 
used [-Wunused-but-set-variable]
2187 | unsigned char tmp = INB(0x3da); \
 |   ^~~
   drivers/video/fbdev/atafb.c:2210:17: note: in expansion of macro 'DACDelay'
2210 | DACDelay;
 | ^~~~
   drivers/video/fbdev/atafb.c:2187:31: warning: variable 'tmp' set but not 
used [-Wunused-but-set-variable]
2187 | unsigned char tmp = INB(0x3da); \
 |   ^~~
   drivers/video/fbdev/atafb.c:2212:17: note: in expansion of macro 'DACDelay'
2212 | DACDelay;
 | ^~~~
   drivers/video/fbdev/atafb.c:2187:31: warning: variable 'tmp' set but not 
used [-Wunused-but-set-variable]
2187 | unsigned char tmp = INB(0x3da); \
 |   ^~~
   drivers/video/fbdev/atafb.c:2214:17: note: in expansion of macro 'DACDelay'
2214 | DACDelay;
 | ^~~~
   drivers/video/fbdev/atafb.c:2187:31: warning: variable 'tmp' set but not 
used [-Wunused-but-set-variable]
2187 | unsigned char tmp = INB(0x3da); \
 |   ^~~
   drivers/video/fbdev/atafb.c:2216:17: note: in expansion of macro 'DACDelay'
2216 | DACDelay;
 | ^~~~
   drivers/video/fbdev/atafb.c: In function 'atafb_copyarea':
   drivers/video/fbdev/atafb.c:2464:13: warning: variable 'rev_copy' set but 
not used [-Wunused-but-set-variable]
2464 | int rev_copy = 0;
 | ^~~~
   drivers/video/fbdev/atafb.c: In function 'atafb_setup':
>> drivers/video/fbdev/atafb.c:2948:44: warning: passing argument 1 of 
>> 'get_video_mode' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
2948 | if ((temp = get_video_mode(this_opt))) {
 |^~~~
   drivers/video/fbdev/atafb.c:529:33: note: expected 'char *' but argument is 
of type 'const char *'
 529 | static int get_video_mode(char *vname)
 |   ~~^
>> drivers/video/fbdev/atafb.c:2973:50: warning: passing argument 1 of 
>> 'atafb_setup_ext' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
2973 | atafb_setup_ext(this_opt + 9);
 | ~^~~
   drivers/video/fbdev/atafb.c:2720:42: note: expected 'char *' but argument is 
of type 'const char *'
2720 | static void __init atafb_setup_ext(char *spec)
 |~~^~

Re: [PATCH v6 32/57] nouveau: adapt NV_DEBUG, NV_ATOMIC to use DRM.debug

2023-03-06 Thread Timur Tabi
On Sun, Sep 4, 2022 at 4:48 PM Jim Cromie  wrote:
>
> These 2 macros used drm_debug_enabled() on DRM_UT_{DRIVER,ATOMIC}
> respectively, replace those with drm_dbg_##cat invocations.
>
> this results in new class'd prdbg callsites:
>
> :#> grep nouveau /proc/dynamic_debug/control | grep class | wc
> 1161130   15584
> :#> grep nouveau /proc/dynamic_debug/control | grep class | grep DRIVER | wc
>  74 7049709
> :#> grep nouveau /proc/dynamic_debug/control | grep class | grep ATOMIC | wc
>  31 3074237
> :#> grep nouveau /proc/dynamic_debug/control | grep class | grep KMS | wc
>  11 1191638
>
> the KMS entries are due to existing uses of drm_dbg_kms().
>
> Signed-off-by: Jim Cromie 

Has this patch set been forgotten?  It was posted six months ago and
there's no sign that it was picked up.

The changes to drm_debug_enabled have impacted NV_DEBUG and NV_ATOMIC
and something needs to be fixed.  I posted a simpler patch a few weeks
ago, but maybe Jim's is better.


Re: [PATCH 07/99] fbdev/amifb: Parse option string with struct option_iter

2023-03-06 Thread kernel test robot
Hi Thomas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on staging/staging-testing staging/staging-next 
staging/staging-linus linus/master v6.3-rc1 next-20230306]
[cannot apply to deller-parisc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:
https://lore.kernel.org/r/20230306160016.4459-8-tzimmermann%40suse.de
patch subject: [PATCH 07/99] fbdev/amifb: Parse option string with struct 
option_iter
config: m68k-allyesconfig 
(https://download.01.org/0day-ci/archive/20230307/202303070108.gtlwdysm-...@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/0b2c4af3b565e5ee830f7ed8e844d89237938f96
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Thomas-Zimmermann/lib-Add-option-iterator/20230307-000524
git checkout 0b2c4af3b565e5ee830f7ed8e844d89237938f96
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=m68k SHELL=/bin/bash drivers/video/fbdev/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202303070108.gtlwdysm-...@intel.com/

All warnings (new ones prefixed by >>):

   drivers/video/fbdev/amifb.c: In function 'ami_decode_var':
   drivers/video/fbdev/amifb.c:1134:23: warning: variable 'vtotal' set but not 
used [-Wunused-but-set-variable]
1134 | u_int htotal, vtotal;
 |   ^~
   drivers/video/fbdev/amifb.c:1134:15: warning: variable 'htotal' set but not 
used [-Wunused-but-set-variable]
1134 | u_int htotal, vtotal;
 |   ^~
   drivers/video/fbdev/amifb.c: In function 'ami_get_var_cursorinfo':
   drivers/video/fbdev/amifb.c:1855:19: warning: variable 'alloc' set but not 
used [-Wunused-but-set-variable]
1855 | int size, alloc;
 |   ^
   drivers/video/fbdev/amifb.c: In function 'amifb_setup':
>> drivers/video/fbdev/amifb.c:2362:51: warning: passing argument 1 of 
>> 'amifb_setup_mcap' discards 'const' qualifier from pointer target type 
>> [-Wdiscarded-qualifiers]
2362 | amifb_setup_mcap(this_opt + 11);
 |  ~^~~~
   drivers/video/fbdev/amifb.c:2312:43: note: expected 'char *' but argument is 
of type 'const char *'
2312 | static void __init amifb_setup_mcap(char *spec)
 | ~~^~~~


vim +2362 drivers/video/fbdev/amifb.c

f1cbb17ac739932 drivers/video/amifb.c   Geert Uytterhoeven 2011-11-21  2348 
 
0b2c4af3b565e5e drivers/video/fbdev/amifb.c Thomas Zimmermann  2023-03-06  2349 
 static int __init amifb_setup(const char *options)
^1da177e4c3f415 drivers/video/amifb.c   Linus Torvalds 2005-04-16  2350 
 {
0b2c4af3b565e5e drivers/video/fbdev/amifb.c Thomas Zimmermann  2023-03-06  2351 
struct option_iter iter;
0b2c4af3b565e5e drivers/video/fbdev/amifb.c Thomas Zimmermann  2023-03-06  2352 
const char *this_opt;
f1cbb17ac739932 drivers/video/amifb.c   Geert Uytterhoeven 2011-11-21  2353 
 
0b2c4af3b565e5e drivers/video/fbdev/amifb.c Thomas Zimmermann  2023-03-06  2354 
option_iter_init(, options);
f1cbb17ac739932 drivers/video/amifb.c   Geert Uytterhoeven 2011-11-21  2355 
 
0b2c4af3b565e5e drivers/video/fbdev/amifb.c Thomas Zimmermann  2023-03-06  2356 
while (option_iter_next(, this_opt)) {
f1cbb17ac739932 drivers/video/amifb.c   Geert Uytterhoeven 2011-11-21  2357 
if (!strcmp(this_opt, "inverse")) {
f1cbb17ac739932 drivers/video/amifb.c   Geert Uytterhoeven 2011-11-21  2358 
fb_invert_cmaps();
f1cbb17ac739932 drivers/video/amifb.c   Geert Uytterhoeven 2011-11-21  2359 
} else if (!strcmp(this_opt, "ilbm"))
f1cbb17ac739932 drivers/video/amifb.c   Geert Uytterhoeven 2011-11-21  2360 
amifb_ilbm = 1;
f1cbb17ac739932 drivers/video/amifb.c   Geert Uytterhoeven 2011-11-21  2361 
 

Re: [PATCH v3] drm/virtio: Fix handling CONFIG_DRM_VIRTIO_GPU_KMS option

2023-03-06 Thread Dmitry Osipenko
On 3/6/23 19:39, Dmitry Osipenko wrote:
> VirtIO-GPU got a new config option for disabling KMS. There were two
> problems left unnoticed during review when the new option was added:
> 
> 1. The IS_ENABLED(CONFIG_DRM_VIRTIO_GPU_KMS) check in the code was
> inverted, hence KMS was disabled when it should be enabled and vice versa.
> 
> 2. The disabled KMS crashed kernel with a NULL dereference in
> drm_kms_helper_hotplug_event(), which shall not be invoked with a
> disabled KMS.
> 
> Fix the inverted config option check in the code and skip handling the
> VIRTIO_GPU_EVENT_DISPLAY sent by host when KMS is disabled in guest to fix
> the crash.
> 
> Acked-by: Gerd Hoffmann 
> Fixes: 72122c69d717 ("drm/virtio: Add option to disable KMS support")
> Signed-off-by: Dmitry Osipenko 
> ---

Added r-b from Emil and applied to misc-next

-- 
Best regards,
Dmitry



Re: [PATCH v14 00/14] Add PSR support for eDP

2023-03-06 Thread Doug Anderson
Hi,

On Thu, Mar 2, 2023 at 8:33 AM Vinod Polimera  wrote:
>
> Changes in v2:
>   - Use dp bridge to set psr entry/exit instead of dpu_enocder.
>   - Don't modify whitespaces.
>   - Set self refresh aware from atomic_check.
>   - Set self refresh aware only if psr is supported.
>   - Provide a stub for msm_dp_display_set_psr.
>   - Move dp functions to bridge code.
>
> Changes in v3:
>   - Change callback names to reflect atomic interfaces.
>   - Move bridge callback change to separate patch as suggested by Dmitry.
>   - Remove psr function declaration from msm_drv.h.
>   - Set self_refresh_aware flag only if psr is supported.
>   - Modify the variable names to simpler form.
>   - Define bit fields for PSR settings.
>   - Add comments explaining the steps to enter/exit psr.
>   - Change DRM_INFO to drm_dbg_db.
>
> Changes in v4:
>   - Move the get crtc functions to drm_atomic.
>   - Add atomic functions for DP bridge too.
>   - Add ternary operator to choose eDP or DP ops.
>   - Return true/false instead of 1/0.
>   - mode_valid missing in the eDP bridge ops.
>   - Move the functions to get crtc into drm_atomic.c.
>   - Fix compilation issues.
>   - Remove dpu_assign_crtc and get crtc from drm_enc instead of dpu_enc.
>   - Check for crtc state enable while reserving resources.
>
> Changes in v5:
>   - Move the mode_valid changes into a different patch.
>   - Complete psr_op_comp only when isr is set.
>   - Move the DP atomic callback changes to a different patch.
>   - Get crtc from drm connector state crtc.
>   - Move to separate patch for check for crtc state enable while
> reserving resources.
>
> Changes in v6:
>   - Remove crtc from dpu_encoder_virt struct.
>   - fix crtc check during vblank toggle crtc.
>   - Misc changes.
>
> Changes in v7:
>   - Add fix for underrun issue on kasan build.
>
> Changes in v8:
>   - Drop the enc spinlock as it won't serve any purpose in
> protetcing conn state.(Dmitry/Doug)
>
> Changes in v9:
>   - Update commit message and fix alignment using spaces.(Marijn)
>   - Misc changes.(Marijn)
>
> Changes in v10:
>   - Get crtc cached in dpu_enc during obj init.(Dmitry)
>
> Changes in v11:
>   - Remove crtc cached in dpu_enc during obj init.
>   - Update dpu_enc crtc state on crtc enable/disable during self refresh.
>
> Changes in v12:
>   - Update sc7180 intf mask to get intf timing gen status
> based on DPU_INTF_STATUS_SUPPORTED bit.(Dmitry)
>   - Remove "clear active interface in the datapath cleanup" change
> as it is already included.
>
> Changes in v13:
>   - Move core changes to top of the series.(Dmitry)
>   - Drop self refresh aware disable change after psr entry.(Dmitry)
>
> Changes in v14:
>   - Set self_refresh_aware for the PSR to kick in.
>
> Vinod Polimera (14):
>   drm: add helper functions to retrieve old and new crtc
>   drm/bridge: use atomic enable/disable callbacks for panel bridge
>   drm/bridge: add psr support for panel bridge callbacks
>   drm/msm/disp/dpu: check for crtc enable rather than crtc active to
> release shared resources
>   drm/msm/disp/dpu: get timing engine status from intf status register
>   drm/msm/disp/dpu: wait for extra vsync till timing engine status is
> disabled
>   drm/msm/disp/dpu: reset the datapath after timing engine disable
>   drm/msm/dp: use atomic callbacks for DP bridge ops
>   drm/msm/dp: Add basic PSR support for eDP
>   drm/msm/dp: use the eDP bridge ops to validate eDP modes
>   drm/msm/disp/dpu: use atomic enable/disable callbacks for encoder
> functions
>   drm/msm/disp/dpu: add PSR support for eDP interface in dpu driver
>   drm/msm/disp/dpu: update dpu_enc crtc state on crtc enable/disable
> during self refresh
>   drm/msm/dp: set self refresh aware based on psr support
>
>  drivers/gpu/drm/bridge/panel.c |  68 +++-
>  drivers/gpu/drm/drm_atomic.c   |  60 +++
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c   |  40 -
>  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c|  26 +++-
>  .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c   |  22 +++
>  drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c |   3 +-
>  drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h |  12 +-
>  drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c|   8 +-
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c|   2 +-
>  drivers/gpu/drm/msm/dp/dp_catalog.c|  80 ++
>  drivers/gpu/drm/msm/dp/dp_catalog.h|   4 +
>  drivers/gpu/drm/msm/dp/dp_ctrl.c   |  80 ++
>  drivers/gpu/drm/msm/dp/dp_ctrl.h   |   3 +
>  drivers/gpu/drm/msm/dp/dp_display.c|  36 +++--
>  drivers/gpu/drm/msm/dp/dp_display.h|   2 +
>  drivers/gpu/drm/msm/dp/dp_drm.c| 173 
> -
>  drivers/gpu/drm/msm/dp/dp_drm.h|   9 +-
>  drivers/gpu/drm/msm/dp/dp_link.c   |  36 +
>  drivers/gpu/drm/msm/dp/dp_panel.c  

Re: [Intel-gfx] [PATCH 1/3] drm/i915: Set I915_BO_ALLOC_USER for framebuffer

2023-03-06 Thread Ville Syrjälä
On Mon, Mar 06, 2023 at 05:22:19PM +0100, Das, Nirmoy wrote:
> 
> On 3/6/2023 3:21 PM, Ville Syrjälä wrote:
> > On Mon, Mar 06, 2023 at 11:28:48AM +0100, Nirmoy Das wrote:
> >> Framebuffer is exposed to userspace so set I915_BO_ALLOC_USER
> >> flag for it. This also make sure that ttm allocates offset
> >> for lmem objects.
> > I have no idea what that means.
> 
> Sorry for poor explanation.
> 
> Without I915_BO_ALLOC_USER, ttm will assume the obj as kernel buffer and 
> will not allocate fake offset which I needed for fb_mmap callback to work.

So that's the fake vm_pgoff thing? Doesn't that exist just so
mmap() through /dev/dri* can be passed a "gem handle"? 
With fbdev mmap we already know which BO we want to map so
why would any of that stuff even be needed?

> 
> Regards,
> Nirmoy
> 
> >
> >> Signed-off-by: Nirmoy Das 
> >> ---
> >>   drivers/gpu/drm/i915/display/intel_dpt.c   | 4 +++-
> >>   drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++-
> >>   drivers/gpu/drm/i915/display/intel_plane_initial.c | 3 ++-
> >>   3 files changed, 7 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c 
> >> b/drivers/gpu/drm/i915/display/intel_dpt.c
> >> index ad1a37b515fb..2e6238881860 100644
> >> --- a/drivers/gpu/drm/i915/display/intel_dpt.c
> >> +++ b/drivers/gpu/drm/i915/display/intel_dpt.c
> >> @@ -254,7 +254,9 @@ intel_dpt_create(struct intel_framebuffer *fb)
> >>   
> >>size = round_up(size * sizeof(gen8_pte_t), I915_GTT_PAGE_SIZE);
> >>   
> >> -  dpt_obj = i915_gem_object_create_lmem(i915, size, 
> >> I915_BO_ALLOC_CONTIGUOUS);
> >> +  dpt_obj = i915_gem_object_create_lmem(i915, size,
> >> +I915_BO_ALLOC_CONTIGUOUS |
> >> +I915_BO_ALLOC_USER);
> >>if (IS_ERR(dpt_obj) && i915_ggtt_has_aperture(to_gt(i915)->ggtt))
> >>dpt_obj = i915_gem_object_create_stolen(i915, size);
> >>if (IS_ERR(dpt_obj) && !HAS_LMEM(i915)) {
> >> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
> >> b/drivers/gpu/drm/i915/display/intel_fbdev.c
> >> index 3659350061a7..98ae3a3a986a 100644
> >> --- a/drivers/gpu/drm/i915/display/intel_fbdev.c
> >> +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
> >> @@ -163,7 +163,8 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
> >>obj = ERR_PTR(-ENODEV);
> >>if (HAS_LMEM(dev_priv)) {
> >>obj = i915_gem_object_create_lmem(dev_priv, size,
> >> -I915_BO_ALLOC_CONTIGUOUS);
> >> +I915_BO_ALLOC_CONTIGUOUS |
> >> +I915_BO_ALLOC_USER);
> >>} else {
> >>/*
> >> * If the FB is too big, just don't use it since fbdev is not 
> >> very
> >> diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c 
> >> b/drivers/gpu/drm/i915/display/intel_plane_initial.c
> >> index bb6ea7de5c61..4a3680f6a3f5 100644
> >> --- a/drivers/gpu/drm/i915/display/intel_plane_initial.c
> >> +++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c
> >> @@ -110,7 +110,8 @@ initial_plane_vma(struct drm_i915_private *i915,
> >>size * 2 > i915->dsm.usable_size)
> >>return NULL;
> >>   
> >> -  obj = i915_gem_object_create_region_at(mem, phys_base, size, 0);
> >> +  obj = i915_gem_object_create_region_at(mem, phys_base, size,
> >> + I915_BO_ALLOC_USER);
> >>if (IS_ERR(obj))
> >>return NULL;
> >>   
> >> -- 
> >> 2.39.0

-- 
Ville Syrjälä
Intel


Re: [PATCH v15 00/16] drm: Add Samsung MIPI DSIM bridge

2023-03-06 Thread Jagan Teki
Hi Marek,

On Mon, Mar 6, 2023 at 4:32 PM Marek Szyprowski
 wrote:
>
> Hi Jagan,
>
> On 04.03.2023 19:59, Jagan Teki wrote:
> > On Sat, Mar 4, 2023 at 3:56 AM Marek Szyprowski
> >  wrote:
> >> On 03.03.2023 15:51, Jagan Teki wrote:
> >>> This series supports common bridge support for Samsung MIPI DSIM
> >>> which is used in Exynos and i.MX8MM SoC's.
> >>>
> >>> The final bridge supports both the Exynos and i.MX8M Mini/Nano/Plus.
> >>>
> >>> Inki Dae: please note that this series added on top of exynos-drm-next
> >>> since few exynos dsi changes are not been part of drm-misc-next.
> >>> Request you to pick these via exynos-drm-next, or let me know if you
> >>> have any comments?
> >> I gave it a try on Exynos TM2e and unfortunately it nukes again:
> >>
> >> exynos-drm exynos-drm: bound 1397.hdmi (ops hdmi_component_ops)
> >> Unable to handle kernel paging request at virtual address 003d454d414e5675
> >> ...
> >> [003d454d414e5675] address between user and kernel address ranges
> >> Internal error: Oops: 9604 [#1] PREEMPT SMP
> >> Modules linked in:
> >> CPU: 4 PID: 9 Comm: kworker/u16:0 Not tainted 6.2.0-next-20230303+ #13341
> >> Hardware name: Samsung TM2E board (DT)
> >> Workqueue: events_unbound deferred_probe_work_func
> >> pstate: 00c5 (nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> >> pc : drm_connector_list_iter_next+0x58/0x100
> >> lr : drm_connector_list_iter_next+0x2c/0x100
> >> sp : 8bbab910
> >> ...
> >> Call trace:
> >>drm_connector_list_iter_next+0x58/0x100
> >>drm_mode_config_reset+0xfc/0x144
> >>exynos_drm_bind+0x160/0x1b8
> >>try_to_bring_up_aggregate_device+0x168/0x1d4
> >>__component_add+0xa8/0x170
> >>component_add+0x14/0x20
> >>hdmi_probe+0x3fc/0x6d4
> >>platform_probe+0x68/0xd8
> >>really_probe+0x148/0x2b4
> >>__driver_probe_device+0x78/0xe0
> >>driver_probe_device+0xd8/0x160
> >>__device_attach_driver+0xb8/0x138
> >>bus_for_each_drv+0x84/0xe0
> >>__device_attach+0xa8/0x1b0
> >>device_initial_probe+0x14/0x20
> >>bus_probe_device+0xb0/0xb4
> >>deferred_probe_work_func+0x8c/0xc8
> >>process_one_work+0x288/0x6c8
> >>worker_thread+0x24c/0x450
> >>kthread+0x118/0x11c
> >>ret_from_fork+0x10/0x20
> > This looks not related to dsi to me since there is no exynos_drm_dsi
> > call in the trace. look hdmi related. Moreover, I think the exynos dsi
> > worked well on v10 and I couldn't find any potential differences in
> > terms of call flow change.
> > https://gitlab.com/openedev/kernel/-/commits/imx8mm-dsi-v10
>
> Well, the issue is definitely related to this patchset. On Friday, due
> to other kernel messages, I missed the most important part of the log:
>
> [drm] Exynos DRM: using 1380.decon device for DMA mapping operations
> exynos-drm exynos-drm: bound 1380.decon (ops decon_component_ops)
> exynos-drm exynos-drm: bound 1388.decon (ops decon_component_ops)
> exynos-dsi 1390.dsi: [drm:samsung_dsim_host_attach] Attached s6e3hf2
> device
> exynos-dsi 1390.dsi: request interrupt failed with -22
> panel-samsung-s6e3ha2: probe of 1390.dsi.0 failed with error -22
> exynos-drm exynos-drm: bound 1390.dsi (ops exynos_dsi_component_ops)
> exynos-drm exynos-drm: bound 1393.mic (ops exynos_mic_component_ops)
>
> It looks that the are at least 2 issues. The first one related to TE
> interrupt registration, the second is broken error path, which should
> free allocated resources and stop DRM from binding/initialization.
>
> This patch fixes the issue (TE gpio/interrupt is optional!):
>
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c
> b/drivers/gpu/drm/bridge/samsung-dsim.c
> index b4a5348b763c..ed83495fe105 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -1518,7 +1518,9 @@ static int samsung_dsim_register_te_irq(struct
> samsung_dsim *dsi, struct device
>  int ret;
>
>  dsi->te_gpio = devm_gpiod_get_optional(dev, "te", GPIOD_IN);
> -   if (IS_ERR(dsi->te_gpio))
> +   if (!dsi->te_gpio)
> +   return 0;
> +   else if (IS_ERR(dsi->te_gpio))

I think I missed this change from v10 where Marek V commented to move
this in dsim instead of in Exynos. anyway, I will correct this.

>  return dev_err_probe(dev, PTR_ERR(dsi->te_gpio),
> "failed to get te GPIO\n");
>
>  te_gpio_irq = gpiod_to_irq(dsi->te_gpio);
>
>
> The error path in samsung_dsim_host_attach() after
> samsung_dsim_register_te_irq() failure is wrong. It lacks cleaning up
> the allocated resources (removing the bridge, detaing the dsi device).

This is because of the same discussion of moving TE GPIO in dsim instead exynos.

How about register TE GPIO before calling host attach like this,

--- a/drivers/gpu/drm/bridge/samsung-dsim.c
+++ b/drivers/gpu/drm/bridge/samsung-dsim.c
@@ -1598,9 +1598,6 @@ static int samsung_dsim_host_attach(struct
mipi_dsi_host *host,


RE: [PATCH 09/22] drm/kmb: Use GEM DMA fbdev emulation

2023-03-06 Thread Chrisanthus, Anitha
Acked-by: Anitha Chrisanthus 

> -Original Message-
> From: Thomas Zimmermann 
> Sent: Wednesday, March 1, 2023 7:31 AM
> To: javi...@redhat.com; maarten.lankho...@linux.intel.com;
> mrip...@kernel.org; airl...@gmail.com; dan...@ffwll.ch; and...@aj.id.au;
> laurentiu.pa...@oss.nxp.com; l.st...@pengutronix.de;
> shawn...@kernel.org; s.ha...@pengutronix.de; ker...@pengutronix.de;
> feste...@gmail.com; linux-...@nxp.com; p.za...@pengutronix.de;
> Chrisanthus, Anitha ;
> edmund.j@intel.com; khil...@baylibre.com; jbru...@baylibre.com;
> martin.blumensti...@googlemail.com; alain.vol...@foss.st.com;
> yannick.fer...@foss.st.com; raphael.gallais-...@foss.st.com;
> philippe.co...@foss.st.com; mcoquelin.st...@gmail.com;
> alexandre.tor...@foss.st.com; jernej.skra...@gmail.com;
> sam...@sholland.org; jyri.sa...@iki.fi; to...@kernel.org;
> linus.wall...@linaro.org; hyun.k...@xilinx.com;
> laurent.pinch...@ideasonboard.com
> Cc: dri-devel@lists.freedesktop.org; linux-asp...@lists.ozlabs.org; linux-arm-
> ker...@lists.infradead.org; linux-amlo...@lists.infradead.org; linux-
> st...@st-md-mailman.stormreply.com; linux-su...@lists.linux.dev; Thomas
> Zimmermann 
> Subject: [PATCH 09/22] drm/kmb: Use GEM DMA fbdev emulation
> 
> Use the fbdev emulation that is optimized for DMA helpers. Avoids
> possible shadow buffering and makes the code simpler.
> 
> Signed-off-by: Thomas Zimmermann 
> ---
>  drivers/gpu/drm/kmb/kmb_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/kmb/kmb_drv.c
> b/drivers/gpu/drm/kmb/kmb_drv.c
> index d29c678f6c91..24035b53441c 100644
> --- a/drivers/gpu/drm/kmb/kmb_drv.c
> +++ b/drivers/gpu/drm/kmb/kmb_drv.c
> @@ -15,7 +15,7 @@
> 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -562,7 +562,7 @@ static int kmb_probe(struct platform_device *pdev)
>   if (ret)
>   goto err_register;
> 
> - drm_fbdev_generic_setup(>drm, 0);
> + drm_fbdev_dma_setup(>drm, 0);
> 
>   return 0;
> 
> --
> 2.39.2



[PATCH v3] dma-buf: cma_heap: Check for device max segment size when attaching

2023-03-06 Thread Andrew Davis
Although there is usually not such a limitation (and when there is it is
often only because the driver forgot to change the super small default),
it is still correct here to break scatterlist element into chunks of
dma_max_mapping_size().

This might cause some issues for users with misbehaving drivers. If
bisecting has landed you on this commit, make sure your drivers both set
dma_set_max_seg_size() and are checking for contiguousness correctly.

Signed-off-by: Andrew Davis 
---

Changes from v2:
 - Rebase v6.3-rc1

Changes from v1:
 - Fixed mixed declarations and code warning

 drivers/dma-buf/heaps/cma_heap.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
index 1131fb943992..579261a46fa3 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -53,16 +53,18 @@ static int cma_heap_attach(struct dma_buf *dmabuf,
 {
struct cma_heap_buffer *buffer = dmabuf->priv;
struct dma_heap_attachment *a;
+   size_t max_segment;
int ret;
 
a = kzalloc(sizeof(*a), GFP_KERNEL);
if (!a)
return -ENOMEM;
 
-   ret = sg_alloc_table_from_pages(>table, buffer->pages,
-   buffer->pagecount, 0,
-   buffer->pagecount << PAGE_SHIFT,
-   GFP_KERNEL);
+   max_segment = dma_get_max_seg_size(attachment->dev);
+   ret = sg_alloc_table_from_pages_segment(>table, buffer->pages,
+   buffer->pagecount, 0,
+   buffer->pagecount << PAGE_SHIFT,
+   max_segment, GFP_KERNEL);
if (ret) {
kfree(a);
return ret;
-- 
2.39.2



[PATCH v3] drm/virtio: Fix handling CONFIG_DRM_VIRTIO_GPU_KMS option

2023-03-06 Thread Dmitry Osipenko
VirtIO-GPU got a new config option for disabling KMS. There were two
problems left unnoticed during review when the new option was added:

1. The IS_ENABLED(CONFIG_DRM_VIRTIO_GPU_KMS) check in the code was
inverted, hence KMS was disabled when it should be enabled and vice versa.

2. The disabled KMS crashed kernel with a NULL dereference in
drm_kms_helper_hotplug_event(), which shall not be invoked with a
disabled KMS.

Fix the inverted config option check in the code and skip handling the
VIRTIO_GPU_EVENT_DISPLAY sent by host when KMS is disabled in guest to fix
the crash.

Acked-by: Gerd Hoffmann 
Fixes: 72122c69d717 ("drm/virtio: Add option to disable KMS support")
Signed-off-by: Dmitry Osipenko 
---

Changelog:

v3: - Moved another similar "has_edid" occurence under the "num_scanouts"
  condition in virtio_gpu_init(), like was suggested by Emil Velikov.

- Added ack from Gerd Hoffmann.

v2: - Moved the "has_edid" under the "num_scanouts" condition, like was
  suggested by Gerd Hoffmann.

 drivers/gpu/drm/virtio/virtgpu_kms.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c 
b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 874ad6c2621a..43e237082cec 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -43,11 +43,13 @@ static void virtio_gpu_config_changed_work_func(struct 
work_struct *work)
virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
events_read, _read);
if (events_read & VIRTIO_GPU_EVENT_DISPLAY) {
-   if (vgdev->has_edid)
-   virtio_gpu_cmd_get_edids(vgdev);
-   virtio_gpu_cmd_get_display_info(vgdev);
-   virtio_gpu_notify(vgdev);
-   drm_helper_hpd_irq_event(vgdev->ddev);
+   if (vgdev->num_scanouts) {
+   if (vgdev->has_edid)
+   virtio_gpu_cmd_get_edids(vgdev);
+   virtio_gpu_cmd_get_display_info(vgdev);
+   virtio_gpu_notify(vgdev);
+   drm_helper_hpd_irq_event(vgdev->ddev);
+   }
events_clear |= VIRTIO_GPU_EVENT_DISPLAY;
}
virtio_cwrite_le(vgdev->vdev, struct virtio_gpu_config,
@@ -224,7 +226,7 @@ int virtio_gpu_init(struct virtio_device *vdev, struct 
drm_device *dev)
vgdev->num_scanouts = min_t(uint32_t, num_scanouts,
VIRTIO_GPU_MAX_SCANOUTS);
 
-   if (IS_ENABLED(CONFIG_DRM_VIRTIO_GPU_KMS) || !vgdev->num_scanouts) {
+   if (!IS_ENABLED(CONFIG_DRM_VIRTIO_GPU_KMS) || !vgdev->num_scanouts) {
DRM_INFO("KMS disabled\n");
vgdev->num_scanouts = 0;
vgdev->has_edid = false;
@@ -253,9 +255,9 @@ int virtio_gpu_init(struct virtio_device *vdev, struct 
drm_device *dev)
 
if (num_capsets)
virtio_gpu_get_capsets(vgdev, num_capsets);
-   if (vgdev->has_edid)
-   virtio_gpu_cmd_get_edids(vgdev);
if (vgdev->num_scanouts) {
+   if (vgdev->has_edid)
+   virtio_gpu_cmd_get_edids(vgdev);
virtio_gpu_cmd_get_display_info(vgdev);
virtio_gpu_notify(vgdev);
wait_event_timeout(vgdev->resp_wq, !vgdev->display_info_pending,
-- 
2.39.2



[PATCH v4 10/10] drm/i915/gt: Hold a wakeref for the active VM

2023-03-06 Thread Andrzej Hajda
From: Chris Wilson 

There may be a disconnect between the GT used by the engine and the GT
used for the VM, requiring us to hold a wakeref on both while the GPU is
active with this request.

Signed-off-by: Chris Wilson 
Signed-off-by: Andrzej Hajda 
---
 drivers/gpu/drm/i915/gt/intel_context.h   | 15 +++
 drivers/gpu/drm/i915/gt/intel_context_types.h |  2 ++
 drivers/gpu/drm/i915/gt/intel_engine_pm.c |  4 
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.h 
b/drivers/gpu/drm/i915/gt/intel_context.h
index 0a8d553da3f439..582faa21181e58 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.h
+++ b/drivers/gpu/drm/i915/gt/intel_context.h
@@ -14,6 +14,7 @@
 #include "i915_drv.h"
 #include "intel_context_types.h"
 #include "intel_engine_types.h"
+#include "intel_gt_pm.h"
 #include "intel_ring_types.h"
 #include "intel_timeline_types.h"
 #include "i915_trace.h"
@@ -207,8 +208,11 @@ void intel_context_exit_engine(struct intel_context *ce);
 static inline void intel_context_enter(struct intel_context *ce)
 {
lockdep_assert_held(>timeline->mutex);
-   if (!ce->active_count++)
-   ce->ops->enter(ce);
+   if (ce->active_count++)
+   return;
+
+   ce->ops->enter(ce);
+   ce->wakeref = intel_gt_pm_get(ce->vm->gt);
 }
 
 static inline void intel_context_mark_active(struct intel_context *ce)
@@ -222,8 +226,11 @@ static inline void intel_context_exit(struct intel_context 
*ce)
 {
lockdep_assert_held(>timeline->mutex);
GEM_BUG_ON(!ce->active_count);
-   if (!--ce->active_count)
-   ce->ops->exit(ce);
+   if (--ce->active_count)
+   return;
+
+   intel_gt_pm_put_async(ce->vm->gt, ce->wakeref);
+   ce->ops->exit(ce);
 }
 
 static inline struct intel_context *intel_context_get(struct intel_context *ce)
diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h 
b/drivers/gpu/drm/i915/gt/intel_context_types.h
index e36670f2e6260b..5dc39a9d7a501c 100644
--- a/drivers/gpu/drm/i915/gt/intel_context_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
@@ -17,6 +17,7 @@
 #include "i915_utils.h"
 #include "intel_engine_types.h"
 #include "intel_sseu.h"
+#include "intel_wakeref.h"
 
 #include "uc/intel_guc_fwif.h"
 
@@ -110,6 +111,7 @@ struct intel_context {
u32 ring_size;
struct intel_ring *ring;
struct intel_timeline *timeline;
+   intel_wakeref_t wakeref;
 
unsigned long flags;
 #define CONTEXT_BARRIER_BIT0
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c 
b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
index 7063dea2112943..c2d17c97bfe989 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
@@ -114,6 +114,10 @@ __queue_and_release_pm(struct i915_request *rq,
 
ENGINE_TRACE(engine, "parking\n");
 
+   GEM_BUG_ON(rq->context->active_count != 1);
+   __intel_gt_pm_get(engine->gt);
+   rq->context->wakeref = intel_wakeref_track(>gt->wakeref);
+
/*
 * We have to serialise all potential retirement paths with our
 * submission, as we don't want to underflow either the

-- 
2.34.1


[PATCH v4 09/10] drm/i915: replace Intel internal tracker with kernel core ref_tracker

2023-03-06 Thread Andrzej Hajda
Beside reusing existing code, the main advantage of ref_tracker is
tracking per instance of wakeref. It allows also to catch double
put.
On the other side we lose information about the first acquire and
the last release, but the advantages outweigh it.

v2: Call ref_tracker_dir_exit() only at driver shutdown not during
suspend so add intel_runtime_pm_driver_last_release (Nirmoy)

Signed-off-by: Andrzej Hajda 
---
 drivers/gpu/drm/i915/Kconfig.debug |  11 +-
 drivers/gpu/drm/i915/Makefile  |   3 -
 drivers/gpu/drm/i915/display/intel_display_power.c |   2 +-
 drivers/gpu/drm/i915/gt/intel_engine_pm.c  |   2 +-
 drivers/gpu/drm/i915/gt/intel_gt_pm.c  |   2 +-
 drivers/gpu/drm/i915/i915_driver.c |   2 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c|  27 ++-
 drivers/gpu/drm/i915/intel_runtime_pm.h|   3 +-
 drivers/gpu/drm/i915/intel_wakeref.c   |   5 +-
 drivers/gpu/drm/i915/intel_wakeref.h   |  72 ++-
 drivers/gpu/drm/i915/intel_wakeref_tracker.c   | 234 -
 drivers/gpu/drm/i915/intel_wakeref_tracker.h   |  76 ---
 12 files changed, 89 insertions(+), 350 deletions(-)

diff --git a/drivers/gpu/drm/i915/Kconfig.debug 
b/drivers/gpu/drm/i915/Kconfig.debug
index 63b77dc48d4394..d26fb4569873ea 100644
--- a/drivers/gpu/drm/i915/Kconfig.debug
+++ b/drivers/gpu/drm/i915/Kconfig.debug
@@ -24,6 +24,7 @@ config DRM_I915_DEBUG
select DEBUG_FS
select PREEMPT_COUNT
select I2C_CHARDEV
+   select REF_TRACKER
select STACKDEPOT
select STACKTRACE
select DRM_DP_AUX_CHARDEV
@@ -38,7 +39,6 @@ config DRM_I915_DEBUG
select DRM_I915_DEBUG_GEM
select DRM_I915_DEBUG_GEM_ONCE
select DRM_I915_DEBUG_MMIO
-   select DRM_I915_TRACK_WAKEREF
select DRM_I915_DEBUG_RUNTIME_PM
select DRM_I915_DEBUG_WAKEREF
select DRM_I915_SW_FENCE_DEBUG_OBJECTS
@@ -230,18 +230,13 @@ config DRM_I915_DEBUG_VBLANK_EVADE
 
  If in doubt, say "N".
 
-config DRM_I915_TRACK_WAKEREF
-   depends on STACKDEPOT
-   depends on STACKTRACE
-   bool
-
 config DRM_I915_DEBUG_RUNTIME_PM
bool "Enable extra state checking for runtime PM"
depends on DRM_I915
default n
+   select REF_TRACKER
select STACKDEPOT
select STACKTRACE
-   select DRM_I915_TRACK_WAKEREF
help
  Choose this option to turn on extra state checking for the
  runtime PM functionality. This may introduce overhead during
@@ -255,9 +250,9 @@ config DRM_I915_DEBUG_WAKEREF
bool "Enable extra tracking for wakerefs"
depends on DRM_I915
default n
+   select REF_TRACKER
select STACKDEPOT
select STACKTRACE
-   select DRM_I915_TRACK_WAKEREF
help
  Choose this option to turn on extra state checking and usage
  tracking for the wakerefPM functionality. This may introduce
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 42daff6d575a82..8d64846430f8aa 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -82,9 +82,6 @@ i915-$(CONFIG_DEBUG_FS) += \
display/intel_display_debugfs.o \
display/intel_pipe_crc.o
 
-i915-$(CONFIG_DRM_I915_TRACK_WAKEREF) += \
-   intel_wakeref_tracker.o
-
 i915-$(CONFIG_PERF_EVENTS) += i915_pmu.o
 
 # "Graphics Technology" (aka we talk to the gpu)
diff --git a/drivers/gpu/drm/i915/display/intel_display_power.c 
b/drivers/gpu/drm/i915/display/intel_display_power.c
index 743b919bb2cfd7..56c0a443f45c75 100644
--- a/drivers/gpu/drm/i915/display/intel_display_power.c
+++ b/drivers/gpu/drm/i915/display/intel_display_power.c
@@ -403,7 +403,7 @@ print_async_put_domains_state(struct i915_power_domains 
*power_domains)
 struct drm_i915_private,
 display.power.domains);
 
-   drm_dbg(>drm, "async_put_wakeref %u\n",
+   drm_dbg(>drm, "async_put_wakeref %lu\n",
power_domains->async_put_wakeref);
 
print_power_domains(power_domains, "async_put_domains[0]",
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c 
b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
index 7db9229d28639c..7063dea2112943 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
@@ -289,7 +289,7 @@ void intel_engine_init__pm(struct intel_engine_cs *engine)
 {
struct intel_runtime_pm *rpm = engine->uncore->rpm;
 
-   intel_wakeref_init(>wakeref, rpm, _ops);
+   intel_wakeref_init(>wakeref, rpm, _ops, engine->name);
intel_engine_init_heartbeat(engine);
 
intel_gsc_idle_msg_enable(engine);
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c 
b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
index 302f908b37fb2e..7f92aa02b2a013 100644
--- 

[PATCH v4 08/10] drm/i915: Correct type of wakeref variable

2023-03-06 Thread Andrzej Hajda
Wakeref has dedicated type. Assumption it will be int
compatible forever is incorrect.

Signed-off-by: Andrzej Hajda 
---
 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index 978820f8697059..c35f551193c9ad 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -3235,7 +3235,7 @@ static void destroyed_worker_func(struct work_struct *w)
struct intel_guc *guc = container_of(w, struct intel_guc,
 submission_state.destroyed_worker);
struct intel_gt *gt = guc_to_gt(guc);
-   int tmp;
+   intel_wakeref_t tmp;
 
with_intel_gt_pm(gt, tmp)
deregister_destroyed_contexts(guc);

-- 
2.34.1


[PATCH v4 07/10] drm/i915: Track leaked gt->wakerefs

2023-03-06 Thread Andrzej Hajda
From: Chris Wilson 

Track every intel_gt_pm_get() until its corresponding release in
intel_gt_pm_put() by returning a cookie to the caller for acquire that
must be passed by on rleased. When there is an imbalance, we can see who
either tried to free a stale wakeref, or who forgot to free theirs.

v2: Rebase from backporting wakeref leak (Umesh)

Signed-off-by: Chris Wilson 
Signed-off-by: Andrzej Hajda 
---
 drivers/gpu/drm/i915/Kconfig.debug | 15 
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c |  7 ++--
 .../drm/i915/gem/selftests/i915_gem_coherency.c| 10 +++---
 drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 14 
 drivers/gpu/drm/i915/gt/intel_breadcrumbs.c| 13 ---
 drivers/gpu/drm/i915/gt/intel_breadcrumbs_types.h  |  3 +-
 drivers/gpu/drm/i915/gt/intel_engine_pm.c  |  4 +--
 drivers/gpu/drm/i915/gt/intel_engine_types.h   |  2 ++
 .../gpu/drm/i915/gt/intel_execlists_submission.c   |  2 +-
 drivers/gpu/drm/i915/gt/intel_gt_pm.c  | 10 +++---
 drivers/gpu/drm/i915/gt/intel_gt_pm.h  | 38 +++-
 drivers/gpu/drm/i915/gt/intel_gt_pm_debugfs.c  |  4 +--
 drivers/gpu/drm/i915/gt/selftest_engine_cs.c   | 20 ++-
 drivers/gpu/drm/i915/gt/selftest_gt_pm.c   |  5 +--
 drivers/gpu/drm/i915/gt/selftest_reset.c   | 10 +++---
 drivers/gpu/drm/i915/gt/selftest_rps.c | 17 +
 drivers/gpu/drm/i915/gt/selftest_slpc.c|  5 +--
 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c  |  9 ++---
 drivers/gpu/drm/i915/i915_pmu.c| 16 +
 drivers/gpu/drm/i915/intel_wakeref.c   |  4 +++
 drivers/gpu/drm/i915/intel_wakeref.h   | 42 ++
 21 files changed, 180 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/i915/Kconfig.debug 
b/drivers/gpu/drm/i915/Kconfig.debug
index 5fde52107e3b44..63b77dc48d4394 100644
--- a/drivers/gpu/drm/i915/Kconfig.debug
+++ b/drivers/gpu/drm/i915/Kconfig.debug
@@ -40,6 +40,7 @@ config DRM_I915_DEBUG
select DRM_I915_DEBUG_MMIO
select DRM_I915_TRACK_WAKEREF
select DRM_I915_DEBUG_RUNTIME_PM
+   select DRM_I915_DEBUG_WAKEREF
select DRM_I915_SW_FENCE_DEBUG_OBJECTS
select DRM_I915_SELFTEST
select BROKEN # for prototype uAPI
@@ -249,3 +250,17 @@ config DRM_I915_DEBUG_RUNTIME_PM
  Recommended for driver developers only.
 
  If in doubt, say "N"
+
+config DRM_I915_DEBUG_WAKEREF
+   bool "Enable extra tracking for wakerefs"
+   depends on DRM_I915
+   default n
+   select STACKDEPOT
+   select STACKTRACE
+   select DRM_I915_TRACK_WAKEREF
+   help
+ Choose this option to turn on extra state checking and usage
+ tracking for the wakerefPM functionality. This may introduce
+ overhead during driver runtime.
+
+ If in doubt, say "N"
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 9dce2957b4e5ae..65abcd82b6de93 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -253,6 +253,7 @@ struct i915_execbuffer {
struct intel_gt *gt; /* gt for the execbuf */
struct intel_context *context; /* logical state for the request */
struct i915_gem_context *gem_context; /** caller's context */
+   intel_wakeref_t wakeref;
 
/** our requests to build */
struct i915_request *requests[MAX_ENGINE_INSTANCE + 1];
@@ -2713,7 +2714,7 @@ eb_select_engine(struct i915_execbuffer *eb)
 
for_each_child(ce, child)
intel_context_get(child);
-   intel_gt_pm_get(ce->engine->gt);
+   eb->wakeref = intel_gt_pm_get(ce->engine->gt);
 
if (!test_bit(CONTEXT_ALLOC_BIT, >flags)) {
err = intel_context_alloc_state(ce);
@@ -2752,7 +2753,7 @@ eb_select_engine(struct i915_execbuffer *eb)
return err;
 
 err:
-   intel_gt_pm_put(ce->engine->gt);
+   intel_gt_pm_put(ce->engine->gt, eb->wakeref);
for_each_child(ce, child)
intel_context_put(child);
intel_context_put(ce);
@@ -2765,7 +2766,7 @@ eb_put_engine(struct i915_execbuffer *eb)
struct intel_context *child;
 
i915_vm_put(eb->context->vm);
-   intel_gt_pm_put(eb->gt);
+   intel_gt_pm_put(eb->context->engine->gt, eb->wakeref);
for_each_child(eb->context, child)
intel_context_put(child);
intel_context_put(eb->context);
diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c 
b/drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c
index 3bef1beec7cbb5..3fd68a099a85ef 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c
@@ -85,6 +85,7 @@ static int cpu_get(struct context *ctx, unsigned long offset, 
u32 *v)
 
 static int 

[PATCH v4 05/10] drm/i915: Separate wakeref tracking types from rpm

2023-03-06 Thread Andrzej Hajda
These structs will be used by other subsystems.

Signed-off-by: Andrzej Hajda 
---
 drivers/gpu/drm/i915/intel_runtime_pm.c  | 14 +++---
 drivers/gpu/drm/i915/intel_runtime_pm.h  | 10 +-
 drivers/gpu/drm/i915/intel_wakeref.h |  4 ++--
 drivers/gpu/drm/i915/intel_wakeref_tracker.h | 24 
 4 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c 
b/drivers/gpu/drm/i915/intel_runtime_pm.c
index 129746713d072f..1901eedb6704a2 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -164,7 +164,7 @@ static int cmphandle(const void *_a, const void *_b)
 
 static void
 __print_intel_runtime_pm_wakeref(struct drm_printer *p,
-const struct intel_runtime_pm_debug *dbg)
+const struct intel_wakeref_tracker *dbg)
 {
unsigned long i;
char *buf;
@@ -202,8 +202,8 @@ __print_intel_runtime_pm_wakeref(struct drm_printer *p,
 }
 
 static noinline void
-__untrack_all_wakerefs(struct intel_runtime_pm_debug *debug,
-  struct intel_runtime_pm_debug *saved)
+__untrack_all_wakerefs(struct intel_wakeref_tracker *debug,
+  struct intel_wakeref_tracker *saved)
 {
*saved = *debug;
 
@@ -213,7 +213,7 @@ __untrack_all_wakerefs(struct intel_runtime_pm_debug *debug,
 }
 
 static void
-dump_and_free_wakeref_tracking(struct intel_runtime_pm_debug *debug)
+dump_and_free_wakeref_tracking(struct intel_wakeref_tracker *debug)
 {
if (debug->count) {
struct drm_printer p = drm_debug_printer("i915");
@@ -227,7 +227,7 @@ dump_and_free_wakeref_tracking(struct 
intel_runtime_pm_debug *debug)
 static noinline void
 __intel_wakeref_dec_and_check_tracking(struct intel_runtime_pm *rpm)
 {
-   struct intel_runtime_pm_debug dbg = {};
+   struct intel_wakeref_tracker dbg = {};
unsigned long flags;
 
if (!atomic_dec_and_lock_irqsave(>wakeref_count,
@@ -244,7 +244,7 @@ __intel_wakeref_dec_and_check_tracking(struct 
intel_runtime_pm *rpm)
 static noinline void
 untrack_all_intel_runtime_pm_wakerefs(struct intel_runtime_pm *rpm)
 {
-   struct intel_runtime_pm_debug dbg = {};
+   struct intel_wakeref_tracker dbg = {};
unsigned long flags;
 
spin_lock_irqsave(>debug.lock, flags);
@@ -257,7 +257,7 @@ untrack_all_intel_runtime_pm_wakerefs(struct 
intel_runtime_pm *rpm)
 void print_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm,
struct drm_printer *p)
 {
-   struct intel_runtime_pm_debug dbg = {};
+   struct intel_wakeref_tracker dbg = {};
 
do {
unsigned long alloc = dbg.count;
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.h 
b/drivers/gpu/drm/i915/intel_runtime_pm.h
index e592e8d6499a1f..a8dc2baf79844f 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.h
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.h
@@ -83,15 +83,7 @@ struct intel_runtime_pm {
 * paired rpm_put) we can remove corresponding pairs of and keep
 * the array trimmed to active wakerefs.
 */
-   struct intel_runtime_pm_debug {
-   spinlock_t lock;
-
-   depot_stack_handle_t last_acquire;
-   depot_stack_handle_t last_release;
-
-   depot_stack_handle_t *owners;
-   unsigned long count;
-   } debug;
+   struct intel_wakeref_tracker debug;
 #endif
 };
 
diff --git a/drivers/gpu/drm/i915/intel_wakeref.h 
b/drivers/gpu/drm/i915/intel_wakeref.h
index 71b8a63f6f104d..583fdaadd9912c 100644
--- a/drivers/gpu/drm/i915/intel_wakeref.h
+++ b/drivers/gpu/drm/i915/intel_wakeref.h
@@ -17,6 +17,8 @@
 #include 
 #include 
 
+#include "intel_wakeref_tracker.h"
+
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
 #define INTEL_WAKEREF_BUG_ON(expr) BUG_ON(expr)
 #else
@@ -26,8 +28,6 @@
 struct intel_runtime_pm;
 struct intel_wakeref;
 
-typedef depot_stack_handle_t intel_wakeref_t;
-
 struct intel_wakeref_ops {
int (*get)(struct intel_wakeref *wf);
int (*put)(struct intel_wakeref *wf);
diff --git a/drivers/gpu/drm/i915/intel_wakeref_tracker.h 
b/drivers/gpu/drm/i915/intel_wakeref_tracker.h
new file mode 100644
index 00..74e6261fb31260
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel_wakeref_tracker.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef INTEL_WAKEREF_TRACKER_H
+#define INTEL_WAKEREF_TRACKER_H
+
+#include 
+#include 
+
+typedef depot_stack_handle_t intel_wakeref_t;
+
+struct intel_wakeref_tracker {
+   spinlock_t lock;
+
+   depot_stack_handle_t last_acquire;
+   depot_stack_handle_t last_release;
+
+   depot_stack_handle_t *owners;
+   unsigned long count;
+};
+
+#endif /* INTEL_WAKEREF_TRACKER_H */

-- 
2.34.1


[PATCH v4 06/10] drm/i915: Separate wakeref tracking

2023-03-06 Thread Andrzej Hajda
From: Chris Wilson 

Extract the callstack tracking of intel_runtime_pm.c into its own
utility so that that we can reuse it for other online debugging of
scoped wakerefs.

Signed-off-by: Chris Wilson 
Signed-off-by: Andrzej Hajda 
---
 drivers/gpu/drm/i915/Kconfig.debug   |   9 ++
 drivers/gpu/drm/i915/Makefile|   4 +
 drivers/gpu/drm/i915/intel_runtime_pm.c  | 222 +++--
 drivers/gpu/drm/i915/intel_wakeref.h |   2 +-
 drivers/gpu/drm/i915/intel_wakeref_tracker.c | 234 +++
 drivers/gpu/drm/i915/intel_wakeref_tracker.h |  52 ++
 6 files changed, 319 insertions(+), 204 deletions(-)

diff --git a/drivers/gpu/drm/i915/Kconfig.debug 
b/drivers/gpu/drm/i915/Kconfig.debug
index 93dfb7ed970547..5fde52107e3b44 100644
--- a/drivers/gpu/drm/i915/Kconfig.debug
+++ b/drivers/gpu/drm/i915/Kconfig.debug
@@ -25,6 +25,7 @@ config DRM_I915_DEBUG
select PREEMPT_COUNT
select I2C_CHARDEV
select STACKDEPOT
+   select STACKTRACE
select DRM_DP_AUX_CHARDEV
select X86_MSR # used by igt/pm_rpm
select DRM_VGEM # used by igt/prime_vgem (dmabuf interop checks)
@@ -37,6 +38,7 @@ config DRM_I915_DEBUG
select DRM_I915_DEBUG_GEM
select DRM_I915_DEBUG_GEM_ONCE
select DRM_I915_DEBUG_MMIO
+   select DRM_I915_TRACK_WAKEREF
select DRM_I915_DEBUG_RUNTIME_PM
select DRM_I915_SW_FENCE_DEBUG_OBJECTS
select DRM_I915_SELFTEST
@@ -227,11 +229,18 @@ config DRM_I915_DEBUG_VBLANK_EVADE
 
  If in doubt, say "N".
 
+config DRM_I915_TRACK_WAKEREF
+   depends on STACKDEPOT
+   depends on STACKTRACE
+   bool
+
 config DRM_I915_DEBUG_RUNTIME_PM
bool "Enable extra state checking for runtime PM"
depends on DRM_I915
default n
select STACKDEPOT
+   select STACKTRACE
+   select DRM_I915_TRACK_WAKEREF
help
  Choose this option to turn on extra state checking for the
  runtime PM functionality. This may introduce overhead during
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index b2f91a1f826858..42daff6d575a82 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -81,6 +81,10 @@ i915-$(CONFIG_DEBUG_FS) += \
i915_debugfs_params.o \
display/intel_display_debugfs.o \
display/intel_pipe_crc.o
+
+i915-$(CONFIG_DRM_I915_TRACK_WAKEREF) += \
+   intel_wakeref_tracker.o
+
 i915-$(CONFIG_PERF_EVENTS) += i915_pmu.o
 
 # "Graphics Technology" (aka we talk to the gpu)
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c 
b/drivers/gpu/drm/i915/intel_runtime_pm.c
index 1901eedb6704a2..43149cf12dc864 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -52,182 +52,37 @@
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
 
-#include 
-
-#define STACKDEPTH 8
-
-static noinline depot_stack_handle_t __save_depot_stack(void)
-{
-   unsigned long entries[STACKDEPTH];
-   unsigned int n;
-
-   n = stack_trace_save(entries, ARRAY_SIZE(entries), 1);
-   return stack_depot_save(entries, n, GFP_NOWAIT | __GFP_NOWARN);
-}
-
 static void init_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm)
 {
-   spin_lock_init(>debug.lock);
-   stack_depot_init();
+   intel_wakeref_tracker_init(>debug);
 }
 
-static noinline depot_stack_handle_t
+static intel_wakeref_t
 track_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm)
 {
-   depot_stack_handle_t stack, *stacks;
-   unsigned long flags;
-
-   if (rpm->no_wakeref_tracking)
-   return -1;
-
-   stack = __save_depot_stack();
-   if (!stack)
+   if (!rpm->available || rpm->no_wakeref_tracking)
return -1;
 
-   spin_lock_irqsave(>debug.lock, flags);
-
-   if (!rpm->debug.count)
-   rpm->debug.last_acquire = stack;
-
-   stacks = krealloc(rpm->debug.owners,
- (rpm->debug.count + 1) * sizeof(*stacks),
- GFP_NOWAIT | __GFP_NOWARN);
-   if (stacks) {
-   stacks[rpm->debug.count++] = stack;
-   rpm->debug.owners = stacks;
-   } else {
-   stack = -1;
-   }
-
-   spin_unlock_irqrestore(>debug.lock, flags);
-
-   return stack;
+   return intel_wakeref_tracker_add(>debug);
 }
 
 static void untrack_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm,
-depot_stack_handle_t stack)
+intel_wakeref_t wakeref)
 {
-   struct drm_i915_private *i915 = container_of(rpm,
-struct drm_i915_private,
-runtime_pm);
-   unsigned long flags, n;
-   bool found = false;
-
-   if (unlikely(stack == -1))
-   return;
-
-   

[PATCH v4 04/10] lib/ref_tracker: remove warnings in case of allocation failure

2023-03-06 Thread Andrzej Hajda
Library can handle allocation failures. To avoid allocation warnings
__GFP_NOWARN has been added everywhere. Moreover GFP_ATOMIC has been
replaced with GFP_NOWAIT in case of stack allocation on tracker free
call.

Signed-off-by: Andrzej Hajda 
---
 lib/ref_tracker.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
index 2ef4596b6b36f5..cae4498fcfd701 100644
--- a/lib/ref_tracker.c
+++ b/lib/ref_tracker.c
@@ -189,7 +189,7 @@ int ref_tracker_alloc(struct ref_tracker_dir *dir,
unsigned long entries[REF_TRACKER_STACK_ENTRIES];
struct ref_tracker *tracker;
unsigned int nr_entries;
-   gfp_t gfp_mask = gfp;
+   gfp_t gfp_mask = gfp | __GFP_NOWARN;
unsigned long flags;
 
WARN_ON_ONCE(dir->dead);
@@ -237,7 +237,8 @@ int ref_tracker_free(struct ref_tracker_dir *dir,
return -EEXIST;
}
nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 1);
-   stack_handle = stack_depot_save(entries, nr_entries, GFP_ATOMIC);
+   stack_handle = stack_depot_save(entries, nr_entries,
+   GFP_NOWAIT | __GFP_NOWARN);
 
spin_lock_irqsave(>lock, flags);
if (tracker->dead) {

-- 
2.34.1


[PATCH v4 03/10] lib/ref_tracker: add printing to memory buffer

2023-03-06 Thread Andrzej Hajda
In case one wants to show stats via debugfs.

Signed-off-by: Andrzej Hajda 
---
 include/linux/ref_tracker.h |  8 +++
 lib/ref_tracker.c   | 56 ++---
 2 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/include/linux/ref_tracker.h b/include/linux/ref_tracker.h
index a2cf1f6309adb2..2fdbfd2e14797a 100644
--- a/include/linux/ref_tracker.h
+++ b/include/linux/ref_tracker.h
@@ -50,6 +50,8 @@ void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
 void ref_tracker_dir_print(struct ref_tracker_dir *dir,
   unsigned int display_limit);
 
+int ref_tracker_dir_snprint(struct ref_tracker_dir *dir, char *buf, size_t 
size);
+
 int ref_tracker_alloc(struct ref_tracker_dir *dir,
  struct ref_tracker **trackerp, gfp_t gfp);
 
@@ -78,6 +80,12 @@ static inline void ref_tracker_dir_print(struct 
ref_tracker_dir *dir,
 {
 }
 
+static inline int ref_tracker_dir_snprint(struct ref_tracker_dir *dir,
+ char *buf, size_t size)
+{
+   return 0;
+}
+
 static inline int ref_tracker_alloc(struct ref_tracker_dir *dir,
struct ref_tracker **trackerp,
gfp_t gfp)
diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
index ab1253fde244ea..2ef4596b6b36f5 100644
--- a/lib/ref_tracker.c
+++ b/lib/ref_tracker.c
@@ -62,8 +62,27 @@ ref_tracker_get_stats(struct ref_tracker_dir *dir, unsigned 
int limit)
return stats;
 }
 
-void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
-  unsigned int display_limit)
+struct ostream {
+   char *buf;
+   int size, used;
+};
+
+#define pr_ostream(stream, fmt, args...) \
+({ \
+   struct ostream *_s = (stream); \
+\
+   if (!_s->buf) { \
+   pr_err(fmt, ##args); \
+   } else { \
+   int ret, len = _s->size - _s->used; \
+   ret = snprintf(_s->buf + _s->used, len, pr_fmt(fmt), ##args); \
+   _s->used += min(ret, len); \
+   } \
+})
+
+static void
+__ref_tracker_dir_pr_ostream(struct ref_tracker_dir *dir,
+unsigned int display_limit, struct ostream *s)
 {
struct ref_tracker_dir_stats *stats;
unsigned int i = 0, skipped;
@@ -77,8 +96,8 @@ void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
 
stats = ref_tracker_get_stats(dir, display_limit);
if (IS_ERR(stats)) {
-   pr_err("%s@%pK: couldn't get stats, error %pe\n",
-  dir->name, dir, stats);
+   pr_ostream(s, "%s@%pK: couldn't get stats, error %pe\n",
+  dir->name, dir, stats);
return;
}
 
@@ -88,19 +107,27 @@ void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
stack = stats->stacks[i].stack_handle;
if (sbuf && !stack_depot_snprint(stack, sbuf, STACK_BUF_SIZE, 
4))
sbuf[0] = 0;
-   pr_err("%s@%pK has %d/%d users at\n%s\n", dir->name, dir,
-  stats->stacks[i].count, stats->total, sbuf);
+   pr_ostream(s, "%s@%pK has %d/%d users at\n%s\n", dir->name, dir,
+  stats->stacks[i].count, stats->total, sbuf);
skipped -= stats->stacks[i].count;
}
 
if (skipped)
-   pr_err("%s@%pK skipped reports about %d/%d users.\n",
-  dir->name, dir, skipped, stats->total);
+   pr_ostream(s, "%s@%pK skipped reports about %d/%d users.\n",
+  dir->name, dir, skipped, stats->total);
 
kfree(sbuf);
 
kfree(stats);
 }
+
+void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
+  unsigned int display_limit)
+{
+   struct ostream os = {};
+
+   __ref_tracker_dir_pr_ostream(dir, display_limit, );
+}
 EXPORT_SYMBOL(__ref_tracker_dir_print);
 
 void ref_tracker_dir_print(struct ref_tracker_dir *dir,
@@ -114,6 +141,19 @@ void ref_tracker_dir_print(struct ref_tracker_dir *dir,
 }
 EXPORT_SYMBOL(ref_tracker_dir_print);
 
+int ref_tracker_dir_snprint(struct ref_tracker_dir *dir, char *buf, size_t 
size)
+{
+   struct ostream os = { .buf = buf, .size = size };
+   unsigned long flags;
+
+   spin_lock_irqsave(>lock, flags);
+   __ref_tracker_dir_pr_ostream(dir, 16, );
+   spin_unlock_irqrestore(>lock, flags);
+
+   return os.used;
+}
+EXPORT_SYMBOL(ref_tracker_dir_snprint);
+
 void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
 {
struct ref_tracker *tracker, *n;

-- 
2.34.1


[PATCH v4 02/10] lib/ref_tracker: __ref_tracker_dir_print improve printing

2023-03-06 Thread Andrzej Hajda
To improve readability of ref_tracker printing following changes
have been performed:
- reports are printed per stack_handle - log is more compact,
- added display name for ref_tracker_dir,
- stack trace is printed indented, in the same printk call,
- total number of references is printed every time,
- print info about dropped references.

Signed-off-by: Andrzej Hajda 
---
 include/linux/ref_tracker.h | 15 ++--
 lib/ref_tracker.c   | 90 +++--
 2 files changed, 91 insertions(+), 14 deletions(-)

diff --git a/include/linux/ref_tracker.h b/include/linux/ref_tracker.h
index 3e9e9df2a41f5f..a2cf1f6309adb2 100644
--- a/include/linux/ref_tracker.h
+++ b/include/linux/ref_tracker.h
@@ -17,12 +17,19 @@ struct ref_tracker_dir {
booldead;
struct list_headlist; /* List of active trackers */
struct list_headquarantine; /* List of dead trackers */
+   charname[32];
 #endif
 };
 
 #ifdef CONFIG_REF_TRACKER
-static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
-   unsigned int quarantine_count)
+
+// Temporary allow two and three arguments, until consumers are converted
+#define ref_tracker_dir_init(_d, _q, args...) _ref_tracker_dir_init(_d, _q, 
##args, #_d)
+#define _ref_tracker_dir_init(_d, _q, _n, ...) __ref_tracker_dir_init(_d, _q, 
_n)
+
+static inline void __ref_tracker_dir_init(struct ref_tracker_dir *dir,
+   unsigned int quarantine_count,
+   const char *name)
 {
INIT_LIST_HEAD(>list);
INIT_LIST_HEAD(>quarantine);
@@ -31,6 +38,7 @@ static inline void ref_tracker_dir_init(struct 
ref_tracker_dir *dir,
dir->dead = false;
refcount_set(>untracked, 1);
refcount_set(>no_tracker, 1);
+   strlcpy(dir->name, name, sizeof(dir->name));
stack_depot_init();
 }
 
@@ -51,7 +59,8 @@ int ref_tracker_free(struct ref_tracker_dir *dir,
 #else /* CONFIG_REF_TRACKER */
 
 static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
-   unsigned int quarantine_count)
+   unsigned int quarantine_count,
+   ...)
 {
 }
 
diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
index 5e9f90bbf771b0..ab1253fde244ea 100644
--- a/lib/ref_tracker.c
+++ b/lib/ref_tracker.c
@@ -1,11 +1,16 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
+
+#define pr_fmt(fmt) "ref_tracker: " fmt
+
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
 #define REF_TRACKER_STACK_ENTRIES 16
+#define STACK_BUF_SIZE 1024
 
 struct ref_tracker {
struct list_headhead;   /* anchor into dir->list or 
dir->quarantine */
@@ -14,24 +19,87 @@ struct ref_tracker {
depot_stack_handle_tfree_stack_handle;
 };
 
-void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
-  unsigned int display_limit)
+struct ref_tracker_dir_stats {
+   int total;
+   int count;
+   struct {
+   depot_stack_handle_t stack_handle;
+   unsigned int count;
+   } stacks[];
+};
+
+static struct ref_tracker_dir_stats *
+ref_tracker_get_stats(struct ref_tracker_dir *dir, unsigned int limit)
 {
+   struct ref_tracker_dir_stats *stats;
struct ref_tracker *tracker;
-   unsigned int i = 0;
 
-   lockdep_assert_held(>lock);
+   stats = kmalloc(struct_size(stats, stacks, limit),
+   GFP_NOWAIT | __GFP_NOWARN);
+   if (!stats)
+   return ERR_PTR(-ENOMEM);
+   stats->total = 0;
+   stats->count = 0;
 
list_for_each_entry(tracker, >list, head) {
-   if (i < display_limit) {
-   pr_err("leaked reference.\n");
-   if (tracker->alloc_stack_handle)
-   stack_depot_print(tracker->alloc_stack_handle);
-   i++;
-   } else {
-   break;
+   depot_stack_handle_t stack = tracker->alloc_stack_handle;
+   int i;
+
+   ++stats->total;
+   for (i = 0; i < stats->count; ++i)
+   if (stats->stacks[i].stack_handle == stack)
+   break;
+   if (i >= limit)
+   continue;
+   if (i >= stats->count) {
+   stats->stacks[i].stack_handle = stack;
+   stats->stacks[i].count = 0;
+   ++stats->count;
}
+   ++stats->stacks[i].count;
+   }
+
+   return stats;
+}
+
+void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
+  unsigned int display_limit)
+{
+   struct ref_tracker_dir_stats *stats;
+   unsigned int i = 0, skipped;
+   depot_stack_handle_t 

[PATCH v4 01/10] lib/ref_tracker: add unlocked leak print helper

2023-03-06 Thread Andrzej Hajda
To have reliable detection of leaks, caller must be able to check under the same
lock both: tracked counter and the leaks. dir.lock is natural candidate for such
lock and unlocked print helper can be called with this lock taken.
As a bonus we can reuse this helper in ref_tracker_dir_exit.

Signed-off-by: Andrzej Hajda 
---
 include/linux/ref_tracker.h |  8 ++
 lib/ref_tracker.c   | 66 ++---
 2 files changed, 46 insertions(+), 28 deletions(-)

diff --git a/include/linux/ref_tracker.h b/include/linux/ref_tracker.h
index 9ca353ab712b5e..3e9e9df2a41f5f 100644
--- a/include/linux/ref_tracker.h
+++ b/include/linux/ref_tracker.h
@@ -36,6 +36,9 @@ static inline void ref_tracker_dir_init(struct 
ref_tracker_dir *dir,
 
 void ref_tracker_dir_exit(struct ref_tracker_dir *dir);
 
+void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
+  unsigned int display_limit);
+
 void ref_tracker_dir_print(struct ref_tracker_dir *dir,
   unsigned int display_limit);
 
@@ -56,6 +59,11 @@ static inline void ref_tracker_dir_exit(struct 
ref_tracker_dir *dir)
 {
 }
 
+static inline void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
+  unsigned int display_limit)
+{
+}
+
 static inline void ref_tracker_dir_print(struct ref_tracker_dir *dir,
 unsigned int display_limit)
 {
diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
index dc7b14aa3431e2..5e9f90bbf771b0 100644
--- a/lib/ref_tracker.c
+++ b/lib/ref_tracker.c
@@ -14,6 +14,38 @@ struct ref_tracker {
depot_stack_handle_tfree_stack_handle;
 };
 
+void __ref_tracker_dir_print(struct ref_tracker_dir *dir,
+  unsigned int display_limit)
+{
+   struct ref_tracker *tracker;
+   unsigned int i = 0;
+
+   lockdep_assert_held(>lock);
+
+   list_for_each_entry(tracker, >list, head) {
+   if (i < display_limit) {
+   pr_err("leaked reference.\n");
+   if (tracker->alloc_stack_handle)
+   stack_depot_print(tracker->alloc_stack_handle);
+   i++;
+   } else {
+   break;
+   }
+   }
+}
+EXPORT_SYMBOL(__ref_tracker_dir_print);
+
+void ref_tracker_dir_print(struct ref_tracker_dir *dir,
+  unsigned int display_limit)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(>lock, flags);
+   __ref_tracker_dir_print(dir, display_limit);
+   spin_unlock_irqrestore(>lock, flags);
+}
+EXPORT_SYMBOL(ref_tracker_dir_print);
+
 void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
 {
struct ref_tracker *tracker, *n;
@@ -27,13 +59,13 @@ void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
kfree(tracker);
dir->quarantine_avail++;
}
-   list_for_each_entry_safe(tracker, n, >list, head) {
-   pr_err("leaked reference.\n");
-   if (tracker->alloc_stack_handle)
-   stack_depot_print(tracker->alloc_stack_handle);
+   if (!list_empty(>list)) {
+   __ref_tracker_dir_print(dir, 16);
leak = true;
-   list_del(>head);
-   kfree(tracker);
+   list_for_each_entry_safe(tracker, n, >list, head) {
+   list_del(>head);
+   kfree(tracker);
+   }
}
spin_unlock_irqrestore(>lock, flags);
WARN_ON_ONCE(leak);
@@ -42,28 +74,6 @@ void ref_tracker_dir_exit(struct ref_tracker_dir *dir)
 }
 EXPORT_SYMBOL(ref_tracker_dir_exit);
 
-void ref_tracker_dir_print(struct ref_tracker_dir *dir,
-  unsigned int display_limit)
-{
-   struct ref_tracker *tracker;
-   unsigned long flags;
-   unsigned int i = 0;
-
-   spin_lock_irqsave(>lock, flags);
-   list_for_each_entry(tracker, >list, head) {
-   if (i < display_limit) {
-   pr_err("leaked reference.\n");
-   if (tracker->alloc_stack_handle)
-   stack_depot_print(tracker->alloc_stack_handle);
-   i++;
-   } else {
-   break;
-   }
-   }
-   spin_unlock_irqrestore(>lock, flags);
-}
-EXPORT_SYMBOL(ref_tracker_dir_print);
-
 int ref_tracker_alloc(struct ref_tracker_dir *dir,
  struct ref_tracker **trackerp,
  gfp_t gfp)

-- 
2.34.1


[PATCH v4 00/10] drm/i915: use ref_tracker library for tracking wakerefs

2023-03-06 Thread Andrzej Hajda
This is revived patchset improving ref_tracker library and converting
i915 internal tracker to ref_tracker.
The old thread ended without consensus about small kernel allocations,
which are performed under spinlock.
I have tried to solve the problem by splitting the calls, but it results
in complicated API, so I went back to original solution.
If there are better solutions I am glad to discuss them.
Meanwhile I send original patchset with addressed remaining comments.

To: Jani Nikula 
To: Joonas Lahtinen 
To: Rodrigo Vivi 
To: Tvrtko Ursulin 
To: David Airlie 
To: Daniel Vetter 
Cc: linux-ker...@vger.kernel.org
Cc: intel-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: Chris Wilson 
Cc: net...@vger.kernel.org
Cc: Eric Dumazet 
Cc: Jakub Kicinski 
Cc: Dmitry Vyukov 
Signed-off-by: Andrzej Hajda 

---
Changes in v4:
- split "Separate wakeref tracking" to smaller parts
- fixed typos,
- Link to v1-v3: https://patchwork.freedesktop.org/series/100327/

---
Andrzej Hajda (7):
  lib/ref_tracker: add unlocked leak print helper
  lib/ref_tracker: __ref_tracker_dir_print improve printing
  lib/ref_tracker: add printing to memory buffer
  lib/ref_tracker: remove warnings in case of allocation failure
  drm/i915: Separate wakeref tracking types from rpm
  drm/i915: Correct type of wakeref variable
  drm/i915: replace Intel internal tracker with kernel core ref_tracker

Chris Wilson (3):
  drm/i915: Separate wakeref tracking
  drm/i915: Track leaked gt->wakerefs
  drm/i915/gt: Hold a wakeref for the active VM

 drivers/gpu/drm/i915/Kconfig.debug |  19 ++
 drivers/gpu/drm/i915/Makefile  |   1 +
 drivers/gpu/drm/i915/display/intel_display_power.c |   2 +-
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c |   7 +-
 .../drm/i915/gem/selftests/i915_gem_coherency.c|  10 +-
 drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c |  14 +-
 drivers/gpu/drm/i915/gt/intel_breadcrumbs.c|  13 +-
 drivers/gpu/drm/i915/gt/intel_breadcrumbs_types.h  |   3 +-
 drivers/gpu/drm/i915/gt/intel_context.h|  15 +-
 drivers/gpu/drm/i915/gt/intel_context_types.h  |   2 +
 drivers/gpu/drm/i915/gt/intel_engine_pm.c  |  10 +-
 drivers/gpu/drm/i915/gt/intel_engine_types.h   |   2 +
 .../gpu/drm/i915/gt/intel_execlists_submission.c   |   2 +-
 drivers/gpu/drm/i915/gt/intel_gt_pm.c  |  12 +-
 drivers/gpu/drm/i915/gt/intel_gt_pm.h  |  38 +++-
 drivers/gpu/drm/i915/gt/intel_gt_pm_debugfs.c  |   4 +-
 drivers/gpu/drm/i915/gt/selftest_engine_cs.c   |  20 +-
 drivers/gpu/drm/i915/gt/selftest_gt_pm.c   |   5 +-
 drivers/gpu/drm/i915/gt/selftest_reset.c   |  10 +-
 drivers/gpu/drm/i915/gt/selftest_rps.c |  17 +-
 drivers/gpu/drm/i915/gt/selftest_slpc.c|   5 +-
 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c  |  11 +-
 drivers/gpu/drm/i915/i915_driver.c |   2 +-
 drivers/gpu/drm/i915/i915_pmu.c|  16 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c| 221 ++---
 drivers/gpu/drm/i915/intel_runtime_pm.h|  11 +-
 drivers/gpu/drm/i915/intel_wakeref.c   |   7 +-
 drivers/gpu/drm/i915/intel_wakeref.h   | 112 ++-
 include/linux/ref_tracker.h|  31 ++-
 lib/ref_tracker.c  | 179 ++---
 30 files changed, 469 insertions(+), 332 deletions(-)
---
base-commit: 1ddc2e762c6a109af52f3c39534c7115aebe
change-id: 20230224-track_gt-1b3da8bdacd7

Best regards,
-- 
Andrzej Hajda 


Re: [Intel-gfx] [PATCH 1/3] drm/i915: Set I915_BO_ALLOC_USER for framebuffer

2023-03-06 Thread Das, Nirmoy



On 3/6/2023 3:21 PM, Ville Syrjälä wrote:

On Mon, Mar 06, 2023 at 11:28:48AM +0100, Nirmoy Das wrote:

Framebuffer is exposed to userspace so set I915_BO_ALLOC_USER
flag for it. This also make sure that ttm allocates offset
for lmem objects.

I have no idea what that means.


Sorry for poor explanation.

Without I915_BO_ALLOC_USER, ttm will assume the obj as kernel buffer and 
will not allocate fake offset which I needed for fb_mmap callback to work.


Regards,
Nirmoy




Signed-off-by: Nirmoy Das 
---
  drivers/gpu/drm/i915/display/intel_dpt.c   | 4 +++-
  drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++-
  drivers/gpu/drm/i915/display/intel_plane_initial.c | 3 ++-
  3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c 
b/drivers/gpu/drm/i915/display/intel_dpt.c
index ad1a37b515fb..2e6238881860 100644
--- a/drivers/gpu/drm/i915/display/intel_dpt.c
+++ b/drivers/gpu/drm/i915/display/intel_dpt.c
@@ -254,7 +254,9 @@ intel_dpt_create(struct intel_framebuffer *fb)
  
  	size = round_up(size * sizeof(gen8_pte_t), I915_GTT_PAGE_SIZE);
  
-	dpt_obj = i915_gem_object_create_lmem(i915, size, I915_BO_ALLOC_CONTIGUOUS);

+   dpt_obj = i915_gem_object_create_lmem(i915, size,
+ I915_BO_ALLOC_CONTIGUOUS |
+ I915_BO_ALLOC_USER);
if (IS_ERR(dpt_obj) && i915_ggtt_has_aperture(to_gt(i915)->ggtt))
dpt_obj = i915_gem_object_create_stolen(i915, size);
if (IS_ERR(dpt_obj) && !HAS_LMEM(i915)) {
diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index 3659350061a7..98ae3a3a986a 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -163,7 +163,8 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
obj = ERR_PTR(-ENODEV);
if (HAS_LMEM(dev_priv)) {
obj = i915_gem_object_create_lmem(dev_priv, size,
- I915_BO_ALLOC_CONTIGUOUS);
+ I915_BO_ALLOC_CONTIGUOUS |
+ I915_BO_ALLOC_USER);
} else {
/*
 * If the FB is too big, just don't use it since fbdev is not 
very
diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c 
b/drivers/gpu/drm/i915/display/intel_plane_initial.c
index bb6ea7de5c61..4a3680f6a3f5 100644
--- a/drivers/gpu/drm/i915/display/intel_plane_initial.c
+++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c
@@ -110,7 +110,8 @@ initial_plane_vma(struct drm_i915_private *i915,
size * 2 > i915->dsm.usable_size)
return NULL;
  
-	obj = i915_gem_object_create_region_at(mem, phys_base, size, 0);

+   obj = i915_gem_object_create_region_at(mem, phys_base, size,
+  I915_BO_ALLOC_USER);
if (IS_ERR(obj))
return NULL;
  
--

2.39.0


Re: [PATCH 11/99] fbdev/aty: Duplicate video-mode option string

2023-03-06 Thread Geert Uytterhoeven
Hi Thomas,

Thanks for your patch!

On Mon, Mar 6, 2023 at 5:00 PM Thomas Zimmermann  wrote:
> Assume that the driver does not own the option string or its substrings
> and hence duplicate the option string for the video mode. The driver only
> parses the option string once as part of module initialization, so use
> a static buffer to store the duplicated mode option. Linux automatically
> frees the memory upon releasing the module.

Are you sure about that?
All of this code is inside "#ifndef MODULE".
In the aty128fb case, the function is not marked __init.
Enabling these 3 drivers adds 3x256 bytes of static buffer, more
if you enable more fbdev drivers.

> Done in preparation of switching the driver to struct option_iter and
> constifying the option string.
>
> Signed-off-by: Thomas Zimmermann 

> --- a/drivers/video/fbdev/aty/aty128fb.c
> +++ b/drivers/video/fbdev/aty/aty128fb.c
> @@ -1723,7 +1723,17 @@ static int aty128fb_setup(char *options)
> continue;
> }
>  #endif /* CONFIG_PPC_PMAC */
> -   mode_option = this_opt;
> +   {
> +   static char mode_option_buf[256];
> +   int ret;
> +
> +   ret = snprintf(mode_option_buf, 
> sizeof(mode_option_buf), "%s", this_opt);
> +   if (WARN(ret < 0, "aty128: ignoring invalid option, 
> ret=%d\n", ret))
> +   continue;
> +   if (WARN(ret >= sizeof(mode_option_buf), "aty128fb: 
> option too long\n"))
> +   continue;
> +   mode_option = mode_option_buf;
> +   }
> }
> return 0;
>  }
eturn 0;
>  }

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 2/3] drm/i915: Add a helper func for gem obj mmap

2023-03-06 Thread Das, Nirmoy



On 3/6/2023 3:26 PM, Ville Syrjälä wrote:

On Mon, Mar 06, 2023 at 11:28:49AM +0100, Nirmoy Das wrote:

Move gem obj mmap code to i915_gem_object_mmap() so that
this can be used by others.

Signed-off-by: Nirmoy Das 
---
  drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 20 ++---
  drivers/gpu/drm/i915/gem/i915_gem_mman.c   | 25 ++
  drivers/gpu/drm/i915/gem/i915_gem_mman.h   |  1 +
  3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c 
b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index fd556a076d05..831dd8ebf819 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -12,6 +12,7 @@
  #include 
  
  #include "gem/i915_gem_dmabuf.h"

+#include "gem/i915_gem_mman.h"
  #include "i915_drv.h"
  #include "i915_gem_object.h"
  #include "i915_scatterlist.h"
@@ -94,27 +95,10 @@ static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf,
  static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct 
vm_area_struct *vma)
  {
struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
-   struct drm_i915_private *i915 = to_i915(obj->base.dev);
-   int ret;
  
  	dma_resv_assert_held(dma_buf->resv);
  
-	if (obj->base.size < vma->vm_end - vma->vm_start)

-   return -EINVAL;
-
-   if (HAS_LMEM(i915))
-   return drm_gem_prime_mmap(>base, vma);
-
-   if (!obj->base.filp)
-   return -ENODEV;
-
-   ret = call_mmap(obj->base.filp, vma);
-   if (ret)
-   return ret;
-
-   vma_set_file(vma, obj->base.filp);
-
-   return 0;
+   return i915_gem_object_mmap(obj, vma);
  }
  
  static int i915_gem_begin_cpu_access(struct dma_buf *dma_buf, enum dma_data_direction direction)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c 
b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index 2aac6bf78740..d378720ca626 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -11,6 +11,8 @@
  
  #include 
  
+#include "gem/i915_gem_lmem.h"

+
  #include "gt/intel_gt.h"
  #include "gt/intel_gt_requests.h"
  
@@ -1043,6 +1045,29 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma)

return 0;
  }
  
+int i915_gem_object_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma)

+{
+   struct drm_i915_private *i915 = to_i915(obj->base.dev);
+   int ret;
+
+   if (obj->base.size < vma->vm_end - vma->vm_start)
+   return -EINVAL;
+
+   if (HAS_LMEM(i915))
+   return drm_gem_prime_mmap(>base, vma);

Calling some prime stuff here doesn't smell right.


Yes, I should use drm_gem_mmap_obj() here.





+
+   if (obj->base.filp) {
+   ret = call_mmap(obj->base.filp, vma);
+   if (ret)
+   return ret;
+
+   vma_set_file(vma, obj->base.filp);
+   return 0;
+   }
+
+   return -ENODEV;
+}
+
  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftests/i915_gem_mman.c"
  #endif
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.h 
b/drivers/gpu/drm/i915/gem/i915_gem_mman.h
index 1fa91b3033b3..303e81ddc5ba 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.h
@@ -30,4 +30,5 @@ void i915_gem_object_release_mmap_gtt(struct 
drm_i915_gem_object *obj);
  void i915_gem_object_runtime_pm_release_mmap_offset(struct 
drm_i915_gem_object *obj);
  void i915_gem_object_release_mmap_offset(struct drm_i915_gem_object *obj);
  
+int i915_gem_object_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma);

  #endif
--
2.39.0


Re: [PATCH] amdgpu: Avoid building on UML

2023-03-06 Thread Felix Kuehling
Looks like this patch got lost over the holidays. Alex, are you OK with 
applying this patch? Or are people looking for a more general solution 
to not build HW drivers for UML? FWIW:


Acked-by: Felix Kuehling 


Am 2023-01-12 um 23:30 schrieb Peter Foley:

The amdgpu driver tries to use fields not supported by UML's cpuinfo
struct. Disable the driver when targeting UML to avoid tripping up
allyesconfig.

e.g.
../drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/smu7_hwmgr.c: In function 
‘intel_core_rkl_chk’:
../drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/smu7_hwmgr.c:1742:33: 
error: initialization of ‘struct cpuinfo_x86 *’ from incompatible pointer type 
‘struct cpuinfo_um *’ [-Werror=incompatible-pointer-types
]
../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: In function 
‘kfd_cpumask_to_apic_id’:
../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:2157:48: error: ‘struct 
cpuinfo_um’ has no member named ‘apicid’

Signed-off-by: Peter Foley 
---
  drivers/gpu/drm/amd/amdgpu/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig 
b/drivers/gpu/drm/amd/amdgpu/Kconfig
index 5fcd510f1abb..aa0008ff8712 100644
--- a/drivers/gpu/drm/amd/amdgpu/Kconfig
+++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
@@ -3,6 +3,7 @@
  config DRM_AMDGPU
tristate "AMD GPU"
depends on DRM && PCI && MMU
+   depends on !UML
select FW_LOADER
select DRM_DISPLAY_DP_HELPER
select DRM_DISPLAY_HDMI_HELPER

---
base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
change-id: 20230112-amduml-565935d34bfb

Best regards,


[PATCH 57/99] fbdev/pm2fb: Duplicate video-mode option string

2023-03-06 Thread Thomas Zimmermann
Assume that the driver does not own the option string or its substrings
and hence duplicate the option string for the video mode. The driver only
parses the option string once as part of module initialization, so use
a static buffer to store the duplicated mode option. Linux automatically
frees the memory upon releasing the module.

Done in preparation of switching the driver to struct option_iter and
constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/pm2fb.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c
index 47d212944f30..c6a117538fd8 100644
--- a/drivers/video/fbdev/pm2fb.c
+++ b/drivers/video/fbdev/pm2fb.c
@@ -1792,8 +1792,17 @@ static int __init pm2fb_setup(char *options)
nomtrr = 1;
else if (!strncmp(this_opt, "noaccel", 7))
noaccel = 1;
-   else
-   mode_option = this_opt;
+   else {
+   static char mode_option_buf[256];
+   int ret;
+
+   ret = snprintf(mode_option_buf, 
sizeof(mode_option_buf), "%s", this_opt);
+   if (WARN(ret < 0, "pm2fb: ignoring invalid option, 
ret=%d\n", ret))
+   continue;
+   if (WARN(ret >= sizeof(mode_option_buf), "pm2fb: option 
too long\n"))
+   continue;
+   mode_option = mode_option_buf;
+   }
}
return 0;
 }
-- 
2.39.2



[PATCH 92/99] fbdev/vesafb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/vesafb.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
index 3f8bdfcf51f0..0310a3db2b10 100644
--- a/drivers/video/fbdev/vesafb.c
+++ b/drivers/video/fbdev/vesafb.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -209,16 +210,14 @@ static struct fb_ops vesafb_ops = {
.fb_imageblit   = cfb_imageblit,
 };
 
-static int vesafb_setup(char *options)
+static int vesafb_setup(const char *options)
 {
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
-   if (!options || !*options)
-   return 0;
-
-   while ((this_opt = strsep(, ",")) != NULL) {
-   if (!*this_opt) continue;
+   option_iter_init(, options);
 
+   while (option_iter_next(, this_opt)) {
if (! strcmp(this_opt, "inverse"))
inverse=1;
else if (! strcmp(this_opt, "redraw"))
@@ -240,6 +239,9 @@ static int vesafb_setup(char *options)
else if (! strncmp(this_opt, "vremap:", 7))
vram_remap = simple_strtoul(this_opt+7, NULL, 0);
}
+
+   option_iter_release();
+
return 0;
 }
 
-- 
2.39.2



[PATCH 96/99] fbdev/viafb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/via/viafbdev.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/via/viafbdev.c 
b/drivers/video/fbdev/via/viafbdev.c
index 2d67c92c5774..4f39319e21f8 100644
--- a/drivers/video/fbdev/via/viafbdev.c
+++ b/drivers/video/fbdev/via/viafbdev.c
@@ -5,6 +5,7 @@
 
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -1922,21 +1923,18 @@ void via_fb_pci_remove(struct pci_dev *pdev)
 #ifndef MODULE
 static int __init viafb_setup(void)
 {
-   char *this_opt;
char *options;
+   struct option_iter iter;
+   const char *this_opt;
 
DEBUG_MSG(KERN_INFO "viafb_setup!\n");
 
if (fb_get_options("viafb", ))
return -ENODEV;
 
-   if (!options || !*options)
-   return 0;
-
-   while ((this_opt = strsep(, ",")) != NULL) {
-   if (!*this_opt)
-   continue;
+   option_iter_init(, options);
 
+   while (option_iter_next(, this_opt)) {
if (!strncmp(this_opt, "viafb_mode1=", 12)) {
viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
if (!viafb_mode1)
@@ -2009,6 +2007,9 @@ static int __init viafb_setup(void)
return -ENOMEM;
}
}
+
+   option_iter_release();
+
return 0;
 }
 #endif
-- 
2.39.2



[PATCH 56/99] fbdev/platinumfb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/platinumfb.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
index c7172174c1b7..71d5b7c169e7 100644
--- a/drivers/video/fbdev/platinumfb.c
+++ b/drivers/video/fbdev/platinumfb.c
@@ -19,6 +19,7 @@
 
 #undef DEBUG
 
+#include 
 #include 
 #include 
 #include 
@@ -486,14 +487,14 @@ static int platinum_var_to_par(struct fb_var_screeninfo 
*var,
 /*
  * Parse user specified options (`video=platinumfb:')
  */
-static int __init platinumfb_setup(char *options)
+static int __init platinumfb_setup(const char *options)
 {
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
-   if (!options || !*options)
-   return 0;
+   option_iter_init(, options);
 
-   while ((this_opt = strsep(, ",")) != NULL) {
+   while (option_iter_next(, this_opt)) {
if (!strncmp(this_opt, "vmode:", 6)) {
int vmode = simple_strtoul(this_opt+6, NULL, 0);
if (vmode > 0 && vmode <= VMODE_MAX)
@@ -516,6 +517,9 @@ static int __init platinumfb_setup(char *options)
}
}
}
+
+   option_iter_release();
+
return 0;
 }
 
-- 
2.39.2



[PATCH 16/99] fbdev/cirrusfb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/cirrusfb.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c
index fbf9281a7004..c6882bff3862 100644
--- a/drivers/video/fbdev/cirrusfb.c
+++ b/drivers/video/fbdev/cirrusfb.c
@@ -35,6 +35,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2323,17 +2324,14 @@ static struct zorro_driver cirrusfb_zorro_driver = {
 #endif /* CONFIG_ZORRO */
 
 #ifndef MODULE
-static int __init cirrusfb_setup(char *options)
+static int __init cirrusfb_setup(const char *options)
 {
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
-   if (!options || !*options)
-   return 0;
-
-   while ((this_opt = strsep(, ",")) != NULL) {
-   if (!*this_opt)
-   continue;
+   option_iter_init(, options);
 
+   while (option_iter_next(, this_opt)) {
if (!strcmp(this_opt, "noaccel"))
noaccel = 1;
else {
@@ -2351,6 +2349,9 @@ static int __init cirrusfb_setup(char *options)
mode_option = mode_option_buf;
}
}
+
+   option_iter_release();
+
return 0;
 }
 #endif
-- 
2.39.2



[PATCH 99/99] fbdev: Constify option strings

2023-03-06 Thread Thomas Zimmermann
Return the option string as const char* from fb_get_options() to
enforce fbdev's ownership of the memory region. Also avoids memory
allocation within fb_get_options().

Callers that have to modify the option string must create their own
copy. As most drivers use struct option_iter, this already happens
transparently in many cases.

Adapt all callers of fb_get_options().

Signed-off-by: Thomas Zimmermann 
---
 drivers/staging/sm750fb/sm750.c  |  2 +-
 drivers/video/fbdev/acornfb.c|  2 +-
 drivers/video/fbdev/amifb.c  |  2 +-
 drivers/video/fbdev/arkfb.c  |  2 +-
 drivers/video/fbdev/atafb.c  |  2 +-
 drivers/video/fbdev/aty/aty128fb.c   |  2 +-
 drivers/video/fbdev/aty/atyfb_base.c |  2 +-
 drivers/video/fbdev/aty/radeon_base.c|  2 +-
 drivers/video/fbdev/au1100fb.c   |  2 +-
 drivers/video/fbdev/au1200fb.c   |  2 +-
 drivers/video/fbdev/cirrusfb.c   |  2 +-
 drivers/video/fbdev/controlfb.c  |  2 +-
 drivers/video/fbdev/core/fb_cmdline.c| 13 +++--
 drivers/video/fbdev/core/modedb.c|  8 ++--
 drivers/video/fbdev/cyber2000fb.c|  2 +-
 drivers/video/fbdev/efifb.c  |  2 +-
 drivers/video/fbdev/ep93xx-fb.c  |  2 +-
 drivers/video/fbdev/fm2fb.c  |  2 +-
 drivers/video/fbdev/fsl-diu-fb.c |  2 +-
 drivers/video/fbdev/gbefb.c  |  2 +-
 drivers/video/fbdev/geode/gx1fb_core.c   |  2 +-
 drivers/video/fbdev/geode/gxfb_core.c|  2 +-
 drivers/video/fbdev/geode/lxfb_core.c|  2 +-
 drivers/video/fbdev/grvga.c  |  3 ++-
 drivers/video/fbdev/gxt4500.c|  2 +-
 drivers/video/fbdev/hyperv_fb.c  |  2 +-
 drivers/video/fbdev/i740fb.c |  2 +-
 drivers/video/fbdev/i810/i810_main.c |  2 +-
 drivers/video/fbdev/imsttfb.c|  2 +-
 drivers/video/fbdev/imxfb.c  |  2 +-
 drivers/video/fbdev/intelfb/intelfbdrv.c |  2 +-
 drivers/video/fbdev/kyro/fbdev.c |  2 +-
 drivers/video/fbdev/macfb.c  |  2 +-
 drivers/video/fbdev/matrox/matroxfb_base.c   |  2 +-
 drivers/video/fbdev/mx3fb.c  |  2 +-
 drivers/video/fbdev/neofb.c  |  2 +-
 drivers/video/fbdev/nvidia/nvidia.c  |  2 +-
 drivers/video/fbdev/ocfb.c   |  2 +-
 drivers/video/fbdev/omap/omapfb_main.c   |  2 +-
 drivers/video/fbdev/platinumfb.c |  2 +-
 drivers/video/fbdev/pm2fb.c  |  2 +-
 drivers/video/fbdev/pm3fb.c  |  2 +-
 drivers/video/fbdev/ps3fb.c  |  2 +-
 drivers/video/fbdev/pvr2fb.c |  2 +-
 drivers/video/fbdev/pxafb.c  |  2 +-
 drivers/video/fbdev/riva/fbdev.c |  2 +-
 drivers/video/fbdev/s3fb.c   |  2 +-
 drivers/video/fbdev/savage/savagefb_driver.c |  2 +-
 drivers/video/fbdev/sis/sis_main.c   |  2 +-
 drivers/video/fbdev/skeletonfb.c |  2 +-
 drivers/video/fbdev/sm712fb.c|  2 +-
 drivers/video/fbdev/sstfb.c  |  2 +-
 drivers/video/fbdev/stifb.c  |  2 +-
 drivers/video/fbdev/tdfxfb.c |  2 +-
 drivers/video/fbdev/tgafb.c  |  2 +-
 drivers/video/fbdev/tridentfb.c  |  2 +-
 drivers/video/fbdev/uvesafb.c|  2 +-
 drivers/video/fbdev/valkyriefb.c |  2 +-
 drivers/video/fbdev/vesafb.c |  2 +-
 drivers/video/fbdev/vfb.c|  2 +-
 drivers/video/fbdev/via/viafbdev.c   |  2 +-
 drivers/video/fbdev/vt8623fb.c   |  3 +--
 include/linux/fb.h   |  2 +-
 63 files changed, 67 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 2eb223f0631e..fe5c18e00ac8 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -1167,7 +1167,7 @@ static struct pci_driver lynxfb_driver = {
 
 static int __init lynxfb_init(void)
 {
-   char *option;
+   const char *option;
 
if (fb_modesetting_disabled("sm750fb"))
return -ENODEV;
diff --git a/drivers/video/fbdev/acornfb.c b/drivers/video/fbdev/acornfb.c
index 1d6dec45615c..be4aafb23a5c 100644
--- a/drivers/video/fbdev/acornfb.c
+++ b/drivers/video/fbdev/acornfb.c
@@ -926,7 +926,7 @@ static int acornfb_probe(struct platform_device *dev)
unsigned long size;
u_int h_sync, v_sync;
int rc, i;
-   char *option = NULL;
+   const char *option = NULL;
 
if (fb_get_options("acornfb", ))
return -ENODEV;
diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c
index b968cf2c5f06..ef8518fd4fdc 100644
--- a/drivers/video/fbdev/amifb.c
+++ b/drivers/video/fbdev/amifb.c
@@ -3546,7 +3546,7 @@ 

[PATCH 87/99] fbdev/uvesafb: Duplicate video-mode option string

2023-03-06 Thread Thomas Zimmermann
Assume that the driver does not own the option string or its substrings
and hence duplicate the option string for the video mode. The driver only
parses the option string once as part of module initialization, so use
a static buffer to store the duplicated mode option. Linux automatically
frees the memory upon releasing the module.

Done in preparation of switching the driver to struct option_iter and
constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/uvesafb.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index f09f483c219b..201f6bba0763 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -1851,7 +1851,15 @@ static int uvesafb_setup(char *options)
else if (!strncmp(this_opt, "vbemode:", 8))
vbemode = simple_strtoul(this_opt + 8, NULL, 0);
else if (this_opt[0] >= '0' && this_opt[0] <= '9') {
-   mode_option = this_opt;
+   static char mode_option_buf[256];
+   int ret;
+
+   ret = snprintf(mode_option_buf, 
sizeof(mode_option_buf), "%s", this_opt);
+   if (WARN(ret < 0, "uvesafb: ignoring invalid option, 
ret=%d\n", ret))
+   continue;
+   if (WARN(ret >= sizeof(mode_option_buf), "uvesafb: 
option too long\n"))
+   continue;
+   mode_option = mode_option_buf;
} else {
pr_warn("unrecognized option %s\n", this_opt);
}
-- 
2.39.2



[PATCH 74/99] fbdev/skeletonfb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/skeletonfb.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/skeletonfb.c b/drivers/video/fbdev/skeletonfb.c
index 40c130ab6b38..1e876ad2a261 100644
--- a/drivers/video/fbdev/skeletonfb.c
+++ b/drivers/video/fbdev/skeletonfb.c
@@ -43,6 +43,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -973,9 +974,19 @@ static struct platform_device *xxxfb_device;
  * Only necessary if your driver takes special options,
  * otherwise we fall back on the generic fb_setup().
  */
-static int __init xxxfb_setup(char *options)
+static int __init xxxfb_setup(const char *options)
 {
-/* Parse user specified options (`video=xxxfb:') */
+   /* Parse user-specified options (`video=xxxfb:') */
+
+   struct option_iter iter;
+   const char *this_opt;
+
+   option_iter_init(, options);
+
+   while (option_iter_next(, this_opt)) {
+   }
+
+   option_iter_release();
 }
 #endif /* MODULE */
 
-- 
2.39.2



[PATCH 72/99] fbdev/sisfb: Constify mode string

2023-03-06 Thread Thomas Zimmermann
Constify the intenal video-mode string that is passed around among
functions. The caller owns the memory and callees do not modify its
content. This change will later allow to constify the option string.
No functional changes.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/sis/sis_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/sis/sis_main.c 
b/drivers/video/fbdev/sis/sis_main.c
index cfba776afcea..c16493d3ac4f 100644
--- a/drivers/video/fbdev/sis/sis_main.c
+++ b/drivers/video/fbdev/sis/sis_main.c
@@ -73,7 +73,7 @@ static intsisfb_blank(int blank,
 static void sisfb_handle_command(struct sis_video_info *ivideo,
 struct sisfb_cmd *sisfb_command);
 
-static voidsisfb_search_mode(char *name, bool quiet);
+static voidsisfb_search_mode(const char *name, bool quiet);
 static int sisfb_validate_mode(struct sis_video_info *ivideo, int 
modeindex, u32 vbflags);
 static u8  sisfb_search_refresh_rate(struct sis_video_info *ivideo, 
unsigned int rate,
int index);
@@ -180,12 +180,12 @@ static void sisfb_search_vesamode(unsigned int vesamode, 
bool quiet)
printk(KERN_ERR "sisfb: Invalid VESA mode 0x%x'\n", vesamode);
 }
 
-static void sisfb_search_mode(char *name, bool quiet)
+static void sisfb_search_mode(const char *name, bool quiet)
 {
unsigned int j = 0, xres = 0, yres = 0, depth = 0, rate = 0;
int i = 0;
char strbuf[16], strbuf1[20];
-   char *nameptr = name;
+   const char *nameptr = name;
 
/* We don't know the hardware specs yet and there is no ivideo */
 
-- 
2.39.2



[PATCH 71/99] fbdev/savagefb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/savage/savagefb_driver.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/savage/savagefb_driver.c 
b/drivers/video/fbdev/savage/savagefb_driver.c
index 19fffe0b6cdd..94026848d67d 100644
--- a/drivers/video/fbdev/savage/savagefb_driver.c
+++ b/drivers/video/fbdev/savage/savagefb_driver.c
@@ -42,6 +42,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2535,15 +2536,15 @@ static void __exit savage_done(void)
 
 /* * init in-kernel code ** */
 
-static int __init savagefb_setup(char *options)
+static int __init savagefb_setup(const char *options)
 {
 #ifndef MODULE
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
-   if (!options || !*options)
-   return 0;
+   option_iter_init(, options);
 
-   while ((this_opt = strsep(, ",")) != NULL) {
+   while (option_iter_next(, this_opt)) {
static char mode_option_buf[256];
int ret;
 
@@ -2554,6 +2555,9 @@ static int __init savagefb_setup(char *options)
continue;
mode_option = mode_option_buf;
}
+
+   option_iter_release();
+
 #endif /* !MODULE */
return 0;
 }
-- 
2.39.2



[PATCH 88/99] fbdev/uvesafb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/uvesafb.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index 201f6bba0763..aada6a44380c 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -9,6 +9,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include 
 #include 
 #include 
 #include 
@@ -1808,16 +1809,14 @@ static struct platform_driver uvesafb_driver = {
 static struct platform_device *uvesafb_device;
 
 #ifndef MODULE
-static int uvesafb_setup(char *options)
+static int uvesafb_setup(const char *options)
 {
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
-   if (!options || !*options)
-   return 0;
-
-   while ((this_opt = strsep(, ",")) != NULL) {
-   if (!*this_opt) continue;
+   option_iter_init(, options);
 
+   while (option_iter_next(, this_opt)) {
if (!strcmp(this_opt, "redraw"))
ypan = 0;
else if (!strcmp(this_opt, "ypan"))
@@ -1865,6 +1864,8 @@ static int uvesafb_setup(char *options)
}
}
 
+   option_iter_release();
+
if (mtrr != 3 && mtrr != 0)
pr_warn("uvesafb: mtrr should be set to 0 or 3; %d is 
unsupported", mtrr);
 
-- 
2.39.2



[PATCH 64/99] fbdev/pvr2fb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/pvr2fb.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c
index cd778f8753f1..9255b3506b81 100644
--- a/drivers/video/fbdev/pvr2fb.c
+++ b/drivers/video/fbdev/pvr2fb.c
@@ -46,6 +46,7 @@
 #undef DEBUG
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1024,20 +1025,18 @@ static void pvr2fb_pci_exit(void)
  */
 
 #ifndef MODULE
-static int __init pvr2fb_setup(char *options)
+static int __init pvr2fb_setup(const char *options)
 {
-   char *this_opt;
char cable_arg[80];
char output_arg[80];
-
-   if (!options || !*options)
-   return 0;
+   struct option_iter iter;
+   const char *this_opt;
 
cable_arg[0] = output_arg[0] = 0;
 
-   while ((this_opt = strsep(, ","))) {
-   if (!*this_opt)
-   continue;
+   option_iter_init(, options);
+
+   while (option_iter_next(, this_opt)) {
if (!strcmp(this_opt, "inverse")) {
fb_invert_cmaps();
} else if (!strncmp(this_opt, "cable:", 6)) {
@@ -1061,6 +1060,8 @@ static int __init pvr2fb_setup(char *options)
}
}
 
+   option_iter_release();
+
if (*cable_arg)
cable_type = pvr2_get_param_val(cables, cable_arg, 3);
if (*output_arg)
-- 
2.39.2



[PATCH 62/99] fbdev/ps3fb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/ps3fb.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c
index 87543411acaf..d7c287089c64 100644
--- a/drivers/video/fbdev/ps3fb.c
+++ b/drivers/video/fbdev/ps3fb.c
@@ -17,6 +17,7 @@
  *  more details.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -1256,6 +1257,8 @@ static struct ps3_system_bus_driver ps3fb_driver = {
 static int __init ps3fb_setup(void)
 {
char *options;
+   struct option_iter iter;
+   const char *this_opt;
 
 #ifdef MODULE
return 0;
@@ -1264,16 +1267,9 @@ static int __init ps3fb_setup(void)
if (fb_get_options(DEVICE_NAME, ))
return -ENXIO;
 
-   if (!options || !*options)
-   return 0;
-
-   while (1) {
-   char *this_opt = strsep(, ",");
+   option_iter_init(, options);
 
-   if (!this_opt)
-   break;
-   if (!*this_opt)
-   continue;
+   while (option_iter_next(, this_opt)) {
if (!strncmp(this_opt, "mode:", 5))
ps3fb_mode = simple_strtoul(this_opt + 5, NULL, 0);
else {
@@ -1288,6 +1284,9 @@ static int __init ps3fb_setup(void)
mode_option = mode_option_buf;
}
}
+
+   option_iter_release();
+
return 0;
 }
 
-- 
2.39.2



[PATCH 89/99] fbdev/valkyriefb: Remove trailing whitespaces

2023-03-06 Thread Thomas Zimmermann
Fix coding style. No functional changes.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/valkyriefb.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c
index 1007023a5e88..b166b7cfe0e5 100644
--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -1,7 +1,7 @@
 /*
  *  valkyriefb.c -- frame buffer device for the PowerMac 'valkyrie' display
  *
- *  Created 8 August 1998 by 
+ *  Created 8 August 1998 by
  *  Martin Costabel  and Kevin Schoedel
  *
  *  Vmode-switching changes and vmode 15/17 modifications created 29 August
@@ -77,13 +77,13 @@ struct fb_info_valkyrie {
struct fb_par_valkyrie  par;
struct cmap_regs__iomem *cmap_regs;
unsigned long   cmap_regs_phys;
-   
+
struct valkyrie_regs__iomem *valkyrie_regs;
unsigned long   valkyrie_regs_phys;
-   
+
__u8__iomem *frame_buffer;
unsigned long   frame_buffer_phys;
-   
+
int sense;
unsigned long   total_vram;
 
@@ -244,7 +244,7 @@ static inline int valkyrie_vram_reqd(int video_mode, int 
color_mode)
 {
int pitch;
struct valkyrie_regvals *init = valkyrie_reg_init[video_mode-1];
-   
+
if ((pitch = init->pitch[color_mode]) == 0)
pitch = 2 * init->pitch[0];
return init->vres * pitch;
@@ -467,7 +467,7 @@ static int valkyrie_var_to_par(struct fb_var_screeninfo 
*var,
printk(KERN_ERR "valkyriefb: vmode %d not valid.\n", vmode);
return -EINVAL;
}
-   
+
if (cmode != CMODE_8 && cmode != CMODE_16) {
printk(KERN_ERR "valkyriefb: cmode %d not valid.\n", cmode);
return -EINVAL;
@@ -516,7 +516,7 @@ static void valkyrie_init_fix(struct fb_fix_screeninfo 
*fix, struct fb_info_valk
fix->ywrapstep = 0;
fix->ypanstep = 0;
fix->xpanstep = 0;
-   
+
 }
 
 /* Fix must already be inited above */
-- 
2.39.2



[PATCH 60/99] fbdev/pm3fb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/pm3fb.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c
index d0a2cf623c60..4eec0ad1e984 100644
--- a/drivers/video/fbdev/pm3fb.c
+++ b/drivers/video/fbdev/pm3fb.c
@@ -23,6 +23,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1509,18 +1510,16 @@ MODULE_DEVICE_TABLE(pci, pm3fb_id_table);
  * Only necessary if your driver takes special options,
  * otherwise we fall back on the generic fb_setup().
  */
-static int __init pm3fb_setup(char *options)
+static int __init pm3fb_setup(const char *options)
 {
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
/* Parse user specified options (`video=pm3fb:') */
-   if (!options || !*options)
-   return 0;
+   option_iter_init(, options);
 
-   while ((this_opt = strsep(, ",")) != NULL) {
-   if (!*this_opt)
-   continue;
-   else if (!strncmp(this_opt, "noaccel", 7))
+   while (option_iter_next(, this_opt)) {
+   if (!strncmp(this_opt, "noaccel", 7))
noaccel = 1;
else if (!strncmp(this_opt, "hwcursor=", 9))
hwcursor = simple_strtoul(this_opt + 9, NULL, 0);
@@ -1538,6 +1537,9 @@ static int __init pm3fb_setup(char *options)
mode_option = mode_option_buf;
}
}
+
+   option_iter_release();
+
return 0;
 }
 #endif /* MODULE */
-- 
2.39.2



[PATCH 77/99] fbdev/sstfb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/sstfb.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c
index 7cd65f924b08..6c3769062d50 100644
--- a/drivers/video/fbdev/sstfb.c
+++ b/drivers/video/fbdev/sstfb.c
@@ -81,6 +81,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1273,16 +1274,14 @@ static void sst_shutdown(struct fb_info *info)
 /*
  * Interface to the world
  */
-static int sstfb_setup(char *options)
+static int sstfb_setup(const char *options)
 {
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
-   if (!options || !*options)
-   return 0;
-
-   while ((this_opt = strsep(, ",")) != NULL) {
-   if (!*this_opt) continue;
+   option_iter_init(, options);
 
+   while (option_iter_next(, this_opt)) {
f_ddprintk("option %s\n", this_opt);
 
if (!strcmp(this_opt, "vganopass"))
@@ -1313,6 +1312,9 @@ static int sstfb_setup(char *options)
mode_option = mode_option_buf;
}
}
+
+   option_iter_release();
+
return 0;
 }
 
-- 
2.39.2



[PATCH 27/99] fbdev/geode: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/geode/gx1fb_core.c | 16 
 drivers/video/fbdev/geode/gxfb_core.c  | 17 -
 drivers/video/fbdev/geode/lxfb_core.c  | 14 ++
 3 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/drivers/video/fbdev/geode/gx1fb_core.c 
b/drivers/video/fbdev/geode/gx1fb_core.c
index 9c942001ac10..dd1dc7ee7f83 100644
--- a/drivers/video/fbdev/geode/gx1fb_core.c
+++ b/drivers/video/fbdev/geode/gx1fb_core.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -403,17 +404,14 @@ static void gx1fb_remove(struct pci_dev *pdev)
 }
 
 #ifndef MODULE
-static void __init gx1fb_setup(char *options)
+static void __init gx1fb_setup(const char *options)
 {
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
-   if (!options || !*options)
-   return;
-
-   while ((this_opt = strsep(, ","))) {
-   if (!*this_opt)
-   continue;
+   option_iter_init(, options);
 
+   while (option_iter_next(, this_opt)) {
if (!strncmp(this_opt, "mode:", 5))
strscpy(mode_option, this_opt + 5, sizeof(mode_option));
else if (!strncmp(this_opt, "crt:", 4))
@@ -423,6 +421,8 @@ static void __init gx1fb_setup(char *options)
else
strscpy(mode_option, this_opt, sizeof(mode_option));
}
+
+   option_iter_release();
 }
 #endif
 
diff --git a/drivers/video/fbdev/geode/gxfb_core.c 
b/drivers/video/fbdev/geode/gxfb_core.c
index 3ed85d2d53e9..f5e88e92ba16 100644
--- a/drivers/video/fbdev/geode/gxfb_core.c
+++ b/drivers/video/fbdev/geode/gxfb_core.c
@@ -16,6 +16,7 @@
  * 16 MiB of framebuffer memory is assumed to be available.
  */
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -488,21 +489,17 @@ static struct pci_driver gxfb_driver = {
 };
 
 #ifndef MODULE
-static int __init gxfb_setup(char *options)
+static int __init gxfb_setup(const char *options)
 {
+   struct option_iter iter;
+   const char *opt;
 
-   char *opt;
+   option_iter_init(, options);
 
-   if (!options || !*options)
-   return 0;
-
-   while ((opt = strsep(, ",")) != NULL) {
+   while (option_iter_next(, opt)) {
static char mode_option_buf[256];
int ret;
 
-   if (!*opt)
-   continue;
-
ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", 
opt);
if (WARN(ret < 0, "gxfb: ignoring invalid option, ret=%d\n", 
ret))
continue;
@@ -511,6 +508,8 @@ static int __init gxfb_setup(char *options)
mode_option = mode_option_buf;
}
 
+   option_iter_release();
+
return 0;
 }
 #endif
diff --git a/drivers/video/fbdev/geode/lxfb_core.c 
b/drivers/video/fbdev/geode/lxfb_core.c
index 6e1e73a21bdb..d687054cdb09 100644
--- a/drivers/video/fbdev/geode/lxfb_core.c
+++ b/drivers/video/fbdev/geode/lxfb_core.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -618,17 +619,14 @@ static struct pci_driver lxfb_driver = {
 };
 
 #ifndef MODULE
-static int __init lxfb_setup(char *options)
+static int __init lxfb_setup(const char *options)
 {
-   char *opt;
+   struct option_iter iter;
+   const char *opt;
 
-   if (!options || !*options)
-   return 0;
-
-   while ((opt = strsep(, ",")) != NULL) {
-   if (!*opt)
-   continue;
+   option_iter_init(, options);
 
+   while (option_iter_next(, opt)) {
if (!strcmp(opt, "noclear"))
noclear = 1;
else if (!strcmp(opt, "nopanel"))
-- 
2.39.2



[PATCH 55/99] fbdev/platinumfb: Remove trailing whitespaces

2023-03-06 Thread Thomas Zimmermann
Fix coding style. No functional changes.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/platinumfb.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
index 5b9e26ea6449..c7172174c1b7 100644
--- a/drivers/video/fbdev/platinumfb.c
+++ b/drivers/video/fbdev/platinumfb.c
@@ -52,17 +52,17 @@ struct fb_info_platinum {
__u8 red, green, blue;
}   palette[256];
u32 pseudo_palette[16];
-   
+
volatile struct cmap_regs   __iomem *cmap_regs;
unsigned long   cmap_regs_phys;
-   
+
volatile struct platinum_regs   __iomem *platinum_regs;
unsigned long   platinum_regs_phys;
-   
+
__u8__iomem *frame_buffer;
volatile __u8   __iomem *base_frame_buffer;
unsigned long   frame_buffer_phys;
-   
+
unsigned long   total_vram;
int clktype;
int dactype;
@@ -133,7 +133,7 @@ static int platinumfb_set_par (struct fb_info *info)
platinum_set_hardware(pinfo);
 
init = platinum_reg_init[pinfo->vmode-1];
-   
+
if ((pinfo->vmode == VMODE_832_624_75) && (pinfo->cmode > CMODE_8))
offset = 0x10;
 
@@ -214,7 +214,7 @@ static int platinumfb_setcolreg(u_int regno, u_int red, 
u_int green, u_int blue,
break;
}
}
-   
+
return 0;
 }
 
@@ -269,7 +269,7 @@ static void platinum_set_hardware(struct fb_info_platinum 
*pinfo)
struct platinum_regvals *init;
int i;
int vmode, cmode;
-   
+
vmode = pinfo->vmode;
cmode = pinfo->cmode;
 
@@ -436,7 +436,7 @@ static int read_platinum_sense(struct fb_info_platinum 
*info)
  * This routine takes a user-supplied var, and picks the best vmode/cmode from 
it.
  * It also updates the var structure to the actual mode data obtained
  */
-static int platinum_var_to_par(struct fb_var_screeninfo *var, 
+static int platinum_var_to_par(struct fb_var_screeninfo *var,
   struct fb_info_platinum *pinfo,
   int check_only)
 {
@@ -478,12 +478,12 @@ static int platinum_var_to_par(struct fb_var_screeninfo 
*var,
pinfo->yoffset = 0;
pinfo->vxres = pinfo->xres;
pinfo->vyres = pinfo->yres;
-   
+
return 0;
 }
 
 
-/* 
+/*
  * Parse user specified options (`video=platinumfb:')
  */
 static int __init platinumfb_setup(char *options)
@@ -624,7 +624,7 @@ static int platinumfb_probe(struct platform_device* odev)
break;
}
dev_set_drvdata(>dev, info);
-   
+
rc = platinum_init_fb(info);
if (rc != 0) {
iounmap(pinfo->frame_buffer);
@@ -640,9 +640,9 @@ static int platinumfb_remove(struct platform_device* odev)
 {
struct fb_info  *info = dev_get_drvdata(>dev);
struct fb_info_platinum *pinfo = info->par;
-   
+
 unregister_framebuffer (info);
-   
+
/* Unmap frame buffer and registers */
iounmap(pinfo->frame_buffer);
iounmap(pinfo->platinum_regs);
@@ -658,7 +658,7 @@ static int platinumfb_remove(struct platform_device* odev)
return 0;
 }
 
-static struct of_device_id platinumfb_match[] = 
+static struct of_device_id platinumfb_match[] =
 {
{
.name   = "platinum",
@@ -666,7 +666,7 @@ static struct of_device_id platinumfb_match[] =
{},
 };
 
-static struct platform_driver platinum_driver = 
+static struct platform_driver platinum_driver =
 {
.driver = {
.name = "platinumfb",
-- 
2.39.2



[PATCH 54/99] fbdev/omapfb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/omap/omapfb_main.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/omap/omapfb_main.c 
b/drivers/video/fbdev/omap/omapfb_main.c
index 1f3df2055ff0..464a667708db 100644
--- a/drivers/video/fbdev/omap/omapfb_main.c
+++ b/drivers/video/fbdev/omap/omapfb_main.c
@@ -11,6 +11,7 @@
  *   Dirk Behme   - changes for 2.6 kernel API
  *   Texas Instruments - H3 support
  */
+#include 
 #include 
 #include 
 #include 
@@ -1842,17 +1843,17 @@ static struct platform_driver omapfb_driver = {
 #ifndef MODULE
 
 /* Process kernel command line parameters */
-static int __init omapfb_setup(char *options)
+static int __init omapfb_setup(const char *options)
 {
-   char *this_opt = NULL;
+   struct option_iter iter;
+   const char *this_opt;
int r = 0;
 
pr_debug("omapfb: options %s\n", options);
 
-   if (!options || !*options)
-   return 0;
+   option_iter_init(, options);
 
-   while (!r && (this_opt = strsep(, ",")) != NULL) {
+   while (option_iter_next(, this_opt)) {
if (!strncmp(this_opt, "accel", 5))
def_accel = 1;
else if (!strncmp(this_opt, "vram:", 5)) {
@@ -1893,6 +1894,8 @@ static int __init omapfb_setup(char *options)
}
}
 
+   option_iter_release();
+
return r;
 }
 
-- 
2.39.2



[PATCH 38/99] fbdev/intelfb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/intelfb/intelfbdrv.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c 
b/drivers/video/fbdev/intelfb/intelfbdrv.c
index 896c2646e2ae..2d4e03b9e7fd 100644
--- a/drivers/video/fbdev/intelfb/intelfbdrv.c
+++ b/drivers/video/fbdev/intelfb/intelfbdrv.c
@@ -108,6 +108,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -323,9 +324,10 @@ static __inline__ int get_opt_bool(const char *this_opt, 
const char *name,
return 1;
 }
 
-static int __init intelfb_setup(char *options)
+static int __init intelfb_setup(const char *options)
 {
-   char *this_opt;
+   struct option_iter iter;
+   const char *this_opt;
 
DBG_MSG("intelfb_setup\n");
 
@@ -348,9 +350,9 @@ static int __init intelfb_setup(char *options)
 *video=intelfb:1024x768-16@75,accel=0
 */
 
-   while ((this_opt = strsep(, ","))) {
-   if (!*this_opt)
-   continue;
+   option_iter_init(, options);
+
+   while (option_iter_next(, this_opt)) {
if (get_opt_bool(this_opt, "accel", ))
;
else if (get_opt_int(this_opt, "vram", ))
@@ -378,6 +380,8 @@ static int __init intelfb_setup(char *options)
}
}
 
+   option_iter_release();
+
return 0;
 }
 
-- 
2.39.2



[PATCH 23/99] fbdev/fsl-diu-fb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/fbdev/fsl-diu-fb.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c
index e01281959062..c97a9c04e8e8 100644
--- a/drivers/video/fbdev/fsl-diu-fb.c
+++ b/drivers/video/fbdev/fsl-diu-fb.c
@@ -12,6 +12,7 @@
  *   Based on imxfb.c Copyright (C) 2004 S.Hauer, Pengutronix
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -1842,17 +1843,15 @@ static int fsl_diu_remove(struct platform_device *pdev)
 }
 
 #ifndef MODULE
-static int __init fsl_diu_setup(char *options)
+static int __init fsl_diu_setup(const char *options)
 {
-   char *opt;
+   struct option_iter iter;
+   const char *opt;
unsigned long val;
 
-   if (!options || !*options)
-   return 0;
+   option_iter_init(, options);
 
-   while ((opt = strsep(, ",")) != NULL) {
-   if (!*opt)
-   continue;
+   while (option_iter_next(, opt)) {
if (!strncmp(opt, "monitor=", 8)) {
monitor_port = fsl_diu_name_to_port(opt + 8);
} else if (!strncmp(opt, "bpp=", 4)) {
@@ -1871,6 +1870,8 @@ static int __init fsl_diu_setup(char *options)
}
}
 
+   option_iter_release();
+
return 0;
 }
 #endif
-- 
2.39.2



[PATCH 98/99] staging/sm750fb: Parse option string with struct option_iter

2023-03-06 Thread Thomas Zimmermann
Use struct option_iter to walk over the individual options in the
driver's option string. Replaces the hand-written strsep() loop with
a clean interface. The helpers for struct option_iter handle empty
option strings and empty options transparently. The struct's _init
and _release functions duplicate and release the option string's
memory buffer as needed.

Done in preparation of constifying the option string.

Signed-off-by: Thomas Zimmermann 
---
 drivers/staging/sm750fb/sm750.c | 43 +
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index effc7fcc3703..2eb223f0631e 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -867,9 +868,10 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int 
index)
 }
 
 /* chip specific g_option configuration routine */
-static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src)
+static void sm750fb_setup(struct sm750_dev *sm750_dev, const char *src)
 {
-   char *opt;
+   struct option_iter iter;
+   const char *opt;
int swap;
 
swap = 0;
@@ -889,9 +891,12 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, 
char *src)
goto NO_PARAM;
}
 
-   while ((opt = strsep(, ":")) != NULL && *opt != 0) {
+   dev_info(_dev->pdev->dev, "src=%s\n", src);
+
+   option_iter_init(, src);
+
+   while (option_iter_next(, opt)) {
dev_info(_dev->pdev->dev, "opt=%s\n", opt);
-   dev_info(_dev->pdev->dev, "src=%s\n", src);
 
if (!strncmp(opt, "swap", strlen("swap"))) {
swap = 1;
@@ -924,6 +929,8 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char 
*src)
}
}
 
+   option_iter_release();
+
 NO_PARAM:
if (sm750_dev->revid != SM750LE_REVISION_ID) {
if (sm750_dev->fb_count > 1) {
@@ -1096,10 +1103,12 @@ static void lynxfb_pci_remove(struct pci_dev *pdev)
kfree(g_settings);
 }
 
-static int __init lynxfb_setup(char *options)
+static int __init lynxfb_setup(const char *options)
 {
+   struct option_iter iter;
+   const char *opt;
int len;
-   char *opt, *tmp;
+   char *tmp;
 
if (!options || !*options) {
pr_warn("no options.\n");
@@ -1112,19 +1121,11 @@ static int __init lynxfb_setup(char *options)
g_settings = kzalloc(len, GFP_KERNEL);
if (!g_settings)
return -ENOMEM;
-
tmp = g_settings;
 
-   /*
-* Notes:
-* char * strsep(char **s,const char * ct);
-* @s: the string to be searched
-* @ct :the characters to search for
-*
-* strsep() updates @options to pointer after the first found token
-* it also returns the pointer ahead the token.
-*/
-   while ((opt = strsep(, ":")) != NULL) {
+   option_iter_init(, options);
+
+   while (option_iter_next(, opt)) {
/* options that mean for any lynx chips are configured here */
if (!strncmp(opt, "noaccel", strlen("noaccel"))) {
g_noaccel = 1;
@@ -1133,15 +1134,15 @@ static int __init lynxfb_setup(char *options)
} else if (!strncmp(opt, "dual", strlen("dual"))) {
g_dualview = 1;
} else {
+   if (tmp != g_settings)
+   *tmp++ = ':'; // add separator
strcat(tmp, opt);
tmp += strlen(opt);
-   if (options)
-   *tmp++ = ':';
-   else
-   *tmp++ = 0;
}
}
 
+   option_iter_release();
+
/* misc g_settings are transport to chip specific routines */
pr_info("parameter left for chip specific analysis:%s\n", g_settings);
return 0;
-- 
2.39.2



  1   2   3   >