From: Mihai Moldovan <ionic@ionic.de>
To: Jani Nikula <jani.nikula@intel.com>
Cc: daniel@ffwll.ch, intel-gfx@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/1] hopefully fix null pointer dereference on i915 load
Date: Mon, 13 Aug 2012 17:03:24 +0200 [thread overview]
Message-ID: <5029173C.90709@ionic.de> (raw)
In-Reply-To: <cover.1344867962.git.jani.nikula@intel.com>
[-- Attachment #1: Type: text/plain, Size: 3126 bytes --]
Hi Jani,
* On 13.08.2012 04:33 PM, Jani Nikula wrote:
> Hi Mihai, could you test the following patch to see if it fixes the problem,
> please?
>
> BR,
> Jani.
>
>
> Jani Nikula (1):
> drm/i915: ensure i2c adapter is all set before adding it
>
> drivers/gpu/drm/i915/intel_i2c.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
The reason sounds sane to me, but while looking through the code, I have seen a
few other problems, too.
To my understanding, we should use port for dev_priv->gmbus[], not the pin
mapping (which is only used for gmbus_ports[]).
Don't forget to add the +1 for pin -> port mapping to the error case.
Also, intel_gmbus_get_adapter is already accepting a port value (I made sure to
look at the calls in other files too), so don't map the port back to a pin.
Keep the same in mind for the intel_teardown_gmbus "destructor".
The current code adds the gmbus algorithm (gmbus_xfer) to gmbus port 0, which is
known as "disabled" and shouldn't be used (previously has_gpio was set to false
for those ports to not do any transfer on those ports.)
I may be wrong, could you review this and maybe add it to your patch?
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index 1991a44..b725993 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -472,8 +474,8 @@ int intel_setup_gmbus(struct drm_device *dev)
mutex_init(&dev_priv->gmbus_mutex);
for (i = 0; i < GMBUS_NUM_PORTS; i++) {
- struct intel_gmbus *bus = &dev_priv->gmbus[i];
u32 port = i + 1; /* +1 to map gmbus index to pin pair */
+ struct intel_gmbus *bus = &dev_priv->gmbus[port];
bus->adapter.owner = THIS_MODULE;
bus->adapter.class = I2C_CLASS_DDC;
@@ -506,7 +508,7 @@ int intel_setup_gmbus(struct drm_device *dev)
err:
while (--i) {
- struct intel_gmbus *bus = &dev_priv->gmbus[i];
+ struct intel_gmbus *bus = &dev_priv->gmbus[i + 1];
i2c_del_adapter(&bus->adapter);
}
return ret;
@@ -516,9 +518,8 @@ struct i2c_adapter *intel_gmbus_get_adapter(struct
drm_i915_private *dev_priv,
unsigned port)
{
WARN_ON(!intel_gmbus_is_port_valid(port));
- /* -1 to map pin pair to gmbus index */
return (intel_gmbus_is_port_valid(port)) ?
- &dev_priv->gmbus[port - 1].adapter : NULL;
+ &dev_priv->gmbus[port].adapter : NULL;
}
void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed)
@@ -543,8 +544,9 @@ void intel_teardown_gmbus(struct drm_device *dev)
if (dev_priv->gmbus == NULL)
return;
+ /* +1 to map gmbus index to pin pair */
for (i = 0; i < GMBUS_NUM_PORTS; i++) {
- struct intel_gmbus *bus = &dev_priv->gmbus[i];
+ struct intel_gmbus *bus = &dev_priv->gmbus[i + 1];
i2c_del_adapter(&bus->adapter);
}
}
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4506 bytes --]
next prev parent reply other threads:[~2012-08-13 15:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-08 4:50 null pointer dereference while loading i915 Mihai Moldovan
2012-08-10 10:10 ` Daniel Vetter
2012-08-10 16:05 ` Mihai Moldovan
2012-08-10 16:39 ` Daniel Vetter
2012-08-10 17:44 ` Mihai Moldovan
2012-08-10 23:09 ` Mihai Moldovan
2012-08-13 14:33 ` [PATCH 0/1] hopefully fix null pointer dereference on i915 load Jani Nikula
2012-08-13 14:33 ` Jani Nikula
2012-08-13 14:33 ` [PATCH 1/1] drm/i915: ensure i2c adapter is all set before adding it Jani Nikula
2012-08-13 17:05 ` Daniel Vetter
2012-08-13 15:03 ` Mihai Moldovan [this message]
2012-08-13 15:09 ` [PATCH 0/1] hopefully fix null pointer dereference on i915 load Daniel Vetter
2012-08-13 15:27 ` Mihai Moldovan
2012-08-13 16:15 ` Mihai Moldovan
2012-08-14 6:17 ` Jani Nikula
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=5029173C.90709@ionic.de \
--to=ionic@ionic.de \
--cc=daniel@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=linux-kernel@vger.kernel.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.