From: Leon Romanovsky <leon@kernel.org>
To: Shannon Nelson <shannon.nelson@amd.com>
Cc: brett.creeley@amd.com, davem@davemloft.net,
netdev@vger.kernel.org, kuba@kernel.org, drivers@pensando.io,
jiri@resnulli.us
Subject: Re: [PATCH v9 net-next 01/14] pds_core: initial framework for pds_core PF driver
Date: Sun, 9 Apr 2023 14:26:45 +0300 [thread overview]
Message-ID: <20230409112645.GS14869@unreal> (raw)
In-Reply-To: <20230406234143.11318-2-shannon.nelson@amd.com>
On Thu, Apr 06, 2023 at 04:41:30PM -0700, Shannon Nelson wrote:
> This is the initial PCI driver framework for the new pds_core device
> driver and its family of devices. This does the very basics of
> registering for the new PF PCI device 1dd8:100c, setting up debugfs
> entries, and registering with devlink.
>
> Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
> ---
> .../device_drivers/ethernet/amd/pds_core.rst | 40 ++
> .../device_drivers/ethernet/index.rst | 1 +
> drivers/net/ethernet/amd/pds_core/Makefile | 8 +
> drivers/net/ethernet/amd/pds_core/core.h | 63 ++
> drivers/net/ethernet/amd/pds_core/debugfs.c | 34 ++
> drivers/net/ethernet/amd/pds_core/main.c | 285 +++++++++
> include/linux/pds/pds_common.h | 14 +
> include/linux/pds/pds_core_if.h | 540 ++++++++++++++++++
> 8 files changed, 985 insertions(+)
> create mode 100644 Documentation/networking/device_drivers/ethernet/amd/pds_core.rst
> create mode 100644 drivers/net/ethernet/amd/pds_core/Makefile
> create mode 100644 drivers/net/ethernet/amd/pds_core/core.h
> create mode 100644 drivers/net/ethernet/amd/pds_core/debugfs.c
> create mode 100644 drivers/net/ethernet/amd/pds_core/main.c
> create mode 100644 include/linux/pds/pds_common.h
> create mode 100644 include/linux/pds/pds_core_if.h
<...>
> +#ifdef CONFIG_DEBUG_FS
> +void pdsc_debugfs_create(void);
> +void pdsc_debugfs_destroy(void);
> +void pdsc_debugfs_add_dev(struct pdsc *pdsc);
> +void pdsc_debugfs_del_dev(struct pdsc *pdsc);
> +#else
> +static inline void pdsc_debugfs_create(void) { }
> +static inline void pdsc_debugfs_destroy(void) { }
> +static inline void pdsc_debugfs_add_dev(struct pdsc *pdsc) { }
> +static inline void pdsc_debugfs_del_dev(struct pdsc *pdsc) { }
> +#endif
I don't think that you need CONFIG_DEBUG_FS guard as debugfs code is
built to handle this case, so you can call to internal debugfs_*() calls
without completed initialization of debugfs.
> +
> +#endif /* _PDSC_H_ */
> diff --git a/drivers/net/ethernet/amd/pds_core/debugfs.c b/drivers/net/ethernet/amd/pds_core/debugfs.c
> new file mode 100644
> index 000000000000..9b2385c19c41
> --- /dev/null
> +++ b/drivers/net/ethernet/amd/pds_core/debugfs.c
> @@ -0,0 +1,34 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright(c) 2023 Advanced Micro Devices, Inc */
> +
> +#ifdef CONFIG_DEBUG_FS
> +
> +#include <linux/pci.h>
> +
> +#include "core.h"
> +
> +static struct dentry *pdsc_dir;
> +
> +void pdsc_debugfs_create(void)
> +{
> + pdsc_dir = debugfs_create_dir(PDS_CORE_DRV_NAME, NULL);
> +}
> +
> +void pdsc_debugfs_destroy(void)
> +{
> + debugfs_remove_recursive(pdsc_dir);
> +}
> +
> +void pdsc_debugfs_add_dev(struct pdsc *pdsc)
> +{
> + pdsc->dentry = debugfs_create_dir(pci_name(pdsc->pdev), pdsc_dir);
> +
> + debugfs_create_ulong("state", 0400, pdsc->dentry, &pdsc->state);
> +}
> +
> +void pdsc_debugfs_del_dev(struct pdsc *pdsc)
> +{
> + debugfs_remove_recursive(pdsc->dentry);
> + pdsc->dentry = NULL;
> +}
> +#endif /* CONFIG_DEBUG_FS */
> diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c
> new file mode 100644
> index 000000000000..1c2f3fbaa27c
> --- /dev/null
> +++ b/drivers/net/ethernet/amd/pds_core/main.c
> @@ -0,0 +1,285 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright(c) 2023 Advanced Micro Devices, Inc */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/pci.h>
> +
> +#include <linux/pds/pds_common.h>
> +
> +#include "core.h"
> +
> +MODULE_DESCRIPTION(PDSC_DRV_DESCRIPTION);
> +MODULE_AUTHOR("Advanced Micro Devices, Inc");
> +MODULE_LICENSE("GPL");
> +
> +/* Supported devices */
> +static const struct pci_device_id pdsc_id_table[] = {
> + { PCI_VDEVICE(PENSANDO, PCI_DEVICE_ID_PENSANDO_CORE_PF) },
> + { 0, } /* end of table */
> +};
> +MODULE_DEVICE_TABLE(pci, pdsc_id_table);
> +
> +static void pdsc_unmap_bars(struct pdsc *pdsc)
> +{
> + struct pdsc_dev_bar *bars = pdsc->bars;
> + unsigned int i;
> +
> + for (i = 0; i < PDS_CORE_BARS_MAX; i++) {
> + if (bars[i].vaddr) {
> + pci_iounmap(pdsc->pdev, bars[i].vaddr);
> + bars[i].vaddr = NULL;
> + }
> +
> + bars[i].len = 0;
> + bars[i].bus_addr = 0;
> + bars[i].res_index = 0;
Why are you clearing it? You are going to release bars[] anyway.
It will be great to remove this zeroing pattern from whole driver
as it hides use-after-free bugs.
> + }
> +}
> +
> +static int pdsc_map_bars(struct pdsc *pdsc)
> +{
> + struct pdsc_dev_bar *bar = pdsc->bars;
> + struct pci_dev *pdev = pdsc->pdev;
> + struct device *dev = pdsc->dev;
> + struct pdsc_dev_bar *bars;
> + unsigned int i, j;
> + int num_bars = 0;
> + int err;
> + u32 sig;
> +
> + bars = pdsc->bars;
> + num_bars = 0;
You set it to zero 4 lines above.
> +
<...>
> +module_init(pdsc_init_module);
> +module_exit(pdsc_cleanup_module);
> diff --git a/include/linux/pds/pds_common.h b/include/linux/pds/pds_common.h
> new file mode 100644
> index 000000000000..bd041a5170a6
> --- /dev/null
> +++ b/include/linux/pds/pds_common.h
> @@ -0,0 +1,14 @@
> +/* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) OR BSD-2-Clause */
> +/* Copyright(c) 2023 Advanced Micro Devices, Inc. */
> +
> +#ifndef _PDS_COMMON_H_
> +#define _PDS_COMMON_H_
> +
> +#define PDS_CORE_DRV_NAME "pds_core"
It is KBUILD_MODNAME.
> +
> +/* the device's internal addressing uses up to 52 bits */
> +#define PDS_CORE_ADDR_LEN 52
> +#define PDS_CORE_ADDR_MASK (BIT_ULL(PDS_ADDR_LEN) - 1)
> +#define PDS_PAGE_SIZE 4096
Thanks
next prev parent reply other threads:[~2023-04-09 11:26 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 23:41 [PATCH v9 net-next 00/14] pds_core driver Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 01/14] pds_core: initial framework for pds_core PF driver Shannon Nelson
2023-04-09 11:26 ` Leon Romanovsky [this message]
2023-04-10 18:41 ` Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 02/14] pds_core: add devcmd device interfaces Shannon Nelson
2023-04-09 11:46 ` Leon Romanovsky
2023-04-10 19:05 ` Shannon Nelson
2023-04-13 8:33 ` Leon Romanovsky
2023-04-13 15:08 ` Jakub Kicinski
2023-04-14 0:00 ` Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 03/14] pds_core: health timer and workqueue Shannon Nelson
2023-04-09 11:51 ` Leon Romanovsky
2023-04-10 19:12 ` Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 04/14] pds_core: add devlink health facilities Shannon Nelson
2023-04-09 11:54 ` Leon Romanovsky
2023-04-10 19:18 ` Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 05/14] pds_core: set up device and adminq Shannon Nelson
2023-04-09 12:03 ` Leon Romanovsky
2023-04-10 19:27 ` Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 06/14] pds_core: Add adminq processing and commands Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 07/14] pds_core: add FW update feature to devlink Shannon Nelson
2023-04-10 15:44 ` Simon Horman
2023-04-10 22:59 ` Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 08/14] pds_core: set up the VIF definitions and defaults Shannon Nelson
2023-04-09 12:08 ` Leon Romanovsky
2023-04-10 19:36 ` Shannon Nelson
2023-04-13 8:36 ` Leon Romanovsky
2023-04-06 23:41 ` [PATCH v9 net-next 09/14] pds_core: add initial VF device handling Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 10/14] pds_core: add auxiliary_bus devices Shannon Nelson
2023-04-09 12:23 ` Leon Romanovsky
2023-04-10 20:02 ` Shannon Nelson
2023-04-13 8:43 ` Leon Romanovsky
2023-04-06 23:41 ` [PATCH v9 net-next 11/14] pds_core: devlink params for enabling VIF support Shannon Nelson
2023-04-06 23:41 ` [PATCH v9 net-next 12/14] pds_core: add the aux client API Shannon Nelson
2023-04-09 17:07 ` Leon Romanovsky
2023-04-10 20:50 ` Shannon Nelson
2023-04-13 8:45 ` Leon Romanovsky
2023-04-06 23:41 ` [PATCH v9 net-next 13/14] pds_core: publish events to the clients Shannon Nelson
2023-04-09 17:11 ` Leon Romanovsky
2023-04-10 21:01 ` Shannon Nelson
2023-04-13 8:55 ` Leon Romanovsky
2023-04-13 15:14 ` Jakub Kicinski
2023-04-13 16:44 ` Leon Romanovsky
2023-04-13 16:55 ` Jakub Kicinski
2023-04-13 17:07 ` Leon Romanovsky
2023-04-13 17:10 ` Jakub Kicinski
2023-04-13 23:42 ` Shannon Nelson
2023-04-14 8:51 ` Leon Romanovsky
2023-04-06 23:41 ` [PATCH v9 net-next 14/14] pds_core: Kconfig and pds_core.rst Shannon Nelson
2023-04-09 17:17 ` Leon Romanovsky
2023-04-10 21:05 ` Shannon Nelson
2023-04-08 3:18 ` [PATCH v9 net-next 00/14] pds_core driver Jakub Kicinski
2023-04-10 20:00 ` Alex Williamson
2023-04-10 21:05 ` Shannon Nelson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230409112645.GS14869@unreal \
--to=leon@kernel.org \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=drivers@pensando.io \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shannon.nelson@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).