All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Dexuan Cui <decui@microsoft.com>
Cc: quic_jhugo@quicinc.com, quic_carlv@quicinc.com,
	wei.liu@kernel.org, kys@microsoft.com, haiyangz@microsoft.com,
	sthemmin@microsoft.com, lpieralisi@kernel.org,
	bhelgaas@google.com, linux-hyperv@vger.kernel.org,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	mikelley@microsoft.com, robh@kernel.org, kw@linux.com,
	helgaas@kernel.org, alex.williamson@redhat.com,
	stable@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH v2] PCI: hv: Fix the definition of vector in hv_compose_msi_msg()
Date: Wed, 29 Mar 2023 18:56:12 -0700	[thread overview]
Message-ID: <ZCTsPFb7dBj2IZmo@boqun-archlinux> (raw)
In-Reply-To: <20221027205256.17678-1-decui@microsoft.com>

[Cc stable]

On Thu, Oct 27, 2022 at 01:52:56PM -0700, Dexuan Cui wrote:
> The local variable 'vector' must be u32 rather than u8: see the
> struct hv_msi_desc3.
> 
> 'vector_count' should be u16 rather than u8: see struct hv_msi_desc,
> hv_msi_desc2 and hv_msi_desc3.
> 

Dexuan, I think this patch should only be in 5.15, because...

> Fixes: a2bad844a67b ("PCI: hv: Fix interrupt mapping for multi-MSI")

^^^ this commit is already in 5.15.y (commit id 92dcb50f7f09).

Upstream id e70af8d040d2b7904dca93d942ba23fb722e21b1
Cc: <stable@vger.kernel.org> # 5.15.x

Regards,
Boqun

> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> Cc: Jeffrey Hugo <quic_jhugo@quicinc.com>
> Cc: Carl Vanderlip <quic_carlv@quicinc.com>
> ---
> 
> v1 was posted here (sorry, I forgot to follow this up...):
> https://lwn.net/ml/linux-kernel/20220815185505.7626-1-decui@microsoft.com/
> 
> Changes in v2:
>   Added the explicit "(u8)" cast in hv_compose_msi_msg().
>   Added and improved the comments.
>   Fixed a typo in the subject in v1: s/definiton/definition
> 
>  drivers/pci/controller/pci-hyperv.c | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
> index e7c6f6629e7c..ba64284eaf9f 100644
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -1614,7 +1614,7 @@ static void hv_pci_compose_compl(void *context, struct pci_response *resp,
>  
>  static u32 hv_compose_msi_req_v1(
>  	struct pci_create_interrupt *int_pkt, const struct cpumask *affinity,
> -	u32 slot, u8 vector, u8 vector_count)
> +	u32 slot, u8 vector, u16 vector_count)
>  {
>  	int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE;
>  	int_pkt->wslot.slot = slot;
> @@ -1642,7 +1642,7 @@ static int hv_compose_msi_req_get_cpu(const struct cpumask *affinity)
>  
>  static u32 hv_compose_msi_req_v2(
>  	struct pci_create_interrupt2 *int_pkt, const struct cpumask *affinity,
> -	u32 slot, u8 vector, u8 vector_count)
> +	u32 slot, u8 vector, u16 vector_count)
>  {
>  	int cpu;
>  
> @@ -1661,7 +1661,7 @@ static u32 hv_compose_msi_req_v2(
>  
>  static u32 hv_compose_msi_req_v3(
>  	struct pci_create_interrupt3 *int_pkt, const struct cpumask *affinity,
> -	u32 slot, u32 vector, u8 vector_count)
> +	u32 slot, u32 vector, u16 vector_count)
>  {
>  	int cpu;
>  
> @@ -1701,7 +1701,12 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
>  	struct compose_comp_ctxt comp;
>  	struct tran_int_desc *int_desc;
>  	struct msi_desc *msi_desc;
> -	u8 vector, vector_count;
> +	/*
> +	 * vector_count should be u16: see hv_msi_desc, hv_msi_desc2
> +	 * and hv_msi_desc3. vector must be u32: see hv_msi_desc3.
> +	 */
> +	u16 vector_count;
> +	u32 vector;
>  	struct {
>  		struct pci_packet pci_pkt;
>  		union {
> @@ -1767,6 +1772,11 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
>  		vector_count = 1;
>  	}
>  
> +	/*
> +	 * hv_compose_msi_req_v1 and v2 are for x86 only, meaning 'vector'
> +	 * can't exceed u8. Cast 'vector' down to u8 for v1/v2 explicitly
> +	 * for better readability.
> +	 */
>  	memset(&ctxt, 0, sizeof(ctxt));
>  	init_completion(&comp.comp_pkt.host_event);
>  	ctxt.pci_pkt.completion_func = hv_pci_compose_compl;
> @@ -1777,7 +1787,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
>  		size = hv_compose_msi_req_v1(&ctxt.int_pkts.v1,
>  					dest,
>  					hpdev->desc.win_slot.slot,
> -					vector,
> +					(u8)vector,
>  					vector_count);
>  		break;
>  
> @@ -1786,7 +1796,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
>  		size = hv_compose_msi_req_v2(&ctxt.int_pkts.v2,
>  					dest,
>  					hpdev->desc.win_slot.slot,
> -					vector,
> +					(u8)vector,
>  					vector_count);
>  		break;
>  
> -- 
> 2.25.1
> 

  parent reply	other threads:[~2023-03-30  1:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 20:52 [PATCH v2] PCI: hv: Fix the definition of vector in hv_compose_msi_msg() Dexuan Cui
2022-10-28 14:08 ` Jeffrey Hugo
2022-11-02 13:06   ` Wei Liu
2023-03-30  1:56 ` Boqun Feng [this message]
2023-03-30  2:55   ` Boqun Feng
2023-03-30  3:23     ` Dexuan Cui
2023-03-30  5:58       ` Greg Kroah-Hartman
2023-03-30 19:50         ` Dexuan Cui
2023-03-30 20:56           ` Greg Kroah-Hartman
2023-04-03 18:50           ` Jeffrey Hugo
2023-04-03 19:29             ` Dexuan Cui
2023-04-03 13:07       ` Greg Kroah-Hartman
2023-04-03 18:29         ` Dexuan Cui

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=ZCTsPFb7dBj2IZmo@boqun-archlinux \
    --to=boqun.feng@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=decui@microsoft.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haiyangz@microsoft.com \
    --cc=helgaas@kernel.org \
    --cc=kw@linux.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=quic_carlv@quicinc.com \
    --cc=quic_jhugo@quicinc.com \
    --cc=robh@kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sthemmin@microsoft.com \
    --cc=wei.liu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.