forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/scsi/mvsas/mv_init.c
....@@ -1,26 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Marvell 88SE64xx/88SE94xx pci init
34 *
45 * Copyright 2007 Red Hat, Inc.
56 * Copyright 2008 Marvell. <kewei@marvell.com>
67 * Copyright 2009-2011 Marvell. <yuxiangl@marvell.com>
7
- *
8
- * This file is licensed under GPLv2.
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public License as
12
- * published by the Free Software Foundation; version 2 of the
13
- * License.
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 GNU
18
- * 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; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23
- * USA
248 */
259
2610
....@@ -41,7 +25,7 @@
4125 [chip_1320] = { 2, 4, 0x800, 17, 64, 8, 9, &mvs_94xx_dispatch, },
4226 };
4327
44
-struct device_attribute *mvst_host_attrs[];
28
+static struct device_attribute *mvst_host_attrs[];
4529
4630 #define SOC_SAS_NUM 2
4731
....@@ -49,6 +33,7 @@
4933 .module = THIS_MODULE,
5034 .name = DRV_NAME,
5135 .queuecommand = sas_queuecommand,
36
+ .dma_need_drain = ata_scsi_dma_need_drain,
5237 .target_alloc = sas_target_alloc,
5338 .slave_configure = sas_slave_configure,
5439 .scan_finished = mvs_scan_finished,
....@@ -59,12 +44,14 @@
5944 .this_id = -1,
6045 .sg_tablesize = SG_ALL,
6146 .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
62
- .use_clustering = ENABLE_CLUSTERING,
6347 .eh_device_reset_handler = sas_eh_device_reset_handler,
6448 .eh_target_reset_handler = sas_eh_target_reset_handler,
6549 .slave_alloc = sas_slave_alloc,
6650 .target_destroy = sas_target_destroy,
6751 .ioctl = sas_ioctl,
52
+#ifdef CONFIG_COMPAT
53
+ .compat_ioctl = sas_ioctl,
54
+#endif
6855 .shost_attrs = mvst_host_attrs,
6956 .track_queue_depth = 1,
7057 };
....@@ -191,15 +178,16 @@
191178
192179 static irqreturn_t mvs_interrupt(int irq, void *opaque)
193180 {
194
- u32 core_nr;
195181 u32 stat;
196182 struct mvs_info *mvi;
197183 struct sas_ha_struct *sha = opaque;
198184 #ifndef CONFIG_SCSI_MVSAS_TASKLET
199185 u32 i;
200
-#endif
186
+ u32 core_nr;
201187
202188 core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host;
189
+#endif
190
+
203191 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0];
204192
205193 if (unlikely(!mvi))
....@@ -259,19 +247,16 @@
259247 &mvi->tx_dma, GFP_KERNEL);
260248 if (!mvi->tx)
261249 goto err_out;
262
- memset(mvi->tx, 0, sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ);
263250 mvi->rx_fis = dma_alloc_coherent(mvi->dev, MVS_RX_FISL_SZ,
264251 &mvi->rx_fis_dma, GFP_KERNEL);
265252 if (!mvi->rx_fis)
266253 goto err_out;
267
- memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ);
268254
269255 mvi->rx = dma_alloc_coherent(mvi->dev,
270256 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
271257 &mvi->rx_dma, GFP_KERNEL);
272258 if (!mvi->rx)
273259 goto err_out;
274
- memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1));
275260 mvi->rx[0] = cpu_to_le32(0xfff);
276261 mvi->rx_cons = 0xfff;
277262
....@@ -280,7 +265,6 @@
280265 &mvi->slot_dma, GFP_KERNEL);
281266 if (!mvi->slot)
282267 goto err_out;
283
- memset(mvi->slot, 0, sizeof(*mvi->slot) * slot_nr);
284268
285269 mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
286270 TRASH_BUCKET_SIZE,
....@@ -313,7 +297,7 @@
313297
314298 int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
315299 {
316
- unsigned long res_start, res_len, res_flag, res_flag_ex = 0;
300
+ unsigned long res_start, res_len, res_flag_ex = 0;
317301 struct pci_dev *pdev = mvi->pdev;
318302 if (bar_ex != -1) {
319303 /*
....@@ -341,7 +325,6 @@
341325 goto err_out;
342326 }
343327
344
- res_flag = pci_resource_flags(pdev, bar);
345328 mvi->regs = ioremap(res_start, res_len);
346329
347330 if (!mvi->regs) {
....@@ -404,27 +387,12 @@
404387 {
405388 int rc;
406389
407
- if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
408
- rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
409
- if (rc) {
410
- rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
411
- if (rc) {
412
- dev_printk(KERN_ERR, &pdev->dev,
413
- "64-bit DMA enable failed\n");
414
- return rc;
415
- }
416
- }
417
- } else {
418
- rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
390
+ rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
391
+ if (rc) {
392
+ rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
419393 if (rc) {
420394 dev_printk(KERN_ERR, &pdev->dev,
421395 "32-bit DMA enable failed\n");
422
- return rc;
423
- }
424
- rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
425
- if (rc) {
426
- dev_printk(KERN_ERR, &pdev->dev,
427
- "32-bit consistent DMA enable failed\n");
428396 return rc;
429397 }
430398 }
....@@ -678,6 +646,7 @@
678646 { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1300), chip_1300 },
679647 { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1320), chip_1320 },
680648 { PCI_VDEVICE(ADAPTEC2, 0x0450), chip_6440 },
649
+ { PCI_VDEVICE(TTI, 0x2640), chip_6440 },
681650 { PCI_VDEVICE(TTI, 0x2710), chip_9480 },
682651 { PCI_VDEVICE(TTI, 0x2720), chip_9480 },
683652 { PCI_VDEVICE(TTI, 0x2721), chip_9480 },
....@@ -729,7 +698,7 @@
729698 mvs_show_driver_version(struct device *cdev,
730699 struct device_attribute *attr, char *buffer)
731700 {
732
- return snprintf(buffer, PAGE_SIZE, "%s\n", DRV_VERSION);
701
+ return sysfs_emit(buffer, "%s\n", DRV_VERSION);
733702 }
734703
735704 static DEVICE_ATTR(driver_version,
....@@ -781,7 +750,7 @@
781750 static ssize_t mvs_show_interrupt_coalescing(struct device *cdev,
782751 struct device_attribute *attr, char *buffer)
783752 {
784
- return snprintf(buffer, PAGE_SIZE, "%d\n", interrupt_coalescing);
753
+ return sysfs_emit(buffer, "%d\n", interrupt_coalescing);
785754 }
786755
787756 static DEVICE_ATTR(interrupt_coalescing,
....@@ -789,8 +758,6 @@
789758 mvs_show_interrupt_coalescing,
790759 mvs_store_interrupt_coalescing);
791760
792
-/* task handler */
793
-struct task_struct *mvs_th;
794761 static int __init mvs_init(void)
795762 {
796763 int rc;
....@@ -815,7 +782,7 @@
815782 sas_release_transport(mvs_stt);
816783 }
817784
818
-struct device_attribute *mvst_host_attrs[] = {
785
+static struct device_attribute *mvst_host_attrs[] = {
819786 &dev_attr_driver_version,
820787 &dev_attr_interrupt_coalescing,
821788 NULL,