Commit Graph

24 Commits

Author SHA1 Message Date
Terje Bergstrom
3ba374a5d9 gpu: nvgpu: gk20a: Use new error macro
gk20a_err() and gk20a_warn() require a struct device pointer,
which is not portable across operating systems. The new nvgpu_err()
and nvgpu_warn() macros take struct gk20a pointer. Convert code
to use the more portable macros.

JIRA NVGPU-16

Change-Id: Ia51f36d94c5ce57a5a0ab83b3c83a6bce09e2d5c
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1331694
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
2017-04-10 19:04:19 -07:00
Alex Waterman
335b3fa2fe gpu: nvgpu: Remove vmalloc.h and slab.h usage
Remove all usage of vmalloc.h and slab.h outside of the Linux specific
kmem API implementation code.

Bug 1799159
Bug 1823380

Change-Id: I5b2a91bd1057b272efeaddc24902f6133b35024f
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1331703
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-04-04 16:57:08 -07:00
Terje Bergstrom
f116320137 gpu: nvgpu: Add wrapper for linux/types.h
Add wrapper header nvgpu/types.h. It checks if build is for Linux
kernel and pulls in linux/types.h.

Delete also all #includes for linux/types.h which are not strictly
necessary, and change the remaining ones to use the new wrapper.

JIRA NVGPU-13

Change-Id: I1ddfef0b0b9d840e3e41a62f69c7cb9148d2d5fa
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1453371
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-04-03 14:04:10 -07:00
Alex Waterman
24e1c7e0a7 gpu: nvgpu: Use new kmem API functions (misc)
Use the new kmem API functions in misc gk20a code. Some additional
modifications were also made:

  o  Add a struct gk20a pointer to gk20a_fence to enable proper
     kmem free usage.
  o  Add gk20a pointer to alloc_session() in dbg_gpu_gk20a.c to
     use kmem API for allocating a session.
  o  Plumb a gk20a pointer through the fence creation and deletion.
  o  Use statically allocated buffers for names in file creation.

Bug 1799159
Bug 1823380

Change-Id: I3678080e3ffa1f9bcf6934e3f4819a1bc531689b
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1318323
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-03-30 12:36:09 -07:00
Konsta Holtta
0c45c5fcb6 gpu: nvgpu: delete unused #includes missing in 4.9
Drop old unnecessary references to clock and edp. These headers are not
in kernel-4.9 (yet?). Add proper #ifdefs for #including soctherm.

Bug 1853519

Change-Id: I28e829f78df356e5efcffd9bd985fd736e76d2c0
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1327659
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-03-27 04:45:36 -07:00
Terje Bergstrom
589d6385b1 gpu: nvgpu: Implement get_rate/set_rate as GPU op
Move clock APIs from gk20a_platform to gpu_ops. At the same time
allow use of internal get_rate/set_rate for querying both GPCCLK
and PWRCLK on iGPU.

At the same time we can replace calls to clk framework with the
new HAL and drop direct dependency to clk framework.

gp10b ops were replaced as a whole at HAL initialization. That
replaces anything set in platform probe stage, so reduce that to
touch only clock gating regs.

Change-Id: Iaf219b1f000d362dbf397d45832f52d25463b31c
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1300113
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-03-16 11:48:29 -07:00
Deepak Nibade
d0e3e66885 gpu: nvgpu: compare rounded freq to last value
We right now compare requested value to the last
freq value. Last freq value is always a rounded
value, whereas requested value need not be a
rounded value

Hence it is incorrect to compare requested value
to last freq value

Fix this by comparing rounded value to last_freq

Change-Id: I7c6ea7c4e57105598c9af75efe70016b7fa8038b
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1287360
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2017-01-20 09:45:19 -08:00
Shardar Shariff Md
a470647ad7 gpu: nvgpu: use soc/tegra/chip-id.h for soc header
The soc tegra headers are unified and moved all the content of
linux/tegra-soc.h to the soc/tegra/chip-id.h to have the
single soc header for Tegra.

Change-Id: I281e19dd3eb1538b8dfbea4eb0779fb64d1fcffa
Signed-off-by: Shardar Shariff Md <smohammed@nvidia.com>
Reviewed-on: http://git-master/r/1288365
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
2017-01-20 08:24:01 -08:00
Deepak Nibade
02b8cda953 gpu: nvgpu: store last_freq in gk20a struct
In gk20a_scale_target(), to check for duplicate
freq requests we compare current frequency with
devfreq->previous_freq

But for very first request after boot, we have
devfreq->previous_freq set to MIN freq

And in case we evaluate new frew as MIN freq
then we skip calling postscale() and scaling
of EMC clock
This results in keeping EMC at MAX value

To fix this, add new variable last_freq in
gk20a structure.
Use this variable to store frequency value
and to compare for duplicate requests

Bug 200255163
Bug 200257544

