OSDN Git Service

uclinux-h8/linux.git
2 years agohabanalabs: handle skip multi-CS if handling not done
Ohad Sharabi [Mon, 20 Dec 2021 11:30:35 +0000 (13:30 +0200)]
habanalabs: handle skip multi-CS if handling not done

This patch fixes issue in which we have timeout for multi-CS although
the CS in the list actually completed.

Example scenario (the two threads marked as WAIT for the thread that
handles the wait_for_multi_cs and CMPL as the thread that signal
completion for both CS and multi-CS):
1. Submit CS with sequence X
2. [WAIT]: call wait_for_multi_cs with single CS X
3. [CMPL]: CS X do invoke complete_all for both CS and multi-CS
           (multi_cs_completion_done still false)
4. [WAIT]: enter poll_fences, reinit the completion and find the CS
           as completed when asking on the fence but multi_cs_done is
   still false it returns that no CS actually completed
5. [CMPL]: set multi_cs_handling_done as true
6. [WAIT]: wait for completion but no CS to awake the wait context
           and hence wait till timeout

Solution: if CS detected as completed in poll_fences but multi_cs_done
          is still false invoke complete_all to the multi-CS completion
  and so it will not go to sleep in wait_for_completion but
  rather will have a "second chance" to wait for
  multi_cs_completion_done.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add CPU-CP packet for engine core ASID cfg
Tomer Tayar [Thu, 16 Dec 2021 14:31:18 +0000 (16:31 +0200)]
habanalabs: add CPU-CP packet for engine core ASID cfg

In some cases the driver cannot configure ASID of some engines due to
the security level of the relevant registers.
For this a new CPU-CP packet is introduced, which will allow the driver
to ask the F/W to do this configuration instead.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: replace some -ENOTTY with -EINVAL
Oded Gabbay [Sun, 19 Dec 2021 14:06:59 +0000 (16:06 +0200)]
habanalabs: replace some -ENOTTY with -EINVAL

-ENOTTY is returned in case of error in the ioctl arguments themselves,
such as function that doesn't exists.

In all other cases, where the error is in the arguments of the custom
data structures that we define that are passed in the various ioctls,
we need to return -EINVAL.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: fix comments according to kernel-doc
Ofir Bitton [Sun, 19 Dec 2021 09:38:01 +0000 (11:38 +0200)]
habanalabs: fix comments according to kernel-doc

Fix missing fields, descriptions not according to kernel-doc style.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: fix endianness when reading cpld version
Ofir Bitton [Wed, 15 Dec 2021 12:48:27 +0000 (14:48 +0200)]
habanalabs: fix endianness when reading cpld version

Current sysfs implementation does not take endianness into
consideration when dumping the cpld version.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: change wait_for_interrupt implementation
farah kassabri [Tue, 2 Nov 2021 09:34:18 +0000 (11:34 +0200)]
habanalabs: change wait_for_interrupt implementation

Currently the cq counters are allocated in userspace memory,
and mapped by the driver to the device address space.

A new requirement that is part of new future API related to this one,
requires that cq counters will be allocated in kernel memory.

We leverage the existing cb_create API with KERNEL_MAPPED flag set to
allocate this memory.

That way we gain two things:
1. The memory cannot be freed while in use since it's protected
by refcount in driver.

2. No need to wake up the user thread upon each interrupt from CQ,
because the kernel has direct access to the counter. Therefore,
it can make comparison with the target value in the interrupt
handler and wake up the user thread only if the counter reaches the
target value. This is instead of waking the thread up to copy counter
value from user then go sleep again if target value wasn't reached.

Signed-off-by: farah kassabri <fkassabri@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: prevent wait if CS in multi-CS list completed
Ohad Sharabi [Tue, 7 Dec 2021 12:30:20 +0000 (14:30 +0200)]
habanalabs: prevent wait if CS in multi-CS list completed

By the original design we assumed that if we "miss" multi CS completion
it is of no severe consequence as we'll just call wait_for_multi_cs
again.

Sequence of events for such scenario:
1. user submit CS with sequence N
2. user calls wait for multi-CS with only CS #N in the list
3. the multi CS call starts with poll of the CSs but find that none
   completed (while CS #N did not completed yet)
4. now, multi CS #N complete but multi CS CTX was not yet created for
   the above multi-CS. so, attempt to complete multi-CS fails (as no
   multi CS CTX exist)
5. wait_for_multi_cs call now does init_wait_multi_cs_completion (and
   for this create the multi-CS CTX)
6. wait_for_multi_cs wits on completion but will not get one as CS #N
   already completed

To fix the issue we initialize the multi-CS CTX prior polling the
fences.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: modify cpu boot status error print
Ofir Bitton [Mon, 13 Dec 2021 13:43:06 +0000 (15:43 +0200)]
habanalabs: modify cpu boot status error print

As BTL can be replaced by ROM we should modify relevant error print.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: clean MMU headers definitions
Ohad Sharabi [Wed, 8 Dec 2021 07:06:03 +0000 (09:06 +0200)]
habanalabs: clean MMU headers definitions

During the MMU development the MMU header files were left with unclean
definitions:

- MMU "version specific" definitions that were left in the mmu_general
  file
- unused definitions

This patch attempts, where possible, to keep definitions that can serve
multiple MMU versions (but that are not tightly bound with specific MMU
arch) in the mmu_general header file (e.g. different definitions for
number of HOPs).

Otherwise, move MMU version specific definitions (e.g. HOPs masks and
shifts) to the specific MMU version file.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: expose soft reset sysfs nodes for inference ASIC
Ofir Bitton [Sun, 12 Dec 2021 15:46:21 +0000 (17:46 +0200)]
habanalabs: expose soft reset sysfs nodes for inference ASIC

As we allow soft-reset to be performed only on inference devices,
having the sysfs nodes may cause a confusion. Hence, we remove those
nodes on training ASICs.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: sysfs support for two infineon versions
Ofir Bitton [Wed, 8 Dec 2021 13:00:10 +0000 (15:00 +0200)]
habanalabs: sysfs support for two infineon versions

Currently sysfs support dumping a single infineon version, in
future asics we will have two infineon versions.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: keep control device alive during hard reset
Dani Liberman [Wed, 8 Dec 2021 07:52:03 +0000 (09:52 +0200)]
habanalabs: keep control device alive during hard reset

Need to allow user retrieve data during reset and afterwards without
the need to reopen the device.
Did it by seperating the user peocesses list into two lists:
1. fpriv_list which contains list of user processes that opened
   the device (currently only one).
2. fpriv_ctrl_list which contains list of user processes that opened
   the control device. This processes in this list shall not be
   killed during reset, only when the device is suddenly removed from
   PCI chain.

Signed-off-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: fix hwmon handling for legacy f/w
Oded Gabbay [Sun, 12 Dec 2021 14:40:24 +0000 (16:40 +0200)]
habanalabs: fix hwmon handling for legacy f/w

In legacy f/w that use old hwmon.h file, the values of the hwmon
enums are different than the values that are in newer kernels (5.6
and above).

Therefore, to support working with those f/w, we need to do some
fixup before registering with the hwmon subsystem and also when
calling the functions that communicate with the f/w to retrieve
sensors information.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add current PI value to cpu packets
Ofir Bitton [Wed, 8 Dec 2021 19:46:29 +0000 (21:46 +0200)]
habanalabs: add current PI value to cpu packets

In order to increase cpucp messaging reliability we will add
the current PI value to the descriptor sent to F/W.
F/W will wait for the PI value as an indication of a valid packet.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: remove in_debug check in device open
Oded Gabbay [Wed, 8 Dec 2021 14:25:07 +0000 (16:25 +0200)]
habanalabs: remove in_debug check in device open

The driver supports only a single user anyway, so there is no point
in checking whether we are in_debug state when a user tries to open
the device, because if we are in_debug, it means a user is already
using the device.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: return correct clock throttling period
Ofir Bitton [Tue, 7 Dec 2021 09:20:46 +0000 (11:20 +0200)]
habanalabs: return correct clock throttling period

Current clock throttling period returned from driver was wrong due
to wrong time comparison.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: wait again for multi-CS if no CS completed
Ohad Sharabi [Wed, 1 Dec 2021 08:52:27 +0000 (10:52 +0200)]
habanalabs: wait again for multi-CS if no CS completed

The original multi-CS design assumption that stream masters are used
exclusively (i.e. multi-CS with set of stream master QIDs will not get
completed by CS not from the multi-CS set) is inaccurate.

Thus multi-CS behavior is now modified not to treat such case as an
error.

Instead, if we have multi-CS completion but we detect that no CS from
the list is actually completed we will do another multi-CS wait (with
modified timeout).

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: remove compute context pointer
Oded Gabbay [Tue, 30 Nov 2021 21:08:21 +0000 (23:08 +0200)]
habanalabs: remove compute context pointer

It was an error to save the compute context's pointer in the device
structure, as it allowed its use without proper ref-cnt.

Change the variable to a flag that only indicates whether there is
an active compute context. Code that needs the pointer will now
be forced to use proper internal APIs to get the pointer.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add helper to get compute context
Oded Gabbay [Tue, 30 Nov 2021 21:02:21 +0000 (23:02 +0200)]
habanalabs: add helper to get compute context

There are multiple places where the code needs to get the context's
pointer and increment its ref cnt. This is the proper way instead
of using the compute context pointer in the device structure.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: fix etr asid configuration
Oded Gabbay [Tue, 30 Nov 2021 20:32:13 +0000 (22:32 +0200)]
habanalabs: fix etr asid configuration

Pass the user's context pointer into the etr configuration function
to extract its ASID.

Using the compute_ctx pointer is an error as it is just an indication
of whether a user has opened the compute device.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: save ctx inside encaps signal
Oded Gabbay [Tue, 30 Nov 2021 13:28:23 +0000 (15:28 +0200)]
habanalabs: save ctx inside encaps signal

Compute context pointer in hdev shouldn't be used for fetching the
context's pointer.

If an object needs the context's pointer, it should get it while
incrementing its kref, and when the object is released, put it.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: remove redundant check on ctx_fini
Oded Gabbay [Tue, 30 Nov 2021 15:04:13 +0000 (17:04 +0200)]
habanalabs: remove redundant check on ctx_fini

The driver supports only a single context. Therefore, no need to check
if the user context that is closed is the compute context. The user
context, if exists, is always the compute context.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: free signal handle on failure
Oded Gabbay [Tue, 30 Nov 2021 12:54:53 +0000 (14:54 +0200)]
habanalabs: free signal handle on failure

Fix a bug where in case of failure to allocate idr, the handle's
memory wasn't freed as part of the error handling code.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add missing kernel-doc comments for hl_device fields
Tomer Tayar [Mon, 29 Nov 2021 09:20:27 +0000 (11:20 +0200)]
habanalabs: add missing kernel-doc comments for hl_device fields

Add missing kernel-doc comments for the "last_error" and
"stream_master_qid_arr" fields of the "hl_device" structure".

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: pass reset flags to reset thread
Tomer Tayar [Mon, 22 Nov 2021 10:29:22 +0000 (12:29 +0200)]
habanalabs: pass reset flags to reset thread

The reset flags used by the reset thread are currently a mix of
hard-coded values and a specific flag which is passed from the context
that initiates the reset.
To make it easier to pass more flags in future from this context to the
reset thread, modify it to pass all the original reset flags to the
thread.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: enable access to info ioctl during hard reset
Dani Liberman [Mon, 22 Nov 2021 19:47:30 +0000 (21:47 +0200)]
habanalabs: enable access to info ioctl during hard reset

Because info ioctl is used to retrieve data, some of its opcodes may be
used during hard reset.
Other ioctls should be blocked while device is not operational.

Signed-off-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add SOB information to signal submission uAPI
Dani Liberman [Tue, 9 Nov 2021 09:33:28 +0000 (11:33 +0200)]
habanalabs: add SOB information to signal submission uAPI

For debug purpose, add SOB address and SOB initial counter value
before current submission to uAPI output.

Using SOB address and initial counter, user can calculate how much of
the submmision has been completed.

Signed-off-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: skip read fw errors if dynamic descriptor invalid
Ohad Sharabi [Mon, 22 Nov 2021 10:23:51 +0000 (12:23 +0200)]
habanalabs: skip read fw errors if dynamic descriptor invalid

Reporting FW errors involves reading of the error registers.

In case we have a corrupted FW descriptor we cannot do that since the
dynamic scratchpad is potentially corrupted as well and may cause kernel
crush when attempting access to a corrupted register offset.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: handle events during soft-reset
Ofir Bitton [Sun, 21 Nov 2021 14:02:32 +0000 (16:02 +0200)]
habanalabs: handle events during soft-reset

Driver should handle events during soft-reset as F/W is not
going through reset and it keeps sending events towards host.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: change misleading IRQ warning during reset
Ofir Bitton [Thu, 18 Nov 2021 06:46:15 +0000 (08:46 +0200)]
habanalabs: change misleading IRQ warning during reset

Currently we dump the physical IRQ line index in host if an event
is received during reset. This ID is confusing as it means nothing
to the user.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add power information type to POWER_GET packet
Tomer Tayar [Thu, 18 Nov 2021 08:44:05 +0000 (10:44 +0200)]
habanalabs: add power information type to POWER_GET packet

In new f/w versions, it is required to explicitly indicate the power
information type when querying the F/W for power info.
When getting the current power level it should be set to power_input.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add more info ioctls support during reset
Ofir Bitton [Mon, 15 Nov 2021 17:36:25 +0000 (19:36 +0200)]
habanalabs: add more info ioctls support during reset

Some info ioctls can be served even if the device is disabled or
in reset. Hence, we enable more info ioctls during reset, as these
ioctls do not require any H/W nor F/W communication.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: fix race condition in multi CS completion
Dani Liberman [Wed, 17 Nov 2021 07:59:10 +0000 (09:59 +0200)]
habanalabs: fix race condition in multi CS completion

Race example scenario:
1. User have 2 threads that waits on multi CS:
   - thread_0 waits on QID 0 and uses multi CS context 0.
   - thread_1 waits on QID 1 and uses multi CS context 1.
2. thread_1 got completion and release multi CS context 1.
3. CS related to multi CS of thread_0 starts executing
   complete_multi_cs function, the first iteration of the loop
   completes the multi CS of thread_0, hence multi CS context 0
   is released.
4. thread_1 waits on QID 1 and uses multi CS context 0.
5. thread_0 waits on QID 0 and uses multi CS context 1.
6. The second iterattion of the loop (from step 3) starts, which
   means, start checking multi CS context 1:
   - multi CS contetxt is being used by thread_0 waiting on QID 0.
   - The fence of the CS (still CS from step 3) has QID map the same
     as the multi CS context 1.
   - multi CS context 1 (thread_0) gets completion on CS that triggered
     already thread_0 (with multi CS context 0) and is no longer
     being waited on.

Fixed by exiting the loop in complete_multi_cs after getting completion

Signed-off-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: move device boot warnings to the correct location
Ofir Bitton [Tue, 16 Nov 2021 13:48:42 +0000 (15:48 +0200)]
habanalabs: move device boot warnings to the correct location

As device boot warnings clears the indication from the error mask,
they must be located together before the unknown error validation.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs/gaudi: return EPERM on non hard-reset
Oded Gabbay [Tue, 16 Nov 2021 08:30:26 +0000 (10:30 +0200)]
habanalabs/gaudi: return EPERM on non hard-reset

GAUDI supports only hard-reset. Therefore, this function should
return an error of operation not permitted.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: rename late init after reset function
Oded Gabbay [Tue, 16 Nov 2021 07:59:32 +0000 (09:59 +0200)]
habanalabs: rename late init after reset function

The ASIC-specific soft_reset_late_init() is now called after either
soft-reset or reset-upon-device-release. Therefore, it needs a more
appropriate name.

No need to split it to two functions, as an ASIC either supports
soft-reset or reset-upon-device-release.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: fix soft reset accounting
Oded Gabbay [Tue, 16 Nov 2021 07:46:02 +0000 (09:46 +0200)]
habanalabs: fix soft reset accounting

Reset upon device release is not a soft-reset from user/system point
of view. As such, we shouldn't count that reset in the statistics we
gather and expose to the monitoring applications.

We also shouldn't print soft-reset when doing the reset upon device
release.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: Move frequency change thread to goya_late_init
Rajaravi Krishna Katta [Thu, 5 Aug 2021 07:24:16 +0000 (10:24 +0300)]
habanalabs: Move frequency change thread to goya_late_init

Changing the frequency automatically is only done in Goya. In future
ASICs this is done inside the firmware. Therefore, move the common code
into the Goya specific files.

Main changes as part of the commit are:
    1. The thread for setting frequency is moved from device_late_init
       to goya_late_init
    2. hl_device_set_frequency is removed from hl_device_open as it is
       not relevant for other ASICs and for Goya it is taken care by
       the thread
    3. hl_device_set_frequency is renamed as goya_set_frequency

Signed-off-by: Rajaravi Krishna Katta <rkatta@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: abort reset on invalid request
Oded Gabbay [Mon, 15 Nov 2021 15:13:37 +0000 (17:13 +0200)]
habanalabs: abort reset on invalid request

Hard-reset is mutually exclusive with reset-on-device-release.
Therefore, if such a request arrives to the reset function, abort
the reset and return an error to the callee.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: fix possible deadlock in cache invl failure
Ofir Bitton [Tue, 9 Nov 2021 11:12:38 +0000 (13:12 +0200)]
habanalabs: fix possible deadlock in cache invl failure

Currently there is a deadlock in driver in scenarios where MMU
cache invalidation fails. The issue is basically device reset
being performed without releasing the MMU mutex.
The solution is to skip device reset as it is not necessary.
In addition we introduce a slight code refactor that prints the
invalidation error from a single location.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: skip PLL freq fetch
Ohad Sharabi [Sun, 14 Nov 2021 07:37:33 +0000 (09:37 +0200)]
habanalabs: skip PLL freq fetch

Getting the used PLL index with which to send the CPUPU packet relies on
the CPUCP info packet.

In case CPU queues are not enabled getting the PLL index will issue an
error and in some ASICs will also fail the driver load.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: align debugfs documentation to alphabetical order
Tomer Tayar [Sun, 14 Nov 2021 07:29:48 +0000 (09:29 +0200)]
habanalabs: align debugfs documentation to alphabetical order

Move an entry in the debugfs documentation to align with the
alphabetical order which is kept this file.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: prevent false heartbeat message
Oded Gabbay [Sat, 13 Nov 2021 15:58:43 +0000 (17:58 +0200)]
habanalabs: prevent false heartbeat message

If a device reset has started, there is a chance that the heartbeat
function will fail because the device is disabled at the beginning
of the reset function.

In that case, we don't want the error message to appear in the log.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add support for fetching historic errors
Dani Liberman [Wed, 3 Nov 2021 08:09:59 +0000 (10:09 +0200)]
habanalabs: add support for fetching historic errors

A new uAPI is added for debug purposes of the user-space to retrieve
errors related data from previous session (before device reset was
performed).

Inforamtion is filled when a razwi or CS timeout happens and can
contain one of the following:

1. Retrieve timestamp of last time the device was opened and razwi or
   CS timeout happened.
2. Retrieve information about last CS timeout.
3. Retrieve information about last razwi error.

This information doesn't contain user data, so no danger of data
leakage between users.

Signed-off-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: handle device TPM boot error as warning
Ofir Bitton [Wed, 10 Nov 2021 09:41:43 +0000 (11:41 +0200)]
habanalabs: handle device TPM boot error as warning

AS TPM error indication is not fatal, driver should dump a warning
and continue booting.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: debugfs support for larger I2C transactions
Ofir Bitton [Tue, 12 Oct 2021 17:52:46 +0000 (20:52 +0300)]
habanalabs: debugfs support for larger I2C transactions

I2C debugfs support is limited to 1 byte. We extend functionality
to more than 1 byte by using one of the pad fields as a length.
No backward compatibility issues as new F/W versions will treat 0
length as a 1 byte length transaction.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: make hdev creation code more readable
Oded Gabbay [Thu, 4 Nov 2021 07:48:22 +0000 (09:48 +0200)]
habanalabs: make hdev creation code more readable

Divide the code into 3 different parts:
- Copy kernel parameters
- Setting device behaivor per asic
- Fixup of various device parameters according to the device behaivor.

In addition, remove non-relevant code for upstream (simulator support).

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add new opcodes for INFO IOCTL
farah kassabri [Sun, 24 Oct 2021 16:02:32 +0000 (19:02 +0300)]
habanalabs: add new opcodes for INFO IOCTL

Add implementation for new opcodes in the INFO IOCTL:
1. Retrieve the replaced DRAM rows from f/w.
2. Retrieve the pending DRAM rows from f/w.

Signed-off-by: farah kassabri <fkassabri@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: refactor wait-for-user-interrupt function
Bharat Jauhari [Wed, 8 Sep 2021 14:32:54 +0000 (17:32 +0300)]
habanalabs: refactor wait-for-user-interrupt function

Refactor the wait-for-user-interrupt routine to make it more
generic for re-use for other user exposed h/w interfaces in future
ASICs.

Signed-off-by: Bharat Jauhari <bjauhari@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs/gaudi: Fix collective wait bug
farah kassabri [Wed, 3 Nov 2021 11:15:55 +0000 (13:15 +0200)]
habanalabs/gaudi: Fix collective wait bug

In Signaling-From-Graph case, the driver didn't set the hw_sob pointer
at the right place, which is needed for the cs completion
check prior to start sending all the master/slaves jobs to device.

Signed-off-by: farah kassabri <fkassabri@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: expand clock throttling information uAPI
Ofir Bitton [Mon, 25 Oct 2021 06:47:04 +0000 (09:47 +0300)]
habanalabs: expand clock throttling information uAPI

In addition to the clock throttling reason, user should be able
to obtain also the start time and the duration of the throttling
event.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: change wait for interrupt timeout to 64 bit
Dani Liberman [Thu, 14 Oct 2021 19:38:41 +0000 (22:38 +0300)]
habanalabs: change wait for interrupt timeout to 64 bit

In order to increase maximum wait-for-interrupt timeout, change it
to 64 bit variable. This wait is used only by newer ASICs, so no
problem in changing this interface at this time.

Signed-off-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: rename reset flags
Bharat Jauhari [Thu, 16 Sep 2021 11:00:38 +0000 (14:00 +0300)]
habanalabs: rename reset flags

Rename reset flags for better readability as compared to
HL_RESET_CAUSE* enum shared with the f/w.

Signed-off-by: Bharat Jauhari <bjauhari@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add dedicated message towards f/w to set power
Rajaravi Krishna Katta [Tue, 26 Oct 2021 11:11:06 +0000 (14:11 +0300)]
habanalabs: add dedicated message towards f/w to set power

CPUCP_PACKET_POWER_GET packet type was used for both
hl_get_power() and hl_set_power().

To align with other sensor functions hl_set_power()
should use CPUCP_PACKET_POWER_SET.

This packet will only be used with newer ASICs, so need to add
a compatibility flag to the asic properties to indicate whether to use
this packet or the GET packet.

Signed-off-by: Rajaravi Krishna Katta <rkatta@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: handle abort scenario for user interrupt
Bharat Jauhari [Wed, 8 Sep 2021 14:16:51 +0000 (17:16 +0300)]
habanalabs: handle abort scenario for user interrupt

In case of device reset, the driver does a force trigger on all waiting
users to release them from waiting. However, the driver does not handle
error scenario while waiting.

hl_interrupt_wait_ioctl() now exits the wait in case of an error with
abort status.

Signed-off-by: Bharat Jauhari <bjauhari@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: don't clear previous f/w indications
Ohad Sharabi [Tue, 26 Oct 2021 07:42:24 +0000 (10:42 +0300)]
habanalabs: don't clear previous f/w indications

Once we read indication of whether f/w is doing the reset, we don't
want to clear it, until the next time we read this indication.

Otherwise, we might be in a state of wrong indication.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: use variable poll interval for fw loading
Ohad Sharabi [Tue, 26 Oct 2021 12:33:23 +0000 (15:33 +0300)]
habanalabs: use variable poll interval for fw loading

Using a variable poll interval for fw loading allows us to support
much slower environments (emulation) while changing only a single
line in the code, instead of choosing a different interval in each
function that polls.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: adding indication of boot fit loaded
Ohad Sharabi [Thu, 21 Oct 2021 08:24:41 +0000 (11:24 +0300)]
habanalabs: adding indication of boot fit loaded

Up until now the driver stored indication if Linux was loaded on the
device CPU. This was needed in order to coordinate some tasks that are
performed by the Linux.

In future ASICs, many of those tasks will be performed by the boot
fit, so now we need the same indication of boot fit load status.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: partly skip cache flush when in PMMU map flow
Yuri Nudelman [Mon, 25 Oct 2021 08:37:25 +0000 (11:37 +0300)]
habanalabs: partly skip cache flush when in PMMU map flow

The PCI MMU cache is two layered. The upper layer, memcache, uses cache
lines, the bottom layer doesn't.

Hence, after PMMU map operation we have to invalidate memcache, to avoid
the situation where the new entry is already in the cache due to its
cache line being fully in the cache.

However, we do not have to invalidate the lower cache, and here we can
optimize, since cache invalidation is time consuming.

Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: add enum mmu_op_flags
Yuri Nudelman [Thu, 30 Sep 2021 12:52:25 +0000 (15:52 +0300)]
habanalabs: add enum mmu_op_flags

The enum vm_type was abused, used once as a value (indication
memory type for map) and once as a flag (for cache invalidation).
This makes it hard to add new and still keep it meaningful, hence it
is better to split into one enum for values and one for flags.

Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: make last_mask an MMU property
Yuri Nudelman [Thu, 21 Oct 2021 12:08:51 +0000 (15:08 +0300)]
habanalabs: make last_mask an MMU property

Currently LAST_MASK is a global, but really it is an MMU implementation
specific. We need this change for future ASICs.

Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: wrong VA size calculation
Yuri Nudelman [Thu, 14 Oct 2021 07:33:27 +0000 (10:33 +0300)]
habanalabs: wrong VA size calculation

VA blocks are currently stored in an inconsistent way. Sometimes block
end is inclusive, sometimes exclusive. This leads to wrong size
calculations in certain cases, plus could lead to a segmentation fault
in case mapping process fails in the middle and we try to roll it back.
Need to make this consistent - start inclusive till end inclusive.

For example, the regions table may now look like this:
    0x0000 - 0x1fff : allocated
    0x2000 - 0x2fff : free
    0x3000 - 0x3fff : allocated

Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs/gaudi: fix debugfs dma channel selection
Guy Zadicario [Tue, 12 Oct 2021 07:30:28 +0000 (10:30 +0300)]
habanalabs/gaudi: fix debugfs dma channel selection

Do not use a dma channel for debugfs requested transfer if it's
QM is not idle.

Signed-off-by: Guy Zadicario <gzadicario@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: revise and document use of boot status flags
Ohad Sharabi [Sun, 17 Oct 2021 06:00:43 +0000 (09:00 +0300)]
habanalabs: revise and document use of boot status flags

The boot status flag "SRAM available" can be set by f/w Linux (in the
general case) or by f/w uboot (in some specific debug scenario) but
never by f/w preboot.

Hence, when polling the boot status flags in the preboot stage we do not
want to poll on "SRAM Avialable".

The special case in which uboot set this flag is when we are running
special debug scenario without Linux. In this case, at some point during
the boot, the uboot relocates its code to the DRAM and then set the
specified flag.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: print va_range in vm node debugfs
Yuri Nudelman [Thu, 14 Oct 2021 09:10:31 +0000 (12:10 +0300)]
habanalabs: print va_range in vm node debugfs

VA range info could assist in debugging VA allocation bugs.

Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs/gaudi: recover from CPU WD event
Oded Gabbay [Thu, 21 Oct 2021 11:02:40 +0000 (14:02 +0300)]
habanalabs/gaudi: recover from CPU WD event

There are rare cases where the device CPU's watchdog has expired and as
a result, the watchdog reset has happened and the CPU will now move to
running its preboot f/w.

When that happens, the driver will only know that a heartbeat failure
occurred. As a result, the driver will send a message to the CPU's main
f/w asking it to reset the device, but because the CPU is now running
preboot, it won't respond and the re-initialization process will later
fail when trying to load the f/w.

The solution is to send the request to the preboot as well, only if the
reset was caused because of HB failure.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agohabanalabs: modify wait for boot fit in dynamic FW load
Ohad Sharabi [Sun, 17 Oct 2021 05:40:28 +0000 (08:40 +0300)]
habanalabs: modify wait for boot fit in dynamic FW load

In the dynamic FW load protocol the boot status is updated to
"Ready to Boot" once uboot is active.

Polling on other boot status values is a residue of code duplication
from the static protocol and should be removed.

Signed-off-by: Ohad Sharabi <osharabi@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
2 years agoMerge tag 'iio-for-5.17a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23...
Greg Kroah-Hartman [Wed, 22 Dec 2021 11:33:01 +0000 (12:33 +0100)]
Merge tag 'iio-for-5.17a' of https://git./linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

1st set of IIO new device support, features and cleanup for 5.17

Includes some fixes that were either late breaking, low priority or
complex enough to not be good to rush in late in the cycle.

Tree rebased today to fix up some trivial issues + pull in a fix that
was previously on the fixes-togreg branch. Vast majority have been
in linux-next for some time now.

New device support
* adi,ad7293
  - New driver and bindings for this Power Amplifier drain current
    controller.  A complex device with various related monitoring functions.
* adi,ad75513R
  - New driver and bindings for this combined ADC and DAC device.
  - A few follow up fixes.
* adi,admv8818
  - New driver (and type) for this 2-18GHz filter device. Includes
    bindings and ABI documentation to allow clk_notifier based auto
    adjustment of the filters in appropriate applications.
* liteon,ltr501
  - Support for the ltr303.  ID and chip specific info table.
* xilinx,ams
  - New generic firmware function fwnode_iomap() as used in this driver.
  - New driver and bindings for this ADC and on-chip sensors as found
    in various Xilinx devices.

Core
* Introduced IIO_VAL_INT_64 which uses val and val2 in IIO callbacks to
  form a 64 bit integer when higher precision needed.
* Allow IIO_ENUM_AVAILABLE to be used with different shared values.
* Fix a long term issue with scheduling whilst atomic when iio_trig_poll()
  is called but no trigger consumers are actually enabled and hence the
  trigger may be reenabled from the interrupt handler.  Seen in the wild
  on the tsc2046.
* Mark iio_device_type const.
* buffer: Use a separate index variable to simplify code.
* buffer-dma: Clear out unused struct iio_buffer_block
* buffer-dmaengine: Switch to cheaper round_down() as power of 2 values.

Tests/tools
* format_value
  - Check against NULL returns from allocations in tests.
  - Add IIO_VAL_INT_64 test case.
* event_monitor
  - Flush the output after event to given more consistent latency
    when tool output piped to other programs.

Driver Features
* axp20x
  - Add support for NTC thermistor channel and document TS pin binding.
* arm,scmi
  - Add reading of raw channel values (using IIO_VAL_INT_64)
* liteon,ltr501
  - Add proximity-near-level support and dt-binding.

Tree wide cleanup
* Remove no-op trigger ops from multiple drivers.
* Stop using dev_get_drvdata() on the iio_dev->dev in various drivers
  and then stop assigning it to allow this to be used for other purposes.
  We can always get to the indio_dev using dev_to_iio_dev() which is
  a container_of() based approach. Also cleanup up some related unnecessary
  convoluted cases.
  - atmel,at91-sam5d2
  - nxp,imx7d
  - meas,ms5611
  - st,st_sensors
* Where available (or easy to introduce) use the scan_type.* values
  in place of a second copy for read_raw and similar paths.
  - adi,ad7266
  - bosch,bma220
  - fsl,mac3110
  - fsl,mma7455
  - fsl,mpl3115
  - kionix,kcjk-1013
  - sensortek,stk8ba50
  - sensortek,stk8312
  - ti,adc12138
  - ti,ads1015
  - vti,sca3000
  - xilinx,xadc-core
* Switch drives over to generic firmware properties including appropriate
  header changes to avoid including of.h
  - Various DACs had false CONFIG_OF dependencies.
  - dpot-dac
  - envelope-detector
  - adi,ad5755
  - adi,ad5758
  - capella,cm3605
  - maxim,max9611
  - microchip,mcp41010
  - microchip,mcp3911
  - ti,adc12138
* Trivial clang warning fixes for W=1 warnings.

Driver specific cleanup and minor fixes
* adi,ad7606
  - Comment fixes.
* ams,ad3935
  - Drop pointless cast to the same type.
* atmel,at91-sama5d2
  - Fix wrong cast of iio_dev->dev to platform_device that happened to
    be harmless.
* fsl,mma7660
  - Stop i2c remove() function returning an error code. Part of a rework
    to eventually stop returning anything from these.
* fsl,mma8452
  - Use correct type for local irqreturn_t.
* nxp,imx8mq
  - Maintainer email address update.
* nxp,lpc18xx_adc
  - Ensure clk_prepare_enable() called before clk_get_rate().
  - Switch of.h for mod_devicetable.h to reflect no of specific functions,
    just the id table.
* renesas,rzg2l
  - Drop a dev_err() that just duplicates error printed in platform_get_irq()
* sgx,vz89x
  - Drop pointless cast.
* st,lsm6dsx
  - Make it possible to disable the sensorhub from DT to avoid a corner
    case where the address of a slave device many be accidentally modified.
* st,stm32-adc
  - Stop leaking an of_node in an error path.
* st,stmp2
   - Avoid wrong sized type for bit field which could result in
     over-reading (harmless). Precursor to enabling -Warray-bounds.
* ti,adc081c
  - Put back some ACPI support for non standards compliant ADC081C
    ID because it is known to be in the wild on some Aaeon boards.
* ti,ads8688
  - Cleanup redundant local ret variable assignment.
* ti,ina2xx-adc
  - Use helper macro kthread_run() to replace some boilerplate.
  - Avoid double reference counting.
  - Drop pointless cast.
* xilinx,xadc
  - Make the IRQ optional as not always wired to the host system.

* tag 'iio-for-5.17a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (103 commits)
  iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs
  iio:addac:ad74413r: Fix uninitialized ret in a path that won't be hit.
  MAINTAINERS: Add maintainer for xilinx-ams
  dt-bindings: iio: adc: Add Xilinx AMS binding documentation
  iio: adc: Add Xilinx AMS driver
  device property: Add fwnode_iomap()
  iio:accel:kxcjk-1013: Mark struct __maybe_unused to avoid warning.
  iio:accel:bmc150: Mark structure __maybe_unused as only needed with for pm ops.
  iio:dummy: Drop set but unused variable len.
  iio:magn:ak8975: Suppress clang W=1 warning about pointer to enum conversion.
  iio:imu:inv_mpu6050: Suppress clang W=1 warning about pointer to enum conversion.
  iio:imu:inv_icm42600: Suppress clang W=1 warning about pointer to enum conversion.
  iio:dac:mcp4725: Suppress clang W=1 warning about pointer to enum conversion.
  iio:amplifiers:hmc425a: Suppress clang W=1 warning about pointer to enum conversion.
  iio:adc:ti-ads1015: Suppress clang W=1 warning about pointer to enum conversion.
  iio:adc:rcar: Suppress clang W=1 warning about pointer to enum conversion.
  iio:adc:ina2xx-adc: Suppress clang W=1 warning about pointer to enum conversion.
  iio:accel:bma180: Suppress clang W=1 warning about pointer to enum conversion.
  drivers:iio:dac: Add AD3552R driver support
  dt-bindings: iio: dac: Add adi,ad3552r.yaml
  ...

2 years agoiio: adc: ti-adc081c: Partial revert of removal of ACPI IDs
Jonathan Cameron [Sun, 5 Dec 2021 17:27:28 +0000 (17:27 +0000)]
iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs

Unfortuanately a non standards compliant ACPI ID is known to be
in the wild on some AAEON boards.

Partly revert the removal of these IDs so that ADC081C will again
work + add a comment to that affect for future reference.

Whilst here use generic firmware properties rather than the ACPI
specific handling previously found in this driver.

Reported-by: Kunyang Fan <Kunyang_Fan@aaeon.com.tw>
Fixes: c458b7ca3fd0 ("iio:adc:ti-adc081c: Drop ACPI ids that seem very unlikely to be official.")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Kunyang Fan <Kunyang_Fan@aaeon.com.tw> #UP-extremei11
Link: https://lore.kernel.org/r/20211205172728.2826512-1-jic23@kernel.org
Cc: <Stable@vger.kernel.org>
2 years agoiio:addac:ad74413r: Fix uninitialized ret in a path that won't be hit.
Jonathan Cameron [Mon, 20 Dec 2021 16:47:26 +0000 (16:47 +0000)]
iio:addac:ad74413r: Fix uninitialized ret in a path that won't be hit.

I don't believe it's possible to hit this, because we drop
out of __iio_update_buffers() earlier in the event of an empty
list.  However, that is not visible to the compiler so lets
return an error if we do hit the loop with an empty bitmask.

Fixes: 5d97d9e9a703 ("iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Cosmin Tanislav <cosmin.tanislav@analog.com>
Link: https://lore.kernel.org/r/20211220164726.3136307-1-jic23@kernel.org
2 years agoMAINTAINERS: Add maintainer for xilinx-ams
Anand Ashok Dumbre [Fri, 3 Dec 2021 21:23:58 +0000 (21:23 +0000)]
MAINTAINERS: Add maintainer for xilinx-ams

Add maintaner entry for xilinx-ams driver.

Signed-off-by: Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>
Link: https://lore.kernel.org/r/20211203212358.31444-6-anand.ashok.dumbre@xilinx.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: adc: Add Xilinx AMS binding documentation
Anand Ashok Dumbre [Fri, 3 Dec 2021 21:23:57 +0000 (21:23 +0000)]
dt-bindings: iio: adc: Add Xilinx AMS binding documentation

Xilinx AMS have several ADC channels that can be used for measurement of
different voltages and temperatures. Document the same in the bindings.

Signed-off-by: Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20211203212358.31444-5-anand.ashok.dumbre@xilinx.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: Add Xilinx AMS driver
Anand Ashok Dumbre [Fri, 3 Dec 2021 21:23:56 +0000 (21:23 +0000)]
iio: adc: Add Xilinx AMS driver

The AMS includes an ADC as well as on-chip sensors that can be used to
sample external voltages and monitor on-die operating conditions, such
as temperature and supply voltage levels. The AMS has two SYSMON blocks.
PL-SYSMON block is capable of monitoring off chip voltage and
temperature.

PL-SYSMON block has DRP, JTAG and I2C interface to enable monitoring
from an external master. Out of these interfaces currently only DRP is
supported. Other block PS-SYSMON is memory mapped to PS.

The AMS can use internal channels to monitor voltage and temperature as
well as one primary and up to 16 auxiliary channels for measuring
external voltages.

The voltage and temperature monitoring channels also have event capability
which allows to generate an interrupt when their value falls below or
raises above a set threshold.

Co-developed-by: Manish Narani <manish.narani@xilinx.com>
Signed-off-by: Manish Narani <manish.narani@xilinx.com>
Signed-off-by: Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>
Link: https://lore.kernel.org/r/20211203212358.31444-4-anand.ashok.dumbre@xilinx.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodevice property: Add fwnode_iomap()
Anand Ashok Dumbre [Fri, 3 Dec 2021 21:23:54 +0000 (21:23 +0000)]
device property: Add fwnode_iomap()

This patch introduces a new helper routine - fwnode_iomap(), which
allows to map the memory mapped IO for a given device node.

This implementation does not cover the ACPI case and may be expanded
in the future. The main purpose here is to be able to develop resource
provider agnostic drivers.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20211203212358.31444-2-anand.ashok.dumbre@xilinx.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio:accel:kxcjk-1013: Mark struct __maybe_unused to avoid warning.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:45 +0000 (17:24 +0000)]
iio:accel:kxcjk-1013: Mark struct __maybe_unused to avoid warning.

This structure is only used in PM ops, so may not be used depending
on build configuration.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-13-jic23@kernel.org
2 years agoiio:accel:bmc150: Mark structure __maybe_unused as only needed with for pm ops.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:44 +0000 (17:24 +0000)]
iio:accel:bmc150: Mark structure __maybe_unused as only needed with for pm ops.

If CONFIG_PM not set then clang warns this structure is unused.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-12-jic23@kernel.org
2 years agoiio:dummy: Drop set but unused variable len.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:43 +0000 (17:24 +0000)]
iio:dummy: Drop set but unused variable len.

Not sure what the thinking was here, as lost to history, but the
variable is clearly not used so get rid of it.

Warning seen with clang W=1 tests (may be present with other compilers
and build options).

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-11-jic23@kernel.org
2 years agoiio:magn:ak8975: Suppress clang W=1 warning about pointer to enum conversion.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:42 +0000 (17:24 +0000)]
iio:magn:ak8975: Suppress clang W=1 warning about pointer to enum conversion.

Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-10-jic23@kernel.org
2 years agoiio:imu:inv_mpu6050: Suppress clang W=1 warning about pointer to enum conversion.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:41 +0000 (17:24 +0000)]
iio:imu:inv_mpu6050: Suppress clang W=1 warning about pointer to enum conversion.

Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Baptiste Mansuy <bmansuy@invensense.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-9-jic23@kernel.org
2 years agoiio:imu:inv_icm42600: Suppress clang W=1 warning about pointer to enum conversion.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:40 +0000 (17:24 +0000)]
iio:imu:inv_icm42600: Suppress clang W=1 warning about pointer to enum conversion.

Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-8-jic23@kernel.org
2 years agoiio:dac:mcp4725: Suppress clang W=1 warning about pointer to enum conversion.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:39 +0000 (17:24 +0000)]
iio:dac:mcp4725: Suppress clang W=1 warning about pointer to enum conversion.

Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-7-jic23@kernel.org
2 years agoiio:amplifiers:hmc425a: Suppress clang W=1 warning about pointer to enum conversion.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:38 +0000 (17:24 +0000)]
iio:amplifiers:hmc425a: Suppress clang W=1 warning about pointer to enum conversion.

Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-6-jic23@kernel.org
2 years agoiio:adc:ti-ads1015: Suppress clang W=1 warning about pointer to enum conversion.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:37 +0000 (17:24 +0000)]
iio:adc:ti-ads1015: Suppress clang W=1 warning about pointer to enum conversion.

Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-5-jic23@kernel.org
2 years agoiio:adc:rcar: Suppress clang W=1 warning about pointer to enum conversion.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:36 +0000 (17:24 +0000)]
iio:adc:rcar: Suppress clang W=1 warning about pointer to enum conversion.

Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-4-jic23@kernel.org
2 years agoiio:adc:ina2xx-adc: Suppress clang W=1 warning about pointer to enum conversion.
Jonathan Cameron [Sun, 28 Nov 2021 17:24:35 +0000 (17:24 +0000)]
iio:adc:ina2xx-adc: Suppress clang W=1 warning about pointer to enum conversion.

Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-3-jic23@kernel.org
2 years agow1: w1_therm: use swap() to make code cleaner
Yang Guang [Tue, 21 Dec 2021 09:15:59 +0000 (17:15 +0800)]
w1: w1_therm: use swap() to make code cleaner

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
Link: https://lore.kernel.org/r/cb14f9e6e86cf8494ed2ddce6eec8ebd988908d9.1640077704.git.yang.guang5@zte.com.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agocounter: 104-quad-8: Fix persistent enabled events bug
William Breathitt Gray [Tue, 21 Dec 2021 08:16:48 +0000 (17:16 +0900)]
counter: 104-quad-8: Fix persistent enabled events bug

