Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp43454pxh; Thu, 7 Apr 2022 13:27:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6kD6ukA+h9YenCGPNpdHZW3KyKV3elidszh4LPkBVI0Bv3o8DJs+y/Rg/d792+6ltkpBV X-Received: by 2002:a17:902:f78d:b0:14f:ce61:eaf2 with SMTP id q13-20020a170902f78d00b0014fce61eaf2mr15705959pln.124.1649363220156; Thu, 07 Apr 2022 13:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363220; cv=none; d=google.com; s=arc-20160816; b=kuq4zXwTvRmIm3ewOVYBx8EO7CEc7Nmo4s3pCNo9qzEG5YhK/uSrLuPQFCz4sdcVGH SmDjX0S55ObiUajFx5EZhIwb8Vl6h4ZwmTNzGeQHECLom4tvWqr26qighPaGa3Q8JlUn rTYsGE1ZkeJDQtqRCP5LiGYh1FKM6N4KA2EYH3hsG8YPwl1vlUsGmBkmJitPcJdcKIcF b7jr4GurXM5RDi8hQB6zwGpyM74fB8Tk4e+6lpMVN8WS0ET0jl2weuGH8Qb3RPZzwsiz OfoB2ntSZ0mZRn5EWtBD/TT7Bn1Qa29us1D8E+GN8AnxovmrqD2fjT66luhsmFggJtNG 6XCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=+MRMqRWO/BSpIFPSSldridGY4ck/laYvPKynNTcsQoQ=; b=NstK6Ai6nXba4RESANtMwspQKm2sWE/RNcWgQHesLOQP5yyKTo2zztsb7SLEQYlTgs TQnolmCGbGSGyU+TIasJV//tnrCzt35KYtVkLinCrISvFGmglA59qLDAo2Sf2ZRlQNwC crpvHTYfL+G83rPgYv/46a5szv62m+jphfGe2TBhvOut8Xs3HX4ZNK2wVr+Ae8RvQDJc R6qBGE++IYzEXa0p9IBi6m9ykZ2NS+631/JyZcg0gGw/Qqp2s9hJ0zk12HfQrhWk/bAO 6hwgVQkf3ZvnuPJ6DTs0ePTt2joA/GHCJp8u4CvUZba77wi0ng6Z6HN610XM3+sqeLqa 13Zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k4-20020a170902760400b00153b2d16404si664672pll.12.2022.04.07.13.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:27:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2FE0D35E2FE; Thu, 7 Apr 2022 12:42:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232411AbiDGJtM convert rfc822-to-8bit (ORCPT + 99 others); Thu, 7 Apr 2022 05:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237429AbiDGJtJ (ORCPT ); Thu, 7 Apr 2022 05:49:09 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC59110FDDE for ; Thu, 7 Apr 2022 02:47:08 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ncOix-0007d3-0T; Thu, 07 Apr 2022 11:46:43 +0200 Received: from [2a0a:edc0:0:900:1d::4e] (helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1ncOix-001aNC-5z; Thu, 07 Apr 2022 11:46:41 +0200 Received: from pza by lupine with local (Exim 4.94.2) (envelope-from ) id 1ncOiv-0004Dh-5U; Thu, 07 Apr 2022 11:46:41 +0200 Message-ID: Subject: Re: [PATCH v2 07/10] power: reset: at91-reset: add reset_controller_dev support From: Philipp Zabel To: Claudiu Beznea , robh+dt@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux@armlinux.org.uk, sre@kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Date: Thu, 07 Apr 2022 11:46:41 +0200 In-Reply-To: <20220407071708.3848812-8-claudiu.beznea@microchip.com> References: <20220407071708.3848812-1-claudiu.beznea@microchip.com> <20220407071708.3848812-8-claudiu.beznea@microchip.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: p.zabel@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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Do, 2022-04-07 at 10:17 +0300, Claudiu Beznea wrote: > SAMA7G5 reset controller has 5 extra lines that goes to different devices > (3 lines to USB PHYs, 1 line to DDR controller, 1 line to DDR PHY > controller). These reset lines could be requested by different controller > drivers (e.g. USB PHY driver) and these controllers' drivers could > assert/deassert these lines when necessary. Thus add support for > reset_controller_dev which brings this functionality. > > Signed-off-by: Claudiu Beznea > --- >  drivers/power/reset/at91-reset.c | 107 +++++++++++++++++++++++++++++-- >  1 file changed, 103 insertions(+), 4 deletions(-) > > diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c > index 1b2aca3f490d..a6f65ac430cd 100644 > --- a/drivers/power/reset/at91-reset.c > +++ b/drivers/power/reset/at91-reset.c [...] > +static int at91_reset_update(struct reset_controller_dev *rcdev, > + unsigned long id, bool assert) > +{ > + struct at91_reset *reset = to_at91_reset(rcdev); > + u32 val; > + > + spin_lock(&reset->lock); Use spin_lock_irqsave. We don't know where we are called from and this isn't a time critical path. > + val = readl_relaxed(reset->dev_base); > + if (assert) > + val |= BIT(id); > + else > + val &= ~BIT(id); > + writel_relaxed(val, reset->dev_base); > + spin_unlock(&reset->lock); > + > + return 0; > +} > + > +static int at91_reset_assert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + return at91_reset_update(rcdev, id, true); > +} > + > +static int at91_reset_deassert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + return at91_reset_update(rcdev, id, false); > +} > + > +static int at91_reset_dev_status(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct at91_reset *reset = to_at91_reset(rcdev); > + u32 val; > + > + spin_lock(&reset->lock); Locking is not necessary here. If the read is racing against an update, it either returns the register value before or after the update, same as without a lock. With those changes, Reviewed-by: Philipp Zabel regards Philipp