Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp559632imm; Fri, 21 Sep 2018 04:47:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZaQ5ba99rZQnwzo4wlgaUTmaR35nI5CUtDiQ2CSJhdIXaG56U75xkr1AUK6AKX/i8T+XK9 X-Received: by 2002:a63:2c01:: with SMTP id s1-v6mr38818208pgs.367.1537530429632; Fri, 21 Sep 2018 04:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537530429; cv=none; d=google.com; s=arc-20160816; b=CjLtHF3HkHFGMwtUUyUS5Sc1beq6fik6VyhJtsLo9qZWpK1321UMRBwg6M/hjOLEhO GLloRNSCjsLqbmED2EWmBOCsauk76NTRBUocAzKAGl7IR9KTCuwec2QKuWQSKBZ1kkjM VYzmF2j9NUyIqbdTGIBMTQd3WUc8tw0lJH4zmp9hf+Bo2lEMOx39S2VT1EYMawr2mL7z H0nUfq8YJzHlraAzlUpi1tF9bOEF6oe9D7bRCVDgstWNjBEgACr9UzRrGPqQ0c+LXhZP earvyJHqmz9VbGNJsmgg/gi0woIP01a92vT3b0tNN53boa8ctwbe/d2CvTJp8Fd0/B1R MleA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature; bh=bgdIfrnNcZXiH/j0j2MZ42rmjCrHJ0DjGZ28kFZRjKc=; b=R/tVI95hdwsSiCZ+CrFLT9/s1r4H3Vx+ykuKNgk5Yz9sxOa42h9f+jdC0RxOVA3Af7 vRmgYaC6xNwjktP+vKOScUPUa7BRjPtD3GLKdr9Xr9Q9mUzV52vdt9RNEq1oWjpgkGax sZGo7fKw5mh3LsEDHVUi74SfY7ZgwrkdWmvhqWQ+n9ZooHnpWW5euSXGDW4iHrIdubPc uKZyFN0hRaGj45/kvCScG+eUrk+6n+o1Zct11McEOep+X4fqutv+c+uiukIW01IO7+cs nRyeeFmNZRXfJk61vAX/MSMRxVNSp6jvrSnVZmppRsruC3FT1SlEgCd2WPRqEzIFoRTH 81rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=cA6dbUyC; dkim=pass header.i=@codeaurora.org header.s=default header.b=mJXKkBWV; 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 188-v6si2784525pgf.406.2018.09.21.04.46.52; Fri, 21 Sep 2018 04:47:09 -0700 (PDT) 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=cA6dbUyC; dkim=pass header.i=@codeaurora.org header.s=default header.b=mJXKkBWV; 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 S2389981AbeIURe5 (ORCPT + 99 others); Fri, 21 Sep 2018 13:34:57 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44112 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727681AbeIURe4 (ORCPT ); Fri, 21 Sep 2018 13:34:56 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 377076125F; Fri, 21 Sep 2018 11:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1537530386; bh=nc+UKqztwt319MVF18m0A6wQS49uc1GThSkV77Jr/pI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=cA6dbUyCbH1fRKo/KUic96gs7Rq30Slwqow3CgCj7Ly35V7U3BdVBQ3VrYjX/Jx6j e0F+DXrRPVOWQqAvJnOA2dRQ/IznJQ3vq6MKcgfjcTYvIeKnI6i4Ra3+OZNOAcOqJf 7NFmg0FnbR8peLwdEbuvHee+A6tqaSWjX0av0l/E= 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.24.162] (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: sayalil@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B5C0B61284; Fri, 21 Sep 2018 11:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1537530385; bh=nc+UKqztwt319MVF18m0A6wQS49uc1GThSkV77Jr/pI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=mJXKkBWVl3MtFoqWRQHBzlM0R6pjxbxGXpH3ePKzP/Gq6Or9XOIXba04jAUe/HSsl TW4WZ1meDW4LF9AMWj7aoZh8UDi1yWuX2CPonKf50Mv+jEkSYHUnVEgIHOnPLkLoTo 1YNrPjmt7bxqlgD1B9Qp0TVQE3PxuSfZAzPBkC/U= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B5C0B61284 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=sayalil@codeaurora.org Subject: Re: [PATCH V13 2/2] scsi: ufs: Add configfs support for UFS provisioning To: Evan Green Cc: subhashj@codeaurora.org, cang@codeaurora.org, vivek.gautam@codeaurora.org, Rajendra Nayak , Vinayak Holikatti , jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, asutoshd@codeaurora.org, riteshh@codeaurora.org, stummala@codeaurora.org, adrian.hunter@intel.com, Joel Becker , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <1536918159-311-1-git-send-email-sayalil@codeaurora.org> <1536918159-311-3-git-send-email-sayalil@codeaurora.org> From: Sayali Lokhande Message-ID: Date: Fri, 21 Sep 2018 17:16:17 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/19/2018 2:26 AM, Evan Green wrote: > On Fri, Sep 14, 2018 at 2:43 AM Sayali Lokhande wrote: >> This patch adds configfs support to provision UFS device at >> runtime. This feature can be primarily useful in factory or >> assembly line as some devices may be required to be configured >> multiple times during initial system development phase. >> Configuration Descriptors can be written multiple times until >> bConfigDescrLock attribute is zero. >> >> Configuration descriptor buffer consists of Device and Unit >> descriptor configurable parameters which are parsed from vendor >> specific provisioning file and then passed via configfs node at >> runtime to provision ufs device. >> CONFIG_CONFIGFS_FS and CONFIG_UFS_PROVISION needs to be enabled >> for using this feature. >> >> Usage: >> 1) To read current configuration descriptor with index X >> (where index X can be 0/1/2/3) : >> cat /config//ufs_config_desc_X >> >> 2) To write configuration descriptor with index X : >> echo > /config//ufs_config_desc_X >> >> Signed-off-by: Sayali Lokhande >> --- > ... >> diff --git a/drivers/scsi/ufs/ufs-configfs.c b/drivers/scsi/ufs/ufs-configfs.c >> new file mode 100644 >> index 0000000..84ccb1a >> --- /dev/null >> +++ b/drivers/scsi/ufs/ufs-configfs.c >> @@ -0,0 +1,237 @@ > ... >> +static ssize_t ufs_config_desc_0_show(struct config_item *item, char *buf) >> +{ >> + return ufs_config_desc_show(item, buf, 0); >> +} >> + >> +static ssize_t ufs_config_desc_0_store(struct config_item *item, >> + const char *buf, size_t count) >> +{ >> + return ufshcd_desc_configfs_store(item, buf, count, 0); >> +} >> + >> +static ssize_t ufs_config_desc_1_show(struct config_item *item, char *buf) >> +{ >> + return ufs_config_desc_show(item, buf, 1); >> +} >> + >> +static ssize_t ufs_config_desc_1_store(struct config_item *item, >> + const char *buf, size_t count) >> +{ >> + return ufshcd_desc_configfs_store(item, buf, count, 1); >> +} >> + >> +static ssize_t ufs_config_desc_2_show(struct config_item *item, char *buf) >> +{ >> + return ufs_config_desc_show(item, buf, 2); >> +} >> + >> +static ssize_t ufs_config_desc_2_store(struct config_item *item, >> + const char *buf, size_t count) >> +{ >> + return ufshcd_desc_configfs_store(item, buf, count, 2); >> +} >> + >> +static ssize_t ufs_config_desc_3_show(struct config_item *item, char *buf) >> +{ >> + return ufs_config_desc_show(item, buf, 3); >> +} >> + >> +static ssize_t ufs_config_desc_3_store(struct config_item *item, >> + const char *buf, size_t count) >> +{ >> + return ufshcd_desc_configfs_store(item, buf, count, 3); >> +} >> + > The copypasta above and below is not my favorite, but I suppose it's > either this or wrap it all up in a macro that you stamp down 4 times. > I'm not sure if that's really any cleaner, so I guess this is fine. > >> +static struct configfs_attribute ufshcd_attr_provision_0 = { >> + .ca_name = "ufs_config_desc_0", >> + .ca_mode = 0644, >> + .ca_owner = THIS_MODULE, >> + .show = ufs_config_desc_0_show, >> + .store = ufs_config_desc_0_store, >> +}; >> + >> +static struct configfs_attribute ufshcd_attr_provision_1 = { >> + .ca_name = "ufs_config_desc_1", >> + .ca_mode = 0644, >> + .ca_owner = THIS_MODULE, >> + .show = ufs_config_desc_1_show, >> + .store = ufs_config_desc_1_store, >> +}; >> + >> +static struct configfs_attribute ufshcd_attr_provision_2 = { >> + .ca_name = "ufs_config_desc_2", >> + .ca_mode = 0644, >> + .ca_owner = THIS_MODULE, >> + .show = ufs_config_desc_2_show, >> + .store = ufs_config_desc_2_store, >> +}; >> + >> +static struct configfs_attribute ufshcd_attr_provision_3 = { >> + .ca_name = "ufs_config_desc_3", >> + .ca_mode = 0644, >> + .ca_owner = THIS_MODULE, >> + .show = ufs_config_desc_3_show, >> + .store = ufs_config_desc_3_store, >> +}; >> + >> +static struct configfs_attribute *ufshcd_attrs[] = { >> + &ufshcd_attr_provision_0, >> + &ufshcd_attr_provision_1, >> + &ufshcd_attr_provision_2, >> + &ufshcd_attr_provision_3, >> + NULL, >> +}; >> + >> +static struct config_item_type ufscfg_type = { >> + .ct_attrs = ufshcd_attrs, >> + .ct_owner = THIS_MODULE, >> +}; >> + >> +void ufshcd_configfs_init(struct ufs_hba *hba, const char *name) >> +{ >> + int ret; >> + struct config_item *cg_item; >> + struct configfs_subsystem *subsys; >> + >> + cg_item = &hba->subsys.su_group.cg_item; >> + sprintf(cg_item->ci_namebuf, "%s", name); > CONFIGFS_ITEM_NAME_LEN is only 20. Is there anything preventing the > device name passed in here from being longer than that? You'd have a > nasty overrun on your hands if not. Maybe snprintf here? Agree. I need to use snprintf here. Will update. >> + cg_item->ci_type = &ufscfg_type; >> + >> + subsys = &hba->subsys; >> + config_group_init(&subsys->su_group); >> + mutex_init(&subsys->su_mutex); >> + ret = configfs_register_subsystem(subsys); >> + if (ret) >> + pr_err("Error %d while registering subsystem %s\n", >> + ret, >> + subsys->su_group.cg_item.ci_namebuf); >> +} >> + >> +void ufshcd_configfs_exit(struct ufs_hba *hba) >> +{ >> + configfs_unregister_subsystem(&hba->subsys); >> +}