Commit e2e05394 authored by Ross Zwisler's avatar Ross Zwisler Committed by Dan Williams

pmem, dax: have direct_access use __pmem annotation

Update the annotation for the kaddr pointer returned by direct_access()
so that it is a __pmem pointer.  This is consistent with the PMEM driver
and with how this direct_access() pointer is used in the DAX code.
Signed-off-by: default avatarRoss Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 2765cfbb
...@@ -397,7 +397,8 @@ prototypes: ...@@ -397,7 +397,8 @@ prototypes:
int (*release) (struct gendisk *, fmode_t); int (*release) (struct gendisk *, fmode_t);
int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
int (*direct_access) (struct block_device *, sector_t, void **, unsigned long *); int (*direct_access) (struct block_device *, sector_t, void __pmem **,
unsigned long *);
int (*media_changed) (struct gendisk *); int (*media_changed) (struct gendisk *);
void (*unlock_native_capacity) (struct gendisk *); void (*unlock_native_capacity) (struct gendisk *);
int (*revalidate_disk) (struct gendisk *); int (*revalidate_disk) (struct gendisk *);
......
...@@ -141,13 +141,14 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio) ...@@ -141,13 +141,14 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio)
*/ */
static long static long
axon_ram_direct_access(struct block_device *device, sector_t sector, axon_ram_direct_access(struct block_device *device, sector_t sector,
void **kaddr, unsigned long *pfn, long size) void __pmem **kaddr, unsigned long *pfn, long size)
{ {
struct axon_ram_bank *bank = device->bd_disk->private_data; struct axon_ram_bank *bank = device->bd_disk->private_data;
loff_t offset = (loff_t)sector << AXON_RAM_SECTOR_SHIFT; loff_t offset = (loff_t)sector << AXON_RAM_SECTOR_SHIFT;
void *addr = (void *)(bank->ph_addr + offset);
*kaddr = (void *)(bank->ph_addr + offset); *kaddr = (void __pmem *)addr;
*pfn = virt_to_phys(*kaddr) >> PAGE_SHIFT; *pfn = virt_to_phys(addr) >> PAGE_SHIFT;
return bank->size - offset; return bank->size - offset;
} }
......
...@@ -371,7 +371,7 @@ static int brd_rw_page(struct block_device *bdev, sector_t sector, ...@@ -371,7 +371,7 @@ static int brd_rw_page(struct block_device *bdev, sector_t sector,
#ifdef CONFIG_BLK_DEV_RAM_DAX #ifdef CONFIG_BLK_DEV_RAM_DAX
static long brd_direct_access(struct block_device *bdev, sector_t sector, static long brd_direct_access(struct block_device *bdev, sector_t sector,
void **kaddr, unsigned long *pfn, long size) void __pmem **kaddr, unsigned long *pfn, long size)
{ {
struct brd_device *brd = bdev->bd_disk->private_data; struct brd_device *brd = bdev->bd_disk->private_data;
struct page *page; struct page *page;
...@@ -381,7 +381,7 @@ static long brd_direct_access(struct block_device *bdev, sector_t sector, ...@@ -381,7 +381,7 @@ static long brd_direct_access(struct block_device *bdev, sector_t sector,
page = brd_insert_page(brd, sector); page = brd_insert_page(brd, sector);
if (!page) if (!page)
return -ENOSPC; return -ENOSPC;
*kaddr = page_address(page); *kaddr = (void __pmem *)page_address(page);
*pfn = page_to_pfn(page); *pfn = page_to_pfn(page);
/* /*
......
...@@ -92,7 +92,7 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, ...@@ -92,7 +92,7 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector,
} }
static long pmem_direct_access(struct block_device *bdev, sector_t sector, static long pmem_direct_access(struct block_device *bdev, sector_t sector,
void **kaddr, unsigned long *pfn, long size) void __pmem **kaddr, unsigned long *pfn, long size)
{ {
struct pmem_device *pmem = bdev->bd_disk->private_data; struct pmem_device *pmem = bdev->bd_disk->private_data;
size_t offset = sector << 9; size_t offset = sector << 9;
...@@ -101,7 +101,7 @@ static long pmem_direct_access(struct block_device *bdev, sector_t sector, ...@@ -101,7 +101,7 @@ static long pmem_direct_access(struct block_device *bdev, sector_t sector,
return -ENODEV; return -ENODEV;
/* FIXME convert DAX to comprehend that this mapping has a lifetime */ /* FIXME convert DAX to comprehend that this mapping has a lifetime */
*kaddr = (void __force *) pmem->virt_addr + offset; *kaddr = pmem->virt_addr + offset;
*pfn = (pmem->phys_addr + offset) >> PAGE_SHIFT; *pfn = (pmem->phys_addr + offset) >> PAGE_SHIFT;
return pmem->size - offset; return pmem->size - offset;
......
...@@ -29,7 +29,7 @@ static int dcssblk_open(struct block_device *bdev, fmode_t mode); ...@@ -29,7 +29,7 @@ static int dcssblk_open(struct block_device *bdev, fmode_t mode);
static void dcssblk_release(struct gendisk *disk, fmode_t mode); static void dcssblk_release(struct gendisk *disk, fmode_t mode);
static void dcssblk_make_request(struct request_queue *q, struct bio *bio); static void dcssblk_make_request(struct request_queue *q, struct bio *bio);
static long dcssblk_direct_access(struct block_device *bdev, sector_t secnum, static long dcssblk_direct_access(struct block_device *bdev, sector_t secnum,
void **kaddr, unsigned long *pfn, long size); void __pmem **kaddr, unsigned long *pfn, long size);
static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0"; static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0";
...@@ -879,18 +879,20 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio) ...@@ -879,18 +879,20 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio)
static long static long
dcssblk_direct_access (struct block_device *bdev, sector_t secnum, dcssblk_direct_access (struct block_device *bdev, sector_t secnum,
void **kaddr, unsigned long *pfn, long size) void __pmem **kaddr, unsigned long *pfn, long size)
{ {
struct dcssblk_dev_info *dev_info; struct dcssblk_dev_info *dev_info;
unsigned long offset, dev_sz; unsigned long offset, dev_sz;
void *addr;
dev_info = bdev->bd_disk->private_data; dev_info = bdev->bd_disk->private_data;
if (!dev_info) if (!dev_info)
return -ENODEV; return -ENODEV;
dev_sz = dev_info->end - dev_info->start; dev_sz = dev_info->end - dev_info->start;
offset = secnum * 512; offset = secnum * 512;
*kaddr = (void *) (dev_info->start + offset); addr = (void *) (dev_info->start + offset);
*pfn = virt_to_phys(*kaddr) >> PAGE_SHIFT; *pfn = virt_to_phys(addr) >> PAGE_SHIFT;
*kaddr = (void __pmem *) addr;
return dev_sz - offset; return dev_sz - offset;
} }
......
...@@ -441,7 +441,7 @@ EXPORT_SYMBOL_GPL(bdev_write_page); ...@@ -441,7 +441,7 @@ EXPORT_SYMBOL_GPL(bdev_write_page);
* accessible at this address. * accessible at this address.
*/ */
long bdev_direct_access(struct block_device *bdev, sector_t sector, long bdev_direct_access(struct block_device *bdev, sector_t sector,
void **addr, unsigned long *pfn, long size) void __pmem **addr, unsigned long *pfn, long size)
{ {
long avail; long avail;
const struct block_device_operations *ops = bdev->bd_disk->fops; const struct block_device_operations *ops = bdev->bd_disk->fops;
......
...@@ -35,7 +35,7 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size) ...@@ -35,7 +35,7 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size)
might_sleep(); might_sleep();
do { do {
void *addr; void __pmem *addr;
unsigned long pfn; unsigned long pfn;
long count; long count;
...@@ -47,7 +47,7 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size) ...@@ -47,7 +47,7 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size)
unsigned pgsz = PAGE_SIZE - offset_in_page(addr); unsigned pgsz = PAGE_SIZE - offset_in_page(addr);
if (pgsz > count) if (pgsz > count)
pgsz = count; pgsz = count;
clear_pmem((void __pmem *)addr, pgsz); clear_pmem(addr, pgsz);
addr += pgsz; addr += pgsz;
size -= pgsz; size -= pgsz;
count -= pgsz; count -= pgsz;
...@@ -62,7 +62,8 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size) ...@@ -62,7 +62,8 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size)
} }
EXPORT_SYMBOL_GPL(dax_clear_blocks); EXPORT_SYMBOL_GPL(dax_clear_blocks);
static long dax_get_addr(struct buffer_head *bh, void **addr, unsigned blkbits) static long dax_get_addr(struct buffer_head *bh, void __pmem **addr,
unsigned blkbits)
{ {
unsigned long pfn; unsigned long pfn;
sector_t sector = bh->b_blocknr << (blkbits - 9); sector_t sector = bh->b_blocknr << (blkbits - 9);
...@@ -70,15 +71,15 @@ static long dax_get_addr(struct buffer_head *bh, void **addr, unsigned blkbits) ...@@ -70,15 +71,15 @@ static long dax_get_addr(struct buffer_head *bh, void **addr, unsigned blkbits)
} }
/* the clear_pmem() calls are ordered by a wmb_pmem() in the caller */ /* the clear_pmem() calls are ordered by a wmb_pmem() in the caller */
static void dax_new_buf(void *addr, unsigned size, unsigned first, loff_t pos, static void dax_new_buf(void __pmem *addr, unsigned size, unsigned first,
loff_t end) loff_t pos, loff_t end)
{ {
loff_t final = end - pos + first; /* The final byte of the buffer */ loff_t final = end - pos + first; /* The final byte of the buffer */
if (first > 0) if (first > 0)
clear_pmem((void __pmem *)addr, first); clear_pmem(addr, first);
if (final < size) if (final < size)
clear_pmem((void __pmem *)addr + final, size - final); clear_pmem(addr + final, size - final);
} }
static bool buffer_written(struct buffer_head *bh) static bool buffer_written(struct buffer_head *bh)
...@@ -106,7 +107,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, ...@@ -106,7 +107,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
loff_t pos = start; loff_t pos = start;
loff_t max = start; loff_t max = start;
loff_t bh_max = start; loff_t bh_max = start;
void *addr; void __pmem *addr;
bool hole = false; bool hole = false;
bool need_wmb = false; bool need_wmb = false;
...@@ -158,11 +159,11 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, ...@@ -158,11 +159,11 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
} }
if (iov_iter_rw(iter) == WRITE) { if (iov_iter_rw(iter) == WRITE) {
len = copy_from_iter_pmem((void __pmem *)addr, len = copy_from_iter_pmem(addr, max - pos, iter);
max - pos, iter);
need_wmb = true; need_wmb = true;
} else if (!hole) } else if (!hole)
len = copy_to_iter(addr, max - pos, iter); len = copy_to_iter((void __force *)addr, max - pos,
iter);
else else
len = iov_iter_zero(max - pos, iter); len = iov_iter_zero(max - pos, iter);
...@@ -268,11 +269,13 @@ static int dax_load_hole(struct address_space *mapping, struct page *page, ...@@ -268,11 +269,13 @@ static int dax_load_hole(struct address_space *mapping, struct page *page,
static int copy_user_bh(struct page *to, struct buffer_head *bh, static int copy_user_bh(struct page *to, struct buffer_head *bh,
unsigned blkbits, unsigned long vaddr) unsigned blkbits, unsigned long vaddr)
{ {
void *vfrom, *vto; void __pmem *vfrom;
void *vto;
if (dax_get_addr(bh, &vfrom, blkbits) < 0) if (dax_get_addr(bh, &vfrom, blkbits) < 0)
return -EIO; return -EIO;
vto = kmap_atomic(to); vto = kmap_atomic(to);
copy_user_page(vto, vfrom, vaddr, to); copy_user_page(vto, (void __force *)vfrom, vaddr, to);
kunmap_atomic(vto); kunmap_atomic(vto);
return 0; return 0;
} }
...@@ -283,7 +286,7 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, ...@@ -283,7 +286,7 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh,
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
sector_t sector = bh->b_blocknr << (inode->i_blkbits - 9); sector_t sector = bh->b_blocknr << (inode->i_blkbits - 9);
unsigned long vaddr = (unsigned long)vmf->virtual_address; unsigned long vaddr = (unsigned long)vmf->virtual_address;
void *addr; void __pmem *addr;
unsigned long pfn; unsigned long pfn;
pgoff_t size; pgoff_t size;
int error; int error;
...@@ -312,7 +315,7 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, ...@@ -312,7 +315,7 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh,
} }
if (buffer_unwritten(bh) || buffer_new(bh)) { if (buffer_unwritten(bh) || buffer_new(bh)) {
clear_pmem((void __pmem *)addr, PAGE_SIZE); clear_pmem(addr, PAGE_SIZE);
wmb_pmem(); wmb_pmem();
} }
...@@ -548,11 +551,11 @@ int dax_zero_page_range(struct inode *inode, loff_t from, unsigned length, ...@@ -548,11 +551,11 @@ int dax_zero_page_range(struct inode *inode, loff_t from, unsigned length,
if (err < 0) if (err < 0)
return err; return err;
if (buffer_written(&bh)) { if (buffer_written(&bh)) {
void *addr; void __pmem *addr;
err = dax_get_addr(&bh, &addr, inode->i_blkbits); err = dax_get_addr(&bh, &addr, inode->i_blkbits);
if (err < 0) if (err < 0)
return err; return err;
clear_pmem((void __pmem *)addr + offset, length); clear_pmem(addr + offset, length);
wmb_pmem(); wmb_pmem();
} }
......
...@@ -1555,8 +1555,8 @@ struct block_device_operations { ...@@ -1555,8 +1555,8 @@ struct block_device_operations {
int (*rw_page)(struct block_device *, sector_t, struct page *, int rw); int (*rw_page)(struct block_device *, sector_t, struct page *, int rw);
int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
long (*direct_access)(struct block_device *, sector_t, long (*direct_access)(struct block_device *, sector_t, void __pmem **,
void **, unsigned long *pfn, long size); unsigned long *pfn, long size);
unsigned int (*check_events) (struct gendisk *disk, unsigned int (*check_events) (struct gendisk *disk,
unsigned int clearing); unsigned int clearing);
/* ->media_changed() is DEPRECATED, use ->check_events() instead */ /* ->media_changed() is DEPRECATED, use ->check_events() instead */
...@@ -1574,8 +1574,8 @@ extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int, ...@@ -1574,8 +1574,8 @@ extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
extern int bdev_read_page(struct block_device *, sector_t, struct page *); extern int bdev_read_page(struct block_device *, sector_t, struct page *);
extern int bdev_write_page(struct block_device *, sector_t, struct page *, extern int bdev_write_page(struct block_device *, sector_t, struct page *,
struct writeback_control *); struct writeback_control *);
extern long bdev_direct_access(struct block_device *, sector_t, void **addr, extern long bdev_direct_access(struct block_device *, sector_t,
unsigned long *pfn, long size); void __pmem **addr, unsigned long *pfn, long size);
#else /* CONFIG_BLOCK */ #else /* CONFIG_BLOCK */
struct block_device; struct block_device;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment