[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250207124846.GP554665@kernel.org>
Date: Fri, 7 Feb 2025 12:48:46 +0000
From: Simon Horman <horms@...nel.org>
To: alucerop@....com
Cc: linux-cxl@...r.kernel.org, netdev@...r.kernel.org,
dan.j.williams@...el.com, edward.cree@....com, davem@...emloft.net,
kuba@...nel.org, pabeni@...hat.com, edumazet@...gle.com,
dave.jiang@...el.com
Subject: Re: [PATCH v10 02/26] sfc: add basic cxl initialization
On Wed, Feb 05, 2025 at 03:19:26PM +0000, alucerop@....com wrote:
> From: Alejandro Lucero <alucerop@....com>
>
> Create a cxl_memdev_state with CXL_DEVTYPE_DEVMEM, aka CXL Type2 memory
> device.
>
> Make sfc CXL initialization dependent on kernel CXL configuration.
>
> Signed-off-by: Alejandro Lucero <alucerop@....com>
...
> diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c
> new file mode 100644
> index 000000000000..69feffd4aec3
> --- /dev/null
> +++ b/drivers/net/ethernet/sfc/efx_cxl.c
> @@ -0,0 +1,60 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/****************************************************************************
> + *
> + * Driver for AMD network controllers and boards
> + * Copyright (C) 2024, Advanced Micro Devices, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation, incorporated herein by reference.
> + */
> +
> +#include <cxl/pci.h>
> +#include <cxl/cxl.h>
> +#include <linux/pci.h>
> +
> +#include "net_driver.h"
> +#include "efx_cxl.h"
> +
> +#define EFX_CTPIO_BUFFER_SIZE SZ_256M
> +
> +int efx_cxl_init(struct efx_probe_data *probe_data)
> +{
> + struct efx_nic *efx = &probe_data->efx;
> + struct pci_dev *pci_dev = efx->pci_dev;
> + struct efx_cxl *cxl;
> + u16 dvsec;
> +
> + probe_data->cxl_pio_initialised = false;
> +
> + dvsec = pci_find_dvsec_capability(pci_dev, PCI_VENDOR_ID_CXL,
> + CXL_DVSEC_PCIE_DEVICE);
> + if (!dvsec)
> + return 0;
> +
> + pci_dbg(pci_dev, "CXL_DVSEC_PCIE_DEVICE capability found\n");
> +
> + cxl = kzalloc(sizeof(*cxl), GFP_KERNEL);
> + if (!cxl)
> + return -ENOMEM;
> +
> + cxl->cxlmds = cxl_memdev_state_create(&pci_dev->dev, pci_dev->dev.id,
> + dvsec, CXL_DEVTYPE_DEVMEM);
> +
> + if (IS_ERR(cxl->cxlmds)) {
> + kfree(cxl);
Hi Alejandro,
cxl is freed on the line above but dereferenced on the line below.
> + return PTR_ERR(cxl->cxlmds);
> + }
> +
> + probe_data->cxl = cxl;
> +
> + return 0;
> +}
...
Powered by blists - more mailing lists