mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-25 06:03:36 -04:00
Nothing really exciting: some groundwork for changing virtio endian, and
some robustness fixes for broken virtio devices, plus minor tweaks.
[vs last pull request: added the virtio-scsi broken vq escape patch, which
I somehow lost.]
Cheers,
Rusty.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
iQIcBAABAgAGBQJSgDsJAAoJENkgDmzRrbjxEE4P/jXqZHS/HdlxW9k0BjKKlEIF
PdtCoP3UhWTdskXvy2pD8m6nYn214MEJYUIa4HFlIEZsdxhuexzQHY19Ynkjagyv
57sRsUUm5fYQLIL7IUh2DUD1VU38hUFinno/y333szzvCj9qITDA/QABsiWxK8NO
dq+Lmeixgrhc5yN9iryW+gZV+hekJIZ4LsU5ejSaJucKblzXUH8qIbmSthG7RTYJ
tr4J7xTTXbhxY4CoC5Dpx2hvsFkvzaAIvI4Nr1mDjfq5cR8BaYvnC89U1IbhdAey
p1AbZE58JLrY+Z8K8LBRGV2KjO8qSZ6R47hbZ9nAnodJYB7sZLyj6jUe1q+/htuC
Dh9Xm9O4eW2xNaFk20dYeIF4UU5/HzdsbvG/IlH8x4sm8/K706ocYyAOHlzYUg2T
k7gltrgDzDokMgb2R44gwnr4oaJ2q8Gne6JXswlPEv2eRs6vNnA5Xhc0rEHGkU6C
gYn1vNFN6yx0vf2syG/Ce5pZtMxGpefKQkHzzWdq8FKr1B9s54dDuf2hls7J8A9t
OQT1gE33yURSelf4Kh4k9zWXaWk/Ohv9l2R1cqpALnJ4/+q0fP5t7HdK500S7aax
DxLeFeqvsBw7nlWgsGxQmt+fjITQFHhcDiwst0ehnt6RbDEW7XPIguz0K/gyhxYG
+UNbl/5Gr64jnUX3YCzm
=vY2L
-----END PGP SIGNATURE-----
Merge tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull virtio updates from Rusty Russell:
"Nothing really exciting: some groundwork for changing virtio endian,
and some robustness fixes for broken virtio devices, plus minor
tweaks"
* tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
virtio_scsi: verify if queue is broken after virtqueue_get_buf()
x86, asmlinkage, lguest: Pass in globals into assembler statement
virtio: mmio: fix signature checking for BE guests
virtio_ring: adapt to notify() returning bool
virtio_net: verify if queue is broken after virtqueue_get_buf()
virtio_console: verify if queue is broken after virtqueue_get_buf()
virtio_blk: verify if queue is broken after virtqueue_get_buf()
virtio_ring: add new function virtqueue_is_broken()
virtio_test: verify if virtqueue_kick() succeeded
virtio_net: verify if virtqueue_kick() succeeded
virtio_ring: let virtqueue_{kick()/notify()} return a bool
virtio_ring: change host notification API
virtio_config: remove virtio_config_val
virtio: use size-based config accessors.
virtio_config: introduce size-based accessors.
virtio_ring: plug kmemleak false positive.
virtio: pm: use CONFIG_PM_SLEEP instead of CONFIG_PM
This commit is contained in:
commit
b746f9c794
21 changed files with 310 additions and 166 deletions
|
|
@ -51,11 +51,11 @@ int virtqueue_add_sgs(struct virtqueue *vq,
|
|||
void *data,
|
||||
gfp_t gfp);
|
||||
|
||||
void virtqueue_kick(struct virtqueue *vq);
|
||||
bool virtqueue_kick(struct virtqueue *vq);
|
||||
|
||||
bool virtqueue_kick_prepare(struct virtqueue *vq);
|
||||
|
||||
void virtqueue_notify(struct virtqueue *vq);
|
||||
bool virtqueue_notify(struct virtqueue *vq);
|
||||
|
||||
void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len);
|
||||
|
||||
|
|
@ -73,6 +73,8 @@ void *virtqueue_detach_unused_buf(struct virtqueue *vq);
|
|||
|
||||
unsigned int virtqueue_get_vring_size(struct virtqueue *vq);
|
||||
|
||||
bool virtqueue_is_broken(struct virtqueue *vq);
|
||||
|
||||
/**
|
||||
* virtio_device - representation of a device using virtio
|
||||
* @index: unique position on the virtio bus
|
||||
|
|
|
|||
|
|
@ -96,33 +96,6 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
|
|||
return test_bit(fbit, vdev->features);
|
||||
}
|
||||
|
||||
/**
|
||||
* virtio_config_val - look for a feature and get a virtio config entry.
|
||||
* @vdev: the virtio device
|
||||
* @fbit: the feature bit
|
||||
* @offset: the type to search for.
|
||||
* @v: a pointer to the value to fill in.
|
||||
*
|
||||
* The return value is -ENOENT if the feature doesn't exist. Otherwise
|
||||
* the config value is copied into whatever is pointed to by v. */
|
||||
#define virtio_config_val(vdev, fbit, offset, v) \
|
||||
virtio_config_buf((vdev), (fbit), (offset), (v), sizeof(*v))
|
||||
|
||||
#define virtio_config_val_len(vdev, fbit, offset, v, len) \
|
||||
virtio_config_buf((vdev), (fbit), (offset), (v), (len))
|
||||
|
||||
static inline int virtio_config_buf(struct virtio_device *vdev,
|
||||
unsigned int fbit,
|
||||
unsigned int offset,
|
||||
void *buf, unsigned len)
|
||||
{
|
||||
if (!virtio_has_feature(vdev, fbit))
|
||||
return -ENOENT;
|
||||
|
||||
vdev->config->get(vdev, offset, buf, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline
|
||||
struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev,
|
||||
vq_callback_t *c, const char *n)
|
||||
|
|
@ -162,5 +135,139 @@ int virtqueue_set_affinity(struct virtqueue *vq, int cpu)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Config space accessors. */
|
||||
#define virtio_cread(vdev, structname, member, ptr) \
|
||||
do { \
|
||||
/* Must match the member's type, and be integer */ \
|
||||
if (!typecheck(typeof((((structname*)0)->member)), *(ptr))) \
|
||||
(*ptr) = 1; \
|
||||
\
|
||||
switch (sizeof(*ptr)) { \
|
||||
case 1: \
|
||||
*(ptr) = virtio_cread8(vdev, \
|
||||
offsetof(structname, member)); \
|
||||
break; \
|
||||
case 2: \
|
||||
*(ptr) = virtio_cread16(vdev, \
|
||||
offsetof(structname, member)); \
|
||||
break; \
|
||||
case 4: \
|
||||
*(ptr) = virtio_cread32(vdev, \
|
||||
offsetof(structname, member)); \
|
||||
break; \
|
||||
case 8: \
|
||||
*(ptr) = virtio_cread64(vdev, \
|
||||
offsetof(structname, member)); \
|
||||
break; \
|
||||
default: \
|
||||
BUG(); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* Config space accessors. */
|
||||
#define virtio_cwrite(vdev, structname, member, ptr) \
|
||||
do { \
|
||||
/* Must match the member's type, and be integer */ \
|
||||
if (!typecheck(typeof((((structname*)0)->member)), *(ptr))) \
|
||||
BUG_ON((*ptr) == 1); \
|
||||
\
|
||||
switch (sizeof(*ptr)) { \
|
||||
case 1: \
|
||||
virtio_cwrite8(vdev, \
|
||||
offsetof(structname, member), \
|
||||
*(ptr)); \
|
||||
break; \
|
||||
case 2: \
|
||||
virtio_cwrite16(vdev, \
|
||||
offsetof(structname, member), \
|
||||
*(ptr)); \
|
||||
break; \
|
||||
case 4: \
|
||||
virtio_cwrite32(vdev, \
|
||||
offsetof(structname, member), \
|
||||
*(ptr)); \
|
||||
break; \
|
||||
case 8: \
|
||||
virtio_cwrite64(vdev, \
|
||||
offsetof(structname, member), \
|
||||
*(ptr)); \
|
||||
break; \
|
||||
default: \
|
||||
BUG(); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static inline u8 virtio_cread8(struct virtio_device *vdev, unsigned int offset)
|
||||
{
|
||||
u8 ret;
|
||||
vdev->config->get(vdev, offset, &ret, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void virtio_cread_bytes(struct virtio_device *vdev,
|
||||
unsigned int offset,
|
||||
void *buf, size_t len)
|
||||
{
|
||||
vdev->config->get(vdev, offset, buf, len);
|
||||
}
|
||||
|
||||
static inline void virtio_cwrite8(struct virtio_device *vdev,
|
||||
unsigned int offset, u8 val)
|
||||
{
|
||||
vdev->config->set(vdev, offset, &val, sizeof(val));
|
||||
}
|
||||
|
||||
static inline u16 virtio_cread16(struct virtio_device *vdev,
|
||||
unsigned int offset)
|
||||
{
|
||||
u16 ret;
|
||||
vdev->config->get(vdev, offset, &ret, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void virtio_cwrite16(struct virtio_device *vdev,
|
||||
unsigned int offset, u16 val)
|
||||
{
|
||||
vdev->config->set(vdev, offset, &val, sizeof(val));
|
||||
}
|
||||
|
||||
static inline u32 virtio_cread32(struct virtio_device *vdev,
|
||||
unsigned int offset)
|
||||
{
|
||||
u32 ret;
|
||||
vdev->config->get(vdev, offset, &ret, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void virtio_cwrite32(struct virtio_device *vdev,
|
||||
unsigned int offset, u32 val)
|
||||
{
|
||||
vdev->config->set(vdev, offset, &val, sizeof(val));
|
||||
}
|
||||
|
||||
static inline u64 virtio_cread64(struct virtio_device *vdev,
|
||||
unsigned int offset)
|
||||
{
|
||||
u64 ret;
|
||||
vdev->config->get(vdev, offset, &ret, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void virtio_cwrite64(struct virtio_device *vdev,
|
||||
unsigned int offset, u64 val)
|
||||
{
|
||||
vdev->config->set(vdev, offset, &val, sizeof(val));
|
||||
}
|
||||
|
||||
/* Conditional config space accessors. */
|
||||
#define virtio_cread_feature(vdev, fbit, structname, member, ptr) \
|
||||
({ \
|
||||
int _r = 0; \
|
||||
if (!virtio_has_feature(vdev, fbit)) \
|
||||
_r = -ENOENT; \
|
||||
else \
|
||||
virtio_cread((vdev), structname, member, ptr); \
|
||||
_r; \
|
||||
})
|
||||
|
||||
#endif /* _LINUX_VIRTIO_CONFIG_H */
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ struct virtqueue *vring_new_virtqueue(unsigned int index,
|
|||
struct virtio_device *vdev,
|
||||
bool weak_barriers,
|
||||
void *pages,
|
||||
void (*notify)(struct virtqueue *vq),
|
||||
bool (*notify)(struct virtqueue *vq),
|
||||
void (*callback)(struct virtqueue *vq),
|
||||
const char *name);
|
||||
void vring_del_virtqueue(struct virtqueue *vq);
|
||||
|
|
|
|||
Loading…
Reference in a new issue