Message ID | 20181003132212.12619-1-boris.brezillon@bootlin.com |
---|---|
Headers | show |
Series | Add the I3C subsystem | expand |
On Wed, Oct 3, 2018 at 3:22 PM Boris Brezillon <boris.brezillon@bootlin.com> wrote: > > Add a driver for Cadence I3C master IP. > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> > --- > Changes in v7: > - Fix readsl/writesl() usage > - Add a depends on ARM || ARM64 || XTENSA to forbid selection of this > driver on platforms that are not implementing readsl/writesl Most architectures include asm-generic/io.h, which contains a generic implementation of readsl(). Maybe that #ifdef could be extended here? I remember discussing this with you not so long ago, which led to commit 0bbf47eab469 ("ia64: use asm-generic/io.h"). Do we have a list of architectures that don't include asm-generic/io.h? Maybe the 'depends on' could be for the set of architectures that fail here. > +static void cdns_i3c_master_rd_from_rx_fifo(struct cdns_i3c_master *master, > + u8 *bytes, int nbytes) > +{ > + readsl(master->regs + RX_FIFO, bytes, nbytes / 4); > + if (nbytes & 3) { > + u32 tmp = __raw_readl(master->regs + RX_FIFO); > + > + memcpy(bytes + (nbytes & ~3), &tmp, nbytes & 3); > + } > +} The __raw_readl() is probably correct here (I can't think of any architecture on which it is not), but it still makes me feel uneasy about possible endianess or other issues. Maybe make this:? readsl(master->regs + RX_FIFO, &tmp, 1); Arnd
On Mon, 8 Oct 2018 12:06:30 +0200 Arnd Bergmann <arnd@arndb.de> wrote: > On Wed, Oct 3, 2018 at 3:22 PM Boris Brezillon > <boris.brezillon@bootlin.com> wrote: > > > > Add a driver for Cadence I3C master IP. > > > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> > > --- > > > Changes in v7: > > - Fix readsl/writesl() usage > > - Add a depends on ARM || ARM64 || XTENSA to forbid selection of this > > driver on platforms that are not implementing readsl/writesl > > Most architectures include asm-generic/io.h, which contains a generic > implementation of readsl(). Maybe that #ifdef could be extended here? > I remember discussing this with you not so long ago, which led to > commit 0bbf47eab469 ("ia64: use asm-generic/io.h"). Do we have > a list of architectures that don't include asm-generic/io.h? Maybe > the 'depends on' could be for the set of architectures that fail here. Well, we started patching 2 archs (ia64 and sparc) based on kbuild robots failure report, and then I received other reports (still from kbuild robots) long after the initial ones. I can't tell for sure which archs are not implementing those functions, hence the conservative approach taken here. > > > +static void cdns_i3c_master_rd_from_rx_fifo(struct cdns_i3c_master *master, > > + u8 *bytes, int nbytes) > > +{ > > + readsl(master->regs + RX_FIFO, bytes, nbytes / 4); > > + if (nbytes & 3) { > > + u32 tmp = __raw_readl(master->regs + RX_FIFO); > > + > > + memcpy(bytes + (nbytes & ~3), &tmp, nbytes & 3); > > + } > > +} > > The __raw_readl() is probably correct here (I can't think of any > architecture on which it is not), but it still makes me feel uneasy > about possible endianess or other issues. > > Maybe make this:? > > readsl(master->regs + RX_FIFO, &tmp, 1); I'm fine with that, assuming it does the same thing :-).
On Mon, Oct 8, 2018 at 12:21 PM Boris Brezillon <boris.brezillon@bootlin.com> wrote: > > On Mon, 8 Oct 2018 12:06:30 +0200 > Arnd Bergmann <arnd@arndb.de> wrote: > > > On Wed, Oct 3, 2018 at 3:22 PM Boris Brezillon > > <boris.brezillon@bootlin.com> wrote: > > > > > > Add a driver for Cadence I3C master IP. > > > > > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> > > > --- > > > > > Changes in v7: > > > - Fix readsl/writesl() usage > > > - Add a depends on ARM || ARM64 || XTENSA to forbid selection of this > > > driver on platforms that are not implementing readsl/writesl > > > > Most architectures include asm-generic/io.h, which contains a generic > > implementation of readsl(). Maybe that #ifdef could be extended here? > > I remember discussing this with you not so long ago, which led to > > commit 0bbf47eab469 ("ia64: use asm-generic/io.h"). Do we have > > a list of architectures that don't include asm-generic/io.h? Maybe > > the 'depends on' could be for the set of architectures that fail here. > > Well, we started patching 2 archs (ia64 and sparc) based on kbuild > robots failure report, and then I received other reports (still from > kbuild robots) long after the initial ones. I can't tell for sure which > archs are not implementing those functions, hence the conservative > approach taken here. I think it's a fairly safe assumption that architectures which include asm-generic/io.h will be fine here. If one of them is broken, that can be fixed individually. Looking at the ones that don't include this file: grep -L asm-generic/io.h arch/*/include/asm/io*.h arch/alpha/include/asm/io.h # missing readsl arch/hexagon/include/asm/io.h # has its own readsl arch/mips/include/asm/io.h # missing readsl (but used from ide.h?) arch/parisc/include/asm/io.h # missing readsl arch/powerpc/include/asm/io.h # has its own readsl arch/sh/include/asm/io.h # has its own readsl arch/sparc/include/asm/io.h # has its own readsl Based on this, I would try what happens on mips, and make it depend on !(ALPHA || PARISC) Another option is to just use ioread32_rep(), which should be available everywhere and has almost the same behavior as readsl(). The only difference is that on architectures like x86 it takes a few extra cycles to look at the address. Arnd
On Wed, Oct 3, 2018 at 3:22 PM Boris Brezillon <boris.brezillon@bootlin.com> wrote: > > Sorry for the huge delay between v7 and v8 despite the small amount of > things I was asked to fix/rework. > > This patch series is adding a new subsystem to support I3C devices. > > This is just adding support for basic features. Extra features will > be added afterwards. > > There are a few design choices that are worth mentioning because they > impact the way I3C device drivers can interact with their devices: > > - all functions used to send I3C/I2C frames must be called in > non-atomic context. Mainly done this way to ease implementation, but > this is still open to discussion. Please let me know if you think it's > worth considering an asynchronous model here > - the I3C bus and I3C master controller are now tightly coupled even > though they're still allocated separately. There's now a 1:1 > relationship between these objects, and the I3C master is no longer > represented under the I3C bus object. > Arnd, let me know if you had something different in mind, and I'll > rework the implementation accordingly. I looked at the entire series again and I'm rather happy with how it turned out. I've commented on a tiny issue about the readsl() that should be easy to resolve one way or another, with that you can add my Reviewed-by: Arnd Bergmann <arnd@arndb.de> There is one additional issue that we've talked about previously and that I'd like to hear about from GregKH or maybe other subsystem maintainers: In the current version, you have a single 'bus_type' object, and this is used to represent both a 'host' and a 'device'. I think we concluded that this is done in other subsystems as well, and that this is fitting here because a host (master device) can hand over being a master to another device (slave), which then becomes the host and sees this one as a slave. Also a lot of the sysfs attributes are the same because of this relationship. It also means that you get a mix of things in sysfs: /sys/devices/i3c/<bus> /sys/devices/i3c/<device> /sys/devices/i3c/<bus>/<device> which is a bit like what we have on USB where we can have hub devices that are again parents of other USB devices, but I don't think we can have i3c hubs or multiplexers in the same way, so it's only a single level. I'm ok with this model after our previous discussion and couldn't come up with a better one. If anyone else still sees it as problematic and has a better idea, please let us know now. Arnd
On Mon, 8 Oct 2018 12:36:44 +0200 Arnd Bergmann <arnd@arndb.de> wrote: > On Mon, Oct 8, 2018 at 12:21 PM Boris Brezillon > <boris.brezillon@bootlin.com> wrote: > > > > On Mon, 8 Oct 2018 12:06:30 +0200 > > Arnd Bergmann <arnd@arndb.de> wrote: > > > > > On Wed, Oct 3, 2018 at 3:22 PM Boris Brezillon > > > <boris.brezillon@bootlin.com> wrote: > > > > > > > > Add a driver for Cadence I3C master IP. > > > > > > > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> > > > > --- > > > > > > > Changes in v7: > > > > - Fix readsl/writesl() usage > > > > - Add a depends on ARM || ARM64 || XTENSA to forbid selection of this > > > > driver on platforms that are not implementing readsl/writesl > > > > > > Most architectures include asm-generic/io.h, which contains a generic > > > implementation of readsl(). Maybe that #ifdef could be extended here? > > > I remember discussing this with you not so long ago, which led to > > > commit 0bbf47eab469 ("ia64: use asm-generic/io.h"). Do we have > > > a list of architectures that don't include asm-generic/io.h? Maybe > > > the 'depends on' could be for the set of architectures that fail here. > > > > Well, we started patching 2 archs (ia64 and sparc) based on kbuild > > robots failure report, and then I received other reports (still from > > kbuild robots) long after the initial ones. I can't tell for sure which > > archs are not implementing those functions, hence the conservative > > approach taken here. > > I think it's a fairly safe assumption that architectures which include > asm-generic/io.h will be fine here. If one of them is broken, that > can be fixed individually. Looking at the ones that don't include this > file: > > grep -L asm-generic/io.h arch/*/include/asm/io*.h > arch/alpha/include/asm/io.h # missing readsl > arch/hexagon/include/asm/io.h # has its own readsl > arch/mips/include/asm/io.h # missing readsl (but used from ide.h?) > arch/parisc/include/asm/io.h # missing readsl > arch/powerpc/include/asm/io.h # has its own readsl > arch/sh/include/asm/io.h # has its own readsl > arch/sparc/include/asm/io.h # has its own readsl > > Based on this, I would try what happens on mips, and make it depend > on !(ALPHA || PARISC) Okay, I'll try with that.
Hi Greg, On Mon, 8 Oct 2018 12:47:21 +0200 Arnd Bergmann <arnd@arndb.de> wrote: > On Wed, Oct 3, 2018 at 3:22 PM Boris Brezillon > <boris.brezillon@bootlin.com> wrote: > > > > Sorry for the huge delay between v7 and v8 despite the small amount of > > things I was asked to fix/rework. > > > > This patch series is adding a new subsystem to support I3C devices. > > > > This is just adding support for basic features. Extra features will > > be added afterwards. > > > > There are a few design choices that are worth mentioning because they > > impact the way I3C device drivers can interact with their devices: > > > > - all functions used to send I3C/I2C frames must be called in > > non-atomic context. Mainly done this way to ease implementation, but > > this is still open to discussion. Please let me know if you think it's > > worth considering an asynchronous model here > > - the I3C bus and I3C master controller are now tightly coupled even > > though they're still allocated separately. There's now a 1:1 > > relationship between these objects, and the I3C master is no longer > > represented under the I3C bus object. > > Arnd, let me know if you had something different in mind, and I'll > > rework the implementation accordingly. > > I looked at the entire series again and I'm rather happy with how > it turned out. I've commented on a tiny issue about the readsl() > that should be easy to resolve one way or another, with that > you can add my > > Reviewed-by: Arnd Bergmann <arnd@arndb.de> > > There is one additional issue that we've talked about previously > and that I'd like to hear about from GregKH or maybe other > subsystem maintainers: In the current version, you have a single > 'bus_type' object, and this is used to represent both a 'host' and > a 'device'. I think we concluded that this is done in other > subsystems as well, and that this is fitting here because a > host (master device) can hand over being a master to another > device (slave), which then becomes the host and sees this > one as a slave. Also a lot of the sysfs attributes are the same > because of this relationship. > > It also means that you get a mix of things in sysfs: > > /sys/devices/i3c/<bus> > /sys/devices/i3c/<device> > /sys/devices/i3c/<bus>/<device> > > which is a bit like what we have on USB where we can have hub > devices that are again parents of other USB devices, but I don't > think we can have i3c hubs or multiplexers in the same way, so > it's only a single level. > > I'm ok with this model after our previous discussion and couldn't > come up with a better one. If anyone else still sees it as > problematic and has a better idea, please let us know now. I know you're quite busy with the 4.19 release, but if you find a bit of time, that'd be great to have your feedback on this. Thanks, Boris