Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1108020lqo; Thu, 9 May 2024 05:12:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWvq1aM1jfBfiW6iKRmaUqVHgpxGCfJerVTf8hl493vZc1M6NVjWuVhGEfY7hHUJ8gHr80aiDYViYrNjUDGQ8mKlb0QSn8uJ3tdYWWZwA== X-Google-Smtp-Source: AGHT+IG294Gs+DMDHIsXRkekVcoeolhUGhum8ThH+7Y33ZaP592yzmZ8BHkZMN24JBTm9pz845L/ X-Received: by 2002:a05:6a21:3985:b0:1af:ce5e:ca5f with SMTP id adf61e73a8af0-1afce5ecd95mr4330072637.16.1715256735872; Thu, 09 May 2024 05:12:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715256735; cv=pass; d=google.com; s=arc-20160816; b=bF4IqzzoxXNOKN0RdHdQ3ughLMdDXcP+6ncbhQysiyWaFr3nhnD4fUgkIgvFleJ9yl YvxeokbSbmyfy2c+fAYIbpCG4GybvhhUvqlPE0f/W44CrBrB3b/GB22u8zoelyOqwGLR DCcf2l0VXVYfHNjKm1AvaJA2Ef0bpClyZLf3QLCcciRAJYa5DX/myQRgUCS8+NLMI6RY uQT/pdsZ8eg9A2dOJ/7J42TS98hm5DS/mzsihSpCYfr3DIMyCCijj5BsjBrSYavuLsgC GQdlBn8nFXw+ni0HcrRzioxKBFHcegFDuOOSr/1AIv9e6C6uGhJc9NhO1uUHurGmvK7n 1Ttg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=nJC14KI5N51a3HwicqFWcq+QiW6+wpgCB8tEHpU3Fus=; fh=Ryk+eq1X0xR6iDfe2yuvEcRzN+wD6Pg628GyuWI6JkQ=; b=XjthWIVieex48oMGRvdlOyO0UfNu17tUhH0+d1mAKN6VD0FI2fFkAH/3UErRYfpOUm vSxHAVmQV6MgTKZR+CGuOIv2EsFJ5wpFxUgfHI/lp2lRsCg8vvSfaWQlltw6EC9lSSWW D8lPVCsKKrde1kcuBz+oU49rF9LFacoL2it2fOPQvZAYIXT7KihuQ6whTcrZ+k6z/S3/ ShVlQIehHK7kDal9KeClg7S8lOWqSTNaB3Ynm+DH1fyubLl8dQDQcHmVw5WCdmzue0SP FDkrDhyZBGSqIYpOd+IJoq5wzoPe4/81tI6YeS73KFzqwjcRTX0kdpbBMTvXK0NC6AQ0 IsDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Bub+Bivc; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-174480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174480-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b671589acasi1321507a91.126.2024.05.09.05.12.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 05:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Bub+Bivc; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-174480-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174480-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 09311B224DD for ; Thu, 9 May 2024 12:10:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F8C514D70B; Thu, 9 May 2024 12:08:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Bub+Bivc" Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 8609714D297 for ; Thu, 9 May 2024 12:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715256516; cv=none; b=Pns4+2r8EMN4/T/gRTqqqJ8RqDydyJe10VKaSczYZ/taAyjPKkYjE+a6KqZOg80JkRj13R/MZoElrIccLQIHq6ApE0FxeNpyToy6kmMkYi1yjihNSgwRaE6OAyXUa6FHKxzDsEDNY2WjoC5I5uIJkkXFZ9BCstOemWgXUTdyAng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715256516; c=relaxed/simple; bh=kWgF3tD9Ik2YdBsN+KBUHfHvGZhsFYBdloxc7qbA964=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=tTGG1RF67mjBRA98Ca7TUtjrZdJEFxGOZRS5sxwbnHDqh9ds8FUOrSrWqddOQ5t5x4i0GbOcZLBeWl9fc2aCrq8A/0QIm4kDDTXx6gND/CQpdmBLCmWPAYcJP1iIv4ldz6W9t3fO2VVmxY1kW8PX7FEbQL4vhc/Ipc4rBDOn3wg= 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=Bub+Bivc; arc=none smtp.client-ip=209.85.210.49 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-ot1-f49.google.com with SMTP id 46e09a7af769-6eb86b69e65so434252a34.3 for ; Thu, 09 May 2024 05:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1715256512; x=1715861312; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nJC14KI5N51a3HwicqFWcq+QiW6+wpgCB8tEHpU3Fus=; b=Bub+BivcoOJb4874MGTs33YFce8MgDeGN7oGRdZcSK+wzmnoZys1C5MvZNQ2jp+Prg QP7Uu4g8+xz6kVKlnMVSSPGpzraRknVblr/QQApriuMJkTF2qIBtgs1+CzIY3c3HHmJr mRfpfcw4Yc67XUNJSdWRLaIDCUiCqC1aPsnni4W0xbjm+qFu5v7UTHxx8BToNVHI0Bs9 Ycki7NNEWnI7Np2/ggO+1Q/49jtTdem4lGKjJ70kPzSvy9M8hx7Y6AJgblmmH3vrzxs1 Q81Co80vsa16RIr97TZ1kCAgnbqsTwA6co2E1YRHwLAPrpwfPxXWVnA+ssA1lB2tiUKY pvqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715256512; x=1715861312; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nJC14KI5N51a3HwicqFWcq+QiW6+wpgCB8tEHpU3Fus=; b=p4oFFfZGcqXArSsPm514lXOQCM2+wImiwemjie02yqAdcmc3VDNuec+MJgJGQrAlzC XU+B68GOmTDPOeWCSIgpiosuhsqaYrXzoloiO+sTv1RqftGf3hgbZC5q4DmcQFL1XUjr 6DZv1TNGbvzomrOaaCrBdGL9G1JNqSIu2VIKAF7i660h7an0qAly6W9vGHZmjoLMWnQT UHuM+iTo+LXSrRAtfL8z2WtLXrZYONL4OEYvE2+2XEZTHYq9PKGWulF3WEBlBcn50Mgi FVl9OkWSnkqEM2GYFBj3IqBQa23vM9ezuWqMs7dZeksIc6jZggTVzNkxmlGl0fwyPZt9 4i7g== X-Forwarded-Encrypted: i=1; AJvYcCWgessPB/uQDxTC1MFbln2HGucrN9Z+Lo3uPNEMZ0yY1dRS2sqzykjuE8YXdznFRrolZV21OAqfBN3ublz9LCe5OrINm9H0tvjMrf35 X-Gm-Message-State: AOJu0YxrudQCJ7iDIVQ+AODRbMGSFee6RC6HfayjKRuFqAqK8QtM0gtI 6k3xHtVubImfzHKTutub+CEsLKUVhjpHB7M7MlYglp0CsUqV93zGM78CiupjuB4= X-Received: by 2002:a05:6808:1795:b0:3c9:9339:6fba with SMTP id 5614622812f47-3c9933974a7mr1186822b6e.16.1715256512343; Thu, 09 May 2024 05:08:32 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3c98fc97a8bsm174350b6e.17.2024.05.09.05.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 05:08:31 -0700 (PDT) From: Anup Patel To: Rob Herring , Saravana Kannan Cc: Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v4] of: property: Add fw_devlink support for interrupt-map property Date: Thu, 9 May 2024 17:38:20 +0530 Message-Id: <20240509120820.1430587-1-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some of the PCI host controllers (such as generic PCI host controller) use "interrupt-map" DT property to describe the mapping between PCI endpoints and PCI interrupt pins. This is the only case where the interrupts are not described in DT. Currently, there is no fw_devlink created based on "interrupt-map" DT property so interrupt controller is not guaranteed to be probed before the PCI host controller. This affects every platform where both PCI host controller and interrupt controllers are probed as regular platform devices. This creates fw_devlink between consumers (PCI host controller) and supplier (interrupt controller) based on "interrupt-map" DT property. Signed-off-by: Anup Patel Reviewed-by: Saravana Kannan --- Changes since v3: - Added a comment about of_irq_parse_raw() - Removed redundant NULL assignments to sup_args.np Changes since v2: - No need for a loop to find #interrupt-cells property value - Fix node de-reference leak when index is greater than number of entries in interrupt-map property Changes since v1: - Updated commit description based on Rob's suggestion - Use of_irq_parse_raw() for parsing interrupt-map DT property --- drivers/of/property.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index a6358ee99b74..2d749a18b037 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1311,6 +1311,57 @@ static struct device_node *parse_interrupts(struct device_node *np, return of_irq_parse_one(np, index, &sup_args) ? NULL : sup_args.np; } +static struct device_node *parse_interrupt_map(struct device_node *np, + const char *prop_name, int index) +{ + const __be32 *imap, *imap_end, *addr; + struct of_phandle_args sup_args; + u32 addrcells, intcells; + int i, imaplen; + + if (!IS_ENABLED(CONFIG_OF_IRQ)) + return NULL; + + if (strcmp(prop_name, "interrupt-map")) + return NULL; + + if (of_property_read_u32(np, "#interrupt-cells", &intcells)) + return NULL; + addrcells = of_bus_n_addr_cells(np); + + imap = of_get_property(np, "interrupt-map", &imaplen); + if (!imap || imaplen <= (addrcells + intcells)) + return NULL; + imap_end = imap + imaplen; + + while (imap < imap_end) { + addr = imap; + imap += addrcells; + + sup_args.np = np; + sup_args.args_count = intcells; + for (i = 0; i < intcells; i++) + sup_args.args[i] = be32_to_cpu(imap[i]); + imap += intcells; + + /* + * Upon success, the function of_irq_parse_raw() returns + * interrupt controller DT node pointer in sup_args.np. + */ + if (of_irq_parse_raw(addr, &sup_args)) + return NULL; + + if (!index) + return sup_args.np; + + of_node_put(sup_args.np); + imap += sup_args.args_count + 1; + index--; + } + + return NULL; +} + static struct device_node *parse_remote_endpoint(struct device_node *np, const char *prop_name, int index) @@ -1359,6 +1410,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_msi_parent, }, { .parse_prop = parse_gpio_compat, }, { .parse_prop = parse_interrupts, }, + { .parse_prop = parse_interrupt_map, }, { .parse_prop = parse_regulators, }, { .parse_prop = parse_gpio, }, { .parse_prop = parse_gpios, }, -- 2.34.1