[Nouveau] [Bug 93547] Built failed for "Mesa (master): nouveau: remove use of deprecated nouveau_device:: drm_version"

2016-07-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93547

Ilia Mirkin  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #3 from Ilia Mirkin  ---
This issue generally happens when you don't use packages, but rather "make
install" directly onto your system. What ended up happening is that a file
moved between versions of libdrm, and you probably have a stale version of one
of the header files which is getting included.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [Bug 96836] Kernel unaligned access at TPC[105d9fb4] nvkm_instobj_wr32+0x14/0x20 [nouveau]

2016-07-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96836

--- Comment #3 from Ilia Mirkin  ---
Hmmm... maybe with nv3x the 4K pages aren't such a hard requirement. Definitely
people on PPC64 with 64K pages had trouble with nv4x though.

But, if it worked before, it can work again. Since this isn't exactly *the*
most common setup, you're going to have to do a bit more of the work. Try more
kernels. Nouveau got a huge rewrite in kernel 4.3, try 4.2 maybe? That rewrite
ended up breaking BE briefly, but I fixed it up again and it was working
semi-recently on my FX5200 in a G5 (PPC64, also BE).

iowrite32_native is used all over the place to write to the card's MMIO space
in one of the BARs (can never remember which).

The specific error seems to indicate that we did a wr32 on an instobj to a
non-32-bit-aligned address. This would be very surprising. Please boot with

nouveau.debug=trace

and attach a full log of the result. (It should be large.)

Also, please try several kernels, including both pre- and post-4.3 ones.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [Bug 96836] Kernel unaligned access at TPC[105d9fb4] nvkm_instobj_wr32+0x14/0x20 [nouveau]

2016-07-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96836

--- Comment #2 from Kieron Gillespie  ---
So Sparc64 is a big endian archetecutre. The request to use 4K huge pages is
not possible on Sarc64 as the smallest it supports is 8K (which is what my
system is currently using.)

The card is a GeForce FX5200 128MB DDR PCI

The GPU I am currently testing is a bit of a fossil, but I had great success on
this SPARC system in the past managed to get full hardware acceleration
working, sometime early 2015.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v3 1/7] lib: string: add functions to case-convert strings

2016-07-08 Thread Markus Mayer
Add a collection of generic functions to convert strings to lowercase
or uppercase.

Changing the case of a string (with or without copying it first) seems
to be a recurring requirement in the kernel that is currently being
solved by several duplicated implementations doing the same thing. This
change aims at reducing this code duplication.

The new functions are
void strlcpytoupper(char *dst, const char *src, size_t len);
void strlcpytolower(char *dst, const char *src, size_t len);
void strcpytoupper(char *dst, const char *src);
void strcpytolower(char *dst, const char *src);
void strtoupper(char *s);
void strtolower(char *s);

The "str[l]cpyto*" versions of the function take a destination string
and a source string as arguments. The "strlcpyto*" versions additionally
take a length argument like strlcpy() itself. Lastly, the strto*
functions take a single string argument and modify the passed-in string.

Like strlcpy(), and unlike strncpy(), the functions guarantee NULL
termination of the destination string.

Signed-off-by: Markus Mayer 
---
 include/linux/string.h | 40 
 lib/string.c   | 38 ++
 2 files changed, 78 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 26b6f6a..36c9d14 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -116,6 +116,8 @@ extern void * memchr(const void *,int,__kernel_size_t);
 #endif
 void *memchr_inv(const void *s, int c, size_t n);
 char *strreplace(char *s, char old, char new);
+extern void strlcpytoupper(char *dst, const char *src, size_t len);
+extern void strlcpytolower(char *dst, const char *src, size_t len);
 
 extern void kfree_const(const void *x);
 
@@ -169,4 +171,42 @@ static inline const char *kbasename(const char *path)
return tail ? tail + 1 : path;
 }
 
+/**
+ * strcpytoupper - Copy string and convert to uppercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to uppercase.
+ */
+static inline void strcpytoupper(char *dst, const char *src)
+{
+   strlcpytoupper(dst, src, -1);
+}
+
+/**
+ * strcpytolower - Copy string and convert to lowercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to lowercase.
+ */
+static inline void strcpytolower(char *dst, const char *src)
+{
+   strlcpytolower(dst, src, -1);
+}
+
+/**
+ * strtoupper - Convert string to uppercase.
+ * @s: The string to operate on.
+ */
+static inline void strtoupper(char *s)
+{
+   strlcpytoupper(s, s, -1);
+}
+
+/**
+ * strtolower - Convert string to lowercase.
+ * @s: The string to operate on.
+ */
+static inline void strtolower(char *s)
+{
+   strlcpytolower(s, s, -1);
+}
+
 #endif /* _LINUX_STRING_H_ */
