From patchwork Tue Apr 6 19:40:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 12185819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6007CC433B4 for ; Tue, 6 Apr 2021 19:41:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C5A961158 for ; Tue, 6 Apr 2021 19:41:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C5A961158 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 928806E8B3; Tue, 6 Apr 2021 19:41:35 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2075.outbound.protection.outlook.com [40.107.92.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8308A6E8A4; Tue, 6 Apr 2021 19:40:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iqDsaY0vBKudrCQc08+bzrZWjBMke6NRg3P7xzAVqMRblb1Yl8TG8OVIZruGqXkrkGXSI1elzeJy8R3Dd0QlSpmPHxZHcDzOH9xFHIYsDBYHNHmLkav8ZKvSGFRmf4ERVpUpg7bbpyAJHv8Y44fltEevAtKzhi8YteYvyZVF45euDQId+Sub7a4bJfbmrCXdS/f0DqFaxsQFQ+wozRTOohA+oUXuvigf2/j9QT4ZQgKetuiMe0ys5UXXPqTa0DGSgysmkKZB43oylPMi5cCHcKKN0paXSaaMTD6l885noeIYO7wsUQSjB1eqkfIrx9lTPoe0MIftChih5t1nJlKEQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qEJ2XEneEfvcX3+MPP5Hc/BeZz23h3q1AYfQ0BQVTkg=; b=bk/E6SI25OG06Ucdua/ZJQXQHg7smnCjCR1lnYtpSZoM/LYiZSDh6S6IjoGAczSJsXWldYtEry++2G7XD9P3FgB1Eo/x1WfHl71WXZYYfhKhogM8DVR7B/n72TKhKp3bt0OdIHqjvfDVmLy2YvoxpaLwFjWod0rxYrcbJV2iYnhbkY6v08t6qZN0E/W6btpT2q7LNwJxKEgIsHeUOdvHlS+rWRDse8zj/OK4NZVG5UhwdFHZ5VfD/xuAntMSPB/XPv3SswBaSLBrtHvEn5YL1i/2asBJTQI5u2dkFgVynKz4VDslZPCWlUh6QVH2xewFGSDHrXxZaor27jSegPuCug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qEJ2XEneEfvcX3+MPP5Hc/BeZz23h3q1AYfQ0BQVTkg=; b=FdTYNnS3yXanQCYQeHQx1lWuXFhzzJp71zKy0UR2HOZG4qPzqSPA2Y0fHyjAFgc55ERzvMuKt1KUr9WDogpY+KmOn6Yk/zzcstdWZ2PEyP2EXF6SXornhRarTH4Tp5j9Y9eNvbeoKdPDarPwORafLtesp7fvXT8GL9KOyDCeDWLoKTixD22SiOKLcSXkYKfZApHcz7Yl3fSEfWyasCYj1a40oQDZ49SHBK/ORVfY5nG+OVnXvSolsWhJt1tjCduJ0nD7DYlkBOVAsLQiKMT2GT3A3QZTF7N3gO0GU88bVGnrMGvMF9VBzThS08KMiHqYp/nyu7jSua9TLvhKm1cdcg== Authentication-Results: linux.ie; dkim=none (message not signed) header.d=none;linux.ie; dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB2859.namprd12.prod.outlook.com (2603:10b6:5:15d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27; Tue, 6 Apr 2021 19:40:45 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87%6]) with mapi id 15.20.3999.032; Tue, 6 Apr 2021 19:40:45 +0000 From: Jason Gunthorpe To: David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi Date: Tue, 6 Apr 2021 16:40:38 -0300 Message-Id: <15-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> In-Reply-To: <0-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> References: X-Originating-IP: [142.162.115.133] X-ClientProxiedBy: BLAP220CA0005.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::10) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (142.162.115.133) by BLAP220CA0005.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Tue, 6 Apr 2021 19:40:43 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lTrZ4-001mXm-DA; Tue, 06 Apr 2021 16:40:42 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 155698ca-fb66-4d42-344b-08d8f933de0d X-MS-TrafficTypeDiagnostic: DM6PR12MB2859: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GtAuAjW7NOecAOytIYv6ONaotyJ8FuRtfLohiQrFV7wQ4l7WLTEXWzWd7kAZ90jytPdUtV8//FFSsvkFfEHwGUKZmsaVfikraxzTiJ7Si0tYcxNy99t03wJkwQ/vM4kQ7TK+O/XuOo4iC/SIrVyuTzMdczkYptXnr/mCqmXup2Xusgts6AUVIfym0sfA5PYVJqM8D3AnvIL4YJmIOYbaulnNwjEd787oyaCIybo2D1UQupbRWuaJpKRjUxO0Lns0S9392bS69HvIAPkTbUuOY+8PijB5ivedrSOqVWpDhTBcQ6dUPIzQ+BA/UC34FwW6gxB2YKnpGgw00ff1mBrDCWDEZ88auWovI7G5gK7B/epEbG9vrvtaGbkXG1bVlaAa2ht7G8BpDlMJ3ssfu7d0gtVwEjmaxvAM9y/3aOYwsHhSEeY2LvJMlYAnZWXkwtziRR+fhKDtZJH9jFE73jqLV5K0Nj2iaoINtHpwAbqkRCaeh6SlQ0eBswluY7hy93ET31dXXyisGBnG1oPEVgEtpxf2J3VGVUUTZHXBE+sc3oEMhaMGdht4djwwLyuyO7LShuaDDXGpgb56/PRhA/hAR3ENV5NJsh93/SpqugEqMi2zKHg5+NoApeMXeFDCZ0zOsdcxsxNKikt4AkkLx+ts579oGtKwpjVpk9ogMTQKK6o= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB3834.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(376002)(346002)(366004)(136003)(396003)(54906003)(86362001)(2616005)(26005)(8936002)(38100700001)(66476007)(426003)(7416002)(66946007)(5660300002)(316002)(36756003)(66556008)(2906002)(6666004)(107886003)(83380400001)(186003)(478600001)(110136005)(4326008)(8676002)(9746002)(9786002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: zuGF5mpZLnbQR8TdOl8FvYu9sXjecrpFXUwENKJeTDiRPEr40ra8s97FQkUnbWXK/pN22nUT1+FT97QPp9Xo+6U7t3ZUCeweHqk5qXGQsk+9fElWBQ6Z8wcryBdGpH+YO80vkRfkXeUE0GY8EerZYIzvTmoPtoZJopy9IQ/YkUpSF34Kl+IqDbkHRQRKgcniVmbYHiL8DcJ6/UrLXkiQhagHSneth/3gM+twysQHs2fv43GXG5f12aRjsZedQm/1Tp7DL4r0DDnSbtLSECug+wtqegacWbCgnsB1hPE5KxNLOmZnY8Be2FnUDW3LXn1go4BWoMvEGp9RZ/kyBd4QnTFY0eE+JE99opqOZT0/fefYExp+NW5NMsNZjSYpo5nQr6DWEb5HCuxwE7YIgn4Cze8pHLKE7BaUAs23fB0OmDQCOt9aimRdPUPsbF0a9nsjaqEhQ+XxFWRmSbg4IquqJyiZArhH68TPLEwl4rZGU7omxbrXr1wVCOJRYUumMRx+3TLytJYmMZI/H6wMVHEHdTMeu+NlPUMjn4AwSYvdj2RFutLhEJwiyKc26wJ8OpXkvdsqDEqzmjwBS/OM0JeG8dTaGjTavf9LH8tJel27VD1l/LRyAcT+0fbZanJKvsirDNxqBETcdJsHNSmfOQmP7a8WlppcROx+sYaWHpOV5Bde5qLJTDYzU/mAgfUPEyPXBEQbEs8JcYw+SCqgxXf0NliuFFNwzMOGui51JgP6XfGnQSB9l0A+c6wNL+3bTbPlZI+MJtgVgRSYZsEpTmfG/0+UnDD524IgTWcjC/9xjQ47sqmXnE567thDf1NI88tX1uDfqrQOS/alfMNLYoDMO9ZvlCpgGxgtOeY2gTcoQRZX+kqM6AJZ74MLf170zqgI38V6ZPYVNMMGXsdqypLqHe7HRPsB+VADy1chxwaLewO6t5lHjPVZQf9IvO2rh5BNdD6ahd63sv+vylCEw1JE7pSVGzylsZUJyezJhiL0saJSy7b3/t2AcKJlZWjmA0IsKu/d4MTqHt0YXxM73iXACJ2N+piLULz5Uu7+P7yPS/m+2bhVh1p1wyot+8x6HuSDKFp1NQsWZG/rtQPcW46j1LjO+DxPt27H4wyH8h2+R+rqKRf7eUCeUTxKbPce4x7LBHjRPbVGh9vjPHsWFeh+QDQ4BvirULpRow3HXM5uQ+nVN2CUZo/XemvifTwD6NYqOqlhFdG+OFd7e0OFjahGEA2+VYxHv7KCdkqDG6f4fA01YcLzkFVWb0H49d4RLLtMDYLenV8ZKIFeojsGTmnO8Mr9JaDf5sHzTXNiDcsY+BcUlaSboevAT5QHjJgwRmn8bcQcFX6AJ6x1PjRGvbAaig== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 155698ca-fb66-4d42-344b-08d8f933de0d X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3834.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2021 19:40:43.9419 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0sE0pHd9nZHTKZ27fDeL8gjRPj1Lguzedet/icAKUsLVEvBoCl9N6sRltRmU1Bp4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2859 X-Mailman-Approved-At: Tue, 06 Apr 2021 19:41:32 +0000 Subject: [Intel-gfx] [PATCH v2 15/18] vfio/gvt: Make DRM_I915_GVT depend on VFIO_MDEV X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Gurtovoy , "Raj, Ashok" , Tarun Gupta , Dan Williams , Leon Romanovsky , Christoph Hellwig Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" At some point there may have been some reason for this weird split in this driver, but today only the VFIO side is actually implemented. However, it got messed up at some point and mdev code was put in gvt.c and is pretending to be "generic" by masquerading as some generic attribute list: static MDEV_TYPE_ATTR_RO(description); But MDEV_TYPE attributes are only usable with mdev_device, nothing else. Ideally all of this would be moved to kvmgt.c, but it is entangled with the rest of the "generic" code in an odd way. Thus put in a kconfig dependency so we don't get randconfig failures when the next patch creates a link time dependency related to the use of MDEV_TYPE. Reviewed-by: Kevin Tian Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe Acked-by: Zhenyu Wang --- drivers/gpu/drm/i915/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig index 1e1cb245fca778..483e9ff8ca1d23 100644 --- a/drivers/gpu/drm/i915/Kconfig +++ b/drivers/gpu/drm/i915/Kconfig @@ -101,6 +101,7 @@ config DRM_I915_GVT bool "Enable Intel GVT-g graphics virtualization host support" depends on DRM_I915 depends on 64BIT + depends on VFIO_MDEV default n help Choose this option if you want to enable Intel GVT-g graphics From patchwork Tue Apr 6 19:40:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 12185821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1402C43470 for ; Tue, 6 Apr 2021 19:41:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A0CC613D0 for ; Tue, 6 Apr 2021 19:41:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A0CC613D0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80E9A6E8AE; Tue, 6 Apr 2021 19:41:34 +0000 (UTC) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-eopbgr760040.outbound.protection.outlook.com [40.107.76.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9DC5F6E8A8; Tue, 6 Apr 2021 19:40:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yh0ApidhYhMFLOanb/21ETEoK/hr9tfzloDqNEKdameU4+A2XHC9ACdZj96jQLmMUHNEKM/YqH4s1t+dP9IPGEvjHYwXmC5sLH3myK5iu2VUIn/G7om3V87ds0hYacNcZIOt/zmrtWpmTGyamp55zsMNRiHBq+U5Uf5LzmSBjERmRxZlx/lUvY9JwTh46PS4SF7HlGx2NMVO05HhST8V6C+LarEhbOH2usIgc3v+y4SswjPjKzplbVGyftNiAb3F8VI8CYkz+kGTOlapurb3fWp7hkBCYhe/kw1JWy5motCPVFHuafZzWOqHKJf3NUlVHMMNzUYUOVdkOLhMoOanjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zM504avHIozvkFLs19pzXyt3yFGjrzBaMKr2YWtrQE8=; b=lGuXNOv9ikkVKUJZMkC7dtNLFImM2casrKqEPwdLFdhcomPND5Id3fjxlrE99gHzK4FccI4zt+uLjVHm4p8FAllnlmg01lsFemUVDDrNdfyygyXrnd8FNFs8ojYftNCjp1K08eOREEcwA5HUhOyfQEZCXZbb/kb8pBG/yPelB2MtlDaopo34PHulDz2uPmbSmkSDwLMXpzl5cPmZEeFyWn0crJLd2O7X9zoR6SlMo7RmvJB1KzR3C7bD98DyToFnbkg/SamTguUGuN9MpbGl9rLGYcVuhslAEIRwCSpwD6d/KKFFupzsPR3PA6clFZWsDOdKZCay+Ws1JRf9tYw0QA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zM504avHIozvkFLs19pzXyt3yFGjrzBaMKr2YWtrQE8=; b=M31L4CbGus4XGcbKLPYwBT5X6ivekJWucoiWL0A94Vjgas8/pbvcd7KzseKVOzNLyHt/3TUhWcuZLVS/Ac4w1PahfaV+WQ7ieZp0i6UPHX/j2xyQu7oL4I0YnWU4B8PWGue7XKJBeKd3zPVCkguFfkSJvweoQLoYrHgNQWkM+OpDYVGGDLJNcel84LO/7n4DHUjl0bwobpBmSCcd2lCj0fWKBRKbzKtAE5xsdTnu+NwHAbEwvPFSyCeKgrLfSTJsA7LxYWrWPn7iBSnIEfZJa9Gn6mYD9QNPDsQobTqmd1C5Uutv2LX/b0Zvnult5Hg20guwrs3qMvDCrzUqH/zwZA== Authentication-Results: linux.ie; dkim=none (message not signed) header.d=none;linux.ie; dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM5PR12MB1546.namprd12.prod.outlook.com (2603:10b6:4:8::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16; Tue, 6 Apr 2021 19:40:52 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87%6]) with mapi id 15.20.3999.032; Tue, 6 Apr 2021 19:40:52 +0000 From: Jason Gunthorpe To: David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Zhenyu Wang , Zhi Wang Date: Tue, 6 Apr 2021 16:40:39 -0300 Message-Id: <16-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> In-Reply-To: <0-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> References: X-Originating-IP: [142.162.115.133] X-ClientProxiedBy: BL0PR02CA0086.namprd02.prod.outlook.com (2603:10b6:208:51::27) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (142.162.115.133) by BL0PR02CA0086.namprd02.prod.outlook.com (2603:10b6:208:51::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29 via Frontend Transport; Tue, 6 Apr 2021 19:40:47 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lTrZ4-001mXq-Ef; Tue, 06 Apr 2021 16:40:42 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 468b8762-ed5f-411f-9e30-08d8f933e02f X-MS-TrafficTypeDiagnostic: DM5PR12MB1546: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: amKMwYWWwBZM6cA0zPuEqUAAs/YU3lhFXmhTMMV2UjaQLbXvaG972zmvL4SIh8YEvDcpG3327jd+Hw0qj75BzwkUPbH23hCNSccxYYmYwsg7y548rUmPhemnwPc5G53tKYNay9pCCFQWEbTpZDzA5I9TBrVK4u5E/CtWb1tUHQqT3hoxL/cDdqda62a+TGbZvGM/+mjuc1DvgiaS2jtVtMEiWZ5zMVPZn41/EtMpMsu9ZYpevEVBdvUd05uCVzIM/ok2l5jrrWSiw7/rsQy7CvtEXklP6UakkKI7/S+5dRI521lzqtfQy3vAcT8WAcvT6QY/7S7e9ihPhoM3MCOd5SYrP/9Tz9riu9DvgJOrD4b5gmiTu7dADEyNCtjjznRRKtw8x5k/pU4PL+6VAl61chmNhnOpdu/MH3JZ0BxkVdnbeKIuQRAkHEDy/2Nkw2wIvqSzkIo3T7hSVqOqrtrqLbdxlQ1jd9+J3UdbyTGPIA4hsbQWJQanueSATIHr2UvwSPuQawSUlYJ1RZQc2MZucoInrmvYbSzXhxzgqT6pOKHhu9d4fRgvQkhnn67XHrQPdRIFYEs+kvGJsXhY/l5zQOuA4AOfD+gwQXAEFciAG7LJPAOpwZqGX4KSsEbUttv8YD2APIy1zlFyNOIC8C8JrvfCkY4SqaVPOGE+/ij3TVHRExHMoGhaITaesspSe4Mo X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB3834.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(346002)(39860400002)(376002)(366004)(316002)(86362001)(5660300002)(8676002)(186003)(66946007)(4326008)(8936002)(66556008)(66476007)(2906002)(38100700001)(921005)(83380400001)(9786002)(478600001)(54906003)(426003)(36756003)(9746002)(2616005)(6666004)(7416002)(110136005)(107886003)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: K4Ot7Ctaaqf1mVBFy/s5djrt1dBmfCpzEsWOC29HxIOmLilcTLWNl8dVQdlJUEtDUQzUlaNZ+AoRwQbK8k5azfn+yjdVCwHxViXs5nx0hNcQI6H75zd1Ya9fnImCH9nPPrHWZm56VPZwr3KKH+YhTpXSdUvRhKXov+4fymVgdpfJwGUMttWhcD2hGLGeYHguB9VR2XFwYoSF+8fwDjJqVlqppKftJaSfc3BWhQ2oOlauYt9+EBAsBtI0XZhwYS6Pl42ItRZ5mhbebG2vdOzQtfSRHHMW/ZwI5ViIOEHBcoxmjzuilZcUTEedKjYJp1UjqFM03+criQIDMJvAHkgQYZkoveGFaT2yaMnEpDuz5JLcH83oyfeP+M4+1MfvrwjM2/4GecWED3yKtRtfK9+CNHTAbW7XG58zp5VCjVka+Yomop4FuGH3snVaA2cGzY2LpxiWDHtiF2rLs89h5A1NmV7D2fA1+9XPnZbBo24Tu8b7SHlVyXYMZlPD8KbHNTMrSbqxqV+cYuK8sF4g8M5PuHLtSRxLre7s3LLF5NhtZIESMGxKYpxdODweWR9QJrQEz842wBs+1EPY+PJOktrFgpjZzmWMb2u4LZLkBX/QiGMsHRQjM6I71gjUoq0zPX0+KupKd3qGZ7VI1evzbisRlCgCYE7xv1XepGmWM6ZagQZtWHkL444SOgpbin9wP6wlMKJRrE5Sr81xqQKa7xCgSt+d9YoJ3t/oQ+Nncy4VQxrxnxRr+9ktyr1qOU7w1257omv4on43bnwHP6Os/hDZiYqkIz11bIMz0U4L6dZNAdQnaHZQJWHX4WND5i8oe0hOEiLUq0MaekxEm6UcMymW0cmSzPUVZZGzNXKNKmnJqLVJvwd2FZjJUBrxxQtYR1qSF0uD5Qyxe6WPoVVxmMxjYGOEGs8zlsP6ERjxY5wI+p+t0uQKF0um5i0dkhE79mMLWYE+fm2lGwWqClgXB7xAt+UUPKKSjX3qmrSH0aC4X5WGDyKYowH4z2jAoldpgo5CzqAs9j0T5b3R6KxiK1LTydeT+YeeUI8CuiEtDJgBmh+z8HxBaI4OfbST2rMvfDcgwh/eqC6scVI4/SyziAXDfTdniIVG2DZwhmJbGIkoWaeWM+o4rDu/E8TkVU4um2ZYBsDyab13FAinCh1Utx2NWUcNXWNW8y/+iQrG7lh4e6ldLMj5dh/fqLuJWy/hMhB5+cKdSi1Ee6/BFMtfJE464Psz27ebnW/XBUITttGQ4BuLj/up6P4eeUQuRKW+Vr12hyevcsz47T9Lho11060o2wnV8xeFKNayS+HQHjazZhhLBRLuDvUs41rFh59dZwPlPB6qc/i6knGAaMYhXqrgRA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 468b8762-ed5f-411f-9e30-08d8f933e02f X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3834.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2021 19:40:47.9346 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /adVRMu6mU4OA4+nsSOzhrzsnUw1odcBdxW0ADo8ilA7z9c4W3h5okL8GeVTLcny X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1546 X-Mailman-Approved-At: Tue, 06 Apr 2021 19:41:32 +0000 Subject: [Intel-gfx] [PATCH v2 16/18] vfio/gvt: Use mdev_get_type_group_id() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Gurtovoy , "Raj, Ashok" , Tarun Gupta , Dan Williams , Leon Romanovsky , Christoph Hellwig Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" intel_gvt_init_vgpu_type_groups() makes gvt->types 1:1 with the supported_type_groups array, so the type_group_id is also the index into gvt->types. Use it directly and remove the string matching. Reviewed-by: Kevin Tian Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe Reviewed-by: Zhenyu Wang --- drivers/gpu/drm/i915/gvt/gvt.c | 24 +++++++----------------- drivers/gpu/drm/i915/gvt/gvt.h | 4 ++-- drivers/gpu/drm/i915/gvt/kvmgt.c | 5 ++--- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c index d1d8ee4a5f16a3..4b47a18e9dfa0f 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.c +++ b/drivers/gpu/drm/i915/gvt/gvt.c @@ -46,22 +46,12 @@ static const char * const supported_hypervisors[] = { [INTEL_GVT_HYPERVISOR_KVM] = "KVM", }; -static struct intel_vgpu_type *intel_gvt_find_vgpu_type(struct intel_gvt *gvt, - const char *name) +static struct intel_vgpu_type * +intel_gvt_find_vgpu_type(struct intel_gvt *gvt, unsigned int type_group_id) { - const char *driver_name = - dev_driver_string(&gvt->gt->i915->drm.pdev->dev); - int i; - - name += strlen(driver_name) + 1; - for (i = 0; i < gvt->num_types; i++) { - struct intel_vgpu_type *t = &gvt->types[i]; - - if (!strncmp(t->name, name, sizeof(t->name))) - return t; - } - - return NULL; + if (WARN_ON(type_group_id >= gvt->num_types)) + return NULL; + return &gvt->types[type_group_id]; } static ssize_t available_instances_show(struct kobject *kobj, @@ -71,7 +61,7 @@ static ssize_t available_instances_show(struct kobject *kobj, unsigned int num = 0; void *gvt = kdev_to_i915(dev)->gvt; - type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj)); + type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(kobj)); if (!type) num = 0; else @@ -92,7 +82,7 @@ static ssize_t description_show(struct kobject *kobj, struct device *dev, struct intel_vgpu_type *type; void *gvt = kdev_to_i915(dev)->gvt; - type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj)); + type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(kobj)); if (!type) return 0; diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h index 03c993d68f105a..0cf480f42850d2 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.h +++ b/drivers/gpu/drm/i915/gvt/gvt.h @@ -569,8 +569,8 @@ struct intel_gvt_ops { void (*vgpu_reset)(struct intel_vgpu *); void (*vgpu_activate)(struct intel_vgpu *); void (*vgpu_deactivate)(struct intel_vgpu *); - struct intel_vgpu_type *(*gvt_find_vgpu_type)(struct intel_gvt *gvt, - const char *name); + struct intel_vgpu_type *(*gvt_find_vgpu_type)( + struct intel_gvt *gvt, unsigned int type_group_id); bool (*get_gvt_attrs)(struct attribute_group ***intel_vgpu_type_groups); int (*vgpu_query_plane)(struct intel_vgpu *vgpu, void *); int (*vgpu_get_dmabuf)(struct intel_vgpu *vgpu, unsigned int); diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index b4348256ae9591..16e1e4a38aa1f6 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c @@ -700,10 +700,9 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) pdev = mdev_parent_dev(mdev); gvt = kdev_to_i915(pdev)->gvt; - type = intel_gvt_ops->gvt_find_vgpu_type(gvt, kobject_name(kobj)); + type = intel_gvt_ops->gvt_find_vgpu_type(gvt, + mdev_get_type_group_id(mdev)); if (!type) { - gvt_vgpu_err("failed to find type %s to create\n", - kobject_name(kobj)); ret = -EINVAL; goto out; } From patchwork Tue Apr 6 19:40:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 12187935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D3D7C433B4 for ; Wed, 7 Apr 2021 12:15:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0671161139 for ; Wed, 7 Apr 2021 12:15:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0671161139 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E75D6E152; Wed, 7 Apr 2021 12:15:32 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2063.outbound.protection.outlook.com [40.107.236.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 16A9B6E8AF; Tue, 6 Apr 2021 20:07:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hKaYyFNLaNQOZEemqx+qlQ2n20kZ67guoxSFxYDvegm5fE0bFGBLZ0aPdJdhUpLMyFoogLJN3ZlL7UuRyQx2UTdHMAvYM2lUoDZHPN7QSHrGzDXa/O1QwmrFH8dtPmhNtJ0MO/J0K7QuZ+Z0C4kziNl78juXYLgiSaRjCiAfjWr+XmuMYMk+w31ax8EE57R55+4pvhkGRZRdUs0aPzrlOyqT9mtMtzuXkkO2NSl59bj4nP1yANpgYOXJ5KLbcjzhk1xrxhjFjJ6aQCDG5WYIM74JmoVz4QRqZTX54LQZqcErhS+eQ9GaNYl1a+xqcHOwaM5nALTuSbrSFegOfrslkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pQz5KvjjX7thR+DVlFOXa9VeJSk7pPDIRbsC+KXJL14=; b=ClC5PWnLYp1OBqo0VtByrW2B4eTLQGly9ybavPgbQtTn61nrG6XrpQYyDg4POULQIR/seiCblMTeRSMTnWuWRWKQt3hulpv0D3CqvuoqIp/bNdLhnmXpnwsMR2e8XfLI0GB0DVClyf4w32bBSaiCqdixT9WNiVXRDtOCbDU84JjDRcgiNawDcwnQTIlb2KTZW8ig3pAkXug4bLHNV5OZ5HHSCVap5l8cq4hlDFVYUnDD0XsnOPHufe4cjh3Nw33E0FxgEBxlQijXZO+WB69u2g/6bPg0LqgNz3g+/4OWzlc7g+bYCIjVF2WTEfM64CFh9EggBZrZG4V+JBK2eIA8Zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pQz5KvjjX7thR+DVlFOXa9VeJSk7pPDIRbsC+KXJL14=; b=QfFr32B9vMcAbiYck7Hr/4oP8Mc2U/jn6+qRnC0xkB739fliwPRUqs/xlHedbgTEZQ8/r1Z7qhUCOBvJoam04j7dSGNxZjJFp+y7FldSsX23a3AuB99OAAlKHQA6hWEGlHP1CxDR5HXxeQ1WIhvPIN8IacEZd9MWUo4O1ZAqbsTIMCiXSUdPTaelIL0L0N/MtbZ9o0ZVcIXSi9hlWjTmkN4zrInIub89XjhKDP9XS2FRij+v6nlNVrxMFo+8CyvKCSzHYadtJOAz60meRfr+WEHao+Vzb2ePk2RRtwN+AwNhm7LW+EzaOrzaawCTvujfojVv7cto+jEudje2L0dxTw== Authentication-Results: linux.ie; dkim=none (message not signed) header.d=none;linux.ie; dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM5PR12MB1883.namprd12.prod.outlook.com (2603:10b6:3:113::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27; Tue, 6 Apr 2021 20:07:23 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87%6]) with mapi id 15.20.3999.032; Tue, 6 Apr 2021 20:07:23 +0000 From: Jason Gunthorpe To: David Airlie , Tony Krowiak , Alex Williamson , Christian Borntraeger , Daniel Vetter , dri-devel@lists.freedesktop.org, Eric Farman , Harald Freudenberger , Vasily Gorbik , Heiko Carstens , intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , kvm@vger.kernel.org, Kirti Wankhede , linux-s390@vger.kernel.org, Peter Oberparleiter , Halil Pasic , Pierre Morel , Rodrigo Vivi , Vineeth Vijayan , Zhenyu Wang , Zhi Wang Date: Tue, 6 Apr 2021 16:40:40 -0300 Message-Id: <17-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> In-Reply-To: <0-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> References: X-Originating-IP: [142.162.115.133] X-ClientProxiedBy: BL0PR03CA0027.namprd03.prod.outlook.com (2603:10b6:208:2d::40) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (142.162.115.133) by BL0PR03CA0027.namprd03.prod.outlook.com (2603:10b6:208:2d::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28 via Frontend Transport; Tue, 6 Apr 2021 20:07:22 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lTrZ4-001mXu-G3; Tue, 06 Apr 2021 16:40:42 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c16b43ec-dcd5-4cc6-a792-08d8f9379728 X-MS-TrafficTypeDiagnostic: DM5PR12MB1883: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 12ZzVD5Lr87fpvFfZOj3vtlSDl8Zw/a4G1+IEhgYYx2uhlo0YZfJh1FVE+rR0GAcg/tFihwHSCNSUs3m7YDiMrV8vqtwNALKWjroboaAyhpYICb+MctRc9lmDkXUIhQLUN1dhJUtTcYmlJPAs4ukBUHivJ/ttOL9bxQomEyY3ZZFdKPzZFWwioqsBwkcyXzcsA4sNTiZ+NBdWIVFmwThlvc1NnR6pTYFEobcv4zJ6XY40tLFGf+48Hn/w9FXZ0wrdWc03EaG/jhP7T2HSf1/m2ulYxFy9CWUHfK1wOwN5dvyCXzT6nIVfjZqyM25O0GQNy6+pBGWob2abtRNjPdXcmetBA9/BrIM/FTd7XDpaNusIR8GxfakZFzQuGMhlXHP5TxVW/7WRmyWPGEXnzm5uUmgpaJLLuowJr2Ob57xyacSwoPIqyhhdj77xLEuxU263RP/Fc8OSXSppd03P7+Ut0GLznHD9LBnx9EzwlKUYaVpHYFVOkYRv/cR7B65/wYNMtnezy6ewoGs11seYrzTGY7cXzH4uBBiSsZts8Upj4WP8XxqEaW5Bejt01Iw8vfUaC/gyBFjC28Od+c4t7MvA2F5fE2k/ZoVI6gGp5t97GSnB78EIeDeALfADmUhCS7OYCdiBOScG3VnAdJY5Z6BVNK5Q2Zns7zoWdyLdT5C0xAnaIyV8VClZjtZLILYtoL4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB3834.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(136003)(39860400002)(366004)(346002)(396003)(38100700001)(186003)(86362001)(8676002)(8936002)(2906002)(2616005)(316002)(7416002)(54906003)(478600001)(110136005)(9746002)(83380400001)(26005)(66556008)(5660300002)(66946007)(107886003)(9786002)(4326008)(36756003)(921005)(426003)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GGibTQ8RLskmI4XO6PdQDP97SIeXXTeK0Sw6sDdYWElf2x/uRfvrwXXYvqifgMsBqRb2mvrYv/eautLS5iVXPPvs1HB/4/D/c7mdVt7CMYceM+TnvNY9rFDMa4N2JzRIz+scV+xwfkG1FeVCvP8OWIx4aa9wWJQtN1eTl46TBejt4gCicnsGBll7dvpne4Wsm1ZJwLYKboKQiHM4pKUZ/MSzztdJKsjb4mlfpndYpGu0W6RNy1g6u2iGgXnTf83Tw1kgUv28AN2oTnYooIpj7WPe5tDVcuBseVp82A7eXnaLkyLsZ2aBfHYUH6dVJlCfjapYnZ6UGsllrD5DnBcdZ1TL5TggWpwPuaIJmmdgfYgCGcU/1c0D8499ijVAi7B+12XBbA+zy0pQoCxbPVENz+1Wa/bA1GQl9TaqN4t3fCzoOF5c6KqKH7KpS/MYFfs2FCXzyaUnrNMZADwovLMjAe9Uc7sUUOlWP/iGtGHW43YvNhjF0m5pVBZhQAjyJB8mZnYRmH1fpmbCXteeFI6ytVwf2TKhaoM4gT7TAMtgIjMiS+uALsyS5AXsZZc0Z8uul4d0nalZqWjdfvYxLfhyc3ZTTCbNm5pyKIFmuWVlxx0NaMIRwGja7zmXpQIrDGjqbP0cFGxITmIpE0x5/T4GKrBMltoelaCEo4USzaTqjHAFoL1xjoe6l7Vul3Rxjm5S9vAkO5JUWwoUrb16NICCUjVQvvGVnsFhLs2Weoi8HOCe1fFSWxuG7ARLhfe75DY1M+/xgLThPbjIRV8gSf9cplx2NGrkQepaKssmqgV/vmgFW6Q54ivob0Vyo4MFI/PnbEGVEprrkOBloS83Bge/KROc9BIQXU9o9eqleT71+iQWYks4qY9i4j3MLadbOVg7iK/nCqgtoJIj5ymcz6HwdDMt8+HBmGqUPqf7Tx0Cie//np/s16q9LkdGj6wfAxK7pjFYmDhZIRjSlW1b3sJOiVN6UIaz/l7sIwINXlNX7RQJ0lwBQgxwdVKmyWrCyGpxiDrYCiH3kjDBVYMvZKSUvRiitYiaJ5iPcNQa4yhms3+1dWRW2Bw62+KE3IfG0PzDDTQkMANtuZz3w0SMhzA1WCxE+u1yjiIkinmx+F2TI/0XWVSsaQCTVjVtopz3j781mid5aZd+oR4+Pue3nXwa9WnZxiXaBA0Do1KxKzKsML4cxL6D14oCdBgIkKAm1xWbgn5Pmgxn8GnR5d8LRZxy+i1OFAXO0L6kSpuZGdkNZtcpIC3SxpY7mHVKpZMctp2P/Bi37UXVfGDu8z+mfT3EsOaWWHeByXg711Vk9ueqOOCI76CbMQadF6YI0lbjasIr++8czRnZlfna2OZaEcFz/Q== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c16b43ec-dcd5-4cc6-a792-08d8f9379728 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3834.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2021 20:07:23.1174 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EAt7p3spiPjS8SsQNFCHDz03CNjrL6DLOxk65OD541zQJcWthTd27IOHWxHpQ0Sw X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1883 X-Mailman-Approved-At: Wed, 07 Apr 2021 12:15:31 +0000 Subject: [Intel-gfx] [PATCH v2 17/18] vfio/mdev: Remove kobj from mdev_parent_ops->create() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Gurtovoy , "Raj, Ashok" , Cornelia Huck , Tarun Gupta , Dan Williams , Leon Romanovsky , Christoph Hellwig Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The kobj here is a type-erased version of mdev_type, which is already stored in the struct mdev_device being passed in. It was only ever used to compute the type_group_id, which is now extracted directly from the mdev. Reviewed-by: Kevin Tian Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/gpu/drm/i915/gvt/kvmgt.c | 2 +- drivers/s390/cio/vfio_ccw_ops.c | 2 +- drivers/s390/crypto/vfio_ap_ops.c | 2 +- drivers/vfio/mdev/mdev_core.c | 2 +- include/linux/mdev.h | 3 +-- samples/vfio-mdev/mbochs.c | 2 +- samples/vfio-mdev/mdpy.c | 2 +- samples/vfio-mdev/mtty.c | 2 +- 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index 16e1e4a38aa1f6..6bf176e8426e63 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c @@ -689,7 +689,7 @@ static void kvmgt_put_vfio_device(void *vgpu) vfio_device_put(vdev->vfio_device); } -static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) +static int intel_vgpu_create(struct mdev_device *mdev) { struct intel_vgpu *vgpu = NULL; struct intel_vgpu_type *type; diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c index 767ac41686fe2f..10407cf67583c6 100644 --- a/drivers/s390/cio/vfio_ccw_ops.c +++ b/drivers/s390/cio/vfio_ccw_ops.c @@ -110,7 +110,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) +static int vfio_ccw_mdev_create(struct mdev_device *mdev) { struct vfio_ccw_private *private = dev_get_drvdata(mdev_parent_dev(mdev)); diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 1ffdd411201cd6..d319152dd484a2 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -322,7 +322,7 @@ static void vfio_ap_matrix_init(struct ap_config_info *info, matrix->adm_max = info->apxa ? info->Nd : 15; } -static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev) +static int vfio_ap_mdev_create(struct mdev_device *mdev) { struct ap_matrix_mdev *matrix_mdev; diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index 5ae06f951a0998..10eff33ce1f263 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -286,7 +286,7 @@ int mdev_device_create(struct mdev_type *type, const guid_t *uuid) goto out_put_device; } - ret = parent->ops->create(&type->kobj, mdev); + ret = parent->ops->create(mdev); if (ret) goto out_unlock; diff --git a/include/linux/mdev.h b/include/linux/mdev.h index 41e91936522394..c3a800051d6146 100644 --- a/include/linux/mdev.h +++ b/include/linux/mdev.h @@ -61,7 +61,6 @@ unsigned int mtype_get_type_group_id(struct kobject *mtype_kobj); * @create: Called to allocate basic resources in parent device's * driver for a particular mediated device. It is * mandatory to provide create ops. - * @kobj: kobject of type for which 'create' is called. * @mdev: mdev_device structure on of mediated device * that is being created * Returns integer: success (0) or error (< 0) @@ -107,7 +106,7 @@ struct mdev_parent_ops { const struct attribute_group **mdev_attr_groups; struct attribute_group **supported_type_groups; - int (*create)(struct kobject *kobj, struct mdev_device *mdev); + int (*create)(struct mdev_device *mdev); int (*remove)(struct mdev_device *mdev); int (*open)(struct mdev_device *mdev); void (*release)(struct mdev_device *mdev); diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c index a1af30df10a2ee..ac4d0dc2490705 100644 --- a/samples/vfio-mdev/mbochs.c +++ b/samples/vfio-mdev/mbochs.c @@ -506,7 +506,7 @@ static int mbochs_reset(struct mdev_device *mdev) return 0; } -static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev) +static int mbochs_create(struct mdev_device *mdev) { const struct mbochs_type *type = &mbochs_types[mdev_get_type_group_id(mdev)]; diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c index 08c15f9f06a880..da88fd7dd42329 100644 --- a/samples/vfio-mdev/mdpy.c +++ b/samples/vfio-mdev/mdpy.c @@ -216,7 +216,7 @@ static int mdpy_reset(struct mdev_device *mdev) return 0; } -static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev) +static int mdpy_create(struct mdev_device *mdev) { const struct mdpy_type *type = &mdpy_types[mdev_get_type_group_id(mdev)]; diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c index 191a587a8d5ab1..f2e36c06ac6aa2 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c @@ -708,7 +708,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count, return ret; } -static int mtty_create(struct kobject *kobj, struct mdev_device *mdev) +static int mtty_create(struct mdev_device *mdev) { struct mdev_state *mdev_state; int nr_ports = mdev_get_type_group_id(mdev) + 1; From patchwork Tue Apr 6 19:40:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 12185817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F4B6C433ED for ; Tue, 6 Apr 2021 19:41:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 04EAE613D0 for ; Tue, 6 Apr 2021 19:41:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04EAE613D0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F0296E8A5; Tue, 6 Apr 2021 19:41:33 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2086.outbound.protection.outlook.com [40.107.94.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id F05716E8A4; Tue, 6 Apr 2021 19:40:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQ/WC9ASzH2rvyk15sNfrhPLzKP6Ry+iuBXoRfbPMCadEeiunu74DAlXJprlkFi12FP8N7vPWBa+c+xm4tobFi6tmy//tgUdFZ2+RMweodRqATN6bhLx13YaLgHOVpLuJC0wbJRTIreay3sryDPK5URHCRdxqkz5v4KI5wyJuoNz+xH7teQkF+mzJ/+wgKSMGhW0xWnWdFO/Cu85vN6pPuVfQs4mCtrJWwYhk5ltznbGhZLYFnHq0NtHJCOqAGSdpJWaMyyPA1pYkkMPeKdQPz2vn+SLFvWZ+BIsQ0EM+Dz17Yf+hk5fSpzrsBzaGTOkRl1SdzRe6JjywecxFWJ5Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uoTSSo2mx2JDguO98N5mVfmZp8fU/kZU2AK7qmfO63E=; b=dds+terChKSrBajzIDVFnmTivcNktrdETj32zv4iHRow+gbkuScSFA8cD6CDJCvX6E2gVj+0qnieuE8V0zjgdsiuVTwJN1Z+djkklrc8w8cFpnCTZXMbL7No3LZauyowUkuTDT6e0KW8YrLqh/bbxj031VhhqgCTgox/2B98v0y4soCN+wSENbZMrrpWB3LDo8W7YmxyUYIiEXDHTTgbUmljWJkgmJsauSCAVC1wfjdGwgfX8KTKvaLZr/hvgufKsPGW4wbx2tvaKyiqqfJsU+fgTkfzid7rJ5FKpk3hpRtYwaenMEd9OYtw46Jr/olIaoUCfNmdp7JBT1cCQSeGzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uoTSSo2mx2JDguO98N5mVfmZp8fU/kZU2AK7qmfO63E=; b=MqMRCrqej1HWwxLNr6MXMttUblKZtaal19fgRpmTwdvqbTvsEO4JFXSgjJdI76uw49BWWqd1BHFc7eccIobzPlI1OXO8bX7l1Q4krE5NMa4xGPMhtZR7B2uW5g8+zDE5hL3BD4VctMopW6KeuK0G8ai/CrZ+FowmlsrSQnt65QLlrZndvTkbwUWmRR7C9RqCL2yPjGeex2k/sEGIgGYaDGcLLfk2pQ94zrU8EBmHh/8aBtha1NUIt1tQGh4laIprAteEJ7iIhEsU1EiLlxfllv1FMEFmCwGuaIgthqT815Vb6DVYstSN0Dsp3l36Hi8JGUEkzckVd7xLOF3HJVJPCg== Authentication-Results: linux.ie; dkim=none (message not signed) header.d=none;linux.ie; dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB3515.namprd12.prod.outlook.com (2603:10b6:5:15f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Tue, 6 Apr 2021 19:40:46 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::1c62:7fa3:617b:ab87%6]) with mapi id 15.20.3999.032; Tue, 6 Apr 2021 19:40:45 +0000 From: Jason Gunthorpe To: David Airlie , Tony Krowiak , Alex Williamson , Christian Borntraeger , Daniel Vetter , dri-devel@lists.freedesktop.org, Eric Farman , Harald Freudenberger , Vasily Gorbik , Heiko Carstens , intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , kvm@vger.kernel.org, Kirti Wankhede , linux-s390@vger.kernel.org, Peter Oberparleiter , Halil Pasic , Pierre Morel , Rodrigo Vivi , Vineeth Vijayan , Zhenyu Wang , Zhi Wang Date: Tue, 6 Apr 2021 16:40:41 -0300 Message-Id: <18-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> In-Reply-To: <0-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> References: X-Originating-IP: [142.162.115.133] X-ClientProxiedBy: MN2PR16CA0002.namprd16.prod.outlook.com (2603:10b6:208:134::15) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (142.162.115.133) by MN2PR16CA0002.namprd16.prod.outlook.com (2603:10b6:208:134::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Tue, 6 Apr 2021 19:40:43 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lTrZ4-001mXy-HM; Tue, 06 Apr 2021 16:40:42 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e38573e-dc31-42d5-0ca4-08d8f933de16 X-MS-TrafficTypeDiagnostic: DM6PR12MB3515: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Db7K+JErXl0Kd4wEDxsxs7uM9L5m7KtAfaHh0FA5p0hwodW3oLmI1a/CD40sf/XF9Yy54kPG8ELybolAO0QaVCrOKTUxhakYZl8kuBBt8bFKkhsSRWJSQV0l3X+SQioPHl+f+8PPud7+vhey6t1d7VN4YBxv99ps8NkpvOR97HklqWJW9nuGV99P9Mff5AE+jfHEzxgBO3m94x+q7a3Bj4YvRtPKXNI4l/rsI6gKQf+x6IgiYhDXYbLIDYImPN6C8Zq+QSFGOXTyt8u6cpv5JDvqdUClmVprN2LxeZzmnBv54rMZSds8qW6yM56xo3KkW4OpAiXS46idDy3YhWH0JklhrewjenP3wtdTq7DJoJDgPrHqRV6EvwveTjrnvavA/1nnw91uHIyA/MqZEmbJJEqu1uhfr71kiqk9IM7DNi3bVEy3DWBAtI9LL2BMaUFCTOyTXw2TmLPV/MxVlCGizWrKE4kwry16apiPK8BMN3X8wlfN3ksTnewbWhLxbPn+2YQSAC7LF5U/f6RM23UYzdta68hKaO/hyfsctTpLKCQ1dTlyPPIlaR1W1bvWYnaxOiSJq2TlvE2NMbkFYR4S+/BHSBCwmHtX1v3tcGC2t1a/HCDp78Idi97Oxx3EqqNhwvpYDZVrZDULIgCa2kE9U8Cw1NTGYmQFBl2+xI+a6OI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB3834.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(136003)(396003)(39860400002)(376002)(366004)(9786002)(54906003)(316002)(110136005)(83380400001)(86362001)(8676002)(26005)(426003)(186003)(66476007)(66946007)(2616005)(7416002)(38100700001)(66556008)(107886003)(5660300002)(4326008)(9746002)(2906002)(478600001)(30864003)(8936002)(36756003)(921005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: E+QjFWxhWfvCanJy9MoQjJucRJHPZ88I/xPBVLcZXEp6dXgvlNrL6ToJ1NaS3qrkOMlam9CDyLwj4lrxxVSlJPZNfaFPM9pPh600gRVztsHiGN3wQSDsLrV1Eep4VTCS1KaydIrd4YqbEnBrpMYS4mEmVQh+AvJMrC4sDvQDf3S6UtTEWaq0jEL8GchJBePPQUrhPbapy1JI1R9g3T0mDBy+AakA0qp6m4A4GxQkIYk3UiL6L8B1iKPD6yLIihOU5guO8QELt0TmV/wAk0sRmToJK67gaxT+KGVl4mm6ksUFEgPcEG3Iz6UKb8g8gcNocypVN3zjpL55SCHWC7h48tnyMdjHn1Msje8nb2pILwyIc7Ma9ATIwF+yXrirI2rC2X0QbwqcW39hLm6YGNsQcFuHElcaIXbNL+KXbg7aXVct/l5y5JcnTEpRDK8SbLCicOA9w+tFiGARxRIruAPwBn4nV5731GiDB2hHlMi/NEFHfA3TKbLDHR4rJNg9jd+KYQHJ1Jr+n+mCge2NoPYWPLZy0Slg49rKs/r1pdIBf5tFHyJ9jkqzPDpBEncL7qZma6u+CgYqguxyDR6i5fUQFN+RXoGHgSICFawWRndIGi4rvjDO/B96zu9WIxE8eug1+pN/lMJT81540RZkQ5/2+XDV1VNVfh1XgoN3/Ghhc4hkkSr2tWp4r8PPDmpFImQyTyz1nd45FHjc/dkivo9+rsNm4SlVV3fT7n//67fjuWAin/RlI6tLLFY6SBfVeb8kBpGY8XX3Gn9jyrDP2mE9Jm9VpU6WaxcL/q0JjMiiyUMUR1FJPWbyKXwayp6g93M7ecSxoPQXRbKnfIgHU3MSCTLxXz2lnCb2pz93hvOF9qYeOQIz1/YATVg2Fq4GrwEIXQMdPNNjtSNY6qsDMjtGRcsbcwok//gZ48PTysScf36h2mfu8otOd4rDTskSLpZmC63jC8CKe/+ZvXVQF0UL8aHpUtO4F/CMsD4bkP5NplVhd72FhM/mqOrkEfhDHvjm/1JoPJPm9Mt6vWtUJqv+deS1n/9m/QKVSgAFm8/cjXIaIMh4lnljZB329UNIDHiYVsjxcWEsNlE+b3v9/TB2PaY2RtDoF5m36D6X6BMj6jIGoeb/uT8/yYIU12NXmq2iGCXipiDgLvoRLoTUBIxzHeyY0ZMUmeKHtKBfDmkkzOR8hijjEwiZ6YJdH8D2lyjVn1TciPg5uslm31zCM4YTXXOwhh7H1dd57xbEyElXfpG6qYmWeF+bl+QUzzMgB1DJKM2HUHHJu3mXxUoVLeZ4tZvwnizvX1jKWChF6GmjN+maJi3fEDeoLandg+OkG7VSUpvCJaXAU+gxtaLrgel+fA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e38573e-dc31-42d5-0ca4-08d8f933de16 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3834.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2021 19:40:44.1298 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SIOfr0N9BGi1+nxRDUA3BjnHate2SY6qiGnA1PWFlNr4sDiBLcf8l5MCojQfex05 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3515 X-Mailman-Approved-At: Tue, 06 Apr 2021 19:41:32 +0000 Subject: [Intel-gfx] [PATCH v2 18/18] vfio/mdev: Correct the function signatures for the mdev_type_attributes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Gurtovoy , "Raj, Ashok" , Cornelia Huck , Tarun Gupta , Dan Williams , Leon Romanovsky , Christoph Hellwig Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The driver core standard is to pass in the properly typed object, the properly typed attribute and the buffer data. It stems from the root kobject method: ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..) Each subclass of kobject should provide their own function with the same signature but more specific types, eg struct device uses: ssize_t (*show)(struct device *dev, struct device_attribute *attr,..) In this case the existing signature is: ssize_t (*show)(struct kobject *kobj, struct device *dev,..) Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'. Change the mdev_type related sysfs attribute functions to: ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..) In order to restore type safety and match the driver core standard There are no current users of 'attr', but if it is ever needed it would be hard to add in retroactively, so do it now. Reviewed-by: Kevin Tian Reviewed-by: Cornelia Huck Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/gpu/drm/i915/gvt/gvt.c | 21 +++++++++++---------- drivers/s390/cio/vfio_ccw_ops.c | 15 +++++++++------ drivers/s390/crypto/vfio_ap_ops.c | 12 +++++++----- drivers/vfio/mdev/mdev_core.c | 14 ++++++++++++-- drivers/vfio/mdev/mdev_sysfs.c | 11 ++++++----- include/linux/mdev.h | 11 +++++++---- samples/vfio-mdev/mbochs.c | 26 +++++++++++++++----------- samples/vfio-mdev/mdpy.c | 24 ++++++++++++++---------- samples/vfio-mdev/mtty.c | 18 +++++++++--------- 9 files changed, 90 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c index 4b47a18e9dfa0f..3703814a669b46 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.c +++ b/drivers/gpu/drm/i915/gvt/gvt.c @@ -54,14 +54,15 @@ intel_gvt_find_vgpu_type(struct intel_gvt *gvt, unsigned int type_group_id) return &gvt->types[type_group_id]; } -static ssize_t available_instances_show(struct kobject *kobj, - struct device *dev, char *buf) +static ssize_t available_instances_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, + char *buf) { struct intel_vgpu_type *type; unsigned int num = 0; - void *gvt = kdev_to_i915(dev)->gvt; + void *gvt = kdev_to_i915(mtype_get_parent_dev(mtype))->gvt; - type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(kobj)); + type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(mtype)); if (!type) num = 0; else @@ -70,19 +71,19 @@ static ssize_t available_instances_show(struct kobject *kobj, return sprintf(buf, "%u\n", num); } -static ssize_t device_api_show(struct kobject *kobj, struct device *dev, - char *buf) +static ssize_t device_api_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING); } -static ssize_t description_show(struct kobject *kobj, struct device *dev, - char *buf) +static ssize_t description_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { struct intel_vgpu_type *type; - void *gvt = kdev_to_i915(dev)->gvt; + void *gvt = kdev_to_i915(mtype_get_parent_dev(mtype))->gvt; - type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(kobj)); + type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(mtype)); if (!type) return 0; diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c index 10407cf67583c6..491a64c61fff1a 100644 --- a/drivers/s390/cio/vfio_ccw_ops.c +++ b/drivers/s390/cio/vfio_ccw_ops.c @@ -71,23 +71,26 @@ static int vfio_ccw_mdev_notifier(struct notifier_block *nb, return NOTIFY_DONE; } -static ssize_t name_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t name_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { return sprintf(buf, "I/O subchannel (Non-QDIO)\n"); } static MDEV_TYPE_ATTR_RO(name); -static ssize_t device_api_show(struct kobject *kobj, struct device *dev, - char *buf) +static ssize_t device_api_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { return sprintf(buf, "%s\n", VFIO_DEVICE_API_CCW_STRING); } static MDEV_TYPE_ATTR_RO(device_api); -static ssize_t available_instances_show(struct kobject *kobj, - struct device *dev, char *buf) +static ssize_t available_instances_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, + char *buf) { - struct vfio_ccw_private *private = dev_get_drvdata(dev); + struct vfio_ccw_private *private = + dev_get_drvdata(mtype_get_parent_dev(mtype)); return sprintf(buf, "%d\n", atomic_read(&private->avail)); } diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index d319152dd484a2..0ce00c9311d378 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -366,15 +366,17 @@ static int vfio_ap_mdev_remove(struct mdev_device *mdev) return 0; } -static ssize_t name_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t name_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { return sprintf(buf, "%s\n", VFIO_AP_MDEV_NAME_HWVIRT); } static MDEV_TYPE_ATTR_RO(name); -static ssize_t available_instances_show(struct kobject *kobj, - struct device *dev, char *buf) +static ssize_t available_instances_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, + char *buf) { return sprintf(buf, "%d\n", atomic_read(&matrix_dev->available_instances)); @@ -382,8 +384,8 @@ static ssize_t available_instances_show(struct kobject *kobj, static MDEV_TYPE_ATTR_RO(available_instances); -static ssize_t device_api_show(struct kobject *kobj, struct device *dev, - char *buf) +static ssize_t device_api_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { return sprintf(buf, "%s\n", VFIO_DEVICE_API_AP_STRING); } diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index 10eff33ce1f263..2a85d6fcb7ddd0 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -47,12 +47,22 @@ EXPORT_SYMBOL(mdev_get_type_group_id); * Used in mdev_type_attribute sysfs functions to return the index in the * supported_type_groups that the sysfs is called from. */ -unsigned int mtype_get_type_group_id(struct kobject *mtype_kobj) +unsigned int mtype_get_type_group_id(struct mdev_type *mtype) { - return container_of(mtype_kobj, struct mdev_type, kobj)->type_group_id; + return mtype->type_group_id; } EXPORT_SYMBOL(mtype_get_type_group_id); +/* + * Used in mdev_type_attribute sysfs functions to return the parent struct + * device + */ +struct device *mtype_get_parent_dev(struct mdev_type *mtype) +{ + return mtype->parent->dev; +} +EXPORT_SYMBOL(mtype_get_parent_dev); + /* Should be called holding parent_list_lock */ static struct mdev_parent *__find_parent_device(struct device *dev) { diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c index 712fbc78b12e2d..f5cf1931c54e48 100644 --- a/drivers/vfio/mdev/mdev_sysfs.c +++ b/drivers/vfio/mdev/mdev_sysfs.c @@ -26,7 +26,7 @@ static ssize_t mdev_type_attr_show(struct kobject *kobj, ssize_t ret = -EIO; if (attr->show) - ret = attr->show(kobj, type->parent->dev, buf); + ret = attr->show(type, attr, buf); return ret; } @@ -39,7 +39,7 @@ static ssize_t mdev_type_attr_store(struct kobject *kobj, ssize_t ret = -EIO; if (attr->store) - ret = attr->store(&type->kobj, type->parent->dev, buf, count); + ret = attr->store(type, attr, buf, count); return ret; } @@ -48,8 +48,9 @@ static const struct sysfs_ops mdev_type_sysfs_ops = { .store = mdev_type_attr_store, }; -static ssize_t create_store(struct kobject *kobj, struct device *dev, - const char *buf, size_t count) +static ssize_t create_store(struct mdev_type *mtype, + struct mdev_type_attribute *attr, const char *buf, + size_t count) { char *str; guid_t uuid; @@ -67,7 +68,7 @@ static ssize_t create_store(struct kobject *kobj, struct device *dev, if (ret) return ret; - ret = mdev_device_create(to_mdev_type(kobj), &uuid); + ret = mdev_device_create(mtype, &uuid); if (ret) return ret; diff --git a/include/linux/mdev.h b/include/linux/mdev.h index c3a800051d6146..1fb34ea394ad46 100644 --- a/include/linux/mdev.h +++ b/include/linux/mdev.h @@ -47,7 +47,8 @@ static inline struct device *mdev_get_iommu_device(struct mdev_device *mdev) } unsigned int mdev_get_type_group_id(struct mdev_device *mdev); -unsigned int mtype_get_type_group_id(struct kobject *mtype_kobj); +unsigned int mtype_get_type_group_id(struct mdev_type *mtype); +struct device *mtype_get_parent_dev(struct mdev_type *mtype); /** * struct mdev_parent_ops - Structure to be registered for each parent device to @@ -123,9 +124,11 @@ struct mdev_parent_ops { /* interface for exporting mdev supported type attributes */ struct mdev_type_attribute { struct attribute attr; - ssize_t (*show)(struct kobject *kobj, struct device *dev, char *buf); - ssize_t (*store)(struct kobject *kobj, struct device *dev, - const char *buf, size_t count); + ssize_t (*show)(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf); + ssize_t (*store)(struct mdev_type *mtype, + struct mdev_type_attribute *attr, const char *buf, + size_t count); }; #define MDEV_TYPE_ATTR(_name, _mode, _show, _store) \ diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c index ac4d0dc2490705..861c76914e7639 100644 --- a/samples/vfio-mdev/mbochs.c +++ b/samples/vfio-mdev/mbochs.c @@ -1330,37 +1330,41 @@ static const struct attribute_group *mdev_dev_groups[] = { NULL, }; -static ssize_t -name_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t name_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { - return sprintf(buf, "%s\n", kobj->name); + const struct mbochs_type *type = + &mbochs_types[mtype_get_type_group_id(mtype)]; + + return sprintf(buf, "%s\n", type->name); } static MDEV_TYPE_ATTR_RO(name); -static ssize_t -description_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t description_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { const struct mbochs_type *type = - &mbochs_types[mtype_get_type_group_id(kobj)]; + &mbochs_types[mtype_get_type_group_id(mtype)]; return sprintf(buf, "virtual display, %d MB video memory\n", type ? type->mbytes : 0); } static MDEV_TYPE_ATTR_RO(description); -static ssize_t -available_instances_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t available_instances_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, + char *buf) { const struct mbochs_type *type = - &mbochs_types[mtype_get_type_group_id(kobj)]; + &mbochs_types[mtype_get_type_group_id(mtype)]; int count = (max_mbytes - mbochs_used_mbytes) / type->mbytes; return sprintf(buf, "%d\n", count); } static MDEV_TYPE_ATTR_RO(available_instances); -static ssize_t device_api_show(struct kobject *kobj, struct device *dev, - char *buf) +static ssize_t device_api_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING); } diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c index da88fd7dd42329..885b88ea20e234 100644 --- a/samples/vfio-mdev/mdpy.c +++ b/samples/vfio-mdev/mdpy.c @@ -652,18 +652,21 @@ static const struct attribute_group *mdev_dev_groups[] = { NULL, }; -static ssize_t -name_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t name_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { - return sprintf(buf, "%s\n", kobj->name); + const struct mdpy_type *type = + &mdpy_types[mtype_get_type_group_id(mtype)]; + + return sprintf(buf, "%s\n", type->name); } static MDEV_TYPE_ATTR_RO(name); -static ssize_t -description_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t description_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { const struct mdpy_type *type = - &mdpy_types[mtype_get_type_group_id(kobj)]; + &mdpy_types[mtype_get_type_group_id(mtype)]; return sprintf(buf, "virtual display, %dx%d framebuffer\n", type ? type->width : 0, @@ -671,15 +674,16 @@ description_show(struct kobject *kobj, struct device *dev, char *buf) } static MDEV_TYPE_ATTR_RO(description); -static ssize_t -available_instances_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t available_instances_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, + char *buf) { return sprintf(buf, "%d\n", max_devices - mdpy_count); } static MDEV_TYPE_ATTR_RO(available_instances); -static ssize_t device_api_show(struct kobject *kobj, struct device *dev, - char *buf) +static ssize_t device_api_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING); } diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c index f2e36c06ac6aa2..b9b24be4abdab7 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c @@ -1292,23 +1292,24 @@ static const struct attribute_group *mdev_dev_groups[] = { NULL, }; -static ssize_t -name_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t name_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { static const char *name_str[2] = { "Single port serial", "Dual port serial" }; return sysfs_emit(buf, "%s\n", - name_str[mtype_get_type_group_id(kobj)]); + name_str[mtype_get_type_group_id(mtype)]); } static MDEV_TYPE_ATTR_RO(name); -static ssize_t -available_instances_show(struct kobject *kobj, struct device *dev, char *buf) +static ssize_t available_instances_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, + char *buf) { struct mdev_state *mds; - unsigned int ports = mtype_get_type_group_id(kobj) + 1; + unsigned int ports = mtype_get_type_group_id(mtype) + 1; int used = 0; list_for_each_entry(mds, &mdev_devices_list, next) @@ -1319,9 +1320,8 @@ available_instances_show(struct kobject *kobj, struct device *dev, char *buf) static MDEV_TYPE_ATTR_RO(available_instances); - -static ssize_t device_api_show(struct kobject *kobj, struct device *dev, - char *buf) +static ssize_t device_api_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) { return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING); }