summaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-12-28 22:41:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-28 22:41:58 -0500
commit1984f65c2fbc0d2b557d6e89ece9b39267e215c6 (patch)
treecfaec61ef718812e0ba4c06cb8c3338af71fe1f7 /samples
parentf346b0becb1bc62e45495f9cdbae3eef35d0b635 (diff)
parent8ba35b3a0046d6573c98f00461d9bd1b86250d35 (diff)
Merge tag 'vfio-v4.21-rc1' of git://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson: - Replace global vfio-pci lock with per bus lock to allow concurrent open and release (Alex Williamson) - Declare mdev function as static (Paolo Cretaro) - Convert char to u8 in mdev/mtty sample driver (Nathan Chancellor) * tag 'vfio-v4.21-rc1' of git://github.com/awilliam/linux-vfio: vfio-mdev/samples: Use u8 instead of char for handle functions vfio/mdev: add static modifier to add_mdev_supported_type vfio/pci: Parallelize device open and release
Diffstat (limited to 'samples')
-rw-r--r--samples/vfio-mdev/mtty.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 7abb79d8313d..f6732aa16bb1 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -171,7 +171,7 @@ static struct mdev_state *find_mdev_state_by_uuid(uuid_le uuid)
171 return NULL; 171 return NULL;
172} 172}
173 173
174void dump_buffer(char *buf, uint32_t count) 174void dump_buffer(u8 *buf, uint32_t count)
175{ 175{
176#if defined(DEBUG) 176#if defined(DEBUG)
177 int i; 177 int i;
@@ -250,7 +250,7 @@ static void mtty_create_config_space(struct mdev_state *mdev_state)
250} 250}
251 251
252static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset, 252static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
253 char *buf, u32 count) 253 u8 *buf, u32 count)
254{ 254{
255 u32 cfg_addr, bar_mask, bar_index = 0; 255 u32 cfg_addr, bar_mask, bar_index = 0;
256 256
@@ -304,7 +304,7 @@ static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
304} 304}
305 305
306static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, 306static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
307 u16 offset, char *buf, u32 count) 307 u16 offset, u8 *buf, u32 count)
308{ 308{
309 u8 data = *buf; 309 u8 data = *buf;
310 310
@@ -475,7 +475,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
475} 475}
476 476
477static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state, 477static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state,
478 u16 offset, char *buf, u32 count) 478 u16 offset, u8 *buf, u32 count)
479{ 479{
480 /* Handle read requests by guest */ 480 /* Handle read requests by guest */
481 switch (offset) { 481 switch (offset) {
@@ -650,7 +650,7 @@ static void mdev_read_base(struct mdev_state *mdev_state)
650 } 650 }
651} 651}
652 652
653static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count, 653static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count,
654 loff_t pos, bool is_write) 654 loff_t pos, bool is_write)
655{ 655{
656 struct mdev_state *mdev_state; 656 struct mdev_state *mdev_state;
@@ -698,7 +698,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count,
698#if defined(DEBUG_REGS) 698#if defined(DEBUG_REGS)
699 pr_info("%s: BAR%d WR @0x%llx %s val:0x%02x dlab:%d\n", 699 pr_info("%s: BAR%d WR @0x%llx %s val:0x%02x dlab:%d\n",
700 __func__, index, offset, wr_reg[offset], 700 __func__, index, offset, wr_reg[offset],
701 (u8)*buf, mdev_state->s[index].dlab); 701 *buf, mdev_state->s[index].dlab);
702#endif 702#endif
703 handle_bar_write(index, mdev_state, offset, buf, count); 703 handle_bar_write(index, mdev_state, offset, buf, count);
704 } else { 704 } else {
@@ -708,7 +708,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count,
708#if defined(DEBUG_REGS) 708#if defined(DEBUG_REGS)
709 pr_info("%s: BAR%d RD @0x%llx %s val:0x%02x dlab:%d\n", 709 pr_info("%s: BAR%d RD @0x%llx %s val:0x%02x dlab:%d\n",
710 __func__, index, offset, rd_reg[offset], 710 __func__, index, offset, rd_reg[offset],
711 (u8)*buf, mdev_state->s[index].dlab); 711 *buf, mdev_state->s[index].dlab);
712#endif 712#endif
713 } 713 }
714 break; 714 break;
@@ -827,7 +827,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count,
827 if (count >= 4 && !(*ppos % 4)) { 827 if (count >= 4 && !(*ppos % 4)) {
828 u32 val; 828 u32 val;
829 829
830 ret = mdev_access(mdev, (char *)&val, sizeof(val), 830 ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
831 *ppos, false); 831 *ppos, false);
832 if (ret <= 0) 832 if (ret <= 0)
833 goto read_err; 833 goto read_err;
@@ -839,7 +839,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count,
839 } else if (count >= 2 && !(*ppos % 2)) { 839 } else if (count >= 2 && !(*ppos % 2)) {
840 u16 val; 840 u16 val;
841 841
842 ret = mdev_access(mdev, (char *)&val, sizeof(val), 842 ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
843 *ppos, false); 843 *ppos, false);
844 if (ret <= 0) 844 if (ret <= 0)
845 goto read_err; 845 goto read_err;
@@ -851,7 +851,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count,
851 } else { 851 } else {
852 u8 val; 852 u8 val;
853 853
854 ret = mdev_access(mdev, (char *)&val, sizeof(val), 854 ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
855 *ppos, false); 855 *ppos, false);
856 if (ret <= 0) 856 if (ret <= 0)
857 goto read_err; 857 goto read_err;
@@ -889,7 +889,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf,
889 if (copy_from_user(&val, buf, sizeof(val))) 889 if (copy_from_user(&val, buf, sizeof(val)))
890 goto write_err; 890 goto write_err;
891 891
892 ret = mdev_access(mdev, (char *)&val, sizeof(val), 892 ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
893 *ppos, true); 893 *ppos, true);
894 if (ret <= 0) 894 if (ret <= 0)
895 goto write_err; 895 goto write_err;
@@ -901,7 +901,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf,
901 if (copy_from_user(&val, buf, sizeof(val))) 901 if (copy_from_user(&val, buf, sizeof(val)))
902 goto write_err; 902 goto write_err;
903 903
904 ret = mdev_access(mdev, (char *)&val, sizeof(val), 904 ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
905 *ppos, true); 905 *ppos, true);
906 if (ret <= 0) 906 if (ret <= 0)
907 goto write_err; 907 goto write_err;
@@ -913,7 +913,7 @@ ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf,
913 if (copy_from_user(&val, buf, sizeof(val))) 913 if (copy_from_user(&val, buf, sizeof(val)))
914 goto write_err; 914 goto write_err;
915 915
916 ret = mdev_access(mdev, (char *)&val, sizeof(val), 916 ret = mdev_access(mdev, (u8 *)&val, sizeof(val),
917 *ppos, true); 917 *ppos, true);
918 if (ret <= 0) 918 if (ret <= 0)
919 goto write_err; 919 goto write_err;