diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-10 22:47:57 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-10 22:47:57 +0300 |
commit | 45ba8d5d061b13494c2a7a7652d51b9da3d9e77a (patch) | |
tree | dddb4253b06a58609407ced51aaaf475f724baae /include | |
parent | bb97be23db2a296c5f8b8b4c40feb0435b068c5e (diff) | |
parent | cfdbb4ed31aa777d59b288810f66eb06249ee5b7 (diff) | |
download | linux-45ba8d5d061b13494c2a7a7652d51b9da3d9e77a.tar.xz |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio updates from Michael Tsirkin:
"Several fixes, most notably fix for virtio on swiotlb systems"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
vhost: silence an unused-variable warning
virtio: hint if callbacks surprisingly might sleep
virtio-ccw: wire up ->bus_name callback
s390/virtio: handle find on invalid queue gracefully
virtio-ccw: diag 500 may return a negative cookie
virtio_balloon: remove the unnecessary 0-initialization
virtio-balloon: improve update_balloon_size_func
virtio-blk: Consider virtio_max_dma_size() for maximum segment size
virtio: Introduce virtio_max_dma_size()
dma: Introduce dma_max_mapping_size()
swiotlb: Add is_swiotlb_active() function
swiotlb: Introduce swiotlb_max_mapping_size()
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/dma-mapping.h | 8 | ||||
-rw-r--r-- | include/linux/swiotlb.h | 11 | ||||
-rw-r--r-- | include/linux/virtio.h | 2 | ||||
-rw-r--r-- | include/linux/virtio_config.h | 13 |
4 files changed, 34 insertions, 0 deletions
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 70ad15758a70..75e60be91e5f 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -130,6 +130,7 @@ struct dma_map_ops { enum dma_data_direction direction); int (*dma_supported)(struct device *dev, u64 mask); u64 (*get_required_mask)(struct device *dev); + size_t (*max_mapping_size)(struct device *dev); }; #define DMA_MAPPING_ERROR (~(dma_addr_t)0) @@ -259,6 +260,8 @@ static inline void dma_direct_sync_sg_for_cpu(struct device *dev, } #endif +size_t dma_direct_max_mapping_size(struct device *dev); + #ifdef CONFIG_HAS_DMA #include <asm/dma-mapping.h> @@ -463,6 +466,7 @@ int dma_supported(struct device *dev, u64 mask); int dma_set_mask(struct device *dev, u64 mask); int dma_set_coherent_mask(struct device *dev, u64 mask); u64 dma_get_required_mask(struct device *dev); +size_t dma_max_mapping_size(struct device *dev); #else /* CONFIG_HAS_DMA */ static inline dma_addr_t dma_map_page_attrs(struct device *dev, struct page *page, size_t offset, size_t size, @@ -564,6 +568,10 @@ static inline u64 dma_get_required_mask(struct device *dev) { return 0; } +static inline size_t dma_max_mapping_size(struct device *dev) +{ + return 0; +} #endif /* CONFIG_HAS_DMA */ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr, diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index 54254388899e..361f62bb4a8e 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h @@ -73,6 +73,8 @@ bool swiotlb_map(struct device *dev, phys_addr_t *phys, dma_addr_t *dma_addr, size_t size, enum dma_data_direction dir, unsigned long attrs); void __init swiotlb_exit(void); unsigned int swiotlb_max_segment(void); +size_t swiotlb_max_mapping_size(struct device *dev); +bool is_swiotlb_active(void); #else #define swiotlb_force SWIOTLB_NO_FORCE static inline bool is_swiotlb_buffer(phys_addr_t paddr) @@ -92,6 +94,15 @@ static inline unsigned int swiotlb_max_segment(void) { return 0; } +static inline size_t swiotlb_max_mapping_size(struct device *dev) +{ + return SIZE_MAX; +} + +static inline bool is_swiotlb_active(void) +{ + return false; +} #endif /* CONFIG_SWIOTLB */ extern void swiotlb_print_info(void); diff --git a/include/linux/virtio.h b/include/linux/virtio.h index fa1b5da2804e..673fe3ef3607 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -157,6 +157,8 @@ int virtio_device_freeze(struct virtio_device *dev); int virtio_device_restore(struct virtio_device *dev); #endif +size_t virtio_max_dma_size(struct virtio_device *vdev); + #define virtio_device_for_each_vq(vdev, vq) \ list_for_each_entry(vq, &vdev->vqs, list) diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 987b6491b946..bb4cc4910750 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -290,6 +290,7 @@ static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) /* Config space accessors. */ #define virtio_cread(vdev, structname, member, ptr) \ do { \ + might_sleep(); \ /* Must match the member's type, and be integer */ \ if (!typecheck(typeof((((structname*)0)->member)), *(ptr))) \ (*ptr) = 1; \ @@ -319,6 +320,7 @@ static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) /* Config space accessors. */ #define virtio_cwrite(vdev, structname, member, ptr) \ do { \ + might_sleep(); \ /* Must match the member's type, and be integer */ \ if (!typecheck(typeof((((structname*)0)->member)), *(ptr))) \ BUG_ON((*ptr) == 1); \ @@ -358,6 +360,7 @@ static inline void __virtio_cread_many(struct virtio_device *vdev, vdev->config->generation(vdev) : 0; int i; + might_sleep(); do { old = gen; @@ -380,6 +383,8 @@ static inline void virtio_cread_bytes(struct virtio_device *vdev, static inline u8 virtio_cread8(struct virtio_device *vdev, unsigned int offset) { u8 ret; + + might_sleep(); vdev->config->get(vdev, offset, &ret, sizeof(ret)); return ret; } @@ -387,6 +392,7 @@ static inline u8 virtio_cread8(struct virtio_device *vdev, unsigned int offset) static inline void virtio_cwrite8(struct virtio_device *vdev, unsigned int offset, u8 val) { + might_sleep(); vdev->config->set(vdev, offset, &val, sizeof(val)); } @@ -394,6 +400,8 @@ static inline u16 virtio_cread16(struct virtio_device *vdev, unsigned int offset) { u16 ret; + + might_sleep(); vdev->config->get(vdev, offset, &ret, sizeof(ret)); return virtio16_to_cpu(vdev, (__force __virtio16)ret); } @@ -401,6 +409,7 @@ static inline u16 virtio_cread16(struct virtio_device *vdev, static inline void virtio_cwrite16(struct virtio_device *vdev, unsigned int offset, u16 val) { + might_sleep(); val = (__force u16)cpu_to_virtio16(vdev, val); vdev->config->set(vdev, offset, &val, sizeof(val)); } @@ -409,6 +418,8 @@ static inline u32 virtio_cread32(struct virtio_device *vdev, unsigned int offset) { u32 ret; + + might_sleep(); vdev->config->get(vdev, offset, &ret, sizeof(ret)); return virtio32_to_cpu(vdev, (__force __virtio32)ret); } @@ -416,6 +427,7 @@ static inline u32 virtio_cread32(struct virtio_device *vdev, static inline void virtio_cwrite32(struct virtio_device *vdev, unsigned int offset, u32 val) { + might_sleep(); val = (__force u32)cpu_to_virtio32(vdev, val); vdev->config->set(vdev, offset, &val, sizeof(val)); } @@ -431,6 +443,7 @@ static inline u64 virtio_cread64(struct virtio_device *vdev, static inline void virtio_cwrite64(struct virtio_device *vdev, unsigned int offset, u64 val) { + might_sleep(); val = (__force u64)cpu_to_virtio64(vdev, val); vdev->config->set(vdev, offset, &val, sizeof(val)); } |