linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] habanalabs: update firmware header
@ 2022-05-11 13:19 Oded Gabbay
  2022-05-11 13:19 ` [PATCH 2/3] habanalabs: use NULL for eventfd Oded Gabbay
  2022-05-11 13:19 ` [PATCH 3/3] habanalabs: return -EFAULT on copy_to_user error Oded Gabbay
  0 siblings, 2 replies; 3+ messages in thread
From: Oded Gabbay @ 2022-05-11 13:19 UTC (permalink / raw)
  To: linux-kernel

Update cpucp_if.h to latest version.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
 .../misc/habanalabs/include/common/cpucp_if.h | 32 ++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/habanalabs/include/common/cpucp_if.h b/drivers/misc/habanalabs/include/common/cpucp_if.h
index 4af5bb695c16..38e44b6cf581 100644
--- a/drivers/misc/habanalabs/include/common/cpucp_if.h
+++ b/drivers/misc/habanalabs/include/common/cpucp_if.h
@@ -568,6 +568,12 @@ struct cpucp_array_data_packet {
 	__le32 data[];
 };
 
+enum cpucp_led_index {
+	CPUCP_LED0_INDEX = 0,
+	CPUCP_LED1_INDEX,
+	CPUCP_LED2_INDEX
+};
+
 enum cpucp_packet_rc {
 	cpucp_packet_success,
 	cpucp_packet_invalid,
@@ -589,7 +595,10 @@ enum cpucp_temp_type {
 	cpucp_temp_offset = 19,
 	cpucp_temp_lowest = 21,
 	cpucp_temp_highest = 22,
-	cpucp_temp_reset_history = 23
+	cpucp_temp_reset_history = 23,
+	cpucp_temp_warn = 24,
+	cpucp_temp_max_crit = 25,
+	cpucp_temp_max_warn = 26,
 };
 
 enum cpucp_in_attributes {
@@ -699,6 +708,7 @@ enum pll_index {
 enum rl_index {
 	TPC_RL = 0,
 	MME_RL,
+	EDMA_RL,
 };
 
 enum pvt_index {
@@ -833,6 +843,7 @@ enum cpucp_serdes_type {
 	TYPE_2_SERDES_TYPE,
 	HLS1_SERDES_TYPE,
 	HLS1H_SERDES_TYPE,
+	HLS2_SERDES_TYPE,
 	UNKNOWN_SERDES_TYPE,
 	MAX_NUM_SERDES_TYPE = UNKNOWN_SERDES_TYPE
 };
@@ -846,9 +857,28 @@ struct cpucp_nic_info {
 	__u8 qsfp_eeprom[CPUCP_NIC_QSFP_EEPROM_MAX_LEN];
 	__le64 auto_neg_mask[CPUCP_NIC_MASK_ARR_LEN];
 	__le16 serdes_type; /* enum cpucp_serdes_type */
+	__le16 tx_swap_map[CPUCP_MAX_NICS];
 	__u8 reserved[6];
 };
 
+#define PAGE_DISCARD_MAX	64
+
+struct page_discard_info {
+	__u8 num_entries;
+	__u8 reserved[7];
+	__le32 mmu_page_idx[PAGE_DISCARD_MAX];
+};
+
+/*
+ * struct ser_val - the SER (symbol error rate) value is represented by "integer * 10 ^ -exp".
+ * @integer: the integer part of the SER value;
+ * @exp: the exponent part of the SER value.
+ */
+struct ser_val {
+	__le16 integer;
+	__le16 exp;
+};
+
 /*
  * struct cpucp_nic_status - describes the status of a NIC port.
  * @port: NIC port index.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] habanalabs: use NULL for eventfd
  2022-05-11 13:19 [PATCH 1/3] habanalabs: update firmware header Oded Gabbay
@ 2022-05-11 13:19 ` Oded Gabbay
  2022-05-11 13:19 ` [PATCH 3/3] habanalabs: return -EFAULT on copy_to_user error Oded Gabbay
  1 sibling, 0 replies; 3+ messages in thread
From: Oded Gabbay @ 2022-05-11 13:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel test robot

eventfd is pointer. As such, it should be initialized to NULL, not to 0.

In addition, no need to initialize it after creation because the
entire structure is zeroed-out. Also, no need to initialize it before
release because the entire structure is freed.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
 drivers/misc/habanalabs/common/device.c           | 8 ++------
 drivers/misc/habanalabs/common/habanalabs_drv.c   | 4 ----
 drivers/misc/habanalabs/common/habanalabs_ioctl.c | 4 ++--
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c
index 315510aaca35..0908ac301c70 100644
--- a/drivers/misc/habanalabs/common/device.c
+++ b/drivers/misc/habanalabs/common/device.c
@@ -286,10 +286,8 @@ static void hpriv_release(struct kref *ref)
 	hdev->compute_ctx_in_release = 0;
 
 	/* release the eventfd */
-	if (hpriv->notifier_event.eventfd) {
+	if (hpriv->notifier_event.eventfd)
 		eventfd_ctx_put(hpriv->notifier_event.eventfd);
-		hpriv->notifier_event.eventfd = 0;
-	}
 
 	mutex_destroy(&hpriv->notifier_event.lock);
 
@@ -364,10 +362,8 @@ static int hl_device_release_ctrl(struct inode *inode, struct file *filp)
 	mutex_unlock(&hdev->fpriv_ctrl_list_lock);
 out:
 	/* release the eventfd */
-	if (hpriv->notifier_event.eventfd) {
+	if (hpriv->notifier_event.eventfd)
 		eventfd_ctx_put(hpriv->notifier_event.eventfd);
-		hpriv->notifier_event.eventfd = 0;
-	}
 
 	mutex_destroy(&hpriv->notifier_event.lock);
 	put_pid(hpriv->taskpid);
diff --git a/drivers/misc/habanalabs/common/habanalabs_drv.c b/drivers/misc/habanalabs/common/habanalabs_drv.c
index c97173e9507d..9ead0927208d 100644
--- a/drivers/misc/habanalabs/common/habanalabs_drv.c
+++ b/drivers/misc/habanalabs/common/habanalabs_drv.c
@@ -134,8 +134,6 @@ int hl_device_open(struct inode *inode, struct file *filp)
 	hpriv->hdev = hdev;
 	filp->private_data = hpriv;
 	hpriv->filp = filp;
-	hpriv->notifier_event.events_mask = 0;
-	hpriv->notifier_event.eventfd = 0;
 
 	mutex_init(&hpriv->notifier_event.lock);
 	mutex_init(&hpriv->restore_phase_mutex);
@@ -246,8 +244,6 @@ int hl_device_open_ctrl(struct inode *inode, struct file *filp)
 	hpriv->hdev = hdev;
 	filp->private_data = hpriv;
 	hpriv->filp = filp;
-	hpriv->notifier_event.events_mask = 0;
-	hpriv->notifier_event.eventfd = 0;
 
 	mutex_init(&hpriv->notifier_event.lock);
 	nonseekable_open(inode, filp);
diff --git a/drivers/misc/habanalabs/common/habanalabs_ioctl.c b/drivers/misc/habanalabs/common/habanalabs_ioctl.c
index d1ef56a8d3ac..51fa56287309 100644
--- a/drivers/misc/habanalabs/common/habanalabs_ioctl.c
+++ b/drivers/misc/habanalabs/common/habanalabs_ioctl.c
@@ -647,7 +647,7 @@ static int eventfd_register(struct hl_fpriv *hpriv, struct hl_info_args *args)
 	hpriv->notifier_event.eventfd = eventfd_ctx_fdget(args->eventfd);
 	if (IS_ERR(hpriv->notifier_event.eventfd)) {
 		rc = PTR_ERR(hpriv->notifier_event.eventfd);
-		hpriv->notifier_event.eventfd = 0;
+		hpriv->notifier_event.eventfd = NULL;
 		mutex_unlock(&hpriv->notifier_event.lock);
 		return rc;
 	}
@@ -665,7 +665,7 @@ static int eventfd_unregister(struct hl_fpriv *hpriv, struct hl_info_args *args)
 	}
 
 	eventfd_ctx_put(hpriv->notifier_event.eventfd);
-	hpriv->notifier_event.eventfd = 0;
+	hpriv->notifier_event.eventfd = NULL;
 	mutex_unlock(&hpriv->notifier_event.lock);
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] habanalabs: return -EFAULT on copy_to_user error
  2022-05-11 13:19 [PATCH 1/3] habanalabs: update firmware header Oded Gabbay
  2022-05-11 13:19 ` [PATCH 2/3] habanalabs: use NULL for eventfd Oded Gabbay
@ 2022-05-11 13:19 ` Oded Gabbay
  1 sibling, 0 replies; 3+ messages in thread
From: Oded Gabbay @ 2022-05-11 13:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel test robot, Dan Carpenter

If copy_to_user failed in info ioctl, we always return -EFAULT so the
user will know there was an error.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
 drivers/misc/habanalabs/common/habanalabs_ioctl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/misc/habanalabs/common/habanalabs_ioctl.c b/drivers/misc/habanalabs/common/habanalabs_ioctl.c
index 51fa56287309..8fd2b427863f 100644
--- a/drivers/misc/habanalabs/common/habanalabs_ioctl.c
+++ b/drivers/misc/habanalabs/common/habanalabs_ioctl.c
@@ -118,7 +118,6 @@ static int hw_events_info(struct hl_device *hdev, bool aggregate,
 
 static int events_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
 {
-	int rc;
 	u32 max_size = args->return_size;
 	u64 events_mask;
 	void __user *out = (void __user *) (uintptr_t) args->return_pointer;
@@ -131,8 +130,7 @@ static int events_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
 	hpriv->notifier_event.events_mask = 0;
 	mutex_unlock(&hpriv->notifier_event.lock);
 
-	rc = copy_to_user(out, &events_mask, sizeof(u64));
-	return rc;
+	return copy_to_user(out, &events_mask, sizeof(u64)) ? -EFAULT : 0;
 }
 
 static int dram_usage_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-11 13:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 13:19 [PATCH 1/3] habanalabs: update firmware header Oded Gabbay
2022-05-11 13:19 ` [PATCH 2/3] habanalabs: use NULL for eventfd Oded Gabbay
2022-05-11 13:19 ` [PATCH 3/3] habanalabs: return -EFAULT on copy_to_user error Oded Gabbay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).