diff mbox series

[v2,net-next] pds_core: remove redundant pci_clear_master()

Message ID 20230817025709.2023553-1-liaoyu15@huawei.com (mailing list archive)
State Accepted
Commit 2f48b1d854e853b243fcd7e4f3f11d6ab5431bd7
Delegated to: Netdev Maintainers
Headers show
Series [v2,net-next] pds_core: remove redundant pci_clear_master() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 1 maintainers not CCed: brett.creeley@amd.com
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1353 this patch: 1353
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yu Liao Aug. 17, 2023, 2:57 a.m. UTC
do_pci_disable_device() disable PCI bus-mastering as following:
static void do_pci_disable_device(struct pci_dev *dev)
{
		u16 pci_command;

		pci_read_config_word(dev, PCI_COMMAND, &pci_command);
		if (pci_command & PCI_COMMAND_MASTER) {
				pci_command &= ~PCI_COMMAND_MASTER;
				pci_write_config_word(dev, PCI_COMMAND, pci_command);
		}

		pcibios_disable_device(dev);
}
And pci_disable_device() sets dev->is_busmaster to 0.

pci_enable_device() is called only once before calling to
pci_disable_device() and such pci_clear_master() is not needed. So remove
redundant pci_clear_master().

Also rename goto label 'err_out_clear_master' to 'err_out_disable_device'.

Signed-off-by: Yu Liao <liaoyu15@huawei.com>
---
v1 -> v2:
- add explanation why pci_disable_device() disables PCI bus-mastering
- rename goto label 'err_out_clear_master' to 'err_out_disable_device' 
---
 drivers/net/ethernet/amd/pds_core/main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Simon Horman Aug. 17, 2023, 7:53 a.m. UTC | #1
On Thu, Aug 17, 2023 at 10:57:09AM +0800, Yu Liao wrote:
> do_pci_disable_device() disable PCI bus-mastering as following:
> static void do_pci_disable_device(struct pci_dev *dev)
> {
> 		u16 pci_command;
> 
> 		pci_read_config_word(dev, PCI_COMMAND, &pci_command);
> 		if (pci_command & PCI_COMMAND_MASTER) {
> 				pci_command &= ~PCI_COMMAND_MASTER;
> 				pci_write_config_word(dev, PCI_COMMAND, pci_command);
> 		}
> 
> 		pcibios_disable_device(dev);
> }
> And pci_disable_device() sets dev->is_busmaster to 0.
> 
> pci_enable_device() is called only once before calling to
> pci_disable_device() and such pci_clear_master() is not needed. So remove
> redundant pci_clear_master().
> 
> Also rename goto label 'err_out_clear_master' to 'err_out_disable_device'.
> 
> Signed-off-by: Yu Liao <liaoyu15@huawei.com>

Reviewed-by: Simon Horman <horms@kernel.org>
Leon Romanovsky Aug. 17, 2023, 8:05 a.m. UTC | #2
On Thu, Aug 17, 2023 at 10:57:09AM +0800, Yu Liao wrote:
> do_pci_disable_device() disable PCI bus-mastering as following:
> static void do_pci_disable_device(struct pci_dev *dev)
> {
> 		u16 pci_command;
> 
> 		pci_read_config_word(dev, PCI_COMMAND, &pci_command);
> 		if (pci_command & PCI_COMMAND_MASTER) {
> 				pci_command &= ~PCI_COMMAND_MASTER;
> 				pci_write_config_word(dev, PCI_COMMAND, pci_command);
> 		}
> 
> 		pcibios_disable_device(dev);
> }
> And pci_disable_device() sets dev->is_busmaster to 0.
> 
> pci_enable_device() is called only once before calling to
> pci_disable_device() and such pci_clear_master() is not needed. So remove
> redundant pci_clear_master().
> 
> Also rename goto label 'err_out_clear_master' to 'err_out_disable_device'.
> 
> Signed-off-by: Yu Liao <liaoyu15@huawei.com>
> ---
> v1 -> v2:
> - add explanation why pci_disable_device() disables PCI bus-mastering
> - rename goto label 'err_out_clear_master' to 'err_out_disable_device' 
> ---
>  drivers/net/ethernet/amd/pds_core/main.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Nelson, Shannon Aug. 17, 2023, 3:55 p.m. UTC | #3
On 8/16/2023 7:57 PM, Yu Liao wrote:
> 
> do_pci_disable_device() disable PCI bus-mastering as following:
> static void do_pci_disable_device(struct pci_dev *dev)
> {
>                  u16 pci_command;
> 
>                  pci_read_config_word(dev, PCI_COMMAND, &pci_command);
>                  if (pci_command & PCI_COMMAND_MASTER) {
>                                  pci_command &= ~PCI_COMMAND_MASTER;
>                                  pci_write_config_word(dev, PCI_COMMAND, pci_command);
>                  }
> 
>                  pcibios_disable_device(dev);
> }
> And pci_disable_device() sets dev->is_busmaster to 0.
> 
> pci_enable_device() is called only once before calling to
> pci_disable_device() and such pci_clear_master() is not needed. So remove
> redundant pci_clear_master().
> 
> Also rename goto label 'err_out_clear_master' to 'err_out_disable_device'.
> 
> Signed-off-by: Yu Liao <liaoyu15@huawei.com>

