Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp206644pxb; Tue, 14 Sep 2021 23:31:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEiPohpVXKGpAfAUnJj4cqoW6kOP1E7plInSMI738zSvuSsWu9JkPI1V+T9aoflJASDK5b X-Received: by 2002:a2e:91cc:: with SMTP id u12mr19351546ljg.501.1631687498452; Tue, 14 Sep 2021 23:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631687498; cv=none; d=google.com; s=arc-20160816; b=O1ayqvPw343EMT59JW44KJ305vuCLf/xpJ0JbR/bS9QB7z6jthQjb0cB1d2vaSsea0 nrgGbEqdRUlvB2/X+ncTfciT7+pc+G3Lu8pF9NAau8m8GXxYSzm9qIqcfX3lVC/yfUQn vRCUfNEFQlVeCaaEpqM7Qr7oXHWljVyth5YyfQ+bnLqdGfFZtfx8cyswpVVQjHc7fMjr O+5zLAjRd+npFZdnvET6PJg11/hi8AK5FNJCf64iRDycvC473ePFqUwUJkb7gdfx1NK1 QPG+nF1o0gJYd9Shv2RCUymlpEpmaaqArQiOdhxR1J+X0KR+KO3HGMviP4pkDv0r9b63 TWkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Id7kIGKKqxKA0U9qbGyVLD4ai9k21W2y4KO5XUhZTWE=; b=wtmYaPnvehvOFMv+JNVpd89wdu7lMJtj3Mr7gLWRRlOyZRow7OjRHuhayRYo3qrUWZ jl75dAzfhk2ZihAPIxNAOftYV9gySO4eICekvyH3R/+jNM5gHk3cRWAW8OG9r9hydncJ LHTvE01lT8Vx5kTic4tyn8JXFNPMlCLW5k1bSjBXGe8cBwVuM2RxnaaZEi5zDu8v9MWe buq10dKxh1zhNCrP99W8ytDoWUmpND7InCYXY8vTpUydcydsGyqvpItsuAXr8HWJW8zP Ol8znsBMcNSnbj7ZdafRHuoCQo2RHEqBNJjDIquOpEfza+3eb/lwZXfLMKW+xc/oBIJV sK0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D8yyuXJa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si15506525ljr.482.2021.09.14.23.31.08; Tue, 14 Sep 2021 23:31:38 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=D8yyuXJa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbhIOGa5 (ORCPT + 99 others); Wed, 15 Sep 2021 02:30:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:51718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbhIOGa4 (ORCPT ); Wed, 15 Sep 2021 02:30:56 -0400 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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