From patchwork Mon Jul 29 14:22:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13745138 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6737CC3DA61 for ; Mon, 29 Jul 2024 14:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=S+3yiupMcqBHVKtDhH7R825y7QwUyIVJicMeCQk9e3U=; b=LJI/ByVKFEgl7KpSitGZjdYLed DPa3PThgOlXbXphuiZvgTbjeO7+oPxxdCm8E4Jjo3hHQUG+uTpRxEBXpE9wxsOteWBJLdr/FhNQQ5 W+g7M126QFAsrcdftBwHi7ZK7/MzTxf6o+vabbbWk/iSz6cRkJMyb5dQisou5p6sZT3E6hhqk5anN xOegsBr5EjI8mZUYAZ3gxMI0UmjopGorZG34MAerZwSdG1KP+bXz7hoC0sDva3oLI+mEtU9tbtXWj DdwXb9BMxdaLuoVDUCIOkGPtx5tdDOpxfgmofJyyD0a0SKiYRdX4ag3jnoRebpvB7XvoXVVI2hDVa hVnpYxPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRg2-0000000BjCQ-2DPk; Mon, 29 Jul 2024 14:48:42 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRIN-0000000BZ6F-0oJI for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 14:24:16 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1fc49c0aaffso18640785ad.3 for ; Mon, 29 Jul 2024 07:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722263054; x=1722867854; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S+3yiupMcqBHVKtDhH7R825y7QwUyIVJicMeCQk9e3U=; b=Csd9LRGBJ8AqZaWzPQIDT/I/mQk7vE/hJNVk/9xSsmZTpK0N+HFVhFZ88kbLyy6AMM TIvDRqlzXc8uPWM2RaTWmUA8mFor+6V6XVRsb+60L9MJ/di4sfsKrjjs60BUT7AOhINC C+6dD5dk7XDXSoYO9gze9z5NjfpyGlSs353OL7Ba4TUckZgF3Gc6HmpkM6dgtZFkHZx+ 5PF+ed8po8TrrMMpI2YupRO0bmyOOhQ0NtXCo5Sy/buOk7w+sL1/bvFvKUwuom3IoCwN w1IV4LpHnwvb0W8Z5zz/01MfZ8Y9UKyXU9mCKuOmgCNh5YuRwVODwy/J9KAobWf9lawd eXxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722263054; x=1722867854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S+3yiupMcqBHVKtDhH7R825y7QwUyIVJicMeCQk9e3U=; b=oaJ6+qwdiTasqwA4aV/qpZQDaXMWUyADgRwLPJRYY9IngSd/wMuIZEZKaRHC6RmIVP 45SXURd1ccgZU5xY4S+RJTxkIYT/4tvDPVDjILEVBNsd3tLtb8airheel6Y+NlK+jAth xHwxLLdM5KZSFX+oGoQRKWyttwWvtWxT2wRhIEjozrZCUWM/wqiTPsGYxYy35SUJEwlN f1vyLoubPZ0+zQMKFGGu/KZGdNx+JgUfAjhXpynqQvKKtS8t2ry0THRyyAoZnN4A7b6H Uk7XdMhNKfdqiCUwmVGzmtf4vdDGfKFQ/fpYt907tG10V47jGJ+bE8WMSdByBvMiESzU 61AQ== X-Forwarded-Encrypted: i=1; AJvYcCWf1uHs04Q/5rrwClIOlYqZnX+6KQwdasIDAiimT+kxB95wM8XhZv/BoNDpAWyIk+a8ZC1lQdA3mPzHdOb60w/1loFRScLnMQd8/cUpsrV11yuJA84= X-Gm-Message-State: AOJu0Yxg9qPRvGHyVzwq01rg0/ijR8OGAPlY+8+2GxE95jvjuCmOXiQ/ 9YUtScivorepc9Zgw3xA8/XXXDaZP79NLFOcnkXW8SZIVlcQWboF6sa75mgGt/M= X-Google-Smtp-Source: AGHT+IFyyx8DenY+eymy3lA0x+mYXtwZv9suwKy/4HPR4IzJLW5mFsnZTjAN7/+4Xj4Bjaq4qxjxyA== X-Received: by 2002:a17:902:ec8d:b0:1fd:6f24:efb2 with SMTP id d9443c01a7336-1ff0481a419mr65542815ad.19.1722263054397; Mon, 29 Jul 2024 07:24:14 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.198.16]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fa988dsm83512965ad.263.2024.07.29.07.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 07:24:13 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Haibo Xu , Atish Kumar Patra , Drew Fustini , Sunil V L Subject: [PATCH v7 14/17] irqchip/riscv-imsic-state: Create separate function for DT Date: Mon, 29 Jul 2024 19:52:36 +0530 Message-ID: <20240729142241.733357-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729142241.733357-1-sunilvl@ventanamicro.com> References: <20240729142241.733357-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_072415_288051_4319F6F0 X-CRM114-Status: GOOD ( 16.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org While populating IMSIC global structure, many fields are initialized using DT properties. Make the code which uses DT properties as separate function so that it is easier to add ACPI support later. No functionality added/changed. Suggested-by: Thomas Gleixner Signed-off-by: Sunil V L Reviewed-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-state.c | 97 ++++++++++++++----------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 5479f872e62b..f9e70832863a 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -510,6 +510,60 @@ static int __init imsic_matrix_init(void) return 0; } +static int __init imsic_populate_global_dt(struct fwnode_handle *fwnode, + struct imsic_global_config *global, + u32 *nr_parent_irqs) +{ + int rc; + + /* Find number of guest index bits in MSI address */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", + &global->guest_index_bits); + if (rc) + global->guest_index_bits = 0; + + /* Find number of HART index bits */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,hart-index-bits", + &global->hart_index_bits); + if (rc) { + /* Assume default value */ + global->hart_index_bits = __fls(*nr_parent_irqs); + if (BIT(global->hart_index_bits) < *nr_parent_irqs) + global->hart_index_bits++; + } + + /* Find number of group index bits */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", + &global->group_index_bits); + if (rc) + global->group_index_bits = 0; + + /* + * Find first bit position of group index. + * If not specified assumed the default APLIC-IMSIC configuration. + */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", + &global->group_index_shift); + if (rc) + global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; + + /* Find number of interrupt identities */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-ids", + &global->nr_ids); + if (rc) { + pr_err("%pfwP: number of interrupt identities not found\n", fwnode); + return rc; + } + + /* Find number of guest interrupt identities */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", + &global->nr_guest_ids); + if (rc) + global->nr_guest_ids = global->nr_ids; + + return 0; +} + static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, u32 index, unsigned long *hartid) { @@ -578,50 +632,9 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, return -EINVAL; } - /* Find number of guest index bits in MSI address */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", - &global->guest_index_bits); + rc = imsic_populate_global_dt(fwnode, global, nr_parent_irqs); if (rc) - global->guest_index_bits = 0; - - /* Find number of HART index bits */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,hart-index-bits", - &global->hart_index_bits); - if (rc) { - /* Assume default value */ - global->hart_index_bits = __fls(*nr_parent_irqs); - if (BIT(global->hart_index_bits) < *nr_parent_irqs) - global->hart_index_bits++; - } - - /* Find number of group index bits */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", - &global->group_index_bits); - if (rc) - global->group_index_bits = 0; - - /* - * Find first bit position of group index. - * If not specified assumed the default APLIC-IMSIC configuration. - */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", - &global->group_index_shift); - if (rc) - global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; - - /* Find number of interrupt identities */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-ids", - &global->nr_ids); - if (rc) { - pr_err("%pfwP: number of interrupt identities not found\n", fwnode); return rc; - } - - /* Find number of guest interrupt identities */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", - &global->nr_guest_ids); - if (rc) - global->nr_guest_ids = global->nr_ids; /* Sanity check guest index bits */ i = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT;