mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 15:02:32 +00:00
cddd459140
Add patches for linux-5.4. The patches are from NXP LSDK-20.04 release which was tagged LSDK-20.04-V5.4. https://source.codeaurora.org/external/qoriq/qoriq-components/linux/ For boards LS1021A-IOT, and Traverse-LS1043 which are not involved in LSDK, port the dts patches from 4.14. The patches are sorted into the following categories: 301-arch-xxxx 302-dts-xxxx 303-core-xxxx 701-net-xxxx 801-audio-xxxx 802-can-xxxx 803-clock-xxxx 804-crypto-xxxx 805-display-xxxx 806-dma-xxxx 807-gpio-xxxx 808-i2c-xxxx 809-jailhouse-xxxx 810-keys-xxxx 811-kvm-xxxx 812-pcie-xxxx 813-pm-xxxx 814-qe-xxxx 815-sata-xxxx 816-sdhc-xxxx 817-spi-xxxx 818-thermal-xxxx 819-uart-xxxx 820-usb-xxxx 821-vfio-xxxx Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
141 lines
3.8 KiB
Diff
141 lines
3.8 KiB
Diff
From a309870f6fa4a9f69ca7490b355d147b0caeffd0 Mon Sep 17 00:00:00 2001
|
|
From: Diana Craciun <diana.craciun@nxp.com>
|
|
Date: Fri, 13 Sep 2019 17:20:35 +0300
|
|
Subject: [PATCH] vfio/fsl-mc: Scan DPRC objects on vfio-fsl-mc driver bind
|
|
|
|
The DPRC(Data Path Resource Container) device is a bus device and has
|
|
child devices attached to it. When the vfio-fsl-mc driver is probed
|
|
the DPRC is scanned and the child devices discovered and initialized.
|
|
|
|
Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
|
|
Signed-off-by: Diana Craciun <diana.craciun@nxp.com>
|
|
---
|
|
drivers/vfio/fsl-mc/vfio_fsl_mc.c | 99 +++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 99 insertions(+)
|
|
|
|
--- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
|
|
+++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
|
|
@@ -74,7 +74,75 @@ static int vfio_fsl_mc_mmap(void *device
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
+static int vfio_fsl_mc_init_device(struct vfio_fsl_mc_device *vdev)
|
|
+{
|
|
+ struct fsl_mc_device *mc_dev = vdev->mc_dev;
|
|
+ struct fsl_mc_bus *mc_bus;
|
|
+ size_t region_size;
|
|
+ int ret = 0;
|
|
+ unsigned int irq_count;
|
|
+
|
|
+ /* Non-dprc devices share mc_io from parent */
|
|
+ if (!is_fsl_mc_bus_dprc(mc_dev)) {
|
|
+ struct fsl_mc_device *mc_cont = to_fsl_mc_device(mc_dev->dev.parent);
|
|
+
|
|
+ mc_dev->mc_io = mc_cont->mc_io;
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ /* Use dprc mc-portal for interaction with MC f/w. */
|
|
+ region_size = resource_size(mc_dev->regions);
|
|
+ ret = fsl_create_mc_io(&mc_dev->dev,
|
|
+ mc_dev->regions[0].start,
|
|
+ region_size,
|
|
+ NULL,
|
|
+ FSL_MC_IO_ATOMIC_CONTEXT_PORTAL,
|
|
+ &mc_dev->mc_io);
|
|
+ if (ret < 0) {
|
|
+ dev_err(&mc_dev->dev, "failed to create mc-io (error = %d)\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+ ret = dprc_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id,
|
|
+ &mc_dev->mc_handle);
|
|
+ if (ret < 0) {
|
|
+ dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", ret);
|
|
+ goto clean_mc_io;
|
|
+ }
|
|
|
|
+ mc_bus = to_fsl_mc_bus(mc_dev);
|
|
+ /* initialize resource pools */
|
|
+ fsl_mc_init_all_resource_pools(mc_dev);
|
|
+
|
|
+ mutex_init(&mc_bus->scan_mutex);
|
|
+
|
|
+ mutex_lock(&mc_bus->scan_mutex);
|
|
+ ret = dprc_scan_objects(mc_dev, mc_dev->driver_override, false,
|
|
+ &irq_count);
|
|
+ mutex_unlock(&mc_bus->scan_mutex);
|
|
+
|
|
+ if (ret < 0) {
|
|
+ dev_err(&mc_dev->dev, "dprc_scan_objects() failed: %d\n", ret);
|
|
+ goto clean_resource_pool;
|
|
+ }
|
|
+
|
|
+ if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) {
|
|
+ dev_warn(&mc_dev->dev,
|
|
+ "IRQs needed (%u) exceed IRQs preallocated (%u)\n",
|
|
+ irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
|
|
+ }
|
|
+
|
|
+return 0;
|
|
+
|
|
+clean_resource_pool:
|
|
+ fsl_mc_cleanup_all_resource_pools(mc_dev);
|
|
+ dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
|
|
+
|
|
+clean_mc_io:
|
|
+ fsl_destroy_mc_io(mc_dev->mc_io);
|
|
+ mc_dev->mc_io = NULL;
|
|
+
|
|
+ return ret;
|
|
+}
|
|
static const struct vfio_device_ops vfio_fsl_mc_ops = {
|
|
.name = "vfio-fsl-mc",
|
|
.open = vfio_fsl_mc_open,
|
|
@@ -113,8 +181,34 @@ static int vfio_fsl_mc_probe(struct fsl_
|
|
return ret;
|
|
}
|
|
|
|
+ ret = vfio_fsl_mc_init_device(vdev);
|
|
+ if (ret) {
|
|
+ vfio_iommu_group_put(group, dev);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
return ret;
|
|
}
|
|
+static int vfio_fsl_mc_device_remove(struct device *dev, void *data)
|
|
+{
|
|
+ struct fsl_mc_device *mc_dev;
|
|
+
|
|
+ WARN_ON(dev == NULL);
|
|
+ mc_dev = to_fsl_mc_device(dev);
|
|
+ if (WARN_ON(mc_dev == NULL))
|
|
+ return -ENODEV;
|
|
+ fsl_mc_device_remove(mc_dev);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static void vfio_fsl_mc_cleanup_dprc(struct fsl_mc_device *mc_dev)
|
|
+{
|
|
+ device_for_each_child(&mc_dev->dev, NULL, vfio_fsl_mc_device_remove);
|
|
+ fsl_mc_cleanup_all_resource_pools(mc_dev);
|
|
+ dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
|
|
+ fsl_destroy_mc_io(mc_dev->mc_io);
|
|
+}
|
|
|
|
static int vfio_fsl_mc_remove(struct fsl_mc_device *mc_dev)
|
|
{
|
|
@@ -125,6 +219,11 @@ static int vfio_fsl_mc_remove(struct fsl
|
|
if (!vdev)
|
|
return -EINVAL;
|
|
|
|
+ if (is_fsl_mc_bus_dprc(mc_dev))
|
|
+ vfio_fsl_mc_cleanup_dprc(vdev->mc_dev);
|
|
+
|
|
+ mc_dev->mc_io = NULL;
|
|
+
|
|
vfio_iommu_group_put(mc_dev->dev.iommu_group, dev);
|
|
devm_kfree(dev, vdev);
|
|
|