| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * sata_qstor.c - Pacific Digital Corporation QStor SATA |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * Copyright 2005 Pacific Digital Corporation. |
|---|
| 7 | 8 | * (OSL/GPL code release authorized by Jalil Fadavi). |
|---|
| 8 | 9 | * |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 12 | | - * the Free Software Foundation; either version 2, or (at your option) |
|---|
| 13 | | - * any later version. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | | - * GNU General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program; see the file COPYING. If not, write to |
|---|
| 22 | | - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 23 | | - * |
|---|
| 24 | | - * |
|---|
| 25 | 10 | * libata documentation is available via 'make {ps|pdf}docs', |
|---|
| 26 | 11 | * as Documentation/driver-api/libata.rst |
|---|
| 27 | | - * |
|---|
| 28 | 12 | */ |
|---|
| 29 | 13 | |
|---|
| 30 | 14 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 495 | 479 | GFP_KERNEL); |
|---|
| 496 | 480 | if (!pp->pkt) |
|---|
| 497 | 481 | return -ENOMEM; |
|---|
| 498 | | - memset(pp->pkt, 0, QS_PKT_BYTES); |
|---|
| 499 | 482 | ap->private_data = pp; |
|---|
| 500 | 483 | |
|---|
| 501 | 484 | qs_enter_reg_mode(ap); |
|---|
| .. | .. |
|---|
| 556 | 539 | static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base) |
|---|
| 557 | 540 | { |
|---|
| 558 | 541 | u32 bus_info = readl(mmio_base + QS_HID_HPHY); |
|---|
| 559 | | - int rc, have_64bit_bus = (bus_info & QS_HPHY_64BIT); |
|---|
| 542 | + int dma_bits = (bus_info & QS_HPHY_64BIT) ? 64 : 32; |
|---|
| 543 | + int rc; |
|---|
| 560 | 544 | |
|---|
| 561 | | - if (have_64bit_bus && |
|---|
| 562 | | - !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { |
|---|
| 563 | | - rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); |
|---|
| 564 | | - if (rc) { |
|---|
| 565 | | - rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); |
|---|
| 566 | | - if (rc) { |
|---|
| 567 | | - dev_err(&pdev->dev, |
|---|
| 568 | | - "64-bit DMA enable failed\n"); |
|---|
| 569 | | - return rc; |
|---|
| 570 | | - } |
|---|
| 571 | | - } |
|---|
| 572 | | - } else { |
|---|
| 573 | | - rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
|---|
| 574 | | - if (rc) { |
|---|
| 575 | | - dev_err(&pdev->dev, "32-bit DMA enable failed\n"); |
|---|
| 576 | | - return rc; |
|---|
| 577 | | - } |
|---|
| 578 | | - rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); |
|---|
| 579 | | - if (rc) { |
|---|
| 580 | | - dev_err(&pdev->dev, |
|---|
| 581 | | - "32-bit consistent DMA enable failed\n"); |
|---|
| 582 | | - return rc; |
|---|
| 583 | | - } |
|---|
| 584 | | - } |
|---|
| 585 | | - return 0; |
|---|
| 545 | + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(dma_bits)); |
|---|
| 546 | + if (rc) |
|---|
| 547 | + dev_err(&pdev->dev, "%d-bit DMA enable failed\n", dma_bits); |
|---|
| 548 | + return rc; |
|---|
| 586 | 549 | } |
|---|
| 587 | 550 | |
|---|
| 588 | 551 | static int qs_ata_init_one(struct pci_dev *pdev, |
|---|