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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=no 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 08D21C2B9F4 for ; Thu, 17 Jun 2021 14:23:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFB0960FE5 for ; Thu, 17 Jun 2021 14:23:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232085AbhFQOZY (ORCPT ); Thu, 17 Jun 2021 10:25:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231654AbhFQOZX (ORCPT ); Thu, 17 Jun 2021 10:25:23 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12912C061574; Thu, 17 Jun 2021 07:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=KT8Fho4u1v+WGBh8E32ZhnVOMV59PxuzA427/9wm0KY=; b=kLIUNSr+ZtN2pxK1xLUuPRkASc vjIezr+g0MdhoqjexF9xi5AtFtnrggIZqedSzBTgmjP+Gyk2MBOYM2hZ8wuy7Gb+OrRKZwmIMCzF0 4UyVNX01R4Ij/HUyWOMyklxav25gBlHvDGRXENqugc11vsQgQ27FsKxiKiOxPbq/h+9A5hs7yCLs2 XK9Twq6jS8i4lqZumrwWQIRkUomXLas6RNrz9QTiWREb8Z1evF1hdvBBv7yAZ5+It/87WDVFk82VF YHidW4wLvDfnSD50MuC5RdxmcuMhdWOIT4d/M9D3MhZE2IpYkw982wSThgEk04cqYGqL7p8Ja6j8Q hoNLSn4A==; Received: from [2001:4bb8:19b:fdce:dccf:26cc:e207:71f6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltsuT-009DV6-5t; Thu, 17 Jun 2021 14:22:27 +0000 From: Christoph Hellwig To: Greg Kroah-Hartman , Jason Gunthorpe , Alex Williamson , Kirti Wankhede Cc: David Airlie , Tony Krowiak , Christian Borntraeger , Cornelia Huck , Jonathan Corbet , Daniel Vetter , dri-devel@lists.freedesktop.org, Vasily Gorbik , Heiko Carstens , intel-gfx@lists.freedesktop.org, Jani Nikula , Jason Herne , Joonas Lahtinen , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-s390@vger.kernel.org, Halil Pasic , "Rafael J. Wysocki" , Rodrigo Vivi Subject: Allow mdev drivers to directly create the vfio_device (v4) Date: Thu, 17 Jun 2021 16:22:08 +0200 Message-Id: <20210617142218.1877096-1-hch@lst.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org This is my alternative take on this series from Jason: https://lore.kernel.org/dri-devel/87czsszi9i.fsf@redhat.com/T/ The mdev/vfio parts are exactly the same, but this solves the driver core changes for the direct probing without the in/out flag that Greg hated, which cause a little more work, but probably make the result better. Original decription from Jason below: The mdev bus's core part for managing the lifecycle of devices is mostly as one would expect for a driver core bus subsystem. However instead of having a normal 'struct device_driver' and binding the actual mdev drivers through the standard driver core mechanisms it open codes this with the struct mdev_parent_ops and provides a single driver that shims between the VFIO core's struct vfio_device and the actual device driver. Instead, allow mdev drivers implement an actual struct mdev_driver and directly call vfio_register_group_dev() in the probe() function for the mdev. Arrange to bind the created mdev_device to the mdev_driver that is provided by the end driver. The actual execution flow doesn't change much, eg what was parent_ops->create is now device_driver->probe and it is called at almost the exact same time - except under the normal control of the driver core. Ultimately converting all the drivers unlocks a fair number of additional VFIO simplifications and cleanups. Changes since v3: - minor cleanup to avoid the probe_ret variable in really_probe entirely - use a saner name for a variable in mdev-mtty - use a better driver name in mdev-mtty - update the documentation to match the new interface Changes since v2: - avoid warning spam for successful probes - improve the probe_count protection 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 X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=no 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 88CEFC2B9F4 for ; Thu, 17 Jun 2021 14:23:12 +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 2CCA660FE5 for ; Thu, 17 Jun 2021 14:23:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CCA660FE5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de 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 B0E746E8DE; Thu, 17 Jun 2021 14:23:11 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88AB66E8DE; Thu, 17 Jun 2021 14:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=KT8Fho4u1v+WGBh8E32ZhnVOMV59PxuzA427/9wm0KY=; b=kLIUNSr+ZtN2pxK1xLUuPRkASc vjIezr+g0MdhoqjexF9xi5AtFtnrggIZqedSzBTgmjP+Gyk2MBOYM2hZ8wuy7Gb+OrRKZwmIMCzF0 4UyVNX01R4Ij/HUyWOMyklxav25gBlHvDGRXENqugc11vsQgQ27FsKxiKiOxPbq/h+9A5hs7yCLs2 XK9Twq6jS8i4lqZumrwWQIRkUomXLas6RNrz9QTiWREb8Z1evF1hdvBBv7yAZ5+It/87WDVFk82VF YHidW4wLvDfnSD50MuC5RdxmcuMhdWOIT4d/M9D3MhZE2IpYkw982wSThgEk04cqYGqL7p8Ja6j8Q hoNLSn4A==; Received: from [2001:4bb8:19b:fdce:dccf:26cc:e207:71f6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltsuT-009DV6-5t; Thu, 17 Jun 2021 14:22:27 +0000 From: Christoph Hellwig To: Greg Kroah-Hartman , Jason Gunthorpe , Alex Williamson , Kirti Wankhede Date: Thu, 17 Jun 2021 16:22:08 +0200 Message-Id: <20210617142218.1877096-1-hch@lst.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Subject: [Intel-gfx] Allow mdev drivers to directly create the vfio_device (v4) 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: Tony Krowiak , Jason Herne , kvm@vger.kernel.org, Vasily Gorbik , Jonathan Corbet , David Airlie , linux-s390@vger.kernel.org, Heiko Carstens , Cornelia Huck , linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Halil Pasic , Christian Borntraeger , "Rafael J. Wysocki" , intel-gfx@lists.freedesktop.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This is my alternative take on this series from Jason: https://lore.kernel.org/dri-devel/87czsszi9i.fsf@redhat.com/T/ The mdev/vfio parts are exactly the same, but this solves the driver core changes for the direct probing without the in/out flag that Greg hated, which cause a little more work, but probably make the result better. Original decription from Jason below: The mdev bus's core part for managing the lifecycle of devices is mostly as one would expect for a driver core bus subsystem. However instead of having a normal 'struct device_driver' and binding the actual mdev drivers through the standard driver core mechanisms it open codes this with the struct mdev_parent_ops and provides a single driver that shims between the VFIO core's struct vfio_device and the actual device driver. Instead, allow mdev drivers implement an actual struct mdev_driver and directly call vfio_register_group_dev() in the probe() function for the mdev. Arrange to bind the created mdev_device to the mdev_driver that is provided by the end driver. The actual execution flow doesn't change much, eg what was parent_ops->create is now device_driver->probe and it is called at almost the exact same time - except under the normal control of the driver core. Ultimately converting all the drivers unlocks a fair number of additional VFIO simplifications and cleanups. Changes since v3: - minor cleanup to avoid the probe_ret variable in really_probe entirely - use a saner name for a variable in mdev-mtty - use a better driver name in mdev-mtty - update the documentation to match the new interface Changes since v2: - avoid warning spam for successful probes - improve the probe_count protection _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx