From patchwork Wed Feb 7 05:43:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cindy Lu X-Patchwork-Id: 197742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2023026dyb; Tue, 6 Feb 2024 21:47:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPwncYuyIaDgovDyl0OiXsKG2c5L2PmGSBwCDMf2P9AAa/MId6wBNVAR6UzkJI1/NceJDL X-Received: by 2002:a05:6402:750:b0:55f:40a5:c49b with SMTP id p16-20020a056402075000b0055f40a5c49bmr3314297edy.38.1707284862696; Tue, 06 Feb 2024 21:47:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707284862; cv=pass; d=google.com; s=arc-20160816; b=fxIzb06IfxxuF4KxOhs1pegHr9HN6LrlkRcq1hajqPjz26OMPipLqMRffKAouRYkiu WETshJIQ5TDK2DyM2K3IsDQSf8na5vH+jVg+1Gp2Eltv2UKjd9htl1rLYo+3MQKyrtYG C0oQS1TBOPhpaHJVyL57uyYPvOURabrkj5IdOWrwnY6gZ6HX2m2t4MHvIYmRkPC/hNru jhjZWFeoXvHbvKjttYbJkuXun0WisB7kJAdkym1DA/E27nphv1lxoGKPLTelJvueO7XX OB9p85Omv9sd5Ub/cbXL2Rr1DwYO6RGhc0dBMMX0molhEYguQE8fYHRxA6h4W/bK9LRt db7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=11vsPZmrTyORN2f8NF7cBdxobijSaF6IqQZ7CKve6yA=; fh=j2rkOSw7ssakclD8X3GmYaPl7gAIGW+AbInwzlXjhm4=; b=HNi1wxnnuY03A2HxlIRs+TClVSGXoDou2Dq0maSyaeYaCY6K/nNOP28htfykhnfFME 0I+6iRfIqNJ/BCBGxoOXRkqHm+zFLCxAtNrd8X3G+4TXC0dYz7ke2RV1pOyGmBcAn/4i yOzqqJt9AYsRTppo5lHEag4FT4uTCKNrTsjZ9hkGNa0VTvux49qseLq1aJGEM4TAVhyz QR/SyxZ8iVBPOH6Nq4TyJPs/lyu/W51n/7O91S+4To5Cd8TwmAxGHlGh6Kg7EvpQ9cUP n6V9pSaIinFg8ZjQbEDIxFEPz9ug1QWgT2SF3DULY1IvsretlIsCAor2bdSYycleO6jx akMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LMGVVyqY; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55981-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55981-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCVDtYtcigBZqw3slbbgPjcVT9yZ9A8FO5htWkDciiwuaGcxPjFSXaAjFR6xj0zQDadgGiDubngzEKDnMFxHEX9pfSBKOg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b28-20020a50ccdc000000b00560410689d1si430140edj.31.2024.02.06.21.47.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 21:47:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55981-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LMGVVyqY; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55981-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55981-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4F7BA1F23461 for ; Wed, 7 Feb 2024 05:47:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52A181CF8D; Wed, 7 Feb 2024 05:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LMGVVyqY" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE6F71CD1B for ; Wed, 7 Feb 2024 05:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284836; cv=none; b=uOeovQ6sz57n0IXL9HI8f+wBFXSAdX7D5tNH9935yfepDeu+LHXCfQWMQ5va68EOlP5T7tQb1rjcebwIay04orFoBT0KAdVyRog9QXFOoYhw4erNnMcUbN4fYU79RuyPCiSUcfgbtQA0ky4BkcwhYUWqCV3PZXYOX3KmLPHEAk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284836; c=relaxed/simple; bh=/j71C6LLegHXOz3snuWsv0xGmVODLdDmNr+bmnXNKGQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O2011Jv9QAgv18ygmHQVClOndpAJSlwcptQSu2YR2BopMQfV8HiB7YQqpCbd4kBBsAI9KtETV4NUf1lIklGxvPshkIGCeVRSaavk7ppuO3lwAZU9CEXOOnzwa4XEXTXXSdtcR3HHr+rqHUA++C2oT5FWm+rg02zMkfaeHyX8Sdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LMGVVyqY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707284833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=11vsPZmrTyORN2f8NF7cBdxobijSaF6IqQZ7CKve6yA=; b=LMGVVyqY+2gP/OVXtD4viCVzO4+YD4TUWKUVEDhHJHs3gc28WojwuTaZVBNbzH7k0jD/mO vbL5l9/dUMyU9BRVnS/hcsRvhZpCGcyynoM7nB49LT5UkHLc/ArJWisx+iT6VEBDRbooRa ygJ4yuZ2MslQbGNXEOt28VLrpOM9P8Q= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-pTo_-G6PNOeBD3YIKSAkdw-1; Wed, 07 Feb 2024 00:47:11 -0500 X-MC-Unique: pTo_-G6PNOeBD3YIKSAkdw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 66E371C04B54; Wed, 7 Feb 2024 05:47:11 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA41CC1690E; Wed, 7 Feb 2024 05:47:08 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v4 1/5] vduse: Add new ioctl VDUSE_DEV_GET_CONFIG Date: Wed, 7 Feb 2024 13:43:28 +0800 Message-ID: <20240207054701.616094-2-lulu@redhat.com> In-Reply-To: <20240207054701.616094-1-lulu@redhat.com> References: <20240207054701.616094-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790217932297488173 X-GMAIL-MSGID: 1790217932297488173 The ioctl VDUSE_DEV_GET_CONFIG is used by the Userspace App to get the device configuration space. Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 21 +++++++++++++++++++++ include/uapi/linux/vduse.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 1c1d71d69026..ab246da27616 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1368,6 +1368,27 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, ret = 0; break; } + case VDUSE_DEV_GET_CONFIG: { + struct vduse_config_data config; + unsigned long size = offsetof(struct vduse_config_data, buffer); + + ret = -EFAULT; + if (copy_from_user(&config, argp, size)) + break; + + ret = -EINVAL; + if (config.offset > dev->config_size || config.length == 0 || + config.length > dev->config_size - config.offset) + break; + + if (copy_to_user(argp + size, dev->config + config.offset, + config.length)) { + ret = -EFAULT; + break; + } + ret = 0; + break; + } default: ret = -ENOIOCTLCMD; break; diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 11bd48c72c6c..125d7529d91b 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -350,4 +350,7 @@ struct vduse_dev_response { }; }; +/* get device configuration space */ +#define VDUSE_DEV_GET_CONFIG _IOR(VDUSE_BASE, 0x1b, struct vduse_config_data) + #endif /* _UAPI_VDUSE_H_ */ From patchwork Wed Feb 7 05:43:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cindy Lu X-Patchwork-Id: 197747 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2023639dyb; Tue, 6 Feb 2024 21:49:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjTcv8cQcx7U+gdTdnTcVhLGnXJskXb8gYRqV0d+H6iKctQXVNbXCmmAO8o3qnJ5j9HqAH X-Received: by 2002:a81:ce09:0:b0:604:7b9e:f62f with SMTP id t9-20020a81ce09000000b006047b9ef62fmr3658184ywi.37.1707284987546; Tue, 06 Feb 2024 21:49:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707284987; cv=pass; d=google.com; s=arc-20160816; b=tsqCTx/yRHP8maH6UZ/hcELPwCaKxSngLyvpQFS4It5k7hbPU7oYbtPKNeJG5Zl6ku TbJR6ubSrLqG4AzQInPM4N05K6vo/tuoMYrUXN9FqXP/ke3sgYnN6US7TvvWige3HMkn EnymSM7Gm8RXRhoFKw984E5CgjxzldLXDS4X5E8WA1CedjX6LEiTAhAxKIReHfkGeVTj K9pjkazbn4/rcT/TKjILMjb/LByTdxh2/MChoxk8Pd+q3NK4iSHV1mABhNpve0kowgFm hRwj3XpCyzVRJhL/CbINho6AJclIqX4foT6yV6ifuSczAMk4pHC3inxpLGOTDGMMBIKM ZfLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=hwsrIyNME3xvIfwfaV6NG7sB+rLE21QzcYEDoBZyr4Q=; fh=1jA0oFPtk7ZX3iIrUS3/TVv0elVijhyWka7sr2bXDXQ=; b=qsAjW4fjuqBlJszaZIE53tDhVGonRdNJRq2DTd/FewyLewpB+I36D17IVuuJJxYeyC bS6kgjnODm7nI6rqhxAKsN4CydbpweQlbHs7fpIMxCGh7wWx3AkMYtd9/1VpaEhhCi9/ YNBA6zrqSVV+Jvef2iuRvTlAkv5/2Vmal64tMbQplrwQGZRqJoZMgB/fzXkgs/EqYfCh TFdOi2NS3PZ+fSLc0WrcOCahkuCIdzVL4J0oAyEGv2Bs6AZ4EIDW0D26DRQjR6TTDraB EelljoyP7REx7tjOjiGcaRvhjSCVA9wfn8CjvIWAPZ0lsKob+g6TfRviZfrFhbkw/U8B 9HHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JwnglLS9; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55982-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55982-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCU8e8TD3FpXWt41Ytw7TOhvin7yseL8sIyUYMjuQaUuN16HQCn5WQjjmP8CNyhP6xJGkVAj/ql0hkP34I4ZrEDMsfWihA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x18-20020a63b212000000b005b92edaa151si713286pge.739.2024.02.06.21.49.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 21:49:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55982-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JwnglLS9; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55982-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55982-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E1983B27864 for ; Wed, 7 Feb 2024 05:47:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 075481D554; Wed, 7 Feb 2024 05:47:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JwnglLS9" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 901161CF92 for ; Wed, 7 Feb 2024 05:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284839; cv=none; b=YfCrnWoTkehzVx2y9ofxreLEDWQR0RYM0Mw20LzQt3FZ+bQNzfQ9LyGcfOFrAeMi+e/pvCzV+9EvptM9/kX0xVpuFIOPEB0baBnZC+2WfUNODijuCEiudQPFRluYFt1+phQzyrCor19uBIz9+NNZeG4Nt4ceJoZHomNdvOx6QUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284839; c=relaxed/simple; bh=j1lCtWf8kQGK0h6m9q3I3l1BoBQdXKPTjFjyW0xeUpg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LwT54F+B9ff/4roH/Dlu8JJZhQefMCnhz8WmYAO06Se9ZjoWC8L73e3YcBY6OjzC83meGU0u6JHdBFwvUL4V0Saz/ZvIO4lVe+YtKS+FCpoAqpuW+2LohCquh+Vfp4LAlfha5aH2YaX/OENDy8q7/PLSPc8n/SpU/FuhxiRm86k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JwnglLS9; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707284836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hwsrIyNME3xvIfwfaV6NG7sB+rLE21QzcYEDoBZyr4Q=; b=JwnglLS9NH/V7kX7W39P1A4wZ2sisDAKL0Bw4qQR32eMDaRQOeBxsYwcvxQgirV7kUzmr2 6EzR0zeV5eI0lsv63/JWiyOvkAcQV8Kmsxi1qPZSHTzRia08eOVvRTXZpciJZ7s+MQxz+r QkfiINwneTYC0O1O07RT4zu7vnu1xKQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-DczEB4sWPJKuz0ywDfuvYg-1; Wed, 07 Feb 2024 00:47:14 -0500 X-MC-Unique: DczEB4sWPJKuz0ywDfuvYg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8902483722F; Wed, 7 Feb 2024 05:47:14 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08522C1D36C; Wed, 7 Feb 2024 05:47:11 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v4 2/5] vduse: Add new ioctl VDUSE_DEV_GET_STATUS Date: Wed, 7 Feb 2024 13:43:29 +0800 Message-ID: <20240207054701.616094-3-lulu@redhat.com> In-Reply-To: <20240207054701.616094-1-lulu@redhat.com> References: <20240207054701.616094-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790218063067635749 X-GMAIL-MSGID: 1790218063067635749 The ioctl VDUSE_DEV_GET_STATUS is used by the Userspace App to get the device status Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 7 +++++++ include/uapi/linux/vduse.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index ab246da27616..ef3c9681941e 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1389,6 +1389,13 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, ret = 0; break; } + + case VDUSE_DEV_GET_STATUS: + /* + * Returns the status read from device + */ + ret = put_user(dev->status, (u8 __user *)argp); + break; default: ret = -ENOIOCTLCMD; break; diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 125d7529d91b..f501173a9d69 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -353,4 +353,6 @@ struct vduse_dev_response { /* get device configuration space */ #define VDUSE_DEV_GET_CONFIG _IOR(VDUSE_BASE, 0x1b, struct vduse_config_data) +#define VDUSE_DEV_GET_STATUS _IOR(VDUSE_BASE, 0x1c, __u8) + #endif /* _UAPI_VDUSE_H_ */ From patchwork Wed Feb 7 05:43:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cindy Lu X-Patchwork-Id: 197743 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2023150dyb; Tue, 6 Feb 2024 21:48:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWksXvGFv+nQk3BcIAwQD7kSwsjSoYXsNIdZRG5AjvGrj1VVG5q8uNGBzToIlh1bSh8htnQ+NeQ25Dnianjx4wF8+Wi7Q== X-Google-Smtp-Source: AGHT+IF8bHA5DSyC5q2hA17u06iMEa0Sqa5kdXmIKmTEESA5QNIJRwvv0ltGaft0McvyvCduULnd X-Received: by 2002:a05:6808:1415:b0:3bf:e765:c64e with SMTP id w21-20020a056808141500b003bfe765c64emr3248028oiv.48.1707284888422; Tue, 06 Feb 2024 21:48:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707284888; cv=pass; d=google.com; s=arc-20160816; b=KkGSEj4ERyg/vzi6Au9pTRhZtxXyECCt51zfhEkgwKPjBgSHdSuJ1pRv23AKrkoerr DEU+2KMP4XooG1lk+NaeEdcpQCsAMx2q7aAWA/aOKP9ly28y6P1WzD5pC7Rxg8GDe90c 47t2lnh0tiLQvWAREtWOP3f8r1L6Vehwy8yLdNRxV+c3P/YfPf62VJRzJKE7dscJvw4U Bmxrkg9J06aH4cpEqe9rav5CTwfzVA5PvSq/ZNMy4qvz8zy4aLOkPc0fSstez3hjWREC ONCSBMz/LNMdPcKZi9uCvdKDUN9pl3KKwKZk4P7ZU355zYTeUcwObSR9NiSvCc4xl7Kd cMOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=x2Trg27lougTGtlprzjhUTV72eb8EddnblMr0yERIK0=; fh=qeR5EomaZI6/7hAlidhGnjs85Hss4lsp1Y3hapU7We8=; b=mMy5niZYf+poizUdTPAGkdnF04rcvdrO/WazVdYb1H7AAY3O2lPAHNEU/f9ErBbc7n TW1M6irsjlaOBAXXEF8uJYeLbzPSmWyLgO+DrOFuz0LazWfJ093/qeFSDTeP9vh8VxR2 adqPBm5z0zTdGcpiqYrIfTBaJ3pSyhdahJkqxv4jF686EoJQPGstK/mhYET497BDiv5Y dE0hkwTvWCdmyekfoFtWXWBjyfDaTwtcY9Uec5N2H2BA6dgFk6FUdVsSqWAOT/p9057o IgwSFNeWk8DY3eYsEs5VGz/ks20A/8wDGKqX4s1BJO8ENRr/NBeWT65T4DnfUnh1/3x3 0MOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i8seLXJQ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55983-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55983-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWtuc+illXER7EHFrcnBNS9GP/qor3/868FFebl9lBP7t/pxlKZ0LbmbI8q5aBODdmKxXZSeQEkYc7VkpFcQqoET+MDHg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b1-20020a056a000cc100b006dddfc5e391si823865pfv.20.2024.02.06.21.48.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 21:48:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55983-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i8seLXJQ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55983-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55983-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2CE35289982 for ; Wed, 7 Feb 2024 05:48:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E6F31F922; Wed, 7 Feb 2024 05:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i8seLXJQ" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46D461D557 for ; Wed, 7 Feb 2024 05:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284843; cv=none; b=Cl28Pi3kiFG7Obfn4MfhNzMeaEXmNfmwL2wlTi+4f8b+VHVAbzQ1tEq9hId4nPzhWDS21309iC2AfXtzOA+GaAURqJbNiVgdNBx62rzTCbrJIAXDiL2+UxFpamz7GmOrpu7Z/iTkPr/HXbzjAbXET9c37S5SP0sGBtEb9jzTTJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284843; c=relaxed/simple; bh=cBLjryLsVfu47+tjl5ywQAYVk9Q3xIPJ/WF63oos9zU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ltQ7Yhwe0N10/9Yvr58hTBoi5zpfK3g+e2h+h2Wx3PMCF6iT/wZxRsa2jVhFyNXTUV5W9pMrXqL+8O5LLf3wQxU9kNlrxLV3rmYFMsd33DBCFdScLglojLDt/iRgnZRJC5XpU6UPNZ2FwZv2BDK8dn6Y4SOCKXIXA3hHEUcNOiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i8seLXJQ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707284840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x2Trg27lougTGtlprzjhUTV72eb8EddnblMr0yERIK0=; b=i8seLXJQFjjXGxS32e9vPn2GjccPNCgs4y6B6zF1NQWRhS1ZWBhBRtUKNDFiZ60Yaz196b PLl3QOxKdm70E9GBGse9LGofDFD/EsvGYe7s9u2t2YV6nhREX6J/wpOzRY8vSeNQzJREEF W7grPgZ2tv+Xs38SxVMYAieBkLjPy/0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-Iw2rWcrUNuqMBJ5bPpkdgA-1; Wed, 07 Feb 2024 00:47:17 -0500 X-MC-Unique: Iw2rWcrUNuqMBJ5bPpkdgA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A942E85A58B; Wed, 7 Feb 2024 05:47:17 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AC67C07F51; Wed, 7 Feb 2024 05:47:14 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v4 3/5] vduse: Add function to get/free the pages for reconnection Date: Wed, 7 Feb 2024 13:43:30 +0800 Message-ID: <20240207054701.616094-4-lulu@redhat.com> In-Reply-To: <20240207054701.616094-1-lulu@redhat.com> References: <20240207054701.616094-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790217958960505006 X-GMAIL-MSGID: 1790217958960505006 Add the function vduse_alloc_reconnnect_info_mem and vduse_alloc_reconnnect_info_mem These functions allow vduse to allocate and free memory for reconnection information. The amount of memory allocated is vq_num pages. Each VQS will map its own page where the reconnection information will be saved Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index ef3c9681941e..2da659d5f4a8 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -65,6 +65,7 @@ struct vduse_virtqueue { int irq_effective_cpu; struct cpumask irq_affinity; struct kobject kobj; + unsigned long vdpa_reconnect_vaddr; }; struct vduse_dev; @@ -1105,6 +1106,38 @@ static void vduse_vq_update_effective_cpu(struct vduse_virtqueue *vq) vq->irq_effective_cpu = curr_cpu; } +static int vduse_alloc_reconnnect_info_mem(struct vduse_dev *dev) +{ + unsigned long vaddr = 0; + struct vduse_virtqueue *vq; + + for (int i = 0; i < dev->vq_num; i++) { + /*page 0~ vq_num save the reconnect info for vq*/ + vq = dev->vqs[i]; + vaddr = get_zeroed_page(GFP_KERNEL); + if (vaddr == 0) + return -ENOMEM; + + vq->vdpa_reconnect_vaddr = vaddr; + } + + return 0; +} + +static int vduse_free_reconnnect_info_mem(struct vduse_dev *dev) +{ + struct vduse_virtqueue *vq; + + for (int i = 0; i < dev->vq_num; i++) { + vq = dev->vqs[i]; + + if (vq->vdpa_reconnect_vaddr) + free_page(vq->vdpa_reconnect_vaddr); + vq->vdpa_reconnect_vaddr = 0; + } + + return 0; +} static long vduse_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) @@ -1672,6 +1705,8 @@ static int vduse_destroy_dev(char *name) mutex_unlock(&dev->lock); return -EBUSY; } + vduse_free_reconnnect_info_mem(dev); + dev->connected = true; mutex_unlock(&dev->lock); @@ -1855,12 +1890,17 @@ static int vduse_create_dev(struct vduse_dev_config *config, ret = vduse_dev_init_vqs(dev, config->vq_align, config->vq_num); if (ret) goto err_vqs; + ret = vduse_alloc_reconnnect_info_mem(dev); + if (ret < 0) + goto err_mem; __module_get(THIS_MODULE); return 0; err_vqs: device_destroy(&vduse_class, MKDEV(MAJOR(vduse_major), dev->minor)); +err_mem: + vduse_free_reconnnect_info_mem(dev); err_dev: idr_remove(&vduse_idr, dev->minor); err_idr: From patchwork Wed Feb 7 05:43:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cindy Lu X-Patchwork-Id: 197744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2023209dyb; Tue, 6 Feb 2024 21:48:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpmjKOVuIS3zWfKWY++/E79BsT79W5OvYtyzST5ddTgbGMyq91fQsE2CREzy3ky6bnTa68 X-Received: by 2002:a17:90a:fa02:b0:296:a6dd:98c9 with SMTP id cm2-20020a17090afa0200b00296a6dd98c9mr1700107pjb.42.1707284902573; Tue, 06 Feb 2024 21:48:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707284902; cv=pass; d=google.com; s=arc-20160816; b=S/GHQP15E/o5CQMra2L+NK+HPUEQ2YwEaPMFbfogUYhzawiu7qOQhPjqlTIyEESYPK ALZ5BN7K2GeZC9nULE3OtqDqRRC2tQ5XXQKaB75Ptsizso6fWat5M3Cd2g2bhHn/ClK8 MCGKadiepMEnEjSY1NS5cCtHZXxx1LWAaB240E7ItLbF94LWAkOtrfTQRKciJyNsM7lo u6HslH9DXJtZCntu5ns34AocKdDIBDGbMN3tTYSdcXjy4mQrtywJJo6qzBjNLHj9km1e 3tfyZ7WE4H0dPASWfBtI2LpHLJyVAqDLrsOku6pr1ZPfQ7JqZls/1HoejsxMm6JUbxoR DHsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=dx4vuXIklQBxh8l06pvXMAeW4Cc8GkKcbpmXFc8So2o=; fh=5q/GdiSBE0R8IjW034XCMmTTa1UCpYeHOvxnjprlBlo=; b=obMy4/Waxisox88wM/+Mlx8ST4x3duNdEe5DtDVhsn1RiU5wUfHYFqZC2KQUNibNhs FrZQY866kiSPFmg2Hx469N7OFloJVQ8vEeVQgS7XW8TD+vr+rTS7fMaN6DhvSiG4e2nv elZvzPGEz1dXtQaQxNmBiS8Gj9Rewm5AduRmD0OaCTIRQrpN+CyHu9m54Fd7g8zeZW5b 6YVAqELLd8t0xjlNR61qLsfzcbBSD7GZ4uga2YMpo1hC55PTLY3ENIMr7ga4IASAmGvD fnJhrVmoN39SCdXlmeZ6pnNlfsLW/cEctHhAmFWBA5lioqzzYxN2ybKNkpi1YXOWu3EI fBrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KAVrWgRy; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55984-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55984-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCXG6UmzlZ/tbbjcEvRZCbYBEDVmXZ3Q4mn5QBMktz9wy1YcpDZZahLvWE1Rt1EfwUOqFJb7XMi6bRJ9FDYRcvQwTviG+A== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h9-20020a170902f2c900b001d9374b44f4si705754plc.653.2024.02.06.21.48.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 21:48:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55984-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KAVrWgRy; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55984-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55984-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5D1C0289B34 for ; Wed, 7 Feb 2024 05:48:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67409200C1; Wed, 7 Feb 2024 05:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KAVrWgRy" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AAE41F946 for ; Wed, 7 Feb 2024 05:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284866; cv=none; b=qR+tGSuzlQ57Ri4pnicTRT3VYL480D1iGHlSt4nj4TkNY6ez1o10iYExUBXflWJKE2BhpCdMwdxRyM6mPfwQym22qGyPO69K5kBpBmRCq2gji7RQeIxjbwrOn6FUtk8/209m1ezaIzr1FUJ2X9XaoDCCE7Ewik2OSlFqTkrB0cM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284866; c=relaxed/simple; bh=WXKHRU/uEj6cYAvi50bYRlcQ0ruywm7WIxvBv/gN2jw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CZeWhJw8XReDTeEbaP8+N2HpvbCXoO3wGD6XVtUQW5kbw2lWdntRZiDcgzRinMUFk+d3DaFOgT1O0uXmvi6u6tAT49elpmHzYCEyQIFM3P+7s7gSTqP/owxAqOx1nsYvkCABI8NFCo77h5mwbJTRnzj0DHgczjKeXjYeSan6tvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=KAVrWgRy; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707284864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dx4vuXIklQBxh8l06pvXMAeW4Cc8GkKcbpmXFc8So2o=; b=KAVrWgRyXEykUOLAu0jhOuMlhtYEoyN72bjR+qtPzV78S/o5F2ME3nlQLsELdK1X3hGnh1 0CARfeXjyCNflfs7JIwSDSFZtCgG6YKCa98T+LBZrb71UD6CNTAaO4qTsrcuy7xxL6sTde SIAKAZzXp2reaydwshFQ7GWtGfZNySQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-499-5UgG03rVNwC6AlVylbb-5A-1; Wed, 07 Feb 2024 00:47:42 -0500 X-MC-Unique: 5UgG03rVNwC6AlVylbb-5A-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 586DA3C0F247; Wed, 7 Feb 2024 05:47:42 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBF64492BC6; Wed, 7 Feb 2024 05:47:39 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v4 4/5] vduse: Add file operation for mmap Date: Wed, 7 Feb 2024 13:43:31 +0800 Message-ID: <20240207054701.616094-5-lulu@redhat.com> In-Reply-To: <20240207054701.616094-1-lulu@redhat.com> References: <20240207054701.616094-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790217973945969621 X-GMAIL-MSGID: 1790217973945969621 Add the operation for mmap, This function will be used by the user space application to map the pages to the user space. Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 2da659d5f4a8..083fe0047677 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1465,6 +1465,61 @@ static struct vduse_dev *vduse_dev_get_from_minor(int minor) return dev; } +static vm_fault_t vduse_vm_fault(struct vm_fault *vmf) +{ + struct vduse_dev *dev = vmf->vma->vm_file->private_data; + struct vm_area_struct *vma = vmf->vma; + u16 index = vma->vm_pgoff; + struct vduse_virtqueue *vq; + unsigned long vaddr; + + /* index 1+vq_number page reserved for virtqueue state*/ + vq = dev->vqs[index]; + vaddr = vq->vdpa_reconnect_vaddr; + if (remap_pfn_range(vma, vmf->address & PAGE_MASK, + PFN_DOWN(virt_to_phys((void *)vaddr)), PAGE_SIZE, + vma->vm_page_prot)) + return VM_FAULT_SIGBUS; + return VM_FAULT_NOPAGE; +} + +static const struct vm_operations_struct vduse_vm_ops = { + .fault = vduse_vm_fault, +}; + +static int vduse_dev_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct vduse_dev *dev = file->private_data; + unsigned long vaddr = 0; + unsigned long index = vma->vm_pgoff; + struct vduse_virtqueue *vq; + + if (vma->vm_end - vma->vm_start != PAGE_SIZE) + return -EINVAL; + if ((vma->vm_flags & VM_SHARED) == 0) + return -EINVAL; + + if (index > dev->vq_num) + return -EINVAL; + + vq = dev->vqs[index]; + vaddr = vq->vdpa_reconnect_vaddr; + if (vaddr == 0) + return -EOPNOTSUPP; + + if (virt_to_phys((void *)vaddr) & (PAGE_SIZE - 1)) + return -EINVAL; + + /* Check if the Userspace App mapped the correct size */ + if (vma->vm_end - vma->vm_start != PAGE_SIZE) + return -EOPNOTSUPP; + + vm_flags_set(vma, VM_DONTEXPAND); + vma->vm_ops = &vduse_vm_ops; + + return 0; +} + static int vduse_dev_open(struct inode *inode, struct file *file) { int ret; @@ -1497,6 +1552,8 @@ static const struct file_operations vduse_dev_fops = { .unlocked_ioctl = vduse_dev_ioctl, .compat_ioctl = compat_ptr_ioctl, .llseek = noop_llseek, + .mmap = vduse_dev_mmap, + }; static ssize_t irq_cb_affinity_show(struct vduse_virtqueue *vq, char *buf) From patchwork Wed Feb 7 05:43:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cindy Lu X-Patchwork-Id: 197745 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2023294dyb; Tue, 6 Feb 2024 21:48:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyhwcJ7lF+Mv9qlyqw4NNLrDMzVH51eMm6gfCSZaAs2Gh+AWK/1HbSdoRZWZTzFFqKJfeq X-Received: by 2002:a17:902:dac6:b0:1d7:450c:be68 with SMTP id q6-20020a170902dac600b001d7450cbe68mr4196328plx.66.1707284917167; Tue, 06 Feb 2024 21:48:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707284917; cv=pass; d=google.com; s=arc-20160816; b=JQncFK6fwHKyAriUXatp0Ikn5aiii45rAHJadAhtDb3MuhRSMAv/I3VZO+7KxA2N+n 4/2oxOuscWydUflSzSpqZoddmGlQie5WRByZT3Ze7tcX2tzjaPV7tCoG3wTLWG0J9jgo ON96dRoS7DfEYVj6732GAC2wfo4LohqBnv0in6C0Acv9tUehZkDgEPw7sCOW81DItsee X7gkBRFvilSNLrQq9TutislTmRur5wKxx1+07VhSHvyZQSDC70Bl17YdvyAgeQzfJrcC tUIanydoNypkxPKzHoKKRh765Ab/OLRAjVEYJu2WVbWN1pXjm9lDSEAKzmMzYmCwcVKK rvlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=mxvyLlwFPrOAb4E1s475cmzm9HXLhSgjIXU0tbGtRvE=; fh=kbEg9e5S5heTlZqsXA7xcqbJ0dZJ9wLL0IOc+nRkdSE=; b=0h/hxLvKsjRXpw6T9Eh/1qU2pQcL14KtH493sl5rBlXNJXez1/tOf9ixYfH5F981O3 jFQ+YMhQxgT0MP7noYGzwO1DvacI2rvNfYzE8KoH4xKvVtr9srlUwwYvHxGh6hRcP9/W 3kg7CtzvLt43JbeuPywpRf3rTlivKsGHMauDd5uHrR5rZ4I0ehCaQ2SnXK3jhfxXIToe IfeRGIG1dH4hjfBoZ6z16hldKHt/M+fKrQaVduUiL8LgLoBQXl9UXNWrH+pHGtFBBFVI 3SF5YNeRcgSbtKsAFBPNmAxSS3cNdr2l2iknZzfT2Rf4yKZ3/GsBUjmfm164QAh3wwOI inzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=flQ3DrS5; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55985-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55985-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWfxa0iaVbPyLY2VhHIjDX78iqFWcwn5G2x7Rm5oI/SbmmEPlExajfodm/GaJPjIcpyoYvbqiHV1yS9qWmYcp3BbrQmSg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id iw3-20020a170903044300b001d9727a7422si749479plb.650.2024.02.06.21.48.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 21:48:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55985-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=flQ3DrS5; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55985-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55985-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E4B5E289DFE for ; Wed, 7 Feb 2024 05:48:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5A9820316; Wed, 7 Feb 2024 05:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="flQ3DrS5" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DF96200A8 for ; Wed, 7 Feb 2024 05:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284872; cv=none; b=ohQPa59raDocByFa2rZTX2m/VEeqD7ArJvfhBbumoUCf2Hx3GKEp5tP/B2DwYfj/MKuoCdwXRQY0nHbHhAfu8iTwdCVwj4NW2/+Hia9ouwENe8a0PY9wHw6uzQmr7X5P9eCxYoEvD/UTJD4VvTEpsCQqxHEVx0s6SI+sov8BkXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707284872; c=relaxed/simple; bh=6uX9zfQ8cQJ8WnngTxHu/ne5naJ+QAafInm6eyaxJy0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cs2sFLY1F5GkGSBNB32ScPaSvYjbQbPbO8oQz12+4vcN1A1LWlSCUziI+xXqBe71MNkrLNrbWMEJa27OOippbBIFNSAgT698BVir7cLz1kPjz8mUhexEfxMGbrAZ7lyRN9eb4LdPWiWtATryFlUJO2HMj4i9OOjVcoGYwop5e5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=flQ3DrS5; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707284869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mxvyLlwFPrOAb4E1s475cmzm9HXLhSgjIXU0tbGtRvE=; b=flQ3DrS54ZCp8VW/C5iohqfH+ufwKd3U+3uuU+lpCH3CxRRSrcDQQC/qjhwbXI5bj/GdIr d9uhc7xY2vHc5IcpdKdvdv4wzOI3qVG9hEO5VnJXHMDW/vxuW/+kCSicf6Bokrj1fyC4d4 Nl85h+naRLbd26T5kXR8AuGK4YXKO6g= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-6-f3trEO6NNI-I9I6uYGLkcQ-1; Wed, 07 Feb 2024 00:47:45 -0500 X-MC-Unique: f3trEO6NNI-I9I6uYGLkcQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76D903811F41; Wed, 7 Feb 2024 05:47:45 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECCD7492BC6; Wed, 7 Feb 2024 05:47:42 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, xieyongji@bytedance.com, linux-kernel@vger.kernel.org, maxime.coquelin@redhat.com Subject: [PATCH v4 5/5] Documentation: Add reconnect process for VDUSE Date: Wed, 7 Feb 2024 13:43:32 +0800 Message-ID: <20240207054701.616094-6-lulu@redhat.com> In-Reply-To: <20240207054701.616094-1-lulu@redhat.com> References: <20240207054701.616094-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790217989186825288 X-GMAIL-MSGID: 1790217989186825288 Add a document explaining the reconnect process, including what the Userspace App needs to do and how it works with the kernel. Signed-off-by: Cindy Lu --- Documentation/userspace-api/vduse.rst | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/userspace-api/vduse.rst b/Documentation/userspace-api/vduse.rst index bdb880e01132..a2be85e0e516 100644 --- a/Documentation/userspace-api/vduse.rst +++ b/Documentation/userspace-api/vduse.rst @@ -231,3 +231,35 @@ able to start the dataplane processing as follows: after the used ring is filled. For more details on the uAPI, please see include/uapi/linux/vduse.h. + +HOW VDUSE devices reconnectoin works +---------------- +0. Userspace APP checks if the device /dev/vduse/vduse_name exists. + If it does not exist, need to create the instance.goto step 1 + If it does exist, it means this is a reconnect and goto step 3. + +1. Create a new VDUSE instance with ioctl(VDUSE_CREATE_DEV) on + /dev/vduse/control. + +2. When the ioctl(VDUSE_CREATE_DEV) function is called, the kernel allocates memory + to save the reconnect information. + +3. Userspace App need to mmap the pages to userspace + Userspace App need to map Pages 0 to vq_number for vq status, + Users can define the structure for saving the reconnect information themselves + in the userspace. + +4. Check if the infomatin sutiable for reconnect + If this is reconnect: + Before attempting to reconnect, The userspace application need to the + ioctl VDUSE_DEV_GET_CONFIG,VDUSE_DEV_GET_STATUS,VDUSE_DEV_GET_FEATURES... + to get the and confirm if these information are suitable for reconnecting. + +5. Start the userspace App. + While running, the application should store the relevant information about + reconnections in mapped pages. + When calling ioctl VDUSE_VQ_GET_INFO from the userspace APP to get vq information, it is necessary + to check if this is a reconnection. If a reconnection has occurred, the vq-related information + must be get from the mapped pages. + +6. When the Userspace App exits, it is necessary to unmap all the reconnect pages.