mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Ruziev Miraly <miraly.dev@gmail.com>
Cc: hansg@kernel.org, mchehab@kernel.org, gregkh@linuxfoundation.org,
	andy@kernel.org, sakari.ailus@linux.intel.com,
	linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] media: atomisp: flatten pre_power_down logic and clean up staging code
Date: Sun, 5 Jul 2026 09:46:54 +0300	[thread overview]
Message-ID: <akn93mYvptws9heK@ashevche-desk.local> (raw)
In-Reply-To: <20260704190854.114172-1-miraly.dev@gmail.com>

On Sun, Jul 05, 2026 at 12:08:54AM +0500, Ruziev Miraly wrote:
> Refactor atomisp_mrfld_pre_power_down() by removing the redundant
> nested 'else' block, making the function structure linear and easier
> to follow.

I don't see this. There is no 'else' removal, what did I miss?

> Keep both error logging branches intact to ensure consistency
> in hardware failure reporting.
> 
> In addition, fix minor checkpatch.pl style warnings in the same file
> regarding code alignment and hanging open parentheses.

These are a few things that probably need to be split to different patches.

...

>  	struct pci_dev *pdev = to_pci_dev(isp->dev);
>  	u32 irq;
>  	unsigned long flags;
> +	int ret = 0;

Don't do like this. It makes code harder to maintain and prone to mistakes.

>  	spin_lock_irqsave(&isp->lock, flags);
>  
>  	/*
>  	 * MRFLD HAS requirement: cannot power off i-unit if
>  	 * ISP has IRQ not serviced.
> -	 * So, here we need to check if there is any pending
> -	 * IRQ, if so, waiting for it to be served
> +	 * Wait for pending IRQs to be served.
>  	 */

Hmm... Why is this wording changed?

>  	pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
>  	if (!(irq & BIT(INTR_IIR)))
> -		goto done;
> +		goto power_down;
>  
> +	/* Clear and check interrupt status registers */
>  	atomisp_css2_hw_store_32(MRFLD_INTR_CLEAR_REG, 0xFFFFFFFF);
>  	atomisp_load_uint32(MRFLD_INTR_STATUS_REG, &irq);
> +
>  	if (irq != 0) {
>  		dev_err(isp->dev,
>  			"%s: fail to clear isp interrupt status reg=0x%x\n",
>  			__func__, irq);
> -		spin_unlock_irqrestore(&isp->lock, flags);
> -		return -EAGAIN;
> +		ret = -EAGAIN;
> +		goto unlock_exit;
>  	}
> +
>  	pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
>  	irq &= BIT(INTR_IIR);
>  	pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, irq);
>  
>  	pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
> -	if (!(irq & BIT(INTR_IIR))) {
> -		atomisp_css2_hw_store_32(MRFLD_INTR_ENABLE_REG, 0x0);
> -		goto done;
> +	if (irq & BIT(INTR_IIR)) {
> +		dev_err(isp->dev,
> +			"%s: error in iunit interrupt. status reg=0x%x\n",
> +			__func__, irq);
> +		ret = -EAGAIN;
> +		goto unlock_exit;
>  	}
> -	spin_unlock_irqrestore(&isp->lock, flags);
> -	return -EAGAIN;
> -done:
> +
> +	atomisp_css2_hw_store_32(MRFLD_INTR_ENABLE_REG, 0x0);
> +
> +power_down:
>  	/*
>  	 * MRFLD WORKAROUND:
>  	 * before powering off IUNIT, clear the pending interrupts
> @@ -490,9 +497,10 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
>  
>  	atomisp_msi_irq_uninit(isp);
>  	atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
> -	spin_unlock_irqrestore(&isp->lock, flags);
>  
> -	return 0;
> +unlock_exit:
> +	spin_unlock_irqrestore(&isp->lock, flags);
> +	return ret;
>  }

Are you sending an update on top of your v1?! You must use the same base for
the each version of the patches. The incremental changes in Git means something
different.

...

> @@ -839,7 +847,7 @@ static int atomisp_register_entities(struct atomisp_device *isp)
>  	/* Register internal entities */
>  	for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
>  		ret = atomisp_mipi_csi2_register_entities(&isp->csi2_port[i],
> -			&isp->v4l2_dev);
> +							  &isp->v4l2_dev);
>  		if (ret == 0)
>  			continue;

This change is not related. Split it.

...

> @@ -847,8 +855,7 @@ static int atomisp_register_entities(struct atomisp_device *isp)
>  		dev_err(isp->dev, "failed to register the CSI port: %d\n", i);
>  		/* deregister all registered CSI ports */
>  		while (i--)
> -			atomisp_mipi_csi2_unregister_entities(
> -			    &isp->csi2_port[i]);
> +			atomisp_mipi_csi2_unregister_entities(&isp->csi2_port[i]);
>  
>  		goto csi_and_subdev_probe_failed;
>  	}

As previous, should be in another patch.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-07-05  6:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-04 19:08 Ruziev Miraly
2026-07-05  6:46 ` Andy Shevchenko [this message]
2026-07-05  6:49 ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=akn93mYvptws9heK@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=miraly.dev@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®