LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "xt.hu[胡先韬]" <xt.hu@cqplus1.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "wim@linux-watchdog.org" <wim@linux-watchdog.org>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-watchdog@vger.kernel.org" <linux-watchdog@vger.kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Wells Lu 呂芳騰" <wells.lu@sunplus.com>,
	"qinjian[覃健]" <qinjian@cqplus1.com>
Subject: RE: [PATCH v2 1/2] watchdog: Add watchdog driver for Sunplus SP7021
Date: Mon, 29 Nov 2021 07:57:02 +0000	[thread overview]
Message-ID: <8604284aa38d4ab6bc263d4881107e13@cqplus1.com> (raw)
In-Reply-To: <f69d663a-982b-5876-08c9-b1a4f35e8098@roeck-us.net>


> -----Original Message-----
> From: Guenter Roeck [mailto:groeck7@gmail.com] On Behalf Of Guenter Roeck
> Sent: Thursday, November 25, 2021 12:26 PM
> To: xt.hu[胡先韬] <xt.hu@cqplus1.com>
> Cc: wim@linux-watchdog.org; p.zabel@pengutronix.de; linux-kernel@vger.kernel.org;
> linux-watchdog@vger.kernel.org; robh+dt@kernel.org; devicetree@vger.kernel.org; Wells Lu 呂芳騰
> <wells.lu@sunplus.com>; qinjian[覃健] <qinjian@cqplus1.com>
> Subject: Re: [PATCH v2 1/2] watchdog: Add watchdog driver for Sunplus SP7021
> 
> On 11/24/21 6:42 PM, xt.hu[胡先韬] wrote:
> > Hi
> > 	Thanks for your review. I explain this in detail below the comment.
> >
> > Best Regards,
> > Xiantao
> >> -----Original Message-----
> >> From: Guenter Roeck [mailto:groeck7@gmail.com] On Behalf Of Guenter Roeck
> >> Sent: Wednesday, November 24, 2021 10:25 PM
> >> To: xt.hu[胡先韬] <xt.hu@cqplus1.com>
> >> Cc: wim@linux-watchdog.org; p.zabel@pengutronix.de; linux-kernel@vger.kernel.org;
> >> linux-watchdog@vger.kernel.org; robh+dt@kernel.org; devicetree@vger.kernel.org; Wells Lu 呂芳
> 騰
> >> <wells.lu@sunplus.com>; qinjian[覃健] <qinjian@cqplus1.com>
> >> Subject: Re: [PATCH v2 1/2] watchdog: Add watchdog driver for Sunplus SP7021
> >>
> >> On Wed, Nov 24, 2021 at 06:41:48PM +0800, Xiantao Hu wrote:
> >>> Sunplus SP7021 requires watchdog timer support.
> >>> Add watchdog driver to enable this.
> >>>
> >>> Signed-off-by: Xiantao Hu <xt.hu@cqplus1.com>
> >>> ---
> >>> +
> >>> +	priv->base = devm_platform_ioremap_resource(pdev, 0);
> >>> +	if (IS_ERR(priv->base))
> >>> +		return PTR_ERR(priv->base);
> >>> +
> >>> +	/* The registers accessed here shared by multiple drivers. */
> >>> +	wdt_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> >>
> >> This is unusual. Why would other drivers access WDT_CTRL and WDT_CNT registers, and how is it
> >> ensured that the other drivers do not interfer with the accesses by this driver ?
> >>
> >> Normally such a resource would be shared through a parent driver with appropriate access functions
> to
> >> ensure that accesses are synchronized.
> >>
> >
> > The register used by this driver consists of two parts. The first part which contains WDT_CTRL and
> WDT_CNT
> > registers is exclusive by watchdog.
> > In specially, the second part is belong to a multifunctional register group which control IP and bus.
> Refer to
> > register manual below:
> > -------------------------------------------------------------------------------------------------------------------------------------------------
> > MO1_STC_WDG_RST_EN	4	RW		STC Watchdog Timeout Trigger System Reset Enable
> > 									0: STC watchdog 2 timeout will not trigger system
> reset(default)
> > 									1: STC watchdog 2 timeout will trigger system reset
> > MO1_RI_WDG_RST_EN		1	RW		RBUS Watchdog Timeout Trigger System Reset Enable
> > 									0: RBUS watchdog timeout will not trigger system
> reset(default)
> > 									1: RBUS watchdog timeout will trigger system reset
> > MO1_TIMER_STAND_BY_EN	0	RW		Timer Standby Mode Enable
> > 									0: Disable (default)
> > 									1: Enable Active high to enter timer standby mode,
> > 											default not in standby mode
> > -------------------------------------------------------------------------------------------------------------------------------------------------
> > You can see that in addition to the bits for watchdog there are bit fields for other modules.
> > I use this register bit4 and bit1. Default value is 0 that watchdog internal interrupt signal can't trigger
> system
> > and RBUS reset. I need set 1 when watchdog probe. Early I implement the operation in
> > arch/arm/mach-sunplus/sp7021.c and configure by macro. But in arch/arm64, directory mach-XXX is
> removed.
> > So I solve in this way. Any better way?
> >
> If the register at 0x9C000274 is accessed by other drivers, accesses
> to it must be protected against each other to avoid race conditions.
> How to do that would be up to you.
> 
Hi Guenter,

From the perspective of software, 0x9C000274 is only accessed during
driver probe. If the driver is build-in and only one core is running at kernel 
startup. There is no competition.
The only possibility of an error is to compile the driver into a module. In this 
case, the register at 0x9C000274 offer MASK_BITS[31:16] which write valid 
bit for each LSB 16 bits. Refer to the define in driver:
#define MASK_SET(mask)		((mask) | (mask << 16))
Even if both drivers access the register at the same time, the instructions are 
executed in order on the RBUS. So as long as the same bit in the same register 
is not accessed at the same time, no error will occur.

Best Regards,
Xiantao

> Guenter

  reply	other threads:[~2021-11-29  8:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 10:59 [PATCH 0/2] Add watchdog driver for Sunplus SP7021 SoC Xiantao Hu
2021-11-12 10:59 ` [PATCH 1/2] watchdog: Add watchdog driver for Sunplus SP7021 Xiantao Hu
2021-11-12 14:45   ` Guenter Roeck
2021-11-24 10:31     ` xt.hu[胡先韬]
2021-11-21  0:33   ` kernel test robot
2021-11-12 10:59 ` [PATCH 2/2] dt-bindings: watchdog: Add Sunplus SP7021 WDT devicetree bindings documentation Xiantao Hu
2021-11-24 10:41 ` [PATCH v2 0/2] Add watchdog driver for Sunplus SP7021 SoC Xiantao Hu
2021-11-24 10:41   ` [PATCH v2 1/2] watchdog: Add watchdog driver for Sunplus SP7021 Xiantao Hu
2021-11-24 14:25     ` Guenter Roeck
2021-11-25  2:42       ` xt.hu[胡先韬]
2021-11-25  4:25         ` Guenter Roeck
2021-11-29  7:57           ` xt.hu[胡先韬] [this message]
2021-12-03 21:39             ` Guenter Roeck
2021-11-24 10:41   ` [PATCH v2 2/2] dt-bindings: watchdog: Add Sunplus SP7021 WDT devicetree bindings documentation Xiantao Hu
2021-11-30 22:38     ` Rob Herring
2021-11-24 14:17   ` [PATCH v2 0/2] Add watchdog driver for Sunplus SP7021 SoC Guenter Roeck
2021-11-25  2:52     ` xt.hu[胡先韬]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8604284aa38d4ab6bc263d4881107e13@cqplus1.com \
    --to=xt.hu@cqplus1.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=p.zabel@pengutronix.de \
    --cc=qinjian@cqplus1.com \
    --cc=robh+dt@kernel.org \
    --cc=wells.lu@sunplus.com \
    --cc=wim@linux-watchdog.org \
    --subject='RE: [PATCH v2 1/2] watchdog: Add watchdog driver for Sunplus SP7021' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).