Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2023500ybg; Thu, 30 Jul 2020 08:30:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR5s+zXBYgeoKEjvdE1VAx3elUde4EaNdk/p3lZEWGrgtisn/DlUXJCFELCfGLz/LaxIHa X-Received: by 2002:a17:907:204e:: with SMTP id pg14mr3274160ejb.324.1596123035609; Thu, 30 Jul 2020 08:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596123035; cv=none; d=google.com; s=arc-20160816; b=NY824AlHrbxkbZHV3tJNanp8q9bzAEW7wJtsFtf+iXt72MDIaZtnoE+oqCjQH5B8LX 5090Ntclnbk6/36/Uc0M8eAGcQqg9OG6BeVXpTD4ado9BOfhlLdnvsBfa+BKPL+fWlir 7511CKOdSikWqrq/yT0soBNJrCsxdguPnfUJgwnuwHSkX4NlfBbNrEkOMPt/EhyrwQz1 x2rc8EcZkQAiPIq3UL/bM7BkDc9ox1aPi+fDQydVyxqJAFpMcfgR5QTQLh9unh1NrKYu B/3abqhkTwoi+HA42yZLMuplambQkHLSsUf/xEgkxt+h/nqoDrQzHwGilZfKehkgdspU 7MMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=3Kpt0eMh0JE0v1mi85Gx4R5PNep4ax2wJ47jr3ESmQQ=; b=vz4HFsXt6wh3c5J55mXiSQBtrbPnyN5972MPS5yopsbuqMJr2B2HsR1ZqtWZ8xnZGD vb9aqtRJ2/FuZAahcFstj5x6gkRVs+3CY9exFol76L5pdsQqHYoe1yi6E6iV0m8HO77b 0otwRNyNdcdUbpV8DApCIprGAe6dOPW7kkH9DkjslEkmAPYcpGproIBOf8h/2+6Lfty8 YSeWRDCU1r/5fJ1aCbgGujxGQ9/+8Td04VENZo/zeLNUfheprq8Paxrx6JhCKeC9eZPA f7S6prASJpqNbb/sqgEGU7IBykIm92dg4tdELD+HOqfTtMJlbwMEtBRaTZKKI83jnlqS Vmsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="FiDyM/K3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l21si3280979ejx.722.2020.07.30.08.30.13; Thu, 30 Jul 2020 08:30:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="FiDyM/K3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729778AbgG3P1R (ORCPT + 99 others); Thu, 30 Jul 2020 11:27:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:60142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbgG3P1N (ORCPT ); Thu, 30 Jul 2020 11:27:13 -0400 Received: from localhost (mobile-166-175-62-240.mycingular.net [166.175.62.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2752E20829; Thu, 30 Jul 2020 15:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596122832; bh=KCyq/zOj5qNJ2u6DpNndotsDRFFpeiKIXrv4aEsMJKY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=FiDyM/K3WXa4OsjNfuAXQZEuHxIna/1+4SXUrzaHELeqDig8rBQTLr1+B8AcuXMuL UmIEL+Ys/GWJ/oLVJDViCHAsIUi4yXry1nrfmWKb4NPatO01Wwd+Xtersxv0MGE5nn ePlzes8VcumqqZnHqR48si433BmvVZArHu4M+lqA= Date: Thu, 30 Jul 2020 10:27:07 -0500 From: Bjorn Helgaas To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , Huang Rui Subject: Re: [PATCH v2] PCI/P2PDMA: Allow P2PDMA on all AMD CPUs newer than the Zen family Message-ID: <20200730152707.GA2037922@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200729231844.4653-1-logang@deltatee.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 29, 2020 at 05:18:44PM -0600, Logan Gunthorpe wrote: > In order to avoid needing to add every new AMD CPU host bridge to the list > every cycle, allow P2PDMA if the CPUs vendor is AMD and family is > greater than 0x17 (Zen). > > This should cut down a bunch of the churn adding to the list of allowed > host bridges. > > Signed-off-by: Logan Gunthorpe > Cc: Bjorn Helgaas > Cc: Alex Deucher > Cc: Christian K?nig > Cc: Huang Rui Thanks, applied as below with Alex's reviewed-by to pci/peer-to-peer for v5.9. I had to enable CONFIG_MEMORY_HOTREMOVE and CONFIG_ZONE_DEVICE in order to compile p2pdma.c. I see some reasons why that is, but it's not exactly intuitive, especially for MEMORY_HOTREMOVE. commit dea286bb71ba ("PCI/P2PDMA: Allow P2PDMA on AMD Zen and newer CPUs") Author: Logan Gunthorpe Date: Wed Jul 29 17:18:44 2020 -0600 PCI/P2PDMA: Allow P2PDMA on AMD Zen and newer CPUs Allow P2PDMA if the CPU vendor is AMD and family is 0x17 (Zen) or greater. [bhelgaas: commit log, simplify #if/#else/#endif] Link: https://lore.kernel.org/r/20200729231844.4653-1-logang@deltatee.com Signed-off-by: Logan Gunthorpe Signed-off-by: Bjorn Helgaas Reviewed-by: Alex Deucher Cc: Christian K?nig Cc: Huang Rui diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index e8e444eeb1cd..1ec61fced4c3 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -273,6 +273,19 @@ static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev) seq_buf_printf(buf, "%s;", pci_name(pdev)); } +static bool cpu_supports_p2pdma(void) +{ +#ifdef CONFIG_X86 + struct cpuinfo_x86 *c = &cpu_data(0); + + /* Any AMD CPU whose family ID is Zen or newer supports p2pdma */ + if (c->x86_vendor == X86_VENDOR_AMD && c->x86 >= 0x17) + return true; +#endif + + return false; +} + static const struct pci_p2pdma_whitelist_entry { unsigned short vendor; unsigned short device; @@ -280,11 +293,6 @@ static const struct pci_p2pdma_whitelist_entry { REQ_SAME_HOST_BRIDGE = 1 << 0, } flags; } pci_p2pdma_whitelist[] = { - /* AMD ZEN */ - {PCI_VENDOR_ID_AMD, 0x1450, 0}, - {PCI_VENDOR_ID_AMD, 0x15d0, 0}, - {PCI_VENDOR_ID_AMD, 0x1630, 0}, - /* Intel Xeon E5/Core i7 */ {PCI_VENDOR_ID_INTEL, 0x3c00, REQ_SAME_HOST_BRIDGE}, {PCI_VENDOR_ID_INTEL, 0x3c01, REQ_SAME_HOST_BRIDGE}, @@ -473,7 +481,8 @@ upstream_bridge_distance(struct pci_dev *provider, struct pci_dev *client, acs_redirects, acs_list); if (map_type == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE) { - if (!host_bridge_whitelist(provider, client)) + if (!cpu_supports_p2pdma() && + !host_bridge_whitelist(provider, client)) map_type = PCI_P2PDMA_MAP_NOT_SUPPORTED; }