From patchwork Mon Nov 11 22:02:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 2009941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=wuXFpX34; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=WST1p35a; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XnNpn2L9Dz1xyG for ; Tue, 12 Nov 2024 09:03:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6tEh6nwf5idF0jUbFWNuqUxxuX7WHQmTAmVnIdnLqw4=; b=wuXFpX34WI8NS7 pxB0dmm50pIsqehNeM/UI37yAynmCzmfAswQ/q2GJKZbw1omWRX6SpOnG0+3VsyhH6AECj2ELrtit js26Z4ZeX8yNrUfTK8FjACaiQ3yXsGTNAe5f99CsKPgi0qbHL0y5SOs98Dbt5YkQrz1C73sqBsMsz eQhiUFzfTelMNCn/wg2rVlnb2cl6WHzMZET9ZYt6I9M9HRXPq3K6ySnpvXOx4kIFoFTUzg3DS2Rrf 8wSRSg4E5Hvjjn98jHsuu19H4ZDJ/VtoWb63p8wgOmUq3nEGTpbQYMCF0RiY1KjeBJ1jK0YZa+v1e mxeUstSqat3rDK8TivSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tAcVF-00000001RU2-1hIw; Mon, 11 Nov 2024 22:03:21 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tAcV9-00000001ROp-0MJz for opensbi@lists.infradead.org; Mon, 11 Nov 2024 22:03:16 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2e2ad9825a7so3762425a91.0 for ; Mon, 11 Nov 2024 14:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1731362594; x=1731967394; 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=+XfIZ1UhXVRovl+n6SFGSpuoTFvewVviXcxcFNuEMjE=; b=WST1p35a+gy4MOXkD9/goGjaBOz2PR88OPu2H/hkGgtqmM9aczA03h+PiRTCIXFd+K trzOdUd32Eg+QNyZxgYUDY4c4IBzPGtxA69ScQevvHhD2jIUiXWVBGSlkrO+A5qPison gXVAegzLjzmVueyjw5u+/7Y2lbR1IJSqZy+vYpQwpaX4O2fJxYTBNe8GnODKWAN/MRqs IoVf4zJwsPl1Wr7zXtb9I7SD1eo/yt6trRymU6PvnWEnIT8egI13xRCadXlHo8F7mEGV d/6C+zL8GF9mqOYHFKUsqcJcX6maajk6Yl5MK7HS3WdASntE3DpQOIVSwLohAJYQA6/U aLyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731362594; x=1731967394; 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=+XfIZ1UhXVRovl+n6SFGSpuoTFvewVviXcxcFNuEMjE=; b=CXccVJBYzevJ9PZaQ/0bw4d8qjkOyJvzMt36ZY3wIbhub16+TMVhfhJD1/+cDTSXgY BwmcJ++s5UK3eGJMvUuL57PPt/+VusKJ8ydIAU/rQRGXgYUpeidbNxFP4x26f4Vx2h+g ol9dNjOFnZqlYcv8nKg3QUDenUhQII6z/Ll6RDt/b0AGkd3TNkIoCtZPIrqDcPWODdJw dvJ90ajl5ruuIapvKQYLQZcLWiJOSG+6qAIlpUU4k7sfeNuX3WiSLq3q9XzZSspieOWu ITEGFS3RbmEgHpBr98fn7Ww5mMXCQu4DEiSVjAHUR/zb1lIcueovSNquZgpvVeYQrK84 nDQw== X-Gm-Message-State: AOJu0Yx9gQaFseBhy+sPf+Bc7L2rxzQVVqsrNxFNwbtNwHE/PSuN6H8j l7VK03YRj6tv8Ls9rJ1lx252eHDm8mOXNPpFyDE33WzHOcyaRmGe/vifuEMN6hmXgsoW3H7r6cu FBhKPzcpyuZStoYa71jsOhIfxvA9CoMdI45eoNB/4cYOg+6FY6DFHzBb8LtaJM53g/AG7P01Jyx x/8Ozk98tPt6ecluotwhMkyFPsNwo7ufWfqXzEi2fb9ox2i0q/j+k= X-Google-Smtp-Source: AGHT+IGZid00DJbqI7ItqwyhHxFyksHdo9Oo6Y7n1t5PUXfl1hWbyGlmoG8nWb9O5hJpceWQCWCfaw== X-Received: by 2002:a17:90a:d405:b0:2e2:d3a0:4716 with SMTP id 98e67ed59e1d1-2e9b173c50fmr21835498a91.18.1731362593875; Mon, 11 Nov 2024 14:03:13 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177e58316sm80832635ad.188.2024.11.11.14.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2024 14:03:13 -0800 (PST) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH v2 07/11] lib: utils/ipi: Use fdt_driver for initialization Date: Mon, 11 Nov 2024 14:02:51 -0800 Message-ID: <20241111220304.1228821-8-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241111220304.1228821-1-samuel.holland@sifive.com> References: <20241111220304.1228821-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241111_140315_151912_727C5225 X-CRM114-Status: GOOD ( 16.22 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The ipi driver subsystem does not need any extra data, so it can use `struct fdt_driver` directly. The generic fdt_ipi_init() performs a best-effort initialization of all matching DT nodes. Signed-off-by: Samuel Holland --- Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1033 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The ipi driver subsystem does not need any extra data, so it can use `struct fdt_driver` directly. The generic fdt_ipi_init() performs a best-effort initialization of all matching DT nodes. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- Changes in v2: - New patch for v2 include/sbi_utils/ipi/fdt_ipi.h | 6 +--- lib/utils/ipi/fdt_ipi.c | 42 +++------------------------- lib/utils/ipi/fdt_ipi_drivers.carray | 2 +- lib/utils/ipi/fdt_ipi_mswi.c | 4 +-- lib/utils/ipi/fdt_ipi_plicsw.c | 4 +-- 5 files changed, 10 insertions(+), 48 deletions(-) diff --git a/include/sbi_utils/ipi/fdt_ipi.h b/include/sbi_utils/ipi/fdt_ipi.h index 161f7a2e..9b014470 100644 --- a/include/sbi_utils/ipi/fdt_ipi.h +++ b/include/sbi_utils/ipi/fdt_ipi.h @@ -11,14 +11,10 @@ #define __FDT_IPI_H__ #include +#include #ifdef CONFIG_FDT_IPI -struct fdt_ipi { - const struct fdt_match *match_table; - int (*cold_init)(const void *fdt, int nodeoff, const struct fdt_match *match); -}; - int fdt_ipi_init(void); #else diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c index 6c2feafb..644c9c1c 100644 --- a/lib/utils/ipi/fdt_ipi.c +++ b/lib/utils/ipi/fdt_ipi.c @@ -7,50 +7,16 @@ * Anup Patel */ -#include -#include -#include #include /* List of FDT ipi drivers generated at compile time */ -extern struct fdt_ipi *const fdt_ipi_drivers[]; +extern const struct fdt_driver *const fdt_ipi_drivers[]; int fdt_ipi_init(void) { - int pos, noff, rc; - struct fdt_ipi *drv; - const struct fdt_match *match; - const void *fdt = fdt_get_address(); - - for (pos = 0; fdt_ipi_drivers[pos]; pos++) { - drv = fdt_ipi_drivers[pos]; - - noff = -1; - while ((noff = fdt_find_match(fdt, noff, - drv->match_table, &match)) >= 0) { - if (!fdt_node_is_enabled(fdt, noff)) - continue; - - /* drv->cold_init must not be NULL */ - if (drv->cold_init == NULL) - return SBI_EFAIL; - - rc = drv->cold_init(fdt, noff, match); - if (rc == SBI_ENODEV) - continue; - if (rc) - return rc; - - /* - * We will have multiple IPI devices on multi-die or - * multi-socket systems so we cannot break here. - */ - } - } - /* - * On some single-hart system there is no need for ipi, - * so we cannot return a failure here + * On some single-hart system there is no need for IPIs, + * so do not return a failure if no device is found. */ - return 0; + return fdt_driver_init_all(fdt_get_address(), fdt_ipi_drivers); } diff --git a/lib/utils/ipi/fdt_ipi_drivers.carray b/lib/utils/ipi/fdt_ipi_drivers.carray index 275fa9cf..006b0fd9 100644 --- a/lib/utils/ipi/fdt_ipi_drivers.carray +++ b/lib/utils/ipi/fdt_ipi_drivers.carray @@ -1,3 +1,3 @@ HEADER: sbi_utils/ipi/fdt_ipi.h -TYPE: struct fdt_ipi +TYPE: const struct fdt_driver NAME: fdt_ipi_drivers diff --git a/lib/utils/ipi/fdt_ipi_mswi.c b/lib/utils/ipi/fdt_ipi_mswi.c index c58d7722..aa37d0d0 100644 --- a/lib/utils/ipi/fdt_ipi_mswi.c +++ b/lib/utils/ipi/fdt_ipi_mswi.c @@ -61,7 +61,7 @@ static const struct fdt_match ipi_mswi_match[] = { { }, }; -struct fdt_ipi fdt_ipi_mswi = { +const struct fdt_driver fdt_ipi_mswi = { .match_table = ipi_mswi_match, - .cold_init = ipi_mswi_cold_init, + .init = ipi_mswi_cold_init, }; diff --git a/lib/utils/ipi/fdt_ipi_plicsw.c b/lib/utils/ipi/fdt_ipi_plicsw.c index a178db1b..be669980 100644 --- a/lib/utils/ipi/fdt_ipi_plicsw.c +++ b/lib/utils/ipi/fdt_ipi_plicsw.c @@ -39,7 +39,7 @@ static const struct fdt_match ipi_plicsw_match[] = { {}, }; -struct fdt_ipi fdt_ipi_plicsw = { +const struct fdt_driver fdt_ipi_plicsw = { .match_table = ipi_plicsw_match, - .cold_init = fdt_plicsw_cold_ipi_init, + .init = fdt_plicsw_cold_ipi_init, };