summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-03-12 18:44:12 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-04-05 14:24:05 -0400
commit182760476dbd1415ef9a6c0c33dba0adc4dde1ef (patch)
treea8f2ef172d16b182f04f8719be34d7c40bdb7d85
parentd8e23112915d185deb534aa777c3f81ad6df5507 (diff)
gpu: nvgpu: De-linuxify pmgr code
The pmgr code is in theory common code. However there were uses of Linux stuff within this code. This patch cleans that up by deleting the unnecessary os_linux.h includes, usage of kfree() and adds several platform fields to the gk20a struct. The platform data is copied to the gk20a struct in the platform initialization code so that this common code can access said data without requiring any knowledge of the OS platform data. JIRA NVGPU-525 Change-Id: Ic4bb6021f60b0a0778779ab5f3e15b7e5ca98306 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1673825 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/linux/pci.c5
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h9
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgrpmu.c13
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrpolicy.c5
4 files changed, 20 insertions, 12 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c
index fe4c0f09..97c4c6bb 100644
--- a/drivers/gpu/nvgpu/common/linux/pci.c
+++ b/drivers/gpu/nvgpu/common/linux/pci.c
@@ -581,6 +581,11 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
581 g->pci_class = (pdev->class >> 8) & 0xFFFFU; // we only want base/sub 581 g->pci_class = (pdev->class >> 8) & 0xFFFFU; // we only want base/sub
582 g->pci_revision = pdev->revision; 582 g->pci_revision = pdev->revision;
583 583
584 g->ina3221_dcb_index = platform->ina3221_dcb_index;
585 g->ina3221_i2c_address = platform->ina3221_i2c_address;
586 g->ina3221_i2c_port = platform->ina3221_i2c_port;
587 g->hardcode_sw_threshold = platform->hardcode_sw_threshold;
588
584#if defined(CONFIG_PCI_MSI) 589#if defined(CONFIG_PCI_MSI)
585 err = pci_enable_msi(pdev); 590 err = pci_enable_msi(pdev);
586 if (err) { 591 if (err) {
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 4a1c2f75..efb425c2 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -1416,6 +1416,15 @@ struct gk20a {
1416 u16 pci_class; 1416 u16 pci_class;
1417 u8 pci_revision; 1417 u8 pci_revision;
1418 1418
1419 /*
1420 * PCI power management: i2c device index, port and address for
1421 * INA3221.
1422 */
1423 u32 ina3221_dcb_index;
1424 u32 ina3221_i2c_address;
1425 u32 ina3221_i2c_port;
1426 bool hardcode_sw_threshold;
1427
1419 /* PCIe power states. */ 1428 /* PCIe power states. */
1420 bool xve_l0s; 1429 bool xve_l0s;
1421 bool xve_l1; 1430 bool xve_l1;
diff --git a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
index ed33c08c..3398e8df 100644
--- a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
+++ b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
@@ -26,8 +26,6 @@
26 26
27#include "gk20a/gk20a.h" 27#include "gk20a/gk20a.h"
28#include "gp106/bios_gp106.h" 28#include "gp106/bios_gp106.h"
29#include "common/linux/os_linux.h"
30#include "common/linux/platform_gk20a.h"
31 29
32#include "boardobj/boardobjgrp.h" 30#include "boardobj/boardobjgrp.h"
33#include "boardobj/boardobjgrp_e32.h" 31#include "boardobj/boardobjgrp_e32.h"
@@ -148,8 +146,7 @@ exit:
148static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g) 146static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g)
149{ 147{
150 struct nv_pmu_pmgr_i2c_device_desc_table i2c_desc_table; 148 struct nv_pmu_pmgr_i2c_device_desc_table i2c_desc_table;
151 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g)); 149 u32 idx = g->ina3221_dcb_index;
152 u32 idx = platform->ina3221_dcb_index;
153 u32 status = 0; 150 u32 status = 0;
154 151
155 /* INA3221 I2C device info */ 152 /* INA3221 I2C device info */
@@ -159,9 +156,9 @@ static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g)
159 i2c_desc_table.devices[idx].super.type = 0x4E; 156 i2c_desc_table.devices[idx].super.type = 0x4E;
160 157
161 i2c_desc_table.devices[idx].dcb_index = idx; 158 i2c_desc_table.devices[idx].dcb_index = idx;
162 i2c_desc_table.devices[idx].i2c_address = platform->ina3221_i2c_address; 159 i2c_desc_table.devices[idx].i2c_address = g->ina3221_i2c_address;
163 i2c_desc_table.devices[idx].i2c_flags = 0xC2F; 160 i2c_desc_table.devices[idx].i2c_flags = 0xC2F;
164 i2c_desc_table.devices[idx].i2c_port = platform->ina3221_i2c_port; 161 i2c_desc_table.devices[idx].i2c_port = g->ina3221_i2c_port;
165 162
166 /* Pass the table down the PMU as an object */ 163 /* Pass the table down the PMU as an object */
167 status = pmgr_pmu_set_object( 164 status = pmgr_pmu_set_object(
@@ -220,7 +217,7 @@ static u32 pmgr_send_pwr_device_topology_to_pmu(struct gk20a *g)
220 status); 217 status);
221 218
222exit: 219exit:
223 kfree(pwr_desc_table); 220 nvgpu_kfree(g, pwr_desc_table);
224 return status; 221 return status;
225} 222}
226 223
@@ -289,7 +286,7 @@ static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g)
289 status); 286 status);
290 287
291exit: 288exit:
292 kfree(pwr_monitor_pack); 289 nvgpu_kfree(g, pwr_monitor_pack);
293 return status; 290 return status;
294} 291}
295 292
diff --git a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
index 420eda4f..2942268f 100644
--- a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
+++ b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
@@ -28,8 +28,6 @@
28#include "boardobj/boardobjgrp.h" 28#include "boardobj/boardobjgrp.h"
29#include "boardobj/boardobjgrp_e32.h" 29#include "boardobj/boardobjgrp_e32.h"
30#include "gp106/bios_gp106.h" 30#include "gp106/bios_gp106.h"
31#include "common/linux/os_linux.h"
32#include "common/linux/platform_gk20a.h"
33 31
34#define _pwr_policy_limitarboutputget_helper(p_limit_arb) (p_limit_arb)->output 32#define _pwr_policy_limitarboutputget_helper(p_limit_arb) (p_limit_arb)->output
35#define _pwr_policy_limitdeltaapply(limit, delta) ((u32)max(((s32)limit) + (delta), 0)) 33#define _pwr_policy_limitdeltaapply(limit, delta) ((u32)max(((s32)limit) + (delta), 0))
@@ -517,7 +515,6 @@ static inline void devinit_unpack_pwr_policy_entry(
517static u32 devinit_get_pwr_policy_table(struct gk20a *g, 515static u32 devinit_get_pwr_policy_table(struct gk20a *g,
518 struct pmgr_pwr_policy *ppwrpolicyobjs) 516 struct pmgr_pwr_policy *ppwrpolicyobjs)
519{ 517{
520 struct gk20a_platform *platform = gk20a_get_platform(dev_from_gk20a(g));
521 u32 status = 0; 518 u32 status = 0;
522 u8 *ptr = NULL; 519 u8 *ptr = NULL;
523 struct boardobj *boardobj; 520 struct boardobj *boardobj;
@@ -690,7 +687,7 @@ static u32 devinit_get_pwr_policy_table(struct gk20a *g,
690 ++obj_index; 687 ++obj_index;
691 } 688 }
692 689
693 if (platform->hardcode_sw_threshold) { 690 if (g->hardcode_sw_threshold) {
694 status = _pwr_policy_construct_WAR_SW_Threshold_policy(g, 691 status = _pwr_policy_construct_WAR_SW_Threshold_policy(g,
695 ppwrpolicyobjs, 692 ppwrpolicyobjs,
696 &pwr_policy_data, 693 &pwr_policy_data,