mirror of https://gitee.com/openkylin/linux.git
scsi: snic: switch to pci_irq_alloc_vectors
Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Narsimhulu Musini <nmusini@cisco.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
156f8759bb
commit
8e305cb2bd
|
@ -299,7 +299,6 @@ struct snic {
|
||||||
|
|
||||||
/* pci related */
|
/* pci related */
|
||||||
struct pci_dev *pdev;
|
struct pci_dev *pdev;
|
||||||
struct msix_entry msix_entry[SNIC_MSIX_INTR_MAX];
|
|
||||||
struct snic_msix_entry msix[SNIC_MSIX_INTR_MAX];
|
struct snic_msix_entry msix[SNIC_MSIX_INTR_MAX];
|
||||||
|
|
||||||
/* io related info */
|
/* io related info */
|
||||||
|
|
|
@ -93,7 +93,7 @@ snic_free_intr(struct snic *snic)
|
||||||
/* ONLY interrupt mode MSIX is supported */
|
/* ONLY interrupt mode MSIX is supported */
|
||||||
for (i = 0; i < ARRAY_SIZE(snic->msix); i++) {
|
for (i = 0; i < ARRAY_SIZE(snic->msix); i++) {
|
||||||
if (snic->msix[i].requested) {
|
if (snic->msix[i].requested) {
|
||||||
free_irq(snic->msix_entry[i].vector,
|
free_irq(pci_irq_vector(snic->pdev, i),
|
||||||
snic->msix[i].devid);
|
snic->msix[i].devid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ snic_request_intr(struct snic *snic)
|
||||||
snic->msix[SNIC_MSIX_ERR_NOTIFY].devid = snic;
|
snic->msix[SNIC_MSIX_ERR_NOTIFY].devid = snic;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(snic->msix); i++) {
|
for (i = 0; i < ARRAY_SIZE(snic->msix); i++) {
|
||||||
ret = request_irq(snic->msix_entry[i].vector,
|
ret = request_irq(pci_irq_vector(snic->pdev, i),
|
||||||
snic->msix[i].isr,
|
snic->msix[i].isr,
|
||||||
0,
|
0,
|
||||||
snic->msix[i].devname,
|
snic->msix[i].devname,
|
||||||
|
@ -158,47 +158,37 @@ snic_set_intr_mode(struct snic *snic)
|
||||||
{
|
{
|
||||||
unsigned int n = ARRAY_SIZE(snic->wq);
|
unsigned int n = ARRAY_SIZE(snic->wq);
|
||||||
unsigned int m = SNIC_CQ_IO_CMPL_MAX;
|
unsigned int m = SNIC_CQ_IO_CMPL_MAX;
|
||||||
unsigned int i;
|
unsigned int vecs = n + m + 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need n WQs, m CQs, and n+m+1 INTRs
|
* We need n WQs, m CQs, and n+m+1 INTRs
|
||||||
* (last INTR is used for WQ/CQ errors and notification area
|
* (last INTR is used for WQ/CQ errors and notification area
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BUILD_BUG_ON((ARRAY_SIZE(snic->wq) + SNIC_CQ_IO_CMPL_MAX) >
|
BUILD_BUG_ON((ARRAY_SIZE(snic->wq) + SNIC_CQ_IO_CMPL_MAX) >
|
||||||
ARRAY_SIZE(snic->intr));
|
ARRAY_SIZE(snic->intr));
|
||||||
SNIC_BUG_ON(ARRAY_SIZE(snic->msix_entry) < (n + m + 1));
|
|
||||||
|
|
||||||
for (i = 0; i < (n + m + 1); i++)
|
if (snic->wq_count < n || snic->cq_count < n + m)
|
||||||
snic->msix_entry[i].entry = i;
|
goto fail;
|
||||||
|
|
||||||
if (snic->wq_count >= n && snic->cq_count >= (n + m)) {
|
if (pci_alloc_irq_vectors(snic->pdev, vecs, vecs, PCI_IRQ_MSIX) < 0)
|
||||||
if (!pci_enable_msix(snic->pdev,
|
goto fail;
|
||||||
snic->msix_entry,
|
|
||||||
(n + m + 1))) {
|
|
||||||
snic->wq_count = n;
|
|
||||||
snic->cq_count = n + m;
|
|
||||||
snic->intr_count = n + m + 1;
|
|
||||||
snic->err_intr_offset = SNIC_MSIX_ERR_NOTIFY;
|
|
||||||
|
|
||||||
SNIC_ISR_DBG(snic->shost,
|
snic->wq_count = n;
|
||||||
"Using MSI-X Interrupts\n");
|
snic->cq_count = n + m;
|
||||||
svnic_dev_set_intr_mode(snic->vdev,
|
snic->intr_count = vecs;
|
||||||
VNIC_DEV_INTR_MODE_MSIX);
|
snic->err_intr_offset = SNIC_MSIX_ERR_NOTIFY;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
SNIC_ISR_DBG(snic->shost, "Using MSI-X Interrupts\n");
|
||||||
|
svnic_dev_set_intr_mode(snic->vdev, VNIC_DEV_INTR_MODE_MSIX);
|
||||||
|
return 0;
|
||||||
|
fail:
|
||||||
svnic_dev_set_intr_mode(snic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN);
|
svnic_dev_set_intr_mode(snic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN);
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
} /* end of snic_set_intr_mode */
|
} /* end of snic_set_intr_mode */
|
||||||
|
|
||||||
void
|
void
|
||||||
snic_clear_intr_mode(struct snic *snic)
|
snic_clear_intr_mode(struct snic *snic)
|
||||||
{
|
{
|
||||||
pci_disable_msix(snic->pdev);
|
pci_free_irq_vectors(snic->pdev);
|
||||||
|
|
||||||
svnic_dev_set_intr_mode(snic->vdev, VNIC_DEV_INTR_MODE_INTX);
|
svnic_dev_set_intr_mode(snic->vdev, VNIC_DEV_INTR_MODE_INTX);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue