net: ravb: Fix NULL pointer access
PATCH 1/1 net: ravb: Fix NULL pointer access
Some phy's like rtl8211e do not support writeext() callback. Add a check to avoid null pointer access before calling writeext() callback.
--- drivers/net/ravb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ravb.c +2 -1
@@ -438,7 +438,8 @@ static int ravb_config(struct udevice *dev)writel (mask, eth->iobase +RAVB_REG_ECMR ); - phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 ); +if (phy->drv->writeext) + phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 );return 0 ; }
Signature · 1 line
2.17.1
PATCH 1/1 net: ravb: Fix NULL pointer access
Quoted 15 lines · Biju Das
Some phy's like rtl8211e do not support
writeext()callback. Add a check to avoid null pointer access before callingwriteext()callback.Signed-off-by Biju Das <[email protected]>Reviewed-by Lad Prabhakar <[email protected]>--- drivers/net/ravb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ravb.c +0
-0
drivers/net/ravb.c static int ravb_config(struct udevice *dev) · line 445
Quoted 9 lines
drivers/net/ravb.c +2
-1@@ -438,7 +438,8 @@ static int ravb_config(struct udevice *dev)writel (mask, eth->iobase +RAVB_REG_ECMR ); - phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 ); +if (phy->drv->writeext) + phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 );return 0 ; }
Make sense.
Thanks,
Michal
PATCH 1/1 net: ravb: Fix NULL pointer access
In reply to Biju DasOn 9/15/20 4:10 PM, Biju Das wrote:
[...]
drivers/net/ravb.c static int ravb_config(struct udevice *dev) · line 442
Quoted 8 lines
+++
b/drivers/net/ravb.cdrivers/net/ravb.c +2
-1@@ -438,7 +438,8 @@ static int ravb_config(struct udevice *dev)writel (mask, eth->iobase +RAVB_REG_ECMR ); - phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 ); +if (phy->drv->writeext) + phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 );
Shouldn't we rather move this into the PHY driver altogether ? I _think_ this might be specific to some Micrel PHY.
PATCH 1/1 net: ravb: Fix NULL pointer access
Hi Marek,
Thanks for the review.
Quoted 7 lines
Subject: Re: [PATCH] net: ravb: Fix NULL pointer access
On 9/15/20 4:10 PM, Biju Das wrote:
[...]Quoted 3 lines
+++
b/drivers/net/ravb.c(quoted diff) +0
-0@@ -438,7 +438,8 @@ static int ravb_config(struct udevice *dev)
Quoted 7 lines
drivers/net/ravb.c static int ravb_config(struct udevice *dev) · line 442
Quoted 5 lines
drivers/net/ravb.c +2
-1writel (mask, eth->iobase +RAVB_REG_ECMR ); -phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 ); +if (phy->drv->writeext) +phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 );Shouldn't we rather move this into the PHY driver altogether ?
If I fix, the phydriver with empty function, compiler will complain about unused parameter right? What about other phy's which doesn't have this callback.
Quoted 1 line
I _think_ this might be specific to some Micrel PHY.
As mentioned in the commit message, it is seen with Realtek phy(rtl8211e) and crash seen on Hihope RZ/G2M board.
Thanks and regards,
biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/1 net: ravb: Fix NULL pointer access
Quoted 1 line · Biju Das
Hi Marek,
Hi,
[...]
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
+++
b/drivers/net/ravb.cdrivers/net/ravb.c +0
-0@@ -438,7 +438,8 @@ static int ravb_config(struct udevice *dev)writel (mask, eth->iobase +RAVB_REG_ECMR );
Quoted 8 lines
Quoted 5 lines
drivers/net/ravb.c static int ravb_config(struct udevice *dev) · line 442
Quoted 3 lines
drivers/net/ravb.c +2
-1-phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 ); +if (phy->drv->writeext) +phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 );Shouldn't we rather move this into the PHY driver altogether ?
If I fix, the phydriver with empty function, compiler will complain about unused parameter right? What about other phy's which doesn't have this callback.
I mean, should we not move this entire code which configures something in a Micrel PHY, and is specific to Micrel PHY, into the Micrel PHY driver and remove the whole call of writeext from this ethernet driver ?
Quoted 2 lines
Quoted 1 line
I _think_ this might be specific to some Micrel PHY.
As mentioned in the commit message, it is seen with Realtek phy(rtl8211e) and crash seen on Hihope RZ/G2M board.
Right, because that writeext seems to be micrel-phy specific.
PATCH 1/1 net: ravb: Fix NULL pointer access
Hi Marek,
Thanks for the feedback.
Quoted 20 lines
Subject: Re: [PATCH] net: ravb: Fix NULL pointer access
Quoted 1 line · Biju Das
Hi Marek,
Hi,
[...]
Quoted 11 lines
Quoted 10 lines
drivers/net/ravb.c static int ravb_config(struct udevice *dev) · line 442
Quoted 8 lines
+++
b/drivers/net/ravb.cdrivers/net/ravb.c +2
-1@@ -438,7 +438,8 @@ static int ravb_config(struct udevice *dev)writel (mask, eth->iobase +RAVB_REG_ECMR ); -phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 ); +if (phy->drv->writeext) +phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 );Shouldn't we rather move this into the PHY driver altogether ?
Quoted 7 lines
Quoted 1 line
If I fix, the phydriver with empty function, compiler will complain about
unused parameter right?
Quoted 1 line
What about other phy's which doesn't have this callback.
I mean, should we not move this entire code which configures something in a Micrel PHY, and is specific to Micrel PHY, into the Micrel PHY driver and remove the whole call of writeext from this ethernet driver ?
Ok , this function is invoked during data transfer. We could remove this function and test on all RCar boards to see any issues present or not? By looking at [1], only this driver is using writeext. [1]https://elixir.bootlin.com/u-boot/v2020.10-rc4/A/ident/writeext
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/1 net: ravb: Fix NULL pointer access
On 9/18/20 5:26 PM, Biju Das wrote:
[...]
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 10 lines
drivers/net/ravb.c static int ravb_config(struct udevice *dev) · line 442
Quoted 8 lines
+++
b/drivers/net/ravb.cdrivers/net/ravb.c +2
-1@@ -438,7 +438,8 @@ static int ravb_config(struct udevice *dev)writel (mask, eth->iobase +RAVB_REG_ECMR ); -phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 ); +if (phy->drv->writeext) +phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 );Shouldn't we rather move this into the PHY driver altogether ?
If I fix, the phydriver with empty function, compiler will complain about
Quoted 8 lines
Quoted 6 lines
unused parameter right?
Quoted 1 line
What about other phy's which doesn't have this callback.
I mean, should we not move this entire code which configures something in a Micrel PHY, and is specific to Micrel PHY, into the Micrel PHY driver and remove the whole call of writeext from this ethernet driver ?
Ok , this function is invoked during data transfer.
The ravb_config() is invoked when starting the interface, see ravb_start(), it is not repeatedly called during data transfer.
Quoted 1 line
We could remove this function and test on all RCar boards to see any issues present or not?
No, because calling the writeext configures something in the Micrel KSZ90x1 PHY, and by removing it, I suspect the Micrel PHY would stop working.
Quoted 2 lines
By looking at [1], only this driver is using writeext. [1]https://elixir.bootlin.com/u-boot/v2020.10-rc4/A/ident/writeext
git grep indicates a couple more sites where the writeext is called. But look into the KSZ9031 datasheet, that particular writeext call seems to be setting up RGMII Clock Pad Skew (MMD Address 2, Register 8), and I think there is a matching DT binding to set those up too, rxc-skew-ps and txc-skew-ps I think.
So I think if you set those two DT properties in rcar2/3 DTs accordingly (and that might already be the case, but please double-check), you can even drop this entire writeext altogether.
[...]
PATCH 1/1 net: ravb: Fix NULL pointer access
Hi Marek,
Thanks for the feedback.
Quoted 24 lines
Subject: Re: [PATCH] net: ravb: Fix NULL pointer access
On 9/18/20 5:26 PM, Biju Das wrote:
[...]Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
drivers/net/ravb.c static int ravb_config(struct udevice *dev) · line 442
Quoted 8 lines
+++
b/drivers/net/ravb.cdrivers/net/ravb.c +2
-1@@ -438,7 +438,8 @@ static int ravb_config(struct udevice *dev)writel (mask, eth->iobase +RAVB_REG_ECMR ); -phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 ); +if (phy->drv->writeext) +phy->drv->writeext (phy,-1 ,0x02 ,0x08 , (0x0f <<5 ) |0x19 );Shouldn't we rather move this into the PHY driver altogether ?
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
If I fix, the phydriver with empty function, compiler will complain about
unused parameter right?
Quoted 1 line
What about other phy's which doesn't have this callback.
I mean, should we not move this entire code which configures something in a Micrel PHY, and is specific to Micrel PHY, into the Micrel PHY driver and remove the whole call of writeext from this
Quoted 6 lines
ethernet driver ?
Quoted 2 lines
Ok , this function is invoked during data transfer.
The
ravb_config()is invoked when starting the interface, seeravb_start(), it is not repeatedly called during data transfer.
Yep you are correct , it will be called during starting of the interface. I have seen the crash when I started doing tftp or ping, which in turn calls ravb_start.
Quoted 6 lines
Quoted 1 line
We could remove this function and test on all RCar boards to see any issues
present or not?
No, because calling the writeext configures something in the Micrel KSZ90x1 PHY, and by removing it, I suspect the Micrel PHY would stop working.
I agree, otherwise it will use default values which may cause issues.
Quoted 8 lines
Quoted 2 lines
By looking at [1], only this driver is using writeext. [1]https://elixir.bootlin.com/u-boot/v2020.10-rc4/A/ident/writeext
git grep indicates a couple more sites where the writeext is called. But look into the KSZ9031 datasheet, that particular writeext call seems to be setting up RGMII Clock Pad Skew (MMD Address 2, Register 8), and I think there is a matching DT binding to set those up too, rxc-skew-ps and txc- skew-ps I think.
Thanks for the pointers. I checked the configs[2] which uses renesas ravb driver and found that we are defining only rxc-skew-ps in all dts.
since CONFIG DM_ETH is defined it is already picking the value corresponding to "rxc-skew-ps".
For txc-skew-ps anyway the value is default one. So we don't care.
Quoted 3 lines
So I think if you set those two DT properties in rcar2/3 DTs accordingly (and that might already be the case, but please double-check), you can even drop this entire writeext altogether.
I did a grep and the below configs enables renesas ravb driver .Only Gen3 uses renesas ravb driver and all of them have "rxc-skew-ps" in Devicetree. So I agree with you, it is safe to remove writephyext. I will post V2, removing this
[2] u-boot/configs/rcar3_ulcb_defconfig:CONFIG_RENESAS_RAVB=y u-boot/configs/r8a77990_ebisu_defconfig:CONFIG_RENESAS_RAVB=y u-boot/configs/r8a774a1_beacon_defconfig:CONFIG_RENESAS_RAVB=y u-boot/configs/hihope_rzg2_defconfig:CONFIG_RENESAS_RAVB=y u-boot/configs/r8a77995_draak_defconfig:CONFIG_RENESAS_RAVB=y u-boot/configs/r8a77970_eagle_defconfig:CONFIG_RENESAS_RAVB=y u-boot/configs/rcar3_salvator-x_defconfig:CONFIG_RENESAS_RAVB=y
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/1 net: ravb: Fix NULL pointer access
On 9/19/20 1:14 PM, Biju Das wrote:
[...]
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
By looking at [1], only this driver is using writeext. [1]https://elixir.bootlin.com/u-boot/v2020.10-rc4/A/ident/writeext
git grep indicates a couple more sites where the writeext is called. But look into the KSZ9031 datasheet, that particular writeext call seems to be setting up RGMII Clock Pad Skew (MMD Address 2, Register 8), and I think there is a matching DT binding to set those up too, rxc-skew-ps and txc- skew-ps I think.
Quoted 6 lines
Thanks for the pointers. I checked the configs[2] which uses renesas ravb driver and found that we are defining only rxc-skew-ps in all dts.
since CONFIG
DM_ETHis defined it is already picking the value corresponding to "rxc-skew-ps".For txc-skew-ps anyway the value is default one. So we don't care.
Are you sure (0xf << 5) | 0x19 is the same as the default value of the clock pad skew register ?
[...]
PATCH 1/1 net: ravb: Fix NULL pointer access
Hi Marek,
Thanks for the feedback.
Quoted 16 lines
Subject: Re: [PATCH] net: ravb: Fix NULL pointer access
On 9/19/20 1:14 PM, Biju Das wrote:
[...]Quoted 12 lines
Quoted 8 lines
Quoted 2 lines
By looking at [1], only this driver is using writeext. [1]https://elixir.bootlin.com/u-boot/v2020.10-rc4/A/ident/writeext
git grep indicates a couple more sites where the writeext is called. But look into the KSZ9031 datasheet, that particular writeext call seems to be setting up RGMII Clock Pad Skew (MMD Address 2, Register 8), and I think there is a matching DT binding to set those up too, rxc-skew-ps and txc- skew-ps I think.
Thanks for the pointers. I checked the configs[2] which uses renesas ravb driver and found that we are defining only rxc-skew-ps in all dts.
Quoted 7 lines
Quoted 1 line
since CONFIG
DM_ETHis defined it is already picking the valuecorresponding to "rxc-skew-ps".
Quoted 2 lines
For txc-skew-ps anyway the value is default one. So we don't care.
Are you sure (
0xf<< 5) |0x19is the same as the default value of the clock pad skew register ?
No.
As per [1] & [2], the default values for this registers are 0xf
[1] https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/drivers/net/phy/micrel_ksz90x1.c#L105
[2] http://ww1.microchip.com/downloads/en/devicedoc/00002117f.pdf
if we remove writephyext, by looking the code at [1], rxc-skew-ps will be taken from the device tree[3] and "txc-skew-pc" will be the default value(0xf). [3]https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/arch/arm/dts/salvator-common.dtsi#L331
I will check this and let you know the results after checking on RCar board. Unfortunately currently I don't have RCar board.
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/1 net: ravb: Fix NULL pointer access
On 9/19/20 8:14 PM, Biju Das wrote:
Hi,
[...]
Quoted 15 lines
Quoted 15 lines
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
By looking at [1], only this driver is using writeext. [1]https://elixir.bootlin.com/u-boot/v2020.10-rc4/A/ident/writeext
git grep indicates a couple more sites where the writeext is called. But look into the KSZ9031 datasheet, that particular writeext call seems to be setting up RGMII Clock Pad Skew (MMD Address 2, Register 8), and I think there is a matching DT binding to set those up too, rxc-skew-ps and txc- skew-ps I think.
Quoted 4 lines
Thanks for the pointers. I checked the configs[2] which uses renesas ravb driver and found that we are defining only rxc-skew-ps in all dts.
since CONFIG
DM_ETHis defined it is already picking the valuecorresponding to "rxc-skew-ps".
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
For txc-skew-ps anyway the value is default one. So we don't care.
Are you sure (
0xf<< 5) |0x19is the same as the default value of the clock pad skew register ?No.
As per [1] & [2], the default values for this registers are0xf
So the combined value of the MMD 2-8 register is (0xf << 5) | (0xf << 0) , right.
Quoted 5 lines
[1] https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/drivers/net/phy/micrel_ksz90x1.c#L105
[2] http://ww1.microchip.com/downloads/en/devicedoc/00002117f.pdfif we remove writephyext, by looking the code at [1], rxc-skew-ps will be taken from the device tree[3] and "txc-skew-pc" will be the default value(0xf). [3]https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/arch/arm/dts/salvator-common.dtsi#L331
So you want to check whether each RCar3 DT contains a PHY node and that PHY node has rxc-skew-ps and txc-skew-ps , which combined then results into a register value (0xf << 5) | (0x19 << 0) .
Quoted 1 line
I will check this and let you know the results after checking on RCar board. Unfortunately currently I don't have RCar board.
It's enough to just check the DTs and verify that they set the matching correct values of rxc-skew-ps/txc-skew-ps . I can test it on the real hardware.
If you want, you can add the txc-skew-ps into the Linux R-Car3 DTs too.
btw unrelated, you seem to have rxc-skew-ps in your hihope-rzg2-ex.dtsi, but I think you don't have KSZ9031 PHY, so maybe you want to remove it form your DT too.
Thanks
PATCH 1/1 net: ravb: Fix NULL pointer access
Hi Marek,
Thanks for the feedback.
Quoted 41 lines
Subject: Re: [PATCH] net: ravb: Fix NULL pointer access
On 9/19/20 8:14 PM, Biju Das wrote:
Hi,
[...]
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines
By looking at [1], only this driver is using writeext. [1]https://elixir.bootlin.com/u-boot/v2020.10-rc4/A/ident/writeext
git grep indicates a couple more sites where the writeext is called. But look into the KSZ9031 datasheet, that particular writeext call seems to be setting up RGMII Clock Pad Skew (MMD Address 2, Register 8), and I think there is a matching DT binding to set those up too, rxc-skew-ps and txc- skew-ps I think.
Thanks for the pointers. I checked the configs[2] which uses renesas ravb driver and found that we are defining only rxc-skew-ps in
all dts.
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines
since CONFIG
DM_ETHis defined it is already picking the valuecorresponding to "rxc-skew-ps".
Quoted 2 lines
For txc-skew-ps anyway the value is default one. So we don't care.
Are you sure (
0xf<< 5) |0x19is the same as the default value of the clock pad skew register ?No.
As per [1] & [2], the default values for this registers are0xfSo the combined value of the MMD 2-8 register is (
0xf<< 5) | (0xf<< 0) , right.Quoted 6 lines
[1]
https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/drivers/net/phy/
micrel_ksz90x1.c#L105 [2]
http://ww1.microchip.com/downloads/en/devicedoc/00002117f.pdfif we remove writephyext, by looking the code at [1], rxc-skew-ps will be
Quoted 8 lines
taken from the device tree[3] and "txc-skew-pc" will be the default value(0xf).
Quoted 2 lines
[3]https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/arch/arm/dts/ salvator-common.dtsi#L331
So you want to check whether each RCar3 DT contains a PHY node and that PHY node has rxc-skew-ps and txc-skew-ps , which combined then results into a register value (
0xf<< 5) | (0x19<< 0) .
rxc-skew-ps set in DTS is 1500. 1 step is 60 ps, so 1500/60 = 25 which is 0x19 and this value will be overridden and stored in ofcfg->grp's val[0].
Quoted 5 lines
Quoted 1 line
I will check this and let you know the results after checking on RCar board.
Unfortunately currently I don't have RCar board.
It's enough to just check the DTs and verify that they set the matching correct values of rxc-skew-ps/txc-skew-ps . I can test it on the real hardware.
Yes, that way we can make sure the mapping operation is correct for this phy. 1500 in dts after mapping operation should override ofcfg->grp's val[0] with 0x19.
Quoted 1 line
If you want, you can add the txc-skew-ps into the Linux R-Car3 DTs too.
We don't need to set txc-skew-ps in dts, since it is same as default value and is filled in ofcfg->grp's val[1]. We can avoid unnecessary mapping operations by not specifying in device tree, for default values.
Quoted 3 lines
btw unrelated, you seem to have rxc-skew-ps in your
hihope-rzg2-ex.dtsi, but I think you don't have KSZ9031 PHY, so maybe you want to remove it form your DT too.
OK. Thanks for reporting this. Will fix this in kernel as well as here.
Cheers,
Biju
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
PATCH 1/1 net: ravb: Fix NULL pointer access
On 9/20/20 9:34 AM, Biju Das wrote:
Hi,
[...]
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
if we remove writephyext, by looking the code at [1], rxc-skew-ps will be
taken from the device tree[3] and "txc-skew-pc" will be the default value(0xf).
Quoted 2 lines
[3]https://elixir.bootlin.com/u-boot/v2020.10-rc4/source/arch/arm/dts/ salvator-common.dtsi#L331
So you want to check whether each RCar3 DT contains a PHY node and that PHY node has rxc-skew-ps and txc-skew-ps , which combined then results into a register value (
0xf<< 5) | (0x19<< 0) .rxc-skew-ps set in DTS is 1500. 1 step is 60 ps, so 1500/60 = 25 which is
0x19and this value will be overridden and stored in ofcfg->grp's val[0].
OK, good, thanks.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
I will check this and let you know the results after checking on RCar board.
Unfortunately currently I don't have RCar board.
It's enough to just check the DTs and verify that they set the matching correct values of rxc-skew-ps/txc-skew-ps . I can test it on the real hardware.
Quoted 7 lines
Yes, that way we can make sure the mapping operation is correct for this phy. 1500 in dts after mapping operation should override ofcfg->grp's val[0] with
0x19.Quoted 1 line
If you want, you can add the txc-skew-ps into the Linux R-Car3 DTs too.
We don't need to set txc-skew-ps in dts, since it is same as default value and is filled in ofcfg->grp's val[1]. We can avoid unnecessary mapping operations by not specifying in device tree, for default values.
Hopefully the default setting will not change in some new revision of the PHY then.