From patchwork Tue Apr 4 13:13:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 13200010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48826C761A6 for ; Tue, 4 Apr 2023 13:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234198AbjDDNOa (ORCPT ); Tue, 4 Apr 2023 09:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234795AbjDDNOZ (ORCPT ); Tue, 4 Apr 2023 09:14:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88CB0273D for ; Tue, 4 Apr 2023 06:13:36 -0700 (PDT) Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-zLGzy5rsNmKWCte2I2h_pg-1; Tue, 04 Apr 2023 09:13:34 -0400 X-MC-Unique: zLGzy5rsNmKWCte2I2h_pg-1 Received: by mail-qt1-f199.google.com with SMTP id a11-20020ac85b8b000000b003e3979be6abso21913673qta.12 for ; Tue, 04 Apr 2023 06:13:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680614014; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MmE27wy0MmMLRHR3IF88SSg1j96JW0EiZjlHTqsz8dM=; b=q//DRh7dX72HSNfKWeDZEyUAjpmoVOkh68lGrhi294b8TuYxabd62vPMD3KdNCz4AD gc1LW7ZtDeylkLQixJ6kNgfhsKnprZ/jbbCn/xri2qmCb1yiWcVd2iRSaY+NNp+8OCLZ Lzm/B/cwOknYzDKvewecXDWavOkthzmATr1NBhARrcTAIl3PVd1EbBFxjGBuQ/V/sccY ZoPHvUqBv0jlVq+vmPhfn2DP9nFfiDFai4Du8tARnTLNQBVqsgL+O5mj7o9rKkVqG0OV vngkDMQF5Z5RbkNVVzY5P9HL9qyH1Rqi8o/N9f5FetSD4XkpxHWYvurlrK4FHKbw0Zp+ 7nMQ== X-Gm-Message-State: AAQBX9dbelwrGn8cRRH23t81dDtCoFGLlXlxryLXdz5EauLCYn+AvhkE KCIu9k4ZDNAZyWnoQnN+xU2FnJqllmocpA1JtZQwLSPXKrXX6UsIqqXLyuUuROYcsypzoD8d9bC vrpFT9iM5kMHL X-Received: by 2002:a05:6214:240d:b0:5e0:63ec:5d7a with SMTP id fv13-20020a056214240d00b005e063ec5d7amr3896842qvb.46.1680614013915; Tue, 04 Apr 2023 06:13:33 -0700 (PDT) X-Google-Smtp-Source: AKy350aKm0amVIapEM6Osx9+Rfg1SXxy+vCHEeGfHbCKzQgTZk0x83W/PRr71qSe/u0h5R9nDk3onw== X-Received: by 2002:a05:6214:240d:b0:5e0:63ec:5d7a with SMTP id fv13-20020a056214240d00b005e063ec5d7amr3896807qvb.46.1680614013667; Tue, 04 Apr 2023 06:13:33 -0700 (PDT) Received: from step1.redhat.com (host-82-53-134-157.retail.telecomitalia.it. [82.53.134.157]) by smtp.gmail.com with ESMTPSA id mk14-20020a056214580e00b005dd8b9345e8sm3367788qvb.128.2023.04.04.06.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 06:13:32 -0700 (PDT) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: eperezma@redhat.com, stefanha@redhat.com, Jason Wang , Andrey Zhadchenko , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "Michael S. Tsirkin" , Stefano Garzarella Subject: [PATCH v5 1/9] vdpa: add bind_mm/unbind_mm callbacks Date: Tue, 4 Apr 2023 15:13:18 +0200 Message-Id: <20230404131326.44403-2-sgarzare@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404131326.44403-1-sgarzare@redhat.com> References: <20230404131326.44403-1-sgarzare@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org These new optional callbacks is used to bind/unbind the device to a specific address space so the vDPA framework can use VA when these callbacks are implemented. Suggested-by: Jason Wang Acked-by: Jason Wang Signed-off-by: Stefano Garzarella --- Notes: v2: - removed `struct task_struct *owner` param (unused for now, maybe useful to support cgroups) [Jason] - add unbind_mm callback [Jason] include/linux/vdpa.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 43f59ef10cc9..369c21394284 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -290,6 +290,14 @@ struct vdpa_map_file { * @vdev: vdpa device * @idx: virtqueue index * Returns pointer to structure device or error (NULL) + * @bind_mm: Bind the device to a specific address space + * so the vDPA framework can use VA when this + * callback is implemented. (optional) + * @vdev: vdpa device + * @mm: address space to bind + * @unbind_mm: Unbind the device from the address space + * bound using the bind_mm callback. (optional) + * @vdev: vdpa device * @free: Free resources that belongs to vDPA (optional) * @vdev: vdpa device */ @@ -351,6 +359,8 @@ struct vdpa_config_ops { int (*set_group_asid)(struct vdpa_device *vdev, unsigned int group, unsigned int asid); struct device *(*get_vq_dma_dev)(struct vdpa_device *vdev, u16 idx); + int (*bind_mm)(struct vdpa_device *vdev, struct mm_struct *mm); + void (*unbind_mm)(struct vdpa_device *vdev); /* Free device resources */ void (*free)(struct vdpa_device *vdev);