From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/2] common: dma-mapping: introduce dma_get_parent_cfg() helper
Date: Wed, 17 Dec 2014 22:56:47 +0100 [thread overview]
Message-ID: <1949667.gMcOLHe7Sk@wuerfel> (raw)
In-Reply-To: <1418839344-14393-2-git-send-email-m-karicheri2@ti.com>
On Wednesday 17 December 2014 13:02:23 Murali Karicheri wrote:
> Now, in Kernel, parent device's DMA parameters has to be applied to
> the child as is - to enable DMA support for the device. Usually this
> is happened in places where parent device manually instantiates child
> device such as in drivers/pci/probe.c (pci_device_add() for example).
>
> Now DMA configuration is represented in device data structure not only
> by DMA mask and DMA params, it also includes dma_pfn_offset at least.
> Hence introduce common dma_get_parent_cfg() helper to apply dma
> configuration from parent to child, and use __weak to allow arch to
> override it if needed.
>
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> ---
> drivers/base/dma-mapping.c | 18 ++++++++++++++++++
> include/linux/dma-mapping.h | 3 +++
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
> index 9e8bbdd..5322426 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -339,3 +339,21 @@ void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags)
> vunmap(cpu_addr);
> }
> #endif
> +
> +int __weak dma_get_parent_cfg(struct device *dev, struct device *parent)
> +{
> + struct device *temp = parent;
> +
> + if (!temp)
> + temp = dev->parent;
> +
> + if (temp && is_device_dma_capable(temp)) {
> + dev->dma_mask = temp->dma_mask;
> + dev->coherent_dma_mask = temp->coherent_dma_mask;
As discussed, setting the pointers like this is always wrong,
so don't do it.
What's wrong with using arch_setup_dma_ops() from PCI as suggested
previously?
Arnd
next prev parent reply other threads:[~2014-12-17 21:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-17 18:02 [RFC PATCH 0/2] PCI: get DMA configuration from parent device Murali Karicheri
2014-12-17 18:02 ` [RFC PATCH 1/2] common: dma-mapping: introduce dma_get_parent_cfg() helper Murali Karicheri
2014-12-17 21:56 ` Arnd Bergmann [this message]
2014-12-17 23:24 ` Murali Karicheri
2014-12-18 0:09 ` Arnd Bergmann
2014-12-18 17:20 ` Catalin Marinas
2014-12-21 10:42 ` Will Deacon
2014-12-18 19:02 ` Murali Karicheri
2014-12-17 18:02 ` [RFC PATCH 2/2] PCI: get device dma configuration from parent Murali Karicheri
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=1949667.gMcOLHe7Sk@wuerfel \
--to=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).