From patchwork Thu Nov 24 23:25:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 25748 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3661391wrr; Thu, 24 Nov 2022 15:30:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf5IAeTP3T4P8uPUXG6/9gBM7CmyAg4T2JjO+cahm70eaBsyOKN0OtBH1BAiCFX4P3uWXSxk X-Received: by 2002:a17:906:e083:b0:78d:c155:56b2 with SMTP id gh3-20020a170906e08300b0078dc15556b2mr21009609ejb.291.1669332643533; Thu, 24 Nov 2022 15:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669332643; cv=none; d=google.com; s=arc-20160816; b=ILRAUbtdVgGdm130m6gDpA34S87suyQOMOxCORpLDThzoarh715lo8F8WDcrb7tF1u J3XxnSJja01hih6SlvCgJ+71m5ouYEZrj5yFQDmAF3X71r/okNwc4WcldlHi3dS0npPu 0Yj83m3WN+uzyLCP2aUwLao2asVIlvSP5f73gMykenFd2Y26Pd/YB3QONo9pFYZaIgPe QrBDuESOvbAFFagsgTxp802e5w30dFS+cDlVCjK9v1YToIZOQVWYbt5yZbdZeoVeLzSR nuDksc0CxmPsg0oxNaORT6ggBYBNL8GqMZNSTa3JthKsOSc9PcLRpEE8NnuszVbB6p/A HVpA== 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.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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020aa7cf15000000b00459dc4e4b7fsi1006421edy.143.2022.11.24.15.30.19; Thu, 24 Nov 2022 15:30:43 -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.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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750422146339260647?= X-GMAIL-MSGID: =?utf-8?q?1750422146339260647?= 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);