linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wesley Cheng <quic_wcheng@quicinc.com>
To: <srinivas.kandagatla@linaro.org>, <mathias.nyman@intel.com>,
	<perex@perex.cz>, <lgirdwood@gmail.com>, <andersson@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <gregkh@linuxfoundation.org>,
	<Thinh.Nguyen@synopsys.com>, <broonie@kernel.org>,
	<bgoswami@quicinc.com>, <tiwai@suse.com>, <robh+dt@kernel.org>,
	<agross@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<alsa-devel@alsa-project.org>, <devicetree@vger.kernel.org>,
	<linux-usb@vger.kernel.org>, <quic_jackp@quicinc.com>,
	<quic_plai@quicinc.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [RFC PATCH v2 02/22] xhci: remove xhci_test_trb_in_td_math early development check
Date: Wed, 25 Jan 2023 19:14:04 -0800	[thread overview]
Message-ID: <20230126031424.14582-3-quic_wcheng@quicinc.com> (raw)
In-Reply-To: <20230126031424.14582-1-quic_wcheng@quicinc.com>

From: Mathias Nyman <mathias.nyman@linux.intel.com>

Time to remove this test trb in td math check that was added
in early stage of xhci driver deveopment.

It verified that the size, alignment and boundaries of the event and
command rings the driver itself allocated are correct.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci-mem.c | 160 ------------------------------------
 1 file changed, 160 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 679befa97c7a..bf9bb29f924b 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1929,164 +1929,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
 	xhci->usb3_rhub.bus_state.bus_suspended = 0;
 }
 
-static int xhci_test_trb_in_td(struct xhci_hcd *xhci,
-		struct xhci_segment *input_seg,
-		union xhci_trb *start_trb,
-		union xhci_trb *end_trb,
-		dma_addr_t input_dma,
-		struct xhci_segment *result_seg,
-		char *test_name, int test_number)
-{
-	unsigned long long start_dma;
-	unsigned long long end_dma;
-	struct xhci_segment *seg;
-
-	start_dma = xhci_trb_virt_to_dma(input_seg, start_trb);
-	end_dma = xhci_trb_virt_to_dma(input_seg, end_trb);
-
-	seg = trb_in_td(xhci, input_seg, start_trb, end_trb, input_dma, false);
-	if (seg != result_seg) {
-		xhci_warn(xhci, "WARN: %s TRB math test %d failed!\n",
-				test_name, test_number);
-		xhci_warn(xhci, "Tested TRB math w/ seg %p and "
-				"input DMA 0x%llx\n",
-				input_seg,
-				(unsigned long long) input_dma);
-		xhci_warn(xhci, "starting TRB %p (0x%llx DMA), "
-				"ending TRB %p (0x%llx DMA)\n",
-				start_trb, start_dma,
-				end_trb, end_dma);
-		xhci_warn(xhci, "Expected seg %p, got seg %p\n",
-				result_seg, seg);
-		trb_in_td(xhci, input_seg, start_trb, end_trb, input_dma,
-			  true);
-		return -1;
-	}
-	return 0;
-}
-
-/* TRB math checks for xhci_trb_in_td(), using the command and event rings. */
-static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci)
-{
-	struct {
-		dma_addr_t		input_dma;
-		struct xhci_segment	*result_seg;
-	} simple_test_vector [] = {
-		/* A zeroed DMA field should fail */
-		{ 0, NULL },
-		/* One TRB before the ring start should fail */
-		{ xhci->event_ring->first_seg->dma - 16, NULL },
-		/* One byte before the ring start should fail */
-		{ xhci->event_ring->first_seg->dma - 1, NULL },
-		/* Starting TRB should succeed */
-		{ xhci->event_ring->first_seg->dma, xhci->event_ring->first_seg },
-		/* Ending TRB should succeed */
-		{ xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16,
-			xhci->event_ring->first_seg },
-		/* One byte after the ring end should fail */
-		{ xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16 + 1, NULL },
-		/* One TRB after the ring end should fail */
-		{ xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT)*16, NULL },
-		/* An address of all ones should fail */
-		{ (dma_addr_t) (~0), NULL },
-	};
-	struct {
-		struct xhci_segment	*input_seg;
-		union xhci_trb		*start_trb;
-		union xhci_trb		*end_trb;
-		dma_addr_t		input_dma;
-		struct xhci_segment	*result_seg;
-	} complex_test_vector [] = {
-		/* Test feeding a valid DMA address from a different ring */
-		{	.input_seg = xhci->event_ring->first_seg,
-			.start_trb = xhci->event_ring->first_seg->trbs,
-			.end_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
-			.input_dma = xhci->cmd_ring->first_seg->dma,
-			.result_seg = NULL,
-		},
-		/* Test feeding a valid end TRB from a different ring */
-		{	.input_seg = xhci->event_ring->first_seg,
-			.start_trb = xhci->event_ring->first_seg->trbs,
-			.end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
-			.input_dma = xhci->cmd_ring->first_seg->dma,
-			.result_seg = NULL,
-		},
-		/* Test feeding a valid start and end TRB from a different ring */
-		{	.input_seg = xhci->event_ring->first_seg,
-			.start_trb = xhci->cmd_ring->first_seg->trbs,
-			.end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
-			.input_dma = xhci->cmd_ring->first_seg->dma,
-			.result_seg = NULL,
-		},
-		/* TRB in this ring, but after this TD */
-		{	.input_seg = xhci->event_ring->first_seg,
-			.start_trb = &xhci->event_ring->first_seg->trbs[0],
-			.end_trb = &xhci->event_ring->first_seg->trbs[3],
-			.input_dma = xhci->event_ring->first_seg->dma + 4*16,
-			.result_seg = NULL,
-		},
-		/* TRB in this ring, but before this TD */
-		{	.input_seg = xhci->event_ring->first_seg,
-			.start_trb = &xhci->event_ring->first_seg->trbs[3],
-			.end_trb = &xhci->event_ring->first_seg->trbs[6],
-			.input_dma = xhci->event_ring->first_seg->dma + 2*16,
-			.result_seg = NULL,
-		},
-		/* TRB in this ring, but after this wrapped TD */
-		{	.input_seg = xhci->event_ring->first_seg,
-			.start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
-			.end_trb = &xhci->event_ring->first_seg->trbs[1],
-			.input_dma = xhci->event_ring->first_seg->dma + 2*16,
-			.result_seg = NULL,
-		},
-		/* TRB in this ring, but before this wrapped TD */
-		{	.input_seg = xhci->event_ring->first_seg,
-			.start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
-			.end_trb = &xhci->event_ring->first_seg->trbs[1],
-			.input_dma = xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 4)*16,
-			.result_seg = NULL,
-		},
-		/* TRB not in this ring, and we have a wrapped TD */
-		{	.input_seg = xhci->event_ring->first_seg,
-			.start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3],
-			.end_trb = &xhci->event_ring->first_seg->trbs[1],
-			.input_dma = xhci->cmd_ring->first_seg->dma + 2*16,
-			.result_seg = NULL,
-		},
-	};
-
-	unsigned int num_tests;
-	int i, ret;
-
-	num_tests = ARRAY_SIZE(simple_test_vector);
-	for (i = 0; i < num_tests; i++) {
-		ret = xhci_test_trb_in_td(xhci,
-				xhci->event_ring->first_seg,
-				xhci->event_ring->first_seg->trbs,
-				&xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1],
-				simple_test_vector[i].input_dma,
-				simple_test_vector[i].result_seg,
-				"Simple", i);
-		if (ret < 0)
-			return ret;
-	}
-
-	num_tests = ARRAY_SIZE(complex_test_vector);
-	for (i = 0; i < num_tests; i++) {
-		ret = xhci_test_trb_in_td(xhci,
-				complex_test_vector[i].input_seg,
-				complex_test_vector[i].start_trb,
-				complex_test_vector[i].end_trb,
-				complex_test_vector[i].input_dma,
-				complex_test_vector[i].result_seg,
-				"Complex", i);
-		if (ret < 0)
-			return ret;
-	}
-	xhci_dbg(xhci, "TRB math tests passed.\n");
-	return 0;
-}
-
 static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
 {
 	u64 temp;
@@ -2506,8 +2348,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 					0, flags);
 	if (!xhci->event_ring)
 		goto fail;
-	if (xhci_check_trb_in_td_math(xhci) < 0)
-		goto fail;
 
 	ret = xhci_alloc_erst(xhci, xhci->event_ring, &xhci->erst, flags);
 	if (ret)

  parent reply	other threads:[~2023-01-26  3:14 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26  3:14 [RFC PATCH v2 00/22] Introduce QC USB SND audio offloading support Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 01/22] xhci: fix event ring segment table related masks and variables in header Wesley Cheng
2023-01-26  3:14 ` Wesley Cheng [this message]
2023-01-26  7:48   ` [RFC PATCH v2 02/22] xhci: remove xhci_test_trb_in_td_math early development check Greg KH
2023-01-26  3:14 ` [RFC PATCH v2 03/22] xhci: Refactor interrupter code for initial multi interrupter support Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 04/22] xhci: Add support to allocate several interrupters Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 05/22] usb: xhci: Add XHCI APIs to support USB offloading Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 06/22] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 07/22] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2023-01-26 15:32   ` Pierre-Louis Bossart
2023-01-30 22:36     ` Wesley Cheng
2023-01-28 13:26   ` Greg KH
2023-01-29  6:54     ` Zhou Furong
2023-01-29  7:09       ` Greg KH
2023-01-30  8:34         ` Zhou Furong
2023-01-30  9:27           ` Greg KH
2023-02-10 22:46     ` Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 08/22] ASoC: dt-bindings: Add USB_RX port Wesley Cheng
2023-01-26 11:55   ` Krzysztof Kozlowski
2023-01-30 21:52     ` Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 09/22] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2023-01-26 15:07   ` Srinivas Kandagatla
2023-01-26 15:38   ` Pierre-Louis Bossart
2023-01-30 22:54     ` Wesley Cheng
2023-01-30 23:59       ` Pierre-Louis Bossart
2023-02-01  2:40         ` Wesley Cheng
2023-02-01  3:02           ` Pierre-Louis Bossart
2023-02-03  1:23             ` Wesley Cheng
2023-02-03  1:44               ` Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 10/22] ASoC: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2023-01-26 15:09   ` Srinivas Kandagatla
2023-01-26  3:14 ` [RFC PATCH v2 11/22] ASoC: qcom: Add USB backend ASoC driver for Q6 Wesley Cheng
2023-01-26 15:44   ` Pierre-Louis Bossart
2023-01-30 22:59     ` Wesley Cheng
2023-01-30 23:50       ` Pierre-Louis Bossart
2023-01-26 16:35   ` Srinivas Kandagatla
2023-01-26  3:14 ` [RFC PATCH v2 12/22] sound: usb: card: Introduce USB SND platform op callbacks Wesley Cheng
2023-01-26 15:50   ` Pierre-Louis Bossart
2023-01-30 23:00     ` Wesley Cheng
2023-01-28 13:28   ` Greg KH
2023-02-10 22:49     ` Wesley Cheng
2023-02-28  2:59       ` Wesley Cheng
2023-02-28  7:30         ` Greg KH
2023-02-28  9:19           ` Wesley Cheng
2023-02-28 15:29             ` Greg KH
2023-02-20 17:11   ` Albert Wang
2023-01-26  3:14 ` [RFC PATCH v2 13/22] sound: usb: Export USB SND APIs for modules Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 14/22] dt-bindings: usb: dwc3: Add snps,num-hc-interrupters definition Wesley Cheng
2023-01-26 12:01   ` Krzysztof Kozlowski
2023-01-30 22:02     ` Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 15/22] usb: dwc3: Add DT parameter to specify maximum number of interrupters Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 16/22] sound: usb: Introduce QC USB SND offloading support Wesley Cheng
2023-01-26 16:07   ` Pierre-Louis Bossart
2023-01-28 13:32   ` Greg KH
2023-02-11  0:03     ` Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 17/22] sound: usb: card: Check for support for requested audio format Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 18/22] sound: soc: soc-usb: Add PCM format check API for USB backend Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 19/22] sound: soc: qcom: qusb6: Ensure PCM format is supported by USB audio device Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 20/22] sound: usb: Prevent starting of audio stream if in use Wesley Cheng
2023-01-26 16:12   ` Pierre-Louis Bossart
2023-02-07  1:15     ` Wesley Cheng
2023-02-07 13:29       ` Pierre-Louis Bossart
2023-02-11  9:52         ` Wesley Cheng
2023-02-13 15:22           ` Pierre-Louis Bossart
2023-02-13 20:12             ` Wesley Cheng
2023-01-26  3:14 ` [RFC PATCH v2 21/22] ASoC: dt-bindings: Add Q6USB backend bindings Wesley Cheng
2023-01-26 12:03   ` Krzysztof Kozlowski
2023-01-26 16:01   ` Srinivas Kandagatla
2023-01-26  3:14 ` [RFC PATCH v2 22/22] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2023-01-26 12:05   ` Krzysztof Kozlowski
2023-01-26  9:23 ` [RFC PATCH v2 00/22] Introduce QC USB SND audio offloading support Mathias Nyman
2023-01-30 21:51   ` Wesley Cheng
2023-01-26 16:22 ` Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230126031424.14582-3-quic_wcheng@quicinc.com \
    --to=quic_wcheng@quicinc.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=agross@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=bgoswami@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=perex@perex.cz \
    --cc=quic_jackp@quicinc.com \
    --cc=quic_plai@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).