Commit Graph

418 Commits

Author SHA1 Message Date
YouMin Chen
86f64099c7 PM / devfreq: rockchip_dmcdbg: add support rockchip dmc debug
Change-Id: I54f5792267fcd346bc781e3c3816b5ae2642f351
Signed-off-by: YouMin Chen <cym@rock-chips.com>
2020-09-25 15:01:43 +08:00
YouMin Chen
24edb749b7 PM / devfreq: rockchip_dmc: add rockchip_dmc_timing.h
Move the dmc timing from rockchip_dmc.c to rockchip_dmc_timing.h.
In order to be able to reuse them.

Change-Id: I03edf68c68b78c08100ffa1c149d70d4d7d4ee6e
Signed-off-by: YouMin Chen <cym@rock-chips.com>
2020-09-25 15:01:43 +08:00
YouMin Chen
7bf3b88f36 PM / devfreq: rockchip_dmc: add dynamic switch complt_irq
Change-Id: I7cc8c2f58e9d4e6c8d84cf5c483295ef46c055b0
Signed-off-by: YouMin Chen <cym@rock-chips.com>
2020-09-25 15:01:43 +08:00
Tao Huang
48f4e7f7c2 Merge tag 'ASB-2020-09-05_4.19-stable' of https://android.googlesource.com/kernel/common
https://source.android.com/security/bulletin/2020-09-01
CVE-2020-0402
CVE-2020-0404
CVE-2020-0407

* tag 'ASB-2020-09-05_4.19-stable': (3616 commits)
  Linux 4.19.143
  ALSA: usb-audio: Update documentation comment for MS2109 quirk
  HID: hiddev: Fix slab-out-of-bounds write in hiddev_ioctl_usage()
  tpm: Unify the mismatching TPM space buffer sizes
  usb: dwc3: gadget: Handle ZLP for sg requests
  usb: dwc3: gadget: Fix handling ZLP
  usb: dwc3: gadget: Don't setup more than requested
  btrfs: check the right error variable in btrfs_del_dir_entries_in_log
  usb: storage: Add unusual_uas entry for Sony PSZ drives
  USB: cdc-acm: rework notification_buffer resizing
  USB: gadget: u_f: Unbreak offset calculation in VLAs
  USB: gadget: f_ncm: add bounds checks to ncm_unwrap_ntb()
  USB: gadget: u_f: add overflow checks to VLA macros
  usb: host: ohci-exynos: Fix error handling in exynos_ohci_probe()
  USB: Ignore UAS for JMicron JMS567 ATA/ATAPI Bridge
  USB: quirks: Ignore duplicate endpoint on Sound Devices MixPre-D
  USB: quirks: Add no-lpm quirk for another Raydium touchscreen
  usb: uas: Add quirk for PNY Pro Elite
  USB: yurex: Fix bad gfp argument
  drm/amd/pm: correct Vega12 swctf limit setting
  ...

Change-Id: Iece02c55e9b3446bdda5dc7bdfbe3e310b2dbc83

Conflicts:
	arch/arm/boot/dts/rk322x.dtsi
	arch/arm64/boot/dts/rockchip/rk3399.dtsi
	arch/arm64/kernel/cpuinfo.c
	drivers/clk/clk.c
	drivers/clk/rockchip/clk-cpu.c
	drivers/clk/rockchip/clk-rk3228.c
	drivers/devfreq/governor_simpleondemand.c
	drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
	drivers/gpu/drm/drm_edid.c
	drivers/hid/usbhid/hid-core.c
	drivers/media/i2c/ov5695.c
	drivers/media/v4l2-core/v4l2-ioctl.c
	drivers/regulator/core.c
	drivers/thermal/cpu_cooling.c
	drivers/usb/core/quirks.c
	drivers/usb/dwc2/platform.c
	drivers/usb/dwc3/core.c
	drivers/usb/dwc3/core.h
	drivers/usb/dwc3/gadget.c
	drivers/usb/host/ehci-platform.c
	drivers/usb/storage/unusual_uas.h
	include/drm/drm_connector.h
	include/linux/clk-provider.h
	include/linux/devfreq.h
	include/linux/pci_ids.h
	kernel/power/wakeup_reason.c
	mm/memory.c
	mm/swapfile.c
2020-09-24 17:59:50 +08:00
YouMin Chen
8d3917b810 PM / devfreq: rockchip_dmc: rv1126 support set ddr frequency by DCF
Change-Id: I6f5fdbbfd2a3986212a9c5bf9771ca408657705e
Signed-off-by: YouMin Chen <cym@rock-chips.com>
2020-08-26 17:03:17 +08:00
Sandy Huang
5189e9b511 drivers: devfreq: rockchip_dmc: export dmc symbol
EXPORT_SYMBOL rockchip_dmcfreq_vop_bandwidth_update and
rockchip_dmcfreq_vop_bandwidth_request

Change-Id: Ifb41d9e7885627a3c085fb403289bd3469d073c9
Signed-off-by: Sandy Huang <hjc@rock-chips.com>
2020-07-08 19:48:08 +08:00
Tony Xie
9d2c26a278 PM / devfreq: rockchip_bus: add support for rv1126.
Signed-off-by: Tony Xie <tony.xie@rock-chips.com>
Change-Id: I505d0aa047a347674ad54db18110876cb85937c0
2020-05-27 16:59:17 +08:00
Tony Xie
d0a76dd65c PM / devfreq: rockchip_bus: remove the autocs keyword.
1、remove the autocs keyword.
2、use cfg-val instead of timer-us in rk1808.dtsi
3、remove bus-soc node in px30.dtsi

Signed-off-by: Tony Xie <tony.xie@rock-chips.com>
Change-Id: I0f4563476ad7e08ba8dd9d02097eb4448d024ecd
2020-05-25 18:20:34 +08:00
YouMin Chen
46ebe3def5 PM / devfreq: rockchip_dmc: add support for rv1126
Change-Id: I40b1148a0af2615b55f36f86d3f7df28fd4f6f83
Signed-off-by: YouMin Chen <cym@rock-chips.com>
2020-05-25 18:19:53 +08:00
YouMin Chen
eebda71aa7 PM / devfreq: rockchip-dfi: add support for rv1126 dfi
Change-Id: I65a403424b68804022025309f9af82b55c044192
Signed-off-by: YouMin Chen <cym@rock-chips.com>
2020-05-25 18:19:52 +08:00
Saravana Kannan
a2038b4794 FROMLIST: PM / devfreq: Restart previous governor if new governor fails to start
If the new governor fails to start, switch back to old governor so that the
devfreq state is not left in some weird limbo.

Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Bug: 155527102
Link: https://lore.kernel.org/lkml/1477360800-11509-1-git-send-email-skannan@codeaurora.org/
Signed-off-by: Saravana Kannan <saravanak@google.com>
Change-Id: If853c7d03b6ce6767047f17d747f62d850a7b3b4
2020-05-02 00:07:05 -07:00
Saravana Kannan
ace5c22c16 ANDROID: GKI: PM / devfreq: Allow min freq to be 0
Some vendors have devfreq devices that allow min freq to be 0. So, allow
that.

Bug: 152343889
Signed-off-by: Saravana Kannan <saravanak@google.com>
Change-Id: I03adc475338c5b0376992ab40543f481b75de895
Signed-off-by: Will McVicker <willmcvicker@google.com>
2020-04-30 00:05:39 -07:00
Sahitya Tummala
5e68c49cb6 ANDROID: GKI: PM / devfreq: Add new flag to do simple clock scaling
Add new flag "simple_scaling" to on demand governor so that
the clocks can be scaled up only when the load is more than
up threshold and can be scaled down only when the load is less
than down differential data as provided within
struct devfreq_simple_ondemand_data.

Change-Id: Ibc6ab6297c1b64b6e6eaaa76d735d0b9ae0f6477
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[venkatg@codeaurora.org: dereference stat variables]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Bug: 153569404
(cherry picked from commit 4b185480e88596db66e186534ce4cfc43597e7b9)
Signed-off-by: Saravana Kannan <saravanak@google.com>
2020-04-22 15:31:42 +00:00
Rama Aparna Mallavarapu
4f9183cc24 ANDROID: GKI: PM/devfreq: Do not switch governors from sysfs when device is suspended
There is a possibility to switch the governors from sysfs even when the
device is in suspended state. This can cause a NOC error at times when
trying to access the device's monitor registers in a suspended state. This
change fixes this issue. Introduce a variable dev_suspended to know if
the device is in suspended state or not. Check if the device is suspended
before switching the governor from sysfs.

Change-Id: I15055aa51daa35272be4667e5bafb8ccd7933098
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
Bug: 152343889
(cherry picked from commit 9c41437c072048a9487353b85a452114c4031659)
Signed-off-by: Saravana Kannan <saravanak@google.com>
2020-04-08 00:21:28 -07:00
Rama Aparna Mallavarapu
902ad8fa08 ANDROID: GKI: PM / devfreq: Fix race condition between suspend/resume and governor_store
There is a race condition when the event governor_store is being executed
from sysfs and the device issues a suspend. The devfreq data structures
would become stale when the suspend tries to access them in the middle
of the governor_store operation. Fix this issue by taking a lock around
suspend and resume operations so that these operations are not concurrent
with the other events from sysfs.

Also rename the sysfs_lock as event_lock since the same lock is used
for non sysfs operations like suspend and resume as well.

Change-Id: Ifa0e93915a920cec3e0429966328a1128d61098b
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
Bug: 152343889
(cherry picked from commit 8bf200e7136a6896e429e9bfab116238c1d99be6)
Signed-off-by: Saravana Kannan <saravanak@google.com>
2020-04-08 00:21:28 -07:00
Jonathan Avila
8f43993c58 ANDROID: GKI: PM / devfreq: Introduce a sysfs lock
Currently, concurrent writes to sysfs entries leave the	possibility
for race conditions within the devfreq framework.  For example,
concurrently executing max_freq_store and governor_store can result
in attempting to perform an update_devfreq() before the new governor's
start handler can be executed.

A more concrete case is a race between polling_interval_store and
governor_store.  Because no lock is used after calling into the event
handler of the old governor and there's nothing preventing work from
being queued after the monitor is stopped, it's possible to
accidentally cause delayed work to be queued on the governor being
switched to.  This can be seen if you create two threads, one which
changes a device's governor between simple_ondemand and performance,
and one which changes its polling interval between 45 and 50.

All of these races can be addressed with the introduction of a lock
that prevents sysfs operations from interleaving in this fashion.

Change-Id: Ia6887dcb2d69dc2576837a6c09fed55a28943abc
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
Bug: 152343889
(cherry picked from commit 78fdd25c1abb1f23f43243f09c3d81cccaa844bc)
[saravanak Fixed some conflicts]
Signed-off-by: Saravana Kannan <saravanak@google.com>
2020-04-08 00:21:28 -07:00
Tao Huang
06a7fcfc9a Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common
* android-4.19: (1190 commits)
  ANDROID: update the ABI xml representation
  ANDROID: GKI: Enable V4L2 hidden configs
  ANDROID: GKI: Enable CONFIG_BACKLIGHT_CLASS_DEVICE in gki_defconfig
  ANDROID: Incremental fs: Add INCFS_IOC_PERMIT_FILL
  ANDROID: Incremental fs: Remove signature checks from kernel
  ANDROID: Incremental fs: Pad hash blocks
  ANDROID: Incremental fs: Make fill block an ioctl
  ANDROID: Incremental fs: Remove all access_ok checks
  Linux 4.19.111
  batman-adv: Avoid free/alloc race when handling OGM2 buffer
  efi: Add a sanity check to efivar_store_raw()
  net/smc: cancel event worker during device removal
  net/smc: check for valid ib_client_data
  ipv6: restrict IPV6_ADDRFORM operation
  i2c: acpi: put device when verifying client fails
  iommu/vt-d: Ignore devices with out-of-spec domain number
  iommu/vt-d: Fix the wrong printing in RHSA parsing
  netfilter: nft_tunnel: add missing attribute validation for tunnels
  netfilter: nft_payload: add missing attribute validation for payload csum flags
  netfilter: cthelper: add missing attribute validation for cthelper
  ...

Conflicts:
	arch/arm64/configs/gki_defconfig
	arch/x86/configs/gki_defconfig
	drivers/devfreq/Kconfig
	drivers/dma-buf/dma-buf.c
	include/linux/usb/quirks.h
	kernel/sched/topology.c

Change-Id: Ibd305c952c16c253b34d822cf68c03f9ff5be7b3
2020-03-21 19:46:46 +08:00
Tao Huang
949d4b715c Revert "PM / devfreq: Add new device link for sysfs"
This reverts commit 32948d8b86.

See commit a8b1fa6c47 ("Revert "PM / devfreq: Modify the device name as devfreq(X) for sysfs"")

Conflicts:
	drivers/devfreq/devfreq.c

Change-Id: If4fec73bb1cf38afffd4699dfe25b8c32ea7472f
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2020-03-21 15:55:11 +08:00
Orson Zhai
a8b1fa6c47 Revert "PM / devfreq: Modify the device name as devfreq(X) for sysfs"
commit 66d0e797bf upstream.

This reverts commit 4585fbcb53.

The name changing as devfreq(X) breaks some user space applications,
such as Android HAL from Unisoc and Hikey [1].
The device name will be changed unexpectly after every boot depending
on module init sequence. It will make trouble to setup some system
configuration like selinux for Android.

So we'd like to revert it back to old naming rule before any better
way being found.

[1] https://lkml.org/lkml/2018/5/8/1042

Cc: John Stultz <john.stultz@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: Orson Zhai <orson.unisoc@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-05 16:42:18 +01:00
Chanwoo Choi
0f6ca0c784 PM / devfreq: rk3399_dmc: Add COMPILE_TEST and HAVE_ARM_SMCCC dependency
[ Upstream commit eff5d31f74 ]

To build test, add COMPILE_TEST depedency to both ARM_RK3399_DMC_DEVFREQ
and DEVFREQ_EVENT_ROCKCHIP_DFI configuration. And ARM_RK3399_DMC_DEVFREQ
used the SMCCC interface so that add HAVE_ARM_SMCCC dependency to prevent
the build break.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-02-24 08:34:44 +01:00
Tao Huang
ad61dfe590 Merge tag 'ASB-2020-02-05_4.19' of https://android.googlesource.com/kernel/common
https://source.android.com/security/bulletin/2020-02-01
CVE-2020-0030
CVE-2019-11599

