Message ID | 20240516181907.3468796-24-eajames@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | fsi: Add interrupt support | expand |
Hi Eddie,
kernel test robot noticed the following build errors:
[auto build test ERROR on andi-shyti/i2c/i2c-host]
[also build test ERROR on robh/for-next broonie-spi/for-next linus/master v6.9 next-20240517]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Eddie-James/fsi-hub-Set-master-index-to-link-number-plus-one/20240517-023205
base: git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link: https://lore.kernel.org/r/20240516181907.3468796-24-eajames%40linux.ibm.com
patch subject: [PATCH v3 23/40] fsi: core: Add interrupt support
config: x86_64-randconfig-102-20240517 (https://download.01.org/0day-ci/archive/20240518/202405180410.FkV8wPos-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240518/202405180410.FkV8wPos-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405180410.FkV8wPos-lkp@intel.com/
All errors (new ones prefixed by >>, old ones prefixed by <<):
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/locking/locktorture.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/rcutorture.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/rcuscale.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/refscale.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/torture.o
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/kasan/kasan_test_module.o
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/zsmalloc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nfs/nfsv4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp437.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp737.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp775.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp857.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp860.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp865.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp1251.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-2.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-3.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp1255.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-15.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-r.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-u.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-ru.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_utf8.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-croatian.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-gaelic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-greek.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-iceland.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-romanian.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-turkish.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_ucs2_utils.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/fat/fat.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/smb/common/cifs_arc4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/smb/common/cifs_md4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/autofs/autofs4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in security/keys/trusted-keys/trusted.o
WARNING: modpost: missing MODULE_DESCRIPTION() in crypto/ecc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in block/t10-pi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/crypto/libdes.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_firmware.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_sysctl.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_min_heap.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_module.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_rhashtable.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_user_copy.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_bitmap.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_memcat_p.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_meminit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_free_pages.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/asn1_decoder.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/asn1_encoder.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pinctrl/pinctrl-mcp23s08_i2c.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pinctrl/pinctrl-mcp23s08_spi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pinctrl/pinctrl-mcp23s08.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/backlight/platform_lcd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/dmatest.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/ttynull.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/nvram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/ppdev.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/bridge/lontium-lt9611.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-spmi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-w1.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/misc/open-dice.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/arizona.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/pcf50633-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/scsi/scsi_common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/chips/cfi_util.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rtc/rtc-tps65910.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwmon/corsair-cpro.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/pwrseq_emmc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-apple.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-aureal.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-cypress.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-emsff.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-ezkey.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-ite.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-keytouch.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-lcpower.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-magicmouse.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-mf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-microsoft.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-primax.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-gaff.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-topseed.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-zydacron.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hid/hid-viewsonic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-spilib.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-log.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-power-supply.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-raw.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-gbphy.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-i2c.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-sdio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-spi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/platform/goldfish/goldfish_pipe.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_userspace.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/spmi/hisi-spmi-controller.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/uio/uio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-scom.o
>> ERROR: modpost: "handle_irq_desc" [drivers/fsi/fsi-core.ko] undefined!
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 8b402149acbe9..ae65d87d4b13e 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -14,10 +14,12 @@ #include <linux/device.h> #include <linux/fsi.h> #include <linux/idr.h> +#include <linux/irqdomain.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_device.h> +#include <linux/of_irq.h> #include <linux/regmap.h> #include <linux/slab.h> #include <linux/bitops.h> @@ -109,6 +111,67 @@ int fsi_device_peek(struct fsi_device *dev, void *val) return fsi_slave_read(dev->slave, addr, val, sizeof(uint32_t)); } +EXPORT_SYMBOL_GPL(fsi_device_peek); + +static int fsi_request_irq(struct fsi_slave *slave, irq_handler_t handler, void *data, + unsigned int engine_irq, struct device *dev) +{ + struct device_node *parent = of_node_get(slave->master->dev.of_node); + struct irq_fwspec fwspec; + unsigned int irq; + + /* + * FSI devices can only report interrupts to their own master, so if the master + * isn't an interrupt controller, don't try and map an irq. + */ + if (!of_get_property(parent, "#interrupt-cells", NULL)) { + of_node_put(parent); + return -EINVAL; + } + + fwspec.fwnode = of_node_to_fwnode(parent); + fwspec.param_count = 1; + fwspec.param[0] = engine_irq + (slave->link * FSI_IRQ_COUNT); + irq = irq_create_fwspec_mapping(&fwspec); + if (!irq) + return -EINVAL; + + return devm_request_irq(dev, irq, handler, 0, dev_name(dev), data); +} + +int fsi_device_request_irq(struct fsi_device *dev, irq_handler_t handler, void *data) +{ + unsigned int engine_irq; + + switch (dev->engine_type) { + case 0x4: // shift + engine_irq = 1; + break; + case 0x5: // scom + engine_irq = 2; + break; + case 0x6: // scratchpad + engine_irq = 3; + break; + case 0x7: // i2cm + engine_irq = 4; + break; + case 0x20: // mbox + engine_irq = 7; + break; + case 0x22: // sbefifo + engine_irq = 6; + break; + case 0x23: // spim + engine_irq = 5; + break; + default: + return -EINVAL; + } + + return fsi_request_irq(dev->slave, handler, data, engine_irq, &dev->dev); +} +EXPORT_SYMBOL_GPL(fsi_device_request_irq); unsigned long fsi_device_local_bus_frequency(struct fsi_device *dev) { @@ -1467,6 +1530,99 @@ void fsi_master_regmap_config(struct regmap_config *config) } EXPORT_SYMBOL_GPL(fsi_master_regmap_config); +int fsi_master_irq(struct fsi_master *master, struct irq_domain *irq_domain, unsigned int link) +{ + struct irq_desc *downstream = irq_resolve_mapping(irq_domain, (link * FSI_IRQ_COUNT) + 8); + unsigned long size = FSI_SI1S_SLAVE_BIT + 1; + unsigned long bit = FSI_SI1S_MBOX_BIT; + unsigned long srsis0 = 0; + unsigned long srsis4 = 0; + unsigned long si1s; + __be32 reg; + int rc; + + rc = fsi_master_read(master, link, 0, FSI_SLAVE_BASE + FSI_SI1S, ®, sizeof(reg)); + if (rc) + return rc; + + si1s = (unsigned long)be32_to_cpu(reg); + for_each_set_bit_from(bit, &si1s, size) + generic_handle_domain_irq(irq_domain, (link * FSI_IRQ_COUNT) + (31 - bit)); + + if (downstream) { + int i; + + master->remote_interrupt_status = 0; + + rc = fsi_master_read(master, link, 0, FSI_SLAVE_BASE + FSI_SRSIS0, ®, + sizeof(reg)); + if (rc) + return rc; + + srsis0 = (unsigned long)be32_to_cpu(reg); + for (i = 0; i < 4; ++i) { + if (srsis0 & (0xff000000 >> (8 * i))) + master->remote_interrupt_status |= (1 << i); + } + + rc = fsi_master_read(master, link, 0, FSI_SLAVE_BASE + FSI_SRSIS4, ®, + sizeof(reg)); + if (rc) + return rc; + + srsis4 = (unsigned long)be32_to_cpu(reg); + for (i = 0; i < 4; ++i) { + if (srsis4 & (0xff000000 >> (8 * i))) + master->remote_interrupt_status |= (16 << i); + } + + if (master->remote_interrupt_status) { + handle_irq_desc(downstream); + + reg = cpu_to_be32(0xffffffff); + if (master->remote_interrupt_status & 0xf) + fsi_master_write(master, link, 0, FSI_SLAVE_BASE + FSI_SRSIC0, + ®, sizeof(reg)); + + if (master->remote_interrupt_status & 0xf0) + fsi_master_write(master, link, 0, FSI_SLAVE_BASE + FSI_SRSIC4, + ®, sizeof(reg)); + } + } + + trace_fsi_master_irq(master, link, si1s, srsis0, srsis4); + return 0; +} +EXPORT_SYMBOL_GPL(fsi_master_irq); + +static void fsi_master_irq_mask(struct irq_data *data) +{ + unsigned int bit = 31 - (data->hwirq % FSI_IRQ_COUNT); + + if (bit >= FSI_SI1S_MBOX_BIT) { + struct fsi_master *master = irq_data_get_irq_chip_data(data); + int link = data->hwirq / FSI_IRQ_COUNT; + __be32 mask = cpu_to_be32(BIT(bit)); + + trace_fsi_master_irq_mask(master, link, data->hwirq % FSI_IRQ_COUNT, true); + fsi_master_write(master, link, 0, FSI_SLAVE_BASE + FSI_SCI1M, &mask, sizeof(mask)); + } +} + +static void fsi_master_irq_unmask(struct irq_data *data) +{ + unsigned int bit = 31 - (data->hwirq % FSI_IRQ_COUNT); + + if (bit >= FSI_SI1S_MBOX_BIT) { + struct fsi_master *master = irq_data_get_irq_chip_data(data); + int link = data->hwirq / FSI_IRQ_COUNT; + __be32 mask = cpu_to_be32(BIT(bit)); + + trace_fsi_master_irq_mask(master, link, data->hwirq % FSI_IRQ_COUNT, false); + fsi_master_write(master, link, 0, FSI_SLAVE_BASE + FSI_SSI1M, &mask, sizeof(mask)); + } +} + int fsi_master_register(struct fsi_master *master) { int rc; @@ -1491,6 +1647,9 @@ int fsi_master_register(struct fsi_master *master) if (master->flags & FSI_MASTER_FLAG_SWCLOCK) master->clock_frequency = 100000000; // POWER reference clock + master->irq_chip.name = dev_name(&master->dev); + master->irq_chip.irq_mask = fsi_master_irq_mask; + master->irq_chip.irq_unmask = fsi_master_irq_unmask; master->dev.class = &fsi_master_class; mutex_lock(&master->scan_lock); diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 8ea2f69ec4922..2104902091e05 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -10,6 +10,7 @@ #define DRIVERS_FSI_MASTER_H #include <linux/device.h> +#include <linux/irq.h> #include <linux/mutex.h> /* @@ -112,6 +113,7 @@ /* Misc */ #define FSI_CRC_SIZE 4 #define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ +#define FSI_IRQ_COUNT 9 /* fsi-master definition and flags */ #define FSI_MASTER_FLAG_SWCLOCK 0x1 @@ -137,6 +139,7 @@ struct fsi_master { int n_links; int flags; struct mutex scan_lock; + struct irq_chip irq_chip; int (*read)(struct fsi_master *, int link, uint8_t id, uint32_t addr, void *val, size_t size); int (*write)(struct fsi_master *, int link, uint8_t id, @@ -147,6 +150,7 @@ struct fsi_master { bool enable); int (*link_config)(struct fsi_master *, int link, u8 t_send_delay, u8 t_echo_delay); + u8 remote_interrupt_status; }; #define to_fsi_master(d) container_of(d, struct fsi_master, dev) @@ -176,4 +180,9 @@ extern void fsi_master_unregister(struct fsi_master *master); extern int fsi_master_rescan(struct fsi_master *master); +struct irq_domain; + +extern int fsi_master_irq(struct fsi_master *master, struct irq_domain *irq_domain, + unsigned int link); + #endif /* DRIVERS_FSI_MASTER_H */ diff --git a/include/linux/fsi.h b/include/linux/fsi.h index e0309bf0ae072..c249a95b7ff84 100644 --- a/include/linux/fsi.h +++ b/include/linux/fsi.h @@ -8,6 +8,7 @@ #define LINUX_FSI_H #include <linux/device.h> +#include <linux/interrupt.h> struct fsi_device { struct device dev; @@ -25,6 +26,7 @@ extern int fsi_device_write(struct fsi_device *dev, uint32_t addr, const void *val, size_t size); extern int fsi_device_peek(struct fsi_device *dev, void *val); extern unsigned long fsi_device_local_bus_frequency(struct fsi_device *dev); +extern int fsi_device_request_irq(struct fsi_device *dev, irq_handler_t handler, void *data); struct fsi_device_id { u8 engine_type; diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h index da977d59e163e..0e4d717ee0adb 100644 --- a/include/trace/events/fsi.h +++ b/include/trace/events/fsi.h @@ -8,6 +8,47 @@ #include <linux/tracepoint.h> +TRACE_EVENT(fsi_master_irq, + TP_PROTO(const struct fsi_master *master, unsigned int link, uint32_t si1s, + uint32_t srsis0, uint32_t srsis4), + TP_ARGS(master, link, si1s, srsis0, srsis4), + TP_STRUCT__entry( + __field(int, master_idx) + __field(unsigned int, link) + __field(uint32_t, si1s) + __field(uint32_t, srsis0) + __field(uint32_t, srsis4) + ), + TP_fast_assign( + __entry->master_idx = master->idx; + __entry->link = link; + __entry->si1s = si1s; + __entry->srsis0 = srsis0; + __entry->srsis4 = srsis4; + ), + TP_printk("fsi%d:%02d si1s:%08x srsis0:%08x srsis4:%08x", __entry->master_idx, + __entry->link, __entry->si1s, __entry->srsis0, __entry->srsis4) +); + +TRACE_EVENT(fsi_master_irq_mask, + TP_PROTO(const struct fsi_master *master, unsigned int link, unsigned int bit, bool mask), + TP_ARGS(master, link, bit, mask), + TP_STRUCT__entry( + __field(int, master_idx) + __field(unsigned int, link) + __field(unsigned int, bit) + __field(bool, mask) + ), + TP_fast_assign( + __entry->master_idx = master->idx; + __entry->link = link; + __entry->bit = bit; + __entry->mask = mask; + ), + TP_printk("fsi%d:%02d %s bit:%d", __entry->master_idx, __entry->link, + __entry->mask ? "mask" : "unmask", __entry->bit) +); + TRACE_EVENT(fsi_master_xfer, TP_PROTO(int master_idx, int link, int id, uint32_t addr, size_t size, const void *data, bool read),
Add an irq chip to the FSI master structure to control slave interrupt masking. Add a function to request an IRQ from the FSI device. The FSI master IRQ mapping is based on the FSI device engine type and slave link. Signed-off-by: Eddie James <eajames@linux.ibm.com> --- Changes since v2: - Remove slave interrupt handler since it's not used yet drivers/fsi/fsi-core.c | 159 +++++++++++++++++++++++++++++++++++++ drivers/fsi/fsi-master.h | 9 +++ include/linux/fsi.h | 2 + include/trace/events/fsi.h | 60 ++++++++++++++ 4 files changed, 230 insertions(+)