From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E856FC5B57D for ; Wed, 3 Jul 2019 00:53:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B397B2184C for ; Wed, 3 Jul 2019 00:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562115198; bh=jOXGGlTtxKxUoZb4qZ8/SnpaBt3eFan28kHr8Q3ujSc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=04HNSsETqMyZU2ohQuzc3a7xghq7nXA0XF3EoMD/5WnpBbumy5iY1v6MP+Nb2U8Rs UuUqh5jy+fyGwmZJe/JsXBq1jk7eMrOHMtxYCbJ8t8TLu51+HeaOQVAMOkiUMKKko1 2lUjGuwWIj5VItJjycChchNaldNfdH9ADRLefx+o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726930AbfGCAxR (ORCPT ); Tue, 2 Jul 2019 20:53:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:47376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727092AbfGCAxF (ORCPT ); Tue, 2 Jul 2019 20:53:05 -0400 Received: from localhost (unknown [69.71.4.100]) (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 C1D9420B1F; Tue, 2 Jul 2019 23:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562110648; bh=jOXGGlTtxKxUoZb4qZ8/SnpaBt3eFan28kHr8Q3ujSc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q2qrTeTkiRv5BRUDGvR3KhEh7eRJEcJV/t9TQjTGVbuVFXawgLXl4iKY3PIevY1a5 gzCV0UqSy1wvthVyN7TclqnAc0jI/1yVcQ6qv1iUVY+xZEv9PREZDKygNkw6UMvMRn r95Dz0RFbhYpgjUd1w35MEmic7ObUfs9KbbT5ab8= Date: Tue, 2 Jul 2019 18:37:26 -0500 From: Bjorn Helgaas To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH] PCI/P2PDMA: Fix missing check for dma_virt_ops Message-ID: <20190702233726.GG128603@google.com> References: <20190702173544.21950-1-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190702173544.21950-1-logang@deltatee.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Tue, Jul 02, 2019 at 11:35:44AM -0600, Logan Gunthorpe wrote: > Drivers that use dma_virt_ops were meant to be rejected when testing > compatibility for P2PDMA. > > This check got inadvertantly dropped in one of the later versions of the > original patchset, so add it back. > > Fixes: 52916982af48 ("PCI/P2PDMA: Support peer-to-peer memory") > Signed-off-by: Logan Gunthorpe Applied to pci/peer-to-peer for v5.3, thanks! > --- > drivers/pci/p2pdma.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > index a4994aa3acc0..ab48babdf214 100644 > --- a/drivers/pci/p2pdma.c > +++ b/drivers/pci/p2pdma.c > @@ -487,6 +487,14 @@ int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients, > return -1; > > for (i = 0; i < num_clients; i++) { > + if (IS_ENABLED(CONFIG_DMA_VIRT_OPS) && > + clients[i]->dma_ops == &dma_virt_ops) { > + if (verbose) > + dev_warn(clients[i], > + "cannot be used for peer-to-peer DMA because the driver makes use of dma_virt_ops\n"); > + return -1; > + } > + > pci_client = find_parent_pci_dev(clients[i]); > if (!pci_client) { > if (verbose) > @@ -765,7 +773,7 @@ int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents, > * p2pdma mappings are not compatible with devices that use > * dma_virt_ops. If the upper layers do the right thing > * this should never happen because it will be prevented > - * by the check in pci_p2pdma_add_client() > + * by the check in pci_p2pdma_distance_many() > */ > if (WARN_ON_ONCE(IS_ENABLED(CONFIG_DMA_VIRT_OPS) && > dev->dma_ops == &dma_virt_ops)) > -- > 2.20.1 >