All of lore.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] ARM64: PCI: inherit root controller's dma-coherent
Date: Thu, 27 Nov 2014 10:03:38 +0100	[thread overview]
Message-ID: <2081877.zLc8dS8vkP@wuerfel> (raw)
In-Reply-To: <1417066891-16789-1-git-send-email-ming.lei@canonical.com>

On Thursday 27 November 2014 13:41:31 Ming Lei wrote:

> @@ -37,6 +38,21 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
>  	return res->start;
>  }
>  
> +/* Inherit root controller's dma coherent ops */
> +static void pci_dma_config(struct pci_dev *dev)
> +{
> +	struct pci_bus *bus = dev->bus;
> +	struct device *host;
> +
> +	while (!pci_is_root_bus(bus)) {
> +		bus = bus->parent;
> +	}
> +
> +	host = bus->dev.parent->parent;
> +	if (of_dma_is_coherent(host->of_node))
> +		set_arch_dma_coherent_ops(&dev->dev);
> +}
> +

I think we need something more generic than this: This is not architecture
specific at all, and we have to deal with IOMMU, swiotlb, dma offset and
dma mask as well, coherency is definitely not the only issue.

We have the of_dma_configure() function that does some of this for platform
devices and that have to extend to make it work with IOMMUs, and the
common pci_device_add() function does some other subset in architecture
independent code for PCI, so I think that's where it should go.
We will need an architecture-specific helper to set the dma_map_ops
pointer, dma_parms, dma offset, and the iommu, but that is not PCI
specific, it just gets called from both the platform device and pci
device code.

Regarding the pcibios_add_device() function, I'd rather see the existing
code moved into the PCI core and the function removed, since it also
is not architecture specific. We should be able to delete the entire
arm64/pci.c file eventually.

	Arnd

  parent reply	other threads:[~2014-11-27  9:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-27  5:41 [RFC PATCH] ARM64: PCI: inherit root controller's dma-coherent Ming Lei
2014-11-27  7:39 ` Jon Masters
2014-11-27  9:05   ` Arnd Bergmann
2014-11-27 11:36     ` Catalin Marinas
2014-11-27 11:53       ` Arnd Bergmann
2014-11-27  9:03 ` Arnd Bergmann [this message]
2014-11-27 10:14   ` Ming Lei
2014-11-27 10:14     ` Ming Lei
2014-11-27 10:22   ` Will Deacon
2014-12-04  3:40   ` Ming Lei
2014-12-05 13:26     ` Grygorii Strashko
2014-12-05 16:05       ` Arnd Bergmann
2014-12-09  2:53         ` Ming Lei
2014-12-10 16:06           ` Arnd Bergmann
2014-12-10 16:23             ` Robin Murphy

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=2081877.zLc8dS8vkP@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 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.