Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8641966rwb; Thu, 24 Nov 2022 02:16:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf7zZmHccubFOkRGA52PQv7ZxTpnjwROL7kWBeQk4mfSwLQViyDeUp85sjzFZssjsWiCAHPq X-Received: by 2002:aa7:85c8:0:b0:574:5789:b8a4 with SMTP id z8-20020aa785c8000000b005745789b8a4mr6995016pfn.47.1669285004335; Thu, 24 Nov 2022 02:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669285004; cv=none; d=google.com; s=arc-20160816; b=sDtFiBY5ou6V7XFywzXgV654eo9Mtpflfj1+yWYhGMbEHtbvKm1ucpYaQV3y8gom07 sMGWiLGrnOIG7GqXR8gopS/V7OSq+GexCLTS1ANWot0H1XryMeh0MlCwtAZWIxXfKksY CaaZ1Cx944vH8o5J5/Um7+tQGM3brx0cd5Lfc0sKDzZTX93qwk/vPqb6wM313cC1AIMd nHvlemLdA/n8sar5MkrptKttG3Mc/z3J5zxDxfLSJN/bhkWj5TAkqw5XmoACp+Dvz86W UgQC5sfMF7ze2rcVfJtTp5GYtpwQWFcedgT7MA3l9nRIV8sfii1Jl827j9F6MSAw0co8 Z+1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=vf5+/aiHla/4ly0OoP7CLfyVx7qM6ZIIFk9d+ZXvjMc=; b=DpCQnV9Fs7SRZKyWvGJIQYw7z+u4o6AUGenzM59I7T8A8/TIajx9xa/EM0BdTZWQU0 h1X1w1BQQf6BzF/EWoSEE5vphH6dpCs3cQDHWN7WncXLc43Pft/GPq57yjfOVT7lOEZh 25UyXmj4JX9Y99H2HXkE3rdr91YTIcnRx2EpwRMSAT7Cmyune6c9W9HNVCyxy23R378q O+dKwd4YbGAq14GfIuQG7K0FACvi+H5kFoxGiegRmOyL9DoSafw+zGCWD71eS9xAr5XZ EEa2RsDOjNKKQwWnyiVjME3Jj8X+kONJUR8G1jKwwyz9p2HnxdkXWo7vND4RyLbgx256 hxVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=E89LVilE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8+DEVL1J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a13-20020a62d40d000000b005725d4d6fcdsi644877pfh.205.2022.11.24.02.16.28; Thu, 24 Nov 2022 02:16:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=E89LVilE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8+DEVL1J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbiKXJIq (ORCPT + 87 others); Thu, 24 Nov 2022 04:08:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbiKXJIg (ORCPT ); Thu, 24 Nov 2022 04:08:36 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB66B9BB1; Thu, 24 Nov 2022 01:08:34 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669280911; 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: in-reply-to:in-reply-to:references:references; bh=vf5+/aiHla/4ly0OoP7CLfyVx7qM6ZIIFk9d+ZXvjMc=; b=E89LVilE3e6XbkR6X9uDZKKzxi03YzZUjVl4CePB0jlbeE9d8/7TlYbNAKF9S/x37tm3gR T52XSfM8XRu4I86l1xI/mZqPv9JpIjDvjqhh2dSKPTYfjmILdsAdF4EtqbPhLNLpPYtAti fRJpG7f732NRs09YUvPA4OmbTwegnRJegyclA2U22FzXqb96GHEVchpRkrH5I2x8+5h8lt /sYYIKMGBEpekz5S/FNwC9mQe0HNpegt7kJBGj8EhNInta0qQ6Q4cGFoPHdnXojOKKPvEN U2nqmdds2R1SaH8Y4Dm/ZMfXqUkQWRf5iNu8Tpc+Dc+KvPjhbEmqTpF/S/MKcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669280911; 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: in-reply-to:in-reply-to:references:references; bh=vf5+/aiHla/4ly0OoP7CLfyVx7qM6ZIIFk9d+ZXvjMc=; b=8+DEVL1J12Cn9H7OIatnawR2Ez/52Y3OObvV/7YWFsre4tCC6OAkwuITbzOnkA2znqIX6n 11bu0XNmztteaiDg== To: "Tian, Kevin" , LKML Cc: "x86@kernel.org" , Joerg Roedel , Will Deacon , "linux-pci@vger.kernel.org" , Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , "Jiang, Dave" , Alex Williamson , "Williams, Dan J" , Logan Gunthorpe , "Raj, Ashok" , Jon Mason , Allen Hubbe Subject: RE: [patch V2 25/33] PCI/MSI: Provide post-enable dynamic allocation interfaces for MSI-X In-Reply-To: References: <20221121083657.157152924@linutronix.de> <20221121091327.869774994@linutronix.de> Date: Thu, 24 Nov 2022 10:08:31 +0100 Message-ID: <87r0xsd8j4.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 24 2022 at 02:58, Kevin Tian wrote: >> + >> +/** >> + * pci_msix_free_irq - Free an interrupt on a PCI/MSIX interrupt domain >> + * which was allocated via pci_msix_alloc_irq_at() >> + * >> + * @dev: The PCI device to operate on >> + * @map: A struct msi_map describing the interrupt to free >> + * as returned from the allocation function. >> + */ > > Can this be used on preallocated descriptors? If not any guard required > or just treat it as a driver responsibility to not misuse? The preallocated descriptors are only relevant during setup, but not post setup. So yes, you can do: pci_alloc_irq_vectors(dev, 10, 10, PCI_IRQ_MSIX); and then map = { .index = 9, .virq = $IRQ }; pci_msix_free_irq(dev, &map); It just works. >> +void pci_msix_free_irq(struct pci_dev *dev, struct msi_map map) >> +{ >> + if (WARN_ON_ONCE(map.index < 0 || map.virq <= 0)) > > map.virq cannot be negative. Why? Callers can make up whatever they want, no? Thanks, tglx