From patchwork Sun Jun 19 12:44:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Reimer X-Patchwork-Id: 9186147 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 59ED460465 for ; Sun, 19 Jun 2016 12:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B218262FF for ; Sun, 19 Jun 2016 12:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AC6E2821F; Sun, 19 Jun 2016 12:45:20 +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 235FB262FF for ; Sun, 19 Jun 2016 12:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751789AbcFSMpL (ORCPT ); Sun, 19 Jun 2016 08:45:11 -0400 Received: from mx1.mailbox.org ([80.241.60.212]:47534 "EHLO mx1.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751786AbcFSMpK (ORCPT ); Sun, 19 Jun 2016 08:45:10 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 220C94200A; Sun, 19 Jun 2016 14:44:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id 8mXRjbVsXARX; Sun, 19 Jun 2016 14:44:36 +0200 (CEST) To: linux-input Cc: Cameron Gutman , jikos@kernel.org, dmitry.torokhov@gmail.com From: Manuel Reimer Subject: [PATCH] Fix effect aborting in ff-memless Message-ID: Date: Sun, 19 Jun 2016 14:44:35 +0200 MIME-Version: 1.0 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 Hello, while debugging a problem with hid-sony I got stuck with a problem actually caused by ff-memless. In some situations effect aborting is delayed, so it may be triggered seconds after all devices have been destroyed, which causes the kernel to panic. The aborting request actually gets received here: https://github.com/torvalds/linux/blob/master/drivers/input/ff-memless.c#L467 This "aborting" flag is then handled here: https://github.com/torvalds/linux/blob/master/drivers/input/ff-memless.c#L376 But before this line is reached, there is a time check to check if the effect actually is due to be started: https://github.com/torvalds/linux/blob/master/drivers/input/ff-memless.c#L359 This time check now causes a problem if the effect, which is meant to be *aborted* was scheduled to be *started* some time in future and the device is destroyed before this time is reached. My patch fixes this by setting the trigger times to "now" after setting the aborting flag. This way the following code deals with aborting the effect immediately without setting a timer for it. There may be other ways to fix this, so I would be happy to get some feedback. Signed-off-by: Manuel Reimer --- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/input/ff-memless.c 2016-05-13 16:06:29.722685021 +0200 +++ b/drivers/input/ff-memless.c 2016-06-19 14:25:39.790375270 +0200 @@ -463,9 +463,11 @@ static int ml_ff_playback(struct input_d } else { pr_debug("initiated stop\n"); - if (test_bit(FF_EFFECT_PLAYING, &state->flags)) + if (test_bit(FF_EFFECT_PLAYING, &state->flags)) { __set_bit(FF_EFFECT_ABORTING, &state->flags); - else + state->play_at = jiffies; + state->adj_at = jiffies; + } else __clear_bit(FF_EFFECT_STARTED, &state->flags); }