aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAmit Kumar Salecha <amit.salecha@qlogic.com>2010-06-16 22:56:42 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-17 11:57:56 -0400
commit4de57826810fd2cfeb2ab5c7d003ff9116b8f7ee (patch)
treee6952f6be349196f1bf7e1abe63bf49f74420d6e /drivers
parentef71ff833acfd3795c3af1bb800ac186561508ef (diff)
qlcnic: fix register access
For certain set of register, base window addresses are not defined. In such cases window should not set. Return with error for such cases to avoid NMI. Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/qlcnic/qlcnic_hw.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index d9becb96d403..10ba72302fc9 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -766,7 +766,7 @@ qlcnic_pci_get_crb_addr_2M(struct qlcnic_adapter *adapter,
766 * Out: 'off' is 2M pci map addr 766 * Out: 'off' is 2M pci map addr
767 * side effect: lock crb window 767 * side effect: lock crb window
768 */ 768 */
769static void 769static int
770qlcnic_pci_set_crbwindow_2M(struct qlcnic_adapter *adapter, ulong off) 770qlcnic_pci_set_crbwindow_2M(struct qlcnic_adapter *adapter, ulong off)
771{ 771{
772 u32 window; 772 u32 window;
@@ -775,6 +775,10 @@ qlcnic_pci_set_crbwindow_2M(struct qlcnic_adapter *adapter, ulong off)
775 off -= QLCNIC_PCI_CRBSPACE; 775 off -= QLCNIC_PCI_CRBSPACE;
776 776
777 window = CRB_HI(off); 777 window = CRB_HI(off);
778 if (window == 0) {
779 dev_err(&adapter->pdev->dev, "Invalid offset 0x%lx\n", off);
780 return -EIO;
781 }
778 782
779 writel(window, addr); 783 writel(window, addr);
780 if (readl(addr) != window) { 784 if (readl(addr) != window) {
@@ -782,7 +786,9 @@ qlcnic_pci_set_crbwindow_2M(struct qlcnic_adapter *adapter, ulong off)
782 dev_warn(&adapter->pdev->dev, 786 dev_warn(&adapter->pdev->dev,
783 "failed to set CRB window to %d off 0x%lx\n", 787 "failed to set CRB window to %d off 0x%lx\n",
784 window, off); 788 window, off);
789 return -EIO;
785 } 790 }
791 return 0;
786} 792}
787 793
788int 794int
@@ -803,11 +809,12 @@ qlcnic_hw_write_wx_2M(struct qlcnic_adapter *adapter, ulong off, u32 data)
803 /* indirect access */ 809 /* indirect access */
804 write_lock_irqsave(&adapter->ahw.crb_lock, flags); 810 write_lock_irqsave(&adapter->ahw.crb_lock, flags);
805 crb_win_lock(adapter); 811 crb_win_lock(adapter);
806 qlcnic_pci_set_crbwindow_2M(adapter, off); 812 rv = qlcnic_pci_set_crbwindow_2M(adapter, off);
807 writel(data, addr); 813 if (!rv)
814 writel(data, addr);
808 crb_win_unlock(adapter); 815 crb_win_unlock(adapter);
809 write_unlock_irqrestore(&adapter->ahw.crb_lock, flags); 816 write_unlock_irqrestore(&adapter->ahw.crb_lock, flags);
810 return 0; 817 return rv;
811 } 818 }
812 819
813 dev_err(&adapter->pdev->dev, 820 dev_err(&adapter->pdev->dev,
@@ -821,7 +828,7 @@ qlcnic_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off)
821{ 828{
822 unsigned long flags; 829 unsigned long flags;
823 int rv; 830 int rv;
824 u32 data; 831 u32 data = -1;
825 void __iomem *addr = NULL; 832 void __iomem *addr = NULL;
826 833
827 rv = qlcnic_pci_get_crb_addr_2M(adapter, off, &addr); 834 rv = qlcnic_pci_get_crb_addr_2M(adapter, off, &addr);
@@ -833,8 +840,8 @@ qlcnic_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off)
833 /* indirect access */ 840 /* indirect access */
834 write_lock_irqsave(&adapter->ahw.crb_lock, flags); 841 write_lock_irqsave(&adapter->ahw.crb_lock, flags);
835 crb_win_lock(adapter); 842 crb_win_lock(adapter);
836 qlcnic_pci_set_crbwindow_2M(adapter, off); 843 if (!qlcnic_pci_set_crbwindow_2M(adapter, off))
837 data = readl(addr); 844 data = readl(addr);
838 crb_win_unlock(adapter); 845 crb_win_unlock(adapter);
839 write_unlock_irqrestore(&adapter->ahw.crb_lock, flags); 846 write_unlock_irqrestore(&adapter->ahw.crb_lock, flags);
840 return data; 847 return data;