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: 13745015 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 2100117F4EC for ; Mon, 29 Jul 2024 14:24:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263056; cv=none; b=Cb3vIaJYKdA5Udwo9xg9btaLkvqhM+zw4WQ0jEU4BvBft5NtYbqu3HDU6Xa44sSsE940wMIPOe/33nhGUP2czyoKBr64cejb0QUNUHp35X6KvzoTZX7bHJTFa3mWT3nswzAi57e8xOQcMTuJM9mRuGmUiyTIKD0WO+ukmeu8TnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722263056; c=relaxed/simple; bh=3v6GeaJyGylX1JhRqA0q+Qffx/UKJbYSVwq4vV71mFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EvNT1hJAJhV2F9y5J8bDJrNyIzM9EVZlfdTsOQXzQDYBhZWzcyG4mO97EbnaVJs+nI4XyW9xq8J6XOlf+YfMyn1ti12K8xuvWzTz9oiz55mPt1qZulQoMgNvqYQq/L0Co3WkyaJNfPnIIWSlrxyN8BL6aqx1nn09EvzYxB1gTe4= 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=WWmXVgKD; arc=none smtp.client-ip=209.85.214.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="WWmXVgKD" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fb3b7d0d56so14465735ad.1 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=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=S+3yiupMcqBHVKtDhH7R825y7QwUyIVJicMeCQk9e3U=; b=WWmXVgKDOQrqmCTv78cSZFrQPCdAbBBvZiHX6zC2oqQqxry5bCGsDbeGEGWt1F4Yks SjoefU6BLJYg5zXvb6gGQw46pF/rMQaaa09I4re08b6SY+melz3IPlq/dODQVgfFt3J8 vFfIdoRXuAV58NDodfi/3HB8CNmSf7RI3h61zzvXbt/vGjnzpA8XHHlklgGBWTq/U2sJ q4BRfs2WhhpUoTBKomxownrUC4VDbGS3uyV/eAqmqKYoM4b8hoI3v1NQvhVyfpR/L2Cl UDeAXjwIezO2LQbwTWKHh/E5onIo452TQ485yM/rRXxU0W9o2APZppxH6SQCFu2lyqpW 080g== 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=Zjj9arlUbsR2q7mlHkYdj8QWQAoBBi+PkAAJvpGzoVexWWqfMpyfRaib/uW2UiO+8f DqqXrmdakZ3K3lFb2zfcAyooBmbE5Tc2xf4gJOFrSxqGHCOYSX5KyWgsoN2nCsTTWjqn vz2Ds5GM5trxE0c50YiGRb/QmtTet6TrlYHRqkOMloBEUkVQzLnpbRHlZHQAdTQcHB73 nHyWfIR10lG/s4l6rJ8+7Ay8XSDGaBEE5/VLjKo9NwvdlUsdXzFHHLVSo8THXewo+vjF adSlvTuQWAcQ3Yf1eSuouPG/j4N8GqvXS2D5qLJ5wbAYfaW9O5zwhJvIJHagZErUpXdo SOAA== X-Forwarded-Encrypted: i=1; AJvYcCVFMiSgTXRrJ76SQ0iWgtNPR+ho0wLHquj7kHxIfbNkW/XiEQ3gXcFFrw0/oCfjA792U1gW6i+IAze3VligAbMk9f6ihReuwlGO X-Gm-Message-State: AOJu0YzBWRsYYXWd0Dr/SF5COpFRqc03rj7RIg8x+85ZicD8RgILcLAX i8vynjmwyDOpdTPJGa/R9/UcEYwyg6AQQ9OZudOK5qbmWDvipGWq53y1G4PrUIs= 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> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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;