Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp616849lqg; Fri, 1 Mar 2024 15:59:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZOulNJ0I7h6AwWVxPzq5Q7riO17su4DhI3XDEAKCybjZJqS4nFEJJ9b33P58iNZpxfIOrgVcqBGR0b1ZZxegEEpsPnYNJ6MNh+3uVvw== X-Google-Smtp-Source: AGHT+IEYHKSvceJzxvy2L72zK68K5rOHvymcJOIk5uJWd0bsuUJGr1AN2fC87bHD03fMyTAcJefC X-Received: by 2002:a05:620a:1648:b0:787:9e26:f6f with SMTP id c8-20020a05620a164800b007879e260f6fmr3347452qko.77.1709337541759; Fri, 01 Mar 2024 15:59:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709337541; cv=pass; d=google.com; s=arc-20160816; b=LVw6qX0YTknYn2tVEmoFXfJyKcspfJCOo6bDRoR2h7idj8ayut0tOwXJDnmoyZ0Tqp dXG9d6+qoQqi6zfk45quKVm+1XN1AiNXI7Yv5nTix7BwLqvANLew5EpxLAViu3jLiwkB k6ocL+gt17dQFf+J519c+JVzW7NO8vPVdxELFMQoL1rVU/V02lVfWgZ5BO+wBRv3e6JS 9rVc4fh7nUzco0DLomATOJ9L3eOt4AwuRo1TnP0xcXJKw8co/HrtGXxq0nw8dKQ5pQgS MXd5VsNNR3S+/O5vKnbLcwzkFXIk5fbKa1bSZc9IMeY8pDpl5LBwTJJXID/YggJMvcDY Uc3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=YlCAVuX4UaRN1aV/EeYQU1fnCBON103irv5ZBsuVOqI=; fh=PfMsMO/y1cx9jk8PgASxB3tE8U6q+YSpDEKq1MUv4v8=; b=G3IwLibaI5uAKQiKeNUS+Ems4SzjBumWWJWmfQ29zwJc7MeS5nwmsTTtFfRIucTqR0 eLZpHlDMsh4jQf0eKhNxk7K1LXihkPpwsYljBD2ig4NQ5mS/I1N/DC7qwZjZe/rlzz0z nEvMR8FjSYer3339tRHqvm5bYU57CJCuVZPN6fLTa2jYiEeCu3lSRUlUNWKC+ei6qHwx hbsszqXraqYBRzKCAr/8lcvMwoF4/JXMMM70+aKkdVZ5riV2PtOl6GLAyaS/+aPH569P 03zGsSSRkzzXfqpYVh0zIXgHQRgmOG2Ehs8oaO94Gg7/uGA3QcKQhluMECFrQUjdFbdB /KBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HcF0iIua; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-crypto+bounces-2461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x18-20020a05620a449200b007878204f461si5026511qkp.768.2024.03.01.15.59.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:59:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HcF0iIua; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-crypto+bounces-2461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7E8711C21D6D for ; Fri, 1 Mar 2024 23:59:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DA005F478; Fri, 1 Mar 2024 23:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HcF0iIua" X-Original-To: linux-crypto@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6646C59149 for ; Fri, 1 Mar 2024 23:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709337535; cv=none; b=HomKebZMoN1T5mk8YHnpW7o4NcC45jHCYIR+Rn9y4ey3xeA0HE3JeAaFceKzp92GI0Abxev2sHYk6ZIxnCsoHBSeBh6t09xd3nYdFzdIMXr1OxuLwjSeY9dehEQm4uyLAhqFtkSEeCwvIaGNZkBRJnOYjX0u+xWkTkg1SWLJyRI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709337535; c=relaxed/simple; bh=TEiZWx4zhHeYJu6Wn/bCg5XXbQXaRGha6ZvizIYbH7I=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eAECmjtf7BfBnzuLrxnVMAO7z1C7FbCVXBmxcFzJKmWIYIXjhzmG3tc954OpliMugCkATzO0j5+RvEv1IT+iZrldmA8wHa9U9yRHQIKUevUUOPQHEepjauFd48H28129iMuqnQLV0C9rR7EDums+tOl9PZlP341Mz/4wfVtpNz8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HcF0iIua; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709337532; 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=YlCAVuX4UaRN1aV/EeYQU1fnCBON103irv5ZBsuVOqI=; b=HcF0iIuakwYsFtvRAu+TuIf3Bl4qy0S/msXCjzkIpExHT8+LmNsT38p6J2PHz7TvT+qj8Q LYbhDKeZ+jSJEqbSq0GcCVxYwCDNVTDiN18vFHO03aRkVJFmEbw3aEHVNoz9MdPPuvW1Dy CU/4YKILd4YgQ6dhiMhvGcN02EVPMxg= Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-90-XWXs8MOcMNa7wPunTzP5sg-1; Fri, 01 Mar 2024 18:58:51 -0500 X-MC-Unique: XWXs8MOcMNa7wPunTzP5sg-1 Received: by mail-il1-f197.google.com with SMTP id e9e14a558f8ab-36424431577so32257305ab.3 for ; Fri, 01 Mar 2024 15:58:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709337530; x=1709942330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YlCAVuX4UaRN1aV/EeYQU1fnCBON103irv5ZBsuVOqI=; b=iUroZ8z/B0c9HZY2OV2Qw51c8FJq7Tsdin1FkZ82oqxopkD7lV2H78fKVOIeY9hP5Y njrj8BmZTXqtefbcTbLcBBK8YYHcWF4otKWpyo2Z0T1JqwuGJPSpkz+a9kzRkO01i3oT rngu5S2ZkyKHl4sCMRW4byPQKASAM18IdRq9F0RrNxBokwyC96PuDdq92VvXdD17Kwgn YG7D5r0YWEPtFGOy3Qqne/t0BruT8jZwaByjY+Rd5y9BDcGoa88JeTpYLpZU0mAMq7CD Ho6PGWMAxU2btMF4sTSv5/BHy9iezmFearWtUAFxPFpVlxn3fqHgHXqEVMhGYEuD80YF fqqQ== X-Forwarded-Encrypted: i=1; AJvYcCU/2FATyCNw54gA9fut1u8Qk2asrunk6CUD+A58nacNpT6aN5Wb9P8yhfyE/zDESlnypOC3P2Q73zXxJmf12RwTvM9Yfyu95MfMJSMS X-Gm-Message-State: AOJu0YyxLh50+hyUXYo/Rk7zCAs2BwgmsfUbGIbSdk2F8A6WpI1mjhVk jOEqEcJYwZYCogphZUOpawhsDZ4IjCIAYiFC54TTYPyxf+WY2aPHiSZpcfWvHlSN8tpEAf1R5TE Ss1lv2RrIbkmP1bJZTYrjOLhnZ1esMzsYWrIKWjhq7DXV47rc1VCouG27QmEsTA== X-Received: by 2002:a05:6e02:2164:b0:365:1b7c:670 with SMTP id s4-20020a056e02216400b003651b7c0670mr4106982ilv.8.1709337530257; Fri, 01 Mar 2024 15:58:50 -0800 (PST) X-Received: by 2002:a05:6e02:2164:b0:365:1b7c:670 with SMTP id s4-20020a056e02216400b003651b7c0670mr4106972ilv.8.1709337529949; Fri, 01 Mar 2024 15:58:49 -0800 (PST) Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id y11-20020a92c74b000000b003642688819csm1177284ilp.69.2024.03.01.15.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:58:49 -0800 (PST) Date: Fri, 1 Mar 2024 16:58:48 -0700 From: Alex Williamson To: Xin Zeng Cc: herbert@gondor.apana.org.au, jgg@nvidia.com, yishaih@nvidia.com, shameerali.kolothum.thodi@huawei.com, kevin.tian@intel.com, linux-crypto@vger.kernel.org, kvm@vger.kernel.org, qat-linux@intel.com, Yahui Cao Subject: Re: [PATCH v4 10/10] vfio/qat: Add vfio_pci driver for Intel QAT VF devices Message-ID: <20240301165848.37cfffaf.alex.williamson@redhat.com> In-Reply-To: <20240228143402.89219-11-xin.zeng@intel.com> References: <20240228143402.89219-1-xin.zeng@intel.com> <20240228143402.89219-11-xin.zeng@intel.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 28 Feb 2024 22:34:02 +0800 Xin Zeng wrote: > +static int > +qat_vf_vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) > +{ > + struct device *dev = &pdev->dev; > + struct qat_vf_core_device *qat_vdev; > + int ret; > + > + if (!pci_match_id(id, pdev)) { > + pci_err(pdev, "Incompatible device, disallowing driver_override\n"); > + return -ENODEV; > + } I think the question of whether this is the right thing to do is still up for debate, but as noted in the thread where I raised the question, this mechanism doesn't actually work. The probe callback is passed the matching ID from the set of dynamic IDs added via new_id, the driver id_table, or pci_device_id_any for a strictly driver_override match. Any of those would satisfy pci_match_id(). If we wanted the probe function to exclusively match devices in the id_table, we should call this as: if (!pci_match_id(qat_vf_vfio_pci_table, pdev))... If we wanted to still allow dynamic IDs, the test might be more like: if (id == &pci_device_id_any)... Allowing dynamic IDs but failing driver_override requires a slightly more sophisticated user, but is inconsistent. Do we have any consensus on this? Thanks, Alex > + > + qat_vdev = vfio_alloc_device(qat_vf_core_device, core_device.vdev, dev, &qat_vf_pci_ops); > + if (IS_ERR(qat_vdev)) > + return PTR_ERR(qat_vdev); > + > + pci_set_drvdata(pdev, &qat_vdev->core_device); > + ret = vfio_pci_core_register_device(&qat_vdev->core_device); > + if (ret) > + goto out_put_device; > + > + return 0; > + > +out_put_device: > + vfio_put_device(&qat_vdev->core_device.vdev); > + return ret; > +}