Re: [linux-yocto] [yocto-5.4][master][PATCH] features/media: set default for DVB_CORE to m

2020-08-07 Thread Bruce Ashfield
On Fri, Aug 7, 2020 at 1:43 PM Anuj Mittal  wrote:

> MEDIA_SUPPORT is set by default to m so DVB_CORE can't be y and this is
> the only tristate that we set to y that is controlled by MEDIA_SUPPORT.
> Change it to m. Fixes:
>
> [NOTE]: 'CONFIG_DVB_CORE' last val (y) and .config val (m) do not match
> [INFO]: CONFIG_DVB_CORE : m ## .config: 3617
> :configs/v5.4/standard/features/media/media.cfg (y)
> [INFO]: raw config text:
>
> config DVB_CORE
> tristate
> default y
> select CRC32
> depends on MEDIA_SUPPORT && MEDIA_DIGITAL_TV_SUPPORT &&
> (I2C || I2C = n) && MEDIA_SUPPORT
>
> Config 'DVB_CORE' has the following Direct dependencies
> (DVB_CORE=m):
> MEDIA_SUPPORT(=m) && MEDIA_DIGITAL_TV_SUPPORT(=y) &&
> I2C(=y) || I2C(=y) = n (=y)
> Parent dependencies are:
>  MEDIA_DIGITAL_TV_SUPPORT [y] MEDIA_SUPPORT [m] I2C [y]
> [INFO]: config 'CONFIG_DVB_CORE' was set, but it wasn't assignable,
> check (parent) dependencies
>
>
Thanks Anuj,

sorry to surprise everyone with the enhanced audit tools :D I hope the
improved output made it easier to resolve the warning.

I've merged this to 5.4, master and the 5.8 branch that is just about ready
to be pushed.

Cheers,

Bruce




> Signed-off-by: Anuj Mittal 
> ---
>  features/media/media.cfg | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/features/media/media.cfg b/features/media/media.cfg
> index 401acae6..13e57b73 100644
> --- a/features/media/media.cfg
> +++ b/features/media/media.cfg
> @@ -38,7 +38,7 @@ CONFIG_VIDEOBUF2_VMALLOC=m
>  #
>  # Digital Video Broadcast support
>  #
> -CONFIG_DVB_CORE=y
> +CONFIG_DVB_CORE=m
>  CONFIG_DVB_NET=y
>  CONFIG_DVB_MAX_ADAPTERS=8
>  CONFIG_DVB_DYNAMIC_MINORS=y
> --
> 2.25.4
>
> 
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8943): 
https://lists.yoctoproject.org/g/linux-yocto/message/8943
Mute This Topic: https://lists.yoctoproject.org/mt/76054236/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [linux-yocto] [linux-yocto-dev][kernel standard/bcm-2xxx-rpi 00/11] Enable Xen on Raspberry Pi 4

2020-08-07 Thread Bruce Ashfield
On Fri, Aug 7, 2020 at 2:18 AM Christopher Clark <
christopher.w.cl...@gmail.com> wrote:

> This series of patches, submitted for the standard/bcm-2xxx-rpi kernel,
> support enabling linux-yocto-dev to run Xen on the Raspberry Pi 4.  This
> is version 3 of the series developed within the Xen community, which is
> now queued for inclusion in Linux upstream:
>
> https://lists.xenproject.org/archives/html/xen-devel/2020-08/msg00153.html
>
> This series supports work to enable meta-virtualization to use the
> linux-yocto-dev kernel and retire use of the downstream meta-raspberrypi
> default kernel for use with Xen.
>

The patches look fine to me, no concerns here.



>
> This same patch series can also be applied to linux-yocto-dev's
> standard/base, v5.7/standard/bcm-2xxx-rpi and v5.7/standard/bcm-2xxx-rpi
> branches.
>

I've merged them to standard/ and v5.7/.

FYI: I've created the linux-yocto v5.8 reference kernel locally and it is
in final testing now, I'll bring in the -dev branches to that kernel before
I push it. So the support will exist the same in both trees.

Cheers,

Bruce



>
> Tested locally with the bcm-2xxx-rpi branches.
> Patch series source:
> git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.git
> branch: fix-rpi4-v3
>
> thanks
>
> Christopher
>
>
> Boris Ostrovsky (1):
>   swiotlb-xen: use vmalloc_to_page on vmalloc virt addresses
>
> Stefano Stabellini (10):
>   swiotlb-xen: remove start_dma_addr
>   swiotlb-xen: add struct device * parameter to xen_phys_to_bus
>   swiotlb-xen: add struct device * parameter to xen_bus_to_phys
>   swiotlb-xen: add struct device * parameter to xen_dma_sync_for_cpu
>   swiotlb-xen: add struct device * parameter to xen_dma_sync_for_device
>   swiotlb-xen: add struct device * parameter to is_xen_swiotlb_buffer
>   swiotlb-xen: remove XEN_PFN_PHYS
>   swiotlb-xen: introduce phys_to_dma/dma_to_phys translations
>   xen/arm: introduce phys/dma translations in xen_dma_sync_for_*
>   xen/arm: call dma_to_phys on the dma_addr_t parameter of
> dma_cache_maint
>
>  arch/arm/xen/mm.c |  34 +--
>  drivers/xen/swiotlb-xen.c | 119 +++---
>  include/xen/page.h|   1 -
>  include/xen/swiotlb-xen.h |   8 +--
>  4 files changed, 93 insertions(+), 69 deletions(-)
>
> --
> 2.17.1
>
>

