LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 3/3] drivers/char/tpm: Add securityfs support for event log
From: Ashley Lai @ 2012-08-14 23:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: rcj, adlai, linux-security-module, tpmdd-devel, adlai, key,
	linuxppc-dev
In-Reply-To: <1344986638.4430.22.camel@footlong>

This patch retrieves the event log data from the device tree
during file open. The event log data will then displayed through
securityfs.

Signed-off-by: Ashley Lai <adlai@us.ibm.com>
---
 drivers/char/tpm/Makefile       |    5 +++
 drivers/char/tpm/tpm.h          |   12 ------
 drivers/char/tpm/tpm_eventlog.h |   15 ++++++++
 drivers/char/tpm/tpm_of.c       |   73 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 93 insertions(+), 12 deletions(-)
 create mode 100644 drivers/char/tpm/tpm_of.c

diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index 547509d..9080cc4 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -5,6 +5,11 @@ obj-$(CONFIG_TCG_TPM) += tpm.o
 ifdef CONFIG_ACPI
 	obj-$(CONFIG_TCG_TPM) += tpm_bios.o
 	tpm_bios-objs += tpm_eventlog.o tpm_acpi.o
+else
+ifdef CONFIG_TCG_IBMVTPM
+	obj-$(CONFIG_TCG_TPM) += tpm_bios.o
+	tpm_bios-objs += tpm_eventlog.o tpm_of.o
+endif
 endif
 obj-$(CONFIG_TCG_TIS) += tpm_tis.o
 obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 870fde7..f1af738 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -327,15 +327,3 @@ extern int tpm_pm_suspend(struct device *);
 extern int tpm_pm_resume(struct device *);
 extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long,
 			     wait_queue_head_t *);
-#ifdef CONFIG_ACPI
-extern struct dentry ** tpm_bios_log_setup(char *);
-extern void tpm_bios_log_teardown(struct dentry **);
-#else
-static inline struct dentry ** tpm_bios_log_setup(char *name)
-{
-	return NULL;
-}
-static inline void tpm_bios_log_teardown(struct dentry **dir)
-{
-}
-#endif
diff --git a/drivers/char/tpm/tpm_eventlog.h b/drivers/char/tpm/tpm_eventlog.h
index 8e23ccd..e7da086 100644
--- a/drivers/char/tpm/tpm_eventlog.h
+++ b/drivers/char/tpm/tpm_eventlog.h
@@ -68,4 +68,19 @@ enum tcpa_pc_event_ids {
 };
 
 int read_log(struct tpm_bios_log *log);
+
+#if defined(CONFIG_TCG_IBMVTPM) || defined(CONFIG_TCG_IBMVTPM_MODULE) || \
+	defined(CONFIG_ACPI)
+extern struct dentry **tpm_bios_log_setup(char *);
+extern void tpm_bios_log_teardown(struct dentry **);
+#else
+static inline struct dentry **tpm_bios_log_setup(char *name)
+{
+	return NULL;
+}
+static inline void tpm_bios_log_teardown(struct dentry **dir)
+{
+}
+#endif
+
 #endif
diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c
new file mode 100644
index 0000000..98ba2bd
--- /dev/null
+++ b/drivers/char/tpm/tpm_of.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2012 IBM Corporation
+ *
+ * Author: Ashley Lai <adlai@us.ibm.com>
+ *
+ * Maintained by: <tpmdd-devel@lists.sourceforge.net>
+ *
+ * Read the event log created by the firmware on PPC64
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ */
+
+#include <linux/slab.h>
+#include <linux/of.h>
+
+#include "tpm.h"
+#include "tpm_eventlog.h"
+
+int read_log(struct tpm_bios_log *log)
+{
+	struct device_node *np;
+	const u32 *sizep;
+	const __be64 *basep;
+
+	if (log->bios_event_log != NULL) {
+		pr_err("%s: ERROR - Eventlog already initialized\n", __func__);
+		return -EFAULT;
+	}
+
+	np = of_find_node_by_name(NULL, "ibm,vtpm");
+	if (!np) {
+		pr_err("%s: ERROR - IBMVTPM not supported\n", __func__);
+		return -ENODEV;
+	}
+
+	sizep = of_get_property(np, "linux,sml-size", NULL);
+	if (sizep == NULL) {
+		pr_err("%s: ERROR - SML size not found\n", __func__);
+		goto cleanup_eio;
+	}
+	if (*sizep == 0) {
+		pr_err("%s: ERROR - event log area empty\n", __func__);
+		goto cleanup_eio;
+	}
+
+	basep = of_get_property(np, "linux,sml-base", NULL);
+	if (basep == NULL) {
+		pr_err(KERN_ERR "%s: ERROR - SML not found\n", __func__);
+		goto cleanup_eio;
+	}
+
+	of_node_put(np);
+	log->bios_event_log = kmalloc(*sizep, GFP_KERNEL);
+	if (!log->bios_event_log) {
+		pr_err("%s: ERROR - Not enough memory for BIOS measurements\n",
+		       __func__);
+		return -ENOMEM;
+	}
+
+	log->bios_event_log_end = log->bios_event_log + *sizep;
+
+	memcpy(log->bios_event_log, __va(be64_to_cpup(basep)), *sizep);
+
+	return 0;
+
+cleanup_eio:
+	of_node_put(np);
+	return -EIO;
+}
-- 
1.7.1

^ permalink raw reply related

* [PATCH V3 1/3] drivers/char/tpm: Add new device driver to support IBM vTPM
From: Ashley Lai @ 2012-08-14 23:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: rcj, adlai, linux-security-module, tpmdd-devel, adlai, key,
	linuxppc-dev
In-Reply-To: <1344986638.4430.22.camel@footlong>

This patch adds a new device driver to support IBM virtual TPM
(vTPM) for PPC64.  IBM vTPM is supported through the adjunct
partition with firmware release 740 or higher.  With vTPM
support, each lpar is able to have its own vTPM without the
physical TPM hardware.

This driver provides TPM functionalities by communicating with
the vTPM adjunct partition through Hypervisor calls (Hcalls)
and Command/Response Queue (CRQ) commands.

Signed-off-by: Ashley Lai <adlai@us.ibm.com>
---
 drivers/char/tpm/Kconfig       |    8 +
 drivers/char/tpm/Makefile      |    1 +
 drivers/char/tpm/tpm.h         |    1 +
 drivers/char/tpm/tpm_ibmvtpm.c |  749 ++++++++++++++++++++++++++++++++++++++++
 drivers/char/tpm/tpm_ibmvtpm.h |   83 +++++
 5 files changed, 842 insertions(+), 0 deletions(-)
 create mode 100644 drivers/char/tpm/tpm_ibmvtpm.c
 create mode 100644 drivers/char/tpm/tpm_ibmvtpm.h

diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
index c4aac48..915875e 100644
--- a/drivers/char/tpm/Kconfig
+++ b/drivers/char/tpm/Kconfig
@@ -73,4 +73,12 @@ config TCG_INFINEON
 	  Further information on this driver and the supported hardware
 	  can be found at http://www.trust.rub.de/projects/linux-device-driver-infineon-tpm/ 

+config TCG_IBMVTPM
+	tristate "IBM VTPM Interface"
+	depends on PPC64
+	---help---
+	  If you have IBM virtual TPM (VTPM) support say Yes and it
+	  will be accessible from within Linux.  To compile this driver
+	  as a module, choose M here; the module will be called tpm_ibmvtpm.
+
 endif # TCG_TPM
diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
index beac52f..547509d 100644
--- a/drivers/char/tpm/Makefile
+++ b/drivers/char/tpm/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o
 obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
 obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o
 obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
+obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 645136e..870fde7 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -100,6 +100,7 @@ struct tpm_vendor_specific {
 	bool timeout_adjusted;
 	unsigned long duration[3]; /* jiffies */
 	bool duration_adjusted;
+	void *data;
 
 	wait_queue_head_t read_queue;
 	wait_queue_head_t int_queue;
diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
new file mode 100644
index 0000000..efc4ab3
--- /dev/null
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -0,0 +1,749 @@
+/*
+ * Copyright (C) 2012 IBM Corporation
+ *
+ * Author: Ashley Lai <adlai@us.ibm.com>
+ *
+ * Maintained by: <tpmdd-devel@lists.sourceforge.net>
+ *
+ * Device driver for TCG/TCPA TPM (trusted platform module).
+ * Specifications at www.trustedcomputinggroup.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ *
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/dmapool.h>
+#include <linux/slab.h>
+#include <asm/vio.h>
+#include <asm/irq.h>
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/wait.h>
+#include <asm/prom.h>
+
+#include "tpm.h"
+#include "tpm_ibmvtpm.h"
+
+static const char tpm_ibmvtpm_driver_name[] = "tpm_ibmvtpm";
+
+static struct vio_device_id tpm_ibmvtpm_device_table[] __devinitdata = {
+	{ "IBM,vtpm", "IBM,vtpm"},
+	{ "", "" }
+};
+MODULE_DEVICE_TABLE(vio, tpm_ibmvtpm_device_table);
+
+DECLARE_WAIT_QUEUE_HEAD(wq);
+
+/**
+ * ibmvtpm_send_crq - Send a CRQ request
+ * @vdev:	vio device struct
+ * @w1:		first word
+ * @w2:		second word
+ *
+ * Return value:
+ *	0 -Sucess
+ *	Non-zero - Failure
+ */
+static int ibmvtpm_send_crq(struct vio_dev *vdev, u64 w1, u64 w2)
+{
+	return plpar_hcall_norets(H_SEND_CRQ, vdev->unit_address, w1, w2);
+}
+
+/**
+ * ibmvtpm_get_data - Retrieve ibm vtpm data
+ * @dev:	device struct
+ *
+ * Return value:
+ *	vtpm device struct
+ */
+static struct ibmvtpm_dev *ibmvtpm_get_data(const struct device *dev)
+{
+	struct tpm_chip *chip = dev_get_drvdata(dev);
+	if (chip)
+		return (struct ibmvtpm_dev *)chip->vendor.data;
+	return NULL;
+}
+
+/**
+ * tpm_ibmvtpm_recv - Receive data after send
+ * @chip:	tpm chip struct
+ * @buf:	buffer to read
+ * count:	size of buffer
+ *
+ * Return value:
+ *	Number of bytes read
+ */
+static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
+{
+	struct ibmvtpm_dev *ibmvtpm;
+	u16 len;
+
+	ibmvtpm = (struct ibmvtpm_dev *)chip->vendor.data;
+
+	if (!ibmvtpm->rtce_buf) {
+		dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n");
+		return 0;
+	}
+
+	wait_event_interruptible(wq, ibmvtpm->crq_res.len != 0);
+
+	if (count < ibmvtpm->crq_res.len) {
+		dev_err(ibmvtpm->dev,
+			"Invalid size in recv: count=%ld, crq_size=%d\n",
+			count, ibmvtpm->crq_res.len);
+		return -EIO;
+	}
+
+	spin_lock(&ibmvtpm->rtce_lock);
+	memcpy((void *)buf, (void *)ibmvtpm->rtce_buf, ibmvtpm->crq_res.len);
+	memset(ibmvtpm->rtce_buf, 0, ibmvtpm->crq_res.len);
+	ibmvtpm->crq_res.valid = 0;
+	ibmvtpm->crq_res.msg = 0;
+	len = ibmvtpm->crq_res.len;
+	ibmvtpm->crq_res.len = 0;
+	spin_unlock(&ibmvtpm->rtce_lock);
+	return len;
+}
+
+/**
+ * tpm_ibmvtpm_send - Send tpm request
+ * @chip:	tpm chip struct
+ * @buf:	buffer contains data to send
+ * count:	size of buffer
+ *
+ * Return value:
+ *	Number of bytes sent
+ */
+static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
+{
+	struct ibmvtpm_dev *ibmvtpm;
+	struct ibmvtpm_crq crq;
+	u64 *word = (u64 *) &crq;
+	int rc;
+
+	ibmvtpm = (struct ibmvtpm_dev *)chip->vendor.data;
+
+	if (!ibmvtpm->rtce_buf) {
+		dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n");
+		return 0;
+	}
+
+	if (count > ibmvtpm->rtce_size) {
+		dev_err(ibmvtpm->dev,
+			"Invalid size in send: count=%ld, rtce_size=%d\n",
+			count, ibmvtpm->rtce_size);
+		return -EIO;
+	}
+
+	spin_lock(&ibmvtpm->rtce_lock);
+	memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count);
+	crq.valid = (u8)IBMVTPM_VALID_CMD;
+	crq.msg = (u8)VTPM_TPM_COMMAND;
+	crq.len = (u16)count;
+	crq.data = ibmvtpm->rtce_dma_handle;
+
+	rc = ibmvtpm_send_crq(ibmvtpm->vdev, word[0], word[1]);
+	if (rc != H_SUCCESS) {
+		dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc);
+		rc = 0;
+	} else
+		rc = count;
+
+	spin_unlock(&ibmvtpm->rtce_lock);
+	return rc;
+}
+
+static void tpm_ibmvtpm_cancel(struct tpm_chip *chip)
+{
+	return;
+}
+
+static u8 tpm_ibmvtpm_status(struct tpm_chip *chip)
+{
+	return 0;
+}
+
+/**
+ * ibmvtpm_crq_get_rtce_size - Send a CRQ request to get rtce size
+ * @ibmvtpm:	vtpm device struct
+ *
+ * Return value:
+ *	0 - Success
+ *	Non-zero - Failure
+ */
+static int ibmvtpm_crq_get_rtce_size(struct ibmvtpm_dev *ibmvtpm)
+{
+	struct ibmvtpm_crq crq;
+	u64 *buf = (u64 *) &crq;
+	int rc;
+
+	crq.valid = (u8)IBMVTPM_VALID_CMD;
+	crq.msg = (u8)VTPM_GET_RTCE_BUFFER_SIZE;
+
+	rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
+	if (rc != H_SUCCESS)
+		dev_err(ibmvtpm->dev,
+			"ibmvtpm_crq_get_rtce_size failed rc=%d\n", rc);
+
+	return rc;
+}
+
+/**
+ * ibmvtpm_crq_get_version - Send a CRQ request to get vtpm version
+ *			   - Note that this is vtpm version and not tpm version
+ * @ibmvtpm:	vtpm device struct
+ *
+ * Return value:
+ *	0 - Success
+ *	Non-zero - Failure
+ */
+static int ibmvtpm_crq_get_version(struct ibmvtpm_dev *ibmvtpm)
+{
+	struct ibmvtpm_crq crq;
+	u64 *buf = (u64 *) &crq;
+	int rc;
+
+	crq.valid = (u8)IBMVTPM_VALID_CMD;
+	crq.msg = (u8)VTPM_GET_VERSION;
+
+	rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
+	if (rc != H_SUCCESS)
+		dev_err(ibmvtpm->dev,
+			"ibmvtpm_crq_get_version failed rc=%d\n", rc);
+
+	return rc;
+}
+
+/**
+ * ibmvtpm_crq_send_init_complete - Send a CRQ initialize complete message
+ * @ibmvtpm:	vtpm device struct
+ *
+ * Return value:
+ *	0 - Success
+ *	Non-zero - Failure
+ */
+static int ibmvtpm_crq_send_init_complete(struct ibmvtpm_dev *ibmvtpm)
+{
+	int rc;
+
+	rc = ibmvtpm_send_crq(ibmvtpm->vdev, INIT_CRQ_COMP_CMD, 0);
+	if (rc != H_SUCCESS)
+		dev_err(ibmvtpm->dev,
+			"ibmvtpm_crq_send_init_complete failed rc=%d\n", rc);
+
+	return rc;
+}
+
+/**
+ * ibmvtpm_crq_send_init - Send a CRQ initialize message
+ * @ibmvtpm:	vtpm device struct
+ *
+ * Return value:
+ *	0 - Success
+ *	Non-zero - Failure
+ */
+static int ibmvtpm_crq_send_init(struct ibmvtpm_dev *ibmvtpm)
+{
+	int rc;
+
+	rc = ibmvtpm_send_crq(ibmvtpm->vdev, INIT_CRQ_CMD, 0);
+	if (rc != H_SUCCESS)
+		dev_err(ibmvtpm->dev,
+			"ibmvtpm_crq_send_init failed rc=%d\n", rc);
+
+	return rc;
+}
+
+/**
+ * tpm_ibmvtpm_remove - ibm vtpm remove entry point
+ * @vdev:	vio device struct
+ *
+ * Return value:
+ *	0
+ */
+static int __devexit tpm_ibmvtpm_remove(struct vio_dev *vdev)
+{
+	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);
+	int rc = 0;
+
+	free_irq(vdev->irq, ibmvtpm);
+	tasklet_kill(&ibmvtpm->tasklet);
+
+	do {
+		if (rc)
+			msleep(100);
+		rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address);
+	} while (rc == H_BUSY || H_IS_LONG_BUSY(rc));
+
+	dma_unmap_single(ibmvtpm->dev, ibmvtpm->crq_dma_handle,
+			 CRQ_RES_BUF_SIZE, DMA_BIDIRECTIONAL);
+	free_page((unsigned long)ibmvtpm->crq_queue.crq_addr);
+
+	if (ibmvtpm->rtce_buf) {
+		dma_unmap_single(ibmvtpm->dev, ibmvtpm->rtce_dma_handle,
+				 ibmvtpm->rtce_size, DMA_BIDIRECTIONAL);
+		kfree(ibmvtpm->rtce_buf);
+	}
+
+	tpm_remove_hardware(ibmvtpm->dev);
+
+	kfree(ibmvtpm);
+
+	return 0;
+}
+
+/**
+ * tpm_ibmvtpm_get_desired_dma - Get DMA size needed by this driver
+ * @vdev:	vio device struct
+ *
+ * Return value:
+ *	Number of bytes the driver needs to DMA map
+ */
+static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev)
+{
+	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);
+	return CRQ_RES_BUF_SIZE + ibmvtpm->rtce_size;
+}
+
+/**
+ * tpm_ibmvtpm_suspend - Suspend
+ * @dev:	device struct
+ *
+ * Return value:
+ *	0
+ */
+static int tpm_ibmvtpm_suspend(struct device *dev)
+{
+	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(dev);
+	struct ibmvtpm_crq crq;
+	u64 *buf = (u64 *) &crq;
+	int rc = 0;
+
+	crq.valid = (u8)IBMVTPM_VALID_CMD;
+	crq.msg = (u8)VTPM_PREPARE_TO_SUSPEND;
+
+	rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
+	if (rc != H_SUCCESS)
+		dev_err(ibmvtpm->dev,
+			"tpm_ibmvtpm_suspend failed rc=%d\n", rc);
+
+	return rc;
+}
+
+/**
+ * ibmvtpm_reset_crq - Reset CRQ
+ * @ibmvtpm:	ibm vtpm struct
+ *
+ * Return value:
+ *	0 - Success
+ *	Non-zero - Failure
+ */
+static int ibmvtpm_reset_crq(struct ibmvtpm_dev *ibmvtpm)
+{
+	int rc = 0;
+
+	do {
+		if (rc)
+			msleep(100);
+		rc = plpar_hcall_norets(H_FREE_CRQ,
+					ibmvtpm->vdev->unit_address);
+	} while (rc == H_BUSY || H_IS_LONG_BUSY(rc));
+
+	memset(ibmvtpm->crq_queue.crq_addr, 0, CRQ_RES_BUF_SIZE);
+	ibmvtpm->crq_queue.index = 0;
+
+	return plpar_hcall_norets(H_REG_CRQ, ibmvtpm->vdev->unit_address,
+				  ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE);
+}
+
+/**
+ * tpm_ibmvtpm_resume - Resume from suspend
+ * @dev:	device struct
+ *
+ * Return value:
+ *	0
+ */
+static int tpm_ibmvtpm_resume(struct device *dev)
+{
+	struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(dev);
+	unsigned long flags;
+	int rc = 0;
+
+	do {
+		if (rc)
+			msleep(100);
+		rc = plpar_hcall_norets(H_ENABLE_CRQ,
+					ibmvtpm->vdev->unit_address);
+	} while (rc == H_IN_PROGRESS || rc == H_BUSY || H_IS_LONG_BUSY(rc));
+
+	if (rc) {
+		dev_err(dev, "Error enabling ibmvtpm rc=%d\n", rc);
+		return rc;
+	}
+
+	spin_lock_irqsave(&ibmvtpm->lock, flags);
+	vio_disable_interrupts(ibmvtpm->vdev);
+	tasklet_schedule(&ibmvtpm->tasklet);
+	spin_unlock_irqrestore(&ibmvtpm->lock, flags);
+
+	rc = ibmvtpm_crq_send_init(ibmvtpm);
+	if (rc)
+		dev_err(dev, "Error send_init rc=%d\n", rc);
+
+	return rc;
+}
+
+static const struct file_operations ibmvtpm_ops = {
+	.owner = THIS_MODULE,
+	.llseek = no_llseek,
+	.open = tpm_open,
+	.read = tpm_read,
+	.write = tpm_write,
+	.release = tpm_release,
+};
+
+static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
+static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
+static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
+static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
+static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
+static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated,
+		   NULL);
+static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps_1_2, NULL);
+static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
+static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
+static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
+
+static struct attribute *ibmvtpm_attrs[] = {
+	&dev_attr_pubek.attr,
+	&dev_attr_pcrs.attr,
+	&dev_attr_enabled.attr,
+	&dev_attr_active.attr,
+	&dev_attr_owned.attr,
+	&dev_attr_temp_deactivated.attr,
+	&dev_attr_caps.attr,
+	&dev_attr_cancel.attr,
+	&dev_attr_durations.attr,
+	&dev_attr_timeouts.attr, NULL,
+};
+
+static struct attribute_group ibmvtpm_attr_grp = { .attrs = ibmvtpm_attrs };
+
+static const struct tpm_vendor_specific tpm_ibmvtpm = {
+	.recv = tpm_ibmvtpm_recv,
+	.send = tpm_ibmvtpm_send,
+	.cancel = tpm_ibmvtpm_cancel,
+	.status = tpm_ibmvtpm_status,
+	.req_complete_mask = 0,
+	.req_complete_val = 0,
+	.req_canceled = 0,
+	.attr_group = &ibmvtpm_attr_grp,
+	.miscdev = { .fops = &ibmvtpm_ops, },
+};
+
+static const struct dev_pm_ops tpm_ibmvtpm_pm_ops = {
+	.suspend = tpm_ibmvtpm_suspend,
+	.resume = tpm_ibmvtpm_resume,
+};
+
+/**
+ * ibmvtpm_crq_get_next - Get next responded crq
+ * @ibmvtpm	vtpm device struct
+ *
+ * Return value:
+ *	vtpm crq pointer
+ */
+static struct ibmvtpm_crq *ibmvtpm_crq_get_next(struct ibmvtpm_dev *ibmvtpm)
+{
+	struct ibmvtpm_crq_queue *crq_q = &ibmvtpm->crq_queue;
+	struct ibmvtpm_crq *crq = &crq_q->crq_addr[crq_q->index];
+
+	if (crq->valid & VTPM_MSG_RES) {
+		if (++crq_q->index == crq_q->num_entry)
+			crq_q->index = 0;
+		rmb();
+	} else
+		crq = NULL;
+	return crq;
+}
+
+/**
+ * ibmvtpm_crq_process - Process responded crq
+ * @crq		crq to be processed
+ * @ibmvtpm	vtpm device struct
+ *
+ * Return value:
+ *	Nothing
+ */
+static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq,
+				struct ibmvtpm_dev *ibmvtpm)
+{
+	int rc = 0;
+
+	switch (crq->valid) {
+	case VALID_INIT_CRQ:
+		switch (crq->msg) {
+		case INIT_CRQ_RES:
+			dev_info(ibmvtpm->dev, "CRQ initialized\n");
+			rc = ibmvtpm_crq_send_init_complete(ibmvtpm);
+			if (rc)
+				dev_err(ibmvtpm->dev, "Unable to send CRQ init complete rc=%d\n", rc);
+			return;
+		case INIT_CRQ_COMP_RES:
+			dev_info(ibmvtpm->dev,
+				 "CRQ initialization completed\n");
+			return;
+		default:
+			dev_err(ibmvtpm->dev, "Unknown crq message type: %d\n", crq->msg);
+			return;
+		}
+		return;
+	case IBMVTPM_VALID_CMD:
+		switch (crq->msg) {
+		case VTPM_GET_RTCE_BUFFER_SIZE_RES:
+			if (crq->len <= 0) {
+				dev_err(ibmvtpm->dev, "Invalid rtce size\n");
+				return;
+			}
+			ibmvtpm->rtce_size = crq->len;
+			ibmvtpm->rtce_buf = kmalloc(ibmvtpm->rtce_size,
+						    GFP_KERNEL);
+			if (!ibmvtpm->rtce_buf) {
+				dev_err(ibmvtpm->dev, "Failed to allocate memory for rtce buffer\n");
+				return;
+			}
+
+			ibmvtpm->rtce_dma_handle = dma_map_single(ibmvtpm->dev,
+				ibmvtpm->rtce_buf, ibmvtpm->rtce_size,
+				DMA_BIDIRECTIONAL);
+
+			if (dma_mapping_error(ibmvtpm->dev,
+					      ibmvtpm->rtce_dma_handle)) {
+				kfree(ibmvtpm->rtce_buf);
+				ibmvtpm->rtce_buf = NULL;
+				dev_err(ibmvtpm->dev, "Failed to dma map rtce buffer\n");
+			}
+
+			return;
+		case VTPM_GET_VERSION_RES:
+			ibmvtpm->vtpm_version = crq->data;
+			return;
+		case VTPM_TPM_COMMAND_RES:
+			ibmvtpm->crq_res.valid = crq->valid;
+			ibmvtpm->crq_res.msg = crq->msg;
+			ibmvtpm->crq_res.len = crq->len;
+			ibmvtpm->crq_res.data = crq->data;
+			wake_up_interruptible(&wq);
+			return;
+		default:
+			return;
+		}
+	}
+	return;
+}
+
+/**
+ * ibmvtpm_interrupt -	Interrupt handler
+ * @irq:		irq number to handle
+ * @vtpm_instance:	vtpm that received interrupt
+ *
+ * Returns:
+ *	IRQ_HANDLED
+ **/
+static irqreturn_t ibmvtpm_interrupt(int irq, void *vtpm_instance)
+{
+	struct ibmvtpm_dev *ibmvtpm = (struct ibmvtpm_dev *) vtpm_instance;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ibmvtpm->lock, flags);
+	vio_disable_interrupts(ibmvtpm->vdev);
+	tasklet_schedule(&ibmvtpm->tasklet);
+	spin_unlock_irqrestore(&ibmvtpm->lock, flags);
+
+	return IRQ_HANDLED;
+}
+
+/**
+ * ibmvtpm_tasklet - Interrupt handler tasklet
+ * @data:	ibm vtpm device struct
+ *
+ * Returns:
+ *	Nothing
+ **/
+static void ibmvtpm_tasklet(void *data)
+{
+	struct ibmvtpm_dev *ibmvtpm = data;
+	struct ibmvtpm_crq *crq;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ibmvtpm->lock, flags);
+	while ((crq = ibmvtpm_crq_get_next(ibmvtpm)) != NULL) {
+		ibmvtpm_crq_process(crq, ibmvtpm);
+		crq->valid = 0;
+		wmb();
+	}
+
+	vio_enable_interrupts(ibmvtpm->vdev);
+	spin_unlock_irqrestore(&ibmvtpm->lock, flags);
+}
+
+/**
+ * tpm_ibmvtpm_probe - ibm vtpm initialize entry point
+ * @vio_dev:	vio device struct
+ * @id:		vio device id struct
+ *
+ * Return value:
+ *	0 - Success
+ *	Non-zero - Failure
+ */
+static int __devinit tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
+				   const struct vio_device_id *id)
+{
+	struct ibmvtpm_dev *ibmvtpm;
+	struct device *dev = &vio_dev->dev;
+	struct ibmvtpm_crq_queue *crq_q;
+	struct tpm_chip *chip;
+	int rc = -ENOMEM, rc1;
+
+	chip = tpm_register_hardware(dev, &tpm_ibmvtpm);
+	if (!chip) {
+		dev_err(dev, "tpm_register_hardware failed\n");
+		return -ENODEV;
+	}
+
+	ibmvtpm = kzalloc(sizeof(struct ibmvtpm_dev), GFP_KERNEL);
+	if (!ibmvtpm) {
+		dev_err(dev, "kzalloc for ibmvtpm failed\n");
+		goto cleanup;
+	}
+
+	crq_q = &ibmvtpm->crq_queue;
+	crq_q->crq_addr = (struct ibmvtpm_crq *)get_zeroed_page(GFP_KERNEL);
+	if (!crq_q->crq_addr) {
+		dev_err(dev, "Unable to allocate memory for crq_addr\n");
+		goto cleanup;
+	}
+
+	crq_q->num_entry = CRQ_RES_BUF_SIZE / sizeof(*crq_q->crq_addr);
+	ibmvtpm->crq_dma_handle = dma_map_single(dev, crq_q->crq_addr,
+						 CRQ_RES_BUF_SIZE,
+						 DMA_BIDIRECTIONAL);
+
+	if (dma_mapping_error(dev, ibmvtpm->crq_dma_handle)) {
+		dev_err(dev, "dma mapping failed\n");
+		goto cleanup;
+	}
+
+	rc = plpar_hcall_norets(H_REG_CRQ, vio_dev->unit_address,
+				ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE);
+	if (rc == H_RESOURCE)
+		rc = ibmvtpm_reset_crq(ibmvtpm);
+
+	if (rc) {
+		dev_err(dev, "Unable to register CRQ rc=%d\n", rc);
+		goto reg_crq_cleanup;
+	}
+
+	tasklet_init(&ibmvtpm->tasklet, (void *)ibmvtpm_tasklet,
+		     (unsigned long)ibmvtpm);
+
+	rc = request_irq(vio_dev->irq, ibmvtpm_interrupt, 0,
+			 tpm_ibmvtpm_driver_name, ibmvtpm);
+	if (rc) {
+		dev_err(dev, "Error %d register irq 0x%x\n", rc, vio_dev->irq);
+		goto init_irq_cleanup;
+	}
+
+	rc = vio_enable_interrupts(vio_dev);
+	if (rc) {
+		dev_err(dev, "Error %d enabling interrupts\n", rc);
+		goto init_irq_cleanup;
+	}
+
+	crq_q->index = 0;
+
+	ibmvtpm->dev = dev;
+	ibmvtpm->vdev = vio_dev;
+	chip->vendor.data = (void *)ibmvtpm;
+
+	spin_lock_init(&ibmvtpm->lock);
+	spin_lock_init(&ibmvtpm->rtce_lock);
+
+	rc = ibmvtpm_crq_send_init(ibmvtpm);
+	if (rc)
+		goto init_irq_cleanup;
+
+	rc = ibmvtpm_crq_get_version(ibmvtpm);
+	if (rc)
+		goto init_irq_cleanup;
+
+	rc = ibmvtpm_crq_get_rtce_size(ibmvtpm);
+	if (rc)
+		goto init_irq_cleanup;
+
+	return rc;
+init_irq_cleanup:
+	tasklet_kill(&ibmvtpm->tasklet);
+	do {
+		rc1 = plpar_hcall_norets(H_FREE_CRQ, vio_dev->unit_address);
+	} while (rc1 == H_BUSY || H_IS_LONG_BUSY(rc1));
+reg_crq_cleanup:
+	dma_unmap_single(dev, ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE,
+			 DMA_BIDIRECTIONAL);
+cleanup:
+	if (ibmvtpm) {
+		if (crq_q->crq_addr)
+			free_page((unsigned long)crq_q->crq_addr);
+		kfree(ibmvtpm);
+	}
+
+	tpm_remove_hardware(dev);
+
+	return rc;
+}
+
+static struct vio_driver ibmvtpm_driver = {
+	.id_table	 = tpm_ibmvtpm_device_table,
+	.probe		 = tpm_ibmvtpm_probe,
+	.remove		 = tpm_ibmvtpm_remove,
+	.get_desired_dma = tpm_ibmvtpm_get_desired_dma,
+	.name		 = tpm_ibmvtpm_driver_name,
+	.pm		 = &tpm_ibmvtpm_pm_ops,
+};
+
+/**
+ * ibmvtpm_module_init - Initialize ibm vtpm module
+ *
+ * Return value:
+ *	0 -Success
+ *	Non-zero - Failure
+ */
+static int __init ibmvtpm_module_init(void)
+{
+	return vio_register_driver(&ibmvtpm_driver);
+}
+
+/**
+ * ibmvtpm_module_exit - Teardown ibm vtpm module
+ *
+ * Return value:
+ *	Nothing
+ */
+static void __exit ibmvtpm_module_exit(void)
+{
+	vio_unregister_driver(&ibmvtpm_driver);
+}
+
+module_init(ibmvtpm_module_init);
+module_exit(ibmvtpm_module_exit);
+
+MODULE_AUTHOR("adlai@us.ibm.com");
+MODULE_DESCRIPTION("IBM vTPM Driver");
+MODULE_VERSION("1.0");
+MODULE_LICENSE("GPL");
diff --git a/drivers/char/tpm/tpm_ibmvtpm.h b/drivers/char/tpm/tpm_ibmvtpm.h
new file mode 100644
index 0000000..fb930dd
--- /dev/null
+++ b/drivers/char/tpm/tpm_ibmvtpm.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2012 IBM Corporation
+ *
+ * Author: Ashley Lai <adlai@us.ibm.com>
+ *
+ * Maintained by: <tpmdd-devel@lists.sourceforge.net>
+ *
+ * Device driver for TCG/TCPA TPM (trusted platform module).
+ * Specifications at www.trustedcomputinggroup.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ *
+ * These difference are required on power because the device must be
+ * discovered through the device tree and iomap must be used to get
+ * around the need for holes in the io_page_mask.  This does not happen
+ * automatically because the tpm is not a normal pci device and lives
+ * under the root node.
+ *
+ */
+
+#ifndef __TPM_IBMVTPM_H__
+#define __TPM_IBMVTPM_H__
+
+/* vTPM Message Format 1 */
+struct ibmvtpm_crq {
+	u8 valid;
+	u8 msg;
+	u16 len;
+	u32 data;
+	u64 reserved;
+} __attribute__((packed, aligned(8)));
+
+struct ibmvtpm_crq_queue {
+	struct ibmvtpm_crq *crq_addr;
+	u32 index;
+	u32 num_entry;
+};
+
+struct ibmvtpm_dev {
+	struct device *dev;
+	struct vio_dev *vdev;
+	struct ibmvtpm_crq_queue crq_queue;
+	dma_addr_t crq_dma_handle;
+	spinlock_t lock;
+	struct tasklet_struct tasklet;
+	u32 rtce_size;
+	void __iomem *rtce_buf;
+	dma_addr_t rtce_dma_handle;
+	spinlock_t rtce_lock;
+	struct ibmvtpm_crq crq_res;
+	u32 vtpm_version;
+};
+
+#define CRQ_RES_BUF_SIZE	PAGE_SIZE
+
+/* Initialize CRQ */
+#define INIT_CRQ_CMD		0xC001000000000000LL /* Init cmd */
+#define INIT_CRQ_COMP_CMD	0xC002000000000000LL /* Init complete cmd */
+#define INIT_CRQ_RES		0x01	/* Init respond */
+#define INIT_CRQ_COMP_RES	0x02	/* Init complete respond */
+#define VALID_INIT_CRQ		0xC0	/* Valid command for init crq */
+
+/* vTPM CRQ response is the message type | 0x80 */
+#define VTPM_MSG_RES		0x80
+#define IBMVTPM_VALID_CMD	0x80
+
+/* vTPM CRQ message types */
+#define VTPM_GET_VERSION			0x01
+#define VTPM_GET_VERSION_RES			(0x01 | VTPM_MSG_RES)
+
+#define VTPM_TPM_COMMAND			0x02
+#define VTPM_TPM_COMMAND_RES			(0x02 | VTPM_MSG_RES)
+
+#define VTPM_GET_RTCE_BUFFER_SIZE		0x03
+#define VTPM_GET_RTCE_BUFFER_SIZE_RES		(0x03 | VTPM_MSG_RES)
+
+#define VTPM_PREPARE_TO_SUSPEND			0x04
+#define VTPM_PREPARE_TO_SUSPEND_RES		(0x04 | VTPM_MSG_RES)
+
+#endif
-- 
1.7.1

