From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [PATCH v2 6/7] drm/i915/dsi: Replace poking of CHV GPIOs behind the driver's back
Date: Wed, 1 Nov 2023 12:01:31 +0100 [thread overview]
Message-ID: <437a20fe-121e-0d8c-04a0-da30db71d2ea@redhat.com> (raw)
In-Reply-To: <f68dca47-d9ed-a146-b152-c19bcc9d8828@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2795 bytes --]
Hi,
On 11/1/23 11:20, Hans de Goede wrote:
> Hi,
>
> On 11/1/23 10:32, Andy Shevchenko wrote:
>> On Tue, Oct 31, 2023 at 10:15:52PM +0100, Hans de Goede wrote:
>>> On 10/31/23 17:07, Hans de Goede wrote:
>>>> On 10/24/23 18:11, Andy Shevchenko wrote:
>>>>> On Tue, Oct 24, 2023 at 06:57:38PM +0300, Andy Shevchenko wrote:
>>
>> ...
>>
>>>> As for the CHT support, I have not added that to my tree yet, I would
>>>> prefer to directly test the correct/fixed patch.
>>>
>>> And I hit the "jackpot" on the first device I tried and the code needed
>>> some fixing to actually work, so here is something to fold into v3 to
>>> fix things:
>>
>> Thanks!
>>
>> But let me first send current v3 as it quite differs to v2 in the sense
>> of how I do instantiate GPIO lookup tables.
>
> The problem is there already is a GPIO lookup table registered for
> the "0000:00:02.0" device by intel_dsi_vbt_gpio_init() and there can
> be only be one GPIO lookup table per device. So no matter how you
> instantiate GPIO lookup tables it will not work.
>
> The solution that I chose is to not instantiate a GPIO lookup table
> at all and instead to extend the existing table with an extra entry.
>
> Although thinking more about it I must admit that this is racy.
>
> So a better idea would be to unregister the GPIO lookup
> table registered by intel_dsi_vbt_gpio_init() after getting
> the GPIOs there, that would allow instantiating a new one
> from soc_exec_opaque_gpio() as it currently does and that
> would be race free.
>
>> Meanwhile I will look into the change you sent (and hopefully we can
>> incorporate something in v3 for v4).
>
> Ok, lets go with your v3.
>
> I'll prepare a patch to move the unregistering of the existing
> conflicting GPIO lookup from intel_dsi_vbt_gpio_cleanup()
> to the end of intel_dsi_vbt_gpio_init() to avoid the conflict
> we have there.
Attached is this patch, this should probably be one of
the first patches in the v3 submission.
Note that if you go with Ville's suggestion to preparse
the MIPI sequences, things will change significantly
and then the attached patch will likely be unnecessary.
Regards,
Hans
> Note you still need the first part of my patch which is
> an unrelated bugfix:
>
> --- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> +++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
> @@ -219,8 +219,7 @@ static void soc_exec_gpio(struct intel_connector *connector, const char *con_id,
> } else {
> gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
> con_id, gpio_index,
> - value ? GPIOD_OUT_LOW :
> - GPIOD_OUT_HIGH);
> + value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
> if (IS_ERR(gpio_desc)) {
> drm_err(&dev_priv->drm,
> "GPIO index %u request failed (%pe)\n",
>
> Regards,
>
> Hans
>
>
[-- Attachment #2: 0001-drm-i915-dsi-Remove-GPIO-lookup-table-at-the-end-of-.patch --]
[-- Type: text/x-patch, Size: 3701 bytes --]
From cb3cc656ad89d98824d38c07a35019c512227601 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 1 Nov 2023 11:54:18 +0100
Subject: [PATCH] drm/i915/dsi: Remove GPIO lookup table at the end of
intel_dsi_vbt_gpio_init()
To properly deal with GPIOs used in MIPI panel sequences a temporary
GPIO lookup will be used. Since there can only be 1 GPIO lookup table
for the "0000:00:02.0" device this will not work if the GPIO lookup
table used by intel_dsi_vbt_gpio_init() is still registered.
After getting the "backlight" and "panel" GPIOs the lookup table
registered by intel_dsi_vbt_gpio_init() is no longer necessary,
remove it so that another temporary lookup-table for the "0000:00:02.0"
device can be added.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 25 +++++++-------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
index cb64454932d1..d965ae1d2b08 100644
--- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
+++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c
@@ -922,6 +922,7 @@ void intel_dsi_vbt_gpio_init(struct intel_dsi *intel_dsi, bool panel_is_on)
struct intel_connector *connector = intel_dsi->attached_connector;
struct mipi_config *mipi_config = connector->panel.vbt.dsi.config;
enum gpiod_flags flags = panel_is_on ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
+ struct gpiod_lookup_table *gpiod_lookup_table = NULL;
bool want_backlight_gpio = false;
bool want_panel_gpio = false;
struct pinctrl *pinctrl;
@@ -929,12 +930,12 @@ void intel_dsi_vbt_gpio_init(struct intel_dsi *intel_dsi, bool panel_is_on)
if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
mipi_config->pwm_blc == PPS_BLC_PMIC) {
- gpiod_add_lookup_table(&pmic_panel_gpio_table);
+ gpiod_lookup_table = &pmic_panel_gpio_table;
want_panel_gpio = true;
}
if (IS_VALLEYVIEW(dev_priv) && mipi_config->pwm_blc == PPS_BLC_SOC) {
- gpiod_add_lookup_table(&soc_panel_gpio_table);
+ gpiod_lookup_table = &soc_panel_gpio_table;
want_panel_gpio = true;
want_backlight_gpio = true;
@@ -951,6 +952,9 @@ void intel_dsi_vbt_gpio_init(struct intel_dsi *intel_dsi, bool panel_is_on)
"Failed to set pinmux to PWM\n");
}
+ if (gpiod_lookup_table)
+ gpiod_add_lookup_table(gpiod_lookup_table);
+
if (want_panel_gpio) {
intel_dsi->gpio_panel = gpiod_get(dev->dev, "panel", flags);
if (IS_ERR(intel_dsi->gpio_panel)) {
@@ -969,15 +973,13 @@ void intel_dsi_vbt_gpio_init(struct intel_dsi *intel_dsi, bool panel_is_on)
intel_dsi->gpio_backlight = NULL;
}
}
+
+ if (gpiod_lookup_table)
+ gpiod_remove_lookup_table(gpiod_lookup_table);
}
void intel_dsi_vbt_gpio_cleanup(struct intel_dsi *intel_dsi)
{
- struct drm_device *dev = intel_dsi->base.base.dev;
- struct drm_i915_private *dev_priv = to_i915(dev);
- struct intel_connector *connector = intel_dsi->attached_connector;
- struct mipi_config *mipi_config = connector->panel.vbt.dsi.config;
-
if (intel_dsi->gpio_panel) {
gpiod_put(intel_dsi->gpio_panel);
intel_dsi->gpio_panel = NULL;
@@ -987,13 +989,4 @@ void intel_dsi_vbt_gpio_cleanup(struct intel_dsi *intel_dsi)
gpiod_put(intel_dsi->gpio_backlight);
intel_dsi->gpio_backlight = NULL;
}
-
- if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
- mipi_config->pwm_blc == PPS_BLC_PMIC)
- gpiod_remove_lookup_table(&pmic_panel_gpio_table);
-
- if (IS_VALLEYVIEW(dev_priv) && mipi_config->pwm_blc == PPS_BLC_SOC) {
- pinctrl_unregister_mappings(soc_pwm_pinctrl_map);
- gpiod_remove_lookup_table(&soc_panel_gpio_table);
- }
}
--
2.41.0
next prev parent reply other threads:[~2023-11-01 11:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 15:57 [rft, PATCH v2 0/7] drm/i915/dsi: 2nd attempt to get rid of IOSF GPIO Andy Shevchenko
2023-10-24 15:57 ` [PATCH v2 1/7] drm/i915/dsi: Replace while(1) with one with clear exit condition Andy Shevchenko
2023-10-25 9:15 ` [Intel-gfx] " Andi Shyti
2023-10-24 15:57 ` [PATCH v2 2/7] drm/i915/dsi: Get rid of redundant 'else' Andy Shevchenko
2023-10-25 9:18 ` [Intel-gfx] " Andi Shyti
2023-10-24 15:57 ` [PATCH v2 3/7] drm/i915/dsi: Replace check with a (missing) MIPI sequence name Andy Shevchenko
2023-10-25 9:24 ` [Intel-gfx] " Andi Shyti
2023-10-24 15:57 ` [PATCH v2 4/7] drm/i915/dsi: Extract common soc_gpio_exec() helper Andy Shevchenko
2023-10-24 15:57 ` [PATCH v2 5/7] drm/i915/dsi: Replace poking of VLV GPIOs behind the driver's back Andy Shevchenko
2023-10-24 15:57 ` [PATCH v2 6/7] drm/i915/dsi: Replace poking of CHV " Andy Shevchenko
2023-10-24 16:11 ` Andy Shevchenko
2023-10-31 16:07 ` Hans de Goede
2023-10-31 16:21 ` Andy Shevchenko
2023-10-31 21:15 ` Hans de Goede
2023-11-01 9:32 ` Andy Shevchenko
2023-11-01 10:20 ` Hans de Goede
2023-11-01 10:34 ` [Intel-gfx] " Ville Syrjälä
2023-11-01 10:40 ` Hans de Goede
2023-11-01 11:01 ` Hans de Goede [this message]
2023-11-02 12:27 ` Andy Shevchenko
2023-11-02 14:19 ` Andy Shevchenko
2023-11-02 14:28 ` Hans de Goede
2023-10-24 15:57 ` [PATCH v2 7/7] drm/i915/iosf: Drop unused APIs Andy Shevchenko
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=437a20fe-121e-0d8c-04a0-da30db71d2ea@redhat.com \
--to=hdegoede@redhat.com \
--cc=airlied@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=tvrtko.ursulin@linux.intel.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
all inboxes | Powered by JetHome®