mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-07 14:32:23 +00:00
xen: branch for v5.14-rc1
-----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRTLbB6QfY48x44uB6AXGG7T9hjvgUCYOVQVQAKCRCAXGG7T9hj vnsfAQCLwcqSbno1iiUFDFGDzwnF0RZjIxpvEvdI/Zc0KMAO5gEA9tixIpfBYUO3 0yAd9g/VRumPS0wRsfwUrnLYs8TZ4gY= =pPbL -----END PGP SIGNATURE----- Merge tag 'for-linus-5.14-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip Pull xen updates from Juergen Gross: "Only two minor patches this time: one cleanup patch and one patch refreshing a Xen header" * tag 'for-linus-5.14-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen: sync include/xen/interface/io/ring.h with Xen's newest version xen: Use DEVICE_ATTR_*() macro
This commit is contained in:
commit
4ea9031795
@ -92,7 +92,7 @@ static int xen_pcpu_up(uint32_t cpu_id)
|
||||
return HYPERVISOR_platform_op(&op);
|
||||
}
|
||||
|
||||
static ssize_t show_online(struct device *dev,
|
||||
static ssize_t online_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
@ -101,7 +101,7 @@ static ssize_t show_online(struct device *dev,
|
||||
return sprintf(buf, "%u\n", !!(cpu->flags & XEN_PCPU_FLAGS_ONLINE));
|
||||
}
|
||||
|
||||
static ssize_t __ref store_online(struct device *dev,
|
||||
static ssize_t __ref online_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
@ -130,7 +130,7 @@ static ssize_t __ref store_online(struct device *dev,
|
||||
ret = count;
|
||||
return ret;
|
||||
}
|
||||
static DEVICE_ATTR(online, S_IRUGO | S_IWUSR, show_online, store_online);
|
||||
static DEVICE_ATTR_RW(online);
|
||||
|
||||
static struct attribute *pcpu_dev_attrs[] = {
|
||||
&dev_attr_online.attr,
|
||||
|
@ -134,13 +134,13 @@ void xen_balloon_init(void)
|
||||
EXPORT_SYMBOL_GPL(xen_balloon_init);
|
||||
|
||||
#define BALLOON_SHOW(name, format, args...) \
|
||||
static ssize_t show_##name(struct device *dev, \
|
||||
static ssize_t name##_show(struct device *dev, \
|
||||
struct device_attribute *attr, \
|
||||
char *buf) \
|
||||
{ \
|
||||
return sprintf(buf, format, ##args); \
|
||||
} \
|
||||
static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
|
||||
static DEVICE_ATTR_RO(name)
|
||||
|
||||
BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
|
||||
BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low));
|
||||
@ -152,16 +152,15 @@ static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count);
|
||||
static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count);
|
||||
static DEVICE_BOOL_ATTR(scrub_pages, 0644, xen_scrub_pages);
|
||||
|
||||
static ssize_t show_target_kb(struct device *dev, struct device_attribute *attr,
|
||||
static ssize_t target_kb_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages));
|
||||
}
|
||||
|
||||
static ssize_t store_target_kb(struct device *dev,
|
||||
static ssize_t target_kb_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
char *endchar;
|
||||
unsigned long long target_bytes;
|
||||
@ -176,11 +175,9 @@ static ssize_t store_target_kb(struct device *dev,
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(target_kb, S_IRUGO | S_IWUSR,
|
||||
show_target_kb, store_target_kb);
|
||||
static DEVICE_ATTR_RW(target_kb);
|
||||
|
||||
|
||||
static ssize_t show_target(struct device *dev, struct device_attribute *attr,
|
||||
static ssize_t target_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
return sprintf(buf, "%llu\n",
|
||||
@ -188,10 +185,9 @@ static ssize_t show_target(struct device *dev, struct device_attribute *attr,
|
||||
<< PAGE_SHIFT);
|
||||
}
|
||||
|
||||
static ssize_t store_target(struct device *dev,
|
||||
static ssize_t target_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
char *endchar;
|
||||
unsigned long long target_bytes;
|
||||
@ -206,9 +202,7 @@ static ssize_t store_target(struct device *dev,
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(target, S_IRUGO | S_IWUSR,
|
||||
show_target, store_target);
|
||||
|
||||
static DEVICE_ATTR_RW(target);
|
||||
|
||||
static struct attribute *balloon_attrs[] = {
|
||||
&dev_attr_target_kb.attr,
|
||||
|
@ -207,7 +207,7 @@ void xenbus_otherend_changed(struct xenbus_watch *watch,
|
||||
EXPORT_SYMBOL_GPL(xenbus_otherend_changed);
|
||||
|
||||
#define XENBUS_SHOW_STAT(name) \
|
||||
static ssize_t show_##name(struct device *_dev, \
|
||||
static ssize_t name##_show(struct device *_dev, \
|
||||
struct device_attribute *attr, \
|
||||
char *buf) \
|
||||
{ \
|
||||
@ -215,14 +215,14 @@ static ssize_t show_##name(struct device *_dev, \
|
||||
\
|
||||
return sprintf(buf, "%d\n", atomic_read(&dev->name)); \
|
||||
} \
|
||||
static DEVICE_ATTR(name, 0444, show_##name, NULL)
|
||||
static DEVICE_ATTR_RO(name)
|
||||
|
||||
XENBUS_SHOW_STAT(event_channels);
|
||||
XENBUS_SHOW_STAT(events);
|
||||
XENBUS_SHOW_STAT(spurious_events);
|
||||
XENBUS_SHOW_STAT(jiffies_eoi_delayed);
|
||||
|
||||
static ssize_t show_spurious_threshold(struct device *_dev,
|
||||
static ssize_t spurious_threshold_show(struct device *_dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
@ -231,7 +231,7 @@ static ssize_t show_spurious_threshold(struct device *_dev,
|
||||
return sprintf(buf, "%d\n", dev->spurious_threshold);
|
||||
}
|
||||
|
||||
static ssize_t set_spurious_threshold(struct device *_dev,
|
||||
static ssize_t spurious_threshold_store(struct device *_dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
@ -248,8 +248,7 @@ static ssize_t set_spurious_threshold(struct device *_dev,
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(spurious_threshold, 0644, show_spurious_threshold,
|
||||
set_spurious_threshold);
|
||||
static DEVICE_ATTR_RW(spurious_threshold);
|
||||
|
||||
static struct attribute *xenbus_attrs[] = {
|
||||
&dev_attr_event_channels.attr,
|
||||
|
@ -1,15 +1,47 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/******************************************************************************
|
||||
* ring.h
|
||||
*
|
||||
* Shared producer-consumer ring macros.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Tim Deegan and Andrew Warfield November 2004.
|
||||
*/
|
||||
|
||||
#ifndef __XEN_PUBLIC_IO_RING_H__
|
||||
#define __XEN_PUBLIC_IO_RING_H__
|
||||
|
||||
/*
|
||||
* When #include'ing this header, you need to provide the following
|
||||
* declaration upfront:
|
||||
* - standard integers types (uint8_t, uint16_t, etc)
|
||||
* They are provided by stdint.h of the standard headers.
|
||||
*
|
||||
* In addition, if you intend to use the FLEX macros, you also need to
|
||||
* provide the following, before invoking the FLEX macros:
|
||||
* - size_t
|
||||
* - memcpy
|
||||
* - grant_ref_t
|
||||
* These declarations are provided by string.h of the standard headers,
|
||||
* and grant_table.h from the Xen public headers.
|
||||
*/
|
||||
|
||||
#include <xen/interface/grant_table.h>
|
||||
|
||||
typedef unsigned int RING_IDX;
|
||||
@ -30,45 +62,42 @@ typedef unsigned int RING_IDX;
|
||||
#define __CONST_RING_SIZE(_s, _sz) \
|
||||
(__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
|
||||
sizeof(((struct _s##_sring *)0)->ring[0])))
|
||||
|
||||
/*
|
||||
* The same for passing in an actual pointer instead of a name tag.
|
||||
*/
|
||||
#define __RING_SIZE(_s, _sz) \
|
||||
(__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
|
||||
(__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
|
||||
|
||||
/*
|
||||
* Macros to make the correct C datatypes for a new kind of ring.
|
||||
*
|
||||
* To make a new ring datatype, you need to have two message structures,
|
||||
* let's say struct request, and struct response already defined.
|
||||
* let's say request_t, and response_t already defined.
|
||||
*
|
||||
* In a header where you want the ring datatype declared, you then do:
|
||||
*
|
||||
* DEFINE_RING_TYPES(mytag, struct request, struct response);
|
||||
* DEFINE_RING_TYPES(mytag, request_t, response_t);
|
||||
*
|
||||
* These expand out to give you a set of types, as you can see below.
|
||||
* The most important of these are:
|
||||
*
|
||||
* struct mytag_sring - The shared ring.
|
||||
* struct mytag_front_ring - The 'front' half of the ring.
|
||||
* struct mytag_back_ring - The 'back' half of the ring.
|
||||
* mytag_sring_t - The shared ring.
|
||||
* mytag_front_ring_t - The 'front' half of the ring.
|
||||
* mytag_back_ring_t - The 'back' half of the ring.
|
||||
*
|
||||
* To initialize a ring in your code you need to know the location and size
|
||||
* of the shared memory area (PAGE_SIZE, for instance). To initialise
|
||||
* the front half:
|
||||
*
|
||||
* struct mytag_front_ring front_ring;
|
||||
* SHARED_RING_INIT((struct mytag_sring *)shared_page);
|
||||
* FRONT_RING_INIT(&front_ring, (struct mytag_sring *)shared_page,
|
||||
* PAGE_SIZE);
|
||||
* mytag_front_ring_t front_ring;
|
||||
* SHARED_RING_INIT((mytag_sring_t *)shared_page);
|
||||
* FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
|
||||
*
|
||||
* Initializing the back follows similarly (note that only the front
|
||||
* initializes the shared ring):
|
||||
*
|
||||
* struct mytag_back_ring back_ring;
|
||||
* BACK_RING_INIT(&back_ring, (struct mytag_sring *)shared_page,
|
||||
* PAGE_SIZE);
|
||||
* mytag_back_ring_t back_ring;
|
||||
* BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
|
||||
*/
|
||||
|
||||
#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t) \
|
||||
@ -83,7 +112,7 @@ union __name##_sring_entry { \
|
||||
struct __name##_sring { \
|
||||
RING_IDX req_prod, req_event; \
|
||||
RING_IDX rsp_prod, rsp_event; \
|
||||
uint8_t pad[48]; \
|
||||
uint8_t __pad[48]; \
|
||||
union __name##_sring_entry ring[1]; /* variable-length */ \
|
||||
}; \
|
||||
\
|
||||
@ -101,8 +130,8 @@ struct __name##_back_ring { \
|
||||
RING_IDX req_cons; \
|
||||
unsigned int nr_ents; \
|
||||
struct __name##_sring *sring; \
|
||||
};
|
||||
|
||||
}; \
|
||||
\
|
||||
/*
|
||||
* Macros for manipulating rings.
|
||||
*
|
||||
@ -122,7 +151,7 @@ struct __name##_back_ring { \
|
||||
#define SHARED_RING_INIT(_s) do { \
|
||||
(_s)->req_prod = (_s)->rsp_prod = 0; \
|
||||
(_s)->req_event = (_s)->rsp_event = 1; \
|
||||
memset((_s)->pad, 0, sizeof((_s)->pad)); \
|
||||
(void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \
|
||||
} while(0)
|
||||
|
||||
#define FRONT_RING_ATTACH(_r, _s, _i, __size) do { \
|
||||
@ -161,8 +190,7 @@ struct __name##_back_ring { \
|
||||
#define RING_HAS_UNCONSUMED_RESPONSES(_r) \
|
||||
((_r)->sring->rsp_prod - (_r)->rsp_cons)
|
||||
|
||||
#define RING_HAS_UNCONSUMED_REQUESTS(_r) \
|
||||
({ \
|
||||
#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \
|
||||
unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \
|
||||
unsigned int rsp = RING_SIZE(_r) - \
|
||||
((_r)->req_cons - (_r)->rsp_prod_pvt); \
|
||||
@ -173,22 +201,25 @@ struct __name##_back_ring { \
|
||||
#define RING_GET_REQUEST(_r, _idx) \
|
||||
(&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
|
||||
|
||||
#define RING_GET_RESPONSE(_r, _idx) \
|
||||
(&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
|
||||
|
||||
/*
|
||||
* Get a local copy of a request.
|
||||
* Get a local copy of a request/response.
|
||||
*
|
||||
* Use this in preference to RING_GET_REQUEST() so all processing is
|
||||
* Use this in preference to RING_GET_{REQUEST,RESPONSE}() so all processing is
|
||||
* done on a local copy that cannot be modified by the other end.
|
||||
*
|
||||
* Note that https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 may cause this
|
||||
* to be ineffective where _req is a struct which consists of only bitfields.
|
||||
* to be ineffective where dest is a struct which consists of only bitfields.
|
||||
*/
|
||||
#define RING_COPY_REQUEST(_r, _idx, _req) do { \
|
||||
/* Use volatile to force the copy into _req. */ \
|
||||
*(_req) = *(volatile typeof(_req))RING_GET_REQUEST(_r, _idx); \
|
||||
#define RING_COPY_(type, r, idx, dest) do { \
|
||||
/* Use volatile to force the copy into dest. */ \
|
||||
*(dest) = *(volatile typeof(dest))RING_GET_##type(r, idx); \
|
||||
} while (0)
|
||||
|
||||
#define RING_GET_RESPONSE(_r, _idx) \
|
||||
(&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
|
||||
#define RING_COPY_REQUEST(r, idx, req) RING_COPY_(REQUEST, r, idx, req)
|
||||
#define RING_COPY_RESPONSE(r, idx, rsp) RING_COPY_(RESPONSE, r, idx, rsp)
|
||||
|
||||
/* Loop termination condition: Would the specified index overflow the ring? */
|
||||
#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \
|
||||
@ -198,6 +229,9 @@ struct __name##_back_ring { \
|
||||
#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \
|
||||
(((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
|
||||
|
||||
/* Ill-behaved backend determination: Can there be this many responses? */
|
||||
#define RING_RESPONSE_PROD_OVERFLOW(_r, _prod) \
|
||||
(((_prod) - (_r)->rsp_cons) > RING_SIZE(_r))
|
||||
|
||||
#define RING_PUSH_REQUESTS(_r) do { \
|
||||
virt_wmb(); /* back sees requests /before/ updated producer index */\
|
||||
@ -205,7 +239,7 @@ struct __name##_back_ring { \
|
||||
} while (0)
|
||||
|
||||
#define RING_PUSH_RESPONSES(_r) do { \
|
||||
virt_wmb(); /* front sees responses /before/ updated producer index */ \
|
||||
virt_wmb(); /* front sees resps /before/ updated producer index */ \
|
||||
(_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \
|
||||
} while (0)
|
||||
|
||||
@ -252,9 +286,9 @@ struct __name##_back_ring { \
|
||||
#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do { \
|
||||
RING_IDX __old = (_r)->sring->rsp_prod; \
|
||||
RING_IDX __new = (_r)->rsp_prod_pvt; \
|
||||
virt_wmb(); /* front sees responses /before/ updated producer index */ \
|
||||
virt_wmb(); /* front sees resps /before/ updated producer index */ \
|
||||
(_r)->sring->rsp_prod = __new; \
|
||||
virt_mb(); /* front sees new responses /before/ we check rsp_event */ \
|
||||
virt_mb(); /* front sees new resps /before/ we check rsp_event */ \
|
||||
(_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \
|
||||
(RING_IDX)(__new - __old)); \
|
||||
} while (0)
|
||||
|
Loading…
Reference in New Issue
Block a user