2018-03-06 17:46:45

by Ioana Ciocoi Radulescu

[permalink] [raw]
Subject: [PATCH 0/5] staging: fsl-mc/dpio: Fix sparse warnings

Some code cleanup and bug fixes based on warnings reported by sparse
when building on x86.

Ioana Radulescu (5):
staging: fsl-mc/dpio: Fix incorrect cast
staging: fsl-mc/dpio: Fix cast truncate warning
staging: fsl-mc/dpio: Use __leXX types where needed
staging: fsl-mc/dpio: Fix incorrect masking
staging: fsl-dpaa2/dpio: Remove dead code

drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 23 +++++++++--------------
drivers/staging/fsl-mc/bus/dpio/qbman-portal.h | 24 ++++++++++++------------
drivers/staging/fsl-mc/include/dpaa2-fd.h | 6 +++---
3 files changed, 24 insertions(+), 29 deletions(-)

--
2.7.4



2018-03-06 17:45:44

by Ioana Ciocoi Radulescu

[permalink] [raw]
Subject: [PATCH 2/5] staging: fsl-mc/dpio: Fix cast truncate warning

Sparse reports the following warning:
drivers/staging/fsl-mc/include/dpaa2-fd.h:421:30:
warning: cast truncates bits from constant value (ffff7fff becomes 7fff)

Fix this by explicitly masking the value with 0xffff.

Signed-off-by: Ioana Radulescu <[email protected]>
---
drivers/staging/fsl-mc/include/dpaa2-fd.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h b/drivers/staging/fsl-mc/include/dpaa2-fd.h
index 70501d7..b55b89b 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-fd.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
@@ -418,8 +418,8 @@ static inline bool dpaa2_sg_is_final(const struct dpaa2_sg_entry *sg)
*/
static inline void dpaa2_sg_set_final(struct dpaa2_sg_entry *sg, bool final)
{
- sg->format_offset &= cpu_to_le16(~(SG_FINAL_FLAG_MASK
- << SG_FINAL_FLAG_SHIFT));
+ sg->format_offset &= cpu_to_le16((~(SG_FINAL_FLAG_MASK
+ << SG_FINAL_FLAG_SHIFT)) & 0xFFFF);
sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT);
}

--
2.7.4


2018-03-06 17:46:20

by Ioana Ciocoi Radulescu

[permalink] [raw]
Subject: [PATCH 5/5] staging: fsl-mc/dpio: Remove dead code

Function qbman_pull_desc_set_token() is not used at all, so remove it.

Signed-off-by: Ioana Radulescu <[email protected]>
---
drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
index 7e55b56..116fafb 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -522,11 +522,6 @@ void qbman_pull_desc_set_numframes(struct qbman_pull_desc *d, u8 numframes)
d->numf = numframes - 1;
}

-static void qbman_pull_desc_set_token(struct qbman_pull_desc *d, u8 token)
-{
- d->tok = token;
-}
-
/*
* Exactly one of the following descriptor "actions" should be set. (Calling any
* one of these will replace the effect of any prior call to one of these.)
--
2.7.4


2018-03-06 17:46:48

by Ioana Ciocoi Radulescu

[permalink] [raw]
Subject: [PATCH 3/5] staging: fsl-mc/dpio: Use __leXX types where needed

Structures that are mapped to hardware registers should explicitly
specify the expected endianness for fields larger than 1 byte.

Signed-off-by: Ioana Radulescu <[email protected]>
---
drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 16 ++++++++--------
drivers/staging/fsl-mc/bus/dpio/qbman-portal.h | 24 ++++++++++++------------
2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
index 7b75c93..377f4d9 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -830,7 +830,7 @@ int qbman_swp_release(struct qbman_swp *s, const struct qbman_release_desc *d,
struct qbman_acquire_desc {
u8 verb;
u8 reserved;
- u16 bpid;
+ __le16 bpid;
u8 num;
u8 reserved2[59];
};
@@ -838,10 +838,10 @@ struct qbman_acquire_desc {
struct qbman_acquire_rslt {
u8 verb;
u8 rslt;
- u16 reserved;
+ __le16 reserved;
u8 num;
u8 reserved2[3];
- u64 buf[7];
+ __le64 buf[7];
};

/**
@@ -904,7 +904,7 @@ int qbman_swp_acquire(struct qbman_swp *s, u16 bpid, u64 *buffers,
struct qbman_alt_fq_state_desc {
u8 verb;
u8 reserved[3];
- u32 fqid;
+ __le32 fqid;
u8 reserved2[56];
};

@@ -953,11 +953,11 @@ int qbman_swp_alt_fq_state(struct qbman_swp *s, u32 fqid,
struct qbman_cdan_ctrl_desc {
u8 verb;
u8 reserved;
- u16 ch;
+ __le16 ch;
u8 we;
u8 ctrl;
- u16 reserved2;
- u64 cdan_ctx;
+ __le16 reserved2;
+ __le64 cdan_ctx;
u8 reserved3[48];

};
@@ -965,7 +965,7 @@ struct qbman_cdan_ctrl_desc {
struct qbman_cdan_ctrl_rslt {
u8 verb;
u8 rslt;
- u16 ch;
+ __le16 ch;
u8 reserved[60];
};

diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
index fb8b9d3..4488a44 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
@@ -32,8 +32,8 @@ struct qbman_pull_desc {
u8 numf;
u8 tok;
u8 reserved;
- u32 dq_src;
- u64 rsp_addr;
+ __le32 dq_src;
+ __le64 rsp_addr;
u64 rsp_addr_virt;
u8 padding[40];
};
@@ -70,17 +70,17 @@ enum qbman_pull_type_e {
struct qbman_eq_desc {
u8 verb;
u8 dca;
- u16 seqnum;
- u16 orpid;
- u16 reserved1;
- u32 tgtid;
- u32 tag;
- u16 qdbin;
+ __le16 seqnum;
+ __le16 orpid;
+ __le16 reserved1;
+ __le32 tgtid;
+ __le32 tag;
+ __le16 qdbin;
u8 qpri;
u8 reserved[3];
u8 wae;
u8 rspid;
- u64 rsp_addr;
+ __le64 rsp_addr;
u8 fd[32];
};

@@ -88,9 +88,9 @@ struct qbman_eq_desc {
struct qbman_release_desc {
u8 verb;
u8 reserved;
- u16 bpid;
- u32 reserved2;
- u64 buf[7];
+ __le16 bpid;
+ __le32 reserved2;
+ __le64 buf[7];
};

/* Management command result codes */
--
2.7.4


2018-03-06 17:46:59

by Ioana Ciocoi Radulescu

[permalink] [raw]
Subject: [PATCH 4/5] staging: fsl-mc/dpio: Fix incorrect masking

In qbman_swp_alt_fq_state(), we need to mask the fqid value
before converting it to little endian, otherwise we write a
wrong value to hardware when running in big endian mode.

Signed-off-by: Ioana Radulescu <[email protected]>
---
drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
index 377f4d9..7e55b56 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -927,7 +927,7 @@ int qbman_swp_alt_fq_state(struct qbman_swp *s, u32 fqid,
if (!p)
return -EBUSY;

- p->fqid = cpu_to_le32(fqid) & ALT_FQ_FQID_MASK;
+ p->fqid = cpu_to_le32(fqid & ALT_FQ_FQID_MASK);

/* Complete the management command */
r = qbman_swp_mc_complete(s, p, alt_fq_verb);
--
2.7.4


2018-03-06 17:47:10

by Ioana Ciocoi Radulescu

[permalink] [raw]
Subject: [PATCH 1/5] staging: fsl-mc/dpio: Fix incorrect cast

Move the cast in dpaa2_sg_get_addr() to the right place.

Signed-off-by: Ioana Radulescu <[email protected]>
---
drivers/staging/fsl-mc/include/dpaa2-fd.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h b/drivers/staging/fsl-mc/include/dpaa2-fd.h
index 3e02200..70501d7 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-fd.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
@@ -287,7 +287,7 @@ enum dpaa2_sg_format {
*/
static inline dma_addr_t dpaa2_sg_get_addr(const struct dpaa2_sg_entry *sg)
{
- return le64_to_cpu((dma_addr_t)sg->addr);
+ return (dma_addr_t)le64_to_cpu(sg->addr);
}

/**
--
2.7.4


2018-03-06 18:33:40

by Ioana Ciocoi Radulescu

[permalink] [raw]
Subject: RE: [PATCH 5/5] staging: fsl-mc/dpio: Remove dead code

> -----Original Message-----
> From: Ruxandra Ioana Ciocoi Radulescu
> Sent: Tuesday, March 6, 2018 7:44 PM
> To: [email protected]
> Cc: [email protected]; [email protected]; Roy Pledge
> <[email protected]>; Laurentiu Tudor <[email protected]>
> Subject: [PATCH 5/5] staging: fsl-mc/dpio: Remove dead code
>
> Function qbman_pull_desc_set_token() is not used at all, so remove it.
>
> Signed-off-by: Ioana Radulescu <[email protected]>
> ---
> drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 5 -----
> 1 file changed, 5 deletions(-)

Hi Greg,

Please ignore this patch, I've just noticed you already applied another
patch with the same content a couple of hours ago.

Thanks,
Ioana

2018-03-08 17:59:47

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 5/5] staging: fsl-mc/dpio: Remove dead code

On Tue, Mar 06, 2018 at 06:32:00PM +0000, Ruxandra Ioana Ciocoi Radulescu wrote:
> > -----Original Message-----
> > From: Ruxandra Ioana Ciocoi Radulescu
> > Sent: Tuesday, March 6, 2018 7:44 PM
> > To: [email protected]
> > Cc: [email protected]; [email protected]; Roy Pledge
> > <[email protected]>; Laurentiu Tudor <[email protected]>
> > Subject: [PATCH 5/5] staging: fsl-mc/dpio: Remove dead code
> >
> > Function qbman_pull_desc_set_token() is not used at all, so remove it.
> >
> > Signed-off-by: Ioana Radulescu <[email protected]>
> > ---
> > drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 5 -----
> > 1 file changed, 5 deletions(-)
>
> Hi Greg,
>
> Please ignore this patch, I've just noticed you already applied another
> patch with the same content a couple of hours ago.

Not a problem, now ignored :)

greg k-h