Commit Graph

138 Commits

Author SHA1 Message Date
Linus Torvalds
8e17b16a2c SoC driver updates for 6.2
There are few major updates in the SoC specific drivers, mainly the usual
 reworks and support for variants of the existing SoC.  While this remains
 Arm centric for the most part, the branch now also contains updates to
 risc-v and loongarch specific code in drivers/soc/.
 
 Notable changes include:
 
  - Support for the newly added Qualcomm Snapdragon variants
    (MSM8956, MSM8976, SM6115, SM4250, SM8150, SA8155 and SM8550) in the
    soc ID, rpmh, rpm, spm and powerdomain drivers.
 
  - Documentation for the somewhat controversial qcom,board-id
    properties that are required for booting a number of machines
 
  - A new SoC identification driver for the loongson-2 (loongarch)
    platform
 
  - memory controller updates for stm32, tegra, and renesas.
 
  - a new DT binding to better describe LPDDR2/3/4/5 chips in
    the memory controller subsystem
 
  - Updates for Tegra specific drivers across multiple subsystems,
    improving support for newer SoCs and better identification
 
  - Minor fixes for Broadcom, Freescale, Apple, Renesas, Sifive,
    TI, Mediatek and Marvell SoC drivers
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmOSAZ8ACgkQmmx57+YA
 GNmoDw/9Hdz2rx6TtdjA2eMKFt97bK0EgrQADT1d4lPQzXzZzFDC9ZxL0bwZRujZ
 b8Q6WrMMgcRiWmzmRlxQWMWEdBU8Y0OzeYlo4lbyCSOV+UA2OA/eu6rm0chapBgM
 1/lkquYLUUcB31wg+NmADoKy5Ejxj9SL1Va36Nvng4YpHDrYHKt4gPyCr/EV+KRO
 Q8JpH7vEzQ0P5CGUzeri2UlYWDdF1GXmObqQGF8pq9s6Qz4ACe63r+eJFXAQFiXK
 xewRK7PuvqmQWLVaEnN8dAcSna5P4aIGKOVjQyZjCCp6qTvfm4d2hxTl4dt9gVtt
 vbQPiPQ5ORRzeMmW6wHxSIdy2QCa9CKQDXuMRoOWHfGMrAZQaxruISpcmHYv9Ug+
 nSfedIEtxtmpGK2SZ1Mvndkezbb0o5QXZF4+kxqpiE/EaxVWmxiecmrUqyvJ5RVv
 RuaZeMQpeOaWElnxb2P/T5uLuoHGhDdZ98HXICuCWPAitvA2rRK4Rv3dqTeclPLa
 HR9gVYgZK3CSj+e9xbe5uczIc664bscRl9unghtB3UWkGTiLt2rroX4T2pTU/2xf
 YvzDHC+f42NEkXUzcs4cZ87R8iY2hr0LmePY5/lqF9k6qx0Rc3syNc7q4N4EBxGC
 2y5dDpKXfFL6fEV4YNeGpNcrwmCwnNppcePjmNvgrdtqmUUB/mY=
 =heNV
 -----END PGP SIGNATURE-----

Merge tag 'soc-drivers-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM SoC driver updates from Arnd Bergmann:
 "There are few major updates in the SoC specific drivers, mainly the
  usual reworks and support for variants of the existing SoC. While this
  remains Arm centric for the most part, the branch now also contains
  updates to risc-v and loongarch specific code in drivers/soc/.

  Notable changes include:

   - Support for the newly added Qualcomm Snapdragon variants (MSM8956,
     MSM8976, SM6115, SM4250, SM8150, SA8155 and SM8550) in the soc ID,
     rpmh, rpm, spm and powerdomain drivers.

   - Documentation for the somewhat controversial qcom,board-id
     properties that are required for booting a number of machines

   - A new SoC identification driver for the loongson-2 (loongarch)
     platform

   - memory controller updates for stm32, tegra, and renesas.

   - a new DT binding to better describe LPDDR2/3/4/5 chips in the
     memory controller subsystem

   - Updates for Tegra specific drivers across multiple subsystems,
     improving support for newer SoCs and better identification

   - Minor fixes for Broadcom, Freescale, Apple, Renesas, Sifive, TI,
     Mediatek and Marvell SoC drivers"

* tag 'soc-drivers-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (137 commits)
  soc: qcom: socinfo: Add SM6115 / SM4250 SoC IDs to the soc_id table
  dt-bindings: arm: qcom,ids: Add SoC IDs for SM6115 / SM4250 and variants
  soc: qcom: socinfo: Add SM8150 and SA8155 SoC IDs to the soc_id table
  dt-bindings: arm: qcom,ids: Add SoC IDs for SM8150 and SA8155
  dt-bindings: soc: qcom: apr: document generic qcom,apr compatible
  soc: qcom: Select REMAP_MMIO for ICC_BWMON driver
  soc: qcom: Select REMAP_MMIO for LLCC driver
  soc: qcom: rpmpd: Add SM4250 support
  dt-bindings: power: rpmpd: Add SM4250 support
  dt-bindings: soc: qcom: aoss: Add compatible for SM8550
  soc: qcom: llcc: Add configuration data for SM8550
  dt-bindings: arm: msm: Add LLCC compatible for SM8550
  soc: qcom: llcc: Add v4.1 HW version support
  soc: qcom: socinfo: Add SM8550 ID
  soc: qcom: rpmh-rsc: Avoid unnecessary checks on irq-done response
  soc: qcom: rpmh-rsc: Add support for RSC v3 register offsets
  soc: qcom: rpmhpd: Add SM8550 power domains
  dt-bindings: power: rpmpd: Add SM8550 to rpmpd binding
  soc: qcom: socinfo: Add MSM8956/76 SoC IDs to the soc_id table
  dt-bindings: arm: qcom,ids: Add SoC IDs for MSM8956 and MSM8976
  ...
2022-12-12 10:17:08 -08:00
Arnd Bergmann
f5014dcd93 Add missing __init/__exit annotations to OP-TEE driver
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmN3dr0aHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJdc+g//RsMRODDwkJQKECfudD8j
 LK0g0v5E2fqA23gZG14eD5v9UY6DSRyhL+DDxJGphsd/SlGV0lA5gn51usj7yu1c
 HFpN1y8k9Z3wYZGDxOnG+C5AR8hpRXsQtPRSd30HrgdHGuZwsNhuYCjQXMXKKYLB
 +w8/yjFj+3Zw54evs5mWHusyEa/kyldWcXuYXNgF9bxRYfxkj7yOSyPQROFGuzP9
 Lr4077Q+/P8nukZ+YubVvnsZ33hlWWykF5nwvhEr1RM7IugCKgEeuj12v2qJfZcR
 3ZccZIzk12oatNpX2PDwXlmrP9MvgD/xA86zt6BmPdaxRGm5E3phTMIlSbeS5Qwd
 jNpn1lUVg7O1R45NoUIdckTekp/vvIfbZuqHIoC0pHVFC0BENQHCLGGY9fo9vdqd
 fW5tSUmlU69fKqmgf/0gPAXKO7qVbASGNvh4nSf7Gv/qgf3446+Dw23b6kYeLm9j
 +kIFiAloXQJ9SFxTF2V5gk5PNcFuSLt1gE9y0DZg+WCHza9VZwoDnjmXUiQeyaa0
 LSsWd42u1YldAfLN1SZ24h1rCmgOenV/7WrVn16WAf5fgRQVmiutARA7K8d3aue3
 TR0sZtw7XGBOTMQWr2nQBOFYVJiM2rynMzLxKD35QHtaFD5fwzJsZvTElqUk7rqc
 /dDWHQmUlggEnECSJ5aP5Xs=
 =rzLm
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmN7cSkACgkQmmx57+YA
 GNnhoA/7BUAXgJqB8ZAWUaFw6HOsKQkltoJxjRK9vkeiHJUKEB5u0w97fHNVondk
 TqxqhceoB36AYBqOc7FECufcvRbmg80EVihyoH34qL8V+37kN+hU4WagImLAbQTF
 v2KXbe5X4JA4LTNt0KXWsPcTifkBaa/CVhYYArWxRpT33+WglMiVr7bJhJdXzQfu
 v7AuYfE+KZzK9aGBJl8gAoXluT59WmgQpxu1PmtsMT8SFeLS4pPYJ16CxjgFL8pW
 s1JaxJfoXuzDzqvUwknRzxxmcAYBI+HR8Cq4znlRaQJj4bKgaZhdMThrbJ9G2yqS
 7LtesfMLmBNJS7jlkLG4d12PvNgE21Kc0IrhJan2nesqiYEgn6WQngGb7Qx8niG2
 +5IZEY9Xdsvi6K6dFP3d1yUSl0yMP30HWo3puoiFsLoS5BWXJ48gXdbdTpF2170g
 KMdlJR6MwNoH83ULpRIC8KtchOrr4sJ9jj0B0RLhvlQVbMDI1lRK/BW5Gs0MbvPQ
 OgwaimDcH9Q3yHWB8K4FDwdAq8SMQxzQw0bO06wZad0nGyZAV9BwHTv9mdsOvGJB
 UBeYM3133Z9jnWk40Zn3Dk9gmbjokX9BlczGAyCANvqPH2zJTujm5JDrxgujUDkO
 9XhkHt8JLmxKZZNWZYcF2I+rCi2eClz7nmxUOP5XvPvTsI0doHY=
 =EDdl
 -----END PGP SIGNATURE-----

Merge tag 'optee-for-6.2' of https://git.linaro.org/people/jens.wiklander/linux-tee into soc/drivers

Add missing __init/__exit annotations to OP-TEE driver

* tag 'optee-for-6.2' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  optee: Add __init/__exit annotations to module init/exit funcs

Link: https://lore.kernel.org/r/Y3d4CHWl3Ofx5OrX@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-11-21 13:38:01 +01:00
Yang Yingliang
cce616e012 tee: optee: fix possible memory leak in optee_register_device()
If device_register() returns error in optee_register_device(),
the name allocated by dev_set_name() need be freed. As comment
of device_register() says, it should use put_device() to give
up the reference in the error path. So fix this by calling
put_device(), then the name can be freed in kobject_cleanup(),
and optee_device is freed in optee_release_device().

Fixes: c3fa24af92 ("tee: optee: add TEE bus device enumeration support")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-11-17 09:22:12 +01:00
Xiu Jianfeng
bd52407221 optee: Add __init/__exit annotations to module init/exit funcs
Add missing __init/__exit annotations to module init/exit funcs.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-10-11 11:20:16 +02:00
Linus Torvalds
27bc50fc90 - Yu Zhao's Multi-Gen LRU patches are here. They've been under test in
linux-next for a couple of months without, to my knowledge, any negative
   reports (or any positive ones, come to that).
 
 - Also the Maple Tree from Liam R.  Howlett.  An overlapping range-based
   tree for vmas.  It it apparently slight more efficient in its own right,
   but is mainly targeted at enabling work to reduce mmap_lock contention.
 
   Liam has identified a number of other tree users in the kernel which
   could be beneficially onverted to mapletrees.
 
   Yu Zhao has identified a hard-to-hit but "easy to fix" lockdep splat
   (https://lkml.kernel.org/r/CAOUHufZabH85CeUN-MEMgL8gJGzJEWUrkiM58JkTbBhh-jew0Q@mail.gmail.com).
   This has yet to be addressed due to Liam's unfortunately timed
   vacation.  He is now back and we'll get this fixed up.
 
 - Dmitry Vyukov introduces KMSAN: the Kernel Memory Sanitizer.  It uses
   clang-generated instrumentation to detect used-unintialized bugs down to
   the single bit level.
 
   KMSAN keeps finding bugs.  New ones, as well as the legacy ones.
 
 - Yang Shi adds a userspace mechanism (madvise) to induce a collapse of
   memory into THPs.
 
 - Zach O'Keefe has expanded Yang Shi's madvise(MADV_COLLAPSE) to support
   file/shmem-backed pages.
 
 - userfaultfd updates from Axel Rasmussen
 
 - zsmalloc cleanups from Alexey Romanov
 
 - cleanups from Miaohe Lin: vmscan, hugetlb_cgroup, hugetlb and memory-failure
 
 - Huang Ying adds enhancements to NUMA balancing memory tiering mode's
   page promotion, with a new way of detecting hot pages.
 
 - memcg updates from Shakeel Butt: charging optimizations and reduced
   memory consumption.
 
 - memcg cleanups from Kairui Song.
 
 - memcg fixes and cleanups from Johannes Weiner.
 
 - Vishal Moola provides more folio conversions
 
 - Zhang Yi removed ll_rw_block() :(
 
 - migration enhancements from Peter Xu
 
 - migration error-path bugfixes from Huang Ying
 
 - Aneesh Kumar added ability for a device driver to alter the memory
   tiering promotion paths.  For optimizations by PMEM drivers, DRM
   drivers, etc.
 
 - vma merging improvements from Jakub Matěn.
 
 - NUMA hinting cleanups from David Hildenbrand.
 
 - xu xin added aditional userspace visibility into KSM merging activity.
 
 - THP & KSM code consolidation from Qi Zheng.
 
 - more folio work from Matthew Wilcox.
 
 - KASAN updates from Andrey Konovalov.
 
 - DAMON cleanups from Kaixu Xia.
 
 - DAMON work from SeongJae Park: fixes, cleanups.
 
 - hugetlb sysfs cleanups from Muchun Song.
 
 - Mike Kravetz fixes locking issues in hugetlbfs and in hugetlb core.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCY0HaPgAKCRDdBJ7gKXxA
 joPjAQDZ5LlRCMWZ1oxLP2NOTp6nm63q9PWcGnmY50FjD/dNlwEAnx7OejCLWGWf
 bbTuk6U2+TKgJa4X7+pbbejeoqnt5QU=
 =xfWx
 -----END PGP SIGNATURE-----

Merge tag 'mm-stable-2022-10-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull MM updates from Andrew Morton:

 - Yu Zhao's Multi-Gen LRU patches are here. They've been under test in
   linux-next for a couple of months without, to my knowledge, any
   negative reports (or any positive ones, come to that).

 - Also the Maple Tree from Liam Howlett. An overlapping range-based
   tree for vmas. It it apparently slightly more efficient in its own
   right, but is mainly targeted at enabling work to reduce mmap_lock
   contention.

   Liam has identified a number of other tree users in the kernel which
   could be beneficially onverted to mapletrees.

   Yu Zhao has identified a hard-to-hit but "easy to fix" lockdep splat
   at [1]. This has yet to be addressed due to Liam's unfortunately
   timed vacation. He is now back and we'll get this fixed up.

 - Dmitry Vyukov introduces KMSAN: the Kernel Memory Sanitizer. It uses
   clang-generated instrumentation to detect used-unintialized bugs down
   to the single bit level.

   KMSAN keeps finding bugs. New ones, as well as the legacy ones.

 - Yang Shi adds a userspace mechanism (madvise) to induce a collapse of
   memory into THPs.

 - Zach O'Keefe has expanded Yang Shi's madvise(MADV_COLLAPSE) to
   support file/shmem-backed pages.

 - userfaultfd updates from Axel Rasmussen

 - zsmalloc cleanups from Alexey Romanov

 - cleanups from Miaohe Lin: vmscan, hugetlb_cgroup, hugetlb and
   memory-failure

 - Huang Ying adds enhancements to NUMA balancing memory tiering mode's
   page promotion, with a new way of detecting hot pages.

 - memcg updates from Shakeel Butt: charging optimizations and reduced
   memory consumption.

 - memcg cleanups from Kairui Song.

 - memcg fixes and cleanups from Johannes Weiner.

 - Vishal Moola provides more folio conversions

 - Zhang Yi removed ll_rw_block() :(

 - migration enhancements from Peter Xu

 - migration error-path bugfixes from Huang Ying

 - Aneesh Kumar added ability for a device driver to alter the memory
   tiering promotion paths. For optimizations by PMEM drivers, DRM
   drivers, etc.

 - vma merging improvements from Jakub Matěn.

 - NUMA hinting cleanups from David Hildenbrand.

 - xu xin added aditional userspace visibility into KSM merging
   activity.

 - THP & KSM code consolidation from Qi Zheng.

 - more folio work from Matthew Wilcox.

 - KASAN updates from Andrey Konovalov.

 - DAMON cleanups from Kaixu Xia.

 - DAMON work from SeongJae Park: fixes, cleanups.

 - hugetlb sysfs cleanups from Muchun Song.

 - Mike Kravetz fixes locking issues in hugetlbfs and in hugetlb core.

Link: https://lkml.kernel.org/r/CAOUHufZabH85CeUN-MEMgL8gJGzJEWUrkiM58JkTbBhh-jew0Q@mail.gmail.com [1]

* tag 'mm-stable-2022-10-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (555 commits)
  hugetlb: allocate vma lock for all sharable vmas
  hugetlb: take hugetlb vma_lock when clearing vma_lock->vma pointer
  hugetlb: fix vma lock handling during split vma and range unmapping
  mglru: mm/vmscan.c: fix imprecise comments
  mm/mglru: don't sync disk for each aging cycle
  mm: memcontrol: drop dead CONFIG_MEMCG_SWAP config symbol
  mm: memcontrol: use do_memsw_account() in a few more places
  mm: memcontrol: deprecate swapaccounting=0 mode
  mm: memcontrol: don't allocate cgroup swap arrays when memcg is disabled
  mm/secretmem: remove reduntant return value
  mm/hugetlb: add available_huge_pages() func
  mm: remove unused inline functions from include/linux/mm_inline.h
  selftests/vm: add selftest for MADV_COLLAPSE of uffd-minor memory
  selftests/vm: add file/shmem MADV_COLLAPSE selftest for cleared pmd
  selftests/vm: add thp collapse shmem testing
  selftests/vm: add thp collapse file and tmpfs testing
  selftests/vm: modularize thp collapse memory operations
  selftests/vm: dedup THP helpers
  mm/khugepaged: add tracepoint to hpage_collapse_scan_file()
  mm/madvise: add file and shmem support to MADV_COLLAPSE
  ...
2022-10-10 17:53:04 -07:00
Matthew Wilcox (Oracle)
df724cedcf optee: remove vma linked list walk
Use the VMA iterator instead.  Change the calling convention of
__check_mem_type() to pass in the mm instead of the first vma in the
range.

Link: https://lkml.kernel.org/r/20220906194824.2110408-39-Liam.Howlett@oracle.com
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Tested-by: Yu Zhao <yuzhao@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: SeongJae Park <sj@kernel.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-09-26 19:46:20 -07:00
Sudeep Holla
5b0c6328e4 firmware: arm_ffa: Split up ffa_ops into info, message and memory operations
In preparation to make memory operations accessible for a non
ffa_driver/device, it is better to split the ffa_ops into different
categories of operations: info, message and memory. The info and memory
are ffa_device independent and can be used without any associated
ffa_device from a non ffa_driver.

However, we don't export these info and memory APIs yet without the user.
The first users of these APIs can export them.

Link: https://lore.kernel.org/r/20220907145240.1683088-11-sudeep.holla@arm.com
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-09-08 11:34:04 +01:00
Sudeep Holla
7aa7a97989 firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
Except the message APIs, all other APIs are ffa_device independent and can
be used without any associated ffa_device from a non ffa_driver.

In order to reflect the same, just rename ffa_dev_ops as ffa_ops to
avoid any confusion or to keep it simple.

Link: https://lore.kernel.org/r/20220907145240.1683088-8-sudeep.holla@arm.com
Suggested-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-09-08 11:30:34 +01:00
Sudeep Holla
8c3812c8f7 firmware: arm_ffa: Make memory apis ffa_device independent
There is a requirement to make memory APIs independent of the ffa_device.
One of the use-case is to have a common memory driver that manages the
memory for all the ffa_devices. That common memory driver won't be a
ffa_driver or won't have any ffa_device associated with it. So having
these memory APIs accessible without a ffa_device is needed and should
be possible as most of these are handled by the partition manager(SPM
or hypervisor).

Drop the ffa_device argument to the memory APIs and make them ffa_device
independent.

Link: https://lore.kernel.org/r/20220907145240.1683088-7-sudeep.holla@arm.com
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-09-08 11:30:34 +01:00
Sudeep Holla
320c3fa38c tee: optee: Drop ffa_ops in optee_ffa structure using ffa_dev->ops directly
Now that the ffa_device structure holds the pointer to ffa_dev_ops,
there is no need to obtain the same through ffa_dev_ops_get().

Just use the ffa_dev->ops directly. Since the ffa_device itself carries
ffa_dev_ops now, there is no need to keep a copy in optee_ffa structure.

Drop ffa_ops in the optee_ffa structure as it is not needed anymore.

Link: https://lore.kernel.org/r/20220907145240.1683088-3-sudeep.holla@arm.com
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-09-08 11:30:34 +01:00
Jiang Jian
b66527ee98 optee: Remove duplicate 'of' in two places.
file: ./drivers/tee/optee/optee_smc.h
line: 192
 * a2   Size of of SHM
chanegd to
 * a2   Size of SHM

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-07-08 10:51:24 +02:00
Yang Yingliang
d4fac258d9 optee: smc_abi.c: fix wrong pointer passed to IS_ERR/PTR_ERR()
In optee_smc_do_call_with_arg() there is a code path when the argument
struct for RPC is passed appended to the primary argument struct. When
the address of the RPC struct is retrieved there's an invalid check for
success. It should be 'rpc_arg' pass to IS_ERR/PTR_ERR().

Fixes: ed8faf6c8f ("optee: add OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_REGD_ARG")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
[jw: added background to the problem]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-07-08 09:56:38 +02:00
Arnd Bergmann
9c76d723ed Fix a compiler warning in OP-TEE driver
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmKUp88aHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJfo1hAAgxWuH8xhuMdvuLOt2mCD
 MyaahZ5Tf7VwyydCBPZvQXEyQqflfuDMSaDRQrrJd9RXTBI8FaGGrvdmJaqr65rD
 t08CopIyaJzDcIl+uwQ0BnWRpPW974ARzd1HylDXyaK4/BroKujpjLS+RnwOLzmS
 fdUANXOKw2tTQUamQRo6/ZQ1bA2CZj6QJqbTqBEifCozEG+ZNx8MCw1au6zf9LUb
 LyjdA0J/Uo8qUp2bBWHHPRe2ieIL9JKD7uBVhGJAP5/qqBpbZCwhDrOUk34qwOmR
 Y9FZv+wY6PYV0t0H2leOd8dx6fZ6K4lxffmwy40zj5vq3OsomrfozYK+GHG6Gw5m
 RBSxBVxnfD4q2FIcIRmJiSbkK/m9dKeW0b3K27huIElVi1l00YJalEc4dOzpVjTK
 LiOlBd4eY8pcNIRCoMwqoYtOLNynpTDoBJmdQFjrs3RdmyIUwLP4PBEuuSy9TV2d
 Od/pB4eBnzFol83G6IKw0zqaLcaJtchdG50EE5DUwf+PbVmuQikWjkNun8oWxH1a
 3qEltbfhvBSVwh/KXgQlEwsiK6mE4yr3pL+5Q6UR+/TbU8Nm5fAFmuJAmQnoLgYI
 Mn86aFiX1GimjdTZ/r0U3bLSGG1vVowoGUayPiQFonuh+Rc+J51PFJHtoZ2ImfzT
 5Tjj4MwjvqpGnPryyDh6+5c=
 =5e2L
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmKUvCsACgkQmmx57+YA
 GNkgBA/+Lsu6hJYfjUmbHWdQl052F8ByXNMpec9UOzjdT4l62B7OPs+ynfuUNs+K
 JEWd8mrlyoBLlJkSP561IlEe1oa3yDLuuzMXnoIOFsYoxSjNZXVSSerRrlHUuqWd
 JTaH3MJ3sScjrwnnBZw5XJvKPv+rG4zSfgsTQnt/JtRwy8Oot1TaaDy9SqRDVkaA
 9Ieb7ZUgfXq2TJRPNCWSHQtVn6bQo73Rn8WTDHJE+u1p78Vm2fAGSU8UMitD363B
 nG2uxHZPQqx5dGqSkSP9XWc+EwOA7DOkYfNhxg7opgKMn7Fxu8D4MmyapymL/ULn
 OxqEzuLHfveanpv2r5i0PRKwCasj3tMRrUBp2FLaGocaww8RuYA92yowy7zRHM67
 UrX3TukIWImdSE43rpw3OZ7Kj4Ymc6YeW0qg0fIfn53rk/morXbJwiGe94bLkFrS
 q0782JkLGlSLm+QUkXK+vdX6NQNkobmGIaVyu2HTpE7IyRhukwITJ6oMf/xN1PcG
 5PmcWXeODYooUKya6Pay4EzYkB11bPuSBiFz8gCydKMKil4gyzd80zSg7cx1XrCO
 5NWXvgLoy7Blj2zqwB9fkZJJT3cLHa8ZlJ3Qx+7fXbTSBdGgZz+qNstXqMhx+HiY
 HDzohlPAr7b9P4/JYgD4WRwkzvcgLhnQQFq0Gg/kAs/avqoFCig=
 =5+PP
 -----END PGP SIGNATURE-----

Merge tag 'optee-warning-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/late

Fix a compiler warning in OP-TEE driver

* tag 'optee-warning-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: optee: Pass a pointer to virt_addr_valid()

Link: https://lore.kernel.org/r/20220530112612.GA1511426@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-30 14:44:27 +02:00
Linus Walleij
a3b9ecc805 tee: optee: Pass a pointer to virt_addr_valid()
A pointer into virtual memory is represented by a (void *)
not an u32, so the compiler warns:

drivers/tee/optee/call.c:365:29: warning: passing argument 1
  of 'virt_to_pfn' makes pointer from integer without a
  cast [-Wint-conversion]

Fix this with an explicit cast.

Cc: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
[jw: fixed merge conflict]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-05-30 08:06:45 +02:00
Linus Torvalds
cc3c470ae4 ARM: driver changes for 5.19
There are minor updates to SoC specific drivers for chips by Rockchip,
 Samsung, NVIDIA, TI, NXP, i.MX, Qualcomm, and Broadcom. Noteworthy
 driver changes include:
 
 - Several conversions of DT bindings to yaml format.
 
 - Renesas adds driver support for R-Car V4H, RZ/V2M and RZ/G2UL SoCs.
 
 - Qualcomm adds a bus driver for the SSC (Snapdragon Sensor Core),
   and support for more chips in the RPMh power domains and the soc-id.
 
 - NXP has a new driver for the HDMI blk-ctrl on i.MX8MP.
 
 - Apple M1 gains support for the on-chip NVMe controller, making it
   possible to finally use the internal disks. This also includes SoC
   drivers for their RTKit IPC and for the SART DMA address filter.
 
 For other subsystems that merge their drivers through the SoC tree,
 we have
 
 - Firmware drivers for the ARM firmware stack including TEE, OP-TEE,
   SCMI and FF-A get a number of smaller updates and cleanups. OP-TEE
   now has a cache for firmware argument structures as an optimization,
   and SCMI now supports the 3.1 version of the specification.
 
 - Reset controller updates to Amlogic, ASpeed, Renesas and ACPI drivers
 
 - Memory controller updates for Tegra, and a few updates for other
   platforms.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmKOXOoACgkQmmx57+YA
 GNlpVQ//eQGfL0WktE5G/y0mCVuVHtXT5nSjHMgjTOdb9+QvaATCfxnLXvP7Gq7C
 7YzJd68G+2ZC4rUkkjTxyMICT7eIrJSAIAFn4PWee4EQ5DfbHgG+1tToTjxqb+QQ
 6wGB5MVaYUhjZE30kY2E8a+OKxHtEnkt9wcch6ei0vzsMZquQJF6byfHd5+I4Knd
 CyDmXX8ZGXK3FnhvuBLr3Rgwyhs0X4Ju7UaONLZxBYxdnh8WmymRszmMnv5qEkub
 KDe8fbhFamOT3Z55JdCA5xq7LvUzjsKpTGFxFcS0ptbkTmtAsuyYqqiWvAPx3D5u
 5TxVGSx9QKid6fpIsITZ2ptO6fgljh1W9b/3Y3/eltudXsM1qqSxyN2Hre+M9egf
 WEDADqbNR5Y5+bq1iZWI348jXkNHVPpsLHI9Ihqf4yyrKwFkmRmNLnws53XTAPH2
 FPXZvJjwFDBDHGfewSoLFePXUPNytVLXbr6Mq72ZyTDIBDU8Mxh666Wd8bu4tgbG
 1Y2pMjDIdXDOsljM6Of5D3XjM1kuDwEmFxWGy+cKLgoEbHLeE1xIbTjUir4687+d
 VNHdtsIRFPRZzz2lUSmI8vlA2aewMWrkOF/Ulz8xh6gG8uitMSfOxghg4IWOfRVM
 mlvgFP5eqTInmQcbWRxaRO9JzP+rPp1sAcEpsBmuEHw5Akflbc8=
 =XoLF
 -----END PGP SIGNATURE-----

Merge tag 'arm-drivers-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM driver updates from Arnd Bergmann:
 "There are minor updates to SoC specific drivers for chips by Rockchip,
  Samsung, NVIDIA, TI, NXP, i.MX, Qualcomm, and Broadcom.

  Noteworthy driver changes include:

   - Several conversions of DT bindings to yaml format.

   - Renesas adds driver support for R-Car V4H, RZ/V2M and RZ/G2UL SoCs.

   - Qualcomm adds a bus driver for the SSC (Snapdragon Sensor Core),
     and support for more chips in the RPMh power domains and the
     soc-id.

   - NXP has a new driver for the HDMI blk-ctrl on i.MX8MP.

   - Apple M1 gains support for the on-chip NVMe controller, making it
     possible to finally use the internal disks. This also includes SoC
     drivers for their RTKit IPC and for the SART DMA address filter.

  For other subsystems that merge their drivers through the SoC tree, we
  have

   - Firmware drivers for the ARM firmware stack including TEE, OP-TEE,
     SCMI and FF-A get a number of smaller updates and cleanups. OP-TEE
     now has a cache for firmware argument structures as an
     optimization, and SCMI now supports the 3.1 version of the
     specification.

   - Reset controller updates to Amlogic, ASpeed, Renesas and ACPI
     drivers

   - Memory controller updates for Tegra, and a few updates for other
     platforms"

* tag 'arm-drivers-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (159 commits)
  memory: tegra: Add MC error logging on Tegra186 onward
  memory: tegra: Add memory controller channels support
  memory: tegra: Add APE memory clients for Tegra234
  memory: tegra: Add Tegra234 support
  nvme-apple: fix sparse endianess warnings
  soc/tegra: pmc: Document core domain fields
  soc: qcom: pdr: use static for servreg_* variables
  soc: imx: fix semicolon.cocci warnings
  soc: renesas: R-Car V3U is R-Car Gen4
  soc: imx: add i.MX8MP HDMI blk-ctrl
  soc: imx: imx8m-blk-ctrl: Add i.MX8MP media blk-ctrl
  soc: imx: add i.MX8MP HSIO blk-ctrl
  soc: imx: imx8m-blk-ctrl: set power device name
  soc: qcom: llcc: Add sc8180x and sc8280xp configurations
  dt-bindings: arm: msm: Add sc8180x and sc8280xp LLCC compatibles
  soc/tegra: pmc: Select REGMAP
  dt-bindings: reset: st,sti-powerdown: Convert to yaml
  dt-bindings: reset: st,sti-picophyreset: Convert to yaml
  dt-bindings: reset: socfpga: Convert to yaml
  dt-bindings: reset: snps,axs10x-reset: Convert to yaml
  ...
2022-05-26 10:32:47 -07:00
Arnd Bergmann
6c6012ab96 OP-TEE RPC argument cache
Adds caching of the OP-TEE argument structure used to pass request to
 secure world. This reduces quite a bit of unnecessary alloc/free and
 possibly switching back and forth to secure work in order to register
 the buffers in some configurations, most notably FF-A.
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmJy2qcaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJfGvRAAwWWyMSRRxFGlaiENphwg
 vLKP0faPgW4kBPLI7bd6ItpWlMNNx6ixtqZo8Icz0yke7yb/5m1wi3jC1rz2FuvU
 JZXdepakJ3TGDpXWX6wVSpZFGfq/l41OTmFh3BV3DvUCMTfjXzcUJqv9zHpWwgU/
 qPY/hhWzrJcJ8fTi6tXtExAhUsGxAmSJ/s+ShvNYXbNa8hrgyU3Nq15HODGR1BXS
 +2mos1F4KlGRxhPu+hCRqyyD5l3Tkzk4HFoSt6AOfBQ9voSCcw8XVtL9/4Jx3592
 +99Y+VqsnJJNEHiSD6ESRyKadRIZvH4zwKBh92J3z/NhhxmeC1isDFYkmlgoxCaq
 OgPdFUa0Nq3JlIY4W+0c3TS0N/CGXrRFkDChEbn4sdQOKeIUy70yX/Eml5d+xhAC
 JDnSzz/B6i8qYgXwK6srSiY2uKi75L4qhGQmemp1x4HToRjEjTfWaKX2rBjfspiQ
 8/9HQBG7Xk1PYiAN0z4xIjpoYqMRLwrtGm7J0Ep8/PKFyr+yzIHkYLFtoWGv9PZa
 F23/muMZALUxCLwm03/WmlFqmEeY2cFh/dB6UBIVpBmTM3X7QPdrTwVpamLgmtyT
 hwONAOpmUGF6du0a84Gz2D3unUaGXGI8Ccyam2MsYYQF9vwxp0HU/Q08zR69vMJA
 BmVbSlUfIPcMLOP0xamfrx4=
 =vq/I
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmJz2LIACgkQmmx57+YA
 GNltcBAAws2PU8EbtUoyYsJlClc1lxj+pUfT9snyv8CJVSLV6a+c94EUrxApJiZv
 HWyNrGfjRCY0otXzI+uFz9VbRC7sOWZNygdK0oDu+P9kkRNqzqdzfD366ms/VOGJ
 cswKla5iqKWThkBM4jA2aZA6YdXg4yHjU5h529K5kd/MlW4FyPrN11Bj3ELMeqH5
 XaPkbGMoUgOTkk2CA/9VxVJz2n3fIvXXPYox2fsaDeNJIv3Y0GLEZSC0qE79lve5
 kALRxoHfawyTkHtmVu+3btaUDyjoopRXP0oxo2e3kssGoOUpCJ5OJ8FQhiCiTWXi
 dXE0U7HdM1NNfUSwo87BaE64oMaAULd1OJsOsPkTzzJwvHlcSewAip2y0dd5N7N9
 ngcfBKWo+D17dVNKCVgA7rATMP5se2wtx2/u2TGsyOTmqhteR3hXznHVRm8ZrHCy
 yjtj/5SCqQL9/0/jRGLUR0BwhL0K8+zpW56uQ28cy1a9j7E5iROnrHRmqE6fYaaF
 /sD08lGaeqRKRuIJxFe0OVpQlgVN4ZL75dkujS7OUCrtI++No3QzCjlkSnLdNKdk
 +UB8r3NNPrZSWqdz87Otd+8T6nt7NBbGK/R2yZMtYy1l532VFLguJvRzuY75J8ks
 8LgvZ0AumWRJbig+WdTulanXneAKgugpdwLGfDzNUt8P1nnjVE4=
 =XEqq
 -----END PGP SIGNATURE-----

Merge tag 'optee-rpc-arg-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/drivers

OP-TEE RPC argument cache

Adds caching of the OP-TEE argument structure used to pass request to
secure world. This reduces quite a bit of unnecessary alloc/free and
possibly switching back and forth to secure work in order to register
the buffers in some configurations, most notably FF-A.

* tag 'optee-rpc-arg-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  optee: cache argument shared memory structs
  optee: add FF-A capability OPTEE_FFA_SEC_CAP_ARG_OFFSET
  optee: add OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_REGD_ARG
  optee: rename rpc_arg_count to rpc_param_count

Link: https://lore.kernel.org/r/20220504201759.GA180315@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-05 16:01:22 +02:00
Arnd Bergmann
91f92d7038 Arm FF-A firmware driver updates/fixes for v5.19
Couple of fixes to handle fragmented memory descriptors and incorrect
 UUID parameter passed to ffa_partition_probe. Another fix deals with
 the incorrect use of ffa_device's driver_data by the core driver.
 Apart from these fixes, there is an addition of ffa_dev_get_drvdata helper
 function and its use in optee driver.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEunHlEgbzHrJD3ZPhAEG6vDF+4pgFAmJyPeUACgkQAEG6vDF+
 4piw1A//Y/LGEj9+4yv/NWt26M3DujFmQzHdjjJbIMZmy/iV+GJqfl/6uNH49pZZ
 6lNl7N3ZJC/hPakpDPOZUkDwmivlQWiKGbpdtiAXA6qNp5X+bpUk0N2DZTifhl1a
 0M9/iY/77N9CBTe0n0VcY24alm4++94ccMcpleGLYzf1sYU7sy8wZKV+++GDDJld
 TkD1wZ6GQaYQMdQTh+Il92jQbOOnMOfGqPrdRIHDS3R9g099GvFeB34QZfUOJL2d
 3ikKdj+Pe7BUD68FZZ8UQo1irudCi66577ufnN6dgV7Gf0wgqt+f0C+nawmErQCT
 yuYtUd1fOSTLlQCKXKsgF/+VgxwjcGHG1is7jCsBKJRFv3oSYzmaUWTifpxx2HVx
 XfCmrz4N46OmXUkQ1J12qo8F7Swo+VeIYZWIB+PrsUdqFHKK0lOX7mgU1dPZV3wx
 iiwzeexfVk2MCidaE0xqkuP9fQun39/3sZhtMvap6W9A3+jHKJhbz+yWP/AwlEtP
 pTjElKmMHgP1Md6G2kFcHuooPvAe8BPvudGD49U56nenz4uP0o6OnAub6Ay/1GVB
 dmYSdm33BmLM9bxiJqZHb/I3HtYO5suQum4DWQhfcrQX4BtqSu9fjLhkIAuznp2g
 YiBhF0Xdp4XF760JmePZiqCGH7Y8rqyNZHwxWnKunxCb+3uaJiQ=
 =IOMn
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmJz2EAACgkQmmx57+YA
 GNlnvBAAqHkiCC9z0WW4I7qGQ/uNbsYeX4EU856CXXyI5I9Lz8huJBiXoZwcuJMg
 3WBx8aF1m6xIUORM3NbuI/MLkVZyHI6z6Xfndcd+w8U1mI2CLg7/B+djr0jLyx78
 ckXRhua1g8DGoXdFwDao3ndsAAkMtWFJhNHpOMf2jqGdY1xEAIOfHb7YAeyNf7SZ
 1ygoSAhpys5rcek5r6GQzate4QqiwL2YTnC5vDkOWA1OFsX33d5WVEbrM4KmuLSO
 TdEcBWMxQX52pVZkrBZ1F+tZqgGqyDhf3bJ64zNleycV5U81abndTjkadpZflr1R
 4JgUkzHNkb0Xh3TkcyFBqwerq5FmeCkF6Um0vStngNpsa9fiQ8L5dC1T/NNTl6y5
 pZJhXWMPPgN7GDqLRnTnqdk9t3YS5lbU5BuNU33M1X2y0jMikn2V61WKkejhiXK4
 ZYcs5z31zXkDWXuO149FT38ZUXzf14rolrLx7zc3GVhk6oGp0R7kz+7SKW65P0z5
 NAWLFUmwPYAYgOsFaSY7P+i6UhBtpEk3YixjdYjjU3RvwqAp+YkARQKPApUTXido
 zVB4PRSgf1owEhnlnBzKKwM9ORkL+lrqxpGnB7fvr9UU3LvlI2QxoU+4LGlGmvMh
 cutmev2PBmC6QYmPMwLTvOziyP100riiI5ORb2zJPQVIplzn2EM=
 =MDJg
 -----END PGP SIGNATURE-----

Merge tag 'ffa-updates-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/drivers

Arm FF-A firmware driver updates/fixes for v5.19

Couple of fixes to handle fragmented memory descriptors and incorrect
UUID parameter passed to ffa_partition_probe. Another fix deals with
the incorrect use of ffa_device's driver_data by the core driver.
Apart from these fixes, there is an addition of ffa_dev_get_drvdata helper
function and its use in optee driver.

* tag 'ffa-updates-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  tee: optee: Use ffa_dev_get_drvdata to fetch driver_data
  firmware: arm_ffa: Add ffa_dev_get_drvdata helper function
  firmware: arm_ffa: Remove incorrect assignment of driver_data
  firmware: arm_ffa: Fix uuid parameter to ffa_partition_probe
  firmware: arm_ffa: Fix handling of fragmented memory descriptors

Link: https://lore.kernel.org/r/20220504112853.3491961-1-sudeep.holla@arm.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-05 15:59:28 +02:00
Sudeep Holla
f3f3bdbd58 tee: optee: Use ffa_dev_get_drvdata to fetch driver_data
Due to lack of an helper like ffa_dev_get_drvdata, this driver was
fetching driver_data directly accessing the structure member. Now that
we have added an helper, just use the same instead.

Link: https://lore.kernel.org/r/20220429113946.2087145-4-sudeep.holla@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-04-29 14:51:46 +01:00
Jens Wiklander
5b4018b959 optee: cache argument shared memory structs
Implements a cache to handle shared memory used to pass the argument
struct needed when doing a normal yielding call into secure world.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-25 21:13:05 +02:00
Jens Wiklander
a639b2b18a optee: add FF-A capability OPTEE_FFA_SEC_CAP_ARG_OFFSET
Adds the secure capability OPTEE_FFA_SEC_CAP_ARG_OFFSET to indicate that
OP-TEE with FF-A can support an argument struct at a non-zero offset into
a passed shared memory object.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-13 07:37:48 +02:00
Jens Wiklander
ed8faf6c8f optee: add OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_REGD_ARG
Adds OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_REGD_ARG where
the struct optee_msg_arg to be used for RPC is appended in the memory
following the normal argument struct optee_msg_arg. This is an
optimization to avoid caching the RPC argument struct while still
maintaining similar performance as if it was cached.

OPTEE_SMC_CALL_WITH_REGD_ARG optimized one step further by using a
registered shared memory object instead. It's in other aspects identical
to OPTEE_SMC_CALL_WITH_RPC_ARG.

The presence of OPTEE_SMC_CALL_WITH_RPC_ARG and
OPTEE_SMC_CALL_WITH_REGD_ARG is indicated by the new
OPTEE_SMC_SEC_CAP_RPC_ARG bit returned by
OPTEE_SMC_EXCHANGE_CAPABILITIES. OPTEE_SMC_EXCHANGE_CAPABILITIES also
reports the number of arguments that the RPC argument struct must have
room for.

OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_ARG can be used
interleaved with difference that when OPTEE_SMC_CALL_WITH_RPC_ARG is
used the RPC argument struct to be used is the one appended to the
normal argument struct. The same is true for
OPTEE_SMC_CALL_WITH_REGD_ARG.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-13 07:37:20 +02:00
Jens Wiklander
30c375a7f6 optee: rename rpc_arg_count to rpc_param_count
Renames the field rpc_arg_count in struct optee to rpc_param_count.
Function parameter names and local variables are also renamed to match.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-13 07:33:59 +02:00
Dongliang Mu
b5e2288683 tee: optee: add missing mutext_destroy in optee_ffa_probe
The error handling code of optee_ffa_probe misses the mutex_destroy of
ffa.mutex when mutext_init succeeds.

Fix this by adding mutex_destory of ffa.mutex at the error handling part

Fixes: aceeafefff ("optee: use driver internal tee_context for some rpc")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-05 08:56:26 +02:00
Phil Chang
3e47235eae tee: make tee_shm_register_kernel_buf vmalloc supported
In some low-memory devices, it's hard to aquire large-orders pages,
this patch allowed user using scatter pages to register shm.

Signed-off-by: Phil Chang <phil.chang@mediatek.com>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-05 08:04:16 +02:00
Linus Torvalds
b4bc93bd76 ARM driver updates for 5.18
There are a few separately maintained driver subsystems that we merge through
 the SoC tree, notable changes are:
 
  - Memory controller updates, mainly for Tegra and Mediatek SoCs,
    and clarifications for the memory controller DT bindings
 
  - SCMI firmware interface updates, in particular a new transport based
    on OPTEE and support for atomic operations.
 
  - Cleanups to the TEE subsystem, refactoring its memory management
 
 For SoC specific drivers without a separate subsystem, changes include
 
  - Smaller updates and fixes for TI, AT91/SAMA5, Qualcomm and NXP
    Layerscape SoCs.
 
  - Driver support for Microchip SAMA5D29, Tesla FSD, Renesas RZ/G2L,
    and Qualcomm SM8450.
 
  - Better power management on Mediatek MT81xx, NXP i.MX8MQ
    and older NVIDIA Tegra chips
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmI4nOUACgkQmmx57+YA
 GNlNNhAApPQw+FKQ6yVj2EZYcaAgik8PJAJoNQWYED52iQfm5uXgjt3aQewvrPNW
 nkKx5Mx+fPUfaKx5mkVOFMhME5Bw9tYbXHm2/RpRp+n8jOdUlQpAhzIPOyWPHOJS
 QX6qu4t+agrQzjbOCGouAJXgyxhTJFUMviM2EgVHbQHXPtdF8i2kyanfCP7Rw8cx
 sVtLwpvhbLm849+deYRXuv2Xw9I3M1Np7018s5QciimI2eLLEb+lJ/C5XWz5pMYn
 M1nZ7uwCLKPCewpMETTuhKOv0ioOXyY9C1ghyiGZFhHQfoCYTu94Hrx9t8x5gQmL
 qWDinXWXVk8LBegyrs8Bp4wcjtmvMMLnfWtsGSfT5uq24JOGg22OmtUNhNJbS9+p
 VjEvBgkXYD7UEl5npI9v9/KQWr3/UDir0zvkuV40gJyeBWNEZ/PB8olXAxgL7wZv
 cXRYSaUYYt3DKQf1k5I4GUyQtkP/4RaBy6AqvH5Sx0lCwuY6G6ISK+kCPaaSRKnX
 WR+nFw84dKCu7miehmW9qSzMQ4kiSCKIDqk7ilHcwv0J2oXDrlqVPKGGGTzZjUc8
 +feqM/eSoYvDDEDemuXNSnl3hc1Zlvm7Apd5AN6kdTaNgoACDYdyvGuJ3CvzcA+K
 1gBHUBvGS/ODA25KnYabr7wCMgxYqf7dXfkyKIBwFHwxOnRHtgs=
 =Cfbk
 -----END PGP SIGNATURE-----

Merge tag 'arm-drivers-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM driver updates from Arnd Bergmann:
 "There are a few separately maintained driver subsystems that we merge
  through the SoC tree, notable changes are:

   - Memory controller updates, mainly for Tegra and Mediatek SoCs, and
     clarifications for the memory controller DT bindings

   - SCMI firmware interface updates, in particular a new transport
     based on OPTEE and support for atomic operations.

   - Cleanups to the TEE subsystem, refactoring its memory management

  For SoC specific drivers without a separate subsystem, changes include

   - Smaller updates and fixes for TI, AT91/SAMA5, Qualcomm and NXP
     Layerscape SoCs.

   - Driver support for Microchip SAMA5D29, Tesla FSD, Renesas RZ/G2L,
     and Qualcomm SM8450.

   - Better power management on Mediatek MT81xx, NXP i.MX8MQ and older
     NVIDIA Tegra chips"

* tag 'arm-drivers-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (154 commits)
  ARM: spear: fix typos in comments
  soc/microchip: fix invalid free in mpfs_sys_controller_delete
  soc: s4: Add support for power domains controller
  dt-bindings: power: add Amlogic s4 power domains bindings
  ARM: at91: add support in soc driver for new SAMA5D29
  soc: mediatek: mmsys: add sw0_rst_offset in mmsys driver data
  dt-bindings: memory: renesas,rpc-if: Document RZ/V2L SoC
  memory: emif: check the pointer temp in get_device_details()
  memory: emif: Add check for setup_interrupts
  dt-bindings: arm: mediatek: mmsys: add support for MT8186
  dt-bindings: mediatek: add compatible for MT8186 pwrap
  soc: mediatek: pwrap: add pwrap driver for MT8186 SoC
  soc: mediatek: mmsys: add mmsys reset control for MT8186
  soc: mediatek: mtk-infracfg: Disable ACP on MT8192
  soc: ti: k3-socinfo: Add AM62x JTAG ID
  soc: mediatek: add MTK mutex support for MT8186
  soc: mediatek: mmsys: add mt8186 mmsys routing table
  soc: mediatek: pm-domains: Add support for mt8186
  dt-bindings: power: Add MT8186 power domains
  soc: mediatek: pm-domains: Add support for mt8195
  ...
2022-03-23 18:23:13 -07:00
Arnd Bergmann
4f6668f052 OP-TEE fix error return code in probe functions
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmIKQNIaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJc28A/9G+hOvPLhDF+nM6bJJzYU
 rAwsKgT7CMGCxWiwH9U06ggl8uo6ItSJyMhnvmp1mVM41UUNTTZUXIotkSHpdP2U
 ezH0MJVO3Ez5q2fSUs6Be7Wz2cdcMMrZgavbBTymiEAkTJVohOrW7Wbk+NK4ATUG
 P894Jt0giH4oIAZZg56UGITs2nhcUPTheuUTrLx4xy2Lq6CWw3+yTkarzyU5hCwJ
 tc4UMsGfNVVccw/sziHioSXC6gIjVezufggsQyrMl5tUSQQRi0TxgxbAXEucefNj
 EChxOxosSp9ZXdQDB8ufu9bIi4zF1UxhFi9b8u1jse8LhchD3UvbSAXkykUbvlyZ
 tCjMP2alacc8RMMcSGw7fFZhTTlkJTja/2H3IiLgfszdZjSJV7nrX290maxRiKBd
 WMCegMTBtSl5tBRnW5LH6gIJ9O0U5oqONI/B1YZ9kRuBD7vlkqb8U3LgvqzoR8H8
 AFVs00nb7SDzlXnmTLjIqcpnM0Ovp8QH/dUEQZk1b9tN+oYG+kfLSu+LB5Okzwum
 fgnxscN66lU8wdwLIhdyIU83YdYpBzTY2y6OxGYril798dwoMFL86fg8c5/zfP5O
 /Q8Tb+IGyLsApPbcU3Yct6ZtpyE4bdzvHLZjxZXq6JCsrKN+sLMAmizJIbEAfzdo
 dfhIGT0uKwEI3km8DwbgEPU=
 =88/o
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmIPyYkACgkQmmx57+YA
 GNl0Bg//dvU6bjJsEfAJYhVt+ByPT/EvU9Q8umlTxo10CsbLhM3WZperPWivfP59
 xt19FmqN9M5BZkC3VSRxxPCLsLJ+IE+r6VyO4+EHAaB/1DBOKnRD5T6iqQm6QW0o
 1oI5OuAQGoeP7fqFJfd8KFjCqYQAUcGTT7wuUl7foIsGNR7Sw+xgE2DkOw0ol7BQ
 /Fll1vlP2mls6RRAnKQUqlA7se6VGvp5tVxlue4v3J/v5FMAXhGNzaa9wrHJEjld
 N6jYnd9/5Muxea31SBjYt1P6ZaOEeDG54UDFGoLdVhLLtFBVopJVuGthyCZx7UNy
 qwfIuZWYaPMXFMxFWmz3d/pAQxM+ZGo+EjwrBTM2JeFhenTZn8HefTpcN3G8Dg+P
 6led6sJn4TCdvD8ZpkRLhWbNHUX+SoRx17vFs5k6GEP4UIVfsGu4mak18yxpDOYT
 LwCEqGqIjc6uIWEkzwkVITyJiwSK63NNHuHZhbm6fYCsOVE4gj42yLXmt8gx+SV+
 LtPDI9CS/3O3HEMd/+hO0I6BQx9bB3Vx44s/4JxVYCDAKSDwSwuMGI1ZHadGIfYI
 YAkNhDQOs82tqXAivh+Hp/0of7F7GSwyHzCZWbHsd0/aPZC7m+gOxy2WUXAUOCt4
 rRSjF85PLhxRHksyh0N7bCujUgx4dctJAtG3mQ46BuaumfbNWuc=
 =4P5l
 -----END PGP SIGNATURE-----

Merge tag 'optee-fix2-for-v5.17' of git://git.linaro.org/people/jens.wiklander/linux-tee into arm/fixes

OP-TEE fix error return code in probe functions

* tag 'optee-fix2-for-v5.17' of git://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: optee: fix error return code in probe function

Link: https://lore.kernel.org/r/20220214125931.GA1332792@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-02-18 17:30:01 +01:00
Jens Wiklander
a45ea4efa3 tee: refactor TEE_SHM_* flags
Removes the redundant TEE_SHM_DMA_BUF, TEE_SHM_EXT_DMA_BUF,
TEE_SHM_MAPPED and TEE_SHM_KERNEL_MAPPED flags.

TEE_SHM_REGISTER is renamed to TEE_SHM_DYNAMIC in order to better
match its usage.

Assigns new values to the remaining flags to void gaps.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander
924e322692 optee: add optee_pool_op_free_helper()
Adds a common helper function to free a tee_shm allocated using the
helper function optee_pool_op_alloc_helper().

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander
5d41f1b3e3 tee: replace tee_shm_alloc()
tee_shm_alloc() is replaced by three new functions,

tee_shm_alloc_user_buf() - for user mode allocations, replacing passing
the flags TEE_SHM_MAPPED | TEE_SHM_DMA_BUF

tee_shm_alloc_kernel_buf() - for kernel mode allocations, slightly
optimized compared to using the flags TEE_SHM_MAPPED | TEE_SHM_DMA_BUF.

tee_shm_alloc_priv_buf() - primarily for TEE driver internal use.

This also makes the interface easier to use as we can get rid of the
somewhat hard to use flags parameter.

The TEE subsystem and the TEE drivers are updated to use the new
functions instead.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander
d88e0493a0 tee: simplify shm pool handling
Replaces the shared memory pool based on two pools with a single pool.
The alloc() function pointer in struct tee_shm_pool_ops gets another
parameter, align. This makes it possible to make less than page aligned
allocations from the optional reserved shared memory pool while still
making user space allocations page aligned. With in practice unchanged
behaviour using only a single pool for bookkeeping.

The allocation algorithm in the static OP-TEE shared memory pool is
changed from best-fit to first-fit since only the latter supports an
alignment parameter. The best-fit algorithm was previously the default
choice and not a conscious one.

The optee and amdtee drivers are updated as needed to work with this
changed pool handling.

This also removes OPTEE_SHM_NUM_PRIV_PAGES which becomes obsolete with
this change as the private pages can be mixed with the payload pages.

The OP-TEE driver changes minimum alignment for argument struct from 8
bytes to 512 bytes. A typical OP-TEE private shm allocation is 224 bytes
(argument struct with 6 parameters, needed for open session). So with an
alignment of 512 well waste a bit more than 50%. Before this we had a
single page reserved for this so worst case usage compared to that would
be 3 pages instead of 1 page. However, this worst case only occurs if
there is a high pressure from multiple threads on secure world. All in
all this should scale up and down better than fixed boundaries.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Yang Yingliang
40eb0dcf41 tee: optee: fix error return code in probe function
If teedev_open() fails, probe function need return
error code.

Fixes: aceeafefff ("optee: use driver internal tee_context for some rpc")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-14 12:36:48 +01:00
Arnd Bergmann
cc0def5b4e OP-TE fixes for v5.17
- Adds error checking in optee_ffa_do_call_with_arg()
 - Reintroduces an accidentally lost fix for a memref size check
 - Uses bitmap_free() to free memory obtained with bitmap_zalloc()
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmHxH3YaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJcfyw/+ON3pjOWqnf/1vx8i6/Ff
 ClwvvnYxTzG5KLcHLVc3mQMRMuckKSOVbudEPVNh21ShzYEG10ZiBvnamVyE90d5
 w5prGYG6VJleWKu48PdPyCBab/70alG5Uz4F9zFype4/Je95GJdzW/9Cdy2Z0/BR
 UbMsBtksE8cRoHdleHu31UdUPsnfSPGzTfJDWH3zVzuZT7cqWcQMnZNnk72K+iXH
 XR9dBVGQL04pejoWVIMy0jzvKl/7MoOtBRrlmzAXxLDWwdxSgriRfmQmA1jEumM8
 LLW8NZTMb7PBI7rkMrWDWziWfyp3N32BtRdkjzvMNHW01u2frsew92XZYK1c3qki
 OgN2rZkJ214xQpT3zMl+XtlSz5qWGA1I6N3oPe7Lr4rxbs9G2ErKn6GLMREfkXgG
 Xi5xy1wzSZg3SXan6oM2DO4cDXq2LOcubqKev8oWzhVBFzYNgnjtccsZ4KXYzp0z
 7Bhs0FrBv6z9bcFNKFXsamzJTezI8m8DhaXLiphfTctgWO6T7NwmrZnOH29YeMzh
 LfdM6cKIe7nR+w65atrlUFGzfSw4YomgLa6Z6QROSpOY4iAOOceszHZsq0VrUP7x
 uDTLzcoRFbsiJflNJ+fkI0pMLV+2DRPi07Ct/KmnRGq2uXOJyCsFmNTFcPRmSHPc
 ho57USzMvl9Loh076Rt71kA=
 =dcSW
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmICLmwACgkQmmx57+YA
 GNn7eA//dwFBYgFW7ATlLzp8lWL7mOg4Dh6vzdinyLLaKp0bPTKn0oNZxuDZE6d4
 FHw7ZDKShwlD5/NwPp9IfigErPgBOUbO1j4FlfLi3rIAqeOka3yuRllRD2tRA2+H
 dl0SI5e8QLwmGZ7pWcJcvR4xm700o45nIkPWptQPQfNcEFfHrML03tnzQvQoA3S3
 ziIK13aKDMBL/9SjLKpWq5dW6d8mkFsbE6TVrmLfwaCqBgcpqy3WC9z6WmG/wI5G
 Vio3LsV2UG+ngfmLer7gePaVgQW9UbAOM2k5pmA4Zxnkh/Q4mWSlQVMFC5wLFyha
 x4fMZkSU46YGTo1zRpLHVY8UjPvpMM6uv5hWTza/j3c3jBbkN9rvm9la9GrpXz4i
 ZPA5ehaFQ51lSQlx2g2WeZaJYuRliZiWNjrR+A4aGGIBh+4aYC+2sUvky4SyavjJ
 LTKwdyvF1RTkDGr7L+mkZLnOZqLQ9xHDIOiMkM0JqLG/xbNFSqMr9oAvh1gf37mo
 42hAtjvx6mU2la21AjCsTzEZgtDXtRJO/bRvT3/3taa3f/ehR47wzUwlMOE7vWcr
 tjHpBJ5vhlg8XwLgHPNxi+nCnAW02q1guEf/QaIxuhpdgyySQQB/NrkQmgsEUYX8
 2RaxOL3iwWjNd56M7D6M+TviUwYmm/aVcrl9adbV48pWtESeL6s=
 =9uyN
 -----END PGP SIGNATURE-----

Merge tag 'optee-fixes-for-v5.17' of git://git.linaro.org/people/jens.wiklander/linux-tee into arm/fixes

OP-TE fixes for v5.17

- Adds error checking in optee_ffa_do_call_with_arg()
- Reintroduces an accidentally lost fix for a memref size check
- Uses bitmap_free() to free memory obtained with bitmap_zalloc()

* tag 'optee-fixes-for-v5.17' of git://git.linaro.org/people/jens.wiklander/linux-tee:
  optee: add error checks in optee_ffa_do_call_with_arg()
  tee: optee: do not check memref size on return from Secure World
  optee: Use bitmap_free() to free bitmap

Link: https://lore.kernel.org/r/20220126102609.GA1516258@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-02-08 09:48:44 +01:00
Jens Wiklander
aceeafefff optee: use driver internal tee_context for some rpc
Adds a driver private tee_context by moving the tee_context in struct
optee_notif to struct optee. This tee_context was previously used when
doing internal calls to secure world to deliver notification.

The new driver internal tee_context is now also when allocating driver
private shared memory. This decouples the shared memory object from its
original tee_context. This is needed when the life time of such a memory
allocation outlives the client tee_context.

This patch fixes the problem described below:

The addition of a shutdown hook by commit f25889f931 ("optee: fix tee out
of memory failure seen during kexec reboot") introduced a kernel shutdown
regression that can be triggered after running the OP-TEE xtest suites.

Once the shutdown hook is called it is not possible to communicate any more
with the supplicant process because the system is not scheduling task any
longer. Thus if the optee driver shutdown path receives a supplicant RPC
request from the OP-TEE we will deadlock the kernel's shutdown.

Fixes: f25889f931 ("optee: fix tee out of memory failure seen during kexec reboot")
Fixes: 217e0250cc ("tee: use reference counting for tee_context")
Reported-by: Lars Persson <larper@axis.com>
Cc: stable@vger.kernel.org
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-03 13:36:32 +01:00
Jens Wiklander
4064c46114 optee: add error checks in optee_ffa_do_call_with_arg()
Adds error checking in optee_ffa_do_call_with_arg() for correctness.

Fixes: 4615e5a34b ("optee: add FF-A support")
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-01-24 13:00:59 +01:00
Jerome Forissier
abc8dc34d1 tee: optee: do not check memref size on return from Secure World
Commit c650b8dc7a ("tee: optee: do not check memref size on return
from Secure World") was mistakenly lost in commit 4602c5842f ("optee:
refactor driver with internal callbacks"). Remove the unwanted code
again.

Fixes: 4602c5842f ("optee: refactor driver with internal callbacks")
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-01-24 12:53:34 +01:00
Christophe JAILLET
9decff5f40 optee: Use bitmap_free() to free bitmap
kfree() and bitmap_free() are the same. But using the latter is more
consistent when freeing memory allocated with bitmap_zalloc().

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-01-24 12:53:34 +01:00
Linus Torvalds
e85195d5bf ARM: SoC driver updates for v5.17
There are cleanups and minor bugfixes across several SoC specific
 drivers, for Qualcomm, Samsung, NXP i.MX, AT91, Tegra, Keystone,
 Renesas, ZynqMP
 
 Noteworthy new features are:
 
  - The op-tee firmware driver gains support for asynchronous
    notifications from secure-world firmware.
 
  - Qualcomm platforms gain support for new SoC types in various
    drivers: power domain, cache controller, RPM sleep, soc-info
 
  - Samsung SoC drivers gain support for new SoCs in ChipID and PMU,
    as well as a new USIv2 driver that handles various types of
    serial communiction (uart, i2c, spi)
 
  - Renesas adds support for R-Car S4-8 (R8A779F0) in multiple
    drivers, as well as memory controller support for RZ/G2L
    (R9A07G044).
 
  - Apple M1 gains support for the PMGR power management driver
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmHDpK8ACgkQmmx57+YA
 GNmUqhAAnaxXJeu+dfWanrAAeH1MKju/uxB6bogtwrAc928BaqmeZfiAqsT9KsWu
 FhkWSGRu+y74fct4zkD3xfl0V2ROSrSjcvrWVu0GJPnXoOLKDZ1RbdZDnfXbwowa
 4urL5HeOtKYUpLjw7z8EQ43SHZba7CsiImGcF/4OtHW1hNGNIlU/Mym93lFT5Xdq
 HwDrktBWWVvBkCnxVGJjMwGGSCJbowIsPK8p8xr4CqML4Vdcx89qKB8cnCOg8Bgo
 YqzcJCTOY9K5qXI8D20GaTJCP5vCPxMgmeFn4LgWa+h9iJrt+g4J8zA1qGw92nwJ
 W2uRu/6YkCC2HMiyExuxkJNPKbFRbOqAm7lA/ZzuFpFU5RowACIrlwm4ZR/4UFDG
 fzrt3ZfNLRu33QxqhKY0jWGeHu729+RE2kpQ4FXveFmrtRIWnuX70/+NQFVhm+qy
 EBgXmlWNhTh2tcgfEzPja52+5h3SYKk6/J44266i/34x5eLDvmuRADzCVpLUmbPS
 G5UHVkWHZPJne6ZJQ+yz+o2h6BjcpCTvPRbt2/KkSOo9S0Qj4/XrOUHBAofy3odH
 Tdiba6lXMHZqvLlOOrMyJ0qdv26FJyJaSg5Wqhq45G1YCW5Xjc+cYzZggJBvBpIh
 thyN4b9jqfTnAZzKB6LCBUmEF2A7gXkuW9oXzNUkKtVzYluu1aQ=
 =tlZT
 -----END PGP SIGNATURE-----

Merge tag 'drivers-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM SoC driver updates from Arnd Bergmann:
 "There are cleanups and minor bugfixes across several SoC specific
  drivers, for Qualcomm, Samsung, NXP i.MX, AT91, Tegra, Keystone,
  Renesas, ZynqMP

  Noteworthy new features are:

   - The op-tee firmware driver gains support for asynchronous
     notifications from secure-world firmware.

   - Qualcomm platforms gain support for new SoC types in various
     drivers: power domain, cache controller, RPM sleep, soc-info

   - Samsung SoC drivers gain support for new SoCs in ChipID and PMU, as
     well as a new USIv2 driver that handles various types of serial
     communiction (uart, i2c, spi)

   - Renesas adds support for R-Car S4-8 (R8A779F0) in multiple drivers,
     as well as memory controller support for RZ/G2L (R9A07G044).

   - Apple M1 gains support for the PMGR power management driver"

* tag 'drivers-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (94 commits)
  soc: qcom: rpmh-rsc: Fix typo in a comment
  soc: qcom: socinfo: Add SM6350 and SM7225
  dt-bindings: arm: msm: Don't mark LLCC interrupt as required
  dt-bindings: firmware: scm: Add SM6350 compatible
  dt-bindings: arm: msm: Add LLCC for SM6350
  soc: qcom: rpmhpd: Sort power-domain definitions and lists
  soc: qcom: rpmhpd: Remove mx/cx relationship on sc7280
  soc: qcom: rpmhpd: Rename rpmhpd struct names
  soc: qcom: rpmhpd: sm8450: Add the missing .peer for sm8450_cx_ao
  soc: qcom: socinfo: add SM8450 ID
  soc: qcom: rpmhpd: Add SM8450 power domains
  dt-bindings: power: rpmpd: Add SM8450 to rpmpd binding
  soc: qcom: smem: Update max processor count
  dt-bindings: arm: qcom: Document SM8450 SoC and boards
  dt-bindings: firmware: scm: Add SM8450 compatible
  dt-bindings: arm: cpus: Add kryo780 compatible
  soc: qcom: rpmpd: Add support for sm6125
  dt-bindings: qcom-rpmpd: Add sm6125 power domains
  soc: qcom: aoss: constify static struct thermal_cooling_device_ops
  PM: AVS: qcom-cpr: Use div64_ul instead of do_div
  ...
2022-01-10 08:13:52 -08:00
Xiaolei Wang
6add87fdae optee: Suppress false positive kmemleak report in optee_handle_rpc()
We observed the following kmemleak report:
unreferenced object 0xffff000007904500 (size 128):
  comm "swapper/0", pid 1, jiffies 4294892671 (age 44.036s)
  hex dump (first 32 bytes):
    00 47 90 07 00 00 ff ff 60 00 c0 ff 00 00 00 00  .G......`.......
    60 00 80 13 00 80 ff ff a0 00 00 00 00 00 00 00  `...............
  backtrace:
    [<000000004c12b1c7>] kmem_cache_alloc+0x1ac/0x2f4
    [<000000005d23eb4f>] tee_shm_alloc+0x78/0x230
    [<00000000794dd22c>] optee_handle_rpc+0x60/0x6f0
    [<00000000d9f7c52d>] optee_do_call_with_arg+0x17c/0x1dc
    [<00000000c35884da>] optee_open_session+0x128/0x1ec
    [<000000001748f2ff>] tee_client_open_session+0x28/0x40
    [<00000000aecb5389>] optee_enumerate_devices+0x84/0x2a0
    [<000000003df18bf1>] optee_probe+0x674/0x6cc
    [<000000003a4a534a>] platform_drv_probe+0x54/0xb0
    [<000000000c51ce7d>] really_probe+0xe4/0x4d0
    [<000000002f04c865>] driver_probe_device+0x58/0xc0
    [<00000000b485397d>] device_driver_attach+0xc0/0xd0
    [<00000000c835f0df>] __driver_attach+0x84/0x124
    [<000000008e5a429c>] bus_for_each_dev+0x70/0xc0
    [<000000001735e8a8>] driver_attach+0x24/0x30
    [<000000006d94b04f>] bus_add_driver+0x104/0x1ec

This is not a memory leak because we pass the share memory pointer
to secure world and would get it from secure world before releasing it.

Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-12-16 15:32:48 +01:00
Sumit Garg
18549bf4b2 tee: optee: Fix incorrect page free bug
Pointer to the allocated pages (struct page *page) has already
progressed towards the end of allocation. It is incorrect to perform
__free_pages(page, order) using this pointer as we would free any
arbitrary pages. Fix this by stop modifying the page pointer.

Fixes: ec185dd3ab ("optee: Fix memory leak when failing to register shm pages")
Cc: stable@vger.kernel.org
Reported-by: Patrik Lantz <patrik.lantz@axis.com>
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Tyler Hicks <tyhicks@linux.microsoft.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-12-16 15:32:37 +01:00
Yang Li
b98aee466d optee: Fix NULL but dereferenced coccicheck error
Eliminate the following coccicheck warning:
./drivers/tee/optee/smc_abi.c:1508:12-15: ERROR: optee is NULL but
dereferenced.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Fixes: 6749e69c4d ("optee: add asynchronous notifications")
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-11-29 22:02:25 +01:00
Jens Wiklander
6749e69c4d optee: add asynchronous notifications
Adds support for asynchronous notifications from secure world to normal
world. This allows a design with a top half and bottom half type of
driver where the top half runs in secure interrupt context and a
notifications tells normal world to schedule a yielding call to do the
bottom half processing.

The protocol is defined in optee_msg.h optee_rpc_cmd.h and optee_smc.h.

A notification consists of a 32-bit value which normal world can
retrieve using a fastcall into secure world. The value
OPTEE_SMC_ASYNC_NOTIF_VALUE_DO_BOTTOM_HALF (0) has a special meaning.
When this value is sent it means that normal world is supposed to make a
yielding call OPTEE_MSG_CMD_DO_BOTTOM_HALF.

Notification capability is negotiated while the driver is initialized.
If both sides supports these notifications then they are enabled.

An interrupt is used to notify the driver that there are asynchronous
notifications pending. The maximum needed notification value is
communicated at this stage. This allows scaling up when needed.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-11-17 14:08:57 +01:00
Jens Wiklander
787c80cc7b optee: separate notification functions
Renames struct optee_wait_queue to struct optee_notif and all related
functions to optee_notif_*().

The implementation is changed to allow sending a notification from an
atomic state, that is from the top half of an interrupt handler.

Waiting for keys is currently only used when secure world is waiting for
a mutex or condition variable. The old implementation could handle any
32-bit key while this new implementation is restricted to only 8 bits or
the maximum value 255. A upper value is needed since a bitmap is
allocated to allow an interrupt handler to only set a bit in case the
waiter hasn't had the time yet to allocate and register a completion.

The keys are currently only representing secure world threads which
number usually are never even close to 255 so it should be safe for now.
In future ABI updates the maximum value of the key will be communicated
while the driver is initializing.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-11-17 14:08:56 +01:00
Lv Ruyi
c23ca66a4d optee: fix kfree NULL pointer
This patch fixes the following Coccinelle error:
drivers/tee/optee/ffa_abi.c: 877: ERROR  optee is NULL but dereferenced.

If memory allocation fails, optee is null pointer. the code will goto err
and release optee.

Fixes: 4615e5a34b ("optee: add FF-A support")
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
[jw: removed the redundant braces]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-11-16 14:41:23 +01:00
Arnd Bergmann
6a03568932 Fix spell errors in OP-TEE FF-A driver log messages
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmF6cLoaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJcTIw/7BSkGVsrW4yGlcxPWdOeg
 kCAMoHzWkK8CKue1gO3zLsEoAUAHJSqDuwvgy8DZZ/D4k6CXBiU+4BmJNZxfLl9s
 RAd5BTMbxjlDPtolUhAJ7mOqTLRNUvkd8NE1EMvIZx4kZ9TvAzuLxfcFOaKnKz50
 m/XGhH1Sw99Nh9Oo05wbDHoNyj9AL24LyBTgq3UU56XSCWQoXJVthMujv2gykFhz
 1HMWRGvMrFLNGMPdPopueC3WgSRCbdH/3pIjSoY6gw+mWNkuayBTRBHTsg4VsDYJ
 0IOP/BUPrQlztKFG9LoWC05tJ/Nf6NLrjA3KBtT3p7IyH/RPWfQXbqpjSA5IOjne
 JKgZpCnLN4ErE0126Y22U+QxFbJ+yaKYtXqQzWoy1p4mcVrT4FusSlr3Pac6KpUl
 bW1hqVSgp5F2nwWq3yb6OX4BTjcjPIxsOUagC/1gplgIjzvBgvQrRu27C2awhQyY
 Q/Z/rNXALEoGtcU4HfK8GJb3LxYnUJRxX3Ew9pAPOoqogDZ2G5XUEOYmEkjXYuk4
 X5kAjDZjsV3ilotlJUUSC5SWCqCMGfjrC7YFdNdZ37z0TEWTwAyteZjMbh25E6QR
 VZayZ8jDAA1XlVj+1IbaJ+9ejDnd7lNNSwhuVdBZUwFsTRkLpK0/v6vAdbez0x+H
 ZDTlayOPF1A5SjjD0em//nQ=
 =s4um
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmGA9VgACgkQmmx57+YA
 GNkW6w//dby66qfdXat+V6iwLwE6mTaWloXkD2neK6cpBEK/+tRrS7ut6muuiBct
 41lMgIn4G0sWphNKUTsKn4ARLHHOWAEZYHyTpWJGnVXUEjspCLLfLWYJjGhRAYpj
 eufYv2feVV4uphuvc30tp9OZT/5byipiJE6JQxkiufLgXBjNc0XtUUhZEQ1tlLkf
 YpTXk3djr+lQy9fNmN+EsKzAbz3MJKjVjQG76b9ELqHWPHENZxYMBlrspcRH9Wa3
 RoYj7e8E+oD9PouCdi10FshLMsujKtkZESKZ/mQ1f5BJ5Z9ypEDqhLRbEG7nicTe
 7rIZ5q8Qsu2dVw7neeHIlH32RqUbKgCcxQA7ZvKI1JMWLZYHWYlT2eFtcD/kiOij
 F/DF1CmXE++QsHzULD0tBRohjpanIVfqNPdomDrmi5cKn5W+MhR4+EsnzSMZWVF6
 srd+9lYLuQW/fnnBj6JcMUkOF8woBUPERtGYTbgt2rMBikcwo49MVd1vcEjHIU20
 ZH+I8mGJwyawWhiDmq0CeCZr6qg86MWrwaWNgjx27FU3O38yUZHxvMQ8XDVFatR8
 vtk2pRO6BHoVcO6kcleWzsuZQwLxJ4k+Jbn0QpyeGMAgn4P/p0ilvB6m9ShnWNCB
 05RvO8EGBTzvnrdMblfuXTpQ1ZCHdGU7q4TeZS8+DtNYAAYggR8=
 =PKVA
 -----END PGP SIGNATURE-----

Merge tag 'optee-ffa-fix-for-v5.16' of git://git.linaro.org/people/jens.wiklander/linux-tee into arm/drivers

Fix spell errors in OP-TEE FF-A driver log messages

* tag 'optee-ffa-fix-for-v5.16' of git://git.linaro.org/people/jens.wiklander/linux-tee:
  optee: Fix spelling mistake "reclain" -> "reclaim"

Link: https://lore.kernel.org/r/20211028185142.GA2489375@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2021-11-02 09:22:48 +01:00
Colin Ian King
1b73a9e498 optee: Fix spelling mistake "reclain" -> "reclaim"
There are spelling mistakes in pr_err error messages. Fix them.

Fixes: 4615e5a34b ("optee: add FF-A support")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
[jw: added a fixes]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-10-28 11:41:39 +02:00
Jens Wiklander
34f3c67b81
optee: smc_abi.c: add missing #include <linux/mm.h>
Adds missing #include <linux/mm.h> drivers/tee/optee/smc_abi.c to fix
compile errors like:
drivers/tee/optee/smc_abi.c:405:15: error: implicit
declaration of function 'page_to_section'
[-Werror,-Wimplicit-function-declaration]
        optee_page = page_to_phys(*pages) +
                     ^
arch/arm/include/asm/memory.h:148:43: note: expanded from
macro 'page_to_phys'
                                               ^
include/asm-generic/memory_model.h:52:21: note: expanded
from macro 'page_to_pfn'
                    ^
include/asm-generic/memory_model.h:35:14: note: expanded
from macro '__page_to_pfn'
        int __sec = page_to_section(__pg);                      \
                    ^
drivers/tee/optee/smc_abi.c:405:15: note: did you mean
'__nr_to_section'?
arch/arm/include/asm/memory.h:148:43: note: expanded from
macro 'page_to_phys'
                                               ^
include/asm-generic/memory_model.h:52:21: note: expanded
from macro 'page_to_pfn'
                    ^
include/asm-generic/memory_model.h:35:14: note: expanded
from macro '__page_to_pfn'
        int __sec = page_to_section(__pg);                      \
                    ^
include/linux/mmzone.h:1365:35: note: '__nr_to_section'
declared here
static inline struct mem_section *__nr_to_section(unsigned long nr)

Fixes: c51a564a5b ("optee: isolate smc abi")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Link: https://lore.kernel.org/r/20211021125539.3858495-1-jens.wiklander@linaro.org'
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2021-10-21 21:35:49 +02:00
Jens Wiklander
4615e5a34b optee: add FF-A support
Adds support for using FF-A [1] as transport to the OP-TEE driver.

Introduces struct optee_msg_param_fmem which carries all information
needed when OP-TEE is calling FFA_MEM_RETRIEVE_REQ to get the shared
memory reference mapped by the hypervisor in S-EL2. Register usage is
also updated to include the information needed.

The FF-A part of this driver is enabled if CONFIG_ARM_FFA_TRANSPORT is
enabled.

[1] https://developer.arm.com/documentation/den0077/latest
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-10-18 11:44:23 +02:00
Jens Wiklander
c51a564a5b optee: isolate smc abi
Isolate the ABI based on raw SMCs. Code specific to the raw SMC ABI is
moved into smc_abi.c. This makes room for other ABIs with a clear
separation.

The driver changes to use module_init()/module_exit() instead of
module_platform_driver(). The platform_driver_register() and
platform_driver_unregister() functions called directly to keep the same
behavior. This is needed because module_platform_driver() is based on
module_driver() which can only be used once in a module.

A function optee_rpc_cmd() is factored out from the function
handle_rpc_func_cmd() to handle the ABI independent part of RPC
processing.

This patch is not supposed to change the driver behavior, it's only a
matter of reorganizing the code.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-10-18 11:44:23 +02:00
Jens Wiklander
4602c5842f optee: refactor driver with internal callbacks
The OP-TEE driver is refactored with three internal callbacks replacing
direct calls to optee_from_msg_param(), optee_to_msg_param() and
optee_do_call_with_arg().

These functions a central to communicating with OP-TEE in secure world
by using the SMC Calling Convention directly.

This refactoring makes room for using other primitives to communicate
with OP-TEE in secure world while being able to reuse as much as
possible from the present driver.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-10-15 11:55:42 +02:00
Jens Wiklander
c0ab6db39a optee: simplify optee_release()
Simplifies optee_release() with a new helper function,
optee_close_session_helper() which has been factored out from
optee_close_session().

A separate optee_release_supp() is added for the supplicant device.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2021-10-15 11:55:41 +02:00