From: Paul Cercueil <paul@crapouillou.net>
To: Felipe Balbi <balbi@kernel.org>
Cc: 周琰杰 <zhouyanjie@wanyeetech.com>, 周正 <sernia.zhou@foxmail.com>,
漆鹏振 <aric.pzqi@ingenic.com>,
od@zcrc.me, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] USB: PHY: JZ4770: Fix uninitialized value written to HW register
Date: Thu, 27 Aug 2020 15:11:49 +0200 [thread overview]
Message-ID: <PN4QFQ.KWNBY2ZWQ7XC2@crapouillou.net> (raw)
In-Reply-To: <87v9h4i6t5.fsf@kernel.org>
Hi Felipe,
Le jeu. 27 août 2020 à 15:58, Felipe Balbi <balbi@kernel.org> a
écrit :
>
> Hi,
>
> Paul Cercueil <paul@crapouillou.net> writes:
>> The 'reg' value was written to a hardware register in
>> ingenic_usb_phy_init(), while not being initialized anywhere.
>
> your patch does a lot more than fix the bug :-)
>
>> Fixes: 2a6c0b82e651 ("USB: PHY: JZ4770: Add support for new Ingenic
>> SoCs.")
>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>> ---
>> drivers/usb/phy/phy-jz4770.c | 28 +++++++++++-----------------
>> 1 file changed, 11 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/usb/phy/phy-jz4770.c
>> b/drivers/usb/phy/phy-jz4770.c
>> index d4ee3cb721ea..58771a8688f2 100644
>> --- a/drivers/usb/phy/phy-jz4770.c
>> +++ b/drivers/usb/phy/phy-jz4770.c
>> @@ -97,7 +97,7 @@ enum ingenic_usb_phy_version {
>> struct ingenic_soc_info {
>> enum ingenic_usb_phy_version version;
>>
>> - void (*usb_phy_init)(struct usb_phy *phy);
>> + u32 (*usb_phy_init)(struct usb_phy *phy);
>
> this is not fixing any bug
>
>> @@ -172,7 +172,8 @@ static int ingenic_usb_phy_init(struct usb_phy
>> *phy)
>> return err;
>> }
>>
>> - priv->soc_info->usb_phy_init(phy);
>> + reg = priv->soc_info->usb_phy_init(phy);
>> + writel(reg, priv->base + REG_USBPCR_OFFSET);
>
> not fixing any bug.
>
> Looking at the code, the bug follows after this line. It would suffice
> to read REG_USBPCR_OFFSET in order to initialize reg. This bug fix
> could
> have been a one liner.
There's no need to re-read a register when you have the value readily
available. It just needs to be returned from the usb_phy_init
callbacks. But yes, it's not a one-liner.
>
>> @@ -195,19 +196,15 @@ static void ingenic_usb_phy_remove(void *phy)
>> usb_remove_phy(phy);
>> }
>>
>> -static void jz4770_usb_phy_init(struct usb_phy *phy)
>> +static u32 jz4770_usb_phy_init(struct usb_phy *phy)
>
> not a bug fix
>
>> {
>> - struct jz4770_phy *priv = phy_to_jz4770_phy(phy);
>> - u32 reg;
>> -
>> - reg = USBPCR_AVLD_REG | USBPCR_COMMONONN | USBPCR_IDPULLUP_ALWAYS
>> |
>> + return USBPCR_AVLD_REG | USBPCR_COMMONONN |
>> USBPCR_IDPULLUP_ALWAYS |
>> USBPCR_COMPDISTUNE_DFT | USBPCR_OTGTUNE_DFT |
>> USBPCR_SQRXTUNE_DFT |
>> USBPCR_TXFSLSTUNE_DFT | USBPCR_TXRISETUNE_DFT |
>> USBPCR_TXVREFTUNE_DFT |
>> USBPCR_POR;
>> - writel(reg, priv->base + REG_USBPCR_OFFSET);
>
> not a bug fix
>
>> }
>>
>> -static void jz4780_usb_phy_init(struct usb_phy *phy)
>> +static u32 jz4780_usb_phy_init(struct usb_phy *phy)
>
> not a bug fix
>
>> @@ -216,11 +213,10 @@ static void jz4780_usb_phy_init(struct
>> usb_phy *phy)
>> USBPCR1_WORD_IF_16BIT;
>> writel(reg, priv->base + REG_USBPCR1_OFFSET);
>>
>> - reg = USBPCR_TXPREEMPHTUNE | USBPCR_COMMONONN | USBPCR_POR;
>> - writel(reg, priv->base + REG_USBPCR_OFFSET);
>> + return USBPCR_TXPREEMPHTUNE | USBPCR_COMMONONN | USBPCR_POR;
>
> not a bug fix
>
>> }
>>
>> -static void x1000_usb_phy_init(struct usb_phy *phy)
>> +static u32 x1000_usb_phy_init(struct usb_phy *phy)
>
> not a bug fix
>
>> {
>> struct jz4770_phy *priv = phy_to_jz4770_phy(phy);
>> u32 reg;
>> @@ -228,13 +224,12 @@ static void x1000_usb_phy_init(struct usb_phy
>> *phy)
>> reg = readl(priv->base + REG_USBPCR1_OFFSET) |
>> USBPCR1_WORD_IF_16BIT;
>> writel(reg, priv->base + REG_USBPCR1_OFFSET);
>>
>> - reg = USBPCR_SQRXTUNE_DCR_20PCT | USBPCR_TXPREEMPHTUNE |
>> + return USBPCR_SQRXTUNE_DCR_20PCT | USBPCR_TXPREEMPHTUNE |
>> USBPCR_TXHSXVTUNE_DCR_15MV | USBPCR_TXVREFTUNE_INC_25PPT |
>> USBPCR_COMMONONN | USBPCR_POR;
>> - writel(reg, priv->base + REG_USBPCR_OFFSET);
>
> not a bug fix
>
>> }
>>
>> -static void x1830_usb_phy_init(struct usb_phy *phy)
>> +static u32 x1830_usb_phy_init(struct usb_phy *phy)
>
> not a bug fix
>
>> {
>> struct jz4770_phy *priv = phy_to_jz4770_phy(phy);
>> u32 reg;
>> @@ -246,9 +241,8 @@ static void x1830_usb_phy_init(struct usb_phy
>> *phy)
>> USBPCR1_DMPD | USBPCR1_DPPD;
>> writel(reg, priv->base + REG_USBPCR1_OFFSET);
>>
>> - reg = USBPCR_IDPULLUP_OTG | USBPCR_VBUSVLDEXT
>> | USBPCR_TXPREEMPHTUNE |
>> + return USBPCR_IDPULLUP_OTG | USBPCR_VBUSVLDEXT |
>> USBPCR_TXPREEMPHTUNE |
>> USBPCR_COMMONONN | USBPCR_POR;
>> - writel(reg, priv->base + REG_USBPCR_OFFSET);
>
> not a bug fix
Well, if you don't like my bug fix, next time wait for my Reviewed-by.
Cheers,
-Paul
next prev parent reply other threads:[~2020-08-27 14:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 12:43 [PATCH 0/1] USB: PHY: JZ4770: Next time, please test it Paul Cercueil
2020-08-27 12:43 ` [PATCH 1/1] USB: PHY: JZ4770: Fix uninitialized value written to HW register Paul Cercueil
2020-08-27 12:58 ` Felipe Balbi
2020-08-27 13:11 ` Paul Cercueil [this message]
2020-08-27 13:25 ` Felipe Balbi
2020-08-27 13:50 ` Paul Cercueil
2020-08-27 14:26 ` Felipe Balbi
2020-08-27 15:35 ` Zhou Yanjie
2020-09-09 10:23 ` Pavel Machek
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=PN4QFQ.KWNBY2ZWQ7XC2@crapouillou.net \
--to=paul@crapouillou.net \
--cc=aric.pzqi@ingenic.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=od@zcrc.me \
--cc=sernia.zhou@foxmail.com \
--cc=zhouyanjie@wanyeetech.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®