All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Anurup M <anurupvasu@gmail.com>
Cc: will.deacon@arm.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, anurup.m@huawei.com,
	zhangshaokun@hisilicon.com, tanxiaojun@huawei.com,
	xuwei5@hisilicon.com, sanil.kumar@hisilicon.com,
	john.garry@huawei.com, gabriele.paoloni@huawei.com,
	shiju.jose@huawei.com, huangdaode@hisilicon.com,
	linuxarm@huawei.com, dikshit.n@huawei.com, shyju.pv@huawei.com
Subject: Re: [PATCH v6 06/11] drivers: perf: hisi: Add support for Hisilicon Djtag driver
Date: Fri, 24 Mar 2017 11:36:11 +0000	[thread overview]
Message-ID: <20170324113610.GB22771@leverpostej> (raw)
In-Reply-To: <58D4F901.5070503@gmail.com>

On Fri, Mar 24, 2017 at 04:16:25PM +0530, Anurup M wrote:
> Thanks for the review.
> 
> On Tuesday 21 March 2017 09:21 PM, Mark Rutland wrote:
> >On Fri, Mar 10, 2017 at 01:28:22AM -0500, Anurup M wrote:

> >>+#define SC_DJTAG_TIMEOUT_US    (100 * USEC_PER_MSEC) /* 100ms */
> >How was this value chosen?
> >
> >How likely is a timeout?
> 
> As explained in PATCH 7,
> 
> The djtag -EBUSY in hardware is a very rare scenario, and by design
> of hardware, does not occur unless there is a Chip hung situation.
> The maximum timeout possible in djtag is 30us, and hardware logic
> shall reset it, if djtag is unavailable for more than 30us.
> The timeout used in driver is 100ms to ensure that it does not fail
> in any case.

I couldn't find such an explanation in patch 7.

So that this doesn't get lost, please place a comment to this effect
above the definition of SC_DJTAG_TIMEOUT_US.

We can drop the existing "100ms" comment at the same time.

What exactly does a "chip hung situation" imply? Does that just mean
that only the djtag HW is hung, or that other parts of the chip are hung
too, such taht other things are likely to go wrong?

[...]

> >static int djtag_do_operation_v1(void __iomem *regs_base)
> >{
> >	int ret;
> >	u32 val;
> >
> >	/* start to write to djtag register */
> >	writel(DJTAG_MSTR_START_EN, regs_base + SC_DJTAG_MSTR_START_EN);
> >
> >	/* wait for the operation to complete */
> >	ret = readl_poll_timout(regs_base + SC_DJTAG_MSTR_START_EN,
> >				val, !(val & DJTAG_MSTR_EN),
> >				1, SC_DJTAG_TIMEOUT_US);
> >	
> >	if (ret)
> >		pr_warn("djtag operation timed out.\n");
> >
> >	return ret;
> >}
> >
> >Depending on how serious a timeout is, this might want to be some kind
> >of WARN variant.

>From the above, I take that a hang indicates a very serious problem, so
this whould be a WARN, with a comment:

	/* 
	 * A timeout should never occur on a working system. See the
	 * definition of SC_DJTAG_TIMEOUT_US.
	 */
	WARN(ret, "djtag operation timed out.\n");

... or, if this really should never happen, and other things are likely
to go wrong were we to see this, we can BUG_ON(ret) instead, remove the
error code, and simplify all the callers.

Likewise for djtag_do_operation_v2().

Thanks,
Mark.

WARNING: multiple messages have this Message-ID (diff)
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 06/11] drivers: perf: hisi: Add support for Hisilicon Djtag driver
Date: Fri, 24 Mar 2017 11:36:11 +0000	[thread overview]
Message-ID: <20170324113610.GB22771@leverpostej> (raw)
In-Reply-To: <58D4F901.5070503@gmail.com>

On Fri, Mar 24, 2017 at 04:16:25PM +0530, Anurup M wrote:
> Thanks for the review.
> 
> On Tuesday 21 March 2017 09:21 PM, Mark Rutland wrote:
> >On Fri, Mar 10, 2017 at 01:28:22AM -0500, Anurup M wrote:

> >>+#define SC_DJTAG_TIMEOUT_US    (100 * USEC_PER_MSEC) /* 100ms */
> >How was this value chosen?
> >
> >How likely is a timeout?
> 
> As explained in PATCH 7,
> 
> The djtag -EBUSY in hardware is a very rare scenario, and by design
> of hardware, does not occur unless there is a Chip hung situation.
> The maximum timeout possible in djtag is 30us, and hardware logic
> shall reset it, if djtag is unavailable for more than 30us.
> The timeout used in driver is 100ms to ensure that it does not fail
> in any case.

I couldn't find such an explanation in patch 7.

So that this doesn't get lost, please place a comment to this effect
above the definition of SC_DJTAG_TIMEOUT_US.

We can drop the existing "100ms" comment at the same time.

What exactly does a "chip hung situation" imply? Does that just mean
that only the djtag HW is hung, or that other parts of the chip are hung
too, such taht other things are likely to go wrong?

[...]

> >static int djtag_do_operation_v1(void __iomem *regs_base)
> >{
> >	int ret;
> >	u32 val;
> >
> >	/* start to write to djtag register */
> >	writel(DJTAG_MSTR_START_EN, regs_base + SC_DJTAG_MSTR_START_EN);
> >
> >	/* wait for the operation to complete */
> >	ret = readl_poll_timout(regs_base + SC_DJTAG_MSTR_START_EN,
> >				val, !(val & DJTAG_MSTR_EN),
> >				1, SC_DJTAG_TIMEOUT_US);
> >	
> >	if (ret)
> >		pr_warn("djtag operation timed out.\n");
> >
> >	return ret;
> >}
> >
> >Depending on how serious a timeout is, this might want to be some kind
> >of WARN variant.

>From the above, I take that a hang indicates a very serious problem, so
this whould be a WARN, with a comment:

	/* 
	 * A timeout should never occur on a working system. See the
	 * definition of SC_DJTAG_TIMEOUT_US.
	 */
	WARN(ret, "djtag operation timed out.\n");

... or, if this really should never happen, and other things are likely
to go wrong were we to see this, we can BUG_ON(ret) instead, remove the
error code, and simplify all the callers.

Likewise for djtag_do_operation_v2().

Thanks,
Mark.

  reply	other threads:[~2017-03-24 11:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10  6:28 [PATCH v6 06/11] drivers: perf: hisi: Add support for Hisilicon Djtag driver Anurup M
2017-03-10  6:28 ` Anurup M
2017-03-21 15:51 ` Mark Rutland
2017-03-21 15:51   ` Mark Rutland
2017-03-24 10:46   ` Anurup M
2017-03-24 10:46     ` Anurup M
2017-03-24 11:36     ` Mark Rutland [this message]
2017-03-24 11:36       ` Mark Rutland
2017-03-27  6:36       ` Anurup M
2017-03-27  6:36         ` Anurup M

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=20170324113610.GB22771@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=anurup.m@huawei.com \
    --cc=anurupvasu@gmail.com \
    --cc=dikshit.n@huawei.com \
    --cc=gabriele.paoloni@huawei.com \
    --cc=huangdaode@hisilicon.com \
    --cc=john.garry@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=sanil.kumar@hisilicon.com \
    --cc=shiju.jose@huawei.com \
    --cc=shyju.pv@huawei.com \
    --cc=tanxiaojun@huawei.com \
    --cc=will.deacon@arm.com \
    --cc=xuwei5@hisilicon.com \
    --cc=zhangshaokun@hisilicon.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.