Skip to content

Commit 0dc82fa

Browse files
committed
Merge tag 'char-misc-4.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "A smattering of different small fixes for some random driver subsystems. Nothing all that major, just resolutions for reported issues and bugs. All have been in linux-next with no reported issues" * tag 'char-misc-4.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (21 commits) extcon: int3496: Set the id pin to direction-input if necessary extcon: int3496: Use gpiod_get instead of gpiod_get_index extcon: int3496: Add dependency on X86 as it's Intel specific extcon: int3496: Add GPIO ACPI mapping table extcon: int3496: Rename GPIO pins in accordance with binding vmw_vmci: handle the return value from pci_alloc_irq_vectors correctly ppdev: fix registering same device name parport: fix attempt to write duplicate procfiles auxdisplay: img-ascii-lcd: add missing sentinel entry in img_ascii_lcd_matches Drivers: hv: vmbus: Don't leak memory when a channel is rescinded Drivers: hv: vmbus: Don't leak channel ids Drivers: hv: util: don't forget to init host_ts.lock Drivers: hv: util: move waiting for release to hv_utils_transport itself vmbus: remove hv_event_tasklet_disable/enable vmbus: use rcu for per-cpu channel list mei: don't wait for os version message reply mei: fix deadlock on mei reset intel_th: pci: Add Gemini Lake support intel_th: pci: Add Denverton SOC support intel_th: Don't leak module refcount on failure to activate ...
2 parents 9e54ef9 + 5c1724c commit 0dc82fa

File tree

21 files changed

+111
-88
lines changed

21 files changed

+111
-88
lines changed

Documentation/extcon/intel-int3496.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ Index 1: The output gpio for enabling Vbus output from the device to the otg
2020
Index 2: The output gpio for muxing of the data pins between the USB host and
2121
the USB peripheral controller, write 1 to mux to the peripheral
2222
controller
23+
24+
There is a mapping between indices and GPIO connection IDs as follows
25+
id index 0
26+
vbus index 1
27+
mux index 2

drivers/auxdisplay/img-ascii-lcd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ static const struct of_device_id img_ascii_lcd_matches[] = {
218218
{ .compatible = "img,boston-lcd", .data = &boston_config },
219219
{ .compatible = "mti,malta-lcd", .data = &malta_config },
220220
{ .compatible = "mti,sead3-lcd", .data = &sead3_config },
221+
{ /* sentinel */ }
221222
};
222223

223224
/**

drivers/char/ppdev.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ struct pp_struct {
8484
struct ieee1284_info state;
8585
struct ieee1284_info saved_state;
8686
long default_inactivity;
87+
int index;
8788
};
8889

8990
/* should we use PARDEVICE_MAX here? */
9091
static struct device *devices[PARPORT_MAX];
9192

93+
static DEFINE_IDA(ida_index);
94+
9295
/* pp_struct.flags bitfields */
9396
#define PP_CLAIMED (1<<0)
9497
#define PP_EXCL (1<<1)
@@ -290,7 +293,7 @@ static int register_device(int minor, struct pp_struct *pp)
290293
struct pardevice *pdev = NULL;
291294
char *name;
292295
struct pardev_cb ppdev_cb;
293-
int rc = 0;
296+
int rc = 0, index;
294297

295298
name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor);
296299
if (name == NULL)
@@ -303,20 +306,23 @@ static int register_device(int minor, struct pp_struct *pp)
303306
goto err;
304307
}
305308

309+
index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
306310
memset(&ppdev_cb, 0, sizeof(ppdev_cb));
307311
ppdev_cb.irq_func = pp_irq;
308312
ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
309313
ppdev_cb.private = pp;
310-
pdev = parport_register_dev_model(port, name, &ppdev_cb, minor);
314+
pdev = parport_register_dev_model(port, name, &ppdev_cb, index);
311315
parport_put_port(port);
312316

313317
if (!pdev) {
314318
pr_warn("%s: failed to register device!\n", name);
315319
rc = -ENXIO;
320+
ida_simple_remove(&ida_index, index);
316321
goto err;
317322
}
318323

319324
pp->pdev = pdev;
325+
pp->index = index;
320326
dev_dbg(&pdev->dev, "registered pardevice\n");
321327
err:
322328
kfree(name);
@@ -755,6 +761,7 @@ static int pp_release(struct inode *inode, struct file *file)
755761

