linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] PCI: hv: Support for create interrupt v3
@ 2021-07-08 23:04 Sunil Muthuswamy
  2021-07-09 10:24 ` Wei Liu
  2021-07-12 19:07 ` Michael Kelley
  0 siblings, 2 replies; 6+ messages in thread
From: Sunil Muthuswamy @ 2021-07-08 23:04 UTC (permalink / raw)
  To: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
	Dexuan Cui, Michael Kelley
  Cc: linux-hyperv, linux-pci, linux-kernel, Lorenzo Pieralisi,
	Rob Herring, Bjorn Helgaas

Hyper-V vPCI protocol version 1_4 adds support for create interrupt
v3. Create interrupt v3 essentially makes the size of the vector
field bigger in the message, thereby allowing bigger vector values.
For example, that will come into play for supporting LPI vectors
on ARM, which start at 8192.

Signed-off-by: Sunil Muthuswamy <sunilmut@microsoft.com>
---
 drivers/pci/controller/pci-hyperv.c | 74 ++++++++++++++++++++++++++---
 1 file changed, 68 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index bebe3eeebc4e..de61b20f9604 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -64,6 +64,7 @@ enum pci_protocol_version_t {
 	PCI_PROTOCOL_VERSION_1_1 = PCI_MAKE_VERSION(1, 1),	/* Win10 */
 	PCI_PROTOCOL_VERSION_1_2 = PCI_MAKE_VERSION(1, 2),	/* RS1 */
 	PCI_PROTOCOL_VERSION_1_3 = PCI_MAKE_VERSION(1, 3),	/* Vibranium */
+	PCI_PROTOCOL_VERSION_1_4 = PCI_MAKE_VERSION(1, 4),      /* Fe */
 };
 
 #define CPU_AFFINITY_ALL	-1ULL
