hv: clean up dev_attr usage
cover hv: clean up dev_attr usage
Hi,
Here's a set of 13 patches to get rid of the dev_attrs use in the hv bus code, as it will be going away soon. It's _way_ bigger than all other conversions I've had to do so far in the kernel, as you were using a "multiplexor" function for all of these files.
So, I've broken it up into individual show/store sysfs functions, and cleaned up a bunch of debug structures that aren't needed and shouldn't be exported to the rest of the kernel.
I've also fixed up some void * usage in the hv core, in patch 07, to make things simpler and not so "magic" when dealing with these pages. If you could review that one closely to ensure I didn't mess anything up, I would appreciate it.
Also, are all of these files really needed for sysfs? They seem to be all debugging stuff, shouldn't they go into debugfs if you really need/use them anymore?
KY, could you test these out? I don't have access to a hv system at the moment. I'll wait for your ack before applying them to any of my trees.
thanks,
greg k-h
PATCH 2/13 hv: move "state" bus attribute to dev_groups
This moves the "state" bus attribute to the dev_groups structure, removing the need for it to be in a temporary structure.
--- drivers/hv/channel.c | 1 - drivers/hv/vmbus_drv.c | 17 ++++++++++++----- include/linux/hyperv.h | 1 - 3 files changed, 12 insertions(+), 7 deletions(-)
drivers/hv/channel.c +0 -1
@@ -69,7 +69,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,u8 monitor_group = (u8 )channel->offermsg.monitorid /32 ;u8 monitor_offset = (u8 )channel->offermsg.monitorid %32 ; - debuginfo->state = channel->state;memcpy (&debuginfo->interfacetype, &channel->offermsg.offer.if_type,sizeof (uuid_le)); memcpy(&debuginfo->interface_instance,
drivers/hv/vmbus_drv.c +12 -5
@@ -47,7 +47,6 @@ static struct completion probe_event;static int irq;struct hv_device_info { -u32 chn_state;uuid_le chn_type;uuid_le chn_instance;
@@ -82,7 +81,6 @@ static void get_channel_info(struct hv_device *device,vmbus_get_debug_info (device->channel, &debug_info); - info->chn_state = debug_info.state;memcpy (&info->chn_type, &debug_info.interfacetype,sizeof (uuid_le)); memcpy(&info->chn_instance, &debug_info.interface_instance,
@@ -152,8 +150,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev, }else if (!strcmp (dev_attr->attr.name,"modalias" )) {print_alias_name (hv_dev, alias_name); ret =sprintf (buf,"vmbus:%s\n" , alias_name); - }else if (!strcmp (dev_attr->attr.name,"state" )) { - ret =sprintf (buf,"%d\n" , device_info->chn_state); }else if (!strcmp (dev_attr->attr.name,"out_intr_mask" )) { ret =sprintf (buf,"%d\n" , device_info->outbound.int_mask); }else if (!strcmp (dev_attr->attr.name,"out_read_index" )) {
@@ -211,15 +207,26 @@ static ssize_t id_show(struct device *dev, struct device_attribute *dev_attr, }static DEVICE_ATTR_RO (id); +static ssize_t state_show (struct device *dev,struct device_attribute *dev_attr, +char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); + +if (!hv_dev->channel) +return -ENODEV ; +return sprintf (buf,"%d\n" , hv_dev->channel->state); +} +static DEVICE_ATTR_RO (state); +static struct attribute *vmbus_attrs[] = { &dev_attr_id.attr, + &dev_attr_state.attr,NULL , };ATTRIBUTE_GROUPS (vmbus);/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ static struct device_attribute vmbus_device_attrs[] = { -__ATTR (state,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (class_id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (device_id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (monitor_id,S_IRUGO , vmbus_show_device_attr,NULL ),
include/linux/hyperv.h +0 -1
@@ -900,7 +900,6 @@ enum vmbus_channel_state { };struct vmbus_channel_debug_info { -enum vmbus_channel_state state;uuid_le interfacetype;uuid_le interface_instance;u32 monitorid;
Signature · 1 line
1.8.4.3.gca3854a
PATCH 1/13 hv: use dev_groups for device attributes
In reply to Greg Kroah-HartmanThis patch is the first in a series that moves the hv bus code to use the dev_groups field instead of dev_attrs, as dev_attrs is going away in future kernel releases.
It moves the id sysfs file to the dev_groups structure, and creates the needed show/store functions, instead of relying on one "universal" function for this. By doing this, it removes the need for this to be in a temporary structure.
--- drivers/hv/channel.c | 1 - drivers/hv/vmbus_drv.c | 23 ++++++++++++++++++----- include/linux/hyperv.h | 1 - 3 files changed, 18 insertions(+), 7 deletions(-)
drivers/hv/channel.c +0 -1
@@ -69,7 +69,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,u8 monitor_group = (u8 )channel->offermsg.monitorid /32 ;u8 monitor_offset = (u8 )channel->offermsg.monitorid %32 ; - debuginfo->relid = channel->offermsg.child_relid; debuginfo->state = channel->state;memcpy (&debuginfo->interfacetype, &channel->offermsg.offer.if_type,sizeof (uuid_le));
drivers/hv/vmbus_drv.c +18 -5
@@ -47,7 +47,6 @@ static struct completion probe_event;static int irq;struct hv_device_info { -u32 chn_id;u32 chn_state;uuid_le chn_type;uuid_le chn_instance;
@@ -83,7 +82,6 @@ static void get_channel_info(struct hv_device *device,vmbus_get_debug_info (device->channel, &debug_info); - info->chn_id = debug_info.relid; info->chn_state = debug_info.state;memcpy (&info->chn_type, &debug_info.interfacetype,sizeof (uuid_le));
@@ -156,8 +154,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev, ret =sprintf (buf,"vmbus:%s\n" , alias_name); }else if (!strcmp (dev_attr->attr.name,"state" )) { ret =sprintf (buf,"%d\n" , device_info->chn_state); - }else if (!strcmp (dev_attr->attr.name,"id" )) { - ret =sprintf (buf,"%d\n" , device_info->chn_id); }else if (!strcmp (dev_attr->attr.name,"out_intr_mask" )) { ret =sprintf (buf,"%d\n" , device_info->outbound.int_mask); }else if (!strcmp (dev_attr->attr.name,"out_read_index" )) {
@@ -204,9 +200,25 @@ static ssize_t vmbus_show_device_attr(struct device *dev,return ret; } +static ssize_t id_show (struct device *dev,struct device_attribute *dev_attr, +char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); + +if (!hv_dev->channel) +return -ENODEV ; +return sprintf (buf,"%d\n" , hv_dev->channel->offermsg.child_relid); +} +static DEVICE_ATTR_RO (id); + +static struct attribute *vmbus_attrs[] = { + &dev_attr_id.attr, +NULL , +}; +ATTRIBUTE_GROUPS (vmbus); +/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ static struct device_attribute vmbus_device_attrs[] = { -__ATTR (id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (state,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (class_id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (device_id,S_IRUGO , vmbus_show_device_attr,NULL ),
@@ -384,6 +396,7 @@ static struct bus_type hv_bus = { .probe = vmbus_probe, .uevent = vmbus_uevent, .dev_attrs = vmbus_device_attrs, + .dev_groups = vmbus_groups, };static const char *driver_name ="hyperv" ;
include/linux/hyperv.h +0 -1
@@ -900,7 +900,6 @@ enum vmbus_channel_state { };struct vmbus_channel_debug_info { -u32 relid;enum vmbus_channel_state state;uuid_le interfacetype;uuid_le interface_instance;
Signature · 1 line
1.8.4.3.gca3854a
PATCH 8/13 hv: move "client/server_monitor_pending" bus attributes to dev_groups
In reply to Greg Kroah-HartmanThis moves the "client_monitor_pending" and "server_monitor_pending" bus attributes to the dev_groups structure, removing the need for it to be in a temporary structure.
--- drivers/hv/channel.c | 4 ---- drivers/hv/vmbus_drv.c | 56 +++++++++++++++++++++++++++++++++++++++++--------- include/linux/hyperv.h | 2 -- 3 files changed, 46 insertions(+), 16 deletions(-)
drivers/hv/channel.c +0 -4
@@ -70,8 +70,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,u8 monitor_offset = (u8 )channel->offermsg.monitorid %32 ; monitorpage = vmbus_connection.monitor_pages[0 ]; - debuginfo->servermonitor_pending = - monitorpage->trigger_group[monitor_group].pending; debuginfo->servermonitor_latency = monitorpage->latency[monitor_group][monitor_offset]; debuginfo->servermonitor_connectionid =
@@ -79,8 +77,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, [monitor_offset].connectionid.u.id; monitorpage = vmbus_connection.monitor_pages[1 ]; - debuginfo->clientmonitor_pending = - monitorpage->trigger_group[monitor_group].pending; debuginfo->clientmonitor_latency = monitorpage->latency[monitor_group][monitor_offset]; debuginfo->clientmonitor_connectionid =
drivers/hv/vmbus_drv.c +46 -10
111 lines not on this page · raw message
include/linux/hyperv.h +0 -2
@@ -900,10 +900,8 @@ enum vmbus_channel_state { };struct vmbus_channel_debug_info { -u32 servermonitor_pending;u32 servermonitor_latency;u32 servermonitor_connectionid; -u32 clientmonitor_pending;u32 clientmonitor_latency;u32 clientmonitor_connectionid;
Signature · 1 line
1.8.4.3.gca3854a
PATCH 10/13 hv: move "client/server_monitor_conn_id" bus attributes to dev_groups
In reply to Greg Kroah-HartmanThis moves the "client_monitor_conn_id" and "server_monitor_conn_id" bus attributes to the dev_groups structure, removing the need for it to be in a temporary structure.
--- drivers/hv/channel.c | 14 ------------- drivers/hv/vmbus_drv.c | 55 ++++++++++++++++++++++++++++++++++---------------- include/linux/hyperv.h | 3 --- 3 files changed, 38 insertions(+), 34 deletions(-)
drivers/hv/channel.c +0 -14
@@ -65,20 +65,6 @@ static void vmbus_setevent(struct vmbus_channel *channel)void vmbus_get_debug_info (struct vmbus_channel *channel,struct vmbus_channel_debug_info *debuginfo) { -struct hv_monitor_page *monitorpage; -u8 monitor_group = (u8 )channel->offermsg.monitorid /32 ; -u8 monitor_offset = (u8 )channel->offermsg.monitorid %32 ; - - monitorpage = vmbus_connection.monitor_pages[0 ]; - debuginfo->servermonitor_connectionid = - monitorpage->parameter[monitor_group] - [monitor_offset].connectionid.u.id; - - monitorpage = vmbus_connection.monitor_pages[1 ]; - debuginfo->clientmonitor_connectionid = - monitorpage->parameter[monitor_group] - [monitor_offset].connectionid.u.id; -hv_ringbuffer_get_debuginfo (&channel->inbound, &debuginfo->inbound);hv_ringbuffer_get_debuginfo (&channel->outbound, &debuginfo->outbound); }
drivers/hv/vmbus_drv.c +38 -17
97 lines not on this page · raw message
include/linux/hyperv.h +0 -3
@@ -900,9 +900,6 @@ enum vmbus_channel_state { };struct vmbus_channel_debug_info { -u32 servermonitor_connectionid; -u32 clientmonitor_connectionid; -struct hv_ring_buffer_debug_info inbound;struct hv_ring_buffer_debug_info outbound; };
Signature · 1 line
1.8.4.3.gca3854a
PATCH 9/13 hv: move "client/server_monitor_latency" bus attributes to dev_groups
In reply to Greg Kroah-HartmanThis moves the "client_monitor_latency" and "server_monitor_latency" bus attributes to the dev_groups structure, removing the need for it to be in a temporary structure.
--- drivers/hv/channel.c | 4 ---- drivers/hv/vmbus_drv.c | 48 ++++++++++++++++++++++++++++++++++++++---------- include/linux/hyperv.h | 2 -- 3 files changed, 38 insertions(+), 16 deletions(-)
drivers/hv/channel.c +0 -4
@@ -70,15 +70,11 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,u8 monitor_offset = (u8 )channel->offermsg.monitorid %32 ; monitorpage = vmbus_connection.monitor_pages[0 ]; - debuginfo->servermonitor_latency = - monitorpage->latency[monitor_group][monitor_offset]; debuginfo->servermonitor_connectionid = monitorpage->parameter[monitor_group] [monitor_offset].connectionid.u.id; monitorpage = vmbus_connection.monitor_pages[1 ]; - debuginfo->clientmonitor_latency = - monitorpage->latency[monitor_group][monitor_offset]; debuginfo->clientmonitor_connectionid = monitorpage->parameter[monitor_group] [monitor_offset].connectionid.u.id;
drivers/hv/vmbus_drv.c +38 -10
98 lines not on this page · raw message
include/linux/hyperv.h +0 -2
@@ -900,9 +900,7 @@ enum vmbus_channel_state { };struct vmbus_channel_debug_info { -u32 servermonitor_latency;u32 servermonitor_connectionid; -u32 clientmonitor_latency;u32 clientmonitor_connectionid;struct hv_ring_buffer_debug_info inbound;
Signature · 1 line
1.8.4.3.gca3854a
PATCH 13/13 hv: move ringbuffer bus attributes to dev_groups
In reply to Greg Kroah-HartmanThis moves the ringbuffer bus attributes to the dev_groups structure, deletes the now unneeded struct hv_device_info, and removes some now unused functions, and variables as everything is now moved to the dev_groups structure, dev_attrs is no longer needed.
--- drivers/hv/vmbus_drv.c | 230 +++++++++++++++++++++++++++++++------------------ 1 file changed, 146 insertions(+), 84 deletions(-)
drivers/hv/vmbus_drv.c +146 -84
@@ -46,11 +46,6 @@ static struct tasklet_struct msg_dpc;static struct completion probe_event;static int irq; -struct hv_device_info { -struct hv_ring_buffer_debug_info inbound; -struct hv_ring_buffer_debug_info outbound; -}; -static int vmbus_exists (void ) {if (hv_acpi_dev ==NULL )
@@ -59,17 +54,6 @@ static int vmbus_exists(void)return 0 ; } - -static void get_channel_info (struct hv_device *device, -struct hv_device_info *info) -{ -if (!device->channel) -return ; - -hv_ringbuffer_get_debuginfo (&device->channel->inbound, &info->inbound); -hv_ringbuffer_get_debuginfo (&device->channel->outbound, &info->outbound); -} -#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2)static void print_alias_name (struct hv_device *hv_dev,char *alias_name) {
@@ -78,56 +62,6 @@ static void print_alias_name(struct hv_device *hv_dev, char *alias_name)sprintf (&alias_name[i],"%02x" , hv_dev->dev_type.b[i/2 ]); } -/* -* vmbus_show_device_attr - Show the device attribute in sysfs. -* -* This is invoked when user does a -* "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>" -*/ -static ssize_t vmbus_show_device_attr (struct device *dev, -struct device_attribute *dev_attr, -char *buf) -{ -struct hv_device *hv_dev =device_to_hv_device (dev); -struct hv_device_info *device_info; -int ret =0 ; - - device_info =kzalloc (sizeof (struct hv_device_info ),GFP_KERNEL ); -if (!device_info) -return ret; - -get_channel_info (hv_dev, device_info); - -if (!strcmp (dev_attr->attr.name,"out_intr_mask" )) { - ret =sprintf (buf,"%d\n" , device_info->outbound.current_interrupt_mask); - }else if (!strcmp (dev_attr->attr.name,"out_read_index" )) { - ret =sprintf (buf,"%d\n" , device_info->outbound.current_read_index); - }else if (!strcmp (dev_attr->attr.name,"out_write_index" )) { - ret =sprintf (buf,"%d\n" , device_info->outbound.current_write_index); - }else if (!strcmp (dev_attr->attr.name,"out_read_bytes_avail" )) { - ret =sprintf (buf,"%d\n" , - device_info->outbound.bytes_avail_toread); - }else if (!strcmp (dev_attr->attr.name,"out_write_bytes_avail" )) { - ret =sprintf (buf,"%d\n" , - device_info->outbound.bytes_avail_towrite); - }else if (!strcmp (dev_attr->attr.name,"in_intr_mask" )) { - ret =sprintf (buf,"%d\n" , device_info->inbound.current_interrupt_mask); - }else if (!strcmp (dev_attr->attr.name,"in_read_index" )) { - ret =sprintf (buf,"%d\n" , device_info->inbound.current_read_index); - }else if (!strcmp (dev_attr->attr.name,"in_write_index" )) { - ret =sprintf (buf,"%d\n" , device_info->inbound.current_write_index); - }else if (!strcmp (dev_attr->attr.name,"in_read_bytes_avail" )) { - ret =sprintf (buf,"%d\n" , - device_info->inbound.bytes_avail_toread); - }else if (!strcmp (dev_attr->attr.name,"in_write_bytes_avail" )) { - ret =sprintf (buf,"%d\n" , - device_info->inbound.bytes_avail_towrite); - } - -kfree (device_info); -return ret; -} -static u8 channel_monitor_group (struct vmbus_channel *channel) {return (u8 )channel->offermsg.monitorid /32 ;
@@ -313,6 +247,142 @@ static ssize_t client_monitor_conn_id_show(struct device *dev, }static DEVICE_ATTR_RO (client_monitor_conn_id); +static ssize_t out_intr_mask_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info outbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->outbound, &outbound); +return sprintf (buf,"%d\n" , outbound.current_interrupt_mask); +} +static DEVICE_ATTR_RO (out_intr_mask); + +static ssize_t out_read_index_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info outbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->outbound, &outbound); +return sprintf (buf,"%d\n" , outbound.current_read_index); +} +static DEVICE_ATTR_RO (out_read_index); + +static ssize_t out_write_index_show (struct device *dev, +struct device_attribute *dev_attr, +char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info outbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->outbound, &outbound); +return sprintf (buf,"%d\n" , outbound.current_write_index); +} +static DEVICE_ATTR_RO (out_write_index); + +static ssize_t out_read_bytes_avail_show (struct device *dev, +struct device_attribute *dev_attr, +char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info outbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->outbound, &outbound); +return sprintf (buf,"%d\n" , outbound.bytes_avail_toread); +} +static DEVICE_ATTR_RO (out_read_bytes_avail); + +static ssize_t out_write_bytes_avail_show (struct device *dev, +struct device_attribute *dev_attr, +char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info outbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->outbound, &outbound); +return sprintf (buf,"%d\n" , outbound.bytes_avail_towrite); +} +static DEVICE_ATTR_RO (out_write_bytes_avail); + +static ssize_t in_intr_mask_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info inbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->inbound, &inbound); +return sprintf (buf,"%d\n" , inbound.current_interrupt_mask); +} +static DEVICE_ATTR_RO (in_intr_mask); + +static ssize_t in_read_index_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info inbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->inbound, &inbound); +return sprintf (buf,"%d\n" , inbound.current_read_index); +} +static DEVICE_ATTR_RO (in_read_index); + +static ssize_t in_write_index_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info inbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->inbound, &inbound); +return sprintf (buf,"%d\n" , inbound.current_write_index); +} +static DEVICE_ATTR_RO (in_write_index); + +static ssize_t in_read_bytes_avail_show (struct device *dev, +struct device_attribute *dev_attr, +char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info inbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->inbound, &inbound); +return sprintf (buf,"%d\n" , inbound.bytes_avail_toread); +} +static DEVICE_ATTR_RO (in_read_bytes_avail); + +static ssize_t in_write_bytes_avail_show (struct device *dev, +struct device_attribute *dev_attr, +char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +struct hv_ring_buffer_debug_info inbound; + +if (!hv_dev->channel) +return -ENODEV ; +hv_ringbuffer_get_debuginfo (&hv_dev->channel->inbound, &inbound); +return sprintf (buf,"%d\n" , inbound.bytes_avail_towrite); +} +static DEVICE_ATTR_RO (in_write_bytes_avail); + +/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ static struct attribute *vmbus_attrs[] = { &dev_attr_id.attr, &dev_attr_state.attr,
@@ -326,27 +396,20 @@ static struct attribute *vmbus_attrs[] = { &dev_attr_client_monitor_latency.attr, &dev_attr_server_monitor_conn_id.attr, &dev_attr_client_monitor_conn_id.attr, + &dev_attr_out_intr_mask.attr, + &dev_attr_out_read_index.attr, + &dev_attr_out_write_index.attr, + &dev_attr_out_read_bytes_avail.attr, + &dev_attr_out_write_bytes_avail.attr, + &dev_attr_in_intr_mask.attr, + &dev_attr_in_read_index.attr, + &dev_attr_in_write_index.attr, + &dev_attr_in_read_bytes_avail.attr, + &dev_attr_in_write_bytes_avail.attr, NULL, };ATTRIBUTE_GROUPS (vmbus); -/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ -static struct device_attribute vmbus_device_attrs[] = { -__ATTR (out_intr_mask,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (out_read_index,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (out_write_index,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (out_read_bytes_avail,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (out_write_bytes_avail,S_IRUGO , vmbus_show_device_attr,NULL ), - -__ATTR (in_intr_mask,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (in_read_index,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (in_write_index,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (in_read_bytes_avail,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (in_write_bytes_avail,S_IRUGO , vmbus_show_device_attr,NULL ), - __ATTR_NULL -}; - -/* * vmbus_uevent - add uevent for our device *
@@ -494,7 +557,6 @@ static struct bus_type hv_bus = { .remove = vmbus_remove, .probe = vmbus_probe, .uevent = vmbus_uevent, - .dev_attrs = vmbus_device_attrs, .dev_groups = vmbus_groups, };
Signature · 1 line
1.8.4.3.gca3854a
PATCH 12/13 hv: delete struct hv_dev_port_info
In reply to Greg Kroah-HartmanIt's no longer needed, and the struct hv_ring_buffer_debug_info structure shouldn't be "global" so move it to the local .h file instead.
--- drivers/hv/hyperv_vmbus.h | 7 +++++++ drivers/hv/vmbus_drv.c | 35 ++++++++++------------------------- include/linux/hyperv.h | 17 ----------------- 3 files changed, 17 insertions(+), 42 deletions(-)
drivers/hv/hyperv_vmbus.h +7 -0
@@ -514,6 +514,13 @@ struct hv_context {extern struct hv_context hv_context; +struct hv_ring_buffer_debug_info { +u32 current_interrupt_mask; +u32 current_read_index; +u32 current_write_index; +u32 bytes_avail_toread; +u32 bytes_avail_towrite; +};/* Hv Interface */
drivers/hv/vmbus_drv.c +10 -25
@@ -47,8 +47,8 @@ static struct completion probe_event;static int irq;struct hv_device_info { -struct hv_dev_port_info inbound; -struct hv_dev_port_info outbound; +struct hv_ring_buffer_debug_info inbound; +struct hv_ring_buffer_debug_info outbound; };static int vmbus_exists (void )
@@ -63,26 +63,11 @@ static int vmbus_exists(void)static void get_channel_info (struct hv_device *device,struct hv_device_info *info) { -struct hv_ring_buffer_debug_info inbound; -struct hv_ring_buffer_debug_info outbound; -if (!device->channel)return ; -hv_ringbuffer_get_debuginfo (&device->channel->inbound, &inbound); -hv_ringbuffer_get_debuginfo (&device->channel->outbound, &outbound); - - info->inbound.int_mask = inbound.current_interrupt_mask; - info->inbound.read_idx = inbound.current_read_index; - info->inbound.write_idx = inbound.current_write_index; - info->inbound.bytes_avail_toread = inbound.bytes_avail_toread; - info->inbound.bytes_avail_towrite = inbound.bytes_avail_towrite; - - info->outbound.int_mask = outbound.current_interrupt_mask; - info->outbound.read_idx = outbound.current_read_index; - info->outbound.write_idx = outbound.current_write_index; - info->outbound.bytes_avail_toread = outbound.bytes_avail_toread; - info->outbound.bytes_avail_towrite = outbound.bytes_avail_towrite; +hv_ringbuffer_get_debuginfo (&device->channel->inbound, &info->inbound); +hv_ringbuffer_get_debuginfo (&device->channel->outbound, &info->outbound); }#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2)
@@ -114,11 +99,11 @@ static ssize_t vmbus_show_device_attr(struct device *dev,get_channel_info (hv_dev, device_info);if (!strcmp (dev_attr->attr.name,"out_intr_mask" )) { - ret =sprintf (buf,"%d\n" , device_info->outbound.int_mask); + ret =sprintf (buf,"%d\n" , device_info->outbound.current_interrupt_mask); }else if (!strcmp (dev_attr->attr.name,"out_read_index" )) { - ret =sprintf (buf,"%d\n" , device_info->outbound.read_idx); + ret =sprintf (buf,"%d\n" , device_info->outbound.current_read_index); }else if (!strcmp (dev_attr->attr.name,"out_write_index" )) { - ret =sprintf (buf,"%d\n" , device_info->outbound.write_idx); + ret =sprintf (buf,"%d\n" , device_info->outbound.current_write_index); }else if (!strcmp (dev_attr->attr.name,"out_read_bytes_avail" )) { ret =sprintf (buf,"%d\n" , device_info->outbound.bytes_avail_toread);
@@ -126,11 +111,11 @@ static ssize_t vmbus_show_device_attr(struct device *dev, ret =sprintf (buf,"%d\n" , device_info->outbound.bytes_avail_towrite); }else if (!strcmp (dev_attr->attr.name,"in_intr_mask" )) { - ret =sprintf (buf,"%d\n" , device_info->inbound.int_mask); + ret =sprintf (buf,"%d\n" , device_info->inbound.current_interrupt_mask); }else if (!strcmp (dev_attr->attr.name,"in_read_index" )) { - ret =sprintf (buf,"%d\n" , device_info->inbound.read_idx); + ret =sprintf (buf,"%d\n" , device_info->inbound.current_read_index); }else if (!strcmp (dev_attr->attr.name,"in_write_index" )) { - ret =sprintf (buf,"%d\n" , device_info->inbound.write_idx); + ret =sprintf (buf,"%d\n" , device_info->inbound.current_write_index); }else if (!strcmp (dev_attr->attr.name,"in_read_bytes_avail" )) { ret =sprintf (buf,"%d\n" , device_info->inbound.bytes_avail_toread);
include/linux/hyperv.h +0 -17
@@ -429,15 +429,6 @@ struct hv_ring_buffer_info {u32 ring_data_startoffset; }; -struct hv_ring_buffer_debug_info { -u32 current_interrupt_mask; -u32 current_read_index; -u32 current_write_index; -u32 bytes_avail_toread; -u32 bytes_avail_towrite; -}; - -/* * * hv_get_ringbuffer_availbytes()
@@ -1166,14 +1157,6 @@ extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,extern void vmbus_ontimer (unsigned long data); -struct hv_dev_port_info { -u32 int_mask; -u32 read_idx; -u32 write_idx; -u32 bytes_avail_toread; -u32 bytes_avail_towrite; -}; -/* Base driver object */ struct hv_driver {const char *name;
Signature · 1 line
1.8.4.3.gca3854a
PATCH 11/13 hv: delete vmbus_get_debug_info()
In reply to Greg Kroah-HartmanIt's only used once, only contains 2 function calls, so just make those calls directly, deleting the function, and the now unneeded structure entirely.
--- drivers/hv/channel.c | 10 ---------- drivers/hv/vmbus_drv.c | 35 ++++++++++++++++------------------- include/linux/hyperv.h | 8 -------- 3 files changed, 16 insertions(+), 37 deletions(-)
drivers/hv/channel.c +0 -10
@@ -60,16 +60,6 @@ static void vmbus_setevent(struct vmbus_channel *channel) }/* -* vmbus_get_debug_info -Retrieve various channel debug info -*/ -void vmbus_get_debug_info (struct vmbus_channel *channel, -struct vmbus_channel_debug_info *debuginfo) -{ -hv_ringbuffer_get_debuginfo (&channel->inbound, &debuginfo->inbound); -hv_ringbuffer_get_debuginfo (&channel->outbound, &debuginfo->outbound); -} - -/* * vmbus_open - Open the specified channel. */ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
drivers/hv/vmbus_drv.c +16 -19
@@ -63,29 +63,26 @@ static int vmbus_exists(void)static void get_channel_info (struct hv_device *device,struct hv_device_info *info) { -struct vmbus_channel_debug_info debug_info; +struct hv_ring_buffer_debug_info inbound; +struct hv_ring_buffer_debug_info outbound;if (!device->channel)return ; -vmbus_get_debug_info (device->channel, &debug_info); - - info->inbound.int_mask = debug_info.inbound.current_interrupt_mask; - info->inbound.read_idx = debug_info.inbound.current_read_index; - info->inbound.write_idx = debug_info.inbound.current_write_index; - info->inbound.bytes_avail_toread = - debug_info.inbound.bytes_avail_toread; - info->inbound.bytes_avail_towrite = - debug_info.inbound.bytes_avail_towrite; - - info->outbound.int_mask = - debug_info.outbound.current_interrupt_mask; - info->outbound.read_idx = debug_info.outbound.current_read_index; - info->outbound.write_idx = debug_info.outbound.current_write_index; - info->outbound.bytes_avail_toread = - debug_info.outbound.bytes_avail_toread; - info->outbound.bytes_avail_towrite = - debug_info.outbound.bytes_avail_towrite; +hv_ringbuffer_get_debuginfo (&device->channel->inbound, &inbound); +hv_ringbuffer_get_debuginfo (&device->channel->outbound, &outbound); + + info->inbound.int_mask = inbound.current_interrupt_mask; + info->inbound.read_idx = inbound.current_read_index; + info->inbound.write_idx = inbound.current_write_index; + info->inbound.bytes_avail_toread = inbound.bytes_avail_toread; + info->inbound.bytes_avail_towrite = inbound.bytes_avail_towrite; + + info->outbound.int_mask = outbound.current_interrupt_mask; + info->outbound.read_idx = outbound.current_read_index; + info->outbound.write_idx = outbound.current_write_index; + info->outbound.bytes_avail_toread = outbound.bytes_avail_toread; + info->outbound.bytes_avail_towrite = outbound.bytes_avail_towrite; }#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2)
include/linux/hyperv.h +0 -8
@@ -899,11 +899,6 @@ enum vmbus_channel_state { CHANNEL_OPENED_STATE, }; -struct vmbus_channel_debug_info { -struct hv_ring_buffer_debug_info inbound; -struct hv_ring_buffer_debug_info outbound; -}; -/* * Represents each channel msg on the vmbus connection This is a * variable-size data structure depending on the msg type itself
@@ -1169,9 +1164,6 @@ extern int vmbus_recvpacket_raw(struct vmbus_channel *channel, u64 *requestid); -extern void vmbus_get_debug_info (struct vmbus_channel *channel, -struct vmbus_channel_debug_info *debug); -extern void vmbus_ontimer (unsigned long data);struct hv_dev_port_info {
Signature · 1 line
1.8.4.3.gca3854a
PATCH 7/13 hv: make "monitor_pages" a "real" pointer array
In reply to Greg Kroah-Hartmanmonitor_pages was a void pointer, containing an unknown number of arrays that we just "knew" were a child and parent array of a specific size. Instead of that implicit knowledge, let's make them a real pointer, allowing us to have type safety, and a semblance of sane addressing schemes.
--- drivers/hv/channel.c | 10 ++++------ drivers/hv/connection.c | 21 ++++++++++----------- drivers/hv/hyperv_vmbus.h | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-)
drivers/hv/channel.c +4 -6
@@ -47,8 +47,8 @@ static void vmbus_setevent(struct vmbus_channel *channel) (unsigned long *) vmbus_connection.send_int_page + (channel->offermsg.child_relid >> 5)); - monitorpage = vmbus_connection.monitor_pages; - monitorpage++;/* Get the child to parent monitor page */ +/* Get the child to parent monitor page */ + monitorpage = vmbus_connection.monitor_pages[1 ];sync_set_bit (channel->monitor_bit, (unsigned long *)&monitorpage->trigger_group
@@ -69,8 +69,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,u8 monitor_group = (u8 )channel->offermsg.monitorid /32 ;u8 monitor_offset = (u8 )channel->offermsg.monitorid %32 ; - monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages; - + monitorpage = vmbus_connection.monitor_pages[0 ]; debuginfo->servermonitor_pending = monitorpage->trigger_group[monitor_group].pending; debuginfo->servermonitor_latency =
@@ -79,8 +78,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, monitorpage->parameter[monitor_group] [monitor_offset].connectionid.u.id; - monitorpage++; - + monitorpage = vmbus_connection.monitor_pages[1 ]; debuginfo->clientmonitor_pending = monitorpage->trigger_group[monitor_group].pending; debuginfo->clientmonitor_latency =
drivers/hv/connection.c +10 -11
@@ -76,10 +76,8 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, msg->header.msgtype =CHANNELMSG_INITIATE_CONTACT ; msg->vmbus_version_requested = version; msg->interrupt_page =virt_to_phys (vmbus_connection.int_page); - msg->monitor_page1 =virt_to_phys (vmbus_connection.monitor_pages); - msg->monitor_page2 =virt_to_phys ( - (void *)((unsigned long )vmbus_connection.monitor_pages + -PAGE_SIZE )); + msg->monitor_page1 =virt_to_phys (vmbus_connection.monitor_pages[0 ]); + msg->monitor_page2 =virt_to_phys (vmbus_connection.monitor_pages[1 ]);/* * Add to list before we send the request since we may
@@ -169,9 +167,10 @@ int vmbus_connect(void)* Setup the monitor notification facility. The 1st page for * parent->child and the 2nd page for child->parent */ - vmbus_connection.monitor_pages = - (void *)__get_free_pages ((GFP_KERNEL |__GFP_ZERO),1 ); -if (vmbus_connection.monitor_pages ==NULL ) { + vmbus_connection.monitor_pages[0 ] = (void *)__get_free_pages ((GFP_KERNEL |__GFP_ZERO),0 ); + vmbus_connection.monitor_pages[1 ] = (void *)__get_free_pages ((GFP_KERNEL |__GFP_ZERO),0 ); +if ((vmbus_connection.monitor_pages[0 ] ==NULL ) || + (vmbus_connection.monitor_pages[1 ] ==NULL )) { ret = -ENOMEM ; goto cleanup; }
@@ -229,10 +228,10 @@ cleanup: vmbus_connection.int_page =NULL ; } -if (vmbus_connection.monitor_pages) { -free_pages ((unsigned long )vmbus_connection.monitor_pages,1 ); - vmbus_connection.monitor_pages =NULL ; - } +free_pages ((unsigned long )vmbus_connection.monitor_pages[0 ],1 ); +free_pages ((unsigned long )vmbus_connection.monitor_pages[1 ],1 ); + vmbus_connection.monitor_pages[0 ] =NULL ; + vmbus_connection.monitor_pages[1 ] =NULL ;kfree (msginfo);
drivers/hv/hyperv_vmbus.h +1 -1
@@ -612,7 +612,7 @@ struct vmbus_connection {* 2 pages - 1st page for parent->child notification and 2nd * is child->parent notification */ -void *monitor_pages; +struct hv_monitor_page *monitor_pages[2 ];struct list_head chn_msg_list;spinlock_t channelmsg_lock;
Signature · 1 line
1.8.4.3.gca3854a
PATCH 6/13 hv: move "device_id" bus attribute to dev_groups
In reply to Greg Kroah-HartmanThis moves the "device_id" bus attribute to the dev_groups structure, removing the need for it to be in a temporary structure.
--- drivers/hv/channel.c | 4 ---- drivers/hv/vmbus_drv.c | 24 ++++++++++++++---------- include/linux/hyperv.h | 1 - 3 files changed, 14 insertions(+), 15 deletions(-)
drivers/hv/channel.c +0 -4
@@ -69,10 +69,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,u8 monitor_group = (u8 )channel->offermsg.monitorid /32 ;u8 monitor_offset = (u8 )channel->offermsg.monitorid %32 ; -memcpy (&debuginfo->interface_instance, - &channel->offermsg.offer.if_instance, -sizeof (uuid_le)); - monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages; debuginfo->servermonitor_pending =
drivers/hv/vmbus_drv.c +14 -10
@@ -47,8 +47,6 @@ static struct completion probe_event;static int irq;struct hv_device_info { -uuid_le chn_instance; -u32 server_monitor_pending;u32 server_monitor_latency;u32 server_monitor_conn_id;
@@ -79,9 +77,6 @@ static void get_channel_info(struct hv_device *device,vmbus_get_debug_info (device->channel, &debug_info); -memcpy (&info->chn_instance, &debug_info.interface_instance, -sizeof (uuid_le)); - info->server_monitor_pending = debug_info.servermonitor_pending; info->server_monitor_latency = debug_info.servermonitor_latency; info->server_monitor_conn_id = debug_info.servermonitor_connectionid;
@@ -136,9 +131,7 @@ static ssize_t vmbus_show_device_attr(struct device *dev,get_channel_info (hv_dev, device_info); -if (!strcmp (dev_attr->attr.name,"device_id" )) { - ret =sprintf (buf,"{%pUl}\n" , device_info->chn_instance.b); - }else if (!strcmp (dev_attr->attr.name,"out_intr_mask" )) { +if (!strcmp (dev_attr->attr.name,"out_intr_mask" )) { ret =sprintf (buf,"%d\n" , device_info->outbound.int_mask); }else if (!strcmp (dev_attr->attr.name,"out_read_index" )) { ret =sprintf (buf,"%d\n" , device_info->outbound.read_idx);
@@ -227,6 +220,18 @@ static ssize_t class_id_show(struct device *dev, }static DEVICE_ATTR_RO (class_id); +static ssize_t device_id_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); + +if (!hv_dev->channel) +return -ENODEV ; +return sprintf (buf,"{%pUl}\n" , + hv_dev->channel->offermsg.offer.if_instance.b); +} +static DEVICE_ATTR_RO (device_id); +static ssize_t modalias_show (struct device *dev,struct device_attribute *dev_attr,char *buf) {
@@ -244,6 +249,7 @@ static struct attribute *vmbus_attrs[] = { &dev_attr_state.attr, &dev_attr_monitor_id.attr, &dev_attr_class_id.attr, + &dev_attr_device_id.attr, &dev_attr_modalias.attr, NULL, };
@@ -251,8 +257,6 @@ ATTRIBUTE_GROUPS(vmbus);/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ static struct device_attribute vmbus_device_attrs[] = { -__ATTR (device_id,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (server_monitor_pending,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (server_monitor_latency,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (server_monitor_conn_id,S_IRUGO , vmbus_show_device_attr,NULL ),
include/linux/hyperv.h +0 -1
@@ -900,7 +900,6 @@ enum vmbus_channel_state { };struct vmbus_channel_debug_info { -uuid_le interface_instance;u32 servermonitor_pending;u32 servermonitor_latency;u32 servermonitor_connectionid;
Signature · 1 line
1.8.4.3.gca3854a
PATCH 5/13 hv: move "class_id" bus attribute to dev_groups
In reply to Greg Kroah-HartmanThis moves the "class_id" bus attribute to the dev_groups structure, removing the need for it to be in a temporary structure.
--- drivers/hv/channel.c | 2 -- drivers/hv/vmbus_drv.c | 22 +++++++++++++++------- include/linux/hyperv.h | 1 - 3 files changed, 15 insertions(+), 10 deletions(-)
drivers/hv/channel.c +0 -2
@@ -69,8 +69,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,u8 monitor_group = (u8 )channel->offermsg.monitorid /32 ;u8 monitor_offset = (u8 )channel->offermsg.monitorid %32 ; -memcpy (&debuginfo->interfacetype, - &channel->offermsg.offer.if_type,sizeof (uuid_le));memcpy (&debuginfo->interface_instance, &channel->offermsg.offer.if_instance,sizeof (uuid_le));
drivers/hv/vmbus_drv.c +15 -7
@@ -47,7 +47,6 @@ static struct completion probe_event;static int irq;struct hv_device_info { -uuid_le chn_type;uuid_le chn_instance;u32 server_monitor_pending;
@@ -80,8 +79,6 @@ static void get_channel_info(struct hv_device *device,vmbus_get_debug_info (device->channel, &debug_info); -memcpy (&info->chn_type, &debug_info.interfacetype, -sizeof (uuid_le));memcpy (&info->chn_instance, &debug_info.interface_instance,sizeof (uuid_le));
@@ -139,9 +136,7 @@ static ssize_t vmbus_show_device_attr(struct device *dev,get_channel_info (hv_dev, device_info); -if (!strcmp (dev_attr->attr.name,"class_id" )) { - ret =sprintf (buf,"{%pUl}\n" , device_info->chn_type.b); - }else if (!strcmp (dev_attr->attr.name,"device_id" )) { +if (!strcmp (dev_attr->attr.name,"device_id" )) { ret =sprintf (buf,"{%pUl}\n" , device_info->chn_instance.b); }else if (!strcmp (dev_attr->attr.name,"out_intr_mask" )) { ret =sprintf (buf,"%d\n" , device_info->outbound.int_mask);
@@ -220,6 +215,18 @@ static ssize_t monitor_id_show(struct device *dev, }static DEVICE_ATTR_RO (monitor_id); +static ssize_t class_id_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); + +if (!hv_dev->channel) +return -ENODEV ; +return sprintf (buf,"{%pUl}\n" , + hv_dev->channel->offermsg.offer.if_type.b); +} +static DEVICE_ATTR_RO (class_id); +static ssize_t modalias_show (struct device *dev,struct device_attribute *dev_attr,char *buf) {
@@ -231,10 +238,12 @@ static ssize_t modalias_show(struct device *dev, }static DEVICE_ATTR_RO (modalias); +static struct attribute *vmbus_attrs[] = { &dev_attr_id.attr, &dev_attr_state.attr, &dev_attr_monitor_id.attr, + &dev_attr_class_id.attr, &dev_attr_modalias.attr,NULL , };
@@ -242,7 +251,6 @@ ATTRIBUTE_GROUPS(vmbus);/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ static struct device_attribute vmbus_device_attrs[] = { -__ATTR (class_id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (device_id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (server_monitor_pending,S_IRUGO , vmbus_show_device_attr,NULL ),
include/linux/hyperv.h +0 -1
@@ -900,7 +900,6 @@ enum vmbus_channel_state { };struct vmbus_channel_debug_info { -uuid_le interfacetype;uuid_le interface_instance;u32 servermonitor_pending;u32 servermonitor_latency;
Signature · 1 line
1.8.4.3.gca3854a
PATCH 4/13 hv: move "modalias" bus attribute to dev_groups
In reply to Greg Kroah-HartmanThis moves the "state" bus attribute to the dev_groups structure.
--- drivers/hv/vmbus_drv.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/hv/vmbus_drv.c +12 -5
@@ -131,7 +131,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev, {struct hv_device *hv_dev =device_to_hv_device (dev);struct hv_device_info *device_info; -char alias_name[VMBUS_ALIAS_LEN +1 ];int ret =0 ; device_info =kzalloc (sizeof (struct hv_device_info ),GFP_KERNEL );
@@ -144,9 +143,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev, ret =sprintf (buf,"{%pUl}\n" , device_info->chn_type.b); }else if (!strcmp (dev_attr->attr.name,"device_id" )) { ret =sprintf (buf,"{%pUl}\n" , device_info->chn_instance.b); - }else if (!strcmp (dev_attr->attr.name,"modalias" )) { -print_alias_name (hv_dev, alias_name); - ret =sprintf (buf,"vmbus:%s\n" , alias_name); }else if (!strcmp (dev_attr->attr.name,"out_intr_mask" )) { ret =sprintf (buf,"%d\n" , device_info->outbound.int_mask); }else if (!strcmp (dev_attr->attr.name,"out_read_index" )) {
@@ -224,10 +220,22 @@ static ssize_t monitor_id_show(struct device *dev, }static DEVICE_ATTR_RO (monitor_id); +static ssize_t modalias_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); +char alias_name[VMBUS_ALIAS_LEN +1 ]; + +print_alias_name (hv_dev, alias_name); +return sprintf (buf,"vmbus:%s\n" , alias_name); +} +static DEVICE_ATTR_RO (modalias); +static struct attribute *vmbus_attrs[] = { &dev_attr_id.attr, &dev_attr_state.attr, &dev_attr_monitor_id.attr, + &dev_attr_modalias.attr,NULL , };ATTRIBUTE_GROUPS (vmbus);
@@ -236,7 +244,6 @@ ATTRIBUTE_GROUPS(vmbus);static struct device_attribute vmbus_device_attrs[] = {__ATTR (class_id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (device_id,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (modalias,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (server_monitor_pending,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (server_monitor_latency,S_IRUGO , vmbus_show_device_attr,NULL ),
Signature · 1 line
1.8.4.3.gca3854a
PATCH 3/13 hv: move "monitor_id" bus attribute to dev_groups
In reply to Greg Kroah-HartmanThis moves the "state" bus attribute to the dev_groups structure, removing the need for it to be in a temporary structure.
--- drivers/hv/channel.c | 2 -- drivers/hv/vmbus_drv.c | 18 ++++++++++++------ include/linux/hyperv.h | 1 - 3 files changed, 12 insertions(+), 9 deletions(-)
drivers/hv/channel.c +0 -2
@@ -77,8 +77,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages; - debuginfo->monitorid = channel->offermsg.monitorid; - debuginfo->servermonitor_pending = monitorpage->trigger_group[monitor_group].pending; debuginfo->servermonitor_latency =
drivers/hv/vmbus_drv.c +12 -6
@@ -50,7 +50,6 @@ struct hv_device_info {uuid_le chn_type;uuid_le chn_instance; -u32 monitor_id;u32 server_monitor_pending;u32 server_monitor_latency;u32 server_monitor_conn_id;
@@ -86,8 +85,6 @@ static void get_channel_info(struct hv_device *device,memcpy (&info->chn_instance, &debug_info.interface_instance,sizeof (uuid_le)); - info->monitor_id = debug_info.monitorid; - info->server_monitor_pending = debug_info.servermonitor_pending; info->server_monitor_latency = debug_info.servermonitor_latency; info->server_monitor_conn_id = debug_info.servermonitor_connectionid;
@@ -174,8 +171,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev, }else if (!strcmp (dev_attr->attr.name,"in_write_bytes_avail" )) { ret =sprintf (buf,"%d\n" , device_info->inbound.bytes_avail_towrite); - }else if (!strcmp (dev_attr->attr.name,"monitor_id" )) { - ret =sprintf (buf,"%d\n" , device_info->monitor_id); }else if (!strcmp (dev_attr->attr.name,"server_monitor_pending" )) { ret =sprintf (buf,"%d\n" , device_info->server_monitor_pending); }else if (!strcmp (dev_attr->attr.name,"server_monitor_latency" )) {
@@ -218,9 +213,21 @@ static ssize_t state_show(struct device *dev, struct device_attribute *dev_attr, }static DEVICE_ATTR_RO (state); +static ssize_t monitor_id_show (struct device *dev, +struct device_attribute *dev_attr,char *buf) +{ +struct hv_device *hv_dev =device_to_hv_device (dev); + +if (!hv_dev->channel) +return -ENODEV ; +return sprintf (buf,"%d\n" , hv_dev->channel->offermsg.monitorid); +} +static DEVICE_ATTR_RO (monitor_id); +static struct attribute *vmbus_attrs[] = { &dev_attr_id.attr, &dev_attr_state.attr, + &dev_attr_monitor_id.attr,NULL , };ATTRIBUTE_GROUPS (vmbus);
@@ -229,7 +236,6 @@ ATTRIBUTE_GROUPS(vmbus);static struct device_attribute vmbus_device_attrs[] = {__ATTR (class_id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (device_id,S_IRUGO , vmbus_show_device_attr,NULL ), -__ATTR (monitor_id,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (modalias,S_IRUGO , vmbus_show_device_attr,NULL ),__ATTR (server_monitor_pending,S_IRUGO , vmbus_show_device_attr,NULL ),
include/linux/hyperv.h +0 -1
@@ -902,7 +902,6 @@ enum vmbus_channel_state {struct vmbus_channel_debug_info {uuid_le interfacetype;uuid_le interface_instance; -u32 monitorid;u32 servermonitor_pending;u32 servermonitor_latency;u32 servermonitor_connectionid;
Signature · 1 line
1.8.4.3.gca3854a
Quoted 25 lines
-----Original Message-----
From: Greg Kroah-Hartman [mailto:[email protected]]
Sent: Friday, September 13, 2013 11:33 AM
To: KY Srinivasan; Haiyang Zhang
Cc: [email protected]; [email protected]
Subject: [PATCH 00/13] hv: clean updev_attrusageHi,
Here's a set of 13 patches to get rid of the
dev_attrsuse in the hv bus code, as it will be going away soon. It's _way_ bigger than all other conversions I've had to do so far in the kernel, as you were using a "multiplexor" function for all of these files.So, I've broken it up into individual show/store sysfs functions, and cleaned up a bunch of debug structures that aren't needed and shouldn't be exported to the rest of the kernel.
I've also fixed up some void * usage in the hv core, in patch 07, to make things simpler and not so "magic" when dealing with these pages. If you could review that one closely to ensure I didn't mess anything up, I would appreciate it.
Quoted 8 lines
Also, are all of these files really needed for sysfs? They seem to be all debugging stuff, shouldn't they go into debugfs if you really need/use them anymore?
KY, could you test these out? I don't have access to a hv system at the moment. I'll wait for your ack before applying them to any of my trees.
thanks,
Will do. Thank you.
K. Y
Quoted 2 lines
greg k-h
Quoted 25 lines
-----Original Message-----
From: Greg Kroah-Hartman [mailto:[email protected]]
Sent: Friday, September 13, 2013 11:33 AM
To: KY Srinivasan; Haiyang Zhang
Cc: [email protected]; [email protected]
Subject: [PATCH 00/13] hv: clean updev_attrusageHi,
Here's a set of 13 patches to get rid of the
dev_attrsuse in the hv bus code, as it will be going away soon. It's _way_ bigger than all other conversions I've had to do so far in the kernel, as you were using a "multiplexor" function for all of these files.So, I've broken it up into individual show/store sysfs functions, and cleaned up a bunch of debug structures that aren't needed and shouldn't be exported to the rest of the kernel.
I've also fixed up some void * usage in the hv core, in patch 07, to make things simpler and not so "magic" when dealing with these pages. If you could review that one closely to ensure I didn't mess anything up, I would appreciate it.
Quoted 6 lines
Also, are all of these files really needed for sysfs? They seem to be all debugging stuff, shouldn't they go into debugfs if you really need/use them anymore?
KY, could you test these out? I don't have access to a hv system at the moment. I'll wait for your ack before applying them to any of my trees.
The patches look good and I tested them. The guest comes up and is functional. I did notice though that the pending state appears to be a signed entity now which was not the the case before - I see a negative sign when I cat the client/server pending state.
Regards,
K. Y
Quoted 4 lines
thanks,
greg k-h
Quoted 29 lines · KY Srinivasan
Quoted 29 lines
-----Original Message-----
From: Greg Kroah-Hartman [mailto:[email protected]]
Sent: Friday, September 13, 2013 11:33 AM
To: KY Srinivasan; Haiyang Zhang
Cc: [email protected]; [email protected]
Subject: [PATCH 00/13] hv: clean updev_attrusageHi,
Here's a set of 13 patches to get rid of the
dev_attrsuse in the hv bus code, as it will be going away soon. It's _way_ bigger than all other conversions I've had to do so far in the kernel, as you were using a "multiplexor" function for all of these files.So, I've broken it up into individual show/store sysfs functions, and cleaned up a bunch of debug structures that aren't needed and shouldn't be exported to the rest of the kernel.
I've also fixed up some void * usage in the hv core, in patch 07, to make things simpler and not so "magic" when dealing with these pages. If you could review that one closely to ensure I didn't mess anything up, I would appreciate it.
Also, are all of these files really needed for sysfs? They seem to be all debugging stuff, shouldn't they go into debugfs if you really need/use them anymore?
Quoted 6 lines
Quoted 2 lines
KY, could you test these out? I don't have access to a hv system at the moment. I'll wait for your ack before applying them to any of my trees.
The patches look good and I tested them. The guest comes up and is functional. I did notice though that the pending state appears to be a signed entity now which was not the the case before - I see a negative sign when I cat the client/server pending state.
Which exact file is that? I didn't change the % modifiers for any of the data types, or at least I sure shouldn't have, if so, that's a bug on my side.
Thanks for testing, I'll queue these up, and if you can tell me which sysfs file is different, I'll verify the code conversion again, but I just reviewed it and can't seem to find anything.
thanks,
greg k-h
Greg,
I am currently travelling; when I get back I will take a look.
K. Y
Quoted 57 lines
-----Original Message-----
From: Greg Kroah-Hartman [mailto:[email protected]]
Sent: Thursday, September 26, 2013 9:00 AM
To: KY Srinivasan
Cc: Haiyang Zhang; [email protected]; [email protected]
Subject: Re: [PATCH 00/13] hv: clean updev_attrusageQuoted 29 lines · KY Srinivasan
Quoted 29 lines
-----Original Message-----
From: Greg Kroah-Hartman [mailto:[email protected]]
Sent: Friday, September 13, 2013 11:33 AM
To: KY Srinivasan; Haiyang Zhang
Cc: [email protected]; [email protected]
Subject: [PATCH 00/13] hv: clean updev_attrusageHi,
Here's a set of 13 patches to get rid of the
dev_attrsuse in the hv bus code, as it will be going away soon. It's _way_ bigger than all other conversions I've had to do so far in the kernel, as you were using a "multiplexor" function for all of these files.So, I've broken it up into individual show/store sysfs functions, and cleaned up a bunch of debug structures that aren't needed and shouldn't be exported to the rest of the kernel.
I've also fixed up some void * usage in the hv core, in patch 07, to make things simpler and not so "magic" when dealing with these pages. If you could review that one closely to ensure I didn't mess anything up, I would appreciate it.
Also, are all of these files really needed for sysfs? They seem to be all debugging stuff, shouldn't they go into debugfs if you really need/use them anymore?
Quoted 5 lines
Quoted 2 lines
KY, could you test these out? I don't have access to a hv system at the moment. I'll wait for your ack before applying them to any of my trees.
The patches look good and I tested them. The guest comes up and is functional. I did notice though that the pending state appears to be a signed entity now
which was not the
Quoted 1 line
the case before - I see a negative sign when I cat the client/server pending
state.
Which exact file is that? I didn't change the % modifiers for any of the data types, or at least I sure shouldn't have, if so, that's a bug on my side.
Thanks for testing, I'll queue these up, and if you can tell me which sysfs file is different, I'll verify the code conversion again, but I just reviewed it and can't seem to find anything.
thanks,
greg k-h