linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: "Hao, Xudong" <xudong.hao@intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: Re: [PATCH V4] Quirk for IVB graphics FLR errata
Date: Wed, 11 Apr 2012 06:22:34 -0600	[thread overview]
Message-ID: <20120411122233.GB6557@parisc-linux.org> (raw)
In-Reply-To: <403610A45A2B5242BD291EDAE8B37D300FD0DA33@SHSMSX102.ccr.corp.intel.com>

On Wed, Apr 11, 2012 at 06:03:43AM +0000, Hao, Xudong wrote:
> +#ifdef CONFIG_X86
> +
> +#include "../gpu/drm/i915/i915_reg.h"
> +#define MSG_CTL	0x45010

There's a strange mixture of constants from i915_reg.h, defined constants
here and bare constants below.  I don't mind which get used, but the
mixture is bizarre.

> +static const int op_timeout = 10;	/* set timeout 10 seconds */
> +static int reset_ivb_igd(struct pci_dev *dev, int probe) {
> +	u8 *mmio_base;
> +	u32 val;
> +	cycles_t cyc_op_timeout = tsc_khz*op_timeout*1000;

Style: use spaces around the multiply operator:
	cycles_t cyc_op_timeout = tsc_khz * op_timeout * 1000;

> +	if (probe)
> +		return 0;
> +
> +	mmio_base = ioremap_nocache(pci_resource_start(dev, 0),
> +				 pci_resource_len(dev, 0));

mmio_base should have type void __iomem *.

> +	if (!mmio_base)
> +		return -ENOMEM;
> +
> +	/* Work Around */
> +	*((u32 *)(mmio_base + MSG_CTL)) = 0x00000002;

Why are you not using writel() here? (and readl() in other places)

> +	/* Clobbering SOUTH_CHICKEN2 register is fine only if the next
> +	 * driver loaded sets the right bits. However, this's a reset and
> +	 * the bits have been set by i915 previously, so we clobber
> +	 * SOUTH_CHICKEN2 register directly here.
> +	 */
> +	*((u32 *)(mmio_base + SOUTH_CHICKEN2)) = 0x00000005;
> +	val = *((u32 *)(mmio_base + PCH_PP_CONTROL)) & 0xfffffffe;
> +	*((u32 *)(mmio_base + PCH_PP_CONTROL)) = val;
> +	do {
> +		cycles_t start_time = get_cycles();
> +		while (1) {
> +			val = *((u32 *)(mmio_base + PCH_PP_STATUS));
> +			if (((val & 0x80000000) == 0)
> +				&& ((val & 0x30000000) == 0))
> +				break;
> +			if (cyc_op_timeout < (get_cycles() - start_time))
> +				break;
> +			cpu_relax();
> +		}
> +	} while (0);
> +	*((u32 *)(mmio_base + 0xd0100)) = 0x00000002;
> +
> +	iounmap(pci_resource_start(dev, 0));
> +	return 0;
> +}
> +#else
> +static int reset_ivb_igd(struct pci_dev *dev, int probe) { }
> +#endif	/* CONFIG_X86 */
> +
>  #define PCI_DEVICE_ID_INTEL_82599_SFP_VF   0x10ed
> +#define PCI_DEVICE_ID_INTEL_IVB_M_VGA      0x0156
> +#define PCI_DEVICE_ID_INTEL_IVB_M2_VGA     0x0166
>  
>  static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {
>  	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF,
>  		 reset_intel_82599_sfp_virtfn },
> +	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IVB_M_VGA,
> +		reset_ivb_igd },
> +	{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IVB_M2_VGA,
> +		reset_ivb_igd },
>  	{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
>  		reset_intel_generic_dev },
>  	{ 0 }
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

  reply	other threads:[~2012-04-11 12:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-11  6:03 [PATCH V4] Quirk for IVB graphics FLR errata Hao, Xudong
2012-04-11 12:22 ` Matthew Wilcox [this message]
2012-04-12  2:26   ` Hao, Xudong
2012-04-11 14:28 ` Don Dutile
2012-04-12  2:12   ` Hao, Xudong
2012-04-12  4:06   ` Matthew Wilcox
2012-04-12 15:19     ` Don Dutile
2012-04-13  1:40       ` Hao, Xudong
2012-04-13  1:48       ` Bjorn Helgaas
2012-04-13 13:48         ` Don Dutile
2012-04-13  1:56       ` Hao, Xudong
  -- strict thread matches above, loose matches on Subject: below --
2012-03-01  9:37 Hao, Xudong

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=20120411122233.GB6557@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=xudong.hao@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;
as well as URLs for NNTP newsgroup(s).