Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp63033lqj; Sat, 1 Jun 2024 08:08:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlAE8H5olyLzeXcKn9G8de73IsYio7HMcyTQdwH2hj13iMd/UIBSc8b+aqzcalaUugiTvQJERvwCICoONfEse/jsvYNJ5bUMQeUqHM5g== X-Google-Smtp-Source: AGHT+IFeUJuiXRtmBX+E8xTe6C82i+HW9XnbBm3Tvhs0PhsnZmZJZB+fK6IKC+EQ1TOkz5Sxrcwb X-Received: by 2002:a17:902:e744:b0:1f4:75e8:2ea0 with SMTP id d9443c01a7336-1f636fe7235mr50910305ad.6.1717254487243; Sat, 01 Jun 2024 08:08:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717254487; cv=pass; d=google.com; s=arc-20160816; b=exTtbLxpKkkO0A9/YTnV8JtW4tvG/dXic9QUeVB1UYuyCsrsD3VOTfIQZQre65bBP7 Unqy8kpqisgGJ2Ov+X5xLCwvf7EwnkP2u8jslEonKSKOgR339CAWMIFHCJSzuB1Wfq2Q ugrQuCVy5/pcpIaGkoZi7q6E5TK0ZALHVdGZ/V9jYhOb7bSo2wagwDOxll23jaoN9/9A X7lWdHQNWUbM8lplcih+uTEJPDdn8GJi3NaWQPjV7taI1wlbNVCYfeMoGeGWVgOwrUBR I+aoChaZbfsbvnh4eyTeJWCy3+oqcj58s68ThKECEoHM3fBOx0TokZubwD+TuDptw8UL n0Ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3PWsEZjmDFCls294wVt5rkIwO83PA99zSOvcBamPy6U=; fh=Pr1qGgO+Izonjb+pysmWiR+ANFBFaDso7gf+rlpZFPU=; b=rU+n+lfK2K75TpOTQqT3U5gakHLxiV+JXETfcCC2sFHEf5/Gs/hux174zIGgqWBiBL iznXx4xPonccRkhHynPNLgTYy1iZDBsquaK79LHe8nH6q+rBGDqhopc8bEV+6SmYjDQI 7xCKkJXQ2oxDJIXYgI6gnQSu5nj/2G5inK8o5exxED1IXFAGH/J2CpULnFLY+SmKpo7j Ufe6Hgo8ute2gC4KpzTA2MND3cMwz1IRtx5oiYDCttree090Y0dcN2/LWDw8TmviWtyw +j8HppSDDVKdbDsaDiFUdw42g9OA2q6ZGbOTaYeAWOmAcGS0Wl/yBGJclDLyWVb4/p6k Q+hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=jKNoXoGS; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-197920-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197920-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6323e9cefsi35964915ad.338.2024.06.01.08.08.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 08:08:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197920-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=jKNoXoGS; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-197920-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197920-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CF0BC283A43 for ; Sat, 1 Jun 2024 15:08:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78B24153824; Sat, 1 Jun 2024 15:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="jKNoXoGS" Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F75F1534E5 for ; Sat, 1 Jun 2024 15:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717254362; cv=none; b=mE3OMqXlHmvIYC85uyZ+8NAhw0jq4l0dQTk+phpJzi0i2vd7PdWvO6Q10hznQ0YGeXdvV2H/V7xnmzxinq4Dfe2VlTWSGWvSmHDCuDqoEZ8p1bhWXqfvPG34xTFVO2w3TRTEP1acsYOXFiGxynx/vhlgAD9dfHiXfGXaWlKgGI0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717254362; c=relaxed/simple; bh=zHxNtk7uwy5NYFihtfjCelt/wBqKO9jFTZ2VaVmdf38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=otonz3VbP+RnefxSj0ILtGw/1ENOJES1+vSJHQII2h7IIVoYnStvOwXjJXeaxVALMUthMeTYKrwMeKaiK+7Vs01xjUqHMQeLr0e4XunpzN+ab+H5cMHjYYPNwSwMEZ3oXobEeslULQBVpFvEqQkmJmZABuVHDUpNig1BzGJoIms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=jKNoXoGS; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-702555eb23bso537625b3a.1 for ; Sat, 01 Jun 2024 08:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1717254360; x=1717859160; darn=vger.kernel.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=3PWsEZjmDFCls294wVt5rkIwO83PA99zSOvcBamPy6U=; b=jKNoXoGS+WFDyCK6NlUqapQEi+8dh+SCoMTuJu8gxPVd4+oUTHoxNRu/G3u0Dd7jEe AIafqwcy6EUO/o80eiAed+3PrjcTlvxVfV3FpHCbAwVlhWUZg0B0x8yyb+7tKOpAMoA9 8RTjNAVrA/P2hBTWrEsASeySM0zWMKz/zpdB77qcDwpb+H/VBdSCvUK4aFOjglBjP4JY BmVYWMl65YIxo1q9+cKZ6JTNrk0C4Nquthjh4hnlsaCC6jan6yRFVD+f+4OnyLvfhXoc RWZERVzq6mWF8uE/G2bEpKmketskQiUWAWqftO3/k7BFY/w8HtByIexz7JlnN7iLsvUI yzWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717254360; x=1717859160; 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=3PWsEZjmDFCls294wVt5rkIwO83PA99zSOvcBamPy6U=; b=VoDFfeqLXa5bV30rVM5hkG2jJOD4IMtQQM/QlQvH48jvoeGxQc/mB91JbrEbPpkp8f 61/LyfNdvBeiaGqXl8tReIhf+UphC3nnac192xwaQM3IMhDTXY5LLyJt1JQ9fHl/R0Qg cXhK7Q2EXA4WQJzg2TFtJhdsCV/sqkIEqI6vfQAvc76PA+NrZabWzEulKcv1LqdPG7np 0LHRes7rVWVX2pthD2qEUx3YY4k47po0gKR6ic5pOJjPB8XjaUs0k9FGDkdYDnfsuR7C 3LkxQAWoDpYiPphRsWmX4Z0o8m7lIMgFKhcy3ybOST/X3l3DnuBPiNnsyyi9gbHWi5PB q7Ug== X-Forwarded-Encrypted: i=1; AJvYcCUqFgEKqjGuSV7L4WwH/UiPrDxcSM7dHGikvQuENIt+5vEr8YzgW/ZLLmyL9Zkbv9huLdTRBGdnHllqrNI6XNAPs/7sFXEyUaJ48Wb5 X-Gm-Message-State: AOJu0YxE7bg6Ifgo+emlRb6EjXDni/Blu/6cJaiSyAx+6abWkJBhCI+d ZqZYI+lC/BZq42pDJTRGBHpab3NVaoCR8ni87QONItY3oPPTV34sRNTX3zUW+TYW6L7K6z50ACG sZj4= X-Received: by 2002:a05:6a20:a115:b0:1b1:e7de:4d36 with SMTP id adf61e73a8af0-1b26f0f1b28mr5381872637.2.1717254360532; Sat, 01 Jun 2024 08:06:00 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.237]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-6c35a4ba741sm2559410a12.85.2024.06.01.08.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 08:06:00 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Andy Shevchenko , Marc Zyngier , Atish Kumar Patra , Haibo1 Xu , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Sunil V L Subject: [PATCH v6 14/17] irqchip/riscv-imsic-state: Create separate function for DT Date: Sat, 1 Jun 2024 20:34:08 +0530 Message-Id: <20240601150411.1929783-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240601150411.1929783-1-sunilvl@ventanamicro.com> References: <20240601150411.1929783-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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; -- 2.40.1