Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3014973img; Mon, 25 Mar 2019 01:51:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyC83npM6BSB3Kd1mmaMdoM+WzPtn8s/sf2KXIeS/byyqLGBxSAvSNOT2AOYAoNTFTdWBns X-Received: by 2002:a17:902:44a4:: with SMTP id l33mr24053836pld.292.1553503872186; Mon, 25 Mar 2019 01:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553503872; cv=none; d=google.com; s=arc-20160816; b=y6Wo0+J+xOAHc6lF6K5A3Mztw+RplTG5pk31gFPe5uWL+gFqWhxp3Scx1vpvbdgoCy Vjbq+lLJxXgX+K5LkAHlD0FmB7MykQzfo7LEoVnxsh4Uacd8hMjlWR+tfwVxFIinUhQX QswBsKQiAxKm4YvIk4upBsSZ1FXTtHMjyqTZAymZa2CfQ5zXrE36O6Rzc5hu9DNTCJ6c 20HSCpxY2U3LTkN7LYZbquEMMWcu8cRK61MV+ZcglpfOhVBopn3VVnTLKJHptZllEV+N 0voYKch7fO+TscwebTU9cnTtGnWyb4Ryn+6xrzqwW+8ap2MLv9ws60SHCISNAqSCq7Vz KW+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=/KFVZgtTyByWSSemeYGFCh5LDVwsaivnAnGEsem2w0M=; b=sHSzrxXfGLKX6Lh4gRfiUa5hSVXGSd4FApk5qigNAFM6icjryreLxmh6dxNxo6DcXw qTnUHjpOfAvDKl4BUZ6n85HkeBbRp7Vk3LQzgveC07xn2RWRsW8CK2JXgRqHLdFEXJG7 jNQQ9sTLhAfcXEk6h8eCoxUVA+Of/MRIJeJFZTkJKs0JJF9OBakLyI9nt+3GBtFici8S 3Wha2G/Ia8h+6jMIq29kGyj/Rc6jE/sThJqeZUg9O/LtaB7XI92nblvVLPkft4S7qUOt V+CqT44VXzVwCBT3Cc46IJouGtOnNswqs6PBC0OXL4Fn/EjDsaXw6n/43obOLof3VzNm dqzg== 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 t3si13890805plq.430.2019.03.25.01.50.57; Mon, 25 Mar 2019 01:51:12 -0700 (PDT) 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 S1730130AbfCYIsh (ORCPT + 99 others); Mon, 25 Mar 2019 04:48:37 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:52237 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730102AbfCYIsf (ORCPT ); Mon, 25 Mar 2019 04:48:35 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h8LHL-000192-E7; Mon, 25 Mar 2019 09:48:23 +0100 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h8LHK-0005lS-Pm; Mon, 25 Mar 2019 09:48:22 +0100 Date: Mon, 25 Mar 2019 09:48:22 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Martin Blumenstingl Cc: thierry.reding@gmail.com, narmstrong@baylibre.com, jbrunet@baylibre.com, linux-pwm@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] pwm: meson: use the spin-lock only to protect register modifications Message-ID: <20190325084822.ozixel6bzi6xiw67@pengutronix.de> References: <20190324220217.15813-1-martin.blumenstingl@googlemail.com> <20190324220217.15813-2-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190324220217.15813-2-martin.blumenstingl@googlemail.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Sun, Mar 24, 2019 at 11:02:17PM +0100, Martin Blumenstingl wrote: > Holding the spin-lock for all of the code in meson_pwm_apply() can > result in a "BUG: scheduling while atomic". This can happen because > clk_get_rate() (which is called from meson_pwm_calc()) may sleep. > Only hold the spin-lock when modifying registers to solve this. > > The reason why we need a spin-lock in the driver is because the > REG_MISC_AB register is shared between the two channels provided by one > PWM controller. The only functions where REG_MISC_AB is modified are > meson_pwm_enable() and meson_pwm_disable() so the register reads/writes > in there need to be protected by the spin-lock. > > The original code also used the spin-lock to protect the values in > struct meson_pwm_channel. This could be necessary if two consumers can > use the same PWM channel. However, PWM core doesn't allow this so we > don't need to protect the values in struct meson_pwm_channel with a > lock. > > Fixes: 211ed630753d2f ("pwm: Add support for Meson PWM Controller") > Signed-off-by: Martin Blumenstingl Looks right. Reviewed-by: Uwe Kleine-K?nig Bonus points for adding a comment to struct meson_pwm::lock. Something like: /* * Protects register access to the MISC_AB register that is * shared between the two PWMs. */ Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |