pci: pcie_dw_rockchip: Fixed the below compilation error
Subsystems (2)
PATCH 1/3 pci: pcie_dw_rockchip: Fixed the below compilation error
Use the Error values that may be returned by PCI functions Added the error macro from linux/include/linux/pci.h
drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read':drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED'
undeclared (first use in this function)
70 | return PCIBIOS_UNSUPPORTED;
| ^~~~~~~~~~~~~~~~~~~
drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write':
drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED'
undeclared (first use in this function)
90 | return PCIBIOS_UNSUPPORTED;
| ^~~~~~~~~~~~~~~~~~~--- drivers/pci/pcie_dw_common.h | 9 +++++++++ drivers/pci/pcie_dw_rockchip.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/pci/pcie_dw_common.h +9 -0
@@ -90,6 +90,15 @@#define PCIE_MISC_CONTROL_1_OFF 0x8bc#define PCIE_DBI_RO_WR_EN BIT(0) +/* Error values that may be returned by PCI functions */ +#define PCIBIOS_SUCCESSFUL 0x00 +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 +#define PCIBIOS_BAD_VENDOR_ID 0x83 +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 +#define PCIBIOS_SET_FAILED 0x88 +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 +/* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5#define LINK_WAIT_IATU 10000
drivers/pci/pcie_dw_rockchip.c +2 -2
@@ -67,7 +67,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) {if ((uintptr_t )addr & (size -1 )) { *val =0 ; -return PCIBIOS_UNSUPPORTED ; +return PCIBIOS_BAD_REGISTER_NUMBER ; }if (size ==4 ) {
@@ -87,7 +87,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val)static int rk_pcie_write (void __iomem *addr,int size,u32 val) {if ((uintptr_t )addr & (size -1 )) -return PCIBIOS_UNSUPPORTED ; +return PCIBIOS_BAD_REGISTER_NUMBER ;if (size ==4 )writel (val, addr);
Signature · 1 line
2.31.1
PATCH 2/3 pci: pcie_dw_rockchip: Drop the unused variable warning
Drop the unused variable warning below.
drivers/pci/pcie_dw_rockchip.c:161:6: warning: unused variable
'val' [-Wunused-variable]
161 | u32 val;
| ^~~--- drivers/pci/pcie_dw_rockchip.c | 2 -- 1 file changed, 2 deletions(-)
drivers/pci/pcie_dw_rockchip.c +0 -2
@@ -158,8 +158,6 @@ static inline void rk_pcie_writel_apb(struct rk_pcie *rk_pcie, u32 reg,*/ static void rk_pcie_configure (struct rk_pcie *pci,u32 cap_speed) { -u32 val; -dw_pcie_dbi_write_enable (&pci->dw, true); clrsetbits_le32(pci->dw.dbi_base + PCIE_LINK_CAPABILITY,
Signature · 1 line
2.31.1
PATCH 3/3 pci: pcie_dw_rockchip: Use udelay instead of msleep
In reply to Anand MoonUse udelay instead of msleep fix the below warning.
drivers/pci/pcie_dw_rockchip.c:254:3: warning: implicit
declaration of function 'msleep' [-Wimplicit-function-declaration]
--- drivers/pci/pcie_dw_rockchip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/pcie_dw_rockchip.c +4 -4
@@ -249,7 +249,7 @@ static int rk_pcie_link_up(struct rk_pcie *priv, u32 cap_speed)* some wired devices need much more, such as 600ms. * Add a enough delay to cover all cases. */ -msleep (PERST_WAIT_MS ); +udelay (PERST_WAIT_MS );dm_gpio_set_value (&priv->rst_gpio,1 ); }
@@ -271,12 +271,12 @@ static int rk_pcie_link_up(struct rk_pcie *priv, u32 cap_speed)dev_info (priv->dw.dev,"PCIe Linking... LTSSM is 0x%x\n" ,rk_pcie_readl_apb (priv,PCIE_CLIENT_LTSSM_STATUS ));rk_pcie_debug_dump (priv); -msleep (1000 ); +udelay (1000 ); }dev_err (priv->dw.dev,"PCIe-%d Link Fail\n" ,dev_seq (priv->dw.dev));/* Link maybe in Gen switch recovery but we need to wait more 1s */ -msleep (1000 ); +udelay (1000 );return -EIO ; }
@@ -296,7 +296,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) } } -msleep (1000 ); +udelay (1000 ); ret =generic_phy_init (&priv->phy);if (ret) {
Signature · 1 line
2.31.1
PATCH 3/3 pci: pcie_dw_rockchip: Use udelay instead of msleep
Am Mon, Apr 26, 2021 at 01:26:32PM +0000 schrieb Anand Moon:
Quoted 1 line
Use udelay instead of msleep fix the below warning.
You sure that's correct? the m in msleep means milli, while the u in udelay means micro. That's a factor of 1000 of a difference.
Quoted 50 lines
drivers/pci/pcie_dw_rockchip.c:254:3: warning: implicit
declaration of function 'msleep' [-Wimplicit-function-declaration]Cc Neil Armstrong <[email protected]>Cc Kever Yang <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/pci/pcie_dw_rockchip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/pci/pcie_dw_rockchip.c +4
-4@@ -249,7 +249,7 @@ static int rk_pcie_link_up(struct rk_pcie *priv, u32 cap_speed)* some wired devices need much more, such as 600ms. * Add a enough delay to cover all cases. */ -msleep (PERST_WAIT_MS ); +udelay (PERST_WAIT_MS );dm_gpio_set_value (&priv->rst_gpio,1 ); }@@ -271,12 +271,12 @@ static int rk_pcie_link_up(struct rk_pcie *priv, u32 cap_speed)dev_info (priv->dw.dev,"PCIe Linking... LTSSM is 0x%x\n" ,rk_pcie_readl_apb (priv,PCIE_CLIENT_LTSSM_STATUS ));rk_pcie_debug_dump (priv); -msleep (1000 ); +udelay (1000 ); }dev_err (priv->dw.dev,"PCIe-%d Link Fail\n" ,dev_seq (priv->dw.dev));/* Link maybe in Gen switch recovery but we need to wait more 1s */ -msleep (1000 ); +udelay (1000 );return -EIO ; }@@ -296,7 +296,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) } } -msleep (1000 ); +udelay (1000 ); ret =generic_phy_init (&priv->phy);if (ret) {Signature · 1 line
2.31.1
PATCH 1/3 pci: pcie_dw_rockchip: Fixed the below compilation error
In reply to Anand MoonAm Mon, Apr 26, 2021 at 01:26:30PM +0000 schrieb Anand Moon:
Quoted 47 lines
Use the Error values that may be returned by PCI functions Added the error macro from
linux/include/linux/pci.h
drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read':drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED'
undeclared (first use in this function)70 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~ drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' undeclared (first use in this function) 90 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~Cc Neil Armstrong <[email protected]>Cc Kever Yang <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/pci/pcie_dw_common.h | 9 +++++++++ drivers/pci/pcie_dw_rockchip.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-)drivers/pci/pcie_dw_common.h +9
-0@@ -90,6 +90,15 @@#define PCIE_MISC_CONTROL_1_OFF 0x8bc#define PCIE_DBI_RO_WR_EN BIT(0) +/* Error values that may be returned by PCI functions */ +#define PCIBIOS_SUCCESSFUL 0x00 +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 +#define PCIBIOS_BAD_VENDOR_ID 0x83 +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 +#define PCIBIOS_SET_FAILED 0x88 +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 +/* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5#define LINK_WAIT_IATU 10000drivers/pci/pcie_dw_rockchip.c +0
-0
drivers/pci/pcie_dw_rockchip.c static int rk_pcie_read(void __iomem *addr, int size, u32 *val) · line 70
Quoted 5 lines
drivers/pci/pcie_dw_rockchip.c +1
-1@@ -67,7 +67,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) {if ((uintptr_t )addr & (size -1 )) { *val =0 ; -return PCIBIOS_UNSUPPORTED ; +return PCIBIOS_BAD_REGISTER_NUMBER ;
Since this function seems to return normal error code, why not use -EINVAL? Or even better -EOPNOTSUP? The callers only check for != 0 anyway.
Quoted 15 lines
drivers/pci/pcie_dw_rockchip.c +1
-1}if (size ==4 ) {@@ -87,7 +87,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val)static int rk_pcie_write (void __iomem *addr,int size,u32 val) {if ((uintptr_t )addr & (size -1 )) -return PCIBIOS_UNSUPPORTED ; +return PCIBIOS_BAD_REGISTER_NUMBER ;if (size ==4 )writel (val, addr);Signature · 1 line
2.31.1
PATCH 1/3 pci: pcie_dw_rockchip: Fixed the below compilation error
Hi Patrick,
Quoted 50 lines · Patrick Wildt
Am Mon, Apr 26, 2021 at 01:26:30PM +0000 schrieb Anand Moon:
Quoted 48 lines
Use the Error values that may be returned by PCI functions Added the error macro from
linux/include/linux/pci.h
drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read':drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED'
undeclared (first use in this function)70 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~ drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' undeclared (first use in this function) 90 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~Cc Neil Armstrong <[email protected]>Cc Kever Yang <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/pci/pcie_dw_common.h | 9 +++++++++ drivers/pci/pcie_dw_rockchip.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-)drivers/pci/pcie_dw_common.h +9
-0@@ -90,6 +90,15 @@#define PCIE_MISC_CONTROL_1_OFF 0x8bc#define PCIE_DBI_RO_WR_EN BIT(0) +/* Error values that may be returned by PCI functions */ +#define PCIBIOS_SUCCESSFUL 0x00 +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 +#define PCIBIOS_BAD_VENDOR_ID 0x83 +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 +#define PCIBIOS_SET_FAILED 0x88 +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 +/* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5#define LINK_WAIT_IATU 10000drivers/pci/pcie_dw_rockchip.c +0
-0@@ -67,7 +67,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) {
Quoted 9 lines
drivers/pci/pcie_dw_rockchip.c static int rk_pcie_read(void __iomem *addr, int size, u32 *val) · line 70
Quoted 4 lines
drivers/pci/pcie_dw_rockchip.c +1
-1if ((uintptr_t )addr & (size -1 )) { *val =0 ; -return PCIBIOS_UNSUPPORTED ; +return PCIBIOS_BAD_REGISTER_NUMBER ;Since this function seems to return normal error code, why not use
-EINVAL? Or even better-EOPNOTSUP? The callers only check for != 0 anyway.
Thanks for your review comments.-EOPNOTSUPP It seems to be the correct return code over here.
-Anand
PATCH 3/3 pci: pcie_dw_rockchip: Use udelay instead of msleep
In reply to Patrick Wildthi Patrick,
Quoted 7 lines · Patrick Wildt
Am Mon, Apr 26, 2021 at 01:26:32PM +0000 schrieb Anand Moon:
Quoted 1 line
Use udelay instead of msleep fix the below warning.
You sure that's correct? the m in msleep means milli, while the u in udelay means micro. That's a factor of 1000 of a difference.
Thanks for your review comments.
Most of the u-boot driver prefers udelay and usleep_range internally calls udelay.
I don't have the HW to test and verify.
-Anand
PATCH 3/3 pci: pcie_dw_rockchip: Use udelay instead of msleep
Am Tue, Apr 27, 2021 at 11:11:19AM +0530 schrieb Anand Moon:
Quoted 10 lines
hi Patrick,
Quoted 7 lines · Patrick Wildt
Am Mon, Apr 26, 2021 at 01:26:32PM +0000 schrieb Anand Moon:
Quoted 1 line
Use udelay instead of msleep fix the below warning.
You sure that's correct? the m in msleep means milli, while the u in udelay means micro. That's a factor of 1000 of a difference.
Quoted 8 lines
Thanks for your review comments.
Most of the u-boot driver prefers udelay and
usleep_rangeinternally calls udelay.I don't have the HW to test and verify.
-Anand
Sure, I'm not complaining about that. My point is that if you pass e. g. 8 milliseconds to a function that takes microseconds, you need to add the factor.
Not good: msleep(1000) -> udelay(1000)
Much better: msleep(1000) -> udelay(1000 * 1000)
Which also means that you either have to rename PERST_WAIT_MS and change its value, or do udelay(PERST_WAIT_MS * 1000)
PATCH 3/3 pci: pcie_dw_rockchip: Use udelay instead of msleep
Hi Patrick,
Quoted 25 lines · Patrick Wildt
Am Tue, Apr 27, 2021 at 11:11:19AM +0530 schrieb Anand Moon:
Quoted 10 lines
hi Patrick,
Quoted 7 lines · Patrick Wildt
Am Mon, Apr 26, 2021 at 01:26:32PM +0000 schrieb Anand Moon:
Quoted 1 line
Use udelay instead of msleep fix the below warning.
You sure that's correct? the m in msleep means milli, while the u in udelay means micro. That's a factor of 1000 of a difference.
Quoted 8 lines
Thanks for your review comments.
Most of the u-boot driver prefers udelay and
usleep_rangeinternally calls udelay.I don't have the HW to test and verify.
-Anand
Sure, I'm not complaining about that. My point is that if you pass e. g. 8 milliseconds to a function that takes microseconds, you need to add the factor.
Quoted 5 lines
Not good: msleep(1000) -> udelay(1000)
Much better: msleep(1000) ->udelay(1000 * 1000)Which also means that you either have to rename
PERST_WAIT_MSand change its value, or doudelay(PERST_WAIT_MS * 1000)
Thanks for this tip, can we use mdelay as sugged above. .
static inline void mdelay(unsigned long msec)
{
udelay(1000 * msec);
}Thanks
-Anand
Re: [PATCH 3/3] pci: pcie_dw_rockchip: Use udelay instead of msleep
In reply to Anand MoonHi Anand,
It's OK to update the API, but please keep the delay duration.
Thanks,
- Kever
Quoted 49 lines · Anand Moon
Use udelay instead of msleep fix the below warning.
drivers/pci/pcie_dw_rockchip.c:254:3: warning: implicit
declaration of function 'msleep' [-Wimplicit-function-declaration]Cc Neil Armstrong <[email protected]>Cc Kever Yang <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/pci/pcie_dw_rockchip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/pci/pcie_dw_rockchip.c +4
-4@@ -249,7 +249,7 @@ static int rk_pcie_link_up(struct rk_pcie *priv, u32 cap_speed)* some wired devices need much more, such as 600ms. * Add a enough delay to cover all cases. */ -msleep (PERST_WAIT_MS ); +udelay (PERST_WAIT_MS );dm_gpio_set_value (&priv->rst_gpio,1 ); }@@ -271,12 +271,12 @@ static int rk_pcie_link_up(struct rk_pcie *priv, u32 cap_speed)dev_info (priv->dw.dev,"PCIe Linking... LTSSM is 0x%x\n" ,rk_pcie_readl_apb (priv,PCIE_CLIENT_LTSSM_STATUS ));rk_pcie_debug_dump (priv); -msleep (1000 ); +udelay (1000 ); }dev_err (priv->dw.dev,"PCIe-%d Link Fail\n" ,dev_seq (priv->dw.dev));/* Link maybe in Gen switch recovery but we need to wait more 1s */ -msleep (1000 ); +udelay (1000 );return -EIO ; }@@ -296,7 +296,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) } } -msleep (1000 ); +udelay (1000 ); ret =generic_phy_init (&priv->phy);if (ret) {
Quoted 14 lines · Anand Moon
Use the Error values that may be returned by PCI functions Added the error macro from
linux/include/linux/pci.h
drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read':drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED'undeclared (first use in this function) 70 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~ drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' undeclared (first use in this function) 90 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~
Quoted 3 lines
Cc Neil Armstrong <[email protected]>Cc Kever Yang <[email protected]>Signed-off-by Anand Moon <[email protected]>
Thanks,
- Kever
Quoted 47 lines
--- drivers/pci/pcie_dw_common.h | 9 +++++++++ drivers/pci/pcie_dw_rockchip.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-)drivers/pci/pcie_dw_common.h +9
-0@@ -90,6 +90,15 @@#define PCIE_MISC_CONTROL_1_OFF 0x8bc#define PCIE_DBI_RO_WR_EN BIT(0) +/* Error values that may be returned by PCI functions */ +#define PCIBIOS_SUCCESSFUL 0x00 +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 +#define PCIBIOS_BAD_VENDOR_ID 0x83 +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 +#define PCIBIOS_SET_FAILED 0x88 +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 +/* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5#define LINK_WAIT_IATU 10000drivers/pci/pcie_dw_rockchip.c +2
-2@@ -67,7 +67,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val) {if ((uintptr_t )addr & (size -1 )) { *val =0 ; -return PCIBIOS_UNSUPPORTED ; +return PCIBIOS_BAD_REGISTER_NUMBER ; }if (size ==4 ) {@@ -87,7 +87,7 @@ static int rk_pcie_read(void __iomem *addr, int size, u32 *val)static int rk_pcie_write (void __iomem *addr,int size,u32 val) {if ((uintptr_t )addr & (size -1 )) -return PCIBIOS_UNSUPPORTED ; +return PCIBIOS_BAD_REGISTER_NUMBER ;if (size ==4 )writel (val, addr);
Re: [PATCH 2/3] pci: pcie_dw_rockchip: Drop the unused variable warning
In reply to Anand MoonQuoted 10 lines · Anand Moon
Drop the unused variable warning below.
drivers/pci/pcie_dw_rockchip.c:161:6: warning: unused variable
'val' [-Wunused-variable]161 | u32 val; | ^~~Cc Neil Armstrong <[email protected]>Cc Kever Yang <[email protected]>Signed-off-by Anand Moon <[email protected]>
Thanks,
- Kever
Quoted 17 lines
--- drivers/pci/pcie_dw_rockchip.c | 2 -- 1 file changed, 2 deletions(-)drivers/pci/pcie_dw_rockchip.c +0
-2@@ -158,8 +158,6 @@ static inline void rk_pcie_writel_apb(struct rk_pcie *rk_pcie, u32 reg,*/ static void rk_pcie_configure (struct rk_pcie *pci,u32 cap_speed) { -u32 val; -dw_pcie_dbi_write_enable (&pci->dw, true); clrsetbits_le32(pci->dw.dbi_base + PCIE_LINK_CAPABILITY,
H Kever,
Quoted 17 lines · Kever Yang
Quoted 14 lines · Anand Moon
Use the Error values that may be returned by PCI functions Added the error macro from
linux/include/linux/pci.h
drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_read':drivers/pci/pcie_dw_rockchip.c:70:10: error: 'PCIBIOS_UNSUPPORTED'undeclared (first use in this function) 70 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~ drivers/pci/pcie_dw_rockchip.c: In function 'rk_pcie_write': drivers/pci/pcie_dw_rockchip.c:90:10: error: 'PCIBIOS_UNSUPPORTED' undeclared (first use in this function) 90 | return PCIBIOS_UNSUPPORTED; | ^~~~~~~~~~~~~~~~~~~
Quoted 7 lines
Quoted 3 lines
Cc Neil Armstrong <[email protected]>Cc Kever Yang <[email protected]>Signed-off-by Anand Moon <[email protected]>Reviewed-by Kever Yang <[email protected]>
Oops, I forgot to send the revised version of these patches.
Quoted 3 lines
Thanks,
- Kever