* [PATCH 0/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform
@ 2021-01-12 10:06 Zhen Lei
2021-01-12 10:06 ` [PATCH 1/1] " Zhen Lei
2021-01-12 12:47 ` [PATCH 0/1] " Mark Brown
0 siblings, 2 replies; 5+ messages in thread
From: Zhen Lei @ 2021-01-12 10:06 UTC (permalink / raw)
To: Mark Brown, linux-spi, linux-kernel; +Cc: Zhen Lei, Yanteng Si, Pratyush Yadav
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="y", Size: 1870 bytes --]
This patch is based on the latest linux-next. So the Fixes commit-id
maybe changed when it merged int v5.12-rc1. For details about the problem
analysis, see the patch description. The auxiliary information is listed here.
1) the type of size_t on 32-bit and 64-bit platforms
include/uapi/asm-generic/posix_types.h:
typedef unsigned long __kernel_ulong_t;
#if __BITS_PER_LONG != 64
typedef unsigned int __kernel_size_t;
#else
typedef __kernel_ulong_t __kernel_size_t;
#endif
include/linux/types.h:
typedef __kernel_size_t size_t;
2) The compilation warning information on arm64:
In file included from ./include/linux/kernel.h:14,
from ./include/linux/clk.h:13,
from drivers/spi/spi-cadence-quadspi.c:9:
drivers/spi/spi-cadence-quadspi.c: In function ‘cqspi_direct_read_execute’:
./include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
18 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^~
./include/linux/minmax.h:32:4: note: in expansion of macro ‘__typecheck’
32 | (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~
./include/linux/minmax.h:42:24: note: in expansion of macro ‘__safe_cmp’
42 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
./include/linux/minmax.h:58:19: note: in expansion of macro ‘__careful_cmp’
58 | #define max(x, y) __careful_cmp(x, y, >)
| ^~~~~~~~~~~~~
drivers/spi/spi-cadence-quadspi.c:1153:24: note: in expansion of macro ‘max’
1153 | msecs_to_jiffies(max(len, 500U)))) {
| ^~~
Zhen Lei (1):
spi: cadence-quadspi: Fix a compilation warning for 64-bit platform
drivers/spi/spi-cadence-quadspi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
1.8.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform
2021-01-12 10:06 [PATCH 0/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform Zhen Lei
@ 2021-01-12 10:06 ` Zhen Lei
2021-01-12 10:16 ` Pratyush Yadav
2021-01-12 12:47 ` [PATCH 0/1] " Mark Brown
1 sibling, 1 reply; 5+ messages in thread
From: Zhen Lei @ 2021-01-12 10:06 UTC (permalink / raw)
To: Mark Brown, linux-spi, linux-kernel; +Cc: Zhen Lei, Yanteng Si, Pratyush Yadav
The __typecheck() requires that the two arguments of max() must be of the
same type. For the current max(), the type of the first parameter "len" is
size_t. But the type of size_t is not fixed, it's "unsigned int" on 32-bit
platforms and "unsigned long" on 64-bit platforms. So both the suffix "U"
and "UL" are not appropriate for the second constant parameter. Therefore,
forcible type conversion is used.
Fixes: 8728a81b8f10 ("spi: Fix distinct pointer types warning for ARCH=mips")
Fixes: 0920a32cf6f2 ("spi: cadence-quadspi: Wait at least 500 ms for direct reads")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/spi/spi-cadence-quadspi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 576610ba11184c6..eb40b8d46b56b0c 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
dma_async_issue_pending(cqspi->rx_chan);
if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
- msecs_to_jiffies(max(len, 500U)))) {
+ msecs_to_jiffies(max_t(size_t, len, 500)))) {
dmaengine_terminate_sync(cqspi->rx_chan);
dev_err(dev, "DMA wait_for_completion_timeout\n");
ret = -ETIMEDOUT;
--
1.8.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform
2021-01-12 10:06 ` [PATCH 1/1] " Zhen Lei
@ 2021-01-12 10:16 ` Pratyush Yadav
2021-01-12 11:23 ` Leizhen (ThunderTown)
0 siblings, 1 reply; 5+ messages in thread
From: Pratyush Yadav @ 2021-01-12 10:16 UTC (permalink / raw)
To: Zhen Lei; +Cc: Mark Brown, linux-spi, linux-kernel, Yanteng Si
Hi Zhen,
On 12/01/21 06:06PM, Zhen Lei wrote:
> The __typecheck() requires that the two arguments of max() must be of the
> same type. For the current max(), the type of the first parameter "len" is
> size_t. But the type of size_t is not fixed, it's "unsigned int" on 32-bit
> platforms and "unsigned long" on 64-bit platforms. So both the suffix "U"
> and "UL" are not appropriate for the second constant parameter. Therefore,
> forcible type conversion is used.
>
> Fixes: 8728a81b8f10 ("spi: Fix distinct pointer types warning for ARCH=mips")
> Fixes: 0920a32cf6f2 ("spi: cadence-quadspi: Wait at least 500 ms for direct reads")
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
> drivers/spi/spi-cadence-quadspi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
> index 576610ba11184c6..eb40b8d46b56b0c 100644
> --- a/drivers/spi/spi-cadence-quadspi.c
> +++ b/drivers/spi/spi-cadence-quadspi.c
> @@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
>
> dma_async_issue_pending(cqspi->rx_chan);
> if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
> - msecs_to_jiffies(max(len, 500U)))) {
> + msecs_to_jiffies(max_t(size_t, len, 500)))) {
I sent a patch with this exact fix already [0]. It has made it in Mark's
for-next branch.
[0] https://lore.kernel.org/linux-spi/20210108181457.30291-1-p.yadav@ti.com/
> dmaengine_terminate_sync(cqspi->rx_chan);
> dev_err(dev, "DMA wait_for_completion_timeout\n");
> ret = -ETIMEDOUT;
> --
> 1.8.3
>
>
--
Regards,
Pratyush Yadav
Texas Instruments India
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform
2021-01-12 10:16 ` Pratyush Yadav
@ 2021-01-12 11:23 ` Leizhen (ThunderTown)
0 siblings, 0 replies; 5+ messages in thread
From: Leizhen (ThunderTown) @ 2021-01-12 11:23 UTC (permalink / raw)
To: Pratyush Yadav; +Cc: Mark Brown, linux-spi, linux-kernel, Yanteng Si
On 2021/1/12 18:16, Pratyush Yadav wrote:
> Hi Zhen,
>
> On 12/01/21 06:06PM, Zhen Lei wrote:
>> The __typecheck() requires that the two arguments of max() must be of the
>> same type. For the current max(), the type of the first parameter "len" is
>> size_t. But the type of size_t is not fixed, it's "unsigned int" on 32-bit
>> platforms and "unsigned long" on 64-bit platforms. So both the suffix "U"
>> and "UL" are not appropriate for the second constant parameter. Therefore,
>> forcible type conversion is used.
>>
>> Fixes: 8728a81b8f10 ("spi: Fix distinct pointer types warning for ARCH=mips")
>> Fixes: 0920a32cf6f2 ("spi: cadence-quadspi: Wait at least 500 ms for direct reads")
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>> ---
>> drivers/spi/spi-cadence-quadspi.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
>> index 576610ba11184c6..eb40b8d46b56b0c 100644
>> --- a/drivers/spi/spi-cadence-quadspi.c
>> +++ b/drivers/spi/spi-cadence-quadspi.c
>> @@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
>>
>> dma_async_issue_pending(cqspi->rx_chan);
>> if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
>> - msecs_to_jiffies(max(len, 500U)))) {
>> + msecs_to_jiffies(max_t(size_t, len, 500)))) {
>
> I sent a patch with this exact fix already [0]. It has made it in Mark's
> for-next branch.
OK,I don't known it.
>
> [0] https://lore.kernel.org/linux-spi/20210108181457.30291-1-p.yadav@ti.com/
>
>> dmaengine_terminate_sync(cqspi->rx_chan);
>> dev_err(dev, "DMA wait_for_completion_timeout\n");
>> ret = -ETIMEDOUT;
>> --
>> 1.8.3
>>
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform
2021-01-12 10:06 [PATCH 0/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform Zhen Lei
2021-01-12 10:06 ` [PATCH 1/1] " Zhen Lei
@ 2021-01-12 12:47 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-01-12 12:47 UTC (permalink / raw)
To: Zhen Lei; +Cc: linux-spi, linux-kernel, Yanteng Si, Pratyush Yadav
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
On Tue, Jan 12, 2021 at 06:06:36PM +0800, Zhen Lei wrote:
> This patch is based on the latest linux-next. So the Fixes commit-id
> maybe changed when it merged int v5.12-rc1. For details about the problem
> analysis, see the patch description. The auxiliary information is listed here.
Please don't send cover letters for single patches, if there is anything
that needs saying put it in the changelog of the patch or after the ---
if it's administrative stuff. This reduces mail volume and ensures that
any important information is recorded in the changelog rather than being
lost.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-12 12:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 10:06 [PATCH 0/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform Zhen Lei
2021-01-12 10:06 ` [PATCH 1/1] " Zhen Lei
2021-01-12 10:16 ` Pratyush Yadav
2021-01-12 11:23 ` Leizhen (ThunderTown)
2021-01-12 12:47 ` [PATCH 0/1] " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).