]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: provide plat_dat->dma_cfg in stmmac_plat_dat_alloc()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 9 Mar 2026 09:39:18 +0000 (09:39 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 11 Mar 2026 02:54:06 +0000 (19:54 -0700)
plat_dat->dma_cfg is unconditionally required for the operation of the
driver, so it would make sense to allocate it along with the plat_dat.

On Arm64, sizeof(*plat_dat) has recently shrunk from 880 to 816 bytes
and sizeof(*plat_dat->dma_cfg) has shrunk from 32 to 20 bytes.

Given that dma_cfg is required, and it is now less than a cache line,
It doesn't make sense to allocate this separateny, so place it at the
end of struct plat_stmmacenet_data, and set plat_dat->dma_cfg to point
at that to avoid mass changes.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Tested-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Link: https://patch.msgid.link/E1vzX54-0000000CVrw-2jfu@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
include/linux/stmmac.h

index fc13bfb477838f32c9a18492d51af59650a41e0b..0b32560cd059de430ec7597351f5c82c15a031a3 100644 (file)
@@ -1251,11 +1251,6 @@ static int intel_eth_pci_probe(struct pci_dev *pdev,
        if (!plat->mdio_bus_data)
                return -ENOMEM;
 
-       plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg),
-                                    GFP_KERNEL);
-       if (!plat->dma_cfg)
-               return -ENOMEM;
-
        plat->safety_feat_cfg = devm_kzalloc(&pdev->dev,
                                             sizeof(*plat->safety_feat_cfg),
                                             GFP_KERNEL);
index ada6c6ef1f5cbdecd8127671c95c5cca17ffff80..51b1562f84d1dfc7f0c43b66cc5fa1987678483a 100644 (file)
@@ -513,10 +513,6 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
        if (!plat->mdio_bus_data)
                return -ENOMEM;
 
-       plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
-       if (!plat->dma_cfg)
-               return -ENOMEM;
-
        ld = devm_kzalloc(&pdev->dev, sizeof(*ld), GFP_KERNEL);
        if (!ld)
                return -ENOMEM;
index 8b45b9cf7202ff84e06c70804a4d12f574e10170..d245546b90db62021f68b7c4046093c857ddb30a 100644 (file)
@@ -218,10 +218,6 @@ motorcomm_default_plat_data(struct pci_dev *pdev)
        if (!plat->mdio_bus_data)
                return NULL;
 
-       plat->dma_cfg = devm_kzalloc(dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
-       if (!plat->dma_cfg)
-               return NULL;
-
        plat->axi = devm_kzalloc(dev, sizeof(*plat->axi), GFP_KERNEL);
        if (!plat->axi)
                return NULL;
index f0160ff54a59b054ee7a944218486a97ba376d1f..87f43811faa0112612a907385a66dc0ad844b1b0 100644 (file)
@@ -7730,6 +7730,8 @@ struct plat_stmmacenet_data *stmmac_plat_dat_alloc(struct device *dev)
        if (!plat_dat)
                return NULL;
 
+       plat_dat->dma_cfg = &plat_dat->__dma_cfg;
+
        /* Set the defaults:
         * - phy autodetection
         * - determine GMII_Address CR field from CSR clock
index 270ad066ced31f97c3d0d3a41440dfa75ed02578..836fed7d60ab3b2927b0a6c84934db715c1bc7a4 100644 (file)
@@ -134,11 +134,6 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
        if (!plat->mdio_bus_data)
                return -ENOMEM;
 
-       plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg),
-                                    GFP_KERNEL);
-       if (!plat->dma_cfg)
-               return -ENOMEM;
-
        plat->safety_feat_cfg = devm_kzalloc(&pdev->dev,
                                             sizeof(*plat->safety_feat_cfg),
                                             GFP_KERNEL);
index c34998486293693ea91da6e1d064b1fa653ad682..1aed48fe0db6c7bb2f943ac1a1aea57b544a5233 100644 (file)
@@ -548,13 +548,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
                                     &plat->multicast_filter_bins);
        }
 
-       dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
-                              GFP_KERNEL);
-       if (!dma_cfg) {
-               ret = ERR_PTR(-ENOMEM);
-               goto error_put_mdio;
-       }
-       plat->dma_cfg = dma_cfg;
+       dma_cfg = plat->dma_cfg;
 
        of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
        if (!dma_cfg->pbl)
index 965ada809fdfe833a0324eec2f2094d96ec692d9..919196713c05a94c638607f28e7507fa0f6e71ec 100644 (file)
@@ -306,5 +306,6 @@ struct plat_stmmacenet_data {
        int msi_tx_base_vec;
        const struct dwmac4_addrs *dwmac4_addrs;
        unsigned int flags;
+       struct stmmac_dma_cfg __dma_cfg;
 };
 #endif