Message ID | 20231128235700.599584-2-ninad@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Introduce model for IBM's FSI | expand |
On 11/29/23 00:56, Ninad Palsule wrote: > This is a part of patchset where IBM's Flexible Service Interface is > introduced. > > The LBUS is modelled to maintain mapped memory for the devices. The > memory is mapped after CFAM config, peek table and FSI slave registers. > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au> > Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> > [ clg: - removed lbus_add_device() bc unused > - removed lbus_create_device() bc used only once > - removed "address" property > - updated meson.build to build fsi dir > - included an empty hw/fsi/trace-events ] > Signed-off-by: Cédric Le Goater <clg@kaod.org> > --- > meson.build | 1 + > hw/fsi/trace.h | 1 + > include/hw/fsi/lbus.h | 40 +++++++++++++++++++++++++++++++++ > hw/fsi/lbus.c | 51 +++++++++++++++++++++++++++++++++++++++++++ > hw/Kconfig | 1 + > hw/fsi/Kconfig | 2 ++ > hw/fsi/meson.build | 1 + > hw/fsi/trace-events | 1 + > hw/meson.build | 1 + > 9 files changed, 99 insertions(+) > create mode 100644 hw/fsi/trace.h > create mode 100644 include/hw/fsi/lbus.h > create mode 100644 hw/fsi/lbus.c > create mode 100644 hw/fsi/Kconfig > create mode 100644 hw/fsi/meson.build > create mode 100644 hw/fsi/trace-events > > diff --git a/meson.build b/meson.build > index ec01f8b138..b6556efd51 100644 > --- a/meson.build > +++ b/meson.build > @@ -3298,6 +3298,7 @@ if have_system > 'hw/char', > 'hw/display', > 'hw/dma', > + 'hw/fsi', > 'hw/hyperv', > 'hw/i2c', > 'hw/i386', > diff --git a/hw/fsi/trace.h b/hw/fsi/trace.h > new file mode 100644 > index 0000000000..ee67c7fb04 > --- /dev/null > +++ b/hw/fsi/trace.h > @@ -0,0 +1 @@ > +#include "trace/trace-hw_fsi.h" > diff --git a/include/hw/fsi/lbus.h b/include/hw/fsi/lbus.h > new file mode 100644 > index 0000000000..a58e33d061 > --- /dev/null > +++ b/include/hw/fsi/lbus.h > @@ -0,0 +1,40 @@ > +/* > + * SPDX-License-Identifier: GPL-2.0-or-later > + * Copyright (C) 2023 IBM Corp. > + * > + * IBM Local bus and connected device structures. > + */ > +#ifndef FSI_LBUS_H > +#define FSI_LBUS_H > + > +#include "exec/memory.h" > +#include "hw/qdev-core.h" > + > +#define TYPE_FSI_LBUS_DEVICE "fsi.lbus.device" > +OBJECT_DECLARE_TYPE(FSILBusDevice, FSILBusDeviceClass, FSI_LBUS_DEVICE) > + > +#define FSI_LBUS_MEM_REGION_SIZE (2 * 1024 * 1024) > +#define FSI_LBUSDEV_IOMEM_START 0xc00 /* 3K used by CFAM config etc */ I don't think sizing the local bus MMIO region exactly to the size of the CFAM MMIO region is necessary. The upper LBUS/CFAM addresses might not even be backed by device registers. I would simplify with : #define FSI_LBUS_MEM_REGION_SIZE (1 * MiB) and forget about the offset. Thanks, C. > + > +typedef struct FSILBusDevice { > + DeviceState parent; > + > + MemoryRegion iomem; > +} FSILBusDevice; > + > +typedef struct FSILBusDeviceClass { > + DeviceClass parent; > + > + uint32_t config; > +} FSILBusDeviceClass; > + > +#define TYPE_FSI_LBUS "fsi.lbus" > +OBJECT_DECLARE_SIMPLE_TYPE(FSILBus, FSI_LBUS) > + > +typedef struct FSILBus { > + BusState bus; > + > + MemoryRegion mr; > +} FSILBus; > + > +#endif /* FSI_LBUS_H */ > diff --git a/hw/fsi/lbus.c b/hw/fsi/lbus.c > new file mode 100644 > index 0000000000..84c46a00d7 > --- /dev/null > +++ b/hw/fsi/lbus.c > @@ -0,0 +1,51 @@ > +/* > + * SPDX-License-Identifier: GPL-2.0-or-later > + * Copyright (C) 2023 IBM Corp. > + * > + * IBM Local bus where FSI slaves are connected > + */ > + > +#include "qemu/osdep.h" > +#include "qapi/error.h" > +#include "hw/fsi/lbus.h" > + > +#include "hw/qdev-properties.h" > + > +static void lbus_init(Object *o) > +{ > + FSILBus *lbus = FSI_LBUS(o); > + > + memory_region_init(&lbus->mr, OBJECT(lbus), TYPE_FSI_LBUS, > + FSI_LBUS_MEM_REGION_SIZE - FSI_LBUSDEV_IOMEM_START); > +} > + > +static const TypeInfo lbus_info = { > + .name = TYPE_FSI_LBUS, > + .parent = TYPE_BUS, > + .instance_init = lbus_init, > + .instance_size = sizeof(FSILBus), > +}; > + > +static void lbus_device_class_init(ObjectClass *klass, void *data) > +{ > + DeviceClass *dc = DEVICE_CLASS(klass); > + > + dc->bus_type = TYPE_FSI_LBUS; > +} > + > +static const TypeInfo lbus_device_type_info = { > + .name = TYPE_FSI_LBUS_DEVICE, > + .parent = TYPE_DEVICE, > + .instance_size = sizeof(FSILBusDevice), > + .abstract = true, > + .class_init = lbus_device_class_init, > + .class_size = sizeof(FSILBusDeviceClass), > +}; > + > +static void lbus_register_types(void) > +{ > + type_register_static(&lbus_info); > + type_register_static(&lbus_device_type_info); > +} > + > +type_init(lbus_register_types); > diff --git a/hw/Kconfig b/hw/Kconfig > index 9ca7b38c31..2c00936c28 100644 > --- a/hw/Kconfig > +++ b/hw/Kconfig > @@ -9,6 +9,7 @@ source core/Kconfig > source cxl/Kconfig > source display/Kconfig > source dma/Kconfig > +source fsi/Kconfig > source gpio/Kconfig > source hyperv/Kconfig > source i2c/Kconfig > diff --git a/hw/fsi/Kconfig b/hw/fsi/Kconfig > new file mode 100644 > index 0000000000..e650c660f0 > --- /dev/null > +++ b/hw/fsi/Kconfig > @@ -0,0 +1,2 @@ > +config FSI_LBUS > + bool > diff --git a/hw/fsi/meson.build b/hw/fsi/meson.build > new file mode 100644 > index 0000000000..4074d3a7d2 > --- /dev/null > +++ b/hw/fsi/meson.build > @@ -0,0 +1 @@ > +system_ss.add(when: 'CONFIG_FSI_LBUS', if_true: files('lbus.c')) > diff --git a/hw/fsi/trace-events b/hw/fsi/trace-events > new file mode 100644 > index 0000000000..8b13789179 > --- /dev/null > +++ b/hw/fsi/trace-events > @@ -0,0 +1 @@ > + > diff --git a/hw/meson.build b/hw/meson.build > index f01fac4617..463d702683 100644 > --- a/hw/meson.build > +++ b/hw/meson.build > @@ -44,6 +44,7 @@ subdir('virtio') > subdir('watchdog') > subdir('xen') > subdir('xenpv') > +subdir('fsi') > > subdir('alpha') > subdir('arm')
Hello Cedric, On 12/12/23 08:46, Cédric Le Goater wrote: > On 11/29/23 00:56, Ninad Palsule wrote: >> This is a part of patchset where IBM's Flexible Service Interface is >> introduced. >> >> The LBUS is modelled to maintain mapped memory for the devices. The >> memory is mapped after CFAM config, peek table and FSI slave registers. >> >> Signed-off-by: Andrew Jeffery <andrew@aj.id.au> >> Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> >> [ clg: - removed lbus_add_device() bc unused >> - removed lbus_create_device() bc used only once >> - removed "address" property >> - updated meson.build to build fsi dir >> - included an empty hw/fsi/trace-events ] >> Signed-off-by: Cédric Le Goater <clg@kaod.org> >> --- >> meson.build | 1 + >> hw/fsi/trace.h | 1 + >> include/hw/fsi/lbus.h | 40 +++++++++++++++++++++++++++++++++ >> hw/fsi/lbus.c | 51 +++++++++++++++++++++++++++++++++++++++++++ >> hw/Kconfig | 1 + >> hw/fsi/Kconfig | 2 ++ >> hw/fsi/meson.build | 1 + >> hw/fsi/trace-events | 1 + >> hw/meson.build | 1 + >> 9 files changed, 99 insertions(+) >> create mode 100644 hw/fsi/trace.h >> create mode 100644 include/hw/fsi/lbus.h >> create mode 100644 hw/fsi/lbus.c >> create mode 100644 hw/fsi/Kconfig >> create mode 100644 hw/fsi/meson.build >> create mode 100644 hw/fsi/trace-events >> >> diff --git a/meson.build b/meson.build >> index ec01f8b138..b6556efd51 100644 >> --- a/meson.build >> +++ b/meson.build >> @@ -3298,6 +3298,7 @@ if have_system >> 'hw/char', >> 'hw/display', >> 'hw/dma', >> + 'hw/fsi', >> 'hw/hyperv', >> 'hw/i2c', >> 'hw/i386', >> diff --git a/hw/fsi/trace.h b/hw/fsi/trace.h >> new file mode 100644 >> index 0000000000..ee67c7fb04 >> --- /dev/null >> +++ b/hw/fsi/trace.h >> @@ -0,0 +1 @@ >> +#include "trace/trace-hw_fsi.h" >> diff --git a/include/hw/fsi/lbus.h b/include/hw/fsi/lbus.h >> new file mode 100644 >> index 0000000000..a58e33d061 >> --- /dev/null >> +++ b/include/hw/fsi/lbus.h >> @@ -0,0 +1,40 @@ >> +/* >> + * SPDX-License-Identifier: GPL-2.0-or-later >> + * Copyright (C) 2023 IBM Corp. >> + * >> + * IBM Local bus and connected device structures. >> + */ >> +#ifndef FSI_LBUS_H >> +#define FSI_LBUS_H >> + >> +#include "exec/memory.h" >> +#include "hw/qdev-core.h" >> + >> +#define TYPE_FSI_LBUS_DEVICE "fsi.lbus.device" >> +OBJECT_DECLARE_TYPE(FSILBusDevice, FSILBusDeviceClass, FSI_LBUS_DEVICE) >> + >> +#define FSI_LBUS_MEM_REGION_SIZE (2 * 1024 * 1024) >> +#define FSI_LBUSDEV_IOMEM_START 0xc00 /* 3K used by CFAM config >> etc */ > > I don't think sizing the local bus MMIO region exactly to the size of > the CFAM MMIO region is necessary. The upper LBUS/CFAM addresses might > not even be backed by device registers. > > I would simplify with : > > #define FSI_LBUS_MEM_REGION_SIZE (1 * MiB) > > and forget about the offset. > ok, I made it as 1MB. Thanks for the review. Regards, Ninad
diff --git a/meson.build b/meson.build index ec01f8b138..b6556efd51 100644 --- a/meson.build +++ b/meson.build @@ -3298,6 +3298,7 @@ if have_system 'hw/char', 'hw/display', 'hw/dma', + 'hw/fsi', 'hw/hyperv', 'hw/i2c', 'hw/i386', diff --git a/hw/fsi/trace.h b/hw/fsi/trace.h new file mode 100644 index 0000000000..ee67c7fb04 --- /dev/null +++ b/hw/fsi/trace.h @@ -0,0 +1 @@ +#include "trace/trace-hw_fsi.h" diff --git a/include/hw/fsi/lbus.h b/include/hw/fsi/lbus.h new file mode 100644 index 0000000000..a58e33d061 --- /dev/null +++ b/include/hw/fsi/lbus.h @@ -0,0 +1,40 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2023 IBM Corp. + * + * IBM Local bus and connected device structures. + */ +#ifndef FSI_LBUS_H +#define FSI_LBUS_H + +#include "exec/memory.h" +#include "hw/qdev-core.h" + +#define TYPE_FSI_LBUS_DEVICE "fsi.lbus.device" +OBJECT_DECLARE_TYPE(FSILBusDevice, FSILBusDeviceClass, FSI_LBUS_DEVICE) + +#define FSI_LBUS_MEM_REGION_SIZE (2 * 1024 * 1024) +#define FSI_LBUSDEV_IOMEM_START 0xc00 /* 3K used by CFAM config etc */ + +typedef struct FSILBusDevice { + DeviceState parent; + + MemoryRegion iomem; +} FSILBusDevice; + +typedef struct FSILBusDeviceClass { + DeviceClass parent; + + uint32_t config; +} FSILBusDeviceClass; + +#define TYPE_FSI_LBUS "fsi.lbus" +OBJECT_DECLARE_SIMPLE_TYPE(FSILBus, FSI_LBUS) + +typedef struct FSILBus { + BusState bus; + + MemoryRegion mr; +} FSILBus; + +#endif /* FSI_LBUS_H */ diff --git a/hw/fsi/lbus.c b/hw/fsi/lbus.c new file mode 100644 index 0000000000..84c46a00d7 --- /dev/null +++ b/hw/fsi/lbus.c @@ -0,0 +1,51 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2023 IBM Corp. + * + * IBM Local bus where FSI slaves are connected + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/fsi/lbus.h" + +#include "hw/qdev-properties.h" + +static void lbus_init(Object *o) +{ + FSILBus *lbus = FSI_LBUS(o); + + memory_region_init(&lbus->mr, OBJECT(lbus), TYPE_FSI_LBUS, + FSI_LBUS_MEM_REGION_SIZE - FSI_LBUSDEV_IOMEM_START); +} + +static const TypeInfo lbus_info = { + .name = TYPE_FSI_LBUS, + .parent = TYPE_BUS, + .instance_init = lbus_init, + .instance_size = sizeof(FSILBus), +}; + +static void lbus_device_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->bus_type = TYPE_FSI_LBUS; +} + +static const TypeInfo lbus_device_type_info = { + .name = TYPE_FSI_LBUS_DEVICE, + .parent = TYPE_DEVICE, + .instance_size = sizeof(FSILBusDevice), + .abstract = true, + .class_init = lbus_device_class_init, + .class_size = sizeof(FSILBusDeviceClass), +}; + +static void lbus_register_types(void) +{ + type_register_static(&lbus_info); + type_register_static(&lbus_device_type_info); +} + +type_init(lbus_register_types); diff --git a/hw/Kconfig b/hw/Kconfig index 9ca7b38c31..2c00936c28 100644 --- a/hw/Kconfig +++ b/hw/Kconfig @@ -9,6 +9,7 @@ source core/Kconfig source cxl/Kconfig source display/Kconfig source dma/Kconfig +source fsi/Kconfig source gpio/Kconfig source hyperv/Kconfig source i2c/Kconfig diff --git a/hw/fsi/Kconfig b/hw/fsi/Kconfig new file mode 100644 index 0000000000..e650c660f0 --- /dev/null +++ b/hw/fsi/Kconfig @@ -0,0 +1,2 @@ +config FSI_LBUS + bool diff --git a/hw/fsi/meson.build b/hw/fsi/meson.build new file mode 100644 index 0000000000..4074d3a7d2 --- /dev/null +++ b/hw/fsi/meson.build @@ -0,0 +1 @@ +system_ss.add(when: 'CONFIG_FSI_LBUS', if_true: files('lbus.c')) diff --git a/hw/fsi/trace-events b/hw/fsi/trace-events new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/hw/fsi/trace-events @@ -0,0 +1 @@ + diff --git a/hw/meson.build b/hw/meson.build index f01fac4617..463d702683 100644 --- a/hw/meson.build +++ b/hw/meson.build @@ -44,6 +44,7 @@ subdir('virtio') subdir('watchdog') subdir('xen') subdir('xenpv') +subdir('fsi') subdir('alpha') subdir('arm')