Skip to contentSkip to conversation

misc: Add Renesas Synchronization Management Unit (SMU) support

PATCH In review [email protected] 3 participants 4 messages Mar 17, 2021 – Mar 18, 2021 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: Add Renesas Synchronization Management Unit (SMU) support

From: Min Li <[email protected]>

This driver is developed for the IDT ClockMatrix(TM) and 82P33xxx families of timing and synchronization devices.It will be used by Renesas PTP Clock Manager for Linux (pcm4l) software to provide support to GNSS assisted partial timing support (APTS) and other networking timing functions.

Current version provides kernel API's to support the following functions -set combomode to enable SYNCE clock support
-read dpll's state to determine if the dpll is locked to the GNSS channel -read dpll's ffo (fractional frequency offset) in ppqt

---
 drivers/misc/Kconfig      |  10 ++
 drivers/misc/Makefile     |   2 +
 drivers/misc/rsmu_cdev.c  | 336 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/rsmu_cdev.h  |  72 ++++++++++
 drivers/misc/rsmu_cm.c    | 166 +++++++++++++++++++++++
 drivers/misc/rsmu_sabre.c | 128 ++++++++++++++++++
 include/uapi/linux/rsmu.h |  61 +++++++++
 7 files changed, 775 insertions(+)
 create mode 100644 drivers/misc/rsmu_cdev.c
 create mode 100644 drivers/misc/rsmu_cdev.h
 create mode 100644 drivers/misc/rsmu_cm.c
 create mode 100644 drivers/misc/rsmu_sabre.c
 create mode 100644 include/uapi/linux/rsmu.h
drivers/misc/Kconfig +10 -0
index e1b1ba5..6efe2f5 100644
@@ -456,6 +456,16 @@ config PVPANIC
 	  a paravirtualized device provided by QEMU; it lets a virtual machine
 	  (guest) communicate panic events to the host.
 
+config RSMU
+	tristate "Renesas Synchronization Management Unit (SMU)"
+	depends on MFD_RSMU_I2C || MFD_RSMU_SPI
+	help
+	  This option enables support for the IDT ClockMatrix(TM) and 82P33xxx
+	  families of timing and synchronization devices. It will be used by
+	  Renesas PTP Clock Manager for Linux (pcm4l) software to provide support
+	  for GNSS assisted partial timing support (APTS) and other networking
+	  timing functions.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +2 -0
index c7bd01a..cf07fd7 100644
@@ -57,3 +57,5 @@ obj-$(CONFIG_PVPANIC)   	+= pvpanic.o
 obj-$(CONFIG_HABANA_AI)		+= habanalabs/
 obj-$(CONFIG_UACCE)		+= uacce/
 obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
+rsmu-objs			:= rsmu_cdev.o rsmu_cm.o rsmu_sabre.o
+obj-$(CONFIG_RSMU)		+= rsmu.o
drivers/misc/rsmu_cdev.c new file +336 -0

336 lines not on this page · raw message

drivers/misc/rsmu_cdev.h new file +72 -0

72 lines not on this page · raw message

drivers/misc/rsmu_cm.c new file +166 -0

166 lines not on this page · raw message

drivers/misc/rsmu_sabre.c new file +128 -0

128 lines not on this page · raw message

include/uapi/linux/rsmu.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/master]

url:    https://github.com/0day-ci/linux/commits/min-li-xe-renesas-com/misc-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210318-052232
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git b3a9e3b9622ae10064826dccb4f7a52bd88c7407
config: x86_64-randconfig-r005-20210317 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/f1c28c63e2514eac89cce46df118039da7c21e47
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review min-li-xe-renesas-com/misc-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210318-052232
        git checkout f1c28c63e2514eac89cce46df118039da7c21e47
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from <command-line>:32:

