Received: by 10.223.185.116 with SMTP id b49csp1457963wrg; Wed, 21 Feb 2018 19:47:46 -0800 (PST) X-Google-Smtp-Source: AH8x225n0rV6Y3sLLMY0GehXvJBIJ+5IkCAENuQpu7OzISN+An9OkCWl/H01/R6HHD6CyZz+prZQ X-Received: by 10.101.81.132 with SMTP id h4mr4561776pgq.332.1519271266618; Wed, 21 Feb 2018 19:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519271266; cv=none; d=google.com; s=arc-20160816; b=Bw2aUsCdyGfQQCFQze9aTgv/RVSNcNr0OIUxzrM+s9YoA2ivzAzvZuduMLFI2LEvA0 aW8OmyiD6MxwctvpYt6k9cV/2z6jAPNYlEcvlZe4BovZKC9TwfPmf98xbQGwjSKtQpLF z+cscRNbGsFmmBjPyiHEgwwOaKanBznpORhP79EsctYKDEsaB9kEKXssfCO0WlQOQ5OG SF0LvL8PN0E7tFalob88EmUWYg3rT4zhP3BYTBbiSWysux+m3z35SStnJBzO4UVKX32C 2SroL1WnyY6Pduw+5MllQtfwkhAlJubMvzYXU1bWWMYN+x8ELCuCpF+Gzlwk0LPPc44i QNgg== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=PslOoHvM6prYE4CN44Ohhxq2sa1u0UjEHxFbMFFO3Os=; b=MFNQ5zh/LK+DLlFiZ22w+Eza5P1N8AhCP8Eq+ZHHqb9TaoVDYyrqUpvGVIDWbqDdwv BsO5uPHH7uGILhbmxBVbwbnnbpImeFk+9pu172J5XvzTHQm+CO1UH3KCpmykhGjja0Tr U+9zGD+l9Gu30tsfsBv5JV3Ki2aOUOLtdek5gPcGrT1lCrA+cOEg9PfS/9YYETJlftl3 BO8N+XQJnTBG/DbdUPYnys338ebz9BntyXxg+F76MuzOCbEdpMdjjPyuKamtWK1VLAWh b380IwlUjqqdCCY18rqdjGLKK/tOuGL1s3VmdviCg3EeMzXCinzXENbH4mrCPdwzH01S r5KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r65sU34G; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si3904598pfe.266.2018.02.21.19.47.31; Wed, 21 Feb 2018 19:47:46 -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=@gmail.com header.s=20161025 header.b=r65sU34G; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752094AbeBVDq4 (ORCPT + 99 others); Wed, 21 Feb 2018 22:46:56 -0500 Received: from mail-vk0-f66.google.com ([209.85.213.66]:35040 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbeBVDqz (ORCPT ); Wed, 21 Feb 2018 22:46:55 -0500 Received: by mail-vk0-f66.google.com with SMTP id n132so2329912vke.2 for ; Wed, 21 Feb 2018 19:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=PslOoHvM6prYE4CN44Ohhxq2sa1u0UjEHxFbMFFO3Os=; b=r65sU34GChJSqFw7mQ0A4Q0wgA+hqPkwEQrYv+hBY2JlQD781v7M0wSb40YIy2fhRI gz5V5zynHOU4qsQi6ovYMqM9HYUGnCccanmcc/u21oYlOwmjt5WnXzr9V8Tufq/P1kk8 Nd+3PGDhNj8Q4bB0arIZx/+GHnPVxH416zBmjNnQpOiq6Cea+X5khLbKrOFJXFM3a3fP tAXXKap8zyZzof5pmNOgdWtENwa7rUzugVYT87JlmF2KR2A/DchHd6lBE90RiZqY4Spi 7cMs/Xb0ccmTzB3qj2ndDasNqZJWAY+wMmSQKcVF9xqIK+c//c2EhBd2ERfdqu4sYq8W wS+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=PslOoHvM6prYE4CN44Ohhxq2sa1u0UjEHxFbMFFO3Os=; b=oqWbygAotc6eWyVtOXk2RLb/ZD1G2YbG8LzzlC8VW/VXhEo/bu2Ua1L8xWxOBbMT/A cALTeY5eRGaIjyN++S7LW08GRY9gwwcSh5POZLi8Cire/FxxkQErEZ/3RtEH01+JhOkY DPmdAY2yot+6pzIJ16d60osXUEjs4HvaFUi+GJxim3YUPUtG9hD4kj2HYo9vKLsW97Ue sNJ9tf8xczd1brEkWOFnweZJ08rtmmDEe5RoKaWZCwFJgvObM6JMvOW+mkjFPaMnU4H7 lER3r95TOlKdy1XcjDqHtfOeV2DWN1mqBUiVqTfUhzcGA7XIvj34MzYcdyOifEp2xpws 8yGA== X-Gm-Message-State: APf1xPD9fz9aZ05jCJfUobw34XSKXj+fMXcIKSx3k3NA2HTLic8SbFzD LpcAoN7EUJ/GVFDuuNJhCSN9Dhij+90OUbM5huI= X-Received: by 10.31.206.198 with SMTP id e189mr4076079vkg.164.1519271214181; Wed, 21 Feb 2018 19:46:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.97.142 with HTTP; Wed, 21 Feb 2018 19:46:53 -0800 (PST) In-Reply-To: References: <20180221045736.7614-1-alastair@au1.ibm.com> From: Balbir Singh Date: Thu, 22 Feb 2018 14:46:53 +1100 Message-ID: Subject: Re: [PATCH] ocxl: Add get_metadata IOCTL to share OCXL information to userspace To: Frederic Barrat Cc: "Alastair D'Silva" , Arnd Bergmann , frederic.barrat@fr.ibm.com, Greg KH , "linux-kernel@vger.kernel.org" , linuxppc-dev , Andrew Donnellan , "Alastair D'Silva" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 21, 2018 at 10:25 PM, Frederic Barrat wrote: > > > Le 21/02/2018 =C3=A0 07:43, Balbir Singh a =C3=A9crit : >> >> On Wed, Feb 21, 2018 at 3:57 PM, Alastair D'Silva >> wrote: >>> >>> From: Alastair D'Silva >>> >>> Some required information is not exposed to userspace currently (eg. th= e >>> PASID), pass this information back, along with other information which >>> is currently communicated via sysfs, which saves some parsing effort in >>> userspace. >>> >>> Signed-off-by: Alastair D'Silva >>> --- >>> drivers/misc/ocxl/file.c | 27 +++++++++++++++++++++++++++ >>> include/uapi/misc/ocxl.h | 22 ++++++++++++++++++++++ >>> 2 files changed, 49 insertions(+) >>> >>> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c >>> index d9aa407db06a..11514a8444e5 100644 >>> --- a/drivers/misc/ocxl/file.c >>> +++ b/drivers/misc/ocxl/file.c >>> @@ -102,10 +102,32 @@ static long afu_ioctl_attach(struct ocxl_context >>> *ctx, >>> return rc; >>> } >>> >>> +static long afu_ioctl_get_metadata(struct ocxl_context *ctx, >>> + struct ocxl_ioctl_get_metadata __user *uarg) >> >> >> Why do we call this metadata? Isn't this an afu_descriptor? >> >>> +{ >>> + struct ocxl_ioctl_get_metadata arg; >>> + >>> + memset(&arg, 0, sizeof(arg)); >>> + >>> + arg.version =3D 0; >> >> >> Does it make sense to have version 0? Even if does, you can afford >> to skip initialization due to the memset above. I prefer that versions >> start with 1 >> >>> + >>> + arg.afu_version_major =3D ctx->afu->config.version_major; >>> + arg.afu_version_minor =3D ctx->afu->config.version_minor; >>> + arg.pasid =3D ctx->pasid; >>> + arg.pp_mmio_size =3D ctx->afu->config.pp_mmio_stride; >>> + arg.global_mmio_size =3D ctx->afu->config.global_mmio_size; >>> + >>> + if (copy_to_user(uarg, &arg, sizeof(arg))) >>> + return -EFAULT; >>> + >>> + return 0; >>> +} >>> + >>> #define CMD_STR(x) (x =3D=3D OCXL_IOCTL_ATTACH ? "ATTACH" : >>> \ >>> x =3D=3D OCXL_IOCTL_IRQ_ALLOC ? "IRQ_ALLOC" : >>> \ >>> x =3D=3D OCXL_IOCTL_IRQ_FREE ? "IRQ_FREE" : >>> \ >>> x =3D=3D OCXL_IOCTL_IRQ_SET_FD ? "IRQ_SET_FD" = : >>> \ >>> + x =3D=3D OCXL_IOCTL_GET_METADATA ? "GET_METADAT= A" : \ >>> "UNKNOWN") >>> >>> static long afu_ioctl(struct file *file, unsigned int cmd, >>> @@ -157,6 +179,11 @@ static long afu_ioctl(struct file *file, unsigned >>> int cmd, >>> irq_fd.eventfd); >>> break; >>> >>> + case OCXL_IOCTL_GET_METADATA: >>> + rc =3D afu_ioctl_get_metadata(ctx, >>> + (struct ocxl_ioctl_get_metadata __user = *) >>> args); >>> + break; >>> + >>> default: >>> rc =3D -EINVAL; >>> } >>> diff --git a/include/uapi/misc/ocxl.h b/include/uapi/misc/ocxl.h >>> index 4b0b0b756f3e..16e1f48ce280 100644 >>> --- a/include/uapi/misc/ocxl.h >>> +++ b/include/uapi/misc/ocxl.h >>> @@ -32,6 +32,27 @@ struct ocxl_ioctl_attach { >>> __u64 reserved3; >>> }; >>> >>> +/* >>> + * Version contains the version of the struct. >>> + * Versions will always be backwards compatible, that is, new versions >>> will not >>> + * alter existing fields >>> + */ >>> +struct ocxl_ioctl_get_metadata { >> >> >> This sounds more like a function name, do we need it to be _get_metdata? >> >>> + __u16 version; >>> + >>> + // Version 0 fields >>> + __u8 afu_version_major; >>> + __u8 afu_version_minor; >>> + __u32 pasid; >>> + >>> + __u64 pp_mmio_size; >>> + __u64 global_mmio_size; >>> + >> >> >> Should we document the fields? pp_ stands for per process, but is not >> very clear at first look. Why do we care to return only the size, what >> about lpc size? > > > My bad, I forgot to mention it before. There's a somewhat high-level > description which needs updating in: > Documentation/accelerators/ocxl.rst Thanks, that's helpful > > It doesn't go down to the level of the structure members, but at least al= l > ioctl commands should have a brief description. > > lpc_size could be added. It's currently useless to the library, but doesn= 't > hurt. The one which was giving me troubles on a previous version of this > patch was the lpc numa node ID, since that was experimental code and felt > out of place considering what's been upstreamed in skiboot and linux so f= ar. > Yeah, I think metadata will evolve for a while till it settle's down. Since ocxl_ioctl_get_metadata is exposed via uapi, a newer program calling an older kernel will never work, since the size of that struct will always be larger than what the OS supports and our copy_to_user() will fail. The other option is for the user program to try all possible versions till one succeeds, that is bad as well. I think there are a few ways around it, if we care about this combination. Balbir Singh.