diff --git a/lib/string.c b/lib/string.c
index ed83562..fd8c427 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -952,3 +952,41 @@ char *strreplace(char *s, char old, char new)
return s;
 }
 EXPORT_SYMBOL(strreplace);
+
+/**
+ * strlcpytoupper - Copy a length-limited string and convert to uppercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to uppercase.
+ * @len: Maximum string length. May be SIZE_MAX (-1) to set no limit.
+ */
+void strlcpytoupper(char *dst, const char *src, size_t len)
+{
+   size_t i;
+
+   if (!len)
+   return;
+
+   for (i = 0; i < len && src[i]; ++i)
+   dst[i] = toupper(src[i]);
+   dst[i < len ? i : i - 1] = '\0';
+}
+EXPORT_SYMBOL(strlcpytoupper);
+
+/**
+ * strlcpytolower - Copy a length-limited string and convert to lowercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to lowercase.
+ * @len: Maximum string length. May be SIZE_MAX (-1) to set no limit.
+ */
+void strlcpytolower(char *dst, const char *src, size_t len)
+{
+   size_t i;
+
+   if (!len)
+   return;
+
+   for (i = 0; i < len && src[i]; ++i)
+   dst[i] = tolower(src[i]);
+   dst[i < len ? i : i - 1] = '\0';
+}
+EXPORT_SYMBOL(strlcpytolower);
-- 
2.7.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v3 2/7] drm/nouveau/core: make use of new strlcpytolower() function

2016-07-08 Thread Markus Mayer
Call strlcpytolower() rather than copying the string explicitly and
then walking it to convert it to lowercase.

Signed-off-by: Markus Mayer 
---

The semantics of the new function has changed, so this patch has been
updated since v2 to match the new strlcpy() semantics (no explicit NULL
terminating is required).

See https://patchwork.kernel.org/patch/9215207/ for the previous version.


 drivers/gpu/drm/nouveau/nvkm/core/firmware.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c 
b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
index 34ecd4a..982601e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
@@ -36,16 +36,9 @@ nvkm_firmware_get(struct nvkm_device *device, const char 
*fwname,
 {
char f[64];
char cname[16];
-   int i;
 
/* Convert device name to lowercase */
-   strncpy(cname, device->chip->name, sizeof(cname));
-   cname[sizeof(cname) - 1] = '\0';
-   i = strlen(cname);
-   while (i) {
-   --i;
-   cname[i] = tolower(cname[i]);
-   }
+   strlcpytolower(cname, device->chip->name, sizeof(cname));
 
snprintf(f, sizeof(f), "nvidia/%s/%s.bin", cname, fwname);
return request_firmware(fw, f, device->dev);
-- 
2.7.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v3 6/7] drm/nouveau/fifo/gk104: make use of new strcpytoupper() function

2016-07-08 Thread Markus Mayer
Call strcpytoupper() rather than copying the string explicitly and then
walking it to convert it to uppercase.

Signed-off-by: Markus Mayer 
---
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
index 743f3a1..8d01032 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
@@ -332,10 +332,7 @@ gk104_fifo_intr_fault(struct gk104_fifo *fifo, int unit)
enum nvkm_devidx engidx = nvkm_top_fault(device->top, unit);
if (engidx < NVKM_SUBDEV_NR) {
const char *src = nvkm_subdev_name[engidx];
-   char *dst = en;
-   do {
-   *dst++ = toupper(*src++);
-   } while(*src);
+   strcpytoupper(en, src);
engine = nvkm_device_engine(device, engidx);
}
} else {
-- 
2.7.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v3 0/7] lib: string: add functions to case-convert strings

2016-07-08 Thread Markus Mayer
This series introduces a family of generic string case conversion
functions. This kind of functionality is needed in several places in
the kernel. Right now, everybody seems to be implementing their own
copy of this functionality.

Based on the discussion of the previous version of this series[1] and
the use cases found in the kernel, it does look like having several
flavours of case conversion functions is beneficial. The use cases fall
into three categories:
- copying a string and converting the case while specifying a
  maximum length to mimic strlcpy()
- copying a string and converting the case without specifying a
  length to mimic strcpy()
