Commit Graph

38 Commits

Author SHA1 Message Date
Manish Bhardwaj
e8c5cb610a vsc: use max supported ioctl size
target is getting crash while triggering multiple
ioctl call from userpsace due to miscalculation
of mempool_virt and mempool_offset for each slot.
So use max supported ioctl size macro instead of
max supported read and write operation size.

Bug 4336445

Change-Id: I438ff50cb0dfba845f4d7852e74314c66dab196c
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3001185
Reviewed-by: Kasinadha Dendukuri <kdendukuri@nvidia.com>
Reviewed-by: Sumeet Gupta <sumeetg@nvidia.com>
Tested-by: Tonny Liang <tonnyl@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-10-24 13:46:24 -07:00
Jon Hunter
35ac3d9d5e block: virtual-storage: Drop version checks for flags
In Linux v5.17, the GENHD_FL_EXT_DEVT and GENHD_FL_NO_PART_SCAN were
removed and in Linux v5.19, the flags QUEUE_FLAG_SECERASE and
QUEUE_FLAG_DISCARD were removed. Rather than using kernel version
checks, simply check if the flag is defined. This is beneficial for
working with 3rd party Linux kernels that may have backported changes
from upstream.

Although the Tegra virtual-storage can be compiled for v5.19 kernels, it
still needs to be fixed properly for v5.19 kernels. Add some dev_WARN
prints to warn if these flags are not supported so that it will be clear
that this is not expected to work.

Bug 4119327
Bug 4311184

Change-Id: I7f7585b238ad45b26fb1d0df42b338c904ce87e7
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2992552
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-10-12 17:27:02 -07:00
Jon Hunter
dc189dfb94 block: virtual-storage: Remove kernel version checks
Rather than using kernel version checks to determine which kernel APIs
to use, add the necessary tests to the conftest script to determine
which kernel APIs are present in the kernel.

This is beneficial for working with 3rd party Linux kernels that may
have back-ported upstream changes into their kernel and so the kernel
version checks do not work.

Bug 4221847

Change-Id: Iec2c793ce408dab1cf7e5118c019dfe656dfa87c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2992630
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-10-09 22:00:21 -07:00
Manish Bhardwaj
a0eaae1775 nvidia-oot: vsc: fix compilation error with k6.5
fix compilation error while building vsc driver
with k6.5

Bug 4221847
Bug 4311184

Change-Id: Ie015a25d8e6d50ecb2c908d9d505fa15d4daad1e
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2990176
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
2023-10-09 21:58:55 -07:00
Jon Hunter
68d1ae26d6 block: virtual-storage: Drop version check
The function blk_mq_alloc_request() has been exported in the Linux
kernel since v3.16 and the function blk_mq_free_request() has been
exported in the Linux kernel since v3.19. The function

Since Linux v5.0, blk_get_request() has always called
blk_mq_alloc_request() and blk_put_request() has always called
blk_mq_free_request(). Given that kernels newer than v5.0 are now
supported drop the version check around blk_mq_alloc_request() and
blk_mq_free_request() and always use these functions.

Bug 4119327

Change-Id: I018687b340acaa9617c81551efb436a0439b14f1
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2991457
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-10-05 17:57:14 -07:00
Manish Bhardwaj
4df331c666 Revert "nvidia: Optimize the request slots for queueing"
This reverts commit 4c20b236c8523e2af0fcd2f7396577ccf0328eec.
Reason for revert: <Seeing hung issue>

Bug 4260060

Change-Id: Ie9347885dd861ae9afc230c803246f86a0f34615
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2984818
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-09-28 21:46:55 -07:00
Jon Hunter
990ccbf02c block: virtual-storage: Remove unneeded header
The header file 'linux/genhd.h' is not needed for compiling the virtual
storage drivers and so remove this unneeded header file.

Bug 4119327

