From: Christoph Hellwig <hch@lst.de>
To: Max Gurtovoy <maxg@mellanox.com>
Cc: linux-pci@vger.kernel.org, hch@lst.de, fbarrat@linux.ibm.com,
clsoto@us.ibm.com, idanw@mellanox.com, aneela@mellanox.com,
shlomin@mellanox.com
Subject: Re: [PATCH 1/2] powerpc/dma: Define map/unmap mmio resource callbacks
Date: Fri, 17 Apr 2020 08:55:48 +0200 [thread overview]
Message-ID: <20200417065548.GB18880@lst.de> (raw)
In-Reply-To: <20200416165725.206741-1-maxg@mellanox.com>
> dma_direct_unmap_sg(dev, sglist, nelems, direction, attrs);
> }
>
> +static dma_addr_t dma_iommu_map_resource(struct device *dev,
> + phys_addr_t phys_addr, size_t size,
> + enum dma_data_direction dir,
> + unsigned long attrs)
> +{
> + struct pci_dev *pdev = to_pci_dev(dev);
> + struct pci_controller *phb = pci_bus_to_host(pdev->bus);
> +
> + if (dma_iommu_map_bypass(dev, attrs)) {
> + if (phb->controller_ops.dma_map_resource &&
> + phb->controller_ops.dma_map_resource(pdev, phys_addr, size,
> + dir))
> + return DMA_MAPPING_ERROR;
> + return dma_direct_map_resource(dev, phys_addr, size,
> + dir, attrs);
> + }
> + return DMA_MAPPING_ERROR;
Just a nitpick, but to the return errors early would be a much more
logical flow. Also if the callback just decides if the mapping is
possible in bypass mode it should have that in the name:
struct pci_controller_ops *ops = &phb->controller_ops;
if (!dma_iommu_map_bypass(dev, attrs) ||
!ops->dma_can_direct_map_resource ||
!ops->dma_can_direct_map_resource(pdev, phys_addr, size, dir)
return DMA_MAPPING_ERROR;
return dma_direct_map_resource(dev, phys_addr, size, dir, attrs);
> + if (dma_iommu_map_bypass(dev, attrs)) {
> + if (phb->controller_ops.dma_unmap_resource)
> + phb->controller_ops.dma_unmap_resource(pdev, dma_handle,
> + size, dir);
> + }
This can do a little early return as well, coupled with a WARN_ON_ONCE
as we should never end up in the unmap path for a setup where the map didn't
work.
next prev parent reply other threads:[~2020-04-17 6:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-16 16:57 [PATCH 1/2] powerpc/dma: Define map/unmap mmio resource callbacks Max Gurtovoy
2020-04-16 16:57 ` [PATCH 2/2] powerpc/powernv: Enable and setup PCI P2P Max Gurtovoy
2020-04-17 7:02 ` Christoph Hellwig
2020-04-17 11:16 ` Max Gurtovoy
2020-04-17 14:04 ` Oliver O'Halloran
2020-04-19 11:46 ` Max Gurtovoy
2020-04-17 6:55 ` Christoph Hellwig [this message]
2020-04-19 10:14 ` [PATCH 1/2] powerpc/dma: Define map/unmap mmio resource callbacks Max Gurtovoy
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=20200417065548.GB18880@lst.de \
--to=hch@lst.de \
--cc=aneela@mellanox.com \
--cc=clsoto@us.ibm.com \
--cc=fbarrat@linux.ibm.com \
--cc=idanw@mellanox.com \
--cc=linux-pci@vger.kernel.org \
--cc=maxg@mellanox.com \
--cc=shlomin@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.