Commit Graph

2046 Commits

Author SHA1 Message Date
Shridhar Rasal
3f12a94e06 video: tegra: host: dla: handle queue abort
- queue abort invoked by user releasing device
- send queue flush command to engine to handle queue abort callback
- fix checkpatch errors

Jira DLA-171

Change-Id: Ied5440af7519c6cc145de4d92fe1e0645d6a05bb
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1257079
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:40 +00:00
Amit Sharma (SW-Tegra)
b79f6e271a video: tegra: host: nvdla: add trace support
- Add debugfs to read the traces
    - Add support for trace buffer reading
    - Add DLA_REGION_TRACE region
    - Use Trace Buffer of size 1MB
    - Pass wait param to nvdla_send_cmd() for printf cmd
      and correct buffer freeing logic for it.

JIRA DLA-94

Change-Id: I42c0b1cb5b3cb1d4866deb80b7636964795d6de5
Signed-off-by: Amit Sharma (SW-Tegra) <amisharma@nvidia.com>
Reviewed-on: http://git-master/r/1229942
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
2023-04-14 11:46:40 +00:00
Prashant Gaikwad
bc8bf342a7 video: tegra: host: dla: increase command timeout
Increase command timeout as in some cases command
execution may take more time, for example when we
have added debug prints in command execution path.

Change-Id: I5222f58d5cdbc79447679219970a3630e35b2a80
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/1249546
2023-04-14 11:46:40 +00:00
Shridhar Rasal
248a3e446f video: tegra: host: dla: add debugfs for fw version
- add debugfs to dump loaded firmware's version

Jira DLA-125

Change-Id: I0063aeaf52481543694b27f0c3212e5f11021118
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1246377
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:40 +00:00
Shridhar Rasal
7cdb90c217 video: tegra: host: dla: add fw version checks
- check firmware version during engine poweron and return failure if
  expected firmware version doesn't match

Jira DLA-125

Change-Id: I7283655b914d30bed64478f50531f035976de85d
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1246376
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:40 +00:00
Shridhar Rasal
f02bb00830 video: tegra: host: dla: use queue refcnt
- while submitting a task get a reference for queue and release
  reference on task completion.
- this is necessary to avoid freeing of queue on user instance close and
  also to avoid reuse of it for by next user

Jira DLA-207
Bug 200246031

Change-Id: If441ad4171acee3550fdbebc887043a971985c88
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1244425
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
361e522423 video: tegra: host: add next and sequence fields to task desc
- task descriptor has two fields next and sequence which helps engine
  scheduler for tracking list of tasks from a given queue.
- 'next' pointer gives next task in queue
- 'sequence' number gives task number

Jira DLA-207

Change-Id: If80d38b01d0b10cea791767ec8d0a3a1787cf645
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1244424
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Tested-by: Prashant Gaikwad <pgaikwad@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:40 +00:00
Shridhar Rasal
ff414053c8 video: tegra: host: dla: add MSS syncpoint support
- adds syncpoint<->MSS support for DLA
- register dla enginges with MSS interface during init
- while task submission fetches dma address from interface for a given
  syncpoint
- removes temp hack added to use dma address
- remove temp slice syncpoint support added for verification without MSS
  support

Jira DLA-100

Change-Id: Iff5665f1aa2fce6f3bfa594e9909ebfc96a916bf
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1242663
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:40 +00:00
Prashant Gaikwad
d783776311 video: tegra: host: nvdla: add more info to task
Add below information to task descriptor
- Address list
- LUT data
- Dynamic ROI

Jira DLA-176

Change-Id: I067025da34a68a2d81c5e3829ac76c516ed8754b
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/1221382
2023-04-14 11:46:40 +00:00
Prashant Gaikwad
fd0023d8df video: tegra: host: nvdla: add offset to memory handles
Use offset and memory handle to calculate IOVA address
for descriptors. It allows using single buffer in user
space for all descriptors.

Jira DLA-176

Change-Id: I141efa7fc8662be8aa4b5c3bd2ea7a369a90769a
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/1220956
2023-04-14 11:46:40 +00:00
Prashant Gaikwad
cbadc2aa0c video: tegra: host: nvdla: add protocol for command
Some commands need completion or error notification
from firmware to proceed ahead such as clearing some
resources or reading response from firmware.

Add mechanism to wait for command complete or error
notification from firmware. This add limitation of
handling only one command at a time as there is single
set of registers for command send and response.

Add locking for command send so that only one command
is processed at one time.

Remove wait for idle from ping command and instead
use waiting mechanism.

Clean up task resources if task submit command fails.

Jira DLA-127
Jira DLA-176

