runtests.c: Fix memleaks

runtests.c: Fix memleaks

--- expat/tests/runtests.c
+++ expat/tests/runtests.c
@@ -2929,6 +2929,7 @@
         xml_failure(ext_parser);
     CharData_CheckXMLChars(&storage, expected);

+    XML_ParserFree(ext_parser);
     return XML_STATUS_OK;
 }

@@ -3415,6 +3416,8 @@
     if (_XML_Parse_SINGLE_BYTES(ext_parser, text, strlen(text),
                                 XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
+
+    XML_ParserFree(ext_parser);
     return XML_STATUS_OK;
 }


added failover option to keycode parsing

--- src/afterstep/menuitem.c
+++ src/afterstep/menuitem.c
@@ -283,10 +283,15 @@
 		if (keysym != NoSymbol && (keycode = XKeysymToKeycode (dpy, keysym)) != 0)
 		{
 			XDisplayKeycodes (dpy, &min, &max);
-			for (i = min; i <= max; i++)
-				if (XKeycodeToKeysym (dpy, i, 0) == keysym)
-					break;
-
+			for (m = 0; m <= 8; m++)   /* is 8 really the maximum number of modifiers to search through? */
+			{
+				for (i = min; i <= max; i++)
+					if (XKeycodeToKeysym (dpy, i, m) == keysym)
+						break;
+			  	if (i <= max)
+			    	break;
+			}
+
 			if (i <= max)
 				keycode = i ;


auth: Improved passwd-file's EACCES error messages.

--- src/auth/db-passwd-file.c
+++ src/auth/db-passwd-file.c
@@ -11,6 +11,7 @@
 #include "istream.h"
 #include "hash.h"
 #include "str.h"
+#include "eacces-error.h"
 #include "var-expand.h"

 #include <stdlib.h>
@@ -164,7 +165,13 @@

 	fd = open(pw->path, O_RDONLY);
 	if (fd == -1) {
-		i_error("passwd-file %s: Can't open file: %m", pw->path);
+		if (errno == EACCES) {
+			i_error("passwd-file %s: %s", pw->path,
+				eacces_error_get("open", pw->path));
+		} else {
+			i_error("passwd-file %s: Can't open file: %m",
+				pw->path);
+		}
 		return FALSE;
 	}

@@ -239,8 +246,12 @@
 	if (stat(pw->path, &st) < 0) {
 		/* with variables don't give hard errors, or errors about
 		   nonexisting files */
-		if (errno != ENOENT)
+		if (errno == EACCES) {
+			i_error("passwd-file %s: %s", pw->path,
+				eacces_error_get("stat", pw->path));
+		} else if (errno != ENOENT) {
 			i_error("passwd-file %s: stat() failed: %m", pw->path);
+		}

 		if (pw->db->default_file != pw)
 			passwd_file_free(pw);


created mDNS[Get/Process]FDSetServer functions for the server to hide the mDNSPosix[Get/Process]FDSet functions that embedded mDNS needs.

--- cal/mdnssd-bip/server/thread-functions.c
+++ cal/mdnssd-bip/server/thread-functions.c
@@ -24,6 +24,26 @@
 #include "cal-server.h"
 #include "cal-mdnssd-bip.h"
 #include "cal-server-mdnssd-bip.h"
+
+
+void mDNSGetFDSetServer(
+    int *max_fd,
+    fd_set *readers,
+    struct timeval *timeout
+) {
+#ifdef HAVE_EMBEDDED_MDNSSD
+    mDNSPosixGetFDSet(&mDNSStorage, max_fd, readers, timeout);
+#endif
+}
+
+void mDNSProcessFDSetServer(
+    fd_set *readers
+) {
+#ifdef HAVE_EMBEDDED_MDNSSD
+    mDNSPosixProcessFDSet(&mDNSStorage, readers);
+#endif
+}
+

 // key is a bip peer name "bip://$HOST:$PORT"
 // value is a bip_peer_t*
@@ -946,8 +966,16 @@
             max_fd = Max(max_fd, fd);
         }

+        cal_pthread_mutex_lock(&avahi_mutex);
+        mDNSGetFDSetServer(&max_fd, &readers, timeout);
+        cal_pthread_mutex_unlock(&avahi_mutex);
+
         // block until there's something to do
-        r = select(max_fd + 1, &readers, NULL, NULL, NULL);
+        r = select(max_fd + 1, &readers, NULL, NULL, timeout);
+
+        cal_pthread_mutex_lock(&avahi_mutex);
+        mDNSProcessFDSetServer(&readers);
+        cal_pthread_mutex_unlock(&avahi_mutex);

         // First, see if we can write to our peers
         {


rtc-pcf85063: break comments at 80 chars

--- linux_kernel_modules/rtc-pcf85063/rtc-pcf85063.c
+++ linux_kernel_modules/rtc-pcf85063/rtc-pcf85063.c
@@ -7,13 +7,12 @@
  *
  * based on the other drivers in this same directory.
  *
- * Sierra Wireless Inc. - Added on functionality to allow
- * control of the square-wave clkout frequencies via sysfs entries.
- * Note, this was developed in the context of the MangOH Yellow board
- * which has the square-wave clkout pin connected to a buzzer. Thus,
- * one can drive the buzzer for the allowable frequencies, note
- * humans can only recognize 20 - 20KHz (some of us, like your author
- * even less).
+ * Sierra Wireless Inc. - Added on functionality to allow control of the
+ * square-wave clkout frequencies via sysfs entries. Note, this was developed in
+ * the context of the MangOH Yellow board which has the square-wave clkout pin
+ * connected to a buzzer. Thus, one can drive the buzzer for the allowable
+ * frequencies, note humans can only recognize 20 - 20KHz (some of us, like your
+ * author even less).
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -58,13 +57,12 @@
 static struct i2c_driver pcf85063_driver;

 /*
- * We need to define a mutex here because the rtc_sync module in MangOH
- * can call into rtc_set_time while sysfs is changing the square-wave
- * output frequencies. Ditto for rtc_read_time from rtc_sync.
- * We wouldn't need the mutex if a workQ handler was defined for this device
- * but then the rtc_sync module would not be generic. Just be aware that
- * any rtc chip that allows rtc_sync to call into it needs a mutex if any
- * other threaded access will concurrently exist.
+ * We need to define a mutex here because the rtc_sync module in MangOH can call
+ * into rtc_set_time while sysfs is changing the square-wave output frequencies.
+ * Ditto for rtc_read_time from rtc_sync. We wouldn't need the mutex if a workQ
+ * handler was defined for this device but then the rtc_sync module would not be
+ * generic. Just be aware that any rtc chip that allows rtc_sync to call into it
+ * needs a mutex if any other threaded access will concurrently exist.
  */
 static DEFINE_MUTEX(pcf85063_rtc_mutex);


Update 36/20 to be not doable by non-relational intervals

--- tests/regression/36-octapron/20-traces-even-more-rpb.c
+++ tests/regression/36-octapron/20-traces-even-more-rpb.c
@@ -2,16 +2,16 @@
 #include <pthread.h>
 #include <assert.h>

-int g = 17; // matches write in t_fun
-int h = 14; // matches write in t_fun
+int g = 17;
+int h = 14;
 pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t B = PTHREAD_MUTEX_INITIALIZER;

 void *t_fun(void *arg) {
-  int t;
+  int t, r; // rand
   pthread_mutex_lock(&A);
   pthread_mutex_lock(&B);
-  g = 17;
+  g = r;
   t = g;
   h = t - 3;
   pthread_mutex_unlock(&B);
@@ -51,7 +51,7 @@

   pthread_mutex_lock(&A);
   pthread_mutex_lock(&B);
-  assert(g >= h); // UNKNOWN?
+  assert(g >= h); // UNKNOWN (for protection at least)
   pthread_mutex_unlock(&B);
   pthread_mutex_unlock(&A);
   return 0;


Fixed some PDCurses-related bugs

Fixed some PDCurses-related bugs

--- src/bzadmin/pdcurses_adapter.h
+++ src/bzadmin/pdcurses_adapter.h
@@ -46,13 +46,23 @@
   return wmove(stdscr, y, x);
 }

+#undef nonl
+inline int nonl() {
+  return OK;
+}
+

 // make it compatible with ncurses
-#define waddstr(W, C) pd_waddstr(W, C)
 inline int pd_waddstr(WINDOW* w, const char* str) {
   char* newStr = new char[strlen(str) + 1];
   strcpy(newStr, str);
-  return ::waddstr(w, newStr);
+  return waddstr(w, newStr);
 }
+#define waddstr(W, C) pd_waddstr(W, C)

-
+inline int pd_endwin() {
+  int i = endwin();
+  XCursesExit();
+  return i;
+}
+#define endwin pd_endwin


NodesWalk: fix stupid bugs in NodesWalk

NodesWalk: fix stupid bugs in NodesWalk

Order of setting lastwalkid matters!

Signed-off-by: Marek Chalupa <a05df156a69ad59faa9af9b666ef78009594c145@gmail.com>

--- src/analysis/NodesWalk.h
+++ src/analysis/NodesWalk.h
@@ -51,7 +51,6 @@
         for (IT I = begin; I != end; ++I) {
             NodePtrT tmp = *I;
             AnalysesAuxiliaryData& aad = this->getAnalysisData(tmp);
-            aad.lastwalkid = run_id;

             if (aad.lastwalkid == run_id)
                 continue;
@@ -64,7 +63,6 @@

     QueueT queue;
 };
-

 #ifdef ENABLE_CFG
 template <typename NodePtrT, typename QueueT>
@@ -79,21 +77,23 @@
         QueueT queue;
         queue.push(entry);

+        // set up the value of new walk and set it to entry node
         unsigned int runid = ++walk_run_counter;
+        AnalysesAuxiliaryData& aad = this->getAnalysisData(entry);
+        aad.lastwalkid = runid;

         while (!queue.empty()) {
             BBlockPtrT BB = queue.front();
             queue.pop();

-            AnalysesAuxiliaryData& aad = this->getAnalysisData(BB);
-            aad.lastwalkid = runid;
-
             func(BB, data);

             for (BBlockPtrT S : BB->successors()) {
                 AnalysesAuxiliaryData& sad = this->getAnalysisData(S);
-                if (sad.lastwalkid != runid)
+                if (sad.lastwalkid != runid) {
+                    sad.lastwalkid = runid;
                     queue.push(S);
+                }
             }
         }
     }


Set a default content type if none would be sent otherwise

--- src/backends/files/main.c
+++ src/backends/files/main.c
@@ -56,6 +56,8 @@

   multimap_t * type_map;

+  content_type_t * default_content_type;
+
   char * cwd;
   size_t cwd_length;

@@ -89,7 +91,7 @@

 } file_server_request_t;

-static void register_content_type(multimap_t * m, char * extension, char * type, char * subtype)
+static content_type_t * register_content_type(multimap_t * m, char * extension, char * type, char * subtype)
 {
   content_type_t * t = malloc(sizeof(content_type_t));

@@ -98,6 +100,8 @@
   t->subtype = subtype;

   multimap_put(m, extension, t);
+
+  return t;
 }

 static void files_backend_init_type_map(file_server_t * fs)
@@ -112,7 +116,9 @@
   register_content_type(fs->type_map, "gif", "image", "gif");
   register_content_type(fs->type_map, "png", "image", "png");
   register_content_type(fs->type_map, "log", "text", "plain");
-  register_content_type(fs->type_map, "bin", "application", "octet-stream");
+  content_type_t * default_ct = register_content_type(fs->type_map, "bin", "application", "octet-stream");
+
+  fs->default_content_type = default_ct;
 }

 static void files_backend_start(backend_t * backend)
@@ -285,8 +291,9 @@
   return t;
 }

-static content_type_t * content_type_for_path(multimap_t * type_map, char * path, char * accept_header)
-{
+static content_type_t * content_type_for_path(file_server_t * fs, char * path, char * accept_header)
+{
+  multimap_t * type_map = fs->type_map;
   char * extension = file_extension(path);

   log_debug("Got extension: %s", extension);
@@ -370,6 +377,11 @@
     current = next;
   }

+  // return the default of application/octet-stream if nothing else matches
+  if (!match) {
+    match = fs->default_content_type;
+  }
+
   return match;
 }

@@ -398,7 +410,7 @@

     char * accept_header = http_request_header_get(fs_request->response->request, "accept");
     log_debug("Accept header: %s", accept_header);
-    content_type_t * content_type = content_type_for_path(fs->type_map, path, accept_header);
+    content_type_t * content_type = content_type_for_path(fs, path, accept_header);

     if (content_type) {
       char content_type_s[strlen(content_type->type) + strlen(content_type->subtype) + 2];


Remove #include <winsock2.h>

Remove #include <winsock2.h>

--- xbyak/xbyak.h
+++ xbyak/xbyak.h
@@ -72,7 +72,6 @@
 	#define XBYAK_STD_UNORDERED_MULTIMAP std::multimap
 #endif
 #ifdef _WIN32
-	#include <winsock2.h>
 	#include <windows.h>
 	#include <malloc.h>
 	#define XBYAK_TLS __declspec(thread)


telnet-based CLI skeleton

telnet-based CLI skeleton

--- src/apps/relay/turncli.c
+++ src/apps/relay/turncli.c
@@ -88,6 +88,7 @@
 	size_t cmds;
 	struct bufferevent *bev;
 	ioa_addr addr;
+	telnet_t *ts;
 };

 ///////////////////////////////
@@ -105,13 +106,42 @@

 static char CLI_CURSOR[] = "> ";

+static const telnet_telopt_t cli_telopts[] = {
+    { TELNET_TELOPT_ECHO,      TELNET_WONT, TELNET_DONT },
+    { TELNET_TELOPT_TTYPE,     TELNET_WONT, TELNET_DONT },
+    { TELNET_TELOPT_COMPRESS2, TELNET_WONT, TELNET_DONT },
+    { TELNET_TELOPT_ZMP,       TELNET_WONT, TELNET_DONT },
+    { TELNET_TELOPT_MSSP,      TELNET_WONT, TELNET_DONT },
+    { TELNET_TELOPT_BINARY,    TELNET_WONT, TELNET_DONT },
+    { TELNET_TELOPT_NAWS,      TELNET_WONT, TELNET_DONT },
+    { -1, 0, 0 }
+  };
+
 ///////////////////////////////

+static void close_cli_session(struct cli_session* cs);
+
+static int run_cli_output(struct cli_session* cs, const char *buf, unsigned int len)
+{
+	if(cs && buf && len) {
+		if(bufferevent_write(cs->bev, buf, len)< 0) {
+			return -1;
+		}
+		return 0;
+	}
+	return -1;
+}
+
 static void close_cli_session(struct cli_session* cs)
 {
 	if(cs) {

 		addr_debug_print(cliserver.verbose, &(cs->addr),"CLI session disconnected from");
+
+		if(cs->ts) {
+			telnet_free(cs->ts);
+			cs->ts = NULL;
+		}

 		if(cs->bev) {
 			bufferevent_flush(cs->bev,EV_WRITE,BEV_FLUSH);
@@ -132,23 +162,26 @@
 static void type_cli_cursor(struct cli_session* cs)
 {
 	if(cs && (cs->bev)) {
-		if (bufferevent_write(cs->bev, CLI_CURSOR,strlen(CLI_CURSOR))< 0) {
-			close_cli_session(cs);
-		}
-	}
-}
-
-static int run_cli_input(struct cli_session* cs, stun_buffer *buf)
+		telnet_send(cs->ts, CLI_CURSOR, strlen(CLI_CURSOR));
+	}
+}
+
+static int run_cli_input(struct cli_session* cs, const char *buf0, unsigned int len)
 {
 	int ret = 0;

-	if(cs && buf) {
-
-		char *cmd = (char*)(buf->buf);
+	if(cs && buf0 && cs->ts && cs->bev) {
+
+		char *buf = strdup(buf0);
+
+		char *cmd = buf;

 		while((cmd[0]==' ') || (cmd[0]=='\t')) ++cmd;

-		size_t sl = strlen(cmd);
+		size_t sl = len;
+
+		sl = strlen(cmd);
+
 		while(sl) {
 			char c = cmd[sl-1];
 			if((c==10)||(c==13)) {
@@ -169,10 +202,7 @@
 						close_cli_session(cs);
 					} else {
 						const char* ipwd="Enter password: ";
-						if (bufferevent_write(cs->bev,
-								ipwd,strlen(ipwd))< 0) {
-							close_cli_session(cs);
-						}
+						telnet_send(cs->ts,ipwd,strlen(ipwd));
 					}
 				} else {
 					cs->auth_completed = 1;
@@ -181,26 +211,28 @@
 				}
 			} else if((strcmp(cmd,"bye") == 0)||(strcmp(cmd,"quit") == 0)||(strcmp(cmd,"exit") == 0)) {
 				const char* str="Bye !";
-				bufferevent_write(cs->bev,str,strlen(str));
+				telnet_send(cs->ts,str,strlen(str));
 				close_cli_session(cs);
 				ret = -1;
 			} else if((strcmp(cmd,"halt") == 0)||(strcmp(cmd,"shutdown") == 0)||(strcmp(cmd,"stop") == 0)) {
 				addr_debug_print(1, &(cs->addr),"CLI user sent shutdown command");
 				const char* str="TURN server is shutting down";
-				bufferevent_write(cs->bev,str,strlen(str));
+				telnet_send(cs->ts,str,strlen(str));
 				close_cli_session(cs);
 				exit(0);
 			} else if((strcmp(cmd,"?") == 0)||(strcmp(cmd,"h") == 0)||(strcmp(cmd,"help") == 0)) {
-				bufferevent_write(cs->bev,CLI_HELP_STR,strlen(CLI_HELP_STR));
+				telnet_send(cs->ts,CLI_HELP_STR,strlen(CLI_HELP_STR));
 				type_cli_cursor(cs);
 			} else {
 				const char* str="Unknown command\n";
-				bufferevent_write(cs->bev,str,strlen(str));
+				telnet_send(cs->ts,str,strlen(str));
 				type_cli_cursor(cs);
 			}
 		} else {
 			type_cli_cursor(cs);
 		}
+
+		free(buf);
 	}

 	return ret;
@@ -211,6 +243,9 @@
 	if (bev && arg) {

 		struct cli_session* cs = (struct cli_session*) arg;
+
+		if(!(cs->ts))
+			return;

 		stun_buffer buf;

@@ -227,8 +262,7 @@
 			buf.len = len;
 			buf.buf[len]=0;

-			if(run_cli_input(cs, &buf)<0)
-				return;
+			telnet_recv(cs->ts, (const char *)buf.buf, (unsigned int)(buf.len));
 		}
 	}
 }
@@ -246,6 +280,28 @@

 			close_cli_session(cs);
 		}
+	}
+}
+
+static void cli_telnet_event_handler(telnet_t *telnet, telnet_event_t *event, void *user_data)
+{
+	if (user_data && telnet) {
+
+		struct cli_session *cs = (struct cli_session *) user_data;
+
+		switch (event->type){
+		case TELNET_EV_DATA:
+			run_cli_input(cs, event->data.buffer, event->data.size);
+			break;
+		case TELNET_EV_SEND:
+			run_cli_output(cs, event->data.buffer, event->data.size);
+			break;
+		case TELNET_EV_ERROR:
+			TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "TELNET error: %s", event->error.msg);
+			break;
+		default:
+			;
+		};
 	}
 }

@@ -275,17 +331,20 @@
 	bufferevent_setwatermark(clisession->bev, EV_READ, 1, BUFFEREVENT_HIGH_WATERMARK);
 	bufferevent_enable(clisession->bev, EV_READ); /* Start reading. */

-	if (bufferevent_write(clisession->bev,
-		CLI_GREETING_STR,strlen(CLI_GREETING_STR))< 0) {
+	clisession->ts = telnet_init(cli_telopts, cli_telnet_event_handler, 0, clisession);
+
+	if(!(clisession->ts)) {
+		const char *str = "Cannot open telnet session\n";
+		addr_debug_print(cliserver.verbose, (ioa_addr*)sa,str);
 		close_cli_session(clisession);
-	} else if(cli_password[0]) {
-		const char* ipwd="Enter password: ";
-		if (bufferevent_write(clisession->bev,
-				ipwd,strlen(ipwd))< 0) {
-			close_cli_session(clisession);
-		}
 	} else {
-		type_cli_cursor(clisession);
+		telnet_send(clisession->ts, CLI_GREETING_STR, strlen(CLI_GREETING_STR));
+		if(cli_password[0]) {
+			const char* ipwd="Enter password: ";
+			telnet_send(clisession->ts,ipwd,strlen(ipwd));
+		} else {
+			type_cli_cursor(clisession);
+		}
 	}
 }


as-app-desktop: don't deference invalid lists

Malformed .desktop files might causes crashes when
returned lists are NULL.

--- libappstream-glib/as-app-desktop.c
+++ libappstream-glib/as-app-desktop.c
@@ -236,7 +236,7 @@
 						   G_KEY_FILE_DESKTOP_GROUP,
 						   key,
 						   NULL, NULL);