-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8942): 
https://lists.yoctoproject.org/g/linux-yocto/message/8942
Mute This Topic: https://lists.yoctoproject.org/mt/76044154/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [yocto-5.4][master][PATCH] features/media: set default for DVB_CORE to m

2020-08-07 Thread Anuj Mittal
MEDIA_SUPPORT is set by default to m so DVB_CORE can't be y and this is
the only tristate that we set to y that is controlled by MEDIA_SUPPORT.
Change it to m. Fixes:

[NOTE]: 'CONFIG_DVB_CORE' last val (y) and .config val (m) do not match
[INFO]: CONFIG_DVB_CORE : m ## .config: 3617 
:configs/v5.4/standard/features/media/media.cfg (y)
[INFO]: raw config text:

config DVB_CORE
tristate
default y
select CRC32
depends on MEDIA_SUPPORT && MEDIA_DIGITAL_TV_SUPPORT && (I2C || 
I2C = n) && MEDIA_SUPPORT

Config 'DVB_CORE' has the following Direct dependencies (DVB_CORE=m):
MEDIA_SUPPORT(=m) && MEDIA_DIGITAL_TV_SUPPORT(=y) && I2C(=y) || 
I2C(=y) = n (=y)
Parent dependencies are:
 MEDIA_DIGITAL_TV_SUPPORT [y] MEDIA_SUPPORT [m] I2C [y]
[INFO]: config 'CONFIG_DVB_CORE' was set, but it wasn't assignable, check 
(parent) dependencies

Signed-off-by: Anuj Mittal 
---
 features/media/media.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/features/media/media.cfg b/features/media/media.cfg
index 401acae6..13e57b73 100644
--- a/features/media/media.cfg
+++ b/features/media/media.cfg
@@ -38,7 +38,7 @@ CONFIG_VIDEOBUF2_VMALLOC=m
 #
 # Digital Video Broadcast support
 #
-CONFIG_DVB_CORE=y
+CONFIG_DVB_CORE=m
 CONFIG_DVB_NET=y
 CONFIG_DVB_MAX_ADAPTERS=8
 CONFIG_DVB_DYNAMIC_MINORS=y
-- 
2.25.4

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8940): 
https://lists.yoctoproject.org/g/linux-yocto/message/8940
Mute This Topic: https://lists.yoctoproject.org/mt/76054236/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [linux-yocto] [linux-yocto-dev] [oe-core] [PATCH] kernel.bbclass: Configuration for environment with HOSTCXX

2020-08-07 Thread Richard Purdie
On Fri, 2020-08-07 at 08:34 -0400, Bruce Ashfield wrote:
> This needs to go to oe-core.
> 
> But see some comments below.
> 
> On Fri, Aug 7, 2020 at 5:26 AM  wrote:
> > From: Zhang Qiang 
> > 
> > When compiling xilinx-zynq board linux-kernel-dev(v5.8) if
> > "GCC_PLUGINS=y", The following error will appear:
> > 
> > "HOSTCXX -fPIC scripts/gcc-plugins/arm_ssp_per_task_plugin.o
> > fatal error: gmp.h: No such file or directory"
> > 
> > the GCC_PLUGINS depend on return result of gcc-plugin.sh execution
> > however in gcc-plugin.sh use HOSTCC to detect the feature of GNU
> > extension of gcc, this will result that HOSTCC can compile the file
> > successfully, but HOSTCXX is used in the actual compilation process.
> > 
> > Signed-off-by: Zhang Qiang 
> > ---
> >  meta/classes/kernel.bbclass | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> > index cf43a5d604..d7ac2dc421 100644
> > --- a/meta/classes/kernel.bbclass
> > +++ b/meta/classes/kernel.bbclass
> > @@ -212,6 +212,8 @@ UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
> >  KERNEL_EXTRA_ARGS ?= ""
> > 
> >  EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" 
> > HOSTCPP="${BUILD_CPP}""
> > +EXTRA_OEMAKE += " HOSTCXX="${BUILD_CXX} ${BUILD_CXXFLAGS} 
> > ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}""
> 
> It is fine if we now need to add HOSTCXX/BUILDCXX, but do not drop HOSTCC 
> /BUILD_CFLAGS while making that addition.

It took me a minute to realise but its appending in the second line so
the variable is set, then appended to...

Cheers,

Richard

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8938): 
https://lists.yoctoproject.org/g/linux-yocto/message/8938
Mute This Topic: https://lists.yoctoproject.org/mt/76045798/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev] [oe-core] [PATCH] kernel.bbclass: Configuration for environment with HOSTCXX

2020-08-07 Thread Zhang, Qiang
From: Zhang Qiang 

When compiling xilinx-zynq board linux-kernel-dev(v5.8) if
"GCC_PLUGINS=y", The following error will appear:

"HOSTCXX -fPIC scripts/gcc-plugins/arm_ssp_per_task_plugin.o
fatal error: gmp.h: No such file or directory"

the GCC_PLUGINS depend on return result of gcc-plugin.sh execution
however in gcc-plugin.sh use HOSTCC to detect the feature of GNU
extension of gcc, this will result that HOSTCC can compile the file
successfully, but HOSTCXX is used in the actual compilation process.

Signed-off-by: Zhang Qiang 
---
 meta/classes/kernel.bbclass | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index cf43a5d604..d7ac2dc421 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -212,6 +212,8 @@ UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
 KERNEL_EXTRA_ARGS ?= ""
 
 EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" 
HOSTCPP="${BUILD_CPP}""
+EXTRA_OEMAKE += " HOSTCXX="${BUILD_CXX} ${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}" 
HOSTCPP="${BUILD_CPP}""
+
 KERNEL_ALT_IMAGETYPE ??= ""
 
 copy_initramfs() {
-- 
2.26.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8936): 
https://lists.yoctoproject.org/g/linux-yocto/message/8936
Mute This Topic: https://lists.yoctoproject.org/mt/76045798/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 03/11] swiotlb-xen: add struct device * parameter to xen_phys_to_bus

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

No functional changes. The parameter is unused in this patch but will be
used by next patches.

Signed-off-by: Stefano Stabellini 
Reviewed-by: Boris Ostrovsky 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 drivers/xen/swiotlb-xen.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 89a775948a02..dbe710a59bf2 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -57,7 +57,7 @@ static unsigned long xen_io_tlb_nslabs;
  * can be 32bit when dma_addr_t is 64bit leading to a loss in
  * information if the shift is done before casting to 64bit.
  */
-static inline dma_addr_t xen_phys_to_bus(phys_addr_t paddr)
+static inline dma_addr_t xen_phys_to_bus(struct device *dev, phys_addr_t paddr)
 {
unsigned long bfn = pfn_to_bfn(XEN_PFN_DOWN(paddr));
dma_addr_t dma = (dma_addr_t)bfn << XEN_PAGE_SHIFT;
@@ -78,9 +78,9 @@ static inline phys_addr_t xen_bus_to_phys(dma_addr_t baddr)
return paddr;
 }
 
-static inline dma_addr_t xen_virt_to_bus(void *address)
+static inline dma_addr_t xen_virt_to_bus(struct device *dev, void *address)
 {
-   return xen_phys_to_bus(virt_to_phys(address));
+   return xen_phys_to_bus(dev, virt_to_phys(address));
 }
 
 static inline int range_straddles_page_boundary(phys_addr_t p, size_t size)
@@ -309,7 +309,7 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t 
size,
 * Do not use virt_to_phys(ret) because on ARM it doesn't correspond
 * to *dma_handle. */
phys = *dma_handle;
-   dev_addr = xen_phys_to_bus(phys);
+   dev_addr = xen_phys_to_bus(hwdev, phys);
if (((dev_addr + size - 1 <= dma_mask)) &&
!range_straddles_page_boundary(phys, size))
*dma_handle = dev_addr;
@@ -370,7 +370,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, 
struct page *page,
unsigned long attrs)
 {
phys_addr_t map, phys = page_to_phys(page) + offset;
-   dma_addr_t dev_addr = xen_phys_to_bus(phys);
+   dma_addr_t dev_addr = xen_phys_to_bus(dev, phys);
 
BUG_ON(dir == DMA_NONE);
/*
@@ -395,7 +395,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, 
struct page *page,
return DMA_MAPPING_ERROR;
 
phys = map;
-   dev_addr = xen_phys_to_bus(map);
+   dev_addr = xen_phys_to_bus(dev, map);
 
/*
 * Ensure that the address returned is DMA'ble
@@ -539,7 +539,7 @@ xen_swiotlb_sync_sg_for_device(struct device *dev, struct 
scatterlist *sgl,
 static int
 xen_swiotlb_dma_supported(struct device *hwdev, u64 mask)
 {
-   return xen_virt_to_bus(xen_io_tlb_end - 1) <= mask;
+   return xen_virt_to_bus(hwdev, xen_io_tlb_end - 1) <= mask;
 }
 
 const struct dma_map_ops xen_swiotlb_dma_ops = {
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8927): 
https://lists.yoctoproject.org/g/linux-yocto/message/8927
Mute This Topic: https://lists.yoctoproject.org/mt/76044157/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 09/11] swiotlb-xen: introduce phys_to_dma/dma_to_phys translations

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

With some devices physical addresses are different than dma addresses.
To be able to deal with these cases, we need to call phys_to_dma on
physical addresses (including machine addresses in Xen terminology)
before returning them from xen_swiotlb_alloc_coherent and
xen_swiotlb_map_page.

We also need to convert dma addresses back to physical addresses using
dma_to_phys in xen_swiotlb_free_coherent and xen_swiotlb_unmap_page if
we want to do any operations on them.

Call dma_to_phys in is_xen_swiotlb_buffer.
Introduce xen_phys_to_dma and call phys_to_dma in its implementation.
Introduce xen_dma_to_phys and call dma_to_phys in its implementation.
Call xen_phys_to_dma/xen_dma_to_phys instead of
xen_phys_to_bus/xen_bus_to_phys through swiotlb-xen.c.

Everything is taken care of by these changes except for
xen_swiotlb_alloc_coherent and xen_swiotlb_free_coherent, which need a
few explicit phys_to_dma/dma_to_phys calls.

Signed-off-by: Stefano Stabellini 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 drivers/xen/swiotlb-xen.c | 53 +++
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 03d118b6c141..a6a95358a8cb 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -52,30 +52,39 @@ static unsigned long xen_io_tlb_nslabs;
  * Quick lookup value of the bus address of the IOTLB.
  */
 
-static inline dma_addr_t xen_phys_to_bus(struct device *dev, phys_addr_t paddr)
+static inline phys_addr_t xen_phys_to_bus(struct device *dev, phys_addr_t 
paddr)
 {
unsigned long bfn = pfn_to_bfn(XEN_PFN_DOWN(paddr));
-   dma_addr_t dma = (dma_addr_t)bfn << XEN_PAGE_SHIFT;
+   phys_addr_t baddr = (phys_addr_t)bfn << XEN_PAGE_SHIFT;
 
-   dma |= paddr & ~XEN_PAGE_MASK;
+   baddr |= paddr & ~XEN_PAGE_MASK;
+   return baddr;
+}
 
-   return dma;
+static inline dma_addr_t xen_phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+   return phys_to_dma(dev, xen_phys_to_bus(dev, paddr));
 }
 
