Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'char-misc-5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg KH:
"Here are some small misc/char driver fixes to resolve some reported
problems:

- habanalabs driver fixes

- Acrn build fixes (reported many times)

- pvpanic module table export fix

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

* tag 'char-misc-5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
misc/pvpanic: Export module FDT device table
misc: fastrpc: restrict user apps from sending kernel RPC messages
virt: acrn: Correct type casting of argument of copy_from_user()
virt: acrn: Use EPOLLIN instead of POLLIN
virt: acrn: Use vfs_poll() instead of f_op->poll()
virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU
cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP
habanalabs: fix debugfs address translation
habanalabs: Disable file operations after device is removed
habanalabs: Call put_pid() when releasing control device
drivers: habanalabs: remove unused dentry pointer for debugfs files
habanalabs: mark hl_eq_inc_ptr() as static

+97 -28
+5
drivers/misc/fastrpc.c
··· 950 950 if (!fl->cctx->rpdev) 951 951 return -EPIPE; 952 952 953 + if (handle == FASTRPC_INIT_HANDLE && !kernel) { 954 + dev_warn_ratelimited(fl->sctx->dev, "user app trying to send a kernel RPC message (%d)\n", handle); 955 + return -EPERM; 956 + } 957 + 953 958 ctx = fastrpc_context_alloc(fl, kernel, sc, args); 954 959 if (IS_ERR(ctx)) 955 960 return PTR_ERR(ctx);
+1 -4
drivers/misc/habanalabs/common/debugfs.c
··· 992 992 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; 993 993 int count = ARRAY_SIZE(hl_debugfs_list); 994 994 struct hl_debugfs_entry *entry; 995 - struct dentry *ent; 996 995 int i; 997 996 998 997 dev_entry->hdev = hdev; ··· 1104 1105 &hl_security_violations_fops); 1105 1106 1106 1107 for (i = 0, entry = dev_entry->entry_arr ; i < count ; i++, entry++) { 1107 - 1108 - ent = debugfs_create_file(hl_debugfs_list[i].name, 1108 + debugfs_create_file(hl_debugfs_list[i].name, 1109 1109 0444, 1110 1110 dev_entry->root, 1111 1111 entry, 1112 1112 &hl_debugfs_fops); 1113 - entry->dent = ent; 1114 1113 entry->info_ent = &hl_debugfs_list[i]; 1115 1114 entry->dev_entry = dev_entry; 1116 1115 }
+35 -5
drivers/misc/habanalabs/common/device.c
··· 93 93 static int hl_device_release(struct inode *inode, struct file *filp) 94 94 { 95 95 struct hl_fpriv *hpriv = filp->private_data; 96 + struct hl_device *hdev = hpriv->hdev; 97 + 98 + filp->private_data = NULL; 99 + 100 + if (!hdev) { 101 + pr_crit("Closing FD after device was removed. Memory leak will occur and it is advised to reboot.\n"); 102 + put_pid(hpriv->taskpid); 103 + return 0; 104 + } 96 105 97 106 hl_cb_mgr_fini(hpriv->hdev, &hpriv->cb_mgr); 98 107 hl_ctx_mgr_fini(hpriv->hdev, &hpriv->ctx_mgr); 99 - 100 - filp->private_data = NULL; 101 108 102 109 hl_hpriv_put(hpriv); 103 110 ··· 114 107 static int hl_device_release_ctrl(struct inode *inode, struct file *filp) 115 108 { 116 109 struct hl_fpriv *hpriv = filp->private_data; 117 - struct hl_device *hdev; 110 + struct hl_device *hdev = hpriv->hdev; 118 111 119 112 filp->private_data = NULL; 120 113 121 - hdev = hpriv->hdev; 114 + if (!hdev) { 115 + pr_err("Closing FD after device was removed\n"); 116 + goto out; 117 + } 122 118 123 119 mutex_lock(&hdev->fpriv_list_lock); 124 120 list_del(&hpriv->dev_node); 125 121 mutex_unlock(&hdev->fpriv_list_lock); 122 + out: 123 + put_pid(hpriv->taskpid); 126 124 127 125 kfree(hpriv); 128 126 ··· 146 134 static int hl_mmap(struct file *filp, struct vm_area_struct *vma) 147 135 { 148 136 struct hl_fpriv *hpriv = filp->private_data; 137 + struct hl_device *hdev = hpriv->hdev; 149 138 unsigned long vm_pgoff; 139 + 140 + if (!hdev) { 141 + pr_err_ratelimited("Trying to mmap after device was removed! Please close FD\n"); 142 + return -ENODEV; 143 + } 150 144 151 145 vm_pgoff = vma->vm_pgoff; 152 146 vma->vm_pgoff = HL_MMAP_OFFSET_VALUE_GET(vm_pgoff); ··· 901 883 return -EBUSY; 902 884 } 903 885 886 + static void device_disable_open_processes(struct hl_device *hdev) 887 + { 888 + struct hl_fpriv *hpriv; 889 + 890 + mutex_lock(&hdev->fpriv_list_lock); 891 + list_for_each_entry(hpriv, &hdev->fpriv_list, dev_node) 892 + hpriv->hdev = NULL; 893 + mutex_unlock(&hdev->fpriv_list_lock); 894 + } 895 + 904 896 /* 905 897 * hl_device_reset - reset the device 906 898 * ··· 1584 1556 HL_PENDING_RESET_LONG_SEC); 1585 1557 1586 1558 rc = device_kill_open_processes(hdev, HL_PENDING_RESET_LONG_SEC); 1587 - if (rc) 1559 + if (rc) { 1588 1560 dev_crit(hdev->dev, "Failed to kill all open processes\n"); 1561 + device_disable_open_processes(hdev); 1562 + } 1589 1563 1590 1564 hl_cb_pool_fini(hdev); 1591 1565
-2
drivers/misc/habanalabs/common/habanalabs.h
··· 1465 1465 1466 1466 /** 1467 1467 * struct hl_debugfs_entry - debugfs dentry wrapper. 1468 - * @dent: base debugfs entry structure. 1469 1468 * @info_ent: dentry realted ops. 1470 1469 * @dev_entry: ASIC specific debugfs manager. 1471 1470 */ 1472 1471 struct hl_debugfs_entry { 1473 - struct dentry *dent; 1474 1472 const struct hl_info_list *info_ent; 1475 1473 struct hl_dbg_device_entry *dev_entry; 1476 1474 };
+12
drivers/misc/habanalabs/common/habanalabs_ioctl.c
··· 5 5 * All Rights Reserved. 6 6 */ 7 7 8 + #define pr_fmt(fmt) "habanalabs: " fmt 9 + 8 10 #include <uapi/misc/habanalabs.h> 9 11 #include "habanalabs.h" 10 12 ··· 684 682 const struct hl_ioctl_desc *ioctl = NULL; 685 683 unsigned int nr = _IOC_NR(cmd); 686 684 685 + if (!hdev) { 686 + pr_err_ratelimited("Sending ioctl after device was removed! Please close FD\n"); 687 + return -ENODEV; 688 + } 689 + 687 690 if ((nr >= HL_COMMAND_START) && (nr < HL_COMMAND_END)) { 688 691 ioctl = &hl_ioctls[nr]; 689 692 } else { ··· 706 699 struct hl_device *hdev = hpriv->hdev; 707 700 const struct hl_ioctl_desc *ioctl = NULL; 708 701 unsigned int nr = _IOC_NR(cmd); 702 + 703 + if (!hdev) { 704 + pr_err_ratelimited("Sending ioctl after device was removed! Please close FD\n"); 705 + return -ENODEV; 706 + } 709 707 710 708 if (nr == _IOC_NR(HL_IOCTL_INFO)) { 711 709 ioctl = &hl_ioctls_control[nr];
+1 -1
drivers/misc/habanalabs/common/irq.c
··· 47 47 * Increment ptr by 1. If it reaches the number of event queue 48 48 * entries, set it to 0 49 49 */ 50 - inline u32 hl_eq_inc_ptr(u32 ptr) 50 + static inline u32 hl_eq_inc_ptr(u32 ptr) 51 51 { 52 52 ptr++; 53 53 if (unlikely(ptr == HL_EQ_LENGTH))
+26 -12
drivers/misc/habanalabs/common/mmu/mmu.c
··· 499 499 else /* HL_VA_RANGE_TYPE_DRAM */ 500 500 p = &prop->dmmu; 501 501 502 - /* 503 - * find the correct hop shift field in hl_mmu_properties structure 504 - * in order to determine the right maks for the page offset. 505 - */ 506 - hop0_shift_off = offsetof(struct hl_mmu_properties, hop0_shift); 507 - p = (char *)p + hop0_shift_off; 508 - p = (char *)p + ((hops->used_hops - 1) * sizeof(u64)); 509 - hop_shift = *(u64 *)p; 510 - offset_mask = (1ull << hop_shift) - 1; 511 - addr_mask = ~(offset_mask); 512 - *phys_addr = (tmp_phys_addr & addr_mask) | 513 - (virt_addr & offset_mask); 502 + if ((hops->range_type == HL_VA_RANGE_TYPE_DRAM) && 503 + !is_power_of_2(prop->dram_page_size)) { 504 + u32 bit; 505 + u64 page_offset_mask; 506 + u64 phys_addr_mask; 507 + 508 + bit = __ffs64((u64)prop->dram_page_size); 509 + page_offset_mask = ((1ull << bit) - 1); 510 + phys_addr_mask = ~page_offset_mask; 511 + *phys_addr = (tmp_phys_addr & phys_addr_mask) | 512 + (virt_addr & page_offset_mask); 513 + } else { 514 + /* 515 + * find the correct hop shift field in hl_mmu_properties 516 + * structure in order to determine the right masks 517 + * for the page offset. 518 + */ 519 + hop0_shift_off = offsetof(struct hl_mmu_properties, hop0_shift); 520 + p = (char *)p + hop0_shift_off; 521 + p = (char *)p + ((hops->used_hops - 1) * sizeof(u64)); 522 + hop_shift = *(u64 *)p; 523 + offset_mask = (1ull << hop_shift) - 1; 524 + addr_mask = ~(offset_mask); 525 + *phys_addr = (tmp_phys_addr & addr_mask) | 526 + (virt_addr & offset_mask); 527 + } 514 528 } 515 529 516 530 int hl_mmu_va_to_pa(struct hl_ctx *ctx, u64 virt_addr, u64 *phys_addr)
+1
drivers/misc/pvpanic.c
··· 140 140 { .compatible = "qemu,pvpanic-mmio", }, 141 141 {} 142 142 }; 143 + MODULE_DEVICE_TABLE(of, pvpanic_mmio_match); 143 144 144 145 static const struct acpi_device_id pvpanic_device_ids[] = { 145 146 { "QEMU0001", 0 },
+10 -1
drivers/virt/acrn/hsm.c
··· 333 333 acrn_ioreq_request_clear(vm); 334 334 break; 335 335 case ACRN_IOCTL_PM_GET_CPU_STATE: 336 - if (copy_from_user(&cstate_cmd, (void *)ioctl_param, 336 + if (copy_from_user(&cstate_cmd, (void __user *)ioctl_param, 337 337 sizeof(cstate_cmd))) 338 338 return -EFAULT; 339 339 ··· 404 404 } 405 405 static DEVICE_ATTR_WO(remove_cpu); 406 406 407 + static umode_t acrn_attr_visible(struct kobject *kobj, struct attribute *a, int n) 408 + { 409 + if (a == &dev_attr_remove_cpu.attr) 410 + return IS_ENABLED(CONFIG_HOTPLUG_CPU) ? a->mode : 0; 411 + 412 + return a->mode; 413 + } 414 + 407 415 static struct attribute *acrn_attrs[] = { 408 416 &dev_attr_remove_cpu.attr, 409 417 NULL ··· 419 411 420 412 static struct attribute_group acrn_attr_group = { 421 413 .attrs = acrn_attrs, 414 + .is_visible = acrn_attr_visible, 422 415 }; 423 416 424 417 static const struct attribute_group *acrn_attr_groups[] = {
+3 -3
drivers/virt/acrn/irqfd.c
··· 112 112 { 113 113 struct eventfd_ctx *eventfd = NULL; 114 114 struct hsm_irqfd *irqfd, *tmp; 115 - unsigned int events; 115 + __poll_t events; 116 116 struct fd f; 117 117 int ret = 0; 118 118 ··· 158 158 mutex_unlock(&vm->irqfds_lock); 159 159 160 160 /* Check the pending event in this stage */ 161 - events = f.file->f_op->poll(f.file, &irqfd->pt); 161 + events = vfs_poll(f.file, &irqfd->pt); 162 162 163 - if (events & POLLIN) 163 + if (events & EPOLLIN) 164 164 acrn_irqfd_inject(irqfd); 165 165 166 166 fdput(f);
+3
include/linux/cpu.h
··· 108 108 { 109 109 } 110 110 111 + static inline int add_cpu(unsigned int cpu) { return 0;} 112 + 111 113 #endif /* CONFIG_SMP */ 112 114 extern struct bus_type cpu_subsys; 113 115 ··· 139 137 static inline void lockdep_assert_cpus_held(void) { } 140 138 static inline void cpu_hotplug_disable(void) { } 141 139 static inline void cpu_hotplug_enable(void) { } 140 + static inline int remove_cpu(unsigned int cpu) { return -EPERM; } 142 141 static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { } 143 142 #endif /* !CONFIG_HOTPLUG_CPU */ 144 143