All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Expose IAA 2.0 device capabilities
@ 2023-01-03 16:53 Fenghua Yu
  2023-01-03 16:53 ` [PATCH 1/2] dmaengine: idxd: reformat swerror output to standard Linux bitmap output Fenghua Yu
  2023-01-03 16:53 ` [PATCH 2/2] dmaengine: idxd: expose IAA CAP register via sysfs knob Fenghua Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Fenghua Yu @ 2023-01-03 16:53 UTC (permalink / raw)
  To: Vinod Koul, Dave Jiang; +Cc: Fenghua Yu, dmaengine, linux-kernel

In-memory Analytics Accelerator (IAA) 2.0 [1] introduces General
Capabilities Register (GENCAP). Add a sysfs attribute to expose the
register to applications.

This series is applied cleanly on top of DSA 2.0 Event Log and Completion
Record Faulting series: 
https://lore.kernel.org/dmaengine/20230103163505.1569356-1-fenghua.yu@intel.com/T/#m13ba6167994f3add6446d2d7e242ecb637c54426

[1] IAA 2.0 spec: https://cdrdv2-public.intel.com/721858/350295-iaa-specification.pdf

Dave Jiang (2):
  dmaengine: idxd: reformat swerror output to standard Linux bitmap
    output
  dmaengine: idxd: expose IAA CAP register via sysfs knob

 .../ABI/stable/sysfs-driver-dma-idxd          |  8 +++++
 drivers/dma/idxd/idxd.h                       |  2 ++
 drivers/dma/idxd/init.c                       |  6 +++-
 drivers/dma/idxd/registers.h                  | 21 ++++++++++++
 drivers/dma/idxd/sysfs.c                      | 34 +++++++++++++++----
 5 files changed, 64 insertions(+), 7 deletions(-)

-- 
2.32.0


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

* [PATCH 1/2] dmaengine: idxd: reformat swerror output to standard Linux bitmap output
  2023-01-03 16:53 [PATCH 0/2] Expose IAA 2.0 device capabilities Fenghua Yu
@ 2023-01-03 16:53 ` Fenghua Yu
  2023-01-18 12:02   ` Vinod Koul
  2023-01-03 16:53 ` [PATCH 2/2] dmaengine: idxd: expose IAA CAP register via sysfs knob Fenghua Yu
  1 sibling, 1 reply; 4+ messages in thread
From: Fenghua Yu @ 2023-01-03 16:53 UTC (permalink / raw)
  To: Vinod Koul, Dave Jiang; +Cc: Fenghua Yu, dmaengine, linux-kernel

From: Dave Jiang <dave.jiang@intel.com>

SWERROR register is 4 64bit wide registers. Currently the sysfs attribute
just outputs 4 64bit hex integers. Covert to output with %*pb format
specifier.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
---
 drivers/dma/idxd/idxd.h  |  1 +
 drivers/dma/idxd/init.c  |  2 +-
 drivers/dma/idxd/sysfs.c | 10 ++++------
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
index f92f8ec83722..e449d905bea3 100644
--- a/drivers/dma/idxd/idxd.h
+++ b/drivers/dma/idxd/idxd.h
@@ -654,6 +654,7 @@ int idxd_register_driver(void);
 void idxd_unregister_driver(void);
 void idxd_wqs_quiesce(struct idxd_device *idxd);
 bool idxd_queue_int_handle_resubmit(struct idxd_desc *desc);
+void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count);
 
 /* device interrupt control */
 irqreturn_t idxd_misc_thread(int vec, void *data);
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 564c025b9b7e..996bd3e4e50f 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -425,7 +425,7 @@ static void idxd_read_table_offsets(struct idxd_device *idxd)
 	dev_dbg(dev, "IDXD Perfmon Offset: %#x\n", idxd->perfmon_offset);
 }
 
-static void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count)
+void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count)
 {
 	int i, j, nr;
 
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index c772172d4ceb..dae28509e6ed 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1506,15 +1506,13 @@ static ssize_t errors_show(struct device *dev,
 			   struct device_attribute *attr, char *buf)
 {
 	struct idxd_device *idxd = confdev_to_idxd(dev);
-	int i, out = 0;
+	DECLARE_BITMAP(swerr_bmap, 256);
 
+	bitmap_zero(swerr_bmap, 256);
 	spin_lock(&idxd->dev_lock);
-	for (i = 0; i < 4; i++)
-		out += sysfs_emit_at(buf, out, "%#018llx ", idxd->sw_err.bits[i]);
+	multi_u64_to_bmap(swerr_bmap, &idxd->sw_err.bits[0], 4);
 	spin_unlock(&idxd->dev_lock);
-	out--;
-	out += sysfs_emit_at(buf, out, "\n");
-	return out;
+	return sysfs_emit(buf, "%*pb\n", 256, swerr_bmap);
 }
 static DEVICE_ATTR_RO(errors);
 
-- 
2.32.0


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

* [PATCH 2/2] dmaengine: idxd: expose IAA CAP register via sysfs knob
  2023-01-03 16:53 [PATCH 0/2] Expose IAA 2.0 device capabilities Fenghua Yu
  2023-01-03 16:53 ` [PATCH 1/2] dmaengine: idxd: reformat swerror output to standard Linux bitmap output Fenghua Yu
