Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp72765ybl; Mon, 27 Jan 2020 22:29:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwzNspOwm3ssgt+dnPpnE/ZHsLOsR3xCLI6keI3ULyUUszMAchEZsxX+YiR8mE/2rot+bIR X-Received: by 2002:aca:fc0c:: with SMTP id a12mr1800456oii.118.1580192989957; Mon, 27 Jan 2020 22:29:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580192989; cv=none; d=google.com; s=arc-20160816; b=kak26KBGdDOPH8mFFQPYEJDXoKOnPU/OAMQ4DpVj48UZ3WK3nCW0sntzNc+5C9p1Zc JIy/B1gJzDtj0I1G6917yZ4M/qUCTCw4BY+wdIlpjG7A42hFCWpvEzoSHPa9YMgkexED TYs8GM+RJ5jihyRlc4Y6nQWxbJg+9liYkEYVodXDncEDkcDNLDhekLX5iwnDEl02ME9W z+OfyNvalJN8xAP9W7Pv/jsMVeqtkX6ybn1R71dEwdVf6x/7qsrLRRnaluXwOpCDNbJz UK4349hqqS5xOwuY3b4M96g/IhgwCLXU3ZmbqXSGJ3ZEgG+CZp545rLMvtp0SNLdAAMu QeHw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xc4I3sMV/zlE9o8LHya9qGuv/HobInVgYdOwUQkeKCE=; b=N56oZBpQrvkGRuMBsWe/mBwq3WY8RmyHU4bvZtKHAHMifWdRgUxS5jLypEqn5UH6m8 ErPfcz6S8nMgfCDV8g5ypEb4hHhSqNBAQhyjj9FkNtqVK1yqetHwnUNzSpJr31xbPS81 6mNCmuyE+AWwTwGhDYnDDlRLf/tEH652vCiUuujo6jKuETZoc2W0B9Pyz2/Ts9PfzIJ/ umHM4Kvlbi/Wt7gXljEPRTStjX+wrvljHMZ7dSmyxm2VgzPROPjtiL4lhOBuecJi3gk2 LKv5HslrquGpRU2gY8u4cXCt8DLyqE4jzopKovqZW2tcY6QtCWjF/SY8NXhqtRlp3gNW LjHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Odt/CmZw"; 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 b10si8607245otp.124.2020.01.27.22.29.34; Mon, 27 Jan 2020 22:29:49 -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="Odt/CmZw"; 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 S1725839AbgA1G2T (ORCPT + 99 others); Tue, 28 Jan 2020 01:28:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:36772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbgA1G2T (ORCPT ); Tue, 28 Jan 2020 01:28:19 -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 1E6C2205F4; Tue, 28 Jan 2020 06:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580192898; bh=Nror/33/FGHsPj3Lk3bq4hBaWkgAkgSHit0ACqP5MQE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Odt/CmZwnxY0FSSxYEi8g01nJTEMq0T60weZ9XLx/Hsot8/uLNqQrsY+FSnrA6Sjk LakYOZSNQNtghd4fsZxnu96m/QqzYqWp7d/vJCml8t+qcZe1h1adZPEOCBaDDlmwBW uWwapxJiRkKYOn6mLCUuvUPy3AGPks2TVQ5z0RKY= Date: Tue, 28 Jan 2020 07:28:14 +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: <20200128062814.GA2097606@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> <20200124060339.GB2906795@kroah.com> <2D4B924A-D10C-4A90-A8E6-507BF6C30654@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2D4B924A-D10C-4A90-A8E6-507BF6C30654@xilinx.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 27, 2020 at 11:01:27PM +0000, Jolly Shah wrote: > > > > + 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. > > these registers are for users and for special needs where users wants > to retain values over resets. but as they belong to PMU address space, > these interface APIs are provided. They don’t allow access to any > other registers. That's not the issue here. The issue is you are using an "internal" ioctl, instead just make a "real" call. > > > > +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? > > Since firmware driver is always built-in (we don't provide support to > use as module), user space won't be available before prob is complete. > Correct if I am wrong. Userspace starts earlier than you think, and also, use the correct interfaces for this type of thing, that is why it is there. Don't create purposfully-incorrect code :) > > > > 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. > > They are in Platform Management Unit register address space so it > allows only secure access. Hence for linux to access it, interface > APIs are provided. Again, that's fine, but why are you creating an "internal ioctl"? Just make a real function call. thanks, greg k-h