From patchwork Tue Feb 28 09:41:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 62381 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2917881wrd; Tue, 28 Feb 2023 01:49:18 -0800 (PST) X-Google-Smtp-Source: AK7set8uitblcL09czrp6z7FLsN7if6ah72xQO+U9vqPJmfegFGHKuSVhjGQyU5u3axShyW9K4Qz X-Received: by 2002:a17:906:86c2:b0:872:82d3:4162 with SMTP id j2-20020a17090686c200b0087282d34162mr1488637ejy.44.1677577758138; Tue, 28 Feb 2023 01:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677577758; cv=none; d=google.com; s=arc-20160816; b=YcwzHLivi+mjegTg+4iuCTKunjFXJehmn76IuxnFNq9QL9ANN1j2A43v2kAR7iMVs5 YLofBGWk75NYodkEesZQRXOgcJNWBo9x92D5Yao81x1J6QS/+GMIfd7An/LO5ivga5Er OZkytOMc5Ai9lYWCgzxs5UgyZilDgFRZB7nZ8MKOhrDI0KZVaFwSWWXsinfAlTpwaFVF P3uGa2BrpFDQRxLnasf+DRwDvFO8VxiGsmUxwEvNrb+PnzRXz7rJjsKQyMwOjAUo7NVV 8L8tCb8Yr00H6jHlKrp51BIOTzHF/hVfxNy7RaKYW/0gxcExUOZUyd0xhF+2Og5Swcr9 7yBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=43XkzLpWZVinLMc6qbysNTMc1WeQ5tARy2ulZHhS0yc=; b=vHY229/Ha4MvnyMMJ4dCmN4Pgn46NFChFWICpU9B4LxQKWUhLHpcr5Z4xx7r6ahXNk wgTqfSjgsGDrgXGOYAU9pinRG/UEPGDbJa1ktiG+0vHJh/rO8o+Ibvp0vLK6loPi53Z6 o0OiLaeFJAGsjVKk2gnmaep6aC00UHgldTbUFF65CFGtQOajU5J6kcHkSaQXlQvNxXKd szfEAiiFFnJ0VpJKRBUpIEKHjPCt0CCoT5E8MPrHc/BdUjDwm2O7BzykNGCERULVZ51P o3Rs/zqPBDMBHvtyYUvnMiqR3lAO8ZXMvql/77ezNhWpWmHtM8Wn5DJN163Cbtf9L98o a7lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=OnIaS9R0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm3-20020a0564020b0300b004af70a5422dsi953951edb.446.2023.02.28.01.48.54; Tue, 28 Feb 2023 01:49:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=OnIaS9R0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230042AbjB1Jmt (ORCPT + 99 others); Tue, 28 Feb 2023 04:42:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231142AbjB1Jmn (ORCPT ); Tue, 28 Feb 2023 04:42:43 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DCC2D140 for ; Tue, 28 Feb 2023 01:42:16 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id bh1so9740923plb.11 for ; Tue, 28 Feb 2023 01:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=43XkzLpWZVinLMc6qbysNTMc1WeQ5tARy2ulZHhS0yc=; b=OnIaS9R0UH4qWdL4l1OHkEdbUQV4LfcylF1rlRaJBO8Ks+LLgfX5lMXhpXOcgSxvTK 5fhOnk4BFkUvtamOmAaK8iO/aUReCim2zcyr5CIqFvfxKZhKSchItfK+QzSt3Mqul9U7 2z6bbK/bOpXqdidNHsDAV2ZxNHXR8aXMhgBfuXDSOcyUlMZV4uuvVzZGOxaoKodcsxgj 6sT+Min8zS6xY0vJXUYv5yvBAtEO45plqfro7nvIt6sHFLDCe5PuLangDy0p8EHpq45n 057ojK75FIon17rtVgMPjB4gcMzinWNzTVqG71VkvhLu9QjwBvdVRwYKgAlaYyhvPraF m/Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=43XkzLpWZVinLMc6qbysNTMc1WeQ5tARy2ulZHhS0yc=; b=BGSeR8KXqr3dzJn2a1WyoCz6FlK2LY8uDYRv9cMik4dceSEkNo3+AA/tnGPgS35tU0 JHiWj7QT+pH0MtcnG2Zlcn27oLza45/WT8b9dxQTeGRhEOdD6dMo2HFHfdJEKuD1egZZ 0ZLOi1BGNfp/nsm1i+97K+WouiaTKDf3HZ5U9AnnnkJJwZAQj9vTAsQ0EwQzcc8paYze JvfH6xxZnaran/IXKxXA6kAcFCCkFvBZEZc9qCD6N16ao/5I77HDbyfj3h3nbwlTNr93 mUkAjmf1FMCEoX01qKHv/mzF81sSpdO6wzcZAZsHD0LkWWLL//Ubj1HDw7FuGLZIvEyX R2zA== X-Gm-Message-State: AO0yUKXvvXDiERBprCeekg/Vm733kMoGUTEVhsX/+h13nMcnkRq4i6ai xFwhJcaCy5hbR8Bc6k2mh/KV X-Received: by 2002:a05:6a20:7aa7:b0:cc:120c:b259 with SMTP id u39-20020a056a207aa700b000cc120cb259mr2046843pzh.39.1677577335520; Tue, 28 Feb 2023 01:42:15 -0800 (PST) Received: from localhost ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id y21-20020a63b515000000b00502e48db9aesm5346378pge.53.2023.02.28.01.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 01:42:15 -0800 (PST) From: Xie Yongji To: mst@redhat.com, jasowang@redhat.com, tglx@linutronix.de, hch@lst.de Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/11] vdpa: Add set/get_vq_affinity callbacks in vdpa_config_ops Date: Tue, 28 Feb 2023 17:41:01 +0800 Message-Id: <20230228094110.37-3-xieyongji@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230228094110.37-1-xieyongji@bytedance.com> References: <20230228094110.37-1-xieyongji@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759067774879200257?= X-GMAIL-MSGID: =?utf-8?q?1759067774879200257?= This introduces set/get_vq_affinity callbacks in vdpa_config_ops to support interrupt affinity management for vdpa device drivers. Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/virtio/virtio_vdpa.c | 28 ++++++++++++++++++++++++++++ include/linux/vdpa.h | 13 +++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c index d7f5af62ddaa..f72696b4c1c2 100644 --- a/drivers/virtio/virtio_vdpa.c +++ b/drivers/virtio/virtio_vdpa.c @@ -337,6 +337,32 @@ static const char *virtio_vdpa_bus_name(struct virtio_device *vdev) return dev_name(&vdpa->dev); } +static int virtio_vdpa_set_vq_affinity(struct virtqueue *vq, + const struct cpumask *cpu_mask) +{ + struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vq->vdev); + struct vdpa_device *vdpa = vd_dev->vdpa; + const struct vdpa_config_ops *ops = vdpa->config; + unsigned int index = vq->index; + + if (ops->set_vq_affinity) + return ops->set_vq_affinity(vdpa, index, cpu_mask); + + return 0; +} + +static const struct cpumask * +virtio_vdpa_get_vq_affinity(struct virtio_device *vdev, int index) +{ + struct vdpa_device *vdpa = vd_get_vdpa(vdev); + const struct vdpa_config_ops *ops = vdpa->config; + + if (ops->get_vq_affinity) + return ops->get_vq_affinity(vdpa, index); + + return NULL; +} + static const struct virtio_config_ops virtio_vdpa_config_ops = { .get = virtio_vdpa_get, .set = virtio_vdpa_set, @@ -349,6 +375,8 @@ static const struct virtio_config_ops virtio_vdpa_config_ops = { .get_features = virtio_vdpa_get_features, .finalize_features = virtio_vdpa_finalize_features, .bus_name = virtio_vdpa_bus_name, + .set_vq_affinity = virtio_vdpa_set_vq_affinity, + .get_vq_affinity = virtio_vdpa_get_vq_affinity, }; static void virtio_vdpa_release_dev(struct device *_d) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 43f59ef10cc9..d61f369f9cd6 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -250,6 +250,15 @@ struct vdpa_map_file { * @vdev: vdpa device * Returns the iova range supported by * the device. + * @set_vq_affinity: Set the irq affinity of virtqueue (optional) + * @vdev: vdpa device + * @idx: virtqueue index + * @cpu_mask: irq affinity mask + * Returns integer: success (0) or error (< 0) + * @get_vq_affinity: Get the irq affinity of virtqueue (optional) + * @vdev: vdpa device + * @idx: virtqueue index + * Returns the irq affinity mask * @set_group_asid: Set address space identifier for a * virtqueue group (optional) * @vdev: vdpa device @@ -340,6 +349,10 @@ struct vdpa_config_ops { const void *buf, unsigned int len); u32 (*get_generation)(struct vdpa_device *vdev); struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev); + int (*set_vq_affinity)(struct vdpa_device *vdev, u16 idx, + const struct cpumask *cpu_mask); + const struct cpumask *(*get_vq_affinity)(struct vdpa_device *vdev, + u16 idx); /* DMA ops */ int (*set_map)(struct vdpa_device *vdev, unsigned int asid,