···8383{8484 unsigned long freq;8585 int err = 0;8686+ u32 flags = 0;86878788 if (!mutex_is_locked(&devfreq->lock)) {8889 WARN(true, "devfreq->lock must be locked by the caller.\n");···9594 if (err)9695 return err;97969898- err = devfreq->profile->target(devfreq->dev.parent, &freq);9797+ /*9898+ * Adjust the freuqency with user freq and QoS.9999+ *100100+ * List from the highest proiority101101+ * max_freq (probably called by thermal when it's too hot)102102+ * min_freq103103+ */104104+105105+ if (devfreq->min_freq && freq < devfreq->min_freq) {106106+ freq = devfreq->min_freq;107107+ flags &= ~DEVFREQ_FLAG_LEAST_UPPER_BOUND; /* Use GLB */108108+ }109109+ if (devfreq->max_freq && freq > devfreq->max_freq) {110110+ freq = devfreq->max_freq;111111+ flags |= DEVFREQ_FLAG_LEAST_UPPER_BOUND; /* Use LUB */112112+ }113113+114114+ err = devfreq->profile->target(devfreq->dev.parent, &freq, flags);99115 if (err)100116 return err;101117···643625 * freq value given to target callback.644626 * @dev The devfreq user device. (parent of devfreq)645627 * @freq The frequency given to target function628628+ * @flags Flags handed from devfreq framework.646629 *647630 */648648-struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq)631631+struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq,632632+ u32 flags)649633{650650- struct opp *opp = opp_find_freq_ceil(dev, freq);634634+ struct opp *opp;651635652652- if (opp == ERR_PTR(-ENODEV))636636+ if (flags & DEVFREQ_FLAG_LEAST_UPPER_BOUND) {637637+ /* The freq is an upper bound. opp should be lower */653638 opp = opp_find_freq_floor(dev, freq);639639+640640+ /* If not available, use the closest opp */641641+ if (opp == ERR_PTR(-ENODEV))642642+ opp = opp_find_freq_ceil(dev, freq);643643+ } else {644644+ /* The freq is an lower bound. opp should be higher */645645+ opp = opp_find_freq_ceil(dev, freq);646646+647647+ /* If not available, use the closest opp */648648+ if (opp == ERR_PTR(-ENODEV))649649+ opp = opp_find_freq_floor(dev, freq);650650+ }651651+654652 return opp;655653}656654
+10-4
drivers/devfreq/exynos4_bus.c
···619619 return err;620620}621621622622-static int exynos4_bus_target(struct device *dev, unsigned long *_freq)622622+static int exynos4_bus_target(struct device *dev, unsigned long *_freq,623623+ u32 flags)623624{624625 int err = 0;625625- struct busfreq_data *data = dev_get_drvdata(dev);626626- struct opp *opp = devfreq_recommended_opp(dev, _freq);627627- unsigned long old_freq = opp_get_freq(data->curr_opp);626626+ struct platform_device *pdev = container_of(dev, struct platform_device,627627+ dev);628628+ struct busfreq_data *data = platform_get_drvdata(pdev);629629+ struct opp *opp = devfreq_recommended_opp(dev, _freq, flags);628630 unsigned long freq = opp_get_freq(opp);631631+ unsigned long old_freq = opp_get_freq(data->curr_opp);632632+633633+ if (IS_ERR(opp))634634+ return PTR_ERR(opp);629635630636 if (old_freq == freq)631637 return 0;
+13-3
include/linux/devfreq.h
···4444 void *private_data;4545};46464747+/*4848+ * The resulting frequency should be at most this. (this bound is the4949+ * least upper bound; thus, the resulting freq should be lower or same)5050+ * If the flag is not set, the resulting frequency should be at most the5151+ * bound (greatest lower bound)5252+ */5353+#define DEVFREQ_FLAG_LEAST_UPPER_BOUND 0x15454+4755/**4856 * struct devfreq_dev_profile - Devfreq's user device profile4957 * @initial_freq The operating frequency when devfreq_add_device() is···6254 * higher than any operable frequency, set maximum.6355 * Before returning, target function should set6456 * freq at the current frequency.5757+ * The "flags" parameter's possible values are5858+ * explained above with "DEVFREQ_FLAG_*" macros.6559 * @get_dev_status The device should provide the current performance6660 * status to devfreq, which is used by governors.6761 * @exit An optional callback that is called when devfreq···7666 unsigned long initial_freq;7767 unsigned int polling_ms;78687979- int (*target)(struct device *dev, unsigned long *freq);6969+ int (*target)(struct device *dev, unsigned long *freq, u32 flags);8070 int (*get_dev_status)(struct device *dev,8171 struct devfreq_dev_status *stat);8272 void (*exit)(struct device *dev);···175165176166/* Helper functions for devfreq user device driver with OPP. */177167extern struct opp *devfreq_recommended_opp(struct device *dev,178178- unsigned long *freq);168168+ unsigned long *freq, u32 flags);179169extern int devfreq_register_opp_notifier(struct device *dev,180170 struct devfreq *devfreq);181171extern int devfreq_unregister_opp_notifier(struct device *dev,···226216}227217228218static struct opp *devfreq_recommended_opp(struct device *dev,229229- unsigned long *freq)219219+ unsigned long *freq, u32 flags)230220{231221 return -EINVAL;232222}