| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Marvell 88SE64xx/88SE94xx main function |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2007 Red Hat, Inc. |
|---|
| 5 | 6 | * Copyright 2008 Marvell. <kewei@marvell.com> |
|---|
| 6 | 7 | * 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 |
|---|
| 24 | 8 | */ |
|---|
| 25 | 9 | |
|---|
| 26 | 10 | #include "mv_sas.h" |
|---|
| .. | .. |
|---|
| 232 | 216 | MVS_CHIP_DISP->write_port_cfg_data(mvi, port_id, hi); |
|---|
| 233 | 217 | } |
|---|
| 234 | 218 | |
|---|
| 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) |
|---|
| 236 | 220 | { |
|---|
| 237 | 221 | struct mvs_phy *phy = &mvi->phy[i]; |
|---|
| 238 | 222 | struct asd_sas_phy *sas_phy = &phy->sas_phy; |
|---|
| 239 | | - struct sas_ha_struct *sas_ha; |
|---|
| 223 | + |
|---|
| 240 | 224 | if (!phy->phy_attached) |
|---|
| 241 | 225 | return; |
|---|
| 242 | 226 | |
|---|
| .. | .. |
|---|
| 245 | 229 | return; |
|---|
| 246 | 230 | } |
|---|
| 247 | 231 | |
|---|
| 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); |
|---|
| 250 | 233 | |
|---|
| 251 | 234 | if (sas_phy->phy) { |
|---|
| 252 | 235 | struct sas_phy *sphy = sas_phy->phy; |
|---|
| .. | .. |
|---|
| 278 | 261 | |
|---|
| 279 | 262 | sas_phy->frame_rcvd_size = phy->frame_rcvd_size; |
|---|
| 280 | 263 | |
|---|
| 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); |
|---|
| 283 | 265 | } |
|---|
| 284 | 266 | |
|---|
| 285 | 267 | void mvs_scan_start(struct Scsi_Host *shost) |
|---|
| .. | .. |
|---|
| 295 | 277 | for (j = 0; j < core_nr; j++) { |
|---|
| 296 | 278 | mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[j]; |
|---|
| 297 | 279 | for (i = 0; i < mvi->chip->n_phy; ++i) |
|---|
| 298 | | - mvs_bytes_dmaed(mvi, i); |
|---|
| 280 | + mvs_bytes_dmaed(mvi, i, GFP_KERNEL); |
|---|
| 299 | 281 | } |
|---|
| 300 | 282 | mvs_prv->scan_finished = 1; |
|---|
| 301 | 283 | } |
|---|
| .. | .. |
|---|
| 336 | 318 | * DMA-map SMP request, response buffers |
|---|
| 337 | 319 | */ |
|---|
| 338 | 320 | 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); |
|---|
| 340 | 322 | if (!elem) |
|---|
| 341 | 323 | return -ENOMEM; |
|---|
| 342 | 324 | req_len = sg_dma_len(sg_req); |
|---|
| 343 | 325 | |
|---|
| 344 | 326 | 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); |
|---|
| 346 | 328 | if (!elem) { |
|---|
| 347 | 329 | rc = -ENOMEM; |
|---|
| 348 | 330 | goto err_out; |
|---|
| .. | .. |
|---|
| 416 | 398 | |
|---|
| 417 | 399 | err_out_2: |
|---|
| 418 | 400 | dma_unmap_sg(mvi->dev, &tei->task->smp_task.smp_resp, 1, |
|---|
| 419 | | - PCI_DMA_FROMDEVICE); |
|---|
| 401 | + DMA_FROM_DEVICE); |
|---|
| 420 | 402 | err_out: |
|---|
| 421 | 403 | dma_unmap_sg(mvi->dev, &tei->task->smp_task.smp_req, 1, |
|---|
| 422 | | - PCI_DMA_TODEVICE); |
|---|
| 404 | + DMA_TO_DEVICE); |
|---|
| 423 | 405 | return rc; |
|---|
| 424 | 406 | } |
|---|
| 425 | 407 | |
|---|
| .. | .. |
|---|
| 790 | 772 | slot->n_elem = n_elem; |
|---|
| 791 | 773 | slot->slot_tag = tag; |
|---|
| 792 | 774 | |
|---|
| 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); |
|---|
| 794 | 776 | if (!slot->buf) { |
|---|
| 795 | 777 | rc = -ENOMEM; |
|---|
| 796 | 778 | goto err_out_tag; |
|---|
| 797 | 779 | } |
|---|
| 798 | | - memset(slot->buf, 0, MVS_SLOT_BUF_SZ); |
|---|
| 799 | 780 | |
|---|
| 800 | 781 | tei.task = task; |
|---|
| 801 | 782 | tei.hdr = &mvi->slot[tag]; |
|---|
| .. | .. |
|---|
| 904 | 885 | switch (task->task_proto) { |
|---|
| 905 | 886 | case SAS_PROTOCOL_SMP: |
|---|
| 906 | 887 | dma_unmap_sg(mvi->dev, &task->smp_task.smp_resp, 1, |
|---|
| 907 | | - PCI_DMA_FROMDEVICE); |
|---|
| 888 | + DMA_FROM_DEVICE); |
|---|
| 908 | 889 | dma_unmap_sg(mvi->dev, &task->smp_task.smp_req, 1, |
|---|
| 909 | | - PCI_DMA_TODEVICE); |
|---|
| 890 | + DMA_TO_DEVICE); |
|---|
| 910 | 891 | break; |
|---|
| 911 | 892 | |
|---|
| 912 | 893 | case SAS_PROTOCOL_SATA: |
|---|
| .. | .. |
|---|
| 1210 | 1191 | mvi_device->dev_type = dev->dev_type; |
|---|
| 1211 | 1192 | mvi_device->mvi_info = mvi; |
|---|
| 1212 | 1193 | 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)) { |
|---|
| 1214 | 1195 | int phy_id; |
|---|
| 1215 | 1196 | u8 phy_num = parent_dev->ex_dev.num_phys; |
|---|
| 1216 | 1197 | struct ex_phy *phy; |
|---|
| .. | .. |
|---|
| 1423 | 1404 | { |
|---|
| 1424 | 1405 | unsigned long flags; |
|---|
| 1425 | 1406 | 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; |
|---|
| 1427 | 1408 | struct mvs_info *mvi = mvi_dev->mvi_info; |
|---|
| 1428 | 1409 | |
|---|
| 1429 | 1410 | if (mvi_dev->dev_status != MVS_DEV_EH) |
|---|
| .. | .. |
|---|
| 1558 | 1539 | |
|---|
| 1559 | 1540 | int mvs_abort_task_set(struct domain_device *dev, u8 *lun) |
|---|
| 1560 | 1541 | { |
|---|
| 1561 | | - int rc = TMF_RESP_FUNC_FAILED; |
|---|
| 1542 | + int rc; |
|---|
| 1562 | 1543 | struct mvs_tmf_task tmf_task; |
|---|
| 1563 | 1544 | |
|---|
| 1564 | 1545 | tmf_task.tmf = TMF_ABORT_TASK_SET; |
|---|
| .. | .. |
|---|
| 1897 | 1878 | struct mvs_info *mvi = mwq->mvi; |
|---|
| 1898 | 1879 | unsigned long flags; |
|---|
| 1899 | 1880 | u32 phy_no = (unsigned long) mwq->data; |
|---|
| 1900 | | - struct sas_ha_struct *sas_ha = mvi->sas; |
|---|
| 1901 | 1881 | struct mvs_phy *phy = &mvi->phy[phy_no]; |
|---|
| 1902 | 1882 | struct asd_sas_phy *sas_phy = &phy->sas_phy; |
|---|
| 1903 | 1883 | |
|---|
| .. | .. |
|---|
| 1906 | 1886 | |
|---|
| 1907 | 1887 | if (phy->phy_event & PHY_PLUG_OUT) { |
|---|
| 1908 | 1888 | u32 tmp; |
|---|
| 1909 | | - struct sas_identify_frame *id; |
|---|
| 1910 | | - id = (struct sas_identify_frame *)phy->frame_rcvd; |
|---|
| 1889 | + |
|---|
| 1911 | 1890 | tmp = MVS_CHIP_DISP->read_phy_ctl(mvi, phy_no); |
|---|
| 1912 | 1891 | phy->phy_event &= ~PHY_PLUG_OUT; |
|---|
| 1913 | 1892 | if (!(tmp & PHY_READY_MASK)) { |
|---|
| 1914 | 1893 | sas_phy_disconnected(sas_phy); |
|---|
| 1915 | 1894 | 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); |
|---|
| 1918 | 1897 | mv_dprintk("phy%d Removed Device\n", phy_no); |
|---|
| 1919 | 1898 | } else { |
|---|
| 1920 | 1899 | MVS_CHIP_DISP->detect_porttype(mvi, phy_no); |
|---|
| 1921 | 1900 | mvs_update_phyinfo(mvi, phy_no, 1); |
|---|
| 1922 | | - mvs_bytes_dmaed(mvi, phy_no); |
|---|
| 1901 | + mvs_bytes_dmaed(mvi, phy_no, GFP_ATOMIC); |
|---|
| 1923 | 1902 | mvs_port_notify_formed(sas_phy, 0); |
|---|
| 1924 | 1903 | mv_dprintk("phy%d Attached Device\n", phy_no); |
|---|
| 1925 | 1904 | } |
|---|
| 1926 | 1905 | } |
|---|
| 1927 | 1906 | } else if (mwq->handler & EXP_BRCT_CHG) { |
|---|
| 1928 | 1907 | 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); |
|---|
| 1931 | 1910 | mv_dprintk("phy%d Got Broadcast Change\n", phy_no); |
|---|
| 1932 | 1911 | } |
|---|
| 1933 | 1912 | list_del(&mwq->entry); |
|---|
| .. | .. |
|---|
| 2044 | 2023 | mdelay(10); |
|---|
| 2045 | 2024 | } |
|---|
| 2046 | 2025 | |
|---|
| 2047 | | - mvs_bytes_dmaed(mvi, phy_no); |
|---|
| 2026 | + mvs_bytes_dmaed(mvi, phy_no, GFP_ATOMIC); |
|---|
| 2048 | 2027 | /* whether driver is going to handle hot plug */ |
|---|
| 2049 | 2028 | if (phy->phy_event & PHY_PLUG_OUT) { |
|---|
| 2050 | 2029 | mvs_port_notify_formed(&phy->sas_phy, 0); |
|---|