From patchwork Fri Mar 8 00:18:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nirmal Patel X-Patchwork-Id: 13586376 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8B07139F for ; Fri, 8 Mar 2024 00:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709858353; cv=none; b=AQyfGhvdZNjKxsoebHYnkaHpmmRkI1TBurZ4seSjj4VK9cCX8ekMKGSuVHFteXKuO5IyH7ZXUmyFgYld7PnAZxO/r+5kAoK3AOsz0B2pXTKNGsgiDiiIpKADT9kXnPinOWqkFBieSlKyLm4B9zf9YtzdGOHbfRWeigMvu9Zvpms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709858353; c=relaxed/simple; bh=za1GZa/Y9ARoUCQGKPENlXIM90XXuVfLOsAvIFp/1vE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jUI5f+0/YE6NOXubTzT4nDmiPTPq0VbUGgqGDJXJQP4fyGDfJkTH+UQN6f282nxolWOev+TJsy9dG3BFYDjdB6xp8/VMnK4+PbFrjTN9wyO5IJ8DwNLAsboKa14zccPuEYupyXjCcckppl8x5i1jSApiqyTZr4Pbt+bNE5+STuQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ec2gjpDl; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ec2gjpDl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709858351; x=1741394351; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=za1GZa/Y9ARoUCQGKPENlXIM90XXuVfLOsAvIFp/1vE=; b=Ec2gjpDl6pkMxsgSksnPdvkP3mraGn/I0kHGAUhoUVif+PyiRtm2ca99 zOeRbsd2UF6l1UzfUnfzw5Ey99KGiAZ29FqfDbo77eT16nINaoptrPSCG gvybGCoW7yiKC5D54eqFX8H/ufHS/d8gQG+JoP+lyF24o+I0UG7Ge38rY y+ex5hVPburhHyJPs8fiXh1+XVILC7qiqk26ZByCoGfFCjP9gVthzt5fg Zgj0PobdWmWPfvTMToPn42/kQhPMvcvq/RaQVuPNwCoGgabk5UhkR1B+m 0VgrNJwArxFvJ+ukXEcIafcmmNrCMmggzGfLuKt/8JMRmmb4m0rNjnJ0O w==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="15705313" X-IronPort-AV: E=Sophos;i="6.07,107,1708416000"; d="scan'208";a="15705313" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 16:39:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,107,1708416000"; d="scan'208";a="14964228" Received: from unknown (HELO localhost.ch.intel.com) ([10.2.230.30]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 16:39:11 -0800 From: Nirmal Patel To: nirmal.patel@linux.intel.com, Cc: Dan Williams Subject: [PATCH] PCI: vmd: Disable MSI remap only for low MSI count Date: Thu, 7 Mar 2024 19:18:25 -0500 Message-Id: <20240308001825.4051-1-nirmal.patel@linux.intel.com> X-Mailer: git-send-email 2.31.1 Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 VMD MSI remapping is disabled by default for all the cpus with 28c0 VMD device. Initially MSI remapping was disabled for 28c0 to improve performance since VMD had only 64 vectors. Newer cpus with more VMD vectors doesn't see performance impact anymore. Keep MSI remapping enabled when vector count is more than active cpu in the system. Note, pci_msix_vec_count() failure is translated to ENODEV per typical expectations that drivers may return ENODEV when some driver-known fundamental detail of the device is missing. Signed-off-by: Nirmal Patel Acked-by: Dan Williams --- drivers/pci/controller/vmd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 769eedeb8802..09faa77d1b1f 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -807,13 +807,20 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) sd->node = pcibus_to_node(vmd->dev->bus); + vmd->msix_count = pci_msix_vec_count(dev); + if (vmd->msix_count < 0) + return -ENODEV; + /* * Currently MSI remapping must be enabled in guest passthrough mode * due to some missing interrupt remapping plumbing. This is probably * acceptable because the guest is usually CPU-limited and MSI * remapping doesn't become a performance bottleneck. + * There is no need to disable MSI remapping when VMD MSI count is + * more than cpus. */ if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) || + vmd->msix_count >= nr_cpu_ids || offset[0] || offset[1]) { ret = vmd_alloc_irqs(vmd); if (ret)