Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3921671imu; Fri, 30 Nov 2018 08:05:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/X3QQ3UE/FGH4ketLXlelavsNwifAb57RDbZIWANUX7dV6BB828oANYdM5hQZpLJ+eR7Gmf X-Received: by 2002:a62:546:: with SMTP id 67mr6001024pff.99.1543593907380; Fri, 30 Nov 2018 08:05:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543593907; cv=none; d=google.com; s=arc-20160816; b=PbfFZGbWgxpuSPQXBtw9Gw5yGr+/hDiCOAdQSkzJaTYPXJgPVxzTVXLEf1GvG9wsxo JX2NjJxri7iKAtl5gjLXWVuOBhkHNduyGJVUYi2oHdngB+GBbWXt5Oh5FuAwF0sZsN87 C1KURXzJSlwKZf04nrGSXqXoOXRYWn8z0vmwiYcowLiB3LhKNR4lWSQGHZYOMio2OmE6 0Xa2iIbCZqYK/VHLAee9Knv327NruAXXROH9fyRkZjqDABxbtuPL6KjMLOrqeylTx6O+ F0TGCg8gp3uMV3WAGmzapF0wt4bfD54Dr0TOW+6i35ip06Ut18bCGgTw6eZrEKOK6jsq Ki1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=e0yU3aF3N5EoBQB8hOIFIONtlSEFhDfgKSrxkNHR24k=; b=QdW9/7a8hRe2tMIFg+CTyZdPH0WxwAJgYz0L9q2g45sC1riR77cvSt5L3qcB/gVjlh 0/93dQu64MG187uixMSv1CZJhXtlGemX0q8nbFw3Go725IiBR5rHWvlbq0M3eAULcGgx LqMlRCsBIRdX4Er6xKI8+TndHDxt/EYcAksLPlzAw07R2Shv6fF7DlkWsP2vng6jLYua yNuAFgsVDtyjRRZ1XDmMZlMlDcBuWpwq00wAr1povohqHJKI8F58BDrkIeWQLLj5mDfk NpLnIIhjGrUkt1fxRmQDt1k5iCpMfSOKuQdnetYTQF6PDijyjKP0v6nvaOPNFaOQ4+nG 8AVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jjtLYjWS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si5020097pgb.545.2018.11.30.08.04.25; Fri, 30 Nov 2018 08:05:07 -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=@linaro.org header.s=google header.b=jjtLYjWS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727520AbeLADNO (ORCPT + 99 others); Fri, 30 Nov 2018 22:13:14 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36883 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbeLADNO (ORCPT ); Fri, 30 Nov 2018 22:13:14 -0500 Received: by mail-wr1-f68.google.com with SMTP id j10so5786805wru.4 for ; Fri, 30 Nov 2018 08:03:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=e0yU3aF3N5EoBQB8hOIFIONtlSEFhDfgKSrxkNHR24k=; b=jjtLYjWSTx2gDwG+i3D1OKa0cYoJts6t/hwfl/b3b9uaG+OBnAmE23SALBV7MzkM3R QZAsD6ZZKMAfdkdBAIefLPmegcSat9FBDi//eURGPx5HK+NK0kVysNuDIs2co1sE5YsS 3Ssl1RTJwt8yWf3x4z6Pqw38nyXWelHM/lwdY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=e0yU3aF3N5EoBQB8hOIFIONtlSEFhDfgKSrxkNHR24k=; b=a6FMljDK2yPc0zyrkrp47ZgfxnUWmGFPJoF/TdEgo0z5BmIfGcK+bWzbfC6H4u6wM5 6MPR/EohhJysu3vo8gnN27/tf4/AgMuQnfGD8s9oue3L92WXkew43mJAM1PGC6tL11/C X6TAKRy7Mydx5ix9IIwcLkIv7ePPg6jSSGC3CrUiTTKQYov0ZzsYp1r8CMpKl0m3hAk2 W9JnTo4V6fEa66Gc5gcRpztb8A9RYufljF34OFOAplyELck3cuDpOR9G8tbWbapvtCm9 VbRVsv5xZeuAznm7AuB6AkgxzXzUKdfqPQePNiGpGEfGJf4bezWtOE/gmdzs1Yri2qgi TaBA== X-Gm-Message-State: AA+aEWY43SQV73U/sWggbsU9lcT8Ku+CrHw8/uOOX4+ypEerdy+GW1hv n6VFSGdRtln2NFtV6uzwwIt8xw== X-Received: by 2002:adf:8b83:: with SMTP id o3mr5718427wra.81.1543593804462; Fri, 30 Nov 2018 08:03:24 -0800 (PST) Received: from [192.168.86.29] (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.googlemail.com with ESMTPSA id 125sm7317048wml.35.2018.11.30.08.03.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 08:03:23 -0800 (PST) Subject: Re: [RFC PATCH 3/6] char: fastrpc: Add support for context Invoke method To: Arnd Bergmann 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 References: <20181130104657.14875-1-srinivas.kandagatla@linaro.org> <20181130104657.14875-4-srinivas.kandagatla@linaro.org> <3c177508-cf6f-1f8d-a324-5bec40fd9a9c@linaro.org> From: Srinivas Kandagatla Message-ID: <633cb111-f5d7-3648-54af-a476f3cbb279@linaro.org> Date: Fri, 30 Nov 2018 16:03:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >> >>>> +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. >>> >> This is the case where users need to be notified if the dsp goes down >> due to crash or shut down! > > What is a 'user' then? My point is that it seems to refer to two > different things here. I assume 'fastrpc_user' is whoever > has opened the file descriptor. > >>> >>>> +struct fastrpc_ioctl_invoke { >>>> + uint32_t handle; /* remote handle */ >>>> + uint32_t sc; /* scalars describing the data */ >>>> + remote_arg_t *pra; /* remote arguments list */ >>>> + int *fds; /* fd list */ >>>> + unsigned int *attrs; /* attribute list */ >>>> + unsigned int *crc; >>>> +}; >>> >>> This seems too complex for an ioctl argument, with >>> multiple levels of pointer indirections. I'd normally >>> try to make each ioctl argument either a scalar, or a >>> structure with only fixed-length members. >>> >> I totally agree with you and many thanks for your expert inputs, >> May be something like below with fixed length members would work? >> >> struct fastrpc_remote_arg { >> __u64 ptr; /* buffer ptr */ >> __u64 len; /* length */ >> __u32 fd; /* dmabuf fd */ >> __u32 reserved1 >> __u64 reserved2 >> }; >> >> struct fastrpc_remote_fd { >> __u64 fd; >> __u64 reserved1 >> __u64 reserved2 >> __u64 reserved3 >> }; >> >> struct fastrpc_remote_attr { >> __u64 attr; >> __u64 reserved1 >> __u64 reserved2 >> __u64 reserved3 >> }; >> >> 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; }; > >> >> 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. --srini > > Arnd >