Skip to content

Commit

Permalink
Merge pull request torvalds#283 from zandrey/5.4-2.1.x-imx
Browse files Browse the repository at this point in the history
Update 5.4-2.1.x-imx to v5.4.104
  • Loading branch information
otavio authored Mar 9, 2021
2 parents 0ee76a7 + 9f4d88f commit 589adde
Show file tree
Hide file tree
Showing 23 changed files with 231 additions and 108 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
VERSION = 5
PATCHLEVEL = 4
SUBLEVEL = 103
SUBLEVEL = 104
EXTRAVERSION =
NAME = Kleptomaniac Octopus

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,7 @@ int syscall_trace_enter(struct pt_regs *regs)

if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) {
tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
if (!in_syscall(regs) || (flags & _TIF_SYSCALL_EMU))
if (flags & _TIF_SYSCALL_EMU)
return -1;
}

Expand Down
62 changes: 37 additions & 25 deletions drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,22 @@ static void rpm_put_suppliers(struct device *dev)
static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
__releases(&dev->power.lock) __acquires(&dev->power.lock)
{
int retval, idx;
bool use_links = dev->power.links_count > 0;
bool get = false;
int retval, idx;
bool put;

if (dev->power.irq_safe) {
spin_unlock(&dev->power.lock);
} else if (!use_links) {
spin_unlock_irq(&dev->power.lock);
} else {
get = dev->power.runtime_status == RPM_RESUMING;

spin_unlock_irq(&dev->power.lock);

/*
* Resume suppliers if necessary.
*
* The device's runtime PM status cannot change until this
* routine returns, so it is safe to read the status outside of
* the lock.
*/
if (use_links && dev->power.runtime_status == RPM_RESUMING) {
/* Resume suppliers if necessary. */
if (get) {
idx = device_links_read_lock();

retval = rpm_get_suppliers(dev);
Expand All @@ -355,24 +355,36 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev)

if (dev->power.irq_safe) {
spin_lock(&dev->power.lock);
} else {
/*
* If the device is suspending and the callback has returned
* success, drop the usage counters of the suppliers that have
* been reference counted on its resume.
*
* Do that if resume fails too.
*/
if (use_links
&& ((dev->power.runtime_status == RPM_SUSPENDING && !retval)
|| (dev->power.runtime_status == RPM_RESUMING && retval))) {
idx = device_links_read_lock();
return retval;
}

fail:
rpm_put_suppliers(dev);
spin_lock_irq(&dev->power.lock);

device_links_read_unlock(idx);
}
if (!use_links)
return retval;

/*
* If the device is suspending and the callback has returned success,
* drop the usage counters of the suppliers that have been reference
* counted on its resume.
*
* Do that if the resume fails too.
*/
put = dev->power.runtime_status == RPM_SUSPENDING && !retval;
if (put)
__update_runtime_status(dev, RPM_SUSPENDED);
else
put = get && retval;

if (put) {
spin_unlock_irq(&dev->power.lock);

idx = device_links_read_lock();

fail:
rpm_put_suppliers(dev);

device_links_read_unlock(idx);

spin_lock_irq(&dev->power.lock);
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/block/rsxx/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,17 @@ static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
{
struct rsxx_cardinfo *card = file_inode(fp)->i_private;
char *buf;
ssize_t st;
int st;

buf = kzalloc(cnt, GFP_KERNEL);
if (!buf)
return -ENOMEM;

st = rsxx_creg_read(card, CREG_ADD_CRAM + (u32)*ppos, cnt, buf, 1);
if (!st)
st = copy_to_user(ubuf, buf, cnt);
if (!st) {
if (copy_to_user(ubuf, buf, cnt))
st = -EFAULT;
}
kfree(buf);
if (st)
return st;
Expand Down
30 changes: 25 additions & 5 deletions drivers/char/tpm/tpm_tis_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,22 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
const char *desc = "attempting to generate an interrupt";
u32 cap2;
cap_t cap;
int ret;

/* TPM 2.0 */
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
else
return tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc,
0);

/* TPM 1.2 */
ret = request_locality(chip, 0);
if (ret < 0)
return ret;

ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);

release_locality(chip, 0);

return ret;
}

/* Register the IRQ and issue a command that will cause an interrupt. If an
Expand Down Expand Up @@ -929,11 +939,21 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
init_waitqueue_head(&priv->read_queue);
init_waitqueue_head(&priv->int_queue);
if (irq != -1) {
/* Before doing irq testing issue a command to the TPM in polling mode
/*
* Before doing irq testing issue a command to the TPM in polling mode
* to make sure it works. May as well use that command to set the
* proper timeouts for the driver.
*/
if (tpm_get_timeouts(chip)) {

rc = request_locality(chip, 0);
if (rc < 0)
goto out_err;

rc = tpm_get_timeouts(chip);

release_locality(chip, 0);

if (rc) {
dev_err(dev, "Could not get TPM timeouts and durations\n");
rc = -ENODEV;
goto out_err;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf,
while (size) {
uint32_t value;

value = RREG32_PCIE(*pos >> 2);
value = RREG32_PCIE(*pos);
r = put_user(value, (uint32_t *)buf);
if (r)
return r;
Expand Down Expand Up @@ -283,7 +283,7 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user
if (r)
return r;

WREG32_PCIE(*pos >> 2, value);
WREG32_PCIE(*pos, value);

result += 4;
buf += 4;
Expand Down
4 changes: 3 additions & 1 deletion drivers/infiniband/hw/mlx5/devx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2022,8 +2022,10 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_SUBSCRIBE_EVENT)(

num_alloc_xa_entries++;
event_sub = kzalloc(sizeof(*event_sub), GFP_KERNEL);
if (!event_sub)
if (!event_sub) {
err = -ENOMEM;
goto err;
}

list_add_tail(&event_sub->event_list, &sub_list);
if (use_eventfd) {
Expand Down
1 change: 1 addition & 0 deletions drivers/infiniband/sw/rxe/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config RDMA_RXE
depends on INET && PCI && INFINIBAND
depends on INFINIBAND_VIRT_DMA
select NET_UDP_TUNNEL
select CRYPTO
select CRYPTO_CRC32
select DMA_VIRT_OPS
---help---
Expand Down
4 changes: 4 additions & 0 deletions drivers/md/dm-bufio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,10 @@ EXPORT_SYMBOL_GPL(dm_bufio_get_block_size);
sector_t dm_bufio_get_device_size(struct dm_bufio_client *c)
{
sector_t s = i_size_read(c->bdev->bd_inode) >> SECTOR_SHIFT;
if (s >= c->start)
s -= c->start;
else
s = 0;
if (likely(c->sectors_per_block_bits >= 0))
s >>= c->sectors_per_block_bits;
else
Expand Down
23 changes: 12 additions & 11 deletions drivers/md/dm-verity-fec.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,18 @@ static int fec_decode_rs8(struct dm_verity *v, struct dm_verity_fec_io *fio,
static u8 *fec_read_parity(struct dm_verity *v, u64 rsb, int index,
unsigned *offset, struct dm_buffer **buf)
{
u64 position, block;
u64 position, block, rem;
u8 *res;

position = (index + rsb) * v->fec->roots;
block = position >> v->data_dev_block_bits;
*offset = (unsigned)(position - (block << v->data_dev_block_bits));
block = div64_u64_rem(position, v->fec->roots << SECTOR_SHIFT, &rem);
*offset = (unsigned)rem;

res = dm_bufio_read(v->fec->bufio, v->fec->start + block, buf);
res = dm_bufio_read(v->fec->bufio, block, buf);
if (IS_ERR(res)) {
DMERR("%s: FEC %llu: parity read failed (block %llu): %ld",
v->data_dev->name, (unsigned long long)rsb,
(unsigned long long)(v->fec->start + block),
PTR_ERR(res));
(unsigned long long)block, PTR_ERR(res));
*buf = NULL;
}

Expand Down Expand Up @@ -155,7 +154,7 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio,

/* read the next block when we run out of parity bytes */
offset += v->fec->roots;
if (offset >= 1 << v->data_dev_block_bits) {
if (offset >= v->fec->roots << SECTOR_SHIFT) {
dm_bufio_release(buf);

par = fec_read_parity(v, rsb, block_offset, &offset, &buf);
Expand Down Expand Up @@ -674,7 +673,7 @@ int verity_fec_ctr(struct dm_verity *v)
{
struct dm_verity_fec *f = v->fec;
struct dm_target *ti = v->ti;
u64 hash_blocks;
u64 hash_blocks, fec_blocks;
int ret;

if (!verity_fec_is_enabled(v)) {
Expand Down Expand Up @@ -744,15 +743,17 @@ int verity_fec_ctr(struct dm_verity *v)
}

f->bufio = dm_bufio_client_create(f->dev->bdev,
1 << v->data_dev_block_bits,
f->roots << SECTOR_SHIFT,
1, 0, NULL, NULL);
if (IS_ERR(f->bufio)) {
ti->error = "Cannot initialize FEC bufio client";
return PTR_ERR(f->bufio);
}

if (dm_bufio_get_device_size(f->bufio) <
((f->start + f->rounds * f->roots) >> v->data_dev_block_bits)) {
dm_bufio_set_sector_offset(f->bufio, f->start << (v->data_dev_block_bits - SECTOR_SHIFT));

fec_blocks = div64_u64(f->rounds * f->roots, v->fec->roots << SECTOR_SHIFT);
if (dm_bufio_get_device_size(f->bufio) < fec_blocks) {
ti->error = "FEC device is too small";
return -E2BIG;
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/realtek/r8169_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3959,6 +3959,7 @@ static void rtl_pll_power_down(struct rtl8169_private *tp)

switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_26:
case RTL_GIGA_MAC_VER_29 ... RTL_GIGA_MAC_VER_30:
case RTL_GIGA_MAC_VER_32 ... RTL_GIGA_MAC_VER_33:
case RTL_GIGA_MAC_VER_37:
case RTL_GIGA_MAC_VER_39:
Expand Down Expand Up @@ -3989,6 +3990,7 @@ static void rtl_pll_power_up(struct rtl8169_private *tp)
{
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_26:
case RTL_GIGA_MAC_VER_29 ... RTL_GIGA_MAC_VER_30:
case RTL_GIGA_MAC_VER_32 ... RTL_GIGA_MAC_VER_33:
case RTL_GIGA_MAC_VER_37:
case RTL_GIGA_MAC_VER_39:
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/delayed-inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ static int btrfs_delayed_inode_reserve_metadata(
btrfs_ino(inode),
num_bytes, 1);
} else {
btrfs_qgroup_free_meta_prealloc(root, fs_info->nodesize);
btrfs_qgroup_free_meta_prealloc(root, num_bytes);
}
return ret;
}
Expand Down
5 changes: 4 additions & 1 deletion fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3151,8 +3151,11 @@ static int btrfs_zero_range(struct inode *inode,
goto out;
ret = btrfs_qgroup_reserve_data(inode, &data_reserved,
alloc_start, bytes_to_reserve);
if (ret)
if (ret) {
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart,
lockend, &cached_state);
goto out;
}
ret = btrfs_prealloc_file_range(inode, mode, alloc_start,
alloc_end - alloc_start,
i_blocksize(inode),
Expand Down
19 changes: 18 additions & 1 deletion fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,10 @@ static noinline int btrfs_ioctl_snap_create_v2(struct file *file,
if (vol_args->flags & BTRFS_SUBVOL_RDONLY)
readonly = true;
if (vol_args->flags & BTRFS_SUBVOL_QGROUP_INHERIT) {
if (vol_args->size > PAGE_SIZE) {
u64 nums;

if (vol_args->size < sizeof(*inherit) ||
vol_args->size > PAGE_SIZE) {
ret = -EINVAL;
goto free_args;
}
Expand All @@ -1916,6 +1919,20 @@ static noinline int btrfs_ioctl_snap_create_v2(struct file *file,
ret = PTR_ERR(inherit);
goto free_args;
}

if (inherit->num_qgroups > PAGE_SIZE ||
inherit->num_ref_copies > PAGE_SIZE ||
inherit->num_excl_copies > PAGE_SIZE) {
ret = -EINVAL;
goto free_inherit;
}

nums = inherit->num_qgroups + 2 * inherit->num_ref_copies +
2 * inherit->num_excl_copies;
if (vol_args->size != struct_size(inherit, qgroups, nums)) {
ret = -EINVAL;
goto free_inherit;
}
}

ret = btrfs_ioctl_snap_create_transid(file, vol_args->name,
Expand Down
Loading

0 comments on commit 589adde

Please sign in to comment.