linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/3] linux: address broken PAT drivers
@ 2015-06-09  0:20 Luis R. Rodriguez
  2015-06-09  0:20 ` [PATCH v6 1/3] ivtv: use arch_phys_wc_add() and require PAT disabled Luis R. Rodriguez
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-06-09  0:20 UTC (permalink / raw)
  To: mchehab, bp
  Cc: tomi.valkeinen, bhelgaas, linux-media, linux-rdma, linux-kernel,
	Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@suse.com>

Mauro,

since the ivtv patch is already acked by the driver maintainer
and depends on an x86 symbol that went through Boris' tree are you
OK in it going through Boris' tree?

Boris,

provided the outcome of the above maintainer's preference for you
to merge these please consider these patches for your tree. The
maintainer path is the only thing pending for the 1 ivtv patch.
The Infiniband subsystem maintainer, Doug, already provided his
ACK for the ipath driver and for this to go through you.

Luis R. Rodriguez (3):
  ivtv: use arch_phys_wc_add() and require PAT disabled
  IB/ipath: add counting for MTRR
  IB/ipath: use arch_phys_wc_add() and require PAT disabled

 drivers/infiniband/hw/ipath/Kconfig           |  3 ++
 drivers/infiniband/hw/ipath/ipath_driver.c    | 18 ++++++---
 drivers/infiniband/hw/ipath/ipath_kernel.h    |  4 +-
 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 43 +++++---------------
 drivers/media/pci/ivtv/Kconfig                |  3 ++
 drivers/media/pci/ivtv/ivtvfb.c               | 58 +++++++++++----------------
 6 files changed, 52 insertions(+), 77 deletions(-)

-- 
2.3.2.209.gd67f9d5.dirty


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v6 1/3] ivtv: use arch_phys_wc_add() and require PAT disabled
  2015-06-09  0:20 [PATCH v6 0/3] linux: address broken PAT drivers Luis R. Rodriguez
@ 2015-06-09  0:20 ` Luis R. Rodriguez
  2015-06-09  0:56   ` Mauro Carvalho Chehab
  2015-06-09  0:20 ` [PATCH v6 2/3] IB/ipath: add counting for MTRR Luis R. Rodriguez
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-06-09  0:20 UTC (permalink / raw)
  To: mchehab, bp
  Cc: tomi.valkeinen, bhelgaas, linux-media, linux-rdma, linux-kernel,
	Luis R. Rodriguez, Andy Walls, Doug Ledford, Andy Lutomirski,
	Suresh Siddha, Ingo Molnar, Thomas Gleixner, Juergen Gross,
	Daniel Vetter, Dave Airlie, Antonino Daplas,
	Jean-Christophe Plagniol-Villard, Dave Hansen, Arnd Bergmann,
	Michael S. Tsirkin, Stefan Bader, Ville Syrjälä,
	Mel Gorman, Vlastimil Babka, Davidlohr Bueso, konrad.wilk,
	ville.syrjala, david.vrabel, jbeulich, toshi.kani,
	Roger Pau Monné,
	linux-fbdev, ivtv-devel, xen-devel

From: "Luis R. Rodriguez" <mcgrof@suse.com>

We are burrying direct access to MTRR code support on
x86 in order to take advantage of PAT. In the future we
also want to make the default behaviour of ioremap_nocache()
to use strong UC, use of mtrr_add() on those systems
would make write-combining void.

In order to help both enable us to later make strong
UC default and in order to phase out direct MTRR access
code port the driver over to arch_phys_wc_add() and
annotate that the device driver requires systems to
boot with PAT disabled, with the nopat kernel parameter.

This is a worthy comprmise given that the hardware is
really rare these days, and perhaps only some lost souls
in some third world country are expected to be using this
feature of the device driver.

Acked-by: Andy Walls <awalls@md.metrocast.net>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Borislav Petkov <bp@suse.de>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: konrad.wilk@oracle.com
Cc: ville.syrjala@linux.intel.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: toshi.kani@hp.com
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: ivtv-devel@ivtvdriver.org
Cc: linux-media@vger.kernel.org
Cc: xen-devel@lists.xensource.com
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 drivers/media/pci/ivtv/Kconfig  |  3 +++
 drivers/media/pci/ivtv/ivtvfb.c | 58 ++++++++++++++++-------------------------
 2 files changed, 26 insertions(+), 35 deletions(-)

diff --git a/drivers/media/pci/ivtv/Kconfig b/drivers/media/pci/ivtv/Kconfig
index dd6ee57e..b2a7f88 100644
--- a/drivers/media/pci/ivtv/Kconfig
+++ b/drivers/media/pci/ivtv/Kconfig
@@ -57,5 +57,8 @@ config VIDEO_FB_IVTV
 	  This is used in the Hauppauge PVR-350 card. There is a driver
 	  homepage at <http://www.ivtvdriver.org>.
 
+	  If you have this hardware you will need to boot with PAT disabled
+	  on your x86 systems, use the nopat kernel parameter.
+
 	  To compile this driver as a module, choose M here: the
 	  module will be called ivtvfb.
diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
index 9ff1230..7685ae3 100644
--- a/drivers/media/pci/ivtv/ivtvfb.c
+++ b/drivers/media/pci/ivtv/ivtvfb.c
@@ -44,8 +44,8 @@
 #include <linux/ivtvfb.h>
 #include <linux/slab.h>
 
-#ifdef CONFIG_MTRR
-#include <asm/mtrr.h>
+#ifdef CONFIG_X86_64
+#include <asm/pat.h>
 #endif
 
 #include "ivtv-driver.h"
@@ -155,12 +155,11 @@ struct osd_info {
 	/* Buffer size */
 	u32 video_buffer_size;
 
-#ifdef CONFIG_MTRR
 	/* video_base rounded down as required by hardware MTRRs */
 	unsigned long fb_start_aligned_physaddr;
 	/* video_base rounded up as required by hardware MTRRs */
 	unsigned long fb_end_aligned_physaddr;
-#endif
+	int wc_cookie;
 
 	/* Store the buffer offset */
 	int set_osd_coords_x;
@@ -1099,6 +1098,8 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
 static int ivtvfb_init_io(struct ivtv *itv)
 {
 	struct osd_info *oi = itv->osd_info;
+	/* Find the largest power of two that maps the whole buffer */
+	int size_shift = 31;
 
 	mutex_lock(&itv->serialize_lock);
 	if (ivtv_init_on_first_open(itv)) {
@@ -1132,29 +1133,16 @@ static int ivtvfb_init_io(struct ivtv *itv)
 			oi->video_pbase, oi->video_vbase,
 			oi->video_buffer_size / 1024);
 
-#ifdef CONFIG_MTRR
-	{
-		/* Find the largest power of two that maps the whole buffer */
-		int size_shift = 31;
-
-		while (!(oi->video_buffer_size & (1 << size_shift))) {
-			size_shift--;
-		}
-		size_shift++;
-		oi->fb_start_aligned_physaddr = oi->video_pbase & ~((1 << size_shift) - 1);
-		oi->fb_end_aligned_physaddr = oi->video_pbase + oi->video_buffer_size;
-		oi->fb_end_aligned_physaddr += (1 << size_shift) - 1;
-		oi->fb_end_aligned_physaddr &= ~((1 << size_shift) - 1);
-		if (mtrr_add(oi->fb_start_aligned_physaddr,
-			oi->fb_end_aligned_physaddr - oi->fb_start_aligned_physaddr,
-			     MTRR_TYPE_WRCOMB, 1) < 0) {
-			IVTVFB_INFO("disabled mttr\n");
-			oi->fb_start_aligned_physaddr = 0;
-			oi->fb_end_aligned_physaddr = 0;
-		}
-	}
-#endif
-
+	while (!(oi->video_buffer_size & (1 << size_shift)))
+		size_shift--;
+	size_shift++;
+	oi->fb_start_aligned_physaddr = oi->video_pbase & ~((1 << size_shift) - 1);
+	oi->fb_end_aligned_physaddr = oi->video_pbase + oi->video_buffer_size;
+	oi->fb_end_aligned_physaddr += (1 << size_shift) - 1;
+	oi->fb_end_aligned_physaddr &= ~((1 << size_shift) - 1);
+	oi->wc_cookie = arch_phys_wc_add(oi->fb_start_aligned_physaddr,
+					 oi->fb_end_aligned_physaddr -
+					 oi->fb_start_aligned_physaddr);
 	/* Blank the entire osd. */
 	memset_io(oi->video_vbase, 0, oi->video_buffer_size);
 
@@ -1172,14 +1160,7 @@ static void ivtvfb_release_buffers (struct ivtv *itv)
 
 	/* Release pseudo palette */
 	kfree(oi->ivtvfb_info.pseudo_palette);
-
-#ifdef CONFIG_MTRR
-	if (oi->fb_end_aligned_physaddr) {
-		mtrr_del(-1, oi->fb_start_aligned_physaddr,
-			oi->fb_end_aligned_physaddr - oi->fb_start_aligned_physaddr);
-	}
-#endif
-
+	arch_phys_wc_del(oi->wc_cookie);
 	kfree(oi);
 	itv->osd_info = NULL;
 }
@@ -1284,6 +1265,13 @@ static int __init ivtvfb_init(void)
 	int registered = 0;
 	int err;
 
+#ifdef CONFIG_X86_64
+	if (WARN(pat_enabled(),
+		 "ivtvfb needs PAT disabled, boot with nopat kernel parameter\n")) {
+		return EINVAL;
+	}
+#endif
+
 	if (ivtvfb_card_id < -1 || ivtvfb_card_id >= IVTV_MAX_CARDS) {
 		printk(KERN_ERR "ivtvfb:  ivtvfb_card_id parameter is out of range (valid range: -1 - %d)\n",
 		     IVTV_MAX_CARDS - 1);
-- 
2.3.2.209.gd67f9d5.dirty


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 2/3] IB/ipath: add counting for MTRR
  2015-06-09  0:20 [PATCH v6 0/3] linux: address broken PAT drivers Luis R. Rodriguez
  2015-06-09  0:20 ` [PATCH v6 1/3] ivtv: use arch_phys_wc_add() and require PAT disabled Luis R. Rodriguez
@ 2015-06-09  0:20 ` Luis R. Rodriguez
  2015-06-09  0:20 ` [PATCH v6 3/3] IB/ipath: use arch_phys_wc_add() and require PAT disabled Luis R. Rodriguez
  2015-06-09  0:57 ` [PATCH v6 0/3] linux: address broken PAT drivers Mauro Carvalho Chehab
  3 siblings, 0 replies; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-06-09  0:20 UTC (permalink / raw)
  To: mchehab, bp
  Cc: tomi.valkeinen, bhelgaas, linux-media, linux-rdma, linux-kernel,
	Luis R. Rodriguez, Toshi Kani, Roland Dreier, Sean Hefty,
	Hal Rosenstock, Suresh Siddha, Ingo Molnar, Thomas Gleixner,
	Juergen Gross, Daniel Vetter, Andy Lutomirski, Dave Airlie,
	Antonino Daplas, Jean-Christophe Plagniol-Villard, infinipath,
	linux-fbdev

From: "Luis R. Rodriguez" <mcgrof@suse.com>

There is no good reason not to, we eventually delete it as well.

Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: infinipath@intel.com
Cc: linux-rdma@vger.kernel.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
index 4ad0b93..70c1f3a 100644
--- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
+++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
@@ -127,7 +127,7 @@ int ipath_enable_wc(struct ipath_devdata *dd)
 			   "(addr %llx, len=0x%llx)\n",
 			   (unsigned long long) pioaddr,
 			   (unsigned long long) piolen);
-		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
+		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
 		if (cookie < 0) {
 			{
 				dev_info(&dd->pcidev->dev,
-- 
2.3.2.209.gd67f9d5.dirty


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 3/3] IB/ipath: use arch_phys_wc_add() and require PAT disabled
  2015-06-09  0:20 [PATCH v6 0/3] linux: address broken PAT drivers Luis R. Rodriguez
  2015-06-09  0:20 ` [PATCH v6 1/3] ivtv: use arch_phys_wc_add() and require PAT disabled Luis R. Rodriguez
  2015-06-09  0:20 ` [PATCH v6 2/3] IB/ipath: add counting for MTRR Luis R. Rodriguez
@ 2015-06-09  0:20 ` Luis R. Rodriguez
  2015-06-09  0:57 ` [PATCH v6 0/3] linux: address broken PAT drivers Mauro Carvalho Chehab
  3 siblings, 0 replies; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-06-09  0:20 UTC (permalink / raw)
  To: mchehab, bp
  Cc: tomi.valkeinen, bhelgaas, linux-media, linux-rdma, linux-kernel,
	Luis R. Rodriguez, Doug Ledford, Andy Walls, Hal Rosenstock,
	Sean Hefty, Suresh Siddha, Rickard Strandqvist, Mike Marciniszyn,
	Roland Dreier, Andy Lutomirski, Ingo Molnar, Linus Torvalds,
	Thomas Gleixner, Juergen Gross, Daniel Vetter, Dave Airlie,
	Antonino Daplas, Jean-Christophe Plagniol-Villard,
	Ville Syrjälä,
	Mel Gorman, Vlastimil Babka, Davidlohr Bueso, Dave Hansen,
	Arnd Bergmann, Michael S. Tsirkin, Stefan Bader, konrad.wilk,
	ville.syrjala, david.vrabel, jbeulich, toshi.kani,
	Roger Pau Monné,
	infinipath, linux-fbdev, xen-devel

From: "Luis R. Rodriguez" <mcgrof@suse.com>

We are burrying direct access to MTRR code support on
x86 in order to take advantage of PAT. In the future we
also want to make the default behaviour of ioremap_nocache()
to use strong UC, use of mtrr_add() on those systems
would make write-combining void.

In order to help both enable us to later make strong
UC default and in order to phase out direct MTRR access
code port the driver over to arch_phys_wc_add() and
annotate that the device driver requires systems to
boot with PAT disabled, with the nopat kernel parameter.

This is a worthy compromise given that the ipath device
driver powers the old HTX bus cards that only work in
AMD systems, while the newer IB/qib device driver
powers all PCI-e cards. The ipath device driver is
obsolete, hardware hard to find and because of this
this its a reasonable compromise to make to require
users of ipath to boot with nopat.

Acked-by: Doug Ledford <dledford@redhat.com>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
Cc: Roland Dreier <roland@purestorage.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Borislav Petkov <bp@suse.de>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: konrad.wilk@oracle.com
Cc: ville.syrjala@linux.intel.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: toshi.kani@hp.com
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: infinipath@intel.com
Cc: linux-rdma@vger.kernel.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: xen-devel@lists.xensource.com
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 drivers/infiniband/hw/ipath/Kconfig           |  3 ++
 drivers/infiniband/hw/ipath/ipath_driver.c    | 18 +++++++----
 drivers/infiniband/hw/ipath/ipath_kernel.h    |  4 +--
 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 43 ++++++---------------------
 4 files changed, 26 insertions(+), 42 deletions(-)

diff --git a/drivers/infiniband/hw/ipath/Kconfig b/drivers/infiniband/hw/ipath/Kconfig
index 1d9bb11..8fe54ff 100644
--- a/drivers/infiniband/hw/ipath/Kconfig
+++ b/drivers/infiniband/hw/ipath/Kconfig
@@ -9,3 +9,6 @@ config INFINIBAND_IPATH
 	as IP-over-InfiniBand as well as with userspace applications
 	(in conjunction with InfiniBand userspace access).
 	For QLogic PCIe QLE based cards, use the QIB driver instead.
+
+	If you have this hardware you will need to boot with PAT disabled
+	on your x86-64 systems, use the nopat kernel parameter.
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index bd0caed..441cfe5 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -42,6 +42,9 @@
 #include <linux/bitmap.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#ifdef CONFIG_X86_64
+#include <asm/pat.h>
+#endif
 
 #include "ipath_kernel.h"
 #include "ipath_verbs.h"
@@ -395,6 +398,14 @@ static int ipath_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	unsigned long long addr;
 	u32 bar0 = 0, bar1 = 0;
 
+#ifdef CONFIG_X86_64
+	if (WARN(pat_enabled(),
+		 "ipath needs PAT disabled, boot with nopat kernel parameter\n")) {
+		ret = EINVAL;
+		goto bail;
+	}
+#endif
+
 	dd = ipath_alloc_devdata(pdev);
 	if (IS_ERR(dd)) {
 		ret = PTR_ERR(dd);
@@ -542,6 +553,7 @@ static int ipath_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dd->ipath_kregbase = __ioremap(addr, len,
 		(_PAGE_NO_CACHE|_PAGE_WRITETHRU));
 #else
+	/* XXX: split this properly to enable on PAT */
 	dd->ipath_kregbase = ioremap_nocache(addr, len);
 #endif
 
@@ -587,12 +599,8 @@ static int ipath_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	ret = ipath_enable_wc(dd);
 
-	if (ret) {
-		ipath_dev_err(dd, "Write combining not enabled "
-			      "(err %d): performance may be poor\n",
-			      -ret);
+	if (ret)
 		ret = 0;
-	}
 
 	ipath_verify_pioperf(dd);
 
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index e08db70..f0f9471 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -463,9 +463,7 @@ struct ipath_devdata {
 	/* offset in HT config space of slave/primary interface block */
 	u8 ipath_ht_slave_off;
 	/* for write combining settings */
-	unsigned long ipath_wc_cookie;
-	unsigned long ipath_wc_base;
-	unsigned long ipath_wc_len;
+	int wc_cookie;
 	/* ref count for each pkey */
 	atomic_t ipath_pkeyrefs[4];
 	/* shadow copy of struct page *'s for exp tid pages */
diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
index 70c1f3a..7b6e4c8 100644
--- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
+++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
@@ -37,7 +37,6 @@
  */
 
 #include <linux/pci.h>
-#include <asm/mtrr.h>
 #include <asm/processor.h>
 
 #include "ipath_kernel.h"
@@ -122,27 +121,14 @@ int ipath_enable_wc(struct ipath_devdata *dd)
 	}
 
 	if (!ret) {
-		int cookie;
-		ipath_cdbg(VERBOSE, "Setting mtrr for chip to WC "
-			   "(addr %llx, len=0x%llx)\n",
-			   (unsigned long long) pioaddr,
-			   (unsigned long long) piolen);
-		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
-		if (cookie < 0) {
-			{
-				dev_info(&dd->pcidev->dev,
-					 "mtrr_add()  WC for PIO bufs "
-					 "failed (%d)\n",
-					 cookie);
-				ret = -EINVAL;
-			}
-		} else {
-			ipath_cdbg(VERBOSE, "Set mtrr for chip to WC, "
-				   "cookie is %d\n", cookie);
-			dd->ipath_wc_cookie = cookie;
-			dd->ipath_wc_base = (unsigned long) pioaddr;
-			dd->ipath_wc_len = (unsigned long) piolen;
-		}
+		dd->wc_cookie = arch_phys_wc_add(pioaddr, piolen);
+		if (dd->wc_cookie < 0) {
+			ipath_dev_err(dd, "Seting mtrr failed on PIO buffers\n");
+			ret = -ENODEV;
+		} else if (dd->wc_cookie == 0)
+			ipath_cdbg(VERBOSE, "Set mtrr for chip to WC not needed\n");
+		else
+			ipath_cdbg(VERBOSE, "Set mtrr for chip to WC\n");
 	}
 
 	return ret;
@@ -154,16 +140,5 @@ int ipath_enable_wc(struct ipath_devdata *dd)
  */
 void ipath_disable_wc(struct ipath_devdata *dd)
 {
-	if (dd->ipath_wc_cookie) {
-		int r;
-		ipath_cdbg(VERBOSE, "undoing WCCOMB on pio buffers\n");
-		r = mtrr_del(dd->ipath_wc_cookie, dd->ipath_wc_base,
-			     dd->ipath_wc_len);
-		if (r < 0)
-			dev_info(&dd->pcidev->dev,
-				 "mtrr_del(%lx, %lx, %lx) failed: %d\n",
-				 dd->ipath_wc_cookie, dd->ipath_wc_base,
-				 dd->ipath_wc_len, r);
-		dd->ipath_wc_cookie = 0; /* even on failure */
-	}
+	arch_phys_wc_del(dd->wc_cookie);
 }
-- 
2.3.2.209.gd67f9d5.dirty


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 1/3] ivtv: use arch_phys_wc_add() and require PAT disabled
  2015-06-09  0:20 ` [PATCH v6 1/3] ivtv: use arch_phys_wc_add() and require PAT disabled Luis R. Rodriguez
@ 2015-06-09  0:56   ` Mauro Carvalho Chehab
  2015-06-09  6:23     ` Hans Verkuil
  0 siblings, 1 reply; 11+ messages in thread
From: Mauro Carvalho Chehab @ 2015-06-09  0:56 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: bp, tomi.valkeinen, bhelgaas, linux-media, linux-rdma,
	linux-kernel, Luis R. Rodriguez, Andy Walls, Doug Ledford,
	Andy Lutomirski, Suresh Siddha, Ingo Molnar, Thomas Gleixner,
	Juergen Gross, Daniel Vetter, Dave Airlie, Antonino Daplas,
	Jean-Christophe Plagniol-Villard, Dave Hansen, Arnd Bergmann,
	Michael S. Tsirkin, Stefan Bader, Ville Syrjälä,
	Mel Gorman, Vlastimil Babka, Davidlohr Bueso, konrad.wilk,
	ville.syrjala, david.vrabel, jbeulich, toshi.kani,
	Roger Pau Monné,
	linux-fbdev, ivtv-devel, xen-devel

Em Mon, 08 Jun 2015 17:20:20 -0700
"Luis R. Rodriguez" <mcgrof@do-not-panic.com> escreveu:

> From: "Luis R. Rodriguez" <mcgrof@suse.com>
> 
> We are burrying direct access to MTRR code support on
> x86 in order to take advantage of PAT. In the future we
> also want to make the default behaviour of ioremap_nocache()
> to use strong UC, use of mtrr_add() on those systems
> would make write-combining void.
> 
> In order to help both enable us to later make strong
> UC default and in order to phase out direct MTRR access
> code port the driver over to arch_phys_wc_add() and
> annotate that the device driver requires systems to
> boot with PAT disabled, with the nopat kernel parameter.
> 
> This is a worthy comprmise given that the hardware is
> really rare these days, and perhaps only some lost souls
> in some third world country are expected to be using this
> feature of the device driver.
> 
> Acked-by: Andy Walls <awalls@md.metrocast.net>
> Cc: Andy Walls <awalls@md.metrocast.net>
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Provided that you fix the issues below:
Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Suresh Siddha <sbsiddha@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Antonino Daplas <adaplas@gmail.com>
> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Stefan Bader <stefan.bader@canonical.com>
> Cc: Ville Syrjälä <syrjala@sci.fi>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Davidlohr Bueso <dbueso@suse.de>
> Cc: konrad.wilk@oracle.com
> Cc: ville.syrjala@linux.intel.com
> Cc: david.vrabel@citrix.com
> Cc: jbeulich@suse.com
> Cc: toshi.kani@hp.com
> Cc: Roger Pau Monné <roger.pau@citrix.com>
> Cc: linux-fbdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: ivtv-devel@ivtvdriver.org
> Cc: linux-media@vger.kernel.org
> Cc: xen-devel@lists.xensource.com
> Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
> ---
>  drivers/media/pci/ivtv/Kconfig  |  3 +++
>  drivers/media/pci/ivtv/ivtvfb.c | 58 ++++++++++++++++-------------------------
>  2 files changed, 26 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/media/pci/ivtv/Kconfig b/drivers/media/pci/ivtv/Kconfig
> index dd6ee57e..b2a7f88 100644
> --- a/drivers/media/pci/ivtv/Kconfig
> +++ b/drivers/media/pci/ivtv/Kconfig
> @@ -57,5 +57,8 @@ config VIDEO_FB_IVTV
>  	  This is used in the Hauppauge PVR-350 card. There is a driver
>  	  homepage at <http://www.ivtvdriver.org>.
>  
> +	  If you have this hardware you will need to boot with PAT disabled
> +	  on your x86 systems, use the nopat kernel parameter.
> +

Hmm... FB_IVTV is not hardware... it is framebuffer support for IVTV.
It is optional to use FB API for the video output port of this board,
instead of using V4L2 API.

I would say, instead, something like: 

	"In order to use this module, you will need to boot with PAT disabled
	  on x86 systems, using the nopat kernel parameter."

>  	  To compile this driver as a module, choose M here: the
>  	  module will be called ivtvfb.
> diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
> index 9ff1230..7685ae3 100644
> --- a/drivers/media/pci/ivtv/ivtvfb.c
> +++ b/drivers/media/pci/ivtv/ivtvfb.c
> @@ -44,8 +44,8 @@
>  #include <linux/ivtvfb.h>
>  #include <linux/slab.h>
>  
> -#ifdef CONFIG_MTRR
> -#include <asm/mtrr.h>
> +#ifdef CONFIG_X86_64
> +#include <asm/pat.h>
>  #endif
>  
>  #include "ivtv-driver.h"
> @@ -155,12 +155,11 @@ struct osd_info {
>  	/* Buffer size */
>  	u32 video_buffer_size;
>  
> -#ifdef CONFIG_MTRR
>  	/* video_base rounded down as required by hardware MTRRs */
>  	unsigned long fb_start_aligned_physaddr;
>  	/* video_base rounded up as required by hardware MTRRs */
>  	unsigned long fb_end_aligned_physaddr;
> -#endif
> +	int wc_cookie;
>  
>  	/* Store the buffer offset */
>  	int set_osd_coords_x;
> @@ -1099,6 +1098,8 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
>  static int ivtvfb_init_io(struct ivtv *itv)
>  {
>  	struct osd_info *oi = itv->osd_info;
> +	/* Find the largest power of two that maps the whole buffer */
> +	int size_shift = 31;
>  
>  	mutex_lock(&itv->serialize_lock);
>  	if (ivtv_init_on_first_open(itv)) {
> @@ -1132,29 +1133,16 @@ static int ivtvfb_init_io(struct ivtv *itv)
>  			oi->video_pbase, oi->video_vbase,
>  			oi->video_buffer_size / 1024);
>  
> -#ifdef CONFIG_MTRR
> -	{
> -		/* Find the largest power of two that maps the whole buffer */
> -		int size_shift = 31;
> -
> -		while (!(oi->video_buffer_size & (1 << size_shift))) {
> -			size_shift--;
> -		}
> -		size_shift++;
> -		oi->fb_start_aligned_physaddr = oi->video_pbase & ~((1 << size_shift) - 1);
> -		oi->fb_end_aligned_physaddr = oi->video_pbase + oi->video_buffer_size;
> -		oi->fb_end_aligned_physaddr += (1 << size_shift) - 1;
> -		oi->fb_end_aligned_physaddr &= ~((1 << size_shift) - 1);
> -		if (mtrr_add(oi->fb_start_aligned_physaddr,
> -			oi->fb_end_aligned_physaddr - oi->fb_start_aligned_physaddr,
> -			     MTRR_TYPE_WRCOMB, 1) < 0) {
> -			IVTVFB_INFO("disabled mttr\n");
> -			oi->fb_start_aligned_physaddr = 0;
> -			oi->fb_end_aligned_physaddr = 0;
> -		}
> -	}
> -#endif
> -
> +	while (!(oi->video_buffer_size & (1 << size_shift)))
> +		size_shift--;
> +	size_shift++;
> +	oi->fb_start_aligned_physaddr = oi->video_pbase & ~((1 << size_shift) - 1);
> +	oi->fb_end_aligned_physaddr = oi->video_pbase + oi->video_buffer_size;
> +	oi->fb_end_aligned_physaddr += (1 << size_shift) - 1;
> +	oi->fb_end_aligned_physaddr &= ~((1 << size_shift) - 1);
> +	oi->wc_cookie = arch_phys_wc_add(oi->fb_start_aligned_physaddr,
> +					 oi->fb_end_aligned_physaddr -
> +					 oi->fb_start_aligned_physaddr);
>  	/* Blank the entire osd. */
>  	memset_io(oi->video_vbase, 0, oi->video_buffer_size);
>  
> @@ -1172,14 +1160,7 @@ static void ivtvfb_release_buffers (struct ivtv *itv)
>  
>  	/* Release pseudo palette */
>  	kfree(oi->ivtvfb_info.pseudo_palette);
> -
> -#ifdef CONFIG_MTRR
> -	if (oi->fb_end_aligned_physaddr) {
> -		mtrr_del(-1, oi->fb_start_aligned_physaddr,
> -			oi->fb_end_aligned_physaddr - oi->fb_start_aligned_physaddr);
> -	}
> -#endif
> -
> +	arch_phys_wc_del(oi->wc_cookie);
>  	kfree(oi);
>  	itv->osd_info = NULL;
>  }
> @@ -1284,6 +1265,13 @@ static int __init ivtvfb_init(void)
>  	int registered = 0;
>  	int err;
>  
> +#ifdef CONFIG_X86_64
> +	if (WARN(pat_enabled(),
> +		 "ivtvfb needs PAT disabled, boot with nopat kernel parameter\n")) {
> +		return EINVAL;

Errors are always negative. So: 
		return -EINVAL

Or, perhaps, -ENODEV.

> +	}
> +#endif
> +
>  	if (ivtvfb_card_id < -1 || ivtvfb_card_id >= IVTV_MAX_CARDS) {
>  		printk(KERN_ERR "ivtvfb:  ivtvfb_card_id parameter is out of range (valid range: -1 - %d)\n",
>  		     IVTV_MAX_CARDS - 1);

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 0/3] linux: address broken PAT drivers
  2015-06-09  0:20 [PATCH v6 0/3] linux: address broken PAT drivers Luis R. Rodriguez
                   ` (2 preceding siblings ...)
  2015-06-09  0:20 ` [PATCH v6 3/3] IB/ipath: use arch_phys_wc_add() and require PAT disabled Luis R. Rodriguez
@ 2015-06-09  0:57 ` Mauro Carvalho Chehab
  2015-06-11 17:30   ` Luis R. Rodriguez
  3 siblings, 1 reply; 11+ messages in thread
From: Mauro Carvalho Chehab @ 2015-06-09  0:57 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: bp, tomi.valkeinen, bhelgaas, linux-media, linux-rdma,
	linux-kernel, Luis R. Rodriguez

Em Mon, 08 Jun 2015 17:20:19 -0700
"Luis R. Rodriguez" <mcgrof@do-not-panic.com> escreveu:

> From: "Luis R. Rodriguez" <mcgrof@suse.com>
> 
> Mauro,
> 
> since the ivtv patch is already acked by the driver maintainer
> and depends on an x86 symbol that went through Boris' tree are you
> OK in it going through Boris' tree?

Sure. I just find a minor issues there. After they got solved, feel
free to submit to Boris with my ack.

> 
> Boris,
> 
> provided the outcome of the above maintainer's preference for you
> to merge these please consider these patches for your tree. The
> maintainer path is the only thing pending for the 1 ivtv patch.
> The Infiniband subsystem maintainer, Doug, already provided his
> ACK for the ipath driver and for this to go through you.
> 
> Luis R. Rodriguez (3):
>   ivtv: use arch_phys_wc_add() and require PAT disabled
>   IB/ipath: add counting for MTRR
>   IB/ipath: use arch_phys_wc_add() and require PAT disabled
> 
>  drivers/infiniband/hw/ipath/Kconfig           |  3 ++
>  drivers/infiniband/hw/ipath/ipath_driver.c    | 18 ++++++---
>  drivers/infiniband/hw/ipath/ipath_kernel.h    |  4 +-
>  drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 43 +++++---------------
>  drivers/media/pci/ivtv/Kconfig                |  3 ++
>  drivers/media/pci/ivtv/ivtvfb.c               | 58 +++++++++++----------------
>  6 files changed, 52 insertions(+), 77 deletions(-)
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 1/3] ivtv: use arch_phys_wc_add() and require PAT disabled
  2015-06-09  0:56   ` Mauro Carvalho Chehab
@ 2015-06-09  6:23     ` Hans Verkuil
  0 siblings, 0 replies; 11+ messages in thread
From: Hans Verkuil @ 2015-06-09  6:23 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Luis R. Rodriguez
  Cc: bp, tomi.valkeinen, bhelgaas, linux-media, linux-rdma,
	linux-kernel, Luis R. Rodriguez, Andy Walls, Doug Ledford,
	Andy Lutomirski, Suresh Siddha, Ingo Molnar, Thomas Gleixner,
	Juergen Gross, Daniel Vetter, Dave Airlie, Antonino Daplas,
	Jean-Christophe Plagniol-Villard, Dave Hansen, Arnd Bergmann,
	Michael S. Tsirkin, Stefan Bader, Ville Syrjälä,
	Mel Gorman, Vlastimil Babka, Davidlohr Bueso, konrad.wilk,
	ville.syrjala, david.vrabel, jbeulich, toshi.kani,
	Roger Pau Monné,
	linux-fbdev, ivtv-devel, xen-devel

On 06/09/2015 02:56 AM, Mauro Carvalho Chehab wrote:
> Em Mon, 08 Jun 2015 17:20:20 -0700
> "Luis R. Rodriguez" <mcgrof@do-not-panic.com> escreveu:
> 
>> From: "Luis R. Rodriguez" <mcgrof@suse.com>
>>
>> We are burrying direct access to MTRR code support on
>> x86 in order to take advantage of PAT. In the future we
>> also want to make the default behaviour of ioremap_nocache()
>> to use strong UC, use of mtrr_add() on those systems
>> would make write-combining void.
>>
>> In order to help both enable us to later make strong
>> UC default and in order to phase out direct MTRR access
>> code port the driver over to arch_phys_wc_add() and
>> annotate that the device driver requires systems to
>> boot with PAT disabled, with the nopat kernel parameter.
>>
>> This is a worthy comprmise given that the hardware is
>> really rare these days, and perhaps only some lost souls
>> in some third world country are expected to be using this
>> feature of the device driver.
>>
>> Acked-by: Andy Walls <awalls@md.metrocast.net>
>> Cc: Andy Walls <awalls@md.metrocast.net>
>> Cc: Doug Ledford <dledford@redhat.com>
>> Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> Provided that you fix the issues below:
> Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
>> Cc: Andy Lutomirski <luto@amacapital.net>
>> Cc: Suresh Siddha <sbsiddha@gmail.com>
>> Cc: Ingo Molnar <mingo@elte.hu>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Juergen Gross <jgross@suse.com>
>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>> Cc: Dave Airlie <airlied@redhat.com>
>> Cc: Bjorn Helgaas <bhelgaas@google.com>
>> Cc: Antonino Daplas <adaplas@gmail.com>
>> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
>> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> Cc: Dave Hansen <dave.hansen@linux.intel.com>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Michael S. Tsirkin <mst@redhat.com>
>> Cc: Stefan Bader <stefan.bader@canonical.com>
>> Cc: Ville Syrjälä <syrjala@sci.fi>
>> Cc: Mel Gorman <mgorman@suse.de>
>> Cc: Vlastimil Babka <vbabka@suse.cz>
>> Cc: Borislav Petkov <bp@suse.de>
>> Cc: Davidlohr Bueso <dbueso@suse.de>
>> Cc: konrad.wilk@oracle.com
>> Cc: ville.syrjala@linux.intel.com
>> Cc: david.vrabel@citrix.com
>> Cc: jbeulich@suse.com
>> Cc: toshi.kani@hp.com
>> Cc: Roger Pau Monné <roger.pau@citrix.com>
>> Cc: linux-fbdev@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: ivtv-devel@ivtvdriver.org
>> Cc: linux-media@vger.kernel.org
>> Cc: xen-devel@lists.xensource.com
>> Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
>> ---
>>  drivers/media/pci/ivtv/Kconfig  |  3 +++
>>  drivers/media/pci/ivtv/ivtvfb.c | 58 ++++++++++++++++-------------------------
>>  2 files changed, 26 insertions(+), 35 deletions(-)
>>
>> diff --git a/drivers/media/pci/ivtv/Kconfig b/drivers/media/pci/ivtv/Kconfig
>> index dd6ee57e..b2a7f88 100644
>> --- a/drivers/media/pci/ivtv/Kconfig
>> +++ b/drivers/media/pci/ivtv/Kconfig
>> @@ -57,5 +57,8 @@ config VIDEO_FB_IVTV
>>  	  This is used in the Hauppauge PVR-350 card. There is a driver
>>  	  homepage at <http://www.ivtvdriver.org>.
>>  
>> +	  If you have this hardware you will need to boot with PAT disabled
>> +	  on your x86 systems, use the nopat kernel parameter.
>> +
> 
> Hmm... FB_IVTV is not hardware... it is framebuffer support for IVTV.
> It is optional to use FB API for the video output port of this board,
> instead of using V4L2 API.

That's not true. It is hardware: it drives the video output OSD which overlays
the video output. The reason it is optional is that it is hard to unload a
framebuffer module and most people don't need it.

So V4L2 drives the video output and ivtvfb drives the OSD overlay. So it is
not a case of 'instead of'.

> 
> I would say, instead, something like: 
> 
> 	"In order to use this module, you will need to boot with PAT disabled
> 	  on x86 systems, using the nopat kernel parameter."

I do agree with this change, but that's because this module is optional and
not for the reasons you mentioned above.

Regards,

	Hans

> 
>>  	  To compile this driver as a module, choose M here: the
>>  	  module will be called ivtvfb.
>> diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
>> index 9ff1230..7685ae3 100644
>> --- a/drivers/media/pci/ivtv/ivtvfb.c
>> +++ b/drivers/media/pci/ivtv/ivtvfb.c
>> @@ -44,8 +44,8 @@
>>  #include <linux/ivtvfb.h>
>>  #include <linux/slab.h>
>>  
>> -#ifdef CONFIG_MTRR
>> -#include <asm/mtrr.h>
>> +#ifdef CONFIG_X86_64
>> +#include <asm/pat.h>
>>  #endif
>>  
>>  #include "ivtv-driver.h"
>> @@ -155,12 +155,11 @@ struct osd_info {
>>  	/* Buffer size */
>>  	u32 video_buffer_size;
>>  
>> -#ifdef CONFIG_MTRR
>>  	/* video_base rounded down as required by hardware MTRRs */
>>  	unsigned long fb_start_aligned_physaddr;
>>  	/* video_base rounded up as required by hardware MTRRs */
>>  	unsigned long fb_end_aligned_physaddr;
>> -#endif
>> +	int wc_cookie;
>>  
>>  	/* Store the buffer offset */
>>  	int set_osd_coords_x;
>> @@ -1099,6 +1098,8 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
>>  static int ivtvfb_init_io(struct ivtv *itv)
>>  {
>>  	struct osd_info *oi = itv->osd_info;
>> +	/* Find the largest power of two that maps the whole buffer */
>> +	int size_shift = 31;
>>  
>>  	mutex_lock(&itv->serialize_lock);
>>  	if (ivtv_init_on_first_open(itv)) {
>> @@ -1132,29 +1133,16 @@ static int ivtvfb_init_io(struct ivtv *itv)
>>  			oi->video_pbase, oi->video_vbase,
>>  			oi->video_buffer_size / 1024);
>>  
>> -#ifdef CONFIG_MTRR
>> -	{
>> -		/* Find the largest power of two that maps the whole buffer */
>> -		int size_shift = 31;
>> -
>> -		while (!(oi->video_buffer_size & (1 << size_shift))) {
>> -			size_shift--;
>> -		}
>> -		size_shift++;
>> -		oi->fb_start_aligned_physaddr = oi->video_pbase & ~((1 << size_shift) - 1);
>> -		oi->fb_end_aligned_physaddr = oi->video_pbase + oi->video_buffer_size;
>> -		oi->fb_end_aligned_physaddr += (1 << size_shift) - 1;
>> -		oi->fb_end_aligned_physaddr &= ~((1 << size_shift) - 1);
>> -		if (mtrr_add(oi->fb_start_aligned_physaddr,
>> -			oi->fb_end_aligned_physaddr - oi->fb_start_aligned_physaddr,
>> -			     MTRR_TYPE_WRCOMB, 1) < 0) {
>> -			IVTVFB_INFO("disabled mttr\n");
>> -			oi->fb_start_aligned_physaddr = 0;
>> -			oi->fb_end_aligned_physaddr = 0;
>> -		}
>> -	}
>> -#endif
>> -
>> +	while (!(oi->video_buffer_size & (1 << size_shift)))
>> +		size_shift--;
>> +	size_shift++;
>> +	oi->fb_start_aligned_physaddr = oi->video_pbase & ~((1 << size_shift) - 1);
>> +	oi->fb_end_aligned_physaddr = oi->video_pbase + oi->video_buffer_size;
>> +	oi->fb_end_aligned_physaddr += (1 << size_shift) - 1;
>> +	oi->fb_end_aligned_physaddr &= ~((1 << size_shift) - 1);
>> +	oi->wc_cookie = arch_phys_wc_add(oi->fb_start_aligned_physaddr,
>> +					 oi->fb_end_aligned_physaddr -
>> +					 oi->fb_start_aligned_physaddr);
>>  	/* Blank the entire osd. */
>>  	memset_io(oi->video_vbase, 0, oi->video_buffer_size);
>>  
>> @@ -1172,14 +1160,7 @@ static void ivtvfb_release_buffers (struct ivtv *itv)
>>  
>>  	/* Release pseudo palette */
>>  	kfree(oi->ivtvfb_info.pseudo_palette);
>> -
>> -#ifdef CONFIG_MTRR
>> -	if (oi->fb_end_aligned_physaddr) {
>> -		mtrr_del(-1, oi->fb_start_aligned_physaddr,
>> -			oi->fb_end_aligned_physaddr - oi->fb_start_aligned_physaddr);
>> -	}
>> -#endif
>> -
>> +	arch_phys_wc_del(oi->wc_cookie);
>>  	kfree(oi);
>>  	itv->osd_info = NULL;
>>  }
>> @@ -1284,6 +1265,13 @@ static int __init ivtvfb_init(void)
>>  	int registered = 0;
>>  	int err;
>>  
>> +#ifdef CONFIG_X86_64
>> +	if (WARN(pat_enabled(),
>> +		 "ivtvfb needs PAT disabled, boot with nopat kernel parameter\n")) {
>> +		return EINVAL;
> 
> Errors are always negative. So: 
> 		return -EINVAL
> 
> Or, perhaps, -ENODEV.
> 
>> +	}
>> +#endif
>> +
>>  	if (ivtvfb_card_id < -1 || ivtvfb_card_id >= IVTV_MAX_CARDS) {
>>  		printk(KERN_ERR "ivtvfb:  ivtvfb_card_id parameter is out of range (valid range: -1 - %d)\n",
>>  		     IVTV_MAX_CARDS - 1);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 0/3] linux: address broken PAT drivers
  2015-06-09  0:57 ` [PATCH v6 0/3] linux: address broken PAT drivers Mauro Carvalho Chehab
@ 2015-06-11 17:30   ` Luis R. Rodriguez
  0 siblings, 0 replies; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-06-11 17:30 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Luis R. Rodriguez, bp, tomi.valkeinen, bhelgaas, linux-media,
	linux-rdma, linux-kernel

On Mon, Jun 08, 2015 at 09:57:12PM -0300, Mauro Carvalho Chehab wrote:
> Em Mon, 08 Jun 2015 17:20:19 -0700
> "Luis R. Rodriguez" <mcgrof@do-not-panic.com> escreveu:
> 
> > From: "Luis R. Rodriguez" <mcgrof@suse.com>
> > 
> > Mauro,
> > 
> > since the ivtv patch is already acked by the driver maintainer
> > and depends on an x86 symbol that went through Boris' tree are you
> > OK in it going through Boris' tree?
> 
> Sure. I just find a minor issues there. After they got solved, feel
> free to submit to Boris with my ack.

OK thanks, I just fixed that, will send now to Boris.

  Luis

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/3] IB/ipath: add counting for MTRR
  2015-06-11 19:54   ` Borislav Petkov
@ 2015-06-12  3:36     ` Doug Ledford
  0 siblings, 0 replies; 11+ messages in thread
From: Doug Ledford @ 2015-06-12  3:36 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Luis R. Rodriguez, mchehab, tomi.valkeinen, bhelgaas, luto,
	linux-media, linux-rdma, linux-kernel, Luis R. Rodriguez,
	Toshi Kani, Roland Dreier, Sean Hefty, Hal Rosenstock,
	Suresh Siddha, Ingo Molnar, Thomas Gleixner, Juergen Gross,
	Daniel Vetter, Dave Airlie, Antonino Daplas,
	Jean-Christophe Plagniol-Villard, infinipath, linux-fbdev

[-- Attachment #1: Type: text/plain, Size: 1872 bytes --]

On 06/11/2015 03:54 PM, Borislav Petkov wrote:
> On Thu, Jun 11, 2015 at 10:50:01AM -0700, Luis R. Rodriguez wrote:
>> From: "Luis R. Rodriguez" <mcgrof@suse.com>
>>
>> There is no good reason not to, we eventually delete it as well.
>>
>> Cc: Toshi Kani <toshi.kani@hp.com>
>> Cc: Roland Dreier <roland@kernel.org>
>> Cc: Sean Hefty <sean.hefty@intel.com>
>> Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
>> Cc: Suresh Siddha <sbsiddha@gmail.com>
>> Cc: Ingo Molnar <mingo@elte.hu>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Juergen Gross <jgross@suse.com>
>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>> Cc: Andy Lutomirski <luto@amacapital.net>
>> Cc: Dave Airlie <airlied@redhat.com>
>> Cc: Antonino Daplas <adaplas@gmail.com>
>> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
>> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> Cc: infinipath@intel.com
>> Cc: linux-rdma@vger.kernel.org
>> Cc: linux-fbdev@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
>> ---
>>  drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
>> index 4ad0b93..70c1f3a 100644
>> --- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
>> +++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
>> @@ -127,7 +127,7 @@ int ipath_enable_wc(struct ipath_devdata *dd)
>>  			   "(addr %llx, len=0x%llx)\n",
>>  			   (unsigned long long) pioaddr,
>>  			   (unsigned long long) piolen);
>> -		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
>> +		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
>>  		if (cookie < 0) {
>>  			{
>>  				dev_info(&dd->pcidev->dev,
>> --
> 
> Doug, ack?
> 

Ack.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/3] IB/ipath: add counting for MTRR
  2015-06-11 17:50 ` [PATCH v6 2/3] IB/ipath: add counting for MTRR Luis R. Rodriguez
@ 2015-06-11 19:54   ` Borislav Petkov
  2015-06-12  3:36     ` Doug Ledford
  0 siblings, 1 reply; 11+ messages in thread
From: Borislav Petkov @ 2015-06-11 19:54 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Luis R. Rodriguez, mchehab, tomi.valkeinen, bhelgaas, luto,
	linux-media, linux-rdma, linux-kernel, Luis R. Rodriguez,
	Toshi Kani, Roland Dreier, Sean Hefty, Hal Rosenstock,
	Suresh Siddha, Ingo Molnar, Thomas Gleixner, Juergen Gross,
	Daniel Vetter, Dave Airlie, Antonino Daplas,
	Jean-Christophe Plagniol-Villard, infinipath, linux-fbdev

On Thu, Jun 11, 2015 at 10:50:01AM -0700, Luis R. Rodriguez wrote:
> From: "Luis R. Rodriguez" <mcgrof@suse.com>
> 
> There is no good reason not to, we eventually delete it as well.
> 
> Cc: Toshi Kani <toshi.kani@hp.com>
> Cc: Roland Dreier <roland@kernel.org>
> Cc: Sean Hefty <sean.hefty@intel.com>
> Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
> Cc: Suresh Siddha <sbsiddha@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Antonino Daplas <adaplas@gmail.com>
> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: infinipath@intel.com
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-fbdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
> ---
>  drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
> index 4ad0b93..70c1f3a 100644
> --- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
> +++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
> @@ -127,7 +127,7 @@ int ipath_enable_wc(struct ipath_devdata *dd)
>  			   "(addr %llx, len=0x%llx)\n",
>  			   (unsigned long long) pioaddr,
>  			   (unsigned long long) piolen);
> -		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
> +		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
>  		if (cookie < 0) {
>  			{
>  				dev_info(&dd->pcidev->dev,
> --

Doug, ack?

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v6 2/3] IB/ipath: add counting for MTRR
  2015-06-11 17:49 Luis R. Rodriguez
@ 2015-06-11 17:50 ` Luis R. Rodriguez
  2015-06-11 19:54   ` Borislav Petkov
  0 siblings, 1 reply; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-06-11 17:50 UTC (permalink / raw)
  To: bp
  Cc: mchehab, tomi.valkeinen, bhelgaas, luto, linux-media, linux-rdma,
	linux-kernel, Luis R. Rodriguez, Toshi Kani, Roland Dreier,
	Sean Hefty, Hal Rosenstock, Suresh Siddha, Ingo Molnar,
	Thomas Gleixner, Juergen Gross, Daniel Vetter, Dave Airlie,
	Antonino Daplas, Jean-Christophe Plagniol-Villard, infinipath,
	linux-fbdev

From: "Luis R. Rodriguez" <mcgrof@suse.com>

There is no good reason not to, we eventually delete it as well.

Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: infinipath@intel.com
Cc: linux-rdma@vger.kernel.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
index 4ad0b93..70c1f3a 100644
--- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
+++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
@@ -127,7 +127,7 @@ int ipath_enable_wc(struct ipath_devdata *dd)
 			   "(addr %llx, len=0x%llx)\n",
 			   (unsigned long long) pioaddr,
 			   (unsigned long long) piolen);
-		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
+		cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
 		if (cookie < 0) {
 			{
 				dev_info(&dd->pcidev->dev,
-- 
2.3.2.209.gd67f9d5.dirty


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-06-12  3:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-09  0:20 [PATCH v6 0/3] linux: address broken PAT drivers Luis R. Rodriguez
2015-06-09  0:20 ` [PATCH v6 1/3] ivtv: use arch_phys_wc_add() and require PAT disabled Luis R. Rodriguez
2015-06-09  0:56   ` Mauro Carvalho Chehab
2015-06-09  6:23     ` Hans Verkuil
2015-06-09  0:20 ` [PATCH v6 2/3] IB/ipath: add counting for MTRR Luis R. Rodriguez
2015-06-09  0:20 ` [PATCH v6 3/3] IB/ipath: use arch_phys_wc_add() and require PAT disabled Luis R. Rodriguez
2015-06-09  0:57 ` [PATCH v6 0/3] linux: address broken PAT drivers Mauro Carvalho Chehab
2015-06-11 17:30   ` Luis R. Rodriguez
2015-06-11 17:49 Luis R. Rodriguez
2015-06-11 17:50 ` [PATCH v6 2/3] IB/ipath: add counting for MTRR Luis R. Rodriguez
2015-06-11 19:54   ` Borislav Petkov
2015-06-12  3:36     ` Doug Ledford

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).