Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp484449imn; Wed, 27 Jul 2022 11:29:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uCpiA8uD6rMYoahYalZ+NL4BaZWooImrYfZaFKZK9jnkehIcjRukW5OT7YG83rHUrYhWfp X-Received: by 2002:a05:6402:440c:b0:43a:1124:e56a with SMTP id y12-20020a056402440c00b0043a1124e56amr25335888eda.134.1658946579576; Wed, 27 Jul 2022 11:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946579; cv=none; d=google.com; s=arc-20160816; b=tStipM6wyrBvRtN2lfkRAgVt9zS35FNTizsJZqoFtP26BZveZF/5p8xufMa98snfnO UbZ9dLI+4pFjjZ7k2x+rQNrAsCVcapzABujAe/ynFmZcDqGzdpOMn/XjZPRm9A0ISWiq Xp3rZXksWZiu6mDBhVhl2RbOdRpO0bEn8VywvzSzljHGJcKOg9+xy8/YU8ze/FXVrKJ6 2HKiPCyXlW0TvQ0KnFDMWFrd6WB8uZpjq7Z3Ppwph76LF8ObbNnBR5uOZt9qavyQJl6o aiWvp50ZAUmw43N5WI4EmwiN5ppfohWOuJq8eG5ZfLz3tF6X6EGkvLficqBIUzk6Rg65 94aw== 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=oVNOyZwJjHJDXu0zt+i2PvWvcStponVO01OzW01uF2g=; b=JWDKUP/xPxUTbzazyqbTnQYvQZWed4hLyVEWR2kCEXeoFq/Foq504G2Rx6QZ4kdKsU J4dv4XFZArvZmSMTjtYZahxy4oJLlMytQsoCVvmTit6r4nsS1cs2Z4dmd7WB5fp0IhRn 0UGfnY0syI8+ruz8Z9K2VCrquW7oSdNR+xqtD1j6CS0vVvwib6tZIFuqP1RrDJ6V1X0N cwq8WdolxtfNs8ikUsceD7AMyCv7IWBAmDs6pPeQLv5eyedN1iM6NiGgtk+vx1X/iQeO KVsEjfmsop0qNxFhlPoPbFuGjUODzfcdErI0Wk+DOMjtYCphZU7lvQ0GHGPaKJYuwlXe Krwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MAJ0DXHw; 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 ht8-20020a170907608800b0072b6a93c5ebsi23238502ejc.60.2022.07.27.11.29.14; Wed, 27 Jul 2022 11:29:39 -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=MAJ0DXHw; 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 S239108AbiG0Qiw (ORCPT + 99 others); Wed, 27 Jul 2022 12:38:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239127AbiG0QiR (ORCPT ); Wed, 27 Jul 2022 12:38:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43EBF5727E; Wed, 27 Jul 2022 09:28:31 -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 ams.source.kernel.org (Postfix) with ESMTPS id 905EBB821B8; Wed, 27 Jul 2022 16:28:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BADE9C433D6; Wed, 27 Jul 2022 16:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939288; bh=IpOo+pRYRlEAnKYKJwilqhsyqDHlsRNa311t/c7HpO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MAJ0DXHwZUdAZXL9yJlmWIqTH1/gnvwp3WIZc+FvpLcjJxdcx0QxSQoBcV7PZQI7y 54bTGjLeE9xlzi8iuc7kW6Lud7ggpJnkfhv36LlmbQ4wQjv9MMFrlT1Yyjl2DIy2oW tZW9SrCskRlJSshapw/7cvs2VhJYzBO+ByAxGgls= 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.4 08/87] PCI: hv: Reuse existing IRTE allocation in compose_msi_msg() Date: Wed, 27 Jul 2022 18:10:01 +0200 Message-Id: <20220727161009.353713651@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161008.993711844@linuxfoundation.org> References: <20220727161008.993711844@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 @@ -1387,6 +1387,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; @@ -1395,13 +1404,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;