Received: by 10.223.185.116 with SMTP id b49csp3317994wrg; Sun, 25 Feb 2018 19:56:16 -0800 (PST) X-Google-Smtp-Source: AH8x224f5rrWhKDihylFTniSsDIHo77EFpf5VeBND+kLA/P1PYqVn5QGZpX205nn9gyLqGYwjWai X-Received: by 2002:a17:902:50e:: with SMTP id 14-v6mr9236903plf.360.1519617376017; Sun, 25 Feb 2018 19:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519617375; cv=none; d=google.com; s=arc-20160816; b=eMzhXSuCumLFj09qXk4+TK5ZmVywto2u3DHt9Lzztt21D3+JaexsfFaV4R8JV+yFRt azfwugkIH6x2zOZbqoz01vTx+1Z6lQXQUoBGnQlgs23YRD+Thv2l16MQmZgMSYxu0zV0 dT4XFSnl/kycX1/zuBZWYp+SOsUoZqJk1W30CPsonTWktemlNVH68C8mTIxUKG974lVW rEt4W+QA6qf6UpxkU1cNRjkv32rA1QsKy3iD50M1HJi99h2wvdTTKoJWqEmxsSEidVYf oeT783wL6rasw8AmFSH+wyGrFB570ziDh9aqJ/YUGhcIErm8uhdD/gd37i4UHjd/m3R2 Ou5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=PKMBoWJRQQv2rwwovCS3H9qyQMMYJHhBchmQtCSUW0A=; b=HN8+pZERlju0/uwqecVf68iNek77Ut6SSzK/8yHB4vkvNa9B5RRUQNHFk6iQLodpfq DI4KqNpkgmbJbOwdvs7jjVC+cEE3ru2weYVX7naOAYw/2Q7qNs8dBthVS8uuyj61sv/t l0bmSIobRvWp8sg8I2B2NZf6zDYK1LirpwQEEVFM4T/jrjj5+LUaCks1qm42k1JOUqeF utlYXfrixDDPzl5oTAYbXlwH7mIrf90RdfycR3Bu0VJcOSguXYxH79r2N5sNonsA8ZCZ Mzy6r3Ir+PDMNDqo0MY1fTUF6Q44heKsdsIBZlaXo3v/K4jNIds8rZ+6FVJneAr57l7k dhDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ejd9lPaA; dkim=pass header.i=@codeaurora.org header.s=default header.b=foArt+EJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v32-v6si6090316plb.301.2018.02.25.19.56.01; Sun, 25 Feb 2018 19:56:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ejd9lPaA; dkim=pass header.i=@codeaurora.org header.s=default header.b=foArt+EJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752139AbeBZDzY (ORCPT + 99 others); Sun, 25 Feb 2018 22:55:24 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:55098 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751959AbeBZDzU (ORCPT ); Sun, 25 Feb 2018 22:55:20 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 304C76079B; Mon, 26 Feb 2018 03:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519617320; bh=8JPixPqVT/xbz5lAcWn67CWTH/DC7PsxIVUJXjxfhKY=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Ejd9lPaA/JUXgk8b9xNqaX6RDVGSoUsC6QT0YNR+tzdHc9PazP5kBUpba0CALMKDe wJ/iqjrbLgeqzP+vIyC+QNWkXZ0XEGSTSmHTKKiYQAQo/ne1y//WLfQbxuSRq8kxTD PuSfF+l3nt8+CTKwNi0Icw+P05BjfD/Gnd9RrpXE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.206.25.125] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asutoshd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6215F6070A; Mon, 26 Feb 2018 03:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519617319; bh=8JPixPqVT/xbz5lAcWn67CWTH/DC7PsxIVUJXjxfhKY=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=foArt+EJNivFZj9btenz+gKdBBTK8UgZJsWk5q7mhFO9jE3Xkm7rl//7RhzuZzuMv kL9kPt7EyRoKFviklGFwSCaUNAIETjJAS/o87696mQ+OohHpl5Ixbc5Mxeozzjz/eu kzDo4jwh5TMrot4tnt5pPstpGTxQlCgAo6d1gWsY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6215F6070A Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=asutoshd@codeaurora.org Subject: Re: [PATCH 9/9] scsi: ufs: Add clock ungating to a separate workqueue To: Miguel Ojeda Cc: subhashj@codeaurora.org, cang@codeaurora.org, vivek.gautam@codeaurora.org, rnayak@codeaurora.org, vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, Vijay Viswanath , open list References: <1c92a979dce897db920d9b9a625923d64cba2266.1519120988.git.asutoshd@codeaurora.org> From: "Asutosh Das (asd)" Message-ID: <68880931-6f39-1ffc-92f6-f3b90cec396c@codeaurora.org> Date: Mon, 26 Feb 2018 09:25:14 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/24/2018 5:27 AM, Miguel Ojeda wrote: > On Wed, Feb 21, 2018 at 5:56 AM, Asutosh Das wrote: >> From: Vijay Viswanath >> >> UFS driver can receive a request during memory reclaim by kswapd. >> So when ufs driver puts the ungate work in queue, and if there are no >> idle workers, kthreadd is invoked to create a new kworker. Since >> kswapd task holds a mutex which kthreadd also needs, this can cause >> a deadlock situation. So ungate work must be done in a separate >> work queue with WQ__RECLAIM flag enabled.Such a workqueue will have > > WQ_MEM_RECLAIM here. Also space after dot. > >> a rescue thread which will be called when the above deadlock >> condition is possible. >> >> Signed-off-by: Vijay Viswanath >> Signed-off-by: Can Guo >> Signed-off-by: Asutosh Das >> --- >> drivers/scsi/ufs/ufshcd.c | 10 +++++++++- >> drivers/scsi/ufs/ufshcd.h | 1 + >> 2 files changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >> index 6541e1d..bb3382a 100644 >> --- a/drivers/scsi/ufs/ufshcd.c >> +++ b/drivers/scsi/ufs/ufshcd.c >> @@ -1503,7 +1503,8 @@ int ufshcd_hold(struct ufs_hba *hba, bool async) >> hba->clk_gating.state = REQ_CLKS_ON; >> trace_ufshcd_clk_gating(dev_name(hba->dev), >> hba->clk_gating.state); >> - schedule_work(&hba->clk_gating.ungate_work); >> + queue_work(hba->clk_gating.clk_gating_workq, >> + &hba->clk_gating.ungate_work); >> /* >> * fall through to check if we should wait for this >> * work to be done or not. >> @@ -1689,6 +1690,8 @@ static ssize_t ufshcd_clkgate_enable_store(struct device *dev, >> >> static void ufshcd_init_clk_gating(struct ufs_hba *hba) >> { >> + char wq_name[sizeof("ufs_clk_gating_00")]; >> + >> if (!ufshcd_is_clkgating_allowed(hba)) >> return; >> >> @@ -1696,6 +1699,10 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba) >> INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work); >> INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work); >> >> + snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_clk_gating_%d", >> + hba->host->host_no); >> + hba->clk_gating.clk_gating_workq = create_singlethread_workqueue(wq_name); > > Shouldn't this be alloc_ordered_workqueue() with WQ_MEM_RECLAIM then? > (create_singlethread_workqueue() and friends are deprecated). > > Cheers, > Miguel > >> + >> hba->clk_gating.is_enabled = true; >> >> hba->clk_gating.delay_attr.show = ufshcd_clkgate_delay_show; >> @@ -1723,6 +1730,7 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba) >> device_remove_file(hba->dev, &hba->clk_gating.enable_attr); >> cancel_work_sync(&hba->clk_gating.ungate_work); >> cancel_delayed_work_sync(&hba->clk_gating.gate_work); >> + destroy_workqueue(hba->clk_gating.clk_gating_workq); >> } >> >> /* Must be called with host lock acquired */ >> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h >> index 4385741..570c33e 100644 >> --- a/drivers/scsi/ufs/ufshcd.h >> +++ b/drivers/scsi/ufs/ufshcd.h >> @@ -361,6 +361,7 @@ struct ufs_clk_gating { >> struct device_attribute enable_attr; >> bool is_enabled; >> int active_reqs; >> + struct workqueue_struct *clk_gating_workq; >> }; >> >> struct ufs_saved_pwr_info { >> -- >> Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. >> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project. >> Hi Miguel Thanks for the review. I'll check this and put up the changes in v2. -asd -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project