lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <611fc99e-c947-463a-82e1-9d2a68d67aa4@acm.org>
Date: Tue, 29 Oct 2024 11:11:12 -0700
From: Bart Van Assche <bvanassche@....org>
To: Avri Altman <avri.altman@....com>,
 "Martin K . Petersen" <martin.petersen@...cle.com>
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] scsi: ufs: core: Introduce a new clock_gating lock

On 10/29/24 3:29 AM, Avri Altman wrote:
> +	scoped_guard(spinlock_irqsave, &hba->clk_gating.lock) {
> +		/*
> +		 * In case you are here to cancel this work the gating state
> +		 * would be marked as REQ_CLKS_ON. In this case save time by
> +		 * skipping the gating work and exit after changing the clock
> +		 * state to CLKS_ON.
> +		 */
> +		if (hba->clk_gating.is_suspended || (hba->clk_gating.state != REQ_CLKS_OFF)) {
> +			hba->clk_gating.state = CLKS_ON;
> +			trace_ufshcd_clk_gating(dev_name(hba->dev), hba->clk_gating.state);
> +			return;
> +		}
> +		if (ufshcd_is_ufs_dev_busy(hba) || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL)
> +			return;
>   	}

Please remove the superfluous parentheses from around the REQ_CLKS_OFF 
test and do not exceed the 80 column limit. git clang-format HEAD^ can
help with restricting code to the 80 column limit.

> @@ -2072,18 +2055,18 @@ static ssize_t ufshcd_clkgate_enable_store(struct device *dev,
>   
>   	value = !!value;
>   
> -	spin_lock_irqsave(hba->host->host_lock, flags);
> -	if (value == hba->clk_gating.is_enabled)
> -		goto out;
> +	scoped_guard(spinlock_irqsave, &hba->clk_gating.lock) {
> +		if (value == hba->clk_gating.is_enabled)
> +			goto out;
>   
> -	if (value)
> -		__ufshcd_release(hba);
> -	else
> -		hba->clk_gating.active_reqs++;
> +		if (value)
> +			__ufshcd_release(hba);
> +		else
> +			hba->clk_gating.active_reqs++;
>   
> -	hba->clk_gating.is_enabled = value;
> +		hba->clk_gating.is_enabled = value;
> +	}
>   out:
> -	spin_unlock_irqrestore(hba->host->host_lock, flags);
>   	return count;
>   }

Please use guard() instead of scoped_guard() and remove the "out:"
label.

> @@ -9173,11 +9157,10 @@ static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on)
>   				clk_disable_unprepare(clki->clk);
>   		}
>   	} else if (!ret && on) {
> -		spin_lock_irqsave(hba->host->host_lock, flags);
> -		hba->clk_gating.state = CLKS_ON;
> +		scoped_guard(spinlock_irqsave, &hba->clk_gating.lock)
> +			hba->clk_gating.state = CLKS_ON;
>   		trace_ufshcd_clk_gating(dev_name(hba->dev),
>   					hba->clk_gating.state);
> -		spin_unlock_irqrestore(hba->host->host_lock, flags);
>   	}

The above change moves the trace_ufshcd_clk_gating() call from inside
the region protected by the host lock to outside the region protected
by clk_gating.lock. If this is intentional, shouldn't this be mentioned
in the patch description?

Thanks,

Bart.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