Skip to content

Commit

Permalink
Synchronize codes for OnePlus 8T Oxygen OS 11.0.12.12.KB05AA and OneP…
Browse files Browse the repository at this point in the history
…lus 8 Oxygen OS 11.0.9.9.IN21AA and OnePlus 8 Pro Oxygen OS 11.0.9.9.IN11AA

1.Optimize charge experience.
2.Optimize performance experience.

Change-Id: I62544fb6dc2bf3ee39cacf727c8291ace3463091

Signed-off-by: engstk <eng.stk@sapo.pt>
  • Loading branch information
YuHuang65 authored and engstk committed Dec 21, 2021
1 parent 8dbc508 commit 13d123b
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 54 deletions.
5 changes: 5 additions & 0 deletions drivers/crypto/msm/qce50.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,11 @@ static int _ce_setup_cipher(struct qce_device *pce_dev, struct qce_req *creq,
switch (creq->alg) {
case CIPHER_ALG_DES:
if (creq->mode != QCE_MODE_ECB) {
if (ivsize > MAX_IV_LENGTH) {
pr_err("%s: error: Invalid length parameter\n",
__func__);
return -EINVAL;
}
_byte_stream_to_net_words(enciv32, creq->iv, ivsize);
pce = cmdlistinfo->encr_cntr_iv;
pce->data = enciv32[0];
Expand Down
6 changes: 3 additions & 3 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ EXPORT_SYMBOL_GPL(hid_register_report);
* Register a new field for this report.
*/

static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages)
{
struct hid_field *field;

Expand All @@ -104,7 +104,7 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned

field = kzalloc((sizeof(struct hid_field) +
usages * sizeof(struct hid_usage) +
values * sizeof(unsigned)), GFP_KERNEL);
usages * sizeof(unsigned)), GFP_KERNEL);
if (!field)
return NULL;

Expand Down Expand Up @@ -300,7 +300,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
usages = max_t(unsigned, parser->local.usage_index,
parser->global.report_count);

field = hid_register_field(report, usages, parser->global.report_count);
field = hid_register_field(report, usages);
if (!field)
return 0;

Expand Down
26 changes: 25 additions & 1 deletion drivers/oneplus/power/supply/qcom/oneplus_fastchg.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct fastchg_device_info {
bool is_swarp_supported;
bool warp_normal_path_need_config;
bool fw_ver_not_match;
bool need_recheck_fw;
int asic_hw_id;
#endif
bool is_4300mAh_4p45_support;
Expand Down Expand Up @@ -2297,7 +2298,7 @@ static void dashchg_fw_update(struct work_struct *work)
} else {
rc = dashchg_fw_check();
}
if (rc == FW_CHECK_SUCCESS) {
if (rc == FW_CHECK_SUCCESS && !di->need_recheck_fw) {
di->firmware_already_updated = true;
reset_mcu_and_request_irq(di);
#ifdef OP_SWARP_SUPPORTED
Expand All @@ -2324,6 +2325,7 @@ static void dashchg_fw_update(struct work_struct *work)
msleep(10);
}
rc = rk826_fw_write(di, dashchg_firmware_data, 0, di->dashchg_fw_ver_count);
di->need_recheck_fw = false;
} else if (di->asic_hw_id == RICHTEK_RT5125) {
rc = rt5125_fw_update(di);
}
Expand Down Expand Up @@ -2600,6 +2602,27 @@ void enhance_dash_type_set(int type)
}
}

void recheck_asic_fw_status(void)
{
u8 value_buf[2] = {0};
int rc = 0;
struct fastchg_device_info *di = fastchg_di;

if (di->asic_hw_id == ROCKCHIP_RK826) {
rc = oneplus_u16_i2c_read(di->client, 0x52f8, 2, value_buf);
if (rc < 0) {
pr_info("rk826 read register 0x52f8 fail, rc = %d\n", rc);
pr_info("rk826 fw check ok.");
} else {
pr_info("read 0x52f8 success 0x%x", value_buf[0] | (value_buf[1] << 8));
pr_err("fw has err, need re-download.");
di->need_recheck_fw = true;
di->firmware_already_updated = false;
schedule_delayed_work(&di->update_firmware, msecs_to_jiffies(2000));
}
}
}

int dash_get_adapter_update_status(void)
{
if (!fastchg_di)
Expand Down Expand Up @@ -3896,6 +3919,7 @@ static int dash_probe(struct i2c_client *client, const struct i2c_device_id *id)
di->fast_chg_ing = false;
di->fast_low_temp_full = false;
di->fast_chg_started = false;
di->need_recheck_fw = false;

fastchg_di = di;
dev_set_drvdata(&client->dev, di);
Expand Down
5 changes: 4 additions & 1 deletion drivers/power/supply/qcom/smb5-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -9188,6 +9188,7 @@ bool is_fastchg_allowed(struct smb_charger *chg)
if (chg->swarp_online
&& cap > DASH_VALID_CAPACITY_HIG_THRESHOLD) {
pr_err("capacity high, swarp adapter.");
chg->dash_present = true;
return false;
}

Expand Down Expand Up @@ -9946,8 +9947,10 @@ static void retrigger_dash_work(struct work_struct *work)
schedule_delayed_work(&chg->pd_status_check_work,
msecs_to_jiffies(2000));
}
if (chg->swarp_supported)
if (chg->swarp_supported) {
rerun_election(chg->usb_icl_votable);
recheck_asic_fw_status();
}
return;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/power/supply/qcom/smb5-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ extern bool get_prop_fast_chg_started(struct smb_charger *chg);
extern void mcu_en_gpio_set(int value);
extern void switch_mode_to_normal(void);
extern void enhance_dash_type_set(int type);
extern void recheck_asic_fw_status(void);
extern void notify_pd_in_to_wireless(void);
extern struct smb_charger *g_chg;
extern struct drm_panel *lcd_active_panel;
Expand Down
7 changes: 6 additions & 1 deletion drivers/tty/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2751,10 +2751,14 @@ void __do_SAK(struct tty_struct *tty)
struct task_struct *g, *p;
struct pid *session;
int i;
unsigned long flags;

if (!tty)
return;
session = tty->session;

spin_lock_irqsave(&tty->ctrl_lock, flags);
session = get_pid(tty->session);
spin_unlock_irqrestore(&tty->ctrl_lock, flags);

tty_ldisc_flush(tty);

Expand Down Expand Up @@ -2786,6 +2790,7 @@ void __do_SAK(struct tty_struct *tty)
task_unlock(p);
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
put_pid(session);
#endif
}

Expand Down
44 changes: 31 additions & 13 deletions drivers/tty/tty_jobctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ static void __proc_set_tty(struct tty_struct *tty)
put_pid(tty->session);
put_pid(tty->pgrp);
tty->pgrp = get_pid(task_pgrp(current));
spin_unlock_irqrestore(&tty->ctrl_lock, flags);
tty->session = get_pid(task_session(current));
spin_unlock_irqrestore(&tty->ctrl_lock, flags);
if (current->signal->tty) {
tty_debug(tty, "current tty %s not NULL!!\n",
current->signal->tty->name);
Expand Down Expand Up @@ -293,20 +293,23 @@ void disassociate_ctty(int on_exit)
spin_lock_irq(&current->sighand->siglock);
put_pid(current->signal->tty_old_pgrp);
current->signal->tty_old_pgrp = NULL;

tty = tty_kref_get(current->signal->tty);
spin_unlock_irq(&current->sighand->siglock);

if (tty) {
unsigned long flags;

tty_lock(tty);
spin_lock_irqsave(&tty->ctrl_lock, flags);
put_pid(tty->session);
put_pid(tty->pgrp);
tty->session = NULL;
tty->pgrp = NULL;
spin_unlock_irqrestore(&tty->ctrl_lock, flags);
tty_unlock(tty);
tty_kref_put(tty);
}

spin_unlock_irq(&current->sighand->siglock);
/* Now clear signal->tty under the lock */
read_lock(&tasklist_lock);
session_clear_tty(task_session(current));
Expand Down Expand Up @@ -477,14 +480,19 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
return -ENOTTY;
if (retval)
return retval;
if (!current->signal->tty ||
(current->signal->tty != real_tty) ||
(real_tty->session != task_session(current)))
return -ENOTTY;

if (get_user(pgrp_nr, p))
return -EFAULT;
if (pgrp_nr < 0)
return -EINVAL;

spin_lock_irq(&real_tty->ctrl_lock);
if (!current->signal->tty ||
(current->signal->tty != real_tty) ||
(real_tty->session != task_session(current))) {
retval = -ENOTTY;
goto out_unlock_ctrl;
}
rcu_read_lock();
pgrp = find_vpid(pgrp_nr);
retval = -ESRCH;
Expand All @@ -494,12 +502,12 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
if (session_of_pgrp(pgrp) != task_session(current))
goto out_unlock;
retval = 0;
spin_lock_irq(&real_tty->ctrl_lock);
put_pid(real_tty->pgrp);
real_tty->pgrp = get_pid(pgrp);
spin_unlock_irq(&real_tty->ctrl_lock);
out_unlock:
rcu_read_unlock();
out_unlock_ctrl:
spin_unlock_irq(&real_tty->ctrl_lock);
return retval;
}

Expand All @@ -511,20 +519,30 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
*
* Obtain the session id of the tty. If there is no session
* return an error.
*
* Locking: none. Reference to current->signal->tty is safe.
*/
static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
{
unsigned long flags;
pid_t sid;

/*
* (tty == real_tty) is a cheap way of
* testing if the tty is NOT a master pty.
*/
if (tty == real_tty && current->signal->tty != real_tty)
return -ENOTTY;

spin_lock_irqsave(&real_tty->ctrl_lock, flags);
if (!real_tty->session)
return -ENOTTY;
return put_user(pid_vnr(real_tty->session), p);
goto err;
sid = pid_vnr(real_tty->session);
spin_unlock_irqrestore(&real_tty->ctrl_lock, flags);

return put_user(sid, p);

err:
spin_unlock_irqrestore(&real_tty->ctrl_lock, flags);
return -ENOTTY;
}

