public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: mhkelley58@gmail.com
To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com,
	robh@kernel.org, bhelgaas@google.com,
	James.Bottomley@HansenPartnership.com,
	martin.petersen@oracle.com, arnd@arndb.de,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-arch@vger.kernel.org
Cc: maz@kernel.org, den@valinux.co.jp, jgowans@amazon.com,
	dawei.li@shingroup.cn
Subject: [RFC 03/12] Drivers: hv: vmbus: Add an IRQ name to VMBus channels
Date: Mon,  3 Jun 2024 22:09:31 -0700	[thread overview]
Message-ID: <20240604050940.859909-4-mhklinux@outlook.com> (raw)
In-Reply-To: <20240604050940.859909-1-mhklinux@outlook.com>

From: Michael Kelley <mhklinux@outlook.com>

In preparation for assigning Linux IRQs to VMBus channels, assign a
string name to each channel. The name is used when the IRQ is
requested, and it will appear in the output of /proc/interrupts to
make it easier to identify the device the IRQ is associated with.

Many VMBus devices are single-instance, with a single channel. For
such devices, a default string name can be determined based on the
GUID identifying the device. So add default names to the vmbus_devs
table that lists recognized devices. When a channel is created, set
the channel name to that default so a reasonable name is displayed
without requiring VMBus driver modifications.

However, individual VMBus device drivers may be optionally modified
to override the default name to provide additional information. In
cases where a driver supports multiple instances of a device, or a
device has multiple channels, the additional information may be
helpful to display in /proc/interrupts.

Signed-off-by: Michael Kelley <mhklinux@outlook.com>
---
 drivers/hv/channel_mgmt.c | 45 +++++++++++++++++++++++++++++++--------
 include/linux/hyperv.h    |  5 +++++
 2 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index a216a0aede73..adbe184e5197 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/cpu.h>
 #include <linux/hyperv.h>
+#include <linux/string.h>
 #include <asm/mshyperv.h>
 #include <linux/sched/isolation.h>
 
@@ -33,6 +34,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_IDE_GUID,
 	  .perf_device = true,
 	  .allowed_in_isolated = false,
+	  .irq_name = "storvsc",
 	},
 
 	/* SCSI */
@@ -40,6 +42,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_SCSI_GUID,
 	  .perf_device = true,
 	  .allowed_in_isolated = true,
+	  .irq_name = "storvsc",
 	},
 
 	/* Fibre Channel */
@@ -47,6 +50,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_SYNTHFC_GUID,
 	  .perf_device = true,
 	  .allowed_in_isolated = false,
+	  .irq_name = "storvsc",
 	},
 
 	/* Synthetic NIC */
@@ -54,6 +58,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_NIC_GUID,
 	  .perf_device = true,
 	  .allowed_in_isolated = true,
+	  .irq_name = "netvsc",
 	},
 
 	/* Network Direct */
@@ -61,6 +66,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_ND_GUID,
 	  .perf_device = true,
 	  .allowed_in_isolated = false,
+	  .irq_name = "netdirect",
 	},
 
 	/* PCIE */
@@ -68,6 +74,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_PCIE_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = true,
+	  .irq_name = "vpci",
 	},
 
 	/* Synthetic Frame Buffer */
@@ -75,6 +82,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_SYNTHVID_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = false,
+	  .irq_name = "framebuffer",
 	},
 
 	/* Synthetic Keyboard */
@@ -82,6 +90,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_KBD_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = false,
+	  .irq_name = "keyboard",
 	},
 
 	/* Synthetic MOUSE */
@@ -89,6 +98,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_MOUSE_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = false,
+	  .irq_name = "mouse",
 	},
 
 	/* KVP */
@@ -96,6 +106,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_KVP_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = false,
+	  .irq_name = "kvp",
 	},
 
 	/* Time Synch */
@@ -103,6 +114,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_TS_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = true,
+	  .irq_name = "timesync",
 	},
 
 	/* Heartbeat */
@@ -110,6 +122,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_HEART_BEAT_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = true,
+	  .irq_name = "heartbeat",
 	},
 
 	/* Shutdown */
@@ -117,6 +130,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_SHUTDOWN_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = true,
+	  .irq_name = "shutdown",
 	},
 
 	/* File copy */
@@ -126,6 +140,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_FCOPY_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = false,
+	  .irq_name = "fcopy",
 	},
 
 	/* Backup */
@@ -133,6 +148,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_VSS_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = false,
+	  .irq_name = "vss",
 	},
 
 	/* Dynamic Memory */
