Commit Graph

950527 Commits

Author SHA1 Message Date
Srinivas Kandagatla 709ec3f7fc slimbus: qcom-ngd-ctrl: disable ngd in qmi server down callback
In QMI new server notification we enable the NGD however during
delete server notification we do not disable the NGD.

This can lead to multiple instances of NGD being enabled, so make
sure that we disable NGD in delete server callback to fix this issue!

Fixes: 917809e228 ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20200925095520.27316-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-25 14:41:51 +02:00
Srinivas Kandagatla df2c471c4a slimbus: core: do not enter to clock pause mode in core
Let the controller logic decide when to enter into clock pause mode!
Entering in to pause mode during unregistration does not really make
sense as the controller is totally going down at that point in time.

Fixes: 4b14e62ad3 ("slimbus: Add support for 'clock-pause' feature")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20200925095520.27316-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-25 14:41:50 +02:00
Srinivas Kandagatla f97769fde6 slimbus: core: check get_addr before removing laddr ida
logical address can be either assigned by the SLIMBus controller or the core.
Core uses IDA in cases where get_addr callback is not provided by the
controller.
Core already has this check while allocating IDR, however during absence
reporting this is not checked. This patch fixes this issue.

Fixes: 46a2bb5a7f ("slimbus: core: Add slim controllers support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20200925095520.27316-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-25 14:41:50 +02:00
Greg Kroah-Hartman 5a487cf7ef This tag contains the following changes for kernel 5.10-rc1:
- release the kernel context object after we reset the device. This is
   needed to prevent a race where the firmware still has some in-flight
   transcations that require the kernel context (and its memory mappings) to
   be alive.
 
 - replace constant numbers with defines in QMAN initialization of GAUDI
 
 - correct an error message text and add a few debug messages to help debug
   issues that happen during context open and close.
 -----BEGIN PGP SIGNATURE-----
 
 iQFKBAABCgA0FiEE7TEboABC71LctBLFZR1NuKta54AFAl9t2h4WHG9kZWQuZ2Fi
 YmF5QGdtYWlsLmNvbQAKCRBlHU24q1rngKJTCAClbA79YeWImufwUr2kcs3OhPmI
 QeBCpiAMM/1chKTTLjh5RiAGWYTjEpwRn3DXunnrwdfeqvSoYPw7GxgP/oWKbY9M
 ISdGS5igw7VaFhG6PF2IpmrRt3R8qV+QOhsto54zt9ZkUwwHw2vzkFYrFYUWa1Rq
 g6NBYO9O2O07EK/wfVln9mDNMjsHSaY1hltOfY6vmU00psWGGGDYUg0QpOUJeZBw
 1+Aw5jQPmflfTdcOzEO2Dsts4mVXiLVQxgvaohTXVTbhIXvUZA+aKMj8Xd3snghT
 /SehLKHi0LWUvzpsSNAjk4nw+kAcKatP8aKjpFfKcGoIc805E6fN4tAj5uTb
 =0VFf
 -----END PGP SIGNATURE-----

Merge tag 'misc-habanalabs-next-2020-09-25' of git://people.freedesktop.org/~gabbayo/linux into char-misc-next

Oded writes:

This tag contains the following changes for kernel 5.10-rc1:

- release the kernel context object after we reset the device. This is
  needed to prevent a race where the firmware still has some in-flight
  transcations that require the kernel context (and its memory mappings) to
  be alive.

- replace constant numbers with defines in QMAN initialization of GAUDI

- correct an error message text and add a few debug messages to help debug
  issues that happen during context open and close.

* tag 'misc-habanalabs-next-2020-09-25' of git://people.freedesktop.org/~gabbayo/linux:
  habanalabs/gaudi: configure QMAN LDMA registers properly
  habanalabs: add notice of device not idle
  habanalabs: add debug messages for opening/closing context
  habanalabs: release kernel context after hw_fini
  habanalabs: correct an error message
2020-09-25 14:36:48 +02:00
Ofir Bitton 25121d9804 habanalabs/gaudi: configure QMAN LDMA registers properly
LDMA registers are configured with a fixed value.
We add new define set which gives the configuration
a proper meaning.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-25 14:44:21 +03:00
Oded Gabbay eab1f6e7b0 habanalabs: add notice of device not idle
The device should be idle after a context is closed. If not, print a
notice.

Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-25 14:44:21 +03:00
Oded Gabbay 3c3aa5dbd6 habanalabs: add debug messages for opening/closing context
During debugging of error we sometimes need to know whether the error
happened when a user context was open. Add debug prints when opening and
closing user contexts.

Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-25 14:44:20 +03:00
Oded Gabbay 9e2e8fc7d6 habanalabs: release kernel context after hw_fini
Some engines use resources that belong to the kernel context (e.g. MMU
mappings). In case the halt-engines doesn't work properly due to H/W
restriction, we need to make sure the kernel context lives on until after
the hw_fini. The hw_fini resets the ASIC after that no engine is alive and
we can safely close the kernel context.

Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-25 14:44:20 +03:00
Oded Gabbay fc6121e961 habanalabs: correct an error message
We don't try to allocate huge pages here so remove the huge word.

Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-25 14:44:20 +03:00
Greg Kroah-Hartman 9eb29f2ed9 interconnect changes for 5.10
Here are the interconnect changes for the 5.10-rc1 merge window
 consisting of core changes, new drivers and cleanups.
 
 Core changes:
  - New bulk API helpers for managing multiple interconnect paths.
  - New xlate_extended() interface for parsing additional data from DT.
  - Support for sync_state().
 
 Driver changes:
  - New drivers for SM8150 and SM8250 platforms.
  - New drivers for the Qualcomm OSM and EPSS hardware blocks.
  - Per-BCM scaling factor support.
  - Misc cleanups.
 
 Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJfbIvSAAoJEIDQzArG2BZj2CkQAIcw1FnLPl/rC0yNfaXrpZY/
 NLsh6kVZYjbtTcqMJ1imT9mBfohDFlSdAnonSZrRy8pvGWl57NGZbNII+/bc3w/D
 K/RGOZSG+Wow74eoopwJiIMFnFnQoLB1bCJ+1JLIyo+UyLR1WUD9VovtZs3tKuOw
 qIJyBukMLNKNKy5+xuGVH9y5wMpusQtDgiwO/XYWTgCtU4pxUHH0+OMgpmJOW3Ej
 kpdXCfdes4rDEIrb4NorPcPOuC0eDajpE+2GZJkigZbacgJgrHAkRpM6imj6Ura9
 clULeB/9QFcfKFDH56afMsa+p1VOSkDXaEqXbjkBZibA74ior2wC98vYHga+UKxf
 KtTN2ApGWv6EGJ4mHHi9o9eOh0p01lxHv3aUHWAQXIGFzYWfoYxoJ1C1egba9eWJ
 Asc/q9cMGKiYYXqxQ4lVhrNrSyrPD6xMpkJKqlaiqc3oD30ZUDrlJswG3WSehhdD
 LAvMdCsZ3lbooL6NzVwzBVtA7joO4UzZeNAfDkO3NBG4Dn195CbsVAM1p0cdYhws
 hWp1BwTnkdYFy0lcZxr2MKtrnTafsh46dAXPQI3MD8B51Uxrh5FZjY/E8RaLFUnw
 BqffsJFcX3fY1rcFSHRoDMoGZZbB0sZPOaFt4XXSp5/D+Y200Db0DVYVURQd5r6F
 QSe5CuXZlJVCFifnOfG2
 =PO8p
 -----END PGP SIGNATURE-----

Merge tag 'icc-5.10-rc1' of https://git.linaro.org/people/georgi.djakov/linux into char-misc-next

Georgi writes:

interconnect changes for 5.10

Here are the interconnect changes for the 5.10-rc1 merge window
consisting of core changes, new drivers and cleanups.

Core changes:
 - New bulk API helpers for managing multiple interconnect paths.
 - New xlate_extended() interface for parsing additional data from DT.
 - Support for sync_state().

Driver changes:
 - New drivers for SM8150 and SM8250 platforms.
 - New drivers for the Qualcomm OSM and EPSS hardware blocks.
 - Per-BCM scaling factor support.
 - Misc cleanups.

Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

* tag 'icc-5.10-rc1' of https://git.linaro.org/people/georgi.djakov/linux: (28 commits)
  interconnect: imx: simplify the return expression of imx_icc_unregister
  interconnect: imx: Simplify with dev_err_probe()
  interconnect: core: Simplify with dev_err_probe()
  interconnect: qcom: Use icc_sync_state
  interconnect: Add sync state support
  interconnect: Add get_bw() callback
  interconnect: qcom: osm-l3: Mark more structures const
  interconnect: qcom: Add EPSS L3 support on SM8250
  dt-bindings: interconnect: Add EPSS L3 DT binding on SM8250
  interconnect: qcom: Lay the groundwork for adding EPSS support
  interconnect: qcom: Add OSM L3 support on SM8150
  dt-bindings: interconnect: Add OSM L3 DT binding on SM8150
  interconnect: qcom: sc7180: Replace xlate with xlate_extended
  interconnect: qcom: sdm845: Replace xlate with xlate_extended
  interconnect: qcom: Implement xlate_extended() to parse tags
  dt-bindings: interconnect: Document the support of optional path tag
  interconnect: Introduce xlate_extended() callback
  interconnect: qcom: Add support for per-BCM scaling factors
  interconnect: qcom: Only wait for completion in AMC/WAKE by default
  interconnect: qcom: Support bcm-voter-specific TCS wait behavior
  ...
2020-09-24 15:15:11 +02:00
Dan Carpenter 26ed5146bd misc: hisi_hikey_usb: delete a stray tab
This return statement is indented one tab too far.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200918143405.GF909725@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-22 18:54:00 +02:00
Souptick Joarder a81072a9c0 misc: mic: scif: Fix error handling path
Inside __scif_pin_pages(), when map_flags != SCIF_MAP_KERNEL it
will call pin_user_pages_fast() to map nr_pages. However,
pin_user_pages_fast() might fail with a return value -ERRNO.

The return value is stored in pinned_pages->nr_pages. which in
turn is passed to unpin_user_pages(), which expects
pinned_pages->nr_pages >=0, else disaster.

Fix this by assigning pinned_pages->nr_pages to 0 if
pin_user_pages_fast() returns -ERRNO.

Fixes: ba612aa8b4 ("misc: mic: SCIF memory registration and unregistration")
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Link: https://lore.kernel.org/r/1600570295-29546-1-git-send-email-jrdr.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-22 18:53:47 +02:00
Wang ShaoBo a2e7408cf8 misc: pvpanic: Use devm_platform_ioremap_resource()
Make use of devm_platform_ioremap_resource() provided by driver
core platform instead of duplicated analogue.

Acked-by: Arnd Bergmann <arn@arndb.de>
Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
Link: https://lore.kernel.org/r/20200918083634.33124-1-bobo.shaobowang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-22 18:53:30 +02:00
Greg Kroah-Hartman 9e07279310 This tag contains the following changes for kernel 5.10-rc1:
- Stop using the DRM's dma-fence module and instead use kernel completions.
 - Support PCIe AER
 - Use dma_mmap_coherent for memory allocated using dma_alloc_coherent
 - Use smallest possible alignment when allocating virtual addresses in our
   MMU driver.
 - Refactor MMU driver code to be device-oriented
 - Allow user to check CS status without any sleep
 - Add an option to map a Command Buffer to the Device's MMU
 - Expose sync manager resource allocation to user through INFO IOCTL
 - Convert code to use standard BIT(), GENMASK() and FIELD_PREP()
 - Many small fixes (casting, better error messages, remove unused
   defines, h/w configuration fixes, etc.)
 -----BEGIN PGP SIGNATURE-----
 
 iQFKBAABCgA0FiEE7TEboABC71LctBLFZR1NuKta54AFAl9qIHgWHG9kZWQuZ2Fi
 YmF5QGdtYWlsLmNvbQAKCRBlHU24q1rngKKmB/9EzD+xOFKFM7NOWdbkmJQ8di7P
 eLHlqSh8EpIKyvVtiNp5oMMUwBM7bBK4gsvHqPK4cQNUN6wvqvDYt9lRhjgSua1A
 8heVtWpot0+d8PVT64PDWYxRfkI4UiOhQDpyj2vhrBkepW9cQlxs/DTlJHfDAQRd
 ihY3H94tX5DO5/wy7W9XC5BChvgMMoj9KIP5+wYdReaPbgQyIx9x7L8GbqE1aS9C
 daHmFGXxSfJffxDGkIot3XczrmoBIx+9qtL7EZo2HkC6s1IyBnX1KgxvAJR5urt8
 FFd0ma3Md+8PLkEeNX3VJrDAnQPskCvmrU2B61PftnI0EC3eW7mRufM0+kiM
 =zQ26
 -----END PGP SIGNATURE-----

Merge tag 'misc-habanalabs-next-2020-09-22' of git://people.freedesktop.org/~gabbayo/linux into char-misc-next

Oded writes:

This tag contains the following changes for kernel 5.10-rc1:

- Stop using the DRM's dma-fence module and instead use kernel completions.
- Support PCIe AER
- Use dma_mmap_coherent for memory allocated using dma_alloc_coherent
- Use smallest possible alignment when allocating virtual addresses in our
  MMU driver.
- Refactor MMU driver code to be device-oriented
- Allow user to check CS status without any sleep
- Add an option to map a Command Buffer to the Device's MMU
- Expose sync manager resource allocation to user through INFO IOCTL
- Convert code to use standard BIT(), GENMASK() and FIELD_PREP()
- Many small fixes (casting, better error messages, remove unused
  defines, h/w configuration fixes, etc.)

* tag 'misc-habanalabs-next-2020-09-22' of git://people.freedesktop.org/~gabbayo/linux: (46 commits)
  habanalabs: update scratchpad register map
  habanalabs: add indication of security-enabled F/W
  habanalabs/gaudi: fix DMA completions max outstanding to 15
  habanalabs/gaudi: remove axi drain support
  habanalabs: update firmware interface file
  habanalabs: Add an option to map CB to device MMU
  habanalabs: Save context in a command buffer object
  habanalabs: no need for DMA_SHARED_BUFFER
  habanalabs: allow to wait on CS without sleep
  habanalabs/gaudi: increase timeout for boot fit load
  habanalabs: add debugfs support for MMU with 6 HOPs
  habanalabs: add num_hops to hl_mmu_properties
  habanalabs: refactor MMU as device-oriented
  habanalabs: rename mmu.c to mmu_v1.c
  habanalabs: use smallest possible alignment for virtual addresses
  habanalabs: check flag before reset because of f/w event
  habanalabs: increase PQ COMP_OFFSET by one nibble
  habanalabs: Fix alignment issue in cpucp_info structure
  habanalabs: remove unused define
  habanalabs: remove unused ASIC function pointer
  ...
2020-09-22 18:38:09 +02:00
Oded Gabbay f279e5cd95 habanalabs: update scratchpad register map
Our firmware use some scratchpad registers in the device for different
roles. Update the file to the latest version of the firmware code.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:54 +03:00
Oded Gabbay 57799ce9f8 habanalabs: add indication of security-enabled F/W
Future F/W versions will have enhanced security measures and the driver
won't be able to do certain configurations that it always did and those
configurations will be done by the firmware.

We use the firmware's preboot version to determine whether security
measures are enabled or not. Because we need this very early in our code,
the read of the preboot version is moved to the earliest possible place,
right after the device's PCI initialization.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:54 +03:00
Oded Gabbay d1f3633599 habanalabs/gaudi: fix DMA completions max outstanding to 15
This is a workaround for H/W bug H3-2116, where if there are more than 16
outstanding completions in the DMA transpose engine, there can be a
deadlock in the engine.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:54 +03:00
Oded Gabbay dbf053c429 habanalabs/gaudi: remove axi drain support
AXI drain is broken in GAUDI so remove support for enabling it.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:54 +03:00
Oded Gabbay 219b8f2ff0 habanalabs: update firmware interface file
Add new packet to fetch PLL information from firmware. This will be needed
in the future when the driver won't be able to access the PLL registers
directly

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:54 +03:00
Tomer Tayar ef6a0f6caa habanalabs: Add an option to map CB to device MMU
There are cases in which the device should access the host memory of a
CB through the device MMU, and thus this memory should be mapped.
The patch adds a flag to the CB IOCTL, in which a user can ask the
driver to perform the mapping when creating a CB.
The mapping is allowed only if a dedicated VA range was allocated for
the specific ASIC.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:54 +03:00
Tomer Tayar fa8641a14f habanalabs: Save context in a command buffer object
Future changes require using a context while handling a command buffer,
and thus need to save the context in the command buffer object.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:54 +03:00
Oded Gabbay 448f63badc habanalabs: no need for DMA_SHARED_BUFFER
Now that the driver no longer uses dma_buf, we can remove the select of
DMA_SHARED_BUFFER from kconfig.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:53 +03:00
Oded Gabbay 681a22f55f habanalabs: allow to wait on CS without sleep
The user sometimes wants to check if a CS has completed to clean resources.
In that case, the user doesn't want to sleep but just to check if the CS
has finished and continue with his code.

Add a new definition to the API of the wait on CS. The new definition says
that if the timeout is 0, the driver won't sleep at all but return
immediately after checking if the CS has finished.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:53 +03:00
Oded Gabbay 230b9b7d45 habanalabs/gaudi: increase timeout for boot fit load
The firmware running in the boot stage takes more time to execute due to
increased security mechanisms. Therefore, we need to increase the timeout
we wait for the boot fit to finish loading.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:53 +03:00
Moti Haimovski 214afa974d habanalabs: add debugfs support for MMU with 6 HOPs
This commit modify the existing debugfs code to support future devices that
have a 6 HOPs MMU implementation instead of 5 HOPs implementation.

Signed-off-by: Moti Haimovski <mhaimovski@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:53 +03:00
Moti Haimovski 7edf341b9e habanalabs: add num_hops to hl_mmu_properties
This commit adds the number of HOPs supported by the device to the
device MMU properties.

Signed-off-by: Moti Haimovski <mhaimovski@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:53 +03:00
Moti Haimovski d83fe66928 habanalabs: refactor MMU as device-oriented
As preparation to MMU v2, rework MMU to be device oriented
instantiated according to the device in hand.

Signed-off-by: Moti Haimovski <mhaimovski@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:53 +03:00
Moti Haimovski c91324f41b habanalabs: rename mmu.c to mmu_v1.c
In the future we will have MMU v2 code, so we need to prepare the
driver for it. The first step is to rename the current MMU file to
mmu_v1.c.

Signed-off-by: Moti Haimovski <mhaimovski@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:53 +03:00
Omer Shpigelman 7c52fb0a09 habanalabs: use smallest possible alignment for virtual addresses
Change the acquiring of a device virtual address for mapping by using the
smallest possible alignment, rather than the biggest, depending on the
page size used by the user for allocating the memory. This will lower the
virtual space memory consumption.

Signed-off-by: Omer Shpigelman <oshpigelman@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:53 +03:00
Oded Gabbay 1fb2f37437 habanalabs: check flag before reset because of f/w event
For consistency with GAUDI code, add check of the relevant flag in the
device structure before resetting the GOYA device in case of firmware
event.

Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:52 +03:00
Oded Gabbay 5a1b861daa habanalabs: increase PQ COMP_OFFSET by one nibble
For future ASICs, we increase this field by one nibble. This field was not
used by the current ASICs so this change doesn't break anything.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:52 +03:00
Ofir Bitton 763a0b4d81 habanalabs: Fix alignment issue in cpucp_info structure
Because the device CPU compiler aligns structures to 8 bytes,
struct cpucp_info has an alignment issue as some parts
in the structure are not aligned to 8 bytes.
It is preferred that we explicitly insert placeholders inside
the structure to avoid confusion

in order to validate this scenario, we printed both pointers:

__u8 cpucp_version[VERSION_MAX_LEN]; (0xffff899c67ed4cbc)
__le64 dram_size;                    (0xffff899c67ed4d40)

we see difference of 132 bytes although the first array
is only 128 bytes long, Meaning compiler added a 4 byte padding.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:52 +03:00
Oded Gabbay ae926514dd habanalabs: remove unused define
Cleanup the code.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:52 +03:00
Oded Gabbay b01a971f80 habanalabs: remove unused ASIC function pointer
Old function pointer that was left when the call to this function pointer
was removed.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:52 +03:00
Oded Gabbay 6138bbe911 habanalabs: rename ArmCP to CPU-CP
There were a couple of comments where the name ArmCP was still used. Rename
it to CPU-CP.

In addition, rename ArmCP or ARM in log messages to "device CPU".

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:52 +03:00
Oded Gabbay 975ab7b32b habanalabs: count dropped CS because max CS in-flight
There is a case where the user reaches the maximum number of CS in-flight.
In that case, the driver rejects the new CS of the user with EAGAIN. Count
that event so the user can query the driver later to see if it happened.

Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:52 +03:00
Hillf Danton 0db575350c habanalabs: make use of dma_mmap_coherent
Add dma_mmap_coherent() for goya and gaudi to match their use of
dma_alloc_coherent(), see the Link tag for why.

Link: https://lore.kernel.org/lkml/20200609091727.GA23814@lst.de/
Cc: Christoph Hellwig <hch@lst.de>
Cc: Zhang Li <li.zhang@bitmain.com>
Cc: Ding Z Nan <oshack@hotmail.com>
Signed-off-by: Hillf Danton <hdanton@sina.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:51 +03:00
Oded Gabbay c5e0ec66f0 habanalabs: clear vm_pgoff before doing the mmap
The driver use vm_pgoff to hold the CB idr handle. Before we actually call
the mapping function, we need to clear the handle so there won't be any
garbage left in vm_pgoff.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:51 +03:00
Oded Gabbay 3174ac9bb1 habanalabs: restructure hl_mmap
Arrange the hl_mmap code to be more structured and expandable for the
future. Add better defines that describe our usage of the vm_pgoff.

Note that I shamelessly took the code and defines from the amdkfd driver
(my previous driver).

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:51 +03:00
Oded Gabbay f763946aef habanalabs: cast to u64 before shift > 31 bits
When shifting a boolean variable by more than 31 bits and putting the
result into a u64 variable, we need to cast the boolean into unsigned 64
bits to prevent possible overflow.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:51 +03:00
Oded Gabbay 2f55342c5e habanalabs: replace armcp with the generic cpucp
ArmCP mandates that the device CPU is always an ARM processor, which might
be wrong in the future.

Most of this change is an internal renaming of variables, functions and
defines but there are two entries in sysfs which have armcp in their
names. Add identical cpucp entries but don't remove yet the armcp entries.
Those will be deprecated next year. Add the documentation about it in sysfs
documentation.

Signed-off-by: Moti Haimovski <mhaimovski@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:51 +03:00
Oded Gabbay 42b0698add habanalabs: update GAUDI hardware specs
Add define for the 2 MME slave engines.

Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:51 +03:00
farah kassabri 9f3064913e habanalabs: add support for getting device total energy
Add driver implementation for reading the total energy consumption
from the device ARM FW.

Signed-off-by: farah kassabri <fkassabri@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:51 +03:00
Tomer Tayar 56004701f5 habanalabs: Include linux/bitfield.h only in habanalabs.h
Include linux/bitfield.h only in habanalabs.h, instead of in each and
every file that needs it, as habanalabs.h is already included by all.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:51 +03:00
farah kassabri d90416c84d habanalabs: extend busy engines mask to 64 bits
change busy engines bitmask to 64 bits in order to represent
more engines, needed for future ASIC support.

Signed-off-by: farah kassabri <fkassabri@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:50 +03:00
Oded Gabbay 107dd31465 habanalabs: use 1U when shifting bits
Eliminate following warning:
warning: Shifting signed 32-bit value by 31 bits is undefined behavior

Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:50 +03:00
Oded Gabbay 31ac1f1a57 habanalabs: check TPC vector pipe is empty
The driver waits for the TPC vector pipe to be empty before checking if the
TPC kernel has finished executing, but the code doesn't validate that the
pipe was indeed empty, it just wait for it without checking the return
value.

Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:50 +03:00
Oded Gabbay 0358372bbe habanalabs: remove redundant assignment to variable
new_dma_pkt->ctl is assigned a value and then is reassigned a new value
without the first value ever being used.

Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:50 +03:00
Oded Gabbay 65887291c6 habanalabs: use FIELD_PREP() instead of <<
Use the standard FIELD_PREP() macro instead of << operator to perform
bitmask operations. This ensures type check safety and eliminate compiler
warnings.

Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:50 +03:00
Oded Gabbay a0e072f5a1 habanalabs: use standard BIT() and GENMASK()
Use the standard macros to define bitmasks.

Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2020-09-22 18:49:50 +03:00