Change-Id: Ib6dd7bc072b291a5617880fc65c7cd8dbc0b35ab
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2985997
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-09-27 08:24:49 -07:00
Jon Hunter
e3f94bde03 block: virt-storage: Fix build for pre-v5.15 kernels
Building the Tegra virtual storage driver for v5.14 kernels fails with
the following error ...

 drivers/block/tegra_virt_storage/tegra_hv_vblk.c:1236:48: error:
 passing argument 1 of '__alloc_disk_node' makes integer from pointer
 without a cast [-Werror=int-conversion]
  vblkdev->gd = __alloc_disk_node(vblkdev->queue, NUMA_NO_NODE);
                                  ~~~~~~~^~~~~~~
                                         |
                                         struct request_queue *

Fix this by correcting the arguments passed to __alloc_disk_node() for
pre-v5.15 kernels.

Bug 3820317

Change-Id: I2f208acb3ef0a009d877ab46fb110a87968862fe
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2978392
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
2023-09-20 18:57:55 -07:00
Sanjith T D
8975fb1f4b virt_storage: Update calling of ivc_reset()
Below race condition can happen during boot
1) Server calls sivc_reset()
2) Storage client driver has IVC event handler registered, so it gets the event
   and it calls ivc_notified()
3) Server gets ivc event, it calls ivc_notified()
   ( this makes server local state to established )
4) Storage cliend driver also goes to established state
5) After this, storage client driver continued with probe() and
   calls ivc_reset() which results in disconnecting the
   already established connection.

To fix this race condition, perform ivc_reset in storage client
driver right after tegra_hv_ivc_reserve() before registering
the IVC IRQ handler.

Bug 4125055

Change-Id: I36e6db3479f34fb649bdb8d890f24b1783d10cb9
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2943766
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: Sanjith T D <std@nvidia.com>
Reviewed-by: Vipin Kumar <vipink@nvidia.com>
Tested-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
2023-07-31 06:26:24 -07:00
Manish Bhardwaj
7e764afb5f storage: Update VSC driver for handling erase
1. If vs_blk_dev_config.req_ops_supported has only DISCARD
   support enabled, then REQ_OP_DISCARD should be mapped to
   DISCARD for UFS.

2. If vs_blk_dev_config.req_ops_supported has only SECURE_ERASE
   support enabled, then REQ_OP_DISCARD and REQ_OP_SECURE_ERASE
   both should be mapped to SECURE_ERASE for UFS.

3. If vs_blk_dev_config.req_ops_supported has only ERASE
   support enabled, then REQ_OP_DISCARD and REQ_OP_SECURE_ERASE
   both should be mapped to ERASE for UFS.

Bug 4176555

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: I01599df9ab93525120106dfabf2d345ab8b64770
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2920433
Reviewed-by: Sanjith T D <std@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-07-14 08:37:46 -07:00
Manish Bhardwaj
5d872b9a0d storage: fix cert-c issue in storage driver
Using this patch we are fixing below cert error:-
1. var_deref_model: Passing null pointer bio_req to req_op,
   which dereferences it.

CID 10177627

Bug 3512545

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: Id9c71a82d3adf52590816fa87b53a8965da5c105
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2933682
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-07-10 16:54:20 -07:00
Manish Bhardwaj
309e6943e3 storage: create timer before being started.
timer was getting started evein before being created
leading to below crash. So create timer before getting
started.

