Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3009326pxb; Tue, 19 Jan 2021 11:14:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYk1pfdgHFwQodyE4C6YOqmk3bmRb9gjt1DrspIOqPdm0sZ7jwsFnzKr44zOwcKp414YXZ X-Received: by 2002:aa7:c849:: with SMTP id g9mr4541159edt.48.1611083684530; Tue, 19 Jan 2021 11:14:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611083684; cv=none; d=google.com; s=arc-20160816; b=XaYrxsfz37ZiLd3CLbdYUABsSm8WTz2dYIQez95Py7v1whXa6g79IRMgBG6wqf0bZq KG8GTeGyMJcMTR5p5sfwpgNnpKchNgJLsiBA2aVUc8KYJrRPCwtRkRamrEtYnEibU052 IupRAEu6JDVRKXuwMvp2cNqOqXrL8wDJqAvFSGeJt9/MJtlzlUbsaphGki0lEXZBBtFg x+/0wtK4AC7seaGTxGZr9UrmaWCRuiOuFeijjtXdX4lYB+mvp/YUooZthrWTHIn4YUCx g3PG9EGYqJNATvfSD1ezrEtaIsM5PHmWbLRudHVqDZ6dt8Y/QWxT25348o/53ovxkmQq vd+A== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=USIJV7ocAqDOCberXRvY/8K18emSXxgvsqV2iaD7hJA=; b=P1qav7wWcMXDOM0MAbJNXvw97eV+8bef8yOjrs2n8jNWz7yNCFZWNNwq7nOC3Y5DXY Rol3GrHfWhkKAYNYz0lOZ4n2l1ZLkknAMFu0BiQlKuJaPHMHX9xTqsKarBXzJiA65yOh 1FQdYtvRck8qkXajSyRXprhCvzxn5H16C8/0n9xG3vP5xp+h3jJ88DLwf78VLUgg1nzm ayGG5L/z5pod4rFnaO2954uQHuuwNBuLwse8nsFMwy9QwAZ/6Uev5Ls8b0bd8l0lofy1 nEQiZGmEiITHT/vRMVIaKDBM4L74wZgqR8SqEw7oG/d6uUophiKEmbqd79P8jSOxGOnH jBRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="d6GgJSw/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si3040129ejk.657.2021.01.19.11.14.20; Tue, 19 Jan 2021 11:14:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="d6GgJSw/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727324AbhASTNW (ORCPT + 99 others); Tue, 19 Jan 2021 14:13:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38194 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391798AbhASS6C (ORCPT ); Tue, 19 Jan 2021 13:58:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611082586; 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=USIJV7ocAqDOCberXRvY/8K18emSXxgvsqV2iaD7hJA=; b=d6GgJSw/5UJ9hsAvdUvOtOLgLvfbmjo3PPNnDImL4W4sLPNe2S+wwNiBov/WbTK+B0EMGw L/k3gs2MbpyeoklZcGn+uh4O5/7qexsw6c1m0d22j3WzrvUv2g2N/6zDu85x+RB/DU44pn QGiH2oi+G8qXF950JWg+twoh6vvKWAA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-434-oSXhdUFTOCWgwZgH13Pj2w-1; Tue, 19 Jan 2021 13:56:22 -0500 X-MC-Unique: oSXhdUFTOCWgwZgH13Pj2w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FBA0800D62; Tue, 19 Jan 2021 18:56:19 +0000 (UTC) Received: from gondolin (ovpn-113-246.ams2.redhat.com [10.36.113.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53AD218796; Tue, 19 Jan 2021 18:56:13 +0000 (UTC) Date: Tue, 19 Jan 2021 19:56:10 +0100 From: Cornelia Huck To: Jason Gunthorpe Cc: Max Gurtovoy , , , , , , , , , , , , , , , Subject: Re: [PATCH RFC v1 0/3] Introduce vfio-pci-core subsystem Message-ID: <20210119195610.18da1e78.cohuck@redhat.com> In-Reply-To: <20210118181626.GL4147@nvidia.com> References: <20210117181534.65724-1-mgurtovoy@nvidia.com> <20210118143806.036c8dbc.cohuck@redhat.com> <20210118151020.GJ4147@nvidia.com> <20210118170009.058c8c52.cohuck@redhat.com> <20210118181626.GL4147@nvidia.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 18 Jan 2021 14:16:26 -0400 Jason Gunthorpe wrote: > On Mon, Jan 18, 2021 at 05:00:09PM +0100, Cornelia Huck wrote: > > > > You can say that all the HW specific things are in the mlx5_vfio_pci > > > driver. It is an unusual driver because it must bind to both the PCI > > > VF with a pci_driver and to the mlx5_core PF using an > > > auxiliary_driver. This is needed for the object lifetimes to be > > > correct. > > > > Hm... I might be confused about the usage of the term 'driver' here. > > IIUC, there are two drivers, one on the pci bus and one on the > > auxiliary bus. Is the 'driver' you're talking about here more the > > module you load (and not a driver in the driver core sense?) > > Here "driver" would be the common term meaning the code that realizes > a subsytem for HW - so mlx5_vfio_pci is a VFIO driver because it > ultimately creates a /dev/vfio* through the vfio subsystem. > > The same way we usually call something like mlx5_en an "ethernet > driver" not just a "pci driver" > > > Yes, sure. But it also shows that mlx5_vfio_pci aka the device-specific > > code is rather small in comparison to the common vfio-pci code. > > Therefore my question whether it will gain more specific changes (that > > cannot be covered via the auxiliary driver.) > > I'm not sure what you mean "via the auxiliary driver" - there is only > one mlx5_vfio_pci, and the non-RFC version with all the migration code > is fairly big. > > The pci_driver contributes a 'struct pci_device *' and the > auxiliary_driver contributes a 'struct mlx5_core_dev *'. mlx5_vfio_pci > fuses them together into a VFIO device. Depending on the VFIO > callback, it may use an API from the pci_device or from the > mlx5_core_dev device, or both. Let's rephrase my question a bit: This proposal splits the existing vfio-pci driver into a "core" component and code actually implementing the "driver" part. For mlx5, an alternative "driver" is introduced that reuses the "core" component and also hooks into mlx5-specific code parts via the auxiliary device framework. (IIUC, the plan is to make existing special cases for devices follow mlx5's lead later.) I've been thinking of an alternative split: Keep vfio-pci as it is now, but add an auxiliary device. For mlx5, an auxiliary device_driver can match to that device and implement mlx5-specific things. From the code in this RFC, it is not clear to me whether this would be feasible: most callbacks seem to simply forward to the core component, and that might be possible to be done by a purely auxiliary device_driver; but this may or may not work well for additional functionality. I guess my question is: into which callbacks will the additional functionality hook? If there's no good way to do what they need to do without manipulating the vfio-pci calls, my proposal will not work, and this proposal looks like the better way. But it's hard to tell without seeing the code, which is why I'm asking :)