A bug exists if the user executes a COUNTER_ADD_WATCH_IOCTL ioctl call,
and then executes a COUNTER_DISABLE_EVENTS_IOCTL ioctl call. Disabling
the events should disable the 104-QUAD-8 interrupts, but because of this
bug the interrupts are not disabling.

The reason this bug is occurring is because quad8_events_configure() is
called when COUNTER_DISABLE_EVENTS_IOCTL is handled, but the
next_irq_trigger[] array has not been cleared before it is checked in
the loop.

This patch fixes the bug by removing the next_irq_trigger array and
instead utilizing a different algorithm of walking the events_list list
for the current requested events. When a COUNTER_DISABLE_EVENTS_IOCTL is
handled, events_list will be empty and thus all device channels end up
with interrupts disabled.

Fixes: 7aa2ba0df651 ("counter: 104-quad-8: Add IRQ support for the ACCES 104-QUAD-8")
Cc: Syed Nayyar Waris <syednwaris@gmail.com>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/5fd5731cec1c251acee30eefb7c19160d03c9d39.1640072891.git.vilhelm.gray@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agocounter: ti-eqep: Use container_of instead of struct counter_device::priv
Uwe Kleine-König [Tue, 21 Dec 2021 08:16:47 +0000 (17:16 +0900)]
counter: ti-eqep: Use container_of instead of struct counter_device::priv