>> ./usr/include/linux/rsmu.h:14:2: error: unknown type name '__u8'
      14 |  __u8 dpll;
         |  ^~~~
   ./usr/include/linux/rsmu.h:15:2: error: unknown type name '__u8'
      15 |  __u8 mode;
         |  ^~~~
   ./usr/include/linux/rsmu.h:20:2: error: unknown type name '__u8'
      20 |  __u8 dpll;
         |  ^~~~
   ./usr/include/linux/rsmu.h:21:2: error: unknown type name '__u8'
      21 |  __u8 state;
         |  ^~~~
   ./usr/include/linux/rsmu.h:26:2: error: unknown type name '__u8'
      26 |  __u8 dpll;
         |  ^~~~
>> ./usr/include/linux/rsmu.h:27:2: error: unknown type name '__s64'
      27 |  __s64 ffo;
         |  ^~~~~

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
In reply to [email protected]
Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/master]

url:    https://github.com/0day-ci/linux/commits/min-li-xe-renesas-com/misc-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210318-052232
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git b3a9e3b9622ae10064826dccb4f7a52bd88c7407
config: x86_64-randconfig-a013-20210317 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 6db3ab2903f42712f44000afb5aa467efbd25f35)

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
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/f1c28c63e2514eac89cce46df118039da7c21e47
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review min-li-xe-renesas-com/misc-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210318-052232 git checkout f1c28c63e2514eac89cce46df118039da7c21e47
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from <built-in>:1:

>> ./usr/include/linux/rsmu.h:14:2: error: unknown type name '__u8'
           __u8 dpll;
           ^
   ./usr/include/linux/rsmu.h:15:2: error: unknown type name '__u8'
           __u8 mode;
           ^
   ./usr/include/linux/rsmu.h:20:2: error: unknown type name '__u8'
           __u8 dpll;
           ^
   ./usr/include/linux/rsmu.h:21:2: error: unknown type name '__u8'
           __u8 state;
           ^
   ./usr/include/linux/rsmu.h:26:2: error: unknown type name '__u8'
           __u8 dpll;
           ^
>> ./usr/include/linux/rsmu.h:27:2: error: unknown type name '__s64'
           __s64 ffo;
           ^

6 errors generated.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#3 lore raw
In reply to [email protected]

drivers/misc/rsmu_cdev.c line 115

Quoted 8 lines · On Wed, Mar 17, 2021 at 05:14:34PM -0400, [email protected] wrote:
drivers/misc/rsmu_cdev.c new file +8 -0
+static int
+rsmu_open(struct inode *iptr, struct file *fptr)
+{
+	struct rsmu_cdev *rsmu;
+
+	rsmu = container_of(iptr->i_cdev, struct rsmu_cdev, rsmu_cdev);
+	if (!rsmu)
+		return -EAGAIN;

This check will never happen, so why are you making it?

And what does -EAGIN mean in this case?

drivers/misc/rsmu_cdev.c line 128

Quoted 13 lines
drivers/misc/rsmu_cdev.c new file +13 -0
+
+	fptr->private_data = rsmu;
+	return 0;
+}
+
+static int
+rsmu_release(struct inode *iptr, struct file *fptr)
+{
+	struct rsmu_cdev *rsmu;
+
+	rsmu = container_of(iptr->i_cdev, struct rsmu_cdev, rsmu_cdev);
+	if (!rsmu)
+		return -EAGAIN;

Same here, this is impossible to ever have happen. Please look up how container_of() works.

drivers/misc/rsmu_cdev.c line 141

Quoted 13 lines
drivers/misc/rsmu_cdev.c new file +13 -0
+
+	return 0;
+}
+
+static long
+rsmu_ioctl(struct file *fptr, unsigned int cmd, unsigned long data)
+{
+	struct rsmu_cdev *rsmu = fptr->private_data;
+	void __user *arg = (void __user *)data;
+	int err = 0;
+
+	if (!rsmu)
+		return -EINVAL;

How can this happen?

Why all of these impossible checks?

And the build failures that the kernel test robot obviously need to be fixed as well...

thanks,

greg k-h