@@ -73,6 +74,7 @@ enum pci_protocol_version_t {
  * first.
  */
 static enum pci_protocol_version_t pci_protocol_versions[] = {
+	PCI_PROTOCOL_VERSION_1_4,
 	PCI_PROTOCOL_VERSION_1_3,
 	PCI_PROTOCOL_VERSION_1_2,
 	PCI_PROTOCOL_VERSION_1_1,
@@ -122,6 +124,8 @@ enum pci_message_type {
 	PCI_CREATE_INTERRUPT_MESSAGE2	= PCI_MESSAGE_BASE + 0x17,
 	PCI_DELETE_INTERRUPT_MESSAGE2	= PCI_MESSAGE_BASE + 0x18, /* unused */
 	PCI_BUS_RELATIONS2		= PCI_MESSAGE_BASE + 0x19,
+	PCI_RESOURCES_ASSIGNED3         = PCI_MESSAGE_BASE + 0x1A,
+	PCI_CREATE_INTERRUPT_MESSAGE3   = PCI_MESSAGE_BASE + 0x1B,
 	PCI_MESSAGE_MAXIMUM
 };
 
@@ -235,6 +239,21 @@ struct hv_msi_desc2 {
 	u16	processor_array[32];
 } __packed;
 
+/*
+ * struct hv_msi_desc3 - 1.3 version of hv_msi_desc
+ *	Everything is the same as in 'hv_msi_desc2' except that the size
+ *	of the 'vector_count' field is larger to support bigger vector
+ *	values. For ex: LPI vectors on ARM.
+ */
+struct hv_msi_desc3 {
+	u32	vector;
+	u8	delivery_mode;
+	u8	reserved;
+	u16	vector_count;
+	u16	processor_count;
+	u16	processor_array[32];
+} __packed;
+
 /**
  * struct tran_int_desc
  * @reserved:		unused, padding
@@ -383,6 +402,12 @@ struct pci_create_interrupt2 {
 	struct hv_msi_desc2 int_desc;
 } __packed;
 
+struct pci_create_interrupt3 {
+	struct pci_message message_type;
+	union win_slot_encoding wslot;
+	struct hv_msi_desc3 int_desc;
+} __packed;
+
 struct pci_delete_interrupt {
 	struct pci_message message_type;
 	union win_slot_encoding wslot;
@@ -1334,26 +1359,55 @@ static u32 hv_compose_msi_req_v1(
 	return sizeof(*int_pkt);
 }
 
+static void hv_compose_msi_req_get_cpu(struct cpumask *affinity, int *cpu,
+				       u16 *count)
+{
+	/*
+	 * Create MSI w/ dummy vCPU set targeting just one vCPU, overwritten
+	 * by subsequent retarget in hv_irq_unmask().
+	 */
+	*cpu = cpumask_first_and(affinity, cpu_online_mask);
+	*count = 1;
+}
+
 static u32 hv_compose_msi_req_v2(
 	struct pci_create_interrupt2 *int_pkt, struct cpumask *affinity,
 	u32 slot, u8 vector)
 {
 	int cpu;
+	u16 cpu_count;
 
 	int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE2;
 	int_pkt->wslot.slot = slot;
 	int_pkt->int_desc.vector = vector;
 	int_pkt->int_desc.vector_count = 1;
 	int_pkt->int_desc.delivery_mode = APIC_DELIVERY_MODE_FIXED;
-
-	/*
-	 * Create MSI w/ dummy vCPU set targeting just one vCPU, overwritten
-	 * by subsequent retarget in hv_irq_unmask().
-	 */
 	cpu = cpumask_first_and(affinity, cpu_online_mask);
+	hv_compose_msi_req_get_cpu(affinity, &cpu, &cpu_count);
 	int_pkt->int_desc.processor_array[0] =
 		hv_cpu_number_to_vp_number(cpu);
-	int_pkt->int_desc.processor_count = 1;
+	int_pkt->int_desc.processor_count = cpu_count;
+
+	return sizeof(*int_pkt);
+}
+
+static u32 hv_compose_msi_req_v3(
+	struct pci_create_interrupt3 *int_pkt, struct cpumask *affinity,
+	u32 slot, u32 vector)
+{
+	int cpu;
+	u16 cpu_count;
+
+	int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE3;
+	int_pkt->wslot.slot = slot;
+	int_pkt->int_desc.vector = vector;
+	int_pkt->int_desc.reserved = 0;
+	int_pkt->int_desc.vector_count = 1;
+	int_pkt->int_desc.delivery_mode = APIC_DELIVERY_MODE_FIXED;
+	hv_compose_msi_req_get_cpu(affinity, &cpu, &cpu_count);
+	int_pkt->int_desc.processor_array[0] =
+		hv_cpu_number_to_vp_number(cpu);
+	int_pkt->int_desc.processor_count = cpu_count;
 
 	return sizeof(*int_pkt);
 }
@@ -1385,6 +1439,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
 		union {
 			struct pci_create_interrupt v1;
 			struct pci_create_interrupt2 v2;
+			struct pci_create_interrupt3 v3;
 		} int_pkts;
 	} __packed ctxt;
 
@@ -1432,6 +1487,13 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
 					cfg->vector);
 		break;
 
