From patchwork Tue Feb 28 09:41:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 62377 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2916981wrd; Tue, 28 Feb 2023 01:46:40 -0800 (PST) X-Google-Smtp-Source: AK7set80K/IkE+EAfGVIfeDtPzAa8KIevEMcpAJhZz6xEvsDTaQwL8KTMPN0Yc9aSPfobx8aEvHV X-Received: by 2002:a17:906:e49:b0:8b2:5e3c:e0f0 with SMTP id q9-20020a1709060e4900b008b25e3ce0f0mr2122569eji.74.1677577600044; Tue, 28 Feb 2023 01:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677577600; cv=none; d=google.com; s=arc-20160816; b=0QoL3U/KN64ZCQcGZrONj/TjclC+VwAN5XRNZ5P4PQ9FvKac5UKomISUQbaoeg2xoI pS+2IlaSpWDKctcDWXySr1xV+SxdwzKPZ1Quf85B/bdUmg+Y+NEx1SxuJG5i82XEubuv 0Q8u/GVq8Oq8SbsVjg0wtIxQXr6E4I+06siZtd+h/1t8j/DZXjtmXX1SWvN9GI/b6SIS 6rAs0s5twNOtR2UO/K554+0l00ObZ8ytRfODQI4220iqjWeNgnuJtD1uy0ctc4ST/Beh 17Fz4Lom3iFyDv7d4dyD8LAEnGuUzq8r0oMbm0fS6mtJT38gl39P0SxHWsrRh0RZ9AJN O2yA== 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=4LeXo4wlRPLjaFCDUlWd/vTm6oCQxlpO5FWsfhmVL4c=; b=oqZJeaMIvKiPVA/FgHfoTM6/dFij9ScHpEa1D/+ztCUl53L1KUkfRkN/jC3zTEreS/ OcLb61fUJ9nmK64Ao5awGzov4oNpWTAmM2kWOwNjTdt/jjurlzl6kEXMZJuYmyIWy5lS hhGuqosg9ktPcTjoCyc3i4qa6t/hNQ2dQX4PpKPTK2srYc3OFQo5/tmwBCG++3hg1Gx8 8VAXAR5Vr8HEBp/gJa3g7UiEqpNzOt5cuRbZFCPqXlNGgGsSWLqAfTd59TLwrp2Tlqjt TT0BuEPzzdeRBevgeq3qwRHTw7LUWMGjq0qhNTHCUaE8d9H6qROqvp94wgnWJ2uKD5lO bMAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="jCF/GGa9"; 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 k17-20020a17090627d100b008d092516220si2716823ejc.863.2023.02.28.01.46.17; Tue, 28 Feb 2023 01:46:40 -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="jCF/GGa9"; 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 S230300AbjB1JmX (ORCPT + 99 others); Tue, 28 Feb 2023 04:42:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbjB1JmV (ORCPT ); Tue, 28 Feb 2023 04:42:21 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20DB2CFE8 for ; Tue, 28 Feb 2023 01:42:19 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id n5so5269026pfv.11 for ; Tue, 28 Feb 2023 01:42:19 -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=4LeXo4wlRPLjaFCDUlWd/vTm6oCQxlpO5FWsfhmVL4c=; b=jCF/GGa9lIkRMXEETq9mILXcYfSU+l7wJJCBS/zOo80F2sCHGtOCUJYzhpcVmI5iSJ 7o4Mi57hybiDlC4/jTo4q0MnvArNeUPFnz3V3PHt6GJmPlMoFRQrdmP/iJ8HPv+TbrqM HZX1aD7DvYy12DY1TP+jsbMCyoUlAuLBXx5ocYH6kaYVzwm4gy7z7//J2vZ2rgdyHvzg kiFaAik8PxswTSDDlDNz3EMhlPwkHwLp20/eVb/vwa4yGijprJa61KLUTWsEB/EvKktr FQyCwFFElfzKeQYZ6tMam6/e35BV0dPnAblV6Dktp82JlmCJ3se/54OII1yIUvgNouLE mylg== 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=4LeXo4wlRPLjaFCDUlWd/vTm6oCQxlpO5FWsfhmVL4c=; b=cgwCy1shfML8F6qVqDgLGnP6c1C6mkR7W3S5OyooZ9aiVMM9/dXx9VbKfmtAu762ke LsPC3Vn/jXgyUk9u7tszTiJwC2Hjd5PM7OSi6UQx846Bjo6nkkv1DpNx6NRPE5AN/IZB 3VQxInJXkQxd5GTVlCQhcEvwSvfEJZV2yaadBgwJbDoLzdzN/rATHgpeEZL7fKWlmAqC daxzF1+IDSwejKg0jO146xLsBUu09gRVvAEmhhyXVrX6+edTF242Ll081/O4mCp7rMnf 3ND5KHpo/MkN8cWiugvkh1isA+KWaIYcvV6elPR5T38znWpWoI6IA2zFEctUPaTDI1Nj Rh4w== X-Gm-Message-State: AO0yUKVwGvs1twsf6FE67yi1+5RHVtsH46IhBjECdAe5qkibOXnm6pFJ GwlJs/1wXyO54etv67TVTed67qgamrq/HT0= X-Received: by 2002:aa7:8428:0:b0:600:cc40:2589 with SMTP id q8-20020aa78428000000b00600cc402589mr1758849pfn.3.1677577339176; Tue, 28 Feb 2023 01:42:19 -0800 (PST) Received: from localhost ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id w3-20020aa78583000000b005abc30d9445sm5609518pfn.180.2023.02.28.01.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 01:42:18 -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 03/11] vdpa: Add set_irq_affinity callback in vdpa_config_ops Date: Tue, 28 Feb 2023 17:41:02 +0800 Message-Id: <20230228094110.37-4-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?1759067609585745018?= X-GMAIL-MSGID: =?utf-8?q?1759067609585745018?= This introduces set_irq_affinity callback in vdpa_config_ops so that vdpa device driver can get the interrupt affinity hint from the virtio device driver. The interrupt affinity hint would be needed by the interrupt affinity spreading mechanism. Signed-off-by: Xie Yongji --- drivers/virtio/virtio_vdpa.c | 4 ++++ include/linux/vdpa.h | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c index f72696b4c1c2..9eee8afabda8 100644 --- a/drivers/virtio/virtio_vdpa.c +++ b/drivers/virtio/virtio_vdpa.c @@ -282,9 +282,13 @@ static int virtio_vdpa_find_vqs(struct virtio_device *vdev, unsigned int nvqs, struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vdev); struct vdpa_device *vdpa = vd_get_vdpa(vdev); const struct vdpa_config_ops *ops = vdpa->config; + struct irq_affinity default_affd = { 0 }; struct vdpa_callback cb; int i, err, queue_idx = 0; + if (ops->set_irq_affinity) + ops->set_irq_affinity(vdpa, desc ? desc : &default_affd); + for (i = 0; i < nvqs; ++i) { if (!names[i]) { vqs[i] = NULL; diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index d61f369f9cd6..10bd22387276 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -259,6 +259,13 @@ struct vdpa_map_file { * @vdev: vdpa device * @idx: virtqueue index * Returns the irq affinity mask + * @set_irq_affinity: Pass the irq affinity hint (best effort) + * from the virtio device driver to vdpa + * driver (optional). + * Needed by the interrupt affinity spreading + * mechanism. + * @vdev: vdpa device + * @desc: irq affinity hint * @set_group_asid: Set address space identifier for a * virtqueue group (optional) * @vdev: vdpa device @@ -353,6 +360,8 @@ struct vdpa_config_ops { const struct cpumask *cpu_mask); const struct cpumask *(*get_vq_affinity)(struct vdpa_device *vdev, u16 idx); + void (*set_irq_affinity)(struct vdpa_device *vdev, + struct irq_affinity *desc); /* DMA ops */ int (*set_map)(struct vdpa_device *vdev, unsigned int asid,