Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9645902rwb; Thu, 24 Nov 2022 16:34:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4oEXR0IYA9fLa/Lq76XIBzGOwS2M5j1+NPv3dVeKAX5MAklgS7WsE4Xg7MbyeGursQ1lXN X-Received: by 2002:a17:90a:7003:b0:212:f169:140e with SMTP id f3-20020a17090a700300b00212f169140emr36834409pjk.215.1669336494267; Thu, 24 Nov 2022 16:34:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669336494; cv=none; d=google.com; s=arc-20160816; b=KQFOGeihjGV1xUjyzZxdFqLmscoKV790PcXgoUzJ6YZ6nJw2hd031pNyt6t2yfQXpo 3wwgCLxRZp7pzssbVG55modAtv5qnt2Q84rn6S/ZmngzzbgF9qrel4YCTuTYMYkDpz7U d9y/IjL4p7WGEFAvlSIM2Iz53ytkalBbB0oFYuv0aivL4oWXQLzTdAS+eg8vci31sWvU E4DmuokV9VvNhHy6wgBhNvYOSxA3eb2cyz2jqt9p/sk43U1p1GRWCAZAnyr7Pjkx5Out Pj/kZnuV95/2YQrjrYv3lUhI4t00jwrc22WRst0sAIxGI6cKD4Kg+cMlNHjmvMwDldHs fmPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=KKwu6EVH8ruKNrQNXAsaHWUDYRK2+tT7uRCo5fxd1Vs=; b=1JOhOZkccOX6PWI+U7XxX9iH7slGJt0JwwJCfvGpLm9b3tMgrzxsgHd3j45riXRu1p Ij2CtQU9F//u3wvuX7SpLBVoQu2Z86On5t2hcZENGefORCWlt2AQhrHnLAqfyA8r/Te+ jdiboR5nDMQMEmeWdzsE5iBkYZZH/n3oxr2Ri+kmqaXOXYPH21L/4JyybDtBKKhXRHl+ zKYimEMJ8LCP+sm4Hdwmfqr81711B63HMsWd/CBp+TcmCc+dUkG59XIw3gg+/o2xPyWP ZvvVu3mLL+Ik0R08/vus61dB7h2a0nS1qwwdx0b8909Jg6AlipT1IXtPkGY3Vt/2DxCK VFjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="zBLb/Ox7"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=U714pILZ; 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 f12-20020a65400c000000b00439ae523fd2si2566103pgp.289.2022.11.24.16.34.43; Thu, 24 Nov 2022 16:34:54 -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="zBLb/Ox7"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=U714pILZ; 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 S229983AbiKXX2D (ORCPT + 87 others); Thu, 24 Nov 2022 18:28:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbiKXX1Y (ORCPT ); Thu, 24 Nov 2022 18:27:24 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00818B11A; Thu, 24 Nov 2022 15:26:16 -0800 (PST) Message-ID: <20221124232325.501144862@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669332351; 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: references:references; bh=KKwu6EVH8ruKNrQNXAsaHWUDYRK2+tT7uRCo5fxd1Vs=; b=zBLb/Ox7OJ0VV/3WNc7cfyfHZRZ9kH0LXxBr9yvermW/Cdpi8j9vMj4pORxOMop+qv+3ul M3AvejZVya/4s3APJ5vXtUlaJcaOCznMcq98LQlTnrztPkg7iPWCmwtABH316vm/9aC1fC ks8b27Ofl/d9YGQMDbfUXGZvyGv4kNz+92aLF6Pufvcw1JP+GlRb+eLDaGiyy5/XlBY9UX zLb7mUcRS+p6qPgYkrHpBqO9htQGC889H1qiM8jIbPYu4WH2G9ouMebAgnAwc4evmStG79 Ykn//ds95V5V1BUEPoKLhHNj65WBzT9Zd4Losv9sn6OxOZipDmatJuJbWy+N5A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669332351; 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: references:references; bh=KKwu6EVH8ruKNrQNXAsaHWUDYRK2+tT7uRCo5fxd1Vs=; b=U714pILZM40FuHR0FKCS8MjRY15jpHxDIzBby9AK0wRMzB+f2fhZeyenVKgAS965j0wNDK FLef1Gx9MlMtcsBA== From: Thomas Gleixner To: 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 , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V3 04/33] genirq/msi: Add size info to struct msi_domain_info References: <20221124230505.073418677@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Fri, 25 Nov 2022 00:25:51 +0100 (CET) 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 To allow proper range checking especially for dynamic allocations add a size field to struct msi_domain_info. If the field is 0 then the size is unknown or unlimited (up to MSI_MAX_INDEX) to provide backwards compability. Signed-off-by: Thomas Gleixner --- V3: Move the initialization into the common domain creation code --- include/linux/msi.h | 5 +++++ kernel/irq/msi.c | 11 +++++++++++ 2 files changed, 16 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -422,6 +422,10 @@ struct msi_domain_ops { * struct msi_domain_info - MSI interrupt domain data * @flags: Flags to decribe features and capabilities * @bus_token: The domain bus token + * @hwsize: The hardware table size or the software index limit. + * If 0 then the size is considered unlimited and + * gets initialized to the maximum software index limit + * by the domain creation code. * @ops: The callback data structure * @chip: Optional: associated interrupt chip * @chip_data: Optional: associated interrupt chip data @@ -433,6 +437,7 @@ struct msi_domain_ops { struct msi_domain_info { u32 flags; enum irq_domain_bus_token bus_token; + unsigned int hwsize; struct msi_domain_ops *ops; struct irq_chip *chip; void *chip_data; --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -773,6 +773,17 @@ struct irq_domain *msi_create_irq_domain { struct irq_domain *domain; + if (info->hwsize > MSI_XA_DOMAIN_SIZE) + return NULL; + + /* + * Hardware size 0 is valid for backwards compatibility and for + * domains which are not backed by a hardware table. Grant the + * maximum index space. + */ + if (!info->hwsize) + info->hwsize = MSI_XA_DOMAIN_SIZE; + msi_domain_update_dom_ops(info); if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) msi_domain_update_chip_ops(info);