dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Guo <shawnguo@kernel.org>
To: Sean Paul <seanpaul@chromium.org>
Cc: Xin Zhou <zhou.xin8@zte.com.cn>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Baoyou Xie <xie.baoyou@zte.com.cn>,
	dri-devel@lists.freedesktop.org, Jun Nie <jun.nie@linaro.org>
Subject: Re: [PATCH 4/4] drm: zte: add VGA driver support
Date: Wed, 5 Apr 2017 22:08:21 +0800	[thread overview]
Message-ID: <20170405140815.GG3394@dragon> (raw)
In-Reply-To: <20170404174648.4khdo24dlmrfswuu@art_vandelay>

On Tue, Apr 04, 2017 at 01:46:48PM -0400, Sean Paul wrote:
> > +static int zx_vga_register(struct drm_device *drm, struct zx_vga *vga)
> > +{
> > +	struct drm_encoder *encoder = &vga->encoder;
> > +	struct drm_connector *connector = &vga->connector;
> > +
> > +	encoder->possible_crtcs = VOU_CRTC_MASK;
> > +
> > +	drm_encoder_init(drm, encoder, &zx_vga_encoder_funcs,
> > +			 DRM_MODE_ENCODER_DAC, NULL);
> > +	drm_encoder_helper_add(encoder, &zx_vga_encoder_helper_funcs);
> > +
> > +	vga->connector.polled = DRM_CONNECTOR_POLL_HPD;
> > +
> > +	drm_connector_init(drm, connector, &zx_vga_connector_funcs,
> > +			   DRM_MODE_CONNECTOR_VGA);
> > +	drm_connector_helper_add(connector, &zx_vga_connector_helper_funcs);
> > +
> > +	drm_mode_connector_attach_encoder(connector, encoder);
> 
> You're missing a couple of return value checks in this function.

Okay.  I will add return checks in the new version.

> 
> > +
> > +	return 0;
> > +}

<snip>

> > +static irqreturn_t zx_vga_irq_handler(int irq, void *dev_id)
> > +{
> > +	struct zx_vga *vga = dev_id;
> > +	u32 status;
> > +
> > +	status = zx_readl(vga->mmio + VGA_I2C_STATUS);
> > +
> > +	/* Clear interrupt status */
> > +	zx_writel_mask(vga->mmio + VGA_I2C_STATUS, VGA_CLEAR_IRQ,
> > +		       VGA_CLEAR_IRQ);
> > +
> > +	if (status & VGA_DEVICE_CONNECTED) {
> > +		/*
> > +		 * We should ideally set up VGA_DETECT_SEL_HAS_DEVICE bit here
> > +		 * for unplug detection, but doing so will stop DDC bus from
> > +		 * reading EDID later on. It looks like a HW limitation, and we
> > +		 * work around it by defering the bit setup to .get_modes hook
> > +		 * after EDID read succeeds.
> 
> get_modes resets VGA_AUTO_DETECT_SEL before and after reading edid, so is it
> really necessary to defer setting it here?

Okay, the comment in the code seems confusing.  Since we need to reset
VGA_AUTO_DETECT_SEL bits to switch DDC bus from device detecting to EDID
reading, VGA_DETECT_SEL_HAS_DEVICE will need to be set after reading
EDID anyway.  I will improve the comment.

> 
> > +		 */
> > +		vga->connected = true;
> > +		return IRQ_WAKE_THREAD;
> > +	}
> > +
> > +	if (status & VGA_DEVICE_DISCONNECTED) {
> > +		zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL,
> > +			  VGA_DETECT_SEL_NO_DEVICE);
> 
> This races with get_modes, you should serialize access to this register.

Good catch.  I will add lock for it.

Shawn

> 
> > +		vga->connected = false;
> > +		return IRQ_WAKE_THREAD;
> > +	}
> > +
> > +	if (status & VGA_TRANS_DONE) {
> > +		complete(&vga->complete);
> > +		return IRQ_HANDLED;
> > +	}
> > +
> > +	return IRQ_NONE;
> > +}
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2017-04-05 14:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21 12:15 [PATCH 0/4] Add ZTE VGA driver support Shawn Guo
2017-03-21 12:15 ` [PATCH 1/4] drm: zte: do not enable clock auto-gating by default Shawn Guo
2017-04-04 17:48   ` Sean Paul
2017-03-21 12:15 ` [PATCH 2/4] drm: zte: move CSC register definitions into a common header Shawn Guo
2017-04-04 17:47   ` Sean Paul
2017-03-21 12:15 ` [PATCH 3/4] dt: add bindings for ZTE VGA device Shawn Guo
2017-03-21 12:15 ` [PATCH 4/4] drm: zte: add VGA driver support Shawn Guo
2017-04-03  9:23   ` Daniel Vetter
2017-04-04 13:47     ` Shawn Guo
2017-04-04 17:32       ` Sean Paul
2017-04-05  6:08         ` Shawn Guo
2017-04-05  6:25           ` Daniel Vetter
2017-04-04 17:46   ` Sean Paul
2017-04-05 14:08     ` Shawn Guo [this message]

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=20170405140815.GG3394@dragon \
    --to=shawnguo@kernel.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jun.nie@linaro.org \
    --cc=seanpaul@chromium.org \
    --cc=xie.baoyou@zte.com.cn \
    --cc=zhou.xin8@zte.com.cn \
    /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).