Change-Id: I92246c080c730dcae514bcea93b78372799bda4a
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/1219539
2023-04-14 11:46:40 +00:00
Shridhar Rasal
90ba91c011 video: tegra: host: dla: add api to free task
- updates syncpoints as per fence for task
- updates task free API's

Jira DLA-127
Jira DLA-176

Change-Id: I2a35a782294cb0d5f90f1b56a9ba6a44d14b5381
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/1218313
Reviewed-by: Automatic_Commit_Validation_User
2023-04-14 11:46:40 +00:00
Shridhar Rasal
7f3a13acfc video: tegra: host: dla: manage operation desc
- pin mapped operation descriptor buffers during task submission
- get operation descriptors handle from user and pass its IOVA to engine
- pin API returns IOVA for given mem handle
- unpin operation descriptors buffers in task cleanup

Jira DLA-93

Change-Id: I78fb22301ab472685c3bae7c424d75140b814887
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1213761
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:40 +00:00
Shridhar Rasal
a53758ab10 video: tegra: host: dla: correct num task check
- fix boundary conditions for num tasks passed by user
- check for module power on return condition
- fix ioctl cmd check
- always send fence type to user after updating

- use nvdla debug prints

Bug 1806862

CID 38896
CID 38897
CID 442978
CID 442983

Change-Id: I57e70da99f7f6bcac111a10f8255428b433cec5a
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1209580
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
7a65345fdd video: tegra: host: dla: add debug prints
- add debug prints for function tracing, register access, IOCTL,
  and task submit and completion handlers

Jira DLA-133

Change-Id: Ib7c18ff959431a1c7fd0cdc53e77793fba8feac6
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1203697
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
d51249a8a7 video: tegra: host: dla: add debugging utils
- add debug macro functions for different debug levels like,
  info, function, register access etc.
- add option to print to either on console or trace
- add debugfs to set different debug levels and flag to choose
  trace

Jira DLA-134
Jira DLA-135
Jira DLA-136

Change-Id: I4cfbb463a2cf1a47d40dce911c86abb4542f957a
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1203575
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
2e07947262 video: tegra: host: dla: add basic tasklist support
- fix include files path in makefile
- fix ioctl include header file path
- update comments in doxygen format

add support to submit task to engine as per tasklist
  management protocol
- maintain list of tasks under assigned queue with ref counts
- allocates task to maintain list of fences and update them
- dma alloc task descriptor and action list and update them
- submit tasks one by one and send received fence back
  to application
- register for syncpoint notifier with nvhost for completion
  of fence
- on fence completion interrupt handler, cleanup task

Jira DLA-52

Change-Id: Ibe385f47dc9f17dda79cca3daf29b89218dc7289
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1191495
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
4a791935cd video: tegra: host: dla: do not send cmd during poweroff
- as falcon may not be in a state to process any more request in poweroff
  path, do not send set region command

Jira DLA-19

Change-Id: I7ac858554f769b659d2738f7c8ed48b53cc8ec15
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1197453
2023-04-14 11:46:40 +00:00
Shridhar Rasal
14a5a1d015 video: tegra: host: dla: move dla queue API's
- move queue related DLA API's to new file to include task API's
  along with

Jira DLA-19

Change-Id: I312e021314a3fb7d03dd31a557fb7cf6d6fc86ca
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1191494
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
76148fdb14 video: tegra: host: dla: add submit IOCTL
- add initial task submit stub

Jira DLA-19

Change-Id: Iea249cfd14cf186b984d1f296373740f80429c3d
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1191493
2023-04-14 11:46:40 +00:00
Shridhar Rasal
817230d68c video: tegra: host: dla: split IOCTL API's
- as core driver code is growing, split IOCTL related API's
  to new source file.

Jira DLA-19

Change-Id: I42ce24300671392e6ac99fcdae12e2525f74e57e
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1191491
2023-04-14 11:46:40 +00:00
Shridhar Rasal
f2dba6e7d7 video: tegra: host: dla: remove mailbox reg usage from ping
- passing ping values through mailbox register removed,
  so remove mailbox checks in after command execution.

Jira DLA-82

Change-Id: Ieb19f50107c6aa4ef9a5a26d86acfe9abc03c447
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1195056
2023-04-14 11:46:40 +00:00
Prashant Gaikwad
ae33d25309 video: tegra: host: dla: update set region command
Update set region command as per new interface

Jira DLA-19

Change-Id: Ia171fb89b890f79b8df27785079a00cef7351003
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/1180574
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
2023-04-14 11:46:40 +00:00
Prashant Gaikwad
83fafcd6c4 video: tegra: host: dla: update OS interface
Jira DLA-19
Jira DLA-87