Using counter->priv is a memory read and so more expensive than
container_of which is only an addition. (In this case even a noop
because the offset is 0.)

So container_of is expected to be a tad faster, it's type-safe, and
produces smaller code (ARCH=arm allmodconfig):

$ source/scripts/bloat-o-meter drivers/counter/ti-eqep.o-pre drivers/counter/ti-eqep.o
add/remove: 0/0 grow/shrink: 0/9 up/down: 0/-108 (-108)
Function                                     old     new   delta
ti_eqep_position_enable_write                132     120     -12
ti_eqep_position_enable_read                 260     248     -12
ti_eqep_position_ceiling_write               132     120     -12
ti_eqep_position_ceiling_read                236     224     -12
ti_eqep_function_write                       220     208     -12
ti_eqep_function_read                        372     360     -12
ti_eqep_count_write                          312     300     -12
ti_eqep_count_read                           236     224     -12
ti_eqep_action_read                          664     652     -12
Total: Before=4598, After=4490, chg -2.35%

Acked-by: David Lechner <david@lechnology.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/4bde7cbd9e43a5909208102094444219d3154466.1640072891.git.vilhelm.gray@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agocounter: Add the necessary colons and indents to the comments of counter_compi
Yanteng Si [Tue, 21 Dec 2021 08:16:46 +0000 (17:16 +0900)]
counter: Add the necessary colons and indents to the comments of counter_compi

