lkml.org 
[lkml]   [2023]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 01/19] bus/cdx: add the cdx bus driver
Date
[AMD Official Use Only - General]



> -----Original Message-----
> From: Greg KH <gregkh@linuxfoundation.org>
> Sent: Tuesday, January 17, 2023 7:37 PM
> To: Gupta, Nipun <Nipun.Gupta@amd.com>
> Cc: robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; rafael@kernel.org;
> eric.auger@redhat.com; alex.williamson@redhat.com; cohuck@redhat.com;
> song.bao.hua@hisilicon.com; mchehab+huawei@kernel.org; maz@kernel.org;
> f.fainelli@gmail.com; jeffrey.l.hugo@gmail.com; saravanak@google.com;
> Michael.Srba@seznam.cz; mani@kernel.org; yishaih@nvidia.com;
> jgg@ziepe.ca; jgg@nvidia.com; robin.murphy@arm.com; will@kernel.org;
> joro@8bytes.org; masahiroy@kernel.org; ndesaulniers@google.com; linux-arm-
> kernel@lists.infradead.org; linux-kbuild@vger.kernel.org; linux-
> kernel@vger.kernel.org; devicetree@vger.kernel.org; okaya@kernel.org;
> Anand, Harpreet <harpreet.anand@amd.com>; Agarwal, Nikhil
> <nikhil.agarwal@amd.com>; Simek, Michal <michal.simek@amd.com>; git
> (AMD-Xilinx) <git@amd.com>
> Subject: Re: [PATCH 01/19] bus/cdx: add the cdx bus driver
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Tue, Jan 17, 2023 at 07:11:33PM +0530, Nipun Gupta wrote:
> > Introduce AMD CDX bus, which provides a mechanism for scanning
> > and probing CDX devices. These devices are memory mapped on
> > system bus for Application Processors(APUs).
> >
> > CDX devices can be changed dynamically in the Fabric and CDX
> > bus interacts with CDX controller to rescan the bus and
> > rediscover the devices.
> >
> > Signed-off-by: Nipun Gupta <nipun.gupta@amd.com>
> > Signed-off-by: Tarak Reddy <tarak.reddy@amd.com>
>
> First off, very nice job, I didn't find any obvious issues with this
> integration into the driver core.
>
> That being said, why do you want this in drivers/bus/? Why not
> drivers/cdx/ ?

Thanks, Greg, for taking time out for review and providing your valuable
feedback. We do not have strong affiliation to drivers/bus/cdx so will move
it to drivers/cdx in the next spin.

>
> One minor comment to make the code smaller:
>
> > +static int get_free_index(void)
> > +{
> > + unsigned long id_map;
> > + unsigned long mask;
> > + int index = 0;
> > +
> > + mask = (1UL << MAX_CDX_CONTROLLERS) - 1;
> > +retry:
> > + id_map = cdx_controller_id_map[0];
> > + if ((id_map & mask) == mask)
> > + return -ENOSPC;
> > +
> > + index = ffz(id_map);
> > + if (index >= MAX_CDX_CONTROLLERS)
> > + return -ENOSPC;
> > +
> > + if (test_and_set_bit(index, &cdx_controller_id_map[0]))
> > + goto retry;
> > +
> > + return index;
> > +}
>
> Why not just use the idr/ida structure instead? That will handle all of
> that logic for you and get rid of your bit twiddling.

Agree. Using idr/ida seems more appropriate. Will update the code
accordingly.

>
> > +/**
> > + * struct cdx_dev_params - CDX device parameters
> > + * @cdx: CDX controller associated with the device
> > + * @parent: Associated CDX controller
> > + * @vendor: Vendor ID for CDX device
> > + * @device: Device ID for CDX device
> > + * @bus_num: Bus number for this CDX device
> > + * @dev_num: Device number for this device
> > + * @res: array of MMIO region entries
> > + * @res_count: number of valid MMIO regions
> > + * @req_id: Requestor ID associated with CDX device
> > + */
> > +struct cdx_dev_params {
> > + struct cdx_controller *cdx;
> > + u16 vendor;
> > + u16 device;
>
> Are these in little endian format in memory? Or native? Or something
> else?

While reading from the hardware, these values are little-endian; and
they are converted to CPU endianness by the controller code using
le_to_cpu32() and then passed as CPU endian while registering the
CDX device.

Thanks,
Nipun

>
> thanks,
>
> greg k-h

\
 
 \ /
  Last update: 2023-03-26 23:45    [W:0.094 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site