From: Fenghua Yu <fenghua.yu@intel.com>
To: "Vinod Koul" <vkoul@kernel.org>, "Dave Jiang" <dave.jiang@intel.com>
Cc: dmaengine@vger.kernel.org,
"linux-kernel" <linux-kernel@vger.kernel.org>,
Tony Zhu <tony.zhu@intel.com>, Fenghua Yu <fenghua.yu@intel.com>
Subject: [PATCH v2 02/16] dmaengine: idxd: add event log size sysfs attribute
Date: Mon, 6 Mar 2023 08:31:24 -0800 [thread overview]
Message-ID: <20230306163138.587484-3-fenghua.yu@intel.com> (raw)
In-Reply-To: <20230306163138.587484-1-fenghua.yu@intel.com>
From: Dave Jiang <dave.jiang@intel.com>
Add support for changing of the event log size. Event log is a
feature added to DSA 2.0 hardware to improve error reporting.
It supersedes the SWERROR register on DSA 1.0 hardware and hope
to prevent loss of reported errors.
The error log size determines how many error entries supported for
the device. It can be configured by the user via sysfs attribute.
Tested-by: Tony Zhu <tony.zhu@intel.com>
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>
---
.../ABI/stable/sysfs-driver-dma-idxd | 8 +++
drivers/dma/idxd/idxd.h | 5 ++
drivers/dma/idxd/init.c | 23 ++++++++
drivers/dma/idxd/registers.h | 7 ++-
drivers/dma/idxd/sysfs.c | 52 +++++++++++++++++++
5 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/stable/sysfs-driver-dma-idxd b/Documentation/ABI/stable/sysfs-driver-dma-idxd
index d5e3dd3d8434..e01916611452 100644
--- a/Documentation/ABI/stable/sysfs-driver-dma-idxd
+++ b/Documentation/ABI/stable/sysfs-driver-dma-idxd
@@ -144,6 +144,14 @@ 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/dsa<m>/event_log_size
+Date: Sept 14, 2022
+KernelVersion: 6.4.0
+Contact: dmaengine@vger.kernel.org
+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/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 eca2c9d76db6..2a71273f1822 100644
--- a/drivers/dma/idxd/idxd.h
+++ b/drivers/dma/idxd/idxd.h
@@ -261,6 +261,10 @@ struct idxd_driver_data {
int align;
};
+struct idxd_evl {
+ u16 size;
+};
+
struct idxd_device {
struct idxd_dev idxd_dev;
struct idxd_driver_data *data;
@@ -317,6 +321,7 @@ struct idxd_device {
struct idxd_pmu *idxd_pmu;
unsigned long *opcap_bmap;
+ struct idxd_evl *evl;
};
/* IDXD software descriptor */
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index a408fc91144d..d1fb01c115d8 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -332,6 +332,23 @@ static void idxd_cleanup_internals(struct idxd_device *idxd)
destroy_workqueue(idxd->wq);
}
+static int idxd_init_evl(struct idxd_device *idxd)
+{
+ struct device *dev = &idxd->pdev->dev;
+ struct idxd_evl *evl;
+
+ if (idxd->hw.gen_cap.evl_support == 0)
+ return 0;
+
+ evl = kzalloc_node(sizeof(*evl), GFP_KERNEL, dev_to_node(dev));
+ if (!evl)
+ return -ENOMEM;
+
+ evl->size = IDXD_EVL_SIZE_MIN;
+ idxd->evl = evl;
+ return 0;
+}
+
static int idxd_setup_internals(struct idxd_device *idxd)
{
struct device *dev = &idxd->pdev->dev;
@@ -357,8 +374,14 @@ static int idxd_setup_internals(struct idxd_device *idxd)
goto err_wkq_create;
}
+ rc = idxd_init_evl(idxd);
+ if (rc < 0)
+ goto err_evl;
+
return 0;
+ err_evl:
+ destroy_workqueue(idxd->wq);
err_wkq_create:
for (i = 0; i < idxd->max_groups; i++)
put_device(group_confdev(idxd->groups[i]));
diff --git a/drivers/dma/idxd/registers.h b/drivers/dma/idxd/registers.h
index 338289a66f00..ea3a499a3c3c 100644
--- a/drivers/dma/idxd/registers.h
+++ b/drivers/dma/idxd/registers.h
@@ -31,7 +31,9 @@ union gen_cap_reg {
u64 rsvd:3;
u64 dest_readback:1;
u64 drain_readback:1;
- u64 rsvd2:6;
+ u64 rsvd2:3;
+ u64 evl_support:2;
+ u64 rsvd4:1;
u64 max_xfer_shift:5;
u64 max_batch_shift:4;
u64 max_ims_mult:6;
@@ -297,6 +299,9 @@ union iaa_cap_reg {
#define IDXD_IAACAP_OFFSET 0x180
+#define IDXD_EVL_SIZE_MIN 0x0040
+#define IDXD_EVL_SIZE_MAX 0xffff
+
union msix_perm {
struct {
u32 rsvd:2;
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 2eba8cab25a1..85644e5bde83 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1573,6 +1573,46 @@ static ssize_t iaa_cap_show(struct device *dev,
}
static DEVICE_ATTR_RO(iaa_cap);
+static ssize_t event_log_size_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct idxd_device *idxd = confdev_to_idxd(dev);
+
+ if (!idxd->evl)
+ return -EOPNOTSUPP;
+
+ return sysfs_emit(buf, "%u\n", idxd->evl->size);
+}
+
+static ssize_t event_log_size_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct idxd_device *idxd = confdev_to_idxd(dev);
+ unsigned long val;
+ int rc;
+
+ if (!idxd->evl)
+ return -EOPNOTSUPP;
+
+ rc = kstrtoul(buf, 10, &val);
+ if (rc < 0)
+ return -EINVAL;
+
+ if (idxd->state == IDXD_DEV_ENABLED)
+ return -EPERM;
+
+ if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
+ return -EPERM;
+
+ if (val < IDXD_EVL_SIZE_MIN || val > IDXD_EVL_SIZE_MAX)
+ return -EINVAL;
+
+ idxd->evl->size = val;
+ return count;
+}
+static DEVICE_ATTR_RW(event_log_size);
+
static bool idxd_device_attr_max_batch_size_invisible(struct attribute *attr,
struct idxd_device *idxd)
{
@@ -1603,6 +1643,13 @@ static bool idxd_device_attr_iaa_cap_invisible(struct attribute *attr,
idxd->hw.version < DEVICE_VERSION_2);
}
+static bool idxd_device_attr_event_log_size_invisible(struct attribute *attr,
+ struct idxd_device *idxd)
+{
+ return (attr == &dev_attr_event_log_size.attr &&
+ !idxd->hw.gen_cap.evl_support);
+}
+
static umode_t idxd_device_attr_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
@@ -1618,6 +1665,9 @@ static umode_t idxd_device_attr_visible(struct kobject *kobj,
if (idxd_device_attr_iaa_cap_invisible(attr, idxd))
return 0;
+ if (idxd_device_attr_event_log_size_invisible(attr, idxd))
+ return 0;
+
return attr->mode;
}
@@ -1644,6 +1694,7 @@ static struct attribute *idxd_device_attributes[] = {
&dev_attr_cdev_major.attr,
&dev_attr_cmd_status.attr,
&dev_attr_iaa_cap.attr,
+ &dev_attr_event_log_size.attr,
NULL,
};
@@ -1665,6 +1716,7 @@ static void idxd_conf_device_release(struct device *dev)
bitmap_free(idxd->wq_enable_map);
kfree(idxd->wqs);
kfree(idxd->engines);
+ kfree(idxd->evl);
ida_free(&idxd_ida, idxd->id);
bitmap_free(idxd->opcap_bmap);
kfree(idxd);
--
2.37.1
next prev parent reply other threads:[~2023-03-06 16:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 16:31 [PATCH v2 00/16] Enable DSA 2.0 Event Log and completion record faulting features Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 01/16] dmaengine: idxd: make misc interrupt one shot Fenghua Yu
2023-03-06 16:31 ` Fenghua Yu [this message]
2023-03-06 16:31 ` [PATCH v2 03/16] dmaengine: idxd: setup event log configuration Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 04/16] dmaengine: idxd: add interrupt handling for event log Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 05/16] dmanegine: idxd: add debugfs for event log dump Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 06/16] dmaengine: idxd: add per DSA wq workqueue for processing cr faults Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 07/16] dmaengine: idxd: create kmem cache for event log fault items Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 08/16] iommu: define and export iommu_access_remote_vm() Fenghua Yu
2023-03-07 1:41 ` Baolu Lu
2023-03-07 17:55 ` Fenghua Yu
2023-03-08 2:23 ` Baolu Lu
2023-03-20 13:35 ` Christoph Hellwig
2023-03-31 0:44 ` Fenghua Yu
2023-03-07 8:40 ` Jean-Philippe Brucker
2023-03-07 16:33 ` Fenghua Yu
2023-03-11 17:31 ` Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 09/16] dmaengine: idxd: process user page faults for completion record Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 10/16] dmaengine: idxd: add descs_completed field " Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 11/16] dmaengine: idxd: process batch descriptor completion record faults Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 12/16] dmaengine: idxd: add per file user counters for " Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 13/16] dmaengine: idxd: add a device to represent the file opened Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 14/16] dmaengine: idxd: expose fault counters to sysfs Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 15/16] dmaengine: idxd: add pid to exported sysfs attribute for opened file Fenghua Yu
2023-03-06 16:31 ` [PATCH v2 16/16] dmaengine: idxd: add per wq PRS disable Fenghua Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230306163138.587484-3-fenghua.yu@intel.com \
--to=fenghua.yu@intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.zhu@intel.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox