forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/scsi/bfa/bfad.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
34 * Copyright (c) 2014- QLogic Corporation.
....@@ -5,15 +6,6 @@
56 * www.qlogic.com
67 *
78 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
8
- *
9
- * This program is free software; you can redistribute it and/or modify it
10
- * under the terms of the GNU General Public License (GPL) Version 2 as
11
- * published by the Free Software Foundation
12
- *
13
- * This program is distributed in the hope that it will be useful, but
14
- * WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * General Public License for more details.
179 */
1810
1911 /*
....@@ -58,7 +50,7 @@
5850 int bfa_debugfs_enable = 1;
5951 int msix_disable_cb = 0, msix_disable_ct = 0;
6052 int max_xfer_size = BFAD_MAX_SECTORS >> 1;
61
-int max_rport_logins = BFA_FCS_MAX_RPORT_LOGINS;
53
+static int max_rport_logins = BFA_FCS_MAX_RPORT_LOGINS;
6254
6355 /* Firmware releated */
6456 u32 bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size;
....@@ -727,7 +719,7 @@
727719 int
728720 bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
729721 {
730
- int rc = -ENODEV;
722
+ int rc = -ENODEV;
731723
732724 if (pci_enable_device(pdev)) {
733725 printk(KERN_ERR "pci_enable_device fail %p\n", pdev);
....@@ -739,14 +731,14 @@
739731
740732 pci_set_master(pdev);
741733
734
+ rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
735
+ if (rc)
736
+ rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
742737
743
- if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) ||
744
- (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)) != 0)) {
745
- if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) ||
746
- (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)) != 0)) {
747
- printk(KERN_ERR "pci_set_dma_mask fail %p\n", pdev);
748
- goto out_release_region;
749
- }
738
+ if (rc) {
739
+ rc = -ENODEV;
740
+ printk(KERN_ERR "dma_set_mask_and_coherent fail %p\n", pdev);
741
+ goto out_release_region;
750742 }
751743
752744 /* Enable PCIE Advanced Error Recovery (AER) if kernel supports */
....@@ -757,6 +749,7 @@
757749
758750 if (bfad->pci_bar0_kva == NULL) {
759751 printk(KERN_ERR "Fail to map bar0\n");
752
+ rc = -ENODEV;
760753 goto out_release_region;
761754 }
762755
....@@ -1495,8 +1488,7 @@
14951488 return ret;
14961489 }
14971490
1498
-int
1499
-restart_bfa(struct bfad_s *bfad)
1491
+static int restart_bfa(struct bfad_s *bfad)
15001492 {
15011493 unsigned long flags;
15021494 struct pci_dev *pdev = bfad->pcidev;
....@@ -1538,6 +1530,7 @@
15381530 {
15391531 struct bfad_s *bfad = pci_get_drvdata(pdev);
15401532 u8 byte;
1533
+ int rc;
15411534
15421535 dev_printk(KERN_ERR, &pdev->dev,
15431536 "bfad_pci_slot_reset flags: 0x%x\n", bfad->bfad_flags);
....@@ -1565,11 +1558,12 @@
15651558 pci_save_state(pdev);
15661559 pci_set_master(pdev);
15671560
1568
- if (pci_set_dma_mask(bfad->pcidev, DMA_BIT_MASK(64)) != 0)
1569
- if (pci_set_dma_mask(bfad->pcidev, DMA_BIT_MASK(32)) != 0)
1570
- goto out_disable_device;
1571
-
1572
- pci_cleanup_aer_uncorrect_error_status(pdev);
1561
+ rc = dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64));
1562
+ if (rc)
1563
+ rc = dma_set_mask_and_coherent(&bfad->pcidev->dev,
1564
+ DMA_BIT_MASK(32));
1565
+ if (rc)
1566
+ goto out_disable_device;
15731567
15741568 if (restart_bfa(bfad) == -1)
15751569 goto out_disable_device;