Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp214462ybl; Thu, 23 Jan 2020 22:05:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxXsb7bspQ4ShXVJijiGn9RlU5WQWnkdUWp6QDUVSOPMevmQ7S31jaalMAZ4UEle41XGnI7 X-Received: by 2002:aca:2114:: with SMTP id 20mr1085780oiz.9.1579845938867; Thu, 23 Jan 2020 22:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579845938; cv=none; d=google.com; s=arc-20160816; b=CU4RD73m72Ne/XLqEXMGe1h9j1qI7MWwIahCiqppgv3w31Yt4N8I3KCacZNSFNbgg2 npRhP9AyI5bm2Brlpjs7/eyMnTtySvDeCoCWWMGE+YA9lZBhST8hk/5tGpgNIxLQhGxQ QxFvZ1zVL65uiazDtszhlIbKfwZnRWNTU6yp9+ZOPiCqWxgMR3OmqczzFuh/r0RuaXAU kcKy9IqxnHfcpyPnsfoGXG/2fTITh9PluIzn81scJT+rfz7bTnQn5megwfgDHuH+xJDD S28rpFQY7xH4ZdFFEw+JYeh2ZqUUqA3B7zT1NvERKh6yjSYtTroVr29LP6IAw79eEgiW qTSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9Pmi2rax2rmRFkPbRY2AuzV3x08vyZBESTTDFjw6gaA=; b=u/3Idc+Fv78prseC0DSX7IPdGsPo5HlQIo3TS9k23gtavzfjg1cZ/4afbzuNWPzRfk AbTtQcXt6a20tERDvgiyk+2J3M0kO45nFNkrBgUbeBxQaCuOn5U81YSR7+6mQkQLiXj2 TTNk4UtOIq/XkRlnkU8nZt8uruORpV/AX4wfHVxLBl2BIPoQSvpWcIyk43idZbzFcDwp 2UVdYMdeloHaeyrb7Tu3AJMo+ZNkdEGMpRoFRCHlgDZd+MY6pI9awK8TNG6YGH2zxe6H uy6unPob0m/f85MYLxQHfxhtPY7tNz9e/2jXrWkJ1bW1LbHGKFiM5q6gD14iicy1VuHo Vpaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WTnayUFv; 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 e192si1968124oib.82.2020.01.23.22.05.25; Thu, 23 Jan 2020 22:05:38 -0800 (PST) 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=@kernel.org header.s=default header.b=WTnayUFv; 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 S1730314AbgAXGDn (ORCPT + 99 others); Fri, 24 Jan 2020 01:03:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:58342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbgAXGDm (ORCPT ); Fri, 24 Jan 2020 01:03:42 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 215952071A; Fri, 24 Jan 2020 06:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579845821; bh=HAs60DRf5BSFHERMbxGfL8THT/7QSUVWC8FVp+r5kJ0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WTnayUFvm/P59mIIby5Mw0VHpLV+3UlZ4TGy7oj/xQ8AxjuBh1R/L5zGor66DNiDR FH7hId5xi3GZ7L03i9ZMOrUIT/ualF3cNXjcjIrPQP5vl2SJI2QZo3wNOStNe2/QIV jhratH4nic3QIarXZs2a1gaJZE45f1nKTydd8UGc= Date: Fri, 24 Jan 2020 07:03:39 +0100 From: Greg KH To: Jolly Shah Cc: "ard.biesheuvel@linaro.org" , "mingo@kernel.org" , "matt@codeblueprint.co.uk" , "sudeep.holla@arm.com" , "hkallweit1@gmail.com" , "keescook@chromium.org" , "dmitry.torokhov@gmail.com" , Michal Simek , Rajan Vaja , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 1/4] firmware: xilinx: Add sysfs interface Message-ID: <20200124060339.GB2906795@kroah.com> References: <1578527663-10243-1-git-send-email-jolly.shah@xilinx.com> <1578527663-10243-2-git-send-email-jolly.shah@xilinx.com> <20200114145257.GA1910108@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 23, 2020 at 11:47:57PM +0000, Jolly Shah wrote: > Hi Greg, > > Thanks for the review. > > > -----Original Message----- > > From: Greg KH > > Sent: Tuesday, January 14, 2020 6:53 AM > > To: Jolly Shah > > Cc: ard.biesheuvel@linaro.org; mingo@kernel.org; matt@codeblueprint.co.uk; > > sudeep.holla@arm.com; hkallweit1@gmail.com; keescook@chromium.org; > > dmitry.torokhov@gmail.com; Michal Simek ; Rajan Vaja > > ; linux-arm-kernel@lists.infradead.org; linux- > > kernel@vger.kernel.org; Rajan Vaja ; Jolly Shah > > > > Subject: Re: [PATCH v2 1/4] firmware: xilinx: Add sysfs interface > > > > On Wed, Jan 08, 2020 at 03:54:20PM -0800, Jolly Shah wrote: > > > From: Rajan Vaja > > > > > > Add Firmware-ggs sysfs interface which provides read/write > > > interface to global storage registers. > > > > > > Signed-off-by: Rajan Vaja > > > Signed-off-by: Michal Simek > > > Signed-off-by: Jolly Shah > > > --- > > > Changes in v2: > > > - Updated Linux kernel version in documentation. > > > - Used DEVICE_ATTR_* and ATTRIBUTE_GROUPS macros. > > > - Free Kobject structure in case of error. > > > - Resolved smatch errors. > > > - Updated Signed-off-by sequence. > > > --- > > > Documentation/ABI/stable/sysfs-firmware-zynqmp | 50 +++++ > > > drivers/firmware/xilinx/Makefile | 2 +- > > > drivers/firmware/xilinx/zynqmp-ggs.c | 284 > > +++++++++++++++++++++++++ > > > drivers/firmware/xilinx/zynqmp.c | 32 +++ > > > include/linux/firmware/xlnx-zynqmp.h | 10 + > > > 5 files changed, 377 insertions(+), 1 deletion(-) > > > create mode 100644 Documentation/ABI/stable/sysfs-firmware-zynqmp > > > create mode 100644 drivers/firmware/xilinx/zynqmp-ggs.c > > > > > > diff --git a/Documentation/ABI/stable/sysfs-firmware-zynqmp > > b/Documentation/ABI/stable/sysfs-firmware-zynqmp > > > new file mode 100644 > > > index 0000000..cffa2fc > > > --- /dev/null > > > +++ b/Documentation/ABI/stable/sysfs-firmware-zynqmp > > > @@ -0,0 +1,50 @@ > > > +What: /sys/firmware/zynqmp/ggs* > > > > Why are these attributes just not hanging off of the platform device for > > the firmware controller? Why do you need a new subdir under "firmware"? > > Firmware driver was changed later to be platform driver but these interfaces were defined > earlier and are in use. Defined and in use where? Not in the upstream kernel tree, right? Or am I missing them somewhere else? > > > + ret = kstrtol(tok, 16, &value); > > > + if (ret) { > > > + ret = -EFAULT; > > > + goto err; > > > + } > > > + > > > + ret = eemi_ops->ioctl(0, read_ioctl, reg, 0, ret_payload); > > > > This feels "tricky", if you tie this to the device you have your driver > > bound to, will this make it easier instead of having to go through the > > ioctl callback? > > > > GGS(general global storage) registers are in PMU space and linux doesn't have access to it > Hence ioctl is used. Why not just a "real" call to the driver to make this type of reading? You don't have ioctls within the kernel for other drivers to call, that's not needed at all. > > > +int zynqmp_pm_ggs_init(struct kobject *parent_kobj) > > > +{ > > > + return sysfs_create_group(parent_kobj, zynqmp_ggs_groups[0]); > > > > You might be racing userspace here and loosing :( > > Prob is called before user space is notified about sysfs so racing shouldn't happen. "shouldn't"? How do you know this? > Or you are referring to some other race condition? Your kobject was created, and notified userspace that it was present and then sometime after that you add more attributes which userspace has no idea are there. If you use the proper device model interfaces, none of these problems would be there. > > > > > > +} > > > diff --git a/drivers/firmware/xilinx/zynqmp.c > > b/drivers/firmware/xilinx/zynqmp.c > > > index 75bdfaa..4c1117d 100644 > > > --- a/drivers/firmware/xilinx/zynqmp.c > > > +++ b/drivers/firmware/xilinx/zynqmp.c > > > @@ -473,6 +473,10 @@ static inline int zynqmp_is_valid_ioctl(u32 ioctl_id) > > > case IOCTL_GET_PLL_FRAC_MODE: > > > case IOCTL_SET_PLL_FRAC_DATA: > > > case IOCTL_GET_PLL_FRAC_DATA: > > > + case IOCTL_WRITE_GGS: > > > + case IOCTL_READ_GGS: > > > + case IOCTL_WRITE_PGGS: > > > + case IOCTL_READ_PGGS: > > > > Huh??? > > Sorry not sure about your concern here. These registers are in PMU space and hence > Ioctl is needed to let linux access them. userspace or kernelspace? You seem to be mixing them both here. > > > > > > return 1; > > > default: > > > return 0; > > > @@ -704,6 +708,28 @@ const struct zynqmp_eemi_ops > > *zynqmp_pm_get_eemi_ops(void) > > > } > > > EXPORT_SYMBOL_GPL(zynqmp_pm_get_eemi_ops); > > > > > > +static int zynqmp_pm_sysfs_init(void) > > > +{ > > > + struct kobject *zynqmp_kobj; > > > + int ret; > > > + > > > + zynqmp_kobj = kobject_create_and_add("zynqmp", firmware_kobj); > > > + if (!zynqmp_kobj) { > > > + pr_err("zynqmp: Firmware kobj add failed.\n"); > > > + return -ENOMEM; > > > + } > > > + > > > + ret = zynqmp_pm_ggs_init(zynqmp_kobj); > > > + if (ret) { > > > + kobject_put(zynqmp_kobj); > > > + pr_err("%s() GGS init fail with error %d\n", > > > + __func__, ret); > > > + goto err; > > > + } > > > +err: > > > + return ret; > > > +} > > > + > > > static int zynqmp_firmware_probe(struct platform_device *pdev) > > > { > > > struct device *dev = &pdev->dev; > > > @@ -751,6 +777,12 @@ static int zynqmp_firmware_probe(struct > > platform_device *pdev) > > > /* Assign eemi_ops_table */ > > > eemi_ops_tbl = &eemi_ops; > > > > > > + ret = zynqmp_pm_sysfs_init(); > > > > See, you have a platform device, hang the attributes off of that instead > > of making a kobject and detatching yourself from the global device tree! > > > > Please redo this, I think it will make it a lot simpler and more > > obvious. > > Agree it will be simpler but to as firmware driver was changed to be platform driver, > to keep paths same, we used sysfs. Keep them same from what? Use the platform device as that is what it is there for, do not go create new apis when they are not needed at all. thanks, greg k-h