* tag 'ASB-2020-02-05_4.19': (4206 commits)
  UPSTREAM: sched/fair/util_est: Implement faster ramp-up EWMA on utilization increases
  ANDROID: Re-use SUGOV_RT_MAX_FREQ to control uclamp rt behavior
  BACKPORT: sched/fair: Make EAS wakeup placement consider uclamp restrictions
  BACKPORT: sched/fair: Make task_fits_capacity() consider uclamp restrictions
  ANDROID: sched/core: Move SchedTune task API into UtilClamp wrappers
  ANDROID: sched/core: Add a latency-sensitive flag to uclamp
  ANDROID: sched/tune: Move SchedTune cpu API into UtilClamp wrappers
  ANDROID: init: kconfig: Only allow sched tune if !uclamp
  FROMGIT: sched/core: Fix size of rq::uclamp initialization
  FROMGIT: sched/uclamp: Fix a bug in propagating uclamp value in new cgroups
  FROMGIT: sched/uclamp: Rename uclamp_util_with() into uclamp_rq_util_with()
  FROMGIT: sched/uclamp: Make uclamp util helpers use and return UL values
  FROMGIT: sched/uclamp: Remove uclamp_util()
  BACKPORT: sched/rt: Make RT capacity-aware
  UPSTREAM: tools headers UAPI: Sync sched.h with the kernel
  UPSTREAM: sched/uclamp: Fix overzealous type replacement
  UPSTREAM: sched/uclamp: Fix incorrect condition
  UPSTREAM: sched/core: Fix compilation error when cgroup not selected
  UPSTREAM: sched/core: Fix uclamp ABI bug, clean up and robustify sched_read_attr() ABI logic and code
  UPSTREAM: sched/uclamp: Always use 'enum uclamp_id' for clamp_id values
  ...

Conflicts:
	drivers/char/random.c
	drivers/devfreq/devfreq.c
	drivers/gpu/drm/drm_fb_helper.c
	drivers/media/i2c/ov2680.c
	drivers/media/i2c/ov2685.c
	drivers/media/i2c/ov5670.c
	drivers/media/i2c/ov5695.c
	drivers/media/usb/uvc/uvc_driver.c
	drivers/mmc/host/cqhci.c
	drivers/spi/spi-rockchip.c
	drivers/usb/dwc2/params.c
	drivers/usb/dwc3/debugfs.c
	drivers/usb/dwc3/gadget.c
	drivers/usb/serial/usb_wwan.c
	include/linux/clk-provider.h
	include/linux/mfd/rk808.h
	kernel/cpu.c
	sound/usb/quirks.c

- Export symbol mm_trace_rss_stat on mm/memory.c for GPU drivers.
- Fix sound/usb/pcm.c for SNDRV_PCM_TRIGGER_SUSPEND.
- Enable DEBUG_FS which is not selected by TRACING.
- Disable of_devlink which broken boot. of_devlink is enabled by commit
  ba3aa33b8f ("ANDROID: of: property: Enable of_devlink by default").
- Add CLK_DONT_HOLD_STATE and CLK_KEEP_REQ_RATE to clk_flags
  on drivers/clk/clk.c.

Change-Id: I500ca1bbc735753f9c8251ed2ac8ad757d5a24a4
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2020-02-17 16:00:29 +08:00
Chanwoo Choi
1635d4fc76 PM / devfreq: Add new name attribute for sysfs
commit 2fee1a7cc6 upstream.

