本文整理汇总了C++中pci_release_msi函数的典型用法代码示例。如果您正苦于以下问题:C++ pci_release_msi函数的具体用法?C++ pci_release_msi怎么用?C++ pci_release_msi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pci_release_msi函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ata_setup_interrupt
int
ata_setup_interrupt(device_t dev, void *intr_func)
{
struct ata_pci_controller *ctlr = device_get_softc(dev);
int i, msi = 0;
if (!ctlr->legacy) {
if (resource_int_value(device_get_name(dev),
device_get_unit(dev), "msi", &i) == 0 && i != 0)
msi = 1;
if (msi && pci_msi_count(dev) > 0 && pci_alloc_msi(dev, &msi) == 0) {
ctlr->r_irq_rid = 0x1;
} else {
msi = 0;
ctlr->r_irq_rid = ATA_IRQ_RID;
}
if (!(ctlr->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
&ctlr->r_irq_rid, RF_SHAREABLE | RF_ACTIVE))) {
device_printf(dev, "unable to map interrupt\n");
if (msi)
pci_release_msi(dev);
return ENXIO;
}
if ((bus_setup_intr(dev, ctlr->r_irq, ATA_INTR_FLAGS, NULL,
intr_func, ctlr, &ctlr->handle))) {
device_printf(dev, "unable to setup interrupt\n");
bus_release_resource(dev,
SYS_RES_IRQ, ctlr->r_irq_rid, ctlr->r_irq);
if (msi)
pci_release_msi(dev);
return ENXIO;
}
}
return 0;
}
示例2: vtpci_free_interrupts
static void
vtpci_free_interrupts(struct vtpci_softc *sc)
{
struct vtpci_interrupt *intr;
int i, nvq_intrs;
vtpci_free_interrupt(sc, &sc->vtpci_device_interrupt);
if (sc->vtpci_nmsix_resources != 0) {
nvq_intrs = sc->vtpci_nmsix_resources - 1;
sc->vtpci_nmsix_resources = 0;
intr = sc->vtpci_msix_vq_interrupts;
if (intr != NULL) {
for (i = 0; i < nvq_intrs; i++, intr++)
vtpci_free_interrupt(sc, intr);
free(sc->vtpci_msix_vq_interrupts, M_DEVBUF);
sc->vtpci_msix_vq_interrupts = NULL;
}
}
if (sc->vtpci_flags & (VTPCI_FLAG_MSI | VTPCI_FLAG_MSIX))
pci_release_msi(sc->vtpci_dev);
sc->vtpci_flags &= ~VTPCI_FLAG_ITYPE_MASK;
}
示例3: ppt_teardown_msix
static void
ppt_teardown_msix(struct pptdev *ppt)
{
int i;
if (ppt->msix.num_msgs == 0)
return;
for (i = 0; i < ppt->msix.num_msgs; i++)
ppt_teardown_msix_intr(ppt, i);
if (ppt->msix.msix_table_res) {
bus_release_resource(ppt->dev, SYS_RES_MEMORY,
ppt->msix.msix_table_rid,
ppt->msix.msix_table_res);
ppt->msix.msix_table_res = NULL;
ppt->msix.msix_table_rid = 0;
}
free(ppt->msix.res, M_PPTMSIX);
free(ppt->msix.cookie, M_PPTMSIX);
free(ppt->msix.arg, M_PPTMSIX);
pci_release_msi(ppt->dev);
ppt->msix.num_msgs = 0;
}
示例4: ppt_teardown_msi
static void
ppt_teardown_msi(struct pptdev *ppt)
{
int i, rid;
void *cookie;
struct resource *res;
if (ppt->msi.num_msgs == 0)
return;
for (i = 0; i < ppt->msi.num_msgs; i++) {
rid = ppt->msi.startrid + i;
res = ppt->msi.res[i];
cookie = ppt->msi.cookie[i];
if (cookie != NULL)
bus_teardown_intr(ppt->dev, res, cookie);
if (res != NULL)
bus_release_resource(ppt->dev, SYS_RES_IRQ, rid, res);
ppt->msi.res[i] = NULL;
ppt->msi.cookie[i] = NULL;
}
if (ppt->msi.startrid == 1)
pci_release_msi(ppt->dev);
ppt->msi.num_msgs = 0;
}
示例5: ig4iic_pci_detach
static
int
ig4iic_pci_detach(device_t dev)
{
ig4iic_softc_t *sc = device_get_softc(dev);
int error;
if (sc->pci_attached) {
error = ig4iic_detach(sc);
if (error)
return error;
sc->pci_attached = 0;
}
if (sc->intr_res) {
bus_release_resource(dev, SYS_RES_IRQ,
sc->intr_rid, sc->intr_res);
sc->intr_res = NULL;
}
if (sc->intr_type == PCI_INTR_TYPE_MSI)
pci_release_msi(dev);
if (sc->regs_res) {
bus_release_resource(dev, SYS_RES_MEMORY,
sc->regs_rid, sc->regs_res);
sc->regs_res = NULL;
}
sc->regs_t = 0;
sc->regs_h = 0;
lockuninit(&sc->lk);
return 0;
}
示例6: rtwn_pci_detach
static int
rtwn_pci_detach(device_t dev)
{
struct rtwn_pci_softc *pc = device_get_softc(dev);
struct rtwn_softc *sc = &pc->pc_sc;
int i;
/* Generic detach. */
rtwn_detach(sc);
/* Uninstall interrupt handler. */
if (pc->irq != NULL) {
bus_teardown_intr(dev, pc->irq, pc->pc_ih);
bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(pc->irq),
pc->irq);
pci_release_msi(dev);
}
/* Free Tx/Rx buffers. */
for (i = 0; i < RTWN_PCI_NTXQUEUES; i++)
rtwn_pci_free_tx_list(sc, i);
rtwn_pci_free_rx_list(sc);
if (pc->mem != NULL)
bus_release_resource(dev, SYS_RES_MEMORY,
rman_get_rid(pc->mem), pc->mem);
rtwn_detach_private(sc);
mtx_destroy(&sc->sc_mtx);
return (0);
}
示例7: vtpci_alloc_msix
static int
vtpci_alloc_msix(struct vtpci_softc *sc, int nvectors)
{
device_t dev;
int nmsix, cnt, required;
dev = sc->vtpci_dev;
/* Allocate an additional vector for the config changes. */
required = nvectors + 1;
nmsix = pci_msix_count(dev);
if (nmsix < required)
return (1);
cnt = required;
if (pci_alloc_msix(dev, &cnt) == 0 && cnt >= required) {
sc->vtpci_nmsix_resources = required;
return (0);
}
pci_release_msi(dev);
return (1);
}
示例8: ata_pci_detach
int
ata_pci_detach(device_t dev)
{
struct ata_pci_controller *ctlr = device_get_softc(dev);
/* detach & delete all children */
device_delete_children(dev);
if (ctlr->r_irq) {
bus_teardown_intr(dev, ctlr->r_irq, ctlr->handle);
bus_release_resource(dev, SYS_RES_IRQ, ctlr->r_irq_rid, ctlr->r_irq);
if (ctlr->r_irq_rid != ATA_IRQ_RID)
pci_release_msi(dev);
}
if (ctlr->chipdeinit != NULL)
ctlr->chipdeinit(dev);
if (ctlr->r_res2) {
#ifdef __sparc64__
bus_space_unmap(rman_get_bustag(ctlr->r_res2),
rman_get_bushandle(ctlr->r_res2), rman_get_size(ctlr->r_res2));
#endif
bus_release_resource(dev, ctlr->r_type2, ctlr->r_rid2, ctlr->r_res2);
}
if (ctlr->r_res1) {
#ifdef __sparc64__
bus_space_unmap(rman_get_bustag(ctlr->r_res1),
rman_get_bushandle(ctlr->r_res1), rman_get_size(ctlr->r_res1));
#endif
bus_release_resource(dev, ctlr->r_type1, ctlr->r_rid1, ctlr->r_res1);
}
return 0;
}
示例9: malo_pci_detach
static int
malo_pci_detach(device_t dev)
{
int i;
struct malo_pci_softc *psc = device_get_softc(dev);
struct malo_softc *sc = &psc->malo_sc;
/* check if device was removed */
sc->malo_invalid = !bus_child_present(dev);
malo_detach(sc);
bus_generic_detach(dev);
if (psc->malo_msi == 0)
bus_teardown_intr(dev, psc->malo_res_irq[0],
psc->malo_intrhand[0]);
else {
for (i = 0; i < MALO_MSI_MESSAGES; i++)
bus_teardown_intr(dev, psc->malo_res_irq[i],
psc->malo_intrhand[i]);
pci_release_msi(dev);
}
bus_release_resources(dev, psc->malo_irq_spec, psc->malo_res_irq);
bus_dma_tag_destroy(sc->malo_dmat);
bus_release_resources(dev, psc->malo_mem_spec, psc->malo_res_mem);
return (0);
}
示例10: ath10k_pci_free_irq
static void ath10k_pci_free_irq(struct ath10k_pci *ar_pci)
{
struct ath10k *ar = &ar_pci->sc_sc;
device_t dev = ar->sc_dev;
int i;
if (ar_pci->num_msi_intrs >= 1) {
/* MSI/MSIX */
for (i = 0; i < ar_pci->num_msi_intrs; i++) {
if (ar_pci->sc_ih[i] != NULL)
bus_teardown_intr(dev, ar_pci->sc_irq[i],
ar_pci->sc_ih[i]);
if (ar_pci->sc_irq[i] != NULL)
bus_release_resource(dev, SYS_RES_IRQ, i + 1,
ar_pci->sc_irq[i]);
}
pci_release_msi(dev);
} else {
/* Legacy */
if (ar_pci->sc_ih[0] != NULL)
bus_teardown_intr(dev, ar_pci->sc_irq[0], ar_pci->sc_ih[0]);
if (ar_pci->sc_irq[0] != NULL)
bus_release_resource(dev, SYS_RES_IRQ, 0,
ar_pci->sc_irq[0]);
}
}
示例11: bhndb_pci_detach
static int
bhndb_pci_detach(device_t dev)
{
struct bhndb_pci_softc *sc;
int error;
sc = device_get_softc(dev);
/* Attempt to detach our children */
if ((error = bus_generic_detach(dev)))
return (error);
/* Perform generic bridge detach */
if ((error = bhndb_generic_detach(dev)))
return (error);
/* Disable clocks (if required by this hardware) */
if ((error = bhndb_disable_pci_clocks(sc->dev)))
return (error);
/* Free our interrupt resources */
bhndb_free_intr_isrc(sc->isrc);
/* Release MSI interrupts */
if (sc->msi_count > 0)
pci_release_msi(sc->parent);
/* Disable PCI bus mastering */
pci_disable_busmaster(sc->parent);
BHNDB_PCI_LOCK_DESTROY(sc);
return (0);
}
示例12: bhndb_pci_alloc_msi
/**
* Attempt to allocate MSI interrupts, returning the count in @p msi_count
* on success.
*/
static int
bhndb_pci_alloc_msi(struct bhndb_pci_softc *sc, int *msi_count)
{
int error, count;
/* Is MSI available? */
if (pci_msi_count(sc->parent) < BHNDB_PCI_MSI_COUNT)
return (ENXIO);
/* Allocate expected message count */
count = BHNDB_PCI_MSI_COUNT;
if ((error = pci_alloc_msi(sc->parent, &count))) {
device_printf(sc->dev, "failed to allocate MSI interrupts: "
"%d\n", error);
return (error);
}
if (count < BHNDB_PCI_MSI_COUNT) {
pci_release_msi(sc->parent);
return (ENXIO);
}
*msi_count = count;
return (0);
}
示例13: mpr_pci_free
static void
mpr_pci_free(struct mpr_softc *sc)
{
int i;
if (sc->mpr_parent_dmat != NULL) {
bus_dma_tag_destroy(sc->mpr_parent_dmat);
}
if (sc->mpr_flags & MPR_FLAGS_MSI) {
for (i = 0; i < MPR_MSI_COUNT; i++) {
if (sc->mpr_irq[i] != NULL) {
bus_teardown_intr(sc->mpr_dev, sc->mpr_irq[i],
sc->mpr_intrhand[i]);
bus_release_resource(sc->mpr_dev, SYS_RES_IRQ,
sc->mpr_irq_rid[i], sc->mpr_irq[i]);
}
}
pci_release_msi(sc->mpr_dev);
}
if (sc->mpr_flags & MPR_FLAGS_INTX) {
bus_teardown_intr(sc->mpr_dev, sc->mpr_irq[0],
sc->mpr_intrhand[0]);
bus_release_resource(sc->mpr_dev, SYS_RES_IRQ,
sc->mpr_irq_rid[0], sc->mpr_irq[0]);
}
if (sc->mpr_regs_resource != NULL) {
bus_release_resource(sc->mpr_dev, SYS_RES_MEMORY,
sc->mpr_regs_rid, sc->mpr_regs_resource);
}
return;
}
示例14: mpt_free_bus_resources
/*
* Free bus resources
*/
static void
mpt_free_bus_resources(struct mpt_softc *mpt)
{
if (mpt->ih) {
bus_teardown_intr(mpt->dev, mpt->pci_irq, mpt->ih);
mpt->ih = NULL;
}
if (mpt->pci_irq) {
bus_release_resource(mpt->dev, SYS_RES_IRQ,
rman_get_rid(mpt->pci_irq), mpt->pci_irq);
mpt->pci_irq = NULL;
}
if (mpt->pci_msi_count) {
pci_release_msi(mpt->dev);
mpt->pci_msi_count = 0;
}
if (mpt->pci_pio_reg) {
bus_release_resource(mpt->dev, SYS_RES_IOPORT,
rman_get_rid(mpt->pci_pio_reg), mpt->pci_pio_reg);
mpt->pci_pio_reg = NULL;
}
if (mpt->pci_reg) {
bus_release_resource(mpt->dev, SYS_RES_MEMORY,
rman_get_rid(mpt->pci_reg), mpt->pci_reg);
mpt->pci_reg = NULL;
}
MPT_LOCK_DESTROY(mpt);
}
示例15: ntb_setup_interrupts
static int
ntb_setup_interrupts(struct ntb_softc *ntb)
{
uint32_t desired_vectors, num_vectors;
uint64_t mask;
int rc;
ntb->allocated_interrupts = 0;
/*
* On SOC, disable all interrupts. On XEON, disable all but Link
* Interrupt. The rest will be unmasked as callbacks are registered.
*/
mask = 0;
if (ntb->type == NTB_XEON)
mask = (1 << XEON_LINK_DB);
db_iowrite(ntb, ntb->reg_ofs.ldb_mask, ~mask);
num_vectors = desired_vectors = MIN(pci_msix_count(ntb->device),
ntb->limits.max_db_bits);
if (desired_vectors >= 1) {
rc = pci_alloc_msix(ntb->device, &num_vectors);
if (ntb_force_remap_mode != 0 && rc == 0 &&
num_vectors == desired_vectors)
num_vectors--;
if (rc == 0 && num_vectors < desired_vectors) {
rc = ntb_remap_msix(ntb->device, desired_vectors,
num_vectors);
if (rc == 0)
num_vectors = desired_vectors;
else
pci_release_msi(ntb->device);
}
if (rc != 0)
num_vectors = 1;
} else
num_vectors = 1;
ntb_create_callbacks(ntb, num_vectors);
if (ntb->type == NTB_XEON)
rc = ntb_setup_xeon_msix(ntb, num_vectors);
else
rc = ntb_setup_soc_msix(ntb, num_vectors);
if (rc != 0)
device_printf(ntb->device,
"Error allocating MSI-X interrupts: %d\n", rc);
if (ntb->type == NTB_XEON && rc == ENOSPC)
rc = ntb_setup_legacy_interrupt(ntb);
return (rc);
}