+	case PCI_PROTOCOL_VERSION_1_4:
+		size = hv_compose_msi_req_v3(&ctxt.int_pkts.v3,
+					dest,
+					hpdev->desc.win_slot.slot,
+					cfg->vector);
+		break;
+
 	default:
 		/* As we only negotiate protocol versions known to this driver,
 		 * this path should never hit. However, this is it not a hot
-- 
2.17.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] PCI: hv: Support for create interrupt v3
  2021-07-08 23:04 [PATCH 1/1] PCI: hv: Support for create interrupt v3 Sunil Muthuswamy
@ 2021-07-09 10:24 ` Wei Liu
  2021-07-09 16:42   ` [EXTERNAL] " Sunil Muthuswamy
  2021-07-12 19:07 ` Michael Kelley
  1 sibling, 1 reply; 6+ messages in thread
From: Wei Liu @ 2021-07-09 10:24 UTC (permalink / raw)
  To: Sunil Muthuswamy
  Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
	Dexuan Cui, Michael Kelley, linux-hyperv, linux-pci,
	linux-kernel, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas,
	Wei Liu

On Thu, Jul 08, 2021 at 11:04:49PM +0000, Sunil Muthuswamy wrote:
> Hyper-V vPCI protocol version 1_4 adds support for create interrupt
> v3. Create interrupt v3 essentially makes the size of the vector
> field bigger in the message, thereby allowing bigger vector values.
> For example, that will come into play for supporting LPI vectors
> on ARM, which start at 8192.
> 
> Signed-off-by: Sunil Muthuswamy <sunilmut@microsoft.com>
> ---
>  drivers/pci/controller/pci-hyperv.c | 74 ++++++++++++++++++++++++++---
>  1 file changed, 68 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
> index bebe3eeebc4e..de61b20f9604 100644
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -64,6 +64,7 @@ enum pci_protocol_version_t {
>  	PCI_PROTOCOL_VERSION_1_1 = PCI_MAKE_VERSION(1, 1),	/* Win10 */
>  	PCI_PROTOCOL_VERSION_1_2 = PCI_MAKE_VERSION(1, 2),	/* RS1 */
>  	PCI_PROTOCOL_VERSION_1_3 = PCI_MAKE_VERSION(1, 3),	/* Vibranium */
> +	PCI_PROTOCOL_VERSION_1_4 = PCI_MAKE_VERSION(1, 4),      /* Fe */
>  };
>  
>  #define CPU_AFFINITY_ALL	-1ULL
> @@ -73,6 +74,7 @@ enum pci_protocol_version_t {
>   * first.
>   */
>  static enum pci_protocol_version_t pci_protocol_versions[] = {
> +	PCI_PROTOCOL_VERSION_1_4,
>  	PCI_PROTOCOL_VERSION_1_3,
>  	PCI_PROTOCOL_VERSION_1_2,
>  	PCI_PROTOCOL_VERSION_1_1,
> @@ -122,6 +124,8 @@ enum pci_message_type {
>  	PCI_CREATE_INTERRUPT_MESSAGE2	= PCI_MESSAGE_BASE + 0x17,
>  	PCI_DELETE_INTERRUPT_MESSAGE2	= PCI_MESSAGE_BASE + 0x18, /* unused */
>  	PCI_BUS_RELATIONS2		= PCI_MESSAGE_BASE + 0x19,
> +	PCI_RESOURCES_ASSIGNED3         = PCI_MESSAGE_BASE + 0x1A,
> +	PCI_CREATE_INTERRUPT_MESSAGE3   = PCI_MESSAGE_BASE + 0x1B,
>  	PCI_MESSAGE_MAXIMUM
>  };
>  
> @@ -235,6 +239,21 @@ struct hv_msi_desc2 {
>  	u16	processor_array[32];
>  } __packed;
>  
> +/*
> + * struct hv_msi_desc3 - 1.3 version of hv_msi_desc
> + *	Everything is the same as in 'hv_msi_desc2' except that the size
> + *	of the 'vector_count' field is larger to support bigger vector
> + *	values. For ex: LPI vectors on ARM.
> + */
> +struct hv_msi_desc3 {
> +	u32	vector;
> +	u8	delivery_mode;
> +	u8	reserved;
> +	u16	vector_count;
> +	u16	processor_count;
> +	u16	processor_array[32];
> +} __packed;
> +
>  /**
>   * struct tran_int_desc
>   * @reserved:		unused, padding
> @@ -383,6 +402,12 @@ struct pci_create_interrupt2 {
>  	struct hv_msi_desc2 int_desc;
>  } __packed;
>  
> +struct pci_create_interrupt3 {
> +	struct pci_message message_type;
> +	union win_slot_encoding wslot;
> +	struct hv_msi_desc3 int_desc;
> +} __packed;
> +
>  struct pci_delete_interrupt {
>  	struct pci_message message_type;
>  	union win_slot_encoding wslot;
> @@ -1334,26 +1359,55 @@ static u32 hv_compose_msi_req_v1(
>  	return sizeof(*int_pkt);
>  }
>  
> +static void hv_compose_msi_req_get_cpu(struct cpumask *affinity, int *cpu,
> +				       u16 *count)

Isn't count redundant here? I don't see how this can be used safely for
passing back more than 1 cpu, since if cpu is pointing to an array, its
size is not specified.

Wei.

> +{
> +	/*
> +	 * Create MSI w/ dummy vCPU set targeting just one vCPU, overwritten
> +	 * by subsequent retarget in hv_irq_unmask().
> +	 */
> +	*cpu = cpumask_first_and(affinity, cpu_online_mask);
> +	*count = 1;
> +}
> +

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [EXTERNAL] Re: [PATCH 1/1] PCI: hv: Support for create interrupt v3
  2021-07-09 10:24 ` Wei Liu
@ 2021-07-09 16:42   ` Sunil Muthuswamy
  2021-07-09 19:15     ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Sunil Muthuswamy @ 2021-07-09 16:42 UTC (permalink / raw)
  To: Wei Liu
  Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
	Dexuan Cui, Michael Kelley, linux-hyperv, linux-pci,
	linux-kernel, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas

> > +/*
> > + * struct hv_msi_desc3 - 1.3 version of hv_msi_desc
> > + *	Everything is the same as in 'hv_msi_desc2' except that the size
> > + *	of the 'vector_count' field is larger to support bigger vector
> > + *	values. For ex: LPI vectors on ARM.
> > + */
> > +struct hv_msi_desc3 {
> > +	u32	vector;
> > +	u8	delivery_mode;
> > +	u8	reserved;
> > +	u16	vector_count;
> > +	u16	processor_count;
> > +	u16	processor_array[32];
> > +} __packed;
> > +
> >  /**
> >   * struct tran_int_desc
> >   * @reserved:		unused, padding
> > @@ -383,6 +402,12 @@ struct pci_create_interrupt2 {
> >  	struct hv_msi_desc2 int_desc;
> >  } __packed;
> >
> > +struct pci_create_interrupt3 {
> > +	struct pci_message message_type;
> > +	union win_slot_encoding wslot;
> > +	struct hv_msi_desc3 int_desc;
> > +} __packed;
> > +
> >  struct pci_delete_interrupt {
> >  	struct pci_message message_type;
> >  	union win_slot_encoding wslot;
> > @@ -1334,26 +1359,55 @@ static u32 hv_compose_msi_req_v1(
> >  	return sizeof(*int_pkt);
> >  }
> >
> > +static void hv_compose_msi_req_get_cpu(struct cpumask *affinity, int *cpu,
> > +				       u16 *count)
> 
> Isn't count redundant here? I don't see how this can be used safely for
> passing back more than 1 cpu, since if cpu is pointing to an array, its
> size is not specified.
> 
> Wei.

Yes, it is at the moment. But, the function can be extended in the future to take
a size as well. But, it will always be 1 and I preferred keeping that information
with the implementation. If you have preference, I can hard code that in the
caller. It seems fine for me either ways.

- Sunil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [EXTERNAL] Re: [PATCH 1/1] PCI: hv: Support for create interrupt v3
  2021-07-09 16:42   ` [EXTERNAL] " Sunil Muthuswamy
@ 2021-07-09 19:15     ` Wei Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2021-07-09 19:15 UTC (permalink / raw)
  To: Sunil Muthuswamy
  Cc: Wei Liu, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	Wei Liu, Dexuan Cui, Michael Kelley, linux-hyperv, linux-pci,
	linux-kernel, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas

On Fri, Jul 09, 2021 at 04:42:13PM +0000, Sunil Muthuswamy wrote:
> > > +/*
> > > + * struct hv_msi_desc3 - 1.3 version of hv_msi_desc
> > > + *	Everything is the same as in 'hv_msi_desc2' except that the size
> > > + *	of the 'vector_count' field is larger to support bigger vector
> > > + *	values. For ex: LPI vectors on ARM.
> > > + */
> > > +struct hv_msi_desc3 {
> > > +	u32	vector;
> > > +	u8	delivery_mode;
> > > +	u8	reserved;
> > > +	u16	vector_count;
> > > +	u16	processor_count;
> > > +	u16	processor_array[32];
> > > +} __packed;
> > > +
> > >  /**
> > >   * struct tran_int_desc
> > >   * @reserved:		unused, padding
> > > @@ -383,6 +402,12 @@ struct pci_create_interrupt2 {
> > >  	struct hv_msi_desc2 int_desc;
> > >  } __packed;
> > >
> > > +struct pci_create_interrupt3 {
> > > +	struct pci_message message_type;
> > > +	union win_slot_encoding wslot;
> > > +	struct hv_msi_desc3 int_desc;
> > > +} __packed;
> > > +
> > >  struct pci_delete_interrupt {
> > >  	struct pci_message message_type;
> > >  	union win_slot_encoding wslot;
> > > @@ -1334,26 +1359,55 @@ static u32 hv_compose_msi_req_v1(
> > >  	return sizeof(*int_pkt);
> > >  }
> > >
> > > +static void hv_compose_msi_req_get_cpu(struct cpumask *affinity, int *cpu,
> > > +				       u16 *count)
> > 
> > Isn't count redundant here? I don't see how this can be used safely for
> > passing back more than 1 cpu, since if cpu is pointing to an array, its
> > size is not specified.
> > 
> > Wei.
> 
> Yes, it is at the moment. But, the function can be extended in the future to take
> a size as well. But, it will always be 1 and I preferred keeping that information
> with the implementation. If you have preference, I can hard code that in the
> caller. It seems fine for me either ways.

Since this is not too much trouble I would rather you remove count and
then introduce it when it is needed.

Wei.

> 
> - Sunil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 1/1] PCI: hv: Support for create interrupt v3
  2021-07-08 23:04 [PATCH 1/1] PCI: hv: Support for create interrupt v3 Sunil Muthuswamy
  2021-07-09 10:24 ` Wei Liu
@ 2021-07-12 19:07 ` Michael Kelley
  2021-07-12 19:13   ` Sunil Muthuswamy
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Kelley @ 2021-07-12 19:07 UTC (permalink / raw)
  To: Sunil Muthuswamy, KY Srinivasan, Haiyang Zhang,
	Stephen Hemminger, Wei Liu, Dexuan Cui
  Cc: linux-hyperv, linux-pci, linux-kernel, Lorenzo Pieralisi,
	Rob Herring, Bjorn Helgaas

From: Sunil Muthuswamy <sunilmut@microsoft.com> Sent: Thursday, July 8, 2021 4:05 PM
> 
> Hyper-V vPCI protocol version 1_4 adds support for create interrupt
> v3. Create interrupt v3 essentially makes the size of the vector
> field bigger in the message, thereby allowing bigger vector values.
> For example, that will come into play for supporting LPI vectors
> on ARM, which start at 8192.
> 
> Signed-off-by: Sunil Muthuswamy <sunilmut@microsoft.com>
> ---
>  drivers/pci/controller/pci-hyperv.c | 74 ++++++++++++++++++++++++++---
>  1 file changed, 68 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
> index bebe3eeebc4e..de61b20f9604 100644
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -64,6 +64,7 @@ enum pci_protocol_version_t {
>  	PCI_PROTOCOL_VERSION_1_1 = PCI_MAKE_VERSION(1, 1),	/* Win10 */
>  	PCI_PROTOCOL_VERSION_1_2 = PCI_MAKE_VERSION(1, 2),	/* RS1 */
>  	PCI_PROTOCOL_VERSION_1_3 = PCI_MAKE_VERSION(1, 3),	/* Vibranium */
> +	PCI_PROTOCOL_VERSION_1_4 = PCI_MAKE_VERSION(1, 4),      /* Fe */

It would be better if we can avoid annotating with internal code names.
Inside of MSFT we tend to forget over time, and people outside usually
have no idea what they mean.  

>  };
> 
>  #define CPU_AFFINITY_ALL	-1ULL
> @@ -73,6 +74,7 @@ enum pci_protocol_version_t {
>   * first.
>   */
>  static enum pci_protocol_version_t pci_protocol_versions[] = {
> +	PCI_PROTOCOL_VERSION_1_4,
>  	PCI_PROTOCOL_VERSION_1_3,
>  	PCI_PROTOCOL_VERSION_1_2,
>  	PCI_PROTOCOL_VERSION_1_1,
> @@ -122,6 +124,8 @@ enum pci_message_type {
>  	PCI_CREATE_INTERRUPT_MESSAGE2	= PCI_MESSAGE_BASE + 0x17,
>  	PCI_DELETE_INTERRUPT_MESSAGE2	= PCI_MESSAGE_BASE + 0x18, /* unused */
>  	PCI_BUS_RELATIONS2		= PCI_MESSAGE_BASE + 0x19,
> +	PCI_RESOURCES_ASSIGNED3         = PCI_MESSAGE_BASE + 0x1A,
> +	PCI_CREATE_INTERRUPT_MESSAGE3   = PCI_MESSAGE_BASE + 0x1B,
>  	PCI_MESSAGE_MAXIMUM
>  };
> 
> @@ -235,6 +239,21 @@ struct hv_msi_desc2 {
>  	u16	processor_array[32];
>  } __packed;
> 
> +/*
> + * struct hv_msi_desc3 - 1.3 version of hv_msi_desc
> + *	Everything is the same as in 'hv_msi_desc2' except that the size
> + *	of the 'vector_count' field is larger to support bigger vector

Actually, it's the "vector" field that's bigger, not "vector_count".

> + *	values. For ex: LPI vectors on ARM.
> + */
> +struct hv_msi_desc3 {
> +	u32	vector;
> +	u8	delivery_mode;
> +	u8	reserved;
> +	u16	vector_count;
> +	u16	processor_count;
> +	u16	processor_array[32];
> +} __packed;
> +
>  /**
>   * struct tran_int_desc
>   * @reserved:		unused, padding
> @@ -383,6 +402,12 @@ struct pci_create_interrupt2 {
>  	struct hv_msi_desc2 int_desc;
>  } __packed;
> 
> +struct pci_create_interrupt3 {
> +	struct pci_message message_type;
> +	union win_slot_encoding wslot;
> +	struct hv_msi_desc3 int_desc;
> +} __packed;
> +
>  struct pci_delete_interrupt {
>  	struct pci_message message_type;
>  	union win_slot_encoding wslot;
> @@ -1334,26 +1359,55 @@ static u32 hv_compose_msi_req_v1(
>  	return sizeof(*int_pkt);
>  }
> 
> +static void hv_compose_msi_req_get_cpu(struct cpumask *affinity, int *cpu,
> +				       u16 *count)
> +{
> +	/*
> +	 * Create MSI w/ dummy vCPU set targeting just one vCPU, overwritten
> +	 * by subsequent retarget in hv_irq_unmask().
> +	 */
> +	*cpu = cpumask_first_and(affinity, cpu_online_mask);
> +	*count = 1;
> +}
> +
>  static u32 hv_compose_msi_req_v2(
>  	struct pci_create_interrupt2 *int_pkt, struct cpumask *affinity,
>  	u32 slot, u8 vector)
>  {
>  	int cpu;
> +	u16 cpu_count;
> 
>  	int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE2;
>  	int_pkt->wslot.slot = slot;
>  	int_pkt->int_desc.vector = vector;
>  	int_pkt->int_desc.vector_count = 1;
>  	int_pkt->int_desc.delivery_mode = APIC_DELIVERY_MODE_FIXED;
> -
> -	/*
> -	 * Create MSI w/ dummy vCPU set targeting just one vCPU, overwritten
> -	 * by subsequent retarget in hv_irq_unmask().
> -	 */
>  	cpu = cpumask_first_and(affinity, cpu_online_mask);

Shouldn't this line be deleted since the new hv_compose_msi_req_get_cpu()
function is doing the work?

> +	hv_compose_msi_req_get_cpu(affinity, &cpu, &cpu_count);
>  	int_pkt->int_desc.processor_array[0] =
>  		hv_cpu_number_to_vp_number(cpu);
> -	int_pkt->int_desc.processor_count = 1;
> +	int_pkt->int_desc.processor_count = cpu_count;
> +
> +	return sizeof(*int_pkt);
> +}
> +
> +static u32 hv_compose_msi_req_v3(
> +	struct pci_create_interrupt3 *int_pkt, struct cpumask *affinity,
> +	u32 slot, u32 vector)
> +{
> +	int cpu;
> +	u16 cpu_count;
> +
> +	int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE3;
> +	int_pkt->wslot.slot = slot;
> +	int_pkt->int_desc.vector = vector;
> +	int_pkt->int_desc.reserved = 0;
> +	int_pkt->int_desc.vector_count = 1;
> +	int_pkt->int_desc.delivery_mode = APIC_DELIVERY_MODE_FIXED;
> +	hv_compose_msi_req_get_cpu(affinity, &cpu, &cpu_count);
> +	int_pkt->int_desc.processor_array[0] =
> +		hv_cpu_number_to_vp_number(cpu);
> +	int_pkt->int_desc.processor_count = cpu_count;
> 
>  	return sizeof(*int_pkt);
>  }
> @@ -1385,6 +1439,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
>  		union {
>  			struct pci_create_interrupt v1;
>  			struct pci_create_interrupt2 v2;
> +			struct pci_create_interrupt3 v3;
>  		} int_pkts;
>  	} __packed ctxt;
> 
> @@ -1432,6 +1487,13 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
>  					cfg->vector);
>  		break;
> 
> +	case PCI_PROTOCOL_VERSION_1_4:
> +		size = hv_compose_msi_req_v3(&ctxt.int_pkts.v3,
> +					dest,
> +					hpdev->desc.win_slot.slot,
> +					cfg->vector);
> +		break;
> +
>  	default:
>  		/* As we only negotiate protocol versions known to this driver,
>  		 * this path should never hit. However, this is it not a hot
> --
> 2.17.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 1/1] PCI: hv: Support for create interrupt v3
  2021-07-12 19:07 ` Michael Kelley
@ 2021-07-12 19:13   ` Sunil Muthuswamy
  0 siblings, 0 replies; 6+ messages in thread
From: Sunil Muthuswamy @ 2021-07-12 19:13 UTC (permalink / raw)
  To: Michael Kelley, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	Wei Liu, Dexuan Cui
  Cc: linux-hyperv, linux-pci, linux-kernel, Lorenzo Pieralisi,
	Rob Herring, Bjorn Helgaas

> > --- a/drivers/pci/controller/pci-hyperv.c
> > +++ b/drivers/pci/controller/pci-hyperv.c
> > @@ -64,6 +64,7 @@ enum pci_protocol_version_t {
> >  	PCI_PROTOCOL_VERSION_1_1 = PCI_MAKE_VERSION(1, 1),	/* Win10 */
> >  	PCI_PROTOCOL_VERSION_1_2 = PCI_MAKE_VERSION(1, 2),	/* RS1 */
> >  	PCI_PROTOCOL_VERSION_1_3 = PCI_MAKE_VERSION(1, 3),	/* Vibranium */
> > +	PCI_PROTOCOL_VERSION_1_4 = PCI_MAKE_VERSION(1, 4),      /* Fe */
> 
> It would be better if we can avoid annotating with internal code names.
> Inside of MSFT we tend to forget over time, and people outside usually
> have no idea what they mean.
> 