-		for (i = 0; list[i] != NULL; i++) {
+		for (i = 0; list != NULL && list[i] != NULL; i++) {
 			const gchar *category_blacklist[] = {
 				"X-GNOME-Settings-Panel",
 				"X-Unity-Settings-Panel",
@@ -271,7 +271,7 @@
 						   G_KEY_FILE_DESKTOP_GROUP,
 						   key,
 						   NULL, NULL);
-		for (i = 0; list[i] != NULL; i++) {
+		for (i = 0; list != NULL && list[i] != NULL; i++) {
 			g_auto(GStrv) kw_split = NULL;
 			kw_split = g_strsplit (list[i], ",", -1);
 			for (j = 0; kw_split[j] != NULL; j++) {
@@ -291,7 +291,7 @@
 							  key,
 							  locale,
 							  NULL, NULL);
-		for (i = 0; list[i] != NULL; i++) {
+		for (i = 0; list != NULL && list[i] != NULL; i++) {
 			g_auto(GStrv) kw_split = NULL;
 			kw_split = g_strsplit (list[i], ",", -1);
 			for (j = 0; kw_split[j] != NULL; j++) {
@@ -306,7 +306,7 @@
 						   G_KEY_FILE_DESKTOP_GROUP,
 						   key,
 						   NULL, NULL);
-		for (i = 0; list[i] != NULL; i++)
+		for (i = 0; list != NULL && list[i] != NULL; i++)
 			as_app_add_mimetype (app, list[i]);

 	} else if (g_strcmp0 (key, "X-AppInstall-Package") == 0) {


we build everything with _GNU_SOURCE now

--- libc/sysdeps/linux/bfin/crtreloc.c
+++ libc/sysdeps/linux/bfin/crtreloc.c
@@ -28,7 +28,6 @@

 #ifdef __BFIN_FDPIC__

-#define _GNU_SOURCE 1
 #include <sys/types.h>
 #include <link.h>


Actually, some arches do support _syscall6, so implement a generic version for them...  -Erik

--- libc/sysdeps/linux/common/mmap64.c
+++ libc/sysdeps/linux/common/mmap64.c
@@ -17,17 +17,13 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */

+/* Massivly hacked up for uClibc by Erik Andersen */
+
 #include <errno.h>
 #include <unistd.h>
 #include <sysdep.h>
 #include <sys/mman.h>

-/* Massivly hackd up for uClibc by Erik Andersen
- *
- * This version is a stub that just chops off everything at the mmap 32 bit
- * mmap() address space...  You need to add in an arch specific implementation
- * to override this as there is not a generic way for me to implement this
- * particular syscall. */

 #if defined __UCLIBC_HAS_LFS__

@@ -44,7 +40,17 @@
 # undef __USE_FILE_OFFSET64
 #endif

-#undef	creat
+
+#if ! defined __NR_mmap2 || ! defined _syscall6
+
+/*
+ * This version is a stub that just chops off everything at the mmap 32 bit
+ * mmap() address space...  You will probably need to add in an arch specific
+ * implementation to override this as there is not a generic way for me to
+ * implement this particular syscall if your arch lacks _syscall6...
+ *
+*/
+
 __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t offset)
 {
     if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len))
@@ -55,5 +61,28 @@

     return mmap (addr, len, prot, flags, fd, (off_t) offset);
 }
+
+#else
+
+#define __NR___syscall_mmap2	    __NR_mmap2
+static inline _syscall6(void *, __syscall_mmap2, void *, addr,
+	size_t len, int, prot, int, flags, int, fd, off_t, offset);
+
+/* This is always 12, even on architectures where PAGE_SHIFT != 12.  */
+# ifndef MMAP2_PAGE_SHIFT
+#  define MMAP2_PAGE_SHIFT 12
+# endif
+
+void * __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
+{
+    void *result;
+    if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
+	__set_errno (EINVAL);
+	return MAP_FAILED;
+    }
+    return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
+}
+
+#endif
 #endif /* __UCLIBC_HAS_LFS__ */


if __NR__newselect and __NR_select are unavailable, fall back to __NR_pselect6

--- libc/sysdeps/linux/common/select.c
+++ libc/sysdeps/linux/common/select.c
@@ -12,6 +12,27 @@

 extern __typeof(select) __libc_select;

+#if !defined(__NR__newselect) && !defined(__NR_select)
+
+# define __NR___libc_pselect6 __NR_pselect6
+_syscall6(int, __libc_pselect6, int, n, fd_set *, readfds, fd_set *, writefds,
+	fd_set *, exceptfds, const struct timespec *, timeout,
+	const sigset_t *, sigmask);
+
+int __libc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+                  struct timeval *timeout)
+{
+	struct timespec _ts, *ts = 0;
+	if (timeout) {
+		_ts.tv_sec = timeout->tv_sec;
+		_ts.tv_nsec = timeout->tv_usec * 1000;
+		ts = &_ts;
+	}
+	return __libc_pselect6(n, readfds, writefds, exceptfds, ts, 0);
+}
+
+#else
+
 #ifdef __NR__newselect
 # define __NR___libc_select __NR__newselect
 #else
@@ -19,6 +40,9 @@
 #endif
 _syscall5(int, __libc_select, int, n, fd_set *, readfds, fd_set *, writefds,
 		  fd_set *, exceptfds, struct timeval *, timeout);
+
+#endif
+
 libc_hidden_proto(select)
 weak_alias(__libc_select,select)
 libc_hidden_weak(select)


[IOT-2530] Security provisioning crash fix

Change-Id: I456a0d09266561c7b6d6f6912e234aac2ca550c0
Signed-off-by: Aleksey Volkov <a27d9cdf263d3bb0a7e1b2122425c0a535a3f64c@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21613
Tested-by: jenkins-iotivity <d95b56ce41a2e1ac4cecdd398defd7414407cc08@iotivity.org>
Reviewed-by: Randeep Singh <46ce9385024397d3e4d9ed63be2e0a0d801e95b7@samsung.com>

--- resource/csdk/security/provisioning/src/pmutility.c
+++ resource/csdk/security/provisioning/src/pmutility.c
@@ -848,12 +848,14 @@
             {
                 pDInfo->isFound = true;
             }
-
-            res = SpecVersionDiscovery(pDInfo, clientResponse);
-            if(OC_STACK_OK != res)
-            {
-                OIC_LOG(ERROR, TAG, "Failed to SpecVersionDiscovery");
-                return OC_STACK_DELETE_TRANSACTION;
+            else
+            {
+                res = SpecVersionDiscovery(pDInfo, clientResponse);
+                if(OC_STACK_OK != res)
+                {
+                    OIC_LOG(ERROR, TAG, "Failed to SpecVersionDiscovery");
+                    return OC_STACK_DELETE_TRANSACTION;
+                }
             }

             OIC_LOG(INFO, TAG, "Exiting SecurePortDiscoveryHandler.");


Expose non-prefixed macros. (#169)

Expose non-prefixed macros. (#169)

When DOUBLE_CONVERSION_NON_PREFIXED_MACROS is defined, macros from
utils.h are exposed without the "DOUBLE_CONVERSION_" prefix.

Removing the old macros is still a breaking change, but this should make
it easier to unbreak programs that relied on these macros.

Co-authored-by: ericLemanissier <410eab50b22cff9b754ec7ebaefa9345f8a0564a@users.noreply.github.com>

--- double-conversion/utils.h
+++ double-conversion/utils.h
@@ -28,6 +28,9 @@
 #ifndef DOUBLE_CONVERSION_UTILS_H_
 #define DOUBLE_CONVERSION_UTILS_H_

+// Use DOUBLE_CONVERSION_NON_PREFIXED_MACROS to get unprefixed macros as was
+// the case in double-conversion releases prior to 3.1.6
+
 #include <cstdlib>
 #include <cstring>

@@ -36,9 +39,17 @@
 #define DOUBLE_CONVERSION_ASSERT(condition)         \
     assert(condition)
 #endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(ASSERT)
+#define ASSERT DOUBLE_CONVERSION_ASSERT
+#endif
+
 #ifndef DOUBLE_CONVERSION_UNIMPLEMENTED
 #define DOUBLE_CONVERSION_UNIMPLEMENTED() (abort())
 #endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNIMPLEMENTED)
+#define UNIMPLEMENTED DOUBLE_CONVERSION_UNIMPLEMENTED
+#endif
+
 #ifndef DOUBLE_CONVERSION_NO_RETURN
 #ifdef _MSC_VER
 #define DOUBLE_CONVERSION_NO_RETURN __declspec(noreturn)
@@ -46,6 +57,10 @@
 #define DOUBLE_CONVERSION_NO_RETURN __attribute__((noreturn))
 #endif
 #endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(NO_RETURN)
+#define NO_RETURN DOUBLE_CONVERSION_NO_RETURN
+#endif
+
 #ifndef DOUBLE_CONVERSION_UNREACHABLE
 #ifdef _MSC_VER
 void DOUBLE_CONVERSION_NO_RETURN abort_noreturn();
@@ -55,6 +70,9 @@
 #define DOUBLE_CONVERSION_UNREACHABLE()   (abort())
 #endif
 #endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNREACHABLE)
+#define UNREACHABLE DOUBLE_CONVERSION_UNREACHABLE
+#endif

 // Not all compilers support __has_attribute and combining a check for both
 // ifdef and __has_attribute on the same preprocessor line isn't portable.
@@ -71,11 +89,17 @@
 #define DOUBLE_CONVERSION_UNUSED
 #endif
 #endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UNUSED)
+#define UNUSED DOUBLE_CONVERSION_UNUSED
+#endif

 #if DOUBLE_CONVERSION_HAS_ATTRIBUTE(uninitialized)
 #define DOUBLE_CONVERSION_STACK_UNINITIALIZED __attribute__((uninitialized))
 #else
 #define DOUBLE_CONVERSION_STACK_UNINITIALIZED
+#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(STACK_UNINITIALIZED)
+#define STACK_UNINITIALIZED DOUBLE_CONVERSION_STACK_UNINITIALIZED
 #endif

 // Double operations detection based on target architecture.
@@ -134,6 +158,9 @@
 #else
 #error Target architecture was not detected as supported by Double-Conversion.
 #endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(CORRECT_DOUBLE_OPERATIONS)
+#define CORRECT_DOUBLE_OPERATIONS DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
+#endif

 #if defined(_WIN32) && !defined(__MINGW32__)

@@ -159,7 +186,9 @@
 // Usage: instead of writing 0x1234567890123456
 //      write DOUBLE_CONVERSION_UINT64_2PART_C(0x12345678,90123456);
 #define DOUBLE_CONVERSION_UINT64_2PART_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
-
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(UINT64_2PART_C)
+#define UINT64_2PART_C DOUBLE_CONVERSION_UINT64_2PART_C
+#endif

 // The expression DOUBLE_CONVERSION_ARRAY_SIZE(a) is a compile-time constant of type
 // size_t which represents the number of elements of the given
@@ -170,6 +199,9 @@
   ((sizeof(a) / sizeof(*(a))) /                         \
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
 #endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(ARRAY_SIZE)
+#define ARRAY_SIZE DOUBLE_CONVERSION_ARRAY_SIZE
+#endif

 // A macro to disallow the evil copy constructor and operator= functions
 // This should be used in the private: declarations for a class
@@ -177,6 +209,9 @@
 #define DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName)      \
   TypeName(const TypeName&);                    \
   void operator=(const TypeName&)
+#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(DC_DISALLOW_COPY_AND_ASSIGN)
+#define DC_DISALLOW_COPY_AND_ASSIGN DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN
 #endif

 // A macro to disallow all the implicit constructors, namely the
@@ -189,6 +224,9 @@
 #define DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
   TypeName();                                    \
   DOUBLE_CONVERSION_DISALLOW_COPY_AND_ASSIGN(TypeName)
+#endif
+#if defined(DOUBLE_CONVERSION_NON_PREFIXED_MACROS) && !defined(DC_DISALLOW_IMPLICIT_CONSTRUCTORS)
+#define DC_DISALLOW_IMPLICIT_CONSTRUCTORS DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS
 #endif

 namespace double_conversion {


driver: bmi3xx: Fix set data rate when odr is 0

BRANCH=none
BUG=b:178398789
TEST=Accel implementation tested on Guybrush
     EC commands:
     > accelinfo
     > accelrate 0

Signed-off-by: Bhanu Prakash Maiya <79ad261e151eab8edb2f55ce63e64270997db80f@chromium.org>
Signed-off-by: Latchiamaran Senram <f3780b830136526f34fbdc7f99179c3b51da8b56@bosch.corp-partner.google.com>
Change-Id: I9b3a30eb84304ab0109b23f86686c33d9b3bdfe6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3033969
Tested-by: Bhanu Prakash Maiya <79ad261e151eab8edb2f55ce63e64270997db80f@google.com>
Auto-Submit: Bhanu Prakash Maiya <79ad261e151eab8edb2f55ce63e64270997db80f@google.com>
Commit-Queue: Bhanu Prakash Maiya <79ad261e151eab8edb2f55ce63e64270997db80f@google.com>
Commit-Queue: Diana Z <cb2016afc7183e5356c690dc63b4ba817470501a@chromium.org>
Reviewed-by: Diana Z <cb2016afc7183e5356c690dc63b4ba817470501a@chromium.org>

--- driver/accelgyro_bmi3xx.c
+++ driver/accelgyro_bmi3xx.c
@@ -900,14 +900,15 @@
 			 int rate, int rnd)
 {
 	int ret;
-	int normalized_rate;
+	int normalized_rate = 0;
 	uint8_t reg_data[4];
-	uint8_t reg_val;
+	uint8_t reg_val = 0;

 	struct accelgyro_saved_data_t *saved_data = BMI_GET_SAVED_DATA(s);

-	RETURN_ERROR(bmi_get_normalized_rate(s, rate, rnd, &normalized_rate,
-					     &reg_val));
+	if (rate > 0)
+		RETURN_ERROR(bmi_get_normalized_rate(s, rate, rnd,
+						 &normalized_rate, &reg_val));

 	/*
 	 * Lock accel resource to prevent another task from attempting
@@ -944,10 +945,6 @@
 				      BMI3_POWER_MODE,
 				      BMI3_ACC_MODE_NORMAL);
 		}
-
-		/* Set accelerometer ODR */
-		reg_data[2] = BMI3_SET_BIT_POS0(reg_data[2],
-				BMI3_SENS_ODR, reg_val);
 	} else if (s->type == MOTIONSENSE_TYPE_GYRO) {
 		if (rate == 0) {
 			/* FIFO stop collecting events */
@@ -968,9 +965,10 @@
 				      BMI3_POWER_MODE,
 				      BMI3_GYR_MODE_NORMAL);
 		}
-		reg_data[2] = BMI3_SET_BIT_POS0(reg_data[2], BMI3_SENS_ODR,
-						reg_val);
-	}
+	}
+
+	/* Set accelerometer ODR */
+	reg_data[2] = BMI3_SET_BIT_POS0(reg_data[2], BMI3_SENS_ODR, reg_val);

 	/* Set the accel/gyro configurations. */
 	ret = bmi3_write_n(s, BMI3_REG_ACC_CONF + s->type, &reg_data[2], 2);


libata-acpi: set acpi state for SATA port

Currently, ata_acpi_set_state() only sets acpi sate for IDE port.
Remove this limitation.

Acked-by: Aaron Lu <e835aaae27ef45c770cbc83733586d01aadc3a43@amd.com>
Signed-off-by: Lin Ming <d6f051473f553588884d51874952f6fb19ae8261@intel.com>
Signed-off-by: Jeff Garzik <15f615bf7d20c2937c7eb5aa759110fd6768848c@redhat.com>

--- drivers/ata/libata-acpi.c
+++ drivers/ata/libata-acpi.c
@@ -852,23 +852,25 @@
 void ata_acpi_set_state(struct ata_port *ap, pm_message_t state)
 {
 	struct ata_device *dev;
-
-	if (!ata_ap_acpi_handle(ap) || (ap->flags & ATA_FLAG_ACPI_SATA))
-		return;
+	acpi_handle handle;

 	/* channel first and then drives for power on and vica versa
 	   for power off */
-	if (state.event == PM_EVENT_ON)
-		acpi_bus_set_power(ata_ap_acpi_handle(ap), ACPI_STATE_D0);
+	handle = ata_ap_acpi_handle(ap);
+	if (handle && state.event == PM_EVENT_ON)
+		acpi_bus_set_power(handle, ACPI_STATE_D0);

 	ata_for_each_dev(dev, &ap->link, ENABLED) {
-		if (ata_dev_acpi_handle(dev))
-			acpi_bus_set_power(ata_dev_acpi_handle(dev),
+		handle = ata_dev_acpi_handle(dev);
+		if (handle)
+			acpi_bus_set_power(handle,
 				state.event == PM_EVENT_ON ?
 					ACPI_STATE_D0 : ACPI_STATE_D3);
 	}
-	if (state.event != PM_EVENT_ON)
-		acpi_bus_set_power(ata_ap_acpi_handle(ap), ACPI_STATE_D3);
+
+	handle = ata_ap_acpi_handle(ap);
+	if (handle && state.event != PM_EVENT_ON)
+		acpi_bus_set_power(handle, ACPI_STATE_D3);
 }

 /**


Bluetooth: Controller: Use offsetof() in memory sizing

GCC requires __builtin_offsetof() to be used whenever
sizing arrays with its help. Now that stddef.h
includes conditional compilation, use the macro instead
of hardcoding the GCC usage.

Jira: ZEP-732

Change-Id: Ieb5c694e1dc8323bd1fa2d18711a893f8824c5b1
Signed-off-by: Carles Cufi <853081dc8dca4fe6a7e3c984752718b5db36e060@nordicsemi.no>

--- drivers/bluetooth/controller/ll/ctrl_internal.h
+++ drivers/bluetooth/controller/ll/ctrl_internal.h
@@ -209,12 +209,12 @@
 #define LL_MEM_TXQ (sizeof(struct pdu_data_q_tx) * \
 		    (RADIO_PACKET_COUNT_TX_MAX + 2))

-#define LL_MEM_RX_POOL_SZ (ALIGN4(__builtin_offsetof(struct radio_pdu_node_rx,\
+#define LL_MEM_RX_POOL_SZ (ALIGN4(offsetof(struct radio_pdu_node_rx,\
 				pdu_data) + ((\
 			(RADIO_ACPDU_SIZE_MAX + 1) < \
-			 (__builtin_offsetof(struct pdu_data, payload) + \
+			 (offsetof(struct pdu_data, payload) + \
 			  RADIO_LL_LENGTH_OCTETS_RX_MAX)) ? \
-		      (__builtin_offsetof(struct pdu_data, payload) + \
+		      (offsetof(struct pdu_data, payload) + \
 		      RADIO_LL_LENGTH_OCTETS_RX_MAX) \
 			: \
 		      (RADIO_ACPDU_SIZE_MAX + 1))) * \
@@ -223,13 +223,13 @@
 #define LL_MEM_RX_LINK_POOL (sizeof(void *) * 2 * ((RADIO_PACKET_COUNT_RX_MAX +\
 				4) + RADIO_CONNECTION_CONTEXT_MAX))

-#define LL_MEM_TX_CTRL_POOL ((ALIGN4(__builtin_offsetof( \
+#define LL_MEM_TX_CTRL_POOL ((ALIGN4(offsetof( \
 					struct radio_pdu_node_tx, pdu_data) + \
-		   __builtin_offsetof(struct pdu_data, payload) + 27)) * \
+		   offsetof(struct pdu_data, payload) + 27)) * \
 		PACKET_MEM_COUNT_TX_CTRL)
-#define LL_MEM_TX_DATA_POOL ((ALIGN4(__builtin_offsetof( \
+#define LL_MEM_TX_DATA_POOL ((ALIGN4(offsetof( \
 					struct radio_pdu_node_tx, pdu_data) + \
-		   __builtin_offsetof(struct pdu_data, payload) + \
+		   offsetof(struct pdu_data, payload) + \
 				RADIO_LL_LENGTH_OCTETS_RX_MAX)) \
 			* (RADIO_PACKET_COUNT_TX_MAX + 1))


pata_cmd640: Multiple updates

pata_cmd640: Multiple updates

Fix suspend/resume support
Write 0x5B to 0 not 0x5C

The former is important as we must kill the FIFO on a resume

Signed-off-by: Alan Cox <91e38e63b890fbb214c8914809fde03c73e7f24d@redhat.com>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

--- drivers/ata/pata_cmd640.c
+++ drivers/ata/pata_cmd640.c
@@ -23,7 +23,7 @@
 #include <linux/libata.h>

 #define DRV_NAME "pata_cmd640"
-#define DRV_VERSION "0.0.3"
+#define DRV_VERSION "0.0.5"

 struct cmd640_reg {
 	int last;
@@ -43,6 +43,7 @@

 /**
  *	cmd640_set_piomode	-	set initial PIO mode data
+ *	@ap: ATA port
  *	@adev: ATA device
  *
  *	Called to do the PIO mode setup.
@@ -106,7 +107,7 @@
 		pci_write_config_byte(pdev, arttim + 1, (t.active << 4) | t.recover);
 	} else {
 		/* Save the shared timings for channel, they will be loaded
-		   by qc_issue_prot. Reloading the setup time is expensive
+		   by qc_issue_prot. Reloading the setup time is expensive
 		   so we keep a merged one loaded */
 		pci_read_config_byte(pdev, ARTIM23, &reg);
 		reg &= 0x3F;
@@ -219,29 +220,20 @@
 	.port_start	= cmd640_port_start,
 };

-static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
+static void cmd640_hardware_init(struct pci_dev *pdev)
 {
 	u8 r;
 	u8 ctrl;

-	static struct ata_port_info info = {
-		.sht = &cmd640_sht,
-		.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
-		.pio_mask = 0x1f,
-		.port_ops = &cmd640_port_ops
-	};
-
-	static struct ata_port_info *port_info[2] = { &info, &info };
-
 	/* CMD640 detected, commiserations */
-	pci_write_config_byte(pdev, 0x5C, 0x00);
+	pci_write_config_byte(pdev, 0x5B, 0x00);
 	/* Get version info */
 	pci_read_config_byte(pdev, CFR, &r);
 	/* PIO0 command cycles */
 	pci_write_config_byte(pdev, CMDTIM, 0);
 	/* 512 byte bursts (sector) */
 	pci_write_config_byte(pdev, BRST, 0x40);
-	/*
+	/*
 	 * A reporter a long time ago
 	 * Had problems with the data fifo
 	 * So don't run the risk
@@ -255,12 +247,26 @@
 	pci_read_config_byte(pdev, ARTIM23, &ctrl);
 	ctrl |= 0x0C;
 	pci_write_config_byte(pdev, ARTIM23, ctrl);
-
+}
+
+static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	static struct ata_port_info info = {
+		.sht = &cmd640_sht,
+		.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+		.pio_mask = 0x1f,
+		.port_ops = &cmd640_port_ops
+	};
+
+	static struct ata_port_info *port_info[2] = { &info, &info };
+
+	cmd640_hardware_init(pdev);
 	return ata_pci_init_one(pdev, port_info, 2);
 }

 static int cmd640_reinit_one(struct pci_dev *pdev)
 {
+	cmd640_hardware_init(pdev);
 	return ata_pci_device_resume(pdev);
 }


drm/nvc0/fifo: runlist intr

drm/nvc0/fifo: runlist intr

Signed-off-by: Ben Skeggs <d9f27fb07c1e9f131223ad827fa5179f3846c30b@redhat.com>

--- drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c
+++ drivers/gpu/drm/nouveau/core/engine/fifo/nvc0.c
@@ -41,8 +41,11 @@

 struct nvc0_fifo_priv {
 	struct nouveau_fifo base;
-	struct nouveau_gpuobj *runlist[2];
-	int cur_runlist;
+	struct {
+		struct nouveau_gpuobj *mem[2];
+		int active;
+		wait_queue_head_t wait;
+	} runlist;
 	struct {
 		struct nouveau_gpuobj *mem;
 		struct nouveau_vma bar;
@@ -72,8 +75,8 @@
 	int i, p;

 	mutex_lock(&nv_subdev(priv)->mutex);
-	cur = priv->runlist[priv->cur_runlist];
-	priv->cur_runlist = !priv->cur_runlist;
+	cur = priv->runlist.mem[priv->runlist.active];
+	priv->runlist.active = !priv->runlist.active;

 	for (i = 0, p = 0; i < 128; i++) {
 		if (!(nv_rd32(priv, 0x003004 + (i * 8)) & 1))
@@ -513,6 +516,23 @@
 }

 static void
+nvc0_fifo_intr_runlist(struct nvc0_fifo_priv *priv)
+{
+	u32 intr = nv_rd32(priv, 0x002a00);
+
+	if (intr & 0x10000000) {
+		wake_up(&priv->runlist.wait);
+		nv_wr32(priv, 0x002a00, 0x10000000);
+		intr &= ~0x10000000;
+	}
+
+	if (intr) {
+		nv_error(priv, "RUNLIST 0x%08x\n", intr);
+		nv_wr32(priv, 0x002a00, intr);
+	}
+}
+
+static void
 nvc0_fifo_intr_engine_unit(struct nvc0_fifo_priv *priv, int engn)
 {
 	u32 intr = nv_rd32(priv, 0x0025a8 + (engn * 0x04));
@@ -609,10 +629,7 @@
 	}

 	if (stat & 0x40000000) {
-		u32 intr0 = nv_rd32(priv, 0x0025a4);
-		u32 intr1 = nv_mask(priv, 0x002a00, 0x00000000, 0x00000);
-		nv_debug(priv, "INTR 0x40000000: 0x%08x 0x%08x\n",
-			       intr0, intr1);
+		nvc0_fifo_intr_runlist(priv);
 		stat &= ~0x40000000;
 	}

@@ -656,14 +673,16 @@
 		return ret;

 	ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x1000, 0x1000, 0,
-				&priv->runlist[0]);
+				&priv->runlist.mem[0]);
 	if (ret)
 		return ret;

 	ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x1000, 0x1000, 0,
-				&priv->runlist[1]);
-	if (ret)
-		return ret;
+				&priv->runlist.mem[1]);
+	if (ret)
+		return ret;
+
+	init_waitqueue_head(&priv->runlist.wait);

 	ret = nouveau_gpuobj_new(nv_object(priv), NULL, 128 * 0x1000, 0x1000, 0,
 				&priv->user.mem);
@@ -693,8 +712,8 @@

 	nouveau_gpuobj_unmap(&priv->user.bar);
 	nouveau_gpuobj_ref(NULL, &priv->user.mem);
-	nouveau_gpuobj_ref(NULL, &priv->runlist[1]);
-	nouveau_gpuobj_ref(NULL, &priv->runlist[0]);
+	nouveau_gpuobj_ref(NULL, &priv->runlist.mem[0]);
+	nouveau_gpuobj_ref(NULL, &priv->runlist.mem[1]);

 	nouveau_fifo_destroy(&priv->base);
 }
@@ -735,9 +754,8 @@
 	nv_mask(priv, 0x002200, 0x00000001, 0x00000001);
 	nv_wr32(priv, 0x002254, 0x10000000 | priv->user.bar.offset >> 12);

-	nv_wr32(priv, 0x002a00, 0xffffffff); /* clears PFIFO.INTR bit 30 */
 	nv_wr32(priv, 0x002100, 0xffffffff);
-	nv_wr32(priv, 0x002140, 0x3fffffff);
+	nv_wr32(priv, 0x002140, 0x7fffffff);
 	nv_wr32(priv, 0x002628, 0x00000001); /* ENGINE_INTR_EN */
 	return 0;
 }


[PATCH] pata_hpt366 enablebits

[PATCH] pata_hpt366 enablebits

More enablebits

Signed-off-by: Alan Cox <91e38e63b890fbb214c8914809fde03c73e7f24d@redhat.com>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

--- drivers/ata/pata_hpt366.c
+++ drivers/ata/pata_hpt366.c
@@ -27,7 +27,7 @@
 #include <linux/libata.h>

 #define DRV_NAME	"pata_hpt366"
-#define DRV_VERSION	"0.5"
+#define DRV_VERSION	"0.5.1"

 struct hpt_clock {
 	u8	xfer_speed;
@@ -222,9 +222,17 @@

 static int hpt36x_pre_reset(struct ata_port *ap)
 {
+	static const struct pci_bits hpt36x_enable_bits[] = {
+		{ 0x50, 1, 0x04, 0x04 },
+		{ 0x54, 1, 0x04, 0x04 }
+	};
+
 	u8 ata66;
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);

+	if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no]))
+		return -ENOENT;
+
 	pci_read_config_byte(pdev, 0x5A, &ata66);
 	if (ata66 & (1 << ap->port_no))
 		ap->cbl = ATA_CBL_PATA40;


pata_it821x: use "const char *" for string literals

Some string literals are pointed to by "char *".  This patch fixes
that.

tj: Updated patch title and description.

Signed-off-by: LABBE Corentin <4df73f6d53a690d105cd8130f057950f3b2f7aac@gmail.com>
Signed-off-by: Tejun Heo <546b05909706652891a87f7bfe385ae147f61f91@kernel.org>


PM: Measure device suspend and resume times

Measure and print the time of suspending and resuming all devices.

Signed-off-by: Rafael J. Wysocki <a11f87183a953ab11f50fbafff689c5a7fa3506c@sisk.pl>

--- drivers/base/power/main.c
+++ drivers/base/power/main.c
@@ -372,6 +372,23 @@
 		kobject_name(&dev->kobj), pm_verb(state.event), info, error);
 }

+static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
+{
+	ktime_t calltime;
+	s64 usecs64;
+	int usecs;
+
+	calltime = ktime_get();
+	usecs64 = ktime_to_ns(ktime_sub(calltime, starttime));
+	do_div(usecs64, NSEC_PER_USEC);
+	usecs = usecs64;
+	if (usecs == 0)
+		usecs = 1;
+	pr_info("PM: %s%s%s of devices complete after %ld.%03ld msecs\n",
+		info ?: "", info ? " " : "", pm_verb(state.event),
+		usecs / USEC_PER_MSEC, usecs % USEC_PER_MSEC);
+}
+
 /*------------------------- Resume routines -------------------------*/

 /**
@@ -408,6 +425,7 @@
 void dpm_resume_noirq(pm_message_t state)
 {
 	struct device *dev;
+	ktime_t starttime = ktime_get();

 	mutex_lock(&dpm_list_mtx);
 	transition_started = false;
@@ -421,6 +439,7 @@
 				pm_dev_err(dev, state, " early", error);
 		}
 	mutex_unlock(&dpm_list_mtx);
+	dpm_show_time(starttime, state, "early");
 	resume_device_irqs();
 }
 EXPORT_SYMBOL_GPL(dpm_resume_noirq);
@@ -506,6 +525,7 @@
 static void dpm_resume(pm_message_t state)
 {
 	struct list_head list;
+	ktime_t starttime = ktime_get();

 	INIT_LIST_HEAD(&list);
 	mutex_lock(&dpm_list_mtx);
@@ -534,6 +554,7 @@
 	}
 	list_splice(&list, &dpm_list);
 	mutex_unlock(&dpm_list_mtx);
+	dpm_show_time(starttime, state, NULL);
 }

 /**
@@ -666,6 +687,7 @@
 int dpm_suspend_noirq(pm_message_t state)
 {
 	struct device *dev;
+	ktime_t starttime = ktime_get();
 	int error = 0;

 	suspend_device_irqs();
@@ -681,6 +703,8 @@
 	mutex_unlock(&dpm_list_mtx);
 	if (error)
 		dpm_resume_noirq(resume_event(state));
+	else
+		dpm_show_time(starttime, state, "late");
 	return error;
 }
 EXPORT_SYMBOL_GPL(dpm_suspend_noirq);
@@ -760,6 +784,7 @@
 static int dpm_suspend(pm_message_t state)
 {
 	struct list_head list;
+	ktime_t starttime = ktime_get();
 	int error = 0;

 	INIT_LIST_HEAD(&list);
@@ -785,6 +810,8 @@
 	}
 	list_splice(&list, dpm_list.prev);
 	mutex_unlock(&dpm_list_mtx);
+	if (!error)
+		dpm_show_time(starttime, state, NULL);
 	return error;
 }


NVMe: nvme_submit_async_admin_req() must use atomic rq allocation

We are called for async event notification issues, and the
nvmeq lock is already held. If we fail the request allocation,
we'll just retry next time.

Reported-by: Julia Lawall <018ee4f95fc49739477deedb13d2cd210889e607@lip6.fr>
Signed-off-by: Jens Axboe <cd8c6775e60d6f67a6984377324e5290df3d5358@fb.com>


nvme: merge nvme_dev_reset into nvme_reset_failed_dev

And give the resulting function a more descriptive name.

Signed-off-by: Christoph Hellwig <923f7720577207a44b32e59bbfbea59d27f1ae8e@lst.de>
Reviewed-by: Keith Busch <695e2a2c1e39535baaa147c5eb4e5da14054d59f@intel.com>
Signed-off-by: Jens Axboe <cd8c6775e60d6f67a6984377324e5290df3d5358@fb.com>


Bluetooth: Add support for Broadcom BCM20702A1 variant

This variant requires the flag BTUSB_BCM_PATCHRAM to work.

Relevant details from /sys/kernel/debug/usb/devices:

T:  Bus=01 Lev=02 Prnt=02 Port=04 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=13d3 ProdID=3404 Rev= 1.12
S:  Manufacturer=Broadcom Corp
S:  Product=BCM20702A0
S:  SerialNumber=240A646F1XXX
C:* #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=84(I) Atr=02(Bulk) MxPS=  32 Ivl=0ms
E:  Ad=04(O) Atr=02(Bulk) MxPS=  32 Ivl=0ms
I:* If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)

The firmware was extracted from a Windows 8.1 64-bit installation
and converted from 'hex' to 'hcd' for use in Linux.

Under Windows it also identifies itself as BCM20702A0,
but the firmware is named "BCM20702A1_001.002.014.1315.1356.hex"
and is located in "%SYSTEMROOT%\system32\drivers\"
(md5 67cf6bfdae61c4bb819a66da984f7913)
(sha1 5f74cc6a9a3bf19ee0f8c3d01e4be34c609b188f)

The same firmware file is also available as a download at
http://www.asrock.com/mb/Intel/Z87E-ITX/?cat=Download&os=All
marked as "Bluetooth driver ver:12.0.0.7820"

'hcd' file should be placed at "brcm/BCM20702A0-13d3-3404.hcd"
inside the firmware directory (e.g. "/lib/firmware")

Signed-off-by: Fabio K <1d47618a3b76e9024bf3185bc2d4dcf17fc6f32a@gmail.com>
Signed-off-by: Marcel Holtmann <44592b4eea36663c86b994bb0ea99d15309c1c7d@holtmann.org>

--- drivers/bluetooth/btusb.c
+++ drivers/bluetooth/btusb.c
@@ -106,6 +106,8 @@
 	{ USB_DEVICE(0x0b05, 0x17b5) },
 	{ USB_DEVICE(0x0b05, 0x17cb) },
 	{ USB_DEVICE(0x413c, 0x8197) },
+	{ USB_DEVICE(0x13d3, 0x3404),
+	  .driver_info = BTUSB_BCM_PATCHRAM },

 	/* Foxconn - Hon Hai */
 	{ USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },


se_exp: export [ft]index options too

se_exp: export [ft]index options too


cxgb4: Enable doorbell drop recovery only for T4 adapter

Signed-off-by: Santosh Rastapur <117a211f76f0aa5fbc9b7143b793fdbaf7088c03@chelsio.com>
Signed-off-by: Vipul Pandya <5bed5a3f1ad81aab801fb016f6523d5889165965@chelsio.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3227,10 +3227,18 @@
 unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo)
 {
 	struct adapter *adap = netdev2adap(dev);
-	u32 v;
-
-	v = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
-	return lpfifo ? G_LP_COUNT(v) : G_HP_COUNT(v);
+	u32 v1, v2, lp_count, hp_count;
+
+	v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
+	v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
+	if (is_t4(adap->chip)) {
+		lp_count = G_LP_COUNT(v1);
+		hp_count = G_HP_COUNT(v1);
+	} else {
+		lp_count = G_LP_COUNT_T5(v1);
+		hp_count = G_HP_COUNT_T5(v2);
+	}
+	return lpfifo ? lp_count : hp_count;
 }
 EXPORT_SYMBOL(cxgb4_dbfifo_count);

@@ -3368,14 +3376,23 @@

 static void drain_db_fifo(struct adapter *adap, int usecs)
 {
-	u32 v;
+	u32 v1, v2, lp_count, hp_count;

 	do {
+		v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
+		v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
+		if (is_t4(adap->chip)) {
+			lp_count = G_LP_COUNT(v1);
+			hp_count = G_HP_COUNT(v1);
+		} else {
+			lp_count = G_LP_COUNT_T5(v1);
+			hp_count = G_HP_COUNT_T5(v2);
+		}
+
+		if (lp_count == 0 && hp_count == 0)
+			break;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(usecs_to_jiffies(usecs));
-		v = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
-		if (G_LP_COUNT(v) == 0 && G_HP_COUNT(v) == 0)
-			break;
 	} while (1);
 }

@@ -3484,24 +3501,62 @@

 	adap = container_of(work, struct adapter, db_drop_task);

+	if (is_t4(adap->chip)) {
+		disable_dbs(adap);
+		notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP);
+		drain_db_fifo(adap, 1);
+		recover_all_queues(adap);
+		enable_dbs(adap);
+	} else {
+		u32 dropped_db = t4_read_reg(adap, 0x010ac);
+		u16 qid = (dropped_db >> 15) & 0x1ffff;
+		u16 pidx_inc = dropped_db & 0x1fff;
+		unsigned int s_qpp;
+		unsigned short udb_density;
+		unsigned long qpshift;
+		int page;
+		u32 udb;
+
+		dev_warn(adap->pdev_dev,
+			 "Dropped DB 0x%x qid %d bar2 %d coalesce %d pidx %d\n",
+			 dropped_db, qid,
+			 (dropped_db >> 14) & 1,
+			 (dropped_db >> 13) & 1,
+			 pidx_inc);
+
+		drain_db_fifo(adap, 1);
+
+		s_qpp = QUEUESPERPAGEPF1 * adap->fn;
+		udb_density = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adap,
+				SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp);
+		qpshift = PAGE_SHIFT - ilog2(udb_density);
+		udb = qid << qpshift;
+		udb &= PAGE_MASK;
+		page = udb / PAGE_SIZE;
+		udb += (qid - (page * udb_density)) * 128;
+
+		writel(PIDX(pidx_inc),  adap->bar2 + udb + 8);
+
+		/* Re-enable BAR2 WC */
+		t4_set_reg_field(adap, 0x10b0, 1<<15, 1<<15);
+	}
+
 	t4_set_reg_field(adap, A_SGE_DOORBELL_CONTROL, F_DROPPED_DB, 0);
-	disable_dbs(adap);
-	notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP);
-	drain_db_fifo(adap, 1);
-	recover_all_queues(adap);
-	enable_dbs(adap);
 }

 void t4_db_full(struct adapter *adap)
 {
-	t4_set_reg_field(adap, SGE_INT_ENABLE3,
-			 DBFIFO_HP_INT | DBFIFO_LP_INT, 0);
-	queue_work(workq, &adap->db_full_task);
+	if (is_t4(adap->chip)) {
+		t4_set_reg_field(adap, SGE_INT_ENABLE3,
+				 DBFIFO_HP_INT | DBFIFO_LP_INT, 0);
+		queue_work(workq, &adap->db_full_task);
+	}
 }

 void t4_db_dropped(struct adapter *adap)
 {
-	queue_work(workq, &adap->db_drop_task);
+	if (is_t4(adap->chip))
+		queue_work(workq, &adap->db_drop_task);
 }

 static void uld_attach(struct adapter *adap, unsigned int uld)


cpufreq: Set policy to non-NULL only after all hotplug online work is done

The existing code sets the per CPU policy to a non-NULL value before all
the steps performed during the hotplug online path is done. Specifically,
this is done before the policy min/max, governors, etc are initialized for
the policy.  This in turn means that calls to cpufreq_cpu_get() return a
non-NULL policy before the policy/CPU is ready to be used.

To fix this, move the update of per CPU policy to a valid value after all
the initialization steps for the policy are completed.

Example kernel panic without this fix:
[  512.146185] Unable to handle kernel NULL pointer dereference at virtual address 00000020
[  512.146195] pgd = c0003000
[  512.146213] [00000020] *pgd=80000000004003, *pmd=00000000
[  512.146228] Internal error: Oops: 206 [#1] PREEMPT SMP ARM
<snip>
[  512.146297] PC is at __cpufreq_governor+0x10/0x1ac
[  512.146312] LR is at cpufreq_update_policy+0x114/0x150
<snip>
[  512.149740] ---[ end trace f23a8defea6cd706 ]---
[  512.149761] Kernel panic - not syncing: Fatal exception
[  513.152016] CPU0: stopping
[  513.154710] CPU: 0 PID: 7136 Comm: mpdecision Tainted: G      D W    3.10.0-gd727407-00074-g979ede8 #396
<snip>
[  513.317224] [<c0afe180>] (notifier_call_chain+0x40/0x68) from [<c02a23ac>] (__blocking_notifier_call_chain+0x40/0x58)
[  513.327809] [<c02a23ac>] (__blocking_notifier_call_chain+0x40/0x58) from [<c02a23d8>] (blocking_notifier_call_chain+0x14/0x1c)
[  513.339182] [<c02a23d8>] (blocking_notifier_call_chain+0x14/0x1c) from [<c0803c68>] (cpufreq_set_policy+0xd4/0x2b8)
[  513.349594] [<c0803c68>] (cpufreq_set_policy+0xd4/0x2b8) from [<c0803e7c>] (cpufreq_init_policy+0x30/0x98)
[  513.359231] [<c0803e7c>] (cpufreq_init_policy+0x30/0x98) from [<c0805a18>] (__cpufreq_add_dev.isra.17+0x4dc/0x7a4)
[  513.369560] [<c0805a18>] (__cpufreq_add_dev.isra.17+0x4dc/0x7a4) from [<c0805d38>] (cpufreq_cpu_callback+0x58/0x84)
[  513.379978] [<c0805d38>] (cpufreq_cpu_callback+0x58/0x84) from [<c0afe180>] (notifier_call_chain+0x40/0x68)
[  513.389704] [<c0afe180>] (notifier_call_chain+0x40/0x68) from [<c02812dc>] (__cpu_notify+0x28/0x44)
[  513.398728] [<c02812dc>] (__cpu_notify+0x28/0x44) from [<c0aeed90>] (_cpu_up+0xf4/0x1dc)
[  513.406797] [<c0aeed90>] (_cpu_up+0xf4/0x1dc) from [<c0aeeed4>] (cpu_up+0x5c/0x78)
[  513.414357] [<c0aeeed4>] (cpu_up+0x5c/0x78) from [<c0aec808>] (store_online+0x44/0x74)
[  513.422253] [<c0aec808>] (store_online+0x44/0x74) from [<c03a40f4>] (sysfs_write_file+0x108/0x14c)
[  513.431195] [<c03a40f4>] (sysfs_write_file+0x108/0x14c) from [<c03517d4>] (vfs_write+0xd0/0x180)
[  513.439958] [<c03517d4>] (vfs_write+0xd0/0x180) from [<c0351ca8>] (SyS_write+0x38/0x68)
[  513.447947] [<c0351ca8>] (SyS_write+0x38/0x68) from [<c0205de0>] (ret_fast_syscall+0x0/0x30)

In this specific case, CPU0 set's CPU1's policy->governor in
cpufreq_init_policy() to NULL while CPU1 is using the policy->governor in
__cpufreq_governor().

Change-Id: I8b8bc7114e44744f6f38925e4ed710126a45075d
Signed-off-by: Saravana Kannan <ce25c3cee4cc6c4c8acfc1680b3ed89cf644dba3@codeaurora.org>

--- drivers/cpufreq/cpufreq.c
+++ drivers/cpufreq/cpufreq.c
@@ -1087,22 +1087,22 @@
 		 policy->min, policy->max);
 #endif

+	if (!frozen) {
+		ret = cpufreq_add_dev_interface(policy, dev);
+		if (ret)
+			goto err_out_unregister;
+	}
+
+	write_lock_irqsave(&cpufreq_driver_lock, flags);
+	list_add(&policy->policy_list, &cpufreq_policy_list);
+	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+	cpufreq_init_policy(policy);
+
 	write_lock_irqsave(&cpufreq_driver_lock, flags);
 	for_each_cpu(j, policy->cpus)
 		per_cpu(cpufreq_cpu_data, j) = policy;
 	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
-
-	if (!frozen) {
-		ret = cpufreq_add_dev_interface(policy, dev);
-		if (ret)
-			goto err_out_unregister;
-	}
-
-	write_lock_irqsave(&cpufreq_driver_lock, flags);
-	list_add(&policy->policy_list, &cpufreq_policy_list);
-	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
-
-	cpufreq_init_policy(policy);

 	kobject_uevent(&policy->kobj, KOBJ_ADD);
 	up_read(&cpufreq_rwsem);


a52dec: Call orc_init() before trying to get target flags

--- ext/a52dec/gsta52dec.c
+++ ext/a52dec/gsta52dec.c
@@ -975,6 +975,10 @@
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
+#if HAVE_ORC
+  orc_init ();
+#endif
+
   /* ensure GstAudioChannelPosition type is registered */
   if (!gst_audio_channel_position_get_type ())
     return FALSE;


brcmsmac: extend hardware info shown in debugfs

The hardware info now also include radio and phy information, which
can be helpful in debugging issues.

