From mboxrd@z Thu Jan 1 00:00:00 1970 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 2C91BEB64DC for ; Fri, 16 Jun 2023 10:30:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344863AbjFPK3x (ORCPT ); Fri, 16 Jun 2023 06:29:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344641AbjFPK25 (ORCPT ); Fri, 16 Jun 2023 06:28:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 308FA35A6; Fri, 16 Jun 2023 03:26:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4ADF16245F; Fri, 16 Jun 2023 10:26:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD969C433CD; Fri, 16 Jun 2023 10:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686911180; bh=PFdVP3w56nb0swUwL53Xe87mE6lCu9SOZzlblVkMk7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hT7Qfcds3Wr5cKyDDQ1DYdqpK9MxpfRcQhUmsEK0q6EEZtrHP96WDfYs4kJ5dpa7a KjML+zhKcdP6gD+XUFVy33w8nijZhAD4RBe4Y0z/4NwCGQ+52DFEjEPsAy8f8VpX/g V/f+Ahny6fx6Jh26jBBCgWPH/kyp28ECUNPi4agdZsVJlW1KKP36bHk9mAH6+Vg0YD +wxY7QMb9K+2tIJXqLHtmLsd28g98A6QTscpfPbFyZt9wsc0EXSKJHstMemjQzKAeq UW29PTUE0OFmMoxNbei12tjVukscBgyl6iTq6hsu0yiXHBm1xYDFrSKddPVf1OdySZ XT5fUmlkY8XVg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shannon Nelson , Jason Wang , "Michael S . Tsirkin" , Sasha Levin , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.3 29/30] vhost_vdpa: tell vqs about the negotiated Date: Fri, 16 Jun 2023 06:25:17 -0400 Message-Id: <20230616102521.673087-29-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616102521.673087-1-sashal@kernel.org> References: <20230616102521.673087-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.3.8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shannon Nelson [ Upstream commit 376daf317753ccb6b1ecbdece66018f7f6313a7f ] As is done in the net, iscsi, and vsock vhost support, let the vdpa vqs know about the features that have been negotiated. This allows vhost to more safely make decisions based on the features, such as when using PACKED vs split queues. Signed-off-by: Shannon Nelson Acked-by: Jason Wang Message-Id: <20230424225031.18947-2-shannon.nelson@amd.com> Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/vhost/vdpa.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 74c7d1f978b75..a5e4722cbeda1 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -385,7 +385,10 @@ static long vhost_vdpa_set_features(struct vhost_vdpa *v, u64 __user *featurep) { struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; + struct vhost_dev *d = &v->vdev; + u64 actual_features; u64 features; + int i; /* * It's not allowed to change the features after they have @@ -400,6 +403,16 @@ static long vhost_vdpa_set_features(struct vhost_vdpa *v, u64 __user *featurep) if (vdpa_set_features(vdpa, features)) return -EINVAL; + /* let the vqs know what has been configured */ + actual_features = ops->get_driver_features(vdpa); + for (i = 0; i < d->nvqs; ++i) { + struct vhost_virtqueue *vq = d->vqs[i]; + + mutex_lock(&vq->mutex); + vq->acked_features = actual_features; + mutex_unlock(&vq->mutex); + } + return 0; } -- 2.39.2