Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2129449ybv; Fri, 14 Feb 2020 12:03:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwcLWsV2y80ylTBg4N+wZ4Y3xKG8KyAC8fOpSdiUfdMPvU53LuOVmWD/raqQY34IEgGMf1t X-Received: by 2002:aca:b483:: with SMTP id d125mr3118564oif.167.1581710609832; Fri, 14 Feb 2020 12:03:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581710609; cv=none; d=google.com; s=arc-20160816; b=D+rbb/04O2yzXtQ5XsFXkrPJmIlsXYM1NtX0Gpad6+shKwNeI/JP4HJ/KiE4mKGXbY 7V8SJW7183m840IoKJYktpAyLhr38wECNplm/CpRbfF9Ys9BdunH9Pdo1oO4/7PYPMgp 7URqxq+tV1qjDuQVr9GtKVLmUjFuaBa0IqjXRm16bW5ONaCwSeOE88aclrn9tzB0zWfA igN+HHW1Avmut7rDbIlumvP3MICOYdKBf8G42gi3x+7xksXFRHfLwKYTXalAwph/ST8a en/m77XIvj+GOHCyHHsJ6oYJXFZx3OoXJeqN57lPMe7z/yBDfgVLg5rwyajQFUp0r+c4 3yog== 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=DWq0xF9g6Yd6PNxd8baBm6vZFnDCU+jbCym2haosY8k=; b=qcVukD8mPqPhkFzBAKq6TvkzvDwxc2+Q+2tDR69RrTuktmQVHQBcNDBIol/9h/rrnu B3YnjkRi9/ZSms0icpKloaseziaMFK5GzdfoKbnbZQQ3/ljtHxE+fxUovWzZAasLiaRK Ho93agWY5KNKxUh2+oiJ50QXRKKCE4FnTyAFUba9a62ukfEjLgWhe11JLoC+BcxTsdOB LbMIYF8lBIPQ709xeIndwJLvF5xsnPZuO6hW+OWlOIxQcxJnmTUDlqiDOB5T4ReV/Jpz fyyeKnT0zULNvgDapBcfIDDuLw6T6J5j7SsSy9Ha2jPLXXv8mwSANfcaIdrHsJZbLZRW KKuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V2NYCqcB; 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 v3si2898930oif.122.2020.02.14.12.03.16; Fri, 14 Feb 2020 12:03:29 -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=V2NYCqcB; 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 S2389609AbgBNUCt (ORCPT + 99 others); Fri, 14 Feb 2020 15:02:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:34470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389136AbgBNUCr (ORCPT ); Fri, 14 Feb 2020 15:02:47 -0500 Received: from localhost (unknown [12.246.51.142]) (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 756F124673; Fri, 14 Feb 2020 20:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581710566; bh=ztsFQuOS0jDxnxVmgdeYoi1OWAbYtzzS6bn2PGzoXXs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V2NYCqcBDEnnIrQDdlzOcVVq1BES3aGdj3DrZgNnTiz8J3qTTPLMi1BN0O31c7AO/ 9YflMvVvZ6DgO3fmA0Y6FAQ9iH+37x2vY2VKidy1WCE0znwIlU4xBuqKqWYsyyWX0U 7Sufa/UxI9CMUfe5jXVhF9Znu85MVwaqHmFUlGVs= Date: Fri, 14 Feb 2020 09:10:05 -0800 From: 'Greg KH' To: Jolly Shah Cc: Rajan Vaja , "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 , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 1/4] firmware: xilinx: Add sysfs interface Message-ID: <20200214171005.GB4034785@kroah.com> References: <20200114145257.GA1910108@kroah.com> <20200124060339.GB2906795@kroah.com> <2D4B924A-D10C-4A90-A8E6-507BF6C30654@xilinx.com> <20200128062814.GA2097606@kroah.com> <4EF659A1-2844-46B9-9ED6-5A6A20401D9D@xilinx.com> <20200131061038.GA2180358@kroah.com> <20200131093646.GA2271937@kroah.com> <3ef20e9d-052f-665c-7fc8-69a1f8bc9bd2@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3ef20e9d-052f-665c-7fc8-69a1f8bc9bd2@xilinx.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 10, 2020 at 04:57:01PM -0800, Jolly Shah wrote: > Hi Greg, > > > ------Original Message------ > > From: 'Greg Kh' > > Sent: Friday, January 31, 2020 1:36AM > > To: Rajan Vaja > > Cc: Jolly Shah , Ard Biesheuvel > , Mingo , Matt > , Sudeep Holla , Hkallweit1 > , Keescook , Dmitry Torokhov > , Michal Simek , > Linux-arm-kernel , Linux-kernel > > > Subject: Re: [PATCH v2 1/4] firmware: xilinx: Add sysfs interface > > > > On Fri, Jan 31, 2020 at 09:05:15AM +0000, Rajan Vaja wrote: > > > Hi Greg, > > > > > > > -----Original Message----- > > > > From: Greg KH > > > > Sent: 31 January 2020 11:41 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 > > > > Subject: Re: [PATCH v2 1/4] firmware: xilinx: Add sysfs interface > > > > > > > > EXTERNAL EMAIL > > > > > > > > On Thu, Jan 30, 2020 at 11:59:03PM +0000, Jolly Shah wrote: > > > > > Hi Greg, > > > > > > > > > > On 1/27/20, 10:28 PM, "linux-kernel-owner@vger.kernel.org on behalf of Greg > > > > KH" > > > gregkh@linuxfoundation.org> wrote: > > > > > > > > > > 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. > > > > > > > > > > Sorry I am not clear. Do you mean that we should use linux standard > > > > > ioctl interface instead of internal ioctl by mentioning "real" ? > > > > > > > > No, you should just make a "real" function call to the exact thing you > > > > want to do. Not have an internal multi-plexor ioctl() call that others > > > > then call. This isn't a microkernel :) > > > [Rajan] Sorry for multiple back and forth but as I understand, you are suggesting to create a new API for > > > Read/write of GGS register instead of using PM_IOCTL API (eemi_ops->ioctl) for multiple purpose. Is my understanding correct? > > > > That is correct. > > > > Would like to clarify purpose of having ioctl API to avoid any confusion. > eemi interface apis are defined to be platform independent and allows clock, > reset, power etc management through firmware but apart from these generic > operations, there are some operations which needs secure access through > firmware. Examples are accessing some storage registers(ggs and pggs) for > inter agent communication, configuring another agent(RPU) mode, boot device > configuration etc. Those operations are covered as ioctls as they are very > platform specific. Also only whitelisted operations are allowed through > ioctl and is not exposed to user for any random read/write operation. > > Olof earlier had same concerns. We had clarified the purpose and with his > agreement, initial set of ioctls were accepted. > (https://www.lkml.org/lkml/2018/9/24/1570) > > Please suggest the best approach to handle this for current and future > patches. Ok, in looking further at this, it's both better than I thought, and totally worse. This interface you all are using where you ask the firmware driver for a pointer to a set of operation functions and then make calls through that is indicitive of an api that is NOT what we normally use in Linux at all. Just make the direct call to the firmware driver, no need to muck around with tables of function pointers. In fact, with the spectre changes, you just made things slower than needed, and you can get back a bunch of throughput by removing that whole middle layer. So go do that first please, before adding any new stuff. Now for the ioctl, yeah, that's not a "normal" pattern either. But right now you only have 2 "different" ioctls that you call. So why not just turn those 2 into real function calls as well that then makes the "ioctl" call to the hardware? That makes things a lot more obvious on the kernel driver side exactly what is going on. If you need to add more "ioctl" like calls, just add them as more functions, no big deal. How many more of these are you going to need over time? But that's not all that big of a deal right now, get rid of that whole middle-layer first, that's more important to clean up. You will get rid of a lot of unneeded code and indirection that way, making it simpler and easier to understand what exactly is happening. thanks, greg k-h