All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Stefano Stabellini <sstabellini@kernel.org>, linux@armlinux.org.uk
Cc: xen-devel@lists.xen.org, will.deacon@arm.com,
	linux-kernel@vger.kernel.org, Julien Grall <julien.grall@arm.com>,
	boris.ostrovsky@oracle.com, linux-arm-kernel@lists.infradead.org,
	catalin.marinas@arm.com
Subject: Re: [PATCH 1/2] xen/arm, arm64: fix xen_dma_ops after 815dd18 "Consolidate get_dma_ops..."
Date: Wed, 19 Apr 2017 20:20:00 +0200	[thread overview]
Message-ID: <a4e371e4-44ff-ee6d-22b6-3ff9d57ce421@suse.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1704191023120.31486@sstabellini-ThinkPad-X260>

On 19/04/17 19:25, Stefano Stabellini wrote:
> Hello Russell,
> 
> Can I have your acked-by on the following fix (original patch is
> 1492117462-19886-1-git-send-email-sstabellini@kernel.org)?

Stefano, through which tree should this go? ARM or Xen or other?


Juergen

> 
> Thanks,
> 
> Stefano
> 
> 
> On Tue, 18 Apr 2017, Catalin Marinas wrote:
>> On Thu, Apr 13, 2017 at 02:04:21PM -0700, Stefano Stabellini wrote:
>>> The following commit:
>>>
>>>   commit 815dd18788fe0d41899f51b91d0560279cf16b0d
>>>   Author: Bart Van Assche <bart.vanassche@sandisk.com>
>>>   Date:   Fri Jan 20 13:04:04 2017 -0800
>>>
>>>       treewide: Consolidate get_dma_ops() implementations
>>>
>>> rearranges get_dma_ops in a way that xen_dma_ops are not returned when
>>> running on Xen anymore, dev->dma_ops is returned instead (see
>>> arch/arm/include/asm/dma-mapping.h:get_arch_dma_ops and
>>> include/linux/dma-mapping.h:get_dma_ops).
>>>
>>> Fix the problem by storing dev->dma_ops in dev_archdata, and setting
>>> dev->dma_ops to xen_dma_ops. This way, xen_dma_ops is returned naturally
>>> by get_dma_ops. The Xen code can retrieve the original dev->dma_ops from
>>> dev_archdata when needed. It also allows us to remove __generic_dma_ops
>>> from common headers.
>>>
>>> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
>>> Tested-by: Julien Grall <julien.grall@arm.com>
>>> Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
>>> CC: linux@armlinux.org.uk
>>> CC: catalin.marinas@arm.com
>>> CC: will.deacon@arm.com
>>> CC: boris.ostrovsky@oracle.com
>>> CC: jgross@suse.com
>>> CC: Julien Grall <julien.grall@arm.com>
>>
>> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
>>
>>
>>> diff --git a/arch/arm/include/asm/device.h b/arch/arm/include/asm/device.h
>>> index 220ba20..36ec9c8 100644
>>> --- a/arch/arm/include/asm/device.h
>>> +++ b/arch/arm/include/asm/device.h
>>> @@ -16,6 +16,9 @@ struct dev_archdata {
>>>  #ifdef CONFIG_ARM_DMA_USE_IOMMU
>>>  	struct dma_iommu_mapping	*mapping;
>>>  #endif
>>> +#ifdef CONFIG_XEN
>>> +	const struct dma_map_ops *dev_dma_ops;
>>> +#endif
>>>  	bool dma_coherent;
>>>  };
>>>  
>>> diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
>>> index 7166569..680d3f3 100644
>>> --- a/arch/arm/include/asm/dma-mapping.h
>>> +++ b/arch/arm/include/asm/dma-mapping.h
>>> @@ -16,19 +16,9 @@
>>>  extern const struct dma_map_ops arm_dma_ops;
>>>  extern const struct dma_map_ops arm_coherent_dma_ops;
>>>  
>>> -static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
>>> -{
>>> -	if (dev && dev->dma_ops)
>>> -		return dev->dma_ops;
>>> -	return &arm_dma_ops;
>>> -}
>>> -
>>>  static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
>>>  {
>>> -	if (xen_initial_domain())
>>> -		return xen_dma_ops;
>>> -	else
>>> -		return __generic_dma_ops(NULL);
>>> +	return &arm_dma_ops;
>>>  }
>>>  
>>>  #define HAVE_ARCH_DMA_SUPPORTED 1
>>> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
>>> index 63eabb0..a614459 100644
>>> --- a/arch/arm/mm/dma-mapping.c
>>> +++ b/arch/arm/mm/dma-mapping.c
>>> @@ -2396,6 +2396,13 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
>>>  		dma_ops = arm_get_dma_map_ops(coherent);
>>>  
>>>  	set_dma_ops(dev, dma_ops);
>>> +
>>> +#ifdef CONFIG_XEN
>>> +	if (xen_initial_domain()) {
>>> +		dev->archdata.dev_dma_ops = dev->dma_ops;
>>> +		dev->dma_ops = xen_dma_ops;
>>> +	}
>>> +#endif
>>>  }
>>>  
>>>  void arch_teardown_dma_ops(struct device *dev)
>>> diff --git a/arch/arm64/include/asm/device.h b/arch/arm64/include/asm/device.h
>>> index 73d5bab..5a5fa47 100644
>>> --- a/arch/arm64/include/asm/device.h
>>> +++ b/arch/arm64/include/asm/device.h
>>> @@ -20,6 +20,9 @@ struct dev_archdata {
>>>  #ifdef CONFIG_IOMMU_API
>>>  	void *iommu;			/* private IOMMU data */
>>>  #endif
>>> +#ifdef CONFIG_XEN
>>> +	const struct dma_map_ops *dev_dma_ops;
>>> +#endif
>>>  	bool dma_coherent;
>>>  };
>>>  
>>> diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
>>> index 505756c..5392dbe 100644
>>> --- a/arch/arm64/include/asm/dma-mapping.h
>>> +++ b/arch/arm64/include/asm/dma-mapping.h
>>> @@ -27,11 +27,8 @@
>>>  #define DMA_ERROR_CODE	(~(dma_addr_t)0)
>>>  extern const struct dma_map_ops dummy_dma_ops;
>>>  
>>> -static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
>>> +static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
>>>  {
>>> -	if (dev && dev->dma_ops)
>>> -		return dev->dma_ops;
>>> -
>>>  	/*
>>>  	 * We expect no ISA devices, and all other DMA masters are expected to
>>>  	 * have someone call arch_setup_dma_ops at device creation time.
>>> @@ -39,14 +36,6 @@ static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
>>>  	return &dummy_dma_ops;
>>>  }
>>>  
>>> -static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
>>> -{
>>> -	if (xen_initial_domain())
>>> -		return xen_dma_ops;
>>> -	else
>>> -		return __generic_dma_ops(NULL);
>>> -}
>>> -
>>>  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
>>>  			const struct iommu_ops *iommu, bool coherent);
>>>  #define arch_setup_dma_ops	arch_setup_dma_ops
>>> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
>>> index 81cdb2e..7f8b37e 100644
>>> --- a/arch/arm64/mm/dma-mapping.c
>>> +++ b/arch/arm64/mm/dma-mapping.c
>>> @@ -977,4 +977,11 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
>>>  
>>>  	dev->archdata.dma_coherent = coherent;
>>>  	__iommu_setup_dma_ops(dev, dma_base, size, iommu);
>>> +
>>> +#ifdef CONFIG_XEN
>>> +	if (xen_initial_domain()) {
>>> +		dev->archdata.dev_dma_ops = dev->dma_ops;
>>> +		dev->dma_ops = xen_dma_ops;
>>> +	}
>>> +#endif
>>>  }
>>> diff --git a/include/xen/arm/page-coherent.h b/include/xen/arm/page-coherent.h
>>> index 95ce6ac..b0a2bfc 100644
>>> --- a/include/xen/arm/page-coherent.h
>>> +++ b/include/xen/arm/page-coherent.h
>>> @@ -2,8 +2,16 @@
>>>  #define _ASM_ARM_XEN_PAGE_COHERENT_H
>>>  
>>>  #include <asm/page.h>
>>> +#include <asm/dma-mapping.h>
>>>  #include <linux/dma-mapping.h>
>>>  
>>> +static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
>>> +{
>>> +	if (dev && dev->archdata.dev_dma_ops)
>>> +		return dev->archdata.dev_dma_ops;
>>> +	return get_arch_dma_ops(NULL);
>>> +}
>>> +
>>>  void __xen_dma_map_page(struct device *hwdev, struct page *page,
>>>  	     dma_addr_t dev_addr, unsigned long offset, size_t size,
>>>  	     enum dma_data_direction dir, unsigned long attrs);
> 

WARNING: multiple messages have this Message-ID (diff)
From: jgross@suse.com (Juergen Gross)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] xen/arm, arm64: fix xen_dma_ops after 815dd18 "Consolidate get_dma_ops..."
Date: Wed, 19 Apr 2017 20:20:00 +0200	[thread overview]
Message-ID: <a4e371e4-44ff-ee6d-22b6-3ff9d57ce421@suse.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1704191023120.31486@sstabellini-ThinkPad-X260>

On 19/04/17 19:25, Stefano Stabellini wrote:
> Hello Russell,
> 
> Can I have your acked-by on the following fix (original patch is
> 1492117462-19886-1-git-send-email-sstabellini at kernel.org)?

Stefano, through which tree should this go? ARM or Xen or other?


Juergen

> 
> Thanks,
> 
> Stefano
> 
> 
> On Tue, 18 Apr 2017, Catalin Marinas wrote:
>> On Thu, Apr 13, 2017 at 02:04:21PM -0700, Stefano Stabellini wrote:
>>> The following commit:
>>>
>>>   commit 815dd18788fe0d41899f51b91d0560279cf16b0d
>>>   Author: Bart Van Assche <bart.vanassche@sandisk.com>
>>>   Date:   Fri Jan 20 13:04:04 2017 -0800
>>>
>>>       treewide: Consolidate get_dma_ops() implementations
>>>
>>> rearranges get_dma_ops in a way that xen_dma_ops are not returned when
>>> running on Xen anymore, dev->dma_ops is returned instead (see
>>> arch/arm/include/asm/dma-mapping.h:get_arch_dma_ops and
>>> include/linux/dma-mapping.h:get_dma_ops).
>>>
>>> Fix the problem by storing dev->dma_ops in dev_archdata, and setting
>>> dev->dma_ops to xen_dma_ops. This way, xen_dma_ops is returned naturally
>>> by get_dma_ops. The Xen code can retrieve the original dev->dma_ops from
>>> dev_archdata when needed. It also allows us to remove __generic_dma_ops
>>> from common headers.
>>>
>>> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
>>> Tested-by: Julien Grall <julien.grall@arm.com>
>>> Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
>>> CC: linux at armlinux.org.uk
>>> CC: catalin.marinas at arm.com
>>> CC: will.deacon at arm.com
>>> CC: boris.ostrovsky at oracle.com
>>> CC: jgross at suse.com
>>> CC: Julien Grall <julien.grall@arm.com>
>>
>> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
>>
>>
>>> diff --git a/arch/arm/include/asm/device.h b/arch/arm/include/asm/device.h
>>> index 220ba20..36ec9c8 100644
>>> --- a/arch/arm/include/asm/device.h
>>> +++ b/arch/arm/include/asm/device.h
>>> @@ -16,6 +16,9 @@ struct dev_archdata {
>>>  #ifdef CONFIG_ARM_DMA_USE_IOMMU
>>>  	struct dma_iommu_mapping	*mapping;
>>>  #endif
>>> +#ifdef CONFIG_XEN
>>> +	const struct dma_map_ops *dev_dma_ops;
>>> +#endif
>>>  	bool dma_coherent;
>>>  };
>>>  
>>> diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
>>> index 7166569..680d3f3 100644
>>> --- a/arch/arm/include/asm/dma-mapping.h
>>> +++ b/arch/arm/include/asm/dma-mapping.h
>>> @@ -16,19 +16,9 @@
>>>  extern const struct dma_map_ops arm_dma_ops;
>>>  extern const struct dma_map_ops arm_coherent_dma_ops;
>>>  
>>> -static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
>>> -{
>>> -	if (dev && dev->dma_ops)
>>> -		return dev->dma_ops;
>>> -	return &arm_dma_ops;
>>> -}
>>> -
>>>  static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
>>>  {
>>> -	if (xen_initial_domain())
>>> -		return xen_dma_ops;
>>> -	else
>>> -		return __generic_dma_ops(NULL);
>>> +	return &arm_dma_ops;
>>>  }
>>>  
>>>  #define HAVE_ARCH_DMA_SUPPORTED 1
>>> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
>>> index 63eabb0..a614459 100644
>>> --- a/arch/arm/mm/dma-mapping.c
>>> +++ b/arch/arm/mm/dma-mapping.c
>>> @@ -2396,6 +2396,13 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
>>>  		dma_ops = arm_get_dma_map_ops(coherent);
>>>  
>>>  	set_dma_ops(dev, dma_ops);
>>> +
>>> +#ifdef CONFIG_XEN
>>> +	if (xen_initial_domain()) {
>>> +		dev->archdata.dev_dma_ops = dev->dma_ops;
>>> +		dev->dma_ops = xen_dma_ops;
>>> +	}
>>> +#endif
>>>  }
>>>  
>>>  void arch_teardown_dma_ops(struct device *dev)
>>> diff --git a/arch/arm64/include/asm/device.h b/arch/arm64/include/asm/device.h
>>> index 73d5bab..5a5fa47 100644
>>> --- a/arch/arm64/include/asm/device.h
>>> +++ b/arch/arm64/include/asm/device.h
>>> @@ -20,6 +20,9 @@ struct dev_archdata {
>>>  #ifdef CONFIG_IOMMU_API
>>>  	void *iommu;			/* private IOMMU data */
>>>  #endif
>>> +#ifdef CONFIG_XEN
>>> +	const struct dma_map_ops *dev_dma_ops;
>>> +#endif
>>>  	bool dma_coherent;
>>>  };
>>>  
>>> diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
>>> index 505756c..5392dbe 100644
>>> --- a/arch/arm64/include/asm/dma-mapping.h
>>> +++ b/arch/arm64/include/asm/dma-mapping.h
>>> @@ -27,11 +27,8 @@
>>>  #define DMA_ERROR_CODE	(~(dma_addr_t)0)
>>>  extern const struct dma_map_ops dummy_dma_ops;
>>>  
>>> -static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
>>> +static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
>>>  {
>>> -	if (dev && dev->dma_ops)
>>> -		return dev->dma_ops;
>>> -
>>>  	/*
>>>  	 * We expect no ISA devices, and all other DMA masters are expected to
>>>  	 * have someone call arch_setup_dma_ops at device creation time.
>>> @@ -39,14 +36,6 @@ static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
>>>  	return &dummy_dma_ops;
>>>  }
>>>  
>>> -static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
>>> -{
>>> -	if (xen_initial_domain())
>>> -		return xen_dma_ops;
>>> -	else
>>> -		return __generic_dma_ops(NULL);
>>> -}
>>> -
>>>  void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
>>>  			const struct iommu_ops *iommu, bool coherent);
>>>  #define arch_setup_dma_ops	arch_setup_dma_ops
>>> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
>>> index 81cdb2e..7f8b37e 100644
>>> --- a/arch/arm64/mm/dma-mapping.c
>>> +++ b/arch/arm64/mm/dma-mapping.c
>>> @@ -977,4 +977,11 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
>>>  
>>>  	dev->archdata.dma_coherent = coherent;
>>>  	__iommu_setup_dma_ops(dev, dma_base, size, iommu);
>>> +
>>> +#ifdef CONFIG_XEN
>>> +	if (xen_initial_domain()) {
>>> +		dev->archdata.dev_dma_ops = dev->dma_ops;
>>> +		dev->dma_ops = xen_dma_ops;
>>> +	}
>>> +#endif
>>>  }
>>> diff --git a/include/xen/arm/page-coherent.h b/include/xen/arm/page-coherent.h
>>> index 95ce6ac..b0a2bfc 100644
>>> --- a/include/xen/arm/page-coherent.h
>>> +++ b/include/xen/arm/page-coherent.h
>>> @@ -2,8 +2,16 @@
>>>  #define _ASM_ARM_XEN_PAGE_COHERENT_H
>>>  
>>>  #include <asm/page.h>
>>> +#include <asm/dma-mapping.h>
>>>  #include <linux/dma-mapping.h>
>>>  
>>> +static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
>>> +{
>>> +	if (dev && dev->archdata.dev_dma_ops)
>>> +		return dev->archdata.dev_dma_ops;
>>> +	return get_arch_dma_ops(NULL);
>>> +}
>>> +
>>>  void __xen_dma_map_page(struct device *hwdev, struct page *page,
>>>  	     dma_addr_t dev_addr, unsigned long offset, size_t size,
>>>  	     enum dma_data_direction dir, unsigned long attrs);
> 

  reply	other threads:[~2017-04-19 18:20 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13 21:04 [PATCH 1/2] xen/arm,arm64: fix xen_dma_ops after 815dd18 "Consolidate get_dma_ops..." Stefano Stabellini
2017-04-13 21:04 ` [PATCH 1/2] xen/arm, arm64: " Stefano Stabellini
2017-04-13 21:04 ` [PATCH 2/2] xen/arm,arm64: rename __generic_dma_ops to xen_get_dma_ops Stefano Stabellini
2017-04-13 21:04   ` [PATCH 2/2] xen/arm, arm64: " Stefano Stabellini
2017-04-14  0:48   ` [PATCH 2/2] xen/arm,arm64: " Boris Ostrovsky
2017-04-14  0:48     ` Boris Ostrovsky
2017-04-14  2:14     ` [PATCH 2/2] xen/arm, arm64: " Konrad Rzeszutek Wilk
2017-04-14  2:14     ` [PATCH 2/2] xen/arm,arm64: " Konrad Rzeszutek Wilk
2017-04-14  2:14       ` Konrad Rzeszutek Wilk
2017-04-14  0:48   ` [PATCH 2/2] xen/arm, arm64: " Boris Ostrovsky
2017-04-13 21:04 ` Stefano Stabellini
2017-04-18 14:21 ` [PATCH 1/2] xen/arm, arm64: fix xen_dma_ops after 815dd18 "Consolidate get_dma_ops..." Catalin Marinas
2017-04-18 14:21   ` Catalin Marinas
2017-04-19 17:25   ` Stefano Stabellini
2017-04-19 17:25   ` Stefano Stabellini
2017-04-19 17:25     ` Stefano Stabellini
2017-04-19 18:20     ` Juergen Gross [this message]
2017-04-19 18:20       ` Juergen Gross
2017-04-19 18:32       ` Stefano Stabellini
2017-04-19 18:32       ` Stefano Stabellini
2017-04-19 18:32         ` Stefano Stabellini
2017-04-19 18:20     ` Juergen Gross
2017-04-24 19:16     ` Stefano Stabellini
2017-04-24 19:16     ` Stefano Stabellini
2017-04-24 19:16       ` Stefano Stabellini
2017-04-25 12:51       ` Julien Grall
2017-04-25 12:51       ` Julien Grall
2017-04-25 12:51         ` Julien Grall
2017-04-25 17:22         ` Stefano Stabellini
2017-04-25 17:22         ` Stefano Stabellini
2017-04-25 17:22           ` Stefano Stabellini
2017-04-26 11:19           ` Catalin Marinas
2017-04-26 11:19             ` Catalin Marinas
2017-04-26 17:00             ` Stefano Stabellini
2017-04-26 17:00             ` Stefano Stabellini
2017-04-26 17:00               ` Stefano Stabellini
2017-04-26 17:13               ` Catalin Marinas
2017-04-26 17:13               ` Catalin Marinas
2017-04-26 17:13                 ` Catalin Marinas
2017-04-26 17:17                 ` Stefano Stabellini
2017-04-26 17:17                 ` Stefano Stabellini
2017-04-26 17:17                   ` Stefano Stabellini
2017-04-26 11:19           ` Catalin Marinas
2017-04-18 14:21 ` Catalin Marinas
2017-04-13 21:04 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=a4e371e4-44ff-ee6d-22b6-3ff9d57ce421@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=catalin.marinas@arm.com \
    --cc=julien.grall@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=sstabellini@kernel.org \
    --cc=will.deacon@arm.com \
    --cc=xen-devel@lists.xen.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.