From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9712FC433EF for ; Wed, 15 Sep 2021 06:31:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E45060EFF for ; Wed, 15 Sep 2021 06:31:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5E45060EFF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=x0b6V0DFueO5c0TCkk7hjInfpPj6SfuSut7i1zgRBsA=; b=HMZhPpSBR8vk5c qRfeO0l2ptKzYinIJjT1LyUvmqi7vN+TYHQPYbj1Kpvezy/Ihnpr5ViTnfHtkQ/YLgLMU3gkSE3ej +u5RvB4i+gEpNfyVrOrvWRJ4tZVLT9esK1QFVvu2RVRMZPilf1CYxUBh/YuS3/lHBYyFZlv6IDQ+J 30i6rBjNfNKSe4qd1JVV0KjcA8cio/7Noqoi7ZRVn7v5zNMlgqo7LBZfjFah6AtzXRpQpYBOE8oiW 8yUrdeXNEUcq+cCAiD7TR8/5ORgvK1Jvzlvb2PmFB/+YLXjHTrzooJPajIORwdeiioqlvdOBaaZ+t LtRd67ZhSx/L5qv29Z3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQOQQ-008Ces-7v; Wed, 15 Sep 2021 06:29:42 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQOQN-008CeW-9O for linux-arm-kernel@lists.infradead.org; Wed, 15 Sep 2021 06:29:40 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2B31360BD3; Wed, 15 Sep 2021 06:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631687378; bh=ch01/WbeIC8zu+C33l/ZDhbb3eivc2zeXl3cs9KVGHE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D8yyuXJaAa84N82v74hL6teSI8tZKGzRVI5hHkhv14Ghy16hPIJEluBEFDG3ajiMe PRGSvdpQZ+Dkshg6oqAeHY18tZ22wwpmOJUh6g+7KV3LVUBKsNEoiWQD1tA5oFjgrF trp2Axf44bOEhFSr29kBF78uexqBl9n7YW/jbJeo= Date: Wed, 15 Sep 2021 08:29:16 +0200 From: Greg KH To: Ronak Jain Cc: Michal Simek , "linux-kernel@vger.kernel.org" , Rajan Vaja , "corbet@lwn.net" , "linux-arm-kernel@lists.infradead.org" , "arnd@arndb.de" , Sai Krishna Potthuri Subject: Re: [PATCH v2 3/3] firmware: xilinx: Add sysfs support for feature config Message-ID: References: <20210913083955.27146-1-ronak.jain@xilinx.com> <20210913083955.27146-4-ronak.jain@xilinx.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210914_232939_412225_AA5C5564 X-CRM114-Status: GOOD ( 37.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Sep 15, 2021 at 06:16:16AM +0000, Ronak Jain wrote: > Hi Greg KH, > > Thanks for reviewing. > > > -----Original Message----- > > From: Greg KH > > Sent: Tuesday, September 14, 2021 2:51 PM > > To: Ronak Jain > > Cc: Michal Simek ; linux-kernel@vger.kernel.org; Rajan > > Vaja ; corbet@lwn.net; linux-arm- > > kernel@lists.infradead.org; arnd@arndb.de; Sai Krishna Potthuri > > > > Subject: Re: [PATCH v2 3/3] firmware: xilinx: Add sysfs support for feature > > config > > > > On Mon, Sep 13, 2021 at 01:39:55AM -0700, Ronak Jain wrote: > > > Add support for sysfs interface for runtime features configuration. > > > The user can configure the features at runtime. First the user need > > > to select the config id of the supported features and then the user > > > can configure the parameters of the feature based on the config id. > > > So far the support is added for the over temperature and external > > > watchdog features. > > > > > > Signed-off-by: Ronak Jain > > > --- > > > Changes in v2: > > > - Update commit message > > > --- > > > drivers/firmware/xilinx/zynqmp.c | 71 > > > ++++++++++++++++++++++++++++++++ > > > 1 file changed, 71 insertions(+) > > > > > > diff --git a/drivers/firmware/xilinx/zynqmp.c > > > b/drivers/firmware/xilinx/zynqmp.c > > > index 875d13bc1a57..a1434dd368f2 100644 > > > --- a/drivers/firmware/xilinx/zynqmp.c > > > +++ b/drivers/firmware/xilinx/zynqmp.c > > > @@ -1361,6 +1361,75 @@ static DEVICE_ATTR_RW(pggs1); static > > > DEVICE_ATTR_RW(pggs2); static DEVICE_ATTR_RW(pggs3); > > > > > > +static atomic_t feature_conf_id; > > > > Why does this have to be an atomic? > Use atomic to avoid race conditions. Suppose the case where the user > is trying to write the variable and at the same time it tries to read, > so there might be chances of occurrence of race condition. Also, I am > not so sure whether the race condition will occur or not but just to > prevent race condition I have used atomic variable so, the read/write > operations can handle automatically. Reading/writing a single variable like this will not be a problem with races. If you care about stuff like this, just use a lock to protect it, don't try to mess with an atomic if you do not have to have it. > > And shouldn't this be per-device, not global to all devices in the system? > This is to store the config-id set by the user which will be used to > retrieve config. There is only one firmware device so we can consider > it systemwide. Please let me know if you think of a better way of > handling it. So is it a device attribute or a driver attribute? And you never know how many devices you have in a system, do not assume you will not have multiple ones. Use the proper structures to start with and you never will have to change things in the future if you have multiple devices. thanks, greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel