History log of /linux-master/drivers/staging/media/atomisp/pci/hmm/hmm.c
Revision Date Author Comments
# f5cb5ada 08-Nov-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: Drop userptr support from hmm

After the conversion to videobuf2 userptr support is no longer needed,
drop it.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 931d87d2 26-Sep-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: Add hmm_create_from_vmalloc_buf() function

Add a new hmm creating function to create a vmm object from a vmalloc-ed
kernel buffer. This is a preparation patch for adding videobuf2 (and
working MMAP mode) support.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# ce2203e7 13-Apr-2022 Fabio M. De Francesco <fmdefrancesco@gmail.com>

media: staging: media: atomisp: Use kmap_local_page() in hmm_store()

The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. The same is true for kmap_atomic().

In file pci/hmm/hmm.c, function hmm_store() test if we are in atomic
context and, if so, it calls kmap_atomic(), if not, it calls kmap().

First of all, in_atomic() shouldn't be used in drivers. This macro
cannot always detect atomic context; in particular, it cannot know
about held spinlocks in non-preemptible kernels.

Notwithstanding what it is said above, this code doesn't need to care
whether or not it is executing in atomic context. It can simply use
kmap_local_page() / kunmap_local() that can instead do the mapping /
unmapping regardless of the context.

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore, hmm_store()() is a function where the use
of kmap_local_page() in place of both kmap() and kmap_atomic() is
correctly suited.

Convert the calls of kmap() / kunmap() and kmap_atomic() /
kunmap_atomic() to kmap_local_page() / kunmap_local() and drop the
unnecessary tests which test if the code is in atomic context.

Link: https://lore.kernel.org/linux-media/20220413225531.9425-1-fmdefrancesco@gmail.com
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# aab1c42a 13-Apr-2022 Fabio M. De Francesco <fmdefrancesco@gmail.com>

media: staging: media: atomisp: Use kmap_local_page() in hmm_set()

The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. In file pci/hmm/hmm.c, function hmm_set() calls
kmap() / kunmap() where kmap_local_page() can instead do the mapping.

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore, hmm_set()() is a function where the use
of kmap_local_page() in place of kmap() is correctly suited.

Convert the calls of kmap() / kunmap() to kmap_local_page() /
kunmap_local().

Link: https://lore.kernel.org/linux-media/20220413212210.18494-1-fmdefrancesco@gmail.com
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 2ad935a1 08-Apr-2022 Fabio M. De Francesco <fmdefrancesco@gmail.com>

media: staging: media: atomisp: Convert kmap() to kmap_local_page()

The use of kmap() is being deprecated in favor of kmap_local_page() where
it is feasible. With kmap_local_page(), the mapping is per thread, CPU
local and not globally visible.

load_and_flush_by_kmap() is a function where the use of kmap_local_page()
in place of kmap() is correctly suited.

Convert load_and_flush_by_kmap() from kmap() to kmap_local_page().

Link: https://lore.kernel.org/linux-media/20220408223129.3844-1-fmdefrancesco@gmail.com
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 3a68900a 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: remove hmm_page_object

hmm_page_object only stores a struct page pointer, so we can just use
the hmm_bo.pages page pointer array everywhere.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-33-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 975c343f 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: drop highmem var/arg from the hmm code

highmem is always false, drop it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-31-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 4cc20c9c 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: Simplify hmm_alloc() calls

Make hmm_alloc() only take size as a parameter and remove other parameters.
since all callers always pass the same flags.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-30-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# ceff4bdb 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: add hmm_create_from_userdata() helper

Most hmm_alloc() callers want BO_PRIVATE type memory.

Add a hmm_create_from_userdata() helper for other cases so that
the hmm_alloc() calls for all the callers who don't want this
can be simplied.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-29-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# a9796c7b 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: remove unused hmm address translation functions

hmm_isp_vaddr_to_host_vaddr() and hmm_host_vaddr_to_hrt_vaddr()
are unused, remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-28-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 90612317 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: drop unused ATOMISP_MAP_FLAG_* flags

Drop the ATOMISP_MAP_FLAG_CACHED flag, it is never set anywhere;
also drop the matching "cached" parameter to hmm[_bo]_alloc which
value was derived form the never set flag.

Drop the ATOMISP_MAP_FLAG_NOFLUSH, it is not used anywhere.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-27-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 9f40d3a7 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: drop ATOMISP_MAP_FLAG_CLEARED

This flag is only used by one hmm_alloc() caller, drop it and make
the caller call hmm_set(ptr, 0, size) itself to do the clearing.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-26-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 454da4d2 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: remove hmm_mem_stats

Without pool support the (optional) debug logging done by these is
not really meaningful, drop it all.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-13-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# c35f36b7 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: remove hmm pool code

Since we never register any pools, this is all dead code,
remove it.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-12-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# ad4c63c3 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: remove hmm_pool_[un]register()

These are no-ops, so lets remove them.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-10-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# ca1ce57a 15-Jun-2022 Hans de Goede <hdegoede@redhat.com>

media: atomisp: drop ATOMISP_MAP_FLAG_CONTIGUOUS

Drop the ATOMISP_MAP_FLAG_CONTIGUOUS hmm_alloc flag. After the contiguous
flag removal done in previous patches in this series it is never set.

And hmm_alloc already did a WARN_ON on the flag and otherwise ignored it,
proving that contiguous support was already never used.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-9-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 127efdbc 17-Oct-2021 Tsuchiya Yuto <kitakar@gmail.com>

media: atomisp: fix dummy_ptr check to avoid duplicate active_bo

The dummy_ptr check in hmm_init() [1] results in the following
"hmm_init Failed to create sysfs" error exactly once every
two times on atomisp reload by rmmod/insmod (although atomisp module
loads and works fine regardless of this error):

[ 140.230662] sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:03.0/active_bo'
[ 140.230668] CPU: 1 PID: 2502 Comm: insmod Tainted: G C OE 5.15.0-rc4-1-surface-mainline #1 b8acf6eb64994414b2e20bad312a7a2c45f748f9
[ 140.230675] Hardware name: OEMB OEMB/OEMB, BIOS 1.51116.238 03/09/2015
[ 140.230678] Call Trace:
[ 140.230687] dump_stack_lvl+0x46/0x5a
[ 140.230702] sysfs_warn_dup.cold+0x17/0x24
[ 140.230710] sysfs_add_file_mode_ns+0x160/0x170
[ 140.230717] internal_create_group+0x126/0x390
[ 140.230723] hmm_init+0x5c/0x70 [atomisp 7a6a680bf400629363d2a6f58fd10e7299678b99]
[ 140.230811] atomisp_pci_probe.cold+0x1136/0x148e [atomisp 7a6a680bf400629363d2a6f58fd10e7299678b99]
[ 140.230875] local_pci_probe+0x45/0x80
[ 140.230882] ? pci_match_device+0xd7/0x130
[ 140.230887] pci_device_probe+0xfa/0x1b0
[ 140.230892] really_probe+0x1f5/0x3f0
[ 140.230899] __driver_probe_device+0xfe/0x180
[ 140.230903] driver_probe_device+0x1e/0x90
[ 140.230908] __driver_attach+0xc0/0x1c0
[ 140.230912] ? __device_attach_driver+0xe0/0xe0
[ 140.230915] ? __device_attach_driver+0xe0/0xe0
[ 140.230919] bus_for_each_dev+0x89/0xd0
[ 140.230924] bus_add_driver+0x12b/0x1e0
[ 140.230929] driver_register+0x8f/0xe0
[ 140.230933] ? 0xffffffffc153f000
[ 140.230937] do_one_initcall+0x57/0x220
[ 140.230945] do_init_module+0x5c/0x260
[ 140.230952] load_module+0x24bd/0x26a0
[ 140.230962] ? __do_sys_finit_module+0xae/0x110
[ 140.230966] __do_sys_finit_module+0xae/0x110
[ 140.230972] do_syscall_64+0x5c/0x80
[ 140.230979] ? syscall_exit_to_user_mode+0x23/0x40
[ 140.230983] ? do_syscall_64+0x69/0x80
[ 140.230988] ? exc_page_fault+0x72/0x170
[ 140.230991] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 140.230997] RIP: 0033:0x7f7fd5d8718d
[ 140.231003] Code: b4 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d b3 6c 0c 00 f7 d8 64 89 01 48
[ 140.231006] RSP: 002b:00007ffefc25f0e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[ 140.231012] RAX: ffffffffffffffda RBX: 000055ac3edcd7f0 RCX: 00007f7fd5d8718d
[ 140.231015] RDX: 0000000000000000 RSI: 000055ac3d723270 RDI: 0000000000000003
[ 140.231017] RBP: 0000000000000000 R08: 0000000000000000 R09: 00007f7fd5e52380
[ 140.231019] R10: 0000000000000003 R11: 0000000000000246 R12: 000055ac3d723270
[ 140.231021] R13: 0000000000000000 R14: 000055ac3edd06e0 R15: 0000000000000000
[ 140.231038] atomisp-isp2 0000:00:03.0: hmm_init Failed to create sysfs

The problem is that dummy_ptr == 0 is a valid value. So, change the logic
which checks if dummy_ptr was allocated.

At this point, atomisp now gives WARN_ON() in hmm_free() [2] on atomisp
reload by rmmod/insmod. Again, the check is wrong there.

So, change both checks for mmgr_EXCEPTION, which is the error value when
HMM allocation fails, and initialize dummy_ptr with such value.

[1] added on commit
d9ab83953fa7 ("media: atomisp: don't cause a warn if probe failed")
[2] added on commit
b83cc378dfc4 ("atomisp: clean up the hmm init/cleanup indirections")

Link: https://lore.kernel.org/linux-media/20211017162337.44860-3-kitakar@gmail.com

Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com>
Co-developed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>


# 036bf04f 15-Jan-2021 Hans Verkuil <hverkuil-cisco@xs4all.nl>

media: atomisp/pci/hmm: fix wrong printk format

Fix this compiler warning on i686:

In file included from include/linux/printk.h:409,
from include/linux/kernel.h:16,
from drivers/staging/media/atomisp/pci/hmm/hmm.c:23:
drivers/staging/media/atomisp/pci/hmm/hmm.c: In function 'hmm_alloc':
drivers/staging/media/atomisp/pci/hmm/hmm.c:272:3: warning: format '%ld' expects argument of type 'long int', but argument 6 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
272 | "%s: pages: 0x%08x (%ld bytes), type: %d from highmem %d, user ptr %p, cached %d\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use %zu instead of %ld.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# bfe21ef1 26-Nov-2020 Borislav Petkov <bp@suse.de>

staging: media: atomisp: Fix size_t format specifier in hmm_alloc() debug statemenet

Fix this build warning on 32-bit:

drivers/staging/media/atomisp/pci/hmm/hmm.c: In function ‘hmm_alloc’:
drivers/staging/media/atomisp/pci/hmm/hmm.c:272:3: warning: format ‘%ld’ \
expects argument of type ‘long int’, but argument 6 has type ‘size_t {aka unsigned int}’ [-Wformat=]
"%s: pages: 0x%08x (%ld bytes), type: %d from highmem %d, user ptr %p, cached %d\n",
^

Fixes: 03884c93560c ("media: atomisp: add debug for hmm alloc")
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20201126181150.10576-1-bp@alien8.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c5ea3e43 02-Sep-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: fix some bad indents

As smatch reports, there are several bad indents:

drivers/staging/media/atomisp/pci/hmm/hmm.c:271 hmm_alloc() warn: inconsistent indenting
drivers/staging/media/atomisp/pci/runtime/bufq/src/bufq.c:390 ia_css_bufq_enqueue_psys_event() warn: inconsistent indenting
drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c:2132 ia_css_debug_dump_isys_state() warn: inconsistent indenting
drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c:246 sh_css_binary_get_sc_requirements() warn: inconsistent indenting
drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c:565 ia_css_binary_get_shading_info_type_1() warn: inconsistent indenting
drivers/staging/media/atomisp/pci/sh_css.c:5109 sh_css_pipes_stop() warn: inconsistent indenting
drivers/staging/media/atomisp/pci/sh_css.c:8791 ia_css_pipe_create() warn: inconsistent indenting

Some of them are due to ifdefs. Get rid of them by either getting
a common code that would work for both ISP2400 and ISP2401 or
by creating separate functions, one for each ISP version.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 3d81099c 10-Jul-2020 Nicolas Boichat <drinkcat@chromium.org>

media: atomisp: Replace trace_printk by pr_info

trace_printk should not be used in production code, replace it
call with pr_info.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# f5fbb83f 29-May-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: add SPDX headers

This driver is licensed under GPL 2.0, as stated inside their
headers.

Add the proper tag there. We should probably latter cleanup
the reduntant licensing text, but this could be done later,
after we get rid of other abstraction layers.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 530c09f2 28-May-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: add a debug message at hmm free

In order to check if aren't there any memory leaks, let's
add a debug print for hmm_free().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# d9ab8395 27-May-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: don't cause a warn if probe failed

When probe fails, it is possible that hmm_init() to not be
called. On such case, hmm_cleanup() will cause a WARN_ON().

Avoid it by adding an explicit check at hmm_cleanup() to
ensure that the hmm code was properly initialized.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 03884c93 26-May-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: add debug for hmm alloc

The hmm code is still complex and has bugs. Add a debug print
when memory gets allocated, in order to help identifying what's
happening out there.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 5472b4db 26-May-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: get rid of mmgr_load and mmgr_store

Those functions are just wrappers for hmm_load/hmm_store.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# b92d99ae 24-May-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: go one step further to drop ia_css_memory_access.c

Move the attrs handling into hmm, simplifying even further
what the ia_css_memory_access.c file does.

Yet, the returned type for ia_css_memory_access.c is an
integer, instead of a pointer.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 86df6ff2 25-May-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: reduce abstraction at ia_css_memory_access

Yet another memory abstraction layer. Getting rid of this
may be a little trickier, but let's reduce it to a minimal.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 814634b8 19-May-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: disable the dynamic and reserved pools

The memory management code for atomisp is complex: it has 2
extra pools (plus some ION-specific code).

The code for those extra pools are complex, and there are even
some parts of code over there that were forked from some
mm/ code, probably from Kernel 3.10.

Let's just use a single one, in order to make the driver
simpler.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# 9d4fa1a1 30-Apr-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

media: atomisp: cleanup directory hierarchy

This driver has very long directories without a good
reason (IMHO). Let's drop two directories from such hierarchy,
in order to simplify things a little bit and make the dir
output a bit more readable.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>