-static inline phys_addr_t xen_bus_to_phys(struct device *dev, dma_addr_t baddr)
+static inline phys_addr_t xen_bus_to_phys(struct device *dev,
+ phys_addr_t baddr)
 {
unsigned long xen_pfn = bfn_to_pfn(XEN_PFN_DOWN(baddr));
-   dma_addr_t dma = (dma_addr_t)xen_pfn << XEN_PAGE_SHIFT;
-   phys_addr_t paddr = dma;
-
-   paddr |= baddr & ~XEN_PAGE_MASK;
+   phys_addr_t paddr = (xen_pfn << XEN_PAGE_SHIFT) |
+   (baddr & ~XEN_PAGE_MASK);
 
return paddr;
 }
 
+static inline phys_addr_t xen_dma_to_phys(struct device *dev,
+ dma_addr_t dma_addr)
+{
+   return xen_bus_to_phys(dev, dma_to_phys(dev, dma_addr));
+}
+
 static inline dma_addr_t xen_virt_to_bus(struct device *dev, void *address)
 {
-   return xen_phys_to_bus(dev, virt_to_phys(address));
+   return xen_phys_to_dma(dev, virt_to_phys(address));
 }
 
 static inline int range_straddles_page_boundary(phys_addr_t p, size_t size)
@@ -94,7 +103,7 @@ static inline int range_straddles_page_boundary(phys_addr_t 
p, size_t size)
 
 static int is_xen_swiotlb_buffer(struct device *dev, dma_addr_t dma_addr)
 {
-   unsigned long bfn = XEN_PFN_DOWN(dma_addr);
+   unsigned long bfn = XEN_PFN_DOWN(dma_to_phys(dev, dma_addr));
unsigned long xen_pfn = bfn_to_local_pfn(bfn);
phys_addr_t paddr = (phys_addr_t)xen_pfn << XEN_PAGE_SHIFT;
 
@@ -299,12 +308,12 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t 
size,
if (hwdev && hwdev->coherent_dma_mask)
dma_mask = hwdev->coherent_dma_mask;
 
-   /* At this point dma_handle is the physical address, next we are
+   /* At this point dma_handle is the dma address, next we are
 * going to set it to the machine address.
 * Do not use virt_to_phys(ret) because on ARM it doesn't correspond
 * to *dma_handle. */
-   phys = *dma_handle;
-   dev_addr = xen_phys_to_bus(hwdev, phys);
+   phys = dma_to_phys(hwdev, *dma_handle);
+   dev_addr = xen_phys_to_dma(hwdev, phys);
if (((dev_addr + size - 1 <= dma_mask)) &&
!range_straddles_page_boundary(phys, size))
*dma_handle = dev_addr;
@@ -314,6 +323,7 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t 
size,
xen_free_coherent_pages(hwdev, size, ret, 
(dma_addr_t)phys, attrs);
return NULL;
}
+   *dma_handle = phys_to_dma(hwdev, *dma_handle);
SetPageXenRemapped(virt_to_page(ret));
}
memset(ret, 0, size);
@@ -334,7 +344,7 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t 
size, void *vaddr,
 
/* do not use virt_to_phys because on ARM it doesn't return you the
 * physical address */
- 

[linux-yocto] [linux-yocto-dev][kernel standard/bcm-2xxx-rpi 00/11] Enable Xen on Raspberry Pi 4

2020-08-07 Thread Christopher Clark
This series of patches, submitted for the standard/bcm-2xxx-rpi kernel,
support enabling linux-yocto-dev to run Xen on the Raspberry Pi 4.  This
is version 3 of the series developed within the Xen community, which is
now queued for inclusion in Linux upstream:

https://lists.xenproject.org/archives/html/xen-devel/2020-08/msg00153.html

This series supports work to enable meta-virtualization to use the
linux-yocto-dev kernel and retire use of the downstream meta-raspberrypi
default kernel for use with Xen.

This same patch series can also be applied to linux-yocto-dev's
standard/base, v5.7/standard/bcm-2xxx-rpi and v5.7/standard/bcm-2xxx-rpi
branches.

Tested locally with the bcm-2xxx-rpi branches.
Patch series source:
git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.git
branch: fix-rpi4-v3

thanks

Christopher


Boris Ostrovsky (1):
  swiotlb-xen: use vmalloc_to_page on vmalloc virt addresses

Stefano Stabellini (10):
  swiotlb-xen: remove start_dma_addr
  swiotlb-xen: add struct device * parameter to xen_phys_to_bus
  swiotlb-xen: add struct device * parameter to xen_bus_to_phys
  swiotlb-xen: add struct device * parameter to xen_dma_sync_for_cpu
  swiotlb-xen: add struct device * parameter to xen_dma_sync_for_device
  swiotlb-xen: add struct device * parameter to is_xen_swiotlb_buffer
  swiotlb-xen: remove XEN_PFN_PHYS
  swiotlb-xen: introduce phys_to_dma/dma_to_phys translations
  xen/arm: introduce phys/dma translations in xen_dma_sync_for_*
  xen/arm: call dma_to_phys on the dma_addr_t parameter of
dma_cache_maint

 arch/arm/xen/mm.c |  34 +--
 drivers/xen/swiotlb-xen.c | 119 +++---
 include/xen/page.h|   1 -
 include/xen/swiotlb-xen.h |   8 +--
 4 files changed, 93 insertions(+), 69 deletions(-)

