Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1062311pxu; Wed, 2 Dec 2020 10:03:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0tGUetsLMuoa0Uj/dhE+MmRyIcK0jDQ9e4YSU5O4RefRDjc6Y+tfrUMvxJxXUB/33U4Ha X-Received: by 2002:a17:906:6713:: with SMTP id a19mr995205ejp.468.1606932228231; Wed, 02 Dec 2020 10:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606932228; cv=none; d=google.com; s=arc-20160816; b=g+YnnrCgdzSoDraZUJWYQjWuZEO1wPeOYdRLIGezlftJAHYBfcgddB5LYrzTA9jfkN nMo33d3fmo/y/iRVV0/UEoW1o24NRkDp07EIf9ZV8Vz7ap/Qhoav5ENWvFG+Fw9HZ9Ky uPy5rggndd7hdHJXVzGMCdeLmNoFKZSixInpSseJ6uf4KNlJbcqXwwnH5uvufcOkOiQ3 hTcNsck4RrOhGRyyIBottOvYHmGPm4G9mmHnFGZGlLkZt8UyQtIEiLuedmQlLzSxlJdp Dz+1vhXKzp534AYNS8z3kD4JieDnQoeN4T5h4flWRKf3VGR9gXVfCEL7NFTXnU6KYzA8 mvpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=d20BTJhJuOfIeJ6dTfjs7Aw/4YtAMOVaiif/uqb3Chc=; b=kZO2WOYUpDTjs0wGGjvFlri0gRpR+9m3FPZP9zu6z+9Q+xaEs2euPzkoTNqd1p9dEu Y134/fmji26d2UdTIEYbunTaOdRRa7y5STjzlLRS9woVQVTaQPx3mIdInEOV9NYsHLAk gcRrALEf/eKQ4TssM3A4VBfFR0lSuEw3Dmny5vaKIAnhiVzK1krU77Lj/LcymX+4Y5B1 4IqaNNRucYvD/8kC3iNDS1IIXi1f36tMglnQ3gWfoybb74IGgc8wz5eBQtwN3QGDGB1E Sf0B/GXL35dfypk6XpZ/tWukPL/KRLXGKmxmoO+PDleD7CC+0Mm/9m+4yKabVY6526vJ Aw9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="H/anSwag"; 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 p17si438902ejw.23.2020.12.02.10.03.24; Wed, 02 Dec 2020 10:03:48 -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="H/anSwag"; 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 S1730905AbgLBR7Z (ORCPT + 99 others); Wed, 2 Dec 2020 12:59:25 -0500 Received: from m42-5.mailgun.net ([69.72.42.5]:43259 "EHLO m42-5.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728656AbgLBR7W (ORCPT ); Wed, 2 Dec 2020 12:59:22 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1606931942; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=d20BTJhJuOfIeJ6dTfjs7Aw/4YtAMOVaiif/uqb3Chc=; b=H/anSwagZgxwhb+H4g6tZXZ4E77UIAwpg27t7KMaUdxdttAhrBmHPZkywdQ6wSTbkP8reCxR Us3ECOSZIbIEJ5x/xwMRyuroZVOM+wek3wsZD01EzfwNRlOC1MEF0Eej+9PGwUpvmVUmyiZb w3ops7RKgAeeVXqa4vLad1w6C/A= X-Mailgun-Sending-Ip: 69.72.42.5 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-n09.prod.us-east-1.postgun.com with SMTP id 5fc7d5c97edc97d061e452c4 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 02 Dec 2020 17:58:33 GMT Sender: asutoshd=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id AA702C43469; Wed, 2 Dec 2020 17:58:31 +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, NICE_REPLY_A,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.8.168] (cpe-70-95-149-85.san.res.rr.com [70.95.149.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asutoshd) by smtp.codeaurora.org (Postfix) with ESMTPSA id 121FBC43461; Wed, 2 Dec 2020 17:58:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 121FBC43461 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=asutoshd@codeaurora.org Subject: Re: [PATCH 1/3] scsi: ufs: Add "wb_on" sysfs node to control WB on/off To: Bean Huo , alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20201130181143.5739-1-huobean@gmail.com> <20201130181143.5739-2-huobean@gmail.com> <2a380908-3eb4-2cdc-4156-03e8946ffd88@codeaurora.org> <30767ee7973670b86bff61d1d7b2044f17640b75.camel@gmail.com> From: "Asutosh Das (asd)" Message-ID: <64458f93-55ed-ae62-e7c2-d4c54721b2b1@codeaurora.org> Date: Wed, 2 Dec 2020 09:58:29 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <30767ee7973670b86bff61d1d7b2044f17640b75.camel@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/2/2020 8:20 AM, Bean Huo wrote: > On Mon, 2020-11-30 at 15:19 -0800, Asutosh Das (asd) wrote: >>> + return -EINVAL; >>> + >>> + pm_runtime_get_sync(hba->dev); >>> + res = ufshcd_wb_ctrl(hba, wb_enable); >> >> Say, a platform supports clock-scaling and this bit is toggled. >> The control goes into ufshcd_wb_ctrl for both this sysfs and >> clock-scaling contexts. The clock-scaling context passes all checks >> and >> blocks on waiting for this wb control to be disabled and then tries >> to >> enable wb when it's already disabled. Perhaps that's a race there? > > Hi Asutosh > Appreciate your review. > There is only inconsistent problem between clock-scaling and sysfs, > since hba->dev_cmd.lock can garantee there is only one can change > fWriteBoosterEn. But this is only happening on user willfully wants to > control WB through sysfs even they know the platform supports clock- > scaling. > > Since this is for the platform which doesn't support clock-scaling, I > think based on your comments, it should be acceptable for you like > this: Or a synchronization primitive b/w the 2 contexts would work just as well. However, I don't have an issue if the user is denied toggling of wb anyway. LGTM. > > > +static ssize_t wb_on_store(struct device *dev, struct device_attribute > *attr, > + const char *buf, size_t count) > +{ > + struct ufs_hba *hba = dev_get_drvdata(dev); > + unsigned int wb_enable; > + ssize_t res; > + > + if (ufshcd_is_clkscaling_supported(hba)) { > + dev_err(dev, "supports dynamic clk scaling, control WB > + through sysfs is not allowed!"); > + return -EOPNOTSUPP; > + } > + if (!ufshcd_is_wb_allowed(hba)) > + return -EOPNOTSUPP; > + > + if (kstrtouint(buf, 0, &wb_enable)) > + return -EINVAL; > + > + if (wb_enable != 0 && wb_enable != 1) > + return -EINVAL; > + > + pm_runtime_get_sync(hba->dev); > + res = ufshcd_wb_ctrl(hba, wb_enable); > + pm_runtime_put_sync(hba->dev); > + > + return res < 0 ? res : count; > +} > > thanks, > Bean > > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project