Reviewed-by: Hante Meuleman <31ca5aa57e9f47a38c33f2797b138069dfa82656@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <d101f7ec36e185d305862a92a05a9a0c1b62aa38@broadcom.com>
Signed-off-by: Arend van Spriel <06447fbe43693466d3293d0b5eaeeb2efd3d7d3a@broadcom.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/brcm80211/brcmsmac/debug.c
+++ drivers/net/wireless/brcm80211/brcmsmac/debug.c
@@ -30,6 +30,7 @@
 #include "main.h"
 #include "debug.h"
 #include "brcms_trace_events.h"
+#include "phy/phy_int.h"

 static struct dentry *root_folder;

@@ -74,20 +75,33 @@
 int brcms_debugfs_hardware_read(struct seq_file *s, void *data)
 {
 	struct brcms_pub *drvr = s->private;
-
-	seq_printf(s, "board vendor: %x\n"
-		   "board type: %x\n"
-		   "board revision: %x\n"
-		   "board flags: %x\n"
-		   "board flags2: %x\n"
-		   "firmware revision: %x\n",
-		   drvr->wlc->hw->d11core->bus->boardinfo.vendor,
-		   drvr->wlc->hw->d11core->bus->boardinfo.type,
-		   drvr->wlc->hw->boardrev,
-		   drvr->wlc->hw->boardflags,
-		   drvr->wlc->hw->boardflags2,
-		   drvr->wlc->ucode_rev);
-
+	struct brcms_hardware *hw = drvr->wlc->hw;
+	struct bcma_device *core = hw->d11core;
+	struct bcma_bus *bus = core->bus;
+	char boardrev[10];
+
+	seq_printf(s, "chipnum 0x%x\n"
+		   "chiprev 0x%x\n"
+		   "chippackage 0x%x\n"
+		   "corerev 0x%x\n"
+		   "boardid 0x%x\n"
+		   "boardvendor 0x%x\n"
+		   "boardrev %s\n"
+		   "boardflags 0x%x\n"
+		   "boardflags2 0x%x\n"
+		   "ucoderev 0x%x\n"
+		   "radiorev 0x%x\n"
+		   "phytype 0x%x\n"
+		   "phyrev 0x%x\n"
+		   "anarev 0x%x\n"
+		   "nvramrev %d\n",
+		   bus->chipinfo.id, bus->chipinfo.rev, bus->chipinfo.pkg,
+		   core->id.rev, bus->boardinfo.type, bus->boardinfo.vendor,
+		   brcmu_boardrev_str(hw->boardrev, boardrev),
+		   drvr->wlc->hw->boardflags, drvr->wlc->hw->boardflags2,
+		   drvr->wlc->ucode_rev, hw->band->radiorev,
+		   hw->band->phytype, hw->band->phyrev, hw->band->pi->ana_rev,
+		   hw->sromrev);
 	return 0;
 }


bugfix in SVD

bugfix in SVD

--- Eigen/src/SVD/SVD.h
+++ Eigen/src/SVD/SVD.h
@@ -125,7 +125,7 @@
     {
       return (b >= Scalar(0.0) ? ei_abs(a) : -ei_abs(a));
     }
-
+
   protected:
     /** \internal */
     MatrixUType m_matU;
@@ -254,11 +254,14 @@
     if (g != Scalar(0.0))
     {
       g = Scalar(1.0)/g;
-      for (j=l; j<n; j++)
-      {
-        s = A.col(i).end(m-l).dot(A.col(j).end(m-l));
-        f = (s/A(i,i))*g;
-        A.col(j).end(m-i) += f * A.col(i).end(m-i);
+      if (m-l)
+      {
+        for (j=l; j<n; j++)
+        {
+          s = A.col(i).end(m-l).dot(A.col(j).end(m-l));
+          f = (s/A(i,i))*g;
+          A.col(j).end(m-i) += f * A.col(i).end(m-i);
+        }
       }
       A.col(i).end(m-i) *= g;
     }


amd64_edac: Fix DCT argument type

amd64_edac: Fix DCT argument type

Fix amd64_debug_display_dimm_sizes() arguments order per convention (pvt
is always first). Also, the now second arg denotes the DCT so adjust its
type.

Signed-off-by: Borislav Petkov <2b4cb5acba6b5321acd37371d9b73a646c388783@amd.com>

--- drivers/edac/amd64_edac.c
+++ drivers/edac/amd64_edac.c
@@ -768,8 +768,7 @@
 	return edac_cap;
 }

-
-static void amd64_debug_display_dimm_sizes(int ctrl, struct amd64_pvt *pvt);
+static void amd64_debug_display_dimm_sizes(struct amd64_pvt *, u8);

 static void amd64_dump_dramcfg_low(u32 dclr, int chan)
 {
@@ -817,13 +816,13 @@

 	debugf1("  DramHoleValid: %s\n", dhar_valid(pvt) ? "yes" : "no");

-	amd64_debug_display_dimm_sizes(0, pvt);
+	amd64_debug_display_dimm_sizes(pvt, 0);

 	/* everything below this point is Fam10h and above */
 	if (boot_cpu_data.x86 == 0xf)
 		return;

-	amd64_debug_display_dimm_sizes(1, pvt);
+	amd64_debug_display_dimm_sizes(pvt, 1);

 	amd64_info("using %s syndromes.\n", ((pvt->ecc_sym_sz == 8) ? "x8" : "x4"));

@@ -1536,7 +1535,7 @@
  * debug routine to display the memory sizes of all logical DIMMs and its
  * CSROWs
  */
-static void amd64_debug_display_dimm_sizes(int ctrl, struct amd64_pvt *pvt)
+static void amd64_debug_display_dimm_sizes(struct amd64_pvt *pvt, u8 ctrl)
 {
 	int dimm, size0, size1, factor = 0;
 	u32 *dcsb = ctrl ? pvt->csels[1].csbases : pvt->csels[0].csbases;


Fix put_int32 on big endian platforms.

Fix put_int32 on big endian platforms.

the ruby int was copied into a 64bit int instead of a 32bit.
This error didn't show up on little endian platorms because we copy
the first 4 bytes of the integer (ie the ones that are set) but on big endian
we'd be copying the high 4 bytes (that are all 0)

--- ext/bson/bson_native.c
+++ ext/bson/bson_native.c
@@ -792,7 +792,7 @@

 void bson_byte_buffer_put_int32(byte_buffer_t *b, const int32_t i)
 {
-  const int64_t i32 = BSON_UINT32_TO_LE(i);
+  const int32_t i32 = BSON_UINT32_TO_LE(i);
   ENSURE_BSON_WRITE(b, 4);
   memcpy(WRITE_PTR(b), &i32, 4);
   b->write_position += 4;


staging: comedi: addi_apci_1500: remove unnecessary subdevice initialization

The subdevices that don't initialize any of the callbacks don't really
exist. Remove the unnecessary initialzation and just set the type to
COMEDI_SUBD_UNUSED.

Signed-off-by: H Hartley Sweeten <382ff55d8e07d1082d179e669636cd1552da4f36@visionengravers.com>
Reviewed-by: Ian Abbott <9e6ba6483b6a3e14d61f7c987e72ecb5b46122d6@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/comedi/drivers/addi_apci_1500.c
+++ drivers/staging/comedi/drivers/addi_apci_1500.c
@@ -116,36 +116,12 @@

 	/*  Allocate and Initialise AI Subdevice Structures */
 	s = &dev->subdevices[0];
-	if ((devpriv->s_EeParameters.i_NbrAiChannel)
-		|| (this_board->i_NbrAiChannelDiff)) {
-		dev->read_subdev = s;
-		s->type = COMEDI_SUBD_AI;
-		s->subdev_flags =
-			SDF_READABLE | SDF_COMMON | SDF_GROUND
-			| SDF_DIFF;
-		if (devpriv->s_EeParameters.i_NbrAiChannel)
-			s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel;
-		else
-			s->n_chan = this_board->i_NbrAiChannelDiff;
-		s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
-		s->len_chanlist = this_board->i_AiChannelList;
-		s->range_table = this_board->pr_AiRangelist;
-	} else {
-		s->type = COMEDI_SUBD_UNUSED;
-	}
+	s->type = COMEDI_SUBD_UNUSED;

 	/*  Allocate and Initialise AO Subdevice Structures */
 	s = &dev->subdevices[1];
-	if (devpriv->s_EeParameters.i_NbrAoChannel) {
-		s->type = COMEDI_SUBD_AO;
-		s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-		s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
-		s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
-		s->len_chanlist =
-			devpriv->s_EeParameters.i_NbrAoChannel;
-	} else {
-		s->type = COMEDI_SUBD_UNUSED;
-	}
+		s->type = COMEDI_SUBD_UNUSED;
+
 	/*  Allocate and Initialise DI Subdevice Structures */
 	s = &dev->subdevices[2];
 	if (devpriv->s_EeParameters.i_NbrDiChannel) {


e752x_edac: convert driver to use the new edac ABI

The legacy edac ABI is going to be removed. Port the driver to use
and benefit from the new API functionality.

Cc: Mark Gross <c004c62dd94ce13ea82cbf049418004b9585a60a@intel.com>
Cc: Doug Thompson <4406867d72fe17b9bf5628ab041d8a5cdea8e487@yahoo.com>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/edac/e752x_edac.c
+++ drivers/edac/e752x_edac.c
@@ -5,6 +5,9 @@
  * GNU General Public License.
  *
  * See "enum e752x_chips" below for supported chipsets
+ *
+ * Datasheet:
+ *	http://www.intel.in/content/www/in/en/chipsets/e7525-memory-controller-hub-datasheet.html
  *
  * Written by Tom Zimmerman
  *
@@ -350,8 +353,10 @@
 	channel = !(error_one & 1);

 	/* e752x mc reads 34:6 of the DRAM linear address */
-	edac_mc_handle_ce(mci, page, offset_in_page(sec1_add << 4),
-			sec1_syndrome, row, channel, "e752x CE");
+	edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci,
+			     page, offset_in_page(sec1_add << 4), sec1_syndrome,
+			     row, channel, -1,
+			     "e752x CE", "", NULL);
 }

 static inline void process_ce(struct mem_ctl_info *mci, u16 error_one,
@@ -385,9 +390,12 @@
 			edac_mc_find_csrow_by_page(mci, block_page);

 		/* e752x mc reads 34:6 of the DRAM linear address */
-		edac_mc_handle_ue(mci, block_page,
-				offset_in_page(error_2b << 4),
-				row, "e752x UE from Read");
+		edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci,
+					block_page,
+					offset_in_page(error_2b << 4), 0,
+					 row, -1, -1,
+					"e752x UE from Read", "", NULL);
+
 	}
 	if (error_one & 0x0404) {
 		error_2b = scrb_add;
@@ -401,9 +409,11 @@
 			edac_mc_find_csrow_by_page(mci, block_page);

 		/* e752x mc reads 34:6 of the DRAM linear address */
-		edac_mc_handle_ue(mci, block_page,
-				offset_in_page(error_2b << 4),
-				row, "e752x UE from Scruber");
+		edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci,
+					block_page,
+					offset_in_page(error_2b << 4), 0,
+					row, -1, -1,
+					"e752x UE from Scruber", "", NULL);
 	}
 }

@@ -426,7 +436,9 @@
 		return;

 	debugf3("%s()\n", __func__);
