From: Dan Carpenter <dan.carpenter@oracle.com>
To: Hariprasad S <hariprasad@chelsio.com>
Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch 2/2 v2 -next] cxgb4: clean up a type issue
Date: Wed, 08 Oct 2014 13:44:34 +0000 [thread overview]
Message-ID: <20141008134434.GB12036@mwanda> (raw)
In-Reply-To: <20141003.154629.555967384624529643.davem@davemloft.net>
The tx_desc struct holds 8 __be64 values. The original code in
ring_tx_db() took a tx_desc pointer then casted it to an int pointer and
then casted it to a u64 pointer. It was confusing and triggered some
static checker warnings.
I have changed the cxgb_pio_copy() function to only take tx_desc
pointers. This isn't really a loss of flexibility because anything else
was buggy to begin with.
I also removed the casting on the destination pointer since that was
unnecessary and a bit messy.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: More cleanups as suggested by David Laight.
Update cxgb_pio_copy() comments.
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index e8e90ce..fab4c84 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -850,13 +850,14 @@ static void write_sgl(const struct sk_buff *skb, struct sge_txq *q,
*end = 0;
}
-/* This function copies 64 byte coalesced work request to
- * memory mapped BAR2 space(user space writes).
- * For coalesced WR SGE, fetches data from the FIFO instead of from Host.
+/* This function copies a tx_desc struct to memory mapped BAR2 space(user space
+ * writes). For coalesced WR SGE, fetches data from the FIFO instead of from
+ * Host.
*/
-static void cxgb_pio_copy(u64 __iomem *dst, u64 *src)
+static void cxgb_pio_copy(u64 __iomem *dst, struct tx_desc *desc)
{
- int count = 8;
+ int count = sizeof(*desc) / sizeof(u64);
+ u64 *src = (u64 *)desc;
while (count) {
writeq(*src, dst);
@@ -914,12 +915,9 @@ static inline void ring_tx_db(struct adapter *adap, struct sge_txq *q, int n)
int index = (q->pidx
? (q->pidx - 1)
: (q->size - 1));
- unsigned int *wr = (unsigned int *)&q->desc[index];
- cxgb_pio_copy((u64 __iomem *)
- (adap->bar2 + q->udb +
- SGE_UDB_WCDOORBELL),
- (u64 *)wr);
+ cxgb_pio_copy(adap->bar2 + q->udb + SGE_UDB_WCDOORBELL,
+ q->desc + index);
} else {
writel(val, adap->bar2 + q->udb + SGE_UDB_KDOORBELL);
}
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Hariprasad S <hariprasad@chelsio.com>
Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch 2/2 v2 -next] cxgb4: clean up a type issue
Date: Wed, 8 Oct 2014 16:44:34 +0300 [thread overview]
Message-ID: <20141008134434.GB12036@mwanda> (raw)
In-Reply-To: <20141003.154629.555967384624529643.davem@davemloft.net>
The tx_desc struct holds 8 __be64 values. The original code in
ring_tx_db() took a tx_desc pointer then casted it to an int pointer and
then casted it to a u64 pointer. It was confusing and triggered some
static checker warnings.
I have changed the cxgb_pio_copy() function to only take tx_desc
pointers. This isn't really a loss of flexibility because anything else
was buggy to begin with.
I also removed the casting on the destination pointer since that was
unnecessary and a bit messy.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: More cleanups as suggested by David Laight.
Update cxgb_pio_copy() comments.
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index e8e90ce..fab4c84 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -850,13 +850,14 @@ static void write_sgl(const struct sk_buff *skb, struct sge_txq *q,
*end = 0;
}
-/* This function copies 64 byte coalesced work request to
- * memory mapped BAR2 space(user space writes).
- * For coalesced WR SGE, fetches data from the FIFO instead of from Host.
+/* This function copies a tx_desc struct to memory mapped BAR2 space(user space
+ * writes). For coalesced WR SGE, fetches data from the FIFO instead of from
+ * Host.
*/
-static void cxgb_pio_copy(u64 __iomem *dst, u64 *src)
+static void cxgb_pio_copy(u64 __iomem *dst, struct tx_desc *desc)
{
- int count = 8;
+ int count = sizeof(*desc) / sizeof(u64);
+ u64 *src = (u64 *)desc;
while (count) {
writeq(*src, dst);
@@ -914,12 +915,9 @@ static inline void ring_tx_db(struct adapter *adap, struct sge_txq *q, int n)
int index = (q->pidx
? (q->pidx - 1)
: (q->size - 1));
- unsigned int *wr = (unsigned int *)&q->desc[index];
- cxgb_pio_copy((u64 __iomem *)
- (adap->bar2 + q->udb +
- SGE_UDB_WCDOORBELL),
- (u64 *)wr);
+ cxgb_pio_copy(adap->bar2 + q->udb + SGE_UDB_WCDOORBELL,
+ q->desc + index);
} else {
writel(val, adap->bar2 + q->udb + SGE_UDB_KDOORBELL);
}
next prev parent reply other threads:[~2014-10-08 13:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-02 11:22 [patch 1/2 -next] cxgb4: clean up a type issue Dan Carpenter
2014-10-02 11:22 ` Dan Carpenter
2014-10-02 11:31 ` David Laight
2014-10-02 11:31 ` David Laight
2014-10-03 22:46 ` David Miller
2014-10-03 22:46 ` David Miller
2014-10-08 10:18 ` Dan Carpenter
2014-10-08 10:18 ` Dan Carpenter
2014-10-08 13:43 ` [patch 1/2 v2 -next] cxgb4: potential shift wrapping bug Dan Carpenter
2014-10-08 13:43 ` Dan Carpenter
2014-10-08 20:08 ` David Miller
2014-10-08 20:08 ` David Miller
2014-10-08 13:44 ` Dan Carpenter [this message]
2014-10-08 13:44 ` [patch 2/2 v2 -next] cxgb4: clean up a type issue Dan Carpenter
2014-10-08 20:08 ` David Miller
2014-10-08 20:08 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141008134434.GB12036@mwanda \
--to=dan.carpenter@oracle.com \
--cc=hariprasad@chelsio.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.