public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Logan Gunthorpe <logang@deltatee.com>
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI/P2PDMA: Fix missing check for dma_virt_ops
Date: Tue, 2 Jul 2019 18:37:26 -0500	[thread overview]
Message-ID: <20190702233726.GG128603@google.com> (raw)
In-Reply-To: <20190702173544.21950-1-logang@deltatee.com>

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 <logang@deltatee.com>

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
> 

      reply	other threads:[~2019-07-03  0:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-02 17:35 [PATCH] PCI/P2PDMA: Fix missing check for dma_virt_ops Logan Gunthorpe
2019-07-02 23:37 ` Bjorn Helgaas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190702233726.GG128603@google.com \
    --to=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=logang@deltatee.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox