Skip to content

Commit

Permalink
Merge tag 'char-misc-4.17-rc3' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg KH:
 "Here are some small char and misc driver fixes for 4.17-rc3

  A variety of small things that have fallen out after 4.17-rc1 was out.
  Some vboxguest fixes for systems with lots of memory, amba bus fixes,
  some MAINTAINERS updates, uio_hv_generic driver fixes, and a few other
  minor things that resolve problems that people reported.

  The amba bus fixes took twice to get right, the first time I messed up
  applying the patches in the wrong order, hence the revert and later
  addition again with the correct fix, sorry about that.

  All of these have been in linux-next with no reported issues"

* tag 'char-misc-4.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  ARM: amba: Fix race condition with driver_override
  ARM: amba: Make driver_override output consistent with other buses
  Revert "ARM: amba: Fix race condition with driver_override"
  ARM: amba: Don't read past the end of sysfs "driver_override" buffer
  ARM: amba: Fix race condition with driver_override
  virt: vbox: Log an error when we fail to get the host version
  virt: vbox: Use __get_free_pages instead of kmalloc for DMA32 memory
  virt: vbox: Add vbg_req_free() helper function
  virt: vbox: Move declarations of vboxguest private functions to private header
  slimbus: Fix out-of-bounds access in slim_slicesize()
  MAINTAINERS: add dri-devel&linaro-mm for Android ION
  fpga-manager: altera-ps-spi: preserve nCONFIG state
  MAINTAINERS: update my email address
  uio_hv_generic: fix subchannel ring mmap
  uio_hv_generic: use correct channel in isr
  uio_hv_generic: make ring buffer attribute for primary channel
  uio_hv_generic: set size of ring buffer attribute
  ANDROID: binder: prevent transactions into own process.
  • Loading branch information
torvalds committed Apr 27, 2018
2 parents ee3748b + 6a7228d commit d8a3327
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 121 deletions.
6 changes: 4 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,8 @@ ANDROID ION DRIVER
M: Laura Abbott <[email protected]>
M: Sumit Semwal <[email protected]>
L: [email protected]
L: [email protected]
L: [email protected] (moderated for non-subscribers)
S: Supported
F: drivers/staging/android/ion
F: drivers/staging/android/uapi/ion.h
Expand Down Expand Up @@ -13953,7 +13955,7 @@ THUNDERBOLT DRIVER
M: Andreas Noever <[email protected]>
M: Michael Jamet <[email protected]>
M: Mika Westerberg <[email protected]>
M: Yehezkel Bernat <yehezkel.bernat@intel.com>
M: Yehezkel Bernat <YehezkelShB@gmail.com>
T: git git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt.git
S: Maintained
F: Documentation/admin-guide/thunderbolt.rst
Expand All @@ -13963,7 +13965,7 @@ F: include/linux/thunderbolt.h
THUNDERBOLT NETWORK DRIVER
M: Michael Jamet <[email protected]>
M: Mika Westerberg <[email protected]>
M: Yehezkel Bernat <yehezkel.bernat@intel.com>
M: Yehezkel Bernat <YehezkelShB@gmail.com>
L: [email protected]
S: Maintained
F: drivers/net/thunderbolt.c
Expand Down
17 changes: 11 additions & 6 deletions drivers/amba/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,23 @@ static ssize_t driver_override_show(struct device *_dev,
struct device_attribute *attr, char *buf)
{
struct amba_device *dev = to_amba_device(_dev);
ssize_t len;

if (!dev->driver_override)
return 0;

return sprintf(buf, "%s\n", dev->driver_override);
device_lock(_dev);
len = sprintf(buf, "%s\n", dev->driver_override);
device_unlock(_dev);
return len;
}

