All of lore.kernel.org
 help / color / mirror / Atom feed
From: <sunpeng.li-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Yogesh Mohan Marimuthu
	<yogesh.mohanmarimuthu-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 01/16] drm/amd/display: fix sporadic multiple aux transaction failure
Date: Thu, 29 Nov 2018 10:52:08 -0500	[thread overview]
Message-ID: <1543506743-4674-2-git-send-email-sunpeng.li@amd.com> (raw)
In-Reply-To: <1543506743-4674-1-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>

From: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>

[why]
When there are multiple aux transaction in parallel, it is sometime
sporadically the aux transaction starts to continuously fail. The
aux transaction was failing because the busy bit for the given gpio
pin was always set. The busy bit was alway set because the
programming sequence to read, modify and write busy bit was not
atomic. Due to which when multiple threads are trying to modify the
busy bits for their gpio pins in the same integer variable sometimes
the busy bits integer variable is written with old data causing
failure.

[how]
Instead of using individual bits to track gpio pins and grouping
them to integers, one byte will be allcoated for each gpio pin.
Now whenever a gpio pin needs to be set to mark being used, only
writing a value of one to that byte is sufficient, other bytes
are not impacted. Also no need to have atomicity with bytes unlike
with bits.

Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
---
 drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | 65 ++++++----------------
 drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h |  7 +--
 2 files changed, 21 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
index f20161c..dada042 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
@@ -56,7 +56,6 @@ struct gpio_service *dal_gpio_service_create(
 	struct dc_context *ctx)
 {
 	struct gpio_service *service;
-
 	uint32_t index_of_id;
 
 	service = kzalloc(sizeof(struct gpio_service), GFP_KERNEL);
@@ -78,44 +77,33 @@ struct gpio_service *dal_gpio_service_create(
 		goto failure_1;
 	}
 
-	/* allocate and initialize business storage */
+	/* allocate and initialize busyness storage */
 	{
-		const uint32_t bits_per_uint = sizeof(uint32_t) << 3;
-
 		index_of_id = 0;
 		service->ctx = ctx;
 
 		do {
 			uint32_t number_of_bits =
 				service->factory.number_of_pins[index_of_id];
+			uint32_t i = 0;
 
-			uint32_t number_of_uints =
-				(number_of_bits + bits_per_uint - 1) /
-				bits_per_uint;
-
-			uint32_t *slot;
-
-			if (number_of_bits) {
-				uint32_t index_of_uint = 0;
+			if (number_of_bits)  {
+				service->busyness[index_of_id] =
+					kcalloc(number_of_bits, sizeof(char),
+						GFP_KERNEL);
 
-				slot = kcalloc(number_of_uints,
-					       sizeof(uint32_t),
-					       GFP_KERNEL);
-
-				if (!slot) {
+				if (!service->busyness[index_of_id]) {
 					BREAK_TO_DEBUGGER();
 					goto failure_2;
 				}
 
 				do {
-					slot[index_of_uint] = 0;
-
-					++index_of_uint;
-				} while (index_of_uint < number_of_uints);
-			} else
-				slot = NULL;
-
-			service->busyness[index_of_id] = slot;
+					service->busyness[index_of_id][i] = 0;
+					++i;
+				} while (i < number_of_bits);
+			} else {
+				service->busyness[index_of_id] = NULL;
+			}
 
 			++index_of_id;
 		} while (index_of_id < GPIO_ID_COUNT);
@@ -125,13 +113,8 @@ struct gpio_service *dal_gpio_service_create(
 
 failure_2:
 	while (index_of_id) {
-		uint32_t *slot;
-
 		--index_of_id;
-
-		slot = service->busyness[index_of_id];
-
-		kfree(slot);
+		kfree(service->busyness[index_of_id]);
 	}
 
 failure_1:
@@ -169,9 +152,7 @@ void dal_gpio_service_destroy(
 		uint32_t index_of_id = 0;
 
 		do {
-			uint32_t *slot = (*ptr)->busyness[index_of_id];
-
-			kfree(slot);
+			kfree((*ptr)->busyness[index_of_id]);
 
 			++index_of_id;
 		} while (index_of_id < GPIO_ID_COUNT);
@@ -192,11 +173,7 @@ static bool is_pin_busy(
 	enum gpio_id id,
 	uint32_t en)
 {
-	const uint32_t bits_per_uint = sizeof(uint32_t) << 3;
-
-	const uint32_t *slot = service->busyness[id] + (en / bits_per_uint);
-
-	return 0 != (*slot & (1 << (en % bits_per_uint)));
+	return service->busyness[id][en];
 }
 
 static void set_pin_busy(
@@ -204,10 +181,7 @@ static void set_pin_busy(
 	enum gpio_id id,
 	uint32_t en)
 {
-	const uint32_t bits_per_uint = sizeof(uint32_t) << 3;
-
-	service->busyness[id][en / bits_per_uint] |=
-		(1 << (en % bits_per_uint));
+	service->busyness[id][en] = true;
 }
 
 static void set_pin_free(
@@ -215,10 +189,7 @@ static void set_pin_free(
 	enum gpio_id id,
 	uint32_t en)
 {
-	const uint32_t bits_per_uint = sizeof(uint32_t) << 3;
-
-	service->busyness[id][en / bits_per_uint] &=
-		~(1 << (en % bits_per_uint));
+	service->busyness[id][en] = false;
 }
 
 enum gpio_result dal_gpio_service_open(
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h
index c7f3081..1d501a4 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h
+++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.h
@@ -36,10 +36,9 @@ struct gpio_service {
 	/*
 	 * @brief
 	 * Business storage.
-	 * For each member of 'enum gpio_id',
-	 * store array of bits (packed into uint32_t slots),
-	 * index individual bit by 'en' value */
-	uint32_t *busyness[GPIO_ID_COUNT];
+	 * one byte For each member of 'enum gpio_id'
+	 */
+	char *busyness[GPIO_ID_COUNT];
 };
 
 enum gpio_result dal_gpio_service_open(
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-11-29 15:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 15:52 [PATCH 00/16] DC Patches Nov 29, 2018 sunpeng.li-5C7GfCeVMHo
     [not found] ` <1543506743-4674-1-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-11-29 15:52   ` sunpeng.li-5C7GfCeVMHo [this message]
2018-11-29 15:52   ` [PATCH 02/16] drm/amd/display: 3.2.07 sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 03/16] drm/amd/display: Start documentation of DC sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 04/16] drm/amd/display: Add tracing to dc sunpeng.li-5C7GfCeVMHo
     [not found]     ` <1543506743-4674-5-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-11-29 15:56       ` Christian König
     [not found]         ` <3179d43f-1c48-3987-ba6d-ce70052cc07c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-11-30 14:57           ` [PATCH 04/16 v2] " David Francis
     [not found]             ` <20181130145706.5984-1-David.Francis-5C7GfCeVMHo@public.gmane.org>
2018-12-07  5:40               ` Kuehling, Felix
     [not found]                 ` <DM5PR12MB17077D9220A92FDC6007F4CC92AA0-2J9CzHegvk9TCtO+SvGBKwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-12-07 14:41                   ` Wentland, Harry
     [not found]                     ` <66a179f3-88e1-42c5-3e61-52aec61fa1ce-5C7GfCeVMHo@public.gmane.org>
2018-12-07 14:46                       ` Wentland, Harry
     [not found]                         ` <7ec7a6fc-a1d5-61e2-da46-2660b7b46281-5C7GfCeVMHo@public.gmane.org>
2018-12-07 20:32                           ` Kuehling, Felix
     [not found]                             ` <df1b475d-8562-ddf8-836f-f68e8418bc2e-5C7GfCeVMHo@public.gmane.org>
2018-12-14 19:31                               ` Wentland, Harry
     [not found]                                 ` <06229a96-2826-4947-f805-65a12cd07c4f-5C7GfCeVMHo@public.gmane.org>
2018-12-14 21:11                                   ` Kuehling, Felix
2018-11-29 15:52   ` [PATCH 05/16] drm/amd/display: Remove unused panel patch "disconnect_delay" sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 06/16] drm/amd/display: Fix spelling of axis in modules/color/color_gamma.c sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 07/16] drm/amd/display: CTS 4.2.2.7 sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 08/16] drm/amd/display: Info frame cleanup sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 09/16] drm/amd/display: fbc state could not reach while enable fbc sunpeng.li-5C7GfCeVMHo
     [not found]     ` <1543506743-4674-10-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-11-29 16:27       ` Deucher, Alexander
     [not found]         ` <BN6PR12MB18092FE3F45C1039E19F2F5AF7D20-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-11-29 18:23           ` Li, Roman
2018-11-29 15:52   ` [PATCH 10/16] drm/amd/display: Re-arrange GFX9 fields sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 11/16] drm/amd/display: Add customizable tracing event sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 12/16] drm/amd/display: Copy crc_enabled when duplicating dm_crtc_state sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 13/16] drm/amd/display: Program dithering if requested sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 14/16] drm/amd/display: Allow clock lower on dce100 sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 15/16] drm/amd/display: 3.2.08 sunpeng.li-5C7GfCeVMHo
2018-11-29 15:52   ` [PATCH 16/16] drm/amd/display: Clean up for DCN1 clock debug logging sunpeng.li-5C7GfCeVMHo

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=1543506743-4674-2-git-send-email-sunpeng.li@amd.com \
    --to=sunpeng.li-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=yogesh.mohanmarimuthu-5C7GfCeVMHo@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.