@ 2023-01-03 16:53 ` Fenghua Yu
  1 sibling, 0 replies; 4+ messages in thread
From: Fenghua Yu @ 2023-01-03 16:53 UTC (permalink / raw)
  To: Vinod Koul, Dave Jiang; +Cc: Fenghua Yu, dmaengine, linux-kernel

From: Dave Jiang <dave.jiang@intel.com>

Add IAA (IAX) capability mask sysfs attribute to expose to applications.
The mask provides application knowledge of what capabilities this IAA
device supports. This mask is available for IAA 2.0 device or later.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
---
This patch is applied cleanly on top of DSA 2.0 Event Log and Completion
Record Faulting series: 
https://lore.kernel.org/dmaengine/20230103163505.1569356-1-fenghua.yu@intel.com/T/#m13ba6167994f3add6446d2d7e242ecb637c54426

 .../ABI/stable/sysfs-driver-dma-idxd          |  8 +++++++
 drivers/dma/idxd/idxd.h                       |  1 +
 drivers/dma/idxd/init.c                       |  4 ++++
 drivers/dma/idxd/registers.h                  | 21 ++++++++++++++++
 drivers/dma/idxd/sysfs.c                      | 24 +++++++++++++++++++
 5 files changed, 58 insertions(+)

diff --git a/Documentation/ABI/stable/sysfs-driver-dma-idxd b/Documentation/ABI/stable/sysfs-driver-dma-idxd
index 603869112887..796a5dccdf04 100644
--- a/Documentation/ABI/stable/sysfs-driver-dma-idxd
+++ b/Documentation/ABI/stable/sysfs-driver-dma-idxd
@@ -144,6 +144,14 @@ Description:	The event log size to be configured. Default is 64 entries and
 		occupies 4k size if the evl entry is 64 bytes. It's visible
 		only on platforms that support the capability.
 
+What:		/sys/bus/dsa/devices/dsa<m>/iaa_cap
+Date:		Sept 14, 2022
+KernelVersion: 6.0.0
+Contact:	dmaengine@vger.kernel.org
+Description:	IAA (IAX) capability mask. Exported to user space for application
+		consumption. This attribute should only be visible on IAA devices
+		that are version 2 or later.
+
 What:		/sys/bus/dsa/devices/wq<m>.<n>/block_on_fault
 Date:		Oct 27, 2020
 KernelVersion:	5.11.0
diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
index e449d905bea3..3a20e4933d07 100644
--- a/drivers/dma/idxd/idxd.h
+++ b/drivers/dma/idxd/idxd.h
@@ -245,6 +245,7 @@ struct idxd_hw {
 	union engine_cap_reg engine_cap;
 	struct opcap opcap;
 	u32 cmd_cap;
+	union iaa_cap_reg iaa_cap;
 };
 
 enum idxd_device_state {
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 996bd3e4e50f..6c1d1682fce9 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -497,6 +497,10 @@ static void idxd_read_caps(struct idxd_device *idxd)
 		dev_dbg(dev, "opcap[%d]: %#llx\n", i, idxd->hw.opcap.bits[i]);
 	}
 	multi_u64_to_bmap(idxd->opcap_bmap, &idxd->hw.opcap.bits[0], 4);
+
+	/* read iaa cap */
+	if (idxd->data->type == IDXD_TYPE_IAX && idxd->hw.version >= DEVICE_VERSION_2)
+		idxd->hw.iaa_cap.bits = ioread64(idxd->reg_base + IDXD_IAACAP_OFFSET);
 }
 
 static struct idxd_device *idxd_alloc(struct pci_dev *pdev, struct idxd_driver_data *data)
diff --git a/drivers/dma/idxd/registers.h b/drivers/dma/idxd/registers.h
index 6155dc7d2152..6de810d2d2d8 100644
--- a/drivers/dma/idxd/registers.h
+++ b/drivers/dma/idxd/registers.h
@@ -302,6 +302,27 @@ union evlcfg_reg {
 #define IDXD_EVL_SIZE_MIN	0x0040
 #define IDXD_EVL_SIZE_MAX	0xffff
 
+union iaa_cap_reg {
+	struct {
+		u64 dec_aecs_format_ver:1;
+		u64 drop_init_bits:1;
+		u64 chaining:1;
+		u64 force_array_output_mod:1;
+		u64 load_part_aecs:1;
+		u64 comp_early_abort:1;
+		u64 nested_comp:1;
+		u64 diction_comp:1;
+		u64 header_gen:1;
+		u64 crypto_gcm:1;
+		u64 crypto_cfb:1;
+		u64 crypto_xts:1;
+		u64 rsvd:52;
+	};
+	u64 bits;
+} __packed;
+
+#define IDXD_IAACAP_OFFSET	0x180
+
 union msix_perm {
 	struct {
 		u32 rsvd:2;
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index dae28509e6ed..80a81d441252 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1656,6 +1656,18 @@ static ssize_t event_log_size_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(event_log_size);
 
+static ssize_t iaa_cap_show(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	struct idxd_device *idxd = confdev_to_idxd(dev);
+
+	if (idxd->hw.version < DEVICE_VERSION_2)
+		return -EOPNOTSUPP;
+
+	return sysfs_emit(buf, "%#llx\n", idxd->hw.iaa_cap.bits);
+}
+static DEVICE_ATTR_RO(iaa_cap);
+
 static bool idxd_device_attr_max_batch_size_invisible(struct attribute *attr,
 						      struct idxd_device *idxd)
 {
@@ -1685,6 +1697,14 @@ static bool idxd_device_attr_event_log_size_invisible(struct attribute *attr,
 		!idxd->hw.gen_cap.evl_support);
 }
 
+static bool idxd_device_attr_iaa_cap_invisible(struct attribute *attr,
+					       struct idxd_device *idxd)
+{
+	return attr == &dev_attr_iaa_cap.attr &&
+	       (idxd->data->type != IDXD_TYPE_IAX ||
+	       idxd->hw.version < DEVICE_VERSION_2);
+}
+
 static umode_t idxd_device_attr_visible(struct kobject *kobj,
 					struct attribute *attr, int n)
 {
@@ -1700,6 +1720,9 @@ static umode_t idxd_device_attr_visible(struct kobject *kobj,
 	if (idxd_device_attr_event_log_size_invisible(attr, idxd))
 		return 0;
 
+	if (idxd_device_attr_iaa_cap_invisible(attr, idxd))
+		return 0;
+
 	return attr->mode;
 }
 
@@ -1726,6 +1749,7 @@ static struct attribute *idxd_device_attributes[] = {
 	&dev_attr_cdev_major.attr,
 	&dev_attr_cmd_status.attr,
 	&dev_attr_event_log_size.attr,
+	&dev_attr_iaa_cap.attr,
 	NULL,
 };
 
-- 
2.32.0


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

* Re: [PATCH 1/2] dmaengine: idxd: reformat swerror output to standard Linux bitmap output
  2023-01-03 16:53 ` [PATCH 1/2] dmaengine: idxd: reformat swerror output to standard Linux bitmap output Fenghua Yu
