| @@ -1410,7 +1410,7 @@ static void vmbus_chan_release(struct kobject *kobj) · 1409 unmodified lines |
| 1410 | | 1410 | |
| 1411 | struct vmbus_chan_attribute { | 1411 | struct vmbus_chan_attribute { |
| 1412 | struct attribute attr; | 1412 | struct attribute attr; |
| 1413 | ssize_t (*show)(const struct vmbus_channel *chan, char *buf); | 1413 | ssize_t (*show)(struct vmbus_channel *chan, char *buf); |
| 1414 | ssize_t (*store)(struct vmbus_channel *chan, | 1414 | ssize_t (*store)(struct vmbus_channel *chan, |
| 1415 | const char *buf, size_t count); | 1415 | const char *buf, size_t count); |
| 1416 | }; | 1416 | }; |
| @@ -1429,7 +1429,7 @@ static ssize_t vmbus_chan_attr_show(struct kobject *kobj, · 12 unmodified lines |
| 1429 | { | 1429 | { |
| 1430 | const struct vmbus_chan_attribute *attribute | 1430 | const struct vmbus_chan_attribute *attribute |
| 1431 | = container_of(attr, struct vmbus_chan_attribute, attr); | 1431 | = container_of(attr, struct vmbus_chan_attribute, attr); |
| 1432 | const struct vmbus_channel *chan | 1432 | struct vmbus_channel *chan |
| 1433 | = container_of(kobj, struct vmbus_channel, kobj); | 1433 | = container_of(kobj, struct vmbus_channel, kobj); |
| 1434 | | 1434 | |
| 1435 | if (!attribute->show) | 1435 | if (!attribute->show) |
| @@ -1442,57 +1442,81 @@ static const struct sysfs_ops vmbus_chan_sysfs_ops = { · 6 unmodified lines |
| 1442 | .show = vmbus_chan_attr_show, | 1442 | .show = vmbus_chan_attr_show, |
| 1443 | }; | 1443 | }; |
| 1444 | | 1444 | |
| 1445 | static ssize_t out_mask_show(const struct vmbus_channel *channel, char *buf) | 1445 | static ssize_t out_mask_show(struct vmbus_channel *channel, char *buf) |
| 1446 | { | 1446 | { |
| 1447 | const struct hv_ring_buffer_info *rbi = &channel->outbound; | 1447 | struct hv_ring_buffer_info *rbi = &channel->outbound; |
| | 1448 | ssize_t ret; |
| 1448 | | 1449 | |
| 1449 | if (!rbi->ring_buffer) | 1450 | mutex_lock(&rbi->ring_buffer_mutex); |
| | 1451 | if (!rbi->ring_buffer) { |
| | 1452 | mutex_unlock(&rbi->ring_buffer_mutex); |
| 1450 | return -EINVAL; | 1453 | return -EINVAL; |
| | 1454 | } |
| 1451 | | 1455 | |
| 1452 | return sprintf(buf, "%u\n", rbi->ring_buffer->interrupt_mask); | 1456 | ret = sprintf(buf, "%u\n", rbi->ring_buffer->interrupt_mask); |
| | 1457 | mutex_unlock(&rbi->ring_buffer_mutex); |
| | 1458 | return ret; |
| 1453 | } | 1459 | } |
| 1454 | static VMBUS_CHAN_ATTR_RO(out_mask); | 1460 | static VMBUS_CHAN_ATTR_RO(out_mask); |
| 1455 | | 1461 | |
| 1456 | static ssize_t in_mask_show(const struct vmbus_channel *channel, char *buf) | 1462 | static ssize_t in_mask_show(struct vmbus_channel *channel, char *buf) |
| 1457 | { | 1463 | { |
| 1458 | const struct hv_ring_buffer_info *rbi = &channel->inbound; | 1464 | struct hv_ring_buffer_info *rbi = &channel->inbound; |
| | 1465 | ssize_t ret; |
| 1459 | | 1466 | |
| 1460 | if (!rbi->ring_buffer) | 1467 | mutex_lock(&rbi->ring_buffer_mutex); |
| | 1468 | if (!rbi->ring_buffer) { |
| | 1469 | mutex_unlock(&rbi->ring_buffer_mutex); |
| 1461 | return -EINVAL; | 1470 | return -EINVAL; |
| | 1471 | } |
| 1462 | | 1472 | |
| 1463 | return sprintf(buf, "%u\n", rbi->ring_buffer->interrupt_mask); | 1473 | ret = sprintf(buf, "%u\n", rbi->ring_buffer->interrupt_mask); |
| | 1474 | mutex_unlock(&rbi->ring_buffer_mutex); |
| | 1475 | return ret; |
| 1464 | } | 1476 | } |
| 1465 | static VMBUS_CHAN_ATTR_RO(in_mask); | 1477 | static VMBUS_CHAN_ATTR_RO(in_mask); |
| 1466 | | 1478 | |
| 1467 | static ssize_t read_avail_show(const struct vmbus_channel *channel, char *buf) | 1479 | static ssize_t read_avail_show(struct vmbus_channel *channel, char *buf) |
| 1468 | { | 1480 | { |
| 1469 | const struct hv_ring_buffer_info *rbi = &channel->inbound; | 1481 | struct hv_ring_buffer_info *rbi = &channel->inbound; |
| | 1482 | ssize_t ret; |
| 1470 | | 1483 | |
| 1471 | if (!rbi->ring_buffer) | 1484 | mutex_lock(&rbi->ring_buffer_mutex); |
| | 1485 | if (!rbi->ring_buffer) { |
| | 1486 | mutex_unlock(&rbi->ring_buffer_mutex); |
| 1472 | return -EINVAL; | 1487 | return -EINVAL; |
| | 1488 | } |
| 1473 | | 1489 | |
| 1474 | return sprintf(buf, "%u\n", hv_get_bytes_to_read(rbi)); | 1490 | ret = sprintf(buf, "%u\n", hv_get_bytes_to_read(rbi)); |
| | 1491 | mutex_unlock(&rbi->ring_buffer_mutex); |
| | 1492 | return ret; |
| 1475 | } | 1493 | } |
| 1476 | static VMBUS_CHAN_ATTR_RO(read_avail); | 1494 | static VMBUS_CHAN_ATTR_RO(read_avail); |
| 1477 | | 1495 | |
| 1478 | static ssize_t write_avail_show(const struct vmbus_channel *channel, char *buf) | 1496 | static ssize_t write_avail_show(struct vmbus_channel *channel, char *buf) |
| 1479 | { | 1497 | { |
| 1480 | const struct hv_ring_buffer_info *rbi = &channel->outbound; | 1498 | struct hv_ring_buffer_info *rbi = &channel->outbound; |
| | 1499 | ssize_t ret; |
| 1481 | | 1500 | |
| 1482 | if (!rbi->ring_buffer) | 1501 | mutex_lock(&rbi->ring_buffer_mutex); |
| | 1502 | if (!rbi->ring_buffer) { |
| | 1503 | mutex_unlock(&rbi->ring_buffer_mutex); |
| 1483 | return -EINVAL; | 1504 | return -EINVAL; |
| | 1505 | } |
| 1484 | | 1506 | |
| 1485 | return sprintf(buf, "%u\n", hv_get_bytes_to_write(rbi)); | 1507 | ret = sprintf(buf, "%u\n", hv_get_bytes_to_write(rbi)); |
| | 1508 | mutex_unlock(&rbi->ring_buffer_mutex); |
| | 1509 | return ret; |
| 1486 | } | 1510 | } |
| 1487 | static VMBUS_CHAN_ATTR_RO(write_avail); | 1511 | static VMBUS_CHAN_ATTR_RO(write_avail); |
| 1488 | | 1512 | |
| 1489 | static ssize_t show_target_cpu(const struct vmbus_channel *channel, char *buf) | 1513 | static ssize_t show_target_cpu(struct vmbus_channel *channel, char *buf) |
| 1490 | { | 1514 | { |
| 1491 | return sprintf(buf, "%u\n", channel->target_cpu); | 1515 | return sprintf(buf, "%u\n", channel->target_cpu); |
| 1492 | } | 1516 | } |
| 1493 | static VMBUS_CHAN_ATTR(cpu, S_IRUGO, show_target_cpu, NULL); | 1517 | static VMBUS_CHAN_ATTR(cpu, S_IRUGO, show_target_cpu, NULL); |
| 1494 | | 1518 | |
| 1495 | static ssize_t channel_pending_show(const struct vmbus_channel *channel, | 1519 | static ssize_t channel_pending_show(struct vmbus_channel *channel, |
| 1496 | char *buf) | 1520 | char *buf) |
| 1497 | { | 1521 | { |
| 1498 | return sprintf(buf, "%d\n", | 1522 | return sprintf(buf, "%d\n", |
| @@ -1501,7 +1525,7 @@ static ssize_t channel_pending_show(const struct vmbus_channel *channel, · 2 unmodified lines |
| 1501 | } | 1525 | } |
| 1502 | static VMBUS_CHAN_ATTR(pending, S_IRUGO, channel_pending_show, NULL); | 1526 | static VMBUS_CHAN_ATTR(pending, S_IRUGO, channel_pending_show, NULL); |
| 1503 | | 1527 | |
| 1504 | static ssize_t channel_latency_show(const struct vmbus_channel *channel, | 1528 | static ssize_t channel_latency_show(struct vmbus_channel *channel, |
| 1505 | char *buf) | 1529 | char *buf) |
| 1506 | { | 1530 | { |
| 1507 | return sprintf(buf, "%d\n", | 1531 | return sprintf(buf, "%d\n", |
| @@ -1510,19 +1534,19 @@ static ssize_t channel_latency_show(const struct vmbus_channel *channel, · 2 unmodified lines |
| 1510 | } | 1534 | } |
| 1511 | static VMBUS_CHAN_ATTR(latency, S_IRUGO, channel_latency_show, NULL); | 1535 | static VMBUS_CHAN_ATTR(latency, S_IRUGO, channel_latency_show, NULL); |
| 1512 | | 1536 | |
| 1513 | static ssize_t channel_interrupts_show(const struct vmbus_channel *channel, char *buf) | 1537 | static ssize_t channel_interrupts_show(struct vmbus_channel *channel, char *buf) |
| 1514 | { | 1538 | { |
| 1515 | return sprintf(buf, "%llu\n", channel->interrupts); | 1539 | return sprintf(buf, "%llu\n", channel->interrupts); |
| 1516 | } | 1540 | } |
| 1517 | static VMBUS_CHAN_ATTR(interrupts, S_IRUGO, channel_interrupts_show, NULL); | 1541 | static VMBUS_CHAN_ATTR(interrupts, S_IRUGO, channel_interrupts_show, NULL); |
| 1518 | | 1542 | |
| 1519 | static ssize_t channel_events_show(const struct vmbus_channel *channel, char *buf) | 1543 | static ssize_t channel_events_show(struct vmbus_channel *channel, char *buf) |
| 1520 | { | 1544 | { |
| 1521 | return sprintf(buf, "%llu\n", channel->sig_events); | 1545 | return sprintf(buf, "%llu\n", channel->sig_events); |
| 1522 | } | 1546 | } |
| 1523 | static VMBUS_CHAN_ATTR(events, S_IRUGO, channel_events_show, NULL); | 1547 | static VMBUS_CHAN_ATTR(events, S_IRUGO, channel_events_show, NULL); |
| 1524 | | 1548 | |
| 1525 | static ssize_t channel_intr_in_full_show(const struct vmbus_channel *channel, | 1549 | static ssize_t channel_intr_in_full_show(struct vmbus_channel *channel, |
| 1526 | char *buf) | 1550 | char *buf) |
| 1527 | { | 1551 | { |
| 1528 | return sprintf(buf, "%llu\n", | 1552 | return sprintf(buf, "%llu\n", |
| @@ -1530,7 +1554,7 @@ static ssize_t channel_intr_in_full_show(const struct vmbus_channel *channel, · 1 unmodified line |
| 1530 | } | 1554 | } |
| 1531 | static VMBUS_CHAN_ATTR(intr_in_full, 0444, channel_intr_in_full_show, NULL); | 1555 | static VMBUS_CHAN_ATTR(intr_in_full, 0444, channel_intr_in_full_show, NULL); |
| 1532 | | 1556 | |
| 1533 | static ssize_t channel_intr_out_empty_show(const struct vmbus_channel *channel, | 1557 | static ssize_t channel_intr_out_empty_show(struct vmbus_channel *channel, |
| 1534 | char *buf) | 1558 | char *buf) |
| 1535 | { | 1559 | { |
| 1536 | return sprintf(buf, "%llu\n", | 1560 | return sprintf(buf, "%llu\n", |
| @@ -1538,7 +1562,7 @@ static ssize_t channel_intr_out_empty_show(const struct vmbus_channel *channel, · 1 unmodified line |
| 1538 | } | 1562 | } |
| 1539 | static VMBUS_CHAN_ATTR(intr_out_empty, 0444, channel_intr_out_empty_show, NULL); | 1563 | static VMBUS_CHAN_ATTR(intr_out_empty, 0444, channel_intr_out_empty_show, NULL); |
| 1540 | | 1564 | |
| 1541 | static ssize_t channel_out_full_first_show(const struct vmbus_channel *channel, | 1565 | static ssize_t channel_out_full_first_show(struct vmbus_channel *channel, |
| 1542 | char *buf) | 1566 | char *buf) |
| 1543 | { | 1567 | { |
| 1544 | return sprintf(buf, "%llu\n", | 1568 | return sprintf(buf, "%llu\n", |
| @@ -1546,7 +1570,7 @@ static ssize_t channel_out_full_first_show(const struct vmbus_channel *channel, · 1 unmodified line |
| 1546 | } | 1570 | } |
| 1547 | static VMBUS_CHAN_ATTR(out_full_first, 0444, channel_out_full_first_show, NULL); | 1571 | static VMBUS_CHAN_ATTR(out_full_first, 0444, channel_out_full_first_show, NULL); |
| 1548 | | 1572 | |
| 1549 | static ssize_t channel_out_full_total_show(const struct vmbus_channel *channel, | 1573 | static ssize_t channel_out_full_total_show(struct vmbus_channel *channel, |
| 1550 | char *buf) | 1574 | char *buf) |
| 1551 | { | 1575 | { |
| 1552 | return sprintf(buf, "%llu\n", | 1576 | return sprintf(buf, "%llu\n", |
| @@ -1554,14 +1578,14 @@ static ssize_t channel_out_full_total_show(const struct vmbus_channel *channel, · 1 unmodified line |
| 1554 | } | 1578 | } |
| 1555 | static VMBUS_CHAN_ATTR(out_full_total, 0444, channel_out_full_total_show, NULL); | 1579 | static VMBUS_CHAN_ATTR(out_full_total, 0444, channel_out_full_total_show, NULL); |
| 1556 | | 1580 | |
| 1557 | static ssize_t subchannel_monitor_id_show(const struct vmbus_channel *channel, | 1581 | static ssize_t subchannel_monitor_id_show(struct vmbus_channel *channel, |
| 1558 | char *buf) | 1582 | char *buf) |
| 1559 | { | 1583 | { |
| 1560 | return sprintf(buf, "%u\n", channel->offermsg.monitorid); | 1584 | return sprintf(buf, "%u\n", channel->offermsg.monitorid); |
| 1561 | } | 1585 | } |
| 1562 | static VMBUS_CHAN_ATTR(monitor_id, S_IRUGO, subchannel_monitor_id_show, NULL); | 1586 | static VMBUS_CHAN_ATTR(monitor_id, S_IRUGO, subchannel_monitor_id_show, NULL); |
| 1563 | | 1587 | |
| 1564 | static ssize_t subchannel_id_show(const struct vmbus_channel *channel, | 1588 | static ssize_t subchannel_id_show(struct vmbus_channel *channel, |
| 1565 | char *buf) | 1589 | char *buf) |
| 1566 | { | 1590 | { |
| 1567 | return sprintf(buf, "%u\n", | 1591 | return sprintf(buf, "%u\n", |