Change-Id: Id7eb06cd74bee8c04402501b16b8497fc4d3dcda
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/1180573
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
033b0af3a8 video: tegra: host: fix sparse static warning
Fix below warning from sparse checks:
- nvdla/nvdla.c warning: symbol 'nvdla_queue_abort' was not
  declared. Should it be static?
- pva/pva.c warning: symbol 'pva_queue_abort' was not declared.
  Should it be static?

Bug 200088648

Change-Id: I084156f1b0605008fe9b1dbe534211a682257e2e
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1176532
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
2314481526 video: tegra: host: add queue ops support
- nvhost queue is shared between different clients, for
  client specific queue execution add queue ops.
- add abort queue ops for PVA and DLA.

Jira DLA-51
Jira PVA-44

Change-Id: I3746fa96b4d42649e9c38790988b3648672ab974
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1174800
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:40 +00:00
Shridhar Rasal
59a4029c01 video: tegra: host: add buffer pin and unpin for nvdla
- Using nvhost buffer management framework API's support
  Buffer pin and unpin for multiple buffer handles.

Jira DLA-21

Change-Id: I029dfae698a699caa6e19ef6e7e3c0641b9de782
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1174651
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
6ec04c002b video: tegra: host: nvdla: add Q support
- this adds Queue management support to NvDla
  using nvhost queue framework
- allocate and initialize queues during boot
- On ctrl device node open, assign queue to client separately
- release queue on client node close

- cosmetic fixes for probe code

Jira DLA-51

Change-Id: I978bb9b7d43102a63b7aae15f8e20b79be312fd6
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1173110
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
4f3779d292 video: tegra: host: nvdla: add ping cmd ioctl
- this adds first IOCTL for NvDLA for ping cmd
- this ping cmd added to make sure that, falcon and memory
  read/write are working.

- Through IOCTL, pass ping number to falcon via KMD
- From falcon, for CRC check update mailbox and writeback with
  multiplier.

Jira DLA-20

Change-Id: I9cd1bb57d42d00b03907d7cb45750dcec0b2df7b
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1170198
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
c1215d91b5 video: tegra: host: nvdla: fix sparse warning
Fix sparse warning:
 nvdla.c:40:1: warning: symbol 'attrs' was not declared.
 Should it be static?

Bug 200088648

Change-Id: Ic83c46c938fe82d1e8cbdd7c7e2337b39580cc88
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1167423
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
1dc4850403 video: tegra: host: nvdla: dump falcon data in ISR
- this adds falcon interrupt support for NvDLA driver.
- Register device for falcon interrupt
- Allocate dump data region and pass dma addr to falcon
  after firmware load
- In ISR, read dump data from a allocated dump region and dump
  to console
- During engine power off, free dump region

- add dla KMD<->ucode interface header file for cmd communication.

Jira DLA-45
Jira HOSTX-61

Change-Id: I2163c0e50ce8e2231e185d37bcd3ef8e979f7bdf
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1160994
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:40 +00:00
Shridhar Rasal
5050a625a6 video: tegra: host: NvDLA: enable falcon boot
- add support to boot falcon through nvhost_nvdla_finalize_poweron() PM API.
- nvhost_nvdla_finalize_poweron() called by nvhost as restore start
  dev ops
- nvhost_flcn_finalize_poweron() is API provided by falcon framework to
  request firmware, parse ucode and boot falcon.

- Specify firmware name in NvDLA device data, which is required for
  request_firmware

- Fix Kconfig to enable TEGRA_GRHOST_NVDLA by default

Jira DLA-16

Change-Id: I14791fc1f97c283ff9e9b1890183033bfc4087aa
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1147900
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
ebb39ec0e5 video: tegra: host: do not set private data during probe
private data element of platform data is set during falcon init time.
So remove setting it probe time.

Jira DLA-33

Change-Id: I9807d4520757e8e708b674a1b8f4f95aa24ad526
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1156132
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
c57a31af04 video: tegra: host: nvdla: add IOCTL stub
- adds basic IOCTL stub for device ctrl node
- register newly added fops to ctrl node

Jira DLA-20

Change-Id: I87e764f47dc8b5e96c087b84c1baad909bfcfbf7
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1150326
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Pritesh Raithatha
af16dccff3 video: tegra: host: change kernel path
All kernel versions are getting moved inside $TOP/kernel folder.
Changing kernel paths accordingly.

Bug 200190733

