Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp308677pxu; Fri, 11 Dec 2020 02:54:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzgVM3iy3ietZvDnj2bcWoE58Q7Z44w2SpI/5e3aMLORBDxhZb61MT67qF+KLVu8V0i/atF X-Received: by 2002:a17:907:720e:: with SMTP id dr14mr1362825ejc.303.1607684079695; Fri, 11 Dec 2020 02:54:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607684079; cv=none; d=google.com; s=arc-20160816; b=Z6zvko0hiGVjE2IJcZiAfQKsT6RRClAwqIkpmax7iVFtbSpbpjWTZa0ioa1DacyfE0 xQBp3hJIrSak4F1ghvo9Gf6IAQlmAev6sRPEgNR+NWas4Ljwy2u5TVnSuYUBiVLoo7+s so9Ka2OyMmf9HFy46e3nHTetx90I7JKKSZNjUVG4yPRN2QjukZmvyEz0gtXwxRbwisQA aRBNgi4Qy3ijtu+WSjJGSxj1f5KJmeM/E36nWmal2t9pXT5OVb/TsSzCYlLBhaBP+MyU aYsiP6WVI34Uw/vvjfc5mFRTf+giY2tRv/2k8m0V4JdV79cg0wG67KMbiXi5nT88cwuZ GMrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=cttgESEWFCsZorIB9/3597MAjlCoUbt49Ntrs4a/FsM=; b=wQsaRxtTKOTX55s+zQyrtqCPBcLW8BiA0ZJUDSch6V4RQIBcCeKr7jGl9odJ81Cwx9 /8BMvCmY0RMz88YwYOId1gUY9WdnWfQcyhvoyRdWn84pyt8uMTe31KfeNd0tWNabJ4f9 NWNQvupyDyV1GrOD8KK/8ZU349tAs/pcboGUxRYvh6LRMu8TqtCG0O95R9i62vraMZIh zYnCAGfG3+1DxHfaKch5lxYg3TlZGsIP39i9Mi4/3cQ2uw17eISNh9bnJYEFDP7GqwRR EinEtMmhpK+pbyfdP7cC23jBtYzJdtvUvuZo+USguqRbkrPabUqHFBu4eB5okn1Ok7Ye 79xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=hWPuVMjC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zc2si4472842ejb.427.2020.12.11.02.54.17; Fri, 11 Dec 2020 02:54:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=hWPuVMjC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394519AbgLKBMZ (ORCPT + 99 others); Thu, 10 Dec 2020 20:12:25 -0500 Received: from m43-15.mailgun.net ([69.72.43.15]:58660 "EHLO m43-15.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390314AbgLKBMX (ORCPT ); Thu, 10 Dec 2020 20:12:23 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1607649117; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=cttgESEWFCsZorIB9/3597MAjlCoUbt49Ntrs4a/FsM=; b=hWPuVMjCLQWAYx0PXKcxGQ9OM51NfOZviTkY1KHzPIRAGHyMfA+fPoS1fmCXAxTuNupx+pp0 dvQVkH8jP4rAWG1+3nWkGLSKWcYbAbIIxrKC+5MxGqSjm3WeB74tWlZyqrMJUFs8uY22nuzO tmjcrNwHfX/+c37WCIRmVsUYSbM= X-Mailgun-Sending-Ip: 69.72.43.15 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 5fd2c75df81e894c552807c9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 11 Dec 2020 01:11:57 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A61F5C43466; Fri, 11 Dec 2020 01:11:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id A2989C433C6; Fri, 11 Dec 2020 01:11:55 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 11 Dec 2020 09:11:55 +0800 From: Can Guo To: Bean Huo Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Bart Van Assche , Satya Tangirala , open list Subject: Re: [PATCH 2/2] scsi: ufs: Clean up ufshcd_exit_clk_scaling/gating() In-Reply-To: References: <1607520942-22254-1-git-send-email-cang@codeaurora.org> <1607520942-22254-3-git-send-email-cang@codeaurora.org> Message-ID: X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-12-11 02:03, Bean Huo wrote: > On Wed, 2020-12-09 at 05:35 -0800, Can Guo wrote: >> ufshcd_hba_exit() is always called after ufshcd_exit_clk_scaling() >> and >> ufshcd_exit_clk_gating(), so move ufshcd_exit_clk_scaling/gating() to >> ufshcd_hba_exit(). >> >> Signed-off-by: Can Guo >> >> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >> index 12266bd..41a12d6 100644 >> --- a/drivers/scsi/ufs/ufshcd.c >> +++ b/drivers/scsi/ufs/ufshcd.c >> @@ -1846,11 +1846,14 @@ static void ufshcd_init_clk_scaling(struct >> ufs_hba *hba) >> snprintf(wq_name, sizeof(wq_name), "ufs_clkscaling_%d", >> hba->host->host_no); >> hba->clk_scaling.workq = >> create_singlethread_workqueue(wq_name); >> + >> + hba->clk_scaling.is_initialized = true; >> } >> >> static void ufshcd_exit_clk_scaling(struct ufs_hba *hba) >> { >> - if (!ufshcd_is_clkscaling_supported(hba)) >> + if (!ufshcd_is_clkscaling_supported(hba) || >> + !hba->clk_scaling.is_initialized) >> return; >> >> if (hba->devfreq) >> @@ -1894,12 +1897,16 @@ static void ufshcd_init_clk_gating(struct >> ufs_hba *hba) >> hba->clk_gating.enable_attr.attr.mode = 0644; >> if (device_create_file(hba->dev, &hba- >> >clk_gating.enable_attr)) >> dev_err(hba->dev, "Failed to create sysfs for >> clkgate_enable\n"); >> + >> + hba->clk_gating.is_initialized = true; >> } > > you don't need these two is_initialized at all. they are only be false > when scaling/gating is not supported?? > > Bean In the case of scaling/gating are supported, the flags are used in ufshcd_exit_clk_scaling/gating() - when ufshcd_hba_exit() calls ufshcd_exit_clk_scaling/gating(), the two funcs need to make sure they really have something to remove, otherwise NULL pointer issues. Can Guo.