| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2005-2014 Brocade Communications Systems, Inc. |
|---|
| 3 | 4 | * Copyright (c) 2014- QLogic Corporation. |
|---|
| .. | .. |
|---|
| 5 | 6 | * www.qlogic.com |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * 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. |
|---|
| 17 | 9 | */ |
|---|
| 18 | 10 | |
|---|
| 19 | 11 | /* |
|---|
| .. | .. |
|---|
| 58 | 50 | int bfa_debugfs_enable = 1; |
|---|
| 59 | 51 | int msix_disable_cb = 0, msix_disable_ct = 0; |
|---|
| 60 | 52 | 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; |
|---|
| 62 | 54 | |
|---|
| 63 | 55 | /* Firmware releated */ |
|---|
| 64 | 56 | u32 bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size; |
|---|
| .. | .. |
|---|
| 727 | 719 | int |
|---|
| 728 | 720 | bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad) |
|---|
| 729 | 721 | { |
|---|
| 730 | | - int rc = -ENODEV; |
|---|
| 722 | + int rc = -ENODEV; |
|---|
| 731 | 723 | |
|---|
| 732 | 724 | if (pci_enable_device(pdev)) { |
|---|
| 733 | 725 | printk(KERN_ERR "pci_enable_device fail %p\n", pdev); |
|---|
| .. | .. |
|---|
| 739 | 731 | |
|---|
| 740 | 732 | pci_set_master(pdev); |
|---|
| 741 | 733 | |
|---|
| 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)); |
|---|
| 742 | 737 | |
|---|
| 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; |
|---|
| 750 | 742 | } |
|---|
| 751 | 743 | |
|---|
| 752 | 744 | /* Enable PCIE Advanced Error Recovery (AER) if kernel supports */ |
|---|
| .. | .. |
|---|
| 757 | 749 | |
|---|
| 758 | 750 | if (bfad->pci_bar0_kva == NULL) { |
|---|
| 759 | 751 | printk(KERN_ERR "Fail to map bar0\n"); |
|---|
| 752 | + rc = -ENODEV; |
|---|
| 760 | 753 | goto out_release_region; |
|---|
| 761 | 754 | } |
|---|
| 762 | 755 | |
|---|
| .. | .. |
|---|
| 1495 | 1488 | return ret; |
|---|
| 1496 | 1489 | } |
|---|
| 1497 | 1490 | |
|---|
| 1498 | | -int |
|---|
| 1499 | | -restart_bfa(struct bfad_s *bfad) |
|---|
| 1491 | +static int restart_bfa(struct bfad_s *bfad) |
|---|
| 1500 | 1492 | { |
|---|
| 1501 | 1493 | unsigned long flags; |
|---|
| 1502 | 1494 | struct pci_dev *pdev = bfad->pcidev; |
|---|
| .. | .. |
|---|
| 1538 | 1530 | { |
|---|
| 1539 | 1531 | struct bfad_s *bfad = pci_get_drvdata(pdev); |
|---|
| 1540 | 1532 | u8 byte; |
|---|
| 1533 | + int rc; |
|---|
| 1541 | 1534 | |
|---|
| 1542 | 1535 | dev_printk(KERN_ERR, &pdev->dev, |
|---|
| 1543 | 1536 | "bfad_pci_slot_reset flags: 0x%x\n", bfad->bfad_flags); |
|---|
| .. | .. |
|---|
| 1565 | 1558 | pci_save_state(pdev); |
|---|
| 1566 | 1559 | pci_set_master(pdev); |
|---|
| 1567 | 1560 | |
|---|
| 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; |
|---|
| 1573 | 1567 | |
|---|
| 1574 | 1568 | if (restart_bfa(bfad) == -1) |
|---|
| 1575 | 1569 | goto out_disable_device; |
|---|