/* * c67x00-drv.c: Cypress C67X00 USB Common infrastructure * * Copyright (C) 2006-2008 Barco N.V. * Derived from the Cypress cy7c67200/300 ezusb linux driver and * based on multiple host controller drivers inside the linux kernel. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA. */ /* * This file implements the common infrastructure for using the c67x00. * It is both the link between the platform configuration and subdrivers and * the link between the common hardware parts and the subdrivers (e.g. * interrupt handling). * * The c67x00 has 2 SIE's (serial interface engine) which can be configured * to be host, device or OTG (with some limitations, E.G. only SIE1 can be OTG). * * Depending on the platform configuration, the SIE's are created and * the corresponding subdriver is initialized (c67x00_probe_sie). */ #include #include #include #include #include #include #include #include "c67x00.h" #include "c67x00-hcd.h" static void c67x00_probe_sie(struct c67x00_sie *sie, struct c67x00_device *dev, int sie_num) { spin_lock_init(&sie->lock); sie->dev = dev; sie->sie_num = sie_num; sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num); switch (sie->mode) { case C67X00_SIE_HOST: c67x00_hcd_probe(sie); break; case C67X00_SIE_UNUSED: dev_info(sie_dev(sie), "Not using SIE %d as requested\n", sie->sie_num); break; default: dev_err(sie_dev(sie), "Unsupported configuration: 0x%x for SIE %d\n", sie->mode, sie->sie_num); break; } } static void c67x00_remove_sie(struct c67x00_sie *sie) { switch (sie->mode) { case C67X00_SIE_HOST: c67x00_hcd_remove(sie); break; default: break; } } static irqreturn_t c67x00_irq(int irq, void *__dev) { struct c67x00_device *c67x00 = __dev; struct c67x00_sie *sie; u16 msg, int_status; int i, count = 8; int_status = c67x00_ll_hpi_status(c67x00); if (!int_status) return IRQ_NONE; while (int_status != 0 && (count-- >= 0)) { c67x00_ll_irq(c67x00, int_status); for (i = 0; i < C67X00_SIES; i++) { sie = &c67x00->sie[i]; msg = 0; if (int_status & SIEMSG_FLG(i)) msg = c67x00_ll_fetch_siemsg(c67x00, i); if (sie->irq) sie->irq(sie, int_status, msg); } int_status = c67x00_ll_hpi_status(c67x00); } if (int_status) dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! " "status = 0x%04x\n", int_status); return IRQ_HANDLED; } /* ------------------------------------------------------------------------- */ static int c67x00_drv_probe(struct platform_device *pdev) { struct c67x00_device *c67x00; struct c67x00_platform_data *pdata; struct resource *res, *res2; int ret, i; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res2) return -ENODEV; pdata = dev_get_platdata(&pdev->dev); if (!pdata) return -ENODEV; c67x00 = kzalloc(sizeof(*c67x00), GFP_KERNEL); if (!c67x00) return -ENOMEM; if (!request_mem_region(res->start, resource_size(res), pdev->name)) { dev_err(&pdev->dev, "Memory region busy\n"); ret = -EBUSY; goto request_mem_failed; } c67x00->hpi.base = ioremap(res->start, resource_size(res)); if (!c67x00->hpi.base) { dev_err(&pdev->dev, "Unable to map HPI registers\n"); ret = -EIO; goto map_failed; } spin_lock_init(&c67x00->hpi.lock); c67x00->hpi.regstep = pdata->hpi_regstep; c67x00->pdata = dev_get_platdata(&pdev->dev); c67x00->pdev = pdev; c67x00_ll_init(c67x00); c67x00_ll_hpi_reg_init(c67x00); ret = request_irq(res2->start, c67x00_irq, 0, pdev->name, c67x00); if (ret) { dev_err(&pdev->dev, "Cannot claim IRQ\n"); goto request_irq_failed; } ret = c67x00_ll_reset(c67x00); if (ret) { dev_err(&pdev->dev, "Device reset failed\n"); goto reset_failed; } for (i = 0; i < C67X00_SIES; i++) c67x00_probe_sie(&c67x00->sie[i], c67x00, i); platform_set_drvdata(pdev, c67x00); return 0; reset_failed: free_irq(res2->start, c67x00); request_irq_failed: iounmap(c67x00->hpi.base); map_failed: release_mem_region(res->start, resource_size(res)); request_mem_failed: kfree(c67x00); return ret; } static int c67x00_drv_remove(struct platform_device *pdev) { struct c67x00_device *c67x00 = platform_get_drvdata(pdev); struct resource *res; int i; for (i = 0; i < C67X00_SIES; i++) c67x00_remove_sie(&c67x00->sie[i]); c67x00_ll_release(c67x00); res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (res) free_irq(res->start, c67x00); iounmap(c67x00->hpi.base); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res) release_mem_region(res->start, resource_size(res)); kfree(c67x00); return 0; } static struct platform_driver c67x00_driver = { .probe = c67x00_drv_probe, .remove = c67x00_drv_remove, .driver = { .name = "c67x00", }, }; module_platform_driver(c67x00_driver); MODULE_AUTHOR("Peter Korsgaard, Jan Veldeman, Grant Likely"); MODULE_DESCRIPTION("Cypress C67X00 USB Controller Driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:c67x00"); diff)
drm/atomic: Fix double free in drm_atomic_state_default_clear
drm_atomic_helper_page_flip and drm_atomic_ioctl set their own events in crtc_state->event. But when it's set the event is freed in 2 places. Solve this by only freeing the event in the atomic ioctl when it allocated its own event. This has been broken twice. The first time when the code was introduced, but only in the corner case when an event is allocated, but more crtc's were included by atomic check and then failing. This can mostly happen when you do an atomic modeset in i915 and the display clock is changed, which forces all crtc's to be included to the state. This has been broken worse by adding in-fences support, which caused the double free to be done unconditionally. [IGT] kms_rotation_crc: starting subtest primary-rotation-180 ============================================================================= BUG kmalloc-128 (Tainted: G U ): Object already free ----------------------------------------------------------------------------- Disabling lock debugging due to kernel taint INFO: Allocated in drm_atomic_helper_setup_commit+0x285/0x2f0 [drm_kms_helper] age=0 cpu=3 pid=1529 ___slab_alloc+0x308/0x3b0 __slab_alloc+0xd/0x20 kmem_cache_alloc_trace+0x92/0x1c0 drm_atomic_helper_setup_commit+0x285/0x2f0 [drm_kms_helper] intel_atomic_commit+0x35/0x4f0 [i915] drm_atomic_commit+0x46/0x50 [drm] drm_mode_atomic_ioctl+0x7d4/0xab0 [drm] drm_ioctl+0x2b3/0x490 [drm] do_vfs_ioctl+0x69c/0x700 SyS_ioctl+0x4e/0x80 entry_SYSCALL_64_fastpath+0x13/0x94 INFO: Freed in drm_event_cancel_free+0xa3/0xb0 [drm] age=0 cpu=3 pid=1529 __slab_free+0x48/0x2e0 kfree+0x159/0x1a0 drm_event_cancel_free+0xa3/0xb0 [drm] drm_mode_atomic_ioctl+0x86d/0xab0 [drm] drm_ioctl+0x2b3/0x490 [drm] do_vfs_ioctl+0x69c/0x700 SyS_ioctl+0x4e/0x80 entry_SYSCALL_64_fastpath+0x13/0x94 INFO: Slab 0xffffde1f0997b080 objects=17 used=2 fp=0xffff92fb65ec2578 flags=0x200000000008101 INFO: Object 0xffff92fb65ec2578 @offset=1400 fp=0xffff92fb65ec2ae8 Redzone ffff92fb65ec2570: bb bb bb bb bb bb bb bb ........ Object ffff92fb65ec2578: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec2588: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec2598: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25a8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25b8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25c8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25d8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk Object ffff92fb65ec25e8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 kkkkkkkkkkkkkkk. Redzone ffff92fb65ec25f8: bb bb bb bb bb bb bb bb ........ Padding ffff92fb65ec2738: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ CPU: 3 PID: 180 Comm: kworker/3:2 Tainted: G BU 4.10.0-rc6-patser+ #5039 Hardware name: /NUC5PPYB, BIOS PYBSWCEL.86A.0031.2015.0601.1712 06/01/2015 Workqueue: events intel_atomic_helper_free_state [i915] Call Trace: dump_stack+0x4d/0x6d print_trailer+0x20c/0x220 free_debug_processing+0x1c6/0x330 ? drm_atomic_state_default_clear+0xf7/0x1c0 [drm] __slab_free+0x48/0x2e0 ? drm_atomic_state_default_clear+0xf7/0x1c0 [drm] kfree+0x159/0x1a0 drm_atomic_state_default_clear+0xf7/0x1c0 [drm] ? drm_atomic_state_clear+0x30/0x30 [drm] intel_atomic_state_clear+0xd/0x20 [i915] drm_atomic_state_clear+0x1a/0x30 [drm] __drm_atomic_state_free+0x13/0x60 [drm] intel_atomic_helper_free_state+0x5d/0x70 [i915] process_one_work+0x260/0x4a0 worker_thread+0x2d1/0x4f0 kthread+0x127/0x130 ? process_one_work+0x4a0/0x4a0 ? kthread_stop+0x120/0x120 ret_from_fork+0x29/0x40 FIX kmalloc-128: Object at 0xffff92fb65ec2578 not freed Fixes: 3b24f7d67581 ("drm/atomic: Add struct drm_crtc_commit to track async updates") Fixes: 9626014258a5 ("drm/fence: add in-fences support") Cc: <stable@vger.kernel.org> # v4.8+ Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1485854725-27640-1-git-send-email-maarten.lankhorst@linux.intel.com
Diffstat (limited to 'include/uapi/xen/gntdev.h')