Acked-by: Shannon Nelson <shannon.nelson@amd.com>


> ---
> v1 -> v2:
> - add explanation why pci_disable_device() disables PCI bus-mastering
> - rename goto label 'err_out_clear_master' to 'err_out_disable_device'
> ---
>   drivers/net/ethernet/amd/pds_core/main.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c
> index 672757932246..3a45bf474a19 100644
> --- a/drivers/net/ethernet/amd/pds_core/main.c
> +++ b/drivers/net/ethernet/amd/pds_core/main.c
> @@ -367,14 +367,13 @@ static int pdsc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>                  err = pdsc_init_vf(pdsc);
>          if (err) {
>                  dev_err(dev, "Cannot init device: %pe\n", ERR_PTR(err));
> -               goto err_out_clear_master;
> +               goto err_out_disable_device;
>          }
> 
>          clear_bit(PDSC_S_INITING_DRIVER, &pdsc->state);
>          return 0;
> 
> -err_out_clear_master:
> -       pci_clear_master(pdev);
> +err_out_disable_device:
>          pci_disable_device(pdev);
>   err_out_free_ida:
>          ida_free(&pdsc_ida, pdsc->uid);
> @@ -439,7 +438,6 @@ static void pdsc_remove(struct pci_dev *pdev)
>                  pci_release_regions(pdev);
>          }
> 
> -       pci_clear_master(pdev);
>          pci_disable_device(pdev);
> 
>          ida_free(&pdsc_ida, pdsc->uid);
> --
> 2.25.1
>
patchwork-bot+netdevbpf@kernel.org Aug. 18, 2023, 10:40 p.m. UTC | #4
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 17 Aug 2023 10:57:09 +0800 you wrote:
> do_pci_disable_device() disable PCI bus-mastering as following:
> static void do_pci_disable_device(struct pci_dev *dev)
> {
> 		u16 pci_command;
> 
> 		pci_read_config_word(dev, PCI_COMMAND, &pci_command);
> 		if (pci_command & PCI_COMMAND_MASTER) {
> 				pci_command &= ~PCI_COMMAND_MASTER;
> 				pci_write_config_word(dev, PCI_COMMAND, pci_command);
> 		}
> 
> [...]

Here is the summary with links:
  - [v2,net-next] pds_core: remove redundant pci_clear_master()
    https://git.kernel.org/netdev/net-next/c/2f48b1d854e8

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c
index 672757932246..3a45bf474a19 100644
--- a/drivers/net/ethernet/amd/pds_core/main.c
+++ b/drivers/net/ethernet/amd/pds_core/main.c
@@ -367,14 +367,13 @@  static int pdsc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		err = pdsc_init_vf(pdsc);
 	if (err) {
 		dev_err(dev, "Cannot init device: %pe\n", ERR_PTR(err));
-		goto err_out_clear_master;
+		goto err_out_disable_device;
 	}
 
 	clear_bit(PDSC_S_INITING_DRIVER, &pdsc->state);
 	return 0;
 
-err_out_clear_master:
-	pci_clear_master(pdev);
+err_out_disable_device:
 	pci_disable_device(pdev);
 err_out_free_ida:
 	ida_free(&pdsc_ida, pdsc->uid);
@@ -439,7 +438,6 @@  static void pdsc_remove(struct pci_dev *pdev)
 		pci_release_regions(pdev);
 	}
 
-	pci_clear_master(pdev);
 	pci_disable_device(pdev);
 
 	ida_free(&pdsc_ida, pdsc->uid);