Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp474857imn; Wed, 27 Jul 2022 11:13:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v1ptwdrV5aIxiq5hmvNINgij1bfG6xvPnd2X1r06skGxmtA+Qg7+hY/6U09wyxWJvOLmXp X-Received: by 2002:a17:906:4fc5:b0:72b:9943:6f10 with SMTP id i5-20020a1709064fc500b0072b99436f10mr18736949ejw.722.1658945618986; Wed, 27 Jul 2022 11:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658945618; cv=none; d=google.com; s=arc-20160816; b=MX96L49XlrjRYoJ8kLPwJNwV3IHDTHt94gFiuX6T1AXGx46fRjmugTbt/qc/cg2MBj 2IcQCh+Sr7UqjKEUeQ1tzfwJHqTYO39fCnBYSfO/yLDGMMVnG6fKvgk7B5nvd/L08dtf uwmdbboQshhspUETdEmjLQU/Yx/bjRv1toE8sO4Lx9m5Ix+NkzDzpqTNwSZ3dqHde5Cm Z0M9d6EarAjq1h9/X/HrSO391RfnJLqGTveSJ5jUwVZjONql08NSdWmfndel3/Pb9P9Q LKTZZEN6PxRHLi9RahgO+F203aVCtyh8N0fXGmh+9+H8c/XpqXkS6FkvWKaZt2MNIcAv mbNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u1dMd/hOq9si4VtlOeITf9TFn9JZaP1lRoy3iqX8IAA=; b=eBvzEPap54VKfLuard8nHdF0z5sWKq1f27q6mkxlC3uN0JwHfFWo+Lub02Ijab5GNj 8+3Pk0ckj1SEfFur/H+/sx7WTM/WxJY4TOrAfDAYJuw4oTZaJKeBfLGJyrRCSpRP/Sck YnKJhze0NlOvnjhdEmUxkcnsvsSR4N3uJKLtvYbUDk9L/xzlSN1OKx5kJyyIitIAhE9A SHMchvNHuyS84JswWwOo5x9q/irS53CVvflC/3zKv9uyXGspx86CtXZotRl4DRMb7bdR eE9qzlKf7MEiUHDyuZcpiH20G4SMySBDIS8Nj6TKkeM3XHe54GDyGvs1lollPtzVWyDo SQiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l1xdjcfZ; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020aa7c383000000b0043bb9f01aaesi17976393edq.335.2022.07.27.11.13.13; Wed, 27 Jul 2022 11:13:38 -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=@linuxfoundation.org header.s=korg header.b=l1xdjcfZ; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240621AbiG0QuJ (ORCPT + 99 others); Wed, 27 Jul 2022 12:50:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240732AbiG0QtS (ORCPT ); Wed, 27 Jul 2022 12:49:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9A1B61719; Wed, 27 Jul 2022 09:32:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E9A5A619BF; Wed, 27 Jul 2022 16:32:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3660C433C1; Wed, 27 Jul 2022 16:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939567; bh=SHk0fwewRjaoZyPCGm84OVVHt3jkU1HAF03YpkNu5AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l1xdjcfZhlOkm/LPw7vrjN0ionug5F153AuUvAiJtr5odUiHDY8v94EYktRiiFyBn 7otmWWt12OscbeMvMr8jga4HHW7rx81TkTW+aZ4jxTzDKrRke+o4IdECxoFTT6AMSD bQbifsn77pQNBUe6yUOTV0ZJc+JmsLdcdj1SDQXo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jeffrey Hugo , Dexuan Cui , Michael Kelley , Wei Liu , Carl Vanderlip Subject: [PATCH 5.10 019/105] PCI: hv: Reuse existing IRTE allocation in compose_msi_msg() Date: Wed, 27 Jul 2022 18:10:05 +0200 Message-Id: <20220727161012.867192792@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161012.056867467@linuxfoundation.org> References: <20220727161012.056867467@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 From: Jeffrey Hugo commit b4b77778ecc5bfbd4e77de1b2fd5c1dd3c655f1f upstream. Currently if compose_msi_msg() is called multiple times, it will free any previous IRTE allocation, and generate a new allocation. While nothing prevents this from occurring, it is extraneous when Linux could just reuse the existing allocation and avoid a bunch of overhead. However, when future IRTE allocations operate on blocks of MSIs instead of a single line, freeing the allocation will impact all of the lines. This could cause an issue where an allocation of N MSIs occurs, then some of the lines are retargeted, and finally the allocation is freed/reallocated. The freeing of the allocation removes all of the configuration for the entire block, which requires all the lines to be retargeted, which might not happen since some lines might already be unmasked/active. Signed-off-by: Jeffrey Hugo Reviewed-by: Dexuan Cui Tested-by: Dexuan Cui Tested-by: Michael Kelley Link: https://lore.kernel.org/r/1652282582-21595-1-git-send-email-quic_jhugo@quicinc.com Signed-off-by: Wei Liu Signed-off-by: Carl Vanderlip Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pci-hyperv.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1409,6 +1409,15 @@ static void hv_compose_msi_msg(struct ir u32 size; int ret; + /* Reuse the previous allocation */ + if (data->chip_data) { + int_desc = data->chip_data; + msg->address_hi = int_desc->address >> 32; + msg->address_lo = int_desc->address & 0xffffffff; + msg->data = int_desc->data; + return; + } + pdev = msi_desc_to_pci_dev(irq_data_get_msi_desc(data)); dest = irq_data_get_effective_affinity_mask(data); pbus = pdev->bus; @@ -1418,13 +1427,6 @@ static void hv_compose_msi_msg(struct ir if (!hpdev) goto return_null_message; - /* Free any previous message that might have already been composed. */ - if (data->chip_data) { - int_desc = data->chip_data; - data->chip_data = NULL; - hv_int_desc_free(hpdev, int_desc); - } - int_desc = kzalloc(sizeof(*int_desc), GFP_ATOMIC); if (!int_desc) goto drop_reference;