MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gicv3_its_alloc_msi

Function gicv3_its_alloc_msi

freebsd/arm64/arm64/gicv3_its.c:1271–1328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1269}
1270
1271static int
1272gicv3_its_alloc_msi(device_t dev, device_t child, int count, int maxcount,
1273 device_t *pic, struct intr_irqsrc **srcs)
1274{
1275 struct gicv3_its_softc *sc;
1276 struct gicv3_its_irqsrc *girq;
1277 struct its_dev *its_dev;
1278 u_int irq;
1279 int i;
1280
1281 its_dev = its_device_get(dev, child, count);
1282 if (its_dev == NULL)
1283 return (ENXIO);
1284
1285 KASSERT(its_dev->lpis.lpi_free >= count,
1286 ("gicv3_its_alloc_msi: No free LPIs"));
1287 sc = device_get_softc(dev);
1288 irq = its_dev->lpis.lpi_base + its_dev->lpis.lpi_num -
1289 its_dev->lpis.lpi_free;
1290
1291 /* Allocate the irqsrc for each MSI */
1292 for (i = 0; i < count; i++, irq++) {
1293 its_dev->lpis.lpi_free--;
1294 srcs[i] = (struct intr_irqsrc *)gicv3_its_alloc_irqsrc(dev,
1295 sc, irq);
1296 if (srcs[i] == NULL)
1297 break;
1298 }
1299
1300 /* The allocation failed, release them */
1301 if (i != count) {
1302 mtx_lock_spin(&sc->sc_its_dev_lock);
1303 for (i = 0; i < count; i++) {
1304 girq = (struct gicv3_its_irqsrc *)srcs[i];
1305 if (girq == NULL)
1306 break;
1307 gicv3_its_release_irqsrc(sc, girq);
1308 srcs[i] = NULL;
1309 }
1310 mtx_unlock_spin(&sc->sc_its_dev_lock);
1311 return (ENXIO);
1312 }
1313
1314 /* Finish the allocation now we have all MSI irqsrcs */
1315 for (i = 0; i < count; i++) {
1316 girq = (struct gicv3_its_irqsrc *)srcs[i];
1317 girq->gi_id = i;
1318 girq->gi_its_dev = its_dev;
1319
1320 /* Map the message to the given IRQ */
1321 gicv3_its_select_cpu(dev, (struct intr_irqsrc *)girq);
1322 its_cmd_mapti(dev, girq);
1323 }
1324 its_dev->lpis.lpi_busy += count;
1325 *pic = dev;
1326
1327 return (0);
1328}

Callers

nothing calls this directly

Calls 6

its_device_getFunction · 0.85
device_get_softcFunction · 0.85
gicv3_its_alloc_irqsrcFunction · 0.85
gicv3_its_release_irqsrcFunction · 0.85
gicv3_its_select_cpuFunction · 0.85
its_cmd_maptiFunction · 0.85

Tested by

no test coverage detected