Skip to content

Commit 89ba464

Browse files
DanielmachonPaolo Abeni
authored andcommitted
net: lan966x: refactor buffer reload function
Now that we store everything in the fdma structs, refactor lan966x_fdma_reload() to store and restore the entire struct. Signed-off-by: Daniel Machon <[email protected]> Reviewed-by: Horatiu Vultur <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 9fbc571 commit 89ba464

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -810,14 +810,11 @@ static int lan966x_qsys_sw_status(struct lan966x *lan966x)
810810
static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu)
811811
{
812812
struct page_pool *page_pool;
813-
dma_addr_t rx_dma;
814-
void *rx_dcbs;
815-
u32 size;
813+
struct fdma fdma_rx_old;
816814
int err;
817815

818816
/* Store these for later to free them */
819-
rx_dma = lan966x->rx.fdma.dma;
820-
rx_dcbs = lan966x->rx.fdma.dcbs;
817+
memcpy(&fdma_rx_old, &lan966x->rx.fdma, sizeof(struct fdma));
821818
page_pool = lan966x->rx.page_pool;
822819

823820
napi_synchronize(&lan966x->napi);
@@ -833,9 +830,7 @@ static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu)
833830
goto restore;
834831
lan966x_fdma_rx_start(&lan966x->rx);
835832

836-
size = sizeof(struct fdma_dcb) * lan966x->rx.fdma.n_dcbs;
837-
size = ALIGN(size, PAGE_SIZE);
838-
dma_free_coherent(lan966x->dev, size, rx_dcbs, rx_dma);
833+
fdma_free_coherent(lan966x->dev, &fdma_rx_old);
839834

840835
page_pool_destroy(page_pool);
841836

@@ -845,8 +840,7 @@ static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu)
845840
return err;
846841
restore:
847842
lan966x->rx.page_pool = page_pool;
848-
lan966x->rx.fdma.dma = rx_dma;
849-
lan966x->rx.fdma.dcbs = rx_dcbs;
843+
memcpy(&lan966x->rx.fdma, &fdma_rx_old, sizeof(struct fdma));
850844
lan966x_fdma_rx_start(&lan966x->rx);
851845

852846
return err;

0 commit comments

Comments
 (0)