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

Commit 83374e03 authored by Chunfeng Yun's avatar Chunfeng Yun Committed by Greg Kroah-Hartman
Browse files

usb: mtu3: add tracepoints to help debug



This patch implements a few initial tracepoints for the
mtu3 driver. More traces can be added as necessary in order
to ease the task of debugging.

Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4aab6ad2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,10 +2,17 @@

ccflags-$(CONFIG_USB_MTU3_DEBUG)	+= -DDEBUG

# define_trace.h needs to know how to find our header
CFLAGS_mtu3_trace.o	:= -I$(src)

obj-$(CONFIG_USB_MTU3)	+= mtu3.o

mtu3-y	:= mtu3_plat.o

ifneq ($(CONFIG_TRACING),)
	mtu3-y	+= mtu3_trace.o
endif

ifneq ($(filter y,$(CONFIG_USB_MTU3_HOST) $(CONFIG_USB_MTU3_DUAL_ROLE)),)
	mtu3-y	+= mtu3_host.o
endif
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

#include "mtu3.h"
#include "mtu3_debug.h"
#include "mtu3_trace.h"

static int ep_fifo_alloc(struct mtu3_ep *mep, u32 seg_size)
{
@@ -656,6 +657,8 @@ static irqreturn_t mtu3_link_isr(struct mtu3 *mtu)
		break;
	}
	dev_dbg(mtu->dev, "%s: %s\n", __func__, usb_speed_string(udev_speed));
	mtu3_dbg_trace(mtu->dev, "link speed %s",
		       usb_speed_string(udev_speed));

	mtu->g.speed = udev_speed;
	mtu->g.ep0->maxpacket = maxpkt;
@@ -678,6 +681,7 @@ static irqreturn_t mtu3_u3_ltssm_isr(struct mtu3 *mtu)
	ltssm &= mtu3_readl(mbase, U3D_LTSSM_INTR_ENABLE);
	mtu3_writel(mbase, U3D_LTSSM_INTR, ltssm); /* W1C */
	dev_dbg(mtu->dev, "=== LTSSM[%x] ===\n", ltssm);
	trace_mtu3_u3_ltssm_isr(ltssm);

	if (ltssm & (HOT_RST_INTR | WARM_RST_INTR))
		mtu3_gadget_reset(mtu);
@@ -708,6 +712,7 @@ static irqreturn_t mtu3_u2_common_isr(struct mtu3 *mtu)
	u2comm &= mtu3_readl(mbase, U3D_COMMON_USB_INTR_ENABLE);
	mtu3_writel(mbase, U3D_COMMON_USB_INTR, u2comm); /* W1C */
	dev_dbg(mtu->dev, "=== U2COMM[%x] ===\n", u2comm);
	trace_mtu3_u2_common_isr(u2comm);

	if (u2comm & SUSPEND_INTR)
		mtu3_gadget_suspend(mtu);
+8 −0
Original line number Diff line number Diff line
@@ -39,4 +39,12 @@ static inline void ssusb_debugfs_remove_root(struct ssusb_mtk *ssusb) {}

#endif /* CONFIG_DEBUG_FS */

#if IS_ENABLED(CONFIG_TRACING)
void mtu3_dbg_trace(struct device *dev, const char *fmt, ...);

#else
static inline void mtu3_dbg_trace(struct device *dev, const char *fmt, ...) {}

#endif /* CONFIG_TRACING */

#endif /* __MTU3_DEBUG_H__ */
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ static void ssusb_set_mailbox(struct otg_switch_mtk *otg_sx,
	struct mtu3 *mtu = ssusb->u3d;

	dev_dbg(ssusb->dev, "mailbox state(%d)\n", status);
	mtu3_dbg_trace(ssusb->dev, "mailbox %d", status);

	switch (status) {
	case MTU3_ID_GROUND:
+13 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
 */

#include "mtu3.h"
#include "mtu3_trace.h"

void mtu3_req_complete(struct mtu3_ep *mep,
		     struct usb_request *req, int status)
@@ -25,6 +26,8 @@ __acquires(mep->mtu->lock)

	mtu = mreq->mtu;
	mep->busy = 1;

	trace_mtu3_req_complete(mreq);
	spin_unlock(&mtu->lock);

	/* ep0 makes use of PIO, needn't unmap it */
@@ -201,6 +204,7 @@ static int mtu3_gadget_ep_enable(struct usb_ep *ep,
	spin_unlock_irqrestore(&mtu->lock, flags);

	dev_dbg(mtu->dev, "%s active_ep=%d\n", __func__, mtu->active_ep);
	trace_mtu3_gadget_ep_enable(mep);

	return ret;
}
@@ -212,6 +216,7 @@ static int mtu3_gadget_ep_disable(struct usb_ep *ep)
	unsigned long flags;

	dev_dbg(mtu->dev, "%s %s\n", __func__, mep->name);
	trace_mtu3_gadget_ep_disable(mep);

	if (!(mep->flags & MTU3_EP_ENABLED)) {
		dev_warn(mtu->dev, "%s is already disabled\n", mep->name);
@@ -242,13 +247,17 @@ struct usb_request *mtu3_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
	mreq->request.dma = DMA_ADDR_INVALID;
	mreq->epnum = mep->epnum;
	mreq->mep = mep;
	trace_mtu3_alloc_request(mreq);

	return &mreq->request;
}

void mtu3_free_request(struct usb_ep *ep, struct usb_request *req)
{
	kfree(to_mtu3_request(req));
	struct mtu3_request *mreq = to_mtu3_request(req);

	trace_mtu3_free_request(mreq);
	kfree(mreq);
}

static int mtu3_gadget_queue(struct usb_ep *ep,
@@ -316,6 +325,7 @@ static int mtu3_gadget_queue(struct usb_ep *ep,

error:
	spin_unlock_irqrestore(&mtu->lock, flags);
	trace_mtu3_gadget_queue(mreq);

	return ret;
}
@@ -333,6 +343,7 @@ static int mtu3_gadget_dequeue(struct usb_ep *ep, struct usb_request *req)
		return -EINVAL;

	dev_dbg(mtu->dev, "%s : req=%p\n", __func__, req);
	trace_mtu3_gadget_dequeue(mreq);

	spin_lock_irqsave(&mtu->lock, flags);

@@ -403,6 +414,7 @@ static int mtu3_gadget_ep_set_halt(struct usb_ep *ep, int value)

done:
	spin_unlock_irqrestore(&mtu->lock, flags);
	trace_mtu3_gadget_ep_set_halt(mep);

	return ret;
}
Loading