From: "Gangurde, Abhijit" <abhijit.gangurde@amd.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: "masahiroy@kernel.org" <masahiroy@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Gupta, Nipun" <Nipun.Gupta@amd.com>,
"Agarwal, Nikhil" <nikhil.agarwal@amd.com>,
"Gupta, Puneet (DCG-ENG)" <puneet.gupta@amd.com>,
"git (AMD-Xilinx)" <git@amd.com>,
"Simek, Michal" <michal.simek@amd.com>
Subject: RE: [PATCH v3 1/5] cdx: Remove cdx controller list from cdx bus system
Date: Thu, 24 Aug 2023 12:10:55 +0000 [thread overview]
Message-ID: <DM4PR12MB7765CC9DA9EAC441CE389A278F1DA@DM4PR12MB7765.namprd12.prod.outlook.com> (raw)
In-Reply-To: <2023082207-humped-unclasp-6058@gregkh>
> On Mon, Aug 14, 2023 at 03:52:19PM +0530, Abhijit Gangurde wrote:
> > Remove xarray list of cdx controller. Instead, use platform bus
> > to locate the cdx controller using compat string used by cdx
> > controller platform driver.
>
> You also now use an ida instead, right? Do you need to mention that
> here?
Yes. Will add it in the description.
>
> > Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
> > ---
> > drivers/cdx/cdx.c | 39 ++++++++++++++++++++++++-------------
> > include/linux/cdx/cdx_bus.h | 2 ++
> > 2 files changed, 28 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c
> > index d2cad4c670a0..1c0f76cf4f15 100644
> > --- a/drivers/cdx/cdx.c
> > +++ b/drivers/cdx/cdx.c
> > @@ -60,7 +60,7 @@
> > #include <linux/of_device.h>
> > #include <linux/slab.h>
> > #include <linux/mm.h>
> > -#include <linux/xarray.h>
> > +#include <linux/idr.h>
> > #include <linux/cdx/cdx_bus.h>
> > #include <linux/iommu.h>
> > #include <linux/dma-map-ops.h>
> > @@ -70,8 +70,10 @@
> > #define CDX_DEFAULT_DMA_MASK (~0ULL)
> > #define MAX_CDX_CONTROLLERS 16
> >
> > -/* CDX controllers registered with the CDX bus */
> > -static DEFINE_XARRAY_ALLOC(cdx_controllers);
> > +/* IDA for CDX controllers registered with the CDX bus */
> > +DEFINE_IDA(cdx_controller_ida);
>
> Why is this now a global variable?
This should have been static. Will correct this in next version.
>
> thanks,
>
> > +
> > +static char *compat_node_name = "xlnx,versal-net-cdx";
> >
> > /**
> > * cdx_dev_reset - Reset a CDX device
> > @@ -384,7 +386,8 @@ static ssize_t rescan_store(const struct bus_type
> *bus,
> > const char *buf, size_t count)
> > {
> > struct cdx_controller *cdx;
> > - unsigned long index;
> > + struct platform_device *pd;
> > + struct device_node *np;
> > bool val;
> >
> > if (kstrtobool(buf, &val) < 0)
> > @@ -397,12 +400,19 @@ static ssize_t rescan_store(const struct bus_type
> *bus,
> > cdx_unregister_devices(&cdx_bus_type);
> >
> > /* Rescan all the devices */
> > - xa_for_each(&cdx_controllers, index, cdx) {
> > - int ret;
> > + for_each_compatible_node(np, NULL, compat_node_name) {
> > + if (!np)
> > + return -EINVAL;
> >
> > - ret = cdx->ops->scan(cdx);
> > - if (ret)
> > - dev_err(cdx->dev, "cdx bus scanning failed\n");
> > + pd = of_find_device_by_node(np);
> > + if (!pd)
> > + return -EINVAL;
> > +
> > + cdx = platform_get_drvdata(pd);
> > + if (cdx && cdx->controller_registered && cdx->ops->scan)
> > + cdx->ops->scan(cdx);
> > +
> > + put_device(&pd->dev);
>
> What handles the locking here? What if a new device is added , or
> removed, while you iterate this?
>
> And what about racing with the controller_registered flag? Are you sure
> that's needed?
>
As you highlighted, locking is introduced in patch 2 of this series.
Thanks,
Abhijit
next prev parent reply other threads:[~2023-08-24 12:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 10:22 [PATCH v3 0/5] cdx: provide sysfs interface for cdx device resources Abhijit Gangurde
2023-08-14 10:22 ` [PATCH v3 1/5] cdx: Remove cdx controller list from cdx bus system Abhijit Gangurde
2023-08-22 14:06 ` Greg KH
2023-08-24 12:10 ` Gangurde, Abhijit [this message]
2023-08-14 10:22 ` [PATCH v3 2/5] cdx: Introduce lock to protect controller ops Abhijit Gangurde
2023-08-22 14:06 ` Greg KH
2023-08-14 10:22 ` [PATCH v3 3/5] cdx: add support for bus enable and disable Abhijit Gangurde
2023-08-22 14:08 ` Greg KH
2023-08-24 12:11 ` Gangurde, Abhijit
2023-08-14 10:22 ` [PATCH v3 4/5] cdx: add sysfs for bus reset Abhijit Gangurde
2023-08-14 10:22 ` [PATCH v3 5/5] cdx: add sysfs for subsystem, class and revision Abhijit Gangurde
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=DM4PR12MB7765CC9DA9EAC441CE389A278F1DA@DM4PR12MB7765.namprd12.prod.outlook.com \
--to=abhijit.gangurde@amd.com \
--cc=Nipun.Gupta@amd.com \
--cc=git@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=michal.simek@amd.com \
--cc=nikhil.agarwal@amd.com \
--cc=puneet.gupta@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
all inboxes | Powered by JetHome®