Would you like me to just delete the 'Fe' comment or the previous ones as well?

> > @@ -235,6 +239,21 @@ struct hv_msi_desc2 {
> >  	u16	processor_array[32];
> >  } __packed;
> >
> > +/*
> > + * struct hv_msi_desc3 - 1.3 version of hv_msi_desc
> > + *	Everything is the same as in 'hv_msi_desc2' except that the size
> > + *	of the 'vector_count' field is larger to support bigger vector
> 
> Actually, it's the "vector" field that's bigger, not "vector_count".

Will update the comment, thanks.

> 
> > + *	values. For ex: LPI vectors on ARM.
> > + */
> > +struct hv_msi_desc3 {
> > +	u32	vector;
> > +	u8	delivery_mode;
> > +	u8	reserved;
> > +	u16	vector_count;
> > +	u16	processor_count;
> > +	u16	processor_array[32];
> > +} __packed;
> > +
> >  /**
> >   * struct tran_int_desc
> >   * @reserved:		unused, padding
> > @@ -383,6 +402,12 @@ struct pci_create_interrupt2 {
> >  	struct hv_msi_desc2 int_desc;
> >  } __packed;
> >
> > +struct pci_create_interrupt3 {
> > +	struct pci_message message_type;
> > +	union win_slot_encoding wslot;
> > +	struct hv_msi_desc3 int_desc;
> > +} __packed;
> > +
> >  struct pci_delete_interrupt {
> >  	struct pci_message message_type;
> >  	union win_slot_encoding wslot;
> > @@ -1334,26 +1359,55 @@ static u32 hv_compose_msi_req_v1(
> >  	return sizeof(*int_pkt);
> >  }
> >
> > +static void hv_compose_msi_req_get_cpu(struct cpumask *affinity, int *cpu,
> > +				       u16 *count)
> > +{
> > +	/*
> > +	 * Create MSI w/ dummy vCPU set targeting just one vCPU, overwritten
> > +	 * by subsequent retarget in hv_irq_unmask().
> > +	 */
> > +	*cpu = cpumask_first_and(affinity, cpu_online_mask);
> > +	*count = 1;
> > +}
> > +
> >  static u32 hv_compose_msi_req_v2(
> >  	struct pci_create_interrupt2 *int_pkt, struct cpumask *affinity,
> >  	u32 slot, u8 vector)
> >  {
> >  	int cpu;
> > +	u16 cpu_count;
> >
> >  	int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE2;
> >  	int_pkt->wslot.slot = slot;
> >  	int_pkt->int_desc.vector = vector;
> >  	int_pkt->int_desc.vector_count = 1;
> >  	int_pkt->int_desc.delivery_mode = APIC_DELIVERY_MODE_FIXED;
> > -
> > -	/*
> > -	 * Create MSI w/ dummy vCPU set targeting just one vCPU, overwritten
> > -	 * by subsequent retarget in hv_irq_unmask().
> > -	 */
> >  	cpu = cpumask_first_and(affinity, cpu_online_mask);
> 
> Shouldn't this line be deleted since the new hv_compose_msi_req_get_cpu()
> function is doing the work?

Yes, this is fixed in v2 that I just sent out.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-12 19:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 23:04 [PATCH 1/1] PCI: hv: Support for create interrupt v3 Sunil Muthuswamy
2021-07-09 10:24 ` Wei Liu
2021-07-09 16:42   ` [EXTERNAL] " Sunil Muthuswamy
2021-07-09 19:15     ` Wei Liu
2021-07-12 19:07 ` Michael Kelley
2021-07-12 19:13   ` Sunil Muthuswamy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).