lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 7 Feb 2020 05:04:13 +0800
From:   kbuild test robot <lkp@...el.com>
To:     Christoph Hellwig <hch@....de>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Anup Patel <anup@...infault.org>
Subject: drivers//staging/comedi/comedi_fops.c:2380:8: error: 'PAGE_SHARED'
 undeclared; did you mean 'PAGE_SIZE'?

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   90568ecf561540fa330511e21fcd823b0c3829c6
commit: 6bd33e1ece528f67646db33bf97406b747dafda0 riscv: add nommu support
date:   3 months ago
config: riscv-randconfig-a001-20200207 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 6bd33e1ece528f67646db33bf97406b747dafda0
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=riscv 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@...el.com>

All error/warnings (new ones prefixed by >>):

   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
   include/linux/scatterlist.h:145:18: note: in expansion of macro 'virt_to_page'
     sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
                     ^~~~~~~~~~~~
   In file included from arch/riscv/include/asm/page.h:12:0,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/mm.h:10,
                    from include/linux/pagemap.h:8,
                    from fs//cifs/smb2ops.c:8:
   include/linux/scatterlist.h: In function 'sg_phys':
   include/asm-generic/memory_model.h:55:54: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
                                                         ^
   include/linux/pfn.h:21:36: note: in definition of macro 'PFN_PHYS'
    #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
                                       ^
   arch/riscv/include/asm/page.h:115:29: note: in expansion of macro 'pfn_to_phys'
    #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
                                ^~~~~~~~~~~
   include/asm-generic/memory_model.h:81:21: note: in expansion of macro '__page_to_pfn'
    #define page_to_pfn __page_to_pfn
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:115:41: note: in expansion of macro 'page_to_pfn'
    #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
                                            ^~~~~~~~~~~
   include/linux/scatterlist.h:224:9: note: in expansion of macro 'page_to_phys'
     return page_to_phys(sg_page(sg)) + sg->offset;
            ^~~~~~~~~~~~
   In file included from arch/riscv/include/asm/page.h:131:0,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/mm.h:10,
                    from include/linux/pagemap.h:8,
                    from fs//cifs/smb2ops.c:8:
   include/linux/scatterlist.h: In function 'sg_page_iter_page':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   include/linux/mm.h:213:26: note: in expansion of macro 'pfn_to_page'
    #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
                             ^~~~~~~~~~~
   include/linux/scatterlist.h:384:9: note: in expansion of macro 'nth_page'
     return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
            ^~~~~~~~
   include/linux/dma-mapping.h: In function 'dma_map_single_attrs':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
   include/linux/dma-mapping.h:587:33: note: in expansion of macro 'virt_to_page'
     return dma_map_page_attrs(dev, virt_to_page(ptr), offset_in_page(ptr),
                                    ^~~~~~~~~~~~
   In file included from arch/riscv/include/asm/page.h:131:0,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/mm.h:10,
                    from include/linux/pagemap.h:8,
                    from fs//cifs/smb2ops.c:8:
   fs//cifs/smb2ops.c: In function 'smb2_sg_set_buf':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
>> fs//cifs/smb2ops.c:3542:10: note: in expansion of macro 'virt_to_page'
      addr = virt_to_page(buf);
             ^~~~~~~~~~~~
   In file included from include/linux/pagemap.h:8:0,
                    from fs//cifs/smb2ops.c:8:
   include/linux/mm.h: In function 'lowmem_page_address':
   include/linux/mm.h:1322:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
--
                    from include/linux/module.h:10,
                    from drivers//staging/comedi/comedi_fops.c:14:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
   include/linux/scatterlist.h:145:18: note: in expansion of macro 'virt_to_page'
     sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
                     ^~~~~~~~~~~~
   In file included from arch/riscv/include/asm/page.h:12:0,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:10,
                    from drivers//staging/comedi/comedi_fops.c:14:
   include/linux/scatterlist.h: In function 'sg_phys':
   include/asm-generic/memory_model.h:55:54: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
                                                         ^
   include/linux/pfn.h:21:36: note: in definition of macro 'PFN_PHYS'
    #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
                                       ^
   arch/riscv/include/asm/page.h:115:29: note: in expansion of macro 'pfn_to_phys'
    #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
                                ^~~~~~~~~~~
   include/asm-generic/memory_model.h:81:21: note: in expansion of macro '__page_to_pfn'
    #define page_to_pfn __page_to_pfn
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:115:41: note: in expansion of macro 'page_to_pfn'
    #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
                                            ^~~~~~~~~~~
   include/linux/scatterlist.h:224:9: note: in expansion of macro 'page_to_phys'
     return page_to_phys(sg_page(sg)) + sg->offset;
            ^~~~~~~~~~~~
   In file included from arch/riscv/include/asm/page.h:131:0,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:10,
                    from drivers//staging/comedi/comedi_fops.c:14:
   include/linux/scatterlist.h: In function 'sg_page_iter_page':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   include/linux/mm.h:213:26: note: in expansion of macro 'pfn_to_page'
    #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
                             ^~~~~~~~~~~
   include/linux/scatterlist.h:384:9: note: in expansion of macro 'nth_page'
     return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
            ^~~~~~~~
   include/linux/dma-mapping.h: In function 'dma_map_single_attrs':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
   include/linux/dma-mapping.h:587:33: note: in expansion of macro 'virt_to_page'
     return dma_map_page_attrs(dev, virt_to_page(ptr), offset_in_page(ptr),
                                    ^~~~~~~~~~~~
   drivers//staging/comedi/comedi_fops.c: In function 'comedi_mmap':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:55:46: note: in definition of macro '__page_to_pfn'
    #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
                                                 ^~~~
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
   drivers//staging/comedi/comedi_fops.c:2378:22: note: in expansion of macro 'virt_to_page'
       pfn = page_to_pfn(virt_to_page(buf->virt_addr));
                         ^~~~~~~~~~~~
>> drivers//staging/comedi/comedi_fops.c:2380:8: error: 'PAGE_SHARED' undeclared (first use in this function); did you mean 'PAGE_SIZE'?
           PAGE_SHARED);
           ^~~~~~~~~~~
           PAGE_SIZE
--
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
   include/linux/scatterlist.h:145:18: note: in expansion of macro 'virt_to_page'
     sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
                     ^~~~~~~~~~~~
   In file included from arch/riscv/include/asm/page.h:12:0,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/slab.h:15,
                    from net//sunrpc/xprtsock.c:24:
   include/linux/scatterlist.h: In function 'sg_phys':
   include/asm-generic/memory_model.h:55:54: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
                                                         ^
   include/linux/pfn.h:21:36: note: in definition of macro 'PFN_PHYS'
    #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
                                       ^
   arch/riscv/include/asm/page.h:115:29: note: in expansion of macro 'pfn_to_phys'
    #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
                                ^~~~~~~~~~~
   include/asm-generic/memory_model.h:81:21: note: in expansion of macro '__page_to_pfn'
    #define page_to_pfn __page_to_pfn
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:115:41: note: in expansion of macro 'page_to_pfn'
    #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
                                            ^~~~~~~~~~~
   include/linux/scatterlist.h:224:9: note: in expansion of macro 'page_to_phys'
     return page_to_phys(sg_page(sg)) + sg->offset;
            ^~~~~~~~~~~~
   In file included from arch/riscv/include/asm/page.h:131:0,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/slab.h:15,
                    from net//sunrpc/xprtsock.c:24:
   include/linux/scatterlist.h: In function 'sg_page_iter_page':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   include/linux/mm.h:213:26: note: in expansion of macro 'pfn_to_page'
    #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
                             ^~~~~~~~~~~
   include/linux/scatterlist.h:384:9: note: in expansion of macro 'nth_page'
     return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
            ^~~~~~~~
   include/linux/dma-mapping.h: In function 'dma_map_single_attrs':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
   include/linux/dma-mapping.h:587:33: note: in expansion of macro 'virt_to_page'
     return dma_map_page_attrs(dev, virt_to_page(ptr), offset_in_page(ptr),
                                    ^~~~~~~~~~~~
   In file included from arch/riscv/include/asm/page.h:131:0,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/slab.h:15,
                    from net//sunrpc/xprtsock.c:24:
   net//sunrpc/xprtsock.c: In function 'bc_sendto':
   include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
    #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                ^
   include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
    #define pfn_to_page __pfn_to_page
                        ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
    #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
                                 ^~~~~~~~~~~
>> net//sunrpc/xprtsock.c:2668:14: note: in expansion of macro 'virt_to_page'
      tailpage = virt_to_page(xbufp->tail[0].iov_base);
                 ^~~~~~~~~~~~
   In file included from include/linux/pagemap.h:8:0,
                    from net//sunrpc/xprtsock.c:27:
   include/linux/mm.h: In function 'lowmem_page_address':
   include/linux/mm.h:1322:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
..

vim +2380 drivers//staging/comedi/comedi_fops.c

ed9eccbe8970f6 David Schleef      2008-11-04  2296  
ed9eccbe8970f6 David Schleef      2008-11-04  2297  static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
ed9eccbe8970f6 David Schleef      2008-11-04  2298  {
20f083c07565cb Ian Abbott         2014-11-04  2299  	struct comedi_file *cfp = file->private_data;
20f083c07565cb Ian Abbott         2014-11-04  2300  	struct comedi_device *dev = cfp->dev;
a52840a98bbb50 H Hartley Sweeten  2012-12-19  2301  	struct comedi_subdevice *s;
a52840a98bbb50 H Hartley Sweeten  2012-12-19  2302  	struct comedi_async *async;
b34aa86f12e884 Ian Abbott         2014-04-10  2303  	struct comedi_buf_map *bm = NULL;
e36472145aa706 Ian Abbott         2019-06-25  2304  	struct comedi_buf_page *buf;
ed9eccbe8970f6 David Schleef      2008-11-04  2305  	unsigned long start = vma->vm_start;
ed9eccbe8970f6 David Schleef      2008-11-04  2306  	unsigned long size;
ed9eccbe8970f6 David Schleef      2008-11-04  2307  	int n_pages;
ed9eccbe8970f6 David Schleef      2008-11-04  2308  	int i;
e36472145aa706 Ian Abbott         2019-06-25  2309  	int retval = 0;
3ffab428f40849 Bernd Porr         2011-11-08  2310  
b34aa86f12e884 Ian Abbott         2014-04-10  2311  	/*
b34aa86f12e884 Ian Abbott         2014-04-10  2312  	 * 'trylock' avoids circular dependency with current->mm->mmap_sem
b34aa86f12e884 Ian Abbott         2014-04-10  2313  	 * and down-reading &dev->attach_lock should normally succeed without
b34aa86f12e884 Ian Abbott         2014-04-10  2314  	 * contention unless the device is in the process of being attached
b34aa86f12e884 Ian Abbott         2014-04-10  2315  	 * or detached.
b34aa86f12e884 Ian Abbott         2014-04-10  2316  	 */
b34aa86f12e884 Ian Abbott         2014-04-10  2317  	if (!down_read_trylock(&dev->attach_lock))
b34aa86f12e884 Ian Abbott         2014-04-10  2318  		return -EAGAIN;
a52840a98bbb50 H Hartley Sweeten  2012-12-19  2319  
ed9eccbe8970f6 David Schleef      2008-11-04  2320  	if (!dev->attached) {
272850f07c47ab H Hartley Sweeten  2013-11-26  2321  		dev_dbg(dev->class_dev, "no driver attached\n");
ed9eccbe8970f6 David Schleef      2008-11-04  2322  		retval = -ENODEV;
ed9eccbe8970f6 David Schleef      2008-11-04  2323  		goto done;
ed9eccbe8970f6 David Schleef      2008-11-04  2324  	}
a52840a98bbb50 H Hartley Sweeten  2012-12-19  2325  
476b847733636c Greg Kroah-Hartman 2008-11-13  2326  	if (vma->vm_flags & VM_WRITE)
20f083c07565cb Ian Abbott         2014-11-04  2327  		s = comedi_file_write_subdevice(file);
476b847733636c Greg Kroah-Hartman 2008-11-13  2328  	else
20f083c07565cb Ian Abbott         2014-11-04  2329  		s = comedi_file_read_subdevice(file);
a52840a98bbb50 H Hartley Sweeten  2012-12-19  2330  	if (!s) {
ed9eccbe8970f6 David Schleef      2008-11-04  2331  		retval = -EINVAL;
ed9eccbe8970f6 David Schleef      2008-11-04  2332  		goto done;
ed9eccbe8970f6 David Schleef      2008-11-04  2333  	}
a52840a98bbb50 H Hartley Sweeten  2012-12-19  2334  
ed9eccbe8970f6 David Schleef      2008-11-04  2335  	async = s->async;
a52840a98bbb50 H Hartley Sweeten  2012-12-19  2336  	if (!async) {
ed9eccbe8970f6 David Schleef      2008-11-04  2337  		retval = -EINVAL;
ed9eccbe8970f6 David Schleef      2008-11-04  2338  		goto done;
ed9eccbe8970f6 David Schleef      2008-11-04  2339  	}
ed9eccbe8970f6 David Schleef      2008-11-04  2340  
ed9eccbe8970f6 David Schleef      2008-11-04  2341  	if (vma->vm_pgoff != 0) {
272850f07c47ab H Hartley Sweeten  2013-11-26  2342  		dev_dbg(dev->class_dev, "mmap() offset must be 0.\n");
ed9eccbe8970f6 David Schleef      2008-11-04  2343  		retval = -EINVAL;
ed9eccbe8970f6 David Schleef      2008-11-04  2344  		goto done;
ed9eccbe8970f6 David Schleef      2008-11-04  2345  	}
ed9eccbe8970f6 David Schleef      2008-11-04  2346  
ed9eccbe8970f6 David Schleef      2008-11-04  2347  	size = vma->vm_end - vma->vm_start;
ed9eccbe8970f6 David Schleef      2008-11-04  2348  	if (size > async->prealloc_bufsz) {
ed9eccbe8970f6 David Schleef      2008-11-04  2349  		retval = -EFAULT;
ed9eccbe8970f6 David Schleef      2008-11-04  2350  		goto done;
ed9eccbe8970f6 David Schleef      2008-11-04  2351  	}
44b8c793fc0d63 Sandhya Bankar     2016-03-06  2352  	if (offset_in_page(size)) {
ed9eccbe8970f6 David Schleef      2008-11-04  2353  		retval = -EFAULT;
ed9eccbe8970f6 David Schleef      2008-11-04  2354  		goto done;
ed9eccbe8970f6 David Schleef      2008-11-04  2355  	}
ed9eccbe8970f6 David Schleef      2008-11-04  2356  
ec9d0754e0c640 sayli karnik       2016-09-20  2357  	n_pages = vma_pages(vma);
b34aa86f12e884 Ian Abbott         2014-04-10  2358  
b34aa86f12e884 Ian Abbott         2014-04-10  2359  	/* get reference to current buf map (if any) */
b34aa86f12e884 Ian Abbott         2014-04-10  2360  	bm = comedi_buf_map_from_subdev_get(s);
af93da31634d6d Ian Abbott         2013-11-08  2361  	if (!bm || n_pages > bm->n_pages) {
af93da31634d6d Ian Abbott         2013-11-08  2362  		retval = -EINVAL;
af93da31634d6d Ian Abbott         2013-11-08  2363  		goto done;
af93da31634d6d Ian Abbott         2013-11-08  2364  	}
e36472145aa706 Ian Abbott         2019-06-25  2365  	if (bm->dma_dir != DMA_NONE) {
e36472145aa706 Ian Abbott         2019-06-25  2366  		/*
e36472145aa706 Ian Abbott         2019-06-25  2367  		 * DMA buffer was allocated as a single block.
e36472145aa706 Ian Abbott         2019-06-25  2368  		 * Address is in page_list[0].
e36472145aa706 Ian Abbott         2019-06-25  2369  		 */
e36472145aa706 Ian Abbott         2019-06-25  2370  		buf = &bm->page_list[0];
e36472145aa706 Ian Abbott         2019-06-25  2371  		retval = dma_mmap_coherent(bm->dma_hw_dev, vma, buf->virt_addr,
e36472145aa706 Ian Abbott         2019-06-25  2372  					   buf->dma_addr, n_pages * PAGE_SIZE);
e36472145aa706 Ian Abbott         2019-06-25  2373  	} else {
ed9eccbe8970f6 David Schleef      2008-11-04  2374  		for (i = 0; i < n_pages; ++i) {
e36472145aa706 Ian Abbott         2019-06-25  2375  			unsigned long pfn;
e36472145aa706 Ian Abbott         2019-06-25  2376  
e36472145aa706 Ian Abbott         2019-06-25  2377  			buf = &bm->page_list[i];
e36472145aa706 Ian Abbott         2019-06-25  2378  			pfn = page_to_pfn(virt_to_page(buf->virt_addr));
e36472145aa706 Ian Abbott         2019-06-25  2379  			retval = remap_pfn_range(vma, start, pfn, PAGE_SIZE,
e36472145aa706 Ian Abbott         2019-06-25 @2380  						 PAGE_SHARED);
e36472145aa706 Ian Abbott         2019-06-25  2381  			if (retval)
e36472145aa706 Ian Abbott         2019-06-25  2382  				break;
a52840a98bbb50 H Hartley Sweeten  2012-12-19  2383  
ed9eccbe8970f6 David Schleef      2008-11-04  2384  			start += PAGE_SIZE;
ed9eccbe8970f6 David Schleef      2008-11-04  2385  		}
e36472145aa706 Ian Abbott         2019-06-25  2386  	}
ed9eccbe8970f6 David Schleef      2008-11-04  2387  
e36472145aa706 Ian Abbott         2019-06-25  2388  	if (retval == 0) {
ed9eccbe8970f6 David Schleef      2008-11-04  2389  		vma->vm_ops = &comedi_vm_ops;
af93da31634d6d Ian Abbott         2013-11-08  2390  		vma->vm_private_data = bm;
ed9eccbe8970f6 David Schleef      2008-11-04  2391  
af93da31634d6d Ian Abbott         2013-11-08  2392  		vma->vm_ops->open(vma);
e36472145aa706 Ian Abbott         2019-06-25  2393  	}
ed9eccbe8970f6 David Schleef      2008-11-04  2394  
ed9eccbe8970f6 David Schleef      2008-11-04  2395  done:
b34aa86f12e884 Ian Abbott         2014-04-10  2396  	up_read(&dev->attach_lock);
b34aa86f12e884 Ian Abbott         2014-04-10  2397  	comedi_buf_map_put(bm);	/* put reference to buf map - okay if NULL */
ed9eccbe8970f6 David Schleef      2008-11-04  2398  	return retval;
ed9eccbe8970f6 David Schleef      2008-11-04  2399  }
ed9eccbe8970f6 David Schleef      2008-11-04  2400  

:::::: The code at line 2380 was first introduced by commit
:::::: e36472145aa706c186a6bb4f6419c613b0b1305c staging: comedi: use dma_mmap_coherent for DMA-able buffer mmap

:::::: TO: Ian Abbott <abbotti@....co.uk>
:::::: CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Download attachment ".config.gz" of type "application/gzip" (25907 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