Change-Id: I77d110cc4cf43fc16a3c30e77a9becbb97028ac9
Signed-off-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-on: http://git-master/r/1143393
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
2023-04-14 11:46:40 +00:00
Shridhar Rasal
011da9e1c0 video: tegra: host: add NvDLA support
- NvDLA is a fixed function accelerator engine for deep learning in
  Tegra. Engine supports various layers such as convolution, fully-connected,
  activation, pooling and normalization.
- This patch adds minimal support stub for engine for device
  initialization.

Jira DLA-5

Change-Id: Iecdd3963a77a2f20979ae412ff2f9388c57a26b1
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1132605
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
2023-04-14 11:46:40 +00:00
Laxman Dewangan
fc3a785c5f nvdla: Remove dummy Makefile
Remove dummy makefile to prepare the nvdla folder
to do driver integrations from kernel/nvidia to
kernel/nvidia-oot.

Bug 4038415

Change-Id: I45d8fffc504ab9530718c1fa4f3960037e909f25
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
2023-04-14 11:46:18 +00:00
koenz
94064b64d3 driver/misc/mods: kernel v6.2+ support for IVC init
- Add support for IVC channel init for kernel v6.2+

JIRA TM-949
Bug 3846090

Change-Id: I773d99b89067671c76ec2de3d45461fc5efe2814
Signed-off-by: Koen Zhao <koenz@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2887332
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-13 22:25:47 -07:00
Ankur Pawar
82d83f4250 platform: rtcpu: fix coverity defect
Unchecked return value
CID: 10165906

Bug 3952896

Change-Id: Ie2fc93ed97bbeac57bd210a84222da4102e84478
Signed-off-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2886444
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Matti Ryttylainen <mryttylainen@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-13 22:20:38 -07:00
Ankur Pawar
c5fa6476ee media: i2c: Fix camera driver Coverity defects
Fix the below Coverity defects for OV5693

Dereference null return
CID: 10171403

Unchecked return value
CID: 10171401

Bug 3952896

Change-Id: I657cb0ae9a2baf6c6cac7faa84debb754582534d
Signed-off-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2885152
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Michael Stevens (SW-TEGRA) <michaelst@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-13 12:24:36 -07:00
Praveen James
3d2b7e4ff8 tegra-fsicom: send state notificatication to fsi
tegra-fsicom driver updated to send
suspend and shutdown notification to fsi

Jira SS-4834
Bug 4053113

Change-Id: I0df978783894b1a2ddc64ff8255a796366e79daa
Signed-off-by: Praveen James <pjames@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2880270
Reviewed-by: Rahul Bedarkar <rabedarkar@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-13 12:18:08 -07:00
Ketan Patil
6937db210f video: tegra: nvmap: Add CBC carveout support
- Add CBC carveout suport in nvmap.
- Chunk size for CBC is 2MB, hence each bit from bitmap for CBC carveout
indicate 2MB physically contiguous chunk.
- In case of allocation from CBC, first try to allocate the entire chunk
in physically contiguous manner, if it's not possible then allocate in
chunks of 2MB. All page pointers to these chunks will be stored in
nvmap_handle struct.
- Modify all other operations like vmap, kmap, mmap as per the above
restrictions.

Bug 3956637

Change-Id: I7c304b0127c8fef028e135a4662ab3ad3dc1d1f6
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2880662
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2885806
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
2023-04-12 04:32:35 -07:00
Gerrit Code Review
7e15a9bb58 Merge "nvmap: Merge nvmap driver from kernel/nvidia to kernel/nvidia-oot" into dev-main 2023-04-12 04:32:30 -07:00
Gerrit Code Review
91a65bdf7d Merge "dp-serializer: Merge dp-serializer driver from kernel/nvidia to kernel/nvidia-oot" into dev-main 2023-04-11 11:17:29 -07:00
Ketan Patil
5aabb64157 video: tegra: nvmap: Resolve incorrect check
When NvRmMemHandleFromIVCId is called, it is expected that we mark the
bitmap from same position from where the buffer was allocated by the
producer VM. Update the check as per above expectation.

Bug 3990914

Change-Id: I1f7baa3f21f7b2baf28dda3808f8a45515d120da
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2867746
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Austin Tajiri <atajiri@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-11 05:54:22 +00:00
Ketan Patil
678dc695bb video: tegra: nvmap: Fix data race for RO dma-buf
When one process is trying to duplicate RO handle while other process is
trying to free the same RO handle, then race can occur and second
process can decrement the dma-buf's refcount and it may reach to 0. The
first process can then call get_dma_buf on it, leading to NULL pointer
dereference and ultimately to kernel panic. Fix this by taking an extra
dma-buf refcount before duplicating the handle and then decrease it once
duplication is completed.

