mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Will Deacon <will.deacon@arm.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"Ian.Campbell@citrix.com" <Ian.Campbell@citrix.com>,
	"konrad.wilk@oracle.com" <konrad.wilk@oracle.com>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"david.vrabel@citrix.com" <david.vrabel@citrix.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v7 3/8] arm64: introduce is_device_dma_coherent
Date: Tue, 4 Nov 2014 15:00:18 +0000	[thread overview]
Message-ID: <alpine.DEB.2.02.1411041419490.22875@kaball.uk.xensource.com> (raw)
In-Reply-To: <5458B9FC.3050309@ti.com>

On Tue, 4 Nov 2014, Grygorii Strashko wrote:
> Hi Stefano,
> 
> On 11/03/2014 01:10 PM, Stefano Stabellini wrote:
> > On Mon, 3 Nov 2014, Will Deacon wrote:
> >> On Mon, Nov 03, 2014 at 10:46:03AM +0000, Stefano Stabellini wrote:
> >>> On Mon, 27 Oct 2014, Stefano Stabellini wrote:
> >>>> Introduce a boolean flag and an accessor function to check whether a
> >>>> device is dma_coherent. Set the flag from set_arch_dma_coherent_ops.
> >>>>
> >>>> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> >>>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> >>>> CC: will.deacon@arm.com
> >>>
> >>> Will, Catalin,
> >>> are you OK with this patch?
> >>
> >> It would be nicer if the dma_coherent flag didn't have to be duplicated by
> >> each architecture in dev_archdata. Is there any reason not to put it in the
> >> core code?
> > 
> > Yes, there is a reason for it: if I added a boolean dma_coherent flag in
> > struct device as Catalin initially suggested, what would be the default
> > for each architecture? Where would I set it for arch that don't use
> > device tree? It is not easy.
> > 
> > I thought it would be better to introduce is_device_dma_coherent only on
> > the architectures where it certainly makes sense to have it. In fact I
> > checked and arm and arm64 are the only architectures to define
> > set_arch_dma_coherent_ops at the moment. At that point if
> > is_device_dma_coherent becomes arch-specific, it makes sense to store
> > the flag in dev_archdata instead of struct device.
> 
> The proposition from Will looks reasonable for me too, because
> there is "small" side-effect of adding such kind of properties to
> arch-specific data or even to the core device structure. ;(
> 
> There are some sub-systems in kernel which do not create their devices
> from DT and instead some host device populates its children devices manually.
>  Now, I know at least two cases:
> - usb: dwc3 core creates xhci device manually
> - pci: adds its client devices
> 
> In such, case DMA configuration have to be propagated from host to
> child (in our case host device's got DMA configuration from DT), like:
> 	dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask);
> 
> 	xhci->dev.parent	= dwc->dev;
> 	xhci->dev.dma_mask	= dwc->dev->dma_mask;
> 	xhci->dev.dma_parms	= dwc->dev->dma_parms;
> 
> So, once new DMA property is added it has to be propagated from 
> host to child device too.
> 
> Recently, the new property  dma_pfn_offset was introduced in struct device 
> and such kind of problem was observed on keystone 2:
> - for usb case it was fixed using Platform Bus notifier (xhci - platform device)
> - for pci - the work is in progress, because solution with PCI Bus notifier
>   was rejected https://lkml.org/lkml/2014/10/10/308.
> 
> In general, if dma_coherent will belong to struct device then
> such problems will be possible to fix directly in drivers/subsystems:
> xhci->dev.dma_coherent	= dwc->dev->dma_coherent;
> 
> But, if it will be arch-specific data then it will be impossible to
> set it without introducing proper and arch-specific setters/getters functions.
>
> Also, as an idea, we are thinking about introducing something like:
>   void dma_apply_parent_cfg(struct device *dev, struct device *parent)
> which will ensure that all DMA configuration properly copied from
> parent to children device. Now it should be (as minimum for ARM):
>  dma_mask
>  coherent_dma_mask
>  dma_parms
>  dma_pfn_offset
>  dev_archdata->dma_ops
>  [dma_coherent]?

I understand your concern but the problem you have goes far beyond a
simple dma_coherent flag: what about all the other dev_archdata fields?
Aside from dma_ops, on some other architectures there might be other
data structrures in dev_archdata that need to be properly initialized
from the parent.

Your idea of introducing something like dma_apply_parent_cfg is the only
solid solution I can see.  However I would consider naming it something
more generic like init_dev_from_parent to handle other possible
configurations (inside or outside dev_archdata) that might have to be
initialized from information on the parent device.


Regarding the dma_coherent flag, I still prefer this approach because
introducing the dma_coherent flag in dev_archdata wouldn't make this
issue any worse than already is, but would avoid other problems as
mentioned in my previous reply.

  reply	other threads:[~2014-11-04 15:00 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-27 15:08 [PATCH v7 0/8] introduce GNTTABOP_cache_flush Stefano Stabellini
2014-10-27 15:09 ` [PATCH v7 1/8] xen/arm: remove handling of XENFEAT_grant_map_identity Stefano Stabellini
2014-10-27 15:09 ` [PATCH v7 2/8] xen/arm: remove outer_*_range call Stefano Stabellini
2014-10-27 15:09 ` [PATCH v7 3/8] arm64: introduce is_device_dma_coherent Stefano Stabellini
2014-11-03 10:46   ` Stefano Stabellini
2014-11-03 10:57     ` Will Deacon
2014-11-03 11:10       ` Stefano Stabellini
2014-11-04 11:35         ` Grygorii Strashko
2014-11-04 15:00           ` Stefano Stabellini [this message]
2014-11-05 16:56         ` Catalin Marinas
2014-11-05 18:15           ` Stefano Stabellini
2014-11-06 10:33             ` Catalin Marinas
2014-11-06 12:22               ` Stefano Stabellini
2014-11-06 13:40                 ` Catalin Marinas
2014-11-07 11:05                 ` Catalin Marinas
2014-11-07 11:11                   ` Catalin Marinas
2014-11-07 14:10                     ` Stefano Stabellini
2014-11-07 14:10                   ` Stefano Stabellini
2014-11-07 16:00                     ` Catalin Marinas
2014-11-07 17:24                       ` Stefano Stabellini
2014-11-07 17:35                         ` Stefano Stabellini
2014-11-07 18:14                           ` Catalin Marinas
2014-11-07 18:45                             ` Stefano Stabellini
2014-11-10 10:16                               ` Catalin Marinas
2014-11-10 12:35                                 ` Stefano Stabellini
2014-11-10 12:41                                   ` Stefano Stabellini
2014-10-27 15:09 ` [PATCH v7 4/8] arm: " Stefano Stabellini
2014-11-03 10:55   ` Stefano Stabellini
2014-10-27 15:09 ` [PATCH v7 5/8] xen/arm: use is_device_dma_coherent Stefano Stabellini
2014-10-27 15:09 ` [PATCH v7 6/8] xen/arm/arm64: merge xen/mm32.c into xen/mm.c Stefano Stabellini
2014-11-07 14:22   ` Catalin Marinas
2014-11-07 15:28     ` Stefano Stabellini
2014-11-07 16:03       ` Catalin Marinas
2014-11-07 16:46         ` Stefano Stabellini
2014-10-27 15:09 ` [PATCH v7 7/8] xen/arm/arm64: introduce xen_arch_need_swiotlb Stefano Stabellini
2014-11-03 10:45   ` Stefano Stabellini
2014-11-03 11:01     ` [Xen-devel] " David Vrabel
2014-11-03 16:04     ` Konrad Rzeszutek Wilk
2014-10-27 15:09 ` [PATCH v7 8/8] xen/arm: introduce GNTTABOP_cache_flush Stefano Stabellini

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=alpine.DEB.2.02.1411041419490.22875@kaball.uk.xensource.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=grygorii.strashko@ti.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will.deacon@arm.com \
    --cc=xen-devel@lists.xensource.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®