[PATCH v2 07/13] iommufd/viommu: Add iommufd_viommu_report_irq helper
Tian, Kevin
kevin.tian at intel.com
Wed Dec 11 00:05:45 PST 2024
> From: Nicolin Chen <nicolinc at nvidia.com>
> Sent: Wednesday, December 4, 2024 6:10 AM
>
> +/* Typically called in driver's threaded IRQ handler */
> +int iommufd_viommu_report_irq(struct iommufd_viommu *viommu,
> unsigned int type,
> + void *irq_ptr, size_t irq_len)
> +{
> + struct iommufd_eventq_virq *eventq_virq;
> + struct iommufd_virq *virq;
> + int rc = 0;
> +
> + might_sleep();
why is it required here but not in the iopf path?
> +
> + if (!viommu)
> + return -ENODEV;
> + if (WARN_ON_ONCE(!irq_len || !irq_ptr))
> + return -EINVAL;
> +
> + down_read(&viommu->virqs_rwsem);
> +
> + eventq_virq = iommufd_viommu_find_eventq_virq(viommu, type);
> + if (!eventq_virq) {
> + rc = -EOPNOTSUPP;
> + goto out_unlock_vdev_ids;
s/out_unlock_vdev_ids/out_unlock_virqs/
> + }
> +
> + virq = kzalloc(sizeof(*virq) + irq_len, GFP_KERNEL);
> + if (!virq) {
> + rc = -ENOMEM;
> + goto out_unlock_vdev_ids;
> + }
> + virq->irq_data = (void *)virq + sizeof(*virq);
> + memcpy(virq->irq_data, irq_ptr, irq_len);
> +
> + virq->eventq_virq = eventq_virq;
> + virq->irq_len = irq_len;
> +
> + iommufd_eventq_virq_handler(virq);
> +out_unlock_vdev_ids:
> + up_read(&viommu->virqs_rwsem);
> + return rc;
> +}
> +EXPORT_SYMBOL_NS_GPL(iommufd_viommu_report_irq, IOMMUFD);
> +
> MODULE_DESCRIPTION("iommufd code shared with builtin modules");
> MODULE_LICENSE("GPL");
> --
> 2.43.0
More information about the linux-arm-kernel
mailing list