^ permalink raw reply related

* [PATCH V3 0/3] tpm: Add new vTPM device driver for PPC64
From: Ashley Lai @ 2012-08-14 23:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: rcj, adlai, linux-security-module, tpmdd-devel, adlai, key,
	linuxppc-dev

Change log V3:
- Replaced TPM_NO_EVENT_LOG macro with stubs
- Removed tpm_noeventlog.c file 
- Called of_node_put() before return in tpm_of.c

Change log V2:
- Removed unnecessary tpm_bios_log_setup and tpm_bios_log_teardown
  functions in tpm_eventlog.h (patch 3/3).
- Added more descriptions on vTPM (patch 1/3).

These patches add support for IBM vTPM for PPC64. This new device driver
works on firmware that supports vTPM (firmware release 740 or higher).

Tested on Power7+ system with firmware level ZM770_001.

Applied to Kent Yoder tree at:
https://github.com/shpedoikal/linux/tree/v3.6-rc1-tpmdd-staging

Ashley Lai (3):
  drivers/char/tpm: Add new device driver to support IBM vTPM
  PPC64: Add support for instantiating SML from Open Firmware
  drivers/char/tpm: Add securityfs support for event log

 arch/powerpc/kernel/prom_init.c |   62 ++++
 drivers/char/tpm/Kconfig        |    8 +
 drivers/char/tpm/Makefile       |    6 +
 drivers/char/tpm/tpm.h          |   13 +-
 drivers/char/tpm/tpm_eventlog.h |   15 +
 drivers/char/tpm/tpm_ibmvtpm.c  |  749 +++++++++++++++++++++++++++++++++++++++
 drivers/char/tpm/tpm_ibmvtpm.h  |   83 +++++
 drivers/char/tpm/tpm_of.c       |   73 ++++
 8 files changed, 997 insertions(+), 12 deletions(-)
 create mode 100644 drivers/char/tpm/tpm_ibmvtpm.c
 create mode 100644 drivers/char/tpm/tpm_ibmvtpm.h
 create mode 100644 drivers/char/tpm/tpm_of.c

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/85xx: add Fman MDIO muxing support to the P4080DS
From: Scott Wood @ 2012-08-14 23:12 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev, Andy Fleming, ddaney.cavm, netdev
In-Reply-To: <502ADA75.7020200@freescale.com>

