Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2179820imu; Tue, 6 Nov 2018 10:13:28 -0800 (PST) X-Google-Smtp-Source: AJdET5d3XOf4B8zbDONi0Y7CbFQukYMYLepuZ9ED3mPpNr6mj7ohXelau+jPujOhuEUnr0F05TM1 X-Received: by 2002:a63:e70a:: with SMTP id b10-v6mr23914942pgi.363.1541528008697; Tue, 06 Nov 2018 10:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541528008; cv=none; d=google.com; s=arc-20160816; b=B0xTb8jqlKU/+PWsgVMoEJeXs95m7lRqL939UJ67xc1nW5eKRE9PCfQ4gLN71Hpy41 enQ/KgTyinAXWrSvGOreK1UUFb6jIuCE7gimbVnR0p4wRmQ+zQg4D6H/UeWELvzo/a1E KWcOiMiAgYHUVnUVNgJDY6v2rl3p/ppVh2YsoIAu9qL72yDTwiyIzdqBwBf/VB8vRY+m rt8LhVQs6CH3sqT8TBoAeL1Bfvmbu4HjF7z1kADeC6kUET8yyKnqps2cuLtZTbEbvfMN iFKaOdtFZJ9Yref86ODOWedwRI/Wc/OOGxP3uREz57ozEPXjJsENGZBgk88JJdd8JFpV WeEg== 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=q3QS7ROoMxMKBtBIA2enqXYZGYdBJQq/j1ORHN/Oz2E=; b=OVlTUI1ffLRAh07ZBDxCvJLm4zFTmkKuXGnR3HAJ7w+FFl+dZn+pQshwQQk3BP2UOk rsyQgDTZOX1Xu30iaFyK/iTRdsOa8JGrSGJ6bokreDTjmLzUBUnSGayJV/xeyZeC5I8k Xz4Fr45j7OvqZCkCRDdek+VFxCdIjvjXb3BLSQOGNVhNAkC13o6MLlCHZU9TfrnA8f7O 1gXOp70n7OUGnprD1PJCwjHHUTl7gUKncRig54NSpHKwknd6MTPCAhbnuCCO5BlqST1B +aVBqfUgIbidJNJrD41qb9eiO6ZTfIhGho5xuir2CcCxP2YGmv6sVYr9Xkz6Iu6LQBLH LpoQ== 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 t2-v6si47919866plz.427.2018.11.06.10.13.13; Tue, 06 Nov 2018 10:13:28 -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 S2389037AbeKGBXG (ORCPT + 99 others); Tue, 6 Nov 2018 20:23:06 -0500 Received: from mail-vs1-f68.google.com ([209.85.217.68]:39718 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388554AbeKGBXG (ORCPT ); Tue, 6 Nov 2018 20:23:06 -0500 Received: by mail-vs1-f68.google.com with SMTP id h78so7574664vsi.6; Tue, 06 Nov 2018 07:57:14 -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=q3QS7ROoMxMKBtBIA2enqXYZGYdBJQq/j1ORHN/Oz2E=; b=K0je9P/sxH5i0mNjRQAxZklxIfsDAly5spKigoZCUb8vutilcbRQqT0SZFVT8scB5t DO6vGUMcu3t/JAw8wE5uvVFn9Q00GC+07kcJRFi5v+R5DD2mQUQ8QoxURNfTAOsR9QL5 ZE29mr1yYbE4vxEqOjg6lQ+SNI46toDSzDV8o1M57GWk87+TrWis9JPfnNY15CtSOQ8N 2GrktFJVkitzNhWDMfGfD4cLC11NhzSoMCDR5QrqfqYKwvAQpUHKeWGiKqRCeWCPD6sJ bYWmexNvWXd7I8gKN/B0gtQNaaWlQj4cvPNBQy3AIt1UIwrB750y8descTAJHQq1OrbU 8iIA== X-Gm-Message-State: AGRZ1gLYLObVdNbxiimfIxdKKRohyqdkbPTcvPUPJqozx7h7NDw9X/fE oxcACeVKUTLOW+hsPcUPoDojgNxrf3xWATnh0rM= X-Received: by 2002:a67:f43:: with SMTP id 64mr2469569vsp.166.1541519833485; Tue, 06 Nov 2018 07:57:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Geert Uytterhoeven Date: Tue, 6 Nov 2018 16:57:01 +0100 Message-ID: Subject: Re: [PATCH v14 1/2] leds: core: Introduce LED pattern trigger To: Baolin Wang Cc: Jacek Anaszewski , Pavel Machek , rteysseyre@gmail.com, =?UTF-8?Q?Bj=C3=B6rn_Andersson?= , 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 Tue, Oct 2, 2018 at 6:39 PM Baolin Wang wrote: > This patch adds one new led trigger that LED device can configure > the software or hardware pattern and trigger it. > > Consumers can write 'pattern' file to enable the software pattern > which alters the brightness for the specified duration with one > software timer. > > Moreover consumers can write 'hw_pattern' file to enable the hardware > pattern for some LED controllers which can autonomously control > brightness over time, according to some preprogrammed hardware > patterns. > > Signed-off-by: Raphael Teysseyre > Signed-off-by: Baolin Wang > --- /dev/null > +++ b/drivers/leds/trigger/ledtrig-pattern.c > @@ -0,0 +1,431 @@ > +static void pattern_trig_timer_function(struct timer_list *t) > +{ > + struct pattern_trig_data *data = from_timer(data, t, timer); > + > + mutex_lock(&data->lock); Timer functions run in interrupt context, hence if CONFIG_DEBUG_ATOMIC_SLEEP=y: 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) Either this should use a spinlock instead of a mutex, or the timer function should kick a workqueue to do the real work. 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