Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp647542pxf; Thu, 8 Apr 2021 10:03:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf63L8tfttj9/99zNk0aHLqRJ8M5I1vpfG+gJsypPS1fddICmjSdPcYix+GHCeiLpFV5cy X-Received: by 2002:a17:902:ed15:b029:e8:fe5f:a28f with SMTP id b21-20020a170902ed15b02900e8fe5fa28fmr8636910pld.76.1617901407193; Thu, 08 Apr 2021 10:03:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617901407; cv=none; d=google.com; s=arc-20160816; b=OQoMuamMZQ5aG+vNCNnHRKEmFLvoZbyCeiwt+ufuTjII/9WumUp0CCApw/Hm4CW1EC Wl5CzGZYZ7IoZjH/fblw39f5u0WZinLQvXoCxhNeYsJQs7jnnlL0DVhIViaphNWns/eI BfkUq32vr4OENCuIoApwP2ZIENu9ItQv+9ze/1XSvK0HABfAj39Vz7JWp9QygB2x9Xzr 4fnoYX4Fz5hGDiDyYINCt8Gtbma5oijBrrb6M+m7ppvM9kBn5Dxf7JQpLd/unytXfGRL QmQ0SZG6BCWFTOG1yseoPMfPwUNtve/6lsAtz7tizRtQw5tf/uIZs1lPskr7aIWeV1ZV fvGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=2CUsJXeY+RSaU9jaasch5fmI8RII6yrY8/XYTJz/bk4=; b=U7InXE9B4qEZoXudyDzIkz3nvouVicT4xN3OYIOSV6AV9k/V87Eh+Jg8E4syg9wWkn DKa0qRmVQGxEJbPKg6cv1FEzV5QXUmH2Xswl9xUtNL+rEffau93xiOwvNMYhMxmwbl0h cSxSzOPhR7EXsBY68wySfBlgkaJEvMBEiC9AZv5FEzOWh/YXYVFAqtmibWyhmOsLdj60 7Y4LZK0FCl7d7Ji3XsL/Q8yDhc6JP/z76y9afsNRlAo5pR2Qy1BDXo6aWw/mA+j88Vs1 Gs8Dxx8/0DqDOQv+2pQoMSMnKU+t/7T0DeZqT+4YAXcHboWM1/9HDttuTi4UdMCUStCu /jmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=euwuqjHh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg12si7303033plb.381.2021.04.08.10.02.59; Thu, 08 Apr 2021 10:03:27 -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=@deltatee.com header.s=20200525 header.b=euwuqjHh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232547AbhDHRB7 (ORCPT + 99 others); Thu, 8 Apr 2021 13:01:59 -0400 Received: from ale.deltatee.com ([204.191.154.188]:36008 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231906AbhDHRBo (ORCPT ); Thu, 8 Apr 2021 13:01:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:Cc:To:From:content-disposition; bh=2CUsJXeY+RSaU9jaasch5fmI8RII6yrY8/XYTJz/bk4=; b=euwuqjHhNiXYE/+ic/tvOkvR6s BzwYeYVR0wXfmKMV03rqhrHvkhBL+kL4v4EwX6qc4tQA73FMs/tz0yKlGqiXyy59YdFD8ZiDyJl/X 1mUnk9khlFegFNEsgAE2yeYUgUMJNzmTlZgszw3XaDZTAIsiWoIU+7xoJb6tYc2nbmU+02GqbfAa/ aVEITQkNkKxTLJIZ+epQ2rSfRsmEFY0NiBJoOP8uztW9UojTOwXLwvrL46dQXNSY5FkdG0E0jyRcr tqcJ7EA0Ur4rXfZ5oERJt7EbLzVgLXfEASkyucGMx7izZ/affGZoOrt+quaF5NJyl7NelG21msg4P nv+Mz1NQ==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUY26-0002Lk-N1; Thu, 08 Apr 2021 11:01:32 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1lUY25-0002Im-3B; Thu, 08 Apr 2021 11:01:29 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Cc: Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , =?UTF-8?q?Christian=20K=C3=B6nig?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy , Logan Gunthorpe , Bjorn Helgaas Date: Thu, 8 Apr 2021 11:01:08 -0600 Message-Id: <20210408170123.8788-2-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210408170123.8788-1-logang@deltatee.com> References: <20210408170123.8788-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, sbates@raithlin.com, hch@lst.de, jgg@ziepe.ca, christian.koenig@amd.com, jhubbard@nvidia.com, ddutile@redhat.com, willy@infradead.org, daniel.vetter@ffwll.ch, jason@jlekstrand.net, dave.hansen@linux.intel.com, helgaas@kernel.org, dan.j.williams@intel.com, andrzej.jakowski@intel.com, dave.b.minturn@intel.com, jianxin.xiong@intel.com, ira.weiny@intel.com, robin.murphy@arm.com, logang@deltatee.com, bhelgaas@google.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH 01/16] PCI/P2PDMA: Pass gfp_mask flags to upstream_bridge_distance_warn() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to call upstream_bridge_distance_warn() from a dma_map function, it must not sleep. The only reason it does sleep is to allocate the seqbuf to print which devices are within the ACS path. Switch the kmalloc call to use a passed in gfp_mask and don't print that message if the buffer fails to be allocated. Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas --- drivers/pci/p2pdma.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 196382630363..bd89437faf06 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -267,7 +267,7 @@ static int pci_bridge_has_acs_redir(struct pci_dev *pdev) static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev) { - if (!buf) + if (!buf || !buf->buffer) return; seq_buf_printf(buf, "%s;", pci_name(pdev)); @@ -495,25 +495,26 @@ upstream_bridge_distance(struct pci_dev *provider, struct pci_dev *client, static enum pci_p2pdma_map_type upstream_bridge_distance_warn(struct pci_dev *provider, struct pci_dev *client, - int *dist) + int *dist, gfp_t gfp_mask) { struct seq_buf acs_list; bool acs_redirects; int ret; - seq_buf_init(&acs_list, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE); - if (!acs_list.buffer) - return -ENOMEM; + seq_buf_init(&acs_list, kmalloc(PAGE_SIZE, gfp_mask), PAGE_SIZE); ret = upstream_bridge_distance(provider, client, dist, &acs_redirects, &acs_list); if (acs_redirects) { pci_warn(client, "ACS redirect is set between the client and provider (%s)\n", pci_name(provider)); - /* Drop final semicolon */ - acs_list.buffer[acs_list.len-1] = 0; - pci_warn(client, "to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n", - acs_list.buffer); + + if (acs_list.buffer) { + /* Drop final semicolon */ + acs_list.buffer[acs_list.len - 1] = 0; + pci_warn(client, "to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n", + acs_list.buffer); + } } if (ret == PCI_P2PDMA_MAP_NOT_SUPPORTED) { @@ -566,7 +567,7 @@ int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients, if (verbose) ret = upstream_bridge_distance_warn(provider, - pci_client, &distance); + pci_client, &distance, GFP_KERNEL); else ret = upstream_bridge_distance(provider, pci_client, &distance, NULL, NULL); -- 2.20.1