lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <22a0e4a9-96b3-8ecd-b699-4e4aad017b5d@gmail.com>
Date:   Mon, 30 Dec 2019 11:05:34 -0800
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Philipp Zabel <p.zabel@...gutronix.de>,
        Florian Fainelli <f.fainelli@...il.com>,
        linux-kernel@...r.kernel.org, Jim Quinlan <jim2101024@...il.com>,
        Jim Quinlan <james.quinlan@...adcom.com>
Cc:     Rob Herring <robh@...nel.org>, Mark Rutland <mark.rutland@....com>,
        "maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE" 
        <bcm-kernel-feedback-list@...adcom.com>,
        "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
        <devicetree@...r.kernel.org>,
        "moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE" 
        <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH 2/2] reset: Add Broadcom STB RESCAL reset controller

On 12/12/19 2:01 AM, Philipp Zabel wrote:
> On Wed, 2019-12-11 at 10:12 -0800, Florian Fainelli wrote:
>>
>> On 12/11/2019 1:48 AM, Philipp Zabel wrote:
>>>> +#define BRCM_RESCAL_START	0
>>>> +#define	BRCM_RESCAL_START_BIT	BIT(0)
>>>> +#define BRCM_RESCAL_CTRL	4
>>>> +#define BRCM_RESCAL_STATUS	8
>>>> +#define BRCM_RESCAL_STATUS_BIT	BIT(0)
>>>
>>> Is there any reason the start bit is indented but the status bit is not?
>>
>> This is a convention we have tried to adopt to denote the definition
>> from a register word address/offset versus the definition for bits
>> within that register word.
> 
> That's fine, consider indenting BRCM_RESCAL_STATUS_BIT as well, then.
> 
> [...]
>>>> +	reg = readl(base + BRCM_RESCAL_START);
>>>> +	writel(reg | BRCM_RESCAL_START_BIT, base + BRCM_RESCAL_START);
>>>> +	reg = readl(base + BRCM_RESCAL_START);
>>>> +	if (!(reg & BRCM_RESCAL_START_BIT)) {
>>>> +		dev_err(data->dev, "failed to start sata/pcie rescal\n");
> 
> Is this something that can actually happen?

Have not seen it happen but if we have bogus hardware, we would rather
get an informative log from the reset controller than a not so
informative one from the consumer drivers about e.g.: SATA or PCIe link
down (which could be for various other reasons). If you want this
demoted to a debug print, let me know.

> 
> [...]
>>>> +	reg = readl(base + BRCM_RESCAL_START);
>>>> +	writel(reg ^ BRCM_RESCAL_START_BIT, base + BRCM_RESCAL_START);
>>>
>>> Please use &= ~BRCM_RESCAL_START_BIT instead.
>>
>> I think the idea was to avoid unconditionally clearing it, but based on
>> the documentation, I don't see this being harmful, Jim?
> 
> Unless the bit is self-clearing, I can't see how this XOR could ever set
> the bit instead of clearing it.
> And even if it would, I don't understand how that can be indented.
> Wouldn't that restart the reset/calibration sequence?
The bit is not self clearing, but it can be cleared when the
reset/calibration procedure is successfully finished, so this seems to
do what it is intended for, in that, if you read the bit as 1, XOR would
let you clear it. If you read it as 0, XOR would leave it cleared.

Would you want a comment above to explain that?

> 
>>>> +	reg = readl(base + BRCM_RESCAL_START);
>>>> +	dev_dbg(data->dev, "sata/pcie rescal success\n");
>>>> +
>>>> +	return 0;
>>>> +}
>>>
>>> This whole function looks a lot like it doesn't just deassert a reset
>>> line, but actually issues a complete reset procedure of some kind. Do
>>> you have some insight on what actually happens in the hardware when the
>>> start bit is triggered? I suspect this should be implemented with the
>>> .reset operation.
>>
>> This hardware block is controlling the reset and calibration process of
>> the SATA/PCIe combo PHY analog front end, but is not technically part of
>> the PCIe or SATA PHY proper, it stands on its own, both functionally and
>> from a register space perspective. The motivation for modelling this as
>> a reset controller is that it does a reset (and a calibration) and this
>> is a shared reset line among 2/3 instances of another block. If you
>> think we should model this differently, please let us know.
> 
> Thank you for the explanation. I agree the "reset and calibration
> sequence" property is close enough to a pure reset sequence to warrant
> describing this as as reset controller.
> The correct way would be to use the .reset callback though, if you can
> have the drivers use reset_control_reset().

This should be doable, let me try to update the drivers accordingly. It
sounds a bit silly to have to have kind of knowledge pushed down to the
consumer drivers though...
-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