Message ID | 1623576555-40338-2-git-send-email-liudongdong3@huawei.com |
---|---|
State | Superseded |
Headers | show |
Series | PCI: Enable 10-Bit tag support for PCIe devices | expand |
On Sun, Jun 13, 2021 at 05:29:10PM +0800, Dongdong Liu wrote: > It will make sense to store the pcie_devcap value in the pci_dev > structure instead of reading Device Capabilities Register multiple > times. The fisrt place to use pcie_devcap is in set_pcie_port_type(), > get the pcie_devcap value here, then use cached pcie_devcap in the > needed place. > > Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> > Signed-off-by: Dongdong Liu <liudongdong3@huawei.com> > --- > drivers/media/pci/cobalt/cobalt-driver.c | 4 ++-- > drivers/pci/pci.c | 5 +---- > drivers/pci/pcie/aspm.c | 11 ++++------- > drivers/pci/probe.c | 11 +++-------- > drivers/pci/quirks.c | 3 +-- > include/linux/pci.h | 1 + > 6 files changed, 12 insertions(+), 23 deletions(-) > > diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c > index 839503e..04e735f 100644 > --- a/drivers/media/pci/cobalt/cobalt-driver.c > +++ b/drivers/media/pci/cobalt/cobalt-driver.c > @@ -193,11 +193,11 @@ void cobalt_pcie_status_show(struct cobalt *cobalt) > return; > > /* Device */ > - pcie_capability_read_dword(pci_dev, PCI_EXP_DEVCAP, &capa); > pcie_capability_read_word(pci_dev, PCI_EXP_DEVCTL, &ctrl); > pcie_capability_read_word(pci_dev, PCI_EXP_DEVSTA, &stat); > cobalt_info("PCIe device capability 0x%08x: Max payload %d\n", > - capa, get_payload_size(capa & PCI_EXP_DEVCAP_PAYLOAD)); > + capa, > + get_payload_size(pci_dev->pcie_devcap & PCI_EXP_DEVCAP_PAYLOAD)); Overly long line. > + if (!(child->pcie_devcap & PCI_EXP_DEVCAP_RBER) && !aspm_force) { Another one. Otherwise looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
Hi Dongdong, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on pci/next] [also build test WARNING on linuxtv-media/master linus/master v5.13-rc6 next-20210618] [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] url: https://github.com/0day-ci/linux/commits/Dongdong-Liu/PCI-Enable-10-Bit-tag-support-for-PCIe-devices/20210617-041115 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: s390-randconfig-r032-20210618 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install s390 cross compiling tool for clang build # apt-get install binutils-s390x-linux-gnu # https://github.com/0day-ci/linux/commit/caefa7e6d0209bc08eb1934b58dae3aaa0b9dbba git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Dongdong-Liu/PCI-Enable-10-Bit-tag-support-for-PCIe-devices/20210617-041115 git checkout caefa7e6d0209bc08eb1934b58dae3aaa0b9dbba # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): In file included from drivers/media/pci/cobalt/cobalt-driver.c:18: In file included from drivers/media/pci/cobalt/cobalt-driver.h:16: In file included from include/linux/pci.h:39: In file included from include/linux/io.h:13: In file included from arch/s390/include/asm/io.h:75: include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __raw_readb(PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu' #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x)) ^ include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16' #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x)) ^ In file included from drivers/media/pci/cobalt/cobalt-driver.c:18: In file included from drivers/media/pci/cobalt/cobalt-driver.h:16: In file included from include/linux/pci.h:39: In file included from include/linux/io.h:13: In file included from arch/s390/include/asm/io.h:75: include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu' #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x)) ^ include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32' #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) ^ In file included from drivers/media/pci/cobalt/cobalt-driver.c:18: In file included from drivers/media/pci/cobalt/cobalt-driver.h:16: In file included from include/linux/pci.h:39: In file included from include/linux/io.h:13: In file included from arch/s390/include/asm/io.h:75: include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writeb(value, PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ >> drivers/media/pci/cobalt/cobalt-driver.c:199:7: warning: variable 'capa' is uninitialized when used here [-Wuninitialized] capa, ^~~~ drivers/media/pci/cobalt/cobalt-driver.h:160:71: note: expanded from macro 'cobalt_info' #define cobalt_info(fmt, arg...) v4l2_info(&cobalt->v4l2_dev, fmt, ## arg) ^~~ include/media/v4l2-common.h:67:39: note: expanded from macro 'v4l2_info' v4l2_printk(KERN_INFO, dev, fmt , ## arg) ^~~ include/media/v4l2-common.h:58:44: note: expanded from macro 'v4l2_printk' printk(level "%s: " fmt, (dev)->name , ## arg) ^~~ drivers/media/pci/cobalt/cobalt-driver.c:189:10: note: initialize the variable 'capa' to silence this warning u32 capa; ^ = 0 13 warnings generated. vim +/capa +199 drivers/media/pci/cobalt/cobalt-driver.c 184 185 void cobalt_pcie_status_show(struct cobalt *cobalt) 186 { 187 struct pci_dev *pci_dev = cobalt->pci_dev; 188 struct pci_dev *pci_bus_dev = cobalt->pci_dev->bus->self; 189 u32 capa; 190 u16 stat, ctrl; 191 192 if (!pci_is_pcie(pci_dev) || !pci_is_pcie(pci_bus_dev)) 193 return; 194 195 /* Device */ 196 pcie_capability_read_word(pci_dev, PCI_EXP_DEVCTL, &ctrl); 197 pcie_capability_read_word(pci_dev, PCI_EXP_DEVSTA, &stat); 198 cobalt_info("PCIe device capability 0x%08x: Max payload %d\n", > 199 capa, 200 get_payload_size(pci_dev->pcie_devcap & PCI_EXP_DEVCAP_PAYLOAD)); 201 cobalt_info("PCIe device control 0x%04x: Max payload %d. Max read request %d\n", 202 ctrl, 203 get_payload_size((ctrl & PCI_EXP_DEVCTL_PAYLOAD) >> 5), 204 get_payload_size((ctrl & PCI_EXP_DEVCTL_READRQ) >> 12)); 205 cobalt_info("PCIe device status 0x%04x\n", stat); 206 207 /* Link */ 208 pcie_capability_read_dword(pci_dev, PCI_EXP_LNKCAP, &capa); 209 pcie_capability_read_word(pci_dev, PCI_EXP_LNKCTL, &ctrl); 210 pcie_capability_read_word(pci_dev, PCI_EXP_LNKSTA, &stat); 211 cobalt_info("PCIe link capability 0x%08x: %s per lane and %u lanes\n", 212 capa, get_link_speed(capa), 213 (capa & PCI_EXP_LNKCAP_MLW) >> 4); 214 cobalt_info("PCIe link control 0x%04x\n", ctrl); 215 cobalt_info("PCIe link status 0x%04x: %s per lane and %u lanes\n", 216 stat, get_link_speed(stat), 217 (stat & PCI_EXP_LNKSTA_NLW) >> 4); 218 219 /* Bus */ 220 pcie_capability_read_dword(pci_bus_dev, PCI_EXP_LNKCAP, &capa); 221 cobalt_info("PCIe bus link capability 0x%08x: %s per lane and %u lanes\n", 222 capa, get_link_speed(capa), 223 (capa & PCI_EXP_LNKCAP_MLW) >> 4); 224 225 /* Slot */ 226 pcie_capability_read_dword(pci_dev, PCI_EXP_SLTCAP, &capa); 227 pcie_capability_read_word(pci_dev, PCI_EXP_SLTCTL, &ctrl); 228 pcie_capability_read_word(pci_dev, PCI_EXP_SLTSTA, &stat); 229 cobalt_info("PCIe slot capability 0x%08x\n", capa); 230 cobalt_info("PCIe slot control 0x%04x\n", ctrl); 231 cobalt_info("PCIe slot status 0x%04x\n", stat); 232 } 233 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On 2021/6/18 22:51, kernel test robot wrote: > Hi Dongdong, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on pci/next] > [also build test WARNING on linuxtv-media/master linus/master v5.13-rc6 next-20210618] > [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] > > url: https://github.com/0day-ci/linux/commits/Dongdong-Liu/PCI-Enable-10-Bit-tag-support-for-PCIe-devices/20210617-041115 > base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next > config: s390-randconfig-r032-20210618 (attached as .config) > compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 64720f57bea6a6bf033feef4a5751ab9c0c3b401) > reproduce (this is a W=1 build): > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # install s390 cross compiling tool for clang build > # apt-get install binutils-s390x-linux-gnu > # https://github.com/0day-ci/linux/commit/caefa7e6d0209bc08eb1934b58dae3aaa0b9dbba > git remote add linux-review https://github.com/0day-ci/linux > git fetch --no-tags linux-review Dongdong-Liu/PCI-Enable-10-Bit-tag-support-for-PCIe-devices/20210617-041115 > git checkout caefa7e6d0209bc08eb1934b58dae3aaa0b9dbba > # save the attached .config to linux build tree > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390 > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot <lkp@intel.com> > > All warnings (new ones prefixed by >>): > > In file included from drivers/media/pci/cobalt/cobalt-driver.c:18: > In file included from drivers/media/pci/cobalt/cobalt-driver.h:16: > In file included from include/linux/pci.h:39: > In file included from include/linux/io.h:13: > In file included from arch/s390/include/asm/io.h:75: > include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > val = __raw_readb(PCI_IOBASE + addr); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); > ~~~~~~~~~~ ^ > include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu' > #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x)) > ^ > include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16' > #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x)) > ^ > In file included from drivers/media/pci/cobalt/cobalt-driver.c:18: > In file included from drivers/media/pci/cobalt/cobalt-driver.h:16: > In file included from include/linux/pci.h:39: > In file included from include/linux/io.h:13: > In file included from arch/s390/include/asm/io.h:75: > include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); > ~~~~~~~~~~ ^ > include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu' > #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x)) > ^ > include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32' > #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) > ^ > In file included from drivers/media/pci/cobalt/cobalt-driver.c:18: > In file included from drivers/media/pci/cobalt/cobalt-driver.h:16: > In file included from include/linux/pci.h:39: > In file included from include/linux/io.h:13: > In file included from arch/s390/include/asm/io.h:75: > include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > __raw_writeb(value, PCI_IOBASE + addr); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > readsb(PCI_IOBASE + addr, buffer, count); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > readsw(PCI_IOBASE + addr, buffer, count); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > readsl(PCI_IOBASE + addr, buffer, count); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > writesb(PCI_IOBASE + addr, buffer, count); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > writesw(PCI_IOBASE + addr, buffer, count); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > writesl(PCI_IOBASE + addr, buffer, count); > ~~~~~~~~~~ ^ >>> drivers/media/pci/cobalt/cobalt-driver.c:199:7: warning: variable 'capa' is uninitialized when used here [-Wuninitialized] > capa, > ^~~~ > drivers/media/pci/cobalt/cobalt-driver.h:160:71: note: expanded from macro 'cobalt_info' > #define cobalt_info(fmt, arg...) v4l2_info(&cobalt->v4l2_dev, fmt, ## arg) > ^~~ > include/media/v4l2-common.h:67:39: note: expanded from macro 'v4l2_info' > v4l2_printk(KERN_INFO, dev, fmt , ## arg) > ^~~ > include/media/v4l2-common.h:58:44: note: expanded from macro 'v4l2_printk' > printk(level "%s: " fmt, (dev)->name , ## arg) > ^~~ > drivers/media/pci/cobalt/cobalt-driver.c:189:10: note: initialize the variable 'capa' to silence this warning > u32 capa; > ^ > = 0 > 13 warnings generated. > > > vim +/capa +199 drivers/media/pci/cobalt/cobalt-driver.c > > 184 > 185 void cobalt_pcie_status_show(struct cobalt *cobalt) > 186 { > 187 struct pci_dev *pci_dev = cobalt->pci_dev; > 188 struct pci_dev *pci_bus_dev = cobalt->pci_dev->bus->self; > 189 u32 capa; > 190 u16 stat, ctrl; > 191 > 192 if (!pci_is_pcie(pci_dev) || !pci_is_pcie(pci_bus_dev)) > 193 return; > 194 > 195 /* Device */ > 196 pcie_capability_read_word(pci_dev, PCI_EXP_DEVCTL, &ctrl); > 197 pcie_capability_read_word(pci_dev, PCI_EXP_DEVSTA, &stat); > 198 cobalt_info("PCIe device capability 0x%08x: Max payload %d\n", > > 199 capa, Will fix with pci_dev->pcie_devcap. Thanks, Dongdong > 200 get_payload_size(pci_dev->pcie_devcap & PCI_EXP_DEVCAP_PAYLOAD)); > 201 cobalt_info("PCIe device control 0x%04x: Max payload %d. Max read request %d\n", > 202 ctrl, > 203 get_payload_size((ctrl & PCI_EXP_DEVCTL_PAYLOAD) >> 5), > 204 get_payload_size((ctrl & PCI_EXP_DEVCTL_READRQ) >> 12)); > 205 cobalt_info("PCIe device status 0x%04x\n", stat); > 206 > 207 /* Link */ > 208 pcie_capability_read_dword(pci_dev, PCI_EXP_LNKCAP, &capa); > 209 pcie_capability_read_word(pci_dev, PCI_EXP_LNKCTL, &ctrl); > 210 pcie_capability_read_word(pci_dev, PCI_EXP_LNKSTA, &stat); > 211 cobalt_info("PCIe link capability 0x%08x: %s per lane and %u lanes\n", > 212 capa, get_link_speed(capa), > 213 (capa & PCI_EXP_LNKCAP_MLW) >> 4); > 214 cobalt_info("PCIe link control 0x%04x\n", ctrl); > 215 cobalt_info("PCIe link status 0x%04x: %s per lane and %u lanes\n", > 216 stat, get_link_speed(stat), > 217 (stat & PCI_EXP_LNKSTA_NLW) >> 4); > 218 > 219 /* Bus */ > 220 pcie_capability_read_dword(pci_bus_dev, PCI_EXP_LNKCAP, &capa); > 221 cobalt_info("PCIe bus link capability 0x%08x: %s per lane and %u lanes\n", > 222 capa, get_link_speed(capa), > 223 (capa & PCI_EXP_LNKCAP_MLW) >> 4); > 224 > 225 /* Slot */ > 226 pcie_capability_read_dword(pci_dev, PCI_EXP_SLTCAP, &capa); > 227 pcie_capability_read_word(pci_dev, PCI_EXP_SLTCTL, &ctrl); > 228 pcie_capability_read_word(pci_dev, PCI_EXP_SLTSTA, &stat); > 229 cobalt_info("PCIe slot capability 0x%08x\n", capa); > 230 cobalt_info("PCIe slot control 0x%04x\n", ctrl); > 231 cobalt_info("PCIe slot status 0x%04x\n", stat); > 232 } > 233 > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org >
diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c index 839503e..04e735f 100644 --- a/drivers/media/pci/cobalt/cobalt-driver.c +++ b/drivers/media/pci/cobalt/cobalt-driver.c @@ -193,11 +193,11 @@ void cobalt_pcie_status_show(struct cobalt *cobalt) return; /* Device */ - pcie_capability_read_dword(pci_dev, PCI_EXP_DEVCAP, &capa); pcie_capability_read_word(pci_dev, PCI_EXP_DEVCTL, &ctrl); pcie_capability_read_word(pci_dev, PCI_EXP_DEVSTA, &stat); cobalt_info("PCIe device capability 0x%08x: Max payload %d\n", - capa, get_payload_size(capa & PCI_EXP_DEVCAP_PAYLOAD)); + capa, + get_payload_size(pci_dev->pcie_devcap & PCI_EXP_DEVCAP_PAYLOAD)); cobalt_info("PCIe device control 0x%04x: Max payload %d. Max read request %d\n", ctrl, get_payload_size((ctrl & PCI_EXP_DEVCTL_PAYLOAD) >> 5), diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b717680..68ccd77 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4620,13 +4620,10 @@ EXPORT_SYMBOL(pci_wait_for_pending_transaction); */ bool pcie_has_flr(struct pci_dev *dev) { - u32 cap; - if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET) return false; - pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap); - return cap & PCI_EXP_DEVCAP_FLR; + return dev->pcie_devcap & PCI_EXP_DEVCAP_FLR; } EXPORT_SYMBOL_GPL(pcie_has_flr); diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index ac0557a..d637564 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -660,7 +660,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) /* Get and check endpoint acceptable latencies */ list_for_each_entry(child, &linkbus->devices, bus_list) { - u32 reg32, encoding; + u32 encoding; struct aspm_latency *acceptable = &link->acceptable[PCI_FUNC(child->devfn)]; @@ -668,12 +668,11 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END) continue; - pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); /* Calculate endpoint L0s acceptable latency */ - encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; + encoding = (child->pcie_devcap & PCI_EXP_DEVCAP_L0S) >> 6; acceptable->l0s = calc_l0s_acceptable(encoding); /* Calculate endpoint L1 acceptable latency */ - encoding = (reg32 & PCI_EXP_DEVCAP_L1) >> 9; + encoding = (child->pcie_devcap & PCI_EXP_DEVCAP_L1) >> 9; acceptable->l1 = calc_l1_acceptable(encoding); pcie_aspm_check_latency(child); @@ -808,7 +807,6 @@ static void free_link_state(struct pcie_link_state *link) static int pcie_aspm_sanity_check(struct pci_dev *pdev) { struct pci_dev *child; - u32 reg32; /* * Some functions in a slot might not all be PCIe functions, @@ -831,8 +829,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev) * Disable ASPM for pre-1.1 PCIe device, we follow MS to use * RBER bit to determine if a function is 1.1 version device */ - pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); - if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { + if (!(child->pcie_devcap & PCI_EXP_DEVCAP_RBER) && !aspm_force) { pci_info(child, "disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n"); return -EINVAL; } diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 3a62d09..7963ab2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1497,8 +1497,8 @@ void set_pcie_port_type(struct pci_dev *pdev) pdev->pcie_cap = pos; pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16); pdev->pcie_flags_reg = reg16; - pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, ®16); - pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD; + pci_read_config_dword(pdev, pos + PCI_EXP_DEVCAP, &pdev->pcie_devcap); + pdev->pcie_mpss = pdev->pcie_devcap & PCI_EXP_DEVCAP_PAYLOAD; parent = pci_upstream_bridge(pdev); if (!parent) @@ -2008,18 +2008,13 @@ static void pci_configure_mps(struct pci_dev *dev) int pci_configure_extended_tags(struct pci_dev *dev, void *ign) { struct pci_host_bridge *host; - u32 cap; u16 ctl; int ret; if (!pci_is_pcie(dev)) return 0; - ret = pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap); - if (ret) - return 0; - - if (!(cap & PCI_EXP_DEVCAP_EXT_TAG)) + if (!(dev->pcie_devcap & PCI_EXP_DEVCAP_EXT_TAG)) return 0; ret = pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dcb229d..b89b438 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -5073,8 +5073,7 @@ static void quirk_intel_qat_vf_cap(struct pci_dev *pdev) pdev->pcie_cap = pos; pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16); pdev->pcie_flags_reg = reg16; - pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, ®16); - pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD; + pdev->pcie_mpss = pdev->pcie_devcap & PCI_EXP_DEVCAP_PAYLOAD; pdev->cfg_size = PCI_CFG_SPACE_EXP_SIZE; if (pci_read_config_dword(pdev, PCI_CFG_SPACE_SIZE, &status) != diff --git a/include/linux/pci.h b/include/linux/pci.h index c20211e..555a3ac 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -340,6 +340,7 @@ struct pci_dev { u8 rom_base_reg; /* Config register controlling ROM */ u8 pin; /* Interrupt pin this device uses */ u16 pcie_flags_reg; /* Cached PCIe Capabilities Register */ + u32 pcie_devcap; /* Cached Device Capabilities Register */ unsigned long *dma_alias_mask;/* Mask of enabled devfn aliases */ struct pci_driver *driver; /* Driver bound to this device */