Bug 3991243

Change-Id: I99901ce19d8a5d23c5192cb10a17efd2ebaf9d3a
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2865519
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-11 05:54:22 +00:00
Jon Hunter
eb15c0f8cf video: tegra: nvmap: Fix build for Linux v6.3
Upstream Linux commit bc292ab00f6c ("(HEAD) mm: introduce vma->vm_flags
wrapper functions") breaking building the NVMAP driver because the
vm_flags variable is made a const and can no longer be set directly. Fix
the build for Linux v6.3 by using the helper functions for setting the
flags.

Bug 4014315

Change-Id: I52a323a995f5f9ffa8c3356a134c4cf2542e967f
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2867138
Reviewed-by: Puneet Saxena <puneets@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-11 05:54:22 +00:00
Ketan Patil
8a01798884 video: tegra: nvmap: Fix overflow condition
When the carveout size is changed to 2GB, mem->size << PAGE_SHIFT will
overflow the int limit and get wrapped to negative value. Hence
during freeing bitmap, one of the comparison condition is not meeting,
resulting into not freeing bitmap. Ultimately the entire bitmap get
consumed even though it is expected to have empty bits. Fix this by
typecasting the size to u64.

Bug 3962552

Change-Id: Ieaf93a3a91062d3f630921259aa9b3935853e91c
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2861614
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-11 05:54:22 +00:00
Ketan Patil
fd4635f259 video: tegra: nvmap: Update contig flag check
NvRmMemQueryHandleParameters is returning contig flag as false for
handle allocated from generic carveout. Update the contig flag check:
If handle belongs to IOVMM heap then check if it has flag set for
contiguous memory allocation request. Otherwise, if handle belongs to
any carveout then all allocations are contiguous, hence set contig flag
to true.

Bug 3960596

Change-Id: Ic23395942cde2b16f590a44091acfee1b3e59cab
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2851758
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Ashish Mhetre <amhetre@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-11 05:54:22 +00:00
Ketan Patil
9fdb78226d video: tegra: nvmap: Fix data race for RO dma-buf
There is a potential data race for RO dma-buf in the following scenario:
------------------------------------------------------------------
Process 1            | Process 2            | Process 3           |
------------------------------------------------------------------|
AllocAttr handle H1  |                      |                     |
MemMap (H1)          |                      |                     |
AllocAttr(H2)        |                      |                     |
MemMap(H2)           |                      |                     |
id1 = GetSciIpcId(H1)|                      |                     |
id2 = GetSciIpcId(H2)|H3=HandleFromSciIpcId |                     |
id3 = GetSciIpcId(H1)| (id1, RO)            |H4=HandleFromSciIpcId|
MemUnmap(H2)         |QueryHandlePararms(H3)|(id2, RO)            |
MemUnmap(H1)         |MemMap(H3)            |QueryHandleParams(H4)|
HandleFree(H2)       |MemUnmap(H3)          |MemMap(H4)           |
HandleFree(H1)       |HandleFree(H3)        |H5=HandleFromSciIpcId|
                     |                      |(id3, RO)            |
                     |                      |QueryHandleParams(H5)|
                     |                      |MemMap(H5)           |
                     |                      |MemUnmap(H4)         |
                     |                      |MemUnmap(H5)         |
                     |                      |HandleFree(H4)       |
                     |                      |HandleFree(H5)       |
-------------------------------------------------------------------

The race is happening between the HandleFree(H3) in process 2 and
HandleFromSciIpcId(id3, RO) in process 3. Process 2 tries to free the
H3, and function nvmap_free_handle decrements the RO dma-buf's counter,
so that it reaches 0, but nvmap_dmabuf_release is not called immediately
because of which the process 3 get's false value for the following check
if (is_ro && h->dmabuf_ro == NULL)
It results in calling nvmap_duplicate_handle and then meanwhile function
nvmap_dmabuf_release is called and it makes h->dmabuf_ro to NULL. Hence
get_dma_buf fails with null pointer dereference error.

Fix this issue with following approach:
- Before using dmabuf_ro, take the handle->lock, then check if it is not
NULL.
- If not NULL, then call get_file_rcu on the file associated with RO
dma-buf and check return value.
- If return value is false, then dma-buf's ref counter is zero and it is
going away. So wait until dmabuf_ro is set to NULL; and then create a
new dma-buf for RO.
- Otherwise, use the existing RO dma-buf and decrement the refcount
taken with get_file_rcu.

Bug 3741751

Change-Id: I8987efebc476a794b240ca968b7915b4263ba664
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2850394
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-11 05:54:22 +00:00