Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1514647rwl; Wed, 29 Mar 2023 19:58:09 -0700 (PDT) X-Google-Smtp-Source: AK7set8ZQpKpwye/vVf1B5WxM34eyPqrujN7/5ZeWUznZG/ZHpgzdR/jREUV/e/GSGW96Cmr9bvb X-Received: by 2002:a05:6a20:6695:b0:cc:fa4b:3a6a with SMTP id o21-20020a056a20669500b000ccfa4b3a6amr21040028pzh.58.1680145089688; Wed, 29 Mar 2023 19:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680145089; cv=none; d=google.com; s=arc-20160816; b=tM1nOHg4QRxMEJXcsGaxpRyat4PzZ49b/BmcP61ptXA24KS7I2WO9vIYLTifvk44Ot lVa1uO0koDDxyqcTkgwWCLwMvZEggCBHL4KGFLGIfbMAzYgvDTvLqI2rpSrtFdK+Zxjq mu34OfWpAJUTBRFjZVoT0/98fsz5lAEmzrc/i1YOUN8HfucI1ftEDR2xprg7HU7uTk0C xmq8KUzfeP8/xLJfJax5mRYTCUxEBF2tYzqqwU9kAhjFlqbA63PEymgshIQHjUIkQJYl qJ32mkpl3vVgJoM1KNhQxlH+/pL5vQ4Llm3NiSzeBXUu9StSGFY2RtAzKcuXxiv8UfgN pNqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature; bh=8X2YSVby3eARSC5IBWjikSWO8skTq18zdSjFOS2gB6I=; b=pAvPM5Y8eiPP/8ncVaQ7XgplI9XGrYIIX3DeJA0//y8M9h3ZscLFSHo70tPTOi2/Bi f/tybKQM+6yi7CmfJM/dBpdfmaw3ICKxY4IfXTgmeygrH2hZhlk7hCuoS0q9MhakhaA8 TzBwoukl8F5ussPXO+znmoC1+EwXl81zxQR+5+E0Jo/0eXAK3fD2HrVuc4pNliHSaHTk plkml0RAwaufthXESDyaiOQ4mgKGU7OaLQVnNUU2mRW9dq8+CufQbL33H/8JLhw8vbbd JI+/ujumckxwEVfmXm12056Oy5WiuLUj7U4dtGPsqTKuToKtSn5j/0F0uKfoqOtZK8QI SbXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="RPWn/wB+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t16-20020a632250000000b004fb96b91c57si31854675pgm.125.2023.03.29.19.57.56; Wed, 29 Mar 2023 19:58:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="RPWn/wB+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbjC3C43 (ORCPT + 99 others); Wed, 29 Mar 2023 22:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbjC3C41 (ORCPT ); Wed, 29 Mar 2023 22:56:27 -0400 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE07D3C26; Wed, 29 Mar 2023 19:56:17 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id m16so13100645qvi.12; Wed, 29 Mar 2023 19:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680144977; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=8X2YSVby3eARSC5IBWjikSWO8skTq18zdSjFOS2gB6I=; b=RPWn/wB+SOLnUxOcLQLIKnFvdFrJ/Q7oRalBf/lJRKKJ8998AG/120Zt20hEkFjXMK wGLEd/pLUhdwnGBTficsp3sknQRQE18AK+bFlxbHkD9teAzku7+dTDwVW9l2/pOmO0O+ JGyZbVwUWM7JxNm1/nb8HKZZnCQ5Su9urxE8Byl8Aruc/fK/VX5Qrdq4kze/+tH1qfLG S312kdeukWHPRJgAzcQlnQTKpFsyk75hSF5w2qh3ngQbhWzliFccrTyqr9Kg1SKqoKbo lxSZzgCX4BygCt9N6GN6+78SHoBVlUHP4/9OfZYhowFx4HSlTLZPj6dYlbW2dSpcZp/W xxUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680144977; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8X2YSVby3eARSC5IBWjikSWO8skTq18zdSjFOS2gB6I=; b=BJZpZz1cZjEmJy0LoFPcoacccrhsY5lBHGd9Sjvxs1KOx7JeKd+JjO0BHbiI1HoV0s yyVTK9inqBKuHpxNLc18AwxhrFRnaq+90J3hvxvpFADfov/8zFiFXqnNIUCCu1rWBGOF NifGtcPIRtCRAoptLWfcrvMctVWZBDb402ldTuI2syUpJ2ks0r4ZBmZdkD9jk/hHVoad 6qV/0+WEpGfVeNKGID32qltuqh5eek34BnTrGhRGmr4z1p/Hjj+GMliaUEQp7XGSTuj6 nc9OmV2LOkg4DM6KzKHjnDVxcvXoBHrb0nE6qJJ91PnfpSihJ3nJCMFADW4qfx7pXFaY zmPA== X-Gm-Message-State: AAQBX9ejaiIwMgGiRvthaoQJMDs1T3VpgCcMYaufoYuw6m71UMuxYBam 9x/IKMkbn6Tp3v0HYvCy5Ag= X-Received: by 2002:ad4:5c61:0:b0:5c9:422e:c7b9 with SMTP id i1-20020ad45c61000000b005c9422ec7b9mr39171311qvh.19.1680144977029; Wed, 29 Mar 2023 19:56:17 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id a8-20020a0ce908000000b005dd8b9345a3sm5108719qvo.59.2023.03.29.19.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 19:56:16 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id B4DE627C0054; Wed, 29 Mar 2023 22:56:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 29 Mar 2023 22:56:15 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehjedgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeeigeethfejvdfhudegtdevtefhleelffegteevtdelgfeugefhhffhteeg iefhheenucffohhmrghinheplhifnhdrnhgvthenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhpvghr shhonhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnrdhfvg hngheppehgmhgrihhlrdgtohhmsehfihigmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Mar 2023 22:56:15 -0400 (EDT) Date: Wed, 29 Mar 2023 19:55:32 -0700 From: Boqun Feng To: Dexuan Cui 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 , Sasha Levin Subject: Re: [PATCH v2] PCI: hv: Fix the definition of vector in hv_compose_msi_msg() Message-ID: References: <20221027205256.17678-1-decui@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 29, 2023 at 06:56:12PM -0700, Boqun Feng wrote: > [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... > Sorry, I meant: "this patch should also be backported in 5.15" Regards, Boqun > > 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: # 5.15.x > > Regards, > Boqun > > > Signed-off-by: Dexuan Cui > > Cc: Jeffrey Hugo > > Cc: Carl Vanderlip > > --- > > > > 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 > >