Skip to content

Commit

Permalink
Merge branch 'a11/upstream-aosp' into a11/master
Browse files Browse the repository at this point in the history
* a11/upstream-aosp:
  md/dm-table: Update inlinecrypt iterate_devices-based capability checks
  Linux 4.9.261
  misc: eeprom_93xx46: Add quirk to support Microchip 93LC46B eeprom
  PCI: Add function 1 DMA alias quirk for Marvell 9215 SATA controller
  platform/x86: acer-wmi: Add new force_caps module parameter
  iommu/amd: Fix sleeping in atomic in increase_address_space()
  dm table: fix DAX iterate_devices based device capability checks
  dm table: fix iterate_devices based device capability checks
  rsxx: Return -EFAULT if copy_to_user() fails
  ALSA: ctxfi: cthw20k2: fix mask on conf to allow 4 bits
  usbip: tools: fix build error for multiple definition
  btrfs: fix raid6 qstripe kmap
  btrfs: raid56: simplify tracking of Q stripe presence

Signed-off-by: Albert I <[email protected]>
  • Loading branch information
krasCGQ committed Mar 12, 2021
2 parents 1b309fd + 28f2f19 commit a2ceb8f
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 86 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION = 4
PATCHLEVEL = 9
SUBLEVEL = 260
SUBLEVEL = 261
EXTRAVERSION =
NAME = Roaring Lionus

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 @@ -180,15 +180,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
10 changes: 6 additions & 4 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,24 +1331,26 @@ static void increase_address_space(struct protection_domain *domain,
unsigned long flags;
u64 *pte;

pte = (void *)get_zeroed_page(gfp);
if (!pte)
goto out;

spin_lock_irqsave(&domain->lock, flags);

if (WARN_ON_ONCE(domain->mode == PAGE_MODE_6_LEVEL))
/* address space already 64 bit large */
goto out;

pte = (void *)get_zeroed_page(gfp);
if (!pte)
goto out;

*pte = PM_LEVEL_PDE(domain->mode,
virt_to_phys(domain->pt_root));
domain->pt_root = pte;
domain->mode += 1;
domain->updated = true;
pte = NULL;

out:
spin_unlock_irqrestore(&domain->lock, flags);
free_page((unsigned long)pte);

return;
}
Expand Down
107 changes: 65 additions & 42 deletions drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,12 @@ void dm_table_set_type(struct dm_table *t, unsigned type)
}
EXPORT_SYMBOL_GPL(dm_table_set_type);

static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
static int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
struct request_queue *q = bdev_get_queue(dev->bdev);

return q && blk_queue_dax(q);
return q && !blk_queue_dax(q);
}

static bool dm_table_supports_dax(struct dm_table *t)
Expand All @@ -870,7 +870,7 @@ static bool dm_table_supports_dax(struct dm_table *t)
return false;

if (!ti->type->iterate_devices ||
!ti->type->iterate_devices(ti, device_supports_dax, NULL))
ti->type->iterate_devices(ti, device_not_dax_capable, NULL))
return false;
}

Expand Down Expand Up @@ -1307,6 +1307,46 @@ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
return &t->targets[(KEYS_PER_NODE * n) + k];
}

/*
* type->iterate_devices() should be called when the sanity check needs to
* iterate and check all underlying data devices. iterate_devices() will
* iterate all underlying data devices until it encounters a non-zero return
* code, returned by whether the input iterate_devices_callout_fn, or
* iterate_devices() itself internally.
*
* For some target type (e.g. dm-stripe), one call of iterate_devices() may
* iterate multiple underlying devices internally, in which case a non-zero
* return code returned by iterate_devices_callout_fn will stop the iteration
* in advance.
*
* Cases requiring _any_ underlying device supporting some kind of attribute,
* should use the iteration structure like dm_table_any_dev_attr(), or call
* it directly. @func should handle semantics of positive examples, e.g.
* capable of something.
*
* Cases requiring _all_ underlying devices supporting some kind of attribute,
* should use the iteration structure like dm_table_supports_nowait() or
* dm_table_supports_discards(). Or introduce dm_table_all_devs_attr() that
* uses an @anti_func that handle semantics of counter examples, e.g. not
* capable of something. So: return !dm_table_any_dev_attr(t, anti_func);
*/
static bool dm_table_any_dev_attr(struct dm_table *t,
iterate_devices_callout_fn func)
{
struct dm_target *ti;
unsigned int i;

for (i = 0; i < dm_table_get_num_targets(t); i++) {
ti = dm_table_get_target(t, i);

if (ti->type->iterate_devices &&
ti->type->iterate_devices(ti, func, NULL))
return true;
}

return false;
}

static int count_device(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
Expand Down Expand Up @@ -1477,12 +1517,12 @@ static bool dm_table_discard_zeroes_data(struct dm_table *t)
return true;
}

static int device_is_nonrot(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
static int device_is_rotational(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
struct request_queue *q = bdev_get_queue(dev->bdev);

return q && blk_queue_nonrot(q);
return q && !blk_queue_nonrot(q);
}

static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
Expand All @@ -1493,39 +1533,22 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
return q && !blk_queue_add_random(q);
}