[0.483364] Internal error: Oops - BUG: 0 [#1] PREEMPT_RT SMP
Modules linked in: tegra_vblk(O) tegra_hv_vblk_oops(O) tegra_hv(O) ivc_ext(O)
CPU: 10 PID: 9 Comm: kworker/u24:0 Tainted: G O 5.15.98-rt-tegra #1
[0.531518] Hardware name: p3710-0010 (DT)
[0.532301] Workqueue: vblk_req_wq1 0xffff800001271c90
[0.533268] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[0.534552] pc : mod_timer+0x2d8/0x340
[0.535250] lr : mod_timer+0x34/0x340
[0.535936] sp : ffff80000aa13c90
[0.536539] x29: ffff80000aa13c90 x28: ffff000083c18080 x27: ffff000083c182f8
[0.537876] x26: ffff00008012de74 x25: ffff000083c182d8 x24: ffff000083c0f0b0
[0.539253] x23: 00000000fffef8b4 x22: ffff00008028e740 x21: ffff000083c18280
[0.540547] x20: 0000000000000000 x19: ffff000083c183d8 x18: 0000000000000001
[0.541860] x17: 00000000000002b5 x16: ffff800001271c90 x15: 0000000000000003
[0.543184] x14: 0000000000000000 x13: 0000000000000020 x12: 0101010101010101
[0.544549] x11: 7f7f7f7f7f7f7f7f x10: fefefeff3070765e x9 : ffff00008012de74
[0.545885] x8 : fefefefefefefeff x7 : 0000000000000278 x6 : ffff00008012de74
[0.547213] x5 : 7165725f6b6c6276 x4 : 0000000000001000 x3 : ffff000083c18080
[0.548554] x2 : 0000000000000000 x1 : 00000000fffef8b4 x0 : 0000000000000000
[0.549938] Call trace:
[0.550406]  mod_timer+0x2d8/0x340
[0.551070]  0xffff800001271e0c
[0.551672]  process_one_work+0x1f4/0x520
[0.552406]  worker_thread+0x58/0x450
[0.553071]  kthread+0x198/0x1c0
[0.553685]  ret_from_fork+0x10/0x20

JIRA ESLC-7516

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: I9160c0bc0907880cb128e4245383adf3a4ddb021
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2931256
Tested-by: Advaya Andhare <aandhare@nvidia.com>
Reviewed-by: Kasinadha Dendukuri <kdendukuri@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-07-07 06:57:31 -07:00
Manish Bhardwaj
ef4d81b7d7 storage: fix cert-c issue in storage driver
Using this patch we are fixing below cert error:-
1. cert_exp33_c_violation: Using uninitialized value
   ioctl_req->status when calling vblk_complete_mmc_multi_ioc.

CID 646845

Bug 3512545

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: I7127dbbc3259a8f42dac5003a56e0aa932053f81
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2930565
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-07-05 14:56:29 -07:00
Manish Bhardwaj
eab559cc9d nvidia: Optimize the request slots for queueing
instead of having fixed memory slots of size 512KB
in mempool we are going to create memory slots at
runtime based on size of the request to be processed.

Bug 3777610

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: Ib9b36798109c4a0a79765278a3b6a59a8c362756
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2906754
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-07-03 06:15:10 -07:00
Manish Bhardwaj
37af2918e5 nvidia: vblk: add timer support
Using this patch we are adding timer support for each
request going to storage server with timeout value
of 30 secs just to track request hungs on storage
server.

JIRA ESLC-7429

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: Ief13c0ad0308d548cea34bada047da1714b19e08
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2900572
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-06-24 07:26:21 -07:00
Manish Bhardwaj
312d19b2ff nvidia-oot: align ioctl buffer to 512 byte
Using this patch we are aligning ioctl
buffer to 512 byte address passed to
storage server

Bug 4054343

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: I1384e47411e3e07e27615c434363c37e18060104
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2920267
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-06-14 22:57:13 -07:00
Sanjith T D
19cd2b3ccc vblk: Handle SCSI IOCTL case where mx_sb_len is 0
Storage server expectes the mx_sb_len to be
set to non-zero value in order to pass on the
sense information assosiated with the SCSI
command to the user.

Some of the open source implementations(Ex:f2fs)
that use SG_IO SCSI IOCTL interface set the
mx_sb_len to 0. Handle this case in the vblk
client driver.

Bug 4060482

Change-Id: Ib3779f9cd4beb2822add95d4773909b7d3e7217a
Signed-off-by: Sanjith T D <std@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2894395
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Vipin Kumar <vipink@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-26 20:21:19 -07:00
Manish Bhardwaj
b53f6a8262 nvidia: support PM ops in oops driver
Using this patch we are making changes for
suspend operation to happen as late as possible
and resume operation to happen as early as possible.

Bug 3585622

Change-Id: I941a66c2d4d8a7e9a35d13659f6c1a17422f7e55
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2888613
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: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-21 11:38:22 -07:00
Manish Bhardwaj
1d627f6a49 nvidia: add PM ops support in oops driver
Using this patch we are adding PM ops support in oops
driver so that we can store the crash logs after
SC7 cycle also.

Bug 3585622

Change-Id: Id82252ac869cc8d3b7e09e2faec8289ab4f3859f
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2886489
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 08:19:24 -07:00
Jon Hunter
06b833d570 block: virt-storage: tegra: Fix build for Linux v5.14
For Linux v5.14, the function device_add_disk() has a void return type
and compilation now fails with ...

 nvidia-oot/drivers/block/tegra_virt_storage/tegra_hv_vblk.c:1162:8:
 error: invalid use of void expression
  1162 |  (void)!device_add_disk(vblkdev->device, vblkdev->gd, NULL);
       |        ^

Fix the build for kernels prior to v5.15 by not attempting to  access
the return value. Finally, for kernels v5.15 and newer, do not ignore
the return value and report an error if device_add_disk() fails.

Bug 4052299

Change-Id: I975f30bc67661eacf74634b5edb70e5ad5fc1a8d
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2881453
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-05 06:05:05 -07:00
Laxman Dewangan
035a437f79 block: virt-storage: tegra: Fix compilation warning
Fix below compilation warning:
- Indentation warning just after if
- return value not used from function.

Bug 4052299

Change-Id: I90fc00d41304ba34bf62fef6e2024999abc4a340
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2880032
Reviewed-by: Manish Bhardwaj <mbhardwaj@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-01 10:54:57 -07:00
Sanjith T D
3ca382c8bf vblk: Update sanity check for erase/discard
Check if the req_bytes > mempool_len only if
IOVA is enabled and the operations are not
DISCARD and SECURE_ERASE. Mempool is not used
for DISCARD and SECURE_ERASE operations.

Bug 3854703
Bug 3994714

Change-Id: I42250f7b2d36a83a4fa169ee8e4c1652be22b006
Signed-off-by: Sanjith T D <std@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2803275
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Vipin Kumar <vipink@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2877386
Tested-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
2023-03-27 09:48:01 -07:00
Manish Bhardwaj
a0c0b2f212 nvidia-oot: fix crash issue in vblk driver
Using this patch we are fixing kernel crash
issue which is observed when we are unbinding
the UFS driver, and we are trying to unreserved
the mempool which was never reserved.

Bug 3960718

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: Ib684cc99b9e61aa945ef406af0889aebe57e1a75
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2860634
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sanjith T D <std@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-02-21 03:42:31 -08:00
Manish Bhardwaj
aa5d06bcd3 nvidia-oot: fix Coverity defects
Using this patch we are fixing coverity defects in
CAN and storage OOPS driver.

CID 10132028: Unchecked return value (CHECKED_RETURN)
CID 10166522: Uninitialized scalar variable (UNINIT)
CID 10166537: Uninitialized scalar variable (UNINIT)
CID 10166580: Uninitialized scalar variable (UNINIT)

Bug 3952896

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: I3caf0a9121a4480567ce32c6777b547901f24815
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2860630
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-02-21 03:42:27 -08:00
Manish Bhardwaj
a51a3b4d6f nvidia-oot: protect IVC APIs using mutex
While accessing IVC framework APIs is causing concurrency
issue leading to system crash. so protecting the APIs
using mutex.
Also removing the req_lock mutex which is being used
unnecessarily since the shared resources are already protected
by ivc_lock mutex.

Bug 3937188

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: Ie49161b7f2659f9c44352d50f950d8f5a3cae32c
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2856249
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-02-15 04:26:47 -08:00
Manish Bhardwaj
db2721e896 vblk: increase vblkdev max minor count
currently the max number of minors for a vblock device is 16
With the current configuration this is exceeding and causes errors
during boot. update the max count to 32

Bug 3899893
JIRA ESLC-7100

Change-Id: I07cf631e95af673ad08d0ecf7186ce9cb0114a1b
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2849763
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-02-02 16:38:17 -08:00
Manish Bhardwaj
01a13440b4 nvidia-oot: port virtual oops storage driver
Using this patch we are porting virtual oops storage driver
to OOT kernel.

JIRA ESLC-7217
Bug 3961155

Change-Id: I60ba159b3a4662cf02d686a1916a110c5158901e
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2849807
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
2023-02-02 16:37:45 -08:00
Manish Bhardwaj
4d73511481 nvidia: support HSI error injection
Using this patch we are adding HSI error
injection support for SDMMC controller.

JIRA ESLC-7042
Bug 3413214

Change-Id: Ib1300bd133eb48c30439337c8205365dfd30395d
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2849755
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-02-02 16:37:38 -08:00
Sanjith T D
8efaee4e42 nvidia:vblk: Fix "Using uninitialized value"
Initialze max_ioctl_requests to 0 to fix
"Using uninitialized value" coverity violation.
max_ioctl_requests variable will not be used if IOCTL
operations are not supported on that virtual partition.
So, initializing it to 0 will not have any impact.

CID 10165591
Bug 3952896

Change-Id: Icb50d8af08d6da854bba358722439d5c2ef2a028
Signed-off-by: Sanjith T D <std@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2849581
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: Vipin Kumar <vipink@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-01-30 22:26:51 -08:00
Suresh Venkatachalam
11b4ca8baa nvidia: handle ioctl call gracefully
Using this patch we are gracefully handling
the scenario when ioctl(pass through) is
generated for UFS storage partition where pass
through commands are not supported

Bug 3870621
Bug 3941252

Change-Id: I22937c630a354178113acba68949465eeda81d03
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Signed-off-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2845464
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Sanjith T D <std@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-01-19 07:55:17 -08:00
Suresh Venkatachalam
eec9650f58 nvidia: remove mempool support for UFS devices
Using this patch we are removing the support of
mempool for UFS devices for which pass through
commands are not supported.

Bug 3870621
Bug 3941252

Change-Id: Ifd1be5c4ebeb6f670f0b29f6f19e5ce458446ee7
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Signed-off-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2845274
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Sanjith T D <std@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
2023-01-19 07:54:34 -08:00
Suresh Venkatachalam
04ba246081 vblk: Remove restricting slots based on mempool
The number of slots that is available for queuing
requests is calculated based on mempool size.
For UFS, with IOVA feature enabled, this calculation
is not needed.
Updated code to not restrict slots based on mempool
if IOVA is enabled.

Bug 3941252

Change-Id: I5a2e6c3f6e4fd568fcff47fef7462659ee6db555
Signed-off-by: Sanjith T D <std@nvidia.com>
Signed-off-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2845252
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-01-19 07:54:30 -08:00
Jon Hunter
7125981c99 nvidia-oot: vblk: Fix build errors for various Linux versions
Building the Tegra VBLK driver fails on various Linux v5.x versions due
to mismatches in arguments. Reviewing the Linux history the arguments to
the following functions changed in the following Linux versions ...

1. Linux v5.15
- The function __alloc_disk_node() is updated to pass an additional
  argument of type 'struct request_queue'.

2. Linux v5.16
- The functions blk_get_request() and blk_put_request() are replaced by
  blk_mq_alloc_request() and blk_mq_free_request(), respectively.

3. Linux v5.17
- Removes the argument of type 'struct gendisk' from the function
  blk_execute_rq().

4. Linux v5.18
- Removes the header 'linux/genhd.h'.

5. Linux v6.0
- Replaces the function __alloc_disk_node() with
  blk_mq_alloc_disk_for_queue().

Update the Tegra VBLK driver to ensure that the correct functions and
header files are used per the exact Linux version.

Bug 3820317

Change-Id: Ia04ea78d1edcf7674030379159599949f13f3120
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2791669
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-10-20 02:19:53 -07:00
Manish Bhardwaj
eda5ce0144 nvidia-oot: changes to fix compilation error
Using this patch we are fixing below compilaiton error
with stable kernel.
1. nvidia-oot/drivers/block/tegra_virt_storage/tegra_hv_vblk.c:936:16:
   error: implicit declaration of function ___alloc_disk_node_;
   vblkdev->gd = __alloc_disk_node(vblkdev->queue, NUMA_NO_NODE, NULL);
      |              ^
2. nvidia-oot/drivers/block/tegra_virt_storage/tegra_hv_vblk.c:1176:3:
   error: implicit declaration of function _blk_cleanup_queue_
   [-Werror=implicit-function-declaration]
   1176 |   blk_cleanup_queue(vblkdev->queue);
      |   ^~~~~~~~~~~~~~~~~

Bug 3767126

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: Id0df2c15c42d4dcbae95f1ef33517d096bf96d06
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2787165
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-10-05 20:14:55 -07:00
Manish Bhardwaj
f7b80313df nvidia: vblk: fix compilation error
in linux below patches remove the support for QUEUE_FLAG_DISCARD
and QUEUE_FLAG_SECERASE.
commit 70200574cc229f6ba038259e8142af2aa09e6976
Author: Christoph Hellwig <hch@lst.de>
Date:   Fri Apr 15 06:52:55 2022 +0200

    block: remove QUEUE_FLAG_DISCARD

    Just use a non-zero max_discard_sectors as an indicator for discard
    support, similar to what is done for write zeroes.

    The only places where needs special attention is the RAID5 driver,
    which must clear discard support for security reasons by default,
    even if the default stacking rules would allow for it.

commit 44abff2c0b970ae3d310b97617525dc01f248d7c
Author: Christoph Hellwig <hch@lst.de>
Date:   Fri Apr 15 06:52:57 2022 +0200

    block: decouple REQ_OP_SECURE_ERASE from REQ_OP_DISCARD

    Secure erase is a very different operation from discard in that it is
    a data integrity operation vs hint.  Fully split the limits and helper
    infrastructure to make the separation more clear.

we are fixing below compilation error using this patch.
nvidia-oot/drivers/block/tegra_virt_storage/tegra_hv_vblk.c:921:22:
error: ‘QUEUE_FLAG_DISCARD’ undeclared (first use in this function);
did you mean ‘QUEUE_FLAG_DEAD’?
  921 |   blk_queue_flag_set(QUEUE_FLAG_DISCARD, vblkdev->queue);
      |                      ^~~~~~~~~~~~~~~~~~
      |                      QUEUE_FLAG_DEAD
nvidia-oot/drivers/block/tegra_virt_storage/tegra_hv_vblk.c:921:22:
note: each undeclared identifier is reported only once for each function
it appears in nvidia-oot/drivers/block/tegra_virt_storage/tegra_hv_vblk.c:928:23:
error: ‘QUEUE_FLAG_SECERASE’ undeclared (first use in this function);
did you mean ‘QUEUE_FLAG_NOMERGES’?
  928 |    blk_queue_flag_set(QUEUE_FLAG_SECERASE, vblkdev->queue);

Bug 3733730

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: I47ad13be833fdd7ec7f0d2127699e28311fbeb83
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2784741
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-10-04 05:19:21 -07:00
Manish Bhardwaj
272be41c99 nvidia: vblk: fix compilation error
in Linux v5.18 the following upstream commit removes
genhd.h and now only blkdev.h is needed.
commit 322cbb50de711814c42fb088f6d31901502c711a
Author: Christoph Hellwig <hch@lst.de>
Date:   Mon Jan 24 10:39:13 2022 +0100

    block: remove genhd.h

Using this change we are fixing below compilation
error while upgrading the stable kernel.
/dvs/git/dirty/git-master_linux/out/nvidia/kernel-nvidia-oot/
nvidia-oot/drivers/block/tegra_virt_storage/tegra_vblk.h:9:10:
fatal error: linux/genhd.h: No such file or directory
    9 | #include <linux/genhd.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.

Bug 3733730

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: Ib110b749ca48fed092fcadb9a6ab47d81cc25397
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2784497
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-10-04 05:19:17 -07:00
Laxman Dewangan
a6fd90fb31 ivc: Add wrapper header for ivc.h to avoid multiple inclusion
The ivc.h is not protected for multiple inclusion and so
it is generating error for multiple definition when included
from the source code.

Add wrapper header to protect the multiple inclusion of the ivc.h.

This will make the OOT driers to compile against all core kernel
which does not have proper ivc.h fix.

Change-Id: Ibe85da017d60f525b05d04cd6a5ea15c5b312057
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2784877
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-10-02 02:39:17 -07:00
Manish Bhardwaj
95d8293e6c nvidia-oot: port tegra vblk driver
Using this patch we are adding support for
tegra vblk driver in oot kernel.

JIRA ESLC-6885

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: I914bb3337019412593e05e75fa0569dd1c7398d1
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2781122
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-28 22:48:26 -07:00