-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8924): 
https://lists.yoctoproject.org/g/linux-yocto/message/8924
Mute This Topic: https://lists.yoctoproject.org/mt/76044154/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 02/11] swiotlb-xen: remove start_dma_addr

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

It is not strictly needed. Call virt_to_phys on xen_io_tlb_start
instead. It will be useful not to have a start_dma_addr around with the
next patches.

Note that virt_to_phys is not the same as xen_virt_to_bus but actually
it is used to compared again __pa(xen_io_tlb_start) as passed to
swiotlb_init_with_tbl, so virt_to_phys is actually what we want.

Signed-off-by: Stefano Stabellini 
Reviewed-by: Boris Ostrovsky 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 drivers/xen/swiotlb-xen.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 5fbadd07819b..89a775948a02 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -52,8 +52,6 @@ static unsigned long xen_io_tlb_nslabs;
  * Quick lookup value of the bus address of the IOTLB.
  */
 
-static u64 start_dma_addr;
-
 /*
  * Both of these functions should avoid XEN_PFN_PHYS because phys_addr_t
  * can be 32bit when dma_addr_t is 64bit leading to a loss in
@@ -241,7 +239,6 @@ int __ref xen_swiotlb_init(int verbose, bool early)
m_ret = XEN_SWIOTLB_EFIXUP;
goto error;
}
-   start_dma_addr = xen_virt_to_bus(xen_io_tlb_start);
if (early) {
if (swiotlb_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs,
 verbose))
@@ -392,8 +389,8 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, 
struct page *page,
 */
trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force);
 
-   map = swiotlb_tbl_map_single(dev, start_dma_addr, phys,
-size, size, dir, attrs);
+   map = swiotlb_tbl_map_single(dev, virt_to_phys(xen_io_tlb_start),
+phys, size, size, dir, attrs);
if (map == (phys_addr_t)DMA_MAPPING_ERROR)
return DMA_MAPPING_ERROR;
 
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8926): 
https://lists.yoctoproject.org/g/linux-yocto/message/8926
Mute This Topic: https://lists.yoctoproject.org/mt/76044156/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 01/11] swiotlb-xen: use vmalloc_to_page on vmalloc virt addresses

2020-08-07 Thread Christopher Clark
Author: Boris Ostrovsky 

xen_alloc_coherent_pages might return pages for which virt_to_phys and
virt_to_page don't work, e.g. ioremap'ed pages.

So in xen_swiotlb_free_coherent we can't assume that virt_to_page works.
Instead add a is_vmalloc_addr check and use vmalloc_to_page on vmalloc
virt addresses.

This patch fixes the following crash at boot on RPi4 (the underlying
issue is not RPi4 specific):
https://marc.info/?l=xen-devel=158862573216800

Signed-off-by: Boris Ostrovsky 
Signed-off-by: Stefano Stabellini 
Reviewed-by: Boris Ostrovsky 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 drivers/xen/swiotlb-xen.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index b6d27762c6f8..5fbadd07819b 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -335,6 +335,7 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t 
size, void *vaddr,
int order = get_order(size);
phys_addr_t phys;
u64 dma_mask = DMA_BIT_MASK(32);
+   struct page *page;
 
if (hwdev && hwdev->coherent_dma_mask)
dma_mask = hwdev->coherent_dma_mask;
@@ -346,9 +347,14 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t 
size, void *vaddr,
/* Convert the size to actually allocated. */
size = 1UL << (order + XEN_PAGE_SHIFT);
 
+   if (is_vmalloc_addr(vaddr))
+   page = vmalloc_to_page(vaddr);
+   else
+   page = virt_to_page(vaddr);
+
if (!WARN_ON((dev_addr + size - 1 > dma_mask) ||
 range_straddles_page_boundary(phys, size)) &&
-   TestClearPageXenRemapped(virt_to_page(vaddr)))
+   TestClearPageXenRemapped(page))
xen_destroy_contiguous_region(phys, order);
 
xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys, attrs);
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8925): 
https://lists.yoctoproject.org/g/linux-yocto/message/8925
Mute This Topic: https://lists.yoctoproject.org/mt/76044155/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 05/11] swiotlb-xen: add struct device * parameter to xen_dma_sync_for_cpu

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

No functional changes. The parameter is unused in this patch but will be
used by next patches.

Signed-off-by: Stefano Stabellini 
Reviewed-by: Boris Ostrovsky 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 arch/arm/xen/mm.c | 5 +++--
 drivers/xen/swiotlb-xen.c | 4 ++--
 include/xen/swiotlb-xen.h | 5 +++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index d40e9e5fc52b..1a00e8003c64 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -71,8 +71,9 @@ static void dma_cache_maint(dma_addr_t handle, size_t size, 
u32 op)
  * pfn_valid returns true the pages is local and we can use the native
  * dma-direct functions, otherwise we call the Xen specific version.
  */
-void xen_dma_sync_for_cpu(dma_addr_t handle, phys_addr_t paddr, size_t size,
-   enum dma_data_direction dir)
+void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle,
+ phys_addr_t paddr, size_t size,
+ enum dma_data_direction dir)
 {
if (pfn_valid(PFN_DOWN(handle)))
arch_sync_dma_for_cpu(paddr, size, dir);
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index a8e447137faf..d04b7a15124f 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -428,7 +428,7 @@ static void xen_swiotlb_unmap_page(struct device *hwdev, 
dma_addr_t dev_addr,
BUG_ON(dir == DMA_NONE);
 
if (!dev_is_dma_coherent(hwdev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
-   xen_dma_sync_for_cpu(dev_addr, paddr, size, dir);
+   xen_dma_sync_for_cpu(hwdev, dev_addr, paddr, size, dir);
 
/* NOTE: We use dev_addr here, not paddr! */
if (is_xen_swiotlb_buffer(dev_addr))
@@ -442,7 +442,7 @@ xen_swiotlb_sync_single_for_cpu(struct device *dev, 
dma_addr_t dma_addr,
phys_addr_t paddr = xen_bus_to_phys(dev, dma_addr);
 
if (!dev_is_dma_coherent(dev))
-   xen_dma_sync_for_cpu(dma_addr, paddr, size, dir);
+   xen_dma_sync_for_cpu(dev, dma_addr, paddr, size, dir);
 
if (is_xen_swiotlb_buffer(dma_addr))
swiotlb_tbl_sync_single(dev, paddr, size, dir, SYNC_FOR_CPU);
diff --git a/include/xen/swiotlb-xen.h b/include/xen/swiotlb-xen.h
index ffc0d3902b71..f62d1854780b 100644
--- a/include/xen/swiotlb-xen.h
+++ b/include/xen/swiotlb-xen.h
@@ -4,8 +4,9 @@
 
 #include 
 
-void xen_dma_sync_for_cpu(dma_addr_t handle, phys_addr_t paddr, size_t size,
-   enum dma_data_direction dir);
+void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle,
+ phys_addr_t paddr, size_t size,
+ enum dma_data_direction dir);
 void xen_dma_sync_for_device(dma_addr_t handle, phys_addr_t paddr, size_t size,
enum dma_data_direction dir);
 
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8929): 
https://lists.yoctoproject.org/g/linux-yocto/message/8929
Mute This Topic: https://lists.yoctoproject.org/mt/76044159/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 07/11] swiotlb-xen: add struct device * parameter to is_xen_swiotlb_buffer

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

No functional changes. The parameter is unused in this patch but will be
used by next patches.

Signed-off-by: Stefano Stabellini 
Reviewed-by: Boris Ostrovsky 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 drivers/xen/swiotlb-xen.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 8a3a7bcc5ec0..e2c35f45f91e 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -97,7 +97,7 @@ static inline int range_straddles_page_boundary(phys_addr_t 
p, size_t size)
return 0;
 }
 
-static int is_xen_swiotlb_buffer(dma_addr_t dma_addr)
+static int is_xen_swiotlb_buffer(struct device *dev, dma_addr_t dma_addr)
 {
unsigned long bfn = XEN_PFN_DOWN(dma_addr);
unsigned long xen_pfn = bfn_to_local_pfn(bfn);
@@ -431,7 +431,7 @@ static void xen_swiotlb_unmap_page(struct device *hwdev, 
dma_addr_t dev_addr,
xen_dma_sync_for_cpu(hwdev, dev_addr, paddr, size, dir);
 
/* NOTE: We use dev_addr here, not paddr! */
-   if (is_xen_swiotlb_buffer(dev_addr))
+   if (is_xen_swiotlb_buffer(hwdev, dev_addr))
swiotlb_tbl_unmap_single(hwdev, paddr, size, size, dir, attrs);
 }
 
@@ -444,7 +444,7 @@ xen_swiotlb_sync_single_for_cpu(struct device *dev, 
dma_addr_t dma_addr,
if (!dev_is_dma_coherent(dev))
xen_dma_sync_for_cpu(dev, dma_addr, paddr, size, dir);
 
-   if (is_xen_swiotlb_buffer(dma_addr))
+   if (is_xen_swiotlb_buffer(dev, dma_addr))
swiotlb_tbl_sync_single(dev, paddr, size, dir, SYNC_FOR_CPU);
 }
 
@@ -454,7 +454,7 @@ xen_swiotlb_sync_single_for_device(struct device *dev, 
dma_addr_t dma_addr,
 {
phys_addr_t paddr = xen_bus_to_phys(dev, dma_addr);
 
-   if (is_xen_swiotlb_buffer(dma_addr))
+   if (is_xen_swiotlb_buffer(dev, dma_addr))
swiotlb_tbl_sync_single(dev, paddr, size, dir, SYNC_FOR_DEVICE);
 
if (!dev_is_dma_coherent(dev))
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8931): 
https://lists.yoctoproject.org/g/linux-yocto/message/8931
Mute This Topic: https://lists.yoctoproject.org/mt/76044162/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 08/11] swiotlb-xen: remove XEN_PFN_PHYS

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

XEN_PFN_PHYS is only used in one place in swiotlb-xen making things more
complex than need to be.

Remove the definition of XEN_PFN_PHYS and open code the cast in the one
place where it is needed.

Signed-off-by: Stefano Stabellini 
Signed-off-by: Christopher Clark > XEN_PAGE_SHIFT)
 #define XEN_PFN_UP(x)  (((x) + XEN_PAGE_SIZE-1) >> XEN_PAGE_SHIFT)
-#define XEN_PFN_PHYS(x)((phys_addr_t)(x) << XEN_PAGE_SHIFT)
 
 #include 
 
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8932): 
https://lists.yoctoproject.org/g/linux-yocto/message/8932
Mute This Topic: https://lists.yoctoproject.org/mt/76044163/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 06/11] swiotlb-xen: add struct device * parameter to xen_dma_sync_for_device

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

No functional changes. The parameter is unused in this patch but will be
used by next patches.

Signed-off-by: Stefano Stabellini 
Reviewed-by: Boris Ostrovsky 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 arch/arm/xen/mm.c | 5 +++--
 drivers/xen/swiotlb-xen.c | 4 ++--
 include/xen/swiotlb-xen.h | 5 +++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index 1a00e8003c64..f2414ea40a79 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -81,8 +81,9 @@ void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t 
handle,
dma_cache_maint(handle, size, GNTTAB_CACHE_INVAL);
 }
 
-void xen_dma_sync_for_device(dma_addr_t handle, phys_addr_t paddr, size_t size,
-   enum dma_data_direction dir)
+void xen_dma_sync_for_device(struct device *dev, dma_addr_t handle,
+phys_addr_t paddr, size_t size,
+enum dma_data_direction dir)
 {
if (pfn_valid(PFN_DOWN(handle)))
arch_sync_dma_for_device(paddr, size, dir);
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index d04b7a15124f..8a3a7bcc5ec0 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -408,7 +408,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, 
struct page *page,
 
 done:
if (!dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
-   xen_dma_sync_for_device(dev_addr, phys, size, dir);
+   xen_dma_sync_for_device(dev, dev_addr, phys, size, dir);
return dev_addr;
 }
 
@@ -458,7 +458,7 @@ xen_swiotlb_sync_single_for_device(struct device *dev, 
dma_addr_t dma_addr,
swiotlb_tbl_sync_single(dev, paddr, size, dir, SYNC_FOR_DEVICE);
 
if (!dev_is_dma_coherent(dev))
-   xen_dma_sync_for_device(dma_addr, paddr, size, dir);
+   xen_dma_sync_for_device(dev, dma_addr, paddr, size, dir);
 }
 
 /*
diff --git a/include/xen/swiotlb-xen.h b/include/xen/swiotlb-xen.h
index f62d1854780b..6d235fe2b92d 100644
--- a/include/xen/swiotlb-xen.h
+++ b/include/xen/swiotlb-xen.h
@@ -7,8 +7,9 @@
 void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle,
  phys_addr_t paddr, size_t size,
  enum dma_data_direction dir);
-void xen_dma_sync_for_device(dma_addr_t handle, phys_addr_t paddr, size_t size,
-   enum dma_data_direction dir);
+void xen_dma_sync_for_device(struct device *dev, dma_addr_t handle,
+phys_addr_t paddr, size_t size,
+enum dma_data_direction dir);
 
 extern int xen_swiotlb_init(int verbose, bool early);
 extern const struct dma_map_ops xen_swiotlb_dma_ops;
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8930): 
https://lists.yoctoproject.org/g/linux-yocto/message/8930
Mute This Topic: https://lists.yoctoproject.org/mt/76044161/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 10/11] xen/arm: introduce phys/dma translations in xen_dma_sync_for_*

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

xen_dma_sync_for_cpu, xen_dma_sync_for_device, xen_arch_need_swiotlb are
getting called passing dma addresses. On some platforms dma addresses
could be different from physical addresses. Before doing any operations
on these addresses we need to convert them back to physical addresses
using dma_to_phys.

Move the arch_sync_dma_for_cpu and arch_sync_dma_for_device calls from
xen_dma_sync_for_cpu/device to swiotlb-xen.c, and add a call dma_to_phys
to do address translations there.

dma_cache_maint is fixed by the next patch.

Signed-off-by: Stefano Stabellini 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 arch/arm/xen/mm.c | 17 ++---
 drivers/xen/swiotlb-xen.c | 32 
 include/xen/swiotlb-xen.h |  6 ++
 3 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index f2414ea40a79..a8251a70f442 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -72,22 +73,16 @@ static void dma_cache_maint(dma_addr_t handle, size_t size, 
u32 op)
  * dma-direct functions, otherwise we call the Xen specific version.
  */
 void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle,
- phys_addr_t paddr, size_t size,
- enum dma_data_direction dir)
+ size_t size, enum dma_data_direction dir)
 {
-   if (pfn_valid(PFN_DOWN(handle)))
-   arch_sync_dma_for_cpu(paddr, size, dir);
-   else if (dir != DMA_TO_DEVICE)
+   if (dir != DMA_TO_DEVICE)
dma_cache_maint(handle, size, GNTTAB_CACHE_INVAL);
 }
 
 void xen_dma_sync_for_device(struct device *dev, dma_addr_t handle,
-phys_addr_t paddr, size_t size,
-enum dma_data_direction dir)
+size_t size, enum dma_data_direction dir)
 {
-   if (pfn_valid(PFN_DOWN(handle)))
-   arch_sync_dma_for_device(paddr, size, dir);
-   else if (dir == DMA_FROM_DEVICE)
+   if (dir == DMA_FROM_DEVICE)
dma_cache_maint(handle, size, GNTTAB_CACHE_INVAL);
else
dma_cache_maint(handle, size, GNTTAB_CACHE_CLEAN);
@@ -98,7 +93,7 @@ bool xen_arch_need_swiotlb(struct device *dev,
   dma_addr_t dev_addr)
 {
unsigned int xen_pfn = XEN_PFN_DOWN(phys);
-   unsigned int bfn = XEN_PFN_DOWN(dev_addr);
+   unsigned int bfn = XEN_PFN_DOWN(dma_to_phys(dev, dev_addr));
 
/*
 * The swiotlb buffer should be used if
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index a6a95358a8cb..39a0f2e0847c 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -413,8 +413,12 @@ static dma_addr_t xen_swiotlb_map_page(struct device *dev, 
struct page *page,
}
 
 done:
-   if (!dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
-   xen_dma_sync_for_device(dev, dev_addr, phys, size, dir);
+   if (!dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) {
+   if (pfn_valid(PFN_DOWN(dma_to_phys(dev, dev_addr
+   arch_sync_dma_for_device(phys, size, dir);
+   else
+   xen_dma_sync_for_device(dev, dev_addr, size, dir);
+   }
return dev_addr;
 }
 
@@ -433,8 +437,12 @@ static void xen_swiotlb_unmap_page(struct device *hwdev, 
dma_addr_t dev_addr,
 
BUG_ON(dir == DMA_NONE);
 
-   if (!dev_is_dma_coherent(hwdev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
-   xen_dma_sync_for_cpu(hwdev, dev_addr, paddr, size, dir);
+   if (!dev_is_dma_coherent(hwdev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) {
+   if (pfn_valid(PFN_DOWN(dma_to_phys(hwdev, dev_addr
+   arch_sync_dma_for_cpu(paddr, size, dir);
+   else
+   xen_dma_sync_for_cpu(hwdev, dev_addr, size, dir);
+   }
 
/* NOTE: We use dev_addr here, not paddr! */
if (is_xen_swiotlb_buffer(hwdev, dev_addr))
@@ -447,8 +455,12 @@ xen_swiotlb_sync_single_for_cpu(struct device *dev, 
dma_addr_t dma_addr,
 {
phys_addr_t paddr = xen_dma_to_phys(dev, dma_addr);
 
-   if (!dev_is_dma_coherent(dev))
-   xen_dma_sync_for_cpu(dev, dma_addr, paddr, size, dir);
+   if (!dev_is_dma_coherent(dev)) {
+   if (pfn_valid(PFN_DOWN(dma_to_phys(dev, dma_addr
+   arch_sync_dma_for_cpu(paddr, size, dir);
+   else
+   xen_dma_sync_for_cpu(dev, dma_addr, size, dir);
+   }
 
if (is_xen_swiotlb_buffer(dev, dma_addr))
swiotlb_tbl_sync_single(dev, paddr, size, dir, SYNC_FOR_CPU);
@@ -463,8 +475,12 @@ xen_swiotlb_sync_single_for_device(struct device *dev, 

[linux-yocto] [linux-yocto-dev][PATCH][kernel standard/bcm-2xxx-rpi 11/11] xen/arm: call dma_to_phys on the dma_addr_t parameter of dma_cache_maint

2020-08-07 Thread Christopher Clark
Author: Stefano Stabellini 

dma_cache_maint is getting called passing a dma address which could be
different from a physical address.

Add a struct device* parameter to dma_cache_maint.

Translate the dma_addr_t parameter of dma_cache_maint by calling
dma_to_phys. Do it for the first page and all the following pages, in
case of multipage handling.

Signed-off-by: Stefano Stabellini 
Reviewed-by: Boris Ostrovsky 
Tested-by: Corey Minyard 
Tested-by: Roman Shaposhnik 
Signed-off-by: Christopher Clark 
---
 arch/arm/xen/mm.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index a8251a70f442..396797ffe2b1 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -43,15 +43,18 @@ unsigned long xen_get_swiotlb_free_pages(unsigned int order)
 static bool hypercall_cflush = false;
 
 /* buffers in highmem or foreign pages cannot cross page boundaries */
-static void dma_cache_maint(dma_addr_t handle, size_t size, u32 op)
+static void dma_cache_maint(struct device *dev, dma_addr_t handle,
+   size_t size, u32 op)
 {
struct gnttab_cache_flush cflush;
 
-   cflush.a.dev_bus_addr = handle & XEN_PAGE_MASK;
cflush.offset = xen_offset_in_page(handle);
cflush.op = op;
+   handle &= XEN_PAGE_MASK;
 
do {
+   cflush.a.dev_bus_addr = dma_to_phys(dev, handle);
+
if (size + cflush.offset > XEN_PAGE_SIZE)
cflush.length = XEN_PAGE_SIZE - cflush.offset;
else
@@ -60,7 +63,7 @@ static void dma_cache_maint(dma_addr_t handle, size_t size, 
u32 op)
HYPERVISOR_grant_table_op(GNTTABOP_cache_flush, , 1);
 
cflush.offset = 0;
-   cflush.a.dev_bus_addr += cflush.length;
+   handle += cflush.length;
size -= cflush.length;
} while (size);
 }
@@ -76,16 +79,16 @@ void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t 
handle,
  size_t size, enum dma_data_direction dir)
 {
if (dir != DMA_TO_DEVICE)
-   dma_cache_maint(handle, size, GNTTAB_CACHE_INVAL);
+   dma_cache_maint(dev, handle, size, GNTTAB_CACHE_INVAL);
 }
 
 void xen_dma_sync_for_device(struct device *dev, dma_addr_t handle,
 size_t size, enum dma_data_direction dir)
 {
if (dir == DMA_FROM_DEVICE)
-   dma_cache_maint(handle, size, GNTTAB_CACHE_INVAL);
+   dma_cache_maint(dev, handle, size, GNTTAB_CACHE_INVAL);
else
-   dma_cache_maint(handle, size, GNTTAB_CACHE_CLEAN);
+   dma_cache_maint(dev, handle, size, GNTTAB_CACHE_CLEAN);
 }
 
 bool xen_arch_need_swiotlb(struct device *dev,
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8935): 
https://lists.yoctoproject.org/g/linux-yocto/message/8935
Mute This Topic: https://lists.yoctoproject.org/mt/76044168/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-