* [PATCH 0/5] net: mvpp2: fixes and cleanups
@ 2017-06-08 15:27 Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 1/5] net: mvpp2: remove mvpp2_bm_cookie_{build,pool_get} Thomas Petazzoni
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2017-06-08 15:27 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Marcin Wojtas, Stefan Chulski, Nadav Haklai, Hanna Hawa,
Yehuda Yitschak, Antoine Tenart, Gregory Clement, Markus Elfring,
Marc Zyngier, Thomas Petazzoni
Hello,
Here is a small set of fixes/improvements for the mvpp2 driver.
The first two patches are fixes: they fix bogus usage of
smp_processor_id() in a migration-enabled context. Indeed currently
the driver outputs some fat warnings in CONFIG_DEBUG_PREEMPT-enabled
kernels. Therefore, some fixes should be pushed to stable.
The last three patches are cleanups and not needed for stable, but
they stack on top of the fixes.
Thanks,
Thomas
Thomas Petazzoni (5):
net: mvpp2: remove mvpp2_bm_cookie_{build,pool_get}
net: mvpp2: use {get,put}_cpu() instead of smp_processor_id()
net: mvpp2: add comments about smp_processor_id() usage
net: mvpp2: remove unused mvpp2_bm_cookie_pool_set() function
net: mvpp2: remove mvpp2_pool_refill()
drivers/net/ethernet/marvell/mvpp2.c | 126 +++++++++++++++++------------------
1 file changed, 60 insertions(+), 66 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/5] net: mvpp2: remove mvpp2_bm_cookie_{build,pool_get}
2017-06-08 15:27 [PATCH 0/5] net: mvpp2: fixes and cleanups Thomas Petazzoni
@ 2017-06-08 15:27 ` Thomas Petazzoni
2017-06-09 8:22 ` kbuild test robot
2017-06-08 15:27 ` [PATCH 2/5] net: mvpp2: use {get,put}_cpu() instead of smp_processor_id() Thomas Petazzoni
` (4 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2017-06-08 15:27 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Marcin Wojtas, Stefan Chulski, Nadav Haklai, Hanna Hawa,
Yehuda Yitschak, Antoine Tenart, Gregory Clement, Markus Elfring,
Marc Zyngier, Thomas Petazzoni
This commit removes the useless remove
mvpp2_bm_cookie_{build,pool_get} functions. All what
mvpp2_bm_cookie_build() was doing is compute a 32-bit value by
concatenating the pool number and the CPU number... only to get the pool
number re-extracted by mvpp2_bm_cookie_pool_get() later on.
Instead, just get the pool number directly from RX descriptor status,
and pass it to mvpp2_pool_refill() and mvpp2_rx_refill().
This has the added benefit of dropping a smp_processor_id() call in a
migration-enabled context, which is wrong, and is the original
motivation for making this change.
Fixes: 3f518509dedc9 ("ethernet: Add new driver for Marvell Armada 375 network unit")
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/net/ethernet/marvell/mvpp2.c | 51 ++++++++++--------------------------
1 file changed, 14 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 9b875d7..cff45e3 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -666,10 +666,6 @@ enum mvpp2_prs_l3_cast {
#define MVPP2_BM_SWF_LONG_POOL(port) ((port > 2) ? 2 : port)
#define MVPP2_BM_SWF_SHORT_POOL 3
-/* BM cookie (32 bits) definition */
-#define MVPP2_BM_COOKIE_POOL_OFFS 8
-#define MVPP2_BM_COOKIE_CPU_OFFS 24
-
/* BM short pool packet size
* These value assure that for SWF the total number
* of bytes allocated for each buffer will be 512
@@ -3920,12 +3916,6 @@ static inline u32 mvpp2_bm_cookie_pool_set(u32 cookie, int pool)
return bm;
}
-/* Get pool number from a BM cookie */
-static inline int mvpp2_bm_cookie_pool_get(unsigned long cookie)
-{
- return (cookie >> MVPP2_BM_COOKIE_POOL_OFFS) & 0xFF;
-}
-
/* Release buffer to BM */
static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
dma_addr_t buf_dma_addr,
@@ -3961,12 +3951,10 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
}
/* Refill BM pool */
-static void mvpp2_pool_refill(struct mvpp2_port *port, u32 bm,
+static void mvpp2_pool_refill(struct mvpp2_port *port, int pool,
dma_addr_t dma_addr,
phys_addr_t phys_addr)
{
- int pool = mvpp2_bm_cookie_pool_get(bm);
-
mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
}
@@ -4515,21 +4503,6 @@ static void mvpp2_rxq_offset_set(struct mvpp2_port *port,
mvpp2_write(port->priv, MVPP2_RXQ_CONFIG_REG(prxq), val);
}
-/* Obtain BM cookie information from descriptor */
-static u32 mvpp2_bm_cookie_build(struct mvpp2_port *port,
- struct mvpp2_rx_desc *rx_desc)
-{
- int cpu = smp_processor_id();
- int pool;
-
- pool = (mvpp2_rxdesc_status_get(port, rx_desc) &
- MVPP2_RXD_BM_POOL_ID_MASK) >>
- MVPP2_RXD_BM_POOL_ID_OFFS;
-
- return ((pool & 0xFF) << MVPP2_BM_COOKIE_POOL_OFFS) |
- ((cpu & 0xFF) << MVPP2_BM_COOKIE_CPU_OFFS);
-}
-
/* Tx descriptors helper methods */
/* Get pointer to next Tx descriptor to be processed (send) by HW */
@@ -4980,9 +4953,13 @@ static void mvpp2_rxq_drop_pkts(struct mvpp2_port *port,
for (i = 0; i < rx_received; i++) {
struct mvpp2_rx_desc *rx_desc = mvpp2_rxq_next_desc_get(rxq);
- u32 bm = mvpp2_bm_cookie_build(port, rx_desc);
+ u32 status = mvpp2_rxdesc_status_get(port, rx_desc);
+ int pool;
+
+ pool = (status & MVPP2_RXD_BM_POOL_ID_MASK) >>
+ MVPP2_RXD_BM_POOL_ID_OFFS;
- mvpp2_pool_refill(port, bm,
+ mvpp2_pool_refill(port, pool,
mvpp2_rxdesc_dma_addr_get(port, rx_desc),
mvpp2_rxdesc_cookie_get(port, rx_desc));
}
@@ -5420,7 +5397,7 @@ static void mvpp2_rx_csum(struct mvpp2_port *port, u32 status,
/* Reuse skb if possible, or allocate a new skb and add it to BM pool */
static int mvpp2_rx_refill(struct mvpp2_port *port,
- struct mvpp2_bm_pool *bm_pool, u32 bm)
+ struct mvpp2_bm_pool *bm_pool, int pool)
{
dma_addr_t dma_addr;
phys_addr_t phys_addr;
@@ -5432,7 +5409,7 @@ static int mvpp2_rx_refill(struct mvpp2_port *port,
if (!buf)
return -ENOMEM;
- mvpp2_pool_refill(port, bm, dma_addr, phys_addr);
+ mvpp2_pool_refill(port, pool, dma_addr, phys_addr);
return 0;
}
@@ -5490,7 +5467,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
unsigned int frag_size;
dma_addr_t dma_addr;
phys_addr_t phys_addr;
- u32 bm, rx_status;
+ u32 rx_status;
int pool, rx_bytes, err;
void *data;
@@ -5502,8 +5479,8 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
phys_addr = mvpp2_rxdesc_cookie_get(port, rx_desc);
data = (void *)phys_to_virt(phys_addr);
- bm = mvpp2_bm_cookie_build(port, rx_desc);
- pool = mvpp2_bm_cookie_pool_get(bm);
+ pool = (rx_status & MVPP2_RXD_BM_POOL_ID_MASK) >>
+ MVPP2_RXD_BM_POOL_ID_OFFS;
bm_pool = &port->priv->bm_pools[pool];
/* In case of an error, release the requested buffer pointer
@@ -5516,7 +5493,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
dev->stats.rx_errors++;
mvpp2_rx_error(port, rx_desc);
/* Return the buffer to the pool */
- mvpp2_pool_refill(port, bm, dma_addr, phys_addr);
+ mvpp2_pool_refill(port, pool, dma_addr, phys_addr);
continue;
}
@@ -5531,7 +5508,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
goto err_drop_frame;
}
- err = mvpp2_rx_refill(port, bm_pool, bm);
+ err = mvpp2_rx_refill(port, bm_pool, pool);
if (err) {
netdev_err(port->dev, "failed to refill BM pools\n");
goto err_drop_frame;
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/5] net: mvpp2: use {get,put}_cpu() instead of smp_processor_id()
2017-06-08 15:27 [PATCH 0/5] net: mvpp2: fixes and cleanups Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 1/5] net: mvpp2: remove mvpp2_bm_cookie_{build,pool_get} Thomas Petazzoni
@ 2017-06-08 15:27 ` Thomas Petazzoni
2017-06-08 16:01 ` Marc Zyngier
2017-06-08 15:27 ` [PATCH 3/5] net: mvpp2: add comments about smp_processor_id() usage Thomas Petazzoni
` (3 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2017-06-08 15:27 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Marcin Wojtas, Stefan Chulski, Nadav Haklai, Hanna Hawa,
Yehuda Yitschak, Antoine Tenart, Gregory Clement, Markus Elfring,
Marc Zyngier, Thomas Petazzoni
smp_processor_id() should not be used in migration-enabled contexts. We
originally thought it was OK in the specific situation of this driver,
but it was wrong, and calling smp_processor_id() in a migration-enabled
context prints a big fat warning when CONFIG_DEBUG_PREEMPT=y.
Therefore, this commit replaces the smp_processor_id() in
migration-enabled contexts by the appropriate get_cpu/put_cpu sections.
Reported-by: Marc Zyngier <marc.zyngier@arm.com>
Fixes: a786841df72e ("net: mvpp2: handle register mapping and access for PPv2.2")
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/net/ethernet/marvell/mvpp2.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index cff45e3..fb6e9dc 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3715,7 +3715,7 @@ static void mvpp2_bm_bufs_get_addrs(struct device *dev, struct mvpp2 *priv,
dma_addr_t *dma_addr,
phys_addr_t *phys_addr)
{
- int cpu = smp_processor_id();
+ int cpu = get_cpu();
*dma_addr = mvpp2_percpu_read(priv, cpu,
MVPP2_BM_PHY_ALLOC_REG(bm_pool->id));
@@ -3736,6 +3736,8 @@ static void mvpp2_bm_bufs_get_addrs(struct device *dev, struct mvpp2 *priv,
if (sizeof(phys_addr_t) == 8)
*phys_addr |= (u64)phys_addr_highbits << 32;
}
+
+ put_cpu();
}
/* Free all buffers from the pool */
@@ -3921,7 +3923,7 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
dma_addr_t buf_dma_addr,
phys_addr_t buf_phys_addr)
{
- int cpu = smp_processor_id();
+ int cpu = get_cpu();
if (port->priv->hw_version == MVPP22) {
u32 val = 0;
@@ -3948,6 +3950,8 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
MVPP2_BM_VIRT_RLS_REG, buf_phys_addr);
mvpp2_percpu_write(port->priv, cpu,
MVPP2_BM_PHY_RLS_REG(pool), buf_dma_addr);
+
+ put_cpu();
}
/* Refill BM pool */
@@ -4730,7 +4734,7 @@ static void mvpp2_txp_max_tx_size_set(struct mvpp2_port *port)
static void mvpp2_rx_pkts_coal_set(struct mvpp2_port *port,
struct mvpp2_rx_queue *rxq)
{
- int cpu = smp_processor_id();
+ int cpu = get_cpu();
if (rxq->pkts_coal > MVPP2_OCCUPIED_THRESH_MASK)
rxq->pkts_coal = MVPP2_OCCUPIED_THRESH_MASK;
@@ -4738,6 +4742,8 @@ static void mvpp2_rx_pkts_coal_set(struct mvpp2_port *port,
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id);
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_THRESH_REG,
rxq->pkts_coal);
+
+ put_cpu();
}
static u32 mvpp2_usec_to_cycles(u32 usec, unsigned long clk_hz)
@@ -4918,7 +4924,7 @@ static int mvpp2_rxq_init(struct mvpp2_port *port,
mvpp2_write(port->priv, MVPP2_RXQ_STATUS_REG(rxq->id), 0);
/* Set Rx descriptors queue starting address - indirect access */
- cpu = smp_processor_id();
+ cpu = get_cpu();
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id);
if (port->priv->hw_version == MVPP21)
rxq_dma = rxq->descs_dma;
@@ -4927,6 +4933,7 @@ static int mvpp2_rxq_init(struct mvpp2_port *port,
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_ADDR_REG, rxq_dma);
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_SIZE_REG, rxq->size);
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_INDEX_REG, 0);
+ put_cpu();
/* Set Offset */
mvpp2_rxq_offset_set(port, rxq->id, NET_SKB_PAD);
@@ -4989,10 +4996,11 @@ static void mvpp2_rxq_deinit(struct mvpp2_port *port,
* free descriptor number
*/
mvpp2_write(port->priv, MVPP2_RXQ_STATUS_REG(rxq->id), 0);
- cpu = smp_processor_id();
+ cpu = get_cpu();
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id);
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_ADDR_REG, 0);
mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_SIZE_REG, 0);
+ put_cpu();
}
/* Create and initialize a Tx queue */
@@ -5015,7 +5023,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
txq->last_desc = txq->size - 1;
/* Set Tx descriptors queue starting address - indirect access */
- cpu = smp_processor_id();
+ cpu = get_cpu();
mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id);
mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_ADDR_REG,
txq->descs_dma);
@@ -5040,6 +5048,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG,
MVPP2_PREF_BUF_PTR(desc) | MVPP2_PREF_BUF_SIZE_16 |
MVPP2_PREF_BUF_THRESH(desc_per_txq / 2));
+ put_cpu();
/* WRR / EJP configuration - indirect access */
tx_port_num = mvpp2_egress_port(port);
@@ -5110,10 +5119,11 @@ static void mvpp2_txq_deinit(struct mvpp2_port *port,
mvpp2_write(port->priv, MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(txq->id), 0);
/* Set Tx descriptors queue starting address and size */
- cpu = smp_processor_id();
+ cpu = get_cpu();
mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id);
mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_ADDR_REG, 0);
mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_SIZE_REG, 0);
+ put_cpu();
}
/* Cleanup Tx ports */
@@ -5123,7 +5133,7 @@ static void mvpp2_txq_clean(struct mvpp2_port *port, struct mvpp2_tx_queue *txq)
int delay, pending, cpu;
u32 val;
- cpu = smp_processor_id();
+ cpu = get_cpu();
mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id);
val = mvpp2_percpu_read(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG);
val |= MVPP2_TXQ_DRAIN_EN_MASK;
@@ -5150,6 +5160,7 @@ static void mvpp2_txq_clean(struct mvpp2_port *port, struct mvpp2_tx_queue *txq)
val &= ~MVPP2_TXQ_DRAIN_EN_MASK;
mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG, val);
+ put_cpu();
for_each_present_cpu(cpu) {
txq_pcpu = per_cpu_ptr(txq->pcpu, cpu);
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/5] net: mvpp2: add comments about smp_processor_id() usage
2017-06-08 15:27 [PATCH 0/5] net: mvpp2: fixes and cleanups Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 1/5] net: mvpp2: remove mvpp2_bm_cookie_{build,pool_get} Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 2/5] net: mvpp2: use {get,put}_cpu() instead of smp_processor_id() Thomas Petazzoni
@ 2017-06-08 15:27 ` Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 4/5] net: mvpp2: remove unused mvpp2_bm_cookie_pool_set() function Thomas Petazzoni
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2017-06-08 15:27 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Marcin Wojtas, Stefan Chulski, Nadav Haklai, Hanna Hawa,
Yehuda Yitschak, Antoine Tenart, Gregory Clement, Markus Elfring,
Marc Zyngier, Thomas Petazzoni
A previous commit modified a number of smp_processor_id() used in
migration-enabled contexts into get_cpu/put_cpu sections. However, a few
smp_processor_id() calls remain in the driver, and this commit adds
comments explaining why they can be kept.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/net/ethernet/marvell/mvpp2.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index fb6e9dc..037f6bd 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -4152,7 +4152,10 @@ static inline void mvpp2_interrupts_disable(struct mvpp2_port *port)
MVPP2_ISR_DISABLE_INTERRUPT(cpu_mask));
}
-/* Mask the current CPU's Rx/Tx interrupts */
+/* Mask the current CPU's Rx/Tx interrupts
+ * Called by on_each_cpu(), guaranteed to run with migration disabled,
+ * using smp_processor_id() is OK.
+ */
static void mvpp2_interrupts_mask(void *arg)
{
struct mvpp2_port *port = arg;
@@ -4161,7 +4164,10 @@ static void mvpp2_interrupts_mask(void *arg)
MVPP2_ISR_RX_TX_MASK_REG(port->id), 0);
}
-/* Unmask the current CPU's Rx/Tx interrupts */
+/* Unmask the current CPU's Rx/Tx interrupts.
+ * Called by on_each_cpu(), guaranteed to run with migration disabled,
+ * using smp_processor_id() is OK.
+ */
static void mvpp2_interrupts_unmask(void *arg)
{
struct mvpp2_port *port = arg;
@@ -4519,7 +4525,11 @@ mvpp2_txq_next_desc_get(struct mvpp2_tx_queue *txq)
return txq->descs + tx_desc;
}
-/* Update HW with number of aggregated Tx descriptors to be sent */
+/* Update HW with number of aggregated Tx descriptors to be sent
+ *
+ * Called only from mvpp2_tx(), so migration is disabled, using
+ * smp_processor_id() is OK.
+ */
static void mvpp2_aggr_txq_pend_desc_add(struct mvpp2_port *port, int pending)
{
/* aggregated access - relevant TXQ number is written in TX desc */
@@ -4530,6 +4540,9 @@ static void mvpp2_aggr_txq_pend_desc_add(struct mvpp2_port *port, int pending)
/* Check if there are enough free descriptors in aggregated txq.
* If not, update the number of occupied descriptors and repeat the check.
+ *
+ * Called only from mvpp2_tx(), so migration is disabled, using
+ * smp_processor_id() is OK.
*/
static int mvpp2_aggr_desc_num_check(struct mvpp2 *priv,
struct mvpp2_tx_queue *aggr_txq, int num)
@@ -4548,7 +4561,12 @@ static int mvpp2_aggr_desc_num_check(struct mvpp2 *priv,
return 0;
}
-/* Reserved Tx descriptors allocation request */
+/* Reserved Tx descriptors allocation request
+ *
+ * Called only from mvpp2_txq_reserved_desc_num_proc(), itself called
+ * only by mvpp2_tx(), so migration is disabled, using
+ * smp_processor_id() is OK.
+ */
static int mvpp2_txq_alloc_reserved_desc(struct mvpp2 *priv,
struct mvpp2_tx_queue *txq, int num)
{
@@ -4652,6 +4670,10 @@ static u32 mvpp2_txq_desc_csum(int l3_offs, int l3_proto,
/* Get number of sent descriptors and decrement counter.
* The number of sent descriptors is returned.
* Per-CPU access
+ *
+ * Called only from mvpp2_txq_done(), called from mvpp2_tx()
+ * (migration disabled) and from the TX completion tasklet (migration
+ * disabled) so using smp_processor_id() is OK.
*/
static inline int mvpp2_txq_sent_desc_proc(struct mvpp2_port *port,
struct mvpp2_tx_queue *txq)
@@ -4666,6 +4688,9 @@ static inline int mvpp2_txq_sent_desc_proc(struct mvpp2_port *port,
MVPP2_TRANSMITTED_COUNT_OFFSET;
}
+/* Called through on_each_cpu(), so runs on all CPUs, with migration
+ * disabled, therefore using smp_processor_id() is OK.
+ */
static void mvpp2_txq_sent_counter_clear(void *arg)
{
struct mvpp2_port *port = arg;
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/5] net: mvpp2: remove unused mvpp2_bm_cookie_pool_set() function
2017-06-08 15:27 [PATCH 0/5] net: mvpp2: fixes and cleanups Thomas Petazzoni
` (2 preceding siblings ...)
2017-06-08 15:27 ` [PATCH 3/5] net: mvpp2: add comments about smp_processor_id() usage Thomas Petazzoni
@ 2017-06-08 15:27 ` Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 5/5] net: mvpp2: remove mvpp2_pool_refill() Thomas Petazzoni
2017-06-08 20:11 ` [PATCH 0/5] net: mvpp2: fixes and cleanups David Miller
5 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2017-06-08 15:27 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Marcin Wojtas, Stefan Chulski, Nadav Haklai, Hanna Hawa,
Yehuda Yitschak, Antoine Tenart, Gregory Clement, Markus Elfring,
Marc Zyngier, Thomas Petazzoni
This function is not used in the driver, remove it.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/net/ethernet/marvell/mvpp2.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 037f6bd..4ca1639 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3907,17 +3907,6 @@ static void *mvpp2_buf_alloc(struct mvpp2_port *port,
return data;
}
-/* Set pool number in a BM cookie */
-static inline u32 mvpp2_bm_cookie_pool_set(u32 cookie, int pool)
-{
- u32 bm;
-
- bm = cookie & ~(0xFF << MVPP2_BM_COOKIE_POOL_OFFS);
- bm |= ((pool & 0xFF) << MVPP2_BM_COOKIE_POOL_OFFS);
-
- return bm;
-}
-
/* Release buffer to BM */
static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
dma_addr_t buf_dma_addr,
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/5] net: mvpp2: remove mvpp2_pool_refill()
2017-06-08 15:27 [PATCH 0/5] net: mvpp2: fixes and cleanups Thomas Petazzoni
` (3 preceding siblings ...)
2017-06-08 15:27 ` [PATCH 4/5] net: mvpp2: remove unused mvpp2_bm_cookie_pool_set() function Thomas Petazzoni
@ 2017-06-08 15:27 ` Thomas Petazzoni
2017-06-08 20:11 ` [PATCH 0/5] net: mvpp2: fixes and cleanups David Miller
5 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2017-06-08 15:27 UTC (permalink / raw)
To: David S. Miller, netdev
Cc: Marcin Wojtas, Stefan Chulski, Nadav Haklai, Hanna Hawa,
Yehuda Yitschak, Antoine Tenart, Gregory Clement, Markus Elfring,
Marc Zyngier, Thomas Petazzoni
When all a function does is calling another function with the exact same
arguments, in the exact same order, you know it's time to remove said
function. Which is exactly what this commit does.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/net/ethernet/marvell/mvpp2.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 4ca1639..747e3a4 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3943,14 +3943,6 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
put_cpu();
}
-/* Refill BM pool */
-static void mvpp2_pool_refill(struct mvpp2_port *port, int pool,
- dma_addr_t dma_addr,
- phys_addr_t phys_addr)
-{
- mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
-}
-
/* Allocate buffers for the pool */
static int mvpp2_bm_bufs_add(struct mvpp2_port *port,
struct mvpp2_bm_pool *bm_pool, int buf_num)
@@ -4980,7 +4972,7 @@ static void mvpp2_rxq_drop_pkts(struct mvpp2_port *port,
pool = (status & MVPP2_RXD_BM_POOL_ID_MASK) >>
MVPP2_RXD_BM_POOL_ID_OFFS;
- mvpp2_pool_refill(port, pool,
+ mvpp2_bm_pool_put(port, pool,
mvpp2_rxdesc_dma_addr_get(port, rx_desc),
mvpp2_rxdesc_cookie_get(port, rx_desc));
}
@@ -5434,7 +5426,7 @@ static int mvpp2_rx_refill(struct mvpp2_port *port,
if (!buf)
return -ENOMEM;
- mvpp2_pool_refill(port, pool, dma_addr, phys_addr);
+ mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
return 0;
}
@@ -5518,7 +5510,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
dev->stats.rx_errors++;
mvpp2_rx_error(port, rx_desc);
/* Return the buffer to the pool */
- mvpp2_pool_refill(port, pool, dma_addr, phys_addr);
+ mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
continue;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/5] net: mvpp2: use {get,put}_cpu() instead of smp_processor_id()
2017-06-08 15:27 ` [PATCH 2/5] net: mvpp2: use {get,put}_cpu() instead of smp_processor_id() Thomas Petazzoni
@ 2017-06-08 16:01 ` Marc Zyngier
0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2017-06-08 16:01 UTC (permalink / raw)
To: Thomas Petazzoni, David S. Miller, netdev
Cc: Marcin Wojtas, Stefan Chulski, Nadav Haklai, Hanna Hawa,
Yehuda Yitschak, Antoine Tenart, Gregory Clement, Markus Elfring
On 08/06/17 16:27, Thomas Petazzoni wrote:
> smp_processor_id() should not be used in migration-enabled contexts. We
> originally thought it was OK in the specific situation of this driver,
> but it was wrong, and calling smp_processor_id() in a migration-enabled
> context prints a big fat warning when CONFIG_DEBUG_PREEMPT=y.
>
> Therefore, this commit replaces the smp_processor_id() in
> migration-enabled contexts by the appropriate get_cpu/put_cpu sections.
>
> Reported-by: Marc Zyngier <marc.zyngier@arm.com>
> Fixes: a786841df72e ("net: mvpp2: handle register mapping and access for PPv2.2")
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Marc Zyngier <marc.zyngier@arm.com>
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/5] net: mvpp2: fixes and cleanups
2017-06-08 15:27 [PATCH 0/5] net: mvpp2: fixes and cleanups Thomas Petazzoni
` (4 preceding siblings ...)
2017-06-08 15:27 ` [PATCH 5/5] net: mvpp2: remove mvpp2_pool_refill() Thomas Petazzoni
@ 2017-06-08 20:11 ` David Miller
5 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2017-06-08 20:11 UTC (permalink / raw)
To: thomas.petazzoni
Cc: netdev, mw, stefanc, nadavh, hannah, yehuday, antoine.tenart,
gregory.clement, elfring, marc.zyngier
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Thu, 8 Jun 2017 17:27:22 +0200
> Here is a small set of fixes/improvements for the mvpp2 driver.
>
> The first two patches are fixes: they fix bogus usage of
> smp_processor_id() in a migration-enabled context. Indeed currently
> the driver outputs some fat warnings in CONFIG_DEBUG_PREEMPT-enabled
> kernels. Therefore, some fixes should be pushed to stable.
>
> The last three patches are cleanups and not needed for stable, but
> they stack on top of the fixes.
Please do not mix genuine bug fixes and cleanups.
You must submit them separately.
Send the fixes targetting 'net', and once those are accepted and
'net' is merged into 'net-next', you can submit the cleanups.
Thank you.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/5] net: mvpp2: remove mvpp2_bm_cookie_{build,pool_get}
2017-06-08 15:27 ` [PATCH 1/5] net: mvpp2: remove mvpp2_bm_cookie_{build,pool_get} Thomas Petazzoni
@ 2017-06-09 8:22 ` kbuild test robot
0 siblings, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2017-06-09 8:22 UTC (permalink / raw)
To: Thomas Petazzoni
Cc: kbuild-all, David S. Miller, netdev, Marcin Wojtas,
Stefan Chulski, Nadav Haklai, Hanna Hawa, Yehuda Yitschak,
Antoine Tenart, Gregory Clement, Markus Elfring, Marc Zyngier,
Thomas Petazzoni
[-- Attachment #1: Type: text/plain, Size: 2483 bytes --]
Hi Thomas,
[auto build test ERROR on net-next/master]
[also build test ERROR on v4.12-rc4 next-20170608]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Thomas-Petazzoni/net-mvpp2-fixes-and-cleanups/20170609-083211
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64
Note: the linux-review/Thomas-Petazzoni/net-mvpp2-fixes-and-cleanups/20170609-083211 HEAD 5a6bfd0022913d8ffcfd0eae9235b9bee844cf53 builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
drivers/net/ethernet/marvell/mvpp2.c: In function 'mvpp2_bm_cookie_pool_set':
>> drivers/net/ethernet/marvell/mvpp2.c:3913:26: error: 'MVPP2_BM_COOKIE_POOL_OFFS' undeclared (first use in this function)
bm = cookie & ~(0xFF << MVPP2_BM_COOKIE_POOL_OFFS);
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/marvell/mvpp2.c:3913:26: note: each undeclared identifier is reported only once for each function it appears in
vim +/MVPP2_BM_COOKIE_POOL_OFFS +3913 drivers/net/ethernet/marvell/mvpp2.c
3f518509 Marcin Wojtas 2014-07-10 3907
3f518509 Marcin Wojtas 2014-07-10 3908 /* Set pool number in a BM cookie */
3f518509 Marcin Wojtas 2014-07-10 3909 static inline u32 mvpp2_bm_cookie_pool_set(u32 cookie, int pool)
3f518509 Marcin Wojtas 2014-07-10 3910 {
3f518509 Marcin Wojtas 2014-07-10 3911 u32 bm;
3f518509 Marcin Wojtas 2014-07-10 3912
3f518509 Marcin Wojtas 2014-07-10 @3913 bm = cookie & ~(0xFF << MVPP2_BM_COOKIE_POOL_OFFS);
3f518509 Marcin Wojtas 2014-07-10 3914 bm |= ((pool & 0xFF) << MVPP2_BM_COOKIE_POOL_OFFS);
3f518509 Marcin Wojtas 2014-07-10 3915
3f518509 Marcin Wojtas 2014-07-10 3916 return bm;
:::::: The code at line 3913 was first introduced by commit
:::::: 3f518509dedc99f0b755d2ce68d24f610e3a005a ethernet: Add new driver for Marvell Armada 375 network unit
:::::: TO: Marcin Wojtas <mw@semihalf.com>
:::::: CC: David S. Miller <davem@davemloft.net>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35296 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-06-09 8:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-08 15:27 [PATCH 0/5] net: mvpp2: fixes and cleanups Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 1/5] net: mvpp2: remove mvpp2_bm_cookie_{build,pool_get} Thomas Petazzoni
2017-06-09 8:22 ` kbuild test robot
2017-06-08 15:27 ` [PATCH 2/5] net: mvpp2: use {get,put}_cpu() instead of smp_processor_id() Thomas Petazzoni
2017-06-08 16:01 ` Marc Zyngier
2017-06-08 15:27 ` [PATCH 3/5] net: mvpp2: add comments about smp_processor_id() usage Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 4/5] net: mvpp2: remove unused mvpp2_bm_cookie_pool_set() function Thomas Petazzoni
2017-06-08 15:27 ` [PATCH 5/5] net: mvpp2: remove mvpp2_pool_refill() Thomas Petazzoni
2017-06-08 20:11 ` [PATCH 0/5] net: mvpp2: fixes and cleanups David Miller
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).