- converting the case of a string in-place (i.e. modifying the
  string that was passed in)

Consequently, I am proposing these new functions:
void strlcpytoupper(char *dst, const char *src, size_t len);
void strlcpytolower(char *dst, const char *src, size_t len);
void strcpytoupper(char *dst, const char *src);
void strcpytolower(char *dst, const char *src);
void strtoupper(char *s);
void strtolower(char *s);

Several drivers are being modified to make use of the functions above.
Another driver that also makes use of this functionality will be
submitted upstream shortly, which prompted this whole exercise.

The changes made here have been compile-tested, but not tried out, due
to lack of required hardware.

Changes since v2:
  - use strlcpy() semantics not strncpy() semantics, i.e. guarantee
NULL termination
  - as a result strncpyto are now called
strlcpyto
  - make functions void
  - use len == -1 (SIZE_MAX) as no-limit indicator rather then len == 0
  - change PATCH 2/7 to match strlcpy() semantics
  - change PATCH 4/7 to match strlcpy() semantics

Changes since v1:
  - expanded strtolower() into a family of functions that cover use
cases when a length argument is or isn't required and that support
copying the string into a new buffer or changing it in-place 
  - changed the function semantics to return a pointer to the
terminating '\0' character of the modified string
  - added strtoupper() functionality mirroring the above
  - dropped the ACPICA patch, since that code is OS independent and
can't rely on a Linux library function (see [2])
  - Added two new patches replacing strtoupper() implementations

[1] https://lkml.org/lkml/2016/6/30/727
[2] https://lkml.org/lkml/2016/7/1/9



Markus Mayer (7):
  lib: string: add functions to case-convert strings
  drm/nouveau/core: make use of new strlcpytolower() function
  ACPI / device_sysfs: make use of new strtolower() function
  staging: speakup: replace spk_strlwr() with strlcpytolower()
  iscsi-target: replace iscsi_initiatorname_tolower() with strtolower()
  drm/nouveau/fifo/gk104: make use of new strcpytoupper() function
  power_supply: make use of new strcpytoupper() function

 drivers/acpi/device_sysfs.c  |  4 +--
 drivers/gpu/drm/nouveau/nvkm/core/firmware.c |  9 +-
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c |  5 +--
 drivers/power/power_supply_sysfs.c   | 13 +++-
 drivers/staging/speakup/kobjects.c   |  3 +-
 drivers/staging/speakup/main.c   |  3 +-
 drivers/staging/speakup/speakup.h|  1 -
 drivers/staging/speakup/varhandlers.c| 12 ---
 drivers/target/iscsi/iscsi_target_nego.c | 17 +-
 include/linux/string.h   | 40 
 lib/string.c | 38 ++
 11 files changed, 90 insertions(+), 55 deletions(-)

-- 
2.7.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [Bug 91954] "link training failed": nouveau does not recover from monitor suspend

2016-07-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91954

--- Comment #9 from roflawl2...@gmail.com ---
I'm still running into this issue. I posted more detailed information and the
output of dmesg and journalctl on Fedoraforum, here:
http://forums.fedoraforum.org/showthread.php?t=310633

When my system is suspended and wakes back up, the primary LCD is stuck on a
blank white image and sometimes cannot recover when switching TTY's. Dmesg
fills up with this:
[ 270.115821] nouveau :01:00.0: disp: outp 00:0006:0344: link training
failed
[ 270.122646] nouveau :01:00.0: disp: outp 00:0006:0344: link training
failed
[ 270.123698] nouveau :01:00.0: disp: outp 00:0006:0344: link not trained
before attach

Hardware:
HP EliteBook 8440p, Legacy Boot
Nvidia GT218M (NVS 3100M)

Software:
Fedora 24, latest updates, Gnome 3.20.2
Gallium 0.4 on NVA8
Kernel - 4.6.3-300.fc24.x86_64

-- 
You are receiving this mail because:
You are the assignee for the bug.___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Help with nouveau driver

2016-07-08 Thread Ilia Mirkin
On Fri, Jul 8, 2016 at 2:42 PM, abcd  wrote:
> Thanks for the help so far, I have already solved the main problem,
>
> but sadly it seems I can't find out the last step. I hope you can help me
> there...
>
> Here ist the important part: It is trying to load some nvidia module,
> although i have already done apt-get purge nvidia*
>
> [ 4.636] (II) LoadModule: "glx"
> [ 4.638] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
> [ 4.639] (EE) Failed to load /usr/lib/xorg/modules/extensions/libglx.so:
> libnvidia-tls.so.352.79: cannot open shared object file: No such file or
> directory
> [ 4.639] (II) UnloadModule: "glx"
> [ 4.639] (II) Unloading glx
> [ 4.639] (EE) Failed to load module "glx" (loader failed, 7)

