Merge tag 'MMI-W1UQ36H.73-28' of https://github.com/MotorolaMobilityLLC/kernel-msm into lineage-23.2

"Paros push for Android 16"

* tag 'MMI-W1UQ36H.73-28' of https://github.com/MotorolaMobilityLLC/kernel-msm:
  ufs:qcom:add vendor-specific hook to revert the CP1 flag for Longsys devices
  dwc3: add gsi endpoint config
  Decreasing auto-suspend delay of GPU buffers exists
  fps:add client id in panel notifier
  arm64/config: enable Samsung/Micron UFS HID feature
  paros: disable CONFIG_SCSI_UFS_HID
  : add fpc1020_mmi.ko to blocklist
  ufs: foresee ufs can't bootup
  initial paros base on paro
  Revert "(CR): usb: powerup host ss only when ss device attached"
  usb: powerup host ss only when ss device attached
  [Cusco/Cuscoi]update fsa4480 default value to solve the USB not recognition problem
  reset fsa4480 when shutdown
  fsa4480 add reset in probe
  open fsa4480 debug log
  : add anc_fps_mmi.ko to blocklist
  enable moto sched
  fix Cuscoi initial build error
  cusco initial bringup
  smp2p: the smp2p notify send from AP not received by wlan fw
  wireless charge:fw update process changed
  arm64/config: enabel Hynix ufs HID feature.
  arm64/config: enabel Micron ufs HID feature.
  config:ufs config samsung UFS HID feature
  ufs: add Hynix HID driver
  ufs: add Micron HID driver
  ufs:support HID feature on samsung UFS
  Optimize user debug performance.
  haptics: preloaded haptics effects not match
  usb: add dwc3 setting redriver DP-EQ API
  haptics: set default f0 if kernel calibration failed
  haptic: add debug func for haptic
  build: support different in_tree_modules config in different product
  mmc: when formatting 1tb sd card the machine maybe crash.
  defconfig: add project config for monai(sm7435)
  [11/12]:enable moto sched on android15-6.6 kerenl
  [9/12]: remove moto_sched changes when disabled
  [8/12]: disable walt mutex lock hooks
  [7/12]: Optimize cpu selection in walt
  [6/12]:Optimize moto sched in walt
  [5/12]:Moto sched add task enqueue & dequeue hook
  [4/12]:The macro is for moto schedluer changes.
  [3/12]:optimize scheduling in walt
  [2/12]:refactor scheduling optimization in walt
  [1/12]:implement ux aware scheduling on walt
  bootconfig:remove serial console property
  qcom wdog: delay wdog bark time interval
  blocklist:add watchdogtest
  USB: add adb force enable logic
  dwc3: don't call dwc3_msm_resume() when exit LPM
  Add HS phy init sequence dtsi for Host
  Revert "(CR): Store moto extra restart reason"
  arm64/config: fix factory build error
  Disable reboot to EDL mode
  perf:user-debug:disable needless modules
  Add debug recovery panic
  Add nanosecond unit in power key log.
  power: reset: qcom-dload-mode: Disable RAM dump by default
  8750:ssr: expand ssr_reason for subsystem_ramdump
  power:sysfs Enable the sysfs /sys/private for debugging
  pwrkey: Print system timestamp on Power key event
  power: reset: qcom-dload-mode: Support configurable dload mode
  Store moto extra restart reason
  Add system restart panic mode
  Remove qc mem offline driver.
  minidump: enable default BOTHDUMP mode
  kconfig: kernel variant in user version uses perf variant
  blocklist:Add fps module for parrot
  charge:fixed battery power supply prop abnormal issue
  power: pinctrl Add function to show or change GPIOs
  suspend: Print subsystem stats in kernel log
  usb: add repeater parameter update log
  dwc3-msm-core: Enable debug log for usb issue analysis
  Add redriver ps5169 to the new redriver frameworks
  support debugfs for ssphy tune register change
  Initialize the USB role during dwc3_msm probe
  power:sysfs Add sysfs /sys/private
  power: regulator Add function to show regulators
  arm64: defconfig: Enable qcom-hv-haptics for parrot
  qcom-haptics: add sysfs node to enable vibrator
  qcom-haptics: add debug log
  charge:solve build err after rebase
  charger: add kernel api for charger qnovo function
  Wrangler: modify qti_battry_charger
  Wrangle: modify the qti_battry_charger
  qti_battery_charger: Add tbatt_filter function
  charging: optimize set charge current api
  drivers/power/supply: Get the correct fw_version
  battery: add setting cycle count power supply
  wireless: Support wireless firmware update
  wlc: adjust fw size judgment
  Wirless charge: Change battery SOC threshold
  add charge counter prop for dual battery
  Use the main battery voltage as combo battery voltage
  Read battery properties from combo battery supply
  Fix the glink timeout issue on read property
  qti_battery_charger: support cps4035 fw programmer
  defconfig: add project config for paro(sm6450)
  defconfig: add project config for mona(sm6475)
  defconfig: add project config for paros
  Kconfig: add moto kenrel config base
  build: apply to moto defconfig fragment
  build_with_bazel.py: support only build abl target

Change-Id: If7937d0689acb8512503701f88c7d7a273dd8e81
This commit is contained in:
Nick Reuter 2026-07-01 14:53:58 -05:00
commit 8132abbc80
71 changed files with 9318 additions and 97 deletions

1
.bazelignore Normal file
View file

@ -0,0 +1 @@
common/.kunit

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,5 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#

View file

@ -0,0 +1,5 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#

View file

@ -0,0 +1,5 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#

View file

@ -0,0 +1,6 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#
CONFIG_SUSPEND_DEBUG=m

View file

@ -0,0 +1,6 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#

View file

@ -0,0 +1,11 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#
CONFIG_CUSCO_DTB=y
CONFIG_UFSFEATURE=y
CONFIG_UFSHID=y
CONFIG_MICRON_UFSHID=y
CONFIG_SCSI_SKHID=y
CONFIG_SCHED_MOTO_UNFAIR=m

View file

@ -0,0 +1,11 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#
CONFIG_CUSCO_DTB=y
CONFIG_UFSFEATURE=y
CONFIG_UFSHID=y
CONFIG_MICRON_UFSHID=y
CONFIG_SCSI_SKHID=y
CONFIG_SCHED_MOTO_UNFAIR=m

View file

@ -0,0 +1,6 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#

View file

@ -0,0 +1,11 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#
CONFIG_MONA_DTB=y
CONFIG_SCHED_MOTO_UNFAIR=m
CONFIG_UFSFEATURE=y
CONFIG_UFSHID=y
CONFIG_MICRON_UFSHID=y
CONFIG_SCSI_SKHID=y

View file

@ -0,0 +1,11 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#
CONFIG_MONAI_DTB=y
CONFIG_SCHED_MOTO_UNFAIR=m
CONFIG_UFSFEATURE=y
CONFIG_UFSHID=y
CONFIG_MICRON_UFSHID=y
CONFIG_SCSI_SKHID=y

View file

@ -0,0 +1,7 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#
CONFIG_PARO_DTB=y

View file

@ -0,0 +1,14 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#
CONFIG_PAROS_DTB=y
CONFIG_UFSFEATURE=y
CONFIG_UFSHID=y
CONFIG_MICRON_UFSHID=y
CONFIG_SCSI_SKHID=y
CONFIG_SCHED_MOTO_UNFAIR=m
# Motorola fix Longsys UFS CP0 Timeout Issue Support.
CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT=y

View file

@ -0,0 +1,6 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#

View file

@ -0,0 +1,7 @@
#
# Please avoid changing the Qualcomm defconfig files and use this file to
# add any Motorola-specific configuration changes that are applicable to
# userdebug, eng, and user builds.
#
CONFIG_MMI_DEVICE_DTBS=y

View file

@ -1,10 +1,9 @@
CONFIG_ARM_SMMU_SELFTEST=y
CONFIG_ATOMIC64_SELFTEST=m
CONFIG_CMA_DEBUG=y
# CONFIG_CMA_DEBUG is not set
CONFIG_CMA_DEBUGFS=y
CONFIG_CORESIGHT_SOURCE_ETM4X=m
CONFIG_DEBUG_PAGEALLOC=y
CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y
# CONFIG_CORESIGHT_SOURCE_ETM4X is not set
# CONFIG_DEBUG_PAGEALLOC is not set
CONFIG_DEBUG_SPINLOCK=y
CONFIG_DETECT_HUNG_TASK=y
CONFIG_LKDTM=m
@ -17,7 +16,7 @@ CONFIG_QTI_PMIC_GLINK_CLIENT_DEBUG=y
CONFIG_RCU_TORTURE_TEST=m
CONFIG_REGMAP_QTI_DEBUGFS_ALLOW_WRITE=y
CONFIG_RUNTIME_TESTING_MENU=y
CONFIG_SCHED_WALT_DEBUG=m
# CONFIG_SCHED_WALT_DEBUG is not set
CONFIG_SDHCI_MSM_DBG=y
CONFIG_TEST_USER_COPY=m
CONFIG_UFS_DBG=y

View file

@ -58,6 +58,7 @@ CONFIG_HVC_GUNYAH=m
CONFIG_HWSPINLOCK_QCOM=m
CONFIG_I2C_MSM_GENI=m
CONFIG_INPUT_PM8941_PWRKEY=m
CONFIG_INPUT_QCOM_HV_HAPTICS=m
CONFIG_INPUT_QPNP_POWER_ON=m
CONFIG_INTERCONNECT_QCOM_BCM_VOTER=m
CONFIG_INTERCONNECT_QCOM_DEBUG=m
@ -162,7 +163,7 @@ CONFIG_QCOM_MEM_BUF_DEV=m
CONFIG_QCOM_MEM_BUF_DEV_GH=y
CONFIG_QCOM_MEM_BUF_GH=y
CONFIG_QCOM_MEM_BUF_MSGQ=m
CONFIG_QCOM_MEM_OFFLINE=m
# CONFIG_QCOM_MEM_OFFLINE is not set
CONFIG_QCOM_MINIDUMP=m
CONFIG_QCOM_MINIDUMP_FTRACE=y
CONFIG_QCOM_MINIDUMP_PANIC_CPUFREQ_INFO=y
@ -212,7 +213,7 @@ CONFIG_QCOM_VADC_COMMON=m
CONFIG_QCOM_VA_MINIDUMP=m
CONFIG_QCOM_VM_ALIVE_LOG_DUMPER=y
CONFIG_QCOM_VM_DMESG_DUMPER=m
CONFIG_QCOM_WATCHDOG_BARK_TIME=11000
CONFIG_QCOM_WATCHDOG_BARK_TIME=16000
CONFIG_QCOM_WATCHDOG_IPI_PING=y
CONFIG_QCOM_WATCHDOG_PET_TIME=9360
# CONFIG_QCOM_WATCHDOG_USERSPACE_PET is not set

1
build.config.moto Normal file
View file

@ -0,0 +1 @@
apply_defconfig_fragment ${KERNEL_DIR}/arch/${ARCH}/configs/vendor/ext_config/moto_fragment.config

View file

@ -31,3 +31,4 @@ KERNEL_VENDOR_CMDLINE+=' bootconfig '
## Inheriting MSM configs
. "${KERNEL_DIR}"/build.config.msm.common
. "${KERNEL_DIR}"/build.config.msm.perf
. "${KERNEL_DIR}"/build.config.moto

View file

@ -62,7 +62,7 @@ class Target:
class BazelBuilder:
"""Helper class for building with Bazel"""
def __init__(self, target_list, skip_list, out_dir, cache_dir, dry_run, gki_headers, user_opts):
def __init__(self, target_list, skip_list, out_dir, cache_dir, dry_run, gki_headers, user_opts, abl_only):
BazelBuilder.targets_done = []
self.workspace = os.path.realpath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
@ -86,6 +86,7 @@ class BazelBuilder:
self.dry_run = dry_run
self.gki_headers = gki_headers
self.user_opts = user_opts
self.abl_only = abl_only
self.process_list = []
if len(self.target_list) > 1 and out_dir:
logging.error("cannot specify multiple targets with one out dir")
@ -187,7 +188,9 @@ class BazelBuilder:
for label in label_list:
if any((skip_re.match(label) for skip_re in skip_list_re)):
continue
if self.abl_only and re.search(r"_abl_dist", label) is None:
logging.info("force to skip target label: [%s]" , label)
continue
if v == "ALL":
real_variant = re.search(
r"//{}:[^_]*_([^_]+)_".format(self.kernel_dir), label
@ -488,6 +491,12 @@ def main():
action="store_true",
help="Run menuconfig for <target>-<variant> and exit without building",
)
parser.add_argument(
"-a",
"--abl_only",
action="store_true",
help="only build abl target and skip all other non abl targets",
)
parser.add_argument(
"-d",
"--dry-run",
@ -523,7 +532,8 @@ def main():
args.cache_dir,
args.dry_run,
args.gki_headers,
user_opts
user_opts,
args.abl_only
)
try:
if args.menuconfig:

View file

@ -17,6 +17,7 @@
#include <linux/platform_device.h>
#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/time64.h>
#define PON_REV2 0x01
@ -150,7 +151,20 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data)
struct pm8941_pwrkey *pwrkey = _data;
unsigned int sts;
int err;
struct timespec64 timestamp;
struct tm tm;
char buff[255];
/* get the time stamp in readable format to print*/
ktime_get_real_ts64(&timestamp);
time64_to_tm(timestamp.tv_sec, 0, &tm);
snprintf(buff, sizeof(buff),
"%u-%02d-%02d %02d:%02d:%02d.%06ld UTC",
(int) tm.tm_year + 1900, tm.tm_mon + 1,
tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
timestamp.tv_nsec);
pr_info("Enter %s at: %s\n", __func__, buff);
if (pwrkey->sw_debounce_time_us) {
if (ktime_before(ktime_get(), pwrkey->sw_debounce_end_time)) {
dev_dbg(pwrkey->dev,
@ -165,6 +179,8 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data)
return IRQ_HANDLED;
sts &= pwrkey->data->status_bit;
pr_info("pwrkey->code=%d, pwrkey->last_status=0x%02X, sts=0x%02X\n", pwrkey->code,
pwrkey->last_status, sts);
if (pwrkey->sw_debounce_time_us && !sts)
pwrkey->sw_debounce_end_time = ktime_add_us(ktime_get(),

View file

@ -221,6 +221,7 @@ static ssize_t fifo_s_dbgfs_read(struct file *fp, char __user *buf, size_t count
return rc;
}
u8 samples_dbg[MMAP_FIFO_LEN_PER_LSB];
static ssize_t fifo_s_dbgfs_write(struct file *fp,
const char __user *buf, size_t count, loff_t *ppos)
{
@ -229,7 +230,6 @@ static ssize_t fifo_s_dbgfs_write(struct file *fp,
char *str, *kbuf, *token;
int rc, i = 0;
int val;
u8 *samples;
kbuf = kzalloc(count + 1, GFP_KERNEL);
if (!kbuf)
@ -245,12 +245,6 @@ static ssize_t fifo_s_dbgfs_write(struct file *fp,
str[count] = '\0';
*ppos += count;
samples = kcalloc(fifo->num_s, sizeof(*samples), GFP_KERNEL);
if (!samples) {
rc = -ENOMEM;
goto exit;
}
while ((token = strsep(&str, " ")) != NULL) {
rc = kstrtoint(token, 0, &val);
if (rc < 0) {
@ -261,13 +255,13 @@ static ssize_t fifo_s_dbgfs_write(struct file *fp,
if (val > 0xff)
val = 0xff;
samples[i++] = (u8)val;
/* only support fifo pattern no longer than before */
if (i >= fifo->num_s)
samples_dbg[i++] = (u8)val;
if (i >= MMAP_FIFO_LEN_PER_LSB)
break;
}
memcpy(fifo->samples, samples, fifo->num_s);
fifo->samples = samples_dbg;
fifo->num_s = i;
fifo->play_length_us = get_fifo_play_length_us(fifo, effect->t_lra_us);
if (fifo->play_length_us == -EINVAL) {
pr_err("get fifo play length failed\n");
@ -277,7 +271,6 @@ static ssize_t fifo_s_dbgfs_write(struct file *fp,
rc = count;
exit2:
kfree(samples);
exit:
kfree(kbuf);
return rc;

View file

@ -491,6 +491,11 @@
#define is_between(val, min, max) \
(((min) <= (max)) && ((min) <= (val)) && ((val) <= (max)))
/*
* rc_clk_cal_count default value if caliration failed and dts not set
* this value get from haptics_get_closeloop_lra_period()
*/
#define LRA_F0_CAL_COUNT 0x244
enum hap_status_sel {
CAL_TLRA_CL_STS = 0x00,
@ -1260,6 +1265,7 @@ static int haptics_get_closeloop_lra_period(
HAP_STATUS_DATA_MSB_SDAM_OFFSET, rc);
return rc;
}
dev_info(chip->dev, "read calibration result from SDAM 0x%x, 0x%x\n", val[0], val[1]);
} else {
rc = haptics_get_status_data(chip, CAL_TLRA_CL_STS, val);
if (rc < 0)
@ -1386,7 +1392,7 @@ static int haptics_get_closeloop_lra_period(
chip->config.rc_clk_cal_count = 0;
}
dev_dbg(chip->dev, "OL_TLRA %u us, CL_TLRA %u us, RC_CLK_CAL_COUNT %#x\n",
dev_info(chip->dev, "OL_TLRA %u us, CL_TLRA %u us, RC_CLK_CAL_COUNT %#x\n",
chip->config.t_lra_us, chip->config.cl_t_lra_us,
chip->config.rc_clk_cal_count);
return 0;
@ -2751,7 +2757,8 @@ static int haptics_load_predefined_effect(struct haptics_chip *chip,
return rc;
pat_sel_mmap = &chip->mmap.pat_sel_mmap[effect->pat_sel];
length = pat_sel_mmap->length /
//length = pat_sel_mmap->length /
length = play->effect->fifo->num_s /
chip->mmap.hw_info.pat_mem_play_step;
addr = pat_sel_mmap->start_addr / HAP530_MMAP_PAT_LEN_PER_LSB;
val[0] = addr & HAP_PTN_PATX_MEM_LEN_LO_MASK;
@ -3022,7 +3029,7 @@ static int haptics_load_periodic_effect(struct haptics_chip *chip,
}
play->vmax_mv = (magnitude * effects[i].vmax_mv) / 0x7fff;
dev_dbg(chip->dev, "upload %s effect %d, vmax=%d\n", primitive ? "primitive" : "predefined",
dev_info(chip->dev, "upload %s effect %d, vmax=%d\n", primitive ? "primitive" : "predefined",
effects[i].id, play->vmax_mv);
rc = haptics_load_predefined_effect(chip, &effects[i]);
@ -3879,6 +3886,10 @@ static int haptics_init_lra_period_config(struct haptics_chip *chip)
/* get calibrated close loop period */
t_lra_us = chip->config.t_lra_us;
if (t_lra_us != 0) {
dev_info(chip->dev, "show lra frequency %ld Hz\n", USEC_PER_SEC / t_lra_us);
}
rc = haptics_get_closeloop_lra_period(chip, true);
if (!rc && chip->config.cl_t_lra_us != 0)
t_lra_us = chip->config.cl_t_lra_us;
@ -4376,6 +4387,7 @@ static int haptics_parse_effect_fifo_data(struct haptics_chip *chip,
return rc;
}
effect->t_lra_us = config->t_lra_us;
effect->fifo->num_s = tmp;
effect->fifo->period_per_s = T_LRA;
rc = of_property_read_u32(node, "qcom,wf-fifo-period", &tmp);
@ -5963,6 +5975,53 @@ static int haptics_start_auto_brake_calibration(struct haptics_chip *chip)
return haptics_auto_brake_pbs_trigger(chip);
}
static int haptics_start_play(struct haptics_chip *chip, bool enable)
{
int rc;
u8 amplitude;
u32 vmax_mv = chip->config.vmax_mv;
mutex_lock(&chip->play.lock);
if (enable) {
/* Stop other mode playing if there is any */
rc = haptics_enable_play(chip, false);
if (rc < 0) {
dev_err(chip->dev, "Stop playing failed, rc=%d\n", rc);
goto unlock;
}
rc = haptics_set_vmax_mv(chip, vmax_mv);
if (rc < 0)
goto unlock;
amplitude = get_direct_play_max_amplitude(chip);
rc = haptics_set_direct_play(chip, amplitude);
if (rc < 0)
goto unlock;
rc = haptics_enable_hpwr_vreg(chip, true);
if (rc < 0)
goto unlock;
chip->play.pattern_src = DIRECT_PLAY;
rc = haptics_enable_play(chip, true);
if (rc < 0)
goto unlock;
mutex_unlock(&chip->play.lock);
return rc;
}
unlock:
/* Disable play in case it's not been disabled */
haptics_enable_play(chip, false);
rc = haptics_enable_hpwr_vreg(chip, false);
mutex_unlock(&chip->play.lock);
return rc;
}
static int haptics_start_lra_calibrate(struct haptics_chip *chip)
{
int rc;
@ -6168,12 +6227,38 @@ static ssize_t i_gain_error_show(const struct class *c,
}
static const CLASS_ATTR_RO(i_gain_error);
static ssize_t enable_play_store(const struct class *c,
const struct class_attribute *attr, const char *buf, size_t count)
{
struct haptics_chip *chip = container_of(c,
struct haptics_chip, hap_class);
int val;
int rc;
if (kstrtoint(buf, 0, &val))
return -EINVAL;
if (val) {
rc = haptics_start_play(chip, true);
if (rc < 0)
return rc;
} else {
rc = haptics_start_play(chip, false);
if (rc < 0)
return rc;
}
return count;
}
static CLASS_ATTR_WO(enable_play);
static struct attribute *hap_class_attrs[] = {
&class_attr_lra_calibration.attr,
&class_attr_lra_frequency_hz.attr,
&class_attr_lra_impedance.attr,
&class_attr_primitive_duration.attr,
&class_attr_visense_enabled.attr,
&class_attr_enable_play.attr,
NULL,
};
ATTRIBUTE_GROUPS(hap_class);
@ -6444,6 +6529,54 @@ static int haptics_probe(struct platform_device *pdev)
haptics_runtime_autosuspend(chip);
phapchip = chip;
if (of_property_read_bool(chip->dev->of_node, "moto,cal_again")) {
u32 t_lra_us_min, t_lra_us_max, f0_cal_count;
u32 cl_f_lra = USEC_PER_SEC / chip->config.cl_t_lra_us;
dev_err(chip->dev, "In XBL cal F0 is %d Hz\n", cl_f_lra);
rc = of_property_read_u32(chip->dev->of_node, "moto,lra-period-us-min", &t_lra_us_min);
if (rc < 0) {
dev_err(chip->dev, "Read T-LRA-min failed, rc=%d\n", rc);
goto continue_on;
}
rc = of_property_read_u32(chip->dev->of_node, "moto,lra-period-us-max", &t_lra_us_max);
if (rc < 0) {
dev_err(chip->dev, "Read T-LRA-max failed, rc=%d\n", rc);
goto continue_on;
}
/* If calibration failed in XBL,will be calibrate again */
if (chip->config.cl_t_lra_us < t_lra_us_min || chip->config.cl_t_lra_us > t_lra_us_max) {
dev_err(chip->dev, "The start up cal fail, cal again in kernel\n");
rc = haptics_start_lra_calibrate(chip);
if (rc < 0) {
dev_err(chip->dev, "Cal again failed in kernel\n");
goto continue_on;
}
cl_f_lra = USEC_PER_SEC / chip->config.cl_t_lra_us;
dev_err(chip->dev, "Latest cal F0 is %d Hz\n", cl_f_lra);
/* If cal failed in kernel, force set manual freq */
if (chip->config.cl_t_lra_us < t_lra_us_min || chip->config.cl_t_lra_us > t_lra_us_max) {
rc = of_property_read_u32(chip->dev->of_node, "moto,lra-period-cal-count", &f0_cal_count);
if (rc < 0) {
dev_err(chip->dev, "Read cal-count failed, rc=%d\n", rc);
f0_cal_count = LRA_F0_CAL_COUNT;
}
dev_err(chip->dev, "Failure of all cal, set manual freq to %dHz, f0_count to %d\n",
cl_f_lra, f0_cal_count);
chip->config.cl_t_lra_us = chip->config.t_lra_us;
chip->config.rc_clk_cal_count = f0_cal_count;
rc = haptics_config_openloop_lra_period(chip, chip->config.cl_t_lra_us);
if (rc < 0)
dev_err(chip->dev, "Config manual freq failed, rc=%d\n", rc);
rc = haptics_set_manual_rc_clk_cal(chip);
if (rc < 0)
dev_err(chip->dev, "Config manual cal count failed, rc=%d\n", rc);
}
}
}
continue_on:
return 0;
remove_v_gain_error:
class_remove_file(&chip->hap_class, &class_attr_v_gain_error);

View file

@ -2183,7 +2183,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
* to 5-10sec worth of reprogramming the context bank, while
* the system appears to be locked up to the user.
*/
pm_runtime_set_autosuspend_delay(smmu->dev, 20);
pm_runtime_set_autosuspend_delay(smmu->dev, 15);
pm_runtime_use_autosuspend(smmu->dev);
rpm_put:

View file

@ -154,6 +154,12 @@ static int qcom_ipcc_mbox_send_data(struct mbox_chan *chan, void *data)
hwirq = qcom_ipcc_get_hwirq(mchan->client_id, mchan->signal_id);
writel(hwirq, ipcc->base + IPCC_REG_SEND_ID);
/* All data writes need to be flushed to memory before the write index
* is updated. This protects against a race condition where the remote
* reads stale data because the write index was written before the data.
*/
wmb();
return 0;
}

View file

@ -35,10 +35,13 @@
#include <soc/qcom/ice.h>
#include <linux/blkdev.h>
#include <linux/dcache.h>
#include "sdhci-cqhci.h"
#include "sdhci-pltfm.h"
#include "cqhci.h"
#include "../core/core.h"
#include "../core/queue.h"
#include <linux/qtee_shmbridge.h>
#define CORE_MCI_VERSION 0x50
@ -221,6 +224,33 @@
#define SDHCI_CMD_FLAGS_MASK 0xff
/* Copied from mmc/core/block.c to access the request queue */
struct mmc_blk_data {
struct device *parent;
struct gendisk *disk;
struct mmc_queue queue;
struct list_head part;
struct list_head rpmbs;
unsigned int flags;
struct kref kref;
unsigned int read_only;
unsigned int part_type;
unsigned int reset_done;
/*
* Only set in main mmc_blk_data associated
* with mmc_card with dev_set_drvdata, and keeps
* track of the current selected device partition.
*/
unsigned int part_curr;
int area_type;
/* debugfs files (only in main mmc_blk_data) */
struct dentry *status_dentry;
struct dentry *ext_csd_dentry;
};
struct sdhci_msm_offset {
u32 core_hc_mode;
u32 core_mci_data_cnt;
@ -518,6 +548,7 @@ struct sdhci_msm_host {
bool skip_bus_bw_voting;
struct sdhci_msm_bus_vote_data *bus_vote_data;
struct delayed_work bus_vote_work;
struct delayed_work sdcard_hotplut_work;
struct workqueue_struct *workq; /* QoS work queue */
struct sdhci_msm_qos_req *sdhci_qos;
struct irq_affinity_notify affinity_notify;
@ -3981,6 +4012,48 @@ static int sdhci_msm_start_signal_voltage_switch(struct mmc_host *mmc,
return -EAGAIN;
}
static void moto_sdcard_event_work(struct work_struct *work)
{
struct sdhci_msm_host *msm_host = container_of(work, struct sdhci_msm_host, sdcard_hotplut_work.work);
struct mmc_host *mmc = NULL;
struct mmc_card *card = NULL;
struct mmc_blk_data *md = NULL;
if ((msm_host != NULL) && (mmc_card_is_removable(msm_host->mmc))) {
mmc = msm_host->mmc;
if (mmc != NULL)
card = mmc->card;
else
goto done;
if (card != NULL)
md = dev_get_drvdata(&card->dev);
else
goto done;
if (md != NULL) {
pr_debug("mmc update the removable card discard sectors to max\n");
blk_queue_max_discard_sectors(md->queue.queue, UINT_MAX);
}
}
done:
if (msm_host != NULL)
cancel_delayed_work(&msm_host->sdcard_hotplut_work);
}
static void sdhci_msm_init_card(struct mmc_host *host,
struct mmc_card *card)
{
struct sdhci_host *sdhci_host = mmc_priv(host);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(sdhci_host);
struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
if (mmc_card_is_removable(host)) {
schedule_delayed_work(&msm_host->sdcard_hotplut_work, msecs_to_jiffies(2*HZ));
}
}
#define MAX_TEST_BUS 60
#define DRIVER_NAME "sdhci_msm"
#define SDHCI_MSM_DUMP(f, x...) \
@ -5228,6 +5301,8 @@ static int sdhci_msm_probe(struct platform_device *pdev)
if (ret)
goto pltfm_free;
INIT_DELAYED_WORK(&msm_host->sdcard_hotplut_work, moto_sdcard_event_work);
/* Setup regulators */
ret = sdhci_msm_vreg_init(&pdev->dev, msm_host, true);
if (ret) {
@ -5286,6 +5361,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
host->mmc_host_ops.start_signal_voltage_switch =
sdhci_msm_start_signal_voltage_switch;
host->mmc_host_ops.execute_tuning = sdhci_msm_execute_tuning;
host->mmc_host_ops.init_card = sdhci_msm_init_card;
msm_host->workq = create_workqueue("sdhci_msm_generic_swq");
if (!msm_host->workq)

View file

@ -42,6 +42,24 @@
#define QUP_MASK GENMASK(5, 0)
#define SPARE_MASK GENMASK(15, 8)
#ifdef CONFIG_SUSPEND_DEBUG_MODULE
/**
* extract GPIO pin from bit-field used for gpio_tlmm_config
*/
#define GPIO_PIN(gpio_cfg) (((gpio_cfg) >> 4) & 0x3ff)
#define GPIO_FUNC(gpio_cfg) (((gpio_cfg) >> 0) & 0xf)
#define GPIO_DIR(gpio_cfg) (((gpio_cfg) >> 14) & 0x1)
#define GPIO_PULL(gpio_cfg) (((gpio_cfg) >> 15) & 0x3)
#define GPIO_DRVSTR(gpio_cfg) (((gpio_cfg) >> 17) & 0xf)
#define GPIO_CFG(gpio, func, dir, pull, drvstr) \
((((gpio) & 0x3FF) << 4) | \
((func) & 0xf) | \
(((dir) & 0x1) << 14) | \
(((pull) & 0x3) << 15) | \
(((drvstr) & 0xF) << 17))
#endif
/**
* struct msm_pinctrl - state for a pinctrl-msm device
* @dev: device handle.
@ -769,6 +787,115 @@ static void msm_gpio_pin_status_get(struct msm_pinctrl *pctrl, const struct msm_
*val = !!(io_reg & BIT(g->in_bit));
}
#ifdef CONFIG_SUSPEND_DEBUG_MODULE
int tlmm_get_inout(unsigned gpio)
{
const struct msm_pingroup *g;
u32 val;
if (msm_pinctrl_data == NULL)
return -ENODEV;
if (gpio >= msm_pinctrl_data->chip.ngpio)
return -ENODEV;
if (!gpiochip_line_is_valid(&msm_pinctrl_data->chip, gpio))
return -EINVAL;
g = &msm_pinctrl_data->soc->groups[gpio];
val = readl_relaxed(msm_pinctrl_data->regs[g->tile] + g->io_reg);
return !!(val & BIT(g->in_bit));
}
EXPORT_SYMBOL_GPL(tlmm_get_inout);
int tlmm_set_inout(unsigned gpio, unsigned value)
{
const struct msm_pingroup *g;
unsigned long flags;
u32 val;
if (msm_pinctrl_data == NULL)
return -ENODEV;
if (gpio >= msm_pinctrl_data->chip.ngpio)
return -ENODEV;
if (!gpiochip_line_is_valid(&msm_pinctrl_data->chip, gpio))
return -EINVAL;
g = &msm_pinctrl_data->soc->groups[gpio];
raw_spin_lock_irqsave(&msm_pinctrl_data->lock, flags);
val = readl_relaxed(msm_pinctrl_data->regs[g->tile] + g->io_reg);
if (value)
val |= BIT(g->out_bit);
else
val &= ~BIT(g->out_bit);
writel_relaxed(val, msm_pinctrl_data->regs[g->tile] + g->io_reg);
raw_spin_unlock_irqrestore(&msm_pinctrl_data->lock, flags);
return 0;
}
EXPORT_SYMBOL_GPL(tlmm_set_inout);
int tlmm_get_config(unsigned gpio, unsigned *cfg)
{
const struct msm_pingroup *g;
u32 ctl_reg;
if (msm_pinctrl_data == NULL)
return -ENODEV;
if (gpio >= msm_pinctrl_data->chip.ngpio)
return -ENODEV;
if (!gpiochip_line_is_valid(&msm_pinctrl_data->chip, gpio))
return -EINVAL;
g = &msm_pinctrl_data->soc->groups[gpio];
ctl_reg = readl_relaxed(msm_pinctrl_data->regs[g->tile] + g->ctl_reg);
pr_debug("%s(), %d, ctl_reg=%x\n", __func__, __LINE__, ctl_reg);
*cfg = GPIO_CFG(gpio, (ctl_reg >> g->mux_bit) & 7,
!!(ctl_reg & BIT(g->oe_bit)), (ctl_reg >> g->pull_bit) & 3,
(ctl_reg >> g->drv_bit) & 7);
return 0;
}
EXPORT_SYMBOL_GPL(tlmm_get_config);
int tlmm_set_config(unsigned config)
{
const struct msm_pingroup *g;
unsigned long flags;
u32 ctl_reg;
u32 val;
unsigned gpio = GPIO_PIN(config);
pr_debug("%s(), %d, gpio=%d\n", __func__, __LINE__, gpio);
if (msm_pinctrl_data == NULL)
return -ENODEV;
if (gpio >= msm_pinctrl_data->chip.ngpio)
return -ENODEV;
if (!gpiochip_line_is_valid(&msm_pinctrl_data->chip, gpio))
return -EINVAL;
config = (config & ~0x40000000);
g = &msm_pinctrl_data->soc->groups[gpio];
ctl_reg = readl_relaxed(msm_pinctrl_data->regs[g->tile] + g->ctl_reg);
pr_debug("%s(), %d, ctl_reg=%x\n", __func__, __LINE__, ctl_reg);
raw_spin_lock_irqsave(&msm_pinctrl_data->lock, flags);
val = (((GPIO_DIR(config) & 1) << g->oe_bit) |
((GPIO_DRVSTR(config) & 7) << g->drv_bit) |
((GPIO_FUNC(config) & 7) << g->mux_bit) |
((GPIO_PULL(config) & 3) << g->pull_bit));
pr_debug("%s(), %d, val=%x\n", __func__, __LINE__, val);
writel_relaxed(val, msm_pinctrl_data->regs[g->tile] + g->ctl_reg);
raw_spin_unlock_irqrestore(&msm_pinctrl_data->lock, flags);
return 0;
}
EXPORT_SYMBOL_GPL(tlmm_set_config);
#endif
#ifdef CONFIG_DEBUG_FS
static void msm_gpio_dbg_show_one(struct seq_file *s,

View file

@ -18,6 +18,9 @@
#include <linux/firmware/qcom/qcom_scm.h>
#include <soc/qcom/minidump.h>
static char *sys_restart_mode = "NULL";
module_param(sys_restart_mode, charp, 0644);
enum qcom_download_dest {
QCOM_DOWNLOAD_DEST_UNKNOWN = -1,
QCOM_DOWNLOAD_DEST_QPST = 0,
@ -39,10 +42,13 @@ struct qcom_dload {
#define QCOM_DOWNLOAD_BOTHDUMP (QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP)
#define DUMP_MODE_NAME_LEN 8
static char dump_mode_name[DUMP_MODE_NAME_LEN];
static int enable_dump =
IS_ENABLED(CONFIG_POWER_RESET_QCOM_DOWNLOAD_MODE_DEFAULT);
static enum qcom_download_mode current_download_mode = QCOM_DOWNLOAD_NODUMP;
static enum qcom_download_mode dump_mode = QCOM_DOWNLOAD_FULLDUMP;
static enum qcom_download_mode dump_mode = QCOM_DOWNLOAD_BOTHDUMP;
static int set_download_mode(enum qcom_download_mode mode)
{
@ -115,6 +121,8 @@ static int param_set_download_mode(const char *val,
module_param_call(download_mode, param_set_download_mode, param_get_int,
&enable_dump, 0644);
module_param_string(name, dump_mode_name, DUMP_MODE_NAME_LEN, 0644);
/* interface for exporting attributes */
struct reset_attribute {
struct attribute attr;
@ -281,11 +289,31 @@ static int qcom_dload_reboot(struct notifier_block *this, unsigned long event,
struct qcom_dload *poweroff = container_of(this, struct qcom_dload,
reboot_nb);
pr_info("%s: sys_restart_mode [%s]\n", __func__, sys_restart_mode);
if (!strcmp(sys_restart_mode, "panic")) {
/* Trigger a real panic on debug setting */
BUG();
}
if (!strcmp(sys_restart_mode, "recovery_panic")) {
if (!strcmp(cmd, "recovery")) {
/* Trigger a real panic on debug setting */
BUG();
}
}
/* Clean shutdown, disable dump mode to allow normal restart */
if (!poweroff->in_panic)
set_download_mode(QCOM_DOWNLOAD_NODUMP);
poweroff->in_reboot = true;
set_download_mode(QCOM_DOWNLOAD_NODUMP);
if (cmd) {
if (!strcmp(cmd, "edl"))
#if 0
set_download_mode(QCOM_DOWNLOAD_EDL);
#else
pr_err("EDL mode disabled\n");
#endif
else if (!strcmp(cmd, "qcom_dload"))
msm_enable_dump_mode(true);
}
@ -340,6 +368,16 @@ static int qcom_dload_probe(struct platform_device *pdev)
}
poweroff->dload_dest_addr = map_prop_mem("qcom,msm-imem-dload-type");
if (!strncmp("full", dump_mode_name, DUMP_MODE_NAME_LEN))
dump_mode = QCOM_DOWNLOAD_FULLDUMP;
else if (!strncmp("mini", dump_mode_name, DUMP_MODE_NAME_LEN))
dump_mode = QCOM_DOWNLOAD_MINIDUMP;
else if (!strncmp("both", dump_mode_name, DUMP_MODE_NAME_LEN))
dump_mode = QCOM_DOWNLOAD_BOTHDUMP;
else
dump_mode = QCOM_DOWNLOAD_NODUMP;
msm_enable_dump_mode(enable_dump);
dump_mode = qcom_scm_get_download_mode(&temp) ? dump_mode : temp;
pr_info("%s: Current dump mode: 0x%x\n", __func__, dump_mode);

View file

@ -46,18 +46,29 @@
#define BC_WLS_FW_GET_VERSION 0x44
#define BC_SHUTDOWN_NOTIFY 0x47
#define BC_CHG_CTRL_LIMIT_EN 0x48
#define BC_WLS_CHECK_CHIP_ID 0x49
#define BC_HBOOST_VMAX_CLAMP_NOTIFY 0x79
#define BC_GENERIC_NOTIFY 0x80
/* Generic definitions */
#define MAX_STR_LEN 128
#define BC_WAIT_TIME_MS 1000
#define WLS_FW_PREPARE_TIME_MS 1000
#define WLS_FW_WAIT_TIME_MS 500
#define BC_WAIT_TIME_MS 2000
#define WLS_FW_PREPARE_TIME_MS 2000
#define WLS_FW_WAIT_TIME_MS 5000
#define WLS_FW_UPDATE_TIME_MS 1000
#define WLS_FW_BUF_SIZE 128
#define DEFAULT_RESTRICT_FCC_UA 1000000
#define AP_BIN_FW_UPDATE 1
#define ADSP_FW_UPDATE 2
enum usb_connector_type {
USB_CONNECTOR_TYPE_TYPEC,
USB_CONNECTOR_TYPE_MICRO_USB,
};
static bool wls_fw_udating = false;
enum psy_type {
PSY_TYPE_BATTERY,
PSY_TYPE_USB,
@ -101,6 +112,8 @@ enum battery_property_id {
BATT_CHG_CTRL_END_THR,
BATT_CURR_AVG,
BATT_PARALLEL_CELL_COUNT,
BATT_QNS_VOLT_MAX,
BATT_CHG_QNS_CTRL_LIM_MAX,
BATT_PROP_MAX,
};
@ -139,6 +152,14 @@ enum wireless_property_id {
WLS_PROP_MAX,
};
enum wireless_vendor {
WLS_IDT,
WLS_CPS,
WLS_CPS4019,
WLS_CPS4038 = 0x4038,
WLS_SC9624 = 0x9624,
};
enum {
QTI_POWER_SUPPLY_USB_TYPE_HVDCP = 0x80,
QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3,
@ -178,11 +199,17 @@ struct battery_model_resp_msg {
char model[MAX_STR_LEN];
};
struct wireless_check_chip_id {
struct pmic_glink_hdr hdr;
u32 ret_code;
};
struct wireless_fw_check_req {
struct pmic_glink_hdr hdr;
u32 fw_version;
u32 fw_size;
u32 fw_crc;
u32 bin_or_h;
};
struct wireless_fw_check_resp {
@ -251,6 +278,7 @@ struct battery_chg_dev {
void *notifier_cookie;
u32 *thermal_levels;
const char *wls_fw_name;
const char *sc_wls_fw_name;
int curr_thermal_level;
int num_thermal_levels;
int shutdown_volt_mv;
@ -264,15 +292,24 @@ struct battery_chg_dev {
bool ship_mode_immediate;
bool debug_battery_detected;
bool wls_fw_update_reqd;
u32 wls_chip_id;
u32 wls_fw_version;
u32 wls_fw_vendor;
u16 wls_fw_crc;
u32 wls_fw_update_time_ms;
int wls_fw_size_min;
struct notifier_block reboot_notifier;
u32 thermal_fcc_ua;
u32 restrict_fcc_ua;
u32 last_fcc_ua;
u32 usb_icl_ua;
u32 thermal_fcc_step;
u32 connector_type;
u32 usb_prev_mode;
u32 tbatt_filter_interval_ms;
u32 tbatt_filter_offset_degree;
int tbatt_filter_save_degree;
bool tbatt_filter_en;
bool restrict_chg_en;
u8 chg_ctrl_start_thr;
u8 chg_ctrl_end_thr;
@ -281,6 +318,7 @@ struct battery_chg_dev {
bool initialized;
bool notify_en;
bool error_prop;
struct power_supply *combo_batt_psy;
};
static const int battery_prop_map[BATT_PROP_MAX] = {
@ -362,6 +400,34 @@ int unregister_hboost_event_notifier(struct notifier_block *nb)
}
EXPORT_SYMBOL(unregister_hboost_event_notifier);
static bool jiffies_timer_expire(struct battery_chg_dev *bcdev, bool clear_jiffies) {
unsigned long cur_jiffies = jiffies;
static unsigned long last_jiffies = 0;
unsigned long intr_timeout = msecs_to_jiffies(bcdev->tbatt_filter_interval_ms);
bool ret = false;
if (!last_jiffies)
last_jiffies = cur_jiffies;
if (time_after(cur_jiffies, intr_timeout + last_jiffies))
ret = true;
else
ret = false;
if (ret) {
pr_err("expire:%dms, curr_jiffies:%dms, last jiffies:%d",
bcdev->tbatt_filter_interval_ms, jiffies_to_msecs(cur_jiffies), jiffies_to_msecs(last_jiffies));
last_jiffies = cur_jiffies;
}
if (clear_jiffies) {
last_jiffies = cur_jiffies;
}
return ret;
}
static int battery_chg_fw_write(struct battery_chg_dev *bcdev, void *data,
int len)
{
@ -369,7 +435,7 @@ static int battery_chg_fw_write(struct battery_chg_dev *bcdev, void *data,
down_read(&bcdev->state_sem);
if (atomic_read(&bcdev->state) == PMIC_GLINK_STATE_DOWN) {
pr_debug("glink state is down\n");
pr_err("glink state is down\n");
up_read(&bcdev->state_sem);
return -ENOTCONN;
}
@ -381,7 +447,7 @@ static int battery_chg_fw_write(struct battery_chg_dev *bcdev, void *data,
rc = wait_for_completion_timeout(&bcdev->fw_buf_ack,
msecs_to_jiffies(WLS_FW_WAIT_TIME_MS));
if (!rc) {
pr_err("Error, timed out sending message\n");
pr_err("Error, timed out sending message, tims_ms %d\n", WLS_FW_WAIT_TIME_MS);
return -ETIMEDOUT;
}
@ -450,6 +516,11 @@ static int write_property_id(struct battery_chg_dev *bcdev,
{
struct battery_charger_req_msg req_msg = { { 0 } };
if (wls_fw_udating) {
pr_debug("wireless doing fw update, refuse to write_property_id");
return -ETIMEDOUT;
}
req_msg.property_id = prop_id;
req_msg.battery_id = 0;
req_msg.value = val;
@ -469,6 +540,11 @@ static int read_property_id(struct battery_chg_dev *bcdev,
{
struct battery_charger_req_msg req_msg = { { 0 } };
if (wls_fw_udating && prop_id != USB_ADAP_TYPE) {
pr_debug("wireless doing fw update, refuse to read_property_id");
return -ETIMEDOUT;
}
req_msg.property_id = prop_id;
req_msg.battery_id = 0;
req_msg.value = 0;
@ -774,6 +850,16 @@ static void handle_message(struct battery_chg_dev *bcdev, void *data,
len);
}
break;
case BC_WLS_CHECK_CHIP_ID:
if (len == sizeof(*fw_check_msg)) {
fw_check_msg = data;
bcdev->wls_chip_id = fw_check_msg->ret_code;
ack_set = true;
} else {
pr_err("Incorrect response length %zu for wls_fw_check_update\n",
len);
}
break;
default:
pr_err("Unknown opcode: %u\n", resp_msg->hdr.opcode);
break;
@ -990,8 +1076,18 @@ static int wls_psy_get_prop(struct power_supply *psy,
return prop_id;
rc = read_property_id(bcdev, pst, prop_id);
#ifdef QCOM_BASE
if (rc < 0)
return rc;
#else
if (rc == -ETIMEDOUT) {
pr_debug("read prop:%d timeout, use old prop value\n", prop_id);
rc = 0;
} else if (rc < 0) {
pr_err("read prop:%d error, rc = %d", prop_id, rc);
return rc;
}
#endif
pval->intval = pst->prop[prop_id];
@ -1121,8 +1217,18 @@ static int usb_psy_get_prop(struct power_supply *psy,
return prop_id;
rc = read_property_id(bcdev, pst, prop_id);
#ifdef QCOM_BASE
if (rc < 0)
return rc;
#else
if (rc == -ETIMEDOUT) {
pr_debug("read prop:%d timeout, use old prop value\n", prop_id);
rc = 0;
} else if (rc < 0) {
pr_err("read prop:%d error, rc = %d", prop_id, rc);
return rc;
}
#endif
pval->intval = pst->prop[prop_id];
if (prop == POWER_SUPPLY_PROP_TEMP)
@ -1334,7 +1440,7 @@ static int __battery_psy_set_charge_current(struct battery_chg_dev *bcdev,
static int battery_psy_set_charge_current(struct battery_chg_dev *bcdev,
int val)
{
int rc;
int rc = 0;
u32 fcc_ua, prev_fcc_ua;
if (!bcdev->num_thermal_levels)
@ -1357,11 +1463,74 @@ static int battery_psy_set_charge_current(struct battery_chg_dev *bcdev,
prev_fcc_ua = bcdev->thermal_fcc_ua;
bcdev->thermal_fcc_ua = fcc_ua;
rc = __battery_psy_set_charge_current(bcdev, fcc_ua);
if (!rc)
bcdev->curr_thermal_level = val;
else
bcdev->thermal_fcc_ua = prev_fcc_ua;
if (prev_fcc_ua != bcdev->thermal_fcc_ua) {
rc = __battery_psy_set_charge_current(bcdev, fcc_ua);
if (!rc)
bcdev->curr_thermal_level = val;
else
bcdev->thermal_fcc_ua = prev_fcc_ua;
}
return rc;
}
static int battery_psy_set_cycle_count(struct battery_chg_dev *bcdev,
int CycleCount)
{
int rc;
rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY],
BATT_CYCLE_COUNT, CycleCount);
if (rc < 0) {
pr_err("Failed to set cycle count %d, rc=%d\n", CycleCount, rc);
} else {
pr_err("Set CycleCount to %d\n", CycleCount);
}
return rc;
}
static int tbatt_filter_handler(struct battery_chg_dev *bcdev, int batt_temp)
{
int ret = batt_temp;
if (batt_temp == -400)
return ret;
if (!bcdev->tbatt_filter_save_degree) {
bcdev->tbatt_filter_save_degree = batt_temp;
jiffies_timer_expire(bcdev, true);
ret = batt_temp;
} else {
if (abs(bcdev->tbatt_filter_save_degree - batt_temp) > bcdev->tbatt_filter_offset_degree &&
!jiffies_timer_expire(bcdev, false)) {
ret = bcdev->tbatt_filter_save_degree;
pr_err("fliter out tbatt: %d, report last temp %d\n", batt_temp, bcdev->tbatt_filter_save_degree);
} else {
jiffies_timer_expire(bcdev, true);
ret = batt_temp;
bcdev->tbatt_filter_save_degree = batt_temp;
}
}
return ret;
}
static int battery_psy_set_battery_fv(struct battery_chg_dev *bcdev, int val)
{
int rc;
rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY],
BATT_QNS_VOLT_MAX, val);
if (rc < 0)
pr_err("%s:%d failed to write property", __func__, __LINE__);
return rc;
}
static int battery_psy_set_battery_fcc(struct battery_chg_dev *bcdev, int val)
{
int rc;
rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY],
BATT_CHG_QNS_CTRL_LIM_MAX, val);
if (rc < 0)
pr_err("%s:%d failed to write property", __func__, __LINE__);
return rc;
}
@ -1388,8 +1557,18 @@ static int battery_psy_get_prop(struct power_supply *psy,
return prop_id;
rc = read_property_id(bcdev, pst, prop_id);
#ifdef QCOM_BASE
if (rc < 0)
return rc;
#else
if (rc == -ETIMEDOUT) {
pr_err("read prop:%d timeout, use old prop value\n", prop_id);
rc = 0;
} else if (rc < 0) {
pr_err("read prop:%d error, rc = %d", prop_id, rc);
return rc;
}
#endif
switch (prop) {
case POWER_SUPPLY_PROP_MODEL_NAME:
@ -1397,13 +1576,41 @@ static int battery_psy_get_prop(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_CAPACITY:
pval->intval = DIV_ROUND_CLOSEST(pst->prop[prop_id], 100);
if (bcdev->combo_batt_psy) {
power_supply_get_property(bcdev->combo_batt_psy,
prop, pval);
}
if (IS_ENABLED(CONFIG_QTI_PMIC_GLINK_CLIENT_DEBUG) &&
(bcdev->fake_soc >= 0 && bcdev->fake_soc <= 100))
pval->intval = bcdev->fake_soc;
break;
case POWER_SUPPLY_PROP_TEMP:
pval->intval = DIV_ROUND_CLOSEST((int)pst->prop[prop_id], 10);
if (bcdev->tbatt_filter_en) {
pval->intval = tbatt_filter_handler(bcdev, DIV_ROUND_CLOSEST((int)pst->prop[prop_id], 10));
} else {
pval->intval = DIV_ROUND_CLOSEST((int)pst->prop[prop_id], 10);
}
break;
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
pval->intval = bcdev->curr_thermal_level;
break;
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
pval->intval = bcdev->num_thermal_levels;
break;
case POWER_SUPPLY_PROP_STATUS:
case POWER_SUPPLY_PROP_CURRENT_NOW:
case POWER_SUPPLY_PROP_CHARGE_FULL:
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
if (bcdev->combo_batt_psy) {
pval->intval = pst->prop[prop_id];
power_supply_get_property(bcdev->combo_batt_psy,
prop, pval);
break;
} else {
pval->intval = pst->prop[prop_id];
break;
}
default:
pval->intval = pst->prop[prop_id];
break;
@ -1425,6 +1632,14 @@ static int battery_psy_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD:
return battery_psy_set_charge_end_threshold(bcdev,
pval->intval);
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
return battery_psy_set_charge_current(bcdev, pval->intval);
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
return battery_psy_set_battery_fv(bcdev, pval->intval);
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
return battery_psy_set_battery_fcc(bcdev, pval->intval);
case POWER_SUPPLY_PROP_CYCLE_COUNT:
return battery_psy_set_cycle_count(bcdev, pval->intval);
default:
return -EINVAL;
}
@ -1438,6 +1653,10 @@ static int battery_psy_prop_is_writeable(struct power_supply *psy,
switch (prop) {
case POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD:
case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD:
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
case POWER_SUPPLY_PROP_CYCLE_COUNT:
return 1;
default:
break;
@ -1520,6 +1739,18 @@ static int battery_chg_init_psy(struct battery_chg_dev *bcdev)
return rc;
}
if (of_find_property(bcdev->dev->of_node, "mmi,combo-batt-psy", NULL)) {
bcdev->combo_batt_psy = devm_power_supply_get_by_phandle(
bcdev->dev,
"mmi,combo-batt-psy");
if (IS_ERR_OR_NULL(bcdev->combo_batt_psy)) {
pr_err("Couldn't get the combo-batt-psy\n");
if (!bcdev->combo_batt_psy)
return -ENODEV;
else
return PTR_ERR(bcdev->combo_batt_psy);
}
}
return 0;
}
@ -1580,7 +1811,7 @@ static int wireless_fw_send_firmware(struct battery_chg_dev *bcdev,
msg.fw_chunk_id = i + 1;
memcpy(msg.buf, ptr, WLS_FW_BUF_SIZE);
pr_debug("sending FW chunk %u\n", i + 1);
pr_info("sending FW chunk %u\n", i + 1);
rc = battery_chg_fw_write(bcdev, &msg, sizeof(msg));
if (rc < 0)
return rc;
@ -1591,7 +1822,7 @@ static int wireless_fw_send_firmware(struct battery_chg_dev *bcdev,
memset(msg.buf, 0, WLS_FW_BUF_SIZE);
memcpy(msg.buf, ptr, partial_chunk_size);
pr_debug("sending partial FW chunk %u\n", i + 1);
pr_info("sending partial FW chunk %u\n", i + 1);
rc = battery_chg_fw_write(bcdev, &msg, sizeof(msg));
if (rc < 0)
return rc;
@ -1600,8 +1831,22 @@ static int wireless_fw_send_firmware(struct battery_chg_dev *bcdev,
return 0;
}
static int wireless_check_chip_id(struct battery_chg_dev *bcdev)
{
struct wireless_check_chip_id req_msg = {};
bcdev->wls_chip_id = 0x0000;
req_msg.hdr.owner = MSG_OWNER_BC;
req_msg.hdr.type = MSG_TYPE_REQ_RESP;
req_msg.hdr.opcode = BC_WLS_CHECK_CHIP_ID;
req_msg.ret_code = 0;
return battery_chg_write(bcdev, &req_msg, sizeof(req_msg));
}
static int wireless_fw_check_for_update(struct battery_chg_dev *bcdev,
u32 version, size_t size)
u32 version, size_t size, u32 bin_or_h)
{
struct wireless_fw_check_req req_msg = {};
@ -1613,6 +1858,7 @@ static int wireless_fw_check_for_update(struct battery_chg_dev *bcdev,
req_msg.fw_version = version;
req_msg.fw_size = size;
req_msg.fw_crc = bcdev->wls_fw_crc;
req_msg.bin_or_h = bin_or_h;
return battery_chg_write(bcdev, &req_msg, sizeof(req_msg));
}
@ -1621,15 +1867,23 @@ static int wireless_fw_check_for_update(struct battery_chg_dev *bcdev,
#define IDT9415_FW_MINOR_VER_OFFSET 0x86
#define IDT_FW_MAJOR_VER_OFFSET 0x94
#define IDT_FW_MINOR_VER_OFFSET 0x96
static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force)
#define CPS_FW_MAJOR_VER_OFFSET 0xc4
#define CPS_FW_MINOR_VER_OFFSET 0xc5
#define CPS4019_FW_MAJOR_VER_OFFSET1 0xc4
#define CPS4019_FW_MAJOR_VER_OFFSET2 0xc5
#define CPS4019_FW_MINOR_VER_OFFSET1 0xc6
#define CPS4019_FW_MINOR_VER_OFFSET2 0xc7
#define SC9624_FW_VER_OFFSET 0x104
static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force, int bin_or_h)
{
const struct firmware *fw;
struct psy_state *pst;
u32 version;
u16 maj_ver, min_ver;
u32 version = 0;
u16 maj_ver, min_ver, maj_ver1, maj_ver2, min_ver1, min_ver2;
int rc;
if (!bcdev->wls_fw_name) {
if (!bcdev->wls_fw_name && !bcdev->sc_wls_fw_name) {
pr_err("wireless FW name is not specified\n");
return -EINVAL;
}
@ -1651,17 +1905,94 @@ static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force)
if (rc < 0)
goto out;
if ((pst->prop[BATT_CAPACITY] / 100) < 50) {
pr_err("Battery SOC should be at least 50%% or connect charger\n");
if ((pst->prop[BATT_CAPACITY] / 100) < 20) {
pr_err("Battery SOC should be at least 20%% or connect charger\n");
rc = -EINVAL;
goto out;
}
}
rc = firmware_request_nowarn(&fw, bcdev->wls_fw_name, bcdev->dev);
if (rc) {
pr_err("Couldn't get firmware rc=%d\n", rc);
goto out;
if (bcdev->sc_wls_fw_name)
{
rc = wireless_check_chip_id(bcdev);
if (rc) {
pr_err("Couldn't get chip id rc=%d\n", rc);
goto out;
}
pr_err("wireless chip id = %04x\n", bcdev->wls_chip_id);
if(bcdev->wls_chip_id == WLS_SC9624) {
rc = firmware_request_nowarn(&fw, bcdev->sc_wls_fw_name, bcdev->dev);
if (rc) {
pr_err("Couldn't get southchip firmware rc=%d\n", rc);
goto out;
}
// version = min_ver << 16 | maj_ver;
version = *(u32 *)&fw->data[SC9624_FW_VER_OFFSET];
pr_info("southchip fw version: %08x\n", version);
} else{
rc = firmware_request_nowarn(&fw, bcdev->wls_fw_name, bcdev->dev);
if (rc) {
pr_err("Couldn't get southchip firmware rc=%d\n", rc);
goto out;
}
if (bcdev->wls_fw_vendor == WLS_CPS4019) {
maj_ver1 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MAJOR_VER_OFFSET1));
maj_ver = maj_ver1 >> 8;
maj_ver2 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MAJOR_VER_OFFSET2));
maj_ver2 = maj_ver2 & 0xFF00;
maj_ver = maj_ver + maj_ver2;
min_ver1 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MINOR_VER_OFFSET1));
min_ver = min_ver1 >> 8;
min_ver2 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MINOR_VER_OFFSET2));
min_ver2 = min_ver2 & 0xFF00;
min_ver = min_ver + min_ver2;
pr_info("WLS_CPS 4019 maj_ver %#x, min_ver %#x\n", maj_ver, min_ver);
version = maj_ver << 16 | min_ver;
} else if (bcdev->wls_fw_vendor == WLS_CPS) {
maj_ver = be16_to_cpu(*(__le16 *)(fw->data + CPS_FW_MAJOR_VER_OFFSET));
maj_ver = maj_ver >> 8;
min_ver = be16_to_cpu(*(__le16 *)(fw->data + CPS_FW_MINOR_VER_OFFSET));
min_ver = min_ver >> 8;
pr_info("WLS_CPS maj_ver %#x, min_ver %#x\n", maj_ver, min_ver);
version = maj_ver << 16 | min_ver;
} else {
maj_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MAJOR_VER_OFFSET));
min_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MINOR_VER_OFFSET));
version = maj_ver << 16 | min_ver;
}
}
} else {
rc = firmware_request_nowarn(&fw, bcdev->wls_fw_name, bcdev->dev);
if (rc) {
pr_err("Couldn't get southchip firmware rc=%d\n", rc);
goto out;
}
if (bcdev->wls_fw_vendor == WLS_CPS4019) {
maj_ver1 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MAJOR_VER_OFFSET1));
maj_ver = maj_ver1 >> 8;
maj_ver2 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MAJOR_VER_OFFSET2));
maj_ver2 = maj_ver2 & 0xFF00;
maj_ver = maj_ver + maj_ver2;
min_ver1 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MINOR_VER_OFFSET1));
min_ver = min_ver1 >> 8;
min_ver2 = be16_to_cpu(*(__le16 *)(fw->data + CPS4019_FW_MINOR_VER_OFFSET2));
min_ver2 = min_ver2 & 0xFF00;
min_ver = min_ver + min_ver2;
pr_info("WLS_CPS 4019 maj_ver %#x, min_ver %#x\n", maj_ver, min_ver);
version = maj_ver << 16 | min_ver;
} else if (bcdev->wls_fw_vendor == WLS_CPS) {
maj_ver = be16_to_cpu(*(__le16 *)(fw->data + CPS_FW_MAJOR_VER_OFFSET));
maj_ver = maj_ver >> 8;
min_ver = be16_to_cpu(*(__le16 *)(fw->data + CPS_FW_MINOR_VER_OFFSET));
min_ver = min_ver >> 8;
pr_info("WLS_CPS maj_ver %#x, min_ver %#x\n", maj_ver, min_ver);
version = maj_ver << 16 | min_ver;
} else {
maj_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MAJOR_VER_OFFSET));
min_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MINOR_VER_OFFSET));
version = maj_ver << 16 | min_ver;
}
}
if (!fw || !fw->data || !fw->size) {
@ -1670,32 +2001,24 @@ static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force)
goto release_fw;
}
if (fw->size < SZ_16K) {
pr_err("Invalid firmware size %zu\n", fw->size);
if (fw->size < bcdev->wls_fw_size_min) {
pr_err("Invalid firmware size (%zu < %d)\n", fw->size, bcdev->wls_fw_size_min);
rc = -EINVAL;
goto release_fw;
}
if (strstr(bcdev->wls_fw_name, "9412")) {
maj_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MAJOR_VER_OFFSET));
min_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT_FW_MINOR_VER_OFFSET));
} else {
maj_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT9415_FW_MAJOR_VER_OFFSET));
min_ver = le16_to_cpu(*(__le16 *)(fw->data + IDT9415_FW_MINOR_VER_OFFSET));
}
version = maj_ver << 16 | min_ver;
if (force)
version = UINT_MAX;
pr_debug("FW size: %zu version: %#x\n", fw->size, version);
rc = wireless_fw_check_for_update(bcdev, version, fw->size);
pr_info("FW size: %zu version: %#x bin_or_h:%x\n", fw->size, version, bin_or_h);
rc = wireless_fw_check_for_update(bcdev, version, fw->size, bin_or_h);
if (rc < 0) {
pr_err("Wireless FW update not needed, rc=%d\n", rc);
goto release_fw;
}
pr_info("southchip %d\n", bcdev->wls_fw_update_reqd);
if (!bcdev->wls_fw_update_reqd) {
pr_warn("Wireless FW update not required\n");
goto release_fw;
@ -1703,13 +2026,17 @@ static int wireless_fw_update(struct battery_chg_dev *bcdev, bool force)
/* Wait for IDT to be setup by charger firmware */
msleep(WLS_FW_PREPARE_TIME_MS);
wls_fw_udating = true;
reinit_completion(&bcdev->fw_update_ack);
if(bin_or_h == 1) { //bin send from AP to ADSP
rc = wireless_fw_send_firmware(bcdev, fw);
if (rc < 0) {
pr_err("Failed to send FW chunk, rc=%d\n", rc);
goto release_fw;
}
} else if(bin_or_h == 2) {
bcdev->wls_fw_update_time_ms = 40*1000;//40s
}
pr_debug("Waiting for fw_update_ack\n");
rc = wait_for_completion_timeout(&bcdev->fw_update_ack,
@ -1731,7 +2058,7 @@ release_fw:
release_firmware(fw);
out:
pm_relax(bcdev->dev);
wls_fw_udating = false;
return rc;
}
@ -1798,19 +2125,24 @@ static ssize_t wireless_fw_version_show(const struct class *c,
}
static CLASS_ATTR_RO(wireless_fw_version);
static ssize_t wireless_fw_force_update_store(const struct class *c,
const struct class_attribute *attr,
const char *buf, size_t count)
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
bool val;
int val;
int rc;
if (kstrtobool(buf, &val) || !val)
return -EINVAL;
rc = wireless_fw_update(bcdev, true);
if (kstrtoint(buf, 0, &val) ||
(val != AP_BIN_FW_UPDATE && val != ADSP_FW_UPDATE)) {
pr_err("%s: invalid FW update mode %d\n", __func__, val);
return -EINVAL;
}
rc = wireless_fw_update(bcdev, true, val); //force update
if (rc < 0)
return rc;
@ -1824,13 +2156,16 @@ static ssize_t wireless_fw_update_store(const struct class *c,
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
bool val;
int val;
int rc;
if (kstrtobool(buf, &val) || !val)
return -EINVAL;
if (kstrtoint(buf, 0, &val) ||
(val != AP_BIN_FW_UPDATE && val != ADSP_FW_UPDATE)) {
pr_err("%s: invalid FW update mode %d\n", __func__, val);
return -EINVAL;
}
rc = wireless_fw_update(bcdev, false);
rc = wireless_fw_update(bcdev, false, val);
if (rc < 0)
return rc;
@ -2293,13 +2628,42 @@ static int battery_chg_parse_dt(struct battery_chg_dev *bcdev)
int i, rc, len;
u32 prev, val;
bcdev->tbatt_filter_en = of_property_read_bool(node, "qcom,tbatt-filter-en");
rc = of_property_read_u32(node, "qcom,tbatt-filter-interval-ms",
&bcdev->tbatt_filter_interval_ms);
if (rc < 0) {
bcdev->tbatt_filter_interval_ms = 5000;
}
rc = of_property_read_u32(node, "qcom,tbatt-filter-offset-degree",
&bcdev->tbatt_filter_offset_degree);
if (rc < 0) {
bcdev->tbatt_filter_offset_degree = 50;
}
of_property_read_string(node, "qcom,wireless-fw-name",
&bcdev->wls_fw_name);
of_property_read_string(node, "qcom,wireless-fw-name-sc",
&bcdev->sc_wls_fw_name);
of_property_read_u32(node, "qcom,shutdown-voltage",
&bcdev->shutdown_volt_mv);
bcdev->ship_mode_immediate = of_property_read_bool(node, "qcom,ship-mode-immediate");
rc = of_property_read_u32(node, "qcom,wireless-fw-size_min",
&bcdev->wls_fw_size_min);
if (rc < 0) {
bcdev->wls_fw_size_min = SZ_16K;
pr_info("%s fw size min do not defined, use 16k as default (%d)\n",
__func__, bcdev->wls_fw_size_min);
}
if (bcdev->wls_fw_name && strstr(bcdev->wls_fw_name, "cps4019"))
bcdev->wls_fw_vendor = WLS_CPS4019;
else if (bcdev->wls_fw_name && strstr(bcdev->wls_fw_name, "cps"))
bcdev->wls_fw_vendor = WLS_CPS;
rc = read_property_id(bcdev, pst, BATT_CHG_CTRL_LIM_MAX);
if (rc < 0) {

View file

@ -591,6 +591,156 @@ void devm_regulator_debug_unregister(struct regulator_dev *rdev)
}
EXPORT_SYMBOL(devm_regulator_debug_unregister);
#ifdef CONFIG_SUSPEND_DEBUG_MODULE
/* Add for vreg debug */
#define VREG_NUM_MAX 100
struct regulator_dump {
char *buf;
int pos;
int id;
};
int _vreg_dump_info(struct regulator_dev *rdev, void *data)
{
struct regulator_dump *dump = data;
const struct regulator_ops *ops = rdev->desc->ops;
unsigned on, mv;
char *p = dump->buf + dump->pos;
p += snprintf(p, PAGE_SIZE, "[%2d]%s: ",
dump->id++, rdev->desc->name);
on = mv = 0;
if (ops->is_enabled)
on = ops->is_enabled(rdev);
if (ops->get_voltage)
mv = ops->get_voltage(rdev) / 1000;
p += snprintf(p, PAGE_SIZE, "%s ", on ? "on " : "off");
p += snprintf(p, PAGE_SIZE, "%4d mv ", mv);
p += snprintf(p, PAGE_SIZE, "\n");
dump->pos = p - dump->buf;
return 0;
}
int vreg_dump_info(char *buf)
{
struct debug_regulator *dreg;
struct regulator_dump data;
data.buf = buf;
data.pos = 0;
data.id = 0;
list_for_each_entry(dreg, &debug_reg_list, list)
_vreg_dump_info(dreg->rdev, &data);
return data.pos;
}
EXPORT_SYMBOL_GPL(vreg_dump_info);
/* save vreg config before sleep */
static unsigned before_sleep_fetched;
static unsigned before_sleep_configs[VREG_NUM_MAX];
int _vreg_before_sleep_save_configs(struct regulator_dev *rdev, void *data)
{
struct regulator_dump *dump = data;
const struct regulator_ops *ops = rdev->desc->ops;
unsigned on, mv;
if (dump->id >= VREG_NUM_MAX)
return -EINVAL;
on = mv = 0;
if (ops->is_enabled)
on = ops->is_enabled(rdev);
if (ops->get_voltage)
mv = ops->get_voltage(rdev) / 1000;
before_sleep_configs[dump->id++] = mv | (on << 31);
return 0;
}
void vreg_before_sleep_save_configs(void)
{
struct debug_regulator *dreg;
struct regulator_dump data;
/* only save vreg configs when it has been fetched */
if (!before_sleep_fetched)
return;
pr_debug("%s(), before_sleep_fetched=%d\n",
__func__, before_sleep_fetched);
data.buf = NULL;
data.pos = 0;
data.id = 0;
list_for_each_entry(dreg, &debug_reg_list, list)
_vreg_before_sleep_save_configs(dreg->rdev, &data);
before_sleep_fetched = false;
}
EXPORT_SYMBOL_GPL(vreg_before_sleep_save_configs);
int _vreg_before_sleep_dump_info(struct regulator_dev *rdev, void *data)
{
struct regulator_dump *dump = data;
char *p = dump->buf + dump->pos;
unsigned on, mv;
if (dump->id >= VREG_NUM_MAX)
return -EINVAL;
p += snprintf(p, PAGE_SIZE, "[%2d]%s: ",
dump->id, rdev->desc->name);
mv = before_sleep_configs[dump->id];
on = (mv & 0x80000000) >> 31;
mv &= ~0x80000000;
p += snprintf(p, PAGE_SIZE, "%s ", on ? "on " : "off");
p += snprintf(p, PAGE_SIZE, "%4d mv ", mv);
p += snprintf(p, PAGE_SIZE, "\n");
dump->id++;
dump->pos = p - dump->buf;
return 0;
}
int vreg_before_sleep_dump_info(char *buf)
{
struct debug_regulator *dreg;
struct regulator_dump data;
char *p = buf;
data.buf = p;
data.pos = 0;
data.id = 0;
p += snprintf(p, PAGE_SIZE, "vreg_before_sleep:\n");
data.pos = p - data.buf;
pr_debug("%s(), before_sleep_fetched=%d\n",
__func__, before_sleep_fetched);
if (!before_sleep_fetched) {
list_for_each_entry(dreg, &debug_reg_list, list)
_vreg_before_sleep_dump_info(dreg->rdev, &data);
before_sleep_fetched = true;
}
return data.pos;
}
EXPORT_SYMBOL_GPL(vreg_before_sleep_dump_info);
#endif
static int _regulator_is_enabled(struct regulator_dev *rdev)
{
if (rdev->ena_pin)

View file

@ -26,6 +26,10 @@
#define Q6V5_LOAD_STATE_MSG_LEN 64
#define Q6V5_PANIC_DELAY_MS 200
static char qcom_ssr_reason[256];
static char *ssr_reason = qcom_ssr_reason;
module_param(ssr_reason, charp, S_IRUGO);
static int q6v5_load_state_toggle(struct qcom_q6v5 *q6v5, bool enable)
{
int ret;
@ -171,6 +175,8 @@ static irqreturn_t q6v5_wdog_interrupt(int irq, void *data)
q6v5->running = false;
trace_rproc_qcom_event(dev_name(q6v5->dev), "q6v5_wdog", msg);
memset(qcom_ssr_reason, 0, sizeof(qcom_ssr_reason));
strlcpy(qcom_ssr_reason, msg, min((size_t)len, (size_t)sizeof(qcom_ssr_reason)));
if (q6v5->ssr_subdev)
qcom_notify_early_ssr_clients(q6v5->ssr_subdev);
@ -202,7 +208,8 @@ static irqreturn_t q6v5_fatal_interrupt(int irq, void *data)
dev_err(q6v5->dev, "fatal error received: %s\n", msg);
else
dev_err(q6v5->dev, "fatal error without message\n");
memset(qcom_ssr_reason, 0, sizeof(qcom_ssr_reason));
strlcpy(qcom_ssr_reason, msg, min((size_t)len, (size_t)sizeof(qcom_ssr_reason)));
if (q6v5->crash_stack) {
msg = qcom_smem_get(q6v5->smem_host_id, q6v5->crash_stack, &len);
if (!IS_ERR(msg) && len > 0 && msg[0])

View file

@ -4,6 +4,53 @@
#
menu "Qualcomm SoC drivers"
config MMI_DEVICE_DTBS
depends on ARCH_QCOM
default n
bool "Motorola Mobility Device DTBs"
help
Only include Motorola device specific DTBs to limit the number that
get built during kernel completion.
config PAROS_DTB
depends on MMI_DEVICE_DTBS
default n
bool "Motorola Mobility Paros Device DTBs"
help
Only include Motorola Paros device specific device tree
config MONA_DTB
depends on MMI_DEVICE_DTBS
default n
bool "Motorola Mobility Mona Device DTBs"
help
Only include Motorola MOna device specific device tree
config MONAI_DTB
depends on MMI_DEVICE_DTBS
default n
bool "Motorola Mobility Monai Device DTBs"
help
Only include Motorola Monai device specific device tree
config PARO_DTB
depends on MMI_DEVICE_DTBS
default n
bool "Motorola Mobility Paro Device DTBs"
help
Only include Motorola Paro device specific device tree
config CUSCO_DTB
depends on MMI_DEVICE_DTBS
default n
bool "Motorola Mobility Cusco Device DTB"
help
Only include Motorola Cusco device specific DTB.
config SPS
tristate "SPS support"
select GENERIC_ALLOCATOR
@ -600,8 +647,8 @@ config QCOM_WDOG_BITE_EARLY_PANIC
config QCOM_WATCHDOG_BARK_TIME
depends on QCOM_WDT_CORE
int "Qualcomm Technologies, Inc. Watchdog bark time in ms"
default 11000
range 11000 11000
default 16000
range 11000 22000
help
The amount of time, in milliseconds, that should elapse after
a watchdog timer reset before a bark interrupt is sent from the

View file

@ -12,6 +12,7 @@
#include <linux/usb/ucsi_glink.h>
#include <linux/soc/qcom/fsa4480-i2c.h>
#include <linux/qti-regmap-debugfs.h>
#include <linux/of.h>
#define FSA4480_I2C_NAME "fsa4480-driver"
@ -29,6 +30,8 @@
#define FSA4480_DELAY_L_AGND 0x10
#define FSA4480_RESET 0x1E
static u32 add_fsa4480_reset_probe_value = 0;
struct fsa4480_priv {
struct regmap *regmap;
struct device *dev;
@ -102,7 +105,7 @@ static int fsa4480_usbc_event_changed(struct notifier_block *nb,
if (!dev)
return -EINVAL;
dev_dbg(dev, "%s: USB change event received, supply mode %d, usbc mode %d, expected %d\n",
dev_info(dev, "%s: USB change event received, supply mode %d, usbc mode %d, expected %d\n",
__func__, acc, fsa_priv->usbc_mode.counter,
TYPEC_ACCESSORY_AUDIO);
@ -141,7 +144,7 @@ static int fsa4480_usbc_analog_setup_switches(struct fsa4480_priv *fsa_priv)
/* get latest mode again within locked context */
mode = atomic_read(&(fsa_priv->usbc_mode));
dev_dbg(dev, "%s: setting GPIOs active = %d\n",
dev_info(dev, "%s: setting GPIOs active = %d\n",
__func__, mode != TYPEC_ACCESSORY_NONE);
switch (mode) {
@ -327,12 +330,20 @@ static void fsa4480_update_reg_defaults(struct regmap *regmap)
for (i = 0; i < ARRAY_SIZE(fsa_reg_i2c_defaults); i++)
regmap_write(regmap, fsa_reg_i2c_defaults[i].reg,
fsa_reg_i2c_defaults[i].val);
if (add_fsa4480_reset_probe_value) {
regmap_write(regmap, FSA4480_SWITCH_CONTROL, 0x18);
}
}
static int fsa4480_probe(struct i2c_client *i2c)
{
struct fsa4480_priv *fsa_priv;
struct device_node *np = i2c->dev.of_node;
int rc = 0;
int ret = 0;
u32 prev_control = 0, prev_enable = 0;
fsa_priv = devm_kzalloc(&i2c->dev, sizeof(*fsa_priv),
GFP_KERNEL);
@ -341,7 +352,17 @@ static int fsa4480_probe(struct i2c_client *i2c)
fsa_priv->dev = &i2c->dev;
ret = of_property_read_u32(np, "add-fsa4480-reset-probe", &add_fsa4480_reset_probe_value);
if (ret) {
dev_err(fsa_priv->dev, "%s get add fsa4480-reset-probe failed,ret = %d\n", __func__, ret);
}
fsa_priv->regmap = devm_regmap_init_i2c(i2c, &fsa4480_regmap_config);
dev_info(fsa_priv->dev, "%s add_fsa4480_reset_probe_value = %d\n", __func__, add_fsa4480_reset_probe_value);
if (IS_ERR_OR_NULL(fsa_priv->regmap)) {
dev_err(fsa_priv->dev, "%s: Failed to initialize regmap: %d\n",
__func__, rc);
@ -354,6 +375,13 @@ static int fsa4480_probe(struct i2c_client *i2c)
}
fsa4480_update_reg_defaults(fsa_priv->regmap);
if (add_fsa4480_reset_probe_value) {
regmap_read(fsa_priv->regmap, FSA4480_SWITCH_CONTROL, &prev_control);
regmap_read(fsa_priv->regmap, FSA4480_SWITCH_SETTINGS, &prev_enable);
dev_info(fsa_priv->dev, "%s default Read control:%u enable:%u \n", __func__, prev_control, prev_enable);
}
devm_regmap_qti_debugfs_register(fsa_priv->dev, fsa_priv->regmap);
fsa_priv->ucsi_nb.notifier_call = fsa4480_usbc_event_changed;
@ -395,6 +423,16 @@ static void fsa4480_remove(struct i2c_client *i2c)
dev_set_drvdata(&i2c->dev, NULL);
}
static void fsa4480_shutdown(struct i2c_client *i2c)
{
if (add_fsa4480_reset_probe_value) {
struct fsa4480_priv *fsa_priv =
(struct fsa4480_priv *)i2c_get_clientdata(i2c);
regmap_write(fsa_priv->regmap, FSA4480_RESET, 0x01);
dev_info(fsa_priv->dev, "%s write FSA4480 RESET shutdown okay\n", __func__);
}
}
static const struct of_device_id fsa4480_i2c_dt_match[] = {
{
.compatible = "qcom,fsa4480-i2c",
@ -410,6 +448,7 @@ static struct i2c_driver fsa4480_i2c_driver = {
},
.probe = fsa4480_probe,
.remove = fsa4480_remove,
.shutdown = fsa4480_shutdown,
};
static int __init fsa4480_init(void)

View file

@ -99,6 +99,9 @@ struct subsystem_data {
u32 smem_item;
u32 pid;
bool not_present;
#ifdef CONFIG_SUSPEND_DEBUG_MODULE
bool debugfs;
#endif
};
static struct subsystem_data subsystems[] = {
@ -724,6 +727,53 @@ int cx_stats_get_ss_vote_info(int ss_count,
}
EXPORT_SYMBOL_GPL(cx_stats_get_ss_vote_info);
#ifdef CONFIG_SUSPEND_DEBUG_MODULE
static ssize_t print_supsystem_sleep_stats(int i, struct sleep_stats *stat,
const char *name)
{
static uint64_t prev_duration[ARRAY_SIZE(subsystems)];
u64 accumulated = stat->accumulated;
uint64_t delta_duration;
/*
* If a subsystem is in sleep when reading the sleep stats adjust
* the accumulated sleep duration to show actual sleep time.
*/
if (stat->last_entered_at > stat->last_exited_at)
accumulated += arch_timer_read_counter()
- stat->last_entered_at;
delta_duration = accumulated - prev_duration[i];
prev_duration[i] = accumulated;
return printk("%s:\tAccumulated Duration:0x%llx, %llu.%03llu\n\n",
name, accumulated, delta_duration / 19200000L, delta_duration % 19200000L * 1000 / 19200000L);
}
ssize_t show_subsystem_sleep_stats(void)
{
ssize_t length = 0;
int i = 0;
struct subsystem_data *subsystem;
struct sleep_stats *stat;
for (i = 0; i < ARRAY_SIZE(subsystems); i++) {
subsystem = &subsystems[i];
if (!subsystem->debugfs)
continue;
stat = qcom_smem_get(subsystem->pid, subsystem->smem_item, NULL);
if (IS_ERR(stat))
continue;
length += print_supsystem_sleep_stats(i, stat,
subsystem->name);
}
return length;
}
EXPORT_SYMBOL_GPL(show_subsystem_sleep_stats);
#endif
int ddr_stats_get_change_his(struct ddr_stats_change_his_info *ddr_his_info)
{
static const char buf[MAX_MSG_LEN] = "{class: misc_debug, res: ddr_his}";
@ -1042,6 +1092,9 @@ static void qcom_create_subsystem_stat_files(struct dentry *root,
for (j = 0; j < ARRAY_SIZE(subsystems); j++) {
if (!strcmp(subsystems[j].name, name)) {
#ifdef CONFIG_SUSPEND_DEBUG_MODULE
subsystems[j].debugfs = true;
#endif
debugfs_create_file(subsystems[j].name, 0400, root,
(void *)&subsystems[j],
&qcom_subsystem_sleep_stats_fops);

View file

@ -165,3 +165,45 @@ config SCSI_UFS_CRYPTO_QTI
Select this to enable QCOM Hardware Wrapped Key support for the
ICE hardware.
config UFSFEATURE
bool "UFS feature activate"
depends on SCSI_UFSHCD
help
UFS feature activate such as tw, hid and etc.
config UFSHID
bool "UFS Host Initiated Defrag support"
depends on SCSI_UFSHCD && UFSFEATURE
help
UFS HID Feature Enable
config UFSHID_POC
bool "UFSHID_POC test"
depends on SCSI_UFSHCD && UFSFEATURE && UFSHID
help
UFS HID POC test
1. block to enter suspend state
2. auto_hibern8 enable/disable (HCI)
3. set flag bDefragOperation
4. debug msg enable (default : disable)
config MICRON_UFSHID
tristate "micron Host Initiated Defrag support"
depends on SCSI_UFSHCD && UFSFEATURE && UFSHID
help
Enable Micron HID feature
config SCSI_SKHID
bool "SKHix UFS Host Initiated Defrag supportr"
depends on SCSI_UFSHCD
help
SKHix UFS HID Feature Enable
config UFS_LONGSYS_RT_CP_TIMEOUT
bool "Moto fix Longsys UFS CP0 Timeout issue with hooks"
depends on SCSI_UFSHCD
default n
help
Enable on products that use Longsys UFS.
This require Kernel support on mcq vendor hook like in kernel 5.15.

View file

@ -4,6 +4,10 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.
obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o
obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o
obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
ufs-qcom-y += ufs_qcom.o
ufs-qcom-$(CONFIG_UFSFEATURE) += vendor/ufsfeature.o vendor/ufsfeature-mimic.o
ufs-qcom-$(CONFIG_UFSHID) += vendor/ufshid.o
ufs-qcom-$(CONFIG_SCSI_SKHID) += vendor/ufs-manual-gc.o
obj-$(CONFIG_SCSI_UFS_CRYPTO_QTI) += ufshcd-crypto-qti.o
obj-$(CONFIG_SCSI_UFS_EXYNOS) += ufs-exynos.o
obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o

View file

@ -40,6 +40,7 @@
#include <soc/qcom/ice.h>
#include <trace/hooks/ufshcd.h>
#include <ufs/ufshcd.h>
#include "ufshcd-pltfrm.h"
#include <ufs/unipro.h>
@ -49,6 +50,9 @@
#include <ufs/ufshci.h>
#include <ufs/ufs_quirks.h>
#include <ufs/ufshcd-crypto-qti.h>
#if defined(CONFIG_SCSI_SKHID)
char storage_mfrid[32];
#endif
#define MCQ_QCFGPTR_MASK GENMASK(7, 0)
#define MCQ_QCFGPTR_UNIT 0x200
@ -462,6 +466,34 @@ static inline void cancel_dwork_unvote_cpufreq(struct ufs_hba *hba)
}
}
#if defined(CONFIG_SCSI_SKHID)
static int get_storage_info(struct ufs_hba *hba)
{
int ret = 0;
struct property *p;
struct device_node *n;
memset(storage_mfrid, 0, sizeof(storage_mfrid));
n = of_find_node_by_path("/chosen/mmi,storage");
if (n == NULL) {
ret = 1;
goto err;
}
for_each_property_of_node(n, p) {
if (!strcmp(p->name, "manufacturer") && p->value)
strlcpy(storage_mfrid, (char *)p->value, sizeof(storage_mfrid));
}
of_node_put(n);
dev_info(hba->dev, "manufacturer parsed from choosen is %s\n", storage_mfrid);
err:
return ret;
}
#endif
static int ufs_qcom_get_pwr_dev_param(struct ufs_qcom_dev_params *qcom_param,
struct ufs_pa_layer_attr *dev_max,
struct ufs_pa_layer_attr *agreed_pwr)
@ -553,6 +585,83 @@ static int ufs_qcom_get_pwr_dev_param(struct ufs_qcom_dev_params *qcom_param,
return 0;
}
#if defined(CONFIG_UFSFEATURE)
static void ufs_vh_prep_fn(void *data, struct ufs_hba *hba, struct request *rq,
struct ufshcd_lrb *lrbp, int *err)
{
*err = ufsf_prep_fn(ufs_qcom_get_ufsf(hba), lrbp);
}
static void ufs_vh_compl_command(void *data, struct ufs_hba *hba,
struct ufshcd_lrb *lrbp)
{
struct scsi_cmnd *cmd = lrbp->cmd;
int scsi_status, result, ocs;
unsigned long *outstanding_reqs;
unsigned long out_tasks = 0;
unsigned long ongoing_cnt = 0;
int tmp_tag, nr_tag;
if (!cmd)
return;
ocs = lrbp->utr_descriptor_ptr->header.ocs & MASK_OCS;
if (ocs != OCS_SUCCESS)
goto check_last_req;
result = lrbp->ucd_rsp_ptr->header.transaction_code;
if (result != UPIU_TRANSACTION_RESPONSE)
goto check_last_req;
scsi_status = lrbp->ucd_rsp_ptr->header.status;
if (scsi_status != SAM_STAT_GOOD)
goto check_last_req;;
ufsf_upiu_check_for_ccd(lrbp);
outstanding_reqs = &hba->outstanding_reqs;
nr_tag = hba->nutrs;
for_each_set_bit(tmp_tag, outstanding_reqs, nr_tag) {
ongoing_cnt = 1;
break;
}
out_tasks = hba->outstanding_tasks;
check_last_req:
#if defined(CONFIG_UFSHID)
/* Check if it is the last request to be completed */
if (!out_tasks && !ongoing_cnt) {
struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba);
schedule_work(&ufsf->on_idle_work);
}
#endif
;
}
#endif
#if defined(CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT)
static void ufs_longsys_clear_cp_flag_hook(void *data, struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
{
if (!lrbp || !lrbp->ucd_req_ptr || !lrbp->cmd)
return;
struct request *rq = scsi_cmd_to_rq(lrbp->cmd);
struct ufs_dev_info *dev_info = &hba->dev_info;
unsigned int ioprio_class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
if (ioprio_class == IOPRIO_CLASS_RT && dev_info->wmanufacturerid == UFS_VENDOR_LONGSYS) {
struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
if (ucd_req_ptr->header.flags & UPIU_CMD_FLAGS_CP){
ucd_req_ptr->header.flags &= ~UPIU_CMD_FLAGS_CP;
}
}
}
#endif
static struct ufs_qcom_host *rcdev_to_ufs_host(struct reset_controller_dev *rcd)
{
return container_of(rcd, struct ufs_qcom_host, rcdev);
@ -2040,8 +2149,12 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
int err = 0;
if (status == PRE_CHANGE)
if (status == PRE_CHANGE) {
#if defined(CONFIG_UFSFEATURE)
ufsf_suspend(ufs_qcom_get_ufsf(hba), pm_op == UFS_SYSTEM_PM);
#endif
return 0;
}
/*
* If UniPro link is not active or OFF, PHY ref_clk, main PHY analog
@ -2083,6 +2196,11 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
{
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
int err;
#if defined(CONFIG_UFSFEATURE)
struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba);
schedule_work(&ufsf->resume_work);
#endif
if (host->vddp_ref_clk && (hba->rpm_lvl > UFS_PM_LVL_3 ||
hba->spm_lvl > UFS_PM_LVL_3))
@ -4188,6 +4306,18 @@ static int ufs_qcom_init(struct ufs_hba *hba)
ufs_qcom_parse_irq_affinity(hba);
ufs_qcom_ber_mon_init(hba);
ufs_qcom_storage_boost_param_init(hba);
#if defined(CONFIG_SCSI_SKHID)
get_storage_info(hba);
if ((IS_SKHYNIX_DEVICE(storage_mfrid)) || (IS_HYNIX_DEVICE(storage_mfrid))) {
err = pixel_init(hba);
if (err) {
return err;
}
pixel_init_manual_gc(hba);
}
#endif
host->ufs_ipc_log_ctx = ipc_log_context_create(UFS_QCOM_MAX_LOG_SZ,
"ufs-qcom", 0);
if (!host->ufs_ipc_log_ctx)
@ -4629,6 +4759,10 @@ static void ufs_qcom_event_notify(struct ufs_hba *hba,
bool ber_th_exceeded = false;
bool disable_ber = true;
#if defined(CONFIG_UFSFEATURE)
if (evt == UFS_EVT_WL_SUSP_ERR)
ufsf_resume(ufs_qcom_get_ufsf(hba), true);
#endif
switch (evt) {
case UFS_EVT_PA_ERR:
if (disable_ber) {
@ -5230,6 +5364,9 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba)
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
int ret = 0;
#if defined(CONFIG_UFSFEATURE)
ufsf_reset_host(ufs_qcom_get_ufsf(hba));
#endif
/* reset gpio is optional */
if (!host->device_reset)
return -EOPNOTSUPP;
@ -5319,6 +5456,9 @@ static struct ufs_dev_quirk ufs_qcom_dev_fixups[] = {
static void ufs_qcom_fixup_dev_quirks(struct ufs_hba *hba)
{
ufshcd_fixup_dev_quirks(hba, ufs_qcom_dev_fixups);
#if defined(CONFIG_UFSFEATURE)
ufsf_set_init_state(hba);
#endif
}
/* Resources */
@ -5546,6 +5686,16 @@ out:
return ret;
}
static void ufs_qcom_config_scsi_dev(struct scsi_device *sdev)
{
#if defined(CONFIG_UFSFEATURE)
struct ufs_hba *hba = shost_priv(sdev->host);
struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba);
ufsf_slave_configure(ufsf, sdev);
#endif
}
/*
* struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
*
@ -5577,8 +5727,24 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
.op_runtime_config = ufs_qcom_op_runtime_config,
.get_outstanding_cqs = ufs_qcom_get_outstanding_cqs,
.config_esi = ufs_qcom_config_esi,
.config_scsi_dev = ufs_qcom_config_scsi_dev,
};
#if defined(CONFIG_UFSFEATURE)
static void ufs_samsung_register_hooks(void)
{
register_trace_android_vh_ufs_prepare_command(ufs_vh_prep_fn, NULL);
register_trace_android_vh_ufs_compl_command(ufs_vh_compl_command, NULL);
}
#endif
#if defined(CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT)
static void ufs_longsys_register_hooks(void)
{
register_trace_android_vh_ufs_send_command(ufs_longsys_clear_cp_flag_hook, NULL);
}
#endif
/**
* QCOM specific sysfs group and nodes
*/
@ -6365,6 +6531,14 @@ static int ufs_qcom_probe(struct platform_device *pdev)
return dev_err_probe(dev, err, "ufshcd_pltfrm_init() failed\n");
ufs_qcom_register_hooks();
#if defined(CONFIG_UFSFEATURE)
/* Register hook for Samsung feature */
ufs_samsung_register_hooks();
#endif
#if defined(CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT)
/* Register hook for Longsys feature */
ufs_longsys_register_hooks();
#endif
return err;
}
@ -6401,7 +6575,9 @@ static int ufs_qcom_remove(struct platform_device *pdev)
if (msm_minidump_enabled())
atomic_notifier_chain_unregister(&panic_notifier_list,
&host->ufs_qcom_panic_nb);
#if defined(CONFIG_UFSFEATURE)
ufsf_remove(ufs_qcom_get_ufsf(hba));
#endif
ufshcd_remove(hba);
if (host->esi_enabled)
platform_msi_domain_free_irqs(hba->dev);

View file

@ -16,6 +16,17 @@
#include <ufs/ufshcd.h>
#include <ufs/unipro.h>
#if defined(CONFIG_UFSFEATURE)
#include "vendor/ufsfeature.h"
#endif
#if defined(CONFIG_SCSI_SKHID)
#include "vendor/ufs-manual-gc.h"
#endif
#if defined(CONFIG_UFS_LONGSYS_RT_CP_TIMEOUT)
#define UFS_VENDOR_LONGSYS 0xBD6
#endif
#define MAX_UFS_QCOM_HOSTS 2
#define MAX_U32 (~(u32)0)
#define MPHY_TX_FSM_STATE 0x41
@ -32,6 +43,22 @@
#define UFS_VENDOR_MICRON 0x12C
#if defined(CONFIG_SCSI_SKHID)
#define IS_SKHYNIX_DEVICE(mfrid) (0 == strncasecmp(mfrid,"SKHYNIX", sizeof("SKHYNIX")))
#define IS_HYNIX_DEVICE(mfrid) (0 == strncasecmp(mfrid,"HYNIX", sizeof("HYNIX")))
#endif
#if defined(CONFIG_UFSFEATURE) || defined(CONFIG_SCSI_SKHID)
#ifndef ufshcd_set_eh_in_progress
/* UFSHCD error handling flags */
enum {
UFSHCD_EH_IN_PROGRESS = (1 << 0),
};
#define ufshcd_eh_in_progress(h) \
((h)->eh_flags & UFSHCD_EH_IN_PROGRESS)
#endif
#endif
#define SLOW 1
#define FAST 2
@ -625,6 +652,14 @@ struct ufs_qcom_host {
unsigned int boost_monitor_timer;
u32 min_boost_thres;
u32 max_boost_thres;
#if defined(CONFIG_UFSFEATURE)
struct ufsf_feature ufsf;
#endif
#if defined(CONFIG_SCSI_SKHID)
struct work_struct update_sysfs_work;
/* manual_gc */
struct ufs_manual_gc manual_gc;
#endif
};
static inline u32
@ -757,4 +792,12 @@ static inline void ufs_qcom_ice_debug(struct ufs_qcom_host *host)
}
#endif /* !CONFIG_SCSI_UFS_CRYPTO */
#if defined(CONFIG_UFSFEATURE)
static inline struct ufsf_feature *ufs_qcom_get_ufsf(struct ufs_hba *hba)
{
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
return &host->ufsf;
}
#endif
#endif /* UFS_QCOM_H_ */

1
drivers/ufs/host/ufs_qcom.c Symbolic link
View file

@ -0,0 +1 @@
ufs-qcom.c

258
drivers/ufs/host/vendor/ufs-manual-gc.c vendored Normal file
View file

@ -0,0 +1,258 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Pixel-Specific UFS feature support
*
* Copyright 2020 Google LLC
*
* Authors: Jaegeuk Kim <jaegeuk@google.com>
*/
#include "ufs-qcom.h"
#include <trace/hooks/ufshcd.h>
extern struct workqueue_struct *system_highpri_wq;
/* for manual gc */
static ssize_t manual_gc_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
struct ufs_qcom_host *ufs = ufshcd_get_variant(hba);
u32 status = MANUAL_GC_OFF;
if (ufs->manual_gc.state == MANUAL_GC_DISABLE)
return scnprintf(buf, PAGE_SIZE, "%s", "disabled\n");
if (ufs->manual_gc.hagc_support) {
int err;
if (!ufshcd_eh_in_progress(hba)) {
pm_runtime_get_sync(hba->dev);
err = ufshcd_query_attr_retry(hba,
UPIU_QUERY_OPCODE_READ_ATTR,
QUERY_ATTR_IDN_MANUAL_GC_STATUS, 0, 0, &status);
pm_runtime_put_sync(hba->dev);
ufs->manual_gc.hagc_support = err ? false: true;
}
}
if (!ufs->manual_gc.hagc_support)
return scnprintf(buf, PAGE_SIZE, "%s", "bkops\n");
return scnprintf(buf, PAGE_SIZE, "%s",
status == MANUAL_GC_OFF ? "off\n" : "on\n");
}
static int manual_gc_enable(struct ufs_hba *hba, u32 *value)
{
int ret;
if (ufshcd_eh_in_progress(hba))
return -EBUSY;
pm_runtime_get_sync(hba->dev);
ret = ufshcd_query_attr_retry(hba,
UPIU_QUERY_OPCODE_WRITE_ATTR,
QUERY_ATTR_IDN_MANUAL_GC_CONT, 0, 0,
value);
pm_runtime_put_sync(hba->dev);
return ret;
}
static u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
{
if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
return hba->dev_info.wb_dedicated_lu;
return 0;
}
static ssize_t manual_gc_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
struct ufs_qcom_host *ufs = ufshcd_get_variant(hba);
u32 value;
int err = 0;
if (kstrtou32(buf, 0, &value))
return -EINVAL;
if (value >= MANUAL_GC_MAX)
return -EINVAL;
if (ufshcd_eh_in_progress(hba))
return -EBUSY;
if (value == MANUAL_GC_DISABLE || value == MANUAL_GC_ENABLE) {
ufs->manual_gc.state = value;
return count;
}
if (ufs->manual_gc.state == MANUAL_GC_DISABLE)
return count;
if (ufs->manual_gc.hagc_support)
ufs->manual_gc.hagc_support =
manual_gc_enable(hba, &value) ? false : true;
pm_runtime_get_sync(hba->dev);
if (!ufs->manual_gc.hagc_support) {
err = ufshcd_bkops_ctrl(hba, (value == MANUAL_GC_ON) ?
BKOPS_STATUS_NON_CRITICAL:
BKOPS_STATUS_CRITICAL);
if (!hba->auto_bkops_enabled)
err = -EAGAIN;
}
/* flush wb buffer */
if (hba->dev_info.wspecversion >= 0x0310) {
enum query_opcode opcode = (value == MANUAL_GC_ON) ?
UPIU_QUERY_OPCODE_SET_FLAG:
UPIU_QUERY_OPCODE_CLEAR_FLAG;
u8 index = ufshcd_wb_get_query_index(hba);
ufshcd_query_flag_retry(hba, opcode,
QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8,
index, NULL);
ufshcd_query_flag_retry(hba, opcode,
QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, index, NULL);
}
if (err || hrtimer_active(&ufs->manual_gc.hrtimer)) {
pm_runtime_put_sync(hba->dev);
return count;
} else {
/* pm_runtime_put_sync in delay_ms */
hrtimer_start(&ufs->manual_gc.hrtimer,
ms_to_ktime(ufs->manual_gc.delay_ms),
HRTIMER_MODE_REL);
}
return count;
}
/* for manual gc */
static ssize_t manual_gc_status_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
struct ufs_qcom_host *ufs = ufshcd_get_variant(hba);
u32 status = MANUAL_GC_OFF;
if (ufs->manual_gc.state == MANUAL_GC_DISABLE)
return scnprintf(buf, PAGE_SIZE, "%s", "disabled\n");
if (ufs->manual_gc.hagc_support) {
int err;
if (!ufshcd_eh_in_progress(hba)) {
pm_runtime_get_sync(hba->dev);
err = ufshcd_query_attr_retry(hba,
UPIU_QUERY_OPCODE_READ_ATTR,
QUERY_ATTR_IDN_MANUAL_GC_STATUS, 0, 0, &status);
pm_runtime_put_sync(hba->dev);
ufs->manual_gc.hagc_support = err ? false: true;
}
}
if (!ufs->manual_gc.hagc_support)
return scnprintf(buf, PAGE_SIZE, "%s", "bkops\n");
return scnprintf(buf, PAGE_SIZE, "%u", status);
}
static ssize_t manual_gc_hold_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
struct ufs_qcom_host *ufs = ufshcd_get_variant(hba);
return snprintf(buf, PAGE_SIZE, "%lu\n", ufs->manual_gc.delay_ms);
}
static ssize_t manual_gc_hold_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
struct ufs_qcom_host *ufs = ufshcd_get_variant(hba);
unsigned long value;
if (kstrtoul(buf, 0, &value))
return -EINVAL;
ufs->manual_gc.delay_ms = value;
return count;
}
static enum hrtimer_restart pixel_mgc_hrtimer_handler(struct hrtimer *timer)
{
struct ufs_qcom_host *ufs = container_of(timer, struct ufs_qcom_host,
manual_gc.hrtimer);
queue_work(ufs->manual_gc.mgc_workq, &ufs->manual_gc.hibern8_work);
return HRTIMER_NORESTART;
}
static void pixel_mgc_hibern8_work(struct work_struct *work)
{
struct ufs_qcom_host *ufs = container_of(work, struct ufs_qcom_host,
manual_gc.hibern8_work);
pm_runtime_put_sync(ufs->hba->dev);
/* bkops will be disabled when power down */
}
void pixel_init_manual_gc(struct ufs_hba *hba)
{
struct ufs_qcom_host *ufs = ufshcd_get_variant(hba);
struct ufs_manual_gc *mgc = &ufs->manual_gc;
char wq_name[sizeof("ufs_mgc_hibern8_work") + 5];
mgc->state = MANUAL_GC_ENABLE;
mgc->hagc_support = true;
mgc->delay_ms = UFSHCD_MANUAL_GC_HOLD_HIBERN8;
hrtimer_init(&mgc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
mgc->hrtimer.function = pixel_mgc_hrtimer_handler;
INIT_WORK(&mgc->hibern8_work, pixel_mgc_hibern8_work);
snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_mgc_hibern8_work_%d",
hba->host->host_no);
ufs->manual_gc.mgc_workq = create_singlethread_workqueue(wq_name);
}
static DEVICE_ATTR_RW(manual_gc);
static DEVICE_ATTR_RO(manual_gc_status);
static DEVICE_ATTR_RW(manual_gc_hold);
static struct attribute *pixel_sysfs_ufshcd_attrs[] = {
&dev_attr_manual_gc.attr,
&dev_attr_manual_gc_hold.attr,
NULL
};
static struct attribute *pixel_sysfs_ufshcd_hagc_status_attrs[] = {
&dev_attr_manual_gc_status.attr,
NULL
};
static const struct attribute_group pixel_sysfs_hagc_status_group = {
.name = "attributes_hid",
.attrs = pixel_sysfs_ufshcd_hagc_status_attrs,
};
static const struct attribute_group pixel_sysfs_default_group = {
.attrs = pixel_sysfs_ufshcd_attrs,
};
static const struct attribute_group *pixel_sysfs_hid_groups[] = {
&pixel_sysfs_default_group,
&pixel_sysfs_hagc_status_group,
NULL,
};
static void pixel_ufs_update_sysfs_work(struct work_struct *work)
{
struct ufs_qcom_host *ufs = container_of(work, struct ufs_qcom_host,
update_sysfs_work);
struct ufs_hba *hba = ufs->hba;
int err;
err = sysfs_create_groups(&hba->dev->kobj,
pixel_sysfs_hid_groups);
if (err)
dev_err(hba->dev, "%s: Failed to add a pixel group\n",
__func__);
}
static void pixel_ufs_update_sysfs(void *data, struct ufs_hba *hba)
{
struct ufs_qcom_host *ufs = ufshcd_get_variant(hba);
queue_work(system_highpri_wq, &ufs->update_sysfs_work);
}
int pixel_init(struct ufs_hba *hba)
{
struct ufs_qcom_host *ufs = ufshcd_get_variant(hba);
int ret;
ret = register_trace_android_vh_ufs_update_sysfs(
pixel_ufs_update_sysfs, NULL);
if (ret)
return ret;
INIT_WORK(&ufs->update_sysfs_work, pixel_ufs_update_sysfs_work);
return 0;
}

41
drivers/ufs/host/vendor/ufs-manual-gc.h vendored Normal file
View file

@ -0,0 +1,41 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Manual GC support
*
* Copyright 2020 Google LLC
*
* Authors: Jaegeuk Kim <jaegeuk@google.com>
*/
#ifndef _UFS_MANUAL_GC_H_
#define _UFS_MANUAL_GC_H_
#include <asm/unaligned.h>
#include <ufs/ufshcd.h>
/* manual gc */
struct ufs_manual_gc {
int state;
bool hagc_support;
struct hrtimer hrtimer;
unsigned long delay_ms;
struct work_struct hibern8_work;
struct workqueue_struct *mgc_workq;
};
#define UFSHCD_MANUAL_GC_HOLD_HIBERN8 2000 /* 2 seconds */
#define QUERY_ATTR_IDN_MANUAL_GC_CONT 0x12
#define QUERY_ATTR_IDN_MANUAL_GC_STATUS 0x13
enum {
MANUAL_GC_OFF = 0,
MANUAL_GC_ON,
MANUAL_GC_DISABLE,
MANUAL_GC_ENABLE,
MANUAL_GC_MAX,
};
extern void pixel_init_manual_gc(struct ufs_hba *hba);
extern int pixel_init(struct ufs_hba *hba);
#endif

View file

@ -0,0 +1,96 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Samsung UFS Feature Mimic for android15-6.6
* commit 3009510505edcc8a0622b6c99925fb841b5e132e
* Date: Fri Aug 16 14:33:14 2024 +0000
*
* from
*
* linux/drivers/ufs/core/ufshcd.c
*/
#include <ufs/ufshcd.h>
void ufsf_scsi_unblock_requests(struct ufs_hba *hba)
{
if (atomic_dec_and_test(&hba->scsi_block_reqs_cnt))
scsi_unblock_requests(hba->host);
}
void ufsf_scsi_block_requests(struct ufs_hba *hba)
{
if (atomic_inc_return(&hba->scsi_block_reqs_cnt) == 1)
scsi_block_requests(hba->host);
}
static u32 ufsf_pending_cmds(struct ufs_hba *hba)
{
const struct scsi_device *sdev;
u32 pending = 0;
lockdep_assert_held(hba->host->host_lock);
__shost_for_each_device(sdev, hba->host)
pending += sbitmap_weight(&sdev->budget_map);
return pending;
}
int ufsf_wait_for_doorbell_clr(struct ufs_hba *hba, u64 wait_timeout_us)
{
unsigned long flags;
int ret = 0;
u32 tm_doorbell;
u32 tr_pending;
bool timeout = false, do_last_check = false;
ktime_t start;
ufshcd_hold(hba);
spin_lock_irqsave(hba->host->host_lock, flags);
/*
* Wait for all the outstanding tasks/transfer requests.
* Verify by checking the doorbell registers are clear.
*/
start = ktime_get();
do {
if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) {
ret = -EBUSY;
goto out;
}
tm_doorbell = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL);
tr_pending = ufsf_pending_cmds(hba);
if (!tm_doorbell && !tr_pending) {
timeout = false;
break;
} else if (do_last_check) {
break;
}
spin_unlock_irqrestore(hba->host->host_lock, flags);
io_schedule_timeout(msecs_to_jiffies(20));
if (ktime_to_us(ktime_sub(ktime_get(), start)) >
wait_timeout_us) {
timeout = true;
/*
* We might have scheduled out for long time so make
* sure to check if doorbells are cleared by this time
* or not.
*/
do_last_check = true;
}
spin_lock_irqsave(hba->host->host_lock, flags);
} while (tm_doorbell || tr_pending);
if (timeout) {
dev_err(hba->dev,
"%s: timedout waiting for doorbell to clear (tm=0x%x, tr=0x%x)\n",
__func__, tm_doorbell, tr_pending);
ret = -EBUSY;
}
out:
spin_unlock_irqrestore(hba->host->host_lock, flags);
ufshcd_release(hba);
return ret;
}
MODULE_LICENSE("GPL v2");

420
drivers/ufs/host/vendor/ufsfeature.c vendored Executable file
View file

@ -0,0 +1,420 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Universal Flash Storage Feature Support
*
* Copyright (C) 2017-2018 Samsung Electronics Co., Ltd.
*
* Authors:
* Yongmyung Lee <ymhungry.lee@samsung.com>
* Jinyoung Choi <j-young.choi@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* See the COPYING file in the top-level directory or visit
* <http://www.gnu.org/licenses/gpl-2.0.html>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This program is provided "AS IS" and "WITH ALL FAULTS" and
* without warranty of any kind. You are solely responsible for
* determining the appropriateness of using and distributing
* the program and assume all risks associated with your exercise
* of rights with respect to the program, including but not limited
* to infringement of third party rights, the risks and costs of
* program errors, damage to or loss of data, programs or equipment,
* and unavailability or interruption of operations. Under no
* circumstances will the contributor of this Program be liable for
* any damages of any kind arising from your use or distribution of
* this program.
*
* The Linux Foundation chooses to take subject only to the GPLv2
* license terms, and distributes only under these terms.
*/
#include "ufsfeature.h"
#include <ufs/ufshcd.h>
#include "../core/ufshcd-priv.h"
#include "ufs-qcom.h"
#if defined(CONFIG_SCSI_SKHID)
extern char storage_mfrid[32];
#endif
static int ufsf_read_desc(struct ufs_hba *hba, u8 desc_id, u8 desc_index,
u8 selector, u8 *desc_buf, u32 size)
{
int err = 0;
ufshcd_rpm_get_sync(hba);
err = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC,
desc_id, desc_index, selector,
desc_buf, &size);
if (err)
ERR_MSG("reading Device Desc failed. err = %d", err);
ufshcd_rpm_put_sync(hba);
return err;
}
static int ufsf_read_dev_desc(struct ufsf_feature *ufsf)
{
u8 desc_buf[UFSF_QUERY_DESC_DEVICE_MAX_SIZE];
int ret;
ret = ufsf_read_desc(ufsf->hba, QUERY_DESC_IDN_DEVICE, 0,
UFSFEATURE_SELECTOR, desc_buf,
UFSF_QUERY_DESC_DEVICE_MAX_SIZE);
if (ret)
return ret;
INFO_MSG("device lu count %d", desc_buf[DEVICE_DESC_PARAM_NUM_LU]);
INFO_MSG("length=%u(0x%x) bSupport=0x%.2x, extend=0x%.2x_%.2x",
desc_buf[DEVICE_DESC_PARAM_LEN],
desc_buf[DEVICE_DESC_PARAM_LEN],
desc_buf[DEVICE_DESC_PARAM_UFS_FEAT],
desc_buf[DEVICE_DESC_PARAM_EX_FEAT_SUP+2],
desc_buf[DEVICE_DESC_PARAM_EX_FEAT_SUP+3]);
INFO_MSG("samsung extend=0x%.2x_%.2x",
desc_buf[DEVICE_DESC_PARAM_SAMSUNG_SUP+2],
desc_buf[DEVICE_DESC_PARAM_SAMSUNG_SUP+3]);
INFO_MSG("Driver Feature Version : (%.6X%s)", UFSFEATURE_DD_VER,
UFSFEATURE_DD_VER_POST);
#if defined(CONFIG_UFSHID)
ufshid_get_dev_info(ufsf, desc_buf);
#endif
return 0;
}
void ufsf_device_check(struct ufs_hba *hba)
{
struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba);
if (ufsf_read_dev_desc(ufsf))
return;
}
inline void ufsf_rpm_put_noidle(struct ufs_hba *hba)
{
pm_runtime_put_noidle(&hba->ufs_device_wlun->sdev_gendev);
}
#define PRINT_BUF_SIZE 1024
void ufsf_print_buf(const unsigned char *field, int size)
{
unsigned char buf[PRINT_BUF_SIZE];
int count;
int i;
if (size > PRINT_BUF_SIZE)
size = PRINT_BUF_SIZE;
count = snprintf(buf, 10, "(0x0000):");
for (i = 0; i < size; i++) {
count += snprintf(buf + count, 4, " %02X", field[i]);
if ((i + 1) % 16 == 0) {
buf[count] = '\n';
buf[count + 1] = '\0';
printk(buf);
count = 0;
count += snprintf(buf, 10, "(0x%04X):", i + 1);
} else if ((i + 1) % 4 == 0)
count += snprintf(buf + count, 3, " :");
}
buf[count] = '\n';
buf[count + 1] = '\0';
printk(buf);
}
/*
* Mimic ufshcd_copy_sense_data()
*/
#define UFS_SENSE_SIZE 18
static inline void ufsf_copy_sense_data(struct ufshcd_lrb *lrbp)
{
u8 *const sense_buffer = lrbp->cmd->sense_buffer;
u16 resp_len;
int len;
resp_len = be16_to_cpu(lrbp->ucd_rsp_ptr->header.data_segment_length);
if (sense_buffer && resp_len) {
int len_to_copy;
len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);
len_to_copy = min_t(int, UFS_SENSE_SIZE, len);
memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,
len_to_copy);
}
}
void ufsf_upiu_check_for_ccd(struct ufshcd_lrb *lrbp)
{
unsigned char *cdb = lrbp->cmd->cmnd;
int data_seg_len, sense_data_len;
struct utp_cmd_rsp *sr = &lrbp->ucd_rsp_ptr->sr;
if (cdb[0] != VENDOR_OP || cdb[1] != VENDOR_CCD)
return;
data_seg_len =
be16_to_cpu(lrbp->ucd_rsp_ptr->header.data_segment_length);
sense_data_len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);
if (data_seg_len != CCD_DATA_SEG_LEN ||
sense_data_len != CCD_SENSE_DATA_LEN) {
WARN_MSG("CCD info is wrong. so check it.");
WARN_MSG("CCD data_seg_len = %d, sense_data_len %d",
data_seg_len, sense_data_len);
} else {
INFO_MSG("CCD info is correct!!");
}
INFO_MSG("sense : %02X %02X %02X %02X %02X %02X\n",
sr->sense_data[0], sr->sense_data[1], sr->sense_data[2],
sr->sense_data[3], sr->sense_data[4], sr->sense_data[5]);
/*
* sense_len will be not set as Descriptor Type isn't 0x70
* if not set sense_len, sense will not be able to copy
* in sg_scsi_ioctl()
*/
lrbp->cmd->sense_len = CCD_SENSE_DATA_LEN;
ufsf_copy_sense_data(lrbp);
}
inline bool ufsf_is_valid_lun(int lun)
{
return lun < UFS_UPIU_MAX_GENERAL_LUN;
}
inline void ufsf_slave_configure(struct ufsf_feature *ufsf,
struct scsi_device *sdev)
{
if (!ufsf_is_valid_lun(sdev->lun))
return;
ufsf->sdev_ufs_lu[sdev->lun] = sdev;
INFO_MSG("lun[%d] sdev(%p) q(%p)", (int)sdev->lun, sdev,
sdev->request_queue);
if (!ufsf->check_init)
schedule_work(&ufsf->device_check_work);
}
inline int ufsf_prep_fn(struct ufsf_feature *ufsf, struct ufshcd_lrb *lrbp)
{
int ret = 0;
/* This is for READ10_DEBUG (ufs-util) */
if (get_unaligned_be32(lrbp->cmd->cmnd + 2) == READ10_DEBUG_LBA) {
lrbp->lun = READ10_DEBUG_LUN;
INFO_MSG("Change lun to 0x%X", lrbp->lun);
return ret;
}
return ret;
}
/*
* called by ufshcd_vops_device_reset()
*/
inline void ufsf_reset_host(struct ufsf_feature *ufsf)
{
struct ufs_hba *hba = ufsf->hba;
struct Scsi_Host *host = hba->host;
unsigned long flags;
u32 eh_flags;
if (!ufsf->check_init)
return;
/*
* Check if it is error handling(eh) context.
*
* In the following cases, we can enter here even though it is not in eh
* context.
* - when ufshcd_is_link_off() is true in ufshcd_resume()
* - when ufshcd_vops_suspend() fails in ufshcd_suspend()
*/
spin_lock_irqsave(host->host_lock, flags);
eh_flags = ufshcd_eh_in_progress(hba);
spin_unlock_irqrestore(host->host_lock, flags);
if (!eh_flags)
return;
#if defined(CONFIG_UFSHID)
INFO_MSG("run reset_host.. hid_state(%d) -> HID_RESET",
ufshid_get_state(ufsf));
if (ufshid_get_state(ufsf) == HID_PRESENT)
ufshid_reset_host(ufsf);
#endif
schedule_work(&ufsf->reset_wait_work);
}
inline void ufsf_init(struct ufsf_feature *ufsf)
{
#if defined(CONFIG_UFSHID)
if (ufshid_get_state(ufsf) == HID_NEED_INIT)
ufshid_init(ufsf);
#endif
ufsf->check_init = true;
}
inline void ufsf_reset(struct ufsf_feature *ufsf)
{
#if defined(CONFIG_UFSHID)
if (ufshid_get_state(ufsf) == HID_RESET)
ufshid_reset(ufsf);
#endif
}
inline void ufsf_remove(struct ufsf_feature *ufsf)
{
#if defined(CONFIG_UFSHID)
if (ufshid_get_state(ufsf) == HID_PRESENT)
ufshid_remove(ufsf);
#endif
}
static void ufsf_device_check_work_handler(struct work_struct *work)
{
struct ufsf_feature *ufsf;
ufsf = container_of(work, struct ufsf_feature, device_check_work);
#if defined(CONFIG_SCSI_SKHID)
if ((IS_SKHYNIX_DEVICE(storage_mfrid)) || (IS_HYNIX_DEVICE(storage_mfrid)))
return;
#endif
if (ufsf->check_init)
return;
ufsf_device_check(ufsf->hba);
ufsf_init(ufsf);
}
/*
* worker to change the feature state to present after processing the error handler.
*/
static void ufsf_reset_wait_work_handler(struct work_struct *work)
{
struct ufsf_feature *ufsf;
struct ufs_hba *hba;
struct Scsi_Host *host;
u32 ufshcd_state;
unsigned long flags;
ufsf = container_of(work, struct ufsf_feature, reset_wait_work);
hba = ufsf->hba;
host = hba->host;
/*
* Wait completion of hba->eh_work.
*
* reset_wait_work is scheduled at ufsf_reset_host(),
* so it can be waken up before eh_work is completed.
*
* ufsf_reset must be called after eh_work has completed.
*/
flush_work(&hba->eh_work);
spin_lock_irqsave(host->host_lock, flags);
ufshcd_state = hba->ufshcd_state;
spin_unlock_irqrestore(host->host_lock, flags);
if (ufshcd_state == UFSHCD_STATE_OPERATIONAL)
ufsf_reset(ufsf);
}
static void ufsf_resume_work_handler(struct work_struct *work)
{
struct ufsf_feature *ufsf = container_of(work, struct ufsf_feature, resume_work);
struct ufs_hba *hba = ufsf->hba;
bool is_link_off = ufshcd_is_link_off(hba);
/*
* Resume of UFS feature should be called after power & link state
* are changed to active. Therefore, it is synchronized as follows.
*
* System PM: waits to acquire the semaphore used by ufshcd_wl_resume()
* Runtime PM: resume using ufshcd_rpm_get_sync()
*/
down(&hba->host_sem);
ufshcd_rpm_get_sync(hba);
if (ufshcd_is_ufs_dev_active(hba) && ufshcd_is_link_active(hba))
ufsf_resume(ufsf, is_link_off);
ufshcd_rpm_put(hba);
up(&hba->host_sem);
}
#if defined(CONFIG_UFSHID)
static void ufsf_on_idle(struct work_struct *work)
{
struct ufsf_feature *ufsf;
ufsf = container_of(work, struct ufsf_feature, on_idle_work);
if (ufshid_get_state(ufsf) == HID_PRESENT)
ufshid_on_idle(ufsf);
}
#endif
inline void ufsf_set_init_state(struct ufs_hba *hba)
{
struct ufsf_feature *ufsf = ufs_qcom_get_ufsf(hba);
ufsf->hba = hba;
INIT_WORK(&ufsf->device_check_work, ufsf_device_check_work_handler);
INIT_WORK(&ufsf->reset_wait_work, ufsf_reset_wait_work_handler);
INIT_WORK(&ufsf->resume_work, ufsf_resume_work_handler);
#if defined(CONFIG_UFSHID)
INIT_WORK(&ufsf->on_idle_work, ufsf_on_idle);
ufshid_set_state(ufsf, HID_NEED_INIT);
#endif
}
inline void ufsf_suspend(struct ufsf_feature *ufsf, bool is_system_pm)
{
/*
* Wait completion of reset_wait_work.
*
* When suspend occurrs immediately after reset
* and reset_wait_work is executed late,
* we can enter here before ufsf_reset() cleans up the feature's reset sequence.
*/
flush_work(&ufsf->reset_wait_work);
#if defined(CONFIG_UFSHID)
if (ufshid_get_state(ufsf) == HID_PRESENT)
ufshid_suspend(ufsf, is_system_pm);
#endif
}
inline void ufsf_resume(struct ufsf_feature *ufsf, bool is_link_off)
{
#if defined(CONFIG_UFSHID)
if (ufshid_get_state(ufsf) == HID_SUSPEND)
ufshid_resume(ufsf, is_link_off);
#endif
}
MODULE_LICENSE("GPL v2");

163
drivers/ufs/host/vendor/ufsfeature.h vendored Normal file
View file

@ -0,0 +1,163 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Universal Flash Storage Feature Support
*
* Copyright (C) 2017-2018 Samsung Electronics Co., Ltd.
*
* Authors:
* Yongmyung Lee <ymhungry.lee@samsung.com>
* Jinyoung Choi <j-young.choi@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* See the COPYING file in the top-level directory or visit
* <http://www.gnu.org/licenses/gpl-2.0.html>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This program is provided "AS IS" and "WITH ALL FAULTS" and
* without warranty of any kind. You are solely responsible for
* determining the appropriateness of using and distributing
* the program and assume all risks associated with your exercise
* of rights with respect to the program, including but not limited
* to infringement of third party rights, the risks and costs of
* program errors, damage to or loss of data, programs or equipment,
* and unavailability or interruption of operations. Under no
* circumstances will the contributor of this Program be liable for
* any damages of any kind arising from your use or distribution of
* this program.
*
* The Linux Foundation chooses to take subject only to the GPLv2
* license terms, and distributes only under these terms.
*/
#ifndef _UFSFEATURE_H_
#define _UFSFEATURE_H_
#include <scsi/scsi_cmnd.h>
#include <asm/unaligned.h>
#include <ufs/ufs.h>
#include "ufshid.h"
#define UFS_UPIU_MAX_GENERAL_LUN 8
/* Version info */
#define UFSFEATURE_DD_VER 0x020500
#define UFSFEATURE_DD_VER_POST ""
/* For read10 debug */
#define READ10_DEBUG_LUN 0x7F
#define READ10_DEBUG_LBA 0x48504230
/* For Chip Crack Detection */
#define VENDOR_OP 0xC0
#define VENDOR_CCD 0x51
#define CCD_DATA_SEG_LEN 0x08
#define CCD_SENSE_DATA_LEN 0x06
#define CCD_DESC_TYPE 0x81
/* Description */
#define UFSF_QUERY_DESC_DEVICE_MAX_SIZE 0xFF
#define UFSF_QUERY_DESC_CONFIGURAION_MAX_SIZE 0xE6
#define UFSF_QUERY_DESC_UNIT_MAX_SIZE 0x2D
#define UFSF_QUERY_DESC_GEOMETRY_MAX_SIZE 0xFF
/* Descriptor idn for Query Request */
#define UFSF_QUERY_DESC_IDN_VENDOR_DEVICE 0xF0
#define UFSF_QUERY_DESC_IDN_VENDOR_GEOMETRY 0xF7
/* query_flag */
#define MASK_QUERY_UPIU_FLAG_LOC 0xFF
#define INFO_MSG(msg, args...) pr_info("%s:%d info: " msg "\n", \
__func__, __LINE__, ##args)
#define ERR_MSG(msg, args...) pr_err("%s:%d err: " msg "\n", \
__func__, __LINE__, ##args)
#define WARN_MSG(msg, args...) pr_warn("%s:%d warn: " msg "\n", \
__func__, __LINE__, ##args)
#define seq_scan_lu(lun) for (lun = 0; lun < UFS_UPIU_MAX_GENERAL_LUN; lun++)
#define UFSFEATURE_SELECTOR 0x01
#define TMSG(ufsf, lun, msg, args...) \
do { if (ufsf->sdev_ufs_lu[lun] && \
ufsf->sdev_ufs_lu[lun]->request_queue) \
blk_add_trace_msg( \
ufsf->sdev_ufs_lu[lun]->request_queue, \
msg, ##args); \
} while (0) \
struct ufsf_lu_desc {
/* Common info */
int lu_enable; /* 03h bLUEnable */
int lu_queue_depth; /* 06h lu queue depth info*/
int lu_logblk_size; /* 0Ah bLogicalBlockSize. default 0x0C = 4KB */
u64 lu_logblk_cnt; /* 0Bh qLogicalBlockCount. */
};
struct ufsf_feature {
struct ufs_hba *hba;
struct scsi_device *sdev_ufs_lu[UFS_UPIU_MAX_GENERAL_LUN];
bool check_init;
struct work_struct device_check_work;
struct work_struct reset_wait_work;
struct work_struct resume_work;
#if defined(CONFIG_UFSHID)
struct work_struct on_idle_work;
atomic_t hid_state;
struct ufshid_dev *hid_dev;
#endif
};
struct ufs_hba;
struct ufshcd_lrb;
void ufsf_device_check(struct ufs_hba *hba);
void ufsf_upiu_check_for_ccd(struct ufshcd_lrb *lrbp);
bool ufsf_is_valid_lun(int lun);
void ufsf_slave_configure(struct ufsf_feature *ufsf, struct scsi_device *sdev);
int ufsf_prep_fn(struct ufsf_feature *ufsf, struct ufshcd_lrb *lrbp);
void ufsf_reset_lu(struct ufsf_feature *ufsf);
void ufsf_reset_host(struct ufsf_feature *ufsf);
void ufsf_init(struct ufsf_feature *ufsf);
void ufsf_reset(struct ufsf_feature *ufsf);
void ufsf_remove(struct ufsf_feature *ufsf);
void ufsf_set_init_state(struct ufs_hba *hba);
void ufsf_suspend(struct ufsf_feature *ufsf, bool is_system_pm);
void ufsf_resume(struct ufsf_feature *ufsf, bool is_link_off);
void ufsf_print_buf(const unsigned char *field, int size);
/* mimic */
void ufsf_scsi_unblock_requests(struct ufs_hba *hba);
void ufsf_scsi_block_requests(struct ufs_hba *hba);
int ufsf_wait_for_doorbell_clr(struct ufs_hba *hba, u64 wait_timeout_us);
void ufsf_rpm_put_noidle(struct ufs_hba *hba);
/* Device descriptor parameters offsets in bytes*/
#define DEVICE_DESC_PARAM_EX_FEAT_SUP 0x4F
#define DEVICE_DESC_PARAM_SAMSUNG_SUP 0xFB
#if defined(CONFIG_UFSHID)
#if defined(CONFIG_MICRON_UFSHID)
#define QUERY_FLAG_IDN_HID_EN 0x13
#endif
/* Attribute idn for Query requests */
#define QUERY_ATTR_IDN_HID_OPERATION 0x20
#define QUERY_ATTR_IDN_HID_FRAG_LEVEL 0x21
#if defined(CONFIG_MICRON_UFSHID)
#define QUERY_ATTR_IDN_HID_FRAG_STATUS 0x31
#define QUERY_ATTR_IDN_HID_PROGRESS 0x32
#endif
#define DEVICE_DESC_PARAM_HID_VER 0x59
#endif
#endif /* End of Header */

1097
drivers/ufs/host/vendor/ufshid.c vendored Normal file

File diff suppressed because it is too large Load diff

176
drivers/ufs/host/vendor/ufshid.h vendored Normal file
View file

@ -0,0 +1,176 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Universal Flash Storage Host Initiated Defrag
*
* Copyright (C) 2019 Samsung Electronics Co., Ltd.
*
* Authors:
* Yongmyung Lee <ymhungry.lee@samsung.com>
* Jinyoung Choi <j-young.choi@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* See the COPYING file in the top-level directory or visit
* <http://www.gnu.org/licenses/gpl-2.0.html>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This program is provided "AS IS" and "WITH ALL FAULTS" and
* without warranty of any kind. You are solely responsible for
* determining the appropriateness of using and distributing
* the program and assume all risks associated with your exercise
* of rights with respect to the program, including but not limited
* to infringement of third party rights, the risks and costs of
* program errors, damage to or loss of data, programs or equipment,
* and unavailability or interruption of operations. Under no
* circumstances will the contributor of this Program be liable for
* any damages of any kind arising from your use or distribution of
* this program.
*
* The Linux Foundation chooses to take subject only to the GPLv2
* license terms, and distributes only under these terms.
*/
#ifndef _UFSHID_H_
#define _UFSHID_H_
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/blktrace_api.h>
#include <linux/blkdev.h>
#include <linux/bitfield.h>
#include <scsi/scsi_cmnd.h>
#include <linux/delay.h>
#include "../../../block/blk.h"
#define UFSHID_VER 0x0101
#define UFSHID_DD_VER 0x010700
#define UFSHID_DD_VER_POST ""
#define UFS_FEATURE_SUPPORT_HID_BIT (1 << 0)
#define HID_TRIGGER_WORKER_DELAY_MS_DEFAULT 2000
#define HID_TRIGGER_WORKER_DELAY_MS_MIN 100
#define HID_TRIGGER_WORKER_DELAY_MS_MAX 10000
#define HID_ON_IDLE_DELAY_MS_DEFAULT 100
#define HID_ON_IDLE_DELAY_MS_MIN 10
#define HID_ON_IDLE_DELAY_MS_MAX 10000
#define HID_FRAG_LEVEL_MASK 0xF
#define HID_GET_FRAG_LEVEL(val) (val & HID_FRAG_LEVEL_MASK)
#define HID_FRAG_UPDATE_STAT_SHIFT 30
#define HID_EXECUTE_REQ_STAT_SHIFT 31
#define HID_FRAG_UPDATE_STAT(val) ((val >> HID_FRAG_UPDATE_STAT_SHIFT) & 0x1)
#define HID_EXECUTE_REQ_STAT(val) ((val >> HID_EXECUTE_REQ_STAT_SHIFT) & 0x1)
#define WAIT_HID_RESUME_TIMEOUT (2 * HZ)
#define HID_DEBUG(hid, msg, args...) \
do { if (hid->hid_debug) \
pr_err("%40s:%3d [%01d%02d%02d] " msg "\n", \
__func__, __LINE__, \
hid->hid_trigger, \
atomic_read(&hid->ufsf->hba->dev->power.usage_count),\
hid->ufsf->hba->clk_gating.active_reqs, ##args); \
} while (0)
enum UFSHID_STATE {
HID_NEED_INIT = 0,
HID_PRESENT = 1,
HID_SUSPEND = 2,
HID_FAILED = -2,
HID_RESET = -3,
};
enum UFSHID_OP {
HID_OP_DISABLE = 0,
HID_OP_ANALYZE = 1,
HID_OP_EXECUTE = 2,
HID_OP_LBA_EXECUTE = 3,
HID_OP_MAX
};
enum {
HID_NO_PARAM = 0,
HID_WITH_PARAM = 1,
};
enum {
HID_LEV_GRAY = 0,
HID_LEV_GREEN = 1,
HID_LEV_YELLOW = 2,
HID_LEV_RED = 3,
HID_LEV_UNKNOWN = 4,
};
enum {
HID_NOT_REQUIRED = 0,
HID_REQUIRED = 1
};
#if defined(CONFIG_MICRON_UFSHID)
enum {
HID_LEV_GREEN_MICRON = 0,
HID_LEV_RED_MICRON = 1,
};
enum {
HID_PROG_IDLE = 0,
HID_PROG_ONGOING = 1,
HID_PROG_STOP = 2, //stopped by Host
HID_PROG_COMPLETE = 3,
};
#endif
struct ufshid_dev {
struct ufsf_feature *ufsf;
unsigned int hid_trigger; /* default value is false */
struct delayed_work hid_trigger_work;
unsigned int hid_trigger_delay;
unsigned int hid_on_idle_delay;
u32 ahit; /* to restore ahit value */
bool is_auto_enabled;
/* for sysfs */
struct kobject kobj;
struct mutex sysfs_lock;
struct ufshid_sysfs_entry *sysfs_entries;
/* for debug */
bool hid_debug;
#if defined(CONFIG_UFSHID_POC)
bool block_suspend;
#endif
struct completion resume_compl;
};
struct ufshid_sysfs_entry {
struct attribute attr;
ssize_t (*show)(struct ufshid_dev *hid, char *buf);
ssize_t (*store)(struct ufshid_dev *hid, const char *buf, size_t count);
};
struct ufshcd_lrb;
int ufshid_get_state(struct ufsf_feature *ufsf);
void ufshid_set_state(struct ufsf_feature *ufsf, int state);
void ufshid_get_dev_info(struct ufsf_feature *ufsf, u8 *desc_buf);
void ufshid_set_init_state(struct ufsf_feature *ufsf);
void ufshid_init(struct ufsf_feature *ufsf);
void ufshid_reset(struct ufsf_feature *ufsf);
void ufshid_reset_host(struct ufsf_feature *ufsf);
void ufshid_remove(struct ufsf_feature *ufsf);
void ufshid_suspend(struct ufsf_feature *ufsf, bool is_system_pm);
void ufshid_resume(struct ufsf_feature *ufsf, bool is_link_off);
void ufshid_on_idle(struct ufsf_feature *ufsf);
#endif /* End of Header */

View file

@ -55,6 +55,11 @@
#include "xhci.h"
#include "debug-ipc.h"
#undef dev_dbg
#undef pr_debug
#define dev_dbg dev_info
#define pr_debug pr_info
#define NUM_LOG_PAGES 12
/* dload specific suppot */
@ -2398,6 +2403,30 @@ static void gsi_free_trbs(struct usb_ep *ep, struct usb_gsi_request *req)
req->buf_base_addr = NULL;
sg_free_table(&req->sgt_data_buff);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,6,87)
static int gsi_set_xfer_resource(struct dwc3_ep *dep)
{
struct dwc3_gadget_ep_cmd_params params;
int ret;
if (dep->flags & DWC3_EP_RESOURCE_ALLOCATED)
return 0;
memset(&params, 0x00, sizeof(params));
params.param0 = DWC3_DEPXFERCFG_NUM_XFER_RES(1);
ret = dwc3_core_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETTRANSFRESOURCE,
&params);
if (ret)
return ret;
dep->flags |= DWC3_EP_RESOURCE_ALLOCATED;
return 0;
}
#endif
/**
* Configures GSI EPs. For GSI EPs we need to set interrupter numbers.
*
@ -2415,6 +2444,9 @@ static void gsi_configure_ep(struct usb_ep *ep, struct usb_gsi_request *request)
int n = request->ep_intr_num - 1;
u32 reg;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,6,87)
gsi_set_xfer_resource(dep);
#endif
/* setup dummy doorbell as IPA connection isn't setup yet */
dwc3_msm_write_reg(mdwc->base, GSI_DBL_ADDR_H(mdwc->gsi_reg, n),
upper_32_bits(mdwc->dummy_gsi_db_dma));
@ -4635,6 +4667,7 @@ skip_update:
if (mdwc->resume_pending) {
pm_runtime_resume(mdwc->dev);
mdwc->resume_pending = false;
dev_dbg(mdwc->dev, "%s: set resume_pending to false\n", __func__);
}
if (atomic_read(&mdwc->pm_suspended)) {
@ -4727,6 +4760,10 @@ static irqreturn_t msm_dwc3_pwr_irq(int irq, void *data)
/* set this to call dwc3_msm_resume() */
mdwc->resume_pending = true;
return IRQ_WAKE_THREAD;
} else {
/* don't set this to call dwc3_msm_resume()when exit LPM */
dev_dbg(mdwc->dev, "%s resume_pending=%d, clean resume_pending\n", __func__, mdwc->resume_pending);
mdwc->resume_pending = false;
}
dwc3_pwr_event_handler(mdwc);
@ -5557,6 +5594,21 @@ static void dwc3_msm_set_dp_only_params(struct dwc3_msm *mdwc)
mdwc->ss_phy->flags |= PHY_DP_MODE;
}
int dwc3_msm_set_usb_redriver_eq(struct device *dev)
{
struct dwc3_msm *mdwc = dev_get_drvdata(dev);
if (!mdwc || !mdwc->redriver) {
dev_err(dev, "dwc3-msm is not initialized yet.\n");
return -EAGAIN;
}
usb_redriver_config_dp_eq(mdwc->redriver);
return 0;
}
EXPORT_SYMBOL(dwc3_msm_set_usb_redriver_eq);
int dwc3_msm_set_dp_mode(struct device *dev, bool dp_connected, int lanes)
{
struct dwc3_msm *mdwc = dev_get_drvdata(dev);
@ -6501,6 +6553,7 @@ static int dwc3_msm_probe(struct platform_device *pdev)
.allow_userspace_control = true,
};
dwc3_msm_set_role(mdwc, USB_ROLE_NONE);
role_desc.fwnode = dev_fwnode(&pdev->dev);
mdwc->role_switch = usb_role_switch_register(mdwc->dev,
&role_desc);
@ -6521,6 +6574,13 @@ static int dwc3_msm_probe(struct platform_device *pdev)
PM_QOS_DEFAULT_VALUE);
mdwc->force_disconnect = false;
if (of_property_read_bool(node,
"qcom,force-adb-enable")) {
dev_err(mdwc->dev, "%s: force usb start device mode\n", __func__);
dwc3_start_stop_device(mdwc, true);
}
return 0;
put_dwc3:

View file

@ -123,6 +123,9 @@ struct msm_hsphy {
int *param_override_seq;
int param_override_seq_cnt;
int *host_param_override_seq;
int host_param_override_seq_cnt;
void __iomem *phy_rcal_reg;
u32 rcal_mask;
@ -488,9 +491,14 @@ static int msm_hsphy_init(struct usb_phy *uphy)
VBUSVLDEXT0, VBUSVLDEXT0);
/* set parameter ovrride if needed */
if (phy->param_override_seq)
if ((phy->phy.flags & PHY_HOST_MODE) &&
phy->host_param_override_seq) {
hsusb_phy_write_seq(phy->base, phy->host_param_override_seq,
phy->host_param_override_seq_cnt, 0);
} else if (phy->param_override_seq) {
hsusb_phy_write_seq(phy->base, phy->param_override_seq,
phy->param_override_seq_cnt, 0);
}
if (phy->pre_emphasis) {
u8 val = TXPREEMPAMPTUNE0(phy->pre_emphasis) &
@ -924,6 +932,34 @@ static int msm_hsphy_probe(struct platform_device *pdev)
if (IS_ERR(phy->phy_reset))
return PTR_ERR(phy->phy_reset);
phy->host_param_override_seq_cnt = of_property_count_elems_of_size(
dev->of_node,
"qcom,host-param-override-seq",
sizeof(*phy->host_param_override_seq));
if (phy->host_param_override_seq_cnt > 0) {
phy->host_param_override_seq = devm_kcalloc(dev,
phy->host_param_override_seq_cnt,
sizeof(*phy->host_param_override_seq),
GFP_KERNEL);
if (!phy->host_param_override_seq)
return -ENOMEM;
if (phy->host_param_override_seq_cnt % 2) {
dev_err(dev, "invalid host_param_override_seq_len\n");
return -EINVAL;
}
ret = of_property_read_u32_array(dev->of_node,
"qcom,host-param-override-seq",
phy->host_param_override_seq,
phy->host_param_override_seq_cnt);
if (ret) {
dev_err(dev, "qcom,host_param-override-seq read failed %d\n",
ret);
return ret;
}
}
phy->param_override_seq_cnt = of_property_count_elems_of_size(
dev->of_node,
"qcom,param-override-seq",

View file

@ -18,6 +18,7 @@
#include <linux/clk.h>
#include <linux/extcon.h>
#include <linux/reset.h>
#include <linux/debugfs.h>
enum core_ldo_levels {
CORE_LEVEL_NONE = 0,
@ -151,6 +152,11 @@ struct msm_ssphy_qmp {
u32 *qmp_phy_init_seq;
int init_seq_len;
enum qmp_phy_type phy_type;
/* debugfs entries */
struct dentry *root;
struct qmp_reg_val *qmp_phy_tune_seq;
int qmp_phy_tune_seq_cnt;
};
static const struct of_device_id msm_usb_id_table[] = {
@ -414,6 +420,7 @@ static int configure_phy_regs(struct usb_phy *uphy,
struct msm_ssphy_qmp *phy = container_of(uphy, struct msm_ssphy_qmp,
phy);
int i;
struct qmp_reg_val *tune_reg;
if (!reg) {
dev_err(uphy->dev, "NULL PHY configuration\n");
@ -424,6 +431,14 @@ static int configure_phy_regs(struct usb_phy *uphy,
writel_relaxed(reg->val, phy->base + reg->offset);
reg++;
}
for (i = 0; i < phy->qmp_phy_tune_seq_cnt; i++) {
tune_reg = &phy->qmp_phy_tune_seq[i];
if (((tune_reg->val >> 16) & 0x0FFF) == 0xDEF)
continue;
writel_relaxed(tune_reg->val, phy->base + tune_reg->offset);
}
return 0;
}
@ -1020,6 +1035,86 @@ static int usb3_get_regulators(struct msm_ssphy_qmp *phy)
return 0;
}
static int msm_ssphy_qmp_tune_reg_show(struct seq_file *s, void *unused)
{
int i;
u32 val;
struct msm_ssphy_qmp *phy = s->private;
struct qmp_reg_val *tune_seq = phy->qmp_phy_tune_seq;
for (i = 0; i < phy->qmp_phy_tune_seq_cnt; i++) {
val = readl_relaxed(phy->base + tune_seq[i].offset);
seq_printf(s, "reg[0x%04x] = 0x%08x(0x%08x)\n",
tune_seq[i].offset, val, tune_seq[i].val);
}
return 0;
}
static int msm_ssphy_qmp_tune_reg_open(struct inode *inode, struct file *file)
{
return single_open(file, msm_ssphy_qmp_tune_reg_show, inode->i_private);
}
static ssize_t msm_ssphy_qmp_tune_reg_write(struct file *file,
const char __user *ubuf, size_t count, loff_t *ppos)
{
int i;
int ret;
char buf[64];
struct qmp_reg_val reg;
struct seq_file *s = file->private_data;
struct msm_ssphy_qmp *phy = s->private;
struct qmp_reg_val *tune_seq = phy->qmp_phy_tune_seq;
int seq_cnt = phy->qmp_phy_tune_seq_cnt;
if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT;
ret = sscanf((const char *)buf, "%x, %x", &reg.offset, &reg.val);
if (ret != 2) {
pr_err("Invalid ssphy tune register seq input\n");
return -EINVAL;
}
for (i = 0; i < seq_cnt; i++) {
if (tune_seq[i].offset == reg.offset) {
memcpy(&tune_seq[i], &reg, sizeof(reg));
return count;
}
}
tune_seq = kzalloc(sizeof(reg) * (seq_cnt + 1), GFP_KERNEL);
if (!tune_seq)
return -ENOMEM;
if (phy->qmp_phy_tune_seq) {
memcpy(tune_seq, phy->qmp_phy_tune_seq, sizeof(reg) * seq_cnt);
kfree(phy->qmp_phy_tune_seq);
}
tune_seq[seq_cnt] = reg;
phy->qmp_phy_tune_seq = tune_seq;
phy->qmp_phy_tune_seq_cnt = seq_cnt + 1;
return count;
}
static const struct file_operations msm_ssphy_qmp_tune_reg_fops = {
.open = msm_ssphy_qmp_tune_reg_open,
.write = msm_ssphy_qmp_tune_reg_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static void msm_ssphy_qmp_create_debugfs(struct msm_ssphy_qmp *phy)
{
phy->root = debugfs_create_dir(dev_name(phy->phy.dev), NULL);
debugfs_create_file("phy_tune_reg", 0644, phy->root, phy,
&msm_ssphy_qmp_tune_reg_fops);
}
static int msm_ssphy_qmp_probe(struct platform_device *pdev)
{
struct msm_ssphy_qmp *phy;
@ -1225,6 +1320,9 @@ static int msm_ssphy_qmp_probe(struct platform_device *pdev)
/* Placed at the end to ensure the probe is complete */
ret = usb_add_phy_dev(&phy->phy);
if (!ret)
msm_ssphy_qmp_create_debugfs(phy);
err:
return ret;
}
@ -1236,6 +1334,12 @@ static int msm_ssphy_qmp_remove(struct platform_device *pdev)
if (!phy)
return 0;
if (phy->qmp_phy_tune_seq) {
kfree(phy->qmp_phy_tune_seq);
phy->qmp_phy_tune_seq = NULL;
phy->qmp_phy_tune_seq_cnt = 0;
}
debugfs_remove_recursive(phy->root);
usb_remove_phy(&phy->phy);
msm_ssphy_qmp_enable_clks(phy, false);
msm_ssusb_qmp_ldo_enable(phy, 0);

View file

@ -21,4 +21,10 @@ config USB_REDRIVER_NB7VPQ904M
it have i2c program interface.
Say Y/M here if you want to support it.
config USB_REDRIVER_PS5169
tristate "USB 3.1 Gen1/Gen2 10Gbps re-driver driver for PS5169"
select REGMAP_I2C
help
Say Y here if you want to support USB super speed re-driver PS5169.
endmenu

View file

@ -2,3 +2,4 @@
obj-$(CONFIG_USB_REDRIVER) += redriver.o
obj-$(CONFIG_USB_REDRIVER_NB7VPQ904M) += nb7vpq904m.o
obj-$(CONFIG_USB_REDRIVER_PS5169) += ps5169.o

File diff suppressed because it is too large Load diff

View file

@ -174,9 +174,9 @@ static void eusb2_repeater_update_seq(struct eusb2_repeater *er,
{
int i;
dev_dbg(er->ur.dev, "param override seq count:%d\n", cnt);
dev_info(er->ur.dev, "param override seq count:%d\n", cnt);
for (i = 0; i < cnt; i = i+2) {
dev_dbg(er->ur.dev, "write 0x%02x to 0x%02x\n",
dev_info(er->ur.dev, "write 0x%02x to 0x%02x\n",
seq[i], seq[i+1]);
eusb2_repeater_reg_write(er, seq[i+1], seq[i]);
}

View file

@ -124,6 +124,9 @@ struct walt_task_struct {
u64 active_time;
u64 last_win_size;
int boost;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
u16 ux_type; // Moto huangzq2: add ux flag for moto_sched
#endif
bool wake_up_idle;
bool misfit;
bool rtg_high_prio;
@ -200,6 +203,57 @@ static inline void set_wake_up_idle(bool wake_up_idle)
extern int sched_lpm_disallowed_time(int cpu, u64 *timeout);
extern int set_task_boost(int boost, u64 period);
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto huangzq2: export api for moto_sched
extern int set_moto_sched_enabled(int enable);
struct msched_ops {
int (*task_get_mvp_prio)(struct task_struct *p, bool with_inherit);
unsigned int (*task_get_mvp_limit)(struct task_struct *p, int mvp_prio);
void (*binder_inherit_ux_type)(struct task_struct *task);
void (*binder_clear_inherited_ux_type)(struct task_struct *task);
void (*binder_ux_type_set)(struct task_struct *task);
void (*queue_ux_task)(struct rq *rq, struct task_struct *task, int enqueue);
};
extern struct msched_ops *moto_sched_ops;
extern void set_moto_sched_ops(struct msched_ops *ops);
static inline int moto_task_get_mvp_prio(struct task_struct *p, bool with_inherit) {
if (moto_sched_ops != NULL && moto_sched_ops->task_get_mvp_prio != NULL)
return moto_sched_ops->task_get_mvp_prio(p, with_inherit);
return -1;
}
static inline unsigned int moto_task_get_mvp_limit(struct task_struct *p, int mvp_prio) {
if (moto_sched_ops != NULL && moto_sched_ops->task_get_mvp_limit != NULL)
return moto_sched_ops->task_get_mvp_limit(p, mvp_prio);
return -1;
}
static inline void moto_binder_inherit_ux_type(struct task_struct *task) {
if (moto_sched_ops != NULL && moto_sched_ops->binder_inherit_ux_type != NULL)
return moto_sched_ops->binder_inherit_ux_type(task);
}
static inline void moto_binder_clear_inherited_ux_type(struct task_struct *task) {
if (moto_sched_ops != NULL && moto_sched_ops->binder_clear_inherited_ux_type != NULL)
return moto_sched_ops->binder_clear_inherited_ux_type(task);
}
static inline void moto_binder_ux_type_set(struct task_struct *task) {
if (moto_sched_ops != NULL && moto_sched_ops->binder_ux_type_set != NULL)
return moto_sched_ops->binder_ux_type_set(task);
}
static inline void moto_queue_ux_task(struct rq *rq, struct task_struct *task, int enqueue) {
if (moto_sched_ops != NULL && moto_sched_ops->queue_ux_task != NULL)
return moto_sched_ops->queue_ux_task(rq, task, enqueue);
}
#endif
struct notifier_block;
extern void core_ctl_notifier_register(struct notifier_block *n);
extern void core_ctl_notifier_unregister(struct notifier_block *n);

View file

@ -24,6 +24,7 @@ enum panel_event_notifier_client {
PANEL_EVENT_NOTIFIER_CLIENT_SECONDARY_TOUCH,
PANEL_EVENT_NOTIFIER_CLIENT_ECM,
PANEL_EVENT_NOTIFIER_CLIENT_BATTERY_CHARGER,
PANEL_EVENT_NOTIFIER_CLIENT_FPS,
PANEL_EVENT_NOTIFIER_CLIENT_MAX
};

View file

@ -290,6 +290,7 @@ int msm_ep_update_ops(struct usb_ep *ep);
int msm_ep_clear_ops(struct usb_ep *ep);
int msm_ep_set_mode(struct usb_ep *ep, enum usb_hw_ep_mode mode);
int dwc3_core_stop_hw_active_transfers(struct dwc3 *dwc);
int dwc3_msm_set_usb_redriver_eq(struct device *dev);
#else
void dwc3_msm_notify_event(struct dwc3 *dwc,
enum dwc3_notify_event event, unsigned int value)
@ -322,6 +323,8 @@ int msm_ep_set_mode(struct usb_ep *ep, enum usb_hw_ep_mode mode)
{ return -ENODEV; }
inline int dwc3_core_stop_hw_active_transfers(struct dwc3 *dwc)
{ return 0; }
inline int dwc3_msm_set_usb_redriver_eq(struct device *dev)
{ return 0; }
#endif
#ifdef CONFIG_ARM64

View file

@ -75,6 +75,7 @@ void usb_redriver_notify_disconnect(struct usb_redriver *ur);
void usb_redriver_gadget_pullup_enter(struct usb_redriver *ur, int is_on);
void usb_redriver_gadget_pullup_exit(struct usb_redriver *ur, int is_on);
void usb_redriver_host_powercycle(struct usb_redriver *ur);
void usb_redriver_config_dp_eq(struct usb_redriver *ur);
#else
@ -95,6 +96,10 @@ static inline int usb_remove_redriver(struct usb_redriver *ur)
return 0;
}
static inline void usb_redriver_config_dp_eq(struct usb_redriver *ur)
{
}
#define usb_put_redriver(ur) do {} while (0)
#define usb_redriver_release_lanes(ur, ort, num) do {} while (0)

View file

@ -350,3 +350,22 @@ config ENERGY_MODEL
The exact usage of the energy model is subsystem-dependent.
If in doubt, say N.
config SUSPEND_DEBUG
tristate "Enable snapshot of regulator and tlmm when suspend"
depends on SUSPEND
default n
help
This allows you to dump the regulator state and tlmm configuration
before suspend. It doesn't work only if you have read the system
file node /sys/privae/tlmm_before_sleep and vreg_before_sleep
config GPIO_VALID_ARRAY
bool "Check if a gpio is valid in an array"
depends on SUSPEND_DEBUG
default n
help
This allows you to use an array maintained manually to indicate
if a GPIO can be accessed by APPS. It's only needed when the GPIO
is still unaccessible although gpiochip_line_is_valid() returns
true.

View file

@ -23,3 +23,5 @@ obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
obj-$(CONFIG_SUSPEND) += wakeup_reason.o
obj-$(CONFIG_ENERGY_MODEL) += energy_model.o
obj-$(CONFIG_SUSPEND_DEBUG) += user_sysfs_private.o

View file

@ -0,0 +1,923 @@
/*
* Copyright (C) 2012 lenovo, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/ctype.h>
#include <linux/uaccess.h>
#include <linux/rtc.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/err.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_wakeup.h>
#ifdef CONFIG_PINCTRL_MSM_MODULE
#include "../../drivers/pinctrl/qcom/pinctrl-msm.h"
#endif
#include <linux/time64.h>
#include "user_sysfs_private.h"
#define GPIO_CFG(gpio, func, dir, pull, drvstr) \
((((gpio) & 0x3FF) << 4) | \
((func) & 0xf) | \
(((dir) & 0x1) << 14) | \
(((pull) & 0x3) << 15) | \
(((drvstr) & 0xF) << 17))
/**
* extract GPIO pin from bit-field used for gpio_tlmm_config
*/
#define GPIO_PIN(gpio_cfg) (((gpio_cfg) >> 4) & 0x3ff)
#define GPIO_FUNC(gpio_cfg) (((gpio_cfg) >> 0) & 0xf)
#define GPIO_DIR(gpio_cfg) (((gpio_cfg) >> 14) & 0x1)
#define GPIO_PULL(gpio_cfg) (((gpio_cfg) >> 15) & 0x3)
#define GPIO_DRVSTR(gpio_cfg) (((gpio_cfg) >> 17) & 0xf)
#define TLMM_NUM_GPIO 255
#define HAL_OUTPUT_VAL(config) (((config)&0x40000000)>>30)
static int before_sleep_fetched;
module_param(before_sleep_fetched, int, 0644);
static unsigned before_sleep_configs[TLMM_NUM_GPIO];
static int before_sleep_table_enabled;
module_param(before_sleep_table_enabled, int, 0644);
static unsigned before_sleep_table_configs[TLMM_NUM_GPIO];
#ifdef CONFIG_GPIO_VALID_ARRAY
static unsigned tz_configs[TLMM_NUM_GPIO];
#endif
#ifndef CONFIG_PINCTRL_MSM_MODULE
int tlmm_get_inout(unsigned gpio)
{
return 0;
}
int tlmm_set_inout(unsigned gpio, unsigned value)
{
return 0;
}
int tlmm_get_config(unsigned gpio, unsigned *cfg)
{
return -EINVAL;
}
int tlmm_set_config(unsigned config)
{
return -EINVAL;
}
#endif
static int tlmm_dump_cfg(char *buf, int size,
unsigned gpio, unsigned cfg, int output_val)
{
/* mA */
static const char * const drvstr_str[] = {
"2", "4", "6", "8", "10", "12", "14", "16" };
/* "NO_PULL", "PULL_DOWN", "KEEPER", "PULL_UP" */
static const char * const pull_str[] = { "N", "D", "K", "U" };
/* "Input", "Output" */
static const char * const dir_str[] = { "I", "O" };
char func_str[20];
char *p = buf;
int drvstr = GPIO_DRVSTR(cfg);
int pull = GPIO_PULL(cfg);
int dir = GPIO_DIR(cfg);
int func = GPIO_FUNC(cfg);
/* pr_debug("%s(), drvstr=%d, pull=%d, dir=%d, func=%d\n", */
/* __func__, drvstr, pull, dir, func); */
snprintf(func_str, sizeof(func_str), "%d", func);
p += snprintf(p, size - (p - buf), "%d: %s%s%s%s", gpio, func_str,
pull_str[pull], dir_str[dir], drvstr_str[drvstr]);
p += snprintf(p, size - (p - buf), " = %d", output_val);
p += snprintf(p, size - (p - buf), "\n");
return p - buf;
}
static int tlmm_dump_header(char *buf, int size)
{
char *p = buf;
p += snprintf(p, size - (p - buf),
"0:GPIO\n");
p += snprintf(p, size - (p - buf),
"N:NO_PULL D:PULL_DOWN K:KEEPER U:PULL_UP\n");
p += snprintf(p, size - (p - buf),
"I:Input O:Output\n");
p += snprintf(p, size - (p - buf),
"2:2, 4, 6, 8, 10, 12, 14, 16 mA (driver strength)\n\n");
return p - buf;
}
int tlmm_dump_info(char *buf, int size, int tlmm_num, int tlmm_count)
{
unsigned i;
char *p = buf;
unsigned cfg;
int output_val = 0;
int ret;
if (tlmm_num < 0 || tlmm_num >= TLMM_NUM_GPIO)
return p - buf;
if (tlmm_count == 1) {
#ifdef CONFIG_GPIO_VALID_ARRAY
if (tz_configs[tlmm_num])
return p - buf;
#endif
ret = tlmm_get_config(tlmm_num, &cfg);
if (ret == 0) {
output_val = tlmm_get_inout(tlmm_num);
p += tlmm_dump_cfg(p, size - (p - buf),
tlmm_num, cfg, output_val);
}
} else {
p += tlmm_dump_header(p, size - (p - buf));
p += snprintf(p, size - (p - buf),
"Format: gpio func pull dir strength [output]\n");
p += snprintf(p, size - (p - buf),
"Shortcut: gpio output\n");
p += snprintf(p, size - (p - buf),
"echo 20 0 D O 2 1, Config tlmm 20 and output 1\n");
p += snprintf(p, size - (p - buf),
"echo 20 1, Set tlmm 20 to output 1\n");
for (i = tlmm_num; i < tlmm_num + tlmm_count; ++i) {
if (i >= TLMM_NUM_GPIO)
break;
#ifdef CONFIG_GPIO_VALID_ARRAY
if (tz_configs[i])
continue;
#endif
ret = tlmm_get_config(i, &cfg);
if (ret == 0) {
output_val = tlmm_get_inout(i);
p += tlmm_dump_cfg(p, size - (p - buf),
i, cfg, output_val);
}
}
pr_debug("%s(), %d\n", __func__, __LINE__);
p += snprintf(p, size - (p - buf), "(%d)\n", (int)(p - buf));
}
return p - buf;
}
/* save tlmm config before sleep */
void tlmm_before_sleep_save_configs(void)
{
unsigned i;
int ret;
/* only save tlmm configs when it has been fetched */
if (!before_sleep_fetched)
return;
pr_debug("%s(), Save tlmms before suspend!\n", __func__);
before_sleep_fetched = false;
for (i = 0; i < TLMM_NUM_GPIO; ++i) {
unsigned cfg;
int output_val = 0;
#ifdef CONFIG_GPIO_VALID_ARRAY
if (tz_configs[i])
continue;
#endif
ret = tlmm_get_config(i, &cfg);
if (ret == -ENODEV)
break;
output_val = tlmm_get_inout(i);
before_sleep_configs[i] = cfg | (output_val << 30);
}
}
EXPORT_SYMBOL_GPL(tlmm_before_sleep_save_configs);
int tlmm_before_sleep_dump_info(char *buf, int size)
{
unsigned i;
char *p = buf;
p += snprintf(p, size - (p - buf), "tlmm_before_sleep:\n");
if (!before_sleep_fetched) {
before_sleep_fetched = true;
p += tlmm_dump_header(p, size - (p - buf));
for (i = 0; i < TLMM_NUM_GPIO; ++i) {
unsigned cfg;
int output_val = 0;
#ifdef CONFIG_GPIO_VALID_ARRAY
if (tz_configs[i])
continue;
#endif
cfg = before_sleep_configs[i];
output_val = HAL_OUTPUT_VAL(cfg);
/* cfg &= ~0x40000000; */
p += tlmm_dump_cfg(p, size - (p - buf),
i, cfg, output_val);
}
p += snprintf(p, size - (p - buf), "(%d)\n", (int)(p - buf));
}
return p - buf;
}
/* set tlmms config before sleep */
void tlmm_before_sleep_set_configs(void)
{
int res;
unsigned i;
/* only set tlmms before sleep when it's enabled */
if (!before_sleep_table_enabled)
return;
pr_debug("%s(), Set tlmms before suspend!\n", __func__);
for (i = 0; i < TLMM_NUM_GPIO; ++i) {
unsigned cfg;
int gpio;
int dir;
int func;
int output_val = 0;
#ifdef CONFIG_GPIO_VALID_ARRAY
if (tz_configs[i])
continue;
#endif
cfg = before_sleep_table_configs[i];
gpio = GPIO_PIN(cfg);
if (gpio != i)
continue;
output_val = HAL_OUTPUT_VAL(cfg);
dir = GPIO_DIR(cfg);
func = GPIO_FUNC(cfg);
pr_debug("%s(), [%d]: 0x%x\n", __func__, i, cfg);
if (gpio < TLMM_NUM_GPIO)
res = tlmm_set_config(cfg & ~0x40000000);
if (res == -ENODEV) {
pr_debug("Error: Config failed.\n");
break;
}
if ((func == 0) && (dir == 1))
tlmm_set_inout(i, output_val);
}
}
EXPORT_SYMBOL_GPL(tlmm_before_sleep_set_configs);
#ifdef CONFIG_GPIO_VALID_ARRAY
int tlmm_tz_dump_info(char *buf, int size)
{
unsigned i;
char *p = buf;
p += snprintf(p, size - (p - buf),
"Format: gpio skip\n");
p += snprintf(p, size - (p - buf),
"Skip tlmms that locked by TZ.\n");
for (i = 0; i < TLMM_NUM_GPIO; ++i) {
p += snprintf(p, size - (p - buf), "%d: ", i);
p += snprintf(p, size - (p - buf), "%d\n", tz_configs[i]);
}
p += snprintf(p, size - (p - buf), "(%d)\n", (int)(p - buf));
return p - buf;
}
#endif
int tlmm_before_sleep_table_set_cfg(unsigned gpio, unsigned cfg)
{
if (gpio >= TLMM_NUM_GPIO && gpio != 255 && gpio != 256) {
pr_debug("gpio >= TLMM_NUM_GPIO && gpio != 255 && gpio != 256!\n");
return -EINVAL;
}
if (gpio < TLMM_NUM_GPIO) {
before_sleep_table_configs[gpio] = cfg;
before_sleep_table_enabled = true;
} else if (gpio == 255)
before_sleep_table_enabled = true;
else if (gpio == 256)
before_sleep_table_enabled = false;
return 0;
}
int tlmm_before_sleep_table_dump_info(char *buf, int size)
{
unsigned i;
char *p = buf;
p += tlmm_dump_header(p, size - (p - buf));
p += snprintf(p, size - (p - buf),
"Format: gpio function pull direction strength [output]\n");
p += snprintf(p, size - (p - buf),
"Set tlmm before suspend.\n");
p += snprintf(p, size - (p - buf),
"echo 20 0 D O 2 1, tlmm 20 output 1\n");
p += snprintf(p, size - (p - buf),
"echo 20, Disable tlmm 20's setting\n");
p += snprintf(p, size - (p - buf),
"echo 255, Enable the setting\n");
p += snprintf(p, size - (p - buf),
"echo 256, Disable the setting\n");
for (i = 0; i < TLMM_NUM_GPIO; ++i) {
unsigned cfg;
int output_val = 0;
#ifdef CONFIG_GPIO_VALID_ARRAY
if (tz_configs[i])
continue;
#endif
cfg = before_sleep_table_configs[i];
output_val = HAL_OUTPUT_VAL(cfg);
/* cfg &= ~0x40000000; */
p += tlmm_dump_cfg(p, size - (p - buf), i, cfg, output_val);
}
p += snprintf(p, size - (p - buf), "(%d)\n", (int)(p - buf));
return p - buf;
}
#define private_attr(_name) \
static struct kobj_attribute _name##_attr = { \
.attr = { \
.name = __stringify(_name), \
.mode = 0644, \
}, \
.show = _name##_show, \
.store = _name##_store, \
}
static int tlmm_num;
static ssize_t tlmm_num_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
char *p = buf;
p += snprintf(p, PAGE_SIZE, "Start gpio to check by cat tlmm\n");
p += snprintf(p, PAGE_SIZE - (p - buf), "0~%d\n", TLMM_NUM_GPIO - 1);
p += snprintf(p, PAGE_SIZE - (p - buf), "%d\n", tlmm_num);
return p - buf;
}
static ssize_t tlmm_num_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
int gpio;
int res;
res = kstrtoint(buf, 10, &gpio);
pr_debug("res=%d. %d\n", res, gpio);
if (res != 0)
goto tlmm_num_store_wrong_para;
if (gpio >= TLMM_NUM_GPIO)
goto tlmm_num_store_wrong_para;
tlmm_num = gpio;
pr_debug("tlmm_num: %d\n", tlmm_num);
goto tlmm_num_store_ok;
tlmm_num_store_wrong_para:
pr_debug("Wrong Input.\n");
pr_debug("Format: tlmm_num\n");
pr_debug(" tlmm_num: 0~%d\n", TLMM_NUM_GPIO - 1);
tlmm_num_store_ok:
return n;
}
static int tlmm_count = TLMM_NUM_GPIO;
static ssize_t tlmm_count_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
char *p = buf;
p += snprintf(p, PAGE_SIZE, "Number of gpios to check by cat tlmm\n");
p += snprintf(p, PAGE_SIZE - (p - buf), "0~%d\n", TLMM_NUM_GPIO);
p += snprintf(p, PAGE_SIZE - (p - buf), "%d\n", tlmm_count);
return p - buf;
}
static ssize_t tlmm_count_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t n)
{
int gpio;
int res;
res = kstrtoint(buf, 10, &gpio);
pr_debug("res=%d. %d\n", res, gpio);
if (res != 0)
goto tlmm_count_store_wrong_para;
if (gpio >= TLMM_NUM_GPIO)
goto tlmm_count_store_wrong_para;
tlmm_count = gpio;
pr_debug("tlmm_count: %d\n", tlmm_count);
goto tlmm_count_store_ok;
tlmm_count_store_wrong_para:
pr_debug("Wrong Input.\n");
pr_debug("Format: tlmm_count\n");
pr_debug(" tlmm_count: 0~%d\n", TLMM_NUM_GPIO);
tlmm_count_store_ok:
return n;
}
static ssize_t tlmm_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
char *p = buf;
p += tlmm_dump_info(buf, PAGE_SIZE, tlmm_num, tlmm_count);
return p - buf;
}
static ssize_t tlmm_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
char pull_c, dir_c;
int gpio, func, pull, dir, drvstr, output_val;
unsigned cfg;
int res;
res = sscanf(buf, "%d %d %c %c %d %d",
&gpio, &func, &pull_c, &dir_c, &drvstr, &output_val);
pr_debug("res=%d. %d %d %c %c %d %d\n",
res, gpio, func, pull_c, dir_c, drvstr, output_val);
/* Add a shortcut wrting format to change an output gpio's value */
if (res == 2 && gpio < TLMM_NUM_GPIO && (func == 0 || func == 1)) {
output_val = func;
goto tlmm_store_only_output_val;
}
if ((res != 5) && (res != 6))
goto tlmm_store_wrong_para;
if (gpio >= TLMM_NUM_GPIO)
goto tlmm_store_wrong_para;
if ('N' == pull_c)
pull = 0;
else if ('D' == pull_c)
pull = 1;
else if ('K' == pull_c)
pull = 2;
else if ('U' == pull_c)
pull = 3;
else
goto tlmm_store_wrong_para;
if ('I' == dir_c)
dir = 0;
else if ('O' == dir_c)
dir = 1;
else
goto tlmm_store_wrong_para;
drvstr = drvstr/2 - 1; /* 2mA -> 0, 4mA -> 1, 6mA -> 2, ... */
if (drvstr > 7)
goto tlmm_store_wrong_para;
if (output_val > 1)
goto tlmm_store_wrong_para;
pr_debug("final set: %d %d %d %d %d %d\n",
gpio, func, pull, dir, drvstr, output_val);
cfg = GPIO_CFG(gpio, func, dir, pull, drvstr);
if (gpio < TLMM_NUM_GPIO) {
#ifdef CONFIG_GPIO_VALID_ARRAY
if (tz_configs[gpio])
res = -1;
else
#endif
res = tlmm_set_config(cfg);
if (res < 0) {
pr_debug("Error: Config failed.\n");
goto tlmm_store_wrong_para;
}
}
pr_debug("final set: %d %d %d %d %d %d\n",
gpio, func, pull, dir, drvstr, output_val);
if ((func == 0) && (dir == 1)) /* gpio output */
tlmm_store_only_output_val:
tlmm_set_inout(gpio, output_val);
goto tlmm_store_ok;
tlmm_store_wrong_para:
pr_debug("Wrong Input or gpio is locked by TZ.\n");
pr_debug("Standard Format: gpio_num function pull direction strength [output_value]\n");
pr_debug("Shortcut Format: gpio_num output_value\n");
pr_debug(" gpio_num: 0 ~ 145\n");
pr_debug(" function: number, where 0 is GPIO\n");
pr_debug(" pull: 'N': NO_PULL, 'D':PULL_DOWN, 'K':KEEPER, 'U': PULL_UP\n");
pr_debug(" direction: 'I': Input, 'O': Output\n");
pr_debug(" strength: 2, 4, 6, 8, 10, 12, 14, 16\n");
pr_debug(" output_value: Optional. 0 or 1. valid if GPIO output\n");
pr_debug(" e.g. 'echo 20 0 D I 2' ==> set pin 20 as GPIO input\n");
pr_debug(" e.g. 'echo 20 0 D O 2 1' ==> set pin 20 as GPIO output and the output = 1\n");
pr_debug(" e.g. 'echo 20 1' ==> set output gpio pin 20 output = 1\n");
tlmm_store_ok:
return n;
}
#ifdef CONFIG_GPIO_VALID_ARRAY
static ssize_t tlmm_tz_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
char *p = buf;
p += tlmm_tz_dump_info(buf, PAGE_SIZE);
return p - buf;
}
static ssize_t tlmm_tz_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t n)
{
int gpio, func = 0;
int res;
res = sscanf(buf, "%d %d", &gpio, &func);
pr_debug("res=%d. %d %d\n", res, gpio, func);
if (res == 1)
func = 1;
pr_debug("final set: %d %d\n", gpio, func);
if (gpio >= TLMM_NUM_GPIO)
goto tlmm_tz_store_wrong_para;
tz_configs[gpio] = func;
goto tlmm_tz_store_ok;
tlmm_tz_store_wrong_para:
pr_debug("Wrong Input.\n");
pr_debug("Format: gpio [0|1]\n");
tlmm_tz_store_ok:
return n;
}
#endif
/* Set GPIO's sleep config from sysfs */
static ssize_t tlmm_before_sleep_table_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
char *p = buf;
p += tlmm_before_sleep_table_dump_info(buf, PAGE_SIZE);
return p - buf;
}
static ssize_t tlmm_before_sleep_table_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t n)
{
char pull_c, dir_c;
int gpio, func = 0, pull = 0, dir = 0, drvstr = 0, output_val = 0;
int ignore;
unsigned cfg;
int res;
res = sscanf(buf, "%d %d %c %c %d %d",
&gpio, &func, &pull_c, &dir_c, &drvstr, &output_val);
pr_debug("res=%d. %d %d %c %c %d %d\n",
res, gpio, func, pull_c, dir_c, drvstr, output_val);
/* if only gpio, means ignore(disable) the gpio's sleep config */
if (res == 1) {
ignore = 1;
pr_debug("final set: to disable gpio %d sleep config\n", gpio);
} else {
ignore = 0;
if ((res != 5) && (res != 6))
goto tlmm_before_sleep_table_store_wrong_para;
if (gpio >= TLMM_NUM_GPIO)
goto tlmm_before_sleep_table_store_wrong_para;
if ('N' == pull_c)
pull = 0;
else if ('D' == pull_c)
pull = 1;
else if ('K' == pull_c)
pull = 2;
else if ('U' == pull_c)
pull = 3;
else
goto tlmm_before_sleep_table_store_wrong_para;
if ('I' == dir_c)
dir = 0;
else if ('O' == dir_c)
dir = 1;
else
goto tlmm_before_sleep_table_store_wrong_para;
drvstr = drvstr/2 - 1; /* 2mA -> 0, 4mA -> 1, 6mA -> 2, ... */
if (drvstr > 7)
goto tlmm_before_sleep_table_store_wrong_para;
pr_debug("final set: %d %d %d %d %d\n",
gpio, func, pull, dir, drvstr);
}
cfg = GPIO_CFG(ignore ? 0xff : gpio, func, dir, pull, drvstr);
res = tlmm_before_sleep_table_set_cfg(gpio, cfg | (output_val << 30));
if (res < 0) {
pr_debug("Error: Config failed.\n");
goto tlmm_before_sleep_table_store_wrong_para;
}
goto tlmm_before_sleep_table_store_ok;
tlmm_before_sleep_table_store_wrong_para:
pr_debug("Wrong Input.\n");
pr_debug("Format: refer to tlmm's format except 'echo gpio_num > xxx' to disable the gpio's setting\n");
tlmm_before_sleep_table_store_ok:
return n;
}
static ssize_t tlmm_before_sleep_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
char *p = buf;
p += tlmm_before_sleep_dump_info(buf, PAGE_SIZE);
return p - buf;
}
static ssize_t tlmm_before_sleep_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t n)
{
pr_err("%s: no support.\n", __func__);
return n;
}
static ssize_t vreg_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
char *p = buf;
p += vreg_dump_info(buf);
return p - buf;
}
static ssize_t vreg_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
pr_err("%s: no support.\n", __func__);
return n;
}
static ssize_t vreg_before_sleep_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
char *p = buf;
p += vreg_before_sleep_dump_info(buf);
return p - buf;
}
static ssize_t vreg_before_sleep_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t n)
{
pr_err("%s: no support.\n", __func__);
return n;
}
static ssize_t wake_lock_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
char *s = buf;
pm_get_active_wakeup_sources(s, PAGE_SIZE - (s - buf));
s += strlen(s);
return (s - buf);
}
static ssize_t wake_lock_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t n)
{
pr_err("%s: no support yet.\n", __func__);
return -EPERM;
}
private_attr(tlmm_num);
private_attr(tlmm_count);
private_attr(tlmm);
#ifdef CONFIG_GPIO_VALID_ARRAY
private_attr(tlmm_tz);
#endif
private_attr(tlmm_before_sleep_table);
private_attr(tlmm_before_sleep);
private_attr(vreg_before_sleep);
private_attr(vreg);
private_attr(wake_lock);
static struct attribute *g_private_attr[] = {
&tlmm_num_attr.attr,
&tlmm_count_attr.attr,
&tlmm_attr.attr,
#ifdef CONFIG_GPIO_VALID_ARRAY
&tlmm_tz_attr.attr,
#endif
&tlmm_before_sleep_table_attr.attr,
&tlmm_before_sleep_attr.attr,
&vreg_attr.attr,
&vreg_before_sleep_attr.attr,
&wake_lock_attr.attr,
NULL,
};
static struct attribute_group private_attr_group = {
.attrs = g_private_attr,
};
static struct kobject *sysfs_private_kobj;
#ifdef CONFIG_GPIO_VALID_ARRAY
static const struct of_device_id msm_tz_gpio_match_table[] = {
{.compatible = "qcom,tz_gpio"},
{},
};
static int tlmm_tz_init(void)
{
struct device_node *node;
const __be32 *list;
int size;
int result = 0;
node = of_find_matching_node(NULL, msm_tz_gpio_match_table);
pr_debug("%s(), %d, node=%p\n", __func__, __LINE__, node);
if (!node)
return -ENODEV;
list = of_get_property(node, "tlmm-tz", &size);
pr_debug("%s(), %d, size=%d\n", __func__, __LINE__, size);
if (!list || !size)
return -ENODEV;
/*
* Size is in bytes. Convert to size of uint32_t
*/
size /= sizeof(*list);
while (size) {
unsigned long gpio = be32_to_cpup(list++);
pr_debug("%s(), %d, gpio=%ld\n", __func__, __LINE__, gpio);
if (gpio < TLMM_NUM_GPIO)
tz_configs[gpio] = 1;
size--;
}
return result;
}
#endif
#ifdef CONFIG_PM_SLEEP
static void pm_suspend_marker(char *annotation)
{
struct timespec64 timestamp;
struct tm tm;
char buff[255];
/* get the time stamp in readable format to print*/
ktime_get_real_ts64(&timestamp);
time64_to_tm(timestamp.tv_sec, 0, &tm);
snprintf(buff, sizeof(buff),
"%u-%02d-%02d %02d:%02d:%02d.%06ld UTC",
(int) tm.tm_year + 1900, tm.tm_mon + 1,
tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
timestamp.tv_nsec);
pr_info("mmi_suspend_dbg_%s at: %s\n", annotation, buff);
}
static int mmi_suspend_dbg_suspend(struct device *device)
{
pm_suspend_marker("suspend");
vreg_before_sleep_save_configs();
tlmm_before_sleep_set_configs();
tlmm_before_sleep_save_configs();
return 0;
}
static int mmi_suspend_dbg_resume(struct device *device)
{
pm_suspend_marker("resume");
show_subsystem_sleep_stats();
return 0;
}
#else
#define mmi_suspend_dbg_suspend NULL
#define mmi_suspend_dbg_resume NULL
#endif
static const struct dev_pm_ops mmi_dev_pm_ops = {
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mmi_suspend_dbg_suspend, mmi_suspend_dbg_resume)
};
static const struct of_device_id mmi_suspend_dbg_match_table[] = {
{.compatible = "mmi,suspend_dbg"},
{},
};
MODULE_DEVICE_TABLE(of, mmi_suspend_dbg_match_table);
static struct platform_driver mmi_suspend_dbg_driver = {
.driver = {
.name = "mmi_suspend_dbg",
.owner = THIS_MODULE,
.pm = &mmi_dev_pm_ops,
.of_match_table = mmi_suspend_dbg_match_table,
},
};
static int __init sysfs_private_init(void)
{
int result;
pr_debug("%s(), %d\n", __func__, __LINE__);
sysfs_private_kobj = kobject_create_and_add("private", NULL);
if (!sysfs_private_kobj)
return -ENOMEM;
result = sysfs_create_group(sysfs_private_kobj, &private_attr_group);
pr_debug("%s(), %d, result=%d\n", __func__, __LINE__, result);
#ifdef CONFIG_GPIO_VALID_ARRAY
result = tlmm_tz_init();
pr_debug("%s(), %d, result=%d\n", __func__, __LINE__, result);
#endif
result = platform_driver_register(&mmi_suspend_dbg_driver);
if (result)
pr_err("mmi_suspend_dbg failed to register driver\n");
return result;
}
static void __exit sysfs_private_exit(void)
{
pr_debug("%s(), %d\n", __func__, __LINE__);
sysfs_remove_group(sysfs_private_kobj, &private_attr_group);
kobject_put(sysfs_private_kobj);
platform_driver_unregister(&mmi_suspend_dbg_driver);
}
module_init(sysfs_private_init);
module_exit(sysfs_private_exit);
MODULE_LICENSE("GPL");

View file

@ -0,0 +1,24 @@
#ifndef USER_SYSFS_PRIVATE_H
#define USER_SYSFS_PRIVATE_H
extern void tlmm_before_sleep_set_configs(void);
extern void tlmm_before_sleep_save_configs(void);
/* drivers/base/power/wakeup.c */
extern int wakelock_dump_active_info(char *buf, int size);
/* drivers/regulator/core.c */
extern void vreg_before_sleep_save_configs(void);
extern int vreg_dump_info(char *buf);
extern int vreg_before_sleep_dump_info(char *buf);
/* drivers/soc/qcom/soc_sleep_stats.c */
extern ssize_t show_subsystem_sleep_stats(void);
/* drivers/pinctrl/qcom/pinctrl-msm.c */
extern int tlmm_get_inout(unsigned gpio);
extern int tlmm_set_inout(unsigned gpio, unsigned val);
extern int tlmm_set_config(unsigned config);
extern int tlmm_get_config(unsigned gpio, unsigned *cfg);
#endif

View file

@ -38,4 +38,12 @@ config SCHED_CONSERVATIVE_BOOST_LPM_BIAS
modes on a cpu if conservative boost is active. The cpu
will not enter low power mode for a hysteresis time period,
which can be configured from userspace.
config SCHED_MOTO_UNFAIR
tristate "Enable moto unfair scheduler"
depends on SCHED_WALT
default n
help
This feature will allow the scheduler to maintain more detailed
mvp scheduling.
endmenu

View file

@ -990,6 +990,71 @@ TRACE_EVENT(walt_lb_cpu_util,
__entry->cpu_util, __entry->capacity_orig)
);
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
TRACE_EVENT(sched_cpu_util,
TP_PROTO(int cpu, struct cpumask *lowest_mask),
TP_ARGS(cpu, lowest_mask),
TP_STRUCT__entry(
__field(unsigned int, cpu)
__field(unsigned int, nr_running)
__field(long, cpu_util)
__field(long, cpu_util_cum)
__field(unsigned long, capacity_curr)
__field(unsigned long, capacity)
__field(unsigned long, capacity_orig)
__field(unsigned int, idle_exit_latency)
__field(u64, irqload)
__field(int, online)
__field(int, inactive)
__field(int, halted)
__field(int, reserved)
__field(int, high_irq_load)
__field(unsigned int, nr_rtg_high_prio_tasks)
__field(u64, prs_gprs)
__field(unsigned int, lowest_mask)
__field(unsigned long, thermal_pressure)
__field(unsigned int, walt_mvp_taks)
),
TP_fast_assign(
struct walt_rq *wrq = &per_cpu(walt_rq, cpu);
__entry->cpu = cpu;
__entry->nr_running = cpu_rq(cpu)->nr_running;
__entry->cpu_util = cpu_util(cpu);
__entry->cpu_util_cum = cpu_util_cum(cpu);
__entry->capacity_curr = capacity_curr_of(cpu);
__entry->capacity = capacity_of(cpu);
__entry->capacity_orig = capacity_orig_of(cpu);
__entry->idle_exit_latency = walt_get_idle_exit_latency(cpu_rq(cpu));
__entry->irqload = sched_irqload(cpu);
__entry->online = cpu_online(cpu);
__entry->inactive = !cpu_active(cpu);
__entry->halted = (cpu_halted(cpu)<<1) + cpu_partial_halted(cpu);
__entry->reserved = is_reserved(cpu);
__entry->high_irq_load = sched_cpu_high_irqload(cpu);
__entry->nr_rtg_high_prio_tasks = walt_nr_rtg_high_prio(cpu);
__entry->prs_gprs = wrq->prev_runnable_sum + wrq->grp_time.prev_runnable_sum;
if (!lowest_mask)
__entry->lowest_mask = 0;
else
__entry->lowest_mask = cpumask_bits(lowest_mask)[0];
__entry->thermal_pressure = arch_scale_thermal_pressure(cpu);
__entry->walt_mvp_taks = walt_mvp_taks(cpu);
),
TP_printk("cpu=%d nr_running=%d cpu_util=%ld cpu_util_cum=%ld capacity_curr=%lu capacity=%lu capacity_orig=%lu idle_exit_latency=%u irqload=%llu online=%u, inactive=%u, halted=%u, reserved=%u, high_irq_load=%u nr_rtg_hp=%u prs_gprs=%llu lowest_mask=0x%x thermal_pressure=%lu nr_mvp=%u",
__entry->cpu, __entry->nr_running, __entry->cpu_util,
__entry->cpu_util_cum, __entry->capacity_curr,
__entry->capacity, __entry->capacity_orig,
__entry->idle_exit_latency, __entry->irqload, __entry->online,
__entry->inactive, __entry->halted, __entry->reserved, __entry->high_irq_load,
__entry->nr_rtg_high_prio_tasks, __entry->prs_gprs,
__entry->lowest_mask, __entry->thermal_pressure, __entry->walt_mvp_taks)
);
#else
TRACE_EVENT(sched_cpu_util,
TP_PROTO(int cpu, struct cpumask *lowest_mask),
@ -1057,6 +1122,7 @@ TRACE_EVENT(sched_cpu_util,
__entry->enforce_high_irq, __entry->nr_rtg_high_prio_tasks, __entry->prs_gprs,
__entry->lowest_mask, __entry->thermal_pressure)
);
#endif
TRACE_EVENT(sched_compute_energy,
@ -1292,6 +1358,69 @@ TRACE_EVENT(sched_task_util,
/*
* Tracepoint for find_best_target
*/
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
TRACE_EVENT(sched_find_best_target,
TP_PROTO(struct task_struct *tsk,
unsigned long min_util, int start_cpu,
unsigned long candidates,
int most_spare_cap,
int order_index, int end_index,
int skip, bool running,
int most_spare_rq_cpu, int least_mvp_cpu, int mvp_prio),
TP_ARGS(tsk, min_util, start_cpu, candidates,
most_spare_cap,
order_index, end_index, skip, running,
most_spare_rq_cpu, least_mvp_cpu, mvp_prio),
TP_STRUCT__entry(
__array(char, comm, TASK_COMM_LEN)
__field(pid_t, pid)
__field(unsigned long, min_util)
__field(int, start_cpu)
__field(unsigned long, candidates)
__field(int, most_spare_cap)
__field(int, order_index)
__field(int, end_index)
__field(int, skip)
__field(bool, running)
__field(int, most_spare_rq_cpu)
__field(int, least_mvp_cpu)
__field(int, mvp_prio)
),
TP_fast_assign(
memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
__entry->pid = tsk->pid;
__entry->min_util = min_util;
__entry->start_cpu = start_cpu;
__entry->candidates = candidates;
__entry->most_spare_cap = most_spare_cap;
__entry->order_index = order_index;
__entry->end_index = end_index;
__entry->skip = skip;
__entry->running = running;
__entry->most_spare_rq_cpu = most_spare_rq_cpu;
__entry->least_mvp_cpu = least_mvp_cpu;
__entry->mvp_prio = mvp_prio;
),
TP_printk("pid=%d comm=%s start_cpu=%d candidates=%#lx most_spare_cap=%d order_index=%d end_index=%d skip=%d running=%d min_util=%lu spare_rq_cpu=%d least_mvp_cpu=%d mvp_prio=%d",
__entry->pid, __entry->comm,
__entry->start_cpu,
__entry->candidates,
__entry->most_spare_cap,
__entry->order_index,
__entry->end_index,
__entry->skip,
__entry->running,
__entry->min_util,
__entry->most_spare_rq_cpu,
__entry->least_mvp_cpu,
__entry->mvp_prio)
);
#else
TRACE_EVENT(sched_find_best_target,
TP_PROTO(struct task_struct *tsk,
@ -1350,6 +1479,7 @@ TRACE_EVENT(sched_find_best_target,
__entry->most_spare_rq_cpu,
__entry->cpu_rq_runnable_cnt)
);
#endif
TRACE_EVENT(sched_enq_deq_task,
@ -1461,6 +1591,57 @@ DEFINE_EVENT(walt_cfs_mvp_task_template, walt_cfs_mvp_pick_next,
TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit),
TP_ARGS(p, wts, limit));
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto wangwang: add more trace for debugging.
DECLARE_EVENT_CLASS(walt_cfs_mvp_task_template2,
TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit, struct task_struct *p2, struct walt_task_struct *wts2),
TP_ARGS(p, wts, limit, p2, wts2),
TP_STRUCT__entry(
__array(char, comm, TASK_COMM_LEN)
__field(pid_t, pid)
__field(int, prio)
__field(int, mvp_prio)
__field(int, cpu)
__field(u64, exec)
__field(unsigned int, limit)
__field(pid_t, pid2)
__field(int, prio2)
__field(int, mvp_prio2)
),
TP_fast_assign(
memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
__entry->pid = p->pid;
__entry->prio = p->prio;
__entry->mvp_prio = wts->mvp_prio;
__entry->cpu = task_cpu(p);
__entry->exec = wts->total_exec;
__entry->limit = limit;
__entry->pid2 = p2->pid;
__entry->prio2 = p2->prio;
__entry->mvp_prio2 = wts2->mvp_prio;
),
TP_printk("comm=%s pid=%d prio=%d mvp_prio=%d cpu=%d exec=%llu limit=%u pid2=%d prio2=%d, mvp_prio2=%d",
__entry->comm, __entry->pid, __entry->prio,
__entry->mvp_prio, __entry->cpu, __entry->exec,
__entry->limit,
__entry->pid2, __entry->prio2, __entry->mvp_prio2)
);
/* called upon when MVP (current) is not preempted by waking task */
DEFINE_EVENT(walt_cfs_mvp_task_template2, walt_cfs_mvp_wakeup_nopreempt,
TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit, struct task_struct *p2, struct walt_task_struct *wts2),
TP_ARGS(p, wts, limit, p2, wts2));
/* called upon when MVP (waking task) preempts the current */
DEFINE_EVENT(walt_cfs_mvp_task_template2, walt_cfs_mvp_wakeup_preempt,
TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit, struct task_struct *p2, struct walt_task_struct *wts2),
TP_ARGS(p, wts, limit, p2, wts2));
#else
/* called upon when MVP (current) is not preempted by waking task */
DEFINE_EVENT(walt_cfs_mvp_task_template, walt_cfs_mvp_wakeup_nopreempt,
TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit),
@ -1470,6 +1651,7 @@ DEFINE_EVENT(walt_cfs_mvp_task_template, walt_cfs_mvp_wakeup_nopreempt,
DEFINE_EVENT(walt_cfs_mvp_task_template, walt_cfs_mvp_wakeup_preempt,
TP_PROTO(struct task_struct *p, struct walt_task_struct *wts, unsigned int limit),
TP_ARGS(p, wts, limit));
#endif
#define SPAN_SIZE (NR_CPUS/4)

View file

@ -119,6 +119,22 @@ static struct syscore_ops walt_syscore_ops = {
.suspend = walt_suspend
};
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto huangzq2
int moto_sched_enabled = 0;
int set_moto_sched_enabled(int enable) {
moto_sched_enabled = enable;
return 0;
}
EXPORT_SYMBOL(set_moto_sched_enabled);
struct msched_ops *moto_sched_ops = NULL;
void set_moto_sched_ops(struct msched_ops *ops) {
moto_sched_ops = ops;
}
EXPORT_SYMBOL_GPL(set_moto_sched_ops);
#endif
/*
*@boost:should be 0,1,2.
*@period:boost time based on ms units.
@ -5313,10 +5329,18 @@ static void walt_do_sched_yield(void *unused, struct rq *rq)
walt_lockdep_assert_rq(rq, NULL);
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto wangwang: don't deactivate mvp tasks when moto_sched enabled.
if (unlikely(!moto_sched_enabled) && !list_empty(&wts->mvp_list) && wts->mvp_list.next) {
if (!pipeline_in_progress() || !walt_pipeline_low_latency_task(curr))
walt_cfs_deactivate_mvp_task(rq, curr, 3); // Moto huangzq2: debugging enhancement.
}
#else
if (!list_empty(&wts->mvp_list) && wts->mvp_list.next) {
if (!pipeline_in_progress() || !walt_pipeline_low_latency_task(curr))
walt_cfs_deactivate_mvp_task(rq, curr);
}
#endif
if (per_cpu(rt_task_arrival_time, cpu_of(rq)))
per_cpu(rt_task_arrival_time, cpu_of(rq)) = 0;
@ -5561,7 +5585,9 @@ static void walt_init(struct work_struct *work)
walt_rt_init();
walt_cfs_init();
walt_halt_init();
#if !IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
walt_mvp_lock_ordering_init();
#endif
wait_for_completion_interruptible(&tick_sched_clock_completion);

View file

@ -964,6 +964,16 @@ static inline unsigned int walt_nr_rtg_high_prio(int cpu)
return wrq->walt_stats.nr_rtg_high_prio_tasks;
}
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
extern int moto_sched_enabled;
static inline unsigned int walt_mvp_taks(int cpu)
{
struct walt_rq *wrq = &per_cpu(walt_rq, cpu);
return wrq->num_mvp_tasks;
}
#endif
static inline bool task_in_related_thread_group(struct task_struct *p)
{
struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1;
@ -1223,10 +1233,23 @@ static inline bool walt_flag_test(struct task_struct *p, unsigned int feature)
/* higher number, better priority */
#define WALT_RTG_MVP 0
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
/* Moto huangzq2: reserve mvp prioriteis (11~100) for moto_sched */
#define UX_PRIO_TOPAPP 70 // must be aligned with moto_sched!
#define UX_PRIO_KSWAPD 65 // must be aligned with moto_sched!
#define WALT_BINDER_MVP 101
#define WALT_TASK_BOOST_MVP UX_PRIO_TOPAPP // align to UX_PRIO_TOPAPP in moto_sched
#define WALT_LL_MVP 103
#define WALT_PIPELINE_MVP 104
#else
#define WALT_BINDER_MVP 1
#define WALT_TASK_BOOST_MVP 2
#define WALT_LL_MVP 3
#define WALT_PIPELINE_MVP 4
#endif
#define WALT_NOT_MVP -1
@ -1370,7 +1393,12 @@ extern struct rq *__migrate_task(struct rq *rq, struct rq_flags *rf,
DECLARE_PER_CPU(u64, rt_task_arrival_time);
extern int walt_get_mvp_task_prio(struct task_struct *p);
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
extern void walt_cfs_deactivate_mvp_task(struct rq *rq, struct task_struct *p, unsigned int reason); // Moto huangzq2: debugging enhancement.
#else
extern void walt_cfs_deactivate_mvp_task(struct rq *rq, struct task_struct *p);
#endif
void inc_rq_walt_stats(struct rq *rq, struct task_struct *p);
void dec_rq_walt_stats(struct rq *rq, struct task_struct *p);

View file

@ -106,6 +106,9 @@ struct find_best_target_env {
int end_index;
bool strict_max;
int skip_cpu;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
int mvp_prio;
#endif
u64 prs[8];
};
@ -275,8 +278,10 @@ static inline bool walt_should_reject_fbt_cpu(struct walt_rq *wrq, struct task_s
if (fbt_env->skip_cpu == cpu)
return true;
#if !IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
if (wrq->num_mvp_tasks > 0 && per_task_boost(p) != TASK_BOOST_STRICT_MAX)
return true;
#endif
return false;
}
@ -341,6 +346,10 @@ static void walt_find_best_target(struct sched_domain *sd,
int packing_cpu, cpu;
unsigned int search_sibling_cluster = 0;
bool visited_clusters[MAX_CLUSTERS] = {[0 ... (MAX_CLUSTERS-1)] = false};
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
int mvp_min_tasks = INT_MAX; // Moto chentao: spread mvp tasks.
int least_mvp_cpu = -1; // Moto huangzq2
#endif
/* Find start CPU based on boost value */
start_cpu = fbt_env->start_cpu;
@ -419,6 +428,26 @@ retry:
if (walt_should_reject_fbt_cpu(wrq, p, i, order_index, fbt_env))
continue;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto huangzq2: skip long exec mvp tasks like top app or kswapd.
if (likely(moto_sched_enabled) && wrq->num_mvp_tasks > 0) {
struct walt_task_struct *rq_wts = list_first_entry(&wrq->mvp_tasks, struct walt_task_struct, mvp_list);
if (rq_wts != NULL && (rq_wts->mvp_prio == UX_PRIO_TOPAPP || rq_wts->mvp_prio == UX_PRIO_KSWAPD)) {
continue;
}
}
if (likely(moto_sched_enabled)
&& (wrq->num_mvp_tasks < mvp_min_tasks // least mvp tasks, select it.
|| (wrq->num_mvp_tasks == mvp_min_tasks && i == prev_cpu))) { // same mvp tasks but prev_cpu, also select it.
mvp_min_tasks = wrq->num_mvp_tasks;
least_mvp_cpu = i;
}
if (wrq->num_mvp_tasks > 0)
continue;
#endif
/*
* p's blocked utilization is still accounted for on prev_cpu
* so prev_cpu will receive a negative bias due to the double
@ -561,6 +590,10 @@ retry:
if (unlikely(cpumask_empty(candidates))) {
if (most_spare_cap_cpu != -1)
cpumask_set_cpu(most_spare_cap_cpu, candidates);
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
else if (least_mvp_cpu != -1)
cpumask_set_cpu(least_mvp_cpu, candidates);
#endif
else if (cpu_active(prev_cpu)
&& (cpu_rq(prev_cpu)->nr_running < DIRE_STRAITS_PREV_NR_LIMIT))
cpumask_set_cpu(prev_cpu, candidates);
@ -583,10 +616,17 @@ out:
goto retry;
}
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
trace_sched_find_best_target(p, min_task_util, start_cpu, cpumask_bits(candidates)[0],
most_spare_cap_cpu, order_index, end_index,
fbt_env->skip_cpu, task_on_rq_queued(p), least_nr_cpu,
least_mvp_cpu, fbt_env->mvp_prio);
#else
trace_sched_find_best_target(p, min_task_util, start_cpu, cpumask_bits(candidates)[0],
most_spare_cap_cpu, order_index, end_index,
fbt_env->skip_cpu, task_on_rq_queued(p), least_nr_cpu,
cpu_rq_runnable_cnt);
#endif
}
static inline unsigned long
@ -990,6 +1030,13 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu,
if (!pd)
goto fail;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// TODO: Mark it here becuase of potential overhead of walt_get_mvp_task_prio,
// pls unmark it once we have further optimization based on current mvp_prio,
// for example, select big core on top app.
// fbt_env.mvp_prio = walt_get_mvp_task_prio(p);
fbt_env.mvp_prio = WALT_NOT_MVP;
#endif
fbt_env.is_rtg = is_rtg;
fbt_env.start_cpu = start_cpu;
fbt_env.order_index = order_index;
@ -1170,6 +1217,12 @@ static void binder_set_priority_hook(void *data,
*/
wts->low_latency &= ~WALT_LOW_LATENCY_BINDER_BIT;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto huangzq2: inherit ux type
if (bndrtrans && bndrtrans->need_reply) {
moto_binder_inherit_ux_type(task);
}
#endif
}
static void binder_restore_priority_hook(void *data,
@ -1182,6 +1235,13 @@ static void binder_restore_priority_hook(void *data,
if (bndrtrans && wts->boost == TASK_BOOST_STRICT_MAX)
wts->boost = bndrtrans->android_vendor_data1;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto huangzq2: clear inherited ux type
if (bndrtrans) {
moto_binder_clear_inherited_ux_type(task);
}
#endif
}
/*
@ -1194,6 +1254,10 @@ static void binder_restore_priority_hook(void *data,
*/
int walt_get_mvp_task_prio(struct task_struct *p)
{
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
int mvp_prio; // Moto huangzq2
#endif
if (walt_pipeline_low_latency_task(p))
return WALT_PIPELINE_MVP;
@ -1206,12 +1270,44 @@ int walt_get_mvp_task_prio(struct task_struct *p)
if (walt_binder_low_latency_task(p))
return WALT_BINDER_MVP;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
mvp_prio = moto_task_get_mvp_prio(p, true);
if (mvp_prio > WALT_NOT_MVP) // Moto huangzq2
return mvp_prio;
#endif
if (task_rtg_high_prio(p))
return WALT_RTG_MVP;
return WALT_NOT_MVP;
}
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto huangzq2
static inline unsigned int __walt_cfs_mvp_task_limit(struct task_struct *p, int mvp_prio)
{
unsigned int limit; // Moto huangzq2
/* Binder MVP tasks are high prio but have only single slice */
if (mvp_prio == WALT_BINDER_MVP)
return WALT_MVP_SLICE;
if (mvp_prio == WALT_PIPELINE_MVP)
return 2 * WALT_MVP_LIMIT;
limit = moto_task_get_mvp_limit(p, mvp_prio); // Moto huangzq2
if (limit > 0)
return limit;
return WALT_MVP_LIMIT;
}
static inline unsigned int walt_cfs_mvp_task_limit(struct task_struct *p)
{
struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1;
return __walt_cfs_mvp_task_limit(p, wts->mvp_prio);
}
#else
static inline unsigned int walt_cfs_mvp_task_limit(struct task_struct *p)
{
struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1;
@ -1220,11 +1316,9 @@ static inline unsigned int walt_cfs_mvp_task_limit(struct task_struct *p)
if (wts->mvp_prio == WALT_BINDER_MVP)
return WALT_MVP_SLICE;
if (wts->mvp_prio == WALT_PIPELINE_MVP)
return 2 * WALT_MVP_LIMIT;
return WALT_MVP_LIMIT;
}
#endif
static void walt_cfs_insert_mvp_task(struct walt_rq *wrq, struct walt_task_struct *wts,
bool at_front)
@ -1248,11 +1342,19 @@ static void walt_cfs_insert_mvp_task(struct walt_rq *wrq, struct walt_task_struc
wrq->num_mvp_tasks++;
}
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
void walt_cfs_deactivate_mvp_task(struct rq *rq, struct task_struct *p, unsigned int reason) // Moto huangzq2: debugging enhancement.
#else
void walt_cfs_deactivate_mvp_task(struct rq *rq, struct task_struct *p)
#endif
{
struct walt_rq *wrq = &per_cpu(walt_rq, cpu_of(rq));
struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
trace_walt_cfs_deactivate_mvp_task(rq->curr, wts, reason); // MOto wangwang: debugging enhancement.
#endif
list_del_init(&wts->mvp_list);
wts->mvp_prio = WALT_NOT_MVP;
wrq->num_mvp_tasks--;
@ -1326,8 +1428,12 @@ static void walt_cfs_account_mvp_runtime(struct rq *rq, struct task_struct *curr
limit = walt_cfs_mvp_task_limit(curr);
if (wts->total_exec > limit) {
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
walt_cfs_deactivate_mvp_task(rq, curr, 2); // Moto huangzq2: debugging enhancement.
#else
walt_cfs_deactivate_mvp_task(rq, curr);
trace_walt_cfs_deactivate_mvp_task(curr, wts, limit);
#endif
return;
}
@ -1354,8 +1460,13 @@ void walt_cfs_enqueue_task(struct rq *rq, struct task_struct *p)
* it was once MVP but got demoted, it will not be MVP until
* it goes to sleep again.
*/
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
if (wts->total_exec > __walt_cfs_mvp_task_limit(p, mvp_prio)) // Moto huangzq2: use __walt_cfs_mvp_task_limit
return;
#else
if (wts->total_exec > walt_cfs_mvp_task_limit(p))
return;
#endif
wts->mvp_prio = mvp_prio;
walt_cfs_insert_mvp_task(wrq, wts, task_on_cpu(rq, p));
@ -1369,14 +1480,24 @@ void walt_cfs_enqueue_task(struct rq *rq, struct task_struct *p)
wts->sum_exec_snapshot_for_total = p->se.sum_exec_runtime;
wts->sum_exec_snapshot_for_slice = p->se.sum_exec_runtime;
}
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto chentao8: enqueue task
moto_queue_ux_task(rq, p, 1);
#endif
}
void walt_cfs_dequeue_task(struct rq *rq, struct task_struct *p)
{
struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
if (!list_empty(&wts->mvp_list) && wts->mvp_list.next)
walt_cfs_deactivate_mvp_task(rq, p, 1); // Moto huangzq2: debugging enhancement.
#else
if (!list_empty(&wts->mvp_list) && wts->mvp_list.next)
walt_cfs_deactivate_mvp_task(rq, p);
#endif
/*
* Reset the exec time during sleep so that it starts
@ -1386,6 +1507,11 @@ void walt_cfs_dequeue_task(struct rq *rq, struct task_struct *p)
*/
if (READ_ONCE(p->__state) != TASK_RUNNING)
wts->total_exec = 0;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
// Moto chentao8: dequeue task
moto_queue_ux_task(rq, p, 0);
#endif
}
void walt_cfs_tick(struct rq *rq)
@ -1455,8 +1581,17 @@ static void walt_cfs_check_preempt_wakeup(void *unused, struct rq *rq, struct ta
*/
skip_mvp = wrq->skip_mvp;
walt_cfs_account_mvp_runtime(rq, c);
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
if (likely(moto_sched_enabled))
resched = ((skip_mvp != wrq->skip_mvp) || (wrq->mvp_tasks.next != &wts_c->mvp_list) ||
(wts_p->mvp_prio > wts_c->mvp_prio)) && (wrq->mvp_tasks.next == &wts_p->mvp_list); // Moto wangwang: fix preemption issue.
else
resched = (skip_mvp != wrq->skip_mvp) || (wrq->mvp_tasks.next != &wts_c->mvp_list) ||
(wts_p->mvp_prio > wts_c->mvp_prio);
#else
resched = (skip_mvp != wrq->skip_mvp) || (wrq->mvp_tasks.next != &wts_c->mvp_list) ||
(wts_p->mvp_prio > wts_c->mvp_prio);
#endif
/*
* current is no longer eligible to run. It must have been
@ -1470,11 +1605,19 @@ static void walt_cfs_check_preempt_wakeup(void *unused, struct rq *rq, struct ta
/* current is the first in the queue, so no preemption */
*nopreempt = true;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
trace_walt_cfs_mvp_wakeup_nopreempt(c, wts_c, walt_cfs_mvp_task_limit(c), p, wts_p); // Moto wangwang: debugging enhancement.
#else
trace_walt_cfs_mvp_wakeup_nopreempt(c, wts_c, walt_cfs_mvp_task_limit(c));
#endif
return;
preempt:
*preempt = true;
#if IS_ENABLED(CONFIG_SCHED_MOTO_UNFAIR)
trace_walt_cfs_mvp_wakeup_preempt(p, wts_p, walt_cfs_mvp_task_limit(p), c, wts_c); // Moto wangwang: debugging enhancement.
#else
trace_walt_cfs_mvp_wakeup_preempt(p, wts_p, walt_cfs_mvp_task_limit(p));
#endif
}
#ifdef CONFIG_FAIR_GROUP_SCHED
@ -1511,6 +1654,9 @@ static void walt_cfs_replace_next_task_fair(void *unused, struct rq *rq, struct
/* RQ is in MVP throttled state*/
if (wrq->skip_mvp)
return;
/* We don't have MVP tasks queued */
if (list_empty(&wrq->mvp_tasks))
return;
if (list_empty(&wrq->mvp_tasks)) {
wrq->mvp_arrival_time = 0;

View file

@ -13,7 +13,6 @@ dispcc-parrot.ko
gcc-sm4450.ko
dispcc-sm4450.ko
sched-walt.ko
sched-walt-debug.ko
qcom_wdt_core.ko
qcom_cpucp.ko
qcom_ipc_logging.ko

View file

@ -63,3 +63,9 @@ blocklist vsock
blocklist vsock_diag
blocklist xc4000
blocklist xc5000
blocklist goodix_fod_mmi.ko
blocklist rbs_fod_mmi.ko
blocklist watchdogtest
blocklist anc_fps_mmi
blocklist fpc1020_mmi

View file

@ -108,6 +108,7 @@ EOF
] + [fragment for fragment in build_config_fragments] + [
"build.config.msm.common",
"build.config.msm.perf",
"build.config.moto",
],
)

View file

@ -1,6 +1,7 @@
load(":image_opts.bzl", "boot_image_opts")
load(":msm_kernel_la.bzl", "define_msm_la")
load(":target_variants.bzl", "la_variants")
load(":moto_product.bzl", "mmi_product_name")
target_name = "parrot"
@ -65,6 +66,7 @@ def define_parrot():
"drivers/iio/adc/qcom-vadc-common.ko",
"drivers/iio/adc/qti-glink-adc.ko",
"drivers/input/misc/pm8941-pwrkey.ko",
"drivers/input/misc/qcom-hv-haptics.ko",
"drivers/input/misc/qpnp-power-on.ko",
"drivers/interconnect/qcom/icc-bcm-voter.ko",
"drivers/interconnect/qcom/icc-debug.ko",
@ -151,7 +153,6 @@ def define_parrot():
"drivers/soc/qcom/gic_intr_routing.ko",
"drivers/soc/qcom/hung_task_enh.ko",
"drivers/soc/qcom/mdt_loader.ko",
"drivers/soc/qcom/mem-offline.ko",
"drivers/soc/qcom/mem_buf/mem_buf.ko",
"drivers/soc/qcom/mem_buf/mem_buf_dev.ko",
"drivers/soc/qcom/mem_buf/mem_buf_msgq.ko",
@ -255,16 +256,25 @@ def define_parrot():
_parrot_consolidate_in_tree_modules = _parrot_in_tree_modules + [
# keep sorted
"drivers/hwtracing/coresight/coresight-etm4x.ko",
"drivers/misc/lkdtm/lkdtm.ko",
"kernel/locking/locktorture.ko",
"kernel/power/user_sysfs_private.ko",
"kernel/rcu/rcutorture.ko",
"kernel/sched/walt/sched-walt-debug.ko",
#"kernel/sched/walt/sched-walt-debug.ko",
"kernel/torture.ko",
"lib/atomic64_test.ko",
"lib/test_user_copy.ko",
]
_parrot_moto_in_tree_modules = {
"mona": [
# keep sorted
],
"monai": [
# keep sorted
],
}
kernel_vendor_cmdline_extras = ["bootconfig"]
for variant in la_variants:
@ -273,7 +283,7 @@ def define_parrot():
if variant == "consolidate":
mod_list = _parrot_consolidate_in_tree_modules
board_bootconfig_extras += ["androidboot.serialconsole=1"]
#board_bootconfig_extras += ["androidboot.serialconsole=1"]
board_kernel_cmdline_extras += [
# do not sort
"console=ttyMSM0,115200n8",
@ -290,12 +300,17 @@ def define_parrot():
mod_list = _parrot_in_tree_modules
board_kernel_cmdline_extras += ["nosoftlockup console=ttynull qcom_geni_serial.con_enabled=0"]
kernel_vendor_cmdline_extras += ["nosoftlockup console=ttynull qcom_geni_serial.con_enabled=0"]
board_bootconfig_extras += ["androidboot.serialconsole=0"]
#board_bootconfig_extras += ["androidboot.serialconsole=0"]
moto_in_tree_modules = [ ]
for p, v in _parrot_moto_in_tree_modules.items():
if p == mmi_product_name:
moto_in_tree_modules = v
define_msm_la(
msm_target = target_name,
variant = variant,
in_tree_module_list = mod_list,
in_tree_module_list = mod_list + moto_in_tree_modules,
boot_image_opts = boot_image_opts(
kernel_vendor_cmdline_extras = kernel_vendor_cmdline_extras,
board_kernel_cmdline_extras = board_kernel_cmdline_extras,