Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1605525pxb; Fri, 20 Nov 2020 13:59:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtnYpIRCQ9+7UgdkuGSSsr/QV4e1t48/S47BEhnSLUQZCnYl+131lTG19Ny3kaNmy0krI5 X-Received: by 2002:a17:907:2805:: with SMTP id eb5mr34101658ejc.27.1605909591701; Fri, 20 Nov 2020 13:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605909591; cv=none; d=google.com; s=arc-20160816; b=nlU1Issi3CGvZ4N7kuUTJlmn+KJV1FpBfPe4x2oGRbMLE5qzxbjmUoKYMqJT2F4T0x 12+zr28jQoyvqwO2U1xoLWuqgSnNZmyLA5klmw7qWzN25XNURMhbN9K4Vz8I5rbsxuAb hAytau/kDWQu6LNM38cqAK/K3v4ITGYsWa3LGaR0ckAopI3jGLAAOLuRmeuLUbSKW8dJ /RcLRg82O2JN/AH+Sq+JeV9dU6PLYkMcMh5y65gYCfZxoZY4eGEm5fqCP0Hrj703aaa4 rh474mIiImvAiSyispOdOpB3QgAEfnq2HjhWxPzW7fLnIKu11ZI7/MH7SNBvoyZJksRd gdZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=Vga2AoBjVtzuzpzzNAVTpnnZ/4+mGnlEpZQxcHwWw2g=; b=sPL7cKBypn/zS+NInhI10BW3rByCLpjwb8uzl61VVxGrJm6yWdU9CM9IaKcN1m+Z+B zI01+n2SPHqngaPuEyKe7cPuEbl/lItKQ0u07kMswHJowzkYVVx8HNsG0zCFu+pXOAoP OanW2a+UMOpWupTPyiAjqCFnZDSVZnneMUA0Ze00STtw9kNhCHkgnejRg4ILxwUW4txK NwTZNqWOBvP93DJZ+L49/M6p9bOEvp5MKcL3JV02UF3Vy6J/q0c3FHL9LGtekYRahS6/ 3E57sCFXG8vG946YshmSyHkKcjDHAPVE0WpRijtfbFgYpkc0R50yh/6U4G0C1yNGUPa6 1CBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l8Mty+qA; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si2442112edm.45.2020.11.20.13.59.28; Fri, 20 Nov 2020 13:59:51 -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=@kernel.org header.s=default header.b=l8Mty+qA; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728398AbgKTV5N (ORCPT + 99 others); Fri, 20 Nov 2020 16:57:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:54146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728039AbgKTV5N (ORCPT ); Fri, 20 Nov 2020 16:57:13 -0500 Received: from localhost (129.sub-72-107-112.myvzw.com [72.107.112.129]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 972AF22254; Fri, 20 Nov 2020 21:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605909432; bh=EyJHD0We1WD+DYetjzdtwyxC7yClq4qfKpddxgRnFP0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=l8Mty+qAlU7C9g5t5MxjDLq+M0w2JXOYxy4O6cEBf9T481CGAuFcaBimpgrJeaU8i Frti8zwOeDY3M3nDLCEsoXpCS4wPxiHpL6NeOq9vB/w5tX8FS1TfYMVvqwna2GheM6 J+kzZMeud15nfXIoyE887+ZvhUkvldStjaZkB8Kk= Date: Fri, 20 Nov 2020 15:57:11 -0600 From: Bjorn Helgaas To: Zhenzhong Duan Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, hch@infradead.org, alex.williamson@redhat.com, cohuck@redhat.com Subject: Re: [PATCH v3 0/2] avoid inserting duplicate IDs in dynids list Message-ID: <20201120215711.GA281372@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117054409.3428-1-zhenzhong.duan@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 01:44:07PM +0800, Zhenzhong Duan wrote: > vfio-pci and pci-stub use new_id to bind devices. But one can add same IDs > multiple times, for example: > > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/new_id > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/new_id > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/new_id > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/remove_id > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/remove_id > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/remove_id > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/remove_id > -bash: echo: write error: No such device > > This doesn't cause user-visible broken behavior, but not user friendly. > he has to remove same IDs same times to ensure it's completely gone. > > Changed to only allow one dynamic entry of the same kind, after fix: > > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/new_id > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/new_id > -bash: echo: write error: File exists > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/remove_id > # echo "1af4 1041" > /sys/bus/pci/drivers/vfio-pci/remove_id > -bash: echo: write error: No such device > > > v3: add a separate patch to process dependency issue per Bjorn > make commit log more clear per Bjorn > v2: revert the export of pci_match_device() per Christoph > combind PATCH1 and PATCH2 into one. > > v2 link:https://lkml.org/lkml/2020/10/25/347 > > Zhenzhong Duan (2): > PCI: move pci_match_device() ahead of new_id_store() > PCI: avoid duplicate IDs in dynamic IDs list > > drivers/pci/pci-driver.c | 146 +++++++++++++++++++++++------------------------ > 1 file changed, 73 insertions(+), 73 deletions(-) > > -- > 1.8.3.1 > > > Zhenzhong Duan (2): > PCI: move pci_match_device() ahead of new_id_store() > PCI: avoid duplicate IDs in dynamic IDs list > > drivers/pci/pci-driver.c | 146 +++++++++++++++++++++++------------------------ > 1 file changed, 73 insertions(+), 73 deletions(-) I corrected the subject lines: PCI: Move pci_match_device() ahead of new_id_store() PCI: Avoid duplicate IDs in driver dynamic IDs list and applied both to pci/enumeration for v5.11, thanks!