@@ -140,6 +156,7 @@ const struct vmbus_device vmbus_devs[] = {
 	  HV_DM_GUID,
 	  .perf_device = false,
 	  .allowed_in_isolated = false,
+	  .irq_name = "balloon",
 	},
 
 	/*
@@ -198,20 +215,30 @@ static bool is_unsupported_vmbus_devs(const guid_t *guid)
 	return false;
 }
 
-static u16 hv_get_dev_type(const struct vmbus_channel *channel)
+static void hv_set_dev_type_and_irq_name(struct vmbus_channel *channel)
 {
 	const guid_t *guid = &channel->offermsg.offer.if_type;
+	char *name = NULL;
 	u16 i;
 
-	if (is_hvsock_channel(channel))
-		return HV_UNKNOWN;
-
-	for (i = HV_IDE; i < HV_UNKNOWN; i++) {
-		if (guid_equal(guid, &vmbus_devs[i].guid))
-			return i;
+	if (is_hvsock_channel(channel)) {
+		i = HV_UNKNOWN;
+		name = "hv_sock";
+		goto found;
 	}
+
+	for (i = HV_IDE; i < HV_UNKNOWN; i++)
+		if (guid_equal(guid, &vmbus_devs[i].guid)) {
+			name = vmbus_devs[i].irq_name;
+			goto found;
+		}
+
 	pr_info("Unknown GUID: %pUl\n", guid);
-	return i;
+
+found:
+	channel->device_id =  i;
+	if (name)
+		strscpy(channel->irq_name, name, VMBUS_CHAN_IRQ_NAME_MAX);
 }
 
 /**
@@ -970,7 +997,7 @@ static void vmbus_setup_channel_state(struct vmbus_channel *channel,
 	       sizeof(struct vmbus_channel_offer_channel));
 	channel->monitor_grp = (u8)offer->monitorid / 32;
 	channel->monitor_bit = (u8)offer->monitorid % 32;
-	channel->device_id = hv_get_dev_type(channel);
+	hv_set_dev_type_and_irq_name(channel);
 }
 
 /*
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index d52c916cc492..897d96fa19d4 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -826,6 +826,7 @@ struct vmbus_device {
 	guid_t guid;
 	bool perf_device;
 	bool allowed_in_isolated;
+	char *irq_name;
 };
 
 #define VMBUS_DEFAULT_MAX_PKT_SIZE 4096
@@ -837,6 +838,8 @@ struct vmbus_gpadl {
 	bool decrypted;
 };
 
+#define VMBUS_CHAN_IRQ_NAME_MAX 32
+
 struct vmbus_channel {
 	struct list_head listentry;
 
@@ -1068,6 +1071,8 @@ struct vmbus_channel {
 
 	/* The max size of a packet on this channel */
 	u32 max_pkt_size;
+
+	char irq_name[VMBUS_CHAN_IRQ_NAME_MAX];
 };
 
 #define lock_requestor(channel, flags)					\
-- 
2.25.1


  parent reply	other threads:[~2024-06-04  5:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  5:09 [RFC 00/12] Hyper-V guests use Linux IRQs for channel interrupts mhkelley58
2024-06-04  5:09 ` [RFC 01/12] Drivers: hv: vmbus: Drop unsupported VMBus devices earlier mhkelley58
2024-06-24  7:11   ` Wei Liu
2024-06-04  5:09 ` [RFC 02/12] Drivers: hv: vmbus: Fix error path that deletes non-existent sysfs group mhkelley58
2024-06-04  5:09 ` mhkelley58 [this message]
2024-06-04  5:09 ` [RFC 04/12] PCI: hv: Annotate the VMBus channel IRQ name mhkelley58
2024-09-20 23:13   ` Bjorn Helgaas
2024-06-04  5:09 ` [RFC 05/12] scsi: storvsc: " mhkelley58
2024-06-04  5:09 ` [RFC 06/12] genirq: Add per-cpu flow handler with conditional IRQ stats mhkelley58
2024-06-04 18:13   ` Thomas Gleixner
2024-06-04 23:03     ` Michael Kelley
2024-06-05 13:20       ` Thomas Gleixner
2024-06-05 13:45         ` Michael Kelley
2024-06-05 14:19           ` Thomas Gleixner
2024-06-06  3:14             ` Michael Kelley
2024-06-06  9:34               ` Thomas Gleixner
2024-06-06 14:34                 ` Michael Kelley
2024-06-04  5:09 ` [RFC 07/12] Drivers: hv: vmbus: Set up irqdomain and irqchip for the VMBus connection mhkelley58
2024-06-04  5:09 ` [RFC 08/12] Drivers: hv: vmbus: Allocate an IRQ per channel and use for relid mapping mhkelley58
2024-06-04  5:09 ` [RFC 09/12] Drivers: hv: vmbus: Use Linux IRQs to handle VMBus channel interrupts mhkelley58
2024-06-04  5:09 ` [RFC 10/12] Drivers: hv: vmbus: Implement vmbus_irq_set_affinity mhkelley58
2024-06-04  5:09 ` [RFC 11/12] Drivers: hv: vmbus: Wait for MODIFYCHANNEL to finish when offlining CPUs mhkelley58
2024-06-24 17:55   ` Boqun Feng
2024-06-24 19:32     ` Michael Kelley
2024-06-04  5:09 ` [RFC 12/12] Drivers: hv: vmbus: Ensure IRQ affinity isn't set to a CPU going offline mhkelley58
2024-09-16 18:15 ` [RFC 00/12] Hyper-V guests use Linux IRQs for channel interrupts Michael Kelley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240604050940.859909-4-mhklinux@outlook.com \
    --to=mhkelley58@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dawei.li@shingroup.cn \
    --cc=decui@microsoft.com \
    --cc=den@valinux.co.jp \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=jgowans@amazon.com \
    --cc=kw@linux.com \
    --cc=kys@microsoft.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=maz@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=mingo@redhat.com \
    --cc=robh@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wei.liu@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox