From patchwork Tue May 31 21:10:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Colenbrander, Roderick" X-Patchwork-Id: 9145713 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4787060752 for ; Tue, 31 May 2016 21:43:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ABB220700 for ; Tue, 31 May 2016 21:43:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C021265F9; Tue, 31 May 2016 21:43:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 256B420700 for ; Tue, 31 May 2016 21:43:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756668AbcEaVnK (ORCPT ); Tue, 31 May 2016 17:43:10 -0400 Received: from mail-bn1bon0092.outbound.protection.outlook.com ([157.56.111.92]:45121 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756662AbcEaVnH convert rfc822-to-8bit (ORCPT ); Tue, 31 May 2016 17:43:07 -0400 X-Greylist: delayed 1931 seconds by postgrey-1.27 at vger.kernel.org; Tue, 31 May 2016 17:43:07 EDT Received: from CY1PR0801CA0029.namprd08.prod.outlook.com (10.163.136.167) by BY2PR08MB491.namprd08.prod.outlook.com (10.141.143.24) with Microsoft SMTP Server (TLS) id 15.1.511.6; Tue, 31 May 2016 21:10:52 +0000 Received: from BN1BFFO11FD052.protection.gbl (2a01:111:f400:7c10::1:123) by CY1PR0801CA0029.outlook.office365.com (2a01:111:e400:5312::39) with Microsoft SMTP Server (TLS) id 15.1.511.6 via Frontend Transport; Tue, 31 May 2016 21:10:51 +0000 Authentication-Results: spf=pass (sender IP is 160.33.194.229) smtp.mailfrom=sony.com; googlemail.com; dkim=none (message not signed) header.d=none;googlemail.com; dmarc=bestguesspass action=none header.from=sony.com; Received-SPF: Pass (protection.outlook.com: domain of sony.com designates 160.33.194.229 as permitted sender) receiver=protection.outlook.com; client-ip=160.33.194.229; helo=usculsndmail02v.am.sony.com; Received: from usculsndmail02v.am.sony.com (160.33.194.229) by BN1BFFO11FD052.mail.protection.outlook.com (10.58.145.7) with Microsoft SMTP Server (TLS) id 15.1.497.8 via Frontend Transport; Tue, 31 May 2016 21:10:50 +0000 Received: from usculsndmail12v.am.sony.com (usculsndmail12v.am.sony.com [146.215.230.103]) by usculsndmail02v.am.sony.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4VLAndN030955; Tue, 31 May 2016 21:10:49 GMT From: "Colenbrander, Roelof" To: "dh.herrmann@googlemail.com" , "jikos@kernel.org" CC: "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , "roderick@gaikai.com" Subject: RE: [PATCH] HID: uhid: Fixes a bug with userspace bluetooth stacks, which causes hangs during certain operations Thread-Topic: [PATCH] HID: uhid: Fixes a bug with userspace bluetooth stacks, which causes hangs during certain operations Thread-Index: AQLL8cbWzbfxDNlX6ojN0e0TpirD/53e/FjA Date: Tue, 31 May 2016 21:10:36 +0000 Message-ID: <1DD62093774CEE42AFC16E785A1088045F496A74@USCULXMSG04.am.sony.com> References: <1463602269-19844-1-git-send-email-roderick.colenbrander@sony.com> In-Reply-To: <1463602269-19844-1-git-send-email-roderick.colenbrander@sony.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [146.215.231.6] MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:160.33.194.229; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(377454003)(2950100001)(3900700001)(2920100001)(66066001)(5004730100002)(47776003)(8746002)(5008740100001)(87936001)(8676002)(97756001)(55846006)(19580395003)(2501003)(19580405001)(8936002)(92566002)(106466001)(106116001)(102836003)(6806005)(6116002)(33656002)(586003)(3846002)(2906002)(5001770100001)(104016004)(50466002)(23726003)(4326007)(46406003)(189998001)(76176999)(86362001)(54356999)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR08MB491; H:usculsndmail02v.am.sony.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD052; 1:IPk9VZfWFTnmEKdpYRto/bHQZdbsxgU+uUi4/z8YBQPt8ostRd20AjexCMn0ZB2x9ymOrrrg24+3ysrOlZ56RCPyYRuJU8/5kZo4+wecuK9tcWg0HT5z/S5QqPllpqKmUd0Zng70HfAXyEShG4FgqtRGRDQT36eZB3W/fksabhjHN3IyvDwhx2J0Rl2LszLqXgBZ2FMwOLfqp0U0HX8NNdXPDJrSV3OZQWAQgiJ15XbB9f0or1Lt+TcoKgpt8BGRMc+1B+mVcpSTnIIrJZhsB8lGznSUNU6Fn4wJqatEUVirBHilBvF4ttCw+m6rnWkjrCl3f/RTTwG27yB1HmByzCxffydXijtooyg6cFiu5lFK8rjuWUCorjJNoRJXz3qtjja7CJLC6ouYBeSL95xU0mWRys0hSV1E42yi6iZ+g+OAi7nPKxVpXvbGoblmMAdZfZzHMdTy+agsnb9xmQ11jsV6f3XTDuD0oV5u681gUt35TSQqx0jop0H/jbko25Ri X-MS-Office365-Filtering-Correlation-Id: 4e8a95f4-d93d-4768-0151-08d389980b9d X-Microsoft-Exchange-Diagnostics: 1; BY2PR08MB491; 2:Q0RRaqluuwTb9k4TR7WbAf157WCEDJMsKWLdbuYV//BJhsHOeW+SAcrenAQupapuDdfmiPrc0tOhlMTl9tqKyO7JWDcwuc270pXsBRCoSTZr19cJkk14Lht/T2SirIFeh9mUaH3mV1BDrHEyBxqrbwdX3/sYecZClgYd+fGJdZ2r6pLgJeFbEItXm7ZWzVNB; 3:Yafw/bcaLWAC9Fc0iyreyEJNCgG4RexCtDUTlufEpRtlJczZeBxIFk5lLJlcHkzD+WmjnohLlTGbWvNG8llbUy655bpyGXD766ZowGVDm4+tfME3njLolhMOtN7MP04/+BjsTFTH9KsRpj6P9Jwq5uDXP8M6l1m6B7FDR+W1YzcdsoeMe46jj/LcV50CMkh4bAAuE8uCGqo0dFMc+0FhCWP/6koNyOlkWrZpZjN719cosQKTuKetdWZkx8NQBHfsc9e9O6qLUr/gaqJE1TK+vQ== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:BY2PR08MB491; X-Microsoft-Exchange-Diagnostics: 1; BY2PR08MB491; 25:jYXQwvmFMULVWHGEZFmL6uD9gV0UZ7vNCRiE3yqg3WYl1pm9bP1vx+7V1EJuzr8Kvv9u2rGPUqDMQTPYbZ8QP3PqcvCvekXoQ+fAs9aE8hnOdXewqxI5w5W41HkwUIJPWs7MM3/IJ4pVJvRcmHUBpuSTBR5+PW3T4/b0rlSo/H7Rhh062GfZwi7wFhDwojKjlogkPwO+ntb7JuvHV4yGyfxHIXgeU1ZCGP6M4Ool2YBnhrnOIdigLXS2055gLKJqq9+jadm5W9d/ulelUD8C4vg9n7uJyEtKF0I/1rAVDk+SQ/14PxGzMDLqOzDcVDk1ZPurHkis/BR+qu1577Sxmne3iCkpkP43JqtmwcW1aRHXJhwMwGcs75v4Dqd32zJVteo40KLp/jvuMb8DVDcEUoRPYFR43OregMLm2R78dTXIulUyBK9NZ0tqSTJBx81C//CxVNfLfIjvPa3tQhuAyctv0ZpIhbDZWcGypRdk85DyqZFqIC8PRbUNH5Vl28XxG9IJUygmvuCtD46RA3vBeIMFLBD4S0VT15jJkdYPMErwkL1PAbgkznhQjbPT/TfrVbEDXmFIzElbYgLDudZna5JIOH+8VXLXA3tj2dYggZZF2ZKBFYt7EB89s5qt2QX6gurvu/TN2oKpTTzheHNJ+eHr0XEcwMt5+/N7vIQIpTHppAMGdJgCcBhA2GFw2UBOEIdH4CAGCqspmJoTMXQaKXzPMJv/1HorHcSICfz+OYFixYepcetQigkP5TjgTJOjzBCh4sJGiaYNpkhXktM2VpzJJyGtR2Wxz2Q3Aa79BFSG9XqhuI7vb8mr9Qk793cq X-LD-Processed: 86f99b1e-a08b-4313-8c0c-2258d53da610,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; BY2PR08MB491; 20:XVc7Wht5h4cvu5OWAJIkO2Vbl8+g/ueuFMpaBNU9fvne6FLepbv3ZPyAVeMwaEevQuHYnoq5s/+Ey1Aj6I31TS1x5XakCfa2vkzTBO0CBwapHD6TODf+7Qve41Kz8GjaURVznTutYbId8UZXAvdlL4f2pyDUihqwh4Pcsq1yTWrOZDDSTfOMkwcwSQBWYqdbbOpIS9N6uzjCvQhkuiXvvZhX4lTQa75jh2Rm1AHlFylAW0vpQgq/zANdaCnSpE0gRlDC/6yppp8rp3T6RYtLKQSwUEVYraJyGL72TaCAhMdxn0KQLDKcW4PKnkfaZHhvuPe600ckt9oCUuI1qn6YdIsdSSCiVbiPRXlvtNbXHWmYcAB3Y0rExSNzs+sepuuG8Ul9I87ydko3HrG1+0d9Dp0IKZ0uqvAsL8AY9OQAY72UmbZlDiXFIju4rJHvUO+4e85eTKlHT7+TfTIb2w7rgi2TgMgyhacYohW3HNRKUz+VcW4z0pYPh0WHKrRsshxJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(182409339516656)(9452136761055)(8415204561270); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(8121501046)(5005006)(13018025)(13023025)(13016025)(10201501046)(3002001)(6055026); SRVR:BY2PR08MB491; BCL:0; PCL:0; RULEID:; SRVR:BY2PR08MB491; X-Microsoft-Exchange-Diagnostics: 1; BY2PR08MB491; 4:gt9Kn80G4+/fiKusVqu0F3ZQ4l/qkvH1f+ItoHKxj9Rh4EVU7OV8D7GNI/Qk2iTovKf1J8ilCJ49kFtuSBloFD7HqJctXiGIt7ihGG0sWzI6C8zva3L1/A+xeGRRqb3Co0C3hAr2YG5vn0Q7L0/xLFVMXHh4J/zUHkuMdHsn1R1YniZ2i1EhWKLy2CabsvdVJu9BhotpI8VIB0LVgdOwgAtBsr5PXJ+svlmxlP1W0WVcudgNygXp6Pflg+a3+Eco9sL9+fpV2e6w1W8REwF/aOY/YSbTyrAQEWzck7KkRj5gCSIZN5QV9K5bLShZfh1N0eLw3wQnIv7Mmgs30+X3H68OOnRQ7CdVYbPsG33d+BB0Glw3ZH41gEayhg17rNMlIypupcMbth/OyAIU2ZpaGdDeYtE8d8X210JUHDYJFGIIoAn4tRtxU2AYEweYsi3opOvoG4Gu5KdG+dtTEsMNH0mhVfUcg8KD0wux2dCcZmazXKTCXDX316xF2omjbISbH8iGgHOqzATXb/ENTID0kqT+3e7lCrKnO7ZMSbljUN1R4GuDsDRDFBf8vNvGuTDG X-Forefront-PRVS: 095972DF2F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR08MB491; 23:ycixzTaLKgUYpRYl//gQpJ0s/C5pl4+wpaEj9s70xp?= =?us-ascii?Q?/Em2uM1F3icNCMMLR1zeBWY9iMug0Wg6Sr6gDTGTGmKl9b2d8zOO1uNwRIkM?= =?us-ascii?Q?AddVxRUexkvePEHob4rdiJ2zIieBbvKOdBLGBfqv1hrjpr8UjVkKceh6lK7N?= =?us-ascii?Q?9REEJBD9XI0n+bo87WPpLNdIEWNpWEdiSbZebs19Ponr5fyvzLHuUHwuRTo4?= =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Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR08MB491; 5:8hgcH7+3hDykZ7Qv2zOhhVrw5JO0GHYHP0tT43oWX0Q6ESpzmfxGLzEYgYVMzkiDeSgwPGbkBmyx4x5WhX6H6cfvrP8Fobxh4PVaVlo8zZ0ub6bceGOu6eNp8i/mKm7PNxMmLd9sJOVtg1K6YynvnA==; 24:aUCjrQ3iLgbuQslF3eREWDLqCliLY1MfyHS13pmqgnzfxNVMWYEW+fSGsdach5VAcydJSvCbGjdSlImvTaCRFYpKzkjBFLqa5A47YomSW0c=; 7:L6y/OT29FwQ4DzS+0MFSTR2r3Fp55bb+dhmZt5iyZ8nmFldk3cwTP831I0MRElJsJtU+2HIOJ/3rmzSdVIG2mRM2vmTInRCeh2oSxbTWqwcDh3qtiTjQN85s6Qw4X4zJb2kRokFDC5+KJTFpBR36T1jKlhfTVE7rLzVautjB5uYda+mx45PPeGI3sz9874Of SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2016 21:10:50.9749 (UTC) X-MS-Exchange-CrossTenant-Id: 86f99b1e-a08b-4313-8c0c-2258d53da610 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=86f99b1e-a08b-4313-8c0c-2258d53da610; Ip=[160.33.194.229]; Helo=[usculsndmail02v.am.sony.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR08MB491 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, The patch in this thread is part of input work I'm doing with my team and will hopefully be the first of many, but we are new to the linux-input project. We shared this patch first in April and again about 2 weeks ago in May, but we haven't received any feedback so far. Originally the discussion leading to this patch was partially on linux-input, but then privately with David and he suggested the direction the patch took. I think the resulting patch is clean and self explanatory. We have tested the patch on various devices without issues. For us this patch fixes an important problem and we would like to get it included in the upstream kernel. Thanks, Roderick Colenbrander Gaikai Inc, a Sony Interactive Entertainment Company diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 16b6f11..99ec3ff 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c @@ -51,10 +51,26 @@ struct uhid_device { u32 report_id; u32 report_type; struct uhid_event report_buf; + struct work_struct worker; }; static struct miscdevice uhid_misc; +static void uhid_device_add_worker(struct work_struct *work) +{ + struct uhid_device *uhid = container_of(work, struct uhid_device, worker); + int ret; + + ret = hid_add_device(uhid->hid); + if (ret) { + hid_err(uhid->hid, "Cannot register HID device: error %d\n", ret); + + hid_destroy_device(uhid->hid); + uhid->hid = NULL; + uhid->running = false; + } +} + static void uhid_queue(struct uhid_device *uhid, struct uhid_event *ev) { __u8 newhead; @@ -498,18 +514,14 @@ static int uhid_dev_create2(struct uhid_device *uhid, uhid->hid = hid; uhid->running = true; - ret = hid_add_device(hid); - if (ret) { - hid_err(hid, "Cannot register HID device\n"); - goto err_hid; - } + /* Adding of a HID device is done through a worker, to allow HID drivers + * which use feature requests during .probe to work, without they would + * be blocked on devlock, which is held by uhid_char_write. + */ + schedule_work(&uhid->worker); return 0; -err_hid: - hid_destroy_device(hid); - uhid->hid = NULL; - uhid->running = false; err_free: kfree(uhid->rd_data); uhid->rd_data = NULL; @@ -550,6 +562,8 @@ static int uhid_dev_destroy(struct uhid_device *uhid) uhid->running = false; wake_up_interruptible(&uhid->report_wait); + cancel_work_sync(&uhid->worker); + hid_destroy_device(uhid->hid); kfree(uhid->rd_data); @@ -612,6 +626,7 @@ static int uhid_char_open(struct inode *inode, struct file *file) init_waitqueue_head(&uhid->waitq); init_waitqueue_head(&uhid->report_wait); uhid->running = false; + INIT_WORK(&uhid->worker, uhid_device_add_worker); file->private_data = uhid; nonseekable_open(inode, file);