-	edac_mc_handle_ue_no_info(mci, "e752x UE log memory write");
+	edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0,
+			     -1, -1, -1,
+			     "e752x UE log memory write", "", NULL);
 }

 static void do_process_ded_retry(struct mem_ctl_info *mci, u16 error,
@@ -1081,10 +1093,11 @@
 		nr_pages = cumul_size - last_cumul_size;
 		last_cumul_size = cumul_size;

-		for (i = 0; i < drc_chan + 1; i++) {
+		for (i = 0; i < csrow->nr_channels; i++) {
 			struct dimm_info *dimm = csrow->channels[i].dimm;

-			dimm->nr_pages = nr_pages / (drc_chan + 1);
+			debugf3("Initializing rank at (%i,%i)\n", index, i);
+			dimm->nr_pages = nr_pages / csrow->nr_channels;
 			dimm->grain = 1 << 12;	/* 4KiB - resolution of CELOG */
 			dimm->mtype = MEM_RDDR;	/* only one type supported */
 			dimm->dtype = mem_dev ? DEV_X4 : DEV_X8;
@@ -1232,6 +1245,7 @@
 	u16 pci_data;
 	u8 stat8;
 	struct mem_ctl_info *mci;
+	struct edac_mc_layer layers[2];
 	struct e752x_pvt *pvt;
 	u16 ddrcsr;
 	int drc_chan;		/* Number of channels 0=1chan,1=2chan */
@@ -1258,11 +1272,16 @@
 	/* Dual channel = 1, Single channel = 0 */
 	drc_chan = dual_channel_active(ddrcsr);

-	mci = edac_mc_alloc(sizeof(*pvt), E752X_NR_CSROWS, drc_chan + 1, 0);
-
-	if (mci == NULL) {
+	layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
+	layers[0].size = E752X_NR_CSROWS;
+	layers[0].is_virt_csrow = true;
+	layers[1].type = EDAC_MC_LAYER_CHANNEL;
+	layers[1].size = drc_chan + 1;
+	layers[1].is_virt_csrow = false;
+	mci = new_edac_mc_alloc(0, ARRAY_SIZE(layers), layers,
+			    sizeof(*pvt));
+	if (mci == NULL)
 		return -ENOMEM;
-	}

 	debugf3("%s(): init mci\n", __func__);
 	mci->mtype_cap = MEM_FLAG_RDDR;


On Stream#read callback, free the pointers before entering the ruby world

Any ruby exception can prevent us from freeing the pointers
Also don't enter the ruby world if there is nothing to do there

--- ext/rbuv/rbuv_stream.c
+++ ext/rbuv/rbuv_stream.c
@@ -24,7 +24,7 @@
 typedef struct {
   uv_stream_t *uv_stream;
   ssize_t nread;
-  uv_buf_t *buf;
+  char *base;
 } _uv_stream_on_read_arg_t;

 typedef struct {
@@ -253,14 +253,36 @@
 }

 void _uv_stream_on_read(uv_stream_t *uv_stream, ssize_t nread, uv_buf_t buf) {
-  _uv_stream_on_read_arg_t arg = { .uv_stream = uv_stream, .nread = nread, .buf = &buf };
-  rb_thread_call_with_gvl((rbuv_rb_blocking_function_t)_uv_stream_on_read_no_gvl, &arg);
+  if (nread == 0) {
+    if (buf.base != NULL) {
+      free(buf.base);
+    }
+    return;
+  } else {
+    _uv_stream_on_read_arg_t arg;
+    arg.uv_stream = uv_stream;
+    arg.nread = nread;
+
+    if (nread < 0) {
+      if (buf.base != NULL) {
+        free(buf.base);
+      }
+      arg.base = NULL;
+    } else {
+      // Here uvrb uses realloc. not sure about that
+      // buf.base = realloc(buf.base, nread);
+      // should we reassign buf.len = nread?
+      arg.base = buf.base;
+    }
+    rb_thread_call_with_gvl((rbuv_rb_blocking_function_t)
+      _uv_stream_on_read_no_gvl, &arg);
+  }
 }

 void _uv_stream_on_read_no_gvl(_uv_stream_on_read_arg_t *arg) {
   uv_stream_t *uv_stream = arg->uv_stream;
   ssize_t nread = arg->nread;
-  uv_buf_t *buf = arg->buf;
+  char *base = arg->base;

   VALUE stream;
   rbuv_stream_t *rbuv_stream;
@@ -277,9 +299,7 @@
                         RSTRING_PTR(rb_inspect(stream)),
                         RSTRING_PTR(rb_inspect(on_read)));

-  if (nread > 0) {
-    rb_funcall(on_read, id_call, 1, rb_str_new(buf->base, nread));
-  } else {
+  if (nread < 0) {
     uv_err = uv_last_error(uv_stream->loop);
     if (uv_err.code == UV_EOF) {
       error = rb_exc_new2(rb_eEOFError, "end of file reached");
@@ -287,10 +307,9 @@
       error = rb_exc_new2(eRbuvError, uv_strerror(uv_err));
     }
     rb_funcall(on_read, id_call, 2, Qnil, error);
-  }
-
-  assert(buf->base);
-  free(buf->base);
+  } else {
+    rb_funcall(on_read, id_call, 1, rb_str_new(base, nread));
+  }
 }

 void _uv_stream_on_write(uv_write_t *uv_req, int status) {


edac: ibecc: Use boolean expressions in if conditions

Use only boolean in if conditions as new coding style implies.

Signed-off-by: Andrei Emeltchenko <a6565233ddc88e4fb9c66c1d70743223493f2ed4@intel.com>

--- drivers/edac/edac_ibecc.c
+++ drivers/edac/edac_ibecc.c
@@ -95,7 +95,7 @@

 	errsts = pcie_conf_read(bdf, ERRSTS_REG);

-	if (!(errsts & (ERRSTS_IBECC_COR | ERRSTS_IBECC_UC))) {
+	if ((errsts & (ERRSTS_IBECC_COR | ERRSTS_IBECC_UC)) == 0) {
 		return;
 	}

@@ -155,7 +155,7 @@
 			uint64_t size;
 			const char *type;

-			if (d ^ l_map) {
+			if ((d ^ l_map) != 0) {
 				type = get_dimm_width(DIMM_S_WIDTH(dimm_ch));
 				size = s_size;
 			} else {
@@ -163,7 +163,7 @@
 				size = l_size;
 			}

-			if (!size) {
+			if (size == 0) {
 				continue;
 			}

@@ -178,7 +178,7 @@
 {
 	struct ibecc_data *data = dev->data;

-	if (!ecclog) {
+	if (ecclog == 0) {
 		return;
 	}

@@ -186,11 +186,11 @@
 	error_data->address = ECC_ERROR_ERRADD(ecclog);
 	error_data->syndrome = ECC_ERROR_ERRSYND(ecclog);

-	if (ecclog & ECC_ERROR_MERRSTS) {
+	if ((ecclog & ECC_ERROR_MERRSTS) != 0) {
 		data->errors_uc++;
 	}

-	if (ecclog & ECC_ERROR_CERRSTS) {
+	if ((ecclog & ECC_ERROR_CERRSTS) != 0) {
 		data->errors_cor++;
 	}
 }
@@ -198,7 +198,7 @@
 #if defined(CONFIG_EDAC_ERROR_INJECT)
 static int inject_set_param1(const struct device *dev, uint64_t addr)
 {
-	if (addr & ~INJ_ADDR_BASE_MASK) {
+	if ((addr & ~INJ_ADDR_BASE_MASK) != 0) {
 		return -EINVAL;
 	}

@@ -216,7 +216,7 @@

 static int inject_set_param2(const struct device *dev, uint64_t mask)
 {
-	if (mask & ~INJ_ADDR_BASE_MASK_MASK) {
+	if ((mask & ~INJ_ADDR_BASE_MASK_MASK) != 0) {
 		return -EINVAL;
 	}

@@ -395,7 +395,7 @@
 	mchbar |= (uint64_t)pcie_conf_read(bdf, MCHBAR_REG + 1) << 32;

 	/* Check that MCHBAR is enabled */
-	if (!(mchbar & MCHBAR_ENABLE)) {
+	if ((mchbar & MCHBAR_ENABLE) == 0) {
 		LOG_ERR("MCHBAR is not enabled");
 		return -ENODEV;
 	}
@@ -454,7 +454,7 @@

 	status = sys_in8(NMI_STS_CNT_REG);

-	if (!(status & NMI_STS_SRC_SERR)) {
+	if (status & NMI_STS_SRC_SERR == 0) {
 		LOG_DBG("Skip NMI, NMI_STS_CNT: 0x%x", status);
 		/**
 		 * We should be able to find that this NMI we
@@ -495,18 +495,18 @@
 	}

 	/* Skip the same NMI handling for other cores and return handled */
-	if (arch_curr_cpu()->id) {
+	if (arch_curr_cpu()->id != 0) {
 		ret = true;
 		goto out;
 	}

-	if (edac_ecc_error_log_get(dev, &ecclog)) {
+	if (edac_ecc_error_log_get(dev, &ecclog) != 0) {
 		goto out;
 	}

 	parse_ecclog(dev, ecclog, &error_data);

-	if (data->cb) {
+	if (data->cb != NULL) {
 		data->cb(dev, &error_data);
 	}


edac: i5100 fix unmask ecc bits

edac: i5100 fix unmask ecc bits

Explicitly unmask ECC errors we are interested in reporting.

Signed-off-by: Arthur Jones <e0a4167e24b3738088c566c3997a0d4144e49f78@riverbed.com>
Signed-off-by: Doug Thompson <35920ba1a7821e73308e9ec6cecac34ddd29c0c4@xmission.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/edac/i5100_edac.c
+++ drivers/edac/i5100_edac.c
@@ -75,6 +75,7 @@
 #define		I5100_FERR_NF_MEM_ANY(a)  ((a) & I5100_FERR_NF_MEM_ANY_MASK)
 #define	I5100_NERR_NF_MEM	0xa4	/* MC Next Non-Fatal Errors */
 #define		I5100_NERR_NF_MEM_ANY(a)  I5100_FERR_NF_MEM_ANY(a)
+#define I5100_EMASK_MEM		0xa8	/* MC Error Mask Register */

 /* device 21 and 22, func 0 */
 #define I5100_MTR_0	0x154	/* Memory Technology Registers 0-3 */
@@ -709,6 +710,11 @@
 		goto bail;
 	}

+	/* enable error reporting... */
+	pci_read_config_dword(pdev, I5100_EMASK_MEM, &dw);
+	dw &= ~I5100_FERR_NF_MEM_ANY_MASK;
+	pci_write_config_dword(pdev, I5100_EMASK_MEM, dw);
+
 	/* device 21, func 0, Channel 0 Memory Map, Error Flag/Mask, etc... */
 	ch0mm = pci_get_device_func(PCI_VENDOR_ID_INTEL,
 				    PCI_DEVICE_ID_INTEL_5100_21, 0);


dmi-id: fix a memory leak in dmi_id_init error path

This patch adds a missing kfree(dmi_dev) in dmi_id_init error path.

Signed-off-by: Axel Lin <b6ffd6973e972cb999e8e535ab74da7fee0c035f@gmail.com>
Acked-by: Tejun Heo <546b05909706652891a87f7bfe385ae147f61f91@kernel.org>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/firmware/dmi-id.c
+++ drivers/firmware/dmi-id.c
@@ -229,10 +229,12 @@

 	ret = device_register(dmi_dev);
 	if (ret)
-		goto fail_class_unregister;
+		goto fail_free_dmi_dev;

 	return 0;

+fail_free_dmi_dev:
+	kfree(dmi_dev);
 fail_class_unregister:

 	class_unregister(&dmi_class);


gpio: mvebu: Use irq_get_trigger_type() to get IRQ flags

Use irq_get_trigger_type() to get the IRQ trigger type flags
instead calling irqd_get_trigger_type(irq_get_irq_data(irq))

Signed-off-by: Javier Martinez Canillas <039000e09e601bba70626bd0fbe59654c9cf8cac@collabora.co.uk>
Acked-by: Grant Likely <9069e6f5a2b566e2674a0ba1e2bf39c12c195fad@linaro.org>
Cc: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>
Cc: Samuel Ortiz <0ba86cb3f08bbb861958e54bd3438887adb4263c@linux.intel.com>
Acked-by: Jason Cooper <68c46a606457643eab92053c1c05574abb26f861@lakedaemon.net>
Cc: Andrew Lunn <02e0a999c50b1f88df7a8f5a04e1b76b35ea6a88@lunn.ch>
Cc: Russell King <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@arm.linux.org.uk>
Cc: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>
Cc: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Cc: f99ef57ccac738b558d0fc2e44478b3c5def9522@lists.infradead.org
Cc: 562397917b9a8bf316569a848858b12fb417723f@linux-mips.org
Link: http://lkml.kernel.org/r/1371228049-27080-3-git-send-email-039000e09e601bba70626bd0fbe59654c9cf8cac@collabora.co.uk
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

--- drivers/gpio/gpio-mvebu.c
+++ drivers/gpio/gpio-mvebu.c
@@ -457,7 +457,7 @@
 		if (!(cause & (1 << i)))
 			continue;

-		type = irqd_get_trigger_type(irq_get_irq_data(irq));
+		type = irq_get_trigger_type(irq);
 		if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
 			/* Swap polarity (race with GPIO line) */
 			u32 polarity;


added include for Enumerable::Reverse to instantiate successfully

--- EnumerableHelpers.h
+++ EnumerableHelpers.h
@@ -2,6 +2,7 @@
 #define STINGRAY_TOOLKIT_ENUMERABLEHELPERS_H

+#include <stingray/toolkit/EnumeratorFromStlContainer.h>
 #include <stingray/toolkit/IEnumerable.h>
 #include <stingray/toolkit/bind.h>
 #include <stingray/toolkit/functional.h>


gpio: Provide the STMPE GPIO driver with its own IRQ Domain

The STMPE GPIO driver can be used as an IRQ controller by some
related devices. Here we provide it with its very own IRQ Domain
so that IRQs can be issued dynamically. This will stand the
driver in good stead when it is enabled for Device Tree, as this
it a prerequisite.

Cc: Grant Likely <9069e6f5a2b566e2674a0ba1e2bf39c12c195fad@secretlab.ca>
Reviewed-by: Viresh Kumar <5ff32272b3d9f86512eddc8e0af523fc6f7924e5@linaro.org>
Signed-off-by: Lee Jones <630e34333487a351a857f6b705e04d30b37c1629@linaro.org>
Signed-off-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>

--- drivers/gpio/gpio-stmpe.c
+++ drivers/gpio/gpio-stmpe.c
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/irq.h>
+#include <linux/irqdomain.h>
 #include <linux/interrupt.h>
 #include <linux/of.h>
 #include <linux/mfd/stmpe.h>
@@ -29,6 +30,7 @@
 	struct stmpe *stmpe;
 	struct device *dev;
 	struct mutex irq_lock;
+	struct irq_domain *domain;

 	int irq_base;
 	unsigned norequest_mask;
@@ -104,7 +106,7 @@
 {
 	struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip);

-	return stmpe_gpio->irq_base + offset;
+	return irq_create_mapping(stmpe_gpio->domain, offset);
 }

 static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset)
@@ -133,7 +135,7 @@
 static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 {
 	struct stmpe_gpio *stmpe_gpio = irq_data_get_irq_chip_data(d);
-	int offset = d->irq - stmpe_gpio->irq_base;
+	int offset = d->hwirq;
 	int regoffset = offset / 8;
 	int mask = 1 << (offset % 8);

@@ -200,7 +202,7 @@
 static void stmpe_gpio_irq_mask(struct irq_data *d)
 {
 	struct stmpe_gpio *stmpe_gpio = irq_data_get_irq_chip_data(d);
-	int offset = d->irq - stmpe_gpio->irq_base;
+	int offset = d->hwirq;
 	int regoffset = offset / 8;
 	int mask = 1 << (offset % 8);

@@ -210,7 +212,7 @@
 static void stmpe_gpio_irq_unmask(struct irq_data *d)
 {
 	struct stmpe_gpio *stmpe_gpio = irq_data_get_irq_chip_data(d);
-	int offset = d->irq - stmpe_gpio->irq_base;
+	int offset = d->hwirq;
 	int regoffset = offset / 8;
 	int mask = 1 << (offset % 8);

@@ -252,8 +254,9 @@
 		while (stat) {
 			int bit = __ffs(stat);
 			int line = bank * 8 + bit;
-
-			handle_nested_irq(stmpe_gpio->irq_base + line);
+			int virq = irq_find_mapping(stmpe_gpio->domain, line);
+
+			handle_nested_irq(virq);
 			stat &= ~(1 << bit);
 		}

@@ -268,38 +271,55 @@
 	return IRQ_HANDLED;
 }

+int stmpe_gpio_irq_map(struct irq_domain *d, unsigned int virq,
+		       irq_hw_number_t hwirq)
+{
+	struct stmpe_gpio *stmpe_gpio = d->host_data;
+
+	if (!stmpe_gpio)
+		return -EINVAL;
+
+	irq_set_chip_data(hwirq, stmpe_gpio);
+	irq_set_chip_and_handler(hwirq, &stmpe_gpio_irq_chip,
+				 handle_simple_irq);
+	irq_set_nested_thread(hwirq, 1);
+#ifdef CONFIG_ARM
+	set_irq_flags(hwirq, IRQF_VALID);
+#else
+	irq_set_noprobe(hwirq);
+#endif
+
+	return 0;
+}
+
+void stmpe_gpio_irq_unmap(struct irq_domain *d, unsigned int virq)
+{
+#ifdef CONFIG_ARM
+	set_irq_flags(virq, 0);
+#endif
+	irq_set_chip_and_handler(virq, NULL, NULL);
+	irq_set_chip_data(virq, NULL);
+}
+
+static const struct irq_domain_ops stmpe_gpio_irq_simple_ops = {
+	.unmap = stmpe_gpio_irq_unmap,
+	.map = stmpe_gpio_irq_map,
+	.xlate = irq_domain_xlate_twocell,
+};
+
 static int __devinit stmpe_gpio_irq_init(struct stmpe_gpio *stmpe_gpio)
 {
 	int base = stmpe_gpio->irq_base;
-	int irq;
-
-	for (irq = base; irq < base + stmpe_gpio->chip.ngpio; irq++) {
-		irq_set_chip_data(irq, stmpe_gpio);
-		irq_set_chip_and_handler(irq, &stmpe_gpio_irq_chip,
-					 handle_simple_irq);
-		irq_set_nested_thread(irq, 1);
-#ifdef CONFIG_ARM
-		set_irq_flags(irq, IRQF_VALID);
-#else
-		irq_set_noprobe(irq);
-#endif
+
+	stmpe_gpio->domain = irq_domain_add_simple(NULL,
+				stmpe_gpio->chip.ngpio, base,
+				&stmpe_gpio_irq_simple_ops, stmpe_gpio);
+	if (!stmpe_gpio->domain) {
+		dev_err(stmpe_gpio->dev, "failed to create irqdomain\n");
+		return -ENOSYS;
 	}

 	return 0;
-}
-
-static void stmpe_gpio_irq_remove(struct stmpe_gpio *stmpe_gpio)
-{
-	int base = stmpe_gpio->irq_base;
-	int irq;
-
-	for (irq = base; irq < base + stmpe_gpio->chip.ngpio; irq++) {
-#ifdef CONFIG_ARM
-		set_irq_flags(irq, 0);
-#endif
-		irq_set_chip_and_handler(irq, NULL, NULL);
-		irq_set_chip_data(irq, NULL);
-	}
 }

 static int __devinit stmpe_gpio_probe(struct platform_device *pdev)
@@ -354,7 +374,7 @@
 				IRQF_ONESHOT, "stmpe-gpio", stmpe_gpio);
 		if (ret) {
 			dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
-			goto out_removeirq;
+			goto out_disable;
 		}
 	}

@@ -374,9 +394,6 @@
 out_freeirq:
 	if (irq >= 0)
 		free_irq(irq, stmpe_gpio);
-out_removeirq:
-	if (irq >= 0)
-		stmpe_gpio_irq_remove(stmpe_gpio);
 out_disable:
 	stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
 out_free:
@@ -404,10 +421,9 @@

 	stmpe_disable(stmpe, STMPE_BLOCK_GPIO);

-	if (irq >= 0) {
+	if (irq >= 0)
 		free_irq(irq, stmpe_gpio);
-		stmpe_gpio_irq_remove(stmpe_gpio);
-	}
+
 	platform_set_drvdata(pdev, NULL);
 	kfree(stmpe_gpio);


drm: Add missing __user annotation

drm: Add missing __user annotation

The drm_copy_field() function copies strings into userspace buffers, so
the first parameter needs to have a __user annotation to avoid warnings
from the sparse checker.

Signed-off-by: Thierry Reding <3055038c414aef68bf32c33b8118623e7554e0f2@nvidia.com>
Reviewed-by: David Herrmann <fb53b2ddb8d141e0cb39d7c67c2f81b6bc2eb0f7@gmail.com>
Signed-off-by: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>


drm: Make drm_ioctls const

drm: Make drm_ioctls const

We never modify the contents of drm_ioctls, so make it const.

Signed-off-by: Ville Syrjälä <cd6e8d405ca90be3a03d5427c5b24fbd2d68dcc4@linux.intel.com>
Signed-off-by: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>

--- drivers/gpu/drm/drm_drv.c
+++ drivers/gpu/drm/drm_drv.c
@@ -60,7 +60,7 @@
 	[DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0}

 /** Ioctl table */
-static struct drm_ioctl_desc drm_ioctls[] = {
+static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
@@ -375,7 +375,7 @@
 {
 	struct drm_file *file_priv = filp->private_data;
 	struct drm_device *dev;
-	struct drm_ioctl_desc *ioctl;
+	const struct drm_ioctl_desc *ioctl;
 	drm_ioctl_t *func;
 	unsigned int nr = DRM_IOCTL_NR(cmd);
 	int retcode = -EINVAL;


drm/gem: Fix typo in kerneldoc

drm/gem: Fix typo in kerneldoc

The function being documented is drm_gem_object_handle_free(), not
drm_gem_object_free().

Signed-off-by: Thierry Reding <3055038c414aef68bf32c33b8118623e7554e0f2@nvidia.com>


writes new padMatrix according to specifications

--- sgemm-small.c
+++ sgemm-small.c
@@ -4,16 +4,16 @@
 #include <stdio.h>

 #define SPECIAL 36
-#define BLOCKSIZE sizeof(__m128i) / sizeof(float) // should be 4
+#define REG_BLOCKSIZE sizeof(__m128i) / sizeof(float) // should be 4

-#define A_width  m_a
-#define A_height n_a
+#define A_height  m_a
+#define A_width n_a

-#define B_width  n_a
-#define B_height m_a
+#define B_height  n_a
+#define B_width m_a

+#define C_height m_a
 #define C_width  m_a
-#define C_height m_a

 /* ************************************************************************* */
 /* Tools                                                                     */
@@ -44,15 +44,47 @@
   //_mm_storeu_pd(m + position, data);
 }

+// /* Add padding to the matrix so that both dimentions are the nearest
+//  * multiples of four to enable register blocking.
+//  * __mm_128i allows 4 single precision floating points */
+// void padMatrix(int size, float ** m) {
+//   if (size % REG_BLOCKSIZE) {
+//     if (*m = realloc(*m, (size + (size % REG_BLOCKSIZE)) * sizeof(float)))
+//       errorAllocation();
+//     bzero(m + size, (size % REG_BLOCKSIZE) * sizeof(float)); /* fill with 0 */
+//   }
+// }
+
 /* Add padding to the matrix so that both dimentions are the nearest
  * multiples of four to enable register blocking.
  * __mm_128i allows 4 single precision floating points */
-void padMatrix(int size, float ** m) {
-  if (size % BLOCKSIZE) {
-    if (*m = realloc(*m, (size + (size % BLOCKSIZE)) * sizeof(float)))
-      errorAllocation();
-    bzero(m + size, (size % BLOCKSIZE) * sizeof(float)); /* fill with 0 */
+void padMatrix(int *m_a, int *n_a, float *A, float *B, float *C){
+
+  if (!(*m_a % REG_BLOCKSIZE) && !(*n_a % REG_BLOCKSIZE)) return;
+
+  int padded_m = ((*m_a -1) / REG_BLOCKSIZE +1) * REG_BLOCKSIZE;
+  int padded_n = ((*n_a -1) / REG_BLOCKSIZE +1) * REG_BLOCKSIZE;
+
+  //Pad Matrix A, column major
+  float *A_padded = (float*)calloc(total(padded_m, padded_n), sizeof(float));
+  if (!A_padded) errorAllocation();
+
+  for (int n = 0; n < n_a; ++n){
+    for (int m = 0; m < m_a; ++m){
+      //need optimization
+      A_padded[m+n*padded_m] = A[m+n*m_a];
+    }
   }
+
+  //Pad Matrix B, row major
+  float *B_padded = (float*)calloc(total(padded_m, padded_n), sizeof(float));
+  for (int m = 0; m < m_a; ++m){
+    for (int n = 0; n < n_a; ++n){
+      //need optimization
+      B_padded[n+m*padded_n] = B[n+m*n_a];
+    }
+  }
+
 }

 /* ************************************************************************* */
@@ -62,10 +94,10 @@
 /* Deals with general case where C = A x B, A is MxN and B is NxM */
 void sgemmRegular(int m_a, int n_a, float * A, float * B, float * C) {
   __m128i r;
-  padMatrix(total(A_width, A_height), &A);
-  padMatrix(total(B_width, B_height), &B);
+  padMatrix(total(A_height, A_width), &A);
+  padMatrix(total(B_height, B_width), &B);
   padMatrix(total(C_width, C_height), &C);
-  for (int i = 0; i < total(C_width, C_height); i += BLOCKSIZE) {
+  for (int i = 0; i < total(C_width, C_height); i += REG_BLOCKSIZE) {
     // todo: algorithm
     //r = _mm_add_pd(load(C, i), _mm_mul_pd(load(A, i), load(B, i)));
     //store(r, C, i);


drm: make frame duration time calculation more precise

It is a bit more precise to compute the total number of pixels first and
then divide, rather than multiplying the line pixel count by the
already-rounded line duration.

Signed-off-by: Daniel Kurtz <31914e832df1cd8e5daa417106c0c6f5297b27d7@chromium.org>
Signed-off-by: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>

--- drivers/gpu/drm/drm_irq.c
+++ drivers/gpu/drm/drm_irq.c
@@ -505,6 +505,7 @@

 	/* Valid dotclock? */
 	if (dotclock > 0) {
+		int frame_size;
 		/* Convert scanline length in pixels and video dot clock to
 		 * line duration, frame duration and pixel duration in
 		 * nanoseconds:
@@ -512,7 +513,10 @@
 		pixeldur_ns = (s64) div64_u64(1000000000, dotclock);
 		linedur_ns  = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal *
 					      1000000000), dotclock);
-		framedur_ns = (s64) crtc->hwmode.crtc_vtotal * linedur_ns;
+		frame_size = crtc->hwmode.crtc_htotal *
+				crtc->hwmode.crtc_vtotal;
+		framedur_ns = (s64) div64_u64((u64) frame_size * 1000000000,
+					      dotclock);
 	} else
 		DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n",
 			  crtc->base.id);


Removed unused enum

Removed unused enum

Change-Id: Ia8272ab838dea4276efca08c94b3d38489e85699

--- shared/view.h
+++ shared/view.h
@@ -25,13 +25,6 @@

 namespace DemoHelper
 {
-
-enum ControlDepthIndexRanges
-{
-    BACKGROUND_DEPTH_INDEX    = -10000000,
-    CONTENT_DEPTH_INDEX       =  0,
-    DECORATION_DEPTH_INDEX    =  10000000
-};

 /**
  * Provide a style for the view and its tool bar.


drm: Allow vblank support without DRIVER_HAVE_IRQ

Drivers that register interrupt handlers without the DRM core helpers
don't initialize the .irq_enabled field and drm_dev_to_irq() may fail
when called on them. This shouldn't preclude them from implementing
the vblank IOCTL.

Signed-off-by: Thierry Reding <b75a4d02013b0e68ae2c6bb0dcfd4b7bec282dc9@avionic-design.de>
Signed-off-by: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>

--- drivers/gpu/drm/drm_irq.c
+++ drivers/gpu/drm/drm_irq.c
@@ -1218,8 +1218,9 @@
 	int ret;
 	unsigned int flags, seq, crtc, high_crtc;

-	if ((!drm_dev_to_irq(dev)) || (!dev->irq_enabled))
-		return -EINVAL;
+	if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
+		if ((!drm_dev_to_irq(dev)) || (!dev->irq_enabled))
+			return -EINVAL;

 	if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
 		return -EINVAL;