Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3941839imu; Fri, 30 Nov 2018 08:21:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/U6O5OaZmWN+Tr9I35YQp8MStqceeHgUiX/weHjZ1MIwlnv1SaTT005JO1pZ21E2Es+iKxi X-Received: by 2002:a63:9d05:: with SMTP id i5mr4951096pgd.98.1543594898174; Fri, 30 Nov 2018 08:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543594898; cv=none; d=google.com; s=arc-20160816; b=C6EXo+DZAKHKhmgIC13waOBT9j1LocaQhMB3wN/I7A9TyEN6Jgd6fN23j+bmaJgosP /H+qZJC/IET/fbMt8LBvyfmo/l/IeiT8LFiyIrMEZDC80RUQD2iKtvm1QI0cBI+rCrpc 2a5+fIa7msFplMx6a2Lhp+Ji4ZItzghCO4L2PztuYztJQCXGLC5xDGXHj7vBThjJZD++ uL6Xo6YQghycWm4rd0T3amR1aM/59WLTBPmUQ7RcsjK20sJkp3PNbDQXbeHVA29dYQaJ Pv0T9S9L9FUI3MIQASRSebdU5WWKFj8v+IOmtocFR2t87eyEzid84jjLFrjMIOYdIaJj oYsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=92lJKmUQne39o4hvgBZDk6qeIkNWSwxaGv7AcYJLor0=; b=FAODC6Sm3i3NwirGX5a/sv8xmTQClH4eIRtaWa6jJdHDdLCC0e5FgLwg5InE+v7mCm cgC9jIbHwAUoWRdkpxnYhXfeOkXKc5AS7Sj0XlU6JeEdsZG4XbceN/LQY/QJQgRR9REj YsxpYFgh7CRi+8xlsZYm1Vr4bupfbk5iZD+IbarSv9FlFT3YZ4VCMVVflAM5xsmBwW5g uWdxpkTygctjZLN+ZckJgjtThWGcGzCHBW1EQAOP1oDif/03kt5EuXyOul6gJMsCKA11 mc6TNhsg6NVqCwrt46GKwUPGVeinhQe/QLpuP7SNGX9MpwNgC6wjEPahjessVGREXCv4 T6RA== ARC-Authentication-Results: i=1; mx.google.com; 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 m142si6454102pfd.171.2018.11.30.08.21.23; Fri, 30 Nov 2018 08:21: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; 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 S1727453AbeLADaD (ORCPT + 99 others); Fri, 30 Nov 2018 22:30:03 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:33438 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbeLADaD (ORCPT ); Fri, 30 Nov 2018 22:30:03 -0500 Received: by mail-qk1-f196.google.com with SMTP id o89so3489657qko.0; Fri, 30 Nov 2018 08:20:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=92lJKmUQne39o4hvgBZDk6qeIkNWSwxaGv7AcYJLor0=; b=HZwN2DtgXIrnnETsJne1kSrBI0QgPGZdOylLChx7BHMm0mNdbWeQQMpS9bYIzLRTFM j9KZwG/5obqYZ+Jusb2hiHjpqEDcwtJUsqHEPpQ0d0cOfBIHnhT5kFxUPncFITULHbpD fW2q8ukagkHTdSjuIJ1PYW8LUFNjI6e89+PhXui6ZjHJga4sw/Ze+fgSfjsUQXCCRoHK Rf/iymRAlSH4PvcRN4KcEGQ62WdAbQcaTFp/hJHtH2GvPZSXLnnn2MIfcwbel9XklyDT hzciqGY+2+xamBx6L0l/WEbEXKUwNoq/AqGLNO+5gcRsJq9QSks9q0ludLbyjVfJycz2 5x/Q== X-Gm-Message-State: AA+aEWYax3g+ZnSZY9t6J1IK2gYk3oAt0RNl6Pk4s7N0MWf6WiN9xr/M xzGqytLOw00voc4K10dBIckIPdUZalJCPAWL8n8= X-Received: by 2002:a37:a3c6:: with SMTP id m189mr5843105qke.173.1543594811954; Fri, 30 Nov 2018 08:20:11 -0800 (PST) MIME-Version: 1.0 References: <20181130104657.14875-1-srinivas.kandagatla@linaro.org> <20181130104657.14875-4-srinivas.kandagatla@linaro.org> <3c177508-cf6f-1f8d-a324-5bec40fd9a9c@linaro.org> <633cb111-f5d7-3648-54af-a476f3cbb279@linaro.org> In-Reply-To: <633cb111-f5d7-3648-54af-a476f3cbb279@linaro.org> From: Arnd Bergmann Date: Fri, 30 Nov 2018 17:19:53 +0100 Message-ID: Subject: Re: [RFC PATCH 3/6] char: fastrpc: Add support for context Invoke method To: Srinivas Kandagatla Cc: Rob Herring , gregkh , Mark Rutland , DTML , Linux Kernel Mailing List , Bjorn Andersson , linux-arm-msm@vger.kernel.org, bkumar@qti.qualcomm.com, thierry.escande@linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 30, 2018 at 5:03 PM Srinivas Kandagatla wrote: > On 30/11/18 15:08, Arnd Bergmann wrote: > > On Fri, Nov 30, 2018 at 4:01 PM Srinivas Kandagatla > > wrote: > >> Thanks Arnd for the review comments! > >> On 30/11/18 13:41, Arnd Bergmann wrote: > >>> On Fri, Nov 30, 2018 at 11:48 AM Srinivas Kandagatla > >>> wrote: > > > >>>> +static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, > >>>> + unsigned long arg) > >>>> +{ > >>>> + struct fastrpc_user *fl = (struct fastrpc_user *)file->private_data; > >>>> + struct fastrpc_channel_ctx *cctx = fl->cctx; > >>>> + char __user *argp = (char __user *)arg; > >>>> + int err; > >>>> + > >>>> + if (!fl->sctx) { > >>>> + fl->sctx = fastrpc_session_alloc(cctx, 0); > >>>> + if (!fl->sctx) > >>>> + return -ENOENT; > >>>> + } > >>> > >>> Shouldn't that session be allocated during open()? > >>> > >> Yes, and no, we do not need context in all the cases. In cases like we > >> just want to allocate dmabuf. > > > > Can you give an example what that would be good for? > > > > Currently the instance which does not need session is used as simple > memory allocator (rpcmem), TBH, this is the side effect of trying to fit > in with downstream application infrastructure which uses ion for andriod > usecases. That does not sound like enough of a reason then, user space is easy to change here to just allocate the memory from the device itself. The only reason that I can see for needing a dmabuf would be if you have to share a buffer between two instances, and then you can use either of them. > >>>> +static void fastrpc_notify_users(struct fastrpc_user *user) > >>>> +{ > >>>> + struct fastrpc_invoke_ctx *ctx, *n;will go > >>>> + > >>>> + spin_lock(&user->lock); > >>>> + list_for_each_entry_safe(ctx, n, &user->pending, node) > >>>> + complete(&ctx->work); > >>>> + spin_unlock(&user->lock); > >>>> +} > >>> > >>> Can you explain here what it means to have multiple 'users' > >>> a 'fastrpc_user' structure? Why are they all done at the same time? > > user is allocated on every open(). Having multiple users means that > there are more than one compute sessions running on a given dsp. > > They reason why all the users are notified here is because the dsp is > going down, so all the compute sessions associated with it will not see > any response from dsp, so any pending/waiting compute contexts are > explicitly notified. I don't get it yet. What are 'compute sessions'? Do you have multiple threads running on a single instance at the same time? I would have expected to only ever see one thread in the 'wait_for_completion()' above, and others possibly waiting for a chance to get to but not already running. > >> struct fastrpc_remote_crc { > >> __u64 crc; > >> __u64 reserved1 > >> __u64 reserved2 > >> __u64 reserved3 > >> }; > > > > I don't see a need to add extra served fields for structures > > that are already naturally aligned here, e.g. in > > fastrpc_remote_arg we need the 'reserved1' but not > > the 'reserved2'. > Yes, I see, I overdone it! > Other idea, is, may be I can try to combine these into single structure > something like: > > struct fastrpc_invoke_arg { > __u64 ptr; > __u64 len; > __u32 fd; > __u32 reserved1 > __u64 attr; > __u64 crc; > }; > > struct fastrpc_ioctl_invoke { > __u32 handle; > __u32 sc; > /* The minimum size is scalar_length * 32*/ > struct fastrpc_invoke_args *args; > }; That is still two structure, not one ;-) > >> struct fastrpc_ioctl_invoke { > >> __u32 handle; > >> __u32 sc; > >> /* The minimum size is scalar_length * 32 */ > >> struct fastrpc_remote_args *rargs; > >> struct fastrpc_remote_fd *fds; > >> struct fastrpc_remote_attr *attrs; > >> struct fastrpc_remote_crc *crc; > >> }; > > > > Do these really have to be indirect then? Are they all > > lists of variable length? How do you know how long? > Yes, they are variable length and will be scalar length long. > Scalar length is derived from sc variable in this structure. Do you mean we have a variable number 'sc', but each array always has the same length as the other ones? In that case: yes, combining them seems sensible. The other question this raises is: what is 'handle'? Why is the file descriptor not enough to identify the instance we want to talk to? Arnd