Right, so as you identified, that's bad. You still have the nvidia
libglx.so or ... something else weird going on. I recommend asking
someone more familiar with your distro to help you out.

Cheers,

  -ilia
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] Help with nouveau driver

2016-07-08 Thread abcd
Thanks for the help so far, I have already solved the main problem,

but sadly it seems I can't find out the last step. I hope you can help
me there...

Here ist the important part: It is trying to load some nvidia module,
although i have already done apt-get purge nvidia*

[ 4.636] (II) LoadModule: "glx"
[ 4.638] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
[ 4.639] (EE) Failed to load
/usr/lib/xorg/modules/extensions/libglx.so: libnvidia-tls.so.352.79:
cannot open shared object file: No such file or directory
[ 4.639] (II) UnloadModule: "glx"
[ 4.639] (II) Unloading glx
[ 4.639] (EE) Failed to load module "glx" (loader failed, 7)


Full log:

[ 4.394]
X.Org X Server 1.16.4
Release Date: 2014-12-20
[ 4.394] X Protocol Version 11, Revision 0
[ 4.394] Build Operating System: Linux 3.16.0-4-amd64 x86_64 Debian
[ 4.394] Current Operating System: Linux NOMAC 4.6.0-0.bpo.1-amd64
#1 SMP Debian 4.6.1-1~bpo8+1 (2016-06-14) x86_64
[ 4.394] Kernel command line:
BOOT_IMAGE=/boot/vmlinuz-4.6.0-0.bpo.1-amd64
root=UUID=2c330f07-0904-46a0-a554-16ec45d06fdf ro quiet
[ 4.394] Build Date: 11 February 2015  12:32:02AM
[ 4.394] xorg-server 2:1.16.4-1 (http://www.debian.org/support)
[ 4.394] Current version of pixman: 0.32.6
[ 4.394]Before reporting problems, check http://wiki.x.org
   to make sure that you have the latest version.
[ 4.394] Markers: (--) probed, (**) from config file, (==) default
setting,
   (++) from command line, (!!) notice, (II) informational,
   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[ 4.394] (==) Log file: "/var/log/Xorg.0.log", Time: Fri Jul  8
10:40:35 2016
[ 4.397] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[ 4.399] (==) No Layout section.  Using the first Screen section.
[ 4.399] (==) No screen section available. Using defaults.
[ 4.399] (**) |-->Screen "Default Screen Section" (0)
[ 4.399] (**) |   |-->Monitor ""
[ 4.399] (==) No monitor specified for screen "Default Screen Section".
   Using a default monitor configuration.
[ 4.399] (==) Automatically adding devices
[ 4.399] (==) Automatically enabling devices
[ 4.399] (==) Automatically adding GPU devices
[ 4.401] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not
exist.
[ 4.401]Entry deleted from font path.
[ 4.403] (==) FontPath set to:
   /usr/share/fonts/X11/misc,
   /usr/share/fonts/X11/100dpi/:unscaled,
   /usr/share/fonts/X11/75dpi/:unscaled,
   /usr/share/fonts/X11/Type1,
   /usr/share/fonts/X11/100dpi,
   /usr/share/fonts/X11/75dpi,
   built-ins
[ 4.403] (**) ModulePath set to "/usr/lib/xorg/modules/"
[ 4.403] (II) The server relies on udev to provide the list of input
devices.
   If no devices become available, reconfigure udev or disable
AutoAddDevices.
[ 4.403] (II) Loader magic: 0x55db3d382d80
[ 4.403] (II) Module ABI versions:
[ 4.403]X.Org ANSI C Emulation: 0.4
[ 4.403]X.Org Video Driver: 18.0
[ 4.403]X.Org XInput driver : 21.0
[ 4.403]X.Org Server Extension : 8.0
[ 4.403] (II) xfree86: Adding drm device (/dev/dri/card0)
[ 4.404] (--) PCI:*(0:1:0:0) 10de:1183:1043:841e rev 161, Mem @
0xee00/16777216, 0xe000/134217728, 0xe800/33554432, I/O @
0xe000/128, BIOS @ 0x/131072
[ 4.404] (II) LoadModule: "glx"
[ 4.406] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
[ 4.408] (EE) Failed to load
/usr/lib/xorg/modules/extensions/libglx.so: libnvidia-tls.so.352.79:
cannot open shared object file: No such file or directory
[ 4.408] (II) UnloadModule: "glx"
[ 4.408] (II) Unloading glx
[ 4.408] (EE) Failed to load module "glx" (loader failed, 7)
[ 4.408] (==) Matched nouveau as autoconfigured driver 0
[ 4.408] (==) Matched nv as autoconfigured driver 1
[ 4.408] (==) Matched nouveau as autoconfigured driver 2
[ 4.408] (==) Matched nv as autoconfigured driver 3
[ 4.408] (==) Matched modesetting as autoconfigured driver 4
[ 4.408] (==) Matched fbdev as autoconfigured driver 5
[ 4.408] (==) Matched vesa as autoconfigured driver 6
[ 4.408] (==) Assigned the driver to the xf86ConfigLayout
[ 4.408] (II) LoadModule: "nouveau"
[ 4.408] (II) Loading /usr/lib/xorg/modules/drivers/nouveau_drv.so
[ 4.410] (II) Module nouveau: vendor="X.Org Foundation"
[ 4.410]compiled for 1.16.0, module version = 1.0.11
[ 4.410]Module class: X.Org Video Driver
[ 4.410]ABI class: X.Org Video Driver, version 18.0
[ 4.410] (II) LoadModule: "nv"
[ 4.410] (WW) Warning, couldn't open module nv
[ 4.410] (II) UnloadModule: "nv"
[ 4.410] (II) Unloading nv
[ 4.410] (EE) Failed to load module "nv" (module does not exist, 0)
[ 4.410] (II) LoadModule: "modesetting"
[ 4.410] (WW) Warning, couldn't open module modesetting
[ 4.410] (II) UnloadModule: "modesetting"
[ 4.410] (II) Unloading modesett

Re: [Nouveau] [PATCH v2 1/7] lib: string: add functions to case-convert strings

2016-07-08 Thread Markus Mayer
On 7 July 2016 at 17:19, Rasmus Villemoes  wrote:
> On Tue, Jul 05 2016, Markus Mayer  wrote:
>
>> +/**
>> + * strncpytoupper - Copy a length-limited string and convert to uppercase.
>> + * @dst: The buffer to store the result.
>> + * @src: The string to convert to uppercase.
>> + * @len: Maximum string length. May be 0 to set no limit.
>> + *
>> + * Returns pointer to terminating '\0' in @dst.
>> + */
>> +char *strncpytoupper(char *dst, const char *src, size_t len)
>> +{
>> + size_t i;
>> +
>> + for (i = 0; src[i] != '\0' && (i < len || !len); i++)
>> + dst[i] = toupper(src[i]);
>> + if (i < len || !len)
>> + dst[i] = '\0';
>> +
>> + return dst + i;
>> +}
>
> Hm, this seems to copy the insane semantics from strncpy of not
> guaranteeing '\0'-termination.

Yeah. I've been tossing that one around a bit. The reason I did it
this way in the end is due to the use cases I found. strncpy() is
being used there and I was a little wary to make too many changes all
at once.

But I understand your point. I'll look at it again and see what
changes might be required in the code that used strncpy() before.

> Why use 0 as a sentinel, when (size_t)-1 == SIZE_MAX would work just as
> well and require a little less code (no || !len)?

I'll change that.

> I regret suggesting this return semantics and now agree that void would
> be better, especially since there doesn't seem to be anyone who can
> use this (or any other) return value. How about
>
> if (!len)
>return;
>
> for (i = 0; i < len && src[i]; ++i)
>   dst[i] = toupper(src[i]);
> dst[i < len ? i : i-1] = '\0';

This makes sense.

> (I think you must do i < len before testing src[i], since the len
> parameter should be an upper bound on the number of bytes to access in
> both src and dst).
>
> Rasmus

Thanks,
-Markus
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH v2 0/4] nouveau RPM fixes for Optimus

