Re: [PATCH] testing/cxl: Fix abused pci_bus_read_config_word() on platform device
From: Dan Williams
Date: Mon Oct 21 2024 - 16:47:53 EST
Ira Weiny wrote:
[..]
> > --- a/drivers/cxl/core/cdat.c
> > +++ b/drivers/cxl/core/cdat.c
> > @@ -5,6 +5,7 @@
> > #include <linux/fw_table.h>
> > #include <linux/node.h>
> > #include <linux/overflow.h>
> > +#include <linux/platform_device.h>
> > #include "cxlpci.h"
> > #include "cxlmem.h"
> > #include "core.h"
> > @@ -641,9 +642,13 @@ static int cxl_endpoint_gather_bandwidth(struct cxl_region *cxlr,
> > void *ptr;
> > int rc;
> >
> > + if (dev_is_pci(cxlds->dev))
>
> Did you mean...
>
> if (!dev_is_pci(cxlds->dev))
> ???
Yes, skip non-PCI.
[..]
> Couldn't this be done on the endpoint call? (Making it non-static?)
>
> int __wrap_cxl_endpoint_gather_bandwidth(...
> struct cxl_endpoint_decoder *cxled,
> ...)
> {
> struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
> struct cxl_dev_state *cxlds = cxlmd->cxlds;
>
> if (!dev_is_pci(cxlds->dev))
> return -ENODEV;
>
> return cxl_endpoint_gather_bandwidth(...);
> }
No, cxl_endpoint_gather_bandwidth() is called internal to cxl_core,
there is no opportunity to optionally wrap it, only replace it.
In order for this path to be mocked the cxl_region driver would need to
be moved to a module and then
cxl_region_shared_upstream_bandwidth_update() could be unit tested.