aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYijing Wang <wangyijing@huawei.com>2013-09-05 03:55:25 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-09-23 19:30:03 -0400
commitc0102c00d8c9f4109509d9d68631a1ad47703b5f (patch)
treeff3e9ce1eff09b5af990e73565949c7b4421d487
parentf8a26fe637fc740ebb927ce25dcf036363a998df (diff)
[SCSI] bfa: Use pcie_set()/get_readrq() to simplify code
Use pcie_get_readrq()/pcie_set_readrq() to simplify code. Jon Mason proposed a similar patch a couple years ago (see below). [bhelgaas: validate pcie_max_read_reqsz, add pointer to Jon's patch] Reference: http://lkml.kernel.org/r/1309191190-14670-1-git-send-email-jdmason@kudzu.us Signed-off-by: Yijing Wang <wangyijing@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Cc: Jiang Liu <jiang.liu@huawei.com> Cc: Anil Gurumurthy <agurumur@brocade.com> Cc: Vijaya Mohan Guvva <vmohan@brocade.com> Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
-rw-r--r--drivers/scsi/bfa/bfad.c53
1 files changed, 12 insertions, 41 deletions
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index f8ca7becacca..7591fa4e28bb 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -766,49 +766,20 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
766 bfad->pcidev = pdev; 766 bfad->pcidev = pdev;
767 767
768 /* Adjust PCIe Maximum Read Request Size */ 768 /* Adjust PCIe Maximum Read Request Size */
769 if (pcie_max_read_reqsz > 0) { 769 if (pci_is_pcie(pdev) && pcie_max_read_reqsz) {
770 int pcie_cap_reg; 770 if (pcie_max_read_reqsz >= 128 &&
771 u16 pcie_dev_ctl; 771 pcie_max_read_reqsz <= 4096 &&
772 u16 mask = 0xffff; 772 is_power_of_2(pcie_max_read_reqsz)) {
773 773 int max_rq = pcie_get_readrq(pdev);
774 switch (pcie_max_read_reqsz) { 774 printk(KERN_WARNING "BFA[%s]: "
775 case 128:
776 mask = 0x0;
777 break;
778 case 256:
779 mask = 0x1000;
780 break;
781 case 512:
782 mask = 0x2000;
783 break;
784 case 1024:
785 mask = 0x3000;
786 break;
787 case 2048:
788 mask = 0x4000;
789 break;
790 case 4096:
791 mask = 0x5000;
792 break;
793 default:
794 break;
795 }
796
797 pcie_cap_reg = pci_find_capability(pdev, PCI_CAP_ID_EXP);
798 if (mask != 0xffff && pcie_cap_reg) {
799 pcie_cap_reg += 0x08;
800 pci_read_config_word(pdev, pcie_cap_reg, &pcie_dev_ctl);
801 if ((pcie_dev_ctl & 0x7000) != mask) {
802 printk(KERN_WARNING "BFA[%s]: "
803 "pcie_max_read_request_size is %d, " 775 "pcie_max_read_request_size is %d, "
804 "reset to %d\n", bfad->pci_name, 776 "reset to %d\n", bfad->pci_name, max_rq,
805 (1 << ((pcie_dev_ctl & 0x7000) >> 12)) << 7,
806 pcie_max_read_reqsz); 777 pcie_max_read_reqsz);
807 778 pcie_set_readrq(pdev, pcie_max_read_reqsz);
808 pcie_dev_ctl &= ~0x7000; 779 } else {
809 pci_write_config_word(pdev, pcie_cap_reg, 780 printk(KERN_WARNING "BFA[%s]: invalid "
810 pcie_dev_ctl | mask); 781 "pcie_max_read_request_size %d ignored\n",
811 } 782 bfad->pci_name, pcie_max_read_reqsz);
812 } 783 }
813 } 784 }
814 785