Skip to content

Commit a5adb64

Browse files
authored
Merge pull request #63 from NVIDIA/2.26.6
GPUDirect Storage kernel driver (nvidia-fs) ver-2.26.6 commit
2 parents 70be4b0 + 617b693 commit a5adb64

File tree

12 files changed

+57
-37
lines changed

12 files changed

+57
-37
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
nvidia-fs (2.26.6) RELEASE; urgency=low
2+
* Fix issues for 6.11 kernel
3+
* Fix compilation issues for 6.14 kernel
4+
* Minor code cleanup
15
nvidia-fs (2.25.7) RELEASE; urgency=low
26
* fix configure script to export correct macro for access_ok
37

src/GDS_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.14.0.31
1+
1.15.0.42

src/configure

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ fi
149149

150150
cat > $TEST_C <<EOF
151151
152-
153152
#include <linux/uaccess.h>
154153
#include "test.h"
155154
@@ -534,6 +533,21 @@ if compile_prog "Checking if vma_flags are modifiable directly ..."; then
534533
output_sym "NVFS_VM_FLAGS_NOT_CONSTANT"
535534
fi
536535

536+
cat > $TEST_C <<EOF
537+
#include <linux/blk-mq-pci.h>
538+
#include "test.h"
539+
540+
int test (void)
541+
{
542+
return 0;
543+
}
544+
545+
EOF
546+
if compile_prog "Checking if blk-mq-pci.h is present..."; then
547+
output_sym "HAVE_BLK_MQ_PCI_H"
548+
fi
549+
550+
537551
echo "#endif" >> $config_host_h
538552
rm -rf build
539553

src/nvfs-batch.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,16 @@ long nvfs_io_batch_submit(nvfs_batch_io_t *nvfs_batch)
162162
nvfs_batch->start_io),
163163
&nvfs_batch_submit_latency_per_sec);
164164
kfree(nvfs_batch);
165-
return ret;;
165+
return ret;
166166

167167
cleanup:
168-
if (nvfs_batch) {
169-
for (i = 0; i < nvfs_batch->nents; i++) {
170-
if (nvfs_batch->nvfsio[i] && !IS_ERR(nvfs_batch->nvfsio[i]))
171-
nvfs_io_free(nvfs_batch->nvfsio[i], -EINVAL);
172-
}
173-
//XXX: wait for the ongoing ops, or cancel them.
174-
kfree(nvfs_batch);
175-
}
176-
return ret;;
168+
for (i = 0; i < nvfs_batch->nents; i++) {
169+
if (nvfs_batch->nvfsio[i] && !IS_ERR(nvfs_batch->nvfsio[i]))
170+
nvfs_io_free(nvfs_batch->nvfsio[i], -EINVAL);
171+
}
172+
//XXX: wait for the ongoing ops, or cancel them.
173+
kfree(nvfs_batch);
174+
return ret;
177175

178176
}
179177
#endif

src/nvfs-core.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,22 +1035,29 @@ nvfs_direct_io(int op, struct file *filp, char __user *buf,
10351035

10361036
iov_iter_init(&iter, op, &iov, 1, len);
10371037

1038-
//TODO: If the config is not present fallback to vfs_read/vfs_write
1039-
#ifdef HAVE_CALL_READ_WRITE_ITER
10401038
if(op == WRITE) {
10411039
set_write_flag(&nvfsio->common);
10421040
file_start_write(filp);
10431041

1042+
#ifdef HAVE_CALL_READ_WRITE_ITER
10441043
ret = nvfs_io_ret(&nvfsio->common,
10451044
call_write_iter(filp, &nvfsio->common, &iter));
1045+
#else
1046+
ret = nvfs_io_ret(&nvfsio->common,
1047+
filp->f_op->write_iter(&nvfsio->common, &iter));
1048+
#endif
10461049
if (S_ISREG(file_inode(filp)->i_mode))
10471050
__sb_writers_release(file_inode(filp)->i_sb,
10481051
SB_FREEZE_WRITE);
10491052
} else {
1053+
#ifdef HAVE_CALL_READ_WRITE_ITER
10501054
ret = nvfs_io_ret(&nvfsio->common,
10511055
call_read_iter(filp, &nvfsio->common, &iter));
1052-
}
1056+
#else
1057+
ret = nvfs_io_ret(&nvfsio->common,
1058+
filp->f_op->read_iter(&nvfsio->common, &iter));
10531059
#endif
1060+
}
10541061

10551062
nvfs_dbg("nvfs_direct_io : ret = %ld len = %lu\n" , ret, len);
10561063
if (ret == -EIOCBQUEUED) {
@@ -1273,7 +1280,7 @@ static int nvfs_pin_gpu_pages(nvfs_ioctl_map_t *input_param,
12731280
}
12741281

12751282
if(gpu_buf_len < GPU_PAGE_SIZE &&
1276-
(input_param->sbuf_block * NVFS_BLOCK_SIZE) <
1283+
(input_param->sbuf_block * (unsigned long long)NVFS_BLOCK_SIZE) <
12771284
(gpuvaddr - gpu_virt_start + gpu_buf_len))
12781285
{
12791286
nvfs_err("invalid shadow buf size provided %u, gpu_buf_len: %lld, gpuvaddr: %llx \n",
@@ -1504,7 +1511,7 @@ static int nvfs_map(nvfs_ioctl_map_t *input_param)
15041511
nvfs_get_ops();
15051512

15061513
nvfs_mgroup = nvfs_mgroup_pin_shadow_pages(input_param->cpuvaddr,
1507-
input_param->sbuf_block * NVFS_BLOCK_SIZE);
1514+
input_param->sbuf_block * (unsigned long long)NVFS_BLOCK_SIZE);
15081515
if (!nvfs_mgroup) {
15091516
nvfs_err("%s:%d Error nvfs_setup_shadow_buffer\n",
15101517
__func__, __LINE__);
@@ -2462,7 +2469,7 @@ static int get_nvidia_driver_version(void){
24622469
char buf[NVIDIA_DRIVER_BUF_SIZE];
24632470
loff_t pos = 0;
24642471
ssize_t bytes_read;
2465-
int value;
2472+
int value = -1;
24662473

24672474
file = filp_open(NVIDIA_DRIVER_PATH, O_RDONLY, 0);
24682475
if (IS_ERR(file)) {

src/nvfs-dma.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ static int nvfs_dma_map_sg_attrs_internal(struct device *device,
591591
}
592592
// We do not handle dma mapping for CPU pages
593593
nr_cpu_dma++;
594-
continue;
595594
} else {
596595
// Cannot handle GPU/CPU pages
597596
if (unlikely(nr_cpu_dma)) {

src/nvfs-dma.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#include <linux/types.h>
2929
#include <linux/blkdev.h>
3030
#include <linux/blk-mq.h>
31+
#ifdef HAVE_BLK_MQ_PCI_H
3132
#include <linux/blk-mq-pci.h>
33+
#endif
3234
#include <linux/scatterlist.h>
3335
#include <linux/page-flags.h>
3436
#include <linux/dma-direction.h>

src/nvfs-kernel-interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
#include <linux/types.h>
2727
#include <linux/blkdev.h>
2828
#include <linux/blk-mq.h>
29+
#ifdef HAVE_BLK_MQ_PCI_H
2930
#include <linux/blk-mq-pci.h>
31+
#endif
3032
#include <linux/scatterlist.h>
3133
#include <linux/version.h>
3234

src/nvfs-mmap.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ static void nvfs_mgroup_free(nvfs_mgroup_ptr_t nvfs_mgroup, bool from_dma)
173173
nvfs_dbg("freeing base_index %lx(ref:%d) found \n",
174174
nvfs_mgroup->base_index, atomic_read(&nvfs_mgroup->ref));
175175
kfree(nvfs_mgroup);
176-
nvfs_mgroup = NULL;
177176
}
178177

179178

@@ -225,7 +224,7 @@ void nvfs_mgroup_put_dma(nvfs_mgroup_ptr_t nvfs_mgroup) {
225224

226225
static nvfs_mgroup_ptr_t nvfs_get_mgroup_from_vaddr_internal(u64 cpuvaddr)
227226
{
228-
struct page *page;
227+
struct page *page = NULL;
229228
int ret;
230229
unsigned long cur_base_index = 0;
231230
nvfs_mgroup_ptr_t nvfs_mgroup = NULL;
@@ -371,12 +370,12 @@ nvfs_mgroup_ptr_t nvfs_mgroup_pin_shadow_pages(u64 cpuvaddr, unsigned long lengt
371370
count = DIV_ROUND_UP(length, PAGE_SIZE);
372371
block_count = DIV_ROUND_UP(length, NVFS_BLOCK_SIZE);
373372
pages = (struct page **) kmalloc(count * sizeof(struct page *), GFP_KERNEL);
374-
375373
if (!pages) {
376374
nvfs_err("%s:%d shadow buffer pages allocation failed\n",
377375
__func__, __LINE__);
378376
goto out;
379377
}
378+
memset(pages, 0, count * sizeof(struct page *));
380379

381380
#ifdef CONFIG_FAULT_INJECTION
382381
if (nvfs_fault_trigger(&nvfs_pin_shadow_pages_error)) {
@@ -625,7 +624,7 @@ static int nvfs_mgroup_mmap_internal(struct file *filp, struct vm_area_struct *v
625624
nvfs_mgroup_ptr_t nvfs_mgroup, nvfs_new_mgroup;
626625
struct nvfs_gpu_args *gpu_info;
627626
int os_pages_count;
628-
vm_flags_t vm_flags;
627+
vm_flags_t vm_flags, vm_flags_to_set;
629628

630629
nvfs_stat64(&nvfs_n_mmap);
631630
/* check length - do not allow larger mappings than the number of
@@ -668,11 +667,13 @@ static int nvfs_mgroup_mmap_internal(struct file *filp, struct vm_area_struct *v
668667
goto error;
669668
}
670669

670+
671+
vm_flags_to_set = VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_DONTCOPY;
671672
/* dont allow mremap to expand and dont allow copy on fork */
672673
#ifdef NVFS_VM_FLAGS_NOT_CONSTANT
673-
vma->vm_flags |= VM_IO | VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_DONTCOPY;
674+
vma->vm_flags |= vm_flags_to_set;
674675
#else
675-
vm_flags_set(vma, VM_IO | VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_DONTCOPY);
676+
vm_flags_set(vma, vm_flags_to_set);
676677
#endif
677678
vma->vm_ops = &nvfs_mmap_ops;
678679
nvfs_new_mgroup = (nvfs_mgroup_ptr_t)kzalloc(sizeof(struct nvfs_io_mgroup), GFP_KERNEL);
@@ -697,7 +698,6 @@ static int nvfs_mgroup_mmap_internal(struct file *filp, struct vm_area_struct *v
697698
nvfs_mgroup = nvfs_mgroup_get_unlocked(base_index);
698699
if (unlikely(nvfs_mgroup && tries--)) {
699700
nvfs_mgroup_put(nvfs_mgroup);
700-
continue;
701701
} else {
702702
nvfs_new_mgroup->base_index = base_index;
703703
atomic_set(&nvfs_new_mgroup->ref,1);
@@ -744,7 +744,6 @@ static int nvfs_mgroup_mmap_internal(struct file *filp, struct vm_area_struct *v
744744
BUG_ON(vma->vm_private_data != NULL);
745745
}
746746

747-
j = 0;
748747
for (i = 0; i < nvfs_blocks_count; i++) {
749748
j = i / nvfs_block_count_per_page;
750749
if (nvfs_mgroup->nvfs_ppages[j] == NULL) {
@@ -1051,7 +1050,7 @@ int nvfs_mgroup_fill_mpages(nvfs_mgroup_ptr_t nvfs_mgroup, unsigned nr_blocks)
10511050
nvfs_mgroup_fill_mpage(nvfs_mgroup->nvfs_ppages[j/nvfs_block_count_per_page],
10521051
&nvfs_mgroup->nvfs_metadata[j], nvfsio);
10531052
}
1054-
nvfsio->nvfs_active_blocks_end = j-1;
1053+
nvfsio->nvfs_active_blocks_end = (j > 0 ? j-1 : 0);
10551054

10561055
// clear the state for unqueued pages
10571056
for (; j < nvfs_mgroup->nvfs_blocks_count ; j++) {

src/nvfs-mod.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ void cleanup_module_list(void) {
135135
#ifdef HAVE_MODULE_MUTEX
136136
mutex_unlock(&module_mutex);
137137
#endif
138-
139-
// initialized at compile time
140-
if (!mod_entry->is_mod)
141-
continue;
142-
143138
}
144139
}
145140
}

0 commit comments

Comments
 (0)