]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: Remove ext_stat from scaling
authorArto Merilainen <amerilainen@nvidia.com>
Mon, 10 Feb 2014 09:00:37 +0000 (11:00 +0200)
committerHiroshi Doyu <hdoyu@nvidia.com>
Fri, 21 Feb 2014 07:33:03 +0000 (23:33 -0800)
This far we have delivered minimum frequency, maximum frequency and
the last event type in private_data field for the governor. All these
fields are already available in some other format so it makes no
sense to duplicate this information.

This patch makes necessary modifications to remove dependency to
ext_stat structure.

Bug 1454499

Change-Id: I076aaeb0b9204b810f345ab03b648e238cdab3ff
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/365422
Reviewed-by: Hiroshi Doyu <hdoyu@nvidia.com>
Tested-by: Hiroshi Doyu <hdoyu@nvidia.com>
drivers/video/tegra/host/gk20a/gk20a_scale.c
drivers/video/tegra/host/gr3d/pod_scaling.c
drivers/video/tegra/host/nvhost_scale.c
drivers/video/tegra/host/nvhost_scale.h
include/linux/nvhost.h

index c80b372a43dc1a069c8bd28eb4cb20f175374226..bd58383216e1b9022cc74c142551d645fce0f6e8 100644 (file)
@@ -217,7 +217,7 @@ static void gk20a_scale_notify(struct platform_device *pdev, bool busy)
                return;
 
        mutex_lock(&devfreq->lock);
-       profile->last_event_type = busy ? DEVICE_BUSY : DEVICE_IDLE;
+       profile->dev_stat.busy = busy;
        update_devfreq(devfreq);
        mutex_unlock(&devfreq->lock);
 }
@@ -253,7 +253,6 @@ static int gk20a_scale_get_dev_status(struct device *dev,
        update_load_estimate_gpmu(to_platform_device(dev));
 
        /* Copy the contents of the current device status */
-       profile->ext_stat.busy = profile->last_event_type;
        *stat = profile->dev_stat;
 
        /* Finally, clear out the local values */
@@ -273,6 +272,7 @@ void nvhost_gk20a_scale_init(struct platform_device *pdev)
        struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
        struct nvhost_device_profile *profile;
        struct nvhost_emc_params *emc_params;
+       int err;
 
        if (pdata->power_profile)
                return;
@@ -286,20 +286,13 @@ void nvhost_gk20a_scale_init(struct platform_device *pdev)
        }
 
        profile->pdev = pdev;
-       profile->last_event_type = DEVICE_IDLE;
+       profile->dev_stat.busy = false;
        profile->private_data = emc_params;
 
-       /* Initialize devfreq related structures */
-       profile->dev_stat.private_data = &profile->ext_stat;
-       profile->ext_stat.min_freq = gk20a_clk_round_rate(g, 0);
-       profile->ext_stat.max_freq = gk20a_clk_round_rate(g, UINT_MAX);
-       profile->ext_stat.busy = DEVICE_IDLE;
-
-       if (profile->ext_stat.min_freq == profile->ext_stat.max_freq) {
-               dev_warn(&pdev->dev, "max rate = min rate (%lu), disabling scaling\n",
-                        profile->ext_stat.min_freq);
-               goto err_fetch_clocks;
-       }
+       /* Create frequency table */
+       err = nvhost_scale_make_freq_table(profile);
+       if (err || !profile->devfreq_profile.max_state)
+               goto err_get_freqs;
 
        nvhost_scale3d_calibrate_emc(emc_params,
                                     gk20a_clk_get(g), pdata->clk[2],
@@ -314,16 +307,12 @@ void nvhost_gk20a_scale_init(struct platform_device *pdev)
 
        if (pdata->devfreq_governor) {
                struct devfreq *devfreq;
-               int err;
 
                profile->devfreq_profile.initial_freq =
-                       profile->ext_stat.min_freq;
+                       profile->devfreq_profile.freq_table[0];
                profile->devfreq_profile.target = gk20a_scale_target;
                profile->devfreq_profile.get_dev_status =
                        gk20a_scale_get_dev_status;
-               err = nvhost_scale_make_freq_table(profile);
-               if (err)
-                       goto err_get_freqs;
 
                devfreq = devfreq_add_device(&pdev->dev,
                                        &profile->devfreq_profile,
@@ -349,7 +338,6 @@ void nvhost_gk20a_scale_init(struct platform_device *pdev)
 err_get_freqs:
        device_remove_file(&pdev->dev, &dev_attr_load);
 err_create_sysfs_entry:
-err_fetch_clocks:
        kfree(pdata->power_profile);
        pdata->power_profile = NULL;
 }
index 906212ce82da388cb086d16e1084544544798352..67faac916cae66886fc96a3efcaf26c1ae286291 100644 (file)
@@ -546,7 +546,7 @@ static void podgov_idle_handler(struct work_struct *work)
                return;
        }
 
-       if (podgov->last_event_type == DEVICE_IDLE &&
+       if (!podgov->last_event_type &&
            df->previous_freq > df->min_freq &&
            podgov->p_user == false)
                notify_idle = 1;
@@ -821,8 +821,6 @@ static int nvhost_pod_estimate_freq(struct devfreq *df,
 {
        struct podgov_info_rec *podgov = df->data;
        struct devfreq_dev_status dev_stat;
-       struct nvhost_devfreq_ext_stat *ext_stat;
-       int current_event;
        int stat;
        ktime_t now;
 
@@ -841,7 +839,6 @@ static int nvhost_pod_estimate_freq(struct devfreq *df,
                return 0;
        }
 
-       current_event = DEVICE_IDLE;
        stat = 0;
        now = ktime_get();
 
@@ -867,18 +864,10 @@ static int nvhost_pod_estimate_freq(struct devfreq *df,
                return 0;
        }
 
-       /* Retrieve extended data */
-       ext_stat = dev_stat.private_data;
-       if (!ext_stat)
-               return -EINVAL;
-
-       current_event = ext_stat->busy;
        *freq = dev_stat.current_frequency;
-       df->min_freq = ext_stat->min_freq;
-       df->max_freq = ext_stat->max_freq;
 
        /* Sustain local variables */
-       podgov->last_event_type = current_event;
+       podgov->last_event_type = dev_stat.busy;
        podgov->idle = 1000 * (dev_stat.total_time - dev_stat.busy_time);
        podgov->idle = podgov->idle / dev_stat.total_time;
        podgov->idle_avg = (podgov->p_smooth * podgov->idle_avg) +
@@ -890,18 +879,14 @@ static int nvhost_pod_estimate_freq(struct devfreq *df,
                ktime_us_delta(now, podgov->last_throughput_hint) < 1000000)
                return GET_TARGET_FREQ_DONTSCALE;
 
-       switch (current_event) {
-
-       case DEVICE_IDLE:
+       if (dev_stat.busy) {
+               cancel_delayed_work(&podgov->idle_timer);
+               *freq = scaling_state_check(df, now);
+       } else {
                /* Launch a work to slowdown the gpu */
                *freq = scaling_state_check(df, now);
                schedule_delayed_work(&podgov->idle_timer,
                        msecs_to_jiffies(podgov->p_slowdown_delay));
-               break;
-       case DEVICE_BUSY:
-               cancel_delayed_work(&podgov->idle_timer);
-               *freq = scaling_state_check(df, now);
-               break;
        }
 
        if (!(*freq) ||
@@ -930,7 +915,6 @@ static int nvhost_pod_init(struct devfreq *df)
        enum tegra_chipid cid = tegra_get_chipid();
        int error = 0;
 
-       struct nvhost_devfreq_ext_stat *ext_stat;
        struct devfreq_dev_status dev_stat;
        int stat = 0;
 
@@ -993,17 +977,6 @@ static int nvhost_pod_init(struct devfreq *df)
 
        /* Get the current status of the device */
        stat = df->profile->get_dev_status(df->dev.parent, &dev_stat);
-       if (!dev_stat.private_data) {
-               pr_err("podgov: device does not support ext_stat.\n");
-               goto err_get_current_status;
-       }
-       ext_stat = dev_stat.private_data;
-
-       /* store the limits */
-       df->min_freq = ext_stat->min_freq;
-       df->max_freq = ext_stat->max_freq;
-
-       podgov->p_freq_request = ext_stat->max_freq;
 
        /* Create sysfs entries for controlling this governor */
        error = device_create_file(&d->dev,
@@ -1026,6 +999,11 @@ static int nvhost_pod_init(struct devfreq *df)
        if (!podgov->freq_count || !podgov->freqlist)
                goto err_get_freqs;
 
+       /* store the limits */
+       df->min_freq = podgov->freqlist[0];
+       df->max_freq = podgov->freqlist[podgov->freq_count - 1];
+       podgov->p_freq_request = df->max_freq;
+
        podgov->idle_avg = 0;
        podgov->freq_avg = 0;
        podgov->hint_avg = 0;
@@ -1048,7 +1026,6 @@ err_get_freqs:
        device_remove_file(&d->dev, &dev_attr_freq_request);
 err_create_sysfs_entry:
        dev_err(&d->dev, "failed to create sysfs attributes");
-err_get_current_status:
 err_unsupported_chip_id:
        kfree(podgov);
 err_alloc_podgov:
index b916ac6ea0bd7e5e0e7dad6d132b1e5e15db9191..4129c566c92c995ca0bca24d6f3b0bd68d3c9f7a 100644 (file)
@@ -107,7 +107,7 @@ static int nvhost_scale_target(struct device *dev, unsigned long *freq,
        struct nvhost_device_profile *profile = pdata->power_profile;
 
        if (!tegra_is_clk_enabled(profile->clk)) {
-               *freq = profile->ext_stat.min_freq;
+               *freq = profile->devfreq_profile.freq_table[0];
                return 0;
        }
 
@@ -235,7 +235,7 @@ static void nvhost_scale_notify(struct platform_device *pdev, bool busy)
        mutex_lock(&devfreq->lock);
        if (!profile->actmon)
                update_load_estimate(profile, busy);
-       profile->last_event_type = busy ? DEVICE_BUSY : DEVICE_IDLE;
+       profile->dev_stat.busy = busy;
        update_devfreq(devfreq);
        mutex_unlock(&devfreq->lock);
 }
@@ -270,7 +270,6 @@ static int nvhost_scale_get_dev_status(struct device *dev,
                update_load_estimate_actmon(profile);
 
        /* Copy the contents of the current device status */
-       profile->ext_stat.busy = profile->last_event_type;
        *stat = profile->dev_stat;
 
        /* Finally, clear out the local values */
@@ -288,6 +287,7 @@ void nvhost_scale_init(struct platform_device *pdev)
 {
        struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
        struct nvhost_device_profile *profile;
+       int err;
 
        if (pdata->power_profile)
                return;
@@ -298,21 +298,12 @@ void nvhost_scale_init(struct platform_device *pdev)
        pdata->power_profile = profile;
        profile->pdev = pdev;
        profile->clk = pdata->clk[0];
-       profile->last_event_type = DEVICE_IDLE;
-
-       /* Initialize devfreq related structures */
-       profile->dev_stat.private_data = &profile->ext_stat;
-       profile->ext_stat.min_freq =
-               clk_round_rate(clk_get_parent(profile->clk), 0);
-       profile->ext_stat.max_freq =
-               clk_round_rate(clk_get_parent(profile->clk), UINT_MAX);
-       profile->ext_stat.busy = DEVICE_IDLE;
-
-       if (profile->ext_stat.min_freq == profile->ext_stat.max_freq) {
-               dev_warn(&pdev->dev, "max rate = min rate (%lu), disabling scaling\n",
-                        profile->ext_stat.min_freq);
-               goto err_fetch_clocks;
-       }
+       profile->dev_stat.busy = false;
+
+       /* Create frequency table */
+       err = nvhost_scale_make_freq_table(profile);
+       if (err || !profile->devfreq_profile.max_state)
+               goto err_get_freqs;
 
        /* Initialize actmon */
        if (pdata->actmon_enabled) {
@@ -337,16 +328,12 @@ void nvhost_scale_init(struct platform_device *pdev)
 
        if (pdata->devfreq_governor) {
                struct devfreq *devfreq;
-               int err;
 
                profile->devfreq_profile.initial_freq =
-                       profile->ext_stat.min_freq;
+                       profile->devfreq_profile.freq_table[0];
                profile->devfreq_profile.target = nvhost_scale_target;
                profile->devfreq_profile.get_dev_status =
                        nvhost_scale_get_dev_status;
-               err = nvhost_scale_make_freq_table(profile);
-               if (err)
-                       goto err_get_freqs;
 
                devfreq = devfreq_add_device(&pdev->dev,
                                        &profile->devfreq_profile,
@@ -373,7 +360,6 @@ err_get_freqs:
 err_allocate_actmon:
        device_remove_file(&pdev->dev, &dev_attr_load);
 err_create_sysfs_entry:
-err_fetch_clocks:
        kfree(pdata->power_profile);
        pdata->power_profile = NULL;
 }
index 5a74bd6c9b0fd92693a138c80aea7966597e38cf..95ac5891fc1dcf203bd6ca677a29789b1f7baa90 100644 (file)
@@ -39,11 +39,9 @@ struct nvhost_device_profile {
 
        bool                            busy;
        ktime_t                         last_event_time;
-       enum nvhost_devfreq_busy        last_event_type;
 
        struct devfreq_dev_profile      devfreq_profile;
        struct devfreq_dev_status       dev_stat;
-       struct nvhost_devfreq_ext_stat  ext_stat;
 
        void                            *private_data;
        struct notifier_block           qos_notify_block;
index 5d12ee1041064429b38352499960c51c8016fcd0..7a2a1930898f9b2e30824bc5b664c43d5d80db3f 100644 (file)
@@ -251,17 +251,6 @@ struct nvhost_device_data *nvhost_get_devdata(struct platform_device *pdev)
        return (struct nvhost_device_data *)platform_get_drvdata(pdev);
 }
 
-enum nvhost_devfreq_busy {
-       DEVICE_IDLE = 0,
-       DEVICE_BUSY = 1
-};
-
-struct nvhost_devfreq_ext_stat {
-       enum nvhost_devfreq_busy        busy;
-       unsigned long                   max_freq;
-       unsigned long                   min_freq;
-};
-
 struct nvhost_device_power_attr {
        struct platform_device *ndev;
        struct kobj_attribute power_attr[NVHOST_POWER_SYSFS_ATTRIB_MAX];