media: atomisp: Remove loading mutex
authorHans de Goede <hdegoede@redhat.com>
Mon, 29 Aug 2022 10:30:08 +0000 (12:30 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 24 Sep 2022 08:00:07 +0000 (10:00 +0200)
Now that the registering of the /dev/* video / subdev nodes has been
moved to the end of atomisp_pci_probe() the workaround with the loading
mutex to delay opens until init is done is no longer necessary.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_fops.c
drivers/staging/media/atomisp/pci/atomisp_internal.h
drivers/staging/media/atomisp/pci/atomisp_v4l2.c

index 3fa3c28..6518e6d 100644 (file)
@@ -707,29 +707,13 @@ static int atomisp_open(struct file *file)
 
        dev_dbg(isp->dev, "open device %s\n", vdev->name);
 
-       /*
-        * Ensure that if we are still loading we block. Once the loading
-        * is over we can proceed. We can't blindly hold the lock until
-        * that occurs as if the load fails we'll deadlock the unload
-        */
-       rt_mutex_lock(&isp->loading);
-       /*
-        * FIXME: revisit this with a better check once the code structure
-        * is cleaned up a bit more
-        */
        ret = v4l2_fh_open(file);
        if (ret) {
                dev_err(isp->dev,
                        "%s: v4l2_fh_open() returned error %d\n",
                       __func__, ret);
-               rt_mutex_unlock(&isp->loading);
                return ret;
        }
-       if (!isp->ready) {
-               rt_mutex_unlock(&isp->loading);
-               return -ENXIO;
-       }
-       rt_mutex_unlock(&isp->loading);
 
        rt_mutex_lock(&isp->mutex);
 
index e299304..fc7bd87 100644 (file)
@@ -240,13 +240,6 @@ struct atomisp_device {
         * structures and css API calls. */
        struct rt_mutex mutex;
        /*
-        * This mutex ensures that we don't allow an open to succeed while
-        * the initialization process is incomplete
-        */
-       struct rt_mutex loading;
-       /* Set once the ISP is ready to allow opens */
-       bool ready;
-       /*
         * Serialise streamoff: mutex is dropped during streamoff to
         * cancel the watchdog queue. MUST be acquired BEFORE
         * "mutex".
index f819a69..4d73bf3 100644 (file)
@@ -1515,7 +1515,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
        dev_dbg(&pdev->dev, "atomisp mmio base: %p\n", isp->base);
 
        rt_mutex_init(&isp->mutex);
-       rt_mutex_init(&isp->loading);
        mutex_init(&isp->streamoff_mutex);
        spin_lock_init(&isp->lock);
 
@@ -1688,8 +1687,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
                pci_write_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, csi_afe_trim);
        }
 
-       rt_mutex_lock(&isp->loading);
-
        err = atomisp_initialize_modules(isp);
        if (err < 0) {
                dev_err(&pdev->dev, "atomisp_initialize_modules (%d)\n", err);
@@ -1737,9 +1734,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
        release_firmware(isp->firmware);
        isp->firmware = NULL;
        isp->css_env.isp_css_fw.data = NULL;
-       isp->ready = true;
-
-       rt_mutex_unlock(&isp->loading);
 
        err = atomisp_register_device_nodes(isp);
        if (err)
@@ -1760,7 +1754,6 @@ wdt_work_queue_fail:
 register_entities_fail:
        atomisp_uninitialize_modules(isp);
 initialize_modules_fail:
-       rt_mutex_unlock(&isp->loading);
        cpu_latency_qos_remove_request(&isp->pm_qos);
        atomisp_msi_irq_uninit(isp);
        pci_free_irq_vectors(pdev);