756762
if (pp->pdev) {
757763
parport_unregister_device(pp->pdev);
764+
ida_simple_remove(&ida_index, pp->index);
758765
pp->pdev = NULL;
759766
pr_debug(CHRDEV "%x: unregistered pardevice\n", minor);
760767
}

drivers/extcon/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ config EXTCON_GPIO
4444

4545
config EXTCON_INTEL_INT3496
4646
tristate "Intel INT3496 ACPI device extcon driver"
47-
depends on GPIOLIB && ACPI
47+
depends on GPIOLIB && ACPI && (X86 || COMPILE_TEST)
4848
help
4949
Say Y here to enable extcon support for USB OTG ports controlled by
5050
an Intel INT3496 ACPI device.

drivers/extcon/extcon-intel-int3496.c

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ static const unsigned int int3496_cable[] = {
4545
EXTCON_NONE,
4646
};
4747

48+
static const struct acpi_gpio_params id_gpios = { INT3496_GPIO_USB_ID, 0, false };
49+
static const struct acpi_gpio_params vbus_gpios = { INT3496_GPIO_VBUS_EN, 0, false };
50+
static const struct acpi_gpio_params mux_gpios = { INT3496_GPIO_USB_MUX, 0, false };
51+
52+
static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = {
53+
{ "id-gpios", &id_gpios, 1 },
54+
{ "vbus-gpios", &vbus_gpios, 1 },
55+
{ "mux-gpios", &mux_gpios, 1 },
56+
{ },
57+
};
58+
4859
static void int3496_do_usb_id(struct work_struct *work)
4960
{
5061
struct int3496_data *data =
@@ -83,37 +94,41 @@ static int int3496_probe(struct platform_device *pdev)
8394
struct int3496_data *data;
8495
int ret;
8596

97+
ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
98+
acpi_int3496_default_gpios);
99+
if (ret) {
100+
dev_err(dev, "can't add GPIO ACPI mapping\n");
101+
return ret;
102+
}
103+
86104
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
87105
if (!data)
88106
return -ENOMEM;
89107

90108
data->dev = dev;
91109
INIT_DELAYED_WORK(&data->work, int3496_do_usb_id);
92110

93-
data->gpio_usb_id = devm_gpiod_get_index(dev, "id",
94-
INT3496_GPIO_USB_ID,
95-
GPIOD_IN);
111+
data->gpio_usb_id = devm_gpiod_get(dev, "id", GPIOD_IN);
96112
if (IS_ERR(data->gpio_usb_id)) {
97113
ret = PTR_ERR(data->gpio_usb_id);
98114
dev_err(dev, "can't request USB ID GPIO: %d\n", ret);
99115
return ret;
116+
} else if (gpiod_get_direction(data->gpio_usb_id) != GPIOF_DIR_IN) {
117+
dev_warn(dev, FW_BUG "USB ID GPIO not in input mode, fixing\n");
118+
gpiod_direction_input(data->gpio_usb_id);
100119
}
101120

102121
data->usb_id_irq = gpiod_to_irq(data->gpio_usb_id);
103-
if (data->usb_id_irq <= 0) {
122+
if (data->usb_id_irq < 0) {
104123
dev_err(dev, "can't get USB ID IRQ: %d\n", data->usb_id_irq);
105-
return -EINVAL;
124+
return data->usb_id_irq;
106125
}
107126

108-
data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
109-
INT3496_GPIO_VBUS_EN,
110-
GPIOD_ASIS);
127+
data->gpio_vbus_en = devm_gpiod_get(dev, "vbus", GPIOD_ASIS);
111128
if (IS_ERR(data->gpio_vbus_en))
112129
dev_info(dev, "can't request VBUS EN GPIO\n");
113130

114-
data->gpio_usb_mux = devm_gpiod_get_index(dev, "usb mux",
115-
INT3496_GPIO_USB_MUX,
116-
GPIOD_ASIS);
131+
data->gpio_usb_mux = devm_gpiod_get(dev, "mux", GPIOD_ASIS);
117132
if (IS_ERR(data->gpio_usb_mux))
118133
dev_info(dev, "can't request USB MUX GPIO\n");
119134

@@ -154,6 +169,8 @@ static int int3496_remove(struct platform_device *pdev)
154169
devm_free_irq(&pdev->dev, data->usb_id_irq, data);
155170
cancel_delayed_work_sync(&data->work);
156171

172+
acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
173+
157174
return 0;
158175
}
159176

drivers/hv/channel.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,15 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
502502

503503
wait_for_completion(&info->waitevent);
504504

505-
if (channel->rescind) {
506-
ret = -ENODEV;
507-
goto post_msg_err;
508-
}
509-
510505
post_msg_err:
506+
/*
507+
* If the channel has been rescinded;
508+
* we will be awakened by the rescind
509+
* handler; set the error code to zero so we don't leak memory.
510+
*/
511+
if (channel->rescind)
512+
ret = 0;
513+
511514
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
512515
list_del(&info->msglistentry);
513516
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
@@ -530,15 +533,13 @@ static int vmbus_close_internal(struct vmbus_channel *channel)
530533
int ret;
531534

532535
/*
533-
* vmbus_on_event(), running in the tasklet, can race
536+
* vmbus_on_event(), running in the per-channel tasklet, can race
534537
* with vmbus_close_internal() in the case of SMP guest, e.g., when
535538
* the former is accessing channel->inbound.ring_buffer, the latter
536-
* could be freeing the ring_buffer pages.
537-
*
538-
* To resolve the race, we can serialize them by disabling the
539-
* tasklet when the latter is running here.
539+
* could be freeing the ring_buffer pages, so here we must stop it
540+
* first.
540541
*/
541-
hv_event_tasklet_disable(channel);
542+
tasklet_disable(&channel->callback_event);
542543

543544
/*
544545
* In case a device driver's probe() fails (e.g.,
@@ -605,8 +606,6 @@ static int vmbus_close_internal(struct vmbus_channel *channel)
605606
get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
606607

607608
out:
608-
hv_event_tasklet_enable(channel);
609-
610609
return ret;
611610
}
612611

drivers/hv/channel_mgmt.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ static struct vmbus_channel *alloc_channel(void)
350350
static void free_channel(struct vmbus_channel *channel)
351351
{
352352
tasklet_kill(&channel->callback_event);
353-
kfree(channel);
353+
354+
kfree_rcu(channel, rcu);
354355
}
355356

356357
static void percpu_channel_enq(void *arg)
@@ -359,14 +360,14 @@ static void percpu_channel_enq(void *arg)
359360
struct hv_per_cpu_context *hv_cpu
360361
= this_cpu_ptr(hv_context.cpu_context);
361362

362-
list_add_tail(&channel->percpu_list, &hv_cpu->chan_list);
363+
list_add_tail_rcu(&channel->percpu_list, &hv_cpu->chan_list);
363364
}
364365

365366
static void percpu_channel_deq(void *arg)
366367
{
367368
struct vmbus_channel *channel = arg;
368369

369-
list_del(&channel->percpu_list);
370+
list_del_rcu(&channel->percpu_list);
370371
}
371372

372373

@@ -381,19 +382,6 @@ static void vmbus_release_relid(u32 relid)
381382
true);
382383
}
383384

384-
void hv_event_tasklet_disable(struct vmbus_channel *channel)
385-
{
386-
tasklet_disable(&channel->callback_event);
387-
}
388-
389-
void hv_event_tasklet_enable(struct vmbus_channel *channel)
390-
{
391-
tasklet_enable(&channel->callback_event);
392-
393-
/* In case there is any pending event */
394-
tasklet_schedule(&channel->callback_event);
395-
}
396-
397385
void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
398386
{
399387
unsigned long flags;
@@ -402,7 +390,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
402390
BUG_ON(!channel->rescind);
403391
BUG_ON(!mutex_is_locked(&vmbus_connection.channel_mutex));
404392

405-
hv_event_tasklet_disable(channel);
406393
if (channel->target_cpu != get_cpu()) {
407394
put_cpu();
408395
smp_call_function_single(channel->target_cpu,
@@ -411,7 +398,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
411398
percpu_channel_deq(channel);
412399
put_cpu();
413400
}
414-
hv_event_tasklet_enable(channel);
415401

416402
if (channel->primary_channel == NULL) {
417403
list_del(&channel->listentry);
@@ -505,7 +491,6 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
505491

506492
init_vp_index(newchannel, dev_type);
507493

508-
hv_event_tasklet_disable(newchannel);
509494
if (newchannel->target_cpu != get_cpu()) {
510495
put_cpu();
511496
smp_call_function_single(newchannel->target_cpu,
@@ -515,7 +500,6 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
515500
percpu_channel_enq(newchannel);
516501
put_cpu();
517502
}
518-
hv_event_tasklet_enable(newchannel);
519503

520504
/*
521505
* This state is used to indicate a successful open
@@ -565,7 +549,6 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
565549
list_del(&newchannel->listentry);
566550
mutex_unlock(&vmbus_connection.channel_mutex);
567551

568-
hv_event_tasklet_disable(newchannel);
569552
if (newchannel->target_cpu != get_cpu()) {
570553
put_cpu();
571554
smp_call_function_single(newchannel->target_cpu,
@@ -574,7 +557,6 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
574557
percpu_channel_deq(newchannel);
575558
put_cpu();
576559
}
577-
hv_event_tasklet_enable(newchannel);
578560

579561
vmbus_release_relid(newchannel->offermsg.child_relid);
580562

@@ -814,6 +796,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
814796
/* Allocate the channel object and save this offer. */
815797
newchannel = alloc_channel();
816798
if (!newchannel) {
799+
vmbus_release_relid(offer->child_relid);
817800
pr_err("Unable to allocate channel object\n");
818801
return;
819802
}

drivers/hv/hv_fcopy.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ static DECLARE_WORK(fcopy_send_work, fcopy_send_data);
7171
static const char fcopy_devname[] = "vmbus/hv_fcopy";
7272
static u8 *recv_buffer;
7373
static struct hvutil_transport *hvt;
74-
static struct completion release_event;
7574
/*
7675
* This state maintains the version number registered by the daemon.
7776
*/
@@ -331,15 +330,13 @@ static void fcopy_on_reset(void)
331330

332331
if (cancel_delayed_work_sync(&fcopy_timeout_work))
333332
fcopy_respond_to_host(HV_E_FAIL);
334-
complete(&release_event);
335333
}
336334

337335
int hv_fcopy_init(struct hv_util_service *srv)
338336
{
339337
recv_buffer = srv->recv_buffer;
340338
fcopy_transaction.recv_channel = srv->channel;
341339

342-
init_completion(&release_event);
343340
/*
344341
* When this driver loads, the user level daemon that
345342
* processes the host requests may not yet be running.
@@ -361,5 +358,4 @@ void hv_fcopy_deinit(void)
361358
fcopy_transaction.state = HVUTIL_DEVICE_DYING;
362359
cancel_delayed_work_sync(&fcopy_timeout_work);
363360
hvutil_transport_destroy(hvt);
364-
wait_for_completion(&release_event);
365361
}

drivers/hv/hv_kvp.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ static DECLARE_WORK(kvp_sendkey_work, kvp_send_key);
101101
static const char kvp_devname[] = "vmbus/hv_kvp";
102102
static u8 *recv_buffer;
103103
static struct hvutil_transport *hvt;
104-
static struct completion release_event;
105104
/*
106105
* Register the kernel component with the user-level daemon.
107106
* As part of this registration, pass the LIC version number.
@@ -714,7 +713,6 @@ static void kvp_on_reset(void)
714713
if (cancel_delayed_work_sync(&kvp_timeout_work))
715714
kvp_respond_to_host(NULL, HV_E_FAIL);
716715
kvp_transaction.state = HVUTIL_DEVICE_INIT;
717-
complete(&release_event);
718716
}
719717

720718
int
@@ -723,7 +721,6 @@ hv_kvp_init(struct hv_util_service *srv)
723721
recv_buffer = srv->recv_buffer;
724722
kvp_transaction.recv_channel = srv->channel;
725723

726-
init_completion(&release_event);
727724
/*
728725
* When this driver loads, the user level daemon that
729726
* processes the host requests may not yet be running.
@@ -747,5 +744,4 @@ void hv_kvp_deinit(void)
747744
cancel_delayed_work_sync(&kvp_timeout_work);
748745
cancel_work_sync(&kvp_sendkey_work);
749746
hvutil_transport_destroy(hvt);
750-
wait_for_completion(&release_event);
751747
}

0 commit comments

Comments
 (0)