Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5544070iob; Mon, 9 May 2022 20:07:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2QLbsyJ3gSIUqM/6N6KIB3wbO+dGAAjqv8OIkjCZlrT+i34bkUfl/MRVNpVA3qsgL8q2r X-Received: by 2002:a17:907:3f8a:b0:6f4:3f00:b1e9 with SMTP id hr10-20020a1709073f8a00b006f43f00b1e9mr17736531ejc.59.1652152073563; Mon, 09 May 2022 20:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652152073; cv=none; d=google.com; s=arc-20160816; b=IM/nn7tMHvGjW/OK7Cxbi7Seriewhxv+jWE74QbQOiGwMIvdkrQf13a+eQTOY1tFp9 DQzwGYuSVCmlfV4QCdLMEzw+A1BXEZMJV8GmWzWVH/O8WSAlI/pdLNREVPPUsJdwEN91 Gxq6WOzlZJwRRQsdL0dw6HAkNgue1prqUJXVWIhzRsG0hn8I/aYYNXYWBM3vnyLECF69 RRtcwutqtn3Slx6Gvzx91gRfux6mqAD684KiFQKRHmgOwmswjAe9pnXbIAMF1lMRBmGY oFv9GECClwh2rKlZZ+qjiiAMP9eoNwMI+wo7uAOVhZ3jQyFQXSeTejXpcVZcKoOLHK5j R7tw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kSh9rognUJ9GvISoKyUUnljnlRfgqjYQC5CisD4UWYY=; b=jEmlbfc27cmgsQp1wQgl4M+W1AJ+2BD66J1n9f8D//9wotOgZWrZ5Qye0dmknV4bff O7MDDi8Vvlrz+pVpG7gyp+AS1wr9/+4D/3oqyvXv8sUhv6Ty/dhy2kJxtegfYiUjTpNB GGvh3EWsso1UztpiKRnYznCM0BrXKZsUAQm3c5ttZ9MCbg9LV9lI1sEm8cuWe5CiGRaS Sg8B103vBNnvgCJyR51WYyLR8x/ilKhgM/CS50X8WdG0ihUNtRMTgXOiKTPyM1WJsrls RpymW/0LT5GTkbEQYvSDMSnsAaxBqn7xdOOV3JBPU2xoZV6f9qSIorz/M6h2abbE36xu cicQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=KpBp7f0S; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ba8-20020a0564021ac800b00425f8552b6asi13998316edb.195.2022.05.09.20.07.29; Mon, 09 May 2022 20:07:53 -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=@quicinc.com header.s=qcdkim header.b=KpBp7f0S; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230472AbiEIVzB (ORCPT + 99 others); Mon, 9 May 2022 17:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231309AbiEIVxt (ORCPT ); Mon, 9 May 2022 17:53:49 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9246D2CBF9A; Mon, 9 May 2022 14:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1652132925; x=1683668925; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kSh9rognUJ9GvISoKyUUnljnlRfgqjYQC5CisD4UWYY=; b=KpBp7f0SfO8iQPereyCpnwGx6PTV4aYefWyq0E0xJx1o0JWjtMetN9WX ZAXu+3dACs68FaIbFetx0z4aElXF7uW37hJGpSWywSE3g7fdb8XKeN3MZ iXg6Qt4PV5LkJS9oGZ/Mbdqjhk8hgUxvkcfol5KXb92CmTgAcf+X8RHV6 o=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 09 May 2022 14:48:43 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 14:48:42 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 9 May 2022 14:48:37 -0700 Received: from jhugo-lnx.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 9 May 2022 14:48:35 -0700 From: Jeffrey Hugo To: , , , , , , , , CC: , , , , , Jeffrey Hugo Subject: [PATCH 1/2] PCI: hv: Reuse existing ITRE allocation in compose_msi_msg() Date: Mon, 9 May 2022 15:48:21 -0600 Message-ID: <1652132902-27109-2-git-send-email-quic_jhugo@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1652132902-27109-1-git-send-email-quic_jhugo@quicinc.com> References: <1652132902-27109-1-git-send-email-quic_jhugo@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Currently if compose_msi_msg() is called multiple times, it will free any previous ITRE allocation, and generate a new allocation. While nothing prevents this from occurring, it is extranious when Linux could just reuse the existing allocation and avoid a bunch of overhead. However, when future ITRE 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 --- drivers/pci/controller/pci-hyperv.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index cf2fe575..5e2e637 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1707,6 +1707,15 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) 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; @@ -1716,13 +1725,6 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) 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; -- 2.7.4