Skip to contentSkip to conversation

cdx: Rename MCDI_LOGGING to CDX_MCDI_LOGGING

PATCH Superseded Abhijit Gangurde 2 participants 3 messages May 24, 2023 – Jun 5, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cdx: Rename MCDI_LOGGING to CDX_MCDI_LOGGING

MCDI_LOGGING is too generic considering other MCDI users SFC_MCDI_LOGGING and SFC_SIENA_MCDI_LOGGING. Rename it to CDX_MCDI_LOGGING makes it more domain specific.

Also, Move CONFIG_CDX_MCDI_LOGGING to header file and make logging variable as a configurable sysfs parameter.

---
Changes v1->v2:
- Moved CONFIG_CDX_MCDI_LOGGING flag to header file
- Added sysfs entry to enable/disable mcdi logging

 drivers/cdx/controller/Kconfig          |  2 +-
 drivers/cdx/controller/cdx_controller.c | 21 ++++++++++++
 drivers/cdx/controller/mcdi.c           | 45 ++++++++++++-------------
 drivers/cdx/controller/mcdi.h           |  8 +++--
 4 files changed, 49 insertions(+), 27 deletions(-)
drivers/cdx/controller/Kconfig +1 -1
index c3e3b9ff8dfe..e7014e9819ea 100644
@@ -18,7 +18,7 @@ config CDX_CONTROLLER
 
 	  If unsure, say N.
 
-config MCDI_LOGGING
+config CDX_MCDI_LOGGING
 	bool "MCDI Logging for the CDX controller"
 	depends on CDX_CONTROLLER
 	help
drivers/cdx/controller/cdx_controller.c +21 -0
index dc52f95f8978..e5b1a2c01b87 100644
@@ -124,6 +124,23 @@ static struct cdx_ops cdx_ops = {
 	.dev_configure	= cdx_configure_device,
 };
 
