forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/scsi/mvsas/mv_sas.c
....@@ -1,26 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Marvell 88SE64xx/88SE94xx main function
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 #include "mv_sas.h"
....@@ -232,11 +216,11 @@
232216 MVS_CHIP_DISP->write_port_cfg_data(mvi, port_id, hi);
233217 }
234218
235
-static void mvs_bytes_dmaed(struct mvs_info *mvi, int i)
219
+static void mvs_bytes_dmaed(struct mvs_info *mvi, int i, gfp_t gfp_flags)
236220 {
237221 struct mvs_phy *phy = &mvi->phy[i];
238222 struct asd_sas_phy *sas_phy = &phy->sas_phy;
239
- struct sas_ha_struct *sas_ha;
223
+
240224 if (!phy->phy_attached)
241225 return;
242226
....@@ -245,8 +229,7 @@
245229 return;
246230 }
247231
248
- sas_ha = mvi->sas;
249
- sas_ha->notify_phy_event(sas_phy, PHYE_OOB_DONE);
232
+ sas_notify_phy_event_gfp(sas_phy, PHYE_OOB_DONE, gfp_flags);
250233
251234 if (sas_phy->phy) {
252235 struct sas_phy *sphy = sas_phy->phy;
....@@ -278,8 +261,7 @@
278261
279262 sas_phy->frame_rcvd_size = phy->frame_rcvd_size;
280263
281
- mvi->sas->notify_port_event(sas_phy,
282
- PORTE_BYTES_DMAED);
264
+ sas_notify_port_event_gfp(sas_phy, PORTE_BYTES_DMAED, gfp_flags);
283265 }
284266
285267 void mvs_scan_start(struct Scsi_Host *shost)
....@@ -295,7 +277,7 @@
295277 for (j = 0; j < core_nr; j++) {
296278 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[j];
297279 for (i = 0; i < mvi->chip->n_phy; ++i)
298
- mvs_bytes_dmaed(mvi, i);
280
+ mvs_bytes_dmaed(mvi, i, GFP_KERNEL);
299281 }
300282 mvs_prv->scan_finished = 1;
301283 }
....@@ -336,13 +318,13 @@
336318 * DMA-map SMP request, response buffers
337319 */
338320 sg_req = &task->smp_task.smp_req;
339
- elem = dma_map_sg(mvi->dev, sg_req, 1, PCI_DMA_TODEVICE);
321
+ elem = dma_map_sg(mvi->dev, sg_req, 1, DMA_TO_DEVICE);
340322 if (!elem)
341323 return -ENOMEM;
342324 req_len = sg_dma_len(sg_req);
343325
344326 sg_resp = &task->smp_task.smp_resp;
345
- elem = dma_map_sg(mvi->dev, sg_resp, 1, PCI_DMA_FROMDEVICE);
327
+ elem = dma_map_sg(mvi->dev, sg_resp, 1, DMA_FROM_DEVICE);
346328 if (!elem) {
347329 rc = -ENOMEM;
348330 goto err_out;
....@@ -416,10 +398,10 @@
416398
417399 err_out_2:
418400 dma_unmap_sg(mvi->dev, &tei->task->smp_task.smp_resp, 1,
419
- PCI_DMA_FROMDEVICE);
401
+ DMA_FROM_DEVICE);
420402 err_out:
421403 dma_unmap_sg(mvi->dev, &tei->task->smp_task.smp_req, 1,
422
- PCI_DMA_TODEVICE);
404
+ DMA_TO_DEVICE);
423405 return rc;
424406 }
425407
....@@ -790,12 +772,11 @@
790772 slot->n_elem = n_elem;
791773 slot->slot_tag = tag;
792774
793
- slot->buf = dma_pool_alloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
775
+ slot->buf = dma_pool_zalloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
794776 if (!slot->buf) {
795777 rc = -ENOMEM;
796778 goto err_out_tag;
797779 }
798
- memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
799780
800781 tei.task = task;
801782 tei.hdr = &mvi->slot[tag];
....@@ -904,9 +885,9 @@
904885 switch (task->task_proto) {
905886 case SAS_PROTOCOL_SMP:
906887 dma_unmap_sg(mvi->dev, &task->smp_task.smp_resp, 1,
907
- PCI_DMA_FROMDEVICE);
888
+ DMA_FROM_DEVICE);
908889 dma_unmap_sg(mvi->dev, &task->smp_task.smp_req, 1,
909
- PCI_DMA_TODEVICE);
890
+ DMA_TO_DEVICE);
910891 break;
911892
912893 case SAS_PROTOCOL_SATA:
....@@ -1210,7 +1191,7 @@
12101191 mvi_device->dev_type = dev->dev_type;
12111192 mvi_device->mvi_info = mvi;
12121193 mvi_device->sas_device = dev;
1213
- if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) {
1194
+ if (parent_dev && dev_is_expander(parent_dev->dev_type)) {
12141195 int phy_id;
12151196 u8 phy_num = parent_dev->ex_dev.num_phys;
12161197 struct ex_phy *phy;
....@@ -1333,7 +1314,7 @@
13331314 }
13341315
13351316 if (task->task_status.resp == SAS_TASK_COMPLETE &&
1336
- task->task_status.stat == SAM_STAT_GOOD) {
1317
+ task->task_status.stat == SAS_SAM_STAT_GOOD) {
13371318 res = TMF_RESP_FUNC_COMPLETE;
13381319 break;
13391320 }
....@@ -1423,7 +1404,7 @@
14231404 {
14241405 unsigned long flags;
14251406 int rc = TMF_RESP_FUNC_FAILED;
1426
- struct mvs_device * mvi_dev = (struct mvs_device *)dev->lldd_dev;
1407
+ struct mvs_device *mvi_dev = (struct mvs_device *)dev->lldd_dev;
14271408 struct mvs_info *mvi = mvi_dev->mvi_info;
14281409
14291410 if (mvi_dev->dev_status != MVS_DEV_EH)
....@@ -1558,7 +1539,7 @@
15581539
15591540 int mvs_abort_task_set(struct domain_device *dev, u8 *lun)
15601541 {
1561
- int rc = TMF_RESP_FUNC_FAILED;
1542
+ int rc;
15621543 struct mvs_tmf_task tmf_task;
15631544
15641545 tmf_task.tmf = TMF_ABORT_TASK_SET;
....@@ -1783,7 +1764,7 @@
17831764 case SAS_PROTOCOL_SSP:
17841765 /* hw says status == 0, datapres == 0 */
17851766 if (rx_desc & RXQ_GOOD) {
1786
- tstat->stat = SAM_STAT_GOOD;
1767
+ tstat->stat = SAS_SAM_STAT_GOOD;
17871768 tstat->resp = SAS_TASK_COMPLETE;
17881769 }
17891770 /* response frame present */
....@@ -1792,12 +1773,12 @@
17921773 sizeof(struct mvs_err_info);
17931774 sas_ssp_task_response(mvi->dev, task, iu);
17941775 } else
1795
- tstat->stat = SAM_STAT_CHECK_CONDITION;
1776
+ tstat->stat = SAS_SAM_STAT_CHECK_CONDITION;
17961777 break;
17971778
17981779 case SAS_PROTOCOL_SMP: {
17991780 struct scatterlist *sg_resp = &task->smp_task.smp_resp;
1800
- tstat->stat = SAM_STAT_GOOD;
1781
+ tstat->stat = SAS_SAM_STAT_GOOD;
18011782 to = kmap_atomic(sg_page(sg_resp));
18021783 memcpy(to + sg_resp->offset,
18031784 slot->response + sizeof(struct mvs_err_info),
....@@ -1814,7 +1795,7 @@
18141795 }
18151796
18161797 default:
1817
- tstat->stat = SAM_STAT_CHECK_CONDITION;
1798
+ tstat->stat = SAS_SAM_STAT_CHECK_CONDITION;
18181799 break;
18191800 }
18201801 if (!slot->port->port_attached) {
....@@ -1897,7 +1878,6 @@
18971878 struct mvs_info *mvi = mwq->mvi;
18981879 unsigned long flags;
18991880 u32 phy_no = (unsigned long) mwq->data;
1900
- struct sas_ha_struct *sas_ha = mvi->sas;
19011881 struct mvs_phy *phy = &mvi->phy[phy_no];
19021882 struct asd_sas_phy *sas_phy = &phy->sas_phy;
19031883
....@@ -1906,28 +1886,27 @@
19061886
19071887 if (phy->phy_event & PHY_PLUG_OUT) {
19081888 u32 tmp;
1909
- struct sas_identify_frame *id;
1910
- id = (struct sas_identify_frame *)phy->frame_rcvd;
1889
+
19111890 tmp = MVS_CHIP_DISP->read_phy_ctl(mvi, phy_no);
19121891 phy->phy_event &= ~PHY_PLUG_OUT;
19131892 if (!(tmp & PHY_READY_MASK)) {
19141893 sas_phy_disconnected(sas_phy);
19151894 mvs_phy_disconnected(phy);
1916
- sas_ha->notify_phy_event(sas_phy,
1917
- PHYE_LOSS_OF_SIGNAL);
1895
+ sas_notify_phy_event_gfp(sas_phy,
1896
+ PHYE_LOSS_OF_SIGNAL, GFP_ATOMIC);
19181897 mv_dprintk("phy%d Removed Device\n", phy_no);
19191898 } else {
19201899 MVS_CHIP_DISP->detect_porttype(mvi, phy_no);
19211900 mvs_update_phyinfo(mvi, phy_no, 1);
1922
- mvs_bytes_dmaed(mvi, phy_no);
1901
+ mvs_bytes_dmaed(mvi, phy_no, GFP_ATOMIC);
19231902 mvs_port_notify_formed(sas_phy, 0);
19241903 mv_dprintk("phy%d Attached Device\n", phy_no);
19251904 }
19261905 }
19271906 } else if (mwq->handler & EXP_BRCT_CHG) {
19281907 phy->phy_event &= ~EXP_BRCT_CHG;
1929
- sas_ha->notify_port_event(sas_phy,
1930
- PORTE_BROADCAST_RCVD);
1908
+ sas_notify_port_event_gfp(sas_phy,
1909
+ PORTE_BROADCAST_RCVD, GFP_ATOMIC);
19311910 mv_dprintk("phy%d Got Broadcast Change\n", phy_no);
19321911 }
19331912 list_del(&mwq->entry);
....@@ -2044,7 +2023,7 @@
20442023 mdelay(10);
20452024 }
20462025
2047
- mvs_bytes_dmaed(mvi, phy_no);
2026
+ mvs_bytes_dmaed(mvi, phy_no, GFP_ATOMIC);
20482027 /* whether driver is going to handle hot plug */
20492028 if (phy->phy_event & PHY_PLUG_OUT) {
20502029 mvs_port_notify_formed(&phy->sas_phy, 0);