static ssize_t driver_override_store(struct device *_dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct amba_device *dev = to_amba_device(_dev);
char *driver_override, *old = dev->driver_override, *cp;
char *driver_override, *old, *cp;

if (count > PATH_MAX)
/* We need to keep extra room for a newline */
if (count >= (PAGE_SIZE - 1))
return -EINVAL;

driver_override = kstrndup(buf, count, GFP_KERNEL);
Expand All @@ -94,12 +96,15 @@ static ssize_t driver_override_store(struct device *_dev,
if (cp)
*cp = '\0';

device_lock(_dev);
old = dev->driver_override;
if (strlen(driver_override)) {
dev->driver_override = driver_override;
} else {
kfree(driver_override);
dev->driver_override = NULL;
}
device_unlock(_dev);

kfree(old);

Expand Down
8 changes: 8 additions & 0 deletions drivers/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -2839,6 +2839,14 @@ static void binder_transaction(struct binder_proc *proc,
else
return_error = BR_DEAD_REPLY;
mutex_unlock(&context->context_mgr_node_lock);
if (target_node && target_proc == proc) {
binder_user_error("%d:%d got transaction to context manager from process owning it\n",
proc->pid, thread->pid);
return_error = BR_FAILED_REPLY;
return_error_param = -EINVAL;
return_error_line = __LINE__;
goto err_invalid_target_handle;
}
}
if (!target_node) {
/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/fpga/altera-ps-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static int altera_ps_probe(struct spi_device *spi)

conf->data = of_id->data;
conf->spi = spi;
conf->config = devm_gpiod_get(&spi->dev, "nconfig", GPIOD_OUT_HIGH);
conf->config = devm_gpiod_get(&spi->dev, "nconfig", GPIOD_OUT_LOW);
if (IS_ERR(conf->config)) {
dev_err(&spi->dev, "Failed to get config gpio: %ld\n",
PTR_ERR(conf->config));
Expand Down
2 changes: 1 addition & 1 deletion drivers/slimbus/messaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static u16 slim_slicesize(int code)
0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7
};

clamp(code, 1, (int)ARRAY_SIZE(sizetocode));
code = clamp(code, 1, (int)ARRAY_SIZE(sizetocode));

return sizetocode[code - 1];
}
Expand Down
72 changes: 23 additions & 49 deletions drivers/uio/uio_hv_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* # echo -n "ed963694-e847-4b2a-85af-bc9cfc11d6f3" \
* > /sys/bus/vmbus/drivers/uio_hv_generic/bind
*/

#define DEBUG 1
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/device.h>
Expand Down Expand Up @@ -94,10 +94,11 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
*/
static void hv_uio_channel_cb(void *context)
{
struct hv_uio_private_data *pdata = context;
struct hv_device *dev = pdata->device;
struct vmbus_channel *chan = context;
struct hv_device *hv_dev = chan->device_obj;
struct hv_uio_private_data *pdata = hv_get_drvdata(hv_dev);

dev->channel->inbound.ring_buffer->interrupt_mask = 1;
chan->inbound.ring_buffer->interrupt_mask = 1;
virt_mb();

uio_event_notify(&pdata->info);
Expand All @@ -121,78 +122,46 @@ static void hv_uio_rescind(struct vmbus_channel *channel)
uio_event_notify(&pdata->info);
}

/*
* Handle fault when looking for sub channel ring buffer
* Subchannel ring buffer is same as resource 0 which is main ring buffer
* This is derived from uio_vma_fault
/* Sysfs API to allow mmap of the ring buffers
* The ring buffer is allocated as contiguous memory by vmbus_open
*/
static int hv_uio_vma_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
void *ring_buffer = vma->vm_private_data;
struct page *page;
void *addr;

addr = ring_buffer + (vmf->pgoff << PAGE_SHIFT);
page = virt_to_page(addr);
get_page(page);
vmf->page = page;
return 0;
}

static const struct vm_operations_struct hv_uio_vm_ops = {
.fault = hv_uio_vma_fault,
};

/* Sysfs API to allow mmap of the ring buffers */
static int hv_uio_ring_mmap(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
struct vm_area_struct *vma)
{
struct vmbus_channel *channel
= container_of(kobj, struct vmbus_channel, kobj);
unsigned long requested_pages, actual_pages;

if (vma->vm_end < vma->vm_start)
return -EINVAL;

/* only allow 0 for now */
if (vma->vm_pgoff > 0)
return -EINVAL;
struct hv_device *dev = channel->primary_channel->device_obj;
u16 q_idx = channel->offermsg.offer.sub_channel_index;

requested_pages = vma_pages(vma);
actual_pages = 2 * HV_RING_SIZE;
if (requested_pages > actual_pages)
return -EINVAL;
dev_dbg(&dev->device, "mmap channel %u pages %#lx at %#lx\n",
q_idx, vma_pages(vma), vma->vm_pgoff);

vma->vm_private_data = channel->ringbuffer_pages;
vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
vma->vm_ops = &hv_uio_vm_ops;
return 0;
return vm_iomap_memory(vma, virt_to_phys(channel->ringbuffer_pages),
channel->ringbuffer_pagecount << PAGE_SHIFT);
}

static struct bin_attribute ring_buffer_bin_attr __ro_after_init = {
static const struct bin_attribute ring_buffer_bin_attr = {
.attr = {
.name = "ring",
.mode = 0600,
/* size is set at init time */
},
.size = 2 * HV_RING_SIZE * PAGE_SIZE,
.mmap = hv_uio_ring_mmap,
};

/* Callback from VMBUS subystem when new channel created. */
/* Callback from VMBUS subsystem when new channel created. */
static void
hv_uio_new_channel(struct vmbus_channel *new_sc)
{
struct hv_device *hv_dev = new_sc->primary_channel->device_obj;
struct device *device = &hv_dev->device;
struct hv_uio_private_data *pdata = hv_get_drvdata(hv_dev);
const size_t ring_bytes = HV_RING_SIZE * PAGE_SIZE;
int ret;

/* Create host communication ring */
ret = vmbus_open(new_sc, ring_bytes, ring_bytes, NULL, 0,
hv_uio_channel_cb, pdata);
hv_uio_channel_cb, new_sc);
if (ret) {
dev_err(device, "vmbus_open subchannel failed: %d\n", ret);
return;
Expand Down Expand Up @@ -234,7 +203,7 @@ hv_uio_probe(struct hv_device *dev,

ret = vmbus_open(dev->channel, HV_RING_SIZE * PAGE_SIZE,
HV_RING_SIZE * PAGE_SIZE, NULL, 0,
hv_uio_channel_cb, pdata);
hv_uio_channel_cb, dev->channel);
if (ret)
goto fail;

Expand Down Expand Up @@ -326,6 +295,11 @@ hv_uio_probe(struct hv_device *dev,
vmbus_set_chn_rescind_callback(dev->channel, hv_uio_rescind);
vmbus_set_sc_create_callback(dev->channel, hv_uio_new_channel);

ret = sysfs_create_bin_file(&dev->channel->kobj, &ring_buffer_bin_attr);
if (ret)
dev_notice(&dev->device,
"sysfs create ring bin file failed; %d\n", ret);

hv_set_drvdata(dev, pdata);

return 0;
Expand Down
Loading

0 comments on commit d8a3327

Please sign in to comment.