Change-Id: Icfc57234c63f68cce8ccf8221237105272dad853
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1263747
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2016-12-14 12:38:32 -08:00
Sachit Kadle
5494e846c7 gpu: nvgpu: set clk_rate on frequency change
Currently, in gk20a_scale_target, we set clock frequency
even if it is equivalent to the rate previously requested by
the governor. This change adds a check to bypass this in
case new_frequency == prev_frequency.

These clocking operations result in multiple BPMP calls, and add
significant overhead to submit time. So, we avoid these
operations when possible.

Bug 1795076

Change-Id: I0f180564e54581f0f4add4626c647e0b9a1bbe43
Signed-off-by: Sachit Kadle <skadle@nvidia.com>
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1247913
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Aaron Huang <aaronh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-11-16 21:35:22 -08:00
Deepak Nibade
b5c31a23ca gpu: nvgpu: move freq clipping to target function
We right now obtain pm_qos frequency requirments in
qos notifier callback gk20a_scale_qos_notify()

But now we want to limit GPU frequencies based on
frequency limited from devfreq nodes
And devfreq requirement should precede over
qos requirements

Hence, move all frequency estimation and clipping
to function gk20a_scale_target() which sets the
frequency at the end

Bug 200245796

Change-Id: I0572c676dce0acc0917924a11e4c0fb4a9db4e6e
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1243427
(cherry picked from commit 81c757a3232463d126aecba64ca0c55d8e4423d2)
Reviewed-on: http://git-master/r/1239936
Reviewed-by: Aaron Huang <aaronh@nvidia.com>
Tested-by: Aaron Huang <aaronh@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-11-16 21:34:54 -08:00
Deepak Nibade
70cad5fbb5 gpu: nvgpu: unify nvgpu and pci probe
We have completely different versions of probe for
nvgpu and pci device
Extract out common steps into nvgpu_probe() function
and separate it out in new file nvgpu_common.c
Divide task of nvgpu_probe() into further smaller
functions

Do platform specific things (like irq handling,
memresource management, power management) only in
individual probes and then call nvgpu_probe() to
complete the common initialization

Move all debugfs initialization to common gk20a_debug_init()
This also helps to bringup all debug nodes to pci device

Pass debugfs_symlink name as a parameter to gk20a_debug_init()
This allows us to set separate debugfs symlink for nvgpu
and pci device

In case of railgating, cde and ce debugfs, check if
platform supports them or not

Copy vidmem_is_vidmem from platform to mm structure
and set it to true for pci device

Return from gk20a_scale_init() if we don't have either of
governor or qos_notifier

Fix gk20a_alloc_debugfs_init() and gk20a_secure_page_alloc()
to receive device pointer instead of platform_device

Export gk20a_railgating_debugfs_init() so that we can call
it from gk20a_debug_init()

Jira DNVGPU-56
Jira DNVGPU-58

Change-Id: I3cc048082b0a1e57415a9fb8bfb9eec0f0a280cd
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1204207
(cherry picked from commit add6bb0a3d5bd98131bbe6f62d4358d4d722b0fe)
Reviewed-on: http://git-master/r/1204462
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-09-08 09:43:51 -07:00
seshendra Gadagottu
021c23e46e gpu: nvgpu: check for valid function pointers
Before calling prod settings functions, check for
availability of those functions.

Similar check is extended for get_clk_freqs.

Bug 1735760

Change-Id: Ic4b38079043ab2049a479a2d8bb0cb6091e94f4a
Signed-off-by: seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: http://git-master/r/1181571
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
2016-07-25 17:10:03 -07:00
Deepak Nibade
61d4e27607 gpu: nvgpu: add QoS notifier for common clk framework
Define specific QoS notifier for common clk framework
and protect it with CONFIG_COMMON_CLK

This new API will first get min/max requirements from
pm_qos and set min/max freq values in devfreq

A call to update_devfreq() will then ensure that
new estimated frequency is clipped appropriately
between min and max values
This also ensures that frequency is set along with
all the book-keeping

Add below platform specific notifier callback and use it
with pm_qos_add_notifier()
int (*qos_notify)()
If qos_notify is set, then only register the callback

We currently support only one qos_id which is treated
as notifier for min frequency
Remove dependency on qos_id, and use appropriate QoS
APIs like pm_qos_read_min/max_bound()

Store devfreq's min/max frequency in struct gk20a
for reference

Bug 1772462

Change-Id: I63d6d17451d19c9d376b67df7db775b38929287d
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1161161
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-06-27 09:14:04 -07:00
sreenivasulu velpula
abbc813fe3 gpu: nvgpu: add call back for get_cur_freq
When thermal throttling triggers gpcclk clock
changes, devfreq driver need to have call back
for get_cur_freq to get current gpu frequency.

