hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/ata/acard-ahci.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12
23 /*
34 * acard-ahci.c - ACard AHCI SATA support
....@@ -8,29 +9,12 @@
89 *
910 * Copyright 2010 Red Hat, Inc.
1011 *
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License as published by
14
- * the Free Software Foundation; either version 2, or (at your option)
15
- * any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; see the file COPYING. If not, write to
24
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25
- *
26
- *
2712 * libata documentation is available via 'make {ps|pdf}docs',
2813 * as Documentation/driver-api/libata.rst
2914 *
3015 * AHCI hardware documentation:
3116 * http://www.intel.com/technology/serialata/pdf/rev1_0.pdf
3217 * http://www.intel.com/technology/serialata/pdf/rev1_1.pdf
33
- *
3418 */
3519
3620 #include <linux/kernel.h>
....@@ -176,37 +160,6 @@
176160 }
177161 #endif
178162
179
-static int acard_ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
180
-{
181
- int rc;
182
-
183
- if (using_dac &&
184
- !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
185
- rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
186
- if (rc) {
187
- rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
188
- if (rc) {
189
- dev_err(&pdev->dev,
190
- "64-bit DMA enable failed\n");
191
- return rc;
192
- }
193
- }
194
- } else {
195
- rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
196
- if (rc) {
197
- dev_err(&pdev->dev, "32-bit DMA enable failed\n");
198
- return rc;
199
- }
200
- rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
201
- if (rc) {
202
- dev_err(&pdev->dev,
203
- "32-bit consistent DMA enable failed\n");
204
- return rc;
205
- }
206
- }
207
- return 0;
208
-}
209
-
210163 static void acard_ahci_pci_print_info(struct ata_host *host)
211164 {
212165 struct pci_dev *pdev = to_pci_dev(host->dev);
....@@ -265,7 +218,6 @@
265218 void *cmd_tbl;
266219 u32 opts;
267220 const u32 cmd_fis_len = 5; /* five dwords */
268
- unsigned int n_elem;
269221
270222 /*
271223 * Fill in command table information. First, the header,
....@@ -279,9 +231,8 @@
279231 memcpy(cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, qc->dev->cdb_len);
280232 }
281233
282
- n_elem = 0;
283234 if (qc->flags & ATA_QCFLAG_DMAMAP)
284
- n_elem = acard_ahci_fill_sg(qc, cmd_tbl);
235
+ acard_ahci_fill_sg(qc, cmd_tbl);
285236
286237 /*
287238 * Fill in command slot information.
....@@ -362,7 +313,6 @@
362313 mem = dmam_alloc_coherent(dev, dma_sz, &mem_dma, GFP_KERNEL);
363314 if (!mem)
364315 return -ENOMEM;
365
- memset(mem, 0, dma_sz);
366316
367317 /*
368318 * First item in chunk of DMA memory: 32-slot command table,
....@@ -490,9 +440,12 @@
490440 }
491441
492442 /* initialize adapter */
493
- rc = acard_ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64);
494
- if (rc)
443
+ rc = dma_set_mask_and_coherent(&pdev->dev,
444
+ DMA_BIT_MASK((hpriv->cap & HOST_CAP_64) ? 64 : 32));
445
+ if (rc) {
446
+ dev_err(&pdev->dev, "DMA enable failed\n");
495447 return rc;
448
+ }
496449
497450 rc = ahci_reset_controller(host);
498451 if (rc)