From patchwork Fri Dec 23 05:55:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 36136 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp156355wrn; Thu, 22 Dec 2022 21:58:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXutNstUbVcA839RVnlHymmhl1C6BpqEfmkmJ/EpbkH2GR4tZy1MWoJnKxxsDdOWsW2vvOId X-Received: by 2002:a05:6a00:2191:b0:574:3595:a4af with SMTP id h17-20020a056a00219100b005743595a4afmr12055040pfi.2.1671775119792; Thu, 22 Dec 2022 21:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671775119; cv=none; d=google.com; s=arc-20160816; b=ErxRU62kvpDSEta5mB6ZZs8zp2N9Ge4XKdRQ3cWwidxU0TUSi9xqCWX9tq0xWn8S9G YW6d9bU2ITQjqPTCbQflI9TWL5NbsV96Ewo+MiKTwB3ZpZUn4fQsDhLr7zrUoS5zR8OH f0030horm/HzDDtXwvynL9pEfoaYZce+YoxyWvaHfHldk7dWIOd7s34DYIexlQWj3+uJ KV1ooifuEdl6i4LcGRvuVbvpITeG4VpS4QlDljYFYiB6Bk6aKnFKuVmBw46T6XOIwgIv e0J2NhVgYV2adhqwS+wROjAY1y2KwfAeTPIj9jubrA+SkixmhmAozenrMzqJp7zUOqvH V22A== 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=xglbcwBtHUzE7Svvg1D0riaViqFayLrBuEpuMnhx0Os=; b=tSF0GpU18CHxg1DdA4Qf9Dxb59elEaGtOAIfj0pqixYPUf6DeaL9KBkeXKKtYfunGw FQRO51+Piiv1JM4UMgMaHdtZQ152bAdShb+G3wHULOQ5rzI0iZmJ1XiWDfOMms8mDOtM Asq3dFaC10eEAL8rF5tSsyN82CjrDRUynOhjwAc2V3GVv2hZ6RVunmuTY2RqLNeWfNJt /4KM8R8M4g2TlIKDcWgb74yF2ak/jr9423EUxYvKXn387EeWmeFBwYbMbiLn/tQhyPNw /2rpwelNaehCIKwzvns3CXuCY8DdLCtVj9f2FjW7H9acex8C5r9i6ro0Tpnap0EjjcEn 4/qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XdlTGVxW; 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=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p3-20020a056a000b4300b00562331a3562si2811782pfo.130.2022.12.22.21.58.27; Thu, 22 Dec 2022 21:58:39 -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=@redhat.com header.s=mimecast20190719 header.b=XdlTGVxW; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbiLWF4s (ORCPT + 99 others); Fri, 23 Dec 2022 00:56:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiLWF4p (ORCPT ); Fri, 23 Dec 2022 00:56:45 -0500 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 7FECA62EF for ; Thu, 22 Dec 2022 21:56:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671774960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xglbcwBtHUzE7Svvg1D0riaViqFayLrBuEpuMnhx0Os=; b=XdlTGVxW+l+jL/D5wFjjOyPKjiDzBnMDQ4RD7MfGP4ixcGKkoLfRvW+YhAI+SKo/p/8jyl VMND92Ecptunn1uVnaSWxL1T2MyueHpZjSmd/PXt/niysZu4J0rbdi9wd2Ltt20J0lCyJr shj61LOKCJGA1X1HfDYtrZV/zvasjZU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-153-9wZ9O01HPuOwAkPNvArVfw-1; Fri, 23 Dec 2022 00:55:57 -0500 X-MC-Unique: 9wZ9O01HPuOwAkPNvArVfw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C2C1518811F4; Fri, 23 Dec 2022 05:55:56 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-204.pek2.redhat.com [10.72.12.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30D0D40C2064; Fri, 23 Dec 2022 05:55:53 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com Cc: sgarzare@redhat.com, eperezma@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 1/4] vdpa_sim: switch to use __vdpa_alloc_device() Date: Fri, 23 Dec 2022 13:55:45 +0800 Message-Id: <20221223055548.27810-2-jasowang@redhat.com> In-Reply-To: <20221223055548.27810-1-jasowang@redhat.com> References: <20221223055548.27810-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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?1752983267918672792?= X-GMAIL-MSGID: =?utf-8?q?1752983267918672792?= This allows us to control the allocation size of the structure. Reviewed-by: Stefano Garzarella Acked-by: Eugenio PĂ©rez Signed-off-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index cb88891b44a8..118dbc8e5d67 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -249,6 +249,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr, const struct vdpa_dev_set_config *config) { const struct vdpa_config_ops *ops; + struct vdpa_device *vdpa; struct vdpasim *vdpasim; struct device *dev; int i, ret = -ENOMEM; @@ -266,14 +267,16 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr, else ops = &vdpasim_config_ops; - vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, - dev_attr->ngroups, dev_attr->nas, - dev_attr->name, false); - if (IS_ERR(vdpasim)) { - ret = PTR_ERR(vdpasim); + vdpa = __vdpa_alloc_device(NULL, ops, + dev_attr->ngroups, dev_attr->nas, + sizeof(struct vdpasim), + dev_attr->name, false); + if (IS_ERR(vdpa)) { + ret = PTR_ERR(vdpa); goto err_alloc; } + vdpasim = vdpa_to_sim(vdpa); vdpasim->dev_attr = *dev_attr; INIT_WORK(&vdpasim->work, dev_attr->work_fn); spin_lock_init(&vdpasim->lock);