With out this change, "17000000.gp10b/cur_freq"
interface won't show the current gpcclk frequency,
when thermal throttling triggers gpcclk frequency
changes.

Bug 1740309

Change-Id: I2484728094883abc285b2a3808bb2cef26a4ea96
Signed-off-by: sreenivasulu velpula <svelpula@nvidia.com>
Reviewed-on: http://git-master/r/1145912
(cherry picked from commit 0a6ef7b121d1b8aeba42cefa6e8b090b1ccd15e7)
Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: http://git-master/r/1147652
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-06-07 12:05:55 -07:00
Terje Bergstrom
e8bac374c0 gpu: nvgpu: Use device instead of platform_device
Use struct device instead of struct platform_device wherever
possible. This allows adding other bus types later.

Change-Id: I1657287a68d85a542cdbdd8a00d1902c3d6e00ed
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1120466
2016-04-08 09:42:41 -07:00
Deepak Nibade
f28526bb72 gpu: nvgpu: move pmu_load_update() to get_dev_status()
We currently call gk20a_pmu_load_update() before calling
update_devfreq()

But it is possible to disable governor and set a
constant/max frequency.
In that case we will unnecessarily keep executing
gk20a_pmu_load_update() for each submit

Hence. move gk20a_pmu_load_update() to gk20a_scale_get_dev_status()
so that we call gk20a_pmu_load_update() only when we really
have to scale the frequency

Bug 200161377

Change-Id: Ifac5a659a3a2d088b636f048213c2fbec801bdb9
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/929509
(cherry picked from commit f857a1b31400dfc0c35c58c6424aaac36bc09e7c)
Reviewed-on: http://git-master/r/933704
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2016-01-21 08:36:41 -08:00
Deepak Nibade
10f6da09eb gpu: nvgpu: fix Coverity issues
- operands not affecting result (id = 12845)
- logically dead code (id = 12890)
- dereference after null check (id = 12968)
- unsigned compared to 0 (id = 13176)
- resource leak (id = 13338, 18673)
- unused pointer value (id = 13916)

Bug 1703084

Change-Id: I2f401dd93126af27748c53fa1b3a59cb154af36b
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/835143
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
2015-11-25 00:45:58 -08:00
Seshendra Gadagottu
acde16dd16 gpu: nvgpu: scaling driver update
Update scaling driver to support to differnt
clock frameworks.

Bug 200147662

Reviewed-on: http://git-master/r/816929
(cherry picked from commit cbd4cb575fb2d27870089797ff2a8f22540b87e8)

Change-Id: Ie50304b4a593d74bd43b271005cc9616fdb52a6e
Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: http://git-master/r/834748
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
2015-11-19 14:31:49 -08:00
Anders Kugler
f7d7b601ed gpu: nvgpu: 3d.emc frequency scaling
o QoS notifier
  Refresh the gpu load query because we may update the emc target
  if gpu load changed.

o tegra_postscale()
  Scaling the emc clock to a new target may be necessary
  if the gpu load changed at low gpu frequencies.

Bug 1591643

Change-Id: Ibc6f73c02eaf6cedb7f0f579d5f4d90c735d354a
Signed-off-by: Anders Kugler <akugler@nvidia.com>
Reviewed-on: http://git-master/r/680929
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
2015-04-04 19:00:15 -07:00
Konsta Holtta
e99b59d14a gpu: nvgpu: add gk20a_scale_exit()
When removing the module, remove the device from devfreq and free
resources allocated when scaling is initialized.

Bug 1476801

Change-Id: I7bb0f8112a5bf7e5ce2fc56cf8af7059d910002c
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/594444
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2015-03-18 12:12:22 -07:00
Arto Merilainen
b33020008b gpu: nvgpu: Add sw shadow for load value
Reading the load value may increase CPU power consumption
temprorarily. In most cases we are ok with a value that
was read a moment earlier.

This patch introduces a software shadow for gpu load. The shadow
is updated before starting scaling and all scaling code paths use
the sw shadow.

Change-Id: I53d2ccb8e7f83147f411a14d3104d890dd9af9a3
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/453347
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2015-03-18 12:10:45 -07:00
Arto Merilainen
4c7065b558 gpu: nvgpu: Create load sysfs node always
Currently creation of the load sysfs node is bound to devfreq
profile initialisation, however, this information is useful even
if the scaling is not enabled. This patch modifies the code to create
the sysfs node always.

Bug 1485489

Change-Id: Id20433344aa81108f89a36cd56c9a73dd9d2e1c8
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/399474
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2015-03-18 12:09:44 -07:00
Arto Merilainen
a9785995d5 gpu: nvgpu: Add NVIDIA GPU Driver
This patch moves the NVIDIA GPU driver to a new location.

Bug 1482562

Change-Id: I24293810b9d0f1504fd9be00135e21dad656ccb6
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/383722
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
2015-03-18 12:08:53 -07:00