@ 2023-01-18 12:02   ` Vinod Koul
  0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2023-01-18 12:02 UTC (permalink / raw)
  To: Fenghua Yu; +Cc: Dave Jiang, dmaengine, linux-kernel

On 03-01-23, 08:53, Fenghua Yu wrote:
> From: Dave Jiang <dave.jiang@intel.com>
> 
> SWERROR register is 4 64bit wide registers. Currently the sysfs attribute
> just outputs 4 64bit hex integers. Covert to output with %*pb format

s/Covert/Convert

> specifier.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
> ---
>  drivers/dma/idxd/idxd.h  |  1 +
>  drivers/dma/idxd/init.c  |  2 +-
>  drivers/dma/idxd/sysfs.c | 10 ++++------
>  3 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
> index f92f8ec83722..e449d905bea3 100644
> --- a/drivers/dma/idxd/idxd.h
> +++ b/drivers/dma/idxd/idxd.h
> @@ -654,6 +654,7 @@ int idxd_register_driver(void);
>  void idxd_unregister_driver(void);
>  void idxd_wqs_quiesce(struct idxd_device *idxd);
>  bool idxd_queue_int_handle_resubmit(struct idxd_desc *desc);
> +void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count);

This change does not belong to this patch, I dont know why this is here

>  
>  /* device interrupt control */
>  irqreturn_t idxd_misc_thread(int vec, void *data);
> diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
> index 564c025b9b7e..996bd3e4e50f 100644
> --- a/drivers/dma/idxd/init.c
> +++ b/drivers/dma/idxd/init.c
> @@ -425,7 +425,7 @@ static void idxd_read_table_offsets(struct idxd_device *idxd)
>  	dev_dbg(dev, "IDXD Perfmon Offset: %#x\n", idxd->perfmon_offset);
>  }
>  
> -static void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count)
> +void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count)
>  {
>  	int i, j, nr;
>  
> diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
> index c772172d4ceb..dae28509e6ed 100644
> --- a/drivers/dma/idxd/sysfs.c
> +++ b/drivers/dma/idxd/sysfs.c
> @@ -1506,15 +1506,13 @@ static ssize_t errors_show(struct device *dev,
>  			   struct device_attribute *attr, char *buf)
>  {
>  	struct idxd_device *idxd = confdev_to_idxd(dev);
> -	int i, out = 0;
> +	DECLARE_BITMAP(swerr_bmap, 256);
>  
> +	bitmap_zero(swerr_bmap, 256);
>  	spin_lock(&idxd->dev_lock);
> -	for (i = 0; i < 4; i++)
> -		out += sysfs_emit_at(buf, out, "%#018llx ", idxd->sw_err.bits[i]);
> +	multi_u64_to_bmap(swerr_bmap, &idxd->sw_err.bits[0], 4);
>  	spin_unlock(&idxd->dev_lock);
> -	out--;
> -	out += sysfs_emit_at(buf, out, "\n");
> -	return out;
> +	return sysfs_emit(buf, "%*pb\n", 256, swerr_bmap);
>  }
>  static DEVICE_ATTR_RO(errors);
>  
> -- 
> 2.32.0

-- 
~Vinod

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

end of thread, other threads:[~2023-01-18 12:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 16:53 [PATCH 0/2] Expose IAA 2.0 device capabilities Fenghua Yu
2023-01-03 16:53 ` [PATCH 1/2] dmaengine: idxd: reformat swerror output to standard Linux bitmap output Fenghua Yu
2023-01-18 12:02   ` Vinod Koul
2023-01-03 16:53 ` [PATCH 2/2] dmaengine: idxd: expose IAA CAP register via sysfs knob Fenghua Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.