Lines Matching refs:mvi
78 static void mvs_phy_init(struct mvs_info *mvi, int phy_id) in mvs_phy_init() argument
80 struct mvs_phy *phy = &mvi->phy[phy_id]; in mvs_phy_init()
83 phy->mvi = mvi; in mvs_phy_init()
86 sas_phy->enabled = (phy_id < mvi->chip->n_phy) ? 1 : 0; in mvs_phy_init()
94 sas_phy->sas_addr = &mvi->sas_addr[0]; in mvs_phy_init()
96 sas_phy->ha = (struct sas_ha_struct *)mvi->shost->hostdata; in mvs_phy_init()
100 static void mvs_free(struct mvs_info *mvi) in mvs_free() argument
105 if (!mvi) in mvs_free()
108 if (mvi->flags & MVF_FLAG_SOC) in mvs_free()
113 dma_pool_destroy(mvi->dma_pool); in mvs_free()
115 if (mvi->tx) in mvs_free()
116 dma_free_coherent(mvi->dev, in mvs_free()
117 sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ, in mvs_free()
118 mvi->tx, mvi->tx_dma); in mvs_free()
119 if (mvi->rx_fis) in mvs_free()
120 dma_free_coherent(mvi->dev, MVS_RX_FISL_SZ, in mvs_free()
121 mvi->rx_fis, mvi->rx_fis_dma); in mvs_free()
122 if (mvi->rx) in mvs_free()
123 dma_free_coherent(mvi->dev, in mvs_free()
124 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1), in mvs_free()
125 mvi->rx, mvi->rx_dma); in mvs_free()
126 if (mvi->slot) in mvs_free()
127 dma_free_coherent(mvi->dev, in mvs_free()
128 sizeof(*mvi->slot) * slot_nr, in mvs_free()
129 mvi->slot, mvi->slot_dma); in mvs_free()
131 if (mvi->bulk_buffer) in mvs_free()
132 dma_free_coherent(mvi->dev, TRASH_BUCKET_SIZE, in mvs_free()
133 mvi->bulk_buffer, mvi->bulk_buffer_dma); in mvs_free()
134 if (mvi->bulk_buffer1) in mvs_free()
135 dma_free_coherent(mvi->dev, TRASH_BUCKET_SIZE, in mvs_free()
136 mvi->bulk_buffer1, mvi->bulk_buffer_dma1); in mvs_free()
138 MVS_CHIP_DISP->chip_iounmap(mvi); in mvs_free()
139 if (mvi->shost) in mvs_free()
140 scsi_host_put(mvi->shost); in mvs_free()
141 list_for_each_entry(mwq, &mvi->wq_list, entry) in mvs_free()
143 kfree(mvi->rsvd_tags); in mvs_free()
144 kfree(mvi); in mvs_free()
153 struct mvs_info *mvi; in mvs_tasklet() local
157 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; in mvs_tasklet()
159 if (unlikely(!mvi)) in mvs_tasklet()
162 stat = MVS_CHIP_DISP->isr_status(mvi, mvi->pdev->irq); in mvs_tasklet()
167 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; in mvs_tasklet()
168 MVS_CHIP_DISP->isr(mvi, mvi->pdev->irq, stat); in mvs_tasklet()
171 MVS_CHIP_DISP->interrupt_enable(mvi); in mvs_tasklet()
179 struct mvs_info *mvi; in mvs_interrupt() local
188 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; in mvs_interrupt()
190 if (unlikely(!mvi)) in mvs_interrupt()
193 MVS_CHIP_DISP->interrupt_disable(mvi); in mvs_interrupt()
196 stat = MVS_CHIP_DISP->isr_status(mvi, irq); in mvs_interrupt()
199 MVS_CHIP_DISP->interrupt_enable(mvi); in mvs_interrupt()
208 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; in mvs_interrupt()
209 MVS_CHIP_DISP->isr(mvi, irq, stat); in mvs_interrupt()
215 static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost) in mvs_alloc() argument
220 if (mvi->flags & MVF_FLAG_SOC) in mvs_alloc()
225 spin_lock_init(&mvi->lock); in mvs_alloc()
226 for (i = 0; i < mvi->chip->n_phy; i++) { in mvs_alloc()
227 mvs_phy_init(mvi, i); in mvs_alloc()
228 mvi->port[i].wide_port_phymap = 0; in mvs_alloc()
229 mvi->port[i].port_attached = 0; in mvs_alloc()
230 INIT_LIST_HEAD(&mvi->port[i].list); in mvs_alloc()
233 mvi->devices[i].taskfileset = MVS_ID_NOT_MAPPED; in mvs_alloc()
234 mvi->devices[i].dev_type = SAS_PHY_UNUSED; in mvs_alloc()
235 mvi->devices[i].device_id = i; in mvs_alloc()
236 mvi->devices[i].dev_status = MVS_DEV_NORMAL; in mvs_alloc()
242 mvi->tx = dma_alloc_coherent(mvi->dev, in mvs_alloc()
243 sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ, in mvs_alloc()
244 &mvi->tx_dma, GFP_KERNEL); in mvs_alloc()
245 if (!mvi->tx) in mvs_alloc()
247 mvi->rx_fis = dma_alloc_coherent(mvi->dev, MVS_RX_FISL_SZ, in mvs_alloc()
248 &mvi->rx_fis_dma, GFP_KERNEL); in mvs_alloc()
249 if (!mvi->rx_fis) in mvs_alloc()
252 mvi->rx = dma_alloc_coherent(mvi->dev, in mvs_alloc()
253 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1), in mvs_alloc()
254 &mvi->rx_dma, GFP_KERNEL); in mvs_alloc()
255 if (!mvi->rx) in mvs_alloc()
257 mvi->rx[0] = cpu_to_le32(0xfff); in mvs_alloc()
258 mvi->rx_cons = 0xfff; in mvs_alloc()
260 mvi->slot = dma_alloc_coherent(mvi->dev, in mvs_alloc()
261 sizeof(*mvi->slot) * slot_nr, in mvs_alloc()
262 &mvi->slot_dma, GFP_KERNEL); in mvs_alloc()
263 if (!mvi->slot) in mvs_alloc()
266 mvi->bulk_buffer = dma_alloc_coherent(mvi->dev, in mvs_alloc()
268 &mvi->bulk_buffer_dma, GFP_KERNEL); in mvs_alloc()
269 if (!mvi->bulk_buffer) in mvs_alloc()
272 mvi->bulk_buffer1 = dma_alloc_coherent(mvi->dev, in mvs_alloc()
274 &mvi->bulk_buffer_dma1, GFP_KERNEL); in mvs_alloc()
275 if (!mvi->bulk_buffer1) in mvs_alloc()
278 sprintf(pool_name, "%s%d", "mvs_dma_pool", mvi->id); in mvs_alloc()
279 mvi->dma_pool = dma_pool_create(pool_name, &mvi->pdev->dev, in mvs_alloc()
281 if (!mvi->dma_pool) { in mvs_alloc()
292 int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex) in mvs_ioremap() argument
295 struct pci_dev *pdev = mvi->pdev; in mvs_ioremap()
307 mvi->regs_ex = ioremap(res_start, res_len); in mvs_ioremap()
309 mvi->regs_ex = (void *)res_start; in mvs_ioremap()
310 if (!mvi->regs_ex) in mvs_ioremap()
317 iounmap(mvi->regs_ex); in mvs_ioremap()
318 mvi->regs_ex = NULL; in mvs_ioremap()
322 mvi->regs = ioremap(res_start, res_len); in mvs_ioremap()
324 if (!mvi->regs) { in mvs_ioremap()
325 if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM)) in mvs_ioremap()
326 iounmap(mvi->regs_ex); in mvs_ioremap()
327 mvi->regs_ex = NULL; in mvs_ioremap()
345 struct mvs_info *mvi = NULL; in mvs_pci_alloc() local
348 mvi = kzalloc(sizeof(*mvi) + in mvs_pci_alloc()
351 if (!mvi) in mvs_pci_alloc()
354 mvi->pdev = pdev; in mvs_pci_alloc()
355 mvi->dev = &pdev->dev; in mvs_pci_alloc()
356 mvi->chip_id = ent->driver_data; in mvs_pci_alloc()
357 mvi->chip = &mvs_chips[mvi->chip_id]; in mvs_pci_alloc()
358 INIT_LIST_HEAD(&mvi->wq_list); in mvs_pci_alloc()
360 ((struct mvs_prv_info *)sha->lldd_ha)->mvi[id] = mvi; in mvs_pci_alloc()
361 ((struct mvs_prv_info *)sha->lldd_ha)->n_phy = mvi->chip->n_phy; in mvs_pci_alloc()
363 mvi->id = id; in mvs_pci_alloc()
364 mvi->sas = sha; in mvs_pci_alloc()
365 mvi->shost = shost; in mvs_pci_alloc()
367 mvi->rsvd_tags = bitmap_zalloc(MVS_RSVD_SLOTS, GFP_KERNEL); in mvs_pci_alloc()
368 if (!mvi->rsvd_tags) in mvs_pci_alloc()
371 if (MVS_CHIP_DISP->chip_ioremap(mvi)) in mvs_pci_alloc()
373 if (!mvs_alloc(mvi, shost)) in mvs_pci_alloc()
374 return mvi; in mvs_pci_alloc()
376 mvs_free(mvi); in mvs_pci_alloc()
443 struct mvs_info *mvi = NULL; in mvs_post_sas_ha_init() local
448 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[j]; in mvs_post_sas_ha_init()
451 &mvi->phy[i].sas_phy; in mvs_post_sas_ha_init()
453 &mvi->port[i].sas_port; in mvs_post_sas_ha_init()
458 sha->dev = mvi->dev; in mvs_post_sas_ha_init()
459 sha->sas_addr = &mvi->sas_addr[0]; in mvs_post_sas_ha_init()
463 if (mvi->flags & MVF_FLAG_SOC) in mvs_post_sas_ha_init()
472 mvi->shost->cmd_per_lun = MVS_QUEUE_SIZE; in mvs_post_sas_ha_init()
473 sha->shost = mvi->shost; in mvs_post_sas_ha_init()
476 static void mvs_init_sas_add(struct mvs_info *mvi) in mvs_init_sas_add() argument
479 for (i = 0; i < mvi->chip->n_phy; i++) { in mvs_init_sas_add()
480 mvi->phy[i].dev_sas_addr = 0x5005043011ab0000ULL; in mvs_init_sas_add()
481 mvi->phy[i].dev_sas_addr = in mvs_init_sas_add()
482 cpu_to_be64((u64)(*(u64 *)&mvi->phy[i].dev_sas_addr)); in mvs_init_sas_add()
485 memcpy(mvi->sas_addr, &mvi->phy[0].dev_sas_addr, SAS_ADDR_SIZE); in mvs_init_sas_add()
491 struct mvs_info *mvi; in mvs_pci_init() local
537 mvi = mvs_pci_alloc(pdev, ent, shost, nhost); in mvs_pci_init()
538 if (!mvi) { in mvs_pci_init()
543 memset(&mvi->hba_info_param, 0xFF, in mvs_pci_init()
546 mvs_init_sas_add(mvi); in mvs_pci_init()
548 mvi->instance = nhost; in mvs_pci_init()
549 rc = MVS_CHIP_DISP->chip_init(mvi); in mvs_pci_init()
551 mvs_free(mvi); in mvs_pci_init()
579 MVS_CHIP_DISP->interrupt_enable(mvi); in mvs_pci_init()
581 scsi_scan_host(mvi->shost); in mvs_pci_init()
588 scsi_remove_host(mvi->shost); in mvs_pci_init()
601 struct mvs_info *mvi = NULL; in mvs_pci_remove() local
604 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; in mvs_pci_remove()
611 sas_remove_host(mvi->shost); in mvs_pci_remove()
613 MVS_CHIP_DISP->interrupt_disable(mvi); in mvs_pci_remove()
614 free_irq(mvi->pdev->irq, sha); in mvs_pci_remove()
616 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; in mvs_pci_remove()
617 mvs_free(mvi); in mvs_pci_remove()
707 struct mvs_info *mvi = NULL; in interrupt_coalescing_store() local
726 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; in interrupt_coalescing_store()
728 if (unlikely(!mvi)) in interrupt_coalescing_store()
732 mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; in interrupt_coalescing_store()
734 MVS_CHIP_DISP->tune_interrupt(mvi, in interrupt_coalescing_store()