On 08/14/2012 06:08 PM, Timur Tabi wrote:
> Scott Wood wrote:
>>
>> If anything, I'd make the ordering be "wrong" to force that code path to
>> be tested -- though ideally there would be a more systematic approach to
>> such testing, that doesn't require inefficiency during normal boot.
> 
> I can't force the ordering to be wrong, because it's the only entry in the
> list. The DPAA entries are not there yet.

Right, I mean once the DPAA entries are added.

> This is what I have now:
> 
> static const struct of_device_id of_device_ids[] __devinitconst = {
> 	{
> 		.compatible	= "simple-bus"
> 	},
> 	{
> 		.compatible	= "fsl,srio",
> 	},
> 	{
> 		.compatible	= "fsl,p4080-pcie",
> 	},
> 	{
> 		.compatible	= "fsl,qoriq-pcie-v2.2",
> 	},
> 	{
> 		.compatible	= "fsl,qoriq-pcie-v2.3",
> 	},
> 	{
> 		.compatible	= "fsl,qoriq-pcie-v2.4",
> 	},
> 	/* The following two are for the Freescale hypervisor */
> 	{
> 		.name		= "hypervisor",
> 	},
> 	{
> 		.name		= "handles",
> 	},
> 	{
> 		/*
> 		 * Warning: this entry might need to be located before those
> 		 * for the Fman Ethernet nodes, although using EPROBE_DEFER
> 		 * in the DPAA drivers could fix that.
> 		 */
> 		.compatible	= "mdio-mux",
> 	},

I'd either say nothing here or say only "The ethernet driver should use
EPROBE_DEFER to ensure that the mdio-mux is probed first".  Don't give
whoever submits the DPAA ethernet driver the idea that relying on list
order is an acceptable solution.

-Scott

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/85xx: add Fman MDIO muxing support to the P4080DS
From: Timur Tabi @ 2012-08-14 23:08 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, Andy Fleming, ddaney.cavm, netdev
In-Reply-To: <502AD9F4.10903@freescale.com>

Scott Wood wrote:
> 
> If anything, I'd make the ordering be "wrong" to force that code path to
> be tested -- though ideally there would be a more systematic approach to
> such testing, that doesn't require inefficiency during normal boot.

I can't force the ordering to be wrong, because it's the only entry in the
list. The DPAA entries are not there yet.

This is what I have now:

static const struct of_device_id of_device_ids[] __devinitconst = {
	{
		.compatible	= "simple-bus"
	},
	{
		.compatible	= "fsl,srio",
	},
	{
		.compatible	= "fsl,p4080-pcie",
	},
	{
		.compatible	= "fsl,qoriq-pcie-v2.2",
	},
	{
		.compatible	= "fsl,qoriq-pcie-v2.3",
	},
	{
		.compatible	= "fsl,qoriq-pcie-v2.4",
	},
	/* The following two are for the Freescale hypervisor */
	{
		.name		= "hypervisor",
	},
	{
		.name		= "handles",
	},
	{
		/*
		 * Warning: this entry might need to be located before those
		 * for the Fman Ethernet nodes, although using EPROBE_DEFER
		 * in the DPAA drivers could fix that.
		 */
		.compatible	= "mdio-mux",
	},
	{}
};



-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/85xx: add Fman MDIO muxing support to the P4080DS
From: Scott Wood @ 2012-08-14 23:06 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev, Andy Fleming, ddaney.cavm, netdev
In-Reply-To: <502ACA09.6070906@freescale.com>

On 08/14/2012 04:58 PM, Timur Tabi wrote:
> Scott Wood wrote:
> 
>> I think that was internally, and not on this specific comment wording.
>> I don't think that code comment adequately explains things.
> 
> I don't really have any more insight to add.

My point (at least, this part of it) was that more of the insight you've
already provided should be moved from e-mail discussion to the code comment.

>>> otherwise, the mdio-mux code would not prepare the mdio mus in time, and
>>> there would be initialization failures.  Now maybe this goes away with
>>> -EPROBE_DEFER, or maybe it doesn't.  But until we push the DPAA drivers
>>> upstream, we won't know.
>>
>> Do you know if it's theoretically supposed to be fixed and just can't
>> test it, or are you unsure of whether it's even supposed to work?
> 
> I'm not sure of anything.  For one thing, we don't implement EPROBE_DEFER
> in the DPAA drivers, so we'd probably have to fix that before anything.
> And then, I'm just guessing that's the solution.

I feel confident saying it is the solution, at least until it is
demonstrated otherwise.

>> I don't think we should be relying on the order of this list to
>> determine probe order.  For one thing, it won't work if the drivers
>> register after you create the platform devices (e.g. they're modules).
> 
> I agree we should not be relying on the order, but I don't know what to
> do.  EPROBE_DEFER was designed to handle this situation, so my
> recommendation is to worry about it later.  I can beef up the comment to
> talk about that, if you want.

If the DPAA driver doesn't implement it when it's submitted, it's a bug
in the DPAA driver and we should insist it be fixed.  I don't think we
should at all entertain the notion that careful device id list ordering
is even a potential solution.

If anything, I'd make the ordering be "wrong" to force that code path to
be tested -- though ideally there would be a more systematic approach to
such testing, that doesn't require inefficiency during normal boot.

-Scott

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/85xx: add Fman MDIO muxing support to the P4080DS
From: Timur Tabi @ 2012-08-14 21:58 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, Andy Fleming, ddaney.cavm, netdev
In-Reply-To: <502AC8D3.4010602@freescale.com>

Scott Wood wrote:

> I think that was internally, and not on this specific comment wording.
> I don't think that code comment adequately explains things.

I don't really have any more insight to add.

>> otherwise, the mdio-mux code would not prepare the mdio mus in time, and
>> there would be initialization failures.  Now maybe this goes away with
>> -EPROBE_DEFER, or maybe it doesn't.  But until we push the DPAA drivers
>> upstream, we won't know.
> 
> Do you know if it's theoretically supposed to be fixed and just can't
> test it, or are you unsure of whether it's even supposed to work?

I'm not sure of anything.  For one thing, we don't implement EPROBE_DEFER
in the DPAA drivers, so we'd probably have to fix that before anything.
And then, I'm just guessing that's the solution.

> I don't think we should be relying on the order of this list to
> determine probe order.  For one thing, it won't work if the drivers
> register after you create the platform devices (e.g. they're modules).

I agree we should not be relying on the order, but I don't know what to
do.  EPROBE_DEFER was designed to handle this situation, so my
recommendation is to worry about it later.  I can beef up the comment to
talk about that, if you want.

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/85xx: add Fman MDIO muxing support to the P4080DS
From: Scott Wood @ 2012-08-14 21:53 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev, Andy Fleming, ddaney.cavm, netdev
In-Reply-To: <502AC7C3.9030902@freescale.com>

On 08/14/2012 04:48 PM, Timur Tabi wrote:
> Kumar Gala wrote:
>>>> +	{
>>>> +		/*
>>>> +		 * Warning: this entry might need to be located before those
>>>> +		 * for the Fman Ethernet nodes.
>>>> +		 */
>>>> +		.compatible	= "mdio-mux",
>>>> +	},
>>>> 	{}
>>>> };
>> Under what condition would that be the case?
> 
> We had this discussion already.

I think that was internally, and not on this specific comment wording.
I don't think that code comment adequately explains things.

> otherwise, the mdio-mux code would not prepare the mdio mus in time, and
> there would be initialization failures.  Now maybe this goes away with
> -EPROBE_DEFER, or maybe it doesn't.  But until we push the DPAA drivers
> upstream, we won't know.

Do you know if it's theoretically supposed to be fixed and just can't
test it, or are you unsure of whether it's even supposed to work?

I don't think we should be relying on the order of this list to
determine probe order.  For one thing, it won't work if the drivers
register after you create the platform devices (e.g. they're modules).

-Scott

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/85xx: add Fman MDIO muxing support to the P4080DS
From: Timur Tabi @ 2012-08-14 21:48 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Scott Wood, linuxppc-dev, Andy Fleming, ddaney.cavm, netdev
In-Reply-To: <5F0028FE-C555-47DE-B69A-888E7322A6E1@kernel.crashing.org>

Kumar Gala wrote:
>> > +	{
>> > +		/*
>> > +		 * Warning: this entry might need to be located before those
>> > +		 * for the Fman Ethernet nodes.
>> > +		 */
>> > +		.compatible	= "mdio-mux",
>> > +	},
>> > 	{}
>> > };
> Under what condition would that be the case?

We had this discussion already.  In my tests, I had to locate this entry
before these entries:

	{
		.compatible	= "fsl,dpaa"
	},
	{
		.compatible	= "fsl,srio",
	},

otherwise, the mdio-mux code would not prepare the mdio mus in time, and
there would be initialization failures.  Now maybe this goes away with
-EPROBE_DEFER, or maybe it doesn't.  But until we push the DPAA drivers
upstream, we won't know.

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/85xx: add Fman MDIO muxing support to the P4080DS
From: Kumar Gala @ 2012-08-14 21:45 UTC (permalink / raw)
  To: Timur Tabi; +Cc: Scott Wood, linuxppc-dev, Andy Fleming, ddaney.cavm, netdev
In-Reply-To: <1344637896-14267-2-git-send-email-timur@freescale.com>


On Aug 10, 2012, at 5:31 PM, Timur Tabi wrote:

> diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c =
b/arch/powerpc/platforms/85xx/corenet_ds.c
> index 925b028..a79fc79 100644
> --- a/arch/powerpc/platforms/85xx/corenet_ds.c
> +++ b/arch/powerpc/platforms/85xx/corenet_ds.c
> @@ -106,6 +106,13 @@ static const struct of_device_id of_device_ids[] =
__devinitconst =3D {
> 	{
> 		.name		=3D "handles",
> 	},
> +	{
> +		/*
> +		 * Warning: this entry might need to be located before =
those
> +		 * for the Fman Ethernet nodes.
> +		 */
> +		.compatible	=3D "mdio-mux",
> +	},
> 	{}
> };

Under what condition would that be the case?

- k=

^ permalink raw reply

* Re: [PATCH v2 2/2] powerpc/mpic: add global timer support
From: Scott Wood @ 2012-08-14 21:20 UTC (permalink / raw)
  To: Wang Dongsheng-B40534
  Cc: Wood Scott-B07421, Li Yang-R58472, paulus@samba.org,
	Gala Kumar-B11780, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <ABB05CD9C9F68C46A5CEDC7F15439259DB19EB@039-SN2MPN1-022.039d.mgd.msft.net>

On 08/13/2012 09:32 PM, Wang Dongsheng-B40534 wrote:
> 
> 
>> -----Original Message-----
>> From: Wood Scott-B07421
>> Sent: Tuesday, August 14, 2012 10:19 AM
>> To: Wang Dongsheng-B40534
>> Cc: Wood Scott-B07421; benh@kernel.crashing.org; paulus@samba.org;
>> linuxppc-dev@lists.ozlabs.org; Gala Kumar-B11780; Li Yang-R58472
>> Subject: Re: [PATCH v2 2/2] powerpc/mpic: add global timer support
>>
>> On 08/13/2012 09:15 PM, Wang Dongsheng-B40534 wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Wood Scott-B07421
>>>> Sent: Tuesday, August 14, 2012 10:05 AM
>>>> To: Wang Dongsheng-B40534
>>>> Cc: Wood Scott-B07421; benh@kernel.crashing.org; paulus@samba.org;
>>>> linuxppc-dev@lists.ozlabs.org; Gala Kumar-B11780; Li Yang-R58472
>>>> Subject: Re: [PATCH v2 2/2] powerpc/mpic: add global timer support
>>>>
>>>> On 08/13/2012 09:00 PM, Wang Dongsheng-B40534 wrote:
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Wood Scott-B07421
>>>>>> Sent: Tuesday, August 14, 2012 1:37 AM
>>>>>> To: Wang Dongsheng-B40534
>>>>>> Cc: Wood Scott-B07421; benh@kernel.crashing.org; paulus@samba.org;
>>>>>> linuxppc-dev@lists.ozlabs.org; Gala Kumar-B11780; Li Yang-R58472
>>>>>> Subject: Re: [PATCH v2 2/2] powerpc/mpic: add global timer support
>>>>>>
>>>>>> On 08/13/2012 01:18 AM, Wang Dongsheng-B40534 wrote:
>>>>>>>>> +	p = of_get_property(np, "available-ranges", &len);
>>>>>>>>> +	if (p && len % (2 * sizeof(u32)) != 0) {
>>>>>>>>> +		pr_err("%s: malformed fsl,available-ranges property.\n",
>>>>>>>>> +				np->full_name);
>>>>>>>>> +		return -EINVAL;
>>>>>>>>> +	}
>>>>>>>>
>>>>>>>> You need to support fsl,available-ranges since that's in an
>>>>>>>> accepted binding and people could have partitioned setups already
>>>> using it.
>>>>>>>>
>>>>>>> [Wang Dongsheng] FSL chip or OPEN-PIC specification(Only a group)
>>>>>>> in each group only four timer. This is unified. So i use a generic
>> name.
>>>>>>> I think there is not compatible with existing mpic timer nodes.
>>>>>>
>>>>>> We need to be compatible with existing trees, so you'd need to
>>>>>> check for both -- but I think any further discussion of the details
>>>>>> is premature until we decide whether this is worthwhile to begin
>>>>>> with (both the support of non-FSL timers, and the creation of a new
>>>>>> device tree binding which will not be implemented by many of the
>>>>>> machines that have non-FSL openpic because they run real Open
>> Firmware).
>>>>>>
>>>>> [Wang Dongsheng]
>>>>> 	p = of_get_property(np, "available-ranges", &len);
>>>>> 	if (!p)
>>>>> 		p = of_get_property(np, "fsl,available-ranges", &len);
>>>>>
>>>>> 	this code be compatible with existing trees.
>>>>
>>>> Yes, that's what I meant by checking both.
>>>>
>>>> I still think we need to discuss why we're doing this first.  What
>>>> specific machines are going to have these new openpic timer nodes?
>>>>
>>> [Wang Dongsheng] It's support to power management awakening. At
>>> present, the power management more and more important. This way is
>>> important to wake up machine. At least need support power management
>>> of machine still needs such a driver.
>>
>> I mean specifically for the non-Freescale openpic nodes.
>>
> [Wang Dongsheng] I think non-Freescale chips can also use this function
> to wake up the machine. 

Maybe (it's very machine-specific what can be used as a wake source),
but what I asked was what specific machines could make use of this.
Name *one* machine for which these new openpic timer nodes will actually
be created.

> And There is also an important feature, It can
> periodically generate an interrupt.

That's not important at all.  We already have a way to do that using the
decrementer.

> For example, the network periodically check the hardware device(link status).

And it uses standard Linux software timers to do it.

-Scott

^ permalink raw reply

* Re: [PATCH v2 1/2] powerpc/mpic: Add Open-PIC global timer document
From: Scott Wood @ 2012-08-14 21:18 UTC (permalink / raw)
  To: Wang Dongsheng-B40534
  Cc: Wood Scott-B07421, Li Yang-R58472,
	devicetree-discuss@lists.ozlabs.org, paulus@samba.org,
	Gala Kumar-B11780, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <ABB05CD9C9F68C46A5CEDC7F15439259DB1A08@039-SN2MPN1-022.039d.mgd.msft.net>

On 08/13/2012 09:40 PM, Wang Dongsheng-B40534 wrote:
>>>> +Example 2:
>>>>> +
>>>>> +	timer: timer@010f0 {
>>>>> +		compatible = "open-pic,global-timer";
>>>>> +		device_type = "open-pic";
>>>>> +		reg = <0x010f0 4 0x01100 0x100>;
>>>>> +		interrupts = <0 0 3 0
>>>>> +			      1 0 3 0
>>>>> +			      2 0 3 0
>>>>> +		              3 0 3 0>;
>>>>> +	};
>>>>
>>>> 4-cell interrupt specifiers are specific to Freescale MPICs.  This
>>>> means there's no way to describe the timer interrupt on a non-
>> Freescale openpic.
>>>> Again, I suggest we not bother with this in the absence of an actual
>>>> need to support the timer on non-Freescale openpic in partitioned
>> scenarios.
>>>> The existing openpic node is sufficient to describe the
>>>> hardware in the absence of partitioning.   We could have an
>>>> "openpic-no-timer" property to indicate that we're describing it
>>>> separately, so that the absence of a timer node isn't ambiguous as to
>>>> whether it's an old tree or a partitioned scenario.  An fsl,mpic
>>>> compatible would imply openpic-no-timer.
>>>>
>>>> Note that I believe many of the non-Freescale openpic nodes are going
>>>> to be found on systems with real Open Firmware, so we can't go
>>>> changing the device tree for them.
>>> [Wang Dongsheng] In the Open-PIC specification, there are four timer.
>>> 		interrupts = <0 0 3 0
>>> 			      1 0 3 0
>>> 			      2 0 3 0
>>> 		              3 0 3 0>;
>>>
>>> The "interrupts" just let user know there are four timers. Usage based
>> "interrupts"
>>> binding to change dts.
>>
>> I can't understand the above or how it's a response to what I wrote.
>>
> [Wang Dongsheng] I mean this just to tell how many timers to support in Open-PIC
> specification. If someone needs to write "interrupts" into dts, this must comply
> with the specification of the interrupt to write. this is based on the pic driver
> should be changed in different platforms.

My point (beyond that examples provided should be valid for *some*
system) is there is no valid thing to put in the interrupts property
here when the interrupt controller is not "fsl,mpic", so this doesn't work.

-Scott

^ permalink raw reply

* Re: [PATCH v7 0/8] Raid: enable talitos xor offload for improving performance
From: Dan Williams @ 2012-08-14 20:01 UTC (permalink / raw)
  To: Liu Qiang-B32616
  Cc: herbert@gondor.apana.org.au, arnd@arndb.de, Ira W. Snyder,
	vinod.koul@intel.com, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	dan.j.williams@intel.com, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <BCB48C05FCE8BC4D9E61E841ECBE6DB70E3D47@039-SN2MPN1-013.039d.mgd.msft.net>

On Tue, Aug 14, 2012 at 2:04 AM, Liu Qiang-B32616 <B32616@freescale.com> wrote:
> Hi Vinod,
>
> Would you like to apply this series from patch 2/8 to 7/8) in your tree?
> The link as below,
> http://patchwork.ozlabs.org/patch/176023/
> http://patchwork.ozlabs.org/patch/176024/
> http://patchwork.ozlabs.org/patch/176025/
> http://patchwork.ozlabs.org/patch/176026/
> http://patchwork.ozlabs.org/patch/176027/
> http://patchwork.ozlabs.org/patch/176028/
>

Hi, sorry for the recent silence I've been transitioning and am now
just catching up.  I'll take a look and then it's fine for these to go
through Vinod's tree.

--
Dan

^ permalink raw reply

* [PATCH 5/5] arch/powerpc/platforms/powernv/pci.c: Remove potential NULL dereferences
From: Julia Lawall @ 2012-08-14 15:49 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Paul Mackerras, kernel-janitors, linuxppc-dev, linux-kernel
In-Reply-To: <1344959388-19719-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <Julia.Lawall@lip6.fr>

If the NULL test is necessary, the initialization involving a dereference of
the tested value should be moved after the NULL test.

The sematic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
expression E;
identifier i,fld;
statement S;
@@

- T i = E->fld;
+ T i;
  ... when != E
      when != i
  if (E == NULL) S
+ i = E->fld;
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 arch/powerpc/platforms/powernv/pci.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index be3cfc5..928e97b 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -287,12 +287,13 @@ static int pnv_pci_read_config(struct pci_bus *bus,
 			       int where, int size, u32 *val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
-	struct pnv_phb *phb = hose->private_data;
+	struct pnv_phb *phb;
 	u32 bdfn = (((uint64_t)bus->number) << 8) | devfn;
 	s64 rc;
 
 	if (hose == NULL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
+	phb = hose->private_data;
 
 	switch (size) {
 	case 1: {
@@ -331,11 +332,12 @@ static int pnv_pci_write_config(struct pci_bus *bus,
 				int where, int size, u32 val)
 {
 	struct pci_controller *hose = pci_bus_to_host(bus);
-	struct pnv_phb *phb = hose->private_data;
+	struct pnv_phb *phb;
 	u32 bdfn = (((uint64_t)bus->number) << 8) | devfn;
 
 	if (hose == NULL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
+	phb = hose->private_data;
 
 	cfg_dbg("pnv_pci_write_config bus: %x devfn: %x +%x/%x -> %08x\n",
 		bus->number, devfn, where, size, val);

^ permalink raw reply related

* [PATCH] Powerpc 8xx CPM_UART desynchronisation
From: Christophe Leroy @ 2012-08-14 14:26 UTC (permalink / raw)
  To: Alan Cox, Vitaly Bordug, Marcelo Tosatti
  Cc: linuxppc-dev, linux-kernel, linux-serial

Hello,

I'm not sure who to address this Patch to.

It fixes a desynchronisation problem with CPM UART driver on Powerpc MPC8xx.
The problem happens if data is received before the device is open by the user application.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

--- linux-3.5-vanilla/drivers/tty/serial/cpm_uart/cpm_uart_core.c	2012-07-21 22:58:29.000000000 +0200
+++ linux-3.5/drivers/tty/serial/cpm_uart/cpm_uart_core.c	2012-08-09 17:38:37.000000000 +0200
@@ -417,6 +417,7 @@
 			clrbits32(&pinfo->sccp->scc_gsmrl, SCC_GSMRL_ENR);
 			clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_RX);
 		}
+		cpm_uart_initbd(pinfo);
 		cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
 	}
 	/* Install interrupt handler. */

^ permalink raw reply

* [PATCH] Powerpc 8xx CPM_UART delay in receive
From: Christophe Leroy @ 2012-08-14 14:26 UTC (permalink / raw)
  To: Alan Cox, Vitaly Bordug, Marcelo Tosatti
  Cc: linuxppc-dev, linux-kernel, linux-serial

Hello,

I'm not sure who to address this Patch to either

It fixes a delay issue with CPM UART driver on Powerpc MPC8xx.
The problem is that with the actual code, the driver waits 32 IDLE patterns before returning the received data to the upper level. It means for instance about 1 second at 300 bauds.
This fix limits to one byte the waiting period.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

--- linux-3.5-vanilla/drivers/tty/serial/cpm_uart/cpm_uart_core.c	2012-07-21 22:58:29.000000000 +0200
+++ linux-3.5/drivers/tty/serial/cpm_uart/cpm_uart_core.c	2012-08-09 17:38:37.000000000 +0200
@@ -798,7 +799,7 @@
 	cpm_set_scc_fcr(sup);
 
 	out_be16(&sup->scc_genscc.scc_mrblr, pinfo->rx_fifosize);
-	out_be16(&sup->scc_maxidl, pinfo->rx_fifosize);
+	out_be16(&sup->scc_maxidl, 1);
 	out_be16(&sup->scc_brkcr, 1);
 	out_be16(&sup->scc_parec, 0);
 	out_be16(&sup->scc_frmec, 0);
@@ -872,7 +873,7 @@
 
 	/* Using idle character time requires some additional tuning.  */
 	out_be16(&up->smc_mrblr, pinfo->rx_fifosize);
-	out_be16(&up->smc_maxidl, pinfo->rx_fifosize);
+	out_be16(&up->smc_maxidl, 1);
 	out_be16(&up->smc_brklen, 0);
 	out_be16(&up->smc_brkec, 0);
 	out_be16(&up->smc_brkcr, 1);

^ permalink raw reply

* Re: [PATCH] Powerpc 8xx CPM_UART delay in receive
From: Alan Cox @ 2012-08-14 14:52 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Marcelo Tosatti, linux-kernel, linux-serial, linuxppc-dev,
	Alan Cox
In-Reply-To: <201208141426.q7EEQSPc003956@localhost.localdomain>

On Tue, 14 Aug 2012 16:26:28 +0200
Christophe Leroy <christophe.leroy@c-s.fr> wrote:

> Hello,
> 
> I'm not sure who to address this Patch to either
> 
> It fixes a delay issue with CPM UART driver on Powerpc MPC8xx.
> The problem is that with the actual code, the driver waits 32 IDLE patterns before returning the received data to the upper level. It means for instance about 1 second at 300 bauds.
> This fix limits to one byte the waiting period.

Take a look how the 8250 does it - I think you want to set the value
based upon the data rate. Your patch will break it for everyone doing
high seed I/O.

Alan

^ permalink raw reply

* [PATCH 3/5] drivers/net/ethernet/freescale/fs_enet: fix error return code
From: Julia Lawall @ 2012-08-14 12:58 UTC (permalink / raw)
  To: Pantelis Antoniou
  Cc: linuxppc-dev, kernel-janitors, linux-kernel, Vitaly Bordug,
	netdev
In-Reply-To: <1344949115-13266-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <Julia.Lawall@lip6.fr>

Convert a 0 error return code to a negative one, as returned elsewhere in the
function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret;
expression e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c |    4 +++-
 drivers/net/ethernet/freescale/fs_enet/mii-fec.c     |    8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c b/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
index 0f2d1a7..1514533 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
@@ -174,8 +174,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
 
 	new_bus->phy_mask = ~0;
 	new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
-	if (!new_bus->irq)
+	if (!new_bus->irq) {
+		ret = -ENOMEM;
 		goto out_unmap_regs;
+	}
 
 	new_bus->parent = &ofdev->dev;
 	dev_set_drvdata(&ofdev->dev, new_bus);
diff --git a/drivers/net/ethernet/freescale/fs_enet/mii-fec.c b/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
index 55bb867..cdf702a 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
@@ -137,8 +137,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
 	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start);
 
 	fec->fecp = ioremap(res.start, resource_size(&res));
-	if (!fec->fecp)
+	if (!fec->fecp) {
+		ret = -ENOMEM;
 		goto out_fec;
+	}
 
 	if (get_bus_freq) {
 		clock = get_bus_freq(ofdev->dev.of_node);
@@ -172,8 +174,10 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
 
 	new_bus->phy_mask = ~0;
 	new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
-	if (!new_bus->irq)
+	if (!new_bus->irq) {
+		ret = -ENOMEM;
 		goto out_unmap_regs;
+	}
 
 	new_bus->parent = &ofdev->dev;
 	dev_set_drvdata(&ofdev->dev, new_bus);

^ permalink raw reply related

* Re: [PATCH 2/4] fsl_pmc: Add API to enable device as wakeup event source
From: Tabi Timur-B04825 @ 2012-08-14 12:27 UTC (permalink / raw)
  To: Zhao Chenhui-B35336
  Cc: linux-kernel@vger.kernel.org, Li Yang-R58472,
	linuxppc-dev@lists.ozlabs.org, Zhao Chenhui-B35336
In-Reply-To: <20120814100141.GB21028@localhost.localdomain>

Zhao Chenhui wrote:
>>> > >+#ifdef CONFIG_FSL_PMC
>>> > >+extern int mpc85xx_pmc_set_wake(struct device *dev, bool enable);
>>> > >+extern void mpc85xx_pmc_set_lossless_ethernet(int enable);
>> >
>> >Don't use 'extern' for functions.
>> >
> Why? I think there is no difference.

It's unnecessary, and it makes the line longer.

--=20
Timur Tabi
Linux kernel developer at Freescale=

^ permalink raw reply

* Re: [PATCH 2/4] fsl_pmc: Add API to enable device as wakeup event source
From: Zhao Chenhui @ 2012-08-14 10:01 UTC (permalink / raw)
  To: Tabi Timur-B04825
  Cc: Li Yang-R58472, Zhao Chenhui-B35336, linux-kernel@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org
In-Reply-To: <CAOZdJXXdgS5x2ZkuXb4wHckdqLzSM2xy-eYU3+28d_=JH3euxg@mail.gmail.com>

On Sat, Aug 11, 2012 at 08:19:43AM -0500, Tabi Timur-B04825 wrote:
> On Tue, Aug 7, 2012 at 3:43 AM, Zhao Chenhui <chenhui.zhao@freescale.com> wrote:
> 
> > +int mpc85xx_pmc_set_wake(struct device *dev, bool enable)
> > +{
> > +       int ret = 0;
> > +       struct device_node *clk_np;
> > +       const u32 *prop;
> > +       u32 pmcdr_mask;
> > +
> > +       if (!pmc_regs) {
> > +               pr_err("%s: PMC is unavailable\n", __func__);
> 
> You have a 'struct device', so please use dev_err instead.
> 
> > +               return -ENODEV;
> > +       }
> > +
> > +       if (enable && !device_may_wakeup(dev))
> > +               return -EINVAL;
> > +
> > +       clk_np = of_parse_phandle(dev->of_node, "fsl,pmc-handle", 0);
> > +       if (!clk_np)
> > +               return -EINVAL;
> > +
> > +       prop = of_get_property(clk_np, "fsl,pmcdr-mask", NULL);
> > +       if (!prop) {
> > +               ret = -EINVAL;
> > +               goto out;
> > +       }
> > +       pmcdr_mask = be32_to_cpup(prop);
> > +
> > +       if (enable)
> > +               /* clear to enable clock in low power mode */
> > +               clrbits32(&pmc_regs->pmcdr, pmcdr_mask);
> > +       else
> > +               setbits32(&pmc_regs->pmcdr, pmcdr_mask);
> > +
> > +out:
> > +       of_node_put(clk_np);
> > +       return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(mpc85xx_pmc_set_wake);
> 
> Use EXPORT_SYMBOL, not EXPORT_SYMBOL_GPL.
> 
> > +
> > +/**
> > + * mpc85xx_pmc_set_lossless_ethernet - enable lossless ethernet
> > + * in (deep) sleep mode
> > + * @enable: True to enable event generation; false to disable
> > + */
> > +void mpc85xx_pmc_set_lossless_ethernet(int enable)
> 
> Should this be 'bool enable'?
> 
> > @@ -21,6 +22,17 @@ struct device_node;
> >
> >  extern void fsl_rstcr_restart(char *cmd);
> >
> > +#ifdef CONFIG_FSL_PMC
> > +extern int mpc85xx_pmc_set_wake(struct device *dev, bool enable);
> > +extern void mpc85xx_pmc_set_lossless_ethernet(int enable);
> 
> Don't use 'extern' for functions.
> 

Why? I think there is no difference.

-Chenhui

^ permalink raw reply

* Re: [PATCH 2/4] fsl_pmc: Add API to enable device as wakeup event source
From: Zhao Chenhui @ 2012-08-14  9:58 UTC (permalink / raw)
  To: galak
  Cc: Li Yang-R58472, Zhao Chenhui-B35336, B04825,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <CAOZdJXXdgS5x2ZkuXb4wHckdqLzSM2xy-eYU3+28d_=JH3euxg@mail.gmail.com>

On Sat, Aug 11, 2012 at 08:19:43AM -0500, Tabi Timur-B04825 wrote:
> On Tue, Aug 7, 2012 at 3:43 AM, Zhao Chenhui <chenhui.zhao@freescale.com> wrote:
> 
> > +               return -EINVAL;
> > +
> > +       prop = of_get_property(clk_np, "fsl,pmcdr-mask", NULL);
> > +       if (!prop) {
> > +               ret = -EINVAL;
> > +               goto out;
> > +       }
> > +       pmcdr_mask = be32_to_cpup(prop);
> > +
> > +       if (enable)
> > +               /* clear to enable clock in low power mode */
> > +               clrbits32(&pmc_regs->pmcdr, pmcdr_mask);
> > +       else
> > +               setbits32(&pmc_regs->pmcdr, pmcdr_mask);
> > +
> > +out:
> > +       of_node_put(clk_np);
> > +       return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(mpc85xx_pmc_set_wake);
> 
> Use EXPORT_SYMBOL, not EXPORT_SYMBOL_GPL.
> 

Hi kumar,

Is that ok with upstream?

-Chenhui

^ permalink raw reply

* RE: [PATCH v7 0/8] Raid: enable talitos xor offload for improving performance
From: Liu Qiang-B32616 @ 2012-08-14  9:04 UTC (permalink / raw)
  To: dan.j.williams@intel.com, vinod.koul@intel.com,
	dan.j.williams@gmail.com, arnd@arndb.de,
	herbert@gondor.apana.org.au, gregkh@linuxfoundation.org
  Cc: Ira W. Snyder, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
In-Reply-To: <20120809170307.GG14264@ovro.caltech.edu>

Hi Vinod,

Would you like to apply this series from patch 2/8 to 7/8) in your tree?
The link as below,
http://patchwork.ozlabs.org/patch/176023/
http://patchwork.ozlabs.org/patch/176024/
http://patchwork.ozlabs.org/patch/176025/
http://patchwork.ozlabs.org/patch/176026/
http://patchwork.ozlabs.org/patch/176027/
http://patchwork.ozlabs.org/patch/176028/

After that, Herbert will merge patch 1/8, http://patchwork.ozlabs.org/patch=
/176022/
and Greg apply patch 8/8, http://patchwork.ozlabs.org/patch/176029/

Thanks.
=20

> -----Original Message-----
> From: Ira W. Snyder [mailto:iws@ovro.caltech.edu]
> Sent: Friday, August 10, 2012 1:03 AM
> To: Liu Qiang-B32616
> Cc: linux-crypto@vger.kernel.org; vinod.koul@intel.com;
> dan.j.williams@intel.com; herbert@gondor.hengli.com.au; arnd@arndb.de;
> gregkh@linuxfoundation.org; linuxppc-dev@lists.ozlabs.org; linux-
> kernel@vger.kernel.org; dan.j.williams@gmail.com
> Subject: Re: [PATCH v7 0/8] Raid: enable talitos xor offload for
> improving performance
>=20
> On Thu, Aug 09, 2012 at 04:19:35PM +0800, qiang.liu@freescale.com wrote:
> > Hi all,
> >
> > The following 8 patches enabling fsl-dma and talitos offload raid
> > operations for improving raid performance and balancing CPU load.
> >
> > These patches include talitos, fsl-dma and carma module (caram uses
> > some features of fsl-dma).
> >
> > Write performance will be improved by 25-30% tested by iozone.
> > Write performance is improved about 2% after using spin_lock_bh
> > replace spin_lock_irqsave.
> > CPU load will be reduced by 8%.
> >
> > "fwiw, I gave v5 a test-drive, setting up a RAID5 array on ramdisks
> > [1], and this patchseries, along with FSL_DMA && NET_DMA set seems to
> > be holding water, so this series gets my:"
> >
> > Tested-by: Kim Phillips <kim.phillips@freescale.com>
> >
>=20
> The fsldma parts of the series all look great to me.
>=20
> Thanks,
> Ira
>=20
> > [1] mdadm --create --verbose --force /dev/md0 --level=3Draid5 --raid-
> devices=3D4 \
> > 	/dev/ram[0123]
> >
> > Changes in v7:
> > 	- add test result which is provided by Kim Phillips;
> > 	- correct one coding style issue in patch 5/8;
> > 	- add comments by Arnd Bergmann in patch 6/8;
> >
> > Changes in v6:
> > 	- swap the order of original patch 3/6 and 4/6;
> > 	- merge Ira's patch to reduce the size of original patch;
> > 	- merge Ira's patch of carma in 8/8;
> > 	- update documents and descriptions according to Ira's advice;
> >
> > Changes in v5:
> > 	- add detail description in patch 3/6 about the process of
> completed
> > 	descriptor, the process is in align with fsl-dma Reference Manual,
> > 	illustrate the potential risk and how to reproduce it;
> > 	- drop the patch 7/7 in v4 according to Timur's comments;
> >
> > Changes in v4:
> > 	- fix an error in talitos when dest addr is same with src addr,
> dest
> > 	should be freed only one time if src is same with dest addr;
> > 	- correct coding style in fsl-dma according to Ira's comments;
> > 	- fix a race condition in fsl-dma fsl_tx_status(), remove the
> interface
> > 	which is used to free descriptors in queue ld_completed, this
> interface
> > 	has been included in fsldma_cleanup_descriptor(), in v3, there is
> one
> > 	place missed spin_lock protect;
> > 	- split the original patch 3/4 up to 2 patches 3/7 and 4/7
> according to
> > 	Li Yang's comments;
> > 	- fix a warning of unitialized cookie;
> > 	- add memory copy self test in fsl-dma;
> > 	- add more detail description about use spin_lock_bh() to instead
> of
> > 	spin_lock_irqsave() according to Timur's comments.
> >
> > Changes in v3:
> > 	- change release process of fsl-dma descriptor for resolve the
> > 	potential race condition;
> > 	- add test result when use spin_lock_bh replace spin_lock_irqsave;
> > 	- modify the benchmark results according to the latest patch.
> >
> > Changes in v2:
> > 	- rebase onto cryptodev tree;
> > 	- split the patch 3/4 up to 3 independent patches;
> > 	- remove the patch 4/4, the fix is not for cryptodev tree;
> >
> > Qiang Liu (8):
> >       Talitos: Support for async_tx XOR offload
> >       fsl-dma: remove attribute DMA_INTERRUPT of dmaengine
> >       fsl-dma: add fsl_dma_free_descriptor() to reduce code duplication
> >       fsl-dma: move functions to avoid forward declarations
> >       fsl-dma: change release process of dma descriptor for supporting
> async_tx
> >       fsl-dma: use spin_lock_bh to instead of spin_lock_irqsave
> >       fsl-dma: fix a warning of unitialized cookie
> >       carma: remove unnecessary DMA_INTERRUPT capability
> >
> >  drivers/crypto/Kconfig                  |    9 +
> >  drivers/crypto/talitos.c                |  413
> ++++++++++++++++++++++++++
> >  drivers/crypto/talitos.h                |   53 ++++
> >  drivers/dma/fsldma.c                    |  488 +++++++++++++++++------
> --------
> >  drivers/dma/fsldma.h                    |   17 +-
> >  drivers/misc/carma/carma-fpga-program.c |    1 -
> >  drivers/misc/carma/carma-fpga.c         |    2 +-
> >  7 files changed, 761 insertions(+), 222 deletions(-)
> >
> > _______________________________________________
> > Linuxppc-dev mailing list
> > Linuxppc-dev@lists.ozlabs.org
> > https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* RE: [PATCH v2 1/2] powerpc/mpic: Add Open-PIC global timer document
From: Wang Dongsheng-B40534 @ 2012-08-14  2:40 UTC (permalink / raw)
  To: Wood Scott-B07421
  Cc: Li Yang-R58472, devicetree-discuss@lists.ozlabs.org,
	paulus@samba.org, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org
In-Reply-To: <50293BEA.90401@freescale.com>

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogV29vZCBTY290dC1CMDc0
MjENCj4gU2VudDogVHVlc2RheSwgQXVndXN0IDE0LCAyMDEyIDE6NDAgQU0NCj4gVG86IFdhbmcg
RG9uZ3NoZW5nLUI0MDUzNA0KPiBDYzogV29vZCBTY290dC1CMDc0MjE7IGJlbmhAa2VybmVsLmNy
YXNoaW5nLm9yZzsgcGF1bHVzQHNhbWJhLm9yZzsNCj4gbGludXhwcGMtZGV2QGxpc3RzLm96bGFi
cy5vcmc7IGRldmljZXRyZWUtZGlzY3Vzc0BsaXN0cy5vemxhYnMub3JnOyBHYWxhDQo+IEt1bWFy
LUIxMTc4MDsgTGkgWWFuZy1SNTg0NzINCj4gU3ViamVjdDogUmU6IFtQQVRDSCB2MiAxLzJdIHBv
d2VycGMvbXBpYzogQWRkIE9wZW4tUElDIGdsb2JhbCB0aW1lcg0KPiBkb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cHQgdG8gd3JpdGUuIHRoaXMgaXMgYmFzZWQgb24gdGhl
IHBpYyBkcml2ZXINCnNob3VsZCBiZSBjaGFuZ2VkIGluIGRpZmZlcmVudCBwbGF0Zm9ybXMuDQoN
Cj4gLVNjb3R0DQoNCg==

^ permalink raw reply

* RE: [PATCH v2 2/2] powerpc/mpic: add global timer support
From: Wang Dongsheng-B40534 @ 2012-08-14  2:32 UTC (permalink / raw)
  To: Wood Scott-B07421
  Cc: Gala Kumar-B11780, paulus@samba.org,
	linuxppc-dev@lists.ozlabs.org, Li Yang-R58472
In-Reply-To: <5029B576.7070900@freescale.com>

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogV29vZCBTY290dC1CMDc0
MjENCj4gU2VudDogVHVlc2RheSwgQXVndXN0IDE0LCAyMDEyIDEwOjE5IEFNDQo+IFRvOiBXYW5n
IERvbmdzaGVuZy1CNDA1MzQNCj4gQ2M6IFdvb2QgU2NvdHQtQjA3NDIxOyBiZW5oQGtlcm5lbC5j
cmFzaGluZy5vcmc7IHBhdWx1c0BzYW1iYS5vcmc7DQo+IGxpbnV4cHBjLWRldkBsaXN0cy5vemxh
YnMub3JnOyBHYWxhIEt1bWFyLUIxMTc4MDsgTGkgWWFuZy1SNTg0NzINCj4gU3ViamVjdDogUmU6
IFtQQVRDSCB2MiAyLzJdIHBvd2VycGMvbXBpYzogYWRkIGdsb2JhbCB0aW1lciBzdXBwb3J0DQo+
IA0KPiBPbiAwOC8xMy8yMDEyIDA5OjE1IFBNLCBXYW5nIERvbmdzaGVuZy1CNDA1MzQgd3JvdGU6
DQo+ID4NCj4gPg0KPiA+PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiA+PiBGcm9tOiBX
b29kIFNjb3R0LUIwNzQyMQ0KPiA+PiBTZW50OiBUdWVzZGF5LCBBdWd1c3QgMTQsIDIwMTIgMTA6
MDUgQU0NCj4gPj4gVG86IFdhbmcgRG9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oYXZlIHRoZXNlIG5ldyBvcGVu
cGljIHRpbWVyIG5vZGVzPw0KPiA+Pg0KPiA+IFtXYW5nIERvbmdzaGVuZ10gSXQncyBzdXBwb3J0
IHRvIHBvd2VyIG1hbmFnZW1lbnQgYXdha2VuaW5nLiBBdA0KPiA+IHByZXNlbnQsIHRoZSBwb3dl
ciBtYW5hZ2VtZW50IG1vcmUgYW5kIG1vcmUgaW1wb3J0YW50LiBUaGlzIHdheSBpcw0KPiA+IGlt
cG9ydGFudCB0byB3YWtlIHVwIG1hY2hpbmUuIEF0IGxlYXN0IG5lZWQgc3VwcG9ydCBwb3dlciBt
YW5hZ2VtZW50DQo+ID4gb2YgbWFjaGluZSBzdGlsbCBuZWVkcyBzdWNoIGEgZHJpdmVyLg0KPiAN
Cj4gSSBtZWFuIHNwZWNpZmljYWxseSBmb3IgdGhlIG5vbi1GcmVlc2NhbGUgb3BlbnBpYyBub2Rl
cy4NCj4gDQpbV2FuZyBEb25nc2hlbmddIEkgdGhpbmsgbm9uLUZyZWVzY2FsZSBjaGlwcyBjYW4g
YWxzbyB1c2UgdGhpcyBmdW5jdGlvbg0KdG8gd2FrZSB1cCB0aGUgbWFjaGluZS4gQW5kIFRoZXJl
IGlzIGFsc28gYW4gaW1wb3J0YW50IGZlYXR1cmUsIEl0IGNhbiANCnBlcmlvZGljYWxseSBnZW5l
cmF0ZSBhbiBpbnRlcnJ1cHQuIEZvciBleGFtcGxlLCB0aGUgbmV0d29yayBwZXJpb2RpY2FsbHkN
CmNoZWNrIHRoZSBoYXJkd2FyZSBkZXZpY2UobGluayBzdGF0dXMpLg0KPiAtU2NvdHQNCg0K

^ permalink raw reply

* Re: [PATCH v2 2/2] powerpc/mpic: add global timer support
From: Scott Wood @ 2012-08-14  2:18 UTC (permalink / raw)
  To: Wang Dongsheng-B40534
  Cc: Wood Scott-B07421, Li Yang-R58472, paulus@samba.org,
	Gala Kumar-B11780, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <ABB05CD9C9F68C46A5CEDC7F15439259DB19CF@039-SN2MPN1-022.039d.mgd.msft.net>

On 08/13/2012 09:15 PM, Wang Dongsheng-B40534 wrote:
> 
> 
>> -----Original Message-----
>> From: Wood Scott-B07421
>> Sent: Tuesday, August 14, 2012 10:05 AM
>> To: Wang Dongsheng-B40534
>> Cc: Wood Scott-B07421; benh@kernel.crashing.org; paulus@samba.org;
>> linuxppc-dev@lists.ozlabs.org; Gala Kumar-B11780; Li Yang-R58472
>> Subject: Re: [PATCH v2 2/2] powerpc/mpic: add global timer support
>>
>> On 08/13/2012 09:00 PM, Wang Dongsheng-B40534 wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Wood Scott-B07421
>>>> Sent: Tuesday, August 14, 2012 1:37 AM
>>>> To: Wang Dongsheng-B40534
>>>> Cc: Wood Scott-B07421; benh@kernel.crashing.org; paulus@samba.org;
>>>> linuxppc-dev@lists.ozlabs.org; Gala Kumar-B11780; Li Yang-R58472
>>>> Subject: Re: [PATCH v2 2/2] powerpc/mpic: add global timer support
>>>>
>>>> On 08/13/2012 01:18 AM, Wang Dongsheng-B40534 wrote:
>>>>>>> +	p = of_get_property(np, "available-ranges", &len);
>>>>>>> +	if (p && len % (2 * sizeof(u32)) != 0) {
>>>>>>> +		pr_err("%s: malformed fsl,available-ranges property.\n",
>>>>>>> +				np->full_name);
>>>>>>> +		return -EINVAL;
>>>>>>> +	}
>>>>>>
>>>>>> You need to support fsl,available-ranges since that's in an
>>>>>> accepted binding and people could have partitioned setups already
>> using it.
>>>>>>
>>>>> [Wang Dongsheng] FSL chip or OPEN-PIC specification(Only a group) in
>>>>> each group only four timer. This is unified. So i use a generic name.
>>>>> I think there is not compatible with existing mpic timer nodes.
>>>>
>>>> We need to be compatible with existing trees, so you'd need to check
>>>> for both -- but I think any further discussion of the details is
>>>> premature until we decide whether this is worthwhile to begin with
>>>> (both the support of non-FSL timers, and the creation of a new device
>>>> tree binding which will not be implemented by many of the machines
>>>> that have non-FSL openpic because they run real Open Firmware).
>>>>
>>> [Wang Dongsheng]
>>> 	p = of_get_property(np, "available-ranges", &len);
>>> 	if (!p)
>>> 		p = of_get_property(np, "fsl,available-ranges", &len);
>>>
>>> 	this code be compatible with existing trees.
>>
>> Yes, that's what I meant by checking both.
>>
>> I still think we need to discuss why we're doing this first.  What
>> specific machines are going to have these new openpic timer nodes?
>>
> [Wang Dongsheng] It's support to power management awakening. At present, 
> the power management more and more important. This way is important to wake
> up machine. At least need support power management of machine still needs
> such a driver.

I mean specifically for the non-Freescale openpic nodes.

-Scott

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox