cxgb4: Prefer pcie_capability_read_word()
Subsystems (12)
PATCH 1/1 cxgb4: Prefer pcie_capability_read_word()
Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 6 ++---- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +2 -4
@@ -5441,7 +5441,6 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)char name[IFNAMSIZ ];u32 devcap2;u16 flags; -int pos;/* If we want to instantiate Virtual Functions, then our * parent bridge's PCI-E needs to support Alternative Routing
@@ -5449,9 +5448,8 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)* and above. */ pbridge = pdev->bus->self; - pos =pci_find_capability (pbridge,PCI_CAP_ID_EXP ); -pci_read_config_word (pbridge, pos +PCI_EXP_FLAGS , &flags); -pci_read_config_dword (pbridge, pos +PCI_EXP_DEVCAP2 , &devcap2); +pcie_capability_read_word (pbridge,PCI_EXP_FLAGS , &flags); +pcie_capability_read_dword (pbridge,PCI_EXP_DEVCAP2 , &devcap2);if ((flags &PCI_EXP_FLAGS_VERS ) <2 || !(devcap2 &PCI_EXP_DEVCAP2_ARI )) {
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +3 -6
@@ -7267,7 +7267,6 @@ int t4_fixup_host_params(struct adapter *adap, unsigned int page_size, }else {unsigned int pack_align;unsigned int ingpad, ingpack; -unsigned int pcie_cap;/* T5 introduced the separation of the Free List Padding and * Packing Boundaries. Thus, we can select a smaller Padding
@@ -7292,8 +7291,7 @@ int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,* multiple of the Maximum Payload Size. */ pack_align = fl_align; - pcie_cap =pci_find_capability (adap->pdev,PCI_CAP_ID_EXP ); -if (pcie_cap) { +if (pci_is_pcie (adap->pdev)) {unsigned int mps, mps_log;u16 devctl;
@@ -7301,9 +7299,8 @@ int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,* [bits 7:5] encodes sizes as powers of 2 starting at * 128 bytes. */ -pci_read_config_word (adap->pdev, - pcie_cap +PCI_EXP_DEVCTL , - &devctl); +pcie_capability_read_word (adap->pdev,PCI_EXP_DEVCTL , + &devctl); mps_log = ((devctl &PCI_EXP_DEVCTL_PAYLOAD ) >>5 ) +7 ; mps =1 << mps_log;if (mps > pack_align)
Signature · 1 line
2.17.1
PATCH 1/1 drm/amdgpu: Prefer pcie_capability_read_word()
Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/gpu/drm/amd/amdgpu/cik.c | 70 ++++++++++++++++++++------------ drivers/gpu/drm/amd/amdgpu/si.c | 70 ++++++++++++++++++++------------ 2 files changed, 88 insertions(+), 52 deletions(-)
drivers/gpu/drm/amd/amdgpu/cik.c +44 -26
@@ -1377,7 +1377,6 @@ static int cik_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)static void cik_pcie_gen3_enable (struct amdgpu_device *adev) {struct pci_dev *root = adev->pdev->bus->self; -int bridge_pos, gpu_pos;u32 speed_cntl, current_data_rate;int i;u16 tmp16;
@@ -1412,12 +1411,7 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)DRM_INFO ("enabling PCIE gen 2 link speeds, disable with amdgpu.pcie_gen2=0\n" ); } - bridge_pos =pci_pcie_cap (root); -if (!bridge_pos) -return ; - - gpu_pos =pci_pcie_cap (adev->pdev); -if (!gpu_pos) +if (!pci_is_pcie (root) || !pci_is_pcie (adev->pdev))return ;if (adev->pm.pcie_gen_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 ) {
@@ -1427,14 +1421,17 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)u16 bridge_cfg2, gpu_cfg2;u32 max_lw, current_lw, tmp; -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &bridge_cfg); -pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL , &gpu_cfg); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &bridge_cfg); +pcie_capability_read_word (adev->pdev,PCI_EXP_LNKCTL , + &gpu_cfg); tmp16 = bridge_cfg |PCI_EXP_LNKCTL_HAWD ; -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (root,PCI_EXP_LNKCTL , tmp16); tmp16 = gpu_cfg |PCI_EXP_LNKCTL_HAWD ; -pci_write_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (adev->pdev,PCI_EXP_LNKCTL , + tmp16); tmp =RREG32_PCIE (ixPCIE_LC_STATUS1); max_lw = (tmp & PCIE_LC_STATUS1__LC_DETECTED_LINK_WIDTH_MASK) >>
@@ -1458,15 +1455,23 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)for (i =0 ; i <10 ; i++) {/* check status */ -pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_DEVSTA , &tmp16); +pcie_capability_read_word (adev->pdev, +PCI_EXP_DEVSTA , + &tmp16);if (tmp16 &PCI_EXP_DEVSTA_TRPND )break ; -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &bridge_cfg); -pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL , &gpu_cfg); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &bridge_cfg); +pcie_capability_read_word (adev->pdev, +PCI_EXP_LNKCTL , + &gpu_cfg); -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , &bridge_cfg2); -pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &gpu_cfg2); +pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , + &bridge_cfg2); +pcie_capability_read_word (adev->pdev, +PCI_EXP_LNKCTL2 , + &gpu_cfg2); tmp =RREG32_PCIE (ixPCIE_LC_CNTL4); tmp |=PCIE_LC_CNTL4__LC_SET_QUIESCE_MASK ;
@@ -1479,26 +1484,39 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)msleep (100 );/* linkctl */ -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &tmp16); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &tmp16); tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; tmp16 |= (bridge_cfg &PCI_EXP_LNKCTL_HAWD ); -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (root,PCI_EXP_LNKCTL , + tmp16); -pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL , &tmp16); +pcie_capability_read_word (adev->pdev, +PCI_EXP_LNKCTL , + &tmp16); tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; tmp16 |= (gpu_cfg &PCI_EXP_LNKCTL_HAWD ); -pci_write_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (adev->pdev, +PCI_EXP_LNKCTL , + tmp16);/* linkctl2 */ -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (bridge_cfg2 & ((1 <<4 ) | (7 <<9 ))); -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (root, +PCI_EXP_LNKCTL2 , + tmp16); -pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (adev->pdev, +PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (gpu_cfg2 & ((1 <<4 ) | (7 <<9 ))); -pci_write_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (adev->pdev, +PCI_EXP_LNKCTL2 , + tmp16); tmp =RREG32_PCIE (ixPCIE_LC_CNTL4); tmp &= ~PCIE_LC_CNTL4__LC_SET_QUIESCE_MASK ;
@@ -1513,7 +1531,7 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev) speed_cntl &= ~PCIE_LC_SPEED_CNTL__LC_FORCE_DIS_SW_SPEED_CHANGE_MASK ;WREG32_PCIE (ixPCIE_LC_SPEED_CNTL, speed_cntl); -pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (adev->pdev,PCI_EXP_LNKCTL2 , &tmp16); tmp16 &= ~0xf ;if (adev->pm.pcie_gen_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 ) tmp16 |=3 ;/* gen3 */
@@ -1521,7 +1539,7 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev) tmp16 |=2 ;/* gen2 */ else tmp16 |= 1; /* gen1 */ -pci_write_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (adev->pdev,PCI_EXP_LNKCTL2 , tmp16); speed_cntl =RREG32_PCIE (ixPCIE_LC_SPEED_CNTL); speed_cntl |=PCIE_LC_SPEED_CNTL__LC_INITIATE_LINK_SPEED_CHANGE_MASK ;
drivers/gpu/drm/amd/amdgpu/si.c +44 -26
131 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH] drm/amdgpu: Prefer pcie_capability_read_word()
Quoted 11 lines · Frederick Lawler
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>
drivers/gpu/drm/amd/amdgpu/cik.c static void cik_pcie_gen3_enable(struct amdgpu_device *adev) · line 1516
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/cik.c +3
-1-pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (adev->pdev, +PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (gpu_cfg2 & ((1 <<4 ) | (7 <<9 )));
Same comments as for radeon. Looks like a lot of similar code between radeon and amdgpu.
PATCH 1/1 drm/radeon: Prefer pcie_capability_read_word()
In reply to Frederick LawlerCommit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/gpu/drm/radeon/cik.c | 70 +++++++++++++++++++++------------- drivers/gpu/drm/radeon/si.c | 73 +++++++++++++++++++++++------------- 2 files changed, 90 insertions(+), 53 deletions(-)
drivers/gpu/drm/radeon/cik.c +44 -26
@@ -9500,7 +9500,6 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev) {struct pci_dev *root = rdev->pdev->bus->self;enum pci_bus_speed speed_cap; -int bridge_pos, gpu_pos;u32 speed_cntl, current_data_rate;int i;u16 tmp16;
@@ -9542,12 +9541,7 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)DRM_INFO ("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n" ); } - bridge_pos =pci_pcie_cap (root); -if (!bridge_pos) -return ; - - gpu_pos =pci_pcie_cap (rdev->pdev); -if (!gpu_pos) +if (!pci_is_pcie (root) || !pci_is_pcie (rdev->pdev))return ;if (speed_cap ==PCIE_SPEED_8_0GT ) {
@@ -9557,14 +9551,17 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)u16 bridge_cfg2, gpu_cfg2;u32 max_lw, current_lw, tmp; -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &bridge_cfg); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &gpu_cfg); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &bridge_cfg); +pcie_capability_read_word (rdev->pdev,PCI_EXP_LNKCTL , + &gpu_cfg); tmp16 = bridge_cfg |PCI_EXP_LNKCTL_HAWD ; -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (root,PCI_EXP_LNKCTL , tmp16); tmp16 = gpu_cfg |PCI_EXP_LNKCTL_HAWD ; -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (rdev->pdev,PCI_EXP_LNKCTL , + tmp16); tmp =RREG32_PCIE_PORT (PCIE_LC_STATUS1 ); max_lw = (tmp &LC_DETECTED_LINK_WIDTH_MASK ) >>LC_DETECTED_LINK_WIDTH_SHIFT ;
@@ -9582,15 +9579,23 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)for (i =0 ; i <10 ; i++) {/* check status */ -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_DEVSTA , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_DEVSTA , + &tmp16);if (tmp16 &PCI_EXP_DEVSTA_TRPND )break ; -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &bridge_cfg); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &gpu_cfg); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &bridge_cfg); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL , + &gpu_cfg); -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , &bridge_cfg2); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &gpu_cfg2); +pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , + &bridge_cfg2); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + &gpu_cfg2); tmp =RREG32_PCIE_PORT (PCIE_LC_CNTL4 ); tmp |=LC_SET_QUIESCE ;
@@ -9603,26 +9608,39 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)msleep (100 );/* linkctl */ -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &tmp16); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &tmp16); tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; tmp16 |= (bridge_cfg &PCI_EXP_LNKCTL_HAWD ); -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (root,PCI_EXP_LNKCTL , + tmp16); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL , + &tmp16); tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; tmp16 |= (gpu_cfg &PCI_EXP_LNKCTL_HAWD ); -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (rdev->pdev, +PCI_EXP_LNKCTL , + tmp16);/* linkctl2 */ -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (bridge_cfg2 & ((1 <<4 ) | (7 <<9 ))); -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (root, +PCI_EXP_LNKCTL2 , + tmp16); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (gpu_cfg2 & ((1 <<4 ) | (7 <<9 ))); -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + tmp16); tmp =RREG32_PCIE_PORT (PCIE_LC_CNTL4 ); tmp &= ~LC_SET_QUIESCE ;
@@ -9636,7 +9654,7 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev) speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE ;WREG32_PCIE_PORT (PCIE_LC_SPEED_CNTL , speed_cntl); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (rdev->pdev,PCI_EXP_LNKCTL2 , &tmp16); tmp16 &= ~0xf ;if (speed_cap ==PCIE_SPEED_8_0GT ) tmp16 |=3 ;/* gen3 */
@@ -9644,7 +9662,7 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev) tmp16 |=2 ;/* gen2 */ else tmp16 |= 1; /* gen1 */ -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (rdev->pdev,PCI_EXP_LNKCTL2 , tmp16); speed_cntl =RREG32_PCIE_PORT (PCIE_LC_SPEED_CNTL ); speed_cntl |=LC_INITIATE_LINK_SPEED_CHANGE ;
drivers/gpu/drm/radeon/si.c +46 -27
141 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH] drm/radeon: Prefer pcie_capability_read_word()
Quoted 112 lines · Frederick Lawler
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>--- drivers/gpu/drm/radeon/cik.c | 70 +++++++++++++++++++++------------- drivers/gpu/drm/radeon/si.c | 73 +++++++++++++++++++++++------------- 2 files changed, 90 insertions(+), 53 deletions(-)drivers/gpu/drm/radeon/cik.c +28
-20@@ -9500,7 +9500,6 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev) {struct pci_dev *root = rdev->pdev->bus->self;enum pci_bus_speed speed_cap; -int bridge_pos, gpu_pos;u32 speed_cntl, current_data_rate;int i;u16 tmp16;@@ -9542,12 +9541,7 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)DRM_INFO ("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n" ); } - bridge_pos =pci_pcie_cap (root); -if (!bridge_pos) -return ; - - gpu_pos =pci_pcie_cap (rdev->pdev); -if (!gpu_pos) +if (!pci_is_pcie (root) || !pci_is_pcie (rdev->pdev))return ;if (speed_cap ==PCIE_SPEED_8_0GT ) {@@ -9557,14 +9551,17 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)u16 bridge_cfg2, gpu_cfg2;u32 max_lw, current_lw, tmp; -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &bridge_cfg); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &gpu_cfg); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &bridge_cfg); +pcie_capability_read_word (rdev->pdev,PCI_EXP_LNKCTL , + &gpu_cfg); tmp16 = bridge_cfg |PCI_EXP_LNKCTL_HAWD ; -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (root,PCI_EXP_LNKCTL , tmp16); tmp16 = gpu_cfg |PCI_EXP_LNKCTL_HAWD ; -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (rdev->pdev,PCI_EXP_LNKCTL , + tmp16); tmp =RREG32_PCIE_PORT (PCIE_LC_STATUS1 ); max_lw = (tmp &LC_DETECTED_LINK_WIDTH_MASK ) >>LC_DETECTED_LINK_WIDTH_SHIFT ;@@ -9582,15 +9579,23 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)for (i =0 ; i <10 ; i++) {/* check status */ -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_DEVSTA , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_DEVSTA , + &tmp16);if (tmp16 &PCI_EXP_DEVSTA_TRPND )break ; -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &bridge_cfg); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &gpu_cfg); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &bridge_cfg); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL , + &gpu_cfg); -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , &bridge_cfg2); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &gpu_cfg2); +pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , + &bridge_cfg2); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + &gpu_cfg2); tmp =RREG32_PCIE_PORT (PCIE_LC_CNTL4 ); tmp |=LC_SET_QUIESCE ;@@ -9603,26 +9608,39 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)msleep (100 );/* linkctl */ -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &tmp16); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &tmp16); tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; tmp16 |= (bridge_cfg &PCI_EXP_LNKCTL_HAWD ); -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (root,PCI_EXP_LNKCTL , + tmp16); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL , + &tmp16); tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; tmp16 |= (gpu_cfg &PCI_EXP_LNKCTL_HAWD ); -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , tmp16);
drivers/gpu/drm/radeon/cik.c static void cik_pcie_gen3_enable(struct radeon_device *rdev) · line 9631
Quoted 10 lines
drivers/gpu/drm/radeon/cik.c +5
-1+pcie_capability_write_word (rdev->pdev, +PCI_EXP_LNKCTL , + tmp16);/* linkctl2 */ -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (bridge_cfg2 & ((1 <<4 ) | (7 <<9 )));
Looks like we could use some new #defines for these LNKCTL2 bits (also below).
Quoted 172 lines
drivers/gpu/drm/radeon/cik.c +11
-5-pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (root, +PCI_EXP_LNKCTL2 , + tmp16); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (gpu_cfg2 & ((1 <<4 ) | (7 <<9 ))); -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + tmp16); tmp =RREG32_PCIE_PORT (PCIE_LC_CNTL4 ); tmp &= ~LC_SET_QUIESCE ;@@ -9636,7 +9654,7 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev) speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE ;WREG32_PCIE_PORT (PCIE_LC_SPEED_CNTL , speed_cntl); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (rdev->pdev,PCI_EXP_LNKCTL2 , &tmp16); tmp16 &= ~0xf ;if (speed_cap ==PCIE_SPEED_8_0GT ) tmp16 |=3 ;/* gen3 */ @@ -9644,7 +9662,7 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev) tmp16 |=2 ;/* gen2 */ else tmp16 |= 1; /* gen1 */ -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (rdev->pdev,PCI_EXP_LNKCTL2 , tmp16); speed_cntl =RREG32_PCIE_PORT (PCIE_LC_SPEED_CNTL ); speed_cntl |=LC_INITIATE_LINK_SPEED_CHANGE ;drivers/gpu/drm/radeon/si.c +44
-25@@ -3253,7 +3253,7 @@ static void si_gpu_init(struct radeon_device *rdev)/* XXX what about 12? */ rdev->config.si.tile_config |= (3 <<0 );break ; - } + }switch ((mc_arb_ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ) {case 0 :/* four banks */ rdev->config.si.tile_config |=0 <<4 ;@@ -7083,7 +7083,6 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev) {struct pci_dev *root = rdev->pdev->bus->self;enum pci_bus_speed speed_cap; -int bridge_pos, gpu_pos;u32 speed_cntl, current_data_rate;int i;u16 tmp16;@@ -7125,12 +7124,7 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)DRM_INFO ("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n" ); } - bridge_pos =pci_pcie_cap (root); -if (!bridge_pos) -return ; - - gpu_pos =pci_pcie_cap (rdev->pdev); -if (!gpu_pos) +if (!pci_is_pcie (root) || !pci_is_pcie (rdev->pdev))return ;if (speed_cap ==PCIE_SPEED_8_0GT ) {@@ -7140,14 +7134,17 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)u16 bridge_cfg2, gpu_cfg2;u32 max_lw, current_lw, tmp; -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &bridge_cfg); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &gpu_cfg); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &bridge_cfg); +pcie_capability_read_word (rdev->pdev,PCI_EXP_LNKCTL , + &gpu_cfg); tmp16 = bridge_cfg |PCI_EXP_LNKCTL_HAWD ; -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (root,PCI_EXP_LNKCTL , tmp16); tmp16 = gpu_cfg |PCI_EXP_LNKCTL_HAWD ; -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (rdev->pdev,PCI_EXP_LNKCTL , + tmp16); tmp =RREG32_PCIE (PCIE_LC_STATUS1 ); max_lw = (tmp &LC_DETECTED_LINK_WIDTH_MASK ) >>LC_DETECTED_LINK_WIDTH_SHIFT ;@@ -7165,15 +7162,23 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)for (i =0 ; i <10 ; i++) {/* check status */ -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_DEVSTA , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_DEVSTA , + &tmp16);if (tmp16 &PCI_EXP_DEVSTA_TRPND )break ; -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &bridge_cfg); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &gpu_cfg); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &bridge_cfg); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL , + &gpu_cfg); -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , &bridge_cfg2); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &gpu_cfg2); +pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , + &bridge_cfg2); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + &gpu_cfg2); tmp =RREG32_PCIE_PORT (PCIE_LC_CNTL4 ); tmp |=LC_SET_QUIESCE ;@@ -7186,26 +7191,40 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)msleep (100 );/* linkctl */ -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL , &tmp16); +pcie_capability_read_word (root,PCI_EXP_LNKCTL , + &tmp16); tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; tmp16 |= (bridge_cfg &PCI_EXP_LNKCTL_HAWD ); -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (root, +PCI_EXP_LNKCTL , + tmp16); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL , + &tmp16); tmp16 &= ~PCI_EXP_LNKCTL_HAWD ; tmp16 |= (gpu_cfg &PCI_EXP_LNKCTL_HAWD ); -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL , tmp16); +pcie_capability_write_word (rdev->pdev, +PCI_EXP_LNKCTL , + tmp16);/* linkctl2 */ -pci_read_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (root,PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (bridge_cfg2 & ((1 <<4 ) | (7 <<9 ))); -pci_write_config_word (root, bridge_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (root, +PCI_EXP_LNKCTL2 , + tmp16); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + &tmp16); tmp16 &= ~((1 <<4 ) | (7 <<9 )); tmp16 |= (gpu_cfg2 & ((1 <<4 ) | (7 <<9 ))); -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (rdev->pdev, +PCI_EXP_LNKCTL2 , + tmp16); tmp =RREG32_PCIE_PORT (PCIE_LC_CNTL4 ); tmp &= ~LC_SET_QUIESCE ;
drivers/gpu/drm/radeon/si.c static void si_pcie_gen3_enable(struct radeon_device *rdev) · line 7244
Quoted 8 lines
drivers/gpu/drm/radeon/si.c +1
-1@@ -7219,7 +7238,7 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev) speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE ;WREG32_PCIE_PORT (PCIE_LC_SPEED_CNTL , speed_cntl); -pci_read_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); +pcie_capability_read_word (rdev->pdev,PCI_EXP_LNKCTL2 , &tmp16); tmp16 &= ~0xf ;if (speed_cap ==PCIE_SPEED_8_0GT ) tmp16 |=3 ;/* gen3 */
PCI_EXP_LNKCTL2_TLS, PCI_EXP_LNKCTL2_TLS_8_0GT, etc.
Quoted 10 lines
drivers/gpu/drm/radeon/si.c +1
-2@@ -7227,7 +7246,7 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev) tmp16 |=2 ;/* gen2 */ else tmp16 |= 1; /* gen1 */ -pci_write_config_word (rdev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , tmp16); +pcie_capability_write_word (rdev->pdev,PCI_EXP_LNKCTL2 , tmp16); speed_cntl =RREG32_PCIE_PORT (PCIE_LC_SPEED_CNTL ); speed_cntl |=LC_INITIATE_LINK_SPEED_CHANGE ; --
Quoted 2 lines
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 igc: Prefer pcie_capability_read_word()
In reply to Frederick LawlerCommit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/net/ethernet/intel/igc/igc_main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/igc/igc_main.c +4 -8
@@ -3891,13 +3891,11 @@ void igc_write_pci_cfg(struct igc_hw *hw, u32 reg, u16 *value)s32 igc_read_pcie_cap_reg (struct igc_hw *hw,u32 reg,u16 *value) {struct igc_adapter *adapter = hw->back; -u16 cap_offset; - cap_offset =pci_find_capability (adapter->pdev,PCI_CAP_ID_EXP ); -if (!cap_offset) +if (!pci_is_pcie (adapter->pdev))return -IGC_ERR_CONFIG ; -pci_read_config_word (adapter->pdev, cap_offset + reg, value); +pcie_capability_read_word (adapter->pdev, reg, value);return IGC_SUCCESS ; }
@@ -3905,13 +3903,11 @@ s32 igc_read_pcie_cap_reg(struct igc_hw *hw, u32 reg, u16 *value)s32 igc_write_pcie_cap_reg (struct igc_hw *hw,u32 reg,u16 *value) {struct igc_adapter *adapter = hw->back; -u16 cap_offset; - cap_offset =pci_find_capability (adapter->pdev,PCI_CAP_ID_EXP ); -if (!cap_offset) +if (!pci_is_pcie (adapter->pdev))return -IGC_ERR_CONFIG ; -pci_write_config_word (adapter->pdev, cap_offset + reg, *value); +pcie_capability_write_word (adapter->pdev, reg, *value);return IGC_SUCCESS ; }
Signature · 1 line
2.17.1
Re: [PATCH] igc: Prefer pcie_capability_read_word()
From: Frederick Lawler <[email protected]>
Date: Wed, 17 Jul 2019 21:07:39 -0500
Quoted 9 lines
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>
Applied.
PATCH 1/1 scsi: csiostor: Prefer pcie_capability_read_word()
In reply to Frederick LawlerCommit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/scsi/csiostor/csio_wr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/csiostor/csio_wr.c +2 -6
@@ -1316,7 +1316,6 @@ csio_wr_fixup_host_params(struct csio_hw *hw)u32 fl_align = clsz <32 ?32 : clsz;u32 pack_align;u32 ingpad, ingpack; -int pcie_cap; csio_wr_reg32(hw, HOSTPAGESIZEPF0_V(s_hps) | HOSTPAGESIZEPF1_V(s_hps) | HOSTPAGESIZEPF2_V(s_hps) | HOSTPAGESIZEPF3_V(s_hps) |
@@ -1347,8 +1346,7 @@ csio_wr_fixup_host_params(struct csio_hw *hw)* multiple of the Maximum Payload Size. */ pack_align = fl_align; - pcie_cap =pci_find_capability (hw->pdev,PCI_CAP_ID_EXP ); -if (pcie_cap) { +if (pci_is_pcie (hw->pdev)) {u32 mps, mps_log;u16 devctl;
@@ -1356,9 +1354,7 @@ csio_wr_fixup_host_params(struct csio_hw *hw)* [bits 7:5] encodes sizes as powers of 2 starting at * 128 bytes. */ -pci_read_config_word (hw->pdev, - pcie_cap +PCI_EXP_DEVCTL , - &devctl); +pcie_capability_read_word (hw->pdev,PCI_EXP_DEVCTL , &devctl); mps_log = ((devctl &PCI_EXP_DEVCTL_PAYLOAD ) >>5 ) +7 ; mps =1 << mps_log;if (mps > pack_align)
Signature · 1 line
2.17.1
Martin K. Petersen
AppliedRe: [PATCH] scsi: csiostor: Prefer pcie_capability_read_word()
Frederick,
Quoted 7 lines
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().
Applied to 5.4/scsi-queue. Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 1/1 scsi: esas2r: Prefer pcie_capability_read_word()
In reply to Frederick LawlerCommit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/scsi/esas2r/esas2r_init.c | 13 ++++--------- drivers/scsi/esas2r/esas2r_ioctl.c | 14 +++++--------- 2 files changed, 9 insertions(+), 18 deletions(-)
drivers/scsi/esas2r/esas2r_init.c +4 -9
@@ -762,14 +762,10 @@ u32 esas2r_get_uncached_size(struct esas2r_adapter *a)static void esas2r_init_pci_cfg_space (struct esas2r_adapter *a) { -int pcie_cap_reg; - - pcie_cap_reg =pci_find_capability (a->pcid,PCI_CAP_ID_EXP ); -if (pcie_cap_reg) { +if (pci_is_pcie (a->pcid)) {u16 devcontrol; -pci_read_config_word (a->pcid, pcie_cap_reg +PCI_EXP_DEVCTL , - &devcontrol); +pcie_capability_read_word (a->pcid,PCI_EXP_DEVCTL , &devcontrol);if ((devcontrol &PCI_EXP_DEVCTL_READRQ ) >PCI_EXP_DEVCTL_READRQ_512B ) {
@@ -778,9 +774,8 @@ static void esas2r_init_pci_cfg_space(struct esas2r_adapter *a) devcontrol &= ~PCI_EXP_DEVCTL_READRQ ; devcontrol |=PCI_EXP_DEVCTL_READRQ_512B ; -pci_write_config_word (a->pcid, - pcie_cap_reg +PCI_EXP_DEVCTL , - devcontrol); +pcie_capability_write_word (a->pcid,PCI_EXP_DEVCTL , + devcontrol); } } }
drivers/scsi/esas2r/esas2r_ioctl.c +5 -9
@@ -757,7 +757,6 @@ static int hba_ioctl_callback(struct esas2r_adapter *a,struct atto_hba_get_adapter_info *gai = &hi->data.get_adap_info; -int pcie_cap_reg;if (hi->flags &HBAF_TUNNEL ) { hi->status =ATTO_STS_UNSUPPORTED ;
@@ -784,17 +783,14 @@ static int hba_ioctl_callback(struct esas2r_adapter *a, gai->pci.dev_num =PCI_SLOT (a->pcid->devfn); gai->pci.func_num =PCI_FUNC (a->pcid->devfn); - pcie_cap_reg =pci_find_capability (a->pcid,PCI_CAP_ID_EXP ); -if (pcie_cap_reg) { +if (pci_is_pcie (a->pcid)) {u16 stat;u32 caps; -pci_read_config_word (a->pcid, - pcie_cap_reg +PCI_EXP_LNKSTA , - &stat); -pci_read_config_dword (a->pcid, - pcie_cap_reg +PCI_EXP_LNKCAP , - &caps); +pcie_capability_read_word (a->pcid,PCI_EXP_LNKSTA , + &stat); +pcie_capability_read_dword (a->pcid,PCI_EXP_LNKCAP , + &caps); gai->pci.link_speed_curr = (u8)(stat &PCI_EXP_LNKSTA_CLS );
Signature · 1 line
2.17.1
Martin K. Petersen
AppliedRe: [PATCH] scsi: esas2r: Prefer pcie_capability_read_word()
Frederick,
Quoted 7 lines
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().
Applied to 5.4/scsi-queue, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 1/1 media: cobalt: Prefer pcie_capability_read_word()
In reply to Frederick LawlerCommit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/media/pci/cobalt/cobalt-driver.c | 38 ++++++++++-------------- 1 file changed, 15 insertions(+), 23 deletions(-)
drivers/media/pci/cobalt/cobalt-driver.c +15 -23
@@ -186,20 +186,16 @@ void cobalt_pcie_status_show(struct cobalt *cobalt) {struct pci_dev *pci_dev = cobalt->pci_dev;struct pci_dev *pci_bus_dev = cobalt->pci_dev->bus->self; -int offset; -int bus_offset;u32 capa;u16 stat, ctrl; - offset =pci_find_capability (pci_dev,PCI_CAP_ID_EXP ); - bus_offset =pci_find_capability (pci_bus_dev,PCI_CAP_ID_EXP ); -if (!offset || !bus_offset) +if (!pci_is_pcie (pci_dev) || !pci_is_pcie (pci_bus_dev))return ;/* Device */ -pci_read_config_dword (pci_dev, offset +PCI_EXP_DEVCAP , &capa); -pci_read_config_word (pci_dev, offset +PCI_EXP_DEVCTL , &ctrl); -pci_read_config_word (pci_dev, offset +PCI_EXP_DEVSTA , &stat); +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 )); cobalt_info("PCIe device control 0x%04x: Max payload %d. Max read request %d\n",
@@ -209,9 +205,9 @@ void cobalt_pcie_status_show(struct cobalt *cobalt)cobalt_info ("PCIe device status 0x%04x\n" , stat);/* Link */ -pci_read_config_dword (pci_dev, offset +PCI_EXP_LNKCAP , &capa); -pci_read_config_word (pci_dev, offset +PCI_EXP_LNKCTL , &ctrl); -pci_read_config_word (pci_dev, offset +PCI_EXP_LNKSTA , &stat); +pcie_capability_read_dword (pci_dev,PCI_EXP_LNKCAP , &capa); +pcie_capability_read_word (pci_dev,PCI_EXP_LNKCTL , &ctrl); +pcie_capability_read_word (pci_dev,PCI_EXP_LNKSTA , &stat);cobalt_info ("PCIe link capability 0x%08x: %s per lane and %u lanes\n" , capa,get_link_speed (capa), (capa &PCI_EXP_LNKCAP_MLW ) >>4 );
@@ -221,15 +217,15 @@ void cobalt_pcie_status_show(struct cobalt *cobalt) (stat & PCI_EXP_LNKSTA_NLW) >> 4);/* Bus */ -pci_read_config_dword (pci_bus_dev, bus_offset +PCI_EXP_LNKCAP , &capa); +pcie_capability_read_dword (pci_bus_dev,PCI_EXP_LNKCAP , &capa);cobalt_info ("PCIe bus link capability 0x%08x: %s per lane and %u lanes\n" , capa,get_link_speed (capa), (capa &PCI_EXP_LNKCAP_MLW ) >>4 );/* Slot */ -pci_read_config_dword (pci_dev, offset +PCI_EXP_SLTCAP , &capa); -pci_read_config_word (pci_dev, offset +PCI_EXP_SLTCTL , &ctrl); -pci_read_config_word (pci_dev, offset +PCI_EXP_SLTSTA , &stat); +pcie_capability_read_dword (pci_dev,PCI_EXP_SLTCAP , &capa); +pcie_capability_read_word (pci_dev,PCI_EXP_SLTCTL , &ctrl); +pcie_capability_read_word (pci_dev,PCI_EXP_SLTSTA , &stat);cobalt_info ("PCIe slot capability 0x%08x\n" , capa);cobalt_info ("PCIe slot control 0x%04x\n" , ctrl);cobalt_info ("PCIe slot status 0x%04x\n" , stat);
@@ -238,26 +234,22 @@ void cobalt_pcie_status_show(struct cobalt *cobalt)static unsigned pcie_link_get_lanes (struct cobalt *cobalt) {struct pci_dev *pci_dev = cobalt->pci_dev; -unsigned offset;u16 link; - offset =pci_find_capability (pci_dev,PCI_CAP_ID_EXP ); -if (!offset) +if (!pci_is_pcie (pci_dev))return 0 ; -pci_read_config_word (pci_dev, offset +PCI_EXP_LNKSTA , &link); +pcie_capability_read_word (pci_dev,PCI_EXP_LNKSTA , &link);return (link &PCI_EXP_LNKSTA_NLW ) >>4 ; }static unsigned pcie_bus_link_get_lanes (struct cobalt *cobalt) {struct pci_dev *pci_dev = cobalt->pci_dev->bus->self; -unsigned offset;u32 link; - offset =pci_find_capability (pci_dev,PCI_CAP_ID_EXP ); -if (!offset) +if (!pci_is_pcie (pci_dev))return 0 ; -pci_read_config_dword (pci_dev, offset +PCI_EXP_LNKCAP , &link); +pcie_capability_read_dword (pci_dev,PCI_EXP_LNKCAP , &link);return (link &PCI_EXP_LNKCAP_MLW ) >>4 ; }
Signature · 1 line
2.17.1
PATCH 1/1 mtip32xx: Prefer pcie_capability_read_word()
In reply to Frederick LawlerCommit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/block/mtip32xx/mtip32xx.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +12 -16
@@ -3952,22 +3952,18 @@ static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)int pos;unsigned short pcie_dev_ctrl; - pos =pci_find_capability (pdev,PCI_CAP_ID_EXP ); -if (pos) { -pci_read_config_word (pdev, - pos +PCI_EXP_DEVCTL , - &pcie_dev_ctrl); -if (pcie_dev_ctrl & (1 <<11 ) || - pcie_dev_ctrl & (1 <<4 )) { -dev_info (&dd->pdev->dev, -"Disabling ERO/No-Snoop on bridge device %04x:%04x\n" , - pdev->vendor, pdev->device); - pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN | -PCI_EXP_DEVCTL_RELAX_EN ); -pci_write_config_word (pdev, - pos +PCI_EXP_DEVCTL , - pcie_dev_ctrl); - } +if (!pci_is_pcie (pdev)) +return ; + +pcie_capability_read_word (pdev,PCI_EXP_DEVCTL , &pcie_dev_ctrl); +if (pcie_dev_ctrl & (1 <<11 ) || + pcie_dev_ctrl & (1 <<4 )) { +dev_info (&dd->pdev->dev, +"Disabling ERO/No-Snoop on bridge device %04x:%04x\n" , + pdev->vendor, pdev->device); + pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN | +PCI_EXP_DEVCTL_RELAX_EN ); +pcie_capability_write_word (pdev,PCI_EXP_DEVCTL , pcie_dev_ctrl); } }
Signature · 1 line
2.17.1
Re: [PATCH] mtip32xx: Prefer pcie_capability_read_word()
Quoted 34 lines · Frederick Lawler
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>--- drivers/block/mtip32xx/mtip32xx.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)drivers/block/mtip32xx/mtip32xx.c +0
-12@@ -3952,22 +3952,18 @@ static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)int pos;unsigned short pcie_dev_ctrl; - pos =pci_find_capability (pdev,PCI_CAP_ID_EXP ); -if (pos) { -pci_read_config_word (pdev, - pos +PCI_EXP_DEVCTL , - &pcie_dev_ctrl); -if (pcie_dev_ctrl & (1 <<11 ) || - pcie_dev_ctrl & (1 <<4 )) { -dev_info (&dd->pdev->dev, -"Disabling ERO/No-Snoop on bridge device %04x:%04x\n" , - pdev->vendor, pdev->device); - pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN | -PCI_EXP_DEVCTL_RELAX_EN );
drivers/block/mtip32xx/mtip32xx.c static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev) · line 3960
Quoted 10 lines
drivers/block/mtip32xx/mtip32xx.c +6
-4-pci_write_config_word (pdev, - pos +PCI_EXP_DEVCTL , - pcie_dev_ctrl); - } +if (!pci_is_pcie (pdev)) +return ; + +pcie_capability_read_word (pdev,PCI_EXP_DEVCTL , &pcie_dev_ctrl); +if (pcie_dev_ctrl & (1 <<11 ) || + pcie_dev_ctrl & (1 <<4 )) {
Hmm, sort of sloppy that d1e714db8129 ("mtip32xx: Fix ERO and NoSnoop values in PCIe upstream on AMD systems") used PCI_EXP_DEVCTL_NOSNOOP_EN and PCI_EXP_DEVCTL_RELAX_EN below, but not here. Could be fixed with a separate follow-on patch.
Quoted 12 lines
drivers/block/mtip32xx/mtip32xx.c +6
-1+dev_info (&dd->pdev->dev, +"Disabling ERO/No-Snoop on bridge device %04x:%04x\n" , + pdev->vendor, pdev->device); + pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN | +PCI_EXP_DEVCTL_RELAX_EN ); +pcie_capability_write_word (pdev,PCI_EXP_DEVCTL , pcie_dev_ctrl); } } --2.17.1
PATCH 1/1 qed: Prefer pcie_capability_read_word()
In reply to Frederick LawlerCommit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/net/ethernet/qlogic/qed/qed_rdma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_rdma.c +2 -3
@@ -530,9 +530,8 @@ static void qed_rdma_init_devinfo(struct qed_hwfn *p_hwfn,SET_FIELD (dev->dev_caps,QED_RDMA_DEV_CAP_LOCAL_INV_FENCE ,1 );/* Check atomic operations support in PCI configuration space. */ -pci_read_config_dword (cdev->pdev, - cdev->pdev->pcie_cap +PCI_EXP_DEVCTL2 , - &pci_status_control); +pcie_capability_read_dword (cdev->pdev,PCI_EXP_DEVCTL2 , + &pci_status_control);if (pci_status_control &PCI_EXP_DEVCTL2_LTR_EN )SET_FIELD (dev->dev_caps,QED_RDMA_DEV_CAP_ATOMIC_OP ,1 );
Signature · 1 line
2.17.1
RE: [EXT] [PATCH] qed: Prefer pcie_capability_read_word()
Quoted 37 lines
From: Frederick Lawler <[email protected]>
Sent: Thursday, July 18, 2019 5:08 AMExternal Email
----------------------------------------------------------------------
Commit8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>--- drivers/net/ethernet/qlogic/qed/qed_rdma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/net/ethernet/qlogic/qed/qed_rdma.c +2
-3@@ -530,9 +530,8 @@ static void qed_rdma_init_devinfo(struct qed_hwfn *p_hwfn,SET_FIELD (dev->dev_caps,QED_RDMA_DEV_CAP_LOCAL_INV_FENCE ,1 );/* Check atomic operations support in PCI configuration space. */ -pci_read_config_dword (cdev->pdev, - cdev->pdev->pcie_cap +PCI_EXP_DEVCTL2 , - &pci_status_control); +pcie_capability_read_dword (cdev->pdev,PCI_EXP_DEVCTL2 , + &pci_status_control);drivers/net/ethernet/qlogic/qed/qed_rdma.c +0
-0if (pci_status_control &PCI_EXP_DEVCTL2_LTR_EN ) SET_FIELD(dev->dev_caps,
Quoted 3 lines
QED_RDMA_DEV_CAP_ATOMIC_OP, 1);
--
2.17.1
Thanks,
Re: [PATCH] qed: Prefer pcie_capability_read_word()
In reply to Frederick LawlerFrom: Frederick Lawler <[email protected]>
Date: Wed, 17 Jul 2019 21:07:42 -0500
Quoted 9 lines
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>
Applied.
PATCH 1/1 skd: Prefer pcie_capability_read_word()
In reply to Frederick LawlerCommit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.
Replace pci_read_config_word() and pci_write_config_word() calls with pcie_capability_read_word() and pcie_capability_write_word().
--- drivers/block/skd_main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/block/skd_main.c +2 -6
@@ -3137,18 +3137,14 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);static char *skd_pci_info (struct skd_device *skdev,char *str) { -int pcie_reg; -strcpy (str,"PCIe (" ); - pcie_reg =pci_find_capability (skdev->pdev,PCI_CAP_ID_EXP ); -if (pcie_reg) { +if (pci_is_pcie (skdev->pdev)) {char lwstr[6 ];uint16_t pcie_lstat, lspeed, lwidth; - pcie_reg +=0x12 ; -pci_read_config_word (skdev->pdev, pcie_reg, &pcie_lstat); +pcie_capability_read_word (skdev->pdev,0x12 , &pcie_lstat); lspeed = pcie_lstat & (0xF ); lwidth = (pcie_lstat &0x3F0 ) >>4 ;
Signature · 1 line
2.17.1
Re: [PATCH] skd: Prefer pcie_capability_read_word()
Quoted 28 lines · Frederick Lawler
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>--- drivers/block/skd_main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/block/skd_main.c +0
-4@@ -3137,18 +3137,14 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);static char *skd_pci_info (struct skd_device *skdev,char *str) { -int pcie_reg; -strcpy (str,"PCIe (" ); - pcie_reg =pci_find_capability (skdev->pdev,PCI_CAP_ID_EXP ); -if (pcie_reg) {
drivers/block/skd_main.c MODULE_DEVICE_TABLE(pci, skd_pci_tbl); · line 3149
Quoted 10 lines
drivers/block/skd_main.c +2
-2+if (pci_is_pcie (skdev->pdev)) {char lwstr[6 ];uint16_t pcie_lstat, lspeed, lwidth; - pcie_reg +=0x12 ; -pci_read_config_word (skdev->pdev, pcie_reg, &pcie_lstat); +pcie_capability_read_word (skdev->pdev,0x12 , &pcie_lstat); lspeed = pcie_lstat & (0xF ); lwidth = (pcie_lstat &0x3F0 ) >>4 ;
This should use PCI_EXP_LNKSTA, PCI_EXP_LNKSTA_CLS, PCI_EXP_LNKSTA_NLW, etc.
Would probably make sense to do that in a separate patch so this patch matches the other conversions to pcie_capability_read_word().
Quoted 10 lines · Frederick Lawler
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>
Nice job on all these patches! These all help avoid errors and identify possibilities for refactoring.
If there were a cover letter for the series, I would have replied to that, but for all of them:
If you post the series again for any reason, you can add that. Otherwise, whoever applies them can add my reviewed-by.
Quoted 66 lines
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 6 ++---- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-)drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +2
-4@@ -5441,7 +5441,6 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)char name[IFNAMSIZ ];u32 devcap2;u16 flags; -int pos;/* If we want to instantiate Virtual Functions, then our * parent bridge's PCI-E needs to support Alternative Routing @@ -5449,9 +5448,8 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)* and above. */ pbridge = pdev->bus->self; - pos =pci_find_capability (pbridge,PCI_CAP_ID_EXP ); -pci_read_config_word (pbridge, pos +PCI_EXP_FLAGS , &flags); -pci_read_config_dword (pbridge, pos +PCI_EXP_DEVCAP2 , &devcap2); +pcie_capability_read_word (pbridge,PCI_EXP_FLAGS , &flags); +pcie_capability_read_dword (pbridge,PCI_EXP_DEVCAP2 , &devcap2);if ((flags &PCI_EXP_FLAGS_VERS ) <2 || !(devcap2 &PCI_EXP_DEVCAP2_ARI )) {drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +3
-7@@ -7267,7 +7267,6 @@ int t4_fixup_host_params(struct adapter *adap, unsigned int page_size, }else {unsigned int pack_align;unsigned int ingpad, ingpack; -unsigned int pcie_cap;/* T5 introduced the separation of the Free List Padding and * Packing Boundaries. Thus, we can select a smaller Padding @@ -7292,8 +7291,7 @@ int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,* multiple of the Maximum Payload Size. */ pack_align = fl_align; - pcie_cap =pci_find_capability (adap->pdev,PCI_CAP_ID_EXP ); -if (pcie_cap) { +if (pci_is_pcie (adap->pdev)) {unsigned int mps, mps_log;u16 devctl;@@ -7301,9 +7299,8 @@ int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,* [bits 7:5] encodes sizes as powers of 2 starting at * 128 bytes. */ -pci_read_config_word (adap->pdev, - pcie_cap +PCI_EXP_DEVCTL , - &devctl); +pcie_capability_read_word (adap->pdev,PCI_EXP_DEVCTL , + &devctl); mps_log = ((devctl &PCI_EXP_DEVCTL_PAYLOAD ) >>5 ) +7 ; mps =1 << mps_log;if (mps > pack_align) --2.17.1
From: Frederick Lawler <[email protected]>
Date: Wed, 17 Jul 2019 21:07:36 -0500
Quoted 9 lines
Commit
8c0d3a02c130("PCI: Add accessors for PCI Express Capability") added accessors for the PCI Express Capability so that drivers didn't need to be aware of differences between v1 and v2 of the PCI Express Capability.Replace
pci_read_config_word()andpci_write_config_word()calls withpcie_capability_read_word()andpcie_capability_write_word().Signed-off-by Frederick Lawler <[email protected]>
Applied.