Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-06-24 Thread Jason Gunthorpe via iommu
On Mon, Jun 20, 2022 at 05:49:13AM +, nobuhiro1.iwama...@toshiba.co.jp 
wrote:
> Hi,
> 
> Thanks for your review.
> 
> > -Original Message-
> > From: Jason Gunthorpe 
> > Sent: Thursday, May 26, 2022 3:27 AM
> > To: Baolu Lu 
> > Cc: iwamatsu nobuhiro(岩松 信洋 □SWC◯ACT)
> > ; Joerg Roedel ; Will
> > Deacon ; Rob Herring ;
> > devicet...@vger.kernel.org; linux-ker...@vger.kernel.org;
> > iommu@lists.linux-foundation.org; ishikawa yuji(石川 悠司 ○RDC□AIT
> > C○EA開) ;
> > linux-arm-ker...@lists.infradead.org
> > Subject: Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver
> > 
> > On Wed, May 25, 2022 at 02:26:37PM +0800, Baolu Lu wrote:
> > > On 2022/5/25 09:31, Nobuhiro Iwamatsu wrote:
> > > > +static const struct iommu_ops visconti_atu_ops = {
> > > > +   .domain_alloc = visconti_atu_domain_alloc,
> > > > +   .probe_device = visconti_atu_probe_device,
> > > > +   .release_device = visconti_atu_release_device,
> > > > +   .device_group = generic_device_group,
> > > > +   .of_xlate = visconti_atu_of_xlate,
> > > > +   .pgsize_bitmap = ATU_IOMMU_PGSIZE_BITMAP,
> > > > +   .default_domain_ops = &(const struct iommu_domain_ops) {
> > > > +   .attach_dev = visconti_atu_attach_device,
> > > > +   .detach_dev = visconti_atu_detach_device,
> > >
> > > The detach_dev callback is about to be deprecated. The new drivers
> > > should implement the default domain and blocking domain instead.
> > 
> > Yes please, new drivers need to use default_domains.
> > 
> > It is very strange that visconti_atu_detach_device() does nothing.  It is 
> > not
> > required that a domain is fully unmapped before being destructed, I think
> > detach should set ATU_AT_EN to 0.
> 
> I see, I rethink implementation.
> 
> > 
> > What behavior does the HW have when ATU_AT_ENTRY_EN == 0? If DMA is
> > rejected then this driver should have a IOMMU_DOMAIN_BLOCKING and
> > return that from ops->def_domain_type().
> 
> If ATU_AT_ENTRY_EN is 0, nothing happens. It does not work with IOMMU,
> it works with the memory space set in device tree.

So that would be an assignment to DOMAIN_IDENTITY

> > I'm feeling like these "special" drivers need some kind of handshake with 
> > their
> > only users because they don't work with things like VFIO..
> 
> Since the devices that utilize this IOMMU function are fixed, I do
> not think that a special handshake is required.  Could you you tell
> me where you thought you needed a handshake?

In this case the iommu driver is so limited that it will not work with
VFIO - it is only ment to be used with the fixed drivers that are
paired with it.

Ideally we'd prevent VFIO from connecting and only allow drivers that
know the limitations of the IOMMU to use the unmanaged domain.

Jason
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

RE: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-06-19 Thread nobuhiro1.iwamatsu
Hi,

Thanks for your review.

> -Original Message-
> From: Jason Gunthorpe 
> Sent: Thursday, May 26, 2022 3:27 AM
> To: Baolu Lu 
> Cc: iwamatsu nobuhiro(岩松 信洋 □SWC◯ACT)
> ; Joerg Roedel ; Will
> Deacon ; Rob Herring ;
> devicet...@vger.kernel.org; linux-ker...@vger.kernel.org;
> iommu@lists.linux-foundation.org; ishikawa yuji(石川 悠司 ○RDC□AIT
> C○EA開) ;
> linux-arm-ker...@lists.infradead.org
> Subject: Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver
> 
> On Wed, May 25, 2022 at 02:26:37PM +0800, Baolu Lu wrote:
> > On 2022/5/25 09:31, Nobuhiro Iwamatsu wrote:
> > > +static const struct iommu_ops visconti_atu_ops = {
> > > + .domain_alloc = visconti_atu_domain_alloc,
> > > + .probe_device = visconti_atu_probe_device,
> > > + .release_device = visconti_atu_release_device,
> > > + .device_group = generic_device_group,
> > > + .of_xlate = visconti_atu_of_xlate,
> > > + .pgsize_bitmap = ATU_IOMMU_PGSIZE_BITMAP,
> > > + .default_domain_ops = &(const struct iommu_domain_ops) {
> > > + .attach_dev = visconti_atu_attach_device,
> > > + .detach_dev = visconti_atu_detach_device,
> >
> > The detach_dev callback is about to be deprecated. The new drivers
> > should implement the default domain and blocking domain instead.
> 
> Yes please, new drivers need to use default_domains.
> 
> It is very strange that visconti_atu_detach_device() does nothing.  It is not
> required that a domain is fully unmapped before being destructed, I think
> detach should set ATU_AT_EN to 0.

I see, I rethink implementation.

> 
> What behavior does the HW have when ATU_AT_ENTRY_EN == 0? If DMA is
> rejected then this driver should have a IOMMU_DOMAIN_BLOCKING and
> return that from ops->def_domain_type().

If ATU_AT_ENTRY_EN is 0, nothing happens. It does not work with IOMMU,
it works with the memory space set in device tree.
Also, I investigate about IOMMU_DOMAIN_BLOCKING.

> 
> Attaching a the blocking domain should set ATU_AT_ENTRY_EN = 0
> 
> Also, if I surmise how this works properly, it is not following the iommu API 
> to
> halt all DMA during map/unmap operations. Should at least document this and
> explain why it is OK..

I see, I will check DMA during map and unmap operations.

> 
> I'm feeling like these "special" drivers need some kind of handshake with 
> their
> only users because they don't work with things like VFIO..

Since the devices that utilize this IOMMU function are fixed, I do not think 
that a special handshake is required.
Could you you tell me where you thought you needed a handshake?

Best regards,
  Nobuhiro

> 
> Jason

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


RE: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-06-19 Thread nobuhiro1.iwamatsu
Hi,

> -Original Message-
> From: Baolu Lu 
> Sent: Wednesday, May 25, 2022 3:27 PM
> To: iwamatsu nobuhiro(岩松 信洋 □SWC◯ACT)
> ; Joerg Roedel ; Will
> Deacon ; Rob Herring ; Jason
> Gunthorpe 
> Cc: baolu...@linux.intel.com; devicet...@vger.kernel.org;
> linux-ker...@vger.kernel.org; iommu@lists.linux-foundation.org; ishikawa
> yuji(石川 悠司 ○RDC□AITC○EA開)
> ; linux-arm-ker...@lists.infradead.org
> Subject: Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver
> 
> On 2022/5/25 09:31, Nobuhiro Iwamatsu wrote:
> > +static const struct iommu_ops visconti_atu_ops = {
> > +   .domain_alloc = visconti_atu_domain_alloc,
> > +   .probe_device = visconti_atu_probe_device,
> > +   .release_device = visconti_atu_release_device,
> > +   .device_group = generic_device_group,
> > +   .of_xlate = visconti_atu_of_xlate,
> > +   .pgsize_bitmap = ATU_IOMMU_PGSIZE_BITMAP,
> > +   .default_domain_ops = &(const struct iommu_domain_ops) {
> > +   .attach_dev = visconti_atu_attach_device,
> > +   .detach_dev = visconti_atu_detach_device,
> 
> The detach_dev callback is about to be deprecated. The new drivers should
> implement the default domain and blocking domain instead.

I see. I will update this with next version.

> 
> > +   .map = visconti_atu_map,
> > +   .unmap = visconti_atu_unmap,
> > +   .iova_to_phys = visconti_atu_iova_to_phys,
> > +   .free = visconti_atu_domain_free,
> > +   }
> > +};
> 
> Best regards,
> baolu

Best regards,
  Nobuhiro
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-05-25 Thread Jason Gunthorpe via iommu
On Thu, May 26, 2022 at 12:43:25AM +, Tian, Kevin wrote:

> iiuc then this suggests there should be only one iommu group per atu,
> instead of using generic_device_group() to create one group per
> device.

Sounds like it

> > rejected then this driver should have a IOMMU_DOMAIN_BLOCKING and
> > return that from ops->def_domain_type().
> 
> BLOCKING should not be used as a default domain type for DMA API
> which needs either a DMA or IDENTITY type.

New drivers should not have a NULL group->default_domain. 

IMHO this driver does not support the DMA API so the default_domain
should be assigned to blocking and the DMA API disabled. We might need
some core changes to accommodate this.

The alternative would be to implement the identity domain, assuming
the ATU thing can store that kind of translation.

Jason
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


RE: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-05-25 Thread Tian, Kevin
> From: Jason Gunthorpe
> Sent: Thursday, May 26, 2022 2:27 AM
> 
> On Wed, May 25, 2022 at 02:26:37PM +0800, Baolu Lu wrote:
> > On 2022/5/25 09:31, Nobuhiro Iwamatsu wrote:
> > > +static const struct iommu_ops visconti_atu_ops = {
> > > + .domain_alloc = visconti_atu_domain_alloc,
> > > + .probe_device = visconti_atu_probe_device,
> > > + .release_device = visconti_atu_release_device,
> > > + .device_group = generic_device_group,
> > > + .of_xlate = visconti_atu_of_xlate,
> > > + .pgsize_bitmap = ATU_IOMMU_PGSIZE_BITMAP,
> > > + .default_domain_ops = &(const struct iommu_domain_ops) {
> > > + .attach_dev = visconti_atu_attach_device,
> > > + .detach_dev = visconti_atu_detach_device,
> >
> > The detach_dev callback is about to be deprecated. The new drivers
> > should implement the default domain and blocking domain instead.
> 
> Yes please, new drivers need to use default_domains.
> 
> It is very strange that visconti_atu_detach_device() does nothing.  It
> is not required that a domain is fully unmapped before being
> destructed, I think detach should set ATU_AT_EN to 0.

Looks the atu is shared by all devices behind and can only serve one
I/O address space. The atu registers only keep information about
iova ranges without any device notation. That is probably the reason 
why both attach/detach() don't touch hardware.

iiuc then this suggests there should be only one iommu group per atu,
instead of using generic_device_group() to create one group per
device.

> 
> What behavior does the HW have when ATU_AT_ENTRY_EN == 0? If DMA is

I guess it's a blocking behavior since that register tracks which iova range
register is valid. 

> rejected then this driver should have a IOMMU_DOMAIN_BLOCKING and
> return that from ops->def_domain_type().

BLOCKING should not be used as a default domain type for DMA API
which needs either a DMA or IDENTITY type.

> 
> Attaching a the blocking domain should set ATU_AT_ENTRY_EN = 0

Agree

> 
> Also, if I surmise how this works properly, it is not following the
> iommu API to halt all DMA during map/unmap operations. Should at least
> document this and explain why it is OK..
> 
> I'm feeling like these "special" drivers need some kind of handshake
> with their only users because they don't work with things like VFIO..
> 
> Jason
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-05-25 Thread Jason Gunthorpe via iommu
On Wed, May 25, 2022 at 02:26:37PM +0800, Baolu Lu wrote:
> On 2022/5/25 09:31, Nobuhiro Iwamatsu wrote:
> > +static const struct iommu_ops visconti_atu_ops = {
> > +   .domain_alloc = visconti_atu_domain_alloc,
> > +   .probe_device = visconti_atu_probe_device,
> > +   .release_device = visconti_atu_release_device,
> > +   .device_group = generic_device_group,
> > +   .of_xlate = visconti_atu_of_xlate,
> > +   .pgsize_bitmap = ATU_IOMMU_PGSIZE_BITMAP,
> > +   .default_domain_ops = &(const struct iommu_domain_ops) {
> > +   .attach_dev = visconti_atu_attach_device,
> > +   .detach_dev = visconti_atu_detach_device,
> 
> The detach_dev callback is about to be deprecated. The new drivers
> should implement the default domain and blocking domain instead.

Yes please, new drivers need to use default_domains.

It is very strange that visconti_atu_detach_device() does nothing.  It
is not required that a domain is fully unmapped before being
destructed, I think detach should set ATU_AT_EN to 0.

What behavior does the HW have when ATU_AT_ENTRY_EN == 0? If DMA is
rejected then this driver should have a IOMMU_DOMAIN_BLOCKING and
return that from ops->def_domain_type().

Attaching a the blocking domain should set ATU_AT_ENTRY_EN = 0

Also, if I surmise how this works properly, it is not following the
iommu API to halt all DMA during map/unmap operations. Should at least
document this and explain why it is OK..

I'm feeling like these "special" drivers need some kind of handshake
with their only users because they don't work with things like VFIO..

Jason
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-05-25 Thread kernel test robot
Hi Nobuhiro,

I love your patch! Yet something to improve:

[auto build test ERROR on joro-iommu/next]
[also build test ERROR on arm-perf/for-next/perf soc/for-next linus/master 
v5.18 next-20220524]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/intel-lab-lkp/linux/commits/Nobuhiro-Iwamatsu/Add-Visconti5-IOMMU-driver/20220525-093326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next
config: alpha-allyesconfig 
(https://download.01.org/0day-ci/archive/20220525/202205251708.q7cwjpf8-...@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/69bb4f3c2ef0bb1f65922bc72bb31109897a6393
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Nobuhiro-Iwamatsu/Add-Visconti5-IOMMU-driver/20220525-093326
git checkout 69bb4f3c2ef0bb1f65922bc72bb31109897a6393
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 
O=build_dir ARCH=alpha SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

Note: the 
linux-review/Nobuhiro-Iwamatsu/Add-Visconti5-IOMMU-driver/20220525-093326 HEAD 
07739c72b066c0781c371eec7614ed876441e8dd builds fine.
  It only hurts bisectability.

All errors (new ones prefixed by >>):

>> drivers/iommu/visconti-atu.c:47:29: error: field 'iommu' has incomplete type
  47 | struct iommu_device iommu;
 | ^
>> drivers/iommu/visconti-atu.c:62:29: error: field 'io_domain' has incomplete 
>> type
  62 | struct iommu_domain io_domain;
 | ^
   In file included from include/linux/bits.h:22,
from include/linux/ratelimit_types.h:5,
from include/linux/ratelimit.h:5,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from include/linux/dma-mapping.h:7,
from drivers/iommu/visconti-atu.c:12:
   drivers/iommu/visconti-atu.c: In function 'to_atu_domain':
   include/linux/compiler_types.h:293:27: error: expression in static assertion 
is not an integer
 293 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), 
typeof(b))
 |   ^~~~
   include/linux/build_bug.h:78:56: note: in definition of macro 
'__static_assert'
  78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 |^~~~
   include/linux/container_of.h:19:9: note: in expansion of macro 
'static_assert'
  19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||
   \
 | ^
   include/linux/container_of.h:19:23: note: in expansion of macro '__same_type'
  19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||
   \
 |   ^~~
   drivers/iommu/visconti-atu.c:70:16: note: in expansion of macro 
'container_of'
  70 | return container_of(domain, struct visconti_atu_domain, 
io_domain);
 |^~~~
   drivers/iommu/visconti-atu.c: In function 'visconti_atu_attach_device':
>> drivers/iommu/visconti-atu.c:121:43: error: implicit declaration of function 
>> 'dev_iommu_priv_get' [-Werror=implicit-function-declaration]
 121 | struct visconti_atu_device *atu = dev_iommu_priv_get(dev);
 |   ^~
   drivers/iommu/visconti-atu.c:121:43: warning: initialization of 'struct 
visconti_atu_device *' from 'int' makes pointer from integer without a cast 
[-Wint-conversion]
   drivers/iommu/visconti-atu.c: In function 'visconti_atu_detach_device':
   drivers/iommu/visconti-atu.c:150:43: warning: initialization of 'struct 
visconti_atu_device *' from 'int' makes pointer from integer without a cast 
[-Wint-conversion]
 150 | struct visconti_atu_device *atu = dev_iommu_priv_get(dev);
 |   ^~
   drivers/iommu/visconti-atu.c: At top level:
   drivers/iommu/visconti-atu.c:196:41: warning: 'struct iommu_iotlb_gather' 
declared inside parameter list will not be visible outside of this definition 
or declaration
 196 |  struct iommu_iotlb_gather 
*iotlb_gather)
 | 

Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-05-25 Thread Baolu Lu

On 2022/5/25 09:31, Nobuhiro Iwamatsu wrote:

+static const struct iommu_ops visconti_atu_ops = {
+   .domain_alloc = visconti_atu_domain_alloc,
+   .probe_device = visconti_atu_probe_device,
+   .release_device = visconti_atu_release_device,
+   .device_group = generic_device_group,
+   .of_xlate = visconti_atu_of_xlate,
+   .pgsize_bitmap = ATU_IOMMU_PGSIZE_BITMAP,
+   .default_domain_ops = &(const struct iommu_domain_ops) {
+   .attach_dev = visconti_atu_attach_device,
+   .detach_dev = visconti_atu_detach_device,


The detach_dev callback is about to be deprecated. The new drivers
should implement the default domain and blocking domain instead.


+   .map = visconti_atu_map,
+   .unmap = visconti_atu_unmap,
+   .iova_to_phys = visconti_atu_iova_to_phys,
+   .free = visconti_atu_domain_free,
+   }
+};


Best regards,
baolu
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-05-25 Thread kernel test robot
Hi Nobuhiro,

I love your patch! Perhaps something to improve:

[auto build test WARNING on joro-iommu/next]
[also build test WARNING on arm-perf/for-next/perf soc/for-next linus/master 
v5.18 next-20220524]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/intel-lab-lkp/linux/commits/Nobuhiro-Iwamatsu/Add-Visconti5-IOMMU-driver/20220525-093326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next
config: alpha-allyesconfig 
(https://download.01.org/0day-ci/archive/20220525/202205251452.kfxlqhqx-...@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/69bb4f3c2ef0bb1f65922bc72bb31109897a6393
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Nobuhiro-Iwamatsu/Add-Visconti5-IOMMU-driver/20220525-093326
git checkout 69bb4f3c2ef0bb1f65922bc72bb31109897a6393
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 
O=build_dir ARCH=alpha SHELL=/bin/bash drivers/iommu/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

   drivers/iommu/visconti-atu.c:47:29: error: field 'iommu' has incomplete type
  47 | struct iommu_device iommu;
 | ^
   drivers/iommu/visconti-atu.c:62:29: error: field 'io_domain' has incomplete 
type
  62 | struct iommu_domain io_domain;
 | ^
   In file included from include/linux/bits.h:22,
from include/linux/ratelimit_types.h:5,
from include/linux/ratelimit.h:5,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from include/linux/dma-mapping.h:7,
from drivers/iommu/visconti-atu.c:12:
   drivers/iommu/visconti-atu.c: In function 'to_atu_domain':
   include/linux/compiler_types.h:293:27: error: expression in static assertion 
is not an integer
 293 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), 
typeof(b))
 |   ^~~~
   include/linux/build_bug.h:78:56: note: in definition of macro 
'__static_assert'
  78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 |^~~~
   include/linux/container_of.h:19:9: note: in expansion of macro 
'static_assert'
  19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||
   \
 | ^
   include/linux/container_of.h:19:23: note: in expansion of macro '__same_type'
  19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||
   \
 |   ^~~
   drivers/iommu/visconti-atu.c:70:16: note: in expansion of macro 
'container_of'
  70 | return container_of(domain, struct visconti_atu_domain, 
io_domain);
 |^~~~
   drivers/iommu/visconti-atu.c: In function 'visconti_atu_attach_device':
   drivers/iommu/visconti-atu.c:121:43: error: implicit declaration of function 
'dev_iommu_priv_get' [-Werror=implicit-function-declaration]
 121 | struct visconti_atu_device *atu = dev_iommu_priv_get(dev);
 |   ^~
>> drivers/iommu/visconti-atu.c:121:43: warning: initialization of 'struct 
>> visconti_atu_device *' from 'int' makes pointer from integer without a cast 
>> [-Wint-conversion]
   drivers/iommu/visconti-atu.c: In function 'visconti_atu_detach_device':
   drivers/iommu/visconti-atu.c:150:43: warning: initialization of 'struct 
visconti_atu_device *' from 'int' makes pointer from integer without a cast 
[-Wint-conversion]
 150 | struct visconti_atu_device *atu = dev_iommu_priv_get(dev);
 |   ^~
   drivers/iommu/visconti-atu.c: At top level:
>> drivers/iommu/visconti-atu.c:196:41: warning: 'struct iommu_iotlb_gather' 
>> declared inside parameter list will not be visible outside of this 
>> definition or declaration
 196 |  struct iommu_iotlb_gather 
*iotlb_gather)
 | ^~
   drivers/iommu/visconti-atu.c: In function 'visconti_atu_of_xlate':
   drivers/iommu/visconti-atu.c:262:17: error: implicit declaration of 

Re: [PATCH 1/3] iommu: Add Visconti5 IOMMU driver

2022-05-24 Thread kernel test robot
Hi Nobuhiro,

I love your patch! Perhaps something to improve:

[auto build test WARNING on joro-iommu/next]
[also build test WARNING on arm-perf/for-next/perf soc/for-next linus/master 
v5.18 next-20220524]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/intel-lab-lkp/linux/commits/Nobuhiro-Iwamatsu/Add-Visconti5-IOMMU-driver/20220525-093326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next
config: nios2-allyesconfig 
(https://download.01.org/0day-ci/archive/20220525/202205251205.phq3cwj3-...@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/69bb4f3c2ef0bb1f65922bc72bb31109897a6393
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Nobuhiro-Iwamatsu/Add-Visconti5-IOMMU-driver/20220525-093326
git checkout 69bb4f3c2ef0bb1f65922bc72bb31109897a6393
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 
O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/iommu/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

   drivers/iommu/visconti-atu.c:47:29: error: field 'iommu' has incomplete type
  47 | struct iommu_device iommu;
 | ^
   drivers/iommu/visconti-atu.c:62:29: error: field 'io_domain' has incomplete 
type
  62 | struct iommu_domain io_domain;
 | ^
   In file included from include/linux/bits.h:22,
from include/linux/ratelimit_types.h:5,
from include/linux/ratelimit.h:5,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from include/linux/dma-mapping.h:7,
from drivers/iommu/visconti-atu.c:12:
   drivers/iommu/visconti-atu.c: In function 'to_atu_domain':
   include/linux/compiler_types.h:293:27: error: expression in static assertion 
is not an integer
 293 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), 
typeof(b))
 |   ^~~~
   include/linux/build_bug.h:78:56: note: in definition of macro 
'__static_assert'
  78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 |^~~~
   include/linux/container_of.h:19:9: note: in expansion of macro 
'static_assert'
  19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||
   \
 | ^
   include/linux/container_of.h:19:23: note: in expansion of macro '__same_type'
  19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||
   \
 |   ^~~
   drivers/iommu/visconti-atu.c:70:16: note: in expansion of macro 
'container_of'
  70 | return container_of(domain, struct visconti_atu_domain, 
io_domain);
 |^~~~
   drivers/iommu/visconti-atu.c: In function 'visconti_atu_enable_entry':
>> drivers/iommu/visconti-atu.c:102:52: warning: right shift count >= width of 
>> type [-Wshift-count-overflow]
 102 |(atu->iova[num] >> 32) & 
ATU_BGADDR_MASK);
 |^~
   drivers/iommu/visconti-atu.c: In function 'visconti_atu_attach_device':
   drivers/iommu/visconti-atu.c:121:43: error: implicit declaration of function 
'dev_iommu_priv_get' [-Werror=implicit-function-declaration]
 121 | struct visconti_atu_device *atu = dev_iommu_priv_get(dev);
 |   ^~
   drivers/iommu/visconti-atu.c:121:43: warning: initialization of 'struct 
visconti_atu_device *' from 'int' makes pointer from integer without a cast 
[-Wint-conversion]
   drivers/iommu/visconti-atu.c: In function 'visconti_atu_detach_device':
   drivers/iommu/visconti-atu.c:150:43: warning: initialization of 'struct 
visconti_atu_device *' from 'int' makes pointer from integer without a cast 
[-Wint-conversion]
 150 | struct visconti_atu_device *atu = dev_iommu_priv_get(dev);
 |   ^~
   drivers/iommu/visconti-atu.c: At top level:
   drivers/iommu/visconti-atu.c:196:41: warning: 'struct iommu_iotlb_gather' 
declared inside parameter list will not be visible outside of