Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sfc: Initialise MCDI buffers to 0 on declaration.

In order to avoid MC bugs the flags field needs to be set to 0.
Instead of explicitly clearing out the flags individually, a
better way to do this is to memset the MCDI_BUF to 0.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jon Cooper and committed by
David S. Miller
aa09a3da 0d5e0fbb

+27 -23
+15 -13
drivers/net/ethernet/sfc/ef10.c
··· 378 378 379 379 static int efx_ef10_free_vis(struct efx_nic *efx) 380 380 { 381 - MCDI_DECLARE_BUF_OUT_OR_ERR(outbuf, 0); 381 + MCDI_DECLARE_BUF_ERR(outbuf); 382 382 size_t outlen; 383 383 int rc = efx_mcdi_rpc_quiet(efx, MC_CMD_FREE_VIS, NULL, 0, 384 384 outbuf, sizeof(outbuf), &outlen); ··· 449 449 static int efx_ef10_link_piobufs(struct efx_nic *efx) 450 450 { 451 451 struct efx_ef10_nic_data *nic_data = efx->nic_data; 452 - MCDI_DECLARE_BUF(inbuf, 453 - max(MC_CMD_LINK_PIOBUF_IN_LEN, 454 - MC_CMD_UNLINK_PIOBUF_IN_LEN)); 452 + _MCDI_DECLARE_BUF(inbuf, 453 + max(MC_CMD_LINK_PIOBUF_IN_LEN, 454 + MC_CMD_UNLINK_PIOBUF_IN_LEN)); 455 455 struct efx_channel *channel; 456 456 struct efx_tx_queue *tx_queue; 457 457 unsigned int offset, index; ··· 459 459 460 460 BUILD_BUG_ON(MC_CMD_LINK_PIOBUF_OUT_LEN != 0); 461 461 BUILD_BUG_ON(MC_CMD_UNLINK_PIOBUF_OUT_LEN != 0); 462 + 463 + memset(inbuf, 0, sizeof(inbuf)); 462 464 463 465 /* Link a buffer to each VI in the write-combining mapping */ 464 466 for (index = 0; index < nic_data->n_piobufs; ++index) { ··· 1408 1406 { 1409 1407 MCDI_DECLARE_BUF(inbuf, MC_CMD_INIT_TXQ_IN_LEN(EFX_MAX_DMAQ_SIZE * 8 / 1410 1408 EFX_BUF_SIZE)); 1411 - MCDI_DECLARE_BUF(outbuf, MC_CMD_INIT_TXQ_OUT_LEN); 1412 1409 bool csum_offload = tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD; 1413 1410 size_t entries = tx_queue->txd.buf.len / EFX_BUF_SIZE; 1414 1411 struct efx_channel *channel = tx_queue->channel; 1415 1412 struct efx_nic *efx = tx_queue->efx; 1416 1413 struct efx_ef10_nic_data *nic_data = efx->nic_data; 1417 - size_t inlen, outlen; 1414 + size_t inlen; 1418 1415 dma_addr_t dma_addr; 1419 1416 efx_qword_t *txd; 1420 1417 int rc; 1421 1418 int i; 1419 + BUILD_BUG_ON(MC_CMD_INIT_TXQ_OUT_LEN != 0); 1422 1420 1423 1421 MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_SIZE, tx_queue->ptr_mask + 1); 1424 1422 MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_TARGET_EVQ, channel->channel); ··· 1443 1441 inlen = MC_CMD_INIT_TXQ_IN_LEN(entries); 1444 1442 1445 1443 rc = efx_mcdi_rpc(efx, MC_CMD_INIT_TXQ, inbuf, inlen, 1446 - outbuf, sizeof(outbuf), &outlen); 1444 + NULL, 0, NULL); 1447 1445 if (rc) 1448 1446 goto fail; 1449 1447 ··· 1476 1474 static void efx_ef10_tx_fini(struct efx_tx_queue *tx_queue) 1477 1475 { 1478 1476 MCDI_DECLARE_BUF(inbuf, MC_CMD_FINI_TXQ_IN_LEN); 1479 - MCDI_DECLARE_BUF(outbuf, MC_CMD_FINI_TXQ_OUT_LEN); 1477 + MCDI_DECLARE_BUF_ERR(outbuf); 1480 1478 struct efx_nic *efx = tx_queue->efx; 1481 1479 size_t outlen; 1482 1480 int rc; ··· 1783 1781 MCDI_DECLARE_BUF(inbuf, 1784 1782 MC_CMD_INIT_RXQ_IN_LEN(EFX_MAX_DMAQ_SIZE * 8 / 1785 1783 EFX_BUF_SIZE)); 1786 - MCDI_DECLARE_BUF(outbuf, MC_CMD_INIT_RXQ_OUT_LEN); 1787 1784 struct efx_channel *channel = efx_rx_queue_channel(rx_queue); 1788 1785 size_t entries = rx_queue->rxd.buf.len / EFX_BUF_SIZE; 1789 1786 struct efx_nic *efx = rx_queue->efx; 1790 1787 struct efx_ef10_nic_data *nic_data = efx->nic_data; 1791 - size_t inlen, outlen; 1788 + size_t inlen; 1792 1789 dma_addr_t dma_addr; 1793 1790 int rc; 1794 1791 int i; 1792 + BUILD_BUG_ON(MC_CMD_INIT_RXQ_OUT_LEN != 0); 1795 1793 1796 1794 rx_queue->scatter_n = 0; 1797 1795 rx_queue->scatter_len = 0; ··· 1820 1818 inlen = MC_CMD_INIT_RXQ_IN_LEN(entries); 1821 1819 1822 1820 rc = efx_mcdi_rpc(efx, MC_CMD_INIT_RXQ, inbuf, inlen, 1823 - outbuf, sizeof(outbuf), &outlen); 1821 + NULL, 0, NULL); 1824 1822 if (rc) 1825 1823 netdev_WARN(efx->net_dev, "failed to initialise RXQ %d\n", 1826 1824 efx_rx_queue_index(rx_queue)); ··· 1829 1827 static void efx_ef10_rx_fini(struct efx_rx_queue *rx_queue) 1830 1828 { 1831 1829 MCDI_DECLARE_BUF(inbuf, MC_CMD_FINI_RXQ_IN_LEN); 1832 - MCDI_DECLARE_BUF(outbuf, MC_CMD_FINI_RXQ_OUT_LEN); 1830 + MCDI_DECLARE_BUF_ERR(outbuf); 1833 1831 struct efx_nic *efx = rx_queue->efx; 1834 1832 size_t outlen; 1835 1833 int rc; ··· 1991 1989 static void efx_ef10_ev_fini(struct efx_channel *channel) 1992 1990 { 1993 1991 MCDI_DECLARE_BUF(inbuf, MC_CMD_FINI_EVQ_IN_LEN); 1994 - MCDI_DECLARE_BUF(outbuf, MC_CMD_FINI_EVQ_OUT_LEN); 1992 + MCDI_DECLARE_BUF_ERR(outbuf); 1995 1993 struct efx_nic *efx = channel->efx; 1996 1994 size_t outlen; 1997 1995 int rc;
+4 -4
drivers/net/ethernet/sfc/mcdi.c
··· 406 406 struct efx_mcdi_async_param *async; 407 407 size_t hdr_len, data_len, err_len; 408 408 efx_dword_t *outbuf; 409 - MCDI_DECLARE_BUF_OUT_OR_ERR(errbuf, 0); 409 + MCDI_DECLARE_BUF_ERR(errbuf); 410 410 int rc; 411 411 412 412 if (cmpxchg(&mcdi->state, ··· 534 534 size_t *outlen_actual, bool quiet) 535 535 { 536 536 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); 537 - MCDI_DECLARE_BUF_OUT_OR_ERR(errbuf, 0); 537 + MCDI_DECLARE_BUF_ERR(errbuf); 538 538 int rc; 539 539 540 540 if (mcdi->mode == MCDI_MODE_POLL) ··· 1389 1389 static int efx_mcdi_read_assertion(struct efx_nic *efx) 1390 1390 { 1391 1391 MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_ASSERTS_IN_LEN); 1392 - MCDI_DECLARE_BUF_OUT_OR_ERR(outbuf, MC_CMD_GET_ASSERTS_OUT_LEN); 1392 + MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_ASSERTS_OUT_LEN); 1393 1393 unsigned int flags, index; 1394 1394 const char *reason; 1395 1395 size_t outlen; ··· 1699 1699 int efx_mcdi_get_workarounds(struct efx_nic *efx, unsigned int *impl_out, 1700 1700 unsigned int *enabled_out) 1701 1701 { 1702 - MCDI_DECLARE_BUF_OUT_OR_ERR(outbuf, MC_CMD_GET_WORKAROUNDS_OUT_LEN); 1702 + MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_WORKAROUNDS_OUT_LEN); 1703 1703 size_t outlen; 1704 1704 int rc; 1705 1705
+5 -3
drivers/net/ethernet/sfc/mcdi.h
··· 176 176 * 32-bit-aligned. Also, on Siena we must copy to the MC shared 177 177 * memory strictly 32 bits at a time, so add any necessary padding. 178 178 */ 179 - #define MCDI_DECLARE_BUF(_name, _len) \ 179 + #define _MCDI_DECLARE_BUF(_name, _len) \ 180 180 efx_dword_t _name[DIV_ROUND_UP(_len, 4)] 181 - #define MCDI_DECLARE_BUF_OUT_OR_ERR(_name, _len) \ 182 - MCDI_DECLARE_BUF(_name, max_t(size_t, _len, 8)) 181 + #define MCDI_DECLARE_BUF(_name, _len) \ 182 + _MCDI_DECLARE_BUF(_name, _len) = {{{0}}} 183 + #define MCDI_DECLARE_BUF_ERR(_name) \ 184 + MCDI_DECLARE_BUF(_name, 8) 183 185 #define _MCDI_PTR(_buf, _offset) \ 184 186 ((u8 *)(_buf) + (_offset)) 185 187 #define MCDI_PTR(_buf, _field) \
+3 -3
drivers/net/ethernet/sfc/ptp.c
··· 306 306 struct work_struct pps_work; 307 307 struct workqueue_struct *pps_workwq; 308 308 bool nic_ts_enabled; 309 - MCDI_DECLARE_BUF(txbuf, MC_CMD_PTP_IN_TRANSMIT_LENMAX); 309 + _MCDI_DECLARE_BUF(txbuf, MC_CMD_PTP_IN_TRANSMIT_LENMAX); 310 310 311 311 unsigned int good_syncs; 312 312 unsigned int fast_syncs; ··· 573 573 static int efx_ptp_enable(struct efx_nic *efx) 574 574 { 575 575 MCDI_DECLARE_BUF(inbuf, MC_CMD_PTP_IN_ENABLE_LEN); 576 - MCDI_DECLARE_BUF_OUT_OR_ERR(outbuf, 0); 576 + MCDI_DECLARE_BUF_ERR(outbuf); 577 577 int rc; 578 578 579 579 MCDI_SET_DWORD(inbuf, PTP_IN_OP, MC_CMD_PTP_OP_ENABLE); ··· 601 601 static int efx_ptp_disable(struct efx_nic *efx) 602 602 { 603 603 MCDI_DECLARE_BUF(inbuf, MC_CMD_PTP_IN_DISABLE_LEN); 604 - MCDI_DECLARE_BUF_OUT_OR_ERR(outbuf, 0); 604 + MCDI_DECLARE_BUF_ERR(outbuf); 605 605 int rc; 606 606 607 607 MCDI_SET_DWORD(inbuf, PTP_IN_OP, MC_CMD_PTP_OP_DISABLE);