Message ID | 20241114112435.45593-1-alejandro.lucero-palau@amd.com |
---|---|
State | Superseded |
Headers | show |
Series | cxl: avoid driver data for obtaining cxl_dev_state reference | expand |
On Thu, Nov 14, 2024 at 11:24:35AM +0000, alejandro.lucero-palau@amd.com wrote: > From: Alejandro Lucero <alejandro.lucero-palau@amd.com> > > CXL Type3 pci driver uses struct device driver_data for keeping > cxl_dev_state reference. Type1/2 drivers are not only about CXL so > this field so not be used when code requires cxl_dev_state to work with > and such a code used for Type2 support. This sentence is broken to me. Do you mean something like "Type1/2 drivers are not only about CXL and for type1/2 drivers this field is not always available for cxl_dev_state." ? Fan > > Change cxl_dvsec_rr_decode for passing cxl_dev_state as a parameter. > > Signed-off-by: Alejandro Lucero <alucerop@amd.com> > --- > drivers/cxl/core/pci.c | 6 +++--- > drivers/cxl/cxl.h | 2 +- > drivers/cxl/port.c | 2 +- > tools/testing/cxl/test/mock.c | 6 +++--- > 4 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c > index 5b46bc46aaa9..420e4be85a1f 100644 > --- a/drivers/cxl/core/pci.c > +++ b/drivers/cxl/core/pci.c > @@ -291,11 +291,11 @@ static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm) > return devm_add_action_or_reset(host, disable_hdm, cxlhdm); > } > > -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, > +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, > struct cxl_endpoint_dvsec_info *info) > { > - struct pci_dev *pdev = to_pci_dev(dev); > - struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); > + struct pci_dev *pdev = to_pci_dev(cxlds->dev); > + struct device *dev = cxlds->dev; > int hdm_count, rc, i, ranges = 0; > int d = cxlds->cxl_dvsec; > u16 cap, ctrl; > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > index 5406e3ab3d4a..42a46e78d786 100644 > --- a/drivers/cxl/cxl.h > +++ b/drivers/cxl/cxl.h > @@ -812,7 +812,7 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, > int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, > struct cxl_endpoint_dvsec_info *info); > int devm_cxl_add_passthrough_decoder(struct cxl_port *port); > -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, > +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, > struct cxl_endpoint_dvsec_info *info); > > bool is_cxl_region(struct device *dev); > diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c > index 9dc394295e1f..acf2ac70f343 100644 > --- a/drivers/cxl/port.c > +++ b/drivers/cxl/port.c > @@ -98,7 +98,7 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) > struct cxl_port *root; > int rc; > > - rc = cxl_dvsec_rr_decode(cxlds->dev, port, &info); > + rc = cxl_dvsec_rr_decode(cxlds, &info); > if (rc < 0) > return rc; > > diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c > index f4ce96cc11d4..4f82716cfc16 100644 > --- a/tools/testing/cxl/test/mock.c > +++ b/tools/testing/cxl/test/mock.c > @@ -228,16 +228,16 @@ int __wrap_cxl_hdm_decode_init(struct cxl_dev_state *cxlds, > } > EXPORT_SYMBOL_NS_GPL(__wrap_cxl_hdm_decode_init, CXL); > > -int __wrap_cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, > +int __wrap_cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, > struct cxl_endpoint_dvsec_info *info) > { > int rc = 0, index; > struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); > > - if (ops && ops->is_mock_dev(dev)) > + if (ops && ops->is_mock_dev(cxlds->dev)) > rc = 0; > else > - rc = cxl_dvsec_rr_decode(dev, port, info); > + rc = cxl_dvsec_rr_decode(cxlds, info); > put_cxl_mock_ops(index); > > return rc;
On 11/14/24 20:55, Fan Ni wrote: > On Thu, Nov 14, 2024 at 11:24:35AM +0000, alejandro.lucero-palau@amd.com wrote: >> From: Alejandro Lucero <alejandro.lucero-palau@amd.com> >> >> CXL Type3 pci driver uses struct device driver_data for keeping >> cxl_dev_state reference. Type1/2 drivers are not only about CXL so >> this field so not be used when code requires cxl_dev_state to work with >> and such a code used for Type2 support. > This sentence is broken to me. Do you mean something like "Type1/2 > drivers are not only about CXL and for type1/2 drivers this field > is not always available for cxl_dev_state." ? > > Fan Yes. I hope the original sentence makes sense when the typo about the second "so" is fixed: "CXL Type3 pci driver uses struct device driver_data for keeping cxl_dev_state reference. Type1/2 drivers are not only about CXL so this field should not be used when code requires cxl_dev_state to work with and such a code used for Type2 support." >> Change cxl_dvsec_rr_decode for passing cxl_dev_state as a parameter. >> >> Signed-off-by: Alejandro Lucero <alucerop@amd.com> >> --- >> drivers/cxl/core/pci.c | 6 +++--- >> drivers/cxl/cxl.h | 2 +- >> drivers/cxl/port.c | 2 +- >> tools/testing/cxl/test/mock.c | 6 +++--- >> 4 files changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c >> index 5b46bc46aaa9..420e4be85a1f 100644 >> --- a/drivers/cxl/core/pci.c >> +++ b/drivers/cxl/core/pci.c >> @@ -291,11 +291,11 @@ static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm) >> return devm_add_action_or_reset(host, disable_hdm, cxlhdm); >> } >> >> -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, >> +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, >> struct cxl_endpoint_dvsec_info *info) >> { >> - struct pci_dev *pdev = to_pci_dev(dev); >> - struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); >> + struct pci_dev *pdev = to_pci_dev(cxlds->dev); >> + struct device *dev = cxlds->dev; >> int hdm_count, rc, i, ranges = 0; >> int d = cxlds->cxl_dvsec; >> u16 cap, ctrl; >> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h >> index 5406e3ab3d4a..42a46e78d786 100644 >> --- a/drivers/cxl/cxl.h >> +++ b/drivers/cxl/cxl.h >> @@ -812,7 +812,7 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, >> int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, >> struct cxl_endpoint_dvsec_info *info); >> int devm_cxl_add_passthrough_decoder(struct cxl_port *port); >> -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, >> +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, >> struct cxl_endpoint_dvsec_info *info); >> >> bool is_cxl_region(struct device *dev); >> diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c >> index 9dc394295e1f..acf2ac70f343 100644 >> --- a/drivers/cxl/port.c >> +++ b/drivers/cxl/port.c >> @@ -98,7 +98,7 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) >> struct cxl_port *root; >> int rc; >> >> - rc = cxl_dvsec_rr_decode(cxlds->dev, port, &info); >> + rc = cxl_dvsec_rr_decode(cxlds, &info); >> if (rc < 0) >> return rc; >> >> diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c >> index f4ce96cc11d4..4f82716cfc16 100644 >> --- a/tools/testing/cxl/test/mock.c >> +++ b/tools/testing/cxl/test/mock.c >> @@ -228,16 +228,16 @@ int __wrap_cxl_hdm_decode_init(struct cxl_dev_state *cxlds, >> } >> EXPORT_SYMBOL_NS_GPL(__wrap_cxl_hdm_decode_init, CXL); >> >> -int __wrap_cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, >> +int __wrap_cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, >> struct cxl_endpoint_dvsec_info *info) >> { >> int rc = 0, index; >> struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); >> >> - if (ops && ops->is_mock_dev(dev)) >> + if (ops && ops->is_mock_dev(cxlds->dev)) >> rc = 0; >> else >> - rc = cxl_dvsec_rr_decode(dev, port, info); >> + rc = cxl_dvsec_rr_decode(cxlds, info); >> put_cxl_mock_ops(index); >> >> return rc;
Hi, kernel test robot noticed the following build errors: [auto build test ERROR on cxl/next] [also build test ERROR on linus/master v6.12-rc7 next-20241115] [cannot apply to cxl/pending] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/alejandro-lucero-palau-amd-com/cxl-avoid-driver-data-for-obtaining-cxl_dev_state-reference/20241114-192818 base: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git next patch link: https://lore.kernel.org/r/20241114112435.45593-1-alejandro.lucero-palau%40amd.com patch subject: [PATCH] cxl: avoid driver data for obtaining cxl_dev_state reference config: i386-randconfig-053-20241117 (https://download.01.org/0day-ci/archive/20241117/202411171112.pEhqyZHy-lkp@intel.com/config) compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241117/202411171112.pEhqyZHy-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202411171112.pEhqyZHy-lkp@intel.com/ All error/warnings (new ones prefixed by >>): In file included from drivers/cxl/pci.c:11: In file included from include/linux/pci.h:1650: In file included from include/linux/dmapool.h:14: In file included from include/linux/scatterlist.h:8: In file included from include/linux/mm.h:2213: include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ In file included from drivers/cxl/pci.c:15: In file included from drivers/cxl/cxlmem.h:12: >> drivers/cxl/cxl.h:823:32: warning: declaration of 'struct cxl_dev_state' will not be visible outside of this function [-Wvisibility] 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^ 2 warnings generated. -- In file included from drivers/cxl/port.c:7: In file included from drivers/cxl/cxlmem.h:6: In file included from include/linux/pci.h:1650: In file included from include/linux/dmapool.h:14: In file included from include/linux/scatterlist.h:8: In file included from include/linux/mm.h:2213: include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ In file included from drivers/cxl/port.c:7: In file included from drivers/cxl/cxlmem.h:12: >> drivers/cxl/cxl.h:823:32: warning: declaration of 'struct cxl_dev_state' will not be visible outside of this function [-Wvisibility] 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^ >> drivers/cxl/port.c:101:27: error: incompatible pointer types passing 'struct cxl_dev_state *' to parameter of type 'struct cxl_dev_state *' [-Werror,-Wincompatible-pointer-types] 101 | rc = cxl_dvsec_rr_decode(cxlds, &info); | ^~~~~ drivers/cxl/cxl.h:823:47: note: passing argument to parameter 'cxlds' here 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^ 2 warnings and 1 error generated. -- In file included from drivers/cxl/core/pci.c:7: In file included from include/linux/pci.h:1650: In file included from include/linux/dmapool.h:14: In file included from include/linux/scatterlist.h:8: In file included from include/linux/mm.h:2213: include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ In file included from drivers/cxl/core/pci.c:10: In file included from drivers/cxl/cxlpci.h:6: >> drivers/cxl/cxl.h:823:32: warning: declaration of 'struct cxl_dev_state' will not be visible outside of this function [-Wvisibility] 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^ >> drivers/cxl/core/pci.c:294:5: error: conflicting types for 'cxl_dvsec_rr_decode' 294 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^ drivers/cxl/cxl.h:823:5: note: previous declaration is here 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^ 2 warnings and 1 error generated. vim +101 drivers/cxl/port.c 91 92 static int cxl_endpoint_port_probe(struct cxl_port *port) 93 { 94 struct cxl_endpoint_dvsec_info info = { .port = port }; 95 struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev); 96 struct cxl_dev_state *cxlds = cxlmd->cxlds; 97 struct cxl_hdm *cxlhdm; 98 struct cxl_port *root; 99 int rc; 100 > 101 rc = cxl_dvsec_rr_decode(cxlds, &info); 102 if (rc < 0) 103 return rc; 104 105 cxlhdm = devm_cxl_setup_hdm(port, &info); 106 if (IS_ERR(cxlhdm)) { 107 if (PTR_ERR(cxlhdm) == -ENODEV) 108 dev_err(&port->dev, "HDM decoder registers not found\n"); 109 return PTR_ERR(cxlhdm); 110 } 111 112 /* Cache the data early to ensure is_visible() works */ 113 read_cdat_data(port); 114 cxl_endpoint_parse_cdat(port); 115 116 get_device(&cxlmd->dev); 117 rc = devm_add_action_or_reset(&port->dev, schedule_detach, cxlmd); 118 if (rc) 119 return rc; 120 121 rc = cxl_hdm_decode_init(cxlds, cxlhdm, &info); 122 if (rc) 123 return rc; 124 125 rc = devm_cxl_enumerate_decoders(cxlhdm, &info); 126 if (rc) 127 return rc; 128 129 /* 130 * This can't fail in practice as CXL root exit unregisters all 131 * descendant ports and that in turn synchronizes with cxl_port_probe() 132 */ 133 struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); 134 135 root = &cxl_root->port; 136 137 /* 138 * Now that all endpoint decoders are successfully enumerated, try to 139 * assemble regions from committed decoders 140 */ 141 device_for_each_child(&port->dev, root, discover_region); 142 143 return 0; 144 } 145
Hi, kernel test robot noticed the following build warnings: [auto build test WARNING on cxl/next] [also build test WARNING on linus/master v6.12-rc7 next-20241115] [cannot apply to cxl/pending] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/alejandro-lucero-palau-amd-com/cxl-avoid-driver-data-for-obtaining-cxl_dev_state-reference/20241114-192818 base: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git next patch link: https://lore.kernel.org/r/20241114112435.45593-1-alejandro.lucero-palau%40amd.com patch subject: [PATCH] cxl: avoid driver data for obtaining cxl_dev_state reference config: alpha-randconfig-r051-20241117 (https://download.01.org/0day-ci/archive/20241117/202411171240.wwR1wRdZ-lkp@intel.com/config) compiler: alpha-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241117/202411171240.wwR1wRdZ-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202411171240.wwR1wRdZ-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/perf/../cxl/cxlpci.h:6, from drivers/perf/cxl_pmu.c:23: >> drivers/perf/../cxl/cxl.h:823:32: warning: 'struct cxl_dev_state' declared inside parameter list will not be visible outside of this definition or declaration 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^~~~~~~~~~~~~ vim +823 drivers/perf/../cxl/cxl.h 816 817 struct cxl_hdm; 818 struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, 819 struct cxl_endpoint_dvsec_info *info); 820 int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, 821 struct cxl_endpoint_dvsec_info *info); 822 int devm_cxl_add_passthrough_decoder(struct cxl_port *port); > 823 int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, 824 struct cxl_endpoint_dvsec_info *info); 825
Hi, kernel test robot noticed the following build errors: [auto build test ERROR on cxl/next] [also build test ERROR on linus/master v6.12-rc7 next-20241115] [cannot apply to cxl/pending] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/alejandro-lucero-palau-amd-com/cxl-avoid-driver-data-for-obtaining-cxl_dev_state-reference/20241114-192818 base: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git next patch link: https://lore.kernel.org/r/20241114112435.45593-1-alejandro.lucero-palau%40amd.com patch subject: [PATCH] cxl: avoid driver data for obtaining cxl_dev_state reference config: arm-randconfig-003-20241117 (https://download.01.org/0day-ci/archive/20241117/202411171720.1crMgwi0-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241117/202411171720.1crMgwi0-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202411171720.1crMgwi0-lkp@intel.com/ All error/warnings (new ones prefixed by >>): In file included from drivers/cxl/cxlmem.h:12, from drivers/cxl/port.c:7: >> drivers/cxl/cxl.h:823:32: warning: 'struct cxl_dev_state' declared inside parameter list will not be visible outside of this definition or declaration 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^~~~~~~~~~~~~ drivers/cxl/port.c: In function 'cxl_endpoint_port_probe': >> drivers/cxl/port.c:101:34: error: passing argument 1 of 'cxl_dvsec_rr_decode' from incompatible pointer type [-Wincompatible-pointer-types] 101 | rc = cxl_dvsec_rr_decode(cxlds, &info); | ^~~~~ | | | struct cxl_dev_state * drivers/cxl/cxl.h:823:47: note: expected 'struct cxl_dev_state *' but argument is of type 'struct cxl_dev_state *' 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ~~~~~~~~~~~~~~~~~~~~~~^~~~~ -- In file included from drivers/cxl/cxlmem.h:12, from drivers/cxl/pci.c:15: >> drivers/cxl/cxl.h:823:32: warning: 'struct cxl_dev_state' declared inside parameter list will not be visible outside of this definition or declaration 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^~~~~~~~~~~~~ -- In file included from drivers/cxl/cxlpci.h:6, from drivers/cxl/core/pci.c:10: >> drivers/cxl/cxl.h:823:32: warning: 'struct cxl_dev_state' declared inside parameter list will not be visible outside of this definition or declaration 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^~~~~~~~~~~~~ >> drivers/cxl/core/pci.c:294:5: error: conflicting types for 'cxl_dvsec_rr_decode'; have 'int(struct cxl_dev_state *, struct cxl_endpoint_dvsec_info *)' 294 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^~~~~~~~~~~~~~~~~~~ drivers/cxl/cxl.h:823:5: note: previous declaration of 'cxl_dvsec_rr_decode' with type 'int(struct cxl_dev_state *, struct cxl_endpoint_dvsec_info *)' 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^~~~~~~~~~~~~~~~~~~ In file included from include/linux/linkage.h:7, from arch/arm/include/asm/bug.h:5, from include/linux/bug.h:5, from include/linux/io.h:12, from include/linux/io-64-nonatomic-lo-hi.h:5, from drivers/cxl/core/pci.c:4: drivers/cxl/core/pci.c:389:22: error: conflicting types for 'cxl_dvsec_rr_decode'; have 'int(struct cxl_dev_state *, struct cxl_endpoint_dvsec_info *)' 389 | EXPORT_SYMBOL_NS_GPL(cxl_dvsec_rr_decode, CXL); | ^~~~~~~~~~~~~~~~~~~ include/linux/export.h:56:28: note: in definition of macro '__EXPORT_SYMBOL' 56 | extern typeof(sym) sym; \ | ^~~ drivers/cxl/core/pci.c:389:1: note: in expansion of macro 'EXPORT_SYMBOL_NS_GPL' 389 | EXPORT_SYMBOL_NS_GPL(cxl_dvsec_rr_decode, CXL); | ^~~~~~~~~~~~~~~~~~~~ drivers/cxl/cxl.h:823:5: note: previous declaration of 'cxl_dvsec_rr_decode' with type 'int(struct cxl_dev_state *, struct cxl_endpoint_dvsec_info *)' 823 | int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, | ^~~~~~~~~~~~~~~~~~~ vim +/cxl_dvsec_rr_decode +101 drivers/cxl/port.c 91 92 static int cxl_endpoint_port_probe(struct cxl_port *port) 93 { 94 struct cxl_endpoint_dvsec_info info = { .port = port }; 95 struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev); 96 struct cxl_dev_state *cxlds = cxlmd->cxlds; 97 struct cxl_hdm *cxlhdm; 98 struct cxl_port *root; 99 int rc; 100 > 101 rc = cxl_dvsec_rr_decode(cxlds, &info); 102 if (rc < 0) 103 return rc; 104 105 cxlhdm = devm_cxl_setup_hdm(port, &info); 106 if (IS_ERR(cxlhdm)) { 107 if (PTR_ERR(cxlhdm) == -ENODEV) 108 dev_err(&port->dev, "HDM decoder registers not found\n"); 109 return PTR_ERR(cxlhdm); 110 } 111 112 /* Cache the data early to ensure is_visible() works */ 113 read_cdat_data(port); 114 cxl_endpoint_parse_cdat(port); 115 116 get_device(&cxlmd->dev); 117 rc = devm_add_action_or_reset(&port->dev, schedule_detach, cxlmd); 118 if (rc) 119 return rc; 120 121 rc = cxl_hdm_decode_init(cxlds, cxlhdm, &info); 122 if (rc) 123 return rc; 124 125 rc = devm_cxl_enumerate_decoders(cxlhdm, &info); 126 if (rc) 127 return rc; 128 129 /* 130 * This can't fail in practice as CXL root exit unregisters all 131 * descendant ports and that in turn synchronizes with cxl_port_probe() 132 */ 133 struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); 134 135 root = &cxl_root->port; 136 137 /* 138 * Now that all endpoint decoders are successfully enumerated, try to 139 * assemble regions from committed decoders 140 */ 141 device_for_each_child(&port->dev, root, discover_region); 142 143 return 0; 144 } 145
On Thu, 14 Nov 2024 11:24:35 +0000 <alejandro.lucero-palau@amd.com> wrote: > From: Alejandro Lucero <alejandro.lucero-palau@amd.com> > > CXL Type3 pci driver uses struct device driver_data for keeping > cxl_dev_state reference. Type1/2 drivers are not only about CXL so > this field so not be used when code requires cxl_dev_state to work with > and such a code used for Type2 support. > > Change cxl_dvsec_rr_decode for passing cxl_dev_state as a parameter. Looks like you also dropped the unused parameter port. Mention that as well. > > Signed-off-by: Alejandro Lucero <alucerop@amd.com> > --- > drivers/cxl/core/pci.c | 6 +++--- > drivers/cxl/cxl.h | 2 +- > drivers/cxl/port.c | 2 +- > tools/testing/cxl/test/mock.c | 6 +++--- > 4 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c > index 5b46bc46aaa9..420e4be85a1f 100644 > --- a/drivers/cxl/core/pci.c > +++ b/drivers/cxl/core/pci.c > @@ -291,11 +291,11 @@ static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm) > return devm_add_action_or_reset(host, disable_hdm, cxlhdm); > } > > -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, > +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, > struct cxl_endpoint_dvsec_info *info) > { > - struct pci_dev *pdev = to_pci_dev(dev); > - struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); > + struct pci_dev *pdev = to_pci_dev(cxlds->dev); > + struct device *dev = cxlds->dev; > int hdm_count, rc, i, ranges = 0; > int d = cxlds->cxl_dvsec; > u16 cap, ctrl; > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > index 5406e3ab3d4a..42a46e78d786 100644 > --- a/drivers/cxl/cxl.h > +++ b/drivers/cxl/cxl.h > @@ -812,7 +812,7 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, > int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, > struct cxl_endpoint_dvsec_info *info); > int devm_cxl_add_passthrough_decoder(struct cxl_port *port); > -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, > +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, > struct cxl_endpoint_dvsec_info *info); > > bool is_cxl_region(struct device *dev); > diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c > index 9dc394295e1f..acf2ac70f343 100644 > --- a/drivers/cxl/port.c > +++ b/drivers/cxl/port.c > @@ -98,7 +98,7 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) > struct cxl_port *root; > int rc; > > - rc = cxl_dvsec_rr_decode(cxlds->dev, port, &info); > + rc = cxl_dvsec_rr_decode(cxlds, &info); > if (rc < 0) > return rc; > > diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c > index f4ce96cc11d4..4f82716cfc16 100644 > --- a/tools/testing/cxl/test/mock.c > +++ b/tools/testing/cxl/test/mock.c > @@ -228,16 +228,16 @@ int __wrap_cxl_hdm_decode_init(struct cxl_dev_state *cxlds, > } > EXPORT_SYMBOL_NS_GPL(__wrap_cxl_hdm_decode_init, CXL); > > -int __wrap_cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, > +int __wrap_cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, > struct cxl_endpoint_dvsec_info *info) > { > int rc = 0, index; > struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); > > - if (ops && ops->is_mock_dev(dev)) > + if (ops && ops->is_mock_dev(cxlds->dev)) > rc = 0; > else > - rc = cxl_dvsec_rr_decode(dev, port, info); > + rc = cxl_dvsec_rr_decode(cxlds, info); > put_cxl_mock_ops(index); > > return rc;
On 11/26/24 16:09, Jonathan Cameron wrote: > On Thu, 14 Nov 2024 11:24:35 +0000 > <alejandro.lucero-palau@amd.com> wrote: > >> From: Alejandro Lucero <alejandro.lucero-palau@amd.com> >> >> CXL Type3 pci driver uses struct device driver_data for keeping >> cxl_dev_state reference. Type1/2 drivers are not only about CXL so >> this field so not be used when code requires cxl_dev_state to work with >> and such a code used for Type2 support. >> >> Change cxl_dvsec_rr_decode for passing cxl_dev_state as a parameter. > Looks like you also dropped the unused parameter port. Mention that as well. Right, I'll do that. BTW, I sent a v2 fixing the type in the commit message "this field should not" and other robot reported errors. Thanks! >> Signed-off-by: Alejandro Lucero <alucerop@amd.com> >> --- >> drivers/cxl/core/pci.c | 6 +++--- >> drivers/cxl/cxl.h | 2 +- >> drivers/cxl/port.c | 2 +- >> tools/testing/cxl/test/mock.c | 6 +++--- >> 4 files changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c >> index 5b46bc46aaa9..420e4be85a1f 100644 >> --- a/drivers/cxl/core/pci.c >> +++ b/drivers/cxl/core/pci.c >> @@ -291,11 +291,11 @@ static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm) >> return devm_add_action_or_reset(host, disable_hdm, cxlhdm); >> } >> >> -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, >> +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, >> struct cxl_endpoint_dvsec_info *info) >> { >> - struct pci_dev *pdev = to_pci_dev(dev); >> - struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); >> + struct pci_dev *pdev = to_pci_dev(cxlds->dev); >> + struct device *dev = cxlds->dev; >> int hdm_count, rc, i, ranges = 0; >> int d = cxlds->cxl_dvsec; >> u16 cap, ctrl; >> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h >> index 5406e3ab3d4a..42a46e78d786 100644 >> --- a/drivers/cxl/cxl.h >> +++ b/drivers/cxl/cxl.h >> @@ -812,7 +812,7 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, >> int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, >> struct cxl_endpoint_dvsec_info *info); >> int devm_cxl_add_passthrough_decoder(struct cxl_port *port); >> -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, >> +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, >> struct cxl_endpoint_dvsec_info *info); >> >> bool is_cxl_region(struct device *dev); >> diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c >> index 9dc394295e1f..acf2ac70f343 100644 >> --- a/drivers/cxl/port.c >> +++ b/drivers/cxl/port.c >> @@ -98,7 +98,7 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) >> struct cxl_port *root; >> int rc; >> >> - rc = cxl_dvsec_rr_decode(cxlds->dev, port, &info); >> + rc = cxl_dvsec_rr_decode(cxlds, &info); >> if (rc < 0) >> return rc; >> >> diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c >> index f4ce96cc11d4..4f82716cfc16 100644 >> --- a/tools/testing/cxl/test/mock.c >> +++ b/tools/testing/cxl/test/mock.c >> @@ -228,16 +228,16 @@ int __wrap_cxl_hdm_decode_init(struct cxl_dev_state *cxlds, >> } >> EXPORT_SYMBOL_NS_GPL(__wrap_cxl_hdm_decode_init, CXL); >> >> -int __wrap_cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, >> +int __wrap_cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, >> struct cxl_endpoint_dvsec_info *info) >> { >> int rc = 0, index; >> struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); >> >> - if (ops && ops->is_mock_dev(dev)) >> + if (ops && ops->is_mock_dev(cxlds->dev)) >> rc = 0; >> else >> - rc = cxl_dvsec_rr_decode(dev, port, info); >> + rc = cxl_dvsec_rr_decode(cxlds, info); >> put_cxl_mock_ops(index); >> >> return rc;
diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 5b46bc46aaa9..420e4be85a1f 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -291,11 +291,11 @@ static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm) return devm_add_action_or_reset(host, disable_hdm, cxlhdm); } -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, struct cxl_endpoint_dvsec_info *info) { - struct pci_dev *pdev = to_pci_dev(dev); - struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); + struct pci_dev *pdev = to_pci_dev(cxlds->dev); + struct device *dev = cxlds->dev; int hdm_count, rc, i, ranges = 0; int d = cxlds->cxl_dvsec; u16 cap, ctrl; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 5406e3ab3d4a..42a46e78d786 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -812,7 +812,7 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, struct cxl_endpoint_dvsec_info *info); int devm_cxl_add_passthrough_decoder(struct cxl_port *port); -int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, +int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, struct cxl_endpoint_dvsec_info *info); bool is_cxl_region(struct device *dev); diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c index 9dc394295e1f..acf2ac70f343 100644 --- a/drivers/cxl/port.c +++ b/drivers/cxl/port.c @@ -98,7 +98,7 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) struct cxl_port *root; int rc; - rc = cxl_dvsec_rr_decode(cxlds->dev, port, &info); + rc = cxl_dvsec_rr_decode(cxlds, &info); if (rc < 0) return rc; diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c index f4ce96cc11d4..4f82716cfc16 100644 --- a/tools/testing/cxl/test/mock.c +++ b/tools/testing/cxl/test/mock.c @@ -228,16 +228,16 @@ int __wrap_cxl_hdm_decode_init(struct cxl_dev_state *cxlds, } EXPORT_SYMBOL_NS_GPL(__wrap_cxl_hdm_decode_init, CXL); -int __wrap_cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port, +int __wrap_cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, struct cxl_endpoint_dvsec_info *info) { int rc = 0, index; struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); - if (ops && ops->is_mock_dev(dev)) + if (ops && ops->is_mock_dev(cxlds->dev)) rc = 0; else - rc = cxl_dvsec_rr_decode(dev, port, info); + rc = cxl_dvsec_rr_decode(cxlds, info); put_cxl_mock_ops(index); return rc;