Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2841568imu; Wed, 7 Nov 2018 00:00:23 -0800 (PST) X-Google-Smtp-Source: AJdET5dVbtYXXKxiyP3c7uwIkxqw30KnSlCcRk6rBgcIfMhikiSCPe4VpQs9/rVckBx4ZL56O22a X-Received: by 2002:a62:4301:: with SMTP id q1-v6mr846664pfa.163.1541577623725; Wed, 07 Nov 2018 00:00:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541577623; cv=none; d=google.com; s=arc-20160816; b=YLzrBvkbtOAbXAFtOtlgtbi0+o9JHx0ZzTG8goYWPK+pyq8wZNuZFE6xfVulBJ1KLt CafDiGz8VVihqUUQNbnjfC90e0DeOCOjt0S41K1RYoJ6VegYgiK2vZn/j1TLo+nAamrR JPclf6idQ16yNllmxtxV270z/2E9B5u+QpI381+UIvWNH0+xufXDa0kml5DGw15G+xPk ssBPh/mwLw0jqEMKbaXHDeZHD9vJRYvPrGSauzj/RvyWHQzXpS4gL+2X1oNCypdztzKT u8+xDFeRZXQTmYKxmP5M6pLqtZtJ0swR01NLnl2viK0C1EYSVfIn/tosarM+Ng4uBF15 5Rtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=n8F/XueKnoyC/zw8ECGiy8cprJXWkaCvyVKJfxcQV1I=; b=HgVsYIAZTC5asPwK5hIsb93lOFKgJBOmN6xiefKEnaU1rwO453RDy92CL4tB/a3W8D amaiwV9dBZva0yVklC1rkVbzorml0AFGlPI0o7tXPUVO8vKHT56sSw4poheqoyFaAslp Xx4jsBK1VpWJ0snHZMe3W8/Y/zU0zO3lnBBol2BMH1cDyS2N2pYLmmNe8Ph/vLE5UWxo hjFBQAxHAlI9CHQUyeoAxIyO/O53YWrg/u9WGYNelSWyDwYyQsijfNiGYyXo2K0DfFY9 t2awyWCZMtXqAfw2xBja223d1xrh/LYvbNA+S4FC1UTnqCC6R/2KE2d9wEAipkwN0Lrt +/sg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si18541094pgk.341.2018.11.07.00.00.08; Wed, 07 Nov 2018 00:00:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730441AbeKGR2w (ORCPT + 99 others); Wed, 7 Nov 2018 12:28:52 -0500 Received: from mail-vk1-f194.google.com ([209.85.221.194]:39952 "EHLO mail-vk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727315AbeKGR2w (ORCPT ); Wed, 7 Nov 2018 12:28:52 -0500 Received: by mail-vk1-f194.google.com with SMTP id v70so3499234vkv.7; Tue, 06 Nov 2018 23:59:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n8F/XueKnoyC/zw8ECGiy8cprJXWkaCvyVKJfxcQV1I=; b=FL+Yi7yXfwjHJpwZ0NXsdomsDWS1DrtVV3WzfLYRFKF6xFmi+yjrtiLV1w1mEKceJi YNH9nyHqnY4XoOmQNe/BlV0TrcZ/InawigIIzFS/IoN0QGoBkoyZ4PaZDtLjP2Vp6Xek Fm4aiFnQCjQ3I7H8fQuxUprwLQtweCcx9S4x9crW9/C3+51F2eXlT01dAtBFOYjzFbqt PxGRKmXC/9G6H+Yb36WIOKxkeYLaJOMaPEMQAYnqgrlVH/VEONKsOGP5WfnBkwima1Zh wg87dPLhx7iRruLhyhNMaxK67PT4OMBN8VEAHIjM28R6QvLy0uh59doFLvoHlrQebLZW U86Q== X-Gm-Message-State: AGRZ1gJ4Av22gS0BWbLQNy2eu+AiJlC4y6JS7QB8SKmZE2Sl0XpXmYjm iyE9sCKdvIH7GWA2SChp3TCvD/845ixZGKhXVeskjR4N X-Received: by 2002:a1f:2145:: with SMTP id h66mr320779vkh.65.1541577578694; Tue, 06 Nov 2018 23:59:38 -0800 (PST) MIME-Version: 1.0 References: <5f1cfb9c87f591b12efa2e7a0063f15532649634.1541563908.git.baolin.wang@linaro.org> In-Reply-To: <5f1cfb9c87f591b12efa2e7a0063f15532649634.1541563908.git.baolin.wang@linaro.org> From: Geert Uytterhoeven Date: Wed, 7 Nov 2018 08:59:26 +0100 Message-ID: Subject: Re: [PATCH] leds: trigger: Fix sleeping function called from invalid context To: Baolin Wang Cc: Jacek Anaszewski , Pavel Machek , rteysseyre@gmail.com, Mark Brown , linux-leds@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Baolin, On Wed, Nov 7, 2018 at 6:43 AM Baolin Wang wrote: > We will meet below issue due to mutex_lock() is called in interrupt context. > The mutex lock is used to protect the pattern trigger data, but before changing > new pattern trigger data (pattern values or repeat value) by users, we always > cancel the timer firstly to clear previous patterns' performance. That means > there is no race in pattern_trig_timer_function(), so we can drop the mutex > lock in pattern_trig_timer_function() to avoid this issue. > > Moreover we can move the timer cancelling into mutex protection, since there > is no deadlock risk if we remove the mutex lock in pattern_trig_timer_function(). > > BUG: sleeping function called from invalid context at kernel/locking/mutex.c:254 > in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/1 > CPU: 1 PID: 0 Comm: swapper/1 Not tainted > 4.20.0-rc1-koelsch-00841-ga338c8181013c1a9 #171 > Hardware name: Generic R-Car Gen2 (Flattened Device Tree) > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0x7c/0x9c) > [] (dump_stack) from [] (___might_sleep+0xf4/0x158) > [] (___might_sleep) from [] (mutex_lock+0x18/0x60) > [] (mutex_lock) from [] (pattern_trig_timer_function+0x1c/0x11c) > [] (pattern_trig_timer_function) from [] (call_timer_fn+0x1c/0x90) > [] (call_timer_fn) from [] (expire_timers+0x94/0xa4) > [] (expire_timers) from [] (run_timer_softirq+0x108/0x15c) > [] (run_timer_softirq) from [] (__do_softirq+0x1d4/0x258) > [] (__do_softirq) from [] (irq_exit+0x64/0xc4) > [] (irq_exit) from [] (__handle_domain_irq+0x80/0xb4) > [] (__handle_domain_irq) from [] (gic_handle_irq+0x58/0x90) > [] (gic_handle_irq) from [] (__irq_svc+0x58/0x74) > Exception stack(0xeb483f60 to 0xeb483fa8) > 3f60: 00000000 00000000 eb9afaa0 c0217e80 00000000 ffffe000 00000000 c0e06408 > 3f80: 00000002 c0e0647c c0c6a5f0 00000000 c0e04900 eb483fb0 c0207ea8 c0207e98 > 3fa0: 60020013 ffffffff > [] (__irq_svc) from [] (arch_cpu_idle+0x1c/0x38) > [] (arch_cpu_idle) from [] (do_idle+0x138/0x268) > [] (do_idle) from [] (cpu_startup_entry+0x18/0x1c) > [] (cpu_startup_entry) from [<402022ec>] (0x402022ec) > > Fixes: 5fd752b6b3a2 ("leds: core: Introduce LED pattern trigger") > Reported-by: Geert Uytterhoeven > Signed-off-by: Baolin Wang Thanks! Tested-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds