Unverified Commit 2b977914 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2489 Some optimizations for PTT driver

Merge Pull Request from: @lujunhuaHW 
 
This series contains several updates for PTT driver:

Disable interrupt when trace stops, reverse to what we do in trace start
Always handle the interrupt in hardirq context
Optimize the AUX buffer handling to make consumer have more time to process
the data
Since we're a uncore PMU so block any task attach operation 
 
Link:https://gitee.com/openeuler/kernel/pulls/2489

 

Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 7d7cb26c 6607fc0d
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -183,6 +183,10 @@ static void hisi_ptt_wait_dma_reset_done(struct hisi_ptt *hisi_ptt)
static void hisi_ptt_trace_end(struct hisi_ptt *hisi_ptt)
{
	writel(0, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);

	/* Mask the interrupt on the end */
	writel(HISI_PTT_TRACE_INT_MASK_ALL, hisi_ptt->iobase + HISI_PTT_TRACE_INT_MASK);

	hisi_ptt->trace_ctrl.started = false;
}

@@ -270,15 +274,14 @@ static int hisi_ptt_update_aux(struct hisi_ptt *hisi_ptt, int index, bool stop)
	buf->pos += size;

	/*
	 * Just commit the traced data if we're going to stop. Otherwise if the
	 * resident AUX buffer cannot contain the data of next trace buffer,
	 * apply a new one.
	 * Always commit the data to the AUX buffer in time to make sure
	 * userspace got enough time to consume the data.
	 *
	 * If we're not going to stop, apply a new one and check whether
	 * there's enough room for the next trace.
	 */
	if (stop) {
		perf_aux_output_end(handle, buf->pos);
	} else if (buf->length - buf->pos < HISI_PTT_TRACE_BUF_SIZE) {
		perf_aux_output_end(handle, buf->pos);

	perf_aux_output_end(handle, size);
	if (!stop) {
		buf = perf_aux_output_begin(handle, event);
		if (!buf)
			return -EINVAL;
@@ -342,9 +345,9 @@ static int hisi_ptt_register_irq(struct hisi_ptt *hisi_ptt)
		return ret;

	hisi_ptt->trace_irq = pci_irq_vector(pdev, HISI_PTT_TRACE_DMA_IRQ);
	ret = devm_request_threaded_irq(&pdev->dev, hisi_ptt->trace_irq,
					NULL, hisi_ptt_isr, 0,
					DRV_NAME, hisi_ptt);
	ret = devm_request_irq(&pdev->dev, hisi_ptt->trace_irq, hisi_ptt_isr,
				IRQF_NOBALANCING | IRQF_NO_THREAD, DRV_NAME,
				hisi_ptt);
	if (ret) {
		pci_err(pdev, "failed to request irq %d, ret = %d\n",
			hisi_ptt->trace_irq, ret);
@@ -1000,6 +1003,9 @@ static int hisi_ptt_pmu_event_init(struct perf_event *event)
		return -EOPNOTSUPP;
	}

	if (event->attach_state & PERF_ATTACH_TASK)
		return -EOPNOTSUPP;

	if (event->attr.type != hisi_ptt->hisi_ptt_pmu.type)
		return -ENOENT;

+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#define HISI_PTT_TRACE_INT_STAT		0x0890
#define   HISI_PTT_TRACE_INT_STAT_MASK	GENMASK(3, 0)
#define HISI_PTT_TRACE_INT_MASK		0x0894
#define   HISI_PTT_TRACE_INT_MASK_ALL	GENMASK(3, 0)
#define HISI_PTT_TUNING_INT_STAT	0x0898
#define   HISI_PTT_TUNING_INT_STAT_MASK	BIT(0)
#define HISI_PTT_TRACE_WR_STS		0x08a0