Lines Matching +full:sha +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright 2009-2011 Marvell. <yuxiangl@marvell.com>
17 [chip_6320] = { 1, 2, 0x400, 17, 16, 6, 9, &mvs_64xx_dispatch, },
18 [chip_6440] = { 1, 4, 0x400, 17, 16, 6, 9, &mvs_64xx_dispatch, },
19 [chip_6485] = { 1, 8, 0x800, 33, 32, 6, 10, &mvs_64xx_dispatch, },
22 [chip_9445] = { 1, 4, 0x800, 17, 64, 8, 11, &mvs_94xx_dispatch, },
24 [chip_1300] = { 1, 4, 0x400, 17, 16, 6, 9, &mvs_64xx_dispatch, },
43 .can_queue = 1,
44 .this_id = -1,
56 .track_queue_depth = 1,
81 struct mvs_phy *phy = &mvi->phy[phy_id]; in mvs_phy_init()
82 struct asd_sas_phy *sas_phy = &phy->sas_phy; in mvs_phy_init()
84 phy->mvi = mvi; in mvs_phy_init()
85 phy->port = NULL; in mvs_phy_init()
86 timer_setup(&phy->timer, NULL, 0); in mvs_phy_init()
87 sas_phy->enabled = (phy_id < mvi->chip->n_phy) ? 1 : 0; in mvs_phy_init()
88 sas_phy->class = SAS; in mvs_phy_init()
89 sas_phy->iproto = SAS_PROTOCOL_ALL; in mvs_phy_init()
90 sas_phy->tproto = 0; in mvs_phy_init()
91 sas_phy->type = PHY_TYPE_PHYSICAL; in mvs_phy_init()
92 sas_phy->role = PHY_ROLE_INITIATOR; in mvs_phy_init()
93 sas_phy->oob_mode = OOB_NOT_CONNECTED; in mvs_phy_init()
94 sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN; in mvs_phy_init()
96 sas_phy->id = phy_id; in mvs_phy_init()
97 sas_phy->sas_addr = &mvi->sas_addr[0]; in mvs_phy_init()
98 sas_phy->frame_rcvd = &phy->frame_rcvd[0]; in mvs_phy_init()
99 sas_phy->ha = (struct sas_ha_struct *)mvi->shost->hostdata; in mvs_phy_init()
100 sas_phy->lldd_phy = phy; in mvs_phy_init()
111 if (mvi->flags & MVF_FLAG_SOC) in mvs_free()
116 dma_pool_destroy(mvi->dma_pool); in mvs_free()
118 if (mvi->tx) in mvs_free()
119 dma_free_coherent(mvi->dev, in mvs_free()
120 sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ, in mvs_free()
121 mvi->tx, mvi->tx_dma); in mvs_free()
122 if (mvi->rx_fis) in mvs_free()
123 dma_free_coherent(mvi->dev, MVS_RX_FISL_SZ, in mvs_free()
124 mvi->rx_fis, mvi->rx_fis_dma); in mvs_free()
125 if (mvi->rx) in mvs_free()
126 dma_free_coherent(mvi->dev, in mvs_free()
127 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1), in mvs_free()
128 mvi->rx, mvi->rx_dma); in mvs_free()
129 if (mvi->slot) in mvs_free()
130 dma_free_coherent(mvi->dev, in mvs_free()
131 sizeof(*mvi->slot) * slot_nr, in mvs_free()
132 mvi->slot, mvi->slot_dma); in mvs_free()
134 if (mvi->bulk_buffer) in mvs_free()
135 dma_free_coherent(mvi->dev, TRASH_BUCKET_SIZE, in mvs_free()
136 mvi->bulk_buffer, mvi->bulk_buffer_dma); in mvs_free()
137 if (mvi->bulk_buffer1) in mvs_free()
138 dma_free_coherent(mvi->dev, TRASH_BUCKET_SIZE, in mvs_free()
139 mvi->bulk_buffer1, mvi->bulk_buffer_dma1); in mvs_free()
141 MVS_CHIP_DISP->chip_iounmap(mvi); in mvs_free()
142 if (mvi->shost) in mvs_free()
143 scsi_host_put(mvi->shost); in mvs_free()
144 list_for_each_entry(mwq, &mvi->wq_list, entry) in mvs_free()
145 cancel_delayed_work(&mwq->work_q); in mvs_free()
146 kfree(mvi->tags); in mvs_free()
157 struct sas_ha_struct *sha = (struct sas_ha_struct *)opaque; in mvs_tasklet() local
159 core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; in mvs_tasklet()
160 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; in mvs_tasklet()
163 BUG_ON(1); in mvs_tasklet()
165 stat = MVS_CHIP_DISP->isr_status(mvi, mvi->pdev->irq); in mvs_tasklet()
170 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; in mvs_tasklet()
171 MVS_CHIP_DISP->isr(mvi, mvi->pdev->irq, stat); in mvs_tasklet()
174 MVS_CHIP_DISP->interrupt_enable(mvi); in mvs_tasklet()
183 struct sas_ha_struct *sha = opaque; in mvs_interrupt() local
188 core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; in mvs_interrupt()
191 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; in mvs_interrupt()
196 MVS_CHIP_DISP->interrupt_disable(mvi); in mvs_interrupt()
199 stat = MVS_CHIP_DISP->isr_status(mvi, irq); in mvs_interrupt()
202 MVS_CHIP_DISP->interrupt_enable(mvi); in mvs_interrupt()
208 tasklet_schedule(&((struct mvs_prv_info *)sha->lldd_ha)->mv_tasklet); in mvs_interrupt()
211 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; in mvs_interrupt()
212 MVS_CHIP_DISP->isr(mvi, irq, stat); in mvs_interrupt()
223 if (mvi->flags & MVF_FLAG_SOC) in mvs_alloc()
228 spin_lock_init(&mvi->lock); in mvs_alloc()
229 for (i = 0; i < mvi->chip->n_phy; i++) { in mvs_alloc()
231 mvi->port[i].wide_port_phymap = 0; in mvs_alloc()
232 mvi->port[i].port_attached = 0; in mvs_alloc()
233 INIT_LIST_HEAD(&mvi->port[i].list); in mvs_alloc()
236 mvi->devices[i].taskfileset = MVS_ID_NOT_MAPPED; in mvs_alloc()
237 mvi->devices[i].dev_type = SAS_PHY_UNUSED; in mvs_alloc()
238 mvi->devices[i].device_id = i; in mvs_alloc()
239 mvi->devices[i].dev_status = MVS_DEV_NORMAL; in mvs_alloc()
245 mvi->tx = dma_alloc_coherent(mvi->dev, in mvs_alloc()
246 sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ, in mvs_alloc()
247 &mvi->tx_dma, GFP_KERNEL); in mvs_alloc()
248 if (!mvi->tx) in mvs_alloc()
250 mvi->rx_fis = dma_alloc_coherent(mvi->dev, MVS_RX_FISL_SZ, in mvs_alloc()
251 &mvi->rx_fis_dma, GFP_KERNEL); in mvs_alloc()
252 if (!mvi->rx_fis) in mvs_alloc()
255 mvi->rx = dma_alloc_coherent(mvi->dev, in mvs_alloc()
256 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1), in mvs_alloc()
257 &mvi->rx_dma, GFP_KERNEL); in mvs_alloc()
258 if (!mvi->rx) in mvs_alloc()
260 mvi->rx[0] = cpu_to_le32(0xfff); in mvs_alloc()
261 mvi->rx_cons = 0xfff; in mvs_alloc()
263 mvi->slot = dma_alloc_coherent(mvi->dev, in mvs_alloc()
264 sizeof(*mvi->slot) * slot_nr, in mvs_alloc()
265 &mvi->slot_dma, GFP_KERNEL); in mvs_alloc()
266 if (!mvi->slot) in mvs_alloc()
269 mvi->bulk_buffer = dma_alloc_coherent(mvi->dev, in mvs_alloc()
271 &mvi->bulk_buffer_dma, GFP_KERNEL); in mvs_alloc()
272 if (!mvi->bulk_buffer) in mvs_alloc()
275 mvi->bulk_buffer1 = dma_alloc_coherent(mvi->dev, in mvs_alloc()
277 &mvi->bulk_buffer_dma1, GFP_KERNEL); in mvs_alloc()
278 if (!mvi->bulk_buffer1) in mvs_alloc()
281 sprintf(pool_name, "%s%d", "mvs_dma_pool", mvi->id); in mvs_alloc()
282 mvi->dma_pool = dma_pool_create(pool_name, &mvi->pdev->dev, in mvs_alloc()
284 if (!mvi->dma_pool) { in mvs_alloc()
288 mvi->tags_num = slot_nr; in mvs_alloc()
294 return 1; in mvs_alloc()
301 struct pci_dev *pdev = mvi->pdev; in mvs_ioremap()
302 if (bar_ex != -1) { in mvs_ioremap()
313 mvi->regs_ex = ioremap(res_start, res_len); in mvs_ioremap()
315 mvi->regs_ex = (void *)res_start; in mvs_ioremap()
316 if (!mvi->regs_ex) in mvs_ioremap()
323 iounmap(mvi->regs_ex); in mvs_ioremap()
324 mvi->regs_ex = NULL; in mvs_ioremap()
328 mvi->regs = ioremap(res_start, res_len); in mvs_ioremap()
330 if (!mvi->regs) { in mvs_ioremap()
331 if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM)) in mvs_ioremap()
332 iounmap(mvi->regs_ex); in mvs_ioremap()
333 mvi->regs_ex = NULL; in mvs_ioremap()
339 return -1; in mvs_ioremap()
352 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); in mvs_pci_alloc() local
355 (1L << mvs_chips[ent->driver_data].slot_width) * in mvs_pci_alloc()
360 mvi->pdev = pdev; in mvs_pci_alloc()
361 mvi->dev = &pdev->dev; in mvs_pci_alloc()
362 mvi->chip_id = ent->driver_data; in mvs_pci_alloc()
363 mvi->chip = &mvs_chips[mvi->chip_id]; in mvs_pci_alloc()
364 INIT_LIST_HEAD(&mvi->wq_list); in mvs_pci_alloc()
366 ((struct mvs_prv_info *)sha->lldd_ha)->mvi[id] = mvi; in mvs_pci_alloc()
367 ((struct mvs_prv_info *)sha->lldd_ha)->n_phy = mvi->chip->n_phy; in mvs_pci_alloc()
369 mvi->id = id; in mvs_pci_alloc()
370 mvi->sas = sha; in mvs_pci_alloc()
371 mvi->shost = shost; in mvs_pci_alloc()
373 mvi->tags = kzalloc(MVS_CHIP_SLOT_SZ>>3, GFP_KERNEL); in mvs_pci_alloc()
374 if (!mvi->tags) in mvs_pci_alloc()
377 if (MVS_CHIP_DISP->chip_ioremap(mvi)) in mvs_pci_alloc()
390 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in pci_go_64()
392 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in pci_go_64()
394 dev_printk(KERN_ERR, &pdev->dev, in pci_go_64()
395 "32-bit DMA enable failed\n"); in pci_go_64()
409 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); in mvs_prep_sas_ha_init() local
411 core_nr = chip_info->n_host; in mvs_prep_sas_ha_init()
412 phy_nr = core_nr * chip_info->n_phy; in mvs_prep_sas_ha_init()
415 memset(sha, 0x00, sizeof(struct sas_ha_struct)); in mvs_prep_sas_ha_init()
421 sha->sas_phy = arr_phy; in mvs_prep_sas_ha_init()
422 sha->sas_port = arr_port; in mvs_prep_sas_ha_init()
423 sha->core.shost = shost; in mvs_prep_sas_ha_init()
425 sha->lldd_ha = kzalloc(sizeof(struct mvs_prv_info), GFP_KERNEL); in mvs_prep_sas_ha_init()
426 if (!sha->lldd_ha) in mvs_prep_sas_ha_init()
429 ((struct mvs_prv_info *)sha->lldd_ha)->n_host = core_nr; in mvs_prep_sas_ha_init()
431 shost->transportt = mvs_stt; in mvs_prep_sas_ha_init()
432 shost->max_id = MVS_MAX_DEVICES; in mvs_prep_sas_ha_init()
433 shost->max_lun = ~0; in mvs_prep_sas_ha_init()
434 shost->max_channel = 1; in mvs_prep_sas_ha_init()
435 shost->max_cmd_len = 16; in mvs_prep_sas_ha_init()
441 return -1; in mvs_prep_sas_ha_init()
450 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); in mvs_post_sas_ha_init() local
451 unsigned short nr_core = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; in mvs_post_sas_ha_init()
454 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[j]; in mvs_post_sas_ha_init()
455 for (i = 0; i < chip_info->n_phy; i++) { in mvs_post_sas_ha_init()
456 sha->sas_phy[j * chip_info->n_phy + i] = in mvs_post_sas_ha_init()
457 &mvi->phy[i].sas_phy; in mvs_post_sas_ha_init()
458 sha->sas_port[j * chip_info->n_phy + i] = in mvs_post_sas_ha_init()
459 &mvi->port[i].sas_port; in mvs_post_sas_ha_init()
463 sha->sas_ha_name = DRV_NAME; in mvs_post_sas_ha_init()
464 sha->dev = mvi->dev; in mvs_post_sas_ha_init()
465 sha->lldd_module = THIS_MODULE; in mvs_post_sas_ha_init()
466 sha->sas_addr = &mvi->sas_addr[0]; in mvs_post_sas_ha_init()
468 sha->num_phys = nr_core * chip_info->n_phy; in mvs_post_sas_ha_init()
470 if (mvi->flags & MVF_FLAG_SOC) in mvs_post_sas_ha_init()
475 shost->sg_tablesize = min_t(u16, SG_ALL, MVS_MAX_SG); in mvs_post_sas_ha_init()
476 shost->can_queue = can_queue; in mvs_post_sas_ha_init()
477 mvi->shost->cmd_per_lun = MVS_QUEUE_SIZE; in mvs_post_sas_ha_init()
478 sha->core.shost = mvi->shost; in mvs_post_sas_ha_init()
484 for (i = 0; i < mvi->chip->n_phy; i++) { in mvs_init_sas_add()
485 mvi->phy[i].dev_sas_addr = 0x5005043011ab0000ULL; in mvs_init_sas_add()
486 mvi->phy[i].dev_sas_addr = in mvs_init_sas_add()
487 cpu_to_be64((u64)(*(u64 *)&mvi->phy[i].dev_sas_addr)); in mvs_init_sas_add()
490 memcpy(mvi->sas_addr, &mvi->phy[0].dev_sas_addr, SAS_ADDR_SIZE); in mvs_init_sas_add()
502 dev_printk(KERN_INFO, &pdev->dev, in mvs_pci_init()
520 rc = -ENOMEM; in mvs_pci_init()
524 chip = &mvs_chips[ent->driver_data]; in mvs_pci_init()
526 kcalloc(1, sizeof(struct sas_ha_struct), GFP_KERNEL); in mvs_pci_init()
529 rc = -ENOMEM; in mvs_pci_init()
536 rc = -ENOMEM; in mvs_pci_init()
545 rc = -ENOMEM; in mvs_pci_init()
549 memset(&mvi->hba_info_param, 0xFF, in mvs_pci_init()
554 mvi->instance = nhost; in mvs_pci_init()
555 rc = MVS_CHIP_DISP->chip_init(mvi); in mvs_pci_init()
561 } while (nhost < chip->n_host); in mvs_pci_init()
562 mpi = (struct mvs_prv_info *)(SHOST_TO_SAS_HA(shost)->lldd_ha); in mvs_pci_init()
564 tasklet_init(&(mpi->mv_tasklet), mvs_tasklet, in mvs_pci_init()
570 rc = scsi_add_host(shost, &pdev->dev); in mvs_pci_init()
577 rc = request_irq(pdev->irq, irq_handler, IRQF_SHARED, in mvs_pci_init()
582 MVS_CHIP_DISP->interrupt_enable(mvi); in mvs_pci_init()
584 scsi_scan_host(mvi->shost); in mvs_pci_init()
591 scsi_remove_host(mvi->shost); in mvs_pci_init()
603 struct sas_ha_struct *sha = pci_get_drvdata(pdev); in mvs_pci_remove() local
606 core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; in mvs_pci_remove()
607 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; in mvs_pci_remove()
610 tasklet_kill(&((struct mvs_prv_info *)sha->lldd_ha)->mv_tasklet); in mvs_pci_remove()
613 sas_unregister_ha(sha); in mvs_pci_remove()
614 sas_remove_host(mvi->shost); in mvs_pci_remove()
616 MVS_CHIP_DISP->interrupt_disable(mvi); in mvs_pci_remove()
617 free_irq(mvi->pdev->irq, sha); in mvs_pci_remove()
619 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; in mvs_pci_remove()
622 kfree(sha->sas_phy); in mvs_pci_remove()
623 kfree(sha->sas_port); in mvs_pci_remove()
624 kfree(sha); in mvs_pci_remove()
711 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); in interrupt_coalescing_store() local
716 if (sscanf(buffer, "%u", &val) != 1) in interrupt_coalescing_store()
717 return -EINVAL; in interrupt_coalescing_store()
727 core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; in interrupt_coalescing_store()
728 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; in interrupt_coalescing_store()
731 return -EINVAL; in interrupt_coalescing_store()
734 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; in interrupt_coalescing_store()
735 if (MVS_CHIP_DISP->tune_interrupt) in interrupt_coalescing_store()
736 MVS_CHIP_DISP->tune_interrupt(mvi, in interrupt_coalescing_store()
757 return -ENOMEM; in mvs_init()