Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e6427f5 authored by Rama Aparna Mallavarapu's avatar Rama Aparna Mallavarapu
Browse files

coresight: tmc: Add usb support for coresight



Add support to enable USB mode for coresight devices.
Set memory as the default mode on ETR.

Change-Id: Id804fb819ad19b589a1b978ea0cd65b0265a9268
Signed-off-by: default avatarSatyajit Desai <sadesai@codeaurora.org>
Signed-off-by: default avatarRama Aparna Mallavarapu <aparnam@codeaurora.org>
parent b77e3d8c
Loading
Loading
Loading
Loading
+52 −28
Original line number Diff line number Diff line
@@ -379,14 +379,9 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
	spin_lock_irqsave(&drvdata->spinlock, flags);
	if (!drvdata->vaddr) {
		spin_unlock_irqrestore(&drvdata->spinlock, flags);

		/*
		 * Contiguous  memory can't be allocated while a spinlock is
		 * held.  As such allocate memory here and free it if a buffer
		 * has already been allocated (from a previous session).
		 */
		mutex_lock(&drvdata->mem_lock);

		if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM) {
			/*
			 * ETR DDR memory is not allocated until user enables
			 * tmc at least once. If user specifies different ETR
@@ -395,23 +390,36 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
			 * enabling tmc; the new selection will be honored from
			 * next tmc enable session.
			 */
		if (drvdata->size != drvdata->mem_size)
			if (drvdata->size != drvdata->mem_size ||
				drvdata->memtype != drvdata->mem_type) {
				tmc_etr_free_mem(drvdata);
				drvdata->size = drvdata->mem_size;
				drvdata->memtype = drvdata->mem_type;
			}

			ret = tmc_etr_alloc_mem(drvdata);
			if (ret) {
			pm_runtime_put(drvdata->dev);
				mutex_unlock(&drvdata->mem_lock);
				return ret;
			}
		} else {
			drvdata->usbch = usb_qdss_open("qdss", drvdata,
								usb_notifier);
			if (IS_ERR_OR_NULL(drvdata->usbch)) {
				dev_err(drvdata->dev, "usb_qdss_open failed\n");
				ret = PTR_ERR(drvdata->usbch);
				mutex_unlock(&drvdata->mem_lock);

		/* Let's try again */
				return ret;
			}
		}
		spin_lock_irqsave(&drvdata->spinlock, flags);
	}

	if (drvdata->reading) {
		ret = -EBUSY;
		spin_unlock_irqrestore(&drvdata->spinlock, flags);
		mutex_unlock(&drvdata->mem_lock);
		return ret;
		goto out;
	}

@@ -436,7 +444,11 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
	}

	drvdata->mode = CS_MODE_SYSFS;
	if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM)
		tmc_etr_enable_hw(drvdata);

	drvdata->enable = true;	828
	drvdata->sticky_enable = true;
out:
	spin_unlock_irqrestore(&drvdata->spinlock, flags);

@@ -444,6 +456,8 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
	if (!used && vaddr)
		dma_free_coherent(drvdata->dev, drvdata->size, vaddr, paddr);

	mutex_unlock(&drvdata->mem_lock);

	if (!ret)
		dev_info(drvdata->dev, "TMC-ETR enabled\n");

@@ -505,8 +519,14 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)
	}

	/* Disable the TMC only if it needs to */
	if (drvdata->mode != CS_MODE_DISABLED) {
	if (val != CS_MODE_DISABLED) {
		if (drvdata->out_mode == TMC_ETR_OUT_MODE_USB) {
			__tmc_etr_disable_to_bam(drvdata);
			tmc_etr_bam_disable(drvdata);
			usb_qdss_close(drvdata->usbch);
		} else {
			tmc_etr_disable_hw(drvdata);
		}
		drvdata->mode = CS_MODE_DISABLED;
	}

@@ -540,6 +560,10 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata)
		goto out;
	}

	if (drvdata->out_mode == TMC_ETR_OUT_MODE_USB) {
		ret = -EINVAL;
		goto out;
	}
	/* Don't interfere if operated from Perf */
	if (drvdata->mode == CS_MODE_PERF) {
		ret = -EINVAL;
+1 −0
Original line number Diff line number Diff line
@@ -576,6 +576,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
			drvdata->size = SZ_1M;

		drvdata->mem_size = drvdata->size;
		drvdata->out_mode = TMC_ETR_OUT_MODE_MEM;
	} else {
		drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4;
	}