Skip to content

Commit e01b16a

Browse files
ecree-solarflaredavem330
authored andcommitted
sfc: remove EFX_BUG_ON_PARANOID, use EFX_WARN_ON_[ONCE_]PARANOID instead
Logically, EFX_BUG_ON_PARANOID can never be correct. For, BUG_ON should only be used if it is not possible to continue without potential harm; and since the non-DEBUG driver will continue regardless (as the BUG_ON is compiled out), clearly the BUG_ON cannot be needed in the DEBUG driver. So, replace every EFX_BUG_ON_PARANOID with either an EFX_WARN_ON_PARANOID or the newly defined EFX_WARN_ON_ONCE_PARANOID. Signed-off-by: Edward Cree <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 816fba3 commit e01b16a

File tree

13 files changed

+55
-56
lines changed

13 files changed

+55
-56
lines changed

drivers/net/ethernet/sfc/ef10.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@ static int efx_ef10_tx_tso_desc(struct efx_tx_queue *tx_queue,
21002100
u32 seqnum;
21012101
u32 mss;
21022102

2103-
EFX_BUG_ON_PARANOID(tx_queue->tso_version != 2);
2103+
EFX_WARN_ON_ONCE_PARANOID(tx_queue->tso_version != 2);
21042104

21052105
mss = skb_shinfo(skb)->gso_size;
21062106

drivers/net/ethernet/sfc/efx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static int efx_probe_eventq(struct efx_channel *channel)
355355
/* Build an event queue with room for one event per tx and rx buffer,
356356
* plus some extra for link state events and MCDI completions. */
357357
entries = roundup_pow_of_two(efx->rxq_entries + efx->txq_entries + 128);
358-
EFX_BUG_ON_PARANOID(entries > EFX_MAX_EVQ_SIZE);
358+
EFX_WARN_ON_PARANOID(entries > EFX_MAX_EVQ_SIZE);
359359
channel->eventq_mask = max(entries, EFX_MIN_EVQ_SIZE) - 1;
360360

361361
return efx_nic_probe_eventq(channel);

drivers/net/ethernet/sfc/ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,12 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
333333
"core", 0, "registers", NULL);
334334

335335
if (efx->phy_op->run_tests != NULL) {
336-
EFX_BUG_ON_PARANOID(efx->phy_op->test_name == NULL);
336+
EFX_WARN_ON_PARANOID(efx->phy_op->test_name == NULL);
337337

338338
for (i = 0; true; ++i) {
339339
const char *name;
340340

341-
EFX_BUG_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
341+
EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
342342
name = efx->phy_op->test_name(efx, i);
343343
if (name == NULL)
344344
break;

drivers/net/ethernet/sfc/farch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
177177
dma_addr_t dma_addr;
178178
int i;
179179

180-
EFX_BUG_ON_PARANOID(!buffer->buf.addr);
180+
EFX_WARN_ON_PARANOID(!buffer->buf.addr);
181181

182182
/* Write buffer descriptors to NIC */
183183
for (i = 0; i < buffer->entries; i++) {
@@ -332,7 +332,7 @@ void efx_farch_tx_write(struct efx_tx_queue *tx_queue)
332332
txd = efx_tx_desc(tx_queue, write_ptr);
333333
++tx_queue->write_count;
334334

335-
EFX_BUG_ON_PARANOID(buffer->flags & EFX_TX_BUF_OPTION);
335+
EFX_WARN_ON_ONCE_PARANOID(buffer->flags & EFX_TX_BUF_OPTION);
336336

337337
/* Create TX descriptor ring entry */
338338
BUILD_BUG_ON(EFX_TX_BUF_CONT != 1);
@@ -2041,7 +2041,7 @@ efx_farch_filter_from_gen_spec(struct efx_farch_filter_spec *spec,
20412041
__be32 rhost, host1, host2;
20422042
__be16 rport, port1, port2;
20432043

2044-
EFX_BUG_ON_PARANOID(!(gen_spec->flags & EFX_FILTER_FLAG_RX));
2044+
EFX_WARN_ON_PARANOID(!(gen_spec->flags & EFX_FILTER_FLAG_RX));
20452045

20462046
if (gen_spec->ether_type != htons(ETH_P_IP))
20472047
return -EPROTONOSUPPORT;

drivers/net/ethernet/sfc/mcdi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ struct efx_mcdi_data {
129129

130130
static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
131131
{
132-
EFX_BUG_ON_PARANOID(!efx->mcdi);
132+
EFX_WARN_ON_PARANOID(!efx->mcdi);
133133
return &efx->mcdi->iface;
134134
}
135135

136136
#ifdef CONFIG_SFC_MCDI_MON
137137
static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx)
138138
{
139-
EFX_BUG_ON_PARANOID(!efx->mcdi);
139+
EFX_WARN_ON_PARANOID(!efx->mcdi);
140140
return &efx->mcdi->hwmon;
141141
}
142142
#endif

drivers/net/ethernet/sfc/mcdi_mon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
121121
}
122122
if (!name)
123123
name = "No sensor name available";
124-
EFX_BUG_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names));
124+
EFX_WARN_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names));
125125
state_txt = sensor_status_names[state];
126-
EFX_BUG_ON_PARANOID(hwmon_type >= EFX_HWMON_TYPES_COUNT);
126+
EFX_WARN_ON_PARANOID(hwmon_type >= EFX_HWMON_TYPES_COUNT);
127127
unit = efx_hwmon_unit[hwmon_type];
128128
if (!unit)
129129
unit = "";

drivers/net/ethernet/sfc/mcdi_port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev)
840840
u32 flags, fcntl, speed, lpa;
841841

842842
speed = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_SPEED);
843-
EFX_BUG_ON_PARANOID(speed >= ARRAY_SIZE(efx_mcdi_event_link_speed));
843+
EFX_WARN_ON_PARANOID(speed >= ARRAY_SIZE(efx_mcdi_event_link_speed));
844844
speed = efx_mcdi_event_link_speed[speed];
845845

846846
flags = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_LINK_FLAGS);

drivers/net/ethernet/sfc/net_driver.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
#define EFX_DRIVER_VERSION "4.1"
4545

4646
#ifdef DEBUG
47-
#define EFX_BUG_ON_PARANOID(x) BUG_ON(x)
47+
#define EFX_WARN_ON_ONCE_PARANOID(x) WARN_ON_ONCE(x)
4848
#define EFX_WARN_ON_PARANOID(x) WARN_ON(x)
4949
#else
50-
#define EFX_BUG_ON_PARANOID(x) do {} while (0)
50+
#define EFX_WARN_ON_ONCE_PARANOID(x) do {} while (0)
5151
#define EFX_WARN_ON_PARANOID(x) do {} while (0)
5252
#endif
5353

@@ -1409,7 +1409,7 @@ struct efx_nic_type {
14091409
static inline struct efx_channel *
14101410
efx_get_channel(struct efx_nic *efx, unsigned index)
14111411
{
1412-
EFX_BUG_ON_PARANOID(index >= efx->n_channels);
1412+
EFX_WARN_ON_ONCE_PARANOID(index >= efx->n_channels);
14131413
return efx->channel[index];
14141414
}
14151415

@@ -1430,8 +1430,8 @@ efx_get_channel(struct efx_nic *efx, unsigned index)
14301430
static inline struct efx_tx_queue *
14311431
efx_get_tx_queue(struct efx_nic *efx, unsigned index, unsigned type)
14321432
{
1433-
EFX_BUG_ON_PARANOID(index >= efx->n_tx_channels ||
1434-
type >= EFX_TXQ_TYPES);
1433+
EFX_WARN_ON_ONCE_PARANOID(index >= efx->n_tx_channels ||
1434+
type >= EFX_TXQ_TYPES);
14351435
return &efx->channel[efx->tx_channel_offset + index]->tx_queue[type];
14361436
}
14371437

@@ -1444,8 +1444,8 @@ static inline bool efx_channel_has_tx_queues(struct efx_channel *channel)
14441444
static inline struct efx_tx_queue *
14451445
efx_channel_get_tx_queue(struct efx_channel *channel, unsigned type)
14461446
{
1447-
EFX_BUG_ON_PARANOID(!efx_channel_has_tx_queues(channel) ||
1448-
type >= EFX_TXQ_TYPES);
1447+
EFX_WARN_ON_ONCE_PARANOID(!efx_channel_has_tx_queues(channel) ||
1448+
type >= EFX_TXQ_TYPES);
14491449
return &channel->tx_queue[type];
14501450
}
14511451

@@ -1482,7 +1482,7 @@ static inline bool efx_channel_has_rx_queue(struct efx_channel *channel)
14821482
static inline struct efx_rx_queue *
14831483
efx_channel_get_rx_queue(struct efx_channel *channel)
14841484
{
1485-
EFX_BUG_ON_PARANOID(!efx_channel_has_rx_queue(channel));
1485+
EFX_WARN_ON_ONCE_PARANOID(!efx_channel_has_rx_queue(channel));
14861486
return &channel->rx_queue;
14871487
}
14881488

@@ -1578,9 +1578,9 @@ efx_tx_queue_get_insert_buffer(const struct efx_tx_queue *tx_queue)
15781578
struct efx_tx_buffer *buffer =
15791579
__efx_tx_queue_get_insert_buffer(tx_queue);
15801580

1581-
EFX_BUG_ON_PARANOID(buffer->len);
1582-
EFX_BUG_ON_PARANOID(buffer->flags);
1583-
EFX_BUG_ON_PARANOID(buffer->unmap_len);
1581+
EFX_WARN_ON_ONCE_PARANOID(buffer->len);
1582+
EFX_WARN_ON_ONCE_PARANOID(buffer->flags);
1583+
EFX_WARN_ON_ONCE_PARANOID(buffer->unmap_len);
15841584

15851585
return buffer;
15861586
}

drivers/net/ethernet/sfc/ptp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
835835
ACCESS_ONCE(*start) = 0;
836836
rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
837837
MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
838-
EFX_BUG_ON_PARANOID(rc);
838+
EFX_WARN_ON_ONCE_PARANOID(rc);
839839

840840
/* Wait for start from MCDI (or timeout) */
841841
timeout = jiffies + msecs_to_jiffies(MAX_SYNCHRONISE_WAIT_MS);

drivers/net/ethernet/sfc/rx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic)
335335

336336
/* Calculate current fill level, and exit if we don't need to fill */
337337
fill_level = (rx_queue->added_count - rx_queue->removed_count);
338-
EFX_BUG_ON_PARANOID(fill_level > rx_queue->efx->rxq_entries);
338+
EFX_WARN_ON_ONCE_PARANOID(fill_level > rx_queue->efx->rxq_entries);
339339
if (fill_level >= rx_queue->fast_fill_trigger)
340340
goto out;
341341

@@ -347,7 +347,7 @@ void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic)
347347

348348
batch_size = efx->rx_pages_per_batch * efx->rx_bufs_per_page;
349349
space = rx_queue->max_fill - fill_level;
350-
EFX_BUG_ON_PARANOID(space < batch_size);
350+
EFX_WARN_ON_ONCE_PARANOID(space < batch_size);
351351

352352
netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev,
353353
"RX queue %d fast-filling descriptor ring from"
@@ -475,7 +475,7 @@ static struct sk_buff *efx_rx_mk_skb(struct efx_channel *channel,
475475
return NULL;
476476
}
477477

478-
EFX_BUG_ON_PARANOID(rx_buf->len < hdr_len);
478+
EFX_WARN_ON_ONCE_PARANOID(rx_buf->len < hdr_len);
479479

480480
memcpy(skb->data + efx->rx_ip_align, eh - efx->rx_prefix_size,
481481
efx->rx_prefix_size + hdr_len);
@@ -682,7 +682,7 @@ int efx_probe_rx_queue(struct efx_rx_queue *rx_queue)
682682

683683
/* Create the smallest power-of-two aligned ring */
684684
entries = max(roundup_pow_of_two(efx->rxq_entries), EFX_MIN_DMAQ_SIZE);
685-
EFX_BUG_ON_PARANOID(entries > EFX_MAX_DMAQ_SIZE);
685+
EFX_WARN_ON_PARANOID(entries > EFX_MAX_DMAQ_SIZE);
686686
rx_queue->ptr_mask = entries - 1;
687687

688688
netif_dbg(efx, probe, efx->net_dev,

0 commit comments

Comments
 (0)