drivers: fsi: Add SBE client device driver
RFC 1/1 drivers: fsi: Add SBE client device driver
From: "Edward A. James" <[email protected]>
This is a driver stub for the SBE FSI client driver. Just looking for feedback for driver structuring. SBE doesn't use traditional reads/writes but instead submits requests and receives replies from the SBE fifo (as far as I understand it - need to check with Karlo).
--- drivers/fsi/Kconfig | 6 ++ drivers/fsi/Makefile | 1 + drivers/fsi/fsi-sbe.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 drivers/fsi/fsi-sbe.c
drivers/fsi/Kconfig +6 -0
@@ -36,6 +36,12 @@ config FSI_MBX ---help--- This option enables an FSI based Mailbox device driver. +config FSI_SBE + tristate "SBE FSI client device driver" + depends on FSI + ---help--- + This option enables an FSI based SBE device driver. + endif endmenu
drivers/fsi/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_FSI_MASTER_FAKE) += fsi-master-fake.o obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o obj-$(CONFIG_FSI_SCOM) += fsi-scom.o obj-$(CONFIG_FSI_MBX) += fsi-mbx.o +obj-$(CONFIG_FSI_SBE) += fsi-sbe.o
drivers/fsi/fsi-sbe.c new file +161 -0
161 lines not on this page · raw message
Signature · 1 line
1.9.1
Hi Eddie,
Quoted 6 lines · On Fri, Dec 2, 2016 at 8:52 AM, <[email protected]> wrote:
From: "Edward A. James" <[email protected]>
This is a driver stub for the SBE FSI client driver. Just looking for feedback for driver structuring. SBE doesn't use traditional reads/writes but instead submits requests and receives replies from the SBE fifo (as far as I understand it - need to check with Karlo).
I assume this builds on top of Chris' latest OpenFSI series?
Does this only work for the P9 SBE, or is it relevant for P8?
Quoted 44 lines
Signed-off-by Edward A. James <[email protected]>--- drivers/fsi/Kconfig | 6 ++ drivers/fsi/Makefile | 1 + drivers/fsi/fsi-sbe.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 drivers/fsi/fsi-sbe.cdrivers/fsi/Kconfig +6
-0@@ -36,6 +36,12 @@ config FSI_MBX ---help--- This option enables an FSI based Mailbox device driver. +config FSI_SBE + tristate "SBE FSI client device driver" + depends on FSI + ---help--- + This option enables an FSI based SBE device driver. + endif endmenudrivers/fsi/Makefile +1
-0@@ -4,3 +4,4 @@ obj-$(CONFIG_FSI_MASTER_FAKE) += fsi-master-fake.o obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o obj-$(CONFIG_FSI_SCOM) += fsi-scom.o obj-$(CONFIG_FSI_MBX) += fsi-mbx.o +obj-$(CONFIG_FSI_SBE) += fsi-sbe.odrivers/fsi/fsi-sbe.c new file +3
-0@@ -0,0 +1,161 @@ +/* +* SBE FSI Client device driver +*
drivers/fsi/fsi-sbe.c line 13
Quoted 10 lines
drivers/fsi/fsi-sbe.c new file +10
-0+* Copyright (C) IBM Corporation 2016 +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERGCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details.
Take a look at our other headers of the text we chose to use.
Quoted 7 lines
drivers/fsi/fsi-sbe.c new file +7
-0+*/ + +#include <linux/fsi.h> +#include <linux/module.h> +#include <linux/cdev.h> +#include <linux/delay.h> +#include <linux/fs.h>
drivers/fsi/fsi-sbe.c line 30
Quoted 10 lines
drivers/fsi/fsi-sbe.c new file +10
-0+#include <linux/uaccess.h> +#include <linux/slab.h> +#include <linux/miscdevice.h> +#include <linux/list.h> + +#define FSI_ENGID_P9SBE 0x22 + +#define SBE_IOCTL_SUBMIT 0x01 +#define SBE_IOCTL_REQUEST_RESET 0x02 +#define SBE_IOCTL_RESET 0x03
This is not where we declare ioctl information. Take a look at the impi-bt patch for an example.
http://git.kernel.org/torvalds/c/54f9c4d0778b3f9ab791b1b7eb1a5d2809f02f50
Quoted 8 lines
drivers/fsi/fsi-sbe.c new file +8
-0+ +struct sbe_device { +struct list_head link; +struct fsi_device *fsi_dev; +struct miscdevice mdev; +char name[32 ]; +}; +
drivers/fsi/fsi-sbe.c line 48
Quoted 10 lines
drivers/fsi/fsi-sbe.c new file +10
-0+#define to_sbe_dev (x) container_of((x), struct sbe_device, mdev) + +static struct list_head sbe_devices; +static atomic_t sbe_idx =ATOMIC_INIT (0 ); + +static ssize_t sbe_read (struct file *filep,char __user *buf,size_t len, +loff_t *offset) +{ +return len; +}
This is incorrect; the read call will return the users *buf uninitialised (or with whatever was already in it).
Please omit the callback if it's not doing anything.
drivers/fsi/fsi-sbe.c line 54
Quoted 6 lines
drivers/fsi/fsi-sbe.c new file +6
-0+ +static ssize_t sbe_write (struct file *filep,const char __user *buf, +size_t len,loff_t *offset) +{ +return len; +}
Same here.
Quoted 10 lines
drivers/fsi/fsi-sbe.c new file +10
-0+ +static int sbe_submit (struct sbe_device *sbe,unsigned long data) +{ +int rc =0 ; + +return rc; +} + +static int sbe_reset (struct sbe_device *sbe) +{
drivers/fsi/fsi-sbe.c line 74
Quoted 10 lines
drivers/fsi/fsi-sbe.c new file +10
-0+int rc =0 ; + +return rc; +} + + +static int sbe_request_reset (struct sbe_device *sbe) +{ +return 0 ; +}
I assume this is the information you're waiting on?
drivers/fsi/fsi-sbe.c line 85
Quoted 11 lines
drivers/fsi/fsi-sbe.c new file +11
-0+ +static long sbe_ioctl (struct file *filep,uint32_t cmd,unsigned long data) +{ +struct miscdevice *mdev = (struct miscdevice *)filep->private_data; +struct sbe_device *sbe =to_sbe_dev (mdev); +struct device *dev = &sbe->fsi_dev->dev; +ssize_t rc; + +switch (cmd) { +case SBE_IOCTL_SUBMIT : + rc =sbe_submit (sbe, data);
Can we not read back from the SBE?
I suggest you use the normal write api for doing writes into the SBE.
The ioctls are useful for resetting.
Quoted 79 lines
drivers/fsi/fsi-sbe.c new file +76
-1+break ; +case SBE_IOCTL_REQUEST_RESET : + rc =sbe_request_reset (sbe); +break ; +case SBE_IOCTL_RESET : + rc =sbe_reset (sbe); +break ; +default : +dev_info (dev,"Ivalid ioctl command:%d\n" , cmd); +return -EINVAL ; + } + +return rc; +}; + +static const struct file_operations sbe_fops = { + .owner =THIS_MODULE , + .llseek = no_seek_end_llseek, + .read = sbe_read, + .write = sbe_write, + .compat_ioctl = sbe_ioctl +}; + +static int sbe_probe (struct device *dev) +{ +struct fsi_device *fsi_dev =to_fsi_dev (dev); +struct sbe_device *sbe; + + sbe =devm_kzalloc (dev,sizeof (struct sbe_device ),GFP_KERNEL ); +if (!sbe) +return -ENOMEM ; + +snprintf (sbe->name,32 ,"sbe%d" ,atomic_inc_return (&sbe_idx)); + sbe->fsi_dev = fsi_dev; + + sbe->mdev.minor =MISC_DYNAMIC_MINOR ; + sbe->mdev.fops = &sbe_fops; + sbe->mdev.name = sbe->name; + sbe->mdev.parent = dev; + +list_add (&sbe->link, &sbe_devices); + +return misc_register (&sbe->mdev); +} + +static struct fsi_device_id sbe_ids[] = { + { + .engine_type =FSI_ENGID_P9SBE , + .version =FSI_VERSION_ANY , + }, + {0 } +}; + +static struct fsi_driver sbe_drv = { + .id_table = sbe_ids, + .drv = { + .name ="sbe" , + .bus = &fsi_bus_type, + .probe = sbe_probe, + } +}; + +static int sbe_init (void ) +{ +INIT_LIST_HEAD (&sbe_devices); +return fsi_driver_register (&sbe_drv); +} + +static void sbe_exit (void ) +{ +fsi_driver_unregister (&sbe_drv); +} + +module_init (sbe_init); +module_exit (sbe_exit); +MODULE_LICENSE ("GPL" ); --1.9.1