+static ssize_t mcdi_logging_store(struct device *dev, struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct cdx_controller *cdx = dev_get_drvdata(dev);
+	bool enable;
+
+	if (kstrtobool(buf, &enable) < 0)
+		return -EINVAL;
+
+	if (cdx_enable_mcdi_logging(cdx->priv, enable))
+		return -EINVAL;
+
+	return count;
+}
+
+static DEVICE_ATTR_WO(mcdi_logging);
+
 static int xlnx_cdx_probe(struct platform_device *pdev)
 {
 	struct cdx_controller *cdx;
@@ -154,6 +171,9 @@ static int xlnx_cdx_probe(struct platform_device *pdev)
 	cdx->priv = cdx_mcdi;
 	cdx->ops = &cdx_ops;
 
+	if (device_create_file(&pdev->dev, &dev_attr_mcdi_logging))
+		dev_warn(&pdev->dev, "Failed to create sysfs file\n");
+
 	ret = cdx_setup_rpmsg(pdev);
 	if (ret) {
 		if (ret != -EPROBE_DEFER)
@@ -181,6 +201,7 @@ static int xlnx_cdx_remove(struct platform_device *pdev)
 
 	cdx_destroy_rpmsg(pdev);
 
+	device_remove_file(&pdev->dev, &dev_attr_mcdi_logging);
 	kfree(cdx);
 
 	cdx_mcdi_finish(cdx_mcdi);
drivers/cdx/controller/mcdi.c +21 -24

126 lines not on this page · raw message

drivers/cdx/controller/mcdi.h +6 -2
index 0bfbeab04e43..3a22c71e2f31 100644
@@ -22,6 +22,11 @@
 #define CDX_WARN_ON_PARANOID(x) do {} while (0)
 #endif
 
+#ifdef CONFIG_CDX_MCDI_LOGGING
+#define CDX_MCDI_LOGGING	1
+#else
+#define CDX_MCDI_LOGGING	0
+#endif
 /**
  * enum cdx_mcdi_mode - MCDI transaction mode
  * @MCDI_MODE_EVENTS: wait for an mcdi response callback.
@@ -170,10 +175,8 @@ struct cdx_mcdi_iface {
 	enum cdx_mcdi_mode mode;
 	u8 prev_seq;
 	bool new_epoch;
-#ifdef CONFIG_MCDI_LOGGING
 	bool logging_enabled;
 	char *logging_buffer;
-#endif
 };
 
 /**
@@ -193,6 +196,7 @@ static inline struct cdx_mcdi_iface *cdx_mcdi_if(struct cdx_mcdi *cdx)
 
 int cdx_mcdi_init(struct cdx_mcdi *cdx);
 void cdx_mcdi_finish(struct cdx_mcdi *cdx);
+int cdx_enable_mcdi_logging(struct cdx_mcdi *cdx, bool enable);
 
 void cdx_mcdi_process_cmd(struct cdx_mcdi *cdx, struct cdx_dword *outbuf, int len);
 int cdx_mcdi_rpc(struct cdx_mcdi *cdx, unsigned int cmd,
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Abhijit Gangurde

MCDI_LOGGING is too generic considering other MCDI users SFC_MCDI_LOGGING and SFC_SIENA_MCDI_LOGGING. Rename it to CDX_MCDI_LOGGING makes it more domain specific.

Also, Move CONFIG_CDX_MCDI_LOGGING to header file and make logging variable as a configurable sysfs parameter.

No, sorry, that is not allowed. Just use the normal dynamic debugging in the kernel like everyone else uses.

Also you didn't document your new sysfs file, which would have not allowed me to take this no matter what.

Quoted 56 lines

---
Changes v1->v2:
- Moved CONFIG_CDX_MCDI_LOGGING flag to header file
- Added sysfs entry to enable/disable mcdi logging

 drivers/cdx/controller/Kconfig          |  2 +-
 drivers/cdx/controller/cdx_controller.c | 21 ++++++++++++
 drivers/cdx/controller/mcdi.c           | 45 ++++++++++++-------------
 drivers/cdx/controller/mcdi.h           |  8 +++--
 4 files changed, 49 insertions(+), 27 deletions(-)
drivers/cdx/controller/Kconfig +1 -1
index c3e3b9ff8dfe..e7014e9819ea 100644
@@ -18,7 +18,7 @@ config CDX_CONTROLLER
 
 	  If unsure, say N.
 
-config MCDI_LOGGING
+config CDX_MCDI_LOGGING
 	bool "MCDI Logging for the CDX controller"
 	depends on CDX_CONTROLLER
 	help
drivers/cdx/controller/cdx_controller.c +17 -0
index dc52f95f8978..e5b1a2c01b87 100644
@@ -124,6 +124,23 @@ static struct cdx_ops cdx_ops = {
 	.dev_configure	= cdx_configure_device,
 };
 
+static ssize_t mcdi_logging_store(struct device *dev, struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct cdx_controller *cdx = dev_get_drvdata(dev);
+	bool enable;
+
+	if (kstrtobool(buf, &enable) < 0)
+		return -EINVAL;
+
+	if (cdx_enable_mcdi_logging(cdx->priv, enable))
+		return -EINVAL;
+
+	return count;
+}
+
+static DEVICE_ATTR_WO(mcdi_logging);
+
 static int xlnx_cdx_probe(struct platform_device *pdev)
 {
 	struct cdx_controller *cdx;

drivers/cdx/controller/cdx_controller.c static int xlnx_cdx_probe(struct platform_device *pdev) · line 175

Quoted 5 lines
drivers/cdx/controller/cdx_controller.c +2 -0
@@ -154,6 +171,9 @@ static int xlnx_cdx_probe(struct platform_device *pdev)
 	cdx->priv = cdx_mcdi;
 	cdx->ops = &cdx_ops;
 
+	if (device_create_file(&pdev->dev, &dev_attr_mcdi_logging))
+		dev_warn(&pdev->dev, "Failed to create sysfs file\n");

You just raced with userspace and lost. Even if this feature was ok, this is not how to create sysfs files, sorry.

greg k-h

#2 lore raw

[AMD Official Use Only - General]

Quoted 7 lines · Abhijit Gangurde
Quoted 4 lines

MCDI_LOGGING is too generic considering other MCDI users SFC_MCDI_LOGGING and SFC_SIENA_MCDI_LOGGING. Rename it to CDX_MCDI_LOGGING makes it more domain specific.

Quoted 8 lines
Quoted 2 lines

Also, Move CONFIG_CDX_MCDI_LOGGING to header file and make logging variable as a configurable sysfs parameter.

No, sorry, that is not allowed. Just use the normal dynamic debugging in the kernel like everyone else uses.

Also you didn't document your new sysfs file, which would have not allowed me to take this no matter what.

I'll drop the sysfs changes and send v3 patch for renaming of the macro so it can be on the rc.
Also, will look onto it to be supported by dynamic debugging.

Thanks,
Abhijit