From: Tomasz Figa <tfiga@chromium.org>
To: Robin Murphy <robin.murphy@arm.com>
Cc: "open list:IOMMU DRIVERS" <iommu@lists.linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will.deacon@arm.com>,
Vineet Gupta <vgupta@synopsys.com>,
Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>,
Mitchel Humpherys <mitchelh@codeaurora.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [RFC PATCH 4/5] iommu/dma: Export non-static functions to use in modules
Date: Thu, 6 Jul 2017 11:25:09 +0900 [thread overview]
Message-ID: <CAAFQd5C3P7Rpohq=5xoBs1mUtbQ63FbQ80-Rm08JEY-iDyipYA@mail.gmail.com> (raw)
In-Reply-To: <d02d47f2-8e89-ddba-54d9-1d1f52ae394a@arm.com>
On Thu, Jul 6, 2017 at 1:22 AM, Robin Murphy <robin.murphy@arm.com> wrote:
> On 05/07/17 08:12, Tomasz Figa wrote:
>> There is nothing wrong in having a loadable module implementing DMA API,
>> for example to be used for sub-devices registered by the module. However,
>> most of the functions from dma-iommu do not have their symbols exported,
>> making it impossible to use them from loadable modules.
>>
>> Export all the non-static functions in the file, so that loadable modules
>> can benefit from them. Use EXPORT_SYMBOL() for consistency with other
>> exports in the file.
>
> To echo what Christoph said, everything not already exported here
> shouldn't in any way be considered a driver-facing API in the general
> sense, it's horrible glue code to sit behind an arch-specific DMA
> mapping implementation (and frankly I'd consider even the current
> exports more of an unfortunate abstraction leakage).
Well, if I remember correctly, we agreed that the IPU3 driver would
benefit from using all the iommu_dma_*() helpers in its DMA ops,
similarly to ARM64. This is IMHO much better than re-implementing them
again internally just for this driver. However almost none of
necessary helpers are currently exported...
>
>> Signed-off-by: Tomasz Figa <tfiga@chromium.org>
>> ---
>
> [...]
>
>> @@ -829,17 +838,20 @@ dma_addr_t iommu_dma_map_resource(struct device *dev, phys_addr_t phys,
>> return __iommu_dma_map(dev, phys, size,
>> dma_info_to_prot(dir, false, attrs) | IOMMU_MMIO);
>> }
>> +EXPORT_SYMBOL(iommu_dma_map_resource);
>>
>> void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle,
>> size_t size, enum dma_data_direction dir, unsigned long attrs)
>> {
>> __iommu_dma_unmap(iommu_get_domain_for_dev(dev), handle, size);
>> }
>> +EXPORT_SYMBOL(iommu_dma_unmap_resource);
>
> Do you need these two? Unless your custom DMA ops really have to support
> slave DMA or other peer-to-peer traffic through their IOMMU, I'd be more
> inclined to implement dma_map_resource as "return 0;" and ignore
> dma_unmap_resource.
I don't need them. Getting an idea what is desirable to export and
what not is actually one of the goals of this RFC.
>
>> @@ -913,3 +925,4 @@ void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg)
>> msg->address_lo += lower_32_bits(msi_page->iova);
>> }
>> }
>> +EXPORT_SYMBOL(iommu_dma_map_msi_msg);
>
> Given the nature of the kind of irqchip drivers this exists for, the
> chances of one ever being modular seem vanishingly small.
Agreed. The IPU3 driver does not need it either.
Let me list the (not yet exported) helpers it requires:
dma-iommu.c
- iommu_dma_init,
- dma_info_to_prot,
- iommu_dma_free,
- iommu_dma_alloc,
- iommu_dma_mmap,
- iommu_dma_map_page,
- iommu_dma_unmap_page,
- iommu_dma_map_sg,
- iommu_dma_unmap_sg,
- iommu_dma_mapping_error,
(added by my patch) iommu_dma_cleanup,
iommu.c
- iommu_group_get_for_dev,
base/dma-mapping.c
- dma_common_pages_remap,
- dma_common_free_remap,
(added by my patch) dma_common_get_mapped_pages (OR find_vm_area),
Best regards,
Tomasz
next prev parent reply other threads:[~2017-07-06 2:25 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-05 7:12 [RFC PATCH 0/5] Fixes for loadable modules implementing DMA/IOMMU APIs Tomasz Figa
2017-07-05 7:12 ` [RFC PATCH 1/5] base: dma-mapping: Export commonly used symbols Tomasz Figa
2017-07-05 15:17 ` Christoph Hellwig
2017-07-05 15:22 ` Tomasz Figa
2017-07-05 17:20 ` Christoph Hellwig
2017-07-06 1:44 ` Tomasz Figa
2017-07-06 8:26 ` Arnd Bergmann
2017-07-06 8:34 ` Tomasz Figa
2017-07-06 8:36 ` Tomasz Figa
2017-07-06 12:23 ` Arnd Bergmann
2017-07-06 13:31 ` Tomasz Figa
2017-07-06 13:49 ` Tomasz Figa
2017-07-06 14:02 ` Arnd Bergmann
2017-07-06 14:06 ` Tomasz Figa
2017-07-06 14:27 ` Arnd Bergmann
2017-07-06 14:35 ` Tomasz Figa
2017-07-06 13:56 ` Arnd Bergmann
2017-07-05 7:12 ` [RFC PATCH 2/5] base: dma-mapping: Provide a function to look up remapped pages Tomasz Figa
2017-07-05 7:12 ` [RFC PATCH 3/5] iommu: Export non-static functions to use in modules Tomasz Figa
2017-07-05 7:12 ` [RFC PATCH 4/5] iommu/dma: " Tomasz Figa
2017-07-05 16:22 ` Robin Murphy
2017-07-06 2:25 ` Tomasz Figa [this message]
2017-07-06 11:09 ` Robin Murphy
2017-07-06 14:10 ` Christoph Hellwig
2017-07-06 14:17 ` Tomasz Figa
2017-07-06 14:24 ` Tomasz Figa
2017-07-06 14:35 ` Arnd Bergmann
2017-07-06 14:41 ` Tomasz Figa
2017-07-05 7:12 ` [RFC PATCH 5/5] iommu/dma: Add iommu_dma_cleanup() Tomasz Figa
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='CAAFQd5C3P7Rpohq=5xoBs1mUtbQ63FbQ80-Rm08JEY-iDyipYA@mail.gmail.com' \
--to=tfiga@chromium.org \
--cc=arnd@arndb.de \
--cc=egtvedt@samfundet.no \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mitchelh@codeaurora.org \
--cc=robin.murphy@arm.com \
--cc=vgupta@synopsys.com \
--cc=will.deacon@arm.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
all inboxes | Powered by JetHome®