The commit 4585fbcb53 ("PM / devfreq: Modify the device name as devfreq(X) for
sysfs") changed the node name to devfreq(x). After this commit, it is not
possible to get the device name through /sys/class/devfreq/devfreq(X)/*.

Add new name attribute in order to get device name.

Cc: stable@vger.kernel.org
Fixes: 4585fbcb53 ("PM / devfreq: Modify the device name as devfreq(X) for sysfs")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-05 14:43:34 +00:00
Leonard Crestez
ac57e16058 PM / devfreq: Check NULL governor in available_governors_show
commit d68adc8f85 upstream.

The governor is initialized after sysfs attributes become visible so in
theory the governor field can be NULL here.

Fixes: bcf23c79c4 ("PM / devfreq: Fix available_governor sysfs")
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-09 10:19:03 +01:00
Leonard Crestez
6c3986b6b5 PM / devfreq: Don't fail devfreq_dev_release if not in list
[ Upstream commit 42a6b25e67 ]

Right now devfreq_dev_release will print a warning and abort the rest of
the cleanup if the devfreq instance is not part of the global
devfreq_list. But this is a valid scenario, for example it can happen if
the governor can't be found or on any other init error that happens
after device_register.

Initialize devfreq->node to an empty list head in devfreq_add_device so
that list_del becomes a safe noop inside devfreq_dev_release and we can
continue the rest of the cleanup.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-09 10:18:55 +01:00
Leonard Crestez
56f1c5108d PM / devfreq: Set scaling_max_freq to max on OPP notifier error
[ Upstream commit e7cc792d00 ]

The devfreq_notifier_call functions will update scaling_min_freq and
scaling_max_freq when the OPP table is updated.

If fetching the maximum frequency fails then scaling_max_freq remains
set to zero which is confusing. Set to ULONG_MAX instead so we don't
need special handling for this case in other places.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-09 10:18:55 +01:00
Leonard Crestez
6b2c3bb311 PM / devfreq: Fix devfreq_notifier_call returning errno
[ Upstream commit e876e710ed ]

Notifier callbacks shouldn't return negative errno but one of the
NOTIFY_OK/DONE/BAD values.

The OPP core will ignore return values from notifiers but returning a
value that matches NOTIFY_STOP_MASK will stop the notification chain.

Fix by always returning NOTIFY_OK.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-09 10:18:55 +01:00
Leonard Crestez
b1d06da384 PM / devfreq: Lock devfreq in trans_stat_show
commit 2abb0d5268 upstream.

There is no locking in this sysfs show function so stats printing can
race with a devfreq_update_status called as part of freq switching or
with initialization.

Also add an assert in devfreq_update_status to make it clear that lock
must be held by caller.

Fixes: 39688ce6fa ("PM / devfreq: account suspend/resume for stats")
Cc: stable@vger.kernel.org
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-12-17 20:35:03 +01:00
Huibin Hong
a427468e9e drivers: devfreq: rockchip_dmc: rk3128: fix bug about ddr_2t
Change-Id: I4a30b7f5524df7862e2277d7b252bdbfc767886c
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
2019-12-06 08:40:40 +08:00
Ezequiel Garcia
6938a9da7f PM / devfreq: Fix kernel oops on governor module load
commit 7544fd7f38 upstream.

A bit unexpectedly (but still documented), request_module may
return a positive value, in case of a modprobe error.
This is currently causing issues in the devfreq framework.

When a request_module exits with a positive value, we currently
return that via ERR_PTR. However, because the value is positive,
it's not a ERR_VALUE proper, and is therefore treated as a
valid struct devfreq_governor pointer, leading to a kernel oops.

Fix this by returning -EINVAL if request_module returns a positive
value.

Fixes: b53b012805 ("PM / devfreq: Fix static checker warning in try_then_request_governor")
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-12-01 09:17:46 +01:00
Enric Balletbo i Serra
4039b5dd0f PM / devfreq: Fix static checker warning in try_then_request_governor
[ Upstream commit b53b012805 ]

The patch 23c7b54ca1cd: "PM / devfreq: Fix devfreq_add_device() when
drivers are built as modules." leads to the following static checker
warning:

    drivers/devfreq/devfreq.c:1043 governor_store()
    warn: 'governor' can also be NULL

The reason is that the try_then_request_governor() function returns both
error pointers and NULL. It should just return error pointers, so fix
this by returning a ERR_PTR to the error intead of returning NULL.

Fixes: 23c7b54ca1 ("PM / devfreq: Fix devfreq_add_device() when drivers are built as modules.")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-24 08:21:07 +01:00
Vincent Donnefort
f6ec4fccbf PM / devfreq: stopping the governor before device_unregister()
[ Upstream commit 2f061fd0c2 ]

device_release() is freeing the resources before calling the device
specific release callback which is, in the case of devfreq, stopping
the governor.

It is a problem as some governors are using the device resources. e.g.
simpleondemand which is using the devfreq deferrable monitoring work. If it
is not stopped before the resources are freed, it might lead to a use after
free.

Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Reviewed-by: John Einar Reitan <john.reitan@arm.com>
[cw00.choi: Fix merge conflict]
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-24 08:19:36 +01:00
Matthias Kaehlcke
fc491a1e77 PM / devfreq: Fix handling of min/max_freq == 0
[ Upstream commit df5cf4a361 ]

Commit ab8f58ad72 ("PM / devfreq: Set min/max_freq when adding the
devfreq device") initializes df->min/max_freq with the min/max OPP when
the device is added. Later commit f1d981eaec ("PM / devfreq: Use the
available min/max frequency") adds df->scaling_min/max_freq and the
following to the frequency adjustment code:

  max_freq = MIN(devfreq->scaling_max_freq, devfreq->max_freq);

With the current handling of min/max_freq this is incorrect:

Even though df->max_freq is now initialized to a value != 0 user space
can still set it to 0, in this case max_freq would be 0 instead of
df->scaling_max_freq as intended. In consequence the frequency adjustment
is not performed:

  if (max_freq && freq > max_freq) {
	freq = max_freq;

To fix this set df->min/max freq to the min/max OPP in max/max_freq_store,
when the user passes a value of 0. This also prevents df->max_freq from
being set below the min OPP when df->min_freq is 0, and similar for
min_freq. Since it is now guaranteed that df->min/max_freq can't be 0 the
checks for this case can be removed.

Fixes: f1d981eaec ("PM / devfreq: Use the available min/max frequency")
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-24 08:19:35 +01:00
Enric Balletbo i Serra
b5add975c8 PM / devfreq: Fix devfreq_add_device() when drivers are built as modules.
[ Upstream commit 23c7b54ca1 ]

When the devfreq driver and the governor driver are built as modules,
the call to devfreq_add_device() or governor_store() fails because the
governor driver is not loaded at the time the devfreq driver loads. The
devfreq driver has a build dependency on the governor but also should
have a runtime dependency. We need to make sure that the governor driver
is loaded before the devfreq driver.

This patch fixes this bug by adding a try_then_request_governor()
function. First tries to find the governor, and then, if it is not found,
it requests the module and tries again.

Fixes: 1b5c1be2c8 (PM / devfreq: map devfreq drivers to governor using name)
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-24 08:19:34 +01:00
Huibin Hong
e89f34170a drivers: devfreq: rockchip_dmc: rk3128: add en 2t mode
Change-Id: I27e0ae7397cf4693c64d37ae1c5f7702b48863b9
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
2019-11-21 18:37:59 +08:00
Zhihuan He
efc3fbda71 drivers: devfreq: rockchip_dmc: rk3368: enable ddr 2T mode
Change-Id: I425e9ddb7d5c1d8e789283f3c6ae56efd62c252a
Signed-off-by: Zhihuan He <huan.he@rock-chips.com>
2019-11-11 16:48:42 +08:00
Finley Xiao
8c07126830 PM / devfreq: rockchip_dmc: stop monitor only when enable auto-freq
This fix the warning:
WARNING: CPU: 1 PID: 1 at kernel/workqueue.c:2934 __flush_work+0x1f8/0x220
Modules linked in:
CPU: 1 PID: 1 Comm: init Not tainted 4.19.53 #303
Hardware name: Rockchip RK3399 EVB IND LPDDR4 Board edp (Android) (DT)
pstate: 00400005 (nzcv daif +PAN -UAO)
pc : __flush_work+0x1f8/0x220
lr : __cancel_work_timer+0x12c/0x1a8
sp : ffffff800804ba20
x29: ffffff800804ba20 x28: ffffffc0f1870000
x27: 0000000000000000 x26: ffffffc0f1870000
x25: ffffff800804bb30 x24: ffffff80094e8000
x23: ffffff80080d1910 x22: 0000000000000000
x21: ffffff800933d000 x20: ffffffc0f0777350
x19: ffffff80094e85b8 x18: ffffffffffffffff
x17: 0000000000000000 x16: 0000000000000001
x15: ffffff800933da88 x14: ffffff80894ecdf7
x13: ffffff80094ece05 x12: ffffff80094ed240
x11: ffffff800935e000 x10: 0000000000000000
x9 : ffffffc00a3a0180 x8 : 0000000000000004
x7 : 0000000002487900 x6 : 0000000000000001
x5 : 0000000000000001 x4 : 0000000000000800
x3 : ffffff800933da88 x2 : 0000000000000000
x1 : 0000000000000000 x0 : ffffffc0f0777350

Call trace:
 __flush_work+0x1f8/0x220
 __cancel_work_timer+0x12c/0x1a8
 cancel_delayed_work_sync+0x10/0x18
 devfreq_monitor_stop+0x10/0x18
 rockchip_dmcfreq_system_status_notifier+0x150/0x160
 notifier_call_chain+0x50/0x90
 __blocking_notifier_call_chain+0x50/0x78
 blocking_notifier_call_chain+0x14/0x20
 rockchip_set_system_status+0xb0/0xd0
 rockchip_monitor_reboot_notifier+0x10/0x20
 notifier_call_chain+0x50/0x90
 __blocking_notifier_call_chain+0x50/0x78
 blocking_notifier_call_chain+0x14/0x20
 kernel_restart_prepare+0x1c/0x40
 kernel_restart+0x14/0x78
 __se_sys_reboot+0x1cc/0x208
 __arm64_sys_reboot+0x18/0x20
 el0_svc_common+0xbc/0x188
 el0_svc_handler+0x2c/0x80
 el0_svc+0x8/0xc
---[ end trace 4548dcc701eee1b0 ]---

Change-Id: I479d0abdfcf6aa144036983c57b0878e104cd8e0
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
2019-10-29 10:02:50 +08:00
Tao Huang
70f1413e90 Merge remote branch 'android-4.19' of https://android.googlesource.com/kernel/common
* android-4.19: (2854 commits)
  ANDROID: move up spin_unlock_bh() ahead of remove_proc_entry()
  BACKPORT: arm64: tags: Preserve tags for addresses translated via TTBR1
  UPSTREAM: arm64: memory: Implement __tag_set() as common function
  UPSTREAM: arm64/mm: fix variable 'tag' set but not used
  UPSTREAM: arm64: avoid clang warning about self-assignment
  ANDROID: sdcardfs: evict dentries on fscrypt key removal
  ANDROID: fscrypt: add key removal notifier chain
  ANDROID: refactor build.config files to remove duplication
  ANDROID: Move from clang r353983c to r365631c
  ANDROID: gki_defconfig: remove PWRSEQ_EMMC and PWRSEQ_SIMPLE
  ANDROID: unconditionally compile sig_ok in struct module
  Linux 4.19.80
  perf/hw_breakpoint: Fix arch_hw_breakpoint use-before-initialization
  PCI: vmd: Fix config addressing when using bus offsets
  x86/asm: Fix MWAITX C-state hint value
  hwmon: Fix HWMON_P_MIN_ALARM mask
  tracing: Get trace_array reference for available_tracers files
  ftrace: Get a reference counter for the trace_array on filter files
  tracing/hwlat: Don't ignore outer-loop duration when calculating max_latency
  tracing/hwlat: Report total time spent in all NMIs during the sample
  ...

Conflicts:
	drivers/clk/rockchip/clk-mmc-phase.c
	drivers/gpu/drm/rockchip/rockchip_drm_vop.c
	drivers/regulator/core.c
	drivers/tty/serial/8250/8250_port.c
	drivers/usb/dwc3/core.h
	drivers/usb/dwc3/gadget.c
	drivers/usb/dwc3/gadget.h

Change-Id: I65599d770d6613caba14251b890fcfd1cfa0f100
2019-10-28 20:26:28 +08:00
Finley Xiao
d79b5fb21a PM / devfreq: rockchip_bus: Fix deadlock in rockchip_bus_clkfreq_target()
INFO: task cfinteractive:47 blocked for more than 10 seconds.
      Not tainted 4.19.53 #111
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
cfinteractive   D    0    47      2 0x00000028
Call trace:
 __switch_to+0x8c/0xd0
 __schedule+0x2e0/0x908
 schedule+0x38/0xa0
 schedule_preempt_disabled+0x20/0x38
 __mutex_lock.isra.0+0x188/0x6d8
 __mutex_lock_slowpath+0x10/0x18
 mutex_lock+0x38/0x40
 _find_opp_table+0x30/0x88
 dev_pm_opp_find_freq_ceil+0x20/0x88
 devfreq_recommended_opp+0x34/0x60
 rockchip_bus_clkfreq_target.constprop.2+0x44/0xf0
 rockchip_bus_clk_notifier+0x48/0x88
 notifier_call_chain+0x50/0x90
 __srcu_notifier_call_chain+0x54/0x80
 srcu_notifier_call_chain+0x14/0x20
 __clk_notify+0x8c/0xc8
 clk_propagate_rate_change+0xac/0xc0
 clk_propagate_rate_change+0x9c/0xc0
 clk_core_set_rate_nolock+0x154/0x1b8
 clk_set_rate+0x34/0x90
 _generic_set_opp_regulator+0x70/0x1a0
 dev_pm_opp_set_rate+0x2f0/0x3e0
 set_target+0x40/0x70
 __cpufreq_driver_target+0x2c8/0x540
 cpufreq_interactive_speedchange_task+0x1f0/0x330
 kthread+0xfc/0x128
 ret_from_fork+0x10/0x18
INFO: task kworker/2:2:137 blocked for more than 10 seconds.
      Not tainted 4.19.53 #111
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
kworker/2:2     D    0   137      2 0x00000028
Workqueue: events deferred_probe_work_func
Call trace:
 __switch_to+0x8c/0xd0
 __schedule+0x2e0/0x908
 schedule+0x38/0xa0
 schedule_preempt_disabled+0x20/0x38
 __mutex_lock.isra.0+0x188/0x6d8
 __mutex_lock_slowpath+0x10/0x18
 mutex_lock+0x38/0x40
 clk_prepare_lock+0x40/0xa0
 clk_hw_create_clk.isra.24+0x64/0xb8
 __clk_create_clk+0x3c/0x58
 __of_clk_get_from_provider+0xec/0x130
 __of_clk_get_by_name+0xa8/0x148
 clk_get+0x30/0x80
 dev_pm_opp_get_opp_table+0xbc/0x130
 dev_pm_opp_set_prop_name+0x14/0x88
 rockchip_set_opp_prop_name+0x5c/0xd8
 rockchip_init_opp_table+0x98/0x108
 kbase_platform_rk_init_opp_table+0x24/0x30
 kbase_platform_device_probe+0x228/0xd30
 platform_drv_probe+0x50/0xa8
 really_probe+0x1f8/0x288
 driver_probe_device+0x58/0x100
 __device_attach_driver+0x9c/0xf8
 bus_for_each_drv+0x70/0xc8
 __device_attach+0xdc/0x138
 device_initial_probe+0x10/0x18
 bus_probe_device+0x94/0xa0
 deferred_probe_work_func+0x6c/0xa0
 process_one_work+0x1ec/0x450
 worker_thread+0x234/0x428
 kthread+0xfc/0x128
 ret_from_fork+0x10/0x18

Change-Id: Ibf37fe60513fcfb517a381a404592859a27ed0ea
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
2019-10-23 16:18:00 +08:00
Finley Xiao
dd0fcebd81 thermal: devfreq_cooling: Add support to update stats when get requested power
The power_allocator thermal governor should get utilization of cooling
device to calculate dynamic power, but the powersave, userspace and performance
devfreq governor don't updade stats, so the utilization is inaccurate.

This patch adds support to update status when get requested power, so that
power_allocator can also work properly when use powersave, userspace and
performance devfreq governor.

Change-Id: Ic98fabf46f693a60b0f07094c59e75e4d141e42c
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
2019-10-22 14:58:00 +08:00
Finley Xiao
e8ca6ed7ae PM / devfreq: event: Add new Rockchip NoC probe driver
This patch adds NoC (Network on Chip) Probe driver which provides
the primitive values to get the performance data. For example, RK3399
has multiple NoC probes to monitor traffic statistics for analyzing
the transaction flow.

Change-Id: I66f6708f0d244488ca08f0f1f1cb36b19c7a2d0a
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
2019-10-21 19:08:59 +08:00
XiaoDong Huang
8c9d010061 PM / devfreq: rockchip_bus: add support for rk1808
Change-Id: I2be704a4b72fc0c2b6c8c864e2fb605038271ce5
Signed-off-by: XiaoDong Huang <derrick.huang@rock-chips.com>
2019-10-21 19:08:35 +08:00
Jianqun Xu
907ef342e1 PM / devfreq: add to show current load of device
Calculate current load with busytime / totaltime from status,
also show the current frequency.

Change-Id: Ic310035db9c5478aa3d0b1e526b47c451fe09d23
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
2019-10-21 18:58:31 +08:00
Finley Xiao
32948d8b86 PM / devfreq: Add new device link for sysfs
As the device name has been changed to devfreq(X), but user should find
devfreq driver with their parent device name, so add a new link named
with parent name.

Change-Id: I5077ddecbcc8db8d59cb6f16f2be5107b391677d
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
2019-10-17 08:52:12 +08:00
Tao Huang
89b1aa9ecf PM / devfreq: rockchip_dmc: Update OPP users to put reference
According to
commit 8a31d9d942 ("PM / OPP: Update OPP users to put reference")

Change-Id: Ia4dd086bdb8260a5fc839287e872c89a4b57cb22
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2019-10-12 15:25:20 +08:00
Tao Huang
de384cecb2 PM / devfreq: rockchip_bus: Update OPP users to put reference
According to
commit 8a31d9d942 ("PM / OPP: Update OPP users to put reference")

Change-Id: I56e2212f19eee5bcd570d8729d3a5154f6a02ef4
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2019-10-12 15:25:20 +08:00
Dmitry Osipenko
42b888f633 PM / devfreq: tegra: Fix kHz to Hz conversion
commit 62bacb06b9 upstream.

The kHz to Hz is incorrectly converted in a few places in the code,
this results in a wrong frequency being calculated because devfreq core
uses OPP frequencies that are given in Hz to clamp the rate, while
tegra-devfreq gives to the core value in kHz and then it also expects to
receive value in kHz from the core. In a result memory freq is always set
to a value which is close to ULONG_MAX because of the bug. Hence the EMC
frequency is always capped to the maximum and the driver doesn't do
anything useful. This patch was tested on Tegra30 and Tegra124 SoC's, EMC
frequency scaling works properly now.

Cc: <stable@vger.kernel.org> # 4.14+
Tested-by: Steev Klimaszewski <steev@kali.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-11 18:20:46 +02:00
Tao Huang
7e2da880c1 include: remove unused rk_fb.h and display-sys.h
Change-Id: I88672a3ebc130e69650f1c12be5ebef410bf20af
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2019-10-08 18:44:07 +08:00
MyungJoo Ham
6437ec272e PM / devfreq: passive: fix compiler warning
[ Upstream commit 0465814831 ]

The recent commit of
PM / devfreq: passive: Use non-devm notifiers
had incurred compiler warning, "unused variable 'dev'".

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-10-05 13:09:59 +02:00
Kamil Konieczny
d51268d757 PM / devfreq: exynos-bus: Correct clock enable sequence
[ Upstream commit 2c2b20e0da ]

Regulators should be enabled before clocks to avoid h/w hang. This
require change in exynos_bus_probe() to move exynos_bus_parse_of()
after exynos_bus_parent_parse_of() and change in error handling.
Similar change is needed in exynos_bus_exit() where clock should be
disabled before regulators.

Signed-off-by: Kamil Konieczny <k.konieczny@partner.samsung.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-10-05 13:09:48 +02:00
Leonard Crestez
7e19b7e0d6 PM / devfreq: passive: Use non-devm notifiers
[ Upstream commit 0ef7c7cce4 ]

The devfreq passive governor registers and unregisters devfreq
transition notifiers on DEVFREQ_GOV_START/GOV_STOP using devm wrappers.

If devfreq itself is registered with devm then a warning is triggered on
rmmod from devm_devfreq_unregister_notifier. Call stack looks like this:

	devm_devfreq_unregister_notifier+0x30/0x40
	devfreq_passive_event_handler+0x4c/0x88
	devfreq_remove_device.part.8+0x6c/0x9c
	devm_devfreq_dev_release+0x18/0x20
	release_nodes+0x1b0/0x220
	devres_release_all+0x78/0x84
	device_release_driver_internal+0x100/0x1c0
	driver_detach+0x4c/0x90
	bus_remove_driver+0x7c/0xd0
	driver_unregister+0x2c/0x58
	platform_driver_unregister+0x10/0x18
	imx_devfreq_platdrv_exit+0x14/0xd40 [imx_devfreq]

This happens because devres_release_all will first remove all the nodes
into a separate todo list so the nested devres_release from
devm_devfreq_unregister_notifier won't find anything.

Fix the warning by calling the non-devm APIS for frequency notification.
Using devm wrappers is not actually useful for a governor anyway: it
relies on the devfreq core to correctly match the GOV_START/GOV_STOP
notifications.

Fixes: 996133119f ("PM / devfreq: Add new passive governor")
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-10-05 13:09:48 +02:00