Re: [RFC PATCHv2 1/7] devfreq: event: Add new devfreq_event class to provide basic data for devfreq governor

2014-12-15 Thread Krzysztof Kozlowski
On pią, 2014-12-12 at 12:42 +0900, Chanwoo Choi wrote:
 Hi Krzysztof,
 
 I replied again this mail because I'll use the mutex for 
 set_event()/get_event()
 according to your comment. But, of_parse_phandle() seems that this function
 don't need the of_node_put() function.
 
 
 On 12/11/2014 11:13 AM, Chanwoo Choi wrote:
  Hi Krzysztof,
  
  First of all, thanks for your review.
  
  On 12/10/2014 06:37 PM, Krzysztof Kozlowski wrote:
  On wto, 2014-12-09 at 23:13 +0900, Chanwoo Choi wrote:
  This patch add new devfreq_event class for devfreq_event device which 
  provide
  raw data (e.g., memory bus utilization/GPU utilization). This raw data 
  from
  devfreq_event data would be used for the governor of devfreq subsystem.
  - devfreq_event device : Provide raw data for governor of existing 
  devfreq device
  - devfreq device   : Monitor device state and change 
  frequency/voltage of device
   using the raw data from devfreq_event device
 
  The devfreq subsystem support generic DVFS(Dynamic Voltage/Frequency 
  Scaling)
  for Non-CPU Devices. The devfreq device would dertermine current device 
  state
  using various governor (e.g., ondemand, performance, powersave). After 
  completed
  determination of system state, devfreq device would change the 
  frequency/voltage
  of devfreq device according to the result of governor.
 
  But, devfreq governor must need basic data which indicates current device 
  state.
  Existing devfreq subsystem only consider devfreq device which check 
  current system
  state and determine proper system state using basic data. There is no 
  subsystem
  for device providing basic data to devfreq device.
 
  The devfreq subsystem must need devfreq_event device(data-provider 
  device) for
  existing devfreq device. So, this patch add new devfreq_event class for
  devfreq_event device which read various basic data(e.g, memory bus 
  utilization,
  GPU utilization) and provide measured data to existing devfreq device 
  through
  standard APIs of devfreq_event class.
 
  The following description explains the feature of two kind of devfreq 
  class:
  - devfreq class (existing)
   : devfreq consumer device use raw data from devfreq_event device for
 determining proper current system state and change voltage/frequency
 dynamically using various governors.
 
  - devfreq_event class (new)
   : Provide measured raw data to devfreq device for governor
 
  Cc: MyungJoo Ham myungjoo@samsung.com
  Cc: Kyungmin Park kyungmin.p...@samsung.com
  Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
  ---
   drivers/devfreq/Kconfig |   2 +
   drivers/devfreq/Makefile|   5 +-
   drivers/devfreq/devfreq-event.c | 302 
  
   drivers/devfreq/event/Makefile  |   1 +
   include/linux/devfreq.h | 141 +++
   5 files changed, 450 insertions(+), 1 deletion(-)
   create mode 100644 drivers/devfreq/devfreq-event.c
   create mode 100644 drivers/devfreq/event/Makefile
 
  diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
  index faf4e70..4d15b62 100644
  --- a/drivers/devfreq/Kconfig
  +++ b/drivers/devfreq/Kconfig
  @@ -87,4 +87,6 @@ config ARM_EXYNOS5_BUS_DEVFREQ
  It reads PPMU counters of memory controllers and adjusts the
  operating frequencies and voltages with OPP support.
   
  +comment DEVFREQ Event Drivers
  +
   endif # PM_DEVFREQ
  diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
  index 16138c9..a1ffabe 100644
  --- a/drivers/devfreq/Makefile
  +++ b/drivers/devfreq/Makefile
  @@ -1,4 +1,4 @@
  -obj-$(CONFIG_PM_DEVFREQ) += devfreq.o
  +obj-$(CONFIG_PM_DEVFREQ) += devfreq.o devfreq-event.o
   obj-$(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)+= 
  governor_simpleondemand.o
   obj-$(CONFIG_DEVFREQ_GOV_PERFORMANCE)+= governor_performance.o
   obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE)  += governor_powersave.o
  @@ -7,3 +7,6 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE)   += 
  governor_userspace.o
   # DEVFREQ Drivers
   obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)+= exynos/
   obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)+= exynos/
  +
  +# DEVFREQ Event Drivers
  +obj-$(CONFIG_PM_DEVFREQ) += event/
  diff --git a/drivers/devfreq/devfreq-event.c 
  b/drivers/devfreq/devfreq-event.c
  new file mode 100644
  index 000..b47329f
  --- /dev/null
  +++ b/drivers/devfreq/devfreq-event.c
  @@ -0,0 +1,302 @@
  +/*
  + * devfreq-event: Generic DEVFREQ Event class driver
  + *
  + * Copyright (C) 2014 Samsung Electronics
  + * Chanwoo Choi cw00.c...@samsung.com
  + *
  + * 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 driver is based on drivers/devfreq/devfreq.c
  + */
  +
  +#include linux/kernel.h
  +#include linux/sched.h
  +#include linux/errno.h
  +#include linux/err.h
  

Re: [RFC PATCHv2 1/7] devfreq: event: Add new devfreq_event class to provide basic data for devfreq governor

2014-12-15 Thread Chanwoo Choi
Hi Krzysztof,

On 12/15/2014 07:30 PM, Krzysztof Kozlowski wrote:
 On pią, 2014-12-12 at 12:42 +0900, Chanwoo Choi wrote:
 Hi Krzysztof,

 I replied again this mail because I'll use the mutex for 
 set_event()/get_event()
 according to your comment. But, of_parse_phandle() seems that this function
 don't need the of_node_put() function.


 On 12/11/2014 11:13 AM, Chanwoo Choi wrote:
 Hi Krzysztof,

 First of all, thanks for your review.

 On 12/10/2014 06:37 PM, Krzysztof Kozlowski wrote:
 On wto, 2014-12-09 at 23:13 +0900, Chanwoo Choi wrote:
 This patch add new devfreq_event class for devfreq_event device which 
 provide
 raw data (e.g., memory bus utilization/GPU utilization). This raw data 
 from
 devfreq_event data would be used for the governor of devfreq subsystem.
 - devfreq_event device : Provide raw data for governor of existing 
 devfreq device
 - devfreq device   : Monitor device state and change 
 frequency/voltage of device
  using the raw data from devfreq_event device

 The devfreq subsystem support generic DVFS(Dynamic Voltage/Frequency 
 Scaling)
 for Non-CPU Devices. The devfreq device would dertermine current device 
 state
 using various governor (e.g., ondemand, performance, powersave). After 
 completed
 determination of system state, devfreq device would change the 
 frequency/voltage
 of devfreq device according to the result of governor.

 But, devfreq governor must need basic data which indicates current device 
 state.
 Existing devfreq subsystem only consider devfreq device which check 
 current system
 state and determine proper system state using basic data. There is no 
 subsystem
 for device providing basic data to devfreq device.

 The devfreq subsystem must need devfreq_event device(data-provider 
 device) for
 existing devfreq device. So, this patch add new devfreq_event class for
 devfreq_event device which read various basic data(e.g, memory bus 
 utilization,
 GPU utilization) and provide measured data to existing devfreq device 
 through
 standard APIs of devfreq_event class.

 The following description explains the feature of two kind of devfreq 
 class:
 - devfreq class (existing)
  : devfreq consumer device use raw data from devfreq_event device for
determining proper current system state and change voltage/frequency
dynamically using various governors.

 - devfreq_event class (new)
  : Provide measured raw data to devfreq device for governor

 Cc: MyungJoo Ham myungjoo@samsung.com
 Cc: Kyungmin Park kyungmin.p...@samsung.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 ---
  drivers/devfreq/Kconfig |   2 +
  drivers/devfreq/Makefile|   5 +-
  drivers/devfreq/devfreq-event.c | 302 
 
  drivers/devfreq/event/Makefile  |   1 +
  include/linux/devfreq.h | 141 +++
  5 files changed, 450 insertions(+), 1 deletion(-)
  create mode 100644 drivers/devfreq/devfreq-event.c
  create mode 100644 drivers/devfreq/event/Makefile

 diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
 index faf4e70..4d15b62 100644
 --- a/drivers/devfreq/Kconfig
 +++ b/drivers/devfreq/Kconfig
 @@ -87,4 +87,6 @@ config ARM_EXYNOS5_BUS_DEVFREQ
 It reads PPMU counters of memory controllers and adjusts the
 operating frequencies and voltages with OPP support.
  
 +comment DEVFREQ Event Drivers
 +
  endif # PM_DEVFREQ
 diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
 index 16138c9..a1ffabe 100644
 --- a/drivers/devfreq/Makefile
 +++ b/drivers/devfreq/Makefile
 @@ -1,4 +1,4 @@
 -obj-$(CONFIG_PM_DEVFREQ) += devfreq.o
 +obj-$(CONFIG_PM_DEVFREQ) += devfreq.o devfreq-event.o
  obj-$(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)+= 
 governor_simpleondemand.o
  obj-$(CONFIG_DEVFREQ_GOV_PERFORMANCE)+= governor_performance.o
  obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE)  += governor_powersave.o
 @@ -7,3 +7,6 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE)   += 
 governor_userspace.o
  # DEVFREQ Drivers
  obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)+= exynos/
  obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)+= exynos/
 +
 +# DEVFREQ Event Drivers
 +obj-$(CONFIG_PM_DEVFREQ) += event/
 diff --git a/drivers/devfreq/devfreq-event.c 
 b/drivers/devfreq/devfreq-event.c
 new file mode 100644
 index 000..b47329f
 --- /dev/null
 +++ b/drivers/devfreq/devfreq-event.c
 @@ -0,0 +1,302 @@
 +/*
 + * devfreq-event: Generic DEVFREQ Event class driver
 + *
 + * Copyright (C) 2014 Samsung Electronics
 + * Chanwoo Choi cw00.c...@samsung.com
 + *
 + * 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 driver is based on drivers/devfreq/devfreq.c
 + */
 +
 +#include linux/kernel.h
 +#include linux/sched.h
 +#include linux/errno.h
 +#include linux/err.h
 +#include linux/init.h
 +#include linux/module.h
 +#include 

Re: [RFC PATCHv2 1/7] devfreq: event: Add new devfreq_event class to provide basic data for devfreq governor

2014-12-11 Thread Chanwoo Choi
Hi Krzysztof,

I replied again this mail because I'll use the mutex for set_event()/get_event()
according to your comment. But, of_parse_phandle() seems that this function
don't need the of_node_put() function.


On 12/11/2014 11:13 AM, Chanwoo Choi wrote:
 Hi Krzysztof,
 
 First of all, thanks for your review.
 
 On 12/10/2014 06:37 PM, Krzysztof Kozlowski wrote:
 On wto, 2014-12-09 at 23:13 +0900, Chanwoo Choi wrote:
 This patch add new devfreq_event class for devfreq_event device which 
 provide
 raw data (e.g., memory bus utilization/GPU utilization). This raw data from
 devfreq_event data would be used for the governor of devfreq subsystem.
 - devfreq_event device : Provide raw data for governor of existing devfreq 
 device
 - devfreq device   : Monitor device state and change frequency/voltage 
 of device
  using the raw data from devfreq_event device

 The devfreq subsystem support generic DVFS(Dynamic Voltage/Frequency 
 Scaling)
 for Non-CPU Devices. The devfreq device would dertermine current device 
 state
 using various governor (e.g., ondemand, performance, powersave). After 
 completed
 determination of system state, devfreq device would change the 
 frequency/voltage
 of devfreq device according to the result of governor.

 But, devfreq governor must need basic data which indicates current device 
 state.
 Existing devfreq subsystem only consider devfreq device which check current 
 system
 state and determine proper system state using basic data. There is no 
 subsystem
 for device providing basic data to devfreq device.

 The devfreq subsystem must need devfreq_event device(data-provider device) 
 for
 existing devfreq device. So, this patch add new devfreq_event class for
 devfreq_event device which read various basic data(e.g, memory bus 
 utilization,
 GPU utilization) and provide measured data to existing devfreq device 
 through
 standard APIs of devfreq_event class.

 The following description explains the feature of two kind of devfreq class:
 - devfreq class (existing)
  : devfreq consumer device use raw data from devfreq_event device for
determining proper current system state and change voltage/frequency
dynamically using various governors.

 - devfreq_event class (new)
  : Provide measured raw data to devfreq device for governor

 Cc: MyungJoo Ham myungjoo@samsung.com
 Cc: Kyungmin Park kyungmin.p...@samsung.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 ---
  drivers/devfreq/Kconfig |   2 +
  drivers/devfreq/Makefile|   5 +-
  drivers/devfreq/devfreq-event.c | 302 
 
  drivers/devfreq/event/Makefile  |   1 +
  include/linux/devfreq.h | 141 +++
  5 files changed, 450 insertions(+), 1 deletion(-)
  create mode 100644 drivers/devfreq/devfreq-event.c
  create mode 100644 drivers/devfreq/event/Makefile

 diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
 index faf4e70..4d15b62 100644
 --- a/drivers/devfreq/Kconfig
 +++ b/drivers/devfreq/Kconfig
 @@ -87,4 +87,6 @@ config ARM_EXYNOS5_BUS_DEVFREQ
   It reads PPMU counters of memory controllers and adjusts the
   operating frequencies and voltages with OPP support.
  
 +comment DEVFREQ Event Drivers
 +
  endif # PM_DEVFREQ
 diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
 index 16138c9..a1ffabe 100644
 --- a/drivers/devfreq/Makefile
 +++ b/drivers/devfreq/Makefile
 @@ -1,4 +1,4 @@
 -obj-$(CONFIG_PM_DEVFREQ)   += devfreq.o
 +obj-$(CONFIG_PM_DEVFREQ)   += devfreq.o devfreq-event.o
  obj-$(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)  += governor_simpleondemand.o
  obj-$(CONFIG_DEVFREQ_GOV_PERFORMANCE)  += governor_performance.o
  obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE)+= governor_powersave.o
 @@ -7,3 +7,6 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE) += governor_userspace.o
  # DEVFREQ Drivers
  obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)  += exynos/
  obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)  += exynos/
 +
 +# DEVFREQ Event Drivers
 +obj-$(CONFIG_PM_DEVFREQ)   += event/
 diff --git a/drivers/devfreq/devfreq-event.c 
 b/drivers/devfreq/devfreq-event.c
 new file mode 100644
 index 000..b47329f
 --- /dev/null
 +++ b/drivers/devfreq/devfreq-event.c
 @@ -0,0 +1,302 @@
 +/*
 + * devfreq-event: Generic DEVFREQ Event class driver
 + *
 + * Copyright (C) 2014 Samsung Electronics
 + * Chanwoo Choi cw00.c...@samsung.com
 + *
 + * 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 driver is based on drivers/devfreq/devfreq.c
 + */
 +
 +#include linux/kernel.h
 +#include linux/sched.h
 +#include linux/errno.h
 +#include linux/err.h
 +#include linux/init.h
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/stat.h
 +#include linux/pm_opp.h
 +#include linux/devfreq.h
 +#include linux/workqueue.h
 +#include 

Re: [RFC PATCHv2 1/7] devfreq: event: Add new devfreq_event class to provide basic data for devfreq governor

2014-12-10 Thread Krzysztof Kozlowski
On wto, 2014-12-09 at 23:13 +0900, Chanwoo Choi wrote:
 This patch add new devfreq_event class for devfreq_event device which provide
 raw data (e.g., memory bus utilization/GPU utilization). This raw data from
 devfreq_event data would be used for the governor of devfreq subsystem.
 - devfreq_event device : Provide raw data for governor of existing devfreq 
 device
 - devfreq device   : Monitor device state and change frequency/voltage of 
 device
  using the raw data from devfreq_event device
 
 The devfreq subsystem support generic DVFS(Dynamic Voltage/Frequency Scaling)
 for Non-CPU Devices. The devfreq device would dertermine current device state
 using various governor (e.g., ondemand, performance, powersave). After 
 completed
 determination of system state, devfreq device would change the 
 frequency/voltage
 of devfreq device according to the result of governor.
 
 But, devfreq governor must need basic data which indicates current device 
 state.
 Existing devfreq subsystem only consider devfreq device which check current 
 system
 state and determine proper system state using basic data. There is no 
 subsystem
 for device providing basic data to devfreq device.
 
 The devfreq subsystem must need devfreq_event device(data-provider device) for
 existing devfreq device. So, this patch add new devfreq_event class for
 devfreq_event device which read various basic data(e.g, memory bus 
 utilization,
 GPU utilization) and provide measured data to existing devfreq device through
 standard APIs of devfreq_event class.
 
 The following description explains the feature of two kind of devfreq class:
 - devfreq class (existing)
  : devfreq consumer device use raw data from devfreq_event device for
determining proper current system state and change voltage/frequency
dynamically using various governors.
 
 - devfreq_event class (new)
  : Provide measured raw data to devfreq device for governor
 
 Cc: MyungJoo Ham myungjoo@samsung.com
 Cc: Kyungmin Park kyungmin.p...@samsung.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 ---
  drivers/devfreq/Kconfig |   2 +
  drivers/devfreq/Makefile|   5 +-
  drivers/devfreq/devfreq-event.c | 302 
 
  drivers/devfreq/event/Makefile  |   1 +
  include/linux/devfreq.h | 141 +++
  5 files changed, 450 insertions(+), 1 deletion(-)
  create mode 100644 drivers/devfreq/devfreq-event.c
  create mode 100644 drivers/devfreq/event/Makefile
 
 diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
 index faf4e70..4d15b62 100644
 --- a/drivers/devfreq/Kconfig
 +++ b/drivers/devfreq/Kconfig
 @@ -87,4 +87,6 @@ config ARM_EXYNOS5_BUS_DEVFREQ
 It reads PPMU counters of memory controllers and adjusts the
 operating frequencies and voltages with OPP support.
  
 +comment DEVFREQ Event Drivers
 +
  endif # PM_DEVFREQ
 diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
 index 16138c9..a1ffabe 100644
 --- a/drivers/devfreq/Makefile
 +++ b/drivers/devfreq/Makefile
 @@ -1,4 +1,4 @@
 -obj-$(CONFIG_PM_DEVFREQ) += devfreq.o
 +obj-$(CONFIG_PM_DEVFREQ) += devfreq.o devfreq-event.o
  obj-$(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)+= governor_simpleondemand.o
  obj-$(CONFIG_DEVFREQ_GOV_PERFORMANCE)+= governor_performance.o
  obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE)  += governor_powersave.o
 @@ -7,3 +7,6 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE)   += governor_userspace.o
  # DEVFREQ Drivers
  obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)+= exynos/
  obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)+= exynos/
 +
 +# DEVFREQ Event Drivers
 +obj-$(CONFIG_PM_DEVFREQ) += event/
 diff --git a/drivers/devfreq/devfreq-event.c b/drivers/devfreq/devfreq-event.c
 new file mode 100644
 index 000..b47329f
 --- /dev/null
 +++ b/drivers/devfreq/devfreq-event.c
 @@ -0,0 +1,302 @@
 +/*
 + * devfreq-event: Generic DEVFREQ Event class driver
 + *
 + * Copyright (C) 2014 Samsung Electronics
 + * Chanwoo Choi cw00.c...@samsung.com
 + *
 + * 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 driver is based on drivers/devfreq/devfreq.c
 + */
 +
 +#include linux/kernel.h
 +#include linux/sched.h
 +#include linux/errno.h
 +#include linux/err.h
 +#include linux/init.h
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/stat.h
 +#include linux/pm_opp.h
 +#include linux/devfreq.h
 +#include linux/workqueue.h
 +#include linux/platform_device.h
 +#include linux/list.h
 +#include linux/printk.h
 +#include linux/hrtimer.h
 +#include linux/of.h
 +#include governor.h
 +
 +static struct class *devfreq_event_class;
 +
 +/* The list of all devfreq event list */
 +static LIST_HEAD(devfreq_event_list);
 +static DEFINE_MUTEX(devfreq_event_list_lock);
 +
 +#define to_devfreq_event(DEV) 

Re: [RFC PATCHv2 1/7] devfreq: event: Add new devfreq_event class to provide basic data for devfreq governor

2014-12-10 Thread Chanwoo Choi
Hi Krzysztof,

First of all, thanks for your review.

On 12/10/2014 06:37 PM, Krzysztof Kozlowski wrote:
 On wto, 2014-12-09 at 23:13 +0900, Chanwoo Choi wrote:
 This patch add new devfreq_event class for devfreq_event device which provide
 raw data (e.g., memory bus utilization/GPU utilization). This raw data from
 devfreq_event data would be used for the governor of devfreq subsystem.
 - devfreq_event device : Provide raw data for governor of existing devfreq 
 device
 - devfreq device   : Monitor device state and change frequency/voltage 
 of device
  using the raw data from devfreq_event device

 The devfreq subsystem support generic DVFS(Dynamic Voltage/Frequency Scaling)
 for Non-CPU Devices. The devfreq device would dertermine current device state
 using various governor (e.g., ondemand, performance, powersave). After 
 completed
 determination of system state, devfreq device would change the 
 frequency/voltage
 of devfreq device according to the result of governor.

 But, devfreq governor must need basic data which indicates current device 
 state.
 Existing devfreq subsystem only consider devfreq device which check current 
 system
 state and determine proper system state using basic data. There is no 
 subsystem
 for device providing basic data to devfreq device.

 The devfreq subsystem must need devfreq_event device(data-provider device) 
 for
 existing devfreq device. So, this patch add new devfreq_event class for
 devfreq_event device which read various basic data(e.g, memory bus 
 utilization,
 GPU utilization) and provide measured data to existing devfreq device through
 standard APIs of devfreq_event class.

 The following description explains the feature of two kind of devfreq class:
 - devfreq class (existing)
  : devfreq consumer device use raw data from devfreq_event device for
determining proper current system state and change voltage/frequency
dynamically using various governors.

 - devfreq_event class (new)
  : Provide measured raw data to devfreq device for governor

 Cc: MyungJoo Ham myungjoo@samsung.com
 Cc: Kyungmin Park kyungmin.p...@samsung.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 ---
  drivers/devfreq/Kconfig |   2 +
  drivers/devfreq/Makefile|   5 +-
  drivers/devfreq/devfreq-event.c | 302 
 
  drivers/devfreq/event/Makefile  |   1 +
  include/linux/devfreq.h | 141 +++
  5 files changed, 450 insertions(+), 1 deletion(-)
  create mode 100644 drivers/devfreq/devfreq-event.c
  create mode 100644 drivers/devfreq/event/Makefile

 diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
 index faf4e70..4d15b62 100644
 --- a/drivers/devfreq/Kconfig
 +++ b/drivers/devfreq/Kconfig
 @@ -87,4 +87,6 @@ config ARM_EXYNOS5_BUS_DEVFREQ
It reads PPMU counters of memory controllers and adjusts the
operating frequencies and voltages with OPP support.
  
 +comment DEVFREQ Event Drivers
 +
  endif # PM_DEVFREQ
 diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
 index 16138c9..a1ffabe 100644
 --- a/drivers/devfreq/Makefile
 +++ b/drivers/devfreq/Makefile
 @@ -1,4 +1,4 @@
 -obj-$(CONFIG_PM_DEVFREQ)+= devfreq.o
 +obj-$(CONFIG_PM_DEVFREQ)+= devfreq.o devfreq-event.o
  obj-$(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)   += governor_simpleondemand.o
  obj-$(CONFIG_DEVFREQ_GOV_PERFORMANCE)   += governor_performance.o
  obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE) += governor_powersave.o
 @@ -7,3 +7,6 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE)  += governor_userspace.o
  # DEVFREQ Drivers
  obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)   += exynos/
  obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)   += exynos/
 +
 +# DEVFREQ Event Drivers
 +obj-$(CONFIG_PM_DEVFREQ)+= event/
 diff --git a/drivers/devfreq/devfreq-event.c 
 b/drivers/devfreq/devfreq-event.c
 new file mode 100644
 index 000..b47329f
 --- /dev/null
 +++ b/drivers/devfreq/devfreq-event.c
 @@ -0,0 +1,302 @@
 +/*
 + * devfreq-event: Generic DEVFREQ Event class driver
 + *
 + * Copyright (C) 2014 Samsung Electronics
 + * Chanwoo Choi cw00.c...@samsung.com
 + *
 + * 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 driver is based on drivers/devfreq/devfreq.c
 + */
 +
 +#include linux/kernel.h
 +#include linux/sched.h
 +#include linux/errno.h
 +#include linux/err.h
 +#include linux/init.h
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/stat.h
 +#include linux/pm_opp.h
 +#include linux/devfreq.h
 +#include linux/workqueue.h
 +#include linux/platform_device.h
 +#include linux/list.h
 +#include linux/printk.h
 +#include linux/hrtimer.h
 +#include linux/of.h
 +#include governor.h
 +
 +static struct class *devfreq_event_class;
 +
 +/* The list of all devfreq event list */
 +static 

[RFC PATCHv2 1/7] devfreq: event: Add new devfreq_event class to provide basic data for devfreq governor

2014-12-09 Thread Chanwoo Choi
This patch add new devfreq_event class for devfreq_event device which provide
raw data (e.g., memory bus utilization/GPU utilization). This raw data from
devfreq_event data would be used for the governor of devfreq subsystem.
- devfreq_event device : Provide raw data for governor of existing devfreq 
device
- devfreq device   : Monitor device state and change frequency/voltage of 
device
 using the raw data from devfreq_event device

The devfreq subsystem support generic DVFS(Dynamic Voltage/Frequency Scaling)
for Non-CPU Devices. The devfreq device would dertermine current device state
using various governor (e.g., ondemand, performance, powersave). After completed
determination of system state, devfreq device would change the frequency/voltage
of devfreq device according to the result of governor.

But, devfreq governor must need basic data which indicates current device state.
Existing devfreq subsystem only consider devfreq device which check current 
system
state and determine proper system state using basic data. There is no subsystem
for device providing basic data to devfreq device.

The devfreq subsystem must need devfreq_event device(data-provider device) for
existing devfreq device. So, this patch add new devfreq_event class for
devfreq_event device which read various basic data(e.g, memory bus utilization,
GPU utilization) and provide measured data to existing devfreq device through
standard APIs of devfreq_event class.

The following description explains the feature of two kind of devfreq class:
- devfreq class (existing)
 : devfreq consumer device use raw data from devfreq_event device for
   determining proper current system state and change voltage/frequency
   dynamically using various governors.

- devfreq_event class (new)
 : Provide measured raw data to devfreq device for governor

Cc: MyungJoo Ham myungjoo@samsung.com
Cc: Kyungmin Park kyungmin.p...@samsung.com
Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
---
 drivers/devfreq/Kconfig |   2 +
 drivers/devfreq/Makefile|   5 +-
 drivers/devfreq/devfreq-event.c | 302 
 drivers/devfreq/event/Makefile  |   1 +
 include/linux/devfreq.h | 141 +++
 5 files changed, 450 insertions(+), 1 deletion(-)
 create mode 100644 drivers/devfreq/devfreq-event.c
 create mode 100644 drivers/devfreq/event/Makefile

diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index faf4e70..4d15b62 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -87,4 +87,6 @@ config ARM_EXYNOS5_BUS_DEVFREQ
  It reads PPMU counters of memory controllers and adjusts the
  operating frequencies and voltages with OPP support.
 
+comment DEVFREQ Event Drivers
+
 endif # PM_DEVFREQ
diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
index 16138c9..a1ffabe 100644
--- a/drivers/devfreq/Makefile
+++ b/drivers/devfreq/Makefile
@@ -1,4 +1,4 @@
-obj-$(CONFIG_PM_DEVFREQ)   += devfreq.o
+obj-$(CONFIG_PM_DEVFREQ)   += devfreq.o devfreq-event.o
 obj-$(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)  += governor_simpleondemand.o
 obj-$(CONFIG_DEVFREQ_GOV_PERFORMANCE)  += governor_performance.o
 obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE)+= governor_powersave.o
@@ -7,3 +7,6 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE) += governor_userspace.o
 # DEVFREQ Drivers
 obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)  += exynos/
 obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)  += exynos/
+
+# DEVFREQ Event Drivers
+obj-$(CONFIG_PM_DEVFREQ)   += event/
diff --git a/drivers/devfreq/devfreq-event.c b/drivers/devfreq/devfreq-event.c
new file mode 100644
index 000..b47329f
--- /dev/null
+++ b/drivers/devfreq/devfreq-event.c
@@ -0,0 +1,302 @@
+/*
+ * devfreq-event: Generic DEVFREQ Event class driver
+ *
+ * Copyright (C) 2014 Samsung Electronics
+ * Chanwoo Choi cw00.c...@samsung.com
+ *
+ * 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 driver is based on drivers/devfreq/devfreq.c
+ */
+
+#include linux/kernel.h
+#include linux/sched.h
+#include linux/errno.h
+#include linux/err.h
+#include linux/init.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/stat.h
+#include linux/pm_opp.h
+#include linux/devfreq.h
+#include linux/workqueue.h
+#include linux/platform_device.h
+#include linux/list.h
+#include linux/printk.h
+#include linux/hrtimer.h
+#include linux/of.h
+#include governor.h
+
+static struct class *devfreq_event_class;
+
+/* The list of all devfreq event list */
+static LIST_HEAD(devfreq_event_list);
+static DEFINE_MUTEX(devfreq_event_list_lock);
+
+#define to_devfreq_event(DEV) container_of(DEV, struct devfreq_event_dev, dev)
+
+struct devfreq_event_dev *devfreq_add_event_device(struct device *dev,
+   struct devfreq_event_desc