From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37A65C43334 for ; Mon, 11 Jul 2022 06:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbiGKGad (ORCPT ); Mon, 11 Jul 2022 02:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbiGKGaU (ORCPT ); Mon, 11 Jul 2022 02:30:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB0AB491 for ; Sun, 10 Jul 2022 23:30:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1A051611EE for ; Mon, 11 Jul 2022 06:30:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACECDC341C0; Mon, 11 Jul 2022 06:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657521018; bh=AnjlGY0oPQW4urpHEI87j2xxZ/49V3A13LD+O7W1b08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fB388AwwBUbRbkWJ3U4q1nvfpiEYod1Or8DNJ02CumrWRIdhOXceUHgkCRYkaUL8V pNOWFgEcuAE+bU3UFOEkbYMO9WxOkiGIR1aE41b7WpBW01HF+I653RqyqdtDjyNIkU vzuQQiZBGIGe48a2CkVmkIVGlyeA7GNz3GAn1L/8Wm5meCpksJmffzpn6fRIvKOaC3 p2XzfuzeAurtsXBD8nxvAcAPUep/qgLMUm55khPA84YnVSMlPlOkY6asvjMF23ky0G iKzxEauHozNGEQevsYt8tFB10D+x1JeOkgPKbOhiAVIVX60fBSJBoYAYFh8/y+YwqG A3U4NjlRBI4WA== From: Oded Gabbay To: linux-kernel@vger.kernel.org Cc: Ofir Bitton Subject: [PATCH 08/12] habanalabs: expose only valid debugfs nodes Date: Mon, 11 Jul 2022 09:29:59 +0300 Message-Id: <20220711063003.3182795-8-ogabbay@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711063003.3182795-1-ogabbay@kernel.org> References: <20220711063003.3182795-1-ogabbay@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ofir Bitton In case security is enabled on the device, some debugfs nodes will fail. Hence, we do not expose them. Signed-off-by: Ofir Bitton Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay --- .../ABI/testing/debugfs-driver-habanalabs | 24 +++-- drivers/misc/habanalabs/common/debugfs.c | 94 ++++++++++--------- 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/Documentation/ABI/testing/debugfs-driver-habanalabs b/Documentation/ABI/testing/debugfs-driver-habanalabs index d9580f5d08a0..c915bf17b293 100644 --- a/Documentation/ABI/testing/debugfs-driver-habanalabs +++ b/Documentation/ABI/testing/debugfs-driver-habanalabs @@ -130,14 +130,16 @@ Date: Jan 2019 KernelVersion: 5.1 Contact: ogabbay@kernel.org Description: Sets I2C device address for I2C transaction that is generated - by the device's CPU + by the device's CPU, Not available when device is loaded with secured + firmware What: /sys/kernel/debug/habanalabs/hl/i2c_bus Date: Jan 2019 KernelVersion: 5.1 Contact: ogabbay@kernel.org Description: Sets I2C bus address for I2C transaction that is generated by - the device's CPU + the device's CPU, Not available when device is loaded with secured + firmware What: /sys/kernel/debug/habanalabs/hl/i2c_data Date: Jan 2019 @@ -145,39 +147,45 @@ KernelVersion: 5.1 Contact: ogabbay@kernel.org Description: Triggers an I2C transaction that is generated by the device's CPU. Writing to this file generates a write transaction while - reading from the file generates a read transaction + reading from the file generates a read transaction, Not available + when device is loaded with secured firmware What: /sys/kernel/debug/habanalabs/hl/i2c_len Date: Dec 2021 KernelVersion: 5.17 Contact: obitton@habana.ai Description: Sets I2C length in bytes for I2C transaction that is generated by - the device's CPU + the device's CPU, Not available when device is loaded with secured + firmware What: /sys/kernel/debug/habanalabs/hl/i2c_reg Date: Jan 2019 KernelVersion: 5.1 Contact: ogabbay@kernel.org Description: Sets I2C register id for I2C transaction that is generated by - the device's CPU + the device's CPU, Not available when device is loaded with secured + firmware What: /sys/kernel/debug/habanalabs/hl/led0 Date: Jan 2019 KernelVersion: 5.1 Contact: ogabbay@kernel.org -Description: Sets the state of the first S/W led on the device +Description: Sets the state of the first S/W led on the device, Not available + when device is loaded with secured firmware What: /sys/kernel/debug/habanalabs/hl/led1 Date: Jan 2019 KernelVersion: 5.1 Contact: ogabbay@kernel.org -Description: Sets the state of the second S/W led on the device +Description: Sets the state of the second S/W led on the device, Not available + when device is loaded with secured firmware What: /sys/kernel/debug/habanalabs/hl/led2 Date: Jan 2019 KernelVersion: 5.1 Contact: ogabbay@kernel.org -Description: Sets the state of the third S/W led on the device +Description: Sets the state of the third S/W led on the device, Not available + when device is loaded with secured firmware What: /sys/kernel/debug/habanalabs/hl/memory_scrub Date: May 2022 diff --git a/drivers/misc/habanalabs/common/debugfs.c b/drivers/misc/habanalabs/common/debugfs.c index 3da39662abd9..64439f33a19b 100644 --- a/drivers/misc/habanalabs/common/debugfs.c +++ b/drivers/misc/habanalabs/common/debugfs.c @@ -1562,6 +1562,53 @@ static const struct file_operations hl_debugfs_fops = { .release = single_release, }; +static void add_secured_nodes(struct hl_dbg_device_entry *dev_entry) +{ + debugfs_create_u8("i2c_bus", + 0644, + dev_entry->root, + &dev_entry->i2c_bus); + + debugfs_create_u8("i2c_addr", + 0644, + dev_entry->root, + &dev_entry->i2c_addr); + + debugfs_create_u8("i2c_reg", + 0644, + dev_entry->root, + &dev_entry->i2c_reg); + + debugfs_create_u8("i2c_len", + 0644, + dev_entry->root, + &dev_entry->i2c_len); + + debugfs_create_file("i2c_data", + 0644, + dev_entry->root, + dev_entry, + &hl_i2c_data_fops); + + debugfs_create_file("led0", + 0200, + dev_entry->root, + dev_entry, + &hl_led0_fops); + + debugfs_create_file("led1", + 0200, + dev_entry->root, + dev_entry, + &hl_led1_fops); + + debugfs_create_file("led2", + 0200, + dev_entry->root, + dev_entry, + &hl_led2_fops); +} + void hl_debugfs_add_device(struct hl_device *hdev) { struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; @@ -1632,50 +1679,6 @@ void hl_debugfs_add_device(struct hl_device *hdev) dev_entry, &hl_power_fops); - debugfs_create_u8("i2c_bus", - 0644, - dev_entry->root, - &dev_entry->i2c_bus); - - debugfs_create_u8("i2c_addr", - 0644, - dev_entry->root, - &dev_entry->i2c_addr); - - debugfs_create_u8("i2c_reg", - 0644, - dev_entry->root, - &dev_entry->i2c_reg); - - debugfs_create_u8("i2c_len", - 0644, - dev_entry->root, - &dev_entry->i2c_len); - - debugfs_create_file("i2c_data", - 0644, - dev_entry->root, - dev_entry, - &hl_i2c_data_fops); - - debugfs_create_file("led0", - 0200, - dev_entry->root, - dev_entry, - &hl_led0_fops); - - debugfs_create_file("led1", - 0200, - dev_entry->root, - dev_entry, - &hl_led1_fops); - - debugfs_create_file("led2", - 0200, - dev_entry->root, - dev_entry, - &hl_led2_fops); - debugfs_create_file("device", 0200, dev_entry->root, @@ -1754,6 +1757,9 @@ void hl_debugfs_add_device(struct hl_device *hdev) entry->info_ent = &hl_debugfs_list[i]; entry->dev_entry = dev_entry; } + + if (!hdev->asic_prop.fw_security_enabled) + add_secured_nodes(dev_entry); } void hl_debugfs_remove_device(struct hl_device *hdev) -- 2.25.1