2016-07-08 Thread Hans de Goede

Hi,

On 08-07-16 01:38, Peter Wu wrote:

Hi,

Here are two patches to fix an issue reported on kernel bugzilla (infinite loop
due to unchecked function) and a more important fix to fix hanging Optimus
machines when runtime PM is enabled (with pm/pci patches).

See the first version[1] for a background on the fixed problems. This is the
second revision of incorporating feedback from Emil Velikov (patch 1), Mika
Westerberg (patch 4). Patches 2 and 3 are unchanged.
The previous patchset had R-b from Hans de Goede, I think they are still valid.

Noteworthy is that the fourth patch now checks directly for _PR3. The commit
message is updated to emphasize that memory/disk corruption is fixed for some
machines.


This patchset can be merged before or after the pci/pm changes[2] (expected to
be merged for 4.8), see the original posting[1] for consequences. I have tested
it on top of v4.7-rc5. To make patch four work properly, Lukas' RPM refcounting
patches should be included. A similar (open/new) RPM refcounting issue in
snd-hda-intel should also be fixed. Otherwise the bridge will not really sleep.

There is another minor patch for nouveau_pr3_present, but it is not included
here because it depends on visibility of pci_bridge_d3_possible(). I'll send a
separate mail for this to linux-pci.


Patches 1 - 3 are:

Reviewed-by: Hans de Goede 

Patch 4 looks good to me too, but I'm not familiar enough with the
pci-e pm stuff to feel comfortable acking it.

Regards,

Hans





Kind regards,
Peter

 [1]: https://lists.freedesktop.org/archives/nouveau/2016-May/025116.html
 [2]: https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/?h=pci/pm

Peter Wu (4):
  drm/nouveau/acpi: ensure matching ACPI handle and supported functions
  drm/nouveau/acpi: return supported DSM functions
  drm/nouveau/acpi: check for function 0x1B before using it
  drm/nouveau/acpi: fix lockup with PCIe runtime PM

 drivers/gpu/drm/nouveau/nouveau_acpi.c | 103 +
 1 file changed, 66 insertions(+), 37 deletions(-)


___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH v2 4/4] drm/nouveau/acpi: fix lockup with PCIe runtime PM

2016-07-08 Thread Mika Westerberg
On Fri, Jul 08, 2016 at 01:38:27AM +0200, Peter Wu wrote:
> Since "PCI: Add runtime PM support for PCIe ports", the parent PCIe port
> can be runtime-suspended which disables power resources via ACPI. This
> is incompatible with DSM, resulting in a GPU device which is still in D3
> and locks up the kernel on resume (on a Clevo P651RA, GTX965M).
> 
> Mirror the behavior of Windows 8 and newer[1] (as observed via an AMLi
> debugger trace) and stop using the DSM functions for D3cold when power
> resources are available on the parent PCIe port.
> 
> pci_d3cold_disable() is not used because on some machines, the old DSM
> method is broken. On a Lenovo T440p (GT 730M) memory and disk corruption
> would occur, but that is fixed with this patch[2].

Fair enough.

>  [1]: 
> https://msdn.microsoft.com/windows/hardware/drivers/bringup/firmware-requirements-for-d3cold
>  [2]: 
> https://github.com/Bumblebee-Project/bbswitch/issues/78#issuecomment-223549072
> 
>  v2: simply check directly for _PR3. Added affected machines.
> 
> Signed-off-by: Peter Wu 

One nitpick below but otherwise looks reasonable to me.

Reviewed-by: Mika Westerberg 

BTW, thanks for doing this :)

> ---
>  drivers/gpu/drm/nouveau/nouveau_acpi.c | 33 +
>  1 file changed, 29 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c 
> b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> index ad273ad..38a6445 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> @@ -46,6 +46,7 @@ static struct nouveau_dsm_priv {
>   bool dsm_detected;
>   bool optimus_detected;
>   bool optimus_flags_detected;
> + bool optimus_skip_dsm;
>   acpi_handle dhandle;
>   acpi_handle rom_handle;
>  } nouveau_dsm_priv;
> @@ -212,9 +213,26 @@ static const struct vga_switcheroo_handler 
> nouveau_dsm_handler = {
>   .get_client_id = nouveau_dsm_get_client_id,
>  };
>  
> +/* Firmware supporting Windows 8 or later do not use _DSM to put the device 
> into
> + * D3cold, they instead rely on disabling power resources on the parent. */

You should follow standard block comment style here.

> +static bool nouveau_pr3_present(struct pci_dev *pdev)
> +{
> + struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
> + struct acpi_device *parent_adev;
> +
> + if (!parent_pdev)
> + return false;
> +
> + parent_adev = ACPI_COMPANION(&parent_pdev->dev);
> + if (!parent_adev)
> + return false;
> +
> + return acpi_has_method(parent_adev->handle, "_PR3");
> +}
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau