Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
Merge branch '7.1.x-flash-oos' into 7.1.x-flash-custom-dev
Browse files Browse the repository at this point in the history
* 7.1.x-flash-oos:
  Linux 4.4.86
  drm/i915: fix compiler warning in drivers/gpu/drm/i915/intel_uncore.c
  scsi: sg: reset 'res_in_use' after unlinking reserved array
  scsi: sg: protect accesses to 'reserved' page array
  arm64: fpsimd: Prevent registers leaking across exec
  x86/io: Add "memory" clobber to insb/insw/insl/outsb/outsw/outsl
  arm64: mm: abort uaccess retries upon fatal signal
  lpfc: Fix Device discovery failures during switch reboot test.
  p54: memset(0) whole array
  lightnvm: initialize ppa_addr in dev_to_generic_addr()
  gcov: support GCC 7.1
  gcov: add support for gcc version >= 6
  i2c: jz4780: drop superfluous init
  btrfs: remove duplicate const specifier
  ALSA: au88x0: Fix zero clear of stream->resources
  scsi: isci: avoid array subscript warning
  Flash optimization setup
  qbt1000: Terminate fingerprint TA name with null
  USB: f_qc_rndis: Prevent use-after-free for _rndis_qc
  msm: ipa: Fix for missing int overflow check in the refcount library
  Make msm_serial_hs RT to improve bluetooth performance

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
  • Loading branch information
nathanchance committed Sep 2, 2017
2 parents 3b6ad9e + 9abeeab commit 9883c21
Show file tree
Hide file tree
Showing 22 changed files with 174 additions and 71 deletions.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 85
SUBLEVEL = 86
EXTRAVERSION =
NAME = Blurry Fish Butt

Expand Down Expand Up @@ -644,6 +644,18 @@ KBUILD_CFLAGS += -O2
endif
endif

###########################
# FLASH OPTMIZATION SETUP #
###########################

KBUILD_CFLAGS += -g0 -DNDEBUG \
-fgraphite-identity \
-fivopts \
-floop-nest-optimize \
-ftree-loop-distribution \
-ftree-loop-distribute-patterns \
-ftree-vectorize

# Disable all maybe-uninitialized warnings
KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)

Expand Down
11 changes: 11 additions & 0 deletions arch/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ $(warning LSE atomics not supported by binutils)
endif
endif

###########################
# FLASH OPTMIZATION SETUP #
###########################

# Optimize for Kryo 280
ARM64_ARCH_OPT := -mcpu=cortex-a73+crypto -mtune=cortex-a73

# If for some reason compiling with a toolchain that supports neither mcpu or
# mtune (in which case, wtf?), don't tune at all (march can break assembly)
KBUILD_CFLAGS += $(call cc-option,$(ARM64_ARCH_OPT),)

KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
KBUILD_CFLAGS += -fno-pic
KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
Expand Down
3 changes: 0 additions & 3 deletions arch/arm64/crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ obj-$(CONFIG_CRYPTO_GHASH_ARM64_CE) += ghash-ce.o
ghash-ce-y := ghash-ce-glue.o ghash-ce-core.o

obj-$(CONFIG_CRYPTO_AES_ARM64_CE) += aes-ce-cipher.o
CFLAGS_aes-ce-cipher.o += -march=armv8-a+crypto

obj-$(CONFIG_CRYPTO_AES_ARM64_CE_CCM) += aes-ce-ccm.o
aes-ce-ccm-y := aes-ce-ccm-glue.o aes-ce-ccm-core.o
Expand All @@ -36,7 +35,5 @@ CFLAGS_aes-glue-ce.o := -DUSE_V8_CRYPTO_EXTENSIONS

obj-$(CONFIG_CRYPTO_CRC32_ARM64) += crc32-arm64.o

CFLAGS_crc32-arm64.o := -mcpu=generic+crc

$(obj)/aes-glue-%.o: $(src)/aes-glue.c FORCE
$(call if_changed_rule,cc_o_c)
2 changes: 2 additions & 0 deletions arch/arm64/kernel/fpsimd.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ void fpsimd_thread_switch(struct task_struct *next)

void fpsimd_flush_thread(void)
{
preempt_disable();
memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
fpsimd_flush_task_state(current);
set_thread_flag(TIF_FOREIGN_FPSTATE);
preempt_enable();
}

/*
Expand Down
5 changes: 4 additions & 1 deletion arch/arm64/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
* signal first. We do not need to release the mmap_sem because it
* would already be released in __lock_page_or_retry in mm/filemap.c.
*/
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
if (!user_mode(regs))
goto no_context;
return 0;
}

/*
* Major/minor page fault accounting is only done on the initial
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ static inline unsigned type in##bwl##_p(int port) \
static inline void outs##bwl(int port, const void *addr, unsigned long count) \
{ \
asm volatile("rep; outs" #bwl \
: "+S"(addr), "+c"(count) : "d"(port)); \
: "+S"(addr), "+c"(count) : "d"(port) : "memory"); \
} \
\
static inline void ins##bwl(int port, void *addr, unsigned long count) \
{ \
asm volatile("rep; ins" #bwl \
: "+D"(addr), "+c"(count) : "d"(port)); \
: "+D"(addr), "+c"(count) : "d"(port) : "memory"); \
}

BUILDIO(b, b, char)
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/i915/intel_uncore.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ hsw_unclaimed_reg_detect(struct drm_i915_private *dev_priv)
"enabling oneshot unclaimed register reporting. "
"Please use i915.mmio_debug=N for more information.\n");
__raw_i915_write32(dev_priv, FPGA_DBG, FPGA_DBG_RM_NOCLAIM);
i915.mmio_debug = mmio_debug_once--;
i915.mmio_debug = mmio_debug_once;
mmio_debug_once = false;
}
}

Expand Down
4 changes: 0 additions & 4 deletions drivers/i2c/busses/i2c-jz4780.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,6 @@ static int jz4780_i2c_probe(struct platform_device *pdev)

jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0x0);

i2c->cmd = 0;
memset(i2c->cmd_buf, 0, BUFSIZE);
memset(i2c->data_buf, 0, BUFSIZE);

i2c->irq = platform_get_irq(pdev, 0);
ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0,
dev_name(&pdev->dev), i2c);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/p54/fwio.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ int p54_scan(struct p54_common *priv, u16 mode, u16 dwell)

entry += sizeof(__le16);
chan->pa_points_per_curve = 8;
memset(chan->curve_data, 0, sizeof(*chan->curve_data));
memset(chan->curve_data, 0, sizeof(chan->curve_data));
memcpy(chan->curve_data, entry,
sizeof(struct p54_pa_curve_data_sample) *
min((u8)8, curve_data->points_per_channel));
Expand Down
6 changes: 6 additions & 0 deletions drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,10 @@ int ipa2_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
mutex_lock(&ipa_ctx->lock);
entry = __ipa_find_rt_tbl(lookup->ip, lookup->name);
if (entry && entry->cookie == IPA_COOKIE) {
if (entry->ref_cnt == U32_MAX) {
IPAERR("fail: ref count crossed limit\n");
goto ret;
}
entry->ref_cnt++;
lookup->hdl = entry->id;

Expand All @@ -1362,6 +1366,8 @@ int ipa2_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)

result = 0;
}

ret:
mutex_unlock(&ipa_ctx->lock);

return result;
Expand Down
8 changes: 7 additions & 1 deletion drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -1438,6 +1438,10 @@ int ipa3_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
mutex_lock(&ipa3_ctx->lock);
entry = __ipa3_find_rt_tbl(lookup->ip, lookup->name);
if (entry && entry->cookie == IPA_COOKIE) {
if (entry->ref_cnt == U32_MAX) {
IPAERR("fail: ref count crossed limit\n");
goto ret;
}
entry->ref_cnt++;
lookup->hdl = entry->id;

Expand All @@ -1447,6 +1451,8 @@ int ipa3_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)

result = 0;
}

ret:
mutex_unlock(&ipa3_ctx->lock);

return result;
Expand Down
3 changes: 3 additions & 0 deletions drivers/scsi/isci/remote_node_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ const char *rnc_state_name(enum scis_sds_remote_node_context_states state)
{
static const char * const strings[] = RNC_STATES;

if (state >= ARRAY_SIZE(strings))
return "UNKNOWN";

return strings[state];
}
#undef C
Expand Down
5 changes: 4 additions & 1 deletion drivers/scsi/lpfc/lpfc_els.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,10 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
lpfc_sli4_unreg_all_rpis(vport);
}
}
lpfc_issue_reg_vfi(vport);

/* Do not register VFI if the driver aborted FLOGI */
if (!lpfc_error_lost_link(irsp))
lpfc_issue_reg_vfi(vport);
lpfc_nlp_put(ndlp);
goto out;
}
Expand Down
49 changes: 28 additions & 21 deletions drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ typedef struct sg_fd { /* holds the state of a file descriptor */
struct sg_device *parentdp; /* owning device */
wait_queue_head_t read_wait; /* queue read until command done */
rwlock_t rq_list_lock; /* protect access to list in req_arr */
struct mutex f_mutex; /* protect against changes in this fd */
int timeout; /* defaults to SG_DEFAULT_TIMEOUT */
int timeout_user; /* defaults to SG_DEFAULT_TIMEOUT_USER */
Sg_scatter_hold reserve; /* buffer held for this file descriptor */
Expand All @@ -166,6 +167,7 @@ typedef struct sg_fd { /* holds the state of a file descriptor */
unsigned char next_cmd_len; /* 0: automatic, >0: use on next write() */
char keep_orphan; /* 0 -> drop orphan (def), 1 -> keep for read() */
char mmap_called; /* 0 -> mmap() never called on this fd */
char res_in_use; /* 1 -> 'reserve' array in use */
struct kref f_ref;
struct execute_work ew;
} Sg_fd;
Expand Down Expand Up @@ -209,7 +211,6 @@ static void sg_remove_sfp(struct kref *);
static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
static Sg_request *sg_add_request(Sg_fd * sfp);
static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
static int sg_res_in_use(Sg_fd * sfp);
static Sg_device *sg_get_dev(int dev);
static void sg_device_destroy(struct kref *kref);

Expand Down Expand Up @@ -625,6 +626,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
}
buf += SZ_SG_HEADER;
__get_user(opcode, buf);
mutex_lock(&sfp->f_mutex);
if (sfp->next_cmd_len > 0) {
cmd_size = sfp->next_cmd_len;
sfp->next_cmd_len = 0; /* reset so only this write() effected */
Expand All @@ -633,6 +635,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
if ((opcode >= 0xc0) && old_hdr.twelve_byte)
cmd_size = 12;
}
mutex_unlock(&sfp->f_mutex);
SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
"sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size));
/* Determine buffer size. */
Expand Down Expand Up @@ -732,7 +735,7 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf,
sg_remove_request(sfp, srp);
return -EINVAL; /* either MMAP_IO or DIRECT_IO (not both) */
}
if (sg_res_in_use(sfp)) {
if (sfp->res_in_use) {
sg_remove_request(sfp, srp);
return -EBUSY; /* reserve buffer already being used */
}
Expand Down Expand Up @@ -902,7 +905,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
return result;
if (val) {
sfp->low_dma = 1;
if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) {
if ((0 == sfp->low_dma) && !sfp->res_in_use) {
val = (int) sfp->reserve.bufflen;
sg_remove_scat(sfp, &sfp->reserve);
sg_build_reserve(sfp, val);
Expand Down Expand Up @@ -977,12 +980,18 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
return -EINVAL;
val = min_t(int, val,
max_sectors_bytes(sdp->device->request_queue));
mutex_lock(&sfp->f_mutex);
if (val != sfp->reserve.bufflen) {
if (sg_res_in_use(sfp) || sfp->mmap_called)
if (sfp->mmap_called ||
sfp->res_in_use) {
mutex_unlock(&sfp->f_mutex);
return -EBUSY;
}

sg_remove_scat(sfp, &sfp->reserve);
sg_build_reserve(sfp, val);
}
mutex_unlock(&sfp->f_mutex);
return 0;
case SG_GET_RESERVED_SIZE:
val = min_t(int, sfp->reserve.bufflen,
Expand Down Expand Up @@ -1734,13 +1743,22 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
md = &map_data;

if (md) {
if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen)
mutex_lock(&sfp->f_mutex);
if (dxfer_len <= rsv_schp->bufflen &&
!sfp->res_in_use) {
sfp->res_in_use = 1;
sg_link_reserve(sfp, srp, dxfer_len);
else {
} else if ((hp->flags & SG_FLAG_MMAP_IO) && sfp->res_in_use) {
mutex_unlock(&sfp->f_mutex);
return -EBUSY;
} else {
res = sg_build_indirect(req_schp, sfp, dxfer_len);
if (res)
if (res) {
mutex_unlock(&sfp->f_mutex);
return res;
}
}
mutex_unlock(&sfp->f_mutex);

md->pages = req_schp->pages;
md->page_order = req_schp->page_order;
Expand Down Expand Up @@ -2031,6 +2049,8 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp)
req_schp->sglist_len = 0;
sfp->save_scat_len = 0;
srp->res_used = 0;
/* Called without mutex lock to avoid deadlock */
sfp->res_in_use = 0;
}

static Sg_request *
Expand Down Expand Up @@ -2142,6 +2162,7 @@ sg_add_sfp(Sg_device * sdp)
rwlock_init(&sfp->rq_list_lock);

kref_init(&sfp->f_ref);
mutex_init(&sfp->f_mutex);
sfp->timeout = SG_DEFAULT_TIMEOUT;
sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER;
sfp->force_packid = SG_DEF_FORCE_PACK_ID;
Expand Down Expand Up @@ -2217,20 +2238,6 @@ sg_remove_sfp(struct kref *kref)
schedule_work(&sfp->ew.work);
}

static int
sg_res_in_use(Sg_fd * sfp)
{
const Sg_request *srp;
unsigned long iflags;

read_lock_irqsave(&sfp->rq_list_lock, iflags);
for (srp = sfp->headrp; srp; srp = srp->nextrp)
if (srp->res_used)
break;
read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
return srp ? 1 : 0;
}

#ifdef CONFIG_SCSI_PROC_FS
static int
sg_idr_max_id(int id, void *p, void *data)
Expand Down
4 changes: 3 additions & 1 deletion drivers/soc/qcom/qbt1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ static long qbt1000_ioctl(struct file *file, unsigned cmd, unsigned long arg)
}

pr_debug("app %s load before\n", app.name);
app.name[MAX_NAME_SIZE - 1] = '\0';

/* start the TZ app */
rc = qseecom_start_app(
Expand All @@ -427,7 +428,8 @@ static long qbt1000_ioctl(struct file *file, unsigned cmd, unsigned long arg)
pr_err("App %s failed to set bw\n", app.name);
}
} else {
pr_err("app %s failed to load\n", app.name);
dev_err(drvdata->dev, "%s: Fingerprint Trusted App failed to load\n",
__func__);
goto end;
}

Expand Down
4 changes: 4 additions & 0 deletions drivers/tty/serial/msm_serial_hs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,7 @@ static int uartdm_init_port(struct uart_port *uport)
struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
struct msm_hs_tx *tx = &msm_uport->tx;
struct msm_hs_rx *rx = &msm_uport->rx;
struct sched_param param = { .sched_priority = 1 };

init_waitqueue_head(&rx->wait);
init_waitqueue_head(&tx->wait);
Expand All @@ -2772,6 +2773,8 @@ static int uartdm_init_port(struct uart_port *uport)
MSM_HS_ERR("%s(): error creating task", __func__);
goto exit_lh_init;
}
sched_setscheduler(rx->task, SCHED_FIFO, &param);

init_kthread_work(&rx->kwork, msm_serial_hs_rx_work);

init_kthread_worker(&tx->kworker);
Expand All @@ -2781,6 +2784,7 @@ static int uartdm_init_port(struct uart_port *uport)
MSM_HS_ERR("%s(): error creating task", __func__);
goto exit_lh_init;
}
sched_setscheduler(tx->task, SCHED_FIFO, &param);

init_kthread_work(&tx->kwork, msm_serial_hs_tx_work);

Expand Down
Loading

0 comments on commit 9883c21

Please sign in to comment.