Since commit aaec1a0f76ec ("counter: Internalize sysfs interface code")
introduce a warning as:

linux-next/Documentation/driver-api/generic-counter:234: ./include/linux/counter.h:43: WARNING: Unexpected indentation.
linux-next/Documentation/driver-api/generic-counter:234: ./include/linux/counter.h:45: WARNING: Block quote ends without a blank line; unexpected unindent.

Add the necessary colons and indents.

Fixes: aaec1a0f76ec ("counter: Internalize sysfs interface code")
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/26011e814d6eca02c7ebdbb92f171a49928a7e89.1640072891.git.vilhelm.gray@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agodt-bindings: nvmem: Add missing 'reg' property
Rob Herring [Thu, 9 Dec 2021 17:42:35 +0000 (17:42 +0000)]
dt-bindings: nvmem: Add missing 'reg' property

With 'unevaluatedProperties' support implemented, the following warnings
are generated in the nvmem examples:

Documentation/devicetree/bindings/nvmem/st,stm32-romem.example.dt.yaml: efuse@1fff7800: Unevaluated properties are not allowed ('reg' was unexpected)
Documentation/devicetree/bindings/nvmem/rmem.example.dt.yaml: nvram@10000000: Unevaluated properties are not allowed ('reg' was unexpected)
Documentation/devicetree/bindings/nvmem/brcm,nvram.example.dt.yaml: nvram@1eff0000: Unevaluated properties are not allowed ('reg' was unexpected)

Add the missing 'reg' property definition.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Rafał Miłecki <rafal@milecki.pl>
Cc: Saenz Julienne <nsaenzjulienne@suse.de>
Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20211209174235.14049-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agonvmem: mtk-efuse: support minimum one byte access stride and granularity
Chunfeng Yun [Thu, 9 Dec 2021 17:42:34 +0000 (17:42 +0000)]
nvmem: mtk-efuse: support minimum one byte access stride and granularity

In order to support nvmem bits property, should support minimum 1 byte
read stride and minimum 1 byte read granularity at the same time.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20211209174235.14049-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agodt-bindings: nvmem: mediatek: add support for mt8195
Chunfeng Yun [Thu, 9 Dec 2021 17:42:33 +0000 (17:42 +0000)]
dt-bindings: nvmem: mediatek: add support for mt8195

Add compatible for mt8195

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20211209174235.14049-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agodt-bindings: nvmem: mediatek: add support bits property
Chunfeng Yun [Thu, 9 Dec 2021 17:42:32 +0000 (17:42 +0000)]
dt-bindings: nvmem: mediatek: add support bits property

Add support bits property, will satisfy more consumers.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20211209174235.14049-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agodrivers/misc/ocxl: remove redundant rc variable
Minghao Chi [Wed, 15 Dec 2021 06:04:38 +0000 (06:04 +0000)]
drivers/misc/ocxl: remove redundant rc variable

Return value from ocxl_context_attach() directly instead
of taking this in another redundant variable.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Link: https://lore.kernel.org/r/20211215060438.441918-1-chi.minghao@zte.com.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agomisc: vmw_vmci: Switch to kvfree_rcu() API
Uladzislau Rezki (Sony) [Wed, 15 Dec 2021 11:18:42 +0000 (12:18 +0100)]
misc: vmw_vmci: Switch to kvfree_rcu() API

Instead of invoking a synchronize_rcu() to free a pointer
after a grace period we can directly make use of new API
that does the same but in more efficient way.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Link: https://lore.kernel.org/r/20211215111845.2514-6-urezki@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agoparide: fix up build warning on mips platforms
Greg Kroah-Hartman [Tue, 30 Nov 2021 08:46:26 +0000 (09:46 +0100)]
paride: fix up build warning on mips platforms

MIPS include files define "PC" so when building the paride driver the
following build warning shows up:

rivers/block/paride/bpck.c:32: warning: "PC" redefined

Fix this by undefining PC before redefining it as is done for other
defines in this driver.

Cc: Tim Waugh <tim@cyberelk.net>
Acked-by: Jens Axboe <axboe@kernel.dk>
Link: https://lore.kernel.org/r/20211130084626.3215987-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agorapidio: remove not used code about RIO_VID_TUNDRA
Tiezhu Yang [Thu, 16 Dec 2021 03:33:01 +0000 (11:33 +0800)]
rapidio: remove not used code about RIO_VID_TUNDRA

According to https://rapidio.org/vendor-id/, there is no 0x000d vendor id
in the complete and current list of VendorIDs, it means that the related
code is dead code now, so just remove them.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Link: https://lore.kernel.org/r/1639625581-22867-3-git-send-email-yangtiezhu@loongson.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agorapidio: remove not used macro definition in rio_ids.h
Tiezhu Yang [Thu, 16 Dec 2021 03:33:00 +0000 (11:33 +0800)]
rapidio: remove not used macro definition in rio_ids.h

The definition of RIO_VID_FREESCALE, RIO_DID_MPC8560, RIO_DID_TSI500,
RIO_DID_TSI576 and RIO_DID_TSI721 are not used for many years in the
current code, so just remove them.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Link: https://lore.kernel.org/r/1639625581-22867-2-git-send-email-yangtiezhu@loongson.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agofirmware: qemu_fw_cfg: remove sysfs entries explicitly
Johan Hovold [Wed, 1 Dec 2021 13:25:28 +0000 (14:25 +0100)]
firmware: qemu_fw_cfg: remove sysfs entries explicitly

Explicitly remove the file entries from sysfs before dropping the final
reference for symmetry reasons and for consistency with the rest of the
driver.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20211201132528.30025-5-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 years agofirmware: qemu_fw_cfg: fix sysfs information leak
Johan Hovold [Wed, 1 Dec 2021 13:25:27 +0000 (14:25 +0100)]
firmware: qemu_fw_cfg: fix sysfs information leak

Make sure to always NUL-terminate file names retrieved from the firmware
to avoid accessing data beyond the entry slab buffer and exposing it
through sysfs in case the firmware data is corrupt.

Fixes: 75f3e8e47f38 ("firmware: introduce sysfs driver for QEMU's fw_cfg device")
Cc: stable@vger.kernel.org # 4.6
Cc: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20211201132528.30025-4-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>