static int queue_supports_sg_merge(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
static int queue_no_sg_merge(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
struct request_queue *q = bdev_get_queue(dev->bdev);

return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
return q && test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
}

static int queue_supports_inline_encryption(struct dm_target *ti,
struct dm_dev *dev,
sector_t start, sector_t len,
void *data)
static int queue_no_inline_encryption(struct dm_target *ti,
struct dm_dev *dev,
sector_t start, sector_t len,
void *data)
{
struct request_queue *q = bdev_get_queue(dev->bdev);

return q && blk_queue_inlinecrypt(q);
}

static bool dm_table_all_devices_attribute(struct dm_table *t,
iterate_devices_callout_fn func)
{
struct dm_target *ti;
unsigned i = 0;

while (i < dm_table_get_num_targets(t)) {
ti = dm_table_get_target(t, i++);

if (!ti->type->iterate_devices ||
!ti->type->iterate_devices(ti, func, NULL))
return false;
}

return true;
return q && !blk_queue_inlinecrypt(q);
}

static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev,
Expand Down Expand Up @@ -1618,23 +1641,23 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
q->limits.discard_zeroes_data = 0;

/* Ensure that all underlying devices are non-rotational. */
if (dm_table_all_devices_attribute(t, device_is_nonrot))
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
else
if (dm_table_any_dev_attr(t, device_is_rotational))
queue_flag_clear_unlocked(QUEUE_FLAG_NONROT, q);
else
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);

if (!dm_table_supports_write_same(t))
q->limits.max_write_same_sectors = 0;

if (dm_table_all_devices_attribute(t, queue_supports_sg_merge))
queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
else
if (dm_table_any_dev_attr(t, queue_no_sg_merge))
queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);

if (dm_table_all_devices_attribute(t, queue_supports_inline_encryption))
queue_flag_set_unlocked(QUEUE_FLAG_INLINECRYPT, q);
else
queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);

if (dm_table_any_dev_attr(t, queue_no_inline_encryption))
queue_flag_clear_unlocked(QUEUE_FLAG_INLINECRYPT, q);
else
queue_flag_set_unlocked(QUEUE_FLAG_INLINECRYPT, q);

dm_table_verify_integrity(t);

Expand All @@ -1644,7 +1667,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
* Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not
* have it set.
*/
if (blk_queue_add_random(q) && dm_table_all_devices_attribute(t, device_is_not_random))
if (blk_queue_add_random(q) && dm_table_any_dev_attr(t, device_is_not_random))
queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);

/*
Expand Down
15 changes: 15 additions & 0 deletions drivers/misc/eeprom/eeprom_93xx46.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = {
EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH,
};

static const struct eeprom_93xx46_devtype_data microchip_93lc46b_data = {
.quirks = EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE,
};

struct eeprom_93xx46_dev {
struct spi_device *spi;
struct eeprom_93xx46_platform_data *pdata;
Expand All @@ -58,6 +62,11 @@ static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev)
return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH;
}

static inline bool has_quirk_extra_read_cycle(struct eeprom_93xx46_dev *edev)
{
return edev->pdata->quirks & EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE;
}

static int eeprom_93xx46_read(void *priv, unsigned int off,
void *val, size_t count)
{
Expand Down Expand Up @@ -99,6 +108,11 @@ static int eeprom_93xx46_read(void *priv, unsigned int off,
dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n",
cmd_addr, edev->spi->max_speed_hz);

if (has_quirk_extra_read_cycle(edev)) {
cmd_addr <<= 1;
bits += 1;
}

spi_message_init(&m);

t[0].tx_buf = (char *)&cmd_addr;
Expand Down Expand Up @@ -366,6 +380,7 @@ static void select_deassert(void *context)
static const struct of_device_id eeprom_93xx46_of_table[] = {
{ .compatible = "eeprom-93xx46", },
{ .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, },
{ .compatible = "microchip,93lc46b", .data = &microchip_93lc46b_data, },
{}
};
MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table);
Expand Down
3 changes: 3 additions & 0 deletions drivers/pci/quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3911,6 +3911,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9182,
/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c46 */
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0,
quirk_dma_func1_alias);
/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c135 */
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9215,
quirk_dma_func1_alias);
/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c127 */
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9220,
quirk_dma_func1_alias);
Expand Down
8 changes: 7 additions & 1 deletion drivers/platform/x86/acer-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ static int mailled = -1;
static int brightness = -1;
static int threeg = -1;
static int force_series;
static int force_caps = -1;
static bool ec_raw_mode;
static bool has_type_aa;
static u16 commun_func_bitmap;
Expand All @@ -238,11 +239,13 @@ module_param(mailled, int, 0444);
module_param(brightness, int, 0444);
module_param(threeg, int, 0444);
module_param(force_series, int, 0444);
module_param(force_caps, int, 0444);
module_param(ec_raw_mode, bool, 0444);
MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
MODULE_PARM_DESC(force_series, "Force a different laptop series");
MODULE_PARM_DESC(force_caps, "Force the capability bitmask to this value");
MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");

struct acer_data {
Expand Down Expand Up @@ -2198,7 +2201,7 @@ static int __init acer_wmi_init(void)
}
/* WMID always provides brightness methods */
interface->capability |= ACER_CAP_BRIGHTNESS;
} else if (!wmi_has_guid(WMID_GUID2) && interface && !has_type_aa) {
} else if (!wmi_has_guid(WMID_GUID2) && interface && !has_type_aa && force_caps == -1) {
pr_err("No WMID device detection method found\n");
return -ENODEV;
}
Expand Down Expand Up @@ -2228,6 +2231,9 @@ static int __init acer_wmi_init(void)
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
interface->capability &= ~ACER_CAP_BRIGHTNESS;

if (force_caps != -1)
interface->capability = force_caps;

if (wmi_has_guid(WMID_GUID3)) {
if (ec_raw_mode) {
if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
Expand Down
Loading

0 comments on commit a2ceb8f

Please sign in to comment.