2023-03-23 11:57:34

by Cai Huoqing

[permalink] [raw]
Subject: [PATCH 1/3] ntb_hw_amd: Remove redundant pci_clear_master

Remove pci_clear_master to simplify the code,
the bus-mastering is also cleared in do_pci_disable_device,
like this:
./drivers/pci/pci.c:2197
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 dev->is_busmaster is set to 0 in pci_disable_device.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/ntb/hw/amd/ntb_hw_amd.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index 730f2103b91d..855ff65f64a5 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -1194,7 +1194,6 @@ static int amd_ntb_init_pci(struct amd_ntb_dev *ndev,
return 0;

err_dma_mask:
- pci_clear_master(pdev);
pci_release_regions(pdev);
err_pci_regions:
pci_disable_device(pdev);
@@ -1209,7 +1208,6 @@ static void amd_ntb_deinit_pci(struct amd_ntb_dev *ndev)

pci_iounmap(pdev, ndev->self_mmio);

- pci_clear_master(pdev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
--
2.34.1


2023-03-23 11:57:46

by Cai Huoqing

[permalink] [raw]
Subject: [PATCH 2/3] ntb: epf: Remove redundant pci_clear_master

Remove pci_clear_master to simplify the code,
the bus-mastering is also cleared in do_pci_disable_device,
like this:
./drivers/pci/pci.c:2197
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 dev->is_busmaster is set to 0 in pci_disable_device.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/ntb/hw/epf/ntb_hw_epf.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c
index 3ece49cb18ff..d80f205810a4 100644
--- a/drivers/ntb/hw/epf/ntb_hw_epf.c
+++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
@@ -617,14 +617,11 @@ static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
ndev->db_reg = pci_iomap(pdev, ndev->db_reg_bar, 0);
if (!ndev->db_reg) {
ret = -EIO;
- goto err_dma_mask;
+ goto err_pci_regions;
}

return 0;

-err_dma_mask:
- pci_clear_master(pdev);
-
err_pci_regions:
pci_disable_device(pdev);

@@ -642,7 +639,6 @@ static void ntb_epf_deinit_pci(struct ntb_epf_dev *ndev)
pci_iounmap(pdev, ndev->peer_spad_reg);
pci_iounmap(pdev, ndev->db_reg);

- pci_clear_master(pdev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
--
2.34.1

2023-03-23 11:57:49

by Cai Huoqing

[permalink] [raw]
Subject: [PATCH 3/3] ntb: intel: Remove redundant pci_clear_master

Remove pci_clear_master to simplify the code,
the bus-mastering is also cleared in do_pci_disable_device,
like this:
./drivers/pci/pci.c:2197
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 dev->is_busmaster is set to 0 in pci_disable_device.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/ntb/hw/intel/ntb_hw_gen1.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/ntb/hw/intel/ntb_hw_gen1.c b/drivers/ntb/hw/intel/ntb_hw_gen1.c
index 60a4ebc7bf35..9ab836d0d4f1 100644
--- a/drivers/ntb/hw/intel/ntb_hw_gen1.c
+++ b/drivers/ntb/hw/intel/ntb_hw_gen1.c
@@ -1791,7 +1791,6 @@ static int intel_ntb_init_pci(struct intel_ntb_dev *ndev, struct pci_dev *pdev)

err_mmio:
err_dma_mask:
- pci_clear_master(pdev);
pci_release_regions(pdev);
err_pci_regions:
pci_disable_device(pdev);
@@ -1808,7 +1807,6 @@ static void intel_ntb_deinit_pci(struct intel_ntb_dev *ndev)
pci_iounmap(pdev, ndev->peer_mmio);
pci_iounmap(pdev, ndev->self_mmio);

- pci_clear_master(pdev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
--
2.34.1

2023-03-23 13:45:46

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/3] ntb: epf: Remove redundant pci_clear_master

Hi Cai,

I love your patch! Yet something to improve:

[auto build test ERROR on jonmason-ntb/ntb-next]
[also build test ERROR on linus/master v6.3-rc3 next-20230323]
[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/Cai-Huoqing/ntb-epf-Remove-redundant-pci_clear_master/20230323-195616
base: https://github.com/jonmason/ntb ntb-next
patch link: https://lore.kernel.org/r/20230323115336.12986-2-cai.huoqing%40linux.dev
patch subject: [PATCH 2/3] ntb: epf: Remove redundant pci_clear_master
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230323/[email protected]/config)
compiler: ia64-linux-gcc (GCC) 12.1.0
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
# https://github.com/intel-lab-lkp/linux/commit/aa42a659eb567a583441b91cb47fd1727fa714df
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Cai-Huoqing/ntb-epf-Remove-redundant-pci_clear_master/20230323-195616
git checkout aa42a659eb567a583441b91cb47fd1727fa714df
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/ntb/hw/epf/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/ntb/hw/epf/ntb_hw_epf.c: In function 'ntb_epf_init_pci':
>> drivers/ntb/hw/epf/ntb_hw_epf.c:609:25: error: label 'err_dma_mask' used but not defined
609 | goto err_dma_mask;
| ^~~~


vim +/err_dma_mask +609 drivers/ntb/hw/epf/ntb_hw_epf.c

812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 565
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 566 static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 567 struct pci_dev *pdev)
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 568 {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 569 struct device *dev = ndev->dev;
e75d5ae8ab88b7 Frank Li 2022-02-22 570 size_t spad_sz, spad_off;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 571 int ret;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 572
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 573 pci_set_drvdata(pdev, ndev);
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 574
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 575 ret = pci_enable_device(pdev);
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 576 if (ret) {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 577 dev_err(dev, "Cannot enable PCI device\n");
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 578 goto err_pci_enable;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 579 }
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 580
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 581 ret = pci_request_regions(pdev, "ntb");
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 582 if (ret) {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 583 dev_err(dev, "Cannot obtain PCI resources\n");
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 584 goto err_pci_regions;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 585 }
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 586
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 587 pci_set_master(pdev);
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 588
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 589 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 590 if (ret) {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 591 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 592 if (ret) {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 593 dev_err(dev, "Cannot set DMA mask\n");
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 594 goto err_dma_mask;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 595 }
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 596 dev_warn(&pdev->dev, "Cannot DMA highmem\n");
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 597 }
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 598
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 599 ndev->ctrl_reg = pci_iomap(pdev, ndev->ctrl_reg_bar, 0);
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 600 if (!ndev->ctrl_reg) {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 601 ret = -EIO;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 602 goto err_dma_mask;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 603 }
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 604
e75d5ae8ab88b7 Frank Li 2022-02-22 605 if (ndev->peer_spad_reg_bar) {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 606 ndev->peer_spad_reg = pci_iomap(pdev, ndev->peer_spad_reg_bar, 0);
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 607 if (!ndev->peer_spad_reg) {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 608 ret = -EIO;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 @609 goto err_dma_mask;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 610 }
e75d5ae8ab88b7 Frank Li 2022-02-22 611 } else {
e75d5ae8ab88b7 Frank Li 2022-02-22 612 spad_sz = 4 * readl(ndev->ctrl_reg + NTB_EPF_SPAD_COUNT);
e75d5ae8ab88b7 Frank Li 2022-02-22 613 spad_off = readl(ndev->ctrl_reg + NTB_EPF_SPAD_OFFSET);
e75d5ae8ab88b7 Frank Li 2022-02-22 614 ndev->peer_spad_reg = ndev->ctrl_reg + spad_off + spad_sz;
e75d5ae8ab88b7 Frank Li 2022-02-22 615 }
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 616
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 617 ndev->db_reg = pci_iomap(pdev, ndev->db_reg_bar, 0);
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 618 if (!ndev->db_reg) {
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 619 ret = -EIO;
aa42a659eb567a Cai Huoqing 2023-03-23 620 goto err_pci_regions;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 621 }
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 622
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 623 return 0;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 624
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 625 err_pci_regions:
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 626 pci_disable_device(pdev);
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 627
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 628 err_pci_enable:
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 629 pci_set_drvdata(pdev, NULL);
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 630
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 631 return ret;
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 632 }
812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 633

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

2023-03-23 14:02:00

by Cai Huoqing

[permalink] [raw]
Subject: Re: [PATCH 2/3] ntb: epf: Remove redundant pci_clear_master

On 23 3月 23 21:15:02, kernel test robot wrote:
> Hi Cai,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on jonmason-ntb/ntb-next]
> [also build test ERROR on linus/master v6.3-rc3 next-20230323]
> [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/Cai-Huoqing/ntb-epf-Remove-redundant-pci_clear_master/20230323-195616
> base: https://github.com/jonmason/ntb ntb-next
> patch link: https://lore.kernel.org/r/20230323115336.12986-2-cai.huoqing%40linux.dev
> patch subject: [PATCH 2/3] ntb: epf: Remove redundant pci_clear_master
> config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230323/[email protected]/config)
> compiler: ia64-linux-gcc (GCC) 12.1.0
> 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
> # https://github.com/intel-lab-lkp/linux/commit/aa42a659eb567a583441b91cb47fd1727fa714df
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review Cai-Huoqing/ntb-epf-Remove-redundant-pci_clear_master/20230323-195616
> git checkout aa42a659eb567a583441b91cb47fd1727fa714df
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/ntb/hw/epf/
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <[email protected]>
> | Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> All errors (new ones prefixed by >>):
>
> drivers/ntb/hw/epf/ntb_hw_epf.c: In function 'ntb_epf_init_pci':
> >> drivers/ntb/hw/epf/ntb_hw_epf.c:609:25: error: label 'err_dma_mask' used but not defined
> 609 | goto err_dma_mask;
> | ^~~~

Will fix it and resend v2.

>
>
> vim +/err_dma_mask +609 drivers/ntb/hw/epf/ntb_hw_epf.c
>
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 565
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 566 static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 567 struct pci_dev *pdev)
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 568 {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 569 struct device *dev = ndev->dev;
> e75d5ae8ab88b7 Frank Li 2022-02-22 570 size_t spad_sz, spad_off;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 571 int ret;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 572
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 573 pci_set_drvdata(pdev, ndev);
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 574
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 575 ret = pci_enable_device(pdev);
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 576 if (ret) {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 577 dev_err(dev, "Cannot enable PCI device\n");
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 578 goto err_pci_enable;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 579 }
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 580
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 581 ret = pci_request_regions(pdev, "ntb");
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 582 if (ret) {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 583 dev_err(dev, "Cannot obtain PCI resources\n");
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 584 goto err_pci_regions;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 585 }
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 586
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 587 pci_set_master(pdev);
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 588
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 589 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 590 if (ret) {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 591 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 592 if (ret) {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 593 dev_err(dev, "Cannot set DMA mask\n");
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 594 goto err_dma_mask;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 595 }
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 596 dev_warn(&pdev->dev, "Cannot DMA highmem\n");
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 597 }
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 598
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 599 ndev->ctrl_reg = pci_iomap(pdev, ndev->ctrl_reg_bar, 0);
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 600 if (!ndev->ctrl_reg) {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 601 ret = -EIO;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 602 goto err_dma_mask;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 603 }
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 604
> e75d5ae8ab88b7 Frank Li 2022-02-22 605 if (ndev->peer_spad_reg_bar) {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 606 ndev->peer_spad_reg = pci_iomap(pdev, ndev->peer_spad_reg_bar, 0);
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 607 if (!ndev->peer_spad_reg) {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 608 ret = -EIO;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 @609 goto err_dma_mask;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 610 }
> e75d5ae8ab88b7 Frank Li 2022-02-22 611 } else {
> e75d5ae8ab88b7 Frank Li 2022-02-22 612 spad_sz = 4 * readl(ndev->ctrl_reg + NTB_EPF_SPAD_COUNT);
> e75d5ae8ab88b7 Frank Li 2022-02-22 613 spad_off = readl(ndev->ctrl_reg + NTB_EPF_SPAD_OFFSET);
> e75d5ae8ab88b7 Frank Li 2022-02-22 614 ndev->peer_spad_reg = ndev->ctrl_reg + spad_off + spad_sz;
> e75d5ae8ab88b7 Frank Li 2022-02-22 615 }
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 616
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 617 ndev->db_reg = pci_iomap(pdev, ndev->db_reg_bar, 0);
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 618 if (!ndev->db_reg) {
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 619 ret = -EIO;
> aa42a659eb567a Cai Huoqing 2023-03-23 620 goto err_pci_regions;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 621 }
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 622
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 623 return 0;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 624
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 625 err_pci_regions:
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 626 pci_disable_device(pdev);
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 627
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 628 err_pci_enable:
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 629 pci_set_drvdata(pdev, NULL);
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 630
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 631 return ret;
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 632 }
> 812ce2f8d14ea7 Kishon Vijay Abraham I 2021-02-02 633
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests

2023-03-23 16:52:10

by Dave Jiang

[permalink] [raw]
Subject: Re: [PATCH 3/3] ntb: intel: Remove redundant pci_clear_master



On 3/23/23 4:53 AM, Cai Huoqing wrote:
> Remove pci_clear_master to simplify the code,
> the bus-mastering is also cleared in do_pci_disable_device,
> like this:
> ./drivers/pci/pci.c:2197
> 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 dev->is_busmaster is set to 0 in pci_disable_device.
>
> Signed-off-by: Cai Huoqing <[email protected]>

Acked-by: Dave Jiang <[email protected]>

> ---
> drivers/ntb/hw/intel/ntb_hw_gen1.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/ntb/hw/intel/ntb_hw_gen1.c b/drivers/ntb/hw/intel/ntb_hw_gen1.c
> index 60a4ebc7bf35..9ab836d0d4f1 100644
> --- a/drivers/ntb/hw/intel/ntb_hw_gen1.c
> +++ b/drivers/ntb/hw/intel/ntb_hw_gen1.c
> @@ -1791,7 +1791,6 @@ static int intel_ntb_init_pci(struct intel_ntb_dev *ndev, struct pci_dev *pdev)
>
> err_mmio:
> err_dma_mask:
> - pci_clear_master(pdev);
> pci_release_regions(pdev);
> err_pci_regions:
> pci_disable_device(pdev);
> @@ -1808,7 +1807,6 @@ static void intel_ntb_deinit_pci(struct intel_ntb_dev *ndev)
> pci_iounmap(pdev, ndev->peer_mmio);
> pci_iounmap(pdev, ndev->self_mmio);
>
> - pci_clear_master(pdev);
> pci_release_regions(pdev);
> pci_disable_device(pdev);
> pci_set_drvdata(pdev, NULL);