/** * fsl_create_mc_io() - Creates an MC I/O object * * @dev: device to be associated with the MC I/O object * @mc_portal_phys_addr: physical address of the MC portal to use * @mc_portal_size: size in bytes of the MC portal * @dpmcp_dev: Pointer to the DPMCP object associated with this MC I/O * object or NULL if none. * @flags: flags for the new MC I/O object * @new_mc_io: Area to return pointer to newly created MC I/O object * * Returns '0' on Success; Error code otherwise.
*/ int __must_check fsl_create_mc_io(struct device *dev,
phys_addr_t mc_portal_phys_addr,
u32 mc_portal_size, struct fsl_mc_device *dpmcp_dev,
u32 flags, struct fsl_mc_io **new_mc_io)
{ int error; struct fsl_mc_io *mc_io; void __iomem *mc_portal_virt_addr; struct resource *res;
mc_io = devm_kzalloc(dev, sizeof(*mc_io), GFP_KERNEL); if (!mc_io) return -ENOMEM;
res = devm_request_mem_region(dev,
mc_portal_phys_addr,
mc_portal_size, "mc_portal"); if (!res) {
dev_err(dev, "devm_request_mem_region failed for MC portal %pa\n",
&mc_portal_phys_addr); return -EBUSY;
}
mc_portal_virt_addr = devm_ioremap(dev,
mc_portal_phys_addr,
mc_portal_size); if (!mc_portal_virt_addr) {
dev_err(dev, "devm_ioremap failed for MC portal %pa\n",
&mc_portal_phys_addr); return -ENXIO;
}
mc_io->portal_virt_addr = mc_portal_virt_addr; if (dpmcp_dev) {
error = fsl_mc_io_set_dpmcp(mc_io, dpmcp_dev); if (error < 0) goto error_destroy_mc_io;
}
/** * fsl_mc_portal_allocate - Allocates an MC portal * * @mc_dev: MC device for which the MC portal is to be allocated * @mc_io_flags: Flags for the fsl_mc_io object that wraps the allocated * MC portal. * @new_mc_io: Pointer to area where the pointer to the fsl_mc_io object * that wraps the allocated MC portal is to be returned * * This function allocates an MC portal from the device's parent DPRC, * from the corresponding MC bus' pool of MC portals and wraps * it in a new fsl_mc_io object. If 'mc_dev' is a DPRC itself, the * portal is allocated from its own MC bus.
*/ int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
u16 mc_io_flags, struct fsl_mc_io **new_mc_io)
{ struct fsl_mc_device *mc_bus_dev; struct fsl_mc_bus *mc_bus;
phys_addr_t mc_portal_phys_addr;
size_t mc_portal_size; struct fsl_mc_device *dpmcp_dev; int error = -EINVAL; struct fsl_mc_resource *resource = NULL; struct fsl_mc_io *mc_io = NULL;
if (mc_dev->flags & FSL_MC_IS_DPRC) {
mc_bus_dev = mc_dev;
} else { if (!dev_is_fsl_mc(mc_dev->dev.parent)) return error;
/* If the DPRC device itself tries to allocate a portal (usually for * UAPI interaction), don't add a device link between them since the * DPMCP device is an actual child device of the DPRC and a reverse * dependency is not allowed.
*/ if (mc_dev != mc_bus_dev) {
dpmcp_dev->consumer_link = device_link_add(&mc_dev->dev,
&dpmcp_dev->dev,
DL_FLAG_AUTOREMOVE_CONSUMER); if (!dpmcp_dev->consumer_link) {
error = -EINVAL; goto error_cleanup_mc_io;
}
}
/** * fsl_mc_portal_free - Returns an MC portal to the pool of free MC portals * of a given MC bus * * @mc_io: Pointer to the fsl_mc_io object that wraps the MC portal to free
*/ void fsl_mc_portal_free(struct fsl_mc_io *mc_io)
{ struct fsl_mc_device *dpmcp_dev; struct fsl_mc_resource *resource;
/* * Every mc_io obtained by calling fsl_mc_portal_allocate() is supposed * to have a DPMCP object associated with.
*/
dpmcp_dev = mc_io->dpmcp_dev;
resource = dpmcp_dev->resource; if (!resource || resource->type != FSL_MC_POOL_DPMCP) return;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.