mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd
@ 2017-04-28 14:38 Horia Geantă
  2017-04-29 16:32 ` Stuart Yoder
  0 siblings, 1 reply; 4+ messages in thread
From: Horia Geantă @ 2017-04-28 14:38 UTC (permalink / raw)
  To: gregkh, Roy Pledge
  Cc: devel, linux-kernel, Stuart Yoder, Ioana Radulescu, Haiying Wang

While dpaa2_fd.simple structure fields are marked __leXX,
corresponding cpu_to_leXX / leXX_to_cpu conversions are missing.

While here, fix dpaa2_fd_{get,set}_bpid such that BMT, IVP bits
sharing the 16-bit field with BPID are not affected.

Fixes: d3269bdc7ebc ("bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs")
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/staging/fsl-mc/include/dpaa2-fd.h | 45 ++++++++++++++++---------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h b/drivers/staging/fsl-mc/include/dpaa2-fd.h
index 9500123cc7f9..cf7857f00a5c 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-fd.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
@@ -81,6 +81,7 @@ struct dpaa2_fd {
 #define FD_OFFSET_MASK		0x0FFF
 #define FD_FORMAT_MASK		0x3
 #define FD_FORMAT_SHIFT		12
+#define FD_BPID_MASK		0x3FFF
 #define SG_SHORT_LEN_FLAG_MASK	0x1
 #define SG_SHORT_LEN_FLAG_SHIFT	14
 #define SG_SHORT_LEN_MASK	0x1FFFF
@@ -105,7 +106,7 @@ enum dpaa2_fd_format {
  */
 static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
 {
-	return (dma_addr_t)fd->simple.addr;
+	return (dma_addr_t)le64_to_cpu(fd->simple.addr);
 }
 
 /**
@@ -115,7 +116,7 @@ static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
  */
 static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
 {
-	fd->simple.addr = addr;
+	fd->simple.addr = cpu_to_le64(addr);
 }
 
 /**
@@ -126,7 +127,7 @@ static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
  */
 static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
 {
-	return fd->simple.frc;
+	return le32_to_cpu(fd->simple.frc);
 }
 
 /**
@@ -136,7 +137,7 @@ static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
  */
 static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
 {
-	fd->simple.frc = frc;
+	fd->simple.frc = cpu_to_le32(frc);
 }
 
 /**
@@ -147,7 +148,7 @@ static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
  */
 static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
 {
-	return fd->simple.ctrl;
+	return le32_to_cpu(fd->simple.ctrl);
 }
 
 /**
@@ -157,7 +158,7 @@ static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
  */
 static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
 {
-	fd->simple.ctrl = ctrl;
+	fd->simple.ctrl = cpu_to_le32(ctrl);
 }
 
 /**
@@ -168,7 +169,7 @@ static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
  */
 static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
 {
-	return (dma_addr_t)fd->simple.flc;
+	return (dma_addr_t)le64_to_cpu(fd->simple.flc);
 }
 
 /**
@@ -178,13 +179,13 @@ static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
  */
 static inline void dpaa2_fd_set_flc(struct dpaa2_fd *fd,  dma_addr_t flc_addr)
 {
-	fd->simple.flc = flc_addr;
+	fd->simple.flc = cpu_to_le64(flc_addr);
 }
 
 static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
 {
-	return !!((fd->simple.format_offset >> FD_SHORT_LEN_FLAG_SHIFT)
-		& FD_SHORT_LEN_FLAG_MASK);
+	return !!((le16_to_cpu(fd->simple.format_offset) >>
+		  FD_SHORT_LEN_FLAG_SHIFT) & FD_SHORT_LEN_FLAG_MASK);
 }
 
 /**
@@ -196,9 +197,9 @@ static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
 static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
 {
 	if (dpaa2_fd_short_len(fd))
-		return fd->simple.len & FD_SHORT_LEN_MASK;
+		return le32_to_cpu(fd->simple.len) & FD_SHORT_LEN_MASK;
 
-	return fd->simple.len;
+	return le32_to_cpu(fd->simple.len);
 }
 
 /**
@@ -208,7 +209,7 @@ static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
  */
 static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
 {
-	fd->simple.len = len;
+	fd->simple.len = cpu_to_le32(len);
 }
 
 /**
@@ -219,7 +220,7 @@ static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
  */
 static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
 {
-	return fd->simple.format_offset & FD_OFFSET_MASK;
+	return le16_to_cpu(fd->simple.format_offset) & FD_OFFSET_MASK;
 }
 
 /**
@@ -229,8 +230,8 @@ static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
  */
 static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
 {
-	fd->simple.format_offset &= ~FD_OFFSET_MASK;
-	fd->simple.format_offset |= offset;
+	fd->simple.format_offset &= cpu_to_le16(~FD_OFFSET_MASK);
+	fd->simple.format_offset |= cpu_to_le16(offset);
 }
 
 /**
@@ -242,7 +243,7 @@ static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
 static inline enum dpaa2_fd_format dpaa2_fd_get_format(
 						const struct dpaa2_fd *fd)
 {
-	return (enum dpaa2_fd_format)((fd->simple.format_offset
+	return (enum dpaa2_fd_format)((le16_to_cpu(fd->simple.format_offset)
 				      >> FD_FORMAT_SHIFT) & FD_FORMAT_MASK);
 }
 
@@ -254,8 +255,9 @@ static inline enum dpaa2_fd_format dpaa2_fd_get_format(
 static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
 				       enum dpaa2_fd_format format)
 {
-	fd->simple.format_offset &= ~(FD_FORMAT_MASK << FD_FORMAT_SHIFT);
-	fd->simple.format_offset |= format << FD_FORMAT_SHIFT;
+	fd->simple.format_offset &=
+		cpu_to_le16(~(FD_FORMAT_MASK << FD_FORMAT_SHIFT));
+	fd->simple.format_offset |= cpu_to_le16(format << FD_FORMAT_SHIFT);
 }
 
 /**
@@ -266,7 +268,7 @@ static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
  */
 static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
 {
-	return fd->simple.bpid;
+	return le16_to_cpu(fd->simple.bpid) & FD_BPID_MASK;
 }
 
 /**
@@ -276,7 +278,8 @@ static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
  */
 static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid)
 {
-	fd->simple.bpid = bpid;
+	fd->simple.bpid &= cpu_to_le16(~(FD_BPID_MASK));
+	fd->simple.bpid |= cpu_to_le16(bpid);
 }
 
 /**
-- 
2.12.0.264.gd6db3f216544

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd
  2017-04-28 14:38 [PATCH] staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd Horia Geantă
@ 2017-04-29 16:32 ` Stuart Yoder
  2017-04-29 17:18   ` Horia Geantă
  0 siblings, 1 reply; 4+ messages in thread
From: Stuart Yoder @ 2017-04-29 16:32 UTC (permalink / raw)
  To: Horia Geantă
  Cc: gregkh, Roy Pledge, devel, linux-kernel, Ioana Radulescu, Haiying Wang

On Fri, Apr 28, 2017 at 9:38 AM, Horia Geantă <horia.geanta@nxp.com> wrote:
>
> While dpaa2_fd.simple structure fields are marked __leXX,
> corresponding cpu_to_leXX / leXX_to_cpu conversions are missing.
>
> While here, fix dpaa2_fd_{get,set}_bpid such that BMT, IVP bits
> sharing the 16-bit field with BPID are not affected.

Please split this into 2 separate patches.  Don't fix other misc things "while
you are at it" in the same patch.

Thanks,
Stuart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd
  2017-04-29 16:32 ` Stuart Yoder
@ 2017-04-29 17:18   ` Horia Geantă
  2017-04-30  5:23     ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Horia Geantă @ 2017-04-29 17:18 UTC (permalink / raw)
  To: Stuart Yoder
  Cc: gregkh, Roy Pledge, devel, linux-kernel,
	Ruxandra Ioana Radulescu, Haiying Wang

On 4/29/2017 7:32 PM, Stuart Yoder wrote:
> On Fri, Apr 28, 2017 at 9:38 AM, Horia Geantă <horia.geanta@nxp.com> wrote:
>>
>> While dpaa2_fd.simple structure fields are marked __leXX,
>> corresponding cpu_to_leXX / leXX_to_cpu conversions are missing.
>>
>> While here, fix dpaa2_fd_{get,set}_bpid such that BMT, IVP bits
>> sharing the 16-bit field with BPID are not affected.
> 
> Please split this into 2 separate patches.  Don't fix other misc things "while
> you are at it" in the same patch.
> 
I thought that having 2 issues on the same line would allow for this
approach.

Now that the patch is in staging-next, I am not sure what I am supposed
to do.

Thanks,
Horia

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd
  2017-04-29 17:18   ` Horia Geantă
@ 2017-04-30  5:23     ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-04-30  5:23 UTC (permalink / raw)
  To: Horia Geantă
  Cc: Stuart Yoder, devel, Haiying Wang, gregkh, Roy Pledge, linux-kernel

On Sat, Apr 29, 2017 at 05:18:04PM +0000, Horia Geantă wrote:
> On 4/29/2017 7:32 PM, Stuart Yoder wrote:
> > On Fri, Apr 28, 2017 at 9:38 AM, Horia Geantă <horia.geanta@nxp.com> wrote:
> >>
> >> While dpaa2_fd.simple structure fields are marked __leXX,
> >> corresponding cpu_to_leXX / leXX_to_cpu conversions are missing.
> >>
> >> While here, fix dpaa2_fd_{get,set}_bpid such that BMT, IVP bits
> >> sharing the 16-bit field with BPID are not affected.
> > 
> > Please split this into 2 separate patches.  Don't fix other misc things "while
> > you are at it" in the same patch.
> > 
> I thought that having 2 issues on the same line would allow for this
> approach.
> 
> Now that the patch is in staging-next, I am not sure what I am supposed
> to do.

It's non-rebase tree.  Nothing to do.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-30  5:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-28 14:38 [PATCH] staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd Horia Geantă
2017-04-29 16:32 ` Stuart Yoder
2017-04-29 17:18   ` Horia Geantă
2017-04-30  5:23     ` Dan Carpenter

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®