From patchwork Fri Oct 5 17:27:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 10628537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CCD0933 for ; Fri, 5 Oct 2018 17:28:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22AF329852 for ; Fri, 5 Oct 2018 17:28:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 146B729871; Fri, 5 Oct 2018 17:28:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A489229852 for ; Fri, 5 Oct 2018 17:28:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728139AbeJFA1q (ORCPT ); Fri, 5 Oct 2018 20:27:46 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46585 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728042AbeJFA1q (ORCPT ); Fri, 5 Oct 2018 20:27:46 -0400 Received: by mail-pg1-f196.google.com with SMTP id a5-v6so4998919pgv.13 for ; Fri, 05 Oct 2018 10:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=ZzCUUChjDLJ7vvvfNzAE6rhRTVbnaQkR1LxIqNsXUt4=; b=kFOt/cRw0mrInk1f48gYMFjEoOjUBSwn6dXBBHRWJ19pHwLauD+kJydieY8mTi6xmK 5Z4ERnTn3J7PsscBuxU1GR7AnDxOPVrNcOiZAm3Pp8D2MlXfPRRxPE7g7OA544h18x1I 10J2B8QaibY75e6R3a2YKjvRNoCx7Kspp5AeM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZzCUUChjDLJ7vvvfNzAE6rhRTVbnaQkR1LxIqNsXUt4=; b=KkWefjVlnDy8UgigfO8ZDE/gJIYhl6x+jS2C8FwmjUbpyHI9XBb4WpkfbfdFJoaL9b 5TmYaSIz68RGAQvlaG5QGkuFgM3hGTuZLD0yVo4Er5dBfMbBCY8O/7AMdrsz7WzQ9dh9 aIfTDM8clM5C8gS98+OvFCnvvI4uBMpJUc2CgHviIumiQ5mWnzgKOjbOD6qaXLiBKlCL FWEXUsaNNGLc81XqWaOILXEhEEpdqYJuEfhTrsYOiP+nJg/5ZqthZVrUqGFPjYdplNmp 6beWppkz4h941uoV5RdVnW0n9CHZSbmSjv+vpEizoeUbZHfH+V+tl/zFL0e1W5Pn7A52 Qu9Q== X-Gm-Message-State: ABuFfojDo0wNZvRCILk0/vaEJsGrAXx9xkUzjJHPzYOJYqRBudxgNI9s jB2ij5wTjUGXQh4wgCDEY/OR05epcCU= X-Google-Smtp-Source: ACcGV63o1+VrHh++znxYKAXw960ZGhfrzMO1oHI7KAluMX/1BzI2ypEKN7jjhWY1MTSeCcwu1YPJYg== X-Received: by 2002:a63:84c1:: with SMTP id k184-v6mr1396539pgd.196.1538760483964; Fri, 05 Oct 2018 10:28:03 -0700 (PDT) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:e418:c825:76cf:5f64]) by smtp.gmail.com with ESMTPSA id x17-v6sm11413525pfn.59.2018.10.05.10.28.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Oct 2018 10:28:03 -0700 (PDT) From: Evan Green To: Vinayak Holikatti , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, sayalil@codeaurora.org Cc: Evan Green Subject: [PATCH] scsi: ufs: Schedule clk gating work on correct queue Date: Fri, 5 Oct 2018 10:27:32 -0700 Message-Id: <20181005172732.203793-1-evgreen@chromium.org> X-Mailer: git-send-email 2.16.4 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With commit 10e5e37581fc ("scsi: ufs: Add clock ungating to a separate workqueue"), clock gating work was moved to a separate work queue with WQ_MEM_RECLAIM set, since clock gating could occur from a memory reclaim context. Unfortunately, clk_gating.gate_work was left queued via schedule_delayed_work, which is a system workqueue that does not have WQ_MEM_RECLAIM set. Because ufshcd_ungate_work attempts to cancel gate_work, the following warning appears: [ 14.174170] workqueue: WQ_MEM_RECLAIM ufs_clk_gating_0:ufshcd_ungate_work is flushing !WQ_MEM_RECLAIM events:ufshcd_gate_work [ 14.174179] WARNING: CPU: 4 PID: 173 at kernel/workqueue.c:2440 check_flush_dependency+0x110/0x118 [ 14.205725] CPU: 4 PID: 173 Comm: kworker/u16:3 Not tainted 4.14.68 #1 [ 14.212437] Hardware name: Google Cheza (rev1) (DT) [ 14.217459] Workqueue: ufs_clk_gating_0 ufshcd_ungate_work [ 14.223107] task: ffffffc0f6a40080 task.stack: ffffff800a490000 [ 14.229195] PC is at check_flush_dependency+0x110/0x118 [ 14.234569] LR is at check_flush_dependency+0x110/0x118 [ 14.239944] pc : [] lr : [] pstate: 60c001c9 [ 14.333050] Call trace: [ 14.427767] [] check_flush_dependency+0x110/0x118 [ 14.434219] [] start_flush_work+0xac/0x1fc [ 14.440046] [] flush_work+0x40/0x94 [ 14.445246] [] __cancel_work_timer+0x11c/0x1b8 [ 14.451433] [] cancel_delayed_work_sync+0x20/0x30 [ 14.457886] [] ufshcd_ungate_work+0x24/0xd0 [ 14.463800] [] process_one_work+0x32c/0x690 [ 14.469713] [] worker_thread+0x218/0x338 [ 14.475361] [] kthread+0x120/0x130 [ 14.480470] [] ret_from_fork+0x10/0x18 The simple solution is to put the gate_work on the same WQ_MEM_RECLAIM work queue as the ungate_work. Fixes: 10e5e37581fc ("scsi: ufs: Add clock ungating to a separate workqueue") Signed-off-by: Evan Green Reviewed-by: Douglas Anderson Reviewed-by: Stephen Boyd --- drivers/scsi/ufs/ufshcd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c55f38ec391c..54074dd483a7 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1691,8 +1691,9 @@ static void __ufshcd_release(struct ufs_hba *hba) hba->clk_gating.state = REQ_CLKS_OFF; trace_ufshcd_clk_gating(dev_name(hba->dev), hba->clk_gating.state); - schedule_delayed_work(&hba->clk_gating.gate_work, - msecs_to_jiffies(hba->clk_gating.delay_ms)); + queue_delayed_work(hba->clk_gating.clk_gating_workq, + &hba->clk_gating.gate_work, + msecs_to_jiffies(hba->clk_gating.delay_ms)); } void ufshcd_release(struct ufs_hba *hba)