/*
Expand Down
30 changes: 15 additions & 15 deletions fs/incfs/data_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf)
if (!S_ISREG(bf->f_inode->i_mode))
return ERR_PTR(-EBADF);

bfc = incfs_alloc_bfc(bf);
bfc = incfs_alloc_bfc(mi, bf);
if (IS_ERR(bfc))
return ERR_CAST(bfc);

Expand Down Expand Up @@ -199,6 +199,7 @@ void incfs_free_data_file(struct data_file *df)
for (i = 0; i < ARRAY_SIZE(df->df_segments); i++)
data_file_segment_destroy(&df->df_segments[i]);
incfs_free_bfc(df->df_backing_file_context);
kfree(df->df_signature);
kfree(df);
}

Expand Down Expand Up @@ -387,8 +388,8 @@ static void log_block_read(struct mount_info *mi, incfs_uuid_t *id,
schedule_delayed_work(&log->ml_wakeup_work, msecs_to_jiffies(16));
}

static int validate_hash_tree(struct file *bf, struct file *f, int block_index,
struct mem_range data, u8 *buf)
static int validate_hash_tree(struct backing_file_context *bfc, struct file *f,
int block_index, struct mem_range data, u8 *buf)
{
struct data_file *df = get_incfs_data_file(f);
u8 stored_digest[INCFS_MAX_HASH_SIZE] = {};
Expand Down Expand Up @@ -445,7 +446,7 @@ static int validate_hash_tree(struct file *bf, struct file *f, int block_index,
if (page)
put_page(page);

res = incfs_kread(bf, buf, INCFS_DATA_FILE_BLOCK_SIZE,
res = incfs_kread(bfc, buf, INCFS_DATA_FILE_BLOCK_SIZE,
hash_block_offset[lvl] + sig->hash_offset);
if (res < 0)
return res;
Expand Down Expand Up @@ -918,7 +919,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f,
ssize_t result;
size_t bytes_to_read;
struct mount_info *mi = NULL;
struct file *bf = NULL;
struct backing_file_context *bfc = NULL;
struct data_file_block block = {};
struct data_file *df = get_incfs_data_file(f);

Expand All @@ -929,7 +930,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f,
return -ERANGE;

mi = df->df_mount_info;
bf = df->df_backing_file_context->bc_file;
bfc = df->df_backing_file_context;

result = wait_for_data_block(df, index, timeout_ms, &block);
if (result < 0)
Expand All @@ -938,20 +939,20 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f,
pos = block.db_backing_file_data_offset;
if (block.db_comp_alg == COMPRESSION_NONE) {
bytes_to_read = min(dst.len, block.db_stored_size);
result = incfs_kread(bf, dst.data, bytes_to_read, pos);
result = incfs_kread(bfc, dst.data, bytes_to_read, pos);

/* Some data was read, but not enough */
if (result >= 0 && result != bytes_to_read)
result = -EIO;
} else {
bytes_to_read = min(tmp.len, block.db_stored_size);
result = incfs_kread(bf, tmp.data, bytes_to_read, pos);
result = incfs_kread(bfc, tmp.data, bytes_to_read, pos);
if (result == bytes_to_read) {
result =
decompress(range(tmp.data, bytes_to_read), dst);
if (result < 0) {
const char *name =
bf->f_path.dentry->d_name.name;
bfc->bc_file->f_path.dentry->d_name.name;

pr_warn_once("incfs: Decompression error. %s",
name);
Expand All @@ -963,7 +964,7 @@ ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f,
}

if (result > 0) {
int err = validate_hash_tree(bf, f, index, dst, tmp.data);
int err = validate_hash_tree(bfc, f, index, dst, tmp.data);

if (err < 0)
result = err;
Expand Down Expand Up @@ -1026,14 +1027,13 @@ int incfs_process_new_data_block(struct data_file *df,
unlock:
mutex_unlock(&segment->blockmap_mutex);
if (error)
pr_debug("incfs: %s %d error: %d\n", __func__,
block->block_index, error);
pr_debug("%d error: %d\n", block->block_index, error);
return error;
}

int incfs_read_file_signature(struct data_file *df, struct mem_range dst)
{
struct file *bf = df->df_backing_file_context->bc_file;
struct backing_file_context *bfc = df->df_backing_file_context;
struct incfs_df_signature *sig;
int read_res = 0;

Expand All @@ -1047,7 +1047,7 @@ int incfs_read_file_signature(struct data_file *df, struct mem_range dst)
if (dst.len < sig->sig_size)
return -E2BIG;

read_res = incfs_kread(bf, dst.data, sig->sig_size, sig->sig_offset);
read_res = incfs_kread(bfc, dst.data, sig->sig_size, sig->sig_offset);

if (read_res < 0)
return read_res;
Expand Down Expand Up @@ -1173,7 +1173,7 @@ static int process_file_signature_md(struct incfs_file_signature *sg,
goto out;
}

read = incfs_kread(df->df_backing_file_context->bc_file, buf,
read = incfs_kread(df->df_backing_file_context, buf,
signature->sig_size, signature->sig_offset);
if (read < 0) {
error = read;
Expand Down
Loading

0 comments on commit 13d123b

Please sign in to comment.