[PATCH v4 4/6] ARM: at91: Implement clocksource selection

2018-04-18 Thread Alexandre Belloni
Allow selecting and unselecting the PIT clocksource driver so it doesn't
have to be compile when unused.

Tested-by: Alexander Dahl 
Signed-off-by: Alexandre Belloni 
---
 arch/arm/mach-at91/Kconfig | 25 +
 1 file changed, 25 insertions(+)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 1254bf9d91b4..64f18cd220b9 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -106,6 +106,31 @@ config SOC_AT91SAM9
AT91SAM9X35
AT91SAM9XE
 
+comment "Clocksource driver selection"
+
+config ATMEL_CLOCKSOURCE_PIT
+   bool "Periodic Interval Timer (PIT) support"
+   depends on SOC_AT91SAM9 || SOC_SAMA5
+   default SOC_AT91SAM9 || SOC_SAMA5
+   select ATMEL_PIT
+   help
+ Select this to get a clocksource based on the Atmel Periodic Interval
+ Timer. It has a relatively low resolution and the TC Block clocksource
+ should be preferred.
+
+config ATMEL_CLOCKSOURCE_TCB
+   bool "Timer Counter Blocks (TCB) support"
+   depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
+   default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
+   depends on !ATMEL_TCLIB
+   select ATMEL_ARM_TCB_CLKSRC
+   help
+ Select this to get a high precision clocksource based on a
+ TC block with a 5+ MHz base clock rate.
+ On platforms with 16-bit counters, two timer channels are combined
+ to make a single 32-bit timer.
+ It can also be used as a clock event device supporting oneshot mode.
+
 config HAVE_AT91_UTMI
bool
 
-- 
2.17.0



[PATCH v4 3/6] clocksource/drivers: atmel-pit: make option silent

2018-04-18 Thread Alexandre Belloni
To conform with the other option, make the ATMEL_PIT option silent so it
can be selected from the platform

Tested-by: Alexander Dahl 
Signed-off-by: Alexandre Belloni 
---
 drivers/clocksource/Kconfig | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 540892273a8d..cb635d5d7f42 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -384,8 +384,11 @@ config ARMV7M_SYSTICK
  This options enables support for the ARMv7M system timer unit
 
 config ATMEL_PIT
+   bool "Microchip ARM Periodic Interval Timer (PIT)" if COMPILE_TEST
select TIMER_OF if OF
-   def_bool SOC_AT91SAM9 || SOC_SAMA5
+   help
+ This enables build of clocksource and clockevent driver for
+ the integrated PIT in Microchip ARM SoCs.
 
 config ATMEL_ST
bool "Atmel ST timer support" if COMPILE_TEST
-- 
2.17.0



[PATCH v4 0/6] clocksource: rework Atmel TCB timer driver

2018-04-18 Thread Alexandre Belloni
Hi,

This series gets back on the TCB drivers rework. It introduces a new driver to
handle the clocksource and clockevent devices.

As a reminder, this is necessary because:
 - the current tcb_clksrc driver is probed too late to be able to be used at
   boot and we now have SoCs that don't have a PIT. They currently are not able
   to boot a mainline kernel.
 - using the PIT doesn't work well with preempt-rt because its interrupt is
   shared (in particular with the UART and their interrupt flags are
   incompatible)
 - the current solution is wasting some TCB channels

The plan is to get this driver upstream, then convert the TCB PWM driver to be
able to get rid of the tcb_clksrc driver along with atmel_tclib.

Changes in v4:
 - rebased on top of v4.17-rc1
 - fixed an issue when setting max_delta for clockevents_config_and_register

Alexandre Belloni (6):
  ARM: at91: add TCB registers definitions
  clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  clocksource/drivers: atmel-pit: make option silent
  ARM: at91: Implement clocksource selection
  ARM: configs: at91: use new TCB timer driver
  ARM: configs: at91: unselect PIT

 arch/arm/configs/at91_dt_defconfig|   2 +-
 arch/arm/configs/sama5_defconfig  |   2 +-
 arch/arm/mach-at91/Kconfig|  25 ++
 drivers/clocksource/Kconfig   |  13 +-
 drivers/clocksource/Makefile  |   3 +-
 drivers/clocksource/timer-atmel-tcb.c | 608 ++
 include/soc/at91/atmel_tcb.h  | 216 +
 7 files changed, 865 insertions(+), 4 deletions(-)
 create mode 100644 drivers/clocksource/timer-atmel-tcb.c
 create mode 100644 include/soc/at91/atmel_tcb.h

-- 
2.17.0



[PATCH v2 1/3] perf tools powerpc: Fix callchain ip filtering

2018-04-18 Thread Sandipan Das
For powerpc64, if a probe is added for a function without specifying
a line number, the corresponding trap instruction is placed at offset
0 (for big endian) or 8 (for little endian) from the start address of
the function. This address is in the function prologue and the trap
instruction preceeds the instruction that writes the return address
to the caller's stack frame. So, the call frame information will say
that the return address is undefined here and there will be no DWARF
operations to describe this.

Alternatively, if we place a probe in the function prologue at some
address after the LR value has been copied to R0 but before R0 is
written to the caller's stack frame, the call frame information will
say that the return address is available in R0 and there will be a
corresponding DWARF operation to describe this.

For both these cases, the return address is not available on the
stack which implies that the LR value at index 2 of the callchain
ips provided by the kernel is still valid and must not be skipped.

This can be observed on a powerpc64le system running Fedora 27 as
shown below.

 # objdump -d /usr/lib64/libc-2.26.so | less
 ...
 0015af20 :
   15af20:   0b 00 4c 3c addis   r2,r12,11
   15af24:   e0 c1 42 38 addir2,r2,-15904
   15af28:   a6 02 08 7c mflrr0
   15af2c:   f0 ff c1 fb std r30,-16(r1)
   15af30:   f8 ff e1 fb std r31,-8(r1)
   15af34:   78 1b 7f 7c mr  r31,r3
   15af38:   78 23 83 7c mr  r3,r4
   15af3c:   78 2b be 7c mr  r30,r5
   15af40:   10 00 01 f8 std r0,16(r1)
   15af44:   c1 ff 21 f8 stdur1,-64(r1)
   15af48:   28 00 81 f8 std r4,40(r1)
 ...

 # readelf --debug-dump=frames-interp /usr/lib64/libc-2.26.so | less
 ...
 00027024 0024 00027028 FDE cie= 
pc=0015af20..0015af88
LOC   CFA  r30   r31   ra
 0015af20 r1+0 u u u
 0015af34 r1+0 c-16  c-8   r0
 0015af48 r1+64c-16  c-8   c+16
 0015af5c r1+0 c-16  c-8   c+16
 0015af78 r1+0 u u
 ...

Case 1 - Probe at 0x15af28, return address is undefined.
 # perf probe -x /usr/lib64/libc-2.26.so -a inet_pton
 # perf record -e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1
 # perf script

Case 2 - Probe at 0x15af38, return address is in R0.
 # perf probe -x /usr/lib64/libc-2.26.so -a 0x15af38
 # perf record -e probe_libc:abs_15af38/max-stack=3/ ping -6 -c 1 ::1
 # perf script

Output before applying this patch:

 ping 27909 [007] 532219.943481: probe_libc:inet_pton: (7fff99b0af28)
   15af28 __GI___inet_pton (/usr/lib64/libc-2.26.so)
   1105b4 getaddrinfo (/usr/lib64/libc-2.26.so)

Output after applying this patch:

 ping 27909 [007] 532219.943481: probe_libc:inet_pton: (7fff99b0af28)
   15af28 __GI___inet_pton (/usr/lib64/libc-2.26.so)
   10fa54 gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so)
   1105b4 getaddrinfo (/usr/lib64/libc-2.26.so)

Fixes: a60335ba3298 ("perf tools powerpc: Adjust callchain based on DWARF debug 
info")
Signed-off-by: Sandipan Das 
---
v2:
 - Consider case when return address is in R0 as pointed out by Ravi.
 - Rather than declaring a separate get_return_addr() function that
   ultimately calls check_return_addr() and since check_return_addr()
   is called only from get_return_addr(), integrate additional tasks
   such as finding DSO information inside check_return_addr() itself
   instead of having another function.
 - Update commit message with description of both cases and how to
   reproduce them.
---
 tools/perf/arch/powerpc/util/skip-callchain-idx.c | 72 ++-
 1 file changed, 44 insertions(+), 28 deletions(-)

diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c 
b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
index 0c370f81e002..d3a13f79d3ee 100644
--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
+++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
@@ -61,7 +61,13 @@ static int check_return_reg(int ra_regno, Dwarf_Frame *frame)
 * Check if return address is on the stack.
 */
if (nops != 0 || ops != NULL)
-   return 0;
+   /*
+* Check if return address is not in R0. In that
+* case, it must be on the stack.
+*/
+   if (nops != 1 || ops[0].atom != DW_OP_regx ||
+   ops[0].number != 0 || ops[0].number2 != 0)
+   return 0;
 
/*
 * Return address is in LR. Check if a frame was allocated
@@ -145,18 +151,32 @@ static Dwarf_Frame *get_dwarf_frame(Dwfl_Module *mod, 
Dwarf_Addr pc)
  * yet used)
  * -1 in case of errors
  */
-static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc)
+static int 

[PATCH v2 3/3] perf tests: Fix record+probe_libc_inet_pton.sh for powerpc64

2018-04-18 Thread Sandipan Das
For powerpc64, this test currently fails due to a mismatch in
the expected output.

Output before applying this patch:

  62: probe libc's inet_pton & backtrace it with ping   :
  --- start ---
  test child forked, pid 27723
  ping 27740 [012] 607801.690493: probe_libc:inet_pton: (7fff936caf28)
  15af28 __GI___inet_pton (/usr/lib64/libc-2.26.so)
  10fa54 gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so)
  FAIL: expected backtrace entry 2 
"getaddrinfo[[:space:]]\(/usr/lib64/libc-2.26.so\)$" got "10fa54 
gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so)"
  test child finished with -1
   end 
  probe libc's inet_pton & backtrace it with ping: FAILED!

Output after applying this patch:

  62: probe libc's inet_pton & backtrace it with ping   :
  --- start ---
  test child forked, pid 28782
  ping 28799 [017] 608933.853323: probe_libc:inet_pton: (7fff891baf28)
  15af28 __GI___inet_pton (/usr/lib64/libc-2.26.so)
  10fa54 gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so)
  1105b4 getaddrinfo (/usr/lib64/libc-2.26.so)
  2d70 _init (/usr/bin/ping)
  test child finished with 0
   end 
  probe libc's inet_pton & backtrace it with ping: Ok

Fixes: e07d585e2454 ("perf tests: Switch trace+probe_libc_inet_pton to use 
record")
Signed-off-by: Sandipan Das 
---
 tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 8 
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 1ecc1f0ff84a..b45afc59edc6 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -26,6 +26,14 @@ trace_libc_inet_pton_backtrace() {
expected[5]="__libc_start_main[[:space:]]\($libc\)$"
expected[6]="_start[[:space:]]\(.*/bin/ping.*\)$"
;;
+   ppc64)
+   ;&
+   ppc64le)
+   eventattr='max-stack=4'
+   expected[2]="gaih_inet.*[[:space:]]\($libc\)$"
+   expected[3]="getaddrinfo[[:space:]]\($libc\)$"
+   expected[4]=".*\(.*/bin/ping.*\)$"
+   ;;
*)
eventattr='max-stack=3'
expected[2]="getaddrinfo[[:space:]]\($libc\)$"
-- 
2.14.3



[PATCH v2 0/3] perf: Fixes for callchain ip handling on powerpc

2018-04-18 Thread Sandipan Das
The first patch fixes the callchain ip filtering mechanism for powerpc
from skipping entries in case the LR value is still valid and yet to
be written to the stack frame. This was previously posted as an RFC
here: https://lkml.org/lkml/2018/4/4/633

The second patch fixes a crash caused by attempting to access an empty
callchain.

The third patch fixes a shell test which used to fail on powerpc as
the back trace from perf output did not match the expected pattern.
Also, because of the issue described in the first patch, some entries
from the callchain were incorrectly skipped. So, this has also been
readjusted to work with the fix in the first patch.

v2:
 - Consider case when return address is in R0 as pointed out by Ravi.
 - Add another patch to fix crash when callchain is empty.

Sandipan Das (3):
  perf tools powerpc: Fix callchain ip filtering
  perf tools powerpc: Fix crash if callchain is empty
  perf tests: Fix record+probe_libc_inet_pton.sh for powerpc64

 tools/perf/arch/powerpc/util/skip-callchain-idx.c  | 74 +-
 .../tests/shell/record+probe_libc_inet_pton.sh |  8 +++
 2 files changed, 53 insertions(+), 29 deletions(-)

-- 
2.14.3



Re: [Patch v3 2/6] cifs: Allocate validate negotiation request through kmalloc

2018-04-18 Thread Tom Talpey

Two comments.

On 4/17/2018 8:33 PM, Long Li wrote:

From: Long Li 

The data buffer allocated on the stack can't be DMA'ed, and hence can't send
through RDMA via SMB Direct.


This comment is confusing. Any registered memory can be DMA'd, need to
state the reason for the choice here more clearly.



Fix this by allocating the request on the heap in smb3_validate_negotiate.

Changes in v2:
Removed duplicated code on freeing buffers on function exit.
(Thanks to Parav Pandit )
Fixed typo in the patch title.

Changes in v3:
Added "Fixes" to the patch.
Changed sizeof() to use *pointer in place of struct.

Fixes: ff1c038addc4 ("Check SMB3 dialects against downgrade attacks")
Signed-off-by: Long Li 
Cc: sta...@vger.kernel.org
---
  fs/cifs/smb2pdu.c | 59 ++-
  1 file changed, 32 insertions(+), 27 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 0f044c4..5582a02 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -729,8 +729,8 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
  
  int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)

  {
-   int rc = 0;
-   struct validate_negotiate_info_req vneg_inbuf;
+   int ret, rc = -EIO;
+   struct validate_negotiate_info_req *pneg_inbuf;
struct validate_negotiate_info_rsp *pneg_rsp = NULL;
u32 rsplen;
u32 inbuflen; /* max of 4 dialects */
@@ -741,6 +741,9 @@ int smb3_validate_negotiate(const unsigned int xid, struct 
cifs_tcon *tcon)
if (tcon->ses->server->rdma)
return 0;
  #endif
+   pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_KERNEL);
+   if (!pneg_inbuf)
+   return -ENOMEM;


Why is this a nonblocking allocation? It would seem more robust to
use GFP_NOFS here.

Tom.

  
  	/* In SMB3.11 preauth integrity supersedes validate negotiate */

if (tcon->ses->server->dialect == SMB311_PROT_ID)
@@ -764,63 +767,63 @@ int smb3_validate_negotiate(const unsigned int xid, 
struct cifs_tcon *tcon)
if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
cifs_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by 
server\n");
  
-	vneg_inbuf.Capabilities =

+   pneg_inbuf->Capabilities =
cpu_to_le32(tcon->ses->server->vals->req_capabilities);
-   memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,
+   memcpy(pneg_inbuf->Guid, tcon->ses->server->client_guid,
SMB2_CLIENT_GUID_SIZE);
  
  	if (tcon->ses->sign)

-   vneg_inbuf.SecurityMode =
+   pneg_inbuf->SecurityMode =
cpu_to_le16(SMB2_NEGOTIATE_SIGNING_REQUIRED);
else if (global_secflags & CIFSSEC_MAY_SIGN)
-   vneg_inbuf.SecurityMode =
+   pneg_inbuf->SecurityMode =
cpu_to_le16(SMB2_NEGOTIATE_SIGNING_ENABLED);
else
-   vneg_inbuf.SecurityMode = 0;
+   pneg_inbuf->SecurityMode = 0;
  
  
  	if (strcmp(tcon->ses->server->vals->version_string,

SMB3ANY_VERSION_STRING) == 0) {
-   vneg_inbuf.Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
-   vneg_inbuf.Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
-   vneg_inbuf.DialectCount = cpu_to_le16(2);
+   pneg_inbuf->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
+   pneg_inbuf->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
+   pneg_inbuf->DialectCount = cpu_to_le16(2);
/* structure is big enough for 3 dialects, sending only 2 */
inbuflen = sizeof(struct validate_negotiate_info_req) - 2;
} else if (strcmp(tcon->ses->server->vals->version_string,
SMBDEFAULT_VERSION_STRING) == 0) {
-   vneg_inbuf.Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
-   vneg_inbuf.Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
-   vneg_inbuf.Dialects[2] = cpu_to_le16(SMB302_PROT_ID);
-   vneg_inbuf.DialectCount = cpu_to_le16(3);
+   pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
+   pneg_inbuf->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
+   pneg_inbuf->Dialects[2] = cpu_to_le16(SMB302_PROT_ID);
+   pneg_inbuf->DialectCount = cpu_to_le16(3);
/* structure is big enough for 3 dialects */
inbuflen = sizeof(struct validate_negotiate_info_req);
} else {
/* otherwise specific dialect was requested */
-   vneg_inbuf.Dialects[0] =
+   pneg_inbuf->Dialects[0] =
cpu_to_le16(tcon->ses->server->vals->protocol_id);
-   vneg_inbuf.DialectCount = cpu_to_le16(1);
+   pneg_inbuf->DialectCount = cpu_to_le16(1);
/* structure is big enough for 3 dialects, sending only 1 

[PATCH v6 5/7] vfio/type1: check dma map request is within a valid iova range

2018-04-18 Thread Shameer Kolothum
This checks and rejects any dma map request outside valid iova
range.

Signed-off-by: Shameer Kolothum 
---
 drivers/vfio/vfio_iommu_type1.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 6fd6841..bf33281 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1091,6 +1091,23 @@ static int vfio_pin_map_dma(struct vfio_iommu *iommu, 
struct vfio_dma *dma,
return ret;
 }
 
+/*
+ * Check dma map request is within a valid iova range
+ */
+static bool vfio_iommu_iova_dma_valid(struct vfio_iommu *iommu,
+   dma_addr_t start, dma_addr_t end)
+{
+   struct list_head *iova = >iova_list;
+   struct vfio_iova *node;
+
+   list_for_each_entry(node, iova, list) {
+   if ((start >= node->start) && (end <= node->end))
+   return true;
+   }
+
+   return false;
+}
+
 static int vfio_dma_do_map(struct vfio_iommu *iommu,
   struct vfio_iommu_type1_dma_map *map)
 {
@@ -1129,6 +1146,11 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
goto out_unlock;
}
 
+   if (!vfio_iommu_iova_dma_valid(iommu, iova, iova + size - 1)) {
+   ret = -EINVAL;
+   goto out_unlock;
+   }
+
dma = kzalloc(sizeof(*dma), GFP_KERNEL);
if (!dma) {
ret = -ENOMEM;
-- 
2.7.4




[PATCH v6 2/7] vfio/type1: Check reserve region conflict and update iova list

2018-04-18 Thread Shameer Kolothum
This retrieves the reserved regions associated with dev group and
checks for conflicts with any existing dma mappings. Also update
the iova list excluding the reserved regions.

Signed-off-by: Shameer Kolothum 
---
 drivers/vfio/vfio_iommu_type1.c | 90 +
 1 file changed, 90 insertions(+)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 775946d..a0a79e1 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1422,6 +1422,82 @@ static int vfio_iommu_aper_resize(struct list_head *iova,
return 0;
 }
 
+/*
+ * Check reserved region conflicts with existing dma mappings
+ */
+static bool vfio_iommu_resv_conflict(struct vfio_iommu *iommu,
+   struct list_head *resv_regions)
+{
+   struct iommu_resv_region *region;
+
+   /* Check for conflict with existing dma mappings */
+   list_for_each_entry(region, resv_regions, list) {
+   if (vfio_find_dma(iommu, region->start, region->length))
+   return true;
+   }
+
+   return false;
+}
+
+/*
+ * Check iova region overlap with  reserved regions and
+ * exclude them from the iommu iova range
+ */
+static int vfio_iommu_resv_exclude(struct list_head *iova,
+   struct list_head *resv_regions)
+{
+   struct iommu_resv_region *resv;
+   struct vfio_iova *n, *next;
+
+   list_for_each_entry(resv, resv_regions, list) {
+   phys_addr_t start, end;
+
+   start = resv->start;
+   end = resv->start + resv->length - 1;
+
+   list_for_each_entry_safe(n, next, iova, list) {
+   int ret = 0;
+
+   /* No overlap */
+   if ((start > n->end) || (end < n->start))
+   continue;
+   /*
+* Insert a new node if current node overlaps with the
+* reserve region to exlude that from valid iova range.
+* Note that, new node is inserted before the current
+* node and finally the current node is deleted keeping
+* the list updated and sorted.
+*/
+   if (start > n->start)
+   ret = vfio_iommu_iova_insert(>list,
+   n->start, start - 1);
+   if (!ret && end < n->end)
+   ret = vfio_iommu_iova_insert(>list,
+   end + 1, n->end);
+   if (ret)
+   return ret;
+
+   list_del(>list);
+   kfree(n);
+   }
+   }
+
+   if (list_empty(iova))
+   return -EINVAL;
+
+   return 0;
+}
+
+static void vfio_iommu_resv_free(struct list_head *resv_regions)
+{
+   struct iommu_resv_region *n, *next;
+
+   list_for_each_entry_safe(n, next, resv_regions, list) {
+   list_del(>list);
+   kfree(n);
+   }
+}
+
 static void vfio_iommu_iova_free(struct list_head *iova)
 {
struct vfio_iova *n, *next;
@@ -1475,6 +1551,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
phys_addr_t resv_msi_base;
struct iommu_domain_geometry geo;
LIST_HEAD(iova_copy);
+   LIST_HEAD(group_resv_regions);
 
mutex_lock(>lock);
 
@@ -1553,6 +1630,13 @@ static int vfio_iommu_type1_attach_group(void 
*iommu_data,
goto out_detach;
}
 
+   iommu_get_group_resv_regions(iommu_group, _resv_regions);
+
+   if (vfio_iommu_resv_conflict(iommu, _resv_regions)) {
+   ret = -EINVAL;
+   goto out_detach;
+   }
+
/* Get a copy of the current iova list and work on it */
ret = vfio_iommu_iova_get_copy(iommu, _copy);
if (ret)
@@ -1563,6 +1647,10 @@ static int vfio_iommu_type1_attach_group(void 
*iommu_data,
if (ret)
goto out_detach;
 
+   ret = vfio_iommu_resv_exclude(_copy, _resv_regions);
+   if (ret)
+   goto out_detach;
+
resv_msi = vfio_iommu_has_sw_msi(iommu_group, _msi_base);
 
INIT_LIST_HEAD(>group_list);
@@ -1623,6 +1711,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
/* Delete the old one and insert new iova list */
vfio_iommu_iova_insert_copy(iommu, _copy);
mutex_unlock(>lock);
+   vfio_iommu_resv_free(_resv_regions);
 
return 0;
 
@@ -1631,6 +1720,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
 out_domain:
iommu_domain_free(domain->domain);
vfio_iommu_iova_free(_copy);
+   vfio_iommu_resv_free(_resv_regions);
 out_free:
kfree(domain);

[PATCH v6 6/7] vfio/type1: Add IOVA range capability support

2018-04-18 Thread Shameer Kolothum
This  allows the user-space to retrieve the supported IOVA
range(s), excluding any reserved regions. The implementation
is based on capability chains, added to VFIO_IOMMU_GET_INFO ioctl.

Signed-off-by: Shameer Kolothum 
---
 drivers/vfio/vfio_iommu_type1.c | 96 +
 include/uapi/linux/vfio.h   | 23 ++
 2 files changed, 119 insertions(+)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index bf33281..44d0f13d 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -2038,6 +2038,68 @@ static int vfio_domains_have_iommu_cache(struct 
vfio_iommu *iommu)
return ret;
 }
 
+static int vfio_iommu_iova_add_cap(struct vfio_info_cap *caps,
+struct vfio_iommu_type1_info_cap_iova_range *cap_iovas,
+size_t size)
+{
+   struct vfio_info_cap_header *header;
+   struct vfio_iommu_type1_info_cap_iova_range *iova_cap;
+
+   header = vfio_info_cap_add(caps, size,
+   VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE, 1);
+   if (IS_ERR(header))
+   return PTR_ERR(header);
+
+   iova_cap = container_of(header,
+   struct vfio_iommu_type1_info_cap_iova_range, header);
+   iova_cap->nr_iovas = cap_iovas->nr_iovas;
+   memcpy(iova_cap->iova_ranges, cap_iovas->iova_ranges,
+   cap_iovas->nr_iovas * sizeof(*cap_iovas->iova_ranges));
+   return 0;
+}
+
+static int vfio_iommu_iova_build_caps(struct vfio_iommu *iommu,
+   struct vfio_info_cap *caps)
+{
+   struct vfio_iommu_type1_info_cap_iova_range *cap_iovas;
+   struct vfio_iova *iova;
+   size_t size;
+   int iovas = 0, i = 0, ret;
+
+   mutex_lock(>lock);
+
+   list_for_each_entry(iova, >iova_list, list)
+   iovas++;
+
+   if (!iovas) {
+   ret = -EINVAL;
+   goto out_unlock;
+   }
+
+   size = sizeof(*cap_iovas) + (iovas * sizeof(*cap_iovas->iova_ranges));
+
+   cap_iovas = kzalloc(size, GFP_KERNEL);
+   if (!cap_iovas) {
+   ret = -ENOMEM;
+   goto out_unlock;
+   }
+
+   cap_iovas->nr_iovas = iovas;
+
+   list_for_each_entry(iova, >iova_list, list) {
+   cap_iovas->iova_ranges[i].start = iova->start;
+   cap_iovas->iova_ranges[i].end = iova->end;
+   i++;
+   }
+
+   ret = vfio_iommu_iova_add_cap(caps, cap_iovas, size);
+
+   kfree(cap_iovas);
+out_unlock:
+   mutex_unlock(>lock);
+   return ret;
+}
+
 static long vfio_iommu_type1_ioctl(void *iommu_data,
   unsigned int cmd, unsigned long arg)
 {
@@ -2059,19 +2121,53 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
}
} else if (cmd == VFIO_IOMMU_GET_INFO) {
struct vfio_iommu_type1_info info;
+   struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
+   unsigned long capsz;
+   int ret;
 
minsz = offsetofend(struct vfio_iommu_type1_info, iova_pgsizes);
 
+   /* For backward compatibility, cannot require this */
+   capsz = offsetofend(struct vfio_iommu_type1_info, cap_offset);
+
if (copy_from_user(, (void __user *)arg, minsz))
return -EFAULT;
 
if (info.argsz < minsz)
return -EINVAL;
 
+   if (info.argsz >= capsz) {
+   minsz = capsz;
+   info.cap_offset = 0; /* output, no-recopy necessary */
+   }
+
info.flags = VFIO_IOMMU_INFO_PGSIZES;
 
info.iova_pgsizes = vfio_pgsize_bitmap(iommu);
 
+   ret = vfio_iommu_iova_build_caps(iommu, );
+   if (ret)
+   return ret;
+
+   if (caps.size) {
+   info.flags |= VFIO_IOMMU_INFO_CAPS;
+
+   if (info.argsz < sizeof(info) + caps.size) {
+   info.argsz = sizeof(info) + caps.size;
+   } else {
+   vfio_info_cap_shift(, sizeof(info));
+   if (copy_to_user((void __user *)arg +
+   sizeof(info), caps.buf,
+   caps.size)) {
+   kfree(caps.buf);
+   return -EFAULT;
+   }
+   info.cap_offset = sizeof(info);
+   }
+
+   kfree(caps.buf);
+   }
+
return copy_to_user((void __user *)arg, , minsz) ?
-EFAULT : 0;
 
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 1aa7b82..f1bf6b7 

sysrq option to save the boot log to a file for the purpose of troubleshooting booting issues ?

2018-04-18 Thread AIAMUZZ
Hi,

When the system boots i often encounter the boot process hanging. I
usually hit 'Ctrl+Alt+Del' to reboot.

After coming across Magis Sysrq option, i have even tried sysrq+b to
boot my system from the frozen boot state.

after repeated attempts when i successfully log into the system. I
don't find the unsuccessful boot attempts i previously had encounterd
in syslog or any other log files in ' /var/log/ ' forder.

As a result i am unable to identify the root cause of the boot freezes
my system experiences.

I would like to know if there is any 'sysrq' option that will enable
me to record/capture the boot message from the boot freeze which i can
later use to troubleshoot why the boot freeze's occurrence on my
system ?

If there is no such 'sysrq' option at present, wouldn't it be a great
idea to have an option that will help one to capture/save the system
boot messages to a file in ' /var/log ' folder each time he/she
encounters a boot freeze ?

thanks.


[PATCH v6 7/7] vfio/type1: remove duplicate retrieval of reserved regions

2018-04-18 Thread Shameer Kolothum
As we now already have the reserved regions list, just pass that into
vfio_iommu_has_sw_msi() fn.

Signed-off-by: Shameer Kolothum 
---
 drivers/vfio/vfio_iommu_type1.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 44d0f13d..13c631a 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1313,15 +1313,13 @@ static struct vfio_group *find_iommu_group(struct 
vfio_domain *domain,
return NULL;
 }
 
-static bool vfio_iommu_has_sw_msi(struct iommu_group *group, phys_addr_t *base)
+static bool vfio_iommu_has_sw_msi(struct list_head *group_resv_regions,
+   phys_addr_t *base)
 {
-   struct list_head group_resv_regions;
-   struct iommu_resv_region *region, *next;
+   struct iommu_resv_region *region;
bool ret = false;
 
-   INIT_LIST_HEAD(_resv_regions);
-   iommu_get_group_resv_regions(group, _resv_regions);
-   list_for_each_entry(region, _resv_regions, list) {
+   list_for_each_entry(region, group_resv_regions, list) {
/*
 * The presence of any 'real' MSI regions should take
 * precedence over the software-managed one if the
@@ -1337,8 +1335,7 @@ static bool vfio_iommu_has_sw_msi(struct iommu_group 
*group, phys_addr_t *base)
ret = true;
}
}
-   list_for_each_entry_safe(region, next, _resv_regions, list)
-   kfree(region);
+
return ret;
 }
 
@@ -1673,7 +1670,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
if (ret)
goto out_detach;
 
-   resv_msi = vfio_iommu_has_sw_msi(iommu_group, _msi_base);
+   resv_msi = vfio_iommu_has_sw_msi(_resv_regions, _msi_base);
 
INIT_LIST_HEAD(>group_list);
list_add(>next, >group_list);
-- 
2.7.4




Re: [PATCH] lightnvm: pblk: take bitmap alloc. out of critical section

2018-04-18 Thread Javier González
> On 17 Apr 2018, at 04.48, Matias Bjørling  wrote:
> 
> On 4/16/18 12:21 PM, Javier González wrote:
>> Allocate line bitmaps outside of the line lock on line preparation.
>> Signed-off-by: Javier González 
> 
> 
> The patch description tells what the patch does, it should tell why
> the change the done.
> 

Taking an allocation out of a critical zone should be a reason on itself.

>> ---
>>  drivers/lightnvm/pblk-core.c | 96 
>> +---
>>  1 file changed, 55 insertions(+), 41 deletions(-)
>> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
>> index 5f960a6609c8..7762e89984ee 100644
>> --- a/drivers/lightnvm/pblk-core.c
>> +++ b/drivers/lightnvm/pblk-core.c
>> @@ -1058,6 +1058,25 @@ static int pblk_line_init_metadata(struct pblk *pblk, 
>> struct pblk_line *line,
>>  return 1;
>>  }
>>  +static int pblk_line_alloc_bitmaps(struct pblk *pblk, struct pblk_line 
>> *line)
>> +{
>> +struct pblk_line_meta *lm = >lm;
>> +
>> +line->map_bitmap = kzalloc(lm->sec_bitmap_len, GFP_KERNEL);
>> +if (!line->map_bitmap)
>> +return -ENOMEM;
>> +
>> +/* will be initialized using bb info from map_bitmap */
>> +line->invalid_bitmap = kmalloc(lm->sec_bitmap_len, GFP_KERNEL);
>> +if (!line->invalid_bitmap) {
>> +kfree(line->map_bitmap);
>> +line->map_bitmap = NULL;
>> +return -ENOMEM;
>> +}
>> +
>> +return 0;
>> +}
>> +
>>  /* For now lines are always assumed full lines. Thus, smeta former and 
>> current
>>   * lun bitmaps are omitted.
>>   */
>> @@ -1162,18 +1181,7 @@ static int pblk_line_prepare(struct pblk *pblk, 
>> struct pblk_line *line)
>>  {
>>  struct pblk_line_meta *lm = >lm;
>>  int blk_in_line = atomic_read(>blk_in_line);
>> -int blk_to_erase, ret;
>> -
>> -line->map_bitmap = kzalloc(lm->sec_bitmap_len, GFP_ATOMIC);
>> -if (!line->map_bitmap)
>> -return -ENOMEM;
>> -
>> -/* will be initialized using bb info from map_bitmap */
>> -line->invalid_bitmap = kmalloc(lm->sec_bitmap_len, GFP_ATOMIC);
>> -if (!line->invalid_bitmap) {
>> -ret = -ENOMEM;
>> -goto fail_free_map_bitmap;
>> -}
>> +int blk_to_erase;
>>  /* Bad blocks do not need to be erased */
>>  bitmap_copy(line->erase_bitmap, line->blk_bitmap, lm->blk_per_line);
>> @@ -1191,15 +1199,15 @@ static int pblk_line_prepare(struct pblk *pblk, 
>> struct pblk_line *line)
>>  }
>>  if (blk_in_line < lm->min_blk_line) {
>> -ret = -EAGAIN;
>> -goto fail_free_invalid_bitmap;
>> +spin_unlock(>lock);
>> +return -EAGAIN;
>>  }
>>  if (line->state != PBLK_LINESTATE_FREE) {
>>  WARN(1, "pblk: corrupted line %d, state %d\n",
>>  line->id, line->state);
>> -ret = -EINTR;
>> -goto fail_free_invalid_bitmap;
>> +spin_unlock(>lock);
>> +return -EINTR;
>>  }
>>  line->state = PBLK_LINESTATE_OPEN;
>> @@ -1213,16 +1221,6 @@ static int pblk_line_prepare(struct pblk *pblk, 
>> struct pblk_line *line)
>>  kref_init(>ref);
>>  return 0;
>> -
>> -fail_free_invalid_bitmap:
>> -spin_unlock(>lock);
>> -kfree(line->invalid_bitmap);
>> -line->invalid_bitmap = NULL;
>> -fail_free_map_bitmap:
>> -kfree(line->map_bitmap);
>> -line->map_bitmap = NULL;
>> -
>> -return ret;
>>  }
>>int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line)
>> @@ -1242,13 +1240,15 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct 
>> pblk_line *line)
>>  }
>>  spin_unlock(_mg->free_lock);
>>  -   pblk_rl_free_lines_dec(>rl, line, true);
>> +if (pblk_line_alloc_bitmaps(pblk, line))
>> +return -EINTR;
> 
> Why return -EINTR, instead of the return value from (0, -ENOMEM) from 
> pblk_line_alloc_bitmap?

Sure.

> 
> 
>>  if (!pblk_line_init_bb(pblk, line, 0)) {
>>  list_add(>list, _mg->free_list);
>>  return -EINTR;
>>  }
>>  +   pblk_rl_free_lines_dec(>rl, line, true);
>>  return 0;
>>  }
>>  @@ -1260,6 +1260,24 @@ void pblk_line_recov_close(struct pblk *pblk, struct 
>> pblk_line *line)
>>  line->emeta = NULL;
>>  }
>>  +static void pblk_line_clear(struct pblk_line *line)
>> +{
>> +*line->vsc = cpu_to_le32(EMPTY_ENTRY);
>> +
>> +line->map_bitmap = NULL;
>> +line->invalid_bitmap = NULL;
>> +line->smeta = NULL;
>> +line->emeta = NULL;
>> +}
> 
> Instead of pblk_line_clear, how about pblk_line_reinit?

Em... yes, why not.

I'll resend.

Javier


signature.asc
Description: Message signed with OpenPGP


Re: [PATCH v4 13/15] KVM: s390: configure the guest's AP devices

2018-04-18 Thread Pierre Morel

On 15/04/2018 23:22, Tony Krowiak wrote:

Registers a group notifier during the open of the mediated
matrix device to get information on KVM presence through the
VFIO_GROUP_NOTIFY_SET_KVM event. When notified, the pointer
to the kvm structure is saved inside the mediated matrix
device. Once the VFIO AP device driver has access to KVM,
access to the APs can be configured for the guest.

Access to APs is configured when the file descriptor for the
mediated matrix device is opened by userspace. The items to be
configured are:

1. The ECA.28 bit in the SIE state description determines whether
AP instructions are interpreted by the hardware or intercepted.
The VFIO AP device driver relies interpretive execution of
AP instructions so the ECA.28 bit will be set

2. Guest access to AP adapters, usage domains and control domains
is controlled by three bit masks referenced from the
Crypto Control Block (CRYCB) referenced from the guest's SIE state
description:

* The AP Mask (APM) controls access to the AP adapters. Each bit
  in the APM represents an adapter number - from most significant
  to least significant bit - from 0 to 255. The bits in the APM
  are set according to the adapter numbers assigned to the mediated
  matrix device via its 'assign_adapter' sysfs attribute file.

* The AP Queue (AQM) controls access to the AP queues. Each bit
  in the AQM represents an AP queue index - from most significant
  to least significant bit - from 0 to 255. A queue index references
  a specific domain and is synonymous with the domian number. The
  bits in the AQM are set according to the domain numbers assigned
  to the mediated matrix device via its 'assign_domain' sysfs
  attribute file.

* The AP Domain Mask (ADM) controls access to the AP control domains.
  Each bit in the ADM represents a control domain - from most
  significant to least significant bit - from 0-255. The
  bits in the ADM are set according to the domain numbers assigned
  to the mediated matrix device via its 'assign_control_domain'
  sysfs attribute file.

Signed-off-by: Tony Krowiak 
---
  drivers/s390/crypto/vfio_ap_ops.c |   50 +
  drivers/s390/crypto/vfio_ap_private.h |2 +
  2 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/drivers/s390/crypto/vfio_ap_ops.c 
b/drivers/s390/crypto/vfio_ap_ops.c
index bc2b05e..e3ff5ab 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -53,6 +53,54 @@ static int vfio_ap_mdev_remove(struct mdev_device *mdev)
return 0;
  }

+static int vfio_ap_mdev_group_notifier(struct notifier_block *nb,
+  unsigned long action, void *data)
+{
+   struct ap_matrix_mdev *matrix_mdev;
+
+   if (action == VFIO_GROUP_NOTIFY_SET_KVM) {
+   matrix_mdev = container_of(nb, struct ap_matrix_mdev,
+  group_notifier);
+   matrix_mdev->kvm = data;
+   }
+
+   return NOTIFY_OK;
+}
+
+static int vfio_ap_mdev_open(struct mdev_device *mdev)
+{
+   struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev);
+   unsigned long events;
+   int ret;
+
+   matrix_mdev->group_notifier.notifier_call = vfio_ap_mdev_group_notifier;
+   events = VFIO_GROUP_NOTIFY_SET_KVM;
+
+   ret = vfio_register_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY,
+, _mdev->group_notifier);
+   if (ret)
+   return ret;
+
+   ret = kvm_ap_interpret_instructions(matrix_mdev->kvm, true);
+   if (ret)
+   return ret;
+
+   ret = kvm_ap_configure_matrix(matrix_mdev->kvm,
+ matrix_mdev->matrix);


If all went OK, you may want to increase the module reference count
to avoid removing the module while in use by QEMU.


+
+   return ret;
+}
+
+static void vfio_ap_mdev_release(struct mdev_device *mdev)
+{
+   struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev);
+
+   kvm_ap_deconfigure_matrix(matrix_mdev->kvm);
+   kvm_ap_interpret_instructions(matrix_mdev->kvm, false);
+   vfio_unregister_notifier(mdev_dev(mdev), VFIO_GROUP_NOTIFY,
+_mdev->group_notifier);


... and also decrease the reference count.


+}
+
  static ssize_t name_show(struct kobject *kobj, struct device *dev, char *buf)
  {
return sprintf(buf, "%s\n", VFIO_AP_MDEV_NAME_HWVIRT);
@@ -754,6 +802,8 @@ static ssize_t matrix_show(struct device *dev, struct 
device_attribute *attr,
.mdev_attr_groups   = vfio_ap_mdev_attr_groups,
.create = vfio_ap_mdev_create,
.remove = vfio_ap_mdev_remove,
+   .open   = vfio_ap_mdev_open,
+   .release= vfio_ap_mdev_release,
  };

  int 

Re: [PATCH] rt2x00: fix spelling mistake in various macros, UKNOWN -> UNKNOWN

2018-04-18 Thread Stanislaw Gruszka
On Wed, Apr 18, 2018 at 12:47:50PM +0100, Colin King wrote:
> From: Colin Ian King 
> 
> Rename several macros that contain mispellings of UNKNOWN
> 
> Signed-off-by: Colin Ian King 
Acked-by: Stanislaw Gruszka 


Re: [PATCH v3 06/11] iio: inkern: add module put/get on iio dev module when requesting channels

2018-04-18 Thread Lars-Peter Clausen
On 04/18/2018 11:35 AM, Jonathan Cameron wrote:
> On Tue, 17 Apr 2018 12:19:06 -0700
> Dmitry Torokhov  wrote:
> 
>> Hi Eugen,
>>
>> On Tue, Apr 17, 2018 at 10:39:24AM +0300, Eugen Hristev wrote:
>>>
>>>
>>> On 17.04.2018 02:58, Dmitry Torokhov wrote:  
 On Sun, Apr 15, 2018 at 08:33:21PM +0100, Jonathan Cameron wrote:  
> On Tue, 10 Apr 2018 11:57:52 +0300
> Eugen Hristev  wrote:
>   
>> When requesting channels for a particular consumer device,
>> besides requesting the device (incrementing the reference counter), also
>> do it for the driver module of the iio dev. This will avoid the situation
>> where the producer IIO device can be removed and the consumer is still
>> present in the kernel.
>>
>> Signed-off-by: Eugen Hristev 
>> ---
>>   drivers/iio/inkern.c | 8 +++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
>> index ec98790..68d9b87 100644
>> --- a/drivers/iio/inkern.c
>> +++ b/drivers/iio/inkern.c
>> @@ -11,6 +11,7 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>>   #include 
>>   #include "iio_core.h"
>> @@ -152,6 +153,7 @@ static int __of_iio_channel_get(struct iio_channel 
>> *channel,
>>  if (index < 0)
>>  goto err_put;
>>  channel->channel = _dev->channels[index];
>> +try_module_get(channel->indio_dev->driver_module);  
>
> And if it fails? (the module we are trying to get is going away...)
>
> We should try and handle it I think. Be it by just erroring out of here.  

 Even more, this has nothing to do with modules. A device can go away for
 any number of reasons (we unbind it manually via sysfs, we pull the USB
 plug from the host in case it is USB-connected device, we unload I2C
 adapter for the bus device resides on, we kick underlying PCI device)
 and we should be able to handle this in some fashion. Handling errors
 from reads and ignoring garbage is one of methods.

 FWIW this is a NACK from me.

 Thanks.  
>>> Hello,
>>>
>>> This patch is actually a "best effort attempt" for the consumer driver
>>> (touch driver) to get a reference to the producer of the data (the IIO
>>> device), when it requests the specific channels.
>>> As of this moment, there is no attempt whatsoever for the consumer to have a
>>> reference on the producer driver. Thus, the producer can be removed at any
>>> time, and the consumer will fail ungraciously.  
>>
>> This is the root of the issue. The consumer should be prepared to handle
>> errors from producer.
>>
>>> I can change the perspective from "best effort" to "mandatory" to get a
>>> reference to the producer, or you wish to stop trying to get any reference
>>> at all (remove this patch completely) ?  
>>
>> You should take reference to the device itself (if it is not taken
>> already), so it does not disappear completely and you can continue using
>> IIO API to access it, and IIO API should be prepared to deal with "dead"
>> devices, but as I pointed in my other email, trying to pin the driver
>> is quite pointless as there are myriad other ways of device stopping
>> working besides module unloading.
>>
>> In any case, I think this problem is outside of the scope of this
>> patchset that adds a generic resistive touchscreen, so if you want to
>> continue working on this I'd recommend moving it into a separate series.
>>
>> Thanks.
>>
> Agreed, this one has come up a number of times before.  Quite a lot of
> work got done by (IIRC) Lars Peter Clausen to stabilize things in various
> unexpected 'going away' events.  Of course there may be paths we have
> added since that (it was years ago) that can cause trouble...
> 
> Anyhow, separate issue as Dmitry says, let's deal with it separately.

We do properly get a ref to the device. Not getting a ref to the module is
on purpose. Cause as Dmitry said it does nothing the device can disappear at
any point either way. I second the NACK.



Re: [PATCH v4 01/10] x86/microcode/AMD: Subtract SECTION_HDR_SIZE from file leftover length

2018-04-18 Thread Maciej S. Szmigiero
On 18.03.2018 17:12, Borislav Petkov wrote:
> On Fri, Mar 16, 2018 at 12:07:42AM +0100, Maciej S. Szmigiero wrote:
>> verify_patch_size() function verifies whether the microcode container file
>> remaining size is large enough to contain a patch of the indicated size.
>>
>> However, the section header length is not included in this indicated size
>> but it is present in the leftover file length so it should be subtracted
>> from the leftover file length before passing this value to
>> verify_patch_size().
>>
>> Signed-off-by: Maciej S. Szmigiero 
>> ---
>>  arch/x86/kernel/cpu/microcode/amd.c | 11 ++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> I split the comment and applied this:
> 
> ---
> From: "Maciej S. Szmigiero" 
> Date: Fri, 16 Mar 2018 00:07:42 +0100
> Subject: [PATCH] x86/microcode/AMD: Subtract SECTION_HDR_SIZE from file
>  leftover length

Can't really find this commit in any tree I have looked at (bp.git and
tip.git at kernel.org).
Was it pushed somewhere else?

Maciej


[PATCH 0/2] Fix port memory offsets for IDIO series drivers

2018-04-18 Thread William Breathitt Gray
The GPIO PCI-IDIO-16 and PCIE-IDIO-24 drivers utilize the ioread8 and
iowrite8 functions to interact with their devices' respective I/O
registers. To simplify the get_multiple/set_multiple callbacks, a local
array 'ports' is used to hold the memory address offsets of the
respective device I/O registers.

Currently the get_multiple callback in the GPIO PCI-IDIO-16 driver, and
the get_multiple/set_multiple callbacks in the GPIO PCIE-IDIO-24 driver,
incorrectly pass the memory address of the local 'ports' array elements
to the respective ioread8/iowrite8 functions when they should instead
pass the necessary device I/O register memory offset. This patch fixes
this error by supplying the correct intended memory addresses to these
functions.

William Breathitt Gray (2):
  gpio: pci-idio-16: Fix port memory offset for get_multiple callback
  gpio: pcie-idio-24: Fix port memory offset for
get_multiple/set_multiple callbacks

 drivers/gpio/gpio-pci-idio-16.c  |  8 
 drivers/gpio/gpio-pcie-idio-24.c | 20 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.16.2



[PATCH 1/2] gpio: pci-idio-16: Fix port memory offset for get_multiple callback

2018-04-18 Thread William Breathitt Gray
The ioread8 function expects a memory offset argument. This patch fixes
the ports array to provide the memory addresses of the respective device
I/O registers.

Fixes: 810ebfc5efca ("gpio: pci-idio-16: Implement get_multiple callback")
Signed-off-by: William Breathitt Gray 
---
 drivers/gpio/gpio-pci-idio-16.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
index 1948724d8c36..25d16b2af1c3 100644
--- a/drivers/gpio/gpio-pci-idio-16.c
+++ b/drivers/gpio/gpio-pci-idio-16.c
@@ -116,9 +116,9 @@ static int idio_16_gpio_get_multiple(struct gpio_chip *chip,
unsigned long word_mask;
const unsigned long port_mask = GENMASK(gpio_reg_size - 1, 0);
unsigned long port_state;
-   u8 __iomem ports[] = {
-   idio16gpio->reg->out0_7, idio16gpio->reg->out8_15,
-   idio16gpio->reg->in0_7, idio16gpio->reg->in8_15,
+   void __iomem *ports[] = {
+   >reg->out0_7, >reg->out8_15,
+   >reg->in0_7, >reg->in8_15,
};
 
/* clear bits array to a clean slate */
@@ -143,7 +143,7 @@ static int idio_16_gpio_get_multiple(struct gpio_chip *chip,
}
 
/* read bits from current gpio port */
-   port_state = ioread8(ports + i);
+   port_state = ioread8(ports[i]);
 
/* store acquired bits at respective bits array offset */
bits[word_index] |= port_state << word_offset;
-- 
2.16.2



Re: [PATCH v2] tracing/x86: Update syscall trace events to handle new x86 syscall func names

2018-04-18 Thread Arnaldo Carvalho de Melo
Em Tue, Apr 17, 2018 at 05:41:28PM -0400, Steven Rostedt escreveu:
> On Tue, 17 Apr 2018 15:13:04 -0300 Arnaldo Carvalho de Melo  
> wrote:
> > Yeah, failing:

> > [root@jouet ~]# strace -e openat -e file perf test -F -v "mmap interface" 
> > |& grep syscalls
> > openat(AT_FDCWD, 
> > "/sys/kernel/debug/tracing/events/syscalls/sys_enter_getsid/format", 
> > O_RDONLY) = 3
> > openat(AT_FDCWD, 
> > "/sys/kernel/debug/tracing/events/syscalls/sys_enter_getppid/format", 
> > O_RDONLY) = -1 ENOENT (No such file or directory)
 
> It doesn't have to do with the number of parameters, not everything
> has "__x64" on it.
 
> Try this patch:

Trying...
 
> diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
> index 09ad88572746..15582648887f 100644
> --- a/arch/x86/include/asm/ftrace.h
> +++ b/arch/x86/include/asm/ftrace.h
> @@ -31,6 +31,19 @@ static inline unsigned long ftrace_call_adjust(unsigned 
> long addr)
>   return addr;
>  }
>  
> +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
> +static inline bool arch_syscall_match_sym_name(const char *sym, const char 
> *name)
> +{
> + /*
> +  * Compare the symbol name with the system call name. Skip the
> +  * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
> +  */
> + return !strcmp(sym + 3, name + 3) ||
> + (!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
> + (!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
> +
> +}
> +
>  #ifdef CONFIG_DYNAMIC_FTRACE
>  
>  struct dyn_arch_ftrace {


Re: [PATCH v3 1/3] nvmem: Update the OF binding to use a subnode for the cells list

2018-04-18 Thread Srinivas Kandagatla



On 18/04/18 13:32, Alban wrote:

I was also suggesting you to use nvmem-cell subnode, but make it a
proper nvmem provider device, rather than reusing its parent device.

You would end up some thing like this in dt.

flash@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "s25sl064a";
reg = <0>;

nvmem-cells {
compatible = "mtd-nvmem";
#address-cells = <1>;
#size-cells = <1>;

calibration: calib@404 {
reg = <0x404 0x10>;
};
};
};

But the root cause is in the nvmem binding, this conflict could exists
No, the root cause is because of passing wrong device instance to nvmem 
core. And trying to workaround is the actual issue.



with any device type, not just MTD. I don't understand why we would want
such workarounds instead of just fixing the problem once and for all.
AFAIU, This is not a workaround, this is how nvmem provider bindings are 
and all providers should try to follow it.


I still do not understand what is the issue in making nvmem-cells node a 
proper nvmem provider device?


--srini




[PATCH 2/2] gpio: pcie-idio-24: Fix port memory offset for get_multiple/set_multiple callbacks

2018-04-18 Thread William Breathitt Gray
The ioread8/iowrite8 functions expect a memory offset argument. This
patch fixes the ports array to provide the memory addresses of the
respective device I/O registers.

Fixes: ca37081595a2 ("gpio: pcie-idio-24: Implement get_multiple/set_multiple 
callbacks")
Signed-off-by: William Breathitt Gray 
---
 drivers/gpio/gpio-pcie-idio-24.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
index 835607ecf658..3e77c2a9a9fd 100644
--- a/drivers/gpio/gpio-pcie-idio-24.c
+++ b/drivers/gpio/gpio-pcie-idio-24.c
@@ -206,10 +206,10 @@ static int idio_24_gpio_get_multiple(struct gpio_chip 
*chip,
unsigned long word_mask;
const unsigned long port_mask = GENMASK(gpio_reg_size - 1, 0);
unsigned long port_state;
-   u8 __iomem ports[] = {
-   idio24gpio->reg->out0_7, idio24gpio->reg->out8_15,
-   idio24gpio->reg->out16_23, idio24gpio->reg->in0_7,
-   idio24gpio->reg->in8_15, idio24gpio->reg->in16_23,
+   void __iomem *ports[] = {
+   >reg->out0_7, >reg->out8_15,
+   >reg->out16_23, >reg->in0_7,
+   >reg->in8_15, >reg->in16_23,
};
const unsigned long out_mode_mask = BIT(1);
 
@@ -236,7 +236,7 @@ static int idio_24_gpio_get_multiple(struct gpio_chip *chip,
 
/* read bits from current gpio port (port 6 is TTL GPIO) */
if (i < 6)
-   port_state = ioread8(ports + i);
+   port_state = ioread8(ports[i]);
else if (ioread8(>reg->ctl) & out_mode_mask)
port_state = ioread8(>reg->ttl_out0_7);
else
@@ -301,9 +301,9 @@ static void idio_24_gpio_set_multiple(struct gpio_chip 
*chip,
const unsigned long port_mask = GENMASK(gpio_reg_size, 0);
unsigned long flags;
unsigned int out_state;
-   u8 __iomem ports[] = {
-   idio24gpio->reg->out0_7, idio24gpio->reg->out8_15,
-   idio24gpio->reg->out16_23
+   void __iomem *ports[] = {
+   >reg->out0_7, >reg->out8_15,
+   >reg->out16_23
};
const unsigned long out_mode_mask = BIT(1);
const unsigned int ttl_offset = 48;
@@ -327,9 +327,9 @@ static void idio_24_gpio_set_multiple(struct gpio_chip 
*chip,
raw_spin_lock_irqsave(>lock, flags);
 
/* process output lines */
-   out_state = ioread8(ports + i) & ~gpio_mask;
+   out_state = ioread8(ports[i]) & ~gpio_mask;
out_state |= (*bits >> bits_offset) & gpio_mask;
-   iowrite8(out_state, ports + i);
+   iowrite8(out_state, ports[i]);
 
raw_spin_unlock_irqrestore(>lock, flags);
}
-- 
2.16.2



Re: [PATCH v3 3/3] clk: qcom: Add Global Clock controller (GCC) driver for SDM845

2018-04-18 Thread Amit Nischal

On 2018-04-17 09:21, Stephen Boyd wrote:

Quoting Amit Nischal (2018-04-03 06:22:41)

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index fbf4532..c961e89 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -218,6 +218,15 @@ config MSM_MMCC_8996
  Say Y if you want to support multimedia devices such as 
display,

  graphics, video encode/decode, camera, etc.

+config SDM_GCC_845
+   tristate "SDM845 Global Clock Controller"
+   depends on COMMON_CLK_QCOM
+   help
+ Support for the global clock controller on Qualcomm 
Technologies, Inc

+ sdm845 devices.
+ Say Y if you want to use peripheral devices such as UART, 
SPI,

+ i2c, USB, UFS, SD/eMMC, PCIe, etc.


Is there eMMC?


Thanks for the review comments. There is no eMMC for SDM845. I will fix 
the

above in next patch series.




+
 config SPMI_PMIC_CLKDIV
tristate "SPMI PMIC clkdiv Support"
depends on (COMMON_CLK_QCOM && SPMI) || COMPILE_TEST
diff --git a/drivers/clk/qcom/gcc-sdm845.c 
b/drivers/clk/qcom/gcc-sdm845.c

new file mode 100644
index 000..b1b7a1e
--- /dev/null
+++ b/drivers/clk/qcom/gcc-sdm845.c
@@ -0,0 +1,3546 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 


Is this include used?


No, it is not getting used. We will remove this in next patch series.




+#include 
+#include 
+#include 
+

[...]

+
+static struct clk_rcg2 gcc_usb30_prim_mock_utmi_clk_src = {
+   .cmd_rcgr = 0xf030,
+   .mnd_width = 0,
+   .hid_width = 5,
+   .parent_map = gcc_parent_map_0,
+   .freq_tbl = ftbl_gcc_usb30_prim_mock_utmi_clk_src,
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "gcc_usb30_prim_mock_utmi_clk_src",
+   .parent_names = gcc_parent_names_0,
+   .num_parents = 4,
+   .ops = _rcg2_shared_ops,


Still shared? Why?


We would require the shared_ops for clocks which are configured by
bootloader.




+
+static struct clk_branch gcc_video_ahb_clk = {
+   .halt_reg = 0xb004,
+   .halt_check = BRANCH_HALT,
+   .hwcg_reg = 0xb004,
+   .hwcg_bit = 1,
+   .clkr = {
+   .enable_reg = 0xb004,
+   .enable_mask = BIT(0),
+   .hw.init = &(struct clk_init_data){
+   .name = "gcc_video_ahb_clk",
+   .flags = CLK_IS_CRITICAL,
+   .ops = _branch2_ops,
+   },
+   },
+};
+
+


Weird double space here.


We will fix this in next patch series.




+static struct clk_branch gcc_video_xo_clk = {
+   .halt_reg = 0xb028,
+   .halt_check = BRANCH_HALT,
+   .clkr = {
+   .enable_reg = 0xb028,
+   .enable_mask = BIT(0),
+   .hw.init = &(struct clk_init_data){
+   .name = "gcc_video_xo_clk",
+   .flags = CLK_IS_CRITICAL,


For these "critical" clks that don't have parents can you just throw 
the

enable part in the gcc driver probe and remove these clks from being
exposed? They don't seem to provide any value to expose them as clks
when they don't hook into the final clk tree.



For all of the "critical" clocks which don't have parents, we have
removed the CRITICAL flag and mandate the clients to put their vote
to enable/disable them. Other than this, some of the "critical" clock
instances we have completely removed and enabled them in the probe.
This will be fixed in the next patch series.


+   .ops = _branch2_ops,
+   },
+   },
+};
+
+static struct clk_branch gcc_vs_ctrl_ahb_clk = {
+   .halt_reg = 0x7a014,
+   .halt_check = BRANCH_HALT,
+   .hwcg_reg = 0x7a014,
+   .hwcg_bit = 1,
+   .clkr = {
+   .enable_reg = 0x7a014,
+   .enable_mask = BIT(0),
+   .hw.init = &(struct clk_init_data){
+   .name = "gcc_vs_ctrl_ahb_clk",
+   .ops = _branch2_ops,
+   },
+   },
+};
+
+static struct clk_branch gcc_vs_ctrl_clk = {
+   .halt_reg = 0x7a010,
+   .halt_check = BRANCH_HALT,
+   .clkr = {
+   .enable_reg = 0x7a010,
+   .enable_mask = BIT(0),
+   .hw.init = &(struct clk_init_data){
+   .name = "gcc_vs_ctrl_clk",
+   .parent_names = (const char *[]){
+   "gcc_vs_ctrl_clk_src",
+   },
+   .num_parents = 1,
+   .flags = CLK_SET_RATE_PARENT,
+   .ops = _branch2_ops,
+   },
+   },
+};
+
+
+static int gcc_sdm845_probe(struct platform_device *pdev)
+{
+   struct device *dev = >dev;
+   struct regmap *regmap;
+   int i, ret;
+
+   regmap = qcom_cc_map(pdev, 

[PATCH resend 3/4] virt: vbox: Use __get_free_pages instead of kmalloc for DMA32 memory

2018-04-18 Thread Hans de Goede
It is not possible to get DMA32 zone memory through kmalloc, causing
the vboxguest driver to malfunction due to getting memory above
4G which the PCI device cannot handle.

This commit changes the kmalloc calls where the 4G limit matters to
using __get_free_pages() fixing vboxguest not working on x86_64 guests
with more then 4G RAM.

Cc: sta...@vger.kernel.org
Reported-by: Eloy Coto Pereiro 
Signed-off-by: Hans de Goede 
---
 drivers/virt/vboxguest/vboxguest_linux.c | 19 ---
 drivers/virt/vboxguest/vboxguest_utils.c |  5 +++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/virt/vboxguest/vboxguest_linux.c 
b/drivers/virt/vboxguest/vboxguest_linux.c
index 82e280d38cc2..398d22693234 100644
--- a/drivers/virt/vboxguest/vboxguest_linux.c
+++ b/drivers/virt/vboxguest/vboxguest_linux.c
@@ -87,6 +87,7 @@ static long vbg_misc_device_ioctl(struct file *filp, unsigned 
int req,
struct vbg_session *session = filp->private_data;
size_t returned_size, size;
struct vbg_ioctl_hdr hdr;
+   bool is_vmmdev_req;
int ret = 0;
void *buf;
 
@@ -106,8 +107,17 @@ static long vbg_misc_device_ioctl(struct file *filp, 
unsigned int req,
if (size > SZ_16M)
return -E2BIG;
 
-   /* __GFP_DMA32 because IOCTL_VMMDEV_REQUEST passes this to the host */
-   buf = kmalloc(size, GFP_KERNEL | __GFP_DMA32);
+   /*
+* IOCTL_VMMDEV_REQUEST needs the buffer to be below 4G to avoid
+* the need for a bounce-buffer and another copy later on.
+*/
+   is_vmmdev_req = (req & ~IOCSIZE_MASK) == VBG_IOCTL_VMMDEV_REQUEST(0) ||
+req == VBG_IOCTL_VMMDEV_REQUEST_BIG;
+
+   if (is_vmmdev_req)
+   buf = vbg_req_alloc(size, VBG_IOCTL_HDR_TYPE_DEFAULT);
+   else
+   buf = kmalloc(size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
 
@@ -132,7 +142,10 @@ static long vbg_misc_device_ioctl(struct file *filp, 
unsigned int req,
ret = -EFAULT;
 
 out:
-   kfree(buf);
+   if (is_vmmdev_req)
+   vbg_req_free(buf, size);
+   else
+   kfree(buf);
 
return ret;
 }
diff --git a/drivers/virt/vboxguest/vboxguest_utils.c 
b/drivers/virt/vboxguest/vboxguest_utils.c
index bad915463359..bf4474214b4d 100644
--- a/drivers/virt/vboxguest/vboxguest_utils.c
+++ b/drivers/virt/vboxguest/vboxguest_utils.c
@@ -65,8 +65,9 @@ VBG_LOG(vbg_debug, pr_debug);
 void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type)
 {
struct vmmdev_request_header *req;
+   int order = get_order(PAGE_ALIGN(len));
 
-   req = kmalloc(len, GFP_KERNEL | __GFP_DMA32);
+   req = (void *)__get_free_pages(GFP_KERNEL | GFP_DMA32, order);
if (!req)
return NULL;
 
@@ -87,7 +88,7 @@ void vbg_req_free(void *req, size_t len)
if (!req)
return;
 
-   kfree(req);
+   free_pages((unsigned long)req, get_order(PAGE_ALIGN(len)));
 }
 
 /* Note this function returns a VBox status code, not a negative errno!! */
-- 
2.17.0



[PATCH resend 2/4] virt: vbox: Add vbg_req_free() helper function

2018-04-18 Thread Hans de Goede
This is a preparation patch for fixing issues on x86_64 virtual-machines
with more then 4G of RAM, atm we pass __GFP_DMA32 to kmalloc, but kmalloc
does not honor that, so we need to switch to get_pages, which means we
will not be able to use kfree to free memory allocated with vbg_alloc_req.

While at it also remove a comment on a vbg_alloc_req call which talks
about Windows (inherited from the vbox upstream cross-platform code).

Cc: sta...@vger.kernel.org
Signed-off-by: Hans de Goede 
---
Changes in v2:
-Put the vbg_req_free() prototype decl. in the private vboxguest_core.h
 instead of in linux/vbox_utils.h as it is private
---
 drivers/virt/vboxguest/vboxguest_core.c  | 66 +---
 drivers/virt/vboxguest/vboxguest_core.h  |  1 +
 drivers/virt/vboxguest/vboxguest_utils.c | 14 +++--
 3 files changed, 47 insertions(+), 34 deletions(-)

diff --git a/drivers/virt/vboxguest/vboxguest_core.c 
b/drivers/virt/vboxguest/vboxguest_core.c
index 190dbf8cfcb5..7411a535fda2 100644
--- a/drivers/virt/vboxguest/vboxguest_core.c
+++ b/drivers/virt/vboxguest/vboxguest_core.c
@@ -114,7 +114,7 @@ static void vbg_guest_mappings_init(struct vbg_dev *gdev)
}
 
 out:
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
kfree(pages);
 }
 
@@ -144,7 +144,7 @@ static void vbg_guest_mappings_exit(struct vbg_dev *gdev)
 
rc = vbg_req_perform(gdev, req);
 
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
 
if (rc < 0) {
vbg_err("%s error: %d\n", __func__, rc);
@@ -214,8 +214,8 @@ static int vbg_report_guest_info(struct vbg_dev *gdev)
ret = vbg_status_code_to_errno(rc);
 
 out_free:
-   kfree(req2);
-   kfree(req1);
+   vbg_req_free(req2, sizeof(*req2));
+   vbg_req_free(req1, sizeof(*req1));
return ret;
 }
 
@@ -245,7 +245,7 @@ static int vbg_report_driver_status(struct vbg_dev *gdev, 
bool active)
if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
rc = VINF_SUCCESS;
 
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
 
return vbg_status_code_to_errno(rc);
 }
@@ -431,7 +431,7 @@ static int vbg_heartbeat_host_config(struct vbg_dev *gdev, 
bool enabled)
rc = vbg_req_perform(gdev, req);
do_div(req->interval_ns, 100); /* ns -> ms */
gdev->heartbeat_interval_ms = req->interval_ns;
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
 
return vbg_status_code_to_errno(rc);
 }
@@ -454,12 +454,6 @@ static int vbg_heartbeat_init(struct vbg_dev *gdev)
if (ret < 0)
return ret;
 
-   /*
-* Preallocate the request to use it from the timer callback because:
-*1) on Windows vbg_req_alloc must be called at IRQL <= APC_LEVEL
-*   and the timer callback runs at DISPATCH_LEVEL;
-*2) avoid repeated allocations.
-*/
gdev->guest_heartbeat_req = vbg_req_alloc(
sizeof(*gdev->guest_heartbeat_req),
VMMDEVREQ_GUEST_HEARTBEAT);
@@ -481,8 +475,8 @@ static void vbg_heartbeat_exit(struct vbg_dev *gdev)
 {
del_timer_sync(>heartbeat_timer);
vbg_heartbeat_host_config(gdev, false);
-   kfree(gdev->guest_heartbeat_req);
-
+   vbg_req_free(gdev->guest_heartbeat_req,
+sizeof(*gdev->guest_heartbeat_req));
 }
 
 /**
@@ -543,7 +537,7 @@ static int vbg_reset_host_event_filter(struct vbg_dev *gdev,
if (rc < 0)
vbg_err("%s error, rc: %d\n", __func__, rc);
 
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
return vbg_status_code_to_errno(rc);
 }
 
@@ -617,7 +611,7 @@ static int vbg_set_session_event_filter(struct vbg_dev 
*gdev,
 
 out:
mutex_unlock(>session_mutex);
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
 
return ret;
 }
@@ -642,7 +636,7 @@ static int vbg_reset_host_capabilities(struct vbg_dev *gdev)
if (rc < 0)
vbg_err("%s error, rc: %d\n", __func__, rc);
 
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
return vbg_status_code_to_errno(rc);
 }
 
@@ -712,7 +706,7 @@ static int vbg_set_session_capabilities(struct vbg_dev 
*gdev,
 
 out:
mutex_unlock(>session_mutex);
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
 
return ret;
 }
@@ -749,7 +743,7 @@ static int vbg_query_host_version(struct vbg_dev *gdev)
}
 
 out:
-   kfree(req);
+   vbg_req_free(req, sizeof(*req));
return ret;
 }
 
@@ -847,11 +841,16 @@ int vbg_core_init(struct vbg_dev *gdev, u32 fixed_events)
return 0;
 
 err_free_reqs:
-   kfree(gdev->mouse_status_req);
-   kfree(gdev->ack_events_req);
-   kfree(gdev->cancel_req);
-   kfree(gdev->mem_balloon.change_req);
-   kfree(gdev->mem_balloon.get_req);
+   vbg_req_free(gdev->mouse_status_req,
+

[PATCH resend 1/4] virt: vbox: Move declarations of vboxguest private functions to private header

2018-04-18 Thread Hans de Goede
Move the declarations of functions from vboxguest_utils.c which are only
meant for vboxguest internal use from include/linux/vbox_utils.h to
drivers/virt/vboxguest/vboxguest_core.h.

Cc: sta...@vger.kernel.org
Signed-off-by: Hans de Goede 
---
 drivers/virt/vboxguest/vboxguest_core.h |  8 
 include/linux/vbox_utils.h  | 23 ---
 2 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/virt/vboxguest/vboxguest_core.h 
b/drivers/virt/vboxguest/vboxguest_core.h
index 6c784bf4fa6d..39ed85cf9244 100644
--- a/drivers/virt/vboxguest/vboxguest_core.h
+++ b/drivers/virt/vboxguest/vboxguest_core.h
@@ -171,4 +171,12 @@ irqreturn_t vbg_core_isr(int irq, void *dev_id);
 
 void vbg_linux_mouse_event(struct vbg_dev *gdev);
 
+/* Private (non exported) functions form vboxguest_utils.c */
+void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type);
+int vbg_req_perform(struct vbg_dev *gdev, void *req);
+int vbg_hgcm_call32(
+   struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms,
+   struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count,
+   int *vbox_status);
+
 #endif
diff --git a/include/linux/vbox_utils.h b/include/linux/vbox_utils.h
index c71def6b310f..a240ed2a0372 100644
--- a/include/linux/vbox_utils.h
+++ b/include/linux/vbox_utils.h
@@ -24,24 +24,6 @@ __printf(1, 2) void vbg_debug(const char *fmt, ...);
 #define vbg_debug pr_debug
 #endif
 
-/**
- * Allocate memory for generic request and initialize the request header.
- *
- * Return: the allocated memory
- * @len:   Size of memory block required for the request.
- * @req_type:  The generic request type.
- */
-void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type);
-
-/**
- * Perform a generic request.
- *
- * Return: VBox status code
- * @gdev:  The Guest extension device.
- * @req:   Pointer to the request structure.
- */
-int vbg_req_perform(struct vbg_dev *gdev, void *req);
-
 int vbg_hgcm_connect(struct vbg_dev *gdev,
 struct vmmdev_hgcm_service_location *loc,
 u32 *client_id, int *vbox_status);
@@ -52,11 +34,6 @@ int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 
function,
  u32 timeout_ms, struct vmmdev_hgcm_function_parameter *parms,
  u32 parm_count, int *vbox_status);
 
-int vbg_hgcm_call32(
-   struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms,
-   struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count,
-   int *vbox_status);
-
 /**
  * Convert a VirtualBox status code to a standard Linux kernel return value.
  * Return: 0 or negative errno value.
-- 
2.17.0



[PATCH resend 0/4] virt: vboxguest: Fix vboxguest module not working on VMs with more then 4G of RAM

2018-04-18 Thread Hans de Goede
Hi Greg,

I know you are not entirely happy with the direct get_pages usage in this
patch-set, but as discussed that is currently the only way to get DMA32
memory.

Adding a better API for getting DMA32 mem really falls outside of the scope
of these patches and in the mean time the vboxguest driver is broken on 
VMs with more then 4G RAM, can we please get this bug-fix series merged to
fix this bug?

Regards,

Hans



[PATCH v2 1/1] dts: qcom: db820c: Add gpio-line-names property

2018-04-18 Thread Manivannan Sadhasivam
Add gpio-line-names property for Dragonboard820c based on APQ8096 SoC.
There are 4 gpio-controllers present on this board, including the
APQ8096 SoC, PM8994 (GPIO and MPP) and PMI8994 (GPIO).

Lines names are derived from 96Boards CE Specification 1.0, Appendix
"Expansion Connector Signal Description". Line names for PMI8994 MPP
pins are not added due to the absence of the gpio-controller support.

Signed-off-by: Manivannan Sadhasivam 
---
 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 239 +++
 1 file changed, 239 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi 
b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
index 1c8f1b86472d..473530527e27 100644
--- a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
@@ -19,6 +19,33 @@
 #include 
 #include 
 
+/*
+ * GPIO name legend: proper name = the GPIO line is used as GPIO
+ * NC  = not connected (pin out but not routed from the chip to
+ *   anything the board)
+ * "[PER]" = pin is muxed for [peripheral] (not GPIO)
+ * LSEC= Low Speed External Connector
+ * P HSEC  = Primary High Speed External Connector
+ * S HSEC  = Secondary High Speed External Connector
+ * J14 = Camera Connector
+ * TP  = Test Points
+ *
+ * Line names are taken from the schematic "DragonBoard 820c",
+ * drawing no: LM25-P2751-1
+ *
+ * For the lines routed to the external connectors the
+ * lines are named after the 96Boards CE Specification 1.0,
+ * Appendix "Expansion Connector Signal Description".
+ *
+ * When the 96Board naming of a line and the schematic name of
+ * the same line are in conflict, the 96Board specification
+ * takes precedence, which means that the external UART on the
+ * LSEC is named UART0 while the schematic and SoC names this
+ * UART3. This is only for the informational lines i.e. "[FOO]",
+ * the GPIO named lines "GPIO-A" thru "GPIO-L" are the only
+ * ones actually used for GPIO.
+ */
+
 / {
aliases {
serial0 = _uart1;
@@ -90,6 +117,218 @@
status = "okay";
};
 
+   pinctrl@101 {
+   gpio-line-names =
+   "[SPI0_DOUT]", /* GPIO_0, BLSP1_SPI_MOSI, LSEC 
pin 14 */
+   "[SPI0_DIN]", /* GPIO_1, BLSP1_SPI_MISO, LSEC 
pin 10 */
+   "[SPI0_CS]", /* GPIO_2, BLSP1_SPI_CS_N, LSEC 
pin 12 */
+   "[SPI0_SCLK]", /* GPIO_3, BLSP1_SPI_CLK, LSEC 
pin 8 */
+   "[UART1_TxD]", /* GPIO_4, BLSP8_UART_TX, LSEC 
pin 11 */
+   "[UART1_RxD]", /* GPIO_5, BLSP8_UART_RX, LSEC 
pin 13 */
+   "[I2C1_SDA]", /* GPIO_6, BLSP8_I2C_SDA, LSEC 
pin 21 */
+   "[I2C1_SCL]", /* GPIO_7, BLSP8_I2C_SCL, LSEC 
pin 19 */
+   "GPIO-H", /* GPIO_8, LCD0_RESET_N, LSEC pin 30 
*/
+   "TP93", /* GPIO_9 */
+   "GPIO-G", /* GPIO_10, MDP_VSYNC_P, LSEC pin 29 
*/
+   "[MDP_VSYNC_S]", /* GPIO_11, S HSEC pin 55 */
+   "NC", /* GPIO_12 */
+   "[CSI0_MCLK]", /* GPIO_13, CAM_MCLK0, P HSEC 
pin 15 */
+   "[CAM_MCLK1]", /* GPIO_14, J14 pin 11 */
+   "[CSI1_MCLK]", /* GPIO_15, CAM_MCLK2, P HSEC 
pin 17 */
+   "TP99", /* GPIO_16 */
+   "[I2C2_SDA]", /* GPIO_17, CCI_I2C_SDA0, P HSEC 
pin 34 */
+   "[I2C2_SCL]", /* GPIO_18, CCI_I2C_SCL0, P HSEC 
pin 32 */
+   "[CCI_I2C_SDA1]", /* GPIO_19, S HSEC pin 38 */
+   "[CCI_I2C_SCL1]", /* GPIO_20, S HSEC pin 36 */
+   "FLASH_STROBE_EN", /* GPIO_21, S HSEC pin 5 */
+   "FLASH_STROBE_TRIG", /* GPIO_22, S HSEC pin 1 */
+   "GPIO-K", /* GPIO_23, CAM2_RST_N, LSEC pin 33 */
+   "GPIO-D", /* GPIO_24, LSEC pin 26 */
+   "GPIO-I", /* GPIO_25, CAM0_RST_N, LSEC pin 31 */
+   "GPIO-J", /* GPIO_26, CAM0_STANDBY_N, LSEC pin 
32 */
+   "BLSP6_I2C_SDA", /* GPIO_27 */
+   "BLSP6_I2C_SCL", /* GPIO_28 */
+   "GPIO-B", /* GPIO_29, TS0_RESET_N, LSEC pin 24 
*/
+   "GPIO30", /* GPIO_30, S HSEC pin 4 */
+   "HDMI_CEC", /* GPIO_31 */
+   "HDMI_DDC_CLOCK", /* GPIO_32 */
+   "HDMI_DDC_DATA", /* GPIO_33 */
+   "HDMI_HOT_PLUG_DETECT", /* 

[PATCH v2 0/1] Add gpio-line-names property for Dragonboard820c

2018-04-18 Thread Manivannan Sadhasivam
Add gpio-line-names property for 96Boards Dragonboard820c development
board based on APQ8096 SoC. The lines are named after the 96Boards
CE Specification 1.0, Appendix "Expansion Connector Signal Description".
There are 4 gpio-controllers present on this board, including the
APQ8096 SoC, PM8994 (GPIO, MPP) and PMI8994 (GPIO).

Considering the regular 96Boards Consumer Edition boards, this board belongs
to Entended edition form factor, hence includes additional Primary,
Secondary High Speed Connectors and one Camera Connector.

Line names for PMI8994 MPP pins are not added due to the absence of the
gpio-controller support.

Changes in v2:

* Added schematic names in comments for lines with 96Boards spec names

Manivannan Sadhasivam (1):
  dts: qcom: db820c: Add gpio-line-names property

 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 239 +++
 1 file changed, 239 insertions(+)

-- 
2.14.1



Re: [PATCHv3 03/11] arm64/kvm: hide ptrauth from guests

2018-04-18 Thread Mark Rutland
On Wed, Apr 18, 2018 at 03:19:26PM +0200, Andrew Jones wrote:
> On Tue, Apr 17, 2018 at 07:37:27PM +0100, Mark Rutland wrote:
> > @@ -1000,6 +1000,15 @@ static u64 read_id_reg(struct sys_reg_desc const *r, 
> > bool raz)
> > task_pid_nr(current));
> >  
> > val &= ~(0xfUL << ID_AA64PFR0_SVE_SHIFT);
> > +   } else if (id == SYS_ID_AA64ISAR1_EL1) {
> > +   const u64 ptrauth_mask = (0xfUL << ID_AA64ISAR1_APA_SHIFT) |
> > +(0xfUL << ID_AA64ISAR1_API_SHIFT) |
> > +(0xfUL << ID_AA64ISAR1_GPA_SHIFT) |
> > +(0xfUL << ID_AA64ISAR1_GPI_SHIFT);
> > +   if (val & ptrauth_mask)
> > +   pr_err_once("kvm [%i]: ptrauth unsupported for guests, 
> > suppressing\n",
> > +   task_pid_nr(current));
> 
> Marc just changed the equivalent SVE pr_err_once() to kvm_debug().
> So we probably want to do the same here.

Good point. Done.

> > +   val &= ~ptrauth_mask;
> > } else if (id == SYS_ID_AA64MMFR1_EL1) {
> > if (val & (0xfUL << ID_AA64MMFR1_LOR_SHIFT))
> > pr_err_once("kvm [%i]: LORegions unsupported for 
> > guests, suppressing\n",
> > -- 
> > 2.11.0
> >
> 
> Otherwise
>  
> Reviewed-by: Andrew Jones 

Cheers!

Mark.


Re: [PATCH] serial: imx: warn user when using unsupported configuration

2018-04-18 Thread Uwe Kleine-König
Hello Stefan,

On Wed, Apr 18, 2018 at 03:32:17PM +0200, Stefan Agner wrote:
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 91f3a1a5cb7f..1ba7e98ddc76 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1833,6 +1833,10 @@ static int imx_uart_rs485_config(struct uart_port 
> *port,
>   rs485conf->flags &= ~SER_RS485_ENABLED;
>  
>   if (rs485conf->flags & SER_RS485_ENABLED) {
> + /* Enable receiver if low-active RTS signal is requested */
> + if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND)
> + rs485conf->flags |= SER_RS485_RX_DURING_TX;
> +

this is wrong if RTS is driven by a GPIO.

>   /* disable transmitter */
>   ucr2 = imx_uart_readl(sport, UCR2);
>   if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND)
> @@ -2265,6 +2269,17 @@ static int imx_uart_probe(struct platform_device *pdev)
>   (!sport->have_rtscts && !sport->have_rtsgpio))
>   dev_err(>dev, "no RTS control, disabling rs485\n");
>  
> + /*
> +  * The RTS (CTS_B) signal cannot be set low during transmission
> +  * in case the receiver is off (limitation of the i.MX UART IP).
> +  */
> + if (sport->port.rs485.flags & SER_RS485_ENABLED && sport->have_rtscts &&
> + (!(sport->port.rs485.flags & SER_RS485_RTS_ON_SEND) &&
> +  !(sport->port.rs485.flags & SER_RS485_RX_DURING_TX)))
> + dev_err(>dev,
> + "low-active RTS not possible when receiver is off, "
> + "enabling receiver\n");

If you have the choice between breaking a user visible string and a code
line >80 chars, please pick the latter.

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |


[per_cpu_ptr_to_phys] PANIC: early exception 0x0d IP 10:ffffffffa892f15f error 0 cr2 0xffff88001fbff000

2018-04-18 Thread Fengguang Wu

Hello,

FYI here is a slightly different boot error in mainline kernel 4.17.0-rc1.
It also dates back to v4.16 .

It occurs in 4 out of 4 boots.

[0.00] Built 1 zonelists, mobility grouping on.  Total pages: 128873
[0.00] Kernel command line: root=/dev/ram0 hung_task_panic=1 debug 
apic=debug sysrq_always_enabled rcupdate.rcu_cpu_stall_timeout=100 
net.ifnames=0 printk.devkmsg=on panic=-1 softlockup_panic=1 nmi_watchdog=panic 
oops=panic load_ramdisk=2 prompt_ramdisk=0 drbd.minor_count=8 
systemd.log_level=err ignore_loglevel console=tty0 earlyprintk=ttyS0,115200 
console=ttyS0,115200 vga=normal rw 
link=/kbuild-tests/run-queue/kvm/x86_64-randconfig-a0-04172313/linux-devel:devel-hourly-2018041714:60cc43fc888428bb2f18f08997432d426a243338/.vmlinuz-60cc43fc888428bb2f18f08997432d426a243338-20180418000325-19:yocto-lkp-nhm-dp2-4
 branch=linux-devel/devel-hourly-2018041714 
BOOT_IMAGE=/pkg/linux/x86_64-randconfig-a0-04172313/gcc-7/60cc43fc888428bb2f18f08997432d426a243338/vmlinuz-4.17.0-rc1
 drbd.minor_count=8 rcuperf.shutdown=0
[0.00] sysrq: sysrq always enabled.
[0.00] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes)
[0.00] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes)
PANIC: early exception 0x0d IP 10:a892f15f error 0 cr2 
0x88001fbff000
[0.00] CPU: 0 PID: 0 Comm: swapper Tainted: GT 
4.17.0-rc1 #238
[0.00] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.10.2-1 04/01/2014
[0.00] RIP: 0010:per_cpu_ptr_to_phys+0x16a/0x298:
__section_mem_map_addr at 
include/linux/mmzone.h:1188
 (inlined by) 
per_cpu_ptr_to_phys at mm/percpu.c:1849
[0.00] RSP: :ab407e50 EFLAGS: 00010046 ORIG_RAX: 

[0.00] RAX: dc00 RBX: 88001f17c340 RCX: 000f
[0.00] RDX:  RSI: 0001 RDI: acfbf580
[0.00] RBP: ab40d000 R08: fbfff57c4eca R09: 
[0.00] R10: 880015421000 R11: fbfff57c4ec9 R12: 
[0.00] R13: 88001fb03ff8 R14: 88001fc051c0 R15: 
[0.00] FS:  () GS:ab4c5000() 
knlGS:
[0.00] CS:  0010 DS:  ES:  CR0: 80050033
[0.00] CR2: 88001fbff000 CR3: 1a06c000 CR4: 06b0
[0.00] Call Trace:
[0.00]  setup_cpu_entry_areas+0x7b/0x27b:
setup_cpu_entry_area at 
arch/x86/mm/cpu_entry_area.c:104
 (inlined by) 
setup_cpu_entry_areas at arch/x86/mm/cpu_entry_area.c:177
[0.00]  trap_init+0xb/0x13d:
trap_init at 
arch/x86/kernel/traps.c:949
[0.00]  start_kernel+0x2a5/0x91d:
mm_init at init/main.c:519
 (inlined by) start_kernel at 
init/main.c:589
[0.00]  ? thread_stack_cache_init+0x6/0x6
[0.00]  ? memcpy_orig+0x16/0x110:
memcpy_orig at 
arch/x86/lib/memcpy_64.S:77
[0.00]  ? x86_family+0x5/0x1d:
x86_family at 
arch/x86/lib/cpu.c:8
[0.00]  ? load_ucode_bsp+0x42/0x13e:
load_ucode_bsp at 
arch/x86/kernel/cpu/microcode/core.c:183
[0.00]  secondary_startup_64+0xa5/0xb0:
secondary_startup_64 at 
arch/x86/kernel/head_64.S:242
[0.00] Code: 78 06 00 49 8b 45 00 48 85 c0 74 a5 49 c1 ec 28 41 81 e4 
e0 0f 00 00 49 01 c4 4c 89 e2 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 
02 00 74 08 4c 89 e7 e8 63 78 06 00 49 8b 04 24 81 e5 ff
BUG: kernel hang in boot stage

Attached the full dmesg, kconfig and reproduce scripts.

Thanks,
Fengguang
early console in setup code
early console in extract_kernel
input_data: 0x04cf62b6
input_len: 0x01686ad3
output: 0x0100
output_len: 0x0448ca6c
kernel_total_size: 0x053b1000
trampoline_32bit: 0x0009d000
booted via startup_32()
Physical KASLR using RDTSC...
Virtual KASLR using RDTSC...

Decompressing Linux... Parsing ELF... Performing relocations... done.
Booting the kernel.
[0.00] Linux version 4.17.0-rc1 (kbuild@athens) (gcc version 7.3.0 
(Debian 7.3.0-1)) #238 Tue Apr 17 23:21:37 CST 2018
[0.00] Command line: root=/dev/ram0 hung_task_panic=1 debug apic=debug 
sysrq_always_enabled rcupdate.rcu_cpu_stall_timeout=100 net.ifnames=0 
printk.devkmsg=on panic=-1 softlockup_panic=1 nmi_watchdog=panic oops=panic 
load_ramdisk=2 prompt_ramdisk=0 drbd.minor_count=8 systemd.log_level=err 
ignore_loglevel console=tty0 

Re: [PATCH] ARM: dts: renesas: replace toshiba, mmc-wrprotect-disable with disable-wp

2018-04-18 Thread Simon Horman
On Tue, Apr 17, 2018 at 12:02:32AM +0900, Masahiro Yamada wrote:
> Follow up commit 788778b0d21a ("mmc: tmio: deprecate "toshiba,
> mmc-wrprotect-disable" DT property").
> 
> Signed-off-by: Masahiro Yamada 

Thanks, applied.


Re: [cfs_trace_lock_tcd] BUG: unable to handle kernel NULL pointer dereference at 00000050

2018-04-18 Thread Fengguang Wu

Hi James,

On Wed, Apr 18, 2018 at 02:59:15PM +0100, James Simmons wrote:



Hello,

FYI this happens in mainline kernel 4.17.0-rc1.
It looks like a new regression.

[7.587002]  lnet_selftest_init+0x2c4/0x5d9:
lnet_selftest_init at 
drivers/staging/lustre/lnet/selftest/module.c:134
[7.587002]  ? lnet_selftest_exit+0x8d/0x8d:
lnet_selftest_init at 
drivers/staging/lustre/lnet/selftest/module.c:90


Are you running lnet selftest ?


Perhaps yes -- it's randconfig boot test and the .config does include
CONFIG_LNET_SELFTEST:

   CONFIG_LNET=y
   CONFIG_LNET_MAX_PAYLOAD=1048576
==> CONFIG_LNET_SELFTEST=y
   CONFIG_LNET_XPRT_IB=y


Is this a UMP setup?


Yes, .config has:

   # CONFIG_SMP is not set


The reason I ask is that their is a SMP handling bug in lnet
selftest. If you look at the mailing list I pushed a SMP patch
series. Can you try that series and tell me if it works for you.


So it looks your fixup patch is not for this case? Anyway the
reproduce-* script attached in the previous email should be fairly
straightforward to try out for reproducing the bug.

Thanks,
Fengguang


Re: [RFC PATCH 00/79] Generic page write protection and a solution to page waitqueue

2018-04-18 Thread Jan Kara
Hello,

so I finally got to this :)

On Wed 04-04-18 15:17:50, jgli...@redhat.com wrote:
> From: Jérôme Glisse 
> 
> https://cgit.freedesktop.org/~glisse/linux/log/?h=generic-write-protection-rfc
> 
> This is an RFC for LSF/MM discussions. It impacts the file subsystem,
> the block subsystem and the mm subsystem. Hence it would benefit from
> a cross sub-system discussion.
> 
> Patchset is not fully bake so take it with a graint of salt. I use it
> to illustrate the fact that it is doable and now that i did it once i
> believe i have a better and cleaner plan in my head on how to do this.
> I intend to share and discuss it at LSF/MM (i still need to write it
> down). That plan lead to quite different individual steps than this
> patchset takes and his also easier to split up in more manageable
> pieces.
> 
> I also want to apologize for the size and number of patches (and i am
> not even sending them all).
> 
> --
> The Why ?
> 
> I have two objectives: duplicate memory read only accross nodes and or
> devices and work around PCIE atomic limitations. More on each of those
> objective below. I also want to put forward that it can solve the page
> wait list issue ie having each page with its own wait list and thus
> avoiding long wait list traversale latency recently reported [1].
> 
> It does allow KSM for file back pages (truely generic KSM even between
> both anonymous and file back page). I am not sure how useful this can
> be, this was not an objective i did pursue, this is just a for free
> feature (see below).

I know some people (Matthew Wilcox?) wanted to do something like KSM for
file pages - not all virtualization schemes use overlayfs and e.g. if you
use reflinks (essentially shared on-disk extents among files) for your
container setup, you could save significant amounts of memory with the
ability to share pages in page cache among files that are reflinked.

> [1] https://groups.google.com/forum/#!topic/linux.kernel/Iit1P5BNyX8
> 
> --
> Per page wait list, so long page_waitqueue() !
> 
> Not implemented in this RFC but below is the logic and pseudo code
> at bottom of this email.
> 
> When there is a contention on struct page lock bit, the caller which
> is trying to lock the page will add itself to a waitqueue. The issues
> here is that multiple pages share the same wait queue and on large
> system with a lot of ram this means we can quickly get to a long list
> of waiters for differents pages (or for the same page) on the same
> list [1].
> 
> The present patchset virtualy kills all places that need to access the
> page->mapping field and only a handfull are left, namely for testing
> page truncation and for vmscan. The former can be remove if we reuse
> the PG_waiters flag for a new PG_truncate flag set on truncation then
> we can virtualy kill all derefence of page->mapping (this patchset
> proves it is doable). NOTE THIS DOES NOT MEAN THAT MAPPING is FREE TO
> BE USE BY ANYONE TO STORE WHATEVER IN STRUCT PAGE. SORRY NO !

It is interesting that you can get rid of page->mapping uses in most
places. For page reclaim (vmscan) you'll still need a way to get from a
page to an address_space so that you can reclaim the page so you can hardly
get rid of page->mapping completely but you're right that with such limited
use that transition could be more complex / expensive.

What I wonder though is what is the cost of this (in the terms of code size
and speed) - propagating the mapping down the stack costs something... Also
in terms of maintainability, code readability suffers a bit.

This could be helped though. In some cases it seems we just use the mapping
because it was easily available but could get away without it. In other
case (e.g. lot of fs/buffer.c) we could make bh -> mapping transition easy
by storing the mapping in the struct buffer_head - possibly it could
replace b_bdev pointer as we could get to that from the mapping with a bit
of magic and pointer chasing and accessing b_bdev is not very performance
critical. OTOH such optimizations make a rather complex patches from mostly
mechanical replacement so I can see why you didn't go that route.

Overall I think you'd need to make a good benchmarking comparison showing
how much this helps some real workloads (your motivation) and also how
other loads on lower end machines are affected.

> --
> The What ?
> 
> Aim of this patch serie is to introduce generic page write protection
> for any kind of regular page in a process (private anonymous or back
> by regular file). This feature already exist, in one form, for private
> anonymous page, as part of KSM (Kernel Share Memory).
> 
> So this patch serie is two fold. First it factors out the page write
> protection of KSM into a generic write protection mechanim which KSM
> 

Re: PATCH V4 0/5 nvme-pci: fixes on nvme_timeout and nvme_dev_disable

2018-04-18 Thread jianchao.wang
Hi Ming

On 04/17/2018 11:17 PM, Ming Lei wrote:
> Looks blktest(block/011) can trigger IO hang easily on NVMe PCI device,
> and all are related with nvme_dev_disable():
> 
> 1) admin queue may be disabled by nvme_dev_disable() from timeout path
> during resetting, then reset can't move on
> 
> 2) the nvme_dev_disable() called from nvme_reset_work() may cause double
> completion on timed-out request 
> 
> So could you share us what your plan is about this patchset?

Regarding to this patchset, it is mainly to fix the dependency between
nvme_timeout and nvme_dev_disable, as your can see:
nvme_timeout will invoke nvme_dev_disable, and nvme_dev_disable have to
depend on nvme_timeout when controller no response. Till now, some parts
of the patchset looks bad and seem to have a lot of work need to be done.
:)

Thanks
Jianchao


[PATCH] IB/core: Make ib_mad_client_id atomic

2018-04-18 Thread Håkon Bugge
Two kernel threads may get the same value for agent.hi_tid, if the
agents are registered for different ports. As of now, this works, as
the agent list is per port.

It is however confusing and not future robust. Hence, making it
atomic.

Signed-off-by: Håkon Bugge 
Reviewed-by: Jack Morgenstein 
---
 drivers/infiniband/core/mad.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index c50596f7f98a..b28452a55a08 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -59,7 +59,7 @@ module_param_named(recv_queue_size, mad_recvq_size, int, 
0444);
 MODULE_PARM_DESC(recv_queue_size, "Size of receive queue in number of work 
requests");
 
 static struct list_head ib_mad_port_list;
-static u32 ib_mad_client_id = 0;
+static atomic_t ib_mad_client_id = ATOMIC_INIT(0);
 
 /* Port list lock */
 static DEFINE_SPINLOCK(ib_mad_port_list_lock);
@@ -377,7 +377,7 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device 
*device,
}
 
spin_lock_irqsave(_priv->reg_lock, flags);
-   mad_agent_priv->agent.hi_tid = ++ib_mad_client_id;
+   mad_agent_priv->agent.hi_tid = atomic_inc_return(_mad_client_id);
 
/*
 * Make sure MAD registration (if supplied)
-- 
2.13.6



Re: perf probe line numbers + CONFIG_DEBUG_INFO_SPLIT=y

2018-04-18 Thread Mark Wielaard
On Wed, 2018-04-18 at 23:03 +0900, Masami Hiramatsu wrote:
> It shows where we can see the .dwo file.
> However, it seems elfutils doesn't support dwo.
> 
> $ eu-readelf --debug-dump=info ~/kbin/linux.x86_64/fs/namei.dwo 
> eu-readelf: cannot get debug context descriptor: No DWARF information
> found
> 
> As above gcc article said, the section name has been changed.
> 
> $ eu-readelf -S ~/kbin/linux.x86_64/fs/namei.dwo There are 10 section
> headers, starting at offset 0x49440:
> 
> Section Headers:
> [Nr]
> Name Type Addr Off  Size 
> ES Flags Lk Inf Al
> [ 0]  NULL  
>   00   0  0
> [ 1] .debug_info.dwo  PROGBITS  0040
> 000252d7  0 E  0   0  1
> [ 2] .debug_abbrev.dwoPROGBITS  00025317
> 0f2f  0 E  0   0  1
> [ 3] .debug_loc.dwo   PROGBITS  00026246
> 4f9b  0 E  0   0  1
> 
> 
> And I found below description in systemtap
> document(man/error::dwarf.7stap).
> ===
> debuginfo configuration
> Some tools may generate debuginfo that is unsupported by systemtap,
> such
> as the linux kernel CONFIG_DEBUG_INFO_SPLIT (\f2.dwo\f1 files)
> option.
> Stick with plain ELF/DWARF (optinally split, Fedora-style), if
> possible.
> ===
> 
> So, it seems that elfutils may not support this split debuginfo yet.

No, it doesn't yet. I am working on it. Work in progress patches here:
https://code.wildebeest.org/git/user/mjw/elfutils/log/?h=dwarf5

That includes work on DWARF5 (which also supports split DWARF, but
slightly different from how GNU DebugFission works...).

I am trying to keep the interface of libdw completely the same. In most
cases things should work as is, even though the DIEs or locations come
from different sections/files. But have added some new functions to
"jump" from the skeleton DIEs to split DIEs in case the user needs to
know about the difference (and you probably want to, because otherwise
it will look like you just get "empty" skeleton DIE trees - see the
patches for eu-readelf --debug-dump=info+ and --dwarf-skeleton - but
those are very much WIP, don't use them as is, they are more to
figuring out what interfaces we need).

elfutils 0.171 with support for DWARF5, split DWARF and those new
interfaces should be out as soon as those WIP patches have been cleaned
up.

Once that is done, I'll use the new interfaces to add support to
systemtap.

Cheers,

Mark


Re: [PATCH v3 07/10] Documentation: dt-bindings: Add documents for PECI hwmon client drivers

2018-04-18 Thread Rob Herring
On Tue, Apr 17, 2018 at 3:40 PM, Jae Hyun Yoo
 wrote:
> On 4/16/2018 4:51 PM, Jae Hyun Yoo wrote:
>>
>> On 4/16/2018 4:22 PM, Jae Hyun Yoo wrote:
>>>
>>> On 4/16/2018 11:14 AM, Rob Herring wrote:

 On Tue, Apr 10, 2018 at 11:32:09AM -0700, Jae Hyun Yoo wrote:
>
> This commit adds dt-bindings documents for PECI cputemp and dimmtemp
> client
> drivers.


>
> [...]
>
> +Example:
> +peci-bus@0 {
> +#address-cells = <1>;
> +#size-cells = <0>;
> +< more properties >
> +
> +peci-dimmtemp@cpu0 {


 unit-address is wrong.

>>>
>>> Will fix it using the reg value.
>>>
 It is a different bus from cputemp? Otherwise, you have conflicting
 addresses. If that's the case, probably should make it clear by showing
 different host adapters for each example.

>>>
>>> It could be the same bus with cputemp. Also, client address sharing is
>>> possible by PECI core if the functionality is different. I mean, cputemp and
>>> dimmtemp targeting the same client is possible case like this.
>>> peci-cputemp@30
>>> peci-dimmtemp@30
>>>
>>
>> Oh, I got your point. Probably, I should change these separate settings
>> into one like
>>
>> peci-client@30 {
>>  compatible = "intel,peci-client";
>>  reg = <0x30>;
>> };
>>
>> Then cputemp and dimmtemp drivers could refer the same compatible string.
>> Will rewrite it.
>>
>
> I've checked it again and realized that it should use function based node
> name like:
>
> peci-cputemp@30
> peci-dimmtemp@30
>
> If it use the same string like 'peci-client@30', the drivers cannot be
> selectively enabled. The client address sharing way is well handled in PECI
> core and this way would be better for the future implementations of other
> PECI functional drivers such as crash dump driver and so on. So I'm going
> change the unit-address only.

2 nodes at the same address is wrong (and soon dtc will warn you on
this). You have 2 potential options. The first is you need additional
address information in the DT if these are in fact 2 independent
devices. This could be something like a function number to use
something from PCI addressing. From what I found on PECI, it doesn't
seem to have anything like that. The 2nd option is you have a single
DT node which registers multiple hwmon devices. DT nodes and drivers
don't have to be 1-1. Don't design your DT nodes from how you want to
partition drivers in some OS.

Rob


Re: [PATCH] net: qmi_wwan: add Wistron Neweb D19Q1

2018-04-18 Thread Bjørn Mork
Pawel Dembicki  writes:

> This modem is embedded on dlink dwr-960 router.
> The oem configuration states:
>
> T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 0
> D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
> P: Vendor=1435 ProdID=d191 Rev=ff.ff
> S: Manufacturer=Android
> S: Product=Android
> S: SerialNumber=0123456789ABCDEF
> C:* #Ifs= 6 Cfg#= 1 Atr=80 MxPwr=500mA
> I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
> E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)
> E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
> E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
> E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
> E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
> E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
> E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms
> E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 5 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none)
> E: Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E: Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=125us
>
> Tested on openwrt distribution
>
> Signed-off-by: Pawel Dembicki 

Acked-by: Bjørn Mork 


[PATCH] SLUB: Do not fallback to mininum order if __GFP_NORETRY is set

2018-04-18 Thread Christopher Lameter
Mikulas Patoka wants to ensure that no fallback to lower order happens. I
think __GFP_NORETRY should work correctly in that case too and not fall
back.



Allocating at a smaller order is a retry operation and should not
be attempted.

If the caller does not want retries then respect that.

GFP_NORETRY allows callers to ensure that only maximum order
allocations are attempted.

Signed-off-by: Christoph Lameter 

Index: linux/mm/slub.c
===
--- linux.orig/mm/slub.c
+++ linux/mm/slub.c
@@ -1598,7 +1598,7 @@ static struct page *allocate_slab(struct
alloc_gfp = (alloc_gfp | __GFP_NOMEMALLOC) & 
~(__GFP_RECLAIM|__GFP_NOFAIL);

page = alloc_slab_page(s, alloc_gfp, node, oo);
-   if (unlikely(!page)) {
+   if (unlikely(!page) && !(flags & __GFP_NORETRY)) {
oo = s->min;
alloc_gfp = flags;
/*


Re: [PATCH v2 1/2] tpm: reduce poll sleep time in tpm_transmit()

2018-04-18 Thread Mimi Zohar
On Tue, 2018-04-17 at 09:12 -0400, Nayna Jain wrote:
> The TPM polling code in tpm_transmit sleeps in each loop iteration for
> 5 msecs. However, the TPM might return earlier, and thus waiting for
> 5 msecs adds an unnecessary delay. This patch reduces the polling sleep
> time in tpm_transmit() from 5 msecs to 1 msecs.
> 
> Additionally, this patch renames TPM_POLL_SLEEP and moves it to tpm.h as
> an enum value.
> 
> After this change, performance on a TPM 1.2 with an 8 byte burstcount
> for 1000 extends improved from ~14 sec to ~10.7 sec.
> 
> Signed-off-by: Nayna Jain 

Reviewed-by: Mimi Zohar 

> ---
>  drivers/char/tpm/tpm-interface.c |  2 +-
>  drivers/char/tpm/tpm.h   |  3 ++-
>  drivers/char/tpm/tpm_tis_core.c  | 10 ++
>  3 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-interface.c 
> b/drivers/char/tpm/tpm-interface.c
> index 9e80a953d693..a676d8ad5992 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -470,7 +470,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct 
> tpm_space *space,
>   goto out;
>   }
> 
> - tpm_msleep(TPM_TIMEOUT);
> + tpm_msleep(TPM_TIMEOUT_POLL);
>   rmb();
>   } while (time_before(jiffies, stop));
> 
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index f895fba4e20d..7e797377e1eb 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -53,7 +53,8 @@ enum tpm_const {
>  enum tpm_timeout {
>   TPM_TIMEOUT = 5,/* msecs */
>   TPM_TIMEOUT_RETRY = 100, /* msecs */
> - TPM_TIMEOUT_RANGE_US = 300  /* usecs */
> + TPM_TIMEOUT_RANGE_US = 300, /* usecs */
> + TPM_TIMEOUT_POLL = 1/* msecs */
>  };
> 
>  /* TPM addresses */
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index da074e3db19b..021e6b68f2db 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -31,12 +31,6 @@
>  #include "tpm.h"
>  #include "tpm_tis_core.h"
> 
> -/* This is a polling delay to check for status and burstcount.
> - * As per ddwg input, expectation is that status check and burstcount
> - * check should return within few usecs.
> - */
> -#define TPM_POLL_SLEEP   1  /* msec */
> -
>  static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value);
> 
>  static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
> @@ -90,7 +84,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
>   }
>   } else {
>   do {
> - tpm_msleep(TPM_POLL_SLEEP);
> + tpm_msleep(TPM_TIMEOUT_POLL);
>   status = chip->ops->status(chip);
>   if ((status & mask) == mask)
>   return 0;
> @@ -232,7 +226,7 @@ static int get_burstcount(struct tpm_chip *chip)
>   burstcnt = (value >> 8) & 0x;
>   if (burstcnt)
>   return burstcnt;
> - tpm_msleep(TPM_POLL_SLEEP);
> + tpm_msleep(TPM_TIMEOUT_POLL);
>   } while (time_before(jiffies, stop));
>   return -EBUSY;
>  }



Re: [PATCH 2/2] printk: wake up klogd in vprintk_emit

2018-04-18 Thread Petr Mladek
On Wed 2018-04-18 10:29:43, Steven Rostedt wrote:
> On Sat, 14 Apr 2018 12:01:45 +0900
> Sergey Senozhatsky  wrote:
> 
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -1888,6 +1888,7 @@ asmlinkage int vprintk_emit(int facility, int level,
> >  
> > printed_len = log_output(facility, level, lflags, dict, dictlen, text, 
> > text_len);
> >  
> > +   wake_up_klogd();
> > logbuf_unlock_irqrestore(flags);
> 
> You can't do this, because the scheduler can call printk_deferred()
> with the rq lock held, and printk_deferred() will grab the logbuf lock.
> 
> Calling wake_up_klogd() will grab the rq lock and give us a A-B<->B-A
> locking order.

wake_up_klogd() uses the lockless irq_work_queue(). So it is actually
safe.

But the name is confusing. We should rename it.

Best Regards,
Petr


Re: [PATCH v2] tracing/x86: Update syscall trace events to handle new x86 syscall func names

2018-04-18 Thread Arnaldo Carvalho de Melo
Em Wed, Apr 18, 2018 at 10:36:06AM -0400, Steven Rostedt escreveu:
> On Wed, 18 Apr 2018 09:53:22 -0300
> Arnaldo Carvalho de Melo  wrote:
> > Em Tue, Apr 17, 2018 at 05:41:28PM -0400, Steven Rostedt escreveu:
> > > On Tue, 17 Apr 2018 15:13:04 -0300 Arnaldo Carvalho de Melo 
> > >  wrote:  
> > > > Yeah, failing:  

> > > > [root@jouet ~]# strace -e openat -e file perf test -F -v "mmap 
> > > > interface" |& grep syscalls
> > > > openat(AT_FDCWD, 
> > > > "/sys/kernel/debug/tracing/events/syscalls/sys_enter_getsid/format", 
> > > > O_RDONLY) = 3
> > > > openat(AT_FDCWD, 
> > > > "/sys/kernel/debug/tracing/events/syscalls/sys_enter_getppid/format", 
> > > > O_RDONLY) = -1 ENOENT (No such file or directory)  
> >  
> > > It doesn't have to do with the number of parameters, not everything
> > > has "__x64" on it.  

> > > Try this patch:  

> > Trying...
 
> You're keeping me in suspense!

I switched locations, had trouble reconnecting, those tests are ok now,
there is just one case left, related to the syscall routines renames,
but not related to the syscalls:sys_{enter,exit}_NAME tracepoints:

[root@jouet ~]# perf test
 1: vmlinux symtab matches kallsyms   : Ok
 2: Detect openat syscall event   : Ok
 3: Detect openat syscall event on all cpus   : Ok
 4: Read samples using the mmap interface : Ok
 5: Test data source output   : Ok
 6: Parse event definition strings: Ok
 7: Simple expression parser  : Ok
 8: PERF_RECORD_* events & perf_sample fields : Ok
 9: Parse perf pmu format : Ok
10: DSO data read : Ok
11: DSO data cache: Ok
12: DSO data reopen   : Ok
13: Roundtrip evsel->name : Ok
14: Parse sched tracepoints fields: Ok
15: syscalls:sys_enter_openat event fields: Ok
16: Setup struct perf_event_attr  : Ok
17: Match and link multiple hists : Ok
18: 'import perf' in python   : Ok
19: Breakpoint overflow signal handler: Ok
20: Breakpoint overflow sampling  : Ok
21: Breakpoint accounting : Ok
22: Number of exit events of a simple workload: Ok
23: Software clock events period values   : Ok
24: Object code reading   : Ok
25: Sample parsing: Ok
26: Use a dummy software event to keep tracking   : Ok
27: Parse with no sample_id_all bit set   : Ok
28: Filter hist entries   : Ok
29: Lookup mmap thread: Ok
30: Share thread mg   : Ok
31: Sort output of hist entries   : Ok
32: Cumulate child hist entries   : Ok
33: Track with sched_switch   : Ok
34: Filter fds with revents mask in a fdarray : Ok
35: Add fd to a fdarray, making it autogrow   : Ok
36: kmod_path__parse  : Ok
37: Thread map: Ok
38: LLVM search and compile   :
38.1: Basic BPF llvm compile  : Ok
38.2: kbuild searching: Ok
38.3: Compile source for BPF prologue generation  : Ok
38.4: Compile source for BPF relocation   : Ok
39: Session topology  : Ok
40: BPF filter:
40.1: Basic BPF filtering : FAILED!
40.2: BPF pinning : Skip
40.3: BPF prologue generation : Skip
40.4: BPF relocation checker  : Skip
41: Synthesize thread map : Ok
42: Remove thread map : Ok
43: Synthesize cpu map: Ok
44: Synthesize stat config: Ok
45: Synthesize stat   : Ok
46: Synthesize stat round : Ok
47: Synthesize attr update: Ok
48: Event times   : Ok
49: Read backward ring buffer : Ok
50: Print cpu map : Ok
51: Probe SDT events  : Ok
52: is_printable_array: Ok
53: Print bitmap   

Re: [PATCH v2 01/12] mm: Assign id to every memcg-aware shrinker

2018-04-18 Thread Kirill Tkhai
On 18.04.2018 17:32, Tetsuo Handa wrote:
> Kirill Tkhai wrote:
>> On 18.04.2018 17:14, Tetsuo Handa wrote:
>>> Kirill Tkhai wrote:
 The patch introduces shrinker::id number, which is used to enumerate
 memcg-aware shrinkers. The number start from 0, and the code tries
 to maintain it as small as possible.

 This will be used as to represent a memcg-aware shrinkers in memcg
 shrinkers map.
>>>
>>> I'm not reading this thread. But is there reason "id" needs to be managed
>>> using smallest numbers? Can't we use address of shrinker object as "id"
>>> (which will be sparse bitmap, and would be managed using linked list for 
>>> now)?
>>
>> Yes, it's needed to have the smallest numbers, as next patches introduce
>> per-memcg bitmap containing ids of shrinkers.
> 
> If you use sparse bitmap (xbitmap ?), I think you can do it.

There is no implementation in kernel, and search gave me this link:
https://patchwork.kernel.org/patch/10128397/

The problem is that it may allocate memory, and hence to fail.
While adding an element to shrinker lists (and setting a bit
in bitmap) mustn't fail. So, it's not possible to use sparse bitmap.

Kirill


Re: [RFC] perf/core: what is exclude_idle supposed to do

2018-04-18 Thread Vince Weaver
On Tue, 17 Apr 2018, Jiri Olsa wrote:

> On Mon, Apr 16, 2018 at 10:04:53PM +, Stephane Eranian wrote:
> > Hi,
> > 
> > I am trying to understand what the exclude_idle event attribute is supposed
> > to accomplish.
> > As per the definition in the header file:
> > 
> > exclude_idle   :  1, /* don't count when idle */
> 
> AFAICS it's not implemented

so just to be completely clear hear, we're saying that the "exclude_idle" 
modifier has never done anything useful and still doesn't?

If so I should update the perf_event_open manpage to spell this out.

Vince


Re: [PATCH] [media] include/media: fix missing | operator when setting cfg

2018-04-18 Thread Colin Ian King
On 18/04/18 16:23, Sylwester Nawrocki wrote:
> On 04/18/2018 05:20 PM, Sylwester Nawrocki wrote:
>> On 04/18/2018 05:06 PM, Colin King wrote:
>>> From: Colin Ian King 
>>>
>>> The value from a readl is being masked with ITE_REG_CIOCAN_MASK however
>>> this is not being used and cfg is being re-assigned.  I believe the
>>> assignment operator should actually be instead the |= operator.
>>>
>>> Detected by CoverityScan, CID#1467987 ("Unused value")
>>>
>>> Signed-off-by: Colin Ian King 
>> Thanks for the patch.
>>
>> Acked-by: Sylwester Nawrocki 
> 
> I forgot to mention that the subject should rather looks something
> like:
> 
> "exynos4-is: fimc-lite: : fix missing | operator when setting cfg"
> 
Oops, shall I re-send?


[PATCH v5 10/23] ASoC: qdsp6: q6afe: Add support to MI2S sysclks

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to LPASS Bit clock, LPASS Digital
core clock and OSR clock. These clocks are required for both
MI2S and PCM setup.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/qdsp6/q6afe.c | 212 ++-
 sound/soc/qcom/qdsp6/q6afe.h | 131 ++
 2 files changed, 341 insertions(+), 2 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index fe936d415178..7c7e30e34781 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -26,6 +26,7 @@
 #define AFE_PORT_CMD_DEVICE_START  0x000100E5
 #define AFE_PORT_CMD_DEVICE_STOP   0x000100E6
 #define AFE_PORT_CMD_SET_PARAM_V2  0x000100EF
+#define AFE_SVC_CMD_SET_PARAM  0x000100f3
 #define AFE_PORT_CMDRSP_GET_PARAM_V2   0x00010106
 #define AFE_PARAM_ID_HDMI_CONFIG   0x00010210
 #define AFE_MODULE_AUDIO_DEV_INTERFACE 0x0001020C
@@ -68,6 +69,11 @@
 #define AFE_PORT_ID_MULTICHAN_HDMI_RX  0x100E
 
 #define AFE_API_VERSION_SLIMBUS_CONFIG 0x1
+/* Clock set API version */
+#define AFE_API_VERSION_CLOCK_SET 1
+#define Q6AFE_LPASS_CLK_CONFIG_API_VERSION 0x1
+#define AFE_MODULE_CLOCK_SET   0x0001028F
+#define AFE_PARAM_ID_CLOCK_SET 0x00010290
 
 /* SLIMbus Rx port on channel 0. */
 #define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_RX  0x4000
@@ -146,6 +152,13 @@ struct afe_port_param_data_v2 {
u16 reserved;
 } __packed;
 
+struct afe_svc_cmd_set_param {
+   uint32_t payload_size;
+   uint32_t payload_address_lsw;
+   uint32_t payload_address_msw;
+   uint32_t mem_map_handle;
+} __packed;
+
 struct afe_port_cmd_set_param_v2 {
u16 port_id;
u16 payload_size;
@@ -206,6 +219,23 @@ struct afe_param_id_slimbus_cfg {
  */
 } __packed;
 
+struct afe_clk_cfg {
+   u32  i2s_cfg_minor_version;
+   u32  clk_val1;
+   u32  clk_val2;
+   u16  clk_src;
+   u16  clk_root;
+   u16  clk_set_mode;
+   u16  reserved;
+} __packed;
+
+struct afe_digital_clk_cfg {
+   u32  i2s_cfg_minor_version;
+   u32  clk_val;
+   u16  clk_root;
+   u16  reserved;
+} __packed;
+
 struct afe_param_id_i2s_cfg {
u32 i2s_cfg_minor_version;
u16 bit_width;
@@ -223,9 +253,43 @@ union afe_port_config {
struct afe_param_id_i2s_cfg i2s_cfg;
 } __packed;
 
+
+struct afe_clk_set {
+   uint32_t clk_set_minor_version;
+   uint32_t clk_id;
+   uint32_t clk_freq_in_hz;
+   uint16_t clk_attri;
+   uint16_t clk_root;
+   uint32_t enable;
+};
+
+struct afe_lpass_clk_config_command {
+   struct apr_hdr   hdr;
+   struct afe_port_cmd_set_param_v2 param;
+   struct afe_port_param_data_v2pdata;
+   struct afe_clk_cfg clk_cfg;
+} __packed;
+
+struct afe_lpass_clk_config_command_v2 {
+   struct apr_hdr  hdr;
+   struct afe_svc_cmd_set_paramparam;
+   struct afe_port_param_data_v2pdata;
+   struct afe_clk_set  clk_cfg;
+} __packed;
+
+
+
+struct afe_lpass_digital_clk_config_command {
+   struct apr_hdr   hdr;
+   struct afe_port_cmd_set_param_v2 param;
+   struct afe_port_param_data_v2pdata;
+   struct afe_digital_clk_cfg clk_cfg;
+} __packed;
+
 struct q6afe_port {
wait_queue_head_t wait;
union afe_port_config port_cfg;
+   struct aprv2_ibasic_rsp_result_t result;
int token;
int id;
int cfg_type;
@@ -322,6 +386,7 @@ static int q6afe_callback(struct apr_device *adev,
case AFE_PORT_CMD_SET_PARAM_V2:
case AFE_PORT_CMD_DEVICE_STOP:
case AFE_PORT_CMD_DEVICE_START:
+   case AFE_SVC_CMD_SET_PARAM:
port = afe_find_port(afe, data->token);
if (port) {
port->result = *res;
@@ -393,6 +458,46 @@ static int afe_apr_send_pkt(struct q6afe *afe, void *data,
return ret;
 }
 
+static int q6afe_port_set_param(struct q6afe_port *port, void *data,
+  int param_id, int module_id, int psize)
+{
+   struct apr_hdr *hdr;
+   struct afe_svc_cmd_set_param *param;
+   struct afe_port_param_data_v2 *pdata;
+   struct q6afe *afe = port->afe;
+   u16 port_id = port->id;
+   int ret;
+
+   hdr = data;
+   param = data + sizeof(*hdr);
+   pdata = data + sizeof(*hdr) + sizeof(*param);
+
+   hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
+ APR_HDR_LEN(APR_HDR_SIZE),
+ 

[PATCH v5 09/23] ASoC: qdsp6: q6afe: Add support to MI2S ports

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to 4 MI2S ports on LPASS.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/qdsp6/q6afe.c | 228 +++
 sound/soc/qcom/qdsp6/q6afe.h |  13 +++
 2 files changed, 241 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index 27c1055ac791..fe936d415178 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -14,6 +14,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include "q6dsp-errno.h"
 #include "q6core.h"
 #include "q6afe.h"
@@ -28,7 +32,36 @@
 
 #define AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG 0x00010235
 
+#define AFE_PARAM_ID_LPAIF_CLK_CONFIG  0x00010238
+#define AFE_PARAM_ID_INTERNAL_DIGITAL_CDC_CLK_CONFIG   0x00010239
+
 #define AFE_PARAM_ID_SLIMBUS_CONFIG0x00010212
+#define AFE_PARAM_ID_I2S_CONFIG0x0001020D
+
+/* I2S config specific */
+#define AFE_API_VERSION_I2S_CONFIG 0x1
+#define AFE_PORT_I2S_SD0   0x1
+#define AFE_PORT_I2S_SD1   0x2
+#define AFE_PORT_I2S_SD2   0x3
+#define AFE_PORT_I2S_SD3   0x4
+#define AFE_PORT_I2S_SD0_MASK  BIT(0x1)
+#define AFE_PORT_I2S_SD1_MASK  BIT(0x2)
+#define AFE_PORT_I2S_SD2_MASK  BIT(0x3)
+#define AFE_PORT_I2S_SD3_MASK  BIT(0x4)
+#define AFE_PORT_I2S_SD0_1_MASKGENMASK(2, 1)
+#define AFE_PORT_I2S_SD2_3_MASKGENMASK(4, 3)
+#define AFE_PORT_I2S_SD0_1_2_MASK  GENMASK(3, 1)
+#define AFE_PORT_I2S_SD0_1_2_3_MASKGENMASK(4, 1)
+#define AFE_PORT_I2S_QUAD010x5
+#define AFE_PORT_I2S_QUAD230x6
+#define AFE_PORT_I2S_6CHS  0x7
+#define AFE_PORT_I2S_8CHS  0x8
+#define AFE_PORT_I2S_MONO  0x0
+#define AFE_PORT_I2S_STEREO0x1
+#define AFE_PORT_CONFIG_I2S_WS_SRC_EXTERNAL0x0
+#define AFE_PORT_CONFIG_I2S_WS_SRC_INTERNAL0x1
+#define AFE_LINEAR_PCM_DATA0x0
+
 
 /* Port IDs */
 #define AFE_API_VERSION_HDMI_CONFIG0x1
@@ -64,6 +97,19 @@
 #define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX  0x400c
 /* SLIMbus Tx port on channel 6. */
 #define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_TX  0x400d
+#define AFE_PORT_ID_PRIMARY_MI2S_RX 0x1000
+#define AFE_PORT_ID_PRIMARY_MI2S_TX 0x1001
+#define AFE_PORT_ID_SECONDARY_MI2S_RX   0x1002
+#define AFE_PORT_ID_SECONDARY_MI2S_TX   0x1003
+#define AFE_PORT_ID_TERTIARY_MI2S_RX0x1004
+#define AFE_PORT_ID_TERTIARY_MI2S_TX0x1005
+#define AFE_PORT_ID_QUATERNARY_MI2S_RX  0x1006
+#define AFE_PORT_ID_QUATERNARY_MI2S_TX  0x1007
+
+#define Q6AFE_LPASS_MODE_CLK1_VALID 1
+#define Q6AFE_LPASS_MODE_CLK2_VALID 2
+#define Q6AFE_LPASS_CLK_SRC_INTERNAL 1
+#define Q6AFE_LPASS_CLK_ROOT_DEFAULT 0
 
 #define TIMEOUT_MS 1000
 #define AFE_CMD_RESP_AVAIL 0
@@ -160,10 +206,21 @@ struct afe_param_id_slimbus_cfg {
  */
 } __packed;
 
+struct afe_param_id_i2s_cfg {
+   u32 i2s_cfg_minor_version;
+   u16 bit_width;
+   u16 channel_mode;
+   u16 mono_stereo;
+   u16 ws_src;
+   u32 sample_rate;
+   u16 data_format;
+   u16 reserved;
+} __packed;
 
 union afe_port_config {
struct afe_param_id_hdmi_multi_chan_audio_cfg hdmi_multi_ch;
struct afe_param_id_slimbus_cfg   slim_cfg;
+   struct afe_param_id_i2s_cfg i2s_cfg;
 } __packed;
 
 struct q6afe_port {
@@ -210,6 +267,22 @@ static struct afe_port_map port_maps[AFE_PORT_MAX] = {
SLIMBUS_4_RX, 1, 1},
[SLIMBUS_5_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_RX,
SLIMBUS_5_RX, 1, 1},
+   [QUATERNARY_MI2S_RX] = { AFE_PORT_ID_QUATERNARY_MI2S_RX,
+   QUATERNARY_MI2S_RX, 1, 1},
+   [QUATERNARY_MI2S_TX] = { AFE_PORT_ID_QUATERNARY_MI2S_TX,
+   QUATERNARY_MI2S_TX, 0, 1},
+   [SECONDARY_MI2S_RX] = { AFE_PORT_ID_SECONDARY_MI2S_RX,
+   SECONDARY_MI2S_RX, 1, 1},
+   [SECONDARY_MI2S_TX] = { AFE_PORT_ID_SECONDARY_MI2S_TX,
+   SECONDARY_MI2S_TX, 0, 1},
+   [TERTIARY_MI2S_RX] = { AFE_PORT_ID_TERTIARY_MI2S_RX,
+   TERTIARY_MI2S_RX, 1, 1},
+   [TERTIARY_MI2S_TX] = { AFE_PORT_ID_TERTIARY_MI2S_TX,
+   TERTIARY_MI2S_TX, 0, 1},
+   [PRIMARY_MI2S_RX] = { AFE_PORT_ID_PRIMARY_MI2S_RX,
+   PRIMARY_MI2S_RX, 1, 1},
+   [PRIMARY_MI2S_TX] = { AFE_PORT_ID_PRIMARY_MI2S_TX,
+   PRIMARY_MI2S_RX, 0, 1},
[SLIMBUS_6_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX,
SLIMBUS_6_RX, 1, 1},
 };
@@ -448,6 +521,150 @@ void q6afe_hdmi_port_prepare(struct 

[PATCH v5 06/23] ASoC: qdsp6: dt-bindings: Add q6asm dt bindings

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch add DT bindings for ASM (Audio Stream Manager) DSP module.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 .../devicetree/bindings/sound/qcom,q6asm.txt   | 33 ++
 include/dt-bindings/sound/qcom,q6asm.h | 22 +++
 2 files changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,q6asm.txt
 create mode 100644 include/dt-bindings/sound/qcom,q6asm.h

diff --git a/Documentation/devicetree/bindings/sound/qcom,q6asm.txt 
b/Documentation/devicetree/bindings/sound/qcom,q6asm.txt
new file mode 100644
index ..d034a50a202a
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/qcom,q6asm.txt
@@ -0,0 +1,33 @@
+Qualcomm Audio Stream Manager (Q6ASM) binding
+
+Q6ASM is one of the APR audio service on Q6DSP.
+Please refer to qcom,apr.txt for details of the coommon apr service bindings
+used by the apr service device.
+
+- but must contain the following property:
+
+- compatible:
+   Usage: required
+   Value type: 
+   Definition: must be "qcom,asm-v.".
+   Or "qcom,asm" where the version number can be queried
+   from DSP.
+   example "qcom,asm-v2.0"
+
+= ASM DAIs (Digial Audio Interface)
+"dais" subnode of the ASM node represents dai specific configuration
+
+- #sound-dai-cells
+   Usage: required
+   Value type: 
+   Definition: Must be 1
+
+= EXAMPLE
+
+q6asm {
+   compatible = "qcom,q6asm";
+   reg = ;
+   q6asmdai: dais {
+   #sound-dai-cells = <1>;
+   };
+};
diff --git a/include/dt-bindings/sound/qcom,q6asm.h 
b/include/dt-bindings/sound/qcom,q6asm.h
new file mode 100644
index ..2e11b15d930d
--- /dev/null
+++ b/include/dt-bindings/sound/qcom,q6asm.h
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef __DT_BINDINGS_Q6_ASM_H__
+#define __DT_BINDINGS_Q6_ASM_H__
+
+#defineMSM_FRONTEND_DAI_MULTIMEDIA10
+#defineMSM_FRONTEND_DAI_MULTIMEDIA21
+#defineMSM_FRONTEND_DAI_MULTIMEDIA32
+#defineMSM_FRONTEND_DAI_MULTIMEDIA43
+#defineMSM_FRONTEND_DAI_MULTIMEDIA54
+#defineMSM_FRONTEND_DAI_MULTIMEDIA65
+#defineMSM_FRONTEND_DAI_MULTIMEDIA76
+#defineMSM_FRONTEND_DAI_MULTIMEDIA87
+#defineMSM_FRONTEND_DAI_MULTIMEDIA98
+#defineMSM_FRONTEND_DAI_MULTIMEDIA10   9
+#defineMSM_FRONTEND_DAI_MULTIMEDIA11   10
+#defineMSM_FRONTEND_DAI_MULTIMEDIA12   11
+#defineMSM_FRONTEND_DAI_MULTIMEDIA13   12
+#defineMSM_FRONTEND_DAI_MULTIMEDIA14   13
+#defineMSM_FRONTEND_DAI_MULTIMEDIA15   14
+#defineMSM_FRONTEND_DAI_MULTIMEDIA16   15
+
+#endif /* __DT_BINDINGS_Q6_ASM_H__ */
-- 
2.16.2



Re: [PATCH v9 7/9] pinctrl: madera: Add DT bindings for Cirrus Logic Madera codecs

2018-04-18 Thread Richard Fitzgerald

On 27/03/18 12:29, Linus Walleij wrote:

On Tue, Mar 13, 2018 at 2:19 PM, Richard Fitzgerald
 wrote:


This is the binding description of the pinctrl driver for Cirrus Logic
Madera codecs. The binding uses the generic pinctrl binding so  the main
purpose here is to describe the device-specific names for groups and
functions.

Signed-off-by: Richard Fitzgerald 
Acked-by: Rob Herring 


Acked-by: Linus Walleij 

I can also just apply this if you want, as it has no dependencies to


No let's leave it. There's no point the kernel source containing a
binding description for drivers that don't exist and I've no idea
how long it might take for the drivers to actually get into the
kernel. We've been going about a year now with these patches...


anything else. I just assume you want to keep it together with the
rest of this complex series.

Yours,
Linus Walleij



[PATCH v5 15/23] ASoC: qdsp6: q6core: Add q6core driver

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to core apr service, which is used to query
status of other static and dynamic services on the dsp.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/Kconfig|   4 +
 sound/soc/qcom/qdsp6/Makefile |   1 +
 sound/soc/qcom/qdsp6/q6core.c | 380 ++
 sound/soc/qcom/qdsp6/q6core.h |  15 ++
 4 files changed, 400 insertions(+)
 create mode 100644 sound/soc/qcom/qdsp6/q6core.c
 create mode 100644 sound/soc/qcom/qdsp6/q6core.h

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index a07181290624..488ee93ee084 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -56,6 +56,9 @@ config SND_SOC_QDSP6_ADM
 config SND_SOC_QDSP6_ASM
tristate
 
+config SND_SOC_QDSP6_CORE
+   tristate
+
 config SND_SOC_QDSP6
tristate "SoC ALSA audio driver for QDSP6"
depends on QCOM_APR && HAS_DMA
@@ -63,6 +66,7 @@ config SND_SOC_QDSP6
select SND_SOC_QDSP6_AFE
select SND_SOC_QDSP6_ADM
select SND_SOC_QDSP6_ASM
+   select SND_SOC_QDSP6_CORE
help
 To add support for MSM QDSP6 Soc Audio.
 This will enable sound soc platform specific
diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile
index eea962315ab3..61f089bc0d25 100644
--- a/sound/soc/qcom/qdsp6/Makefile
+++ b/sound/soc/qcom/qdsp6/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o
 obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o
 obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o
 obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o
+obj-$(CONFIG_SND_SOC_QDSP6_CORE) += q6core.o
diff --git a/sound/soc/qcom/qdsp6/q6core.c b/sound/soc/qcom/qdsp6/q6core.c
new file mode 100644
index ..244ec153ab71
--- /dev/null
+++ b/sound/soc/qcom/qdsp6/q6core.c
@@ -0,0 +1,380 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2011-2017, The Linux Foundation
+// Copyright (c) 2018, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "q6core.h"
+#include "q6dsp-errno.h"
+
+#define ADSP_STATE_READY_TIMEOUT_MS3000
+#define Q6_READY_TIMEOUT_MS 100
+#define AVCS_CMD_ADSP_EVENT_GET_STATE  0x0001290C
+#define AVCS_CMDRSP_ADSP_EVENT_GET_STATE   0x0001290D
+#define AVCS_GET_VERSIONS   0x00012905
+#define AVCS_GET_VERSIONS_RSP   0x00012906
+#define AVCS_CMD_GET_FWK_VERSION   0x001292c
+#define AVCS_CMDRSP_GET_FWK_VERSION0x001292d
+
+struct avcs_svc_info {
+   uint32_t service_id;
+   uint32_t version;
+} __packed;
+
+struct avcs_cmdrsp_get_version {
+   uint32_t build_id;
+   uint32_t num_services;
+   struct avcs_svc_info svc_api_info[];
+} __packed;
+
+/* for ADSP2.8 and above */
+struct avcs_svc_api_info {
+   uint32_t service_id;
+   uint32_t api_version;
+   uint32_t api_branch_version;
+} __packed;
+
+struct avcs_cmdrsp_get_fwk_version {
+   uint32_t build_major_version;
+   uint32_t build_minor_version;
+   uint32_t build_branch_version;
+   uint32_t build_subbranch_version;
+   uint32_t num_services;
+   struct avcs_svc_api_info svc_api_info[];
+} __packed;
+
+struct q6core {
+   struct apr_device *adev;
+   wait_queue_head_t wait;
+   uint32_t avcs_state;
+   struct mutex lock;
+   bool resp_received;
+   uint32_t num_services;
+   struct avcs_cmdrsp_get_fwk_version *fwk_version;
+   struct avcs_cmdrsp_get_version *svc_version;
+   bool fwk_version_supported;
+   bool get_state_supported;
+   bool get_version_supported;
+   bool is_version_requested;
+};
+
+static struct q6core *g_core;
+
+static int q6core_callback(struct apr_device *adev,
+struct apr_client_message *data)
+{
+   struct q6core *core = dev_get_drvdata(>dev);
+   struct aprv2_ibasic_rsp_result_t *result;
+
+   result = data->payload;
+   switch (data->opcode) {
+   case APR_BASIC_RSP_RESULT:{
+   result = data->payload;
+   switch (result->opcode) {
+   case AVCS_GET_VERSIONS:
+   if (result->status == ADSP_EUNSUPPORTED)
+   core->get_version_supported = false;
+   core->resp_received = true;
+   break;
+   case AVCS_CMD_GET_FWK_VERSION:
+   if (result->status == ADSP_EUNSUPPORTED)
+   core->fwk_version_supported = false;
+   core->resp_received = true;
+   break;
+   case AVCS_CMD_ADSP_EVENT_GET_STATE:
+   if (result->status == ADSP_EUNSUPPORTED)
+   core->get_state_supported = false;
+   core->resp_received = true;

Re: [Patch v3 2/6] cifs: Allocate validate negotiation request through kmalloc

2018-04-18 Thread Tom Talpey

On 4/18/2018 9:08 AM, David Laight wrote:

From: Tom Talpey

Sent: 18 April 2018 12:32

...

On 4/17/2018 8:33 PM, Long Li wrote:

From: Long Li 

The data buffer allocated on the stack can't be DMA'ed, and hence can't send
through RDMA via SMB Direct.


This comment is confusing. Any registered memory can be DMA'd, need to
state the reason for the choice here more clearly.


The stack could be allocated with vmalloc().
In which case the pages might not be physically contiguous and there is no
(sensible) call to get the physical address required by the dma controller
(or other bus master).


Memory registration does not requires pages to be physically contiguous.
RDMA Regions can and do support very large physical page scatter/gather,
and the adapter DMA's them readily. Is this the only reason?

Tom.


[PATCH v2] fs, elf: don't complain MAP_FIXED_NOREPLACE unless -EEXIST error.

2018-04-18 Thread Tetsuo Handa
>From 3f396857d23d4bf1fac4d4332316b5ba0af6d2f9 Mon Sep 17 00:00:00 2001
From: Tetsuo Handa 
Date: Wed, 18 Apr 2018 23:00:53 +0900
Subject: [PATCH v2] fs, elf: don't complain MAP_FIXED_NOREPLACE unless -EEXIST 
error.

Commit 4ed28639519c7bad ("fs, elf: drop MAP_FIXED usage from elf_map") is
printing spurious messages under memory pressure due to map_addr == -ENOMEM.

 9794 (a.out): Uhuuh, elf segment at 7f2e34738000(fff4) 
requested but the memory is mapped already
 14104 (a.out): Uhuuh, elf segment at 7f34fd76c000(fff4) 
requested but the memory is mapped already
 16843 (a.out): Uhuuh, elf segment at 7f930ecc7000(fff4) 
requested but the memory is mapped already

Complain only if -EEXIST, and use %px for printing the address.

Signed-off-by: Tetsuo Handa 
Acked-by: Michal Hocko 
Cc: Andrei Vagin 
Cc: Khalid Aziz 
Cc: Michael Ellerman 
Cc: Kees Cook 
Cc: Abdul Haleem 
Cc: Joel Stanley 
Cc: Anshuman Khandual 
---
 fs/binfmt_elf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 41e0418..4ad6f66 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -377,10 +377,10 @@ static unsigned long elf_map(struct file *filep, unsigned 
long addr,
} else
map_addr = vm_mmap(filep, addr, size, prot, type, off);
 
-   if ((type & MAP_FIXED_NOREPLACE) && BAD_ADDR(map_addr))
-   pr_info("%d (%s): Uhuuh, elf segment at %p requested but the 
memory is mapped already\n",
-   task_pid_nr(current), current->comm,
-   (void *)addr);
+   if ((type & MAP_FIXED_NOREPLACE) &&
+   PTR_ERR((void *)map_addr) == -EEXIST)
+   pr_info("%d (%s): Uhuuh, elf segment at %px requested but the 
memory is mapped already\n",
+   task_pid_nr(current), current->comm, (void *)addr);
 
return(map_addr);
 }
-- 
1.8.3.1


Re: [PATCH v2] ARM: dts: sunxi: Add sid for a83t

2018-04-18 Thread Kyle Evans
On Tue, Jan 9, 2018 at 7:34 AM, Maxime Ripard
 wrote:
> On Mon, Jan 08, 2018 at 09:30:57AM -0600, Kyle Evans wrote:
>> On Thu, Jan 4, 2018 at 8:01 AM, Maxime Ripard
>>  wrote:
>> > On Fri, Dec 22, 2017 at 06:11:52PM +0800, Chen-Yu Tsai wrote:
>> >> On Fri, Dec 22, 2017 at 6:07 PM, Emmanuel Vadot  
>> >> wrote:
>> >> > On Fri, 22 Dec 2017 09:35:08 +0100
>> >> > Maxime Ripard  wrote:
>> >> >
>> >> >> On Thu, Dec 21, 2017 at 07:09:03PM +0100, Emmanuel Vadot wrote:
>> >> >> >
>> >> >> >  Hi Maxime,
>> >> >> >
>> >> >> > On Thu, 21 Dec 2017 16:26:30 +0100
>> >> >> > Maxime Ripard  wrote:
>> >> >> >
>> >> >> > > Hi,
>> >> >> > >
>> >> >> > > On Thu, Dec 21, 2017 at 09:19:24AM -0600, Kyle Evans wrote:
>> >> >> > > > On Thu, Dec 21, 2017 at 8:55 AM, Maxime Ripard
>> >> >> > > >  wrote:
>> >> >> > > > > Hi Kyle,
>> >> >> > > > >
>> >> >> > > > > On Tue, Dec 19, 2017 at 03:05:23PM -0600, kevan...@ksu.edu 
>> >> >> > > > > wrote:
>> >> >> > > > >> Allwinner a83t has a 1 KB sid block with efuse for security 
>> >> >> > > > >> rootkey and
>> >> >> > > > >> thermal calibration data, add node to describe it.
>> >> >> > > > >>
>> >> >> > > > >> a83t-sid is not currently supported by nvmem/sunxi-sid, but 
>> >> >> > > > >> it is
>> >> >> > > > >> supported in an external driver for FreeBSD.
>> >> >> > > > >>
>> >> >> > > > >> Signed-off-by: Kyle Evans 
>> >> >> > > > >
>> >> >> > > > > The patch looks fine in itself, but we've had a number of 
>> >> >> > > > > issues with
>> >> >> > > > > the register layout (and access patterns) in the past, so I'd 
>> >> >> > > > > rather
>> >> >> > > > > have something that works in Linux too if possible.
>> >> >> > > >
>> >> >> > > > I have a patch that I think should make it work fine on Linux 
>> >> >> > > > [1], but
>> >> >> > > > I'm afraid I have little to no capability to test it myself and 
>> >> >> > > > so I
>> >> >> > > > did not add it as well.
>> >> >> > > >
>> >> >> > > > I do know that the rootkey is offset 0x200 into the given space 
>> >> >> > > > [2],
>> >> >> > > > as is the case with the H3, and that the readout quirk is not 
>> >> >> > > > needed.
>> >> >> > > > I wasn't 100% sure that the a83t has 2Kbit worth of efuse space 
>> >> >> > > > as the
>> >> >> > > > H3, but I do know that thermal data can be found at 0x34 and 
>> >> >> > > > 0x38 in
>> >> >> > > > this space.
>> >> >> > >
>> >> >> > > Then maybe we should leave it aside until someone takes some time 
>> >> >> > > on
>> >> >> > > the A83t.
>> >> >> >
>> >> >> >  Take some time on the Linux driver and do not apply this patch for
>> >> >> > now you mean ?
>> >> >>
>> >> >> Yep.
>> >> >>
>> >> >> Maxime
>> >> >
>> >> >  Since linux doesn't have the compatible in it's driver what would
>> >> > be the harm to add the node in the DTS ? If a quirks is needed because
>> >> > some region is weird this would go in the driver right ? I don't see a
>> >> > technical problem for adding this node right now.
>> >> >  If Kyle confirm the lenght of the region and that no quirk is needed
>> >> > will it be enough ?
>> >>
>> >> I guess I wasn't very clear. I'm OK with the patch going in. The device
>> >> node currently says nothing about how much efuse space there is. The
>> >> memory region covers that and the control section, and the size matches
>> >> what the memory map says.
>> >>
>> >> The size and offset of the efuse space would be dealt with in the driver.
>> >
>> > Let's merge it then.
>> >
>> > Acked-by: Maxime Ripard 
>>
>> What does the timeline for these things normally look like? I'm new to
>> these parts. =)
>
> We're one week away from the merge window, so it's a bit late for it
> to be merged in 4.16, but it'll be in 4.17.
>
> Maxime
>

Hi,

It's been two months and this still hasn't quite landed in
sunxi/for-next. =( May I ask the status on this?

Thanks,

Kyle Evans


Re: [RFC PATCH 1/3] signal: Ensure every siginfo we send has all bits initialized

2018-04-18 Thread Eric W. Biederman
Dave Martin  writes:

> On Tue, Apr 17, 2018 at 02:37:38PM -0500, Eric W. Biederman wrote:
>> Dave Martin  writes:
>> 
>> > Hmmm
>> >
>> > memset()/clear_siginfo() may ensure that there are no uninitialised
>> > explicit fields except for those in inactive union members, but I'm not
>> > sure that this approach is guaranteed to sanitise the padding seen by
>> > userspace.
>> >
>> > Rationale below, though it's a bit theoretical...
>> >
>> > With this in mind, I tend agree with Linus that hiding memset() calls
>> > from the maintainer may be a bad idea unless they are also hidden from
>> > the compiler.  If the compiler sees the memset() it may be able to
>> > optimise it in ways that wouldn't be possible for some other random
>> > external function call, including optimising all or part of the call
>> > out.
>> >
>> > As a result, the breakdown into individual put_user()s etc. in
>> > copy_siginfo_to_user() may still be valuable even if all paths have the
>> > memset().
>> 
>> The breakdown into individual put_user()s is known to be problematically
>> slow, and is actually wrong.
>
> Slowness certainly looked like a potential problem.
>
>> Even exclusing the SI_USER duplication in a small number of cases the
>> fields filled out in siginfo by architecture code are not the fields
>> that copy_siginfo_to_user is copying.  Which is much worse.  The code
>> looks safe but is not.
>> 
>> My intention is to leave 0 instances of clear_siginfo in the
>> architecture specific code.  Ideally struct siginfo will be limited to
>> kernel/signal.c but I am not certain I can quite get that far.
>> The function do_coredump appears to have a legit need for siginfo.
>
> So, you mean we can't detect that the caller didn't initialise all the
> members, or initialised the wrong union member?

Correct.  Even when we smuggled the the union member in the upper bits
of si_code we got it wrong.  So an interface that helps out and does
more and is harder to misues looks desirable.

> What would be the alternative?  Have a separate interface for each SIL_
> type, with only kernel/signal.c translating that into the siginfo_t that
> userspace sees?

Yes.  It really isn't bad as architecture specific code only generates
faults.  In general faults only take a pointer.  I have already merged
the needed helpers into kernel/signal.c

> Either way, I don't see how we force the caller to initilise the whole
> structure.

In general the plan is to convert the callers to call force_sig_fault,
and then there is no need to have siginfo in the architecture specific
code.  I have all of the necessary helpers are already merged into
kernel/signal.c

>
>> > (Rationale for an arch/arm example:)
>> >
>> >> diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
>> >> index 4c375e11ae95..adda3fc2dde8 100644
>> >> --- a/arch/arm/vfp/vfpmodule.c
>> >> +++ b/arch/arm/vfp/vfpmodule.c
>> >> @@ -218,8 +218,7 @@ static void vfp_raise_sigfpe(unsigned int sicode, 
>> >> struct pt_regs *regs)
>> >>  {
>> >>   siginfo_t info;
>> >>  
>> >> - memset(, 0, sizeof(info));
>> >> -
>> >> + clear_siginfo();
>> >>   info.si_signo = SIGFPE;
>> >
>> > /* by c11 (n1570) 6.2.6.1 para 6 [1], all padding bytes in info now take
>> >unspecified values */
>> >
>> >>   info.si_code = sicode;
>> >>   info.si_addr = (void __user *)(instruction_pointer(regs) - 4);
>> >
>> > /* by c11 (n1570) 6.2.6.1 para 7 [2], all bytes of the union info._sifields
>> >other than than those corresponding to _sigfault take unspecified
>> >values */
>> >
>> > So I don't see why the compiler needs to ensure that any of the affected
>> > bytes are zero: it could potentially skip a lot of the memset() as a
>> > result, in theory.
>> >
>> > I've not seen a compiler actually take advantage of that, but I'm now
>> > not sure what forbids it.
>> 
>> I took a quick look at gcc-4.9 which I have handy.
>> 
>> The passes -f-no-strict-aliasing which helps, and gcc actually
>> documents that if you access things through the union it will
>> not take advantage of c11.
>> 
>> gcc-4.9 Documents it this way:
>> 
>> > -fstrict-aliasing'
>> >  Allow the compiler to assume the strictest aliasing rules
>> >  applicable to the language being compiled.  For C (and C++), this
>> >  activates optimizations based on the type of expressions.  In
>> >  particular, an object of one type is assumed never to reside at the
>> >  same address as an object of a different type, unless the types are
>> >  almost the same.  For example, an 'unsigned int' can alias an
>> >  'int', but not a 'void*' or a 'double'.  A character type may alias
>> >  any other type.
>> > 
>> >  Pay special attention to code like this:
>> >   union a_union {
>> > int i;
>> > double d;
>> >   };
>> > 
>> >   int f() {
>> > union a_union t;
>> > t.d = 3.0;
>> > return t.i;
>> >   

Re: [PATCH] trace: add missing forward declaration

2018-04-18 Thread Steven Rostedt
On Tue, 17 Apr 2018 12:29:09 +0200
Greg Kroah-Hartman  wrote:

> On Tue, Apr 17, 2018 at 02:18:47AM +, Ahbong Chang wrote:
> > It does not fail with any config without this fix. This is for new work.  
> 
> Then why not submit it as part of the "new work" patch series?  That's
> how dependancies are normally handled.

I consider this patch making the kernel more robust. The reason I asked
was to know if it should be marked for stable or not. If nothing
currently relies on it, I just put it into the -rc as a "make the
kernel a little more robust" change. If other code relies on it, I
mark it for stable.

I'll take this patch as more of a clean up.

Thanks!

-- Steve


[PATCH v6 4/9] bindings: PCI: designware: Add support for the EP in Designware driver

2018-04-18 Thread Gustavo Pimentel
Add device tree binding documentation for the Endpoint in PCIe Designware
driver.

Signed-off-by: Gustavo Pimentel 
Reviewed-by: Rob Herring 
---
Change v1->v2:
 - Add a missing log description.
 - Add "snps,dw-pcie" compatible string following Kishon's suggestion.
Change v2->v3:
 - Reverted pcie_ep name to pcie.
Changes v3->v4:
 - Reverted "snps,dw-pcie-rc" compatible string requested by Rob Herring.
Changes v4->v5:
 - Removed device_type entry from EP requested by Rob Herring.
Changes v5->v6:
 - Nothing changed, just to follow the patch set version.

 Documentation/devicetree/bindings/pci/designware-pcie.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/pci/designware-pcie.txt 
b/Documentation/devicetree/bindings/pci/designware-pcie.txt
index 7f9804d..c124f9b 100644
--- a/Documentation/devicetree/bindings/pci/designware-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/designware-pcie.txt
@@ -3,6 +3,7 @@
 Required properties:
 - compatible:
"snps,dw-pcie" for RC mode;
+   "snps,dw-pcie-ep" for EP mode;
 - reg: Should contain the configuration address space.
 - reg-names: Must be "config" for the PCIe configuration space.
 (The old way of getting the configuration address space from "ranges"
@@ -56,3 +57,14 @@ Example configuration:
#interrupt-cells = <1>;
num-lanes = <1>;
};
+or
+   pcie: pcie@dfc0 {
+   compatible = "snps,dw-pcie-ep";
+   reg = <0xdfc0 0x0001000>, /* IP registers 1 */
+ <0xdfc01000 0x0001000>, /* IP registers 2 */
+ <0xd000 0x200>; /* Configuration space */
+   reg-names = "dbi", "dbi2", "addr_space";
+   num-ib-windows = <6>;
+   num-ob-windows = <2>;
+   num-lanes = <1>;
+   };
-- 
2.7.4




[PATCH v6 3/9] PCI: endpoint: functions/pci-epf-test: Add second entry

2018-04-18 Thread Gustavo Pimentel
Adds a seconds entry on the pci_epf_test_ids structure that disables the
linkup_notifier parameter on driver for the designware EP.

This allows designware EPs that doesn't have linkup notification signal
to work with pcitest.

Updates the binding documentation accordingly.

Signed-off-by: Gustavo Pimentel 
---
Change v2->v3:
 - Added second entry in pci_epf_test_ids structure.
 - Remove test_reg_bar field assignment on second entry.
Changes v3->v4:
 - Nothing changed, just to follow the patch set version.
Changes v4->v5:
 - Changed pci_epf_test_cfg2 to pci_epf_test_designware.
Changes v5->v6:
 - Changed name field from pci_epf_test_designware to pci_epf_test_dw.

 Documentation/PCI/endpoint/function/binding/pci-test.txt | 2 ++
 drivers/pci/endpoint/functions/pci-epf-test.c| 8 
 2 files changed, 10 insertions(+)

diff --git a/Documentation/PCI/endpoint/function/binding/pci-test.txt 
b/Documentation/PCI/endpoint/function/binding/pci-test.txt
index 3b68b95..dc39f47 100644
--- a/Documentation/PCI/endpoint/function/binding/pci-test.txt
+++ b/Documentation/PCI/endpoint/function/binding/pci-test.txt
@@ -1,6 +1,8 @@
 PCI TEST ENDPOINT FUNCTION
 
 name: Should be "pci_epf_test" to bind to the pci_epf_test driver.
+name: Should be "pci_epf_test_dw" to bind to the pci_epf_test driver
+  with a custom configuration for the designware EP.
 
 Configurable Fields:
 vendorid: should be 0x104c
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c 
b/drivers/pci/endpoint/functions/pci-epf-test.c
index 7cef851..b7dff87 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -459,10 +459,18 @@ static int pci_epf_test_bind(struct pci_epf *epf)
return 0;
 }
 
+static const struct pci_epf_test_data data_cfg2 = {
+   .linkup_notifier = false
+};
+
 static const struct pci_epf_device_id pci_epf_test_ids[] = {
{
.name = "pci_epf_test",
},
+   {
+   .name = "pci_epf_test_dw",
+   .driver_data = (kernel_ulong_t)_cfg2,
+   },
{},
 };
 
-- 
2.7.4




[PATCH v3 0/5] Use of_clk_get_parent_count() instead of open coding

2018-04-18 Thread Geert Uytterhoeven
Hi Mike, Stephen, et al,

This patch series replaces open-coded versions of
of_clk_get_parent_count() by calls to the helper function.

Changes compared to v2:
  - Add Acked-by, Reviewed-by,
  - Add SPDX-License-Identifier to ,
  - Add  to clock section in MAINTAINERS (note that Rob
is still listed as a maintainer, too, due to the include/linux/of*.h
catch-all rule),

Changes compared to v1:
  - Move OF clock helpers (a.o. of_clk_get_parent_count()) to their own
include file , as suggested by Stephen,
  - Update includes for the above change,
  - Fix timer-sp804, now a dummy is available in the !CONFIG_COMMON_CLK
case,
  - Fix a new occurrence.

Note that patches 2-5 depend on the first patch.

Thanks!

Geert Uytterhoeven (5):
  clk: Extract OF clock helpers in 
  ARM: timer-sp: Use of_clk_get_parent_count() instead of open coding
  soc: rockchip: power-domain: Use of_clk_get_parent_count() instead of
open coding
  soc/tegra: pmc: Use of_clk_get_parent_count() instead of open coding
  pinctrl: sunxi: Use of_clk_get_parent_count() instead of open coding

 MAINTAINERS   |  1 +
 drivers/clocksource/timer-sp804.c |  3 ++-
 drivers/pinctrl/sunxi/pinctrl-sunxi.c |  4 ++--
 drivers/soc/rockchip/pm_domains.c |  4 ++--
 drivers/soc/tegra/pmc.c   |  3 ++-
 include/linux/clk-provider.h  | 14 +-
 include/linux/of_clk.h| 30 ++
 7 files changed, 40 insertions(+), 19 deletions(-)
 create mode 100644 include/linux/of_clk.h

-- 
2.7.4

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v3 2/5] ARM: timer-sp: Use of_clk_get_parent_count() instead of open coding

2018-04-18 Thread Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven 
Acked-by: Daniel Lezcano 
---
This depends on "[PATCH v3 1/5] clk: Extract OF clock helpers in
".

v3:
  - Add Acked-by,

v2:
  - of_clk_get_parent_count() was moved to ,
  - Dropped RFC, as a dummy is now available in the !CONFIG_COMMON_CLK
case.
---
 drivers/clocksource/timer-sp804.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-sp804.c 
b/drivers/clocksource/timer-sp804.c
index 3ac9dec9a03852f9..e01222ea888ff9d2 100644
--- a/drivers/clocksource/timer-sp804.c
+++ b/drivers/clocksource/timer-sp804.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -245,7 +246,7 @@ static int __init sp804_of_init(struct device_node *np)
clk1 = NULL;
 
/* Get the 2nd clock if the timer has 3 timer clocks */
-   if (of_count_phandle_with_args(np, "clocks", "#clock-cells") == 3) {
+   if (of_clk_get_parent_count(np) == 3) {
clk2 = of_clk_get(np, 1);
if (IS_ERR(clk2)) {
pr_err("sp804: %s clock not found: %d\n", np->name,
-- 
2.7.4



Re: [PATCH 2/2] selftests/filesystems: remove Makefile warning

2018-04-18 Thread Shuah Khan
On 04/18/2018 01:52 AM, Anders Roxell wrote:
> When overriding the 'clean' target make throws up warnings:
> Makefile:9: warning: overriding recipe for target 'clean'
> ../lib.mk:98: warning: ignoring old recipe for target 'clean'
> 
> In current code we change from TEST_PROGS to TEST_GEN_PROGS and that
> does that we can remove the target 'clean' and 'all'.
> 
> Fixes: 10924bc64487 ("selftests: move dnotify_test from 
> Documentation/filesystems")
> Signed-off-by: Anders Roxell 
> ---
>  tools/testing/selftests/filesystems/Makefile | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/filesystems/Makefile 
> b/tools/testing/selftests/filesystems/Makefile
> index 427a401aae5c..a55ac3ac09ad 100644
> --- a/tools/testing/selftests/filesystems/Makefile
> +++ b/tools/testing/selftests/filesystems/Makefile
> @@ -1,9 +1,5 @@
>  # SPDX-License-Identifier: GPL-2.0
> -TEST_PROGS := dnotify_test devpts_pts
> +TEST_GEN_PROGS := dnotify_test devpts_pts
>  CFLAGS += -I../../../../usr/include/
> -all: $(TEST_PROGS)
>  
>  include ../lib.mk
> -
> -clean:
> - rm -fr $(TEST_PROGS)
> 

Hi Anders,

Michael sent in a patch to fix the problem already. It is in linux-kselftest 
fixes
branch for 4.17-rc2

Classifying dnotify_test to TEST_GEN_PROGS_EXTENDED as Michael is the correct 
way
to handle this problem. It allows the test to be built and installed and it 
won't
be run in the main kselftest run.

thanks,
-- Shuah


[PATCH] [media] include/media: fix missing | operator when setting cfg

2018-04-18 Thread Colin King
From: Colin Ian King 

The value from a readl is being masked with ITE_REG_CIOCAN_MASK however
this is not being used and cfg is being re-assigned.  I believe the
assignment operator should actually be instead the |= operator.

Detected by CoverityScan, CID#1467987 ("Unused value")

Signed-off-by: Colin Ian King 
---
 drivers/media/platform/exynos4-is/fimc-lite-reg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
index f0acc550d065..16565a0b4bf1 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
@@ -254,7 +254,7 @@ void flite_hw_set_dma_window(struct fimc_lite *dev, struct 
flite_frame *f)
/* Maximum output pixel size */
cfg = readl(dev->regs + FLITE_REG_CIOCAN);
cfg &= ~FLITE_REG_CIOCAN_MASK;
-   cfg = (f->f_height << 16) | f->f_width;
+   cfg |= (f->f_height << 16) | f->f_width;
writel(cfg, dev->regs + FLITE_REG_CIOCAN);
 
/* DMA offsets */
-- 
2.17.0



Re: [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path

2018-04-18 Thread Christoph Hellwig
On Wed, Apr 18, 2018 at 08:45:25AM -0600, Keith Busch wrote:
> Nothing against this patch. This just doesn't look correct even from
> before since nvme_find_path can set head->current_path right back to
> this namespace that we're trying to clear.
> 
> Christoph, am I missing something here or does this need additional
> checks/synchronization?

Yes, we should probably call it after removing the namespace from
the ns_head list, instead of right before.


Re: [PATCH 4.16 55/68] apparmor: fix display of .ns_name for containers

2018-04-18 Thread Serge E. Hallyn
Quoting Greg Kroah-Hartman (gre...@linuxfoundation.org):
> 4.16-stable review patch.  If anyone has any objections, please let me know.
> 
> --
> 
> From: John Johansen 
> 
> commit 040d9e2bce0a5b321c402b79ee43a8e8d2fd3b06 upstream.
> 
> The .ns_name should not be virtualized by the current ns view. It
> needs to report the ns base name as that is being used during startup
> as part of determining apparmor policy namespace support.
> 
> BugLink: http://bugs.launchpad.net/bugs/1746463
> Fixes: d9f02d9c237aa ("apparmor: fix display of ns name")
> Cc: Stable 
> Reported-by: Serge Hallyn 

Excellent, thank you - this has been a pretty invasive bug for
nested container usage.

> Tested-by: Serge Hallyn 
> Signed-off-by: John Johansen 
> Signed-off-by: Greg Kroah-Hartman 
> 
> ---
>  security/apparmor/apparmorfs.c |4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> --- a/security/apparmor/apparmorfs.c
> +++ b/security/apparmor/apparmorfs.c
> @@ -1189,9 +1189,7 @@ static int seq_ns_level_show(struct seq_
>  static int seq_ns_name_show(struct seq_file *seq, void *v)
>  {
>   struct aa_label *label = begin_current_label_crit_section();
> -
> - seq_printf(seq, "%s\n", aa_ns_name(labels_ns(label),
> -labels_ns(label), true));
> + seq_printf(seq, "%s\n", labels_ns(label)->base.name);
>   end_current_label_crit_section(label);
>  
>   return 0;
> 


Re: perf probe line numbers + CONFIG_DEBUG_INFO_SPLIT=y

2018-04-18 Thread Arnaldo Carvalho de Melo
Em Wed, Apr 18, 2018 at 11:03:01PM +0900, Masami Hiramatsu escreveu:
> And I found below description in systemtap document(man/error::dwarf.7stap).
> ===
> debuginfo configuration
> Some tools may generate debuginfo that is unsupported by systemtap, such
> as the linux kernel CONFIG_DEBUG_INFO_SPLIT (\f2.dwo\f1 files) option.
> Stick with plain ELF/DWARF (optinally split, Fedora-style), if possible.
> ===
 
> So, it seems that elfutils may not support this split debuginfo yet.

Ok, what about detecting that this is the case: .dwo is being used, as
detected by the presence of those .debug_*.dwo ELF sections and then
warning the user that this mode of operation is not supported yet?

- Arnaldo


Re: [PATCH v1 3/7] soc: mediatek: reuse read[l,x]_poll_timeout helpers

2018-04-18 Thread Matthias Brugger


On 04/03/2018 09:15 AM, sean.w...@mediatek.com wrote:
> From: Sean Wang 
> 
> Reuse the common helpers read[l,x]_poll_timeout provided by Linux core
> instead of an open-coded handling. The name of the local variable
> sram_pdn_ack in scpsys_power_on is renamed to pdn_ack in order to be
> consistent with the one used in scpsys_power_off.
> 
> Signed-off-by: Sean Wang 
> Cc: Matthias Brugger 
> Cc: Ulf Hansson 
> Cc: Weiyi Lu 
> ---

pushed to v4.17-next/soc

Thanks!

>  drivers/soc/mediatek/mtk-scpsys.c | 91 
> ++-
>  1 file changed, 23 insertions(+), 68 deletions(-)
> 
> diff --git a/drivers/soc/mediatek/mtk-scpsys.c 
> b/drivers/soc/mediatek/mtk-scpsys.c
> index d762a46..f9b7248 100644
> --- a/drivers/soc/mediatek/mtk-scpsys.c
> +++ b/drivers/soc/mediatek/mtk-scpsys.c
> @@ -13,6 +13,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -27,6 +28,9 @@
>  #include 
>  #include 
>  
> +#define MTK_POLL_DELAY_US   10
> +#define MTK_POLL_TIMEOUT(jiffies_to_usecs(HZ))
> +
>  #define SPM_VDE_PWR_CON  0x0210
>  #define SPM_MFG_PWR_CON  0x0214
>  #define SPM_VEN_PWR_CON  0x0230
> @@ -184,12 +188,10 @@ static int scpsys_power_on(struct generic_pm_domain 
> *genpd)
>  {
>   struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd);
>   struct scp *scp = scpd->scp;
> - unsigned long timeout;
> - bool expired;
>   void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs;
> - u32 sram_pdn_ack = scpd->data->sram_pdn_ack_bits;
> + u32 pdn_ack = scpd->data->sram_pdn_ack_bits;
>   u32 val;
> - int ret;
> + int ret, tmp;
>   int i;
>  
>   if (scpd->supply) {
> @@ -215,23 +217,10 @@ static int scpsys_power_on(struct generic_pm_domain 
> *genpd)
>   writel(val, ctl_addr);
>  
>   /* wait until PWR_ACK = 1 */
> - timeout = jiffies + HZ;
> - expired = false;
> - while (1) {
> - ret = scpsys_domain_is_on(scpd);
> - if (ret > 0)
> - break;
> -
> - if (expired) {
> - ret = -ETIMEDOUT;
> - goto err_pwr_ack;
> - }
> -
> - cpu_relax();
> -
> - if (time_after(jiffies, timeout))
> - expired = true;
> - }
> + ret = readx_poll_timeout(scpsys_domain_is_on, scpd, tmp, tmp > 0,
> +  MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
> + if (ret < 0)
> + goto err_pwr_ack;
>  
>   val &= ~PWR_CLK_DIS_BIT;
>   writel(val, ctl_addr);
> @@ -246,20 +235,10 @@ static int scpsys_power_on(struct generic_pm_domain 
> *genpd)
>   writel(val, ctl_addr);
>  
>   /* wait until SRAM_PDN_ACK all 0 */
> - timeout = jiffies + HZ;
> - expired = false;
> - while (sram_pdn_ack && (readl(ctl_addr) & sram_pdn_ack)) {
> -
> - if (expired) {
> - ret = -ETIMEDOUT;
> - goto err_pwr_ack;
> - }
> -
> - cpu_relax();
> -
> - if (time_after(jiffies, timeout))
> - expired = true;
> - }
> + ret = readl_poll_timeout(ctl_addr, tmp, (tmp & pdn_ack) == 0,
> +  MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
> + if (ret < 0)
> + goto err_pwr_ack;
>  
>   if (scpd->data->bus_prot_mask) {
>   ret = mtk_infracfg_clear_bus_protection(scp->infracfg,
> @@ -289,12 +268,10 @@ static int scpsys_power_off(struct generic_pm_domain 
> *genpd)
>  {
>   struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd);
>   struct scp *scp = scpd->scp;
> - unsigned long timeout;
> - bool expired;
>   void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs;
>   u32 pdn_ack = scpd->data->sram_pdn_ack_bits;
>   u32 val;
> - int ret;
> + int ret, tmp;
>   int i;
>  
>   if (scpd->data->bus_prot_mask) {
> @@ -310,19 +287,10 @@ static int scpsys_power_off(struct generic_pm_domain 
> *genpd)
>   writel(val, ctl_addr);
>  
>   /* wait until SRAM_PDN_ACK all 1 */
> - timeout = jiffies + HZ;
> - expired = false;
> - while (pdn_ack && (readl(ctl_addr) & pdn_ack) != pdn_ack) {
> - if (expired) {
> - ret = -ETIMEDOUT;
> - goto out;
> - }
> -
> - cpu_relax();
> -
> - if (time_after(jiffies, timeout))
> - expired = true;
> - }
> + ret = readl_poll_timeout(ctl_addr, tmp, (tmp & pdn_ack) == pdn_ack,
> +  MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
> + if (ret < 0)
> + goto out;
>  
>   val |= PWR_ISO_BIT;
>   writel(val, ctl_addr);
> @@ -340,23 +308,10 @@ 

Re: [PATCH] [media] include/media: fix missing | operator when setting cfg

2018-04-18 Thread Sylwester Nawrocki
On 04/18/2018 05:20 PM, Sylwester Nawrocki wrote:
> On 04/18/2018 05:06 PM, Colin King wrote:
>> From: Colin Ian King 
>>
>> The value from a readl is being masked with ITE_REG_CIOCAN_MASK however
>> this is not being used and cfg is being re-assigned.  I believe the
>> assignment operator should actually be instead the |= operator.
>>
>> Detected by CoverityScan, CID#1467987 ("Unused value")
>>
>> Signed-off-by: Colin Ian King 
> Thanks for the patch.
> 
> Acked-by: Sylwester Nawrocki 

I forgot to mention that the subject should rather looks something
like:

"exynos4-is: fimc-lite: : fix missing | operator when setting cfg"

-- 
Regards,
Sylwester


Re: [PATCH] [media] include/media: fix missing | operator when setting cfg

2018-04-18 Thread Sylwester Nawrocki
On 04/18/2018 05:24 PM, Colin Ian King wrote:
> Oops, shall I re-send?

There is no need to, thanks.


[PATCH v5 12/23] ASoC: qdsp6: q6asm: Add q6asm driver

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds basic support to Q6 ASM (Audio Stream Manager) module on
Q6DSP. ASM supports up to 8 concurrent streams. each stream can be setup
as playback/capture. ASM provides top control functions like
Pause/flush/resume for playback and record. ASM can Create/destroy encoder,
decoder and also provides POPP dynamic services.

This patch adds support to basic features to allow hdmi playback.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/Kconfig|   4 +
 sound/soc/qcom/qdsp6/Makefile |   1 +
 sound/soc/qcom/qdsp6/q6asm.c  | 230 ++
 sound/soc/qcom/qdsp6/q6asm.h  |  15 +++
 4 files changed, 250 insertions(+)
 create mode 100644 sound/soc/qcom/qdsp6/q6asm.c
 create mode 100644 sound/soc/qcom/qdsp6/q6asm.h

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index 5090ffa75648..a07181290624 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -53,12 +53,16 @@ config SND_SOC_QDSP6_AFE
 config SND_SOC_QDSP6_ADM
tristate
 
+config SND_SOC_QDSP6_ASM
+   tristate
+
 config SND_SOC_QDSP6
tristate "SoC ALSA audio driver for QDSP6"
depends on QCOM_APR && HAS_DMA
select SND_SOC_QDSP6_COMMON
select SND_SOC_QDSP6_AFE
select SND_SOC_QDSP6_ADM
+   select SND_SOC_QDSP6_ASM
help
 To add support for MSM QDSP6 Soc Audio.
 This will enable sound soc platform specific
diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile
index 930944425051..eea962315ab3 100644
--- a/sound/soc/qcom/qdsp6/Makefile
+++ b/sound/soc/qcom/qdsp6/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o
 obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o
 obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o
+obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o
diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c
new file mode 100644
index ..4ed64d32c6b0
--- /dev/null
+++ b/sound/soc/qcom/qdsp6/q6asm.c
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2011-2017, The Linux Foundation
+// Copyright (c) 2018, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "q6asm.h"
+#include "q6core.h"
+#include "q6dsp-errno.h"
+#include "q6dsp-common.h"
+
+#define ASM_SYNC_IO_MODE   0x0001
+#define ASM_ASYNC_IO_MODE  0x0002
+#define ASM_TUN_READ_IO_MODE   0x0004  /* tunnel read write mode */
+#define ASM_TUN_WRITE_IO_MODE  0x0008  /* tunnel read write mode */
+
+struct audio_client {
+   int session;
+   q6asm_cb cb;
+   void *priv;
+   uint32_t io_mode;
+   struct apr_device *adev;
+   struct mutex lock;
+   wait_queue_head_t cmd_wait;
+   struct aprv2_ibasic_rsp_result_t result;
+   int perf_mode;
+   int stream_id;
+   struct device *dev;
+};
+
+struct q6asm {
+   struct apr_device *adev;
+   struct device *dev;
+   struct q6core_svc_api_info ainfo;
+   wait_queue_head_t mem_wait;
+   struct platform_device *pcmdev;
+   struct audio_client *session[MAX_SESSIONS + 1];
+   struct platform_device *pdev_dais;
+};
+
+static bool q6asm_is_valid_audio_client(struct audio_client *ac)
+{
+   struct q6asm *a = dev_get_drvdata(ac->dev->parent);
+   int n;
+
+   if (!ac)
+   return false;
+
+   for (n = 1; n <= MAX_SESSIONS; n++) {
+   if (a->session[n] == ac)
+   return true;
+   }
+
+   return false;
+}
+
+/**
+ * q6asm_audio_client_free() - Freee allocated audio client
+ *
+ * @ac: audio client to free
+ */
+void q6asm_audio_client_free(struct audio_client *ac)
+{
+   struct q6asm *a = dev_get_drvdata(ac->dev->parent);
+
+   a->session[ac->session] = NULL;
+   kfree(ac);
+}
+EXPORT_SYMBOL_GPL(q6asm_audio_client_free);
+
+static struct audio_client *q6asm_get_audio_client(struct q6asm *a,
+  int session_id)
+{
+   if ((session_id <= 0) || (session_id > MAX_SESSIONS)) {
+   dev_err(a->dev, "invalid session: %d\n", session_id);
+   return NULL;
+   }
+
+   if (!a->session[session_id]) {
+   dev_err(a->dev, "session not active: %d\n", session_id);
+   return NULL;
+   }
+
+   return a->session[session_id];
+}
+
+static int q6asm_srvc_callback(struct apr_device *adev,
+  struct apr_client_message *data)
+{
+   struct aprv2_ibasic_rsp_result_t *result;
+   struct q6asm *a, *q6asm = dev_get_drvdata(>dev);
+   struct audio_client *ac = NULL;
+   struct audio_port_data *port;
+   uint32_t dir = 0;
+   uint32_t sid = 0;
+
+   result = data->payload;
+   sid = 

[PATCH v5 20/23] ASoC: qdsp6: q6asm: Add q6asm dai driver

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to q6asm dai driver which configures Q6ASM streams
to pass pcm data.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/Kconfig   |   4 +
 sound/soc/qcom/qdsp6/Makefile|   1 +
 sound/soc/qcom/qdsp6/q6asm-dai.c | 632 +++
 3 files changed, 637 insertions(+)
 create mode 100644 sound/soc/qcom/qdsp6/q6asm-dai.c

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index 9b630686eb19..5bdf39f6003f 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -62,6 +62,9 @@ config SND_SOC_QDSP6_ROUTING
 config SND_SOC_QDSP6_ASM
tristate
 
+config SND_SOC_QDSP6_ASM_DAI
+   tristate
+
 config SND_SOC_QDSP6_CORE
tristate
 
@@ -74,6 +77,7 @@ config SND_SOC_QDSP6
select SND_SOC_QDSP6_ADM
select SND_SOC_QDSP6_ROUTING
select SND_SOC_QDSP6_ASM
+   select SND_SOC_QDSP6_ASM_DAI
select SND_SOC_QDSP6_CORE
help
 To add support for MSM QDSP6 Soc Audio.
diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile
index 6a8ae698f22f..af44711eba24 100644
--- a/sound/soc/qcom/qdsp6/Makefile
+++ b/sound/soc/qcom/qdsp6/Makefile
@@ -4,4 +4,5 @@ obj-$(CONFIG_SND_SOC_QDSP6_AFE_DAI) += q6afe-dai.o
 obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o
 obj-$(CONFIG_SND_SOC_QDSP6_ROUTING) += q6routing.o
 obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o
+obj-$(CONFIG_SND_SOC_QDSP6_ASM_DAI) += q6asm-dai.o
 obj-$(CONFIG_SND_SOC_QDSP6_CORE) += q6core.o
diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
new file mode 100644
index ..a7a4ac00b897
--- /dev/null
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -0,0 +1,632 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2011-2016, The Linux Foundation
+// Copyright (c) 2017, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "q6asm.h"
+#include "q6routing.h"
+#include "q6dsp-errno.h"
+
+#define PLAYBACK_MIN_NUM_PERIODS2
+#define PLAYBACK_MAX_NUM_PERIODS   8
+#define PLAYBACK_MAX_PERIOD_SIZE65536
+#define PLAYBACK_MIN_PERIOD_SIZE128
+#define CAPTURE_MIN_NUM_PERIODS 2
+#define CAPTURE_MAX_NUM_PERIODS 8
+#define CAPTURE_MAX_PERIOD_SIZE 4096
+#define CAPTURE_MIN_PERIOD_SIZE 320
+#define SID_MASK_DEFAULT   0xF
+
+enum stream_state {
+   Q6ASM_STREAM_IDLE = 0,
+   Q6ASM_STREAM_STOPPED,
+   Q6ASM_STREAM_RUNNING,
+};
+
+struct q6asm_dai_rtd {
+   struct snd_pcm_substream *substream;
+   phys_addr_t phys;
+   unsigned int pcm_size;
+   unsigned int pcm_count;
+   unsigned int pcm_irq_pos;   /* IRQ position */
+   unsigned int periods;
+   uint16_t bits_per_sample;
+   uint16_t source; /* Encoding source bit mask */
+   struct audio_client *audio_client;
+   uint16_t session_id;
+   enum stream_state state;
+};
+
+struct q6asm_dai_data {
+   long long int sid;
+};
+
+static struct snd_pcm_hardware q6asm_dai_hardware_capture = {
+   .info = (SNDRV_PCM_INFO_MMAP |
+   SNDRV_PCM_INFO_BLOCK_TRANSFER |
+   SNDRV_PCM_INFO_MMAP_VALID |
+   SNDRV_PCM_INFO_INTERLEAVED |
+   SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
+   .formats =  (SNDRV_PCM_FMTBIT_S16_LE |
+   SNDRV_PCM_FMTBIT_S24_LE),
+   .rates =SNDRV_PCM_RATE_8000_48000,
+   .rate_min = 8000,
+   .rate_max = 48000,
+   .channels_min = 1,
+   .channels_max = 4,
+   .buffer_bytes_max = CAPTURE_MAX_NUM_PERIODS *
+   CAPTURE_MAX_PERIOD_SIZE,
+   .period_bytes_min = CAPTURE_MIN_PERIOD_SIZE,
+   .period_bytes_max = CAPTURE_MAX_PERIOD_SIZE,
+   .periods_min =  CAPTURE_MIN_NUM_PERIODS,
+   .periods_max =  CAPTURE_MAX_NUM_PERIODS,
+   .fifo_size =0,
+};
+
+static struct snd_pcm_hardware q6asm_dai_hardware_playback = {
+   .info = (SNDRV_PCM_INFO_MMAP |
+   SNDRV_PCM_INFO_BLOCK_TRANSFER |
+   SNDRV_PCM_INFO_MMAP_VALID |
+   SNDRV_PCM_INFO_INTERLEAVED |
+   SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
+   .formats =  (SNDRV_PCM_FMTBIT_S16_LE |
+   SNDRV_PCM_FMTBIT_S24_LE),
+   .rates =SNDRV_PCM_RATE_8000_192000,
+   .rate_min = 8000,
+   .rate_max = 192000,
+   .channels_min = 1,
+   .channels_max = 8,
+   

[PATCH v5 13/23] ASoC: qdsp6: q6asm: Add support to memory map and unmap

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to memory map and unmap regions commands in
q6asm module.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/qdsp6/q6asm.c | 338 +++
 sound/soc/qcom/qdsp6/q6asm.h |   5 +
 2 files changed, 343 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c
index 4ed64d32c6b0..51a5681dd61f 100644
--- a/sound/soc/qcom/qdsp6/q6asm.c
+++ b/sound/soc/qcom/qdsp6/q6asm.c
@@ -17,10 +17,47 @@
 #include "q6dsp-errno.h"
 #include "q6dsp-common.h"
 
+#define ASM_CMD_SHARED_MEM_MAP_REGIONS 0x00010D92
+#define ASM_CMDRSP_SHARED_MEM_MAP_REGIONS  0x00010D93
+#define ASM_CMD_SHARED_MEM_UNMAP_REGIONS   0x00010D94
+
 #define ASM_SYNC_IO_MODE   0x0001
 #define ASM_ASYNC_IO_MODE  0x0002
 #define ASM_TUN_READ_IO_MODE   0x0004  /* tunnel read write mode */
 #define ASM_TUN_WRITE_IO_MODE  0x0008  /* tunnel read write mode */
+#define ASM_SHIFT_GAPLESS_MODE_FLAG31
+#define ADSP_MEMORY_MAP_SHMEM8_4K_POOL 3
+
+struct avs_cmd_shared_mem_map_regions {
+   struct apr_hdr hdr;
+   u16 mem_pool_id;
+   u16 num_regions;
+   u32 property_flag;
+} __packed;
+
+struct avs_shared_map_region_payload {
+   u32 shm_addr_lsw;
+   u32 shm_addr_msw;
+   u32 mem_size_bytes;
+} __packed;
+
+struct avs_cmd_shared_mem_unmap_regions {
+   struct apr_hdr hdr;
+   u32 mem_map_handle;
+} __packed;
+
+struct audio_buffer {
+   phys_addr_t phys;
+   uint32_t used;
+   uint32_t size;  /* size of buffer */
+};
+
+struct audio_port_data {
+   struct audio_buffer *buf;
+   uint32_t num_periods;
+   uint32_t dsp_buf;
+   uint32_t mem_map_handle;
+};
 
 struct audio_client {
int session;
@@ -29,6 +66,9 @@ struct audio_client {
uint32_t io_mode;
struct apr_device *adev;
struct mutex lock;
+   spinlock_t buf_lock;
+   /* idx:1 out port, 0: in port */
+   struct audio_port_data port[2];
wait_queue_head_t cmd_wait;
struct aprv2_ibasic_rsp_result_t result;
int perf_mode;
@@ -62,6 +102,268 @@ static bool q6asm_is_valid_audio_client(struct 
audio_client *ac)
return false;
 }
 
+static inline void q6asm_add_hdr(struct audio_client *ac, struct apr_hdr *hdr,
+uint32_t pkt_size, bool cmd_flg,
+uint32_t stream_id)
+{
+   hdr->hdr_field = APR_SEQ_CMD_HDR_FIELD;
+   hdr->src_svc = ac->adev->svc_id;
+   hdr->src_domain = APR_DOMAIN_APPS;
+   hdr->dest_svc = APR_SVC_ASM;
+   hdr->dest_domain = APR_DOMAIN_ADSP;
+   hdr->src_port = ((ac->session << 8) & 0xFF00) | (stream_id);
+   hdr->dest_port = ((ac->session << 8) & 0xFF00) | (stream_id);
+   hdr->pkt_size = pkt_size;
+   if (cmd_flg)
+   hdr->token = ac->session;
+}
+
+static int q6asm_apr_send_session_pkt(struct q6asm *a, struct audio_client *ac,
+ void *data, uint32_t rsp_opcode)
+{
+   struct apr_hdr *hdr = data;
+   int rc;
+
+   mutex_lock(>lock);
+   ac->result.opcode = 0;
+   ac->result.status = 0;
+   rc = apr_send_pkt(a->adev, data);
+   if (rc < 0)
+   goto err;
+
+   if (rsp_opcode)
+   rc = wait_event_timeout(a->mem_wait,
+   (ac->result.opcode == hdr->opcode) ||
+   (ac->result.opcode == rsp_opcode),
+   5 * HZ);
+   else
+   rc = wait_event_timeout(a->mem_wait,
+   (ac->result.opcode == hdr->opcode),
+   5 * HZ);
+
+   if (!rc) {
+   dev_err(a->dev, "CMD timeout\n");
+   rc = -ETIMEDOUT;
+   } else if (ac->result.status > 0) {
+   dev_err(a->dev, "DSP returned error[%x]\n",
+   ac->result.status);
+   rc = -EINVAL;
+   }
+
+err:
+   mutex_unlock(>lock);
+   return rc;
+}
+
+static int __q6asm_memory_unmap(struct audio_client *ac,
+   phys_addr_t buf_add, int dir)
+{
+   struct avs_cmd_shared_mem_unmap_regions mem_unmap;
+   struct q6asm *a = dev_get_drvdata(ac->dev->parent);
+   int rc;
+
+   if (ac->port[dir].mem_map_handle == 0) {
+   dev_err(ac->dev, "invalid mem handle\n");
+   return -EINVAL;
+   }
+
+   mem_unmap.hdr.hdr_field = APR_SEQ_CMD_HDR_FIELD;
+   mem_unmap.hdr.src_port = 0;
+   mem_unmap.hdr.dest_port = 0;
+   mem_unmap.hdr.pkt_size = sizeof(mem_unmap);
+   mem_unmap.hdr.token = ((ac->session << 8) | dir);
+
+   mem_unmap.hdr.opcode = ASM_CMD_SHARED_MEM_UNMAP_REGIONS;
+   

[PATCH v5 19/23] ASoC: qdsp6: q6afe: Add q6afe dai driver

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to q6afe backend dais driver.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/Kconfig   |   4 +
 sound/soc/qcom/qdsp6/Makefile|   1 +
 sound/soc/qcom/qdsp6/q6afe-dai.c | 752 +++
 3 files changed, 757 insertions(+)
 create mode 100644 sound/soc/qcom/qdsp6/q6afe-dai.c

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index 7a868a6fac1b..9b630686eb19 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -50,6 +50,9 @@ config SND_SOC_QDSP6_COMMON
 config SND_SOC_QDSP6_AFE
tristate
 
+config SND_SOC_QDSP6_AFE_DAI
+   tristate
+
 config SND_SOC_QDSP6_ADM
tristate
 
@@ -67,6 +70,7 @@ config SND_SOC_QDSP6
depends on QCOM_APR && HAS_DMA
select SND_SOC_QDSP6_COMMON
select SND_SOC_QDSP6_AFE
+   select SND_SOC_QDSP6_AFE_DAI
select SND_SOC_QDSP6_ADM
select SND_SOC_QDSP6_ROUTING
select SND_SOC_QDSP6_ASM
diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile
index 6640bceccc18..6a8ae698f22f 100644
--- a/sound/soc/qcom/qdsp6/Makefile
+++ b/sound/soc/qcom/qdsp6/Makefile
@@ -1,5 +1,6 @@
 obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o
 obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o
+obj-$(CONFIG_SND_SOC_QDSP6_AFE_DAI) += q6afe-dai.o
 obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o
 obj-$(CONFIG_SND_SOC_QDSP6_ROUTING) += q6routing.o
 obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o
diff --git a/sound/soc/qcom/qdsp6/q6afe-dai.c b/sound/soc/qcom/qdsp6/q6afe-dai.c
new file mode 100644
index ..0db368488cab
--- /dev/null
+++ b/sound/soc/qcom/qdsp6/q6afe-dai.c
@@ -0,0 +1,752 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2011-2016, The Linux Foundation
+// Copyright (c) 2018, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "q6afe.h"
+
+struct q6afe_dai_priv_data {
+   uint32_t sd_line_mask;
+};
+
+struct q6afe_dai_data {
+   struct q6afe_port *port[AFE_PORT_MAX];
+   struct q6afe_port_config port_config[AFE_PORT_MAX];
+   bool is_port_started[AFE_PORT_MAX];
+   struct q6afe_dai_priv_data priv[AFE_PORT_MAX];
+};
+
+static int q6slim_hw_params(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params,
+   struct snd_soc_dai *dai)
+{
+
+   struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
+   struct q6afe_slim_cfg *slim = _data->port_config[dai->id].slim;
+
+   slim->num_channels = params_channels(params);
+   slim->sample_rate = params_rate(params);
+
+   switch (params_format(params)) {
+   case SNDRV_PCM_FORMAT_S16_LE:
+   case SNDRV_PCM_FORMAT_SPECIAL:
+   slim->bit_width = 16;
+   break;
+   case SNDRV_PCM_FORMAT_S24_LE:
+   slim->bit_width = 24;
+   break;
+   case SNDRV_PCM_FORMAT_S32_LE:
+   slim->bit_width = 32;
+   break;
+   default:
+   pr_err("%s: format %d\n",
+   __func__, params_format(params));
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int q6hdmi_hw_params(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params,
+   struct snd_soc_dai *dai)
+{
+   struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
+   int channels = params_channels(params);
+   struct q6afe_hdmi_cfg *hdmi = _data->port_config[dai->id].hdmi;
+
+   hdmi->sample_rate = params_rate(params);
+   switch (params_format(params)) {
+   case SNDRV_PCM_FORMAT_S16_LE:
+   hdmi->bit_width = 16;
+   break;
+   case SNDRV_PCM_FORMAT_S24_LE:
+   hdmi->bit_width = 24;
+   break;
+   }
+
+   /* HDMI spec CEA-861-E: Table 28 Audio InfoFrame Data Byte 4 */
+   switch (channels) {
+   case 2:
+   hdmi->channel_allocation = 0;
+   break;
+   case 3:
+   hdmi->channel_allocation = 0x02;
+   break;
+   case 4:
+   hdmi->channel_allocation = 0x06;
+   break;
+   case 5:
+   hdmi->channel_allocation = 0x0A;
+   break;
+   case 6:
+   hdmi->channel_allocation = 0x0B;
+   break;
+   case 7:
+   hdmi->channel_allocation = 0x12;
+   break;
+   case 8:
+   hdmi->channel_allocation = 0x13;
+   break;
+   default:
+   dev_err(dai->dev, "invalid Channels = %u\n", channels);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int q6i2s_hw_params(struct snd_pcm_substream 

[PATCH v5 21/23] ASoC: qdsp6: dt-bindings: Add apq8096 machine bindings

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

Add devicetree bindings documentation file for Qualcomm apq8096 sound card.

Signed-off-by: Srinivas Kandagatla 
---
 .../devicetree/bindings/sound/qcom,apq8096.txt | 76 ++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,apq8096.txt

diff --git a/Documentation/devicetree/bindings/sound/qcom,apq8096.txt 
b/Documentation/devicetree/bindings/sound/qcom,apq8096.txt
new file mode 100644
index ..37e23d926b95
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/qcom,apq8096.txt
@@ -0,0 +1,76 @@
+* Qualcomm Technologies APQ8096 ASoC sound card driver
+
+This binding describes the APQ8096 sound card, which uses qdsp for audio.
+
+- compatible:
+   Usage: required
+   Value type: 
+   Definition: must be "qcom,apq8096-sndcard"
+
+- qcom,audio-routing:
+   Usage: Optional
+   Value type: 
+   Definition:  A list of the connections between audio components.
+ Each entry is a pair of strings, the first being the
+ connection's sink, the second being the connection's
+ source. Valid names could be power supplies, MicBias
+ of codec and the jacks on the board:
+
+= dailinks
+Each subnode of sndcard represents either a dailink, and subnodes of each
+dailinks would be cpu/codec/platform dais.
+
+- link-name:
+   Usage: required
+   Value type: 
+   Definition: User friendly name for dai link
+
+= CPU, PLATFORM, CODEC dais subnodes
+- cpu:
+   Usage: required
+   Value type: 
+   Definition: cpu dai sub-node
+
+- codec:
+   Usage: Optional
+   Value type: 
+   Definition: codec dai sub-node
+
+- platform:
+   Usage: Optional
+   Value type: 
+   Definition: platform dai sub-node
+
+- sound-dai:
+   Usage: required
+   Value type: 
+   Definition: dai phandle/s and port of CPU/CODEC/PLATFORM node.
+
+Example:
+
+audio {
+   compatible = "qcom,apq8096-sndcard";
+   qcom,model = "DB820c";
+
+   mm1-dai-link {
+   link-name = "MultiMedia1";
+   cpu {
+   sound-dai = < MSM_FRONTEND_DAI_MULTIMEDIA1>;
+   };
+   };
+
+   hdmi-dai-link {
+   link-name = "HDMI Playback";
+   cpu {
+   sound-dai = < HDMI_RX>;
+   };
+
+   platform {
+   sound-dai = <>;
+   };
+
+   codec {
+   sound-dai = < 0>;
+   };
+   };
+};
-- 
2.16.2



[PATCH v5 08/23] ASoC: qdsp6: qdafe: Add SLIMBus port Support

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to 6 SLIMBus AFE ports, which are used as
backend dais.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/qdsp6/q6afe.c | 129 +++
 sound/soc/qcom/qdsp6/q6afe.h |  14 +
 2 files changed, 143 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index ec328fa7dd1e..27c1055ac791 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -26,9 +26,45 @@
 #define AFE_PARAM_ID_HDMI_CONFIG   0x00010210
 #define AFE_MODULE_AUDIO_DEV_INTERFACE 0x0001020C
 
+#define AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG 0x00010235
+
+#define AFE_PARAM_ID_SLIMBUS_CONFIG0x00010212
+
 /* Port IDs */
 #define AFE_API_VERSION_HDMI_CONFIG0x1
 #define AFE_PORT_ID_MULTICHAN_HDMI_RX  0x100E
+
+#define AFE_API_VERSION_SLIMBUS_CONFIG 0x1
+
+/* SLIMbus Rx port on channel 0. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_RX  0x4000
+/* SLIMbus Tx port on channel 0. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_TX  0x4001
+/* SLIMbus Rx port on channel 1. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_RX  0x4002
+/* SLIMbus Tx port on channel 1. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_TX  0x4003
+/* SLIMbus Rx port on channel 2. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_RX  0x4004
+/* SLIMbus Tx port on channel 2. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_TX  0x4005
+/* SLIMbus Rx port on channel 3. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_RX  0x4006
+/* SLIMbus Tx port on channel 3. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_TX  0x4007
+/* SLIMbus Rx port on channel 4. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_RX  0x4008
+/* SLIMbus Tx port on channel 4. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_TX  0x4009
+/* SLIMbus Rx port on channel 5. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_RX  0x400a
+/* SLIMbus Tx port on channel 5. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_TX  0x400b
+/* SLIMbus Rx port on channel 6. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX  0x400c
+/* SLIMbus Tx port on channel 6. */
+#define AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_TX  0x400d
+
 #define TIMEOUT_MS 1000
 #define AFE_CMD_RESP_AVAIL 0
 #define AFE_CMD_RESP_NONE  1
@@ -81,8 +117,53 @@ struct afe_param_id_hdmi_multi_chan_audio_cfg {
u16 reserved;
 } __packed;
 
+struct afe_param_id_slimbus_cfg {
+   u32  sb_cfg_minor_version;
+/* Minor version used for tracking the version of the SLIMBUS
+ * configuration interface.
+ * Supported values: #AFE_API_VERSION_SLIMBUS_CONFIG
+ */
+
+   u16  slimbus_dev_id;
+/* SLIMbus hardware device ID, which is required to handle
+ * multiple SLIMbus hardware blocks.
+ * Supported values: - #AFE_SLIMBUS_DEVICE_1 - #AFE_SLIMBUS_DEVICE_2
+ */
+   u16  bit_width;
+/* Bit width of the sample.
+ * Supported values: 16, 24
+ */
+   u16  data_format;
+/* Data format supported by the SLIMbus hardware. The default is
+ * 0 (#AFE_SB_DATA_FORMAT_NOT_INDICATED), which indicates the
+ * hardware does not perform any format conversions before the data
+ * transfer.
+ */
+   u16  num_channels;
+/* Number of channels.
+ * Supported values: 1 to #AFE_PORT_MAX_AUDIO_CHAN_CNT
+ */
+   u8  shared_ch_mapping[AFE_PORT_MAX_AUDIO_CHAN_CNT];
+/* Mapping of shared channel IDs (128 to 255) to which the
+ * master port is to be connected.
+ * Shared_channel_mapping[i] represents the shared channel assigned
+ * for audio channel i in multichannel audio data.
+ */
+   u32  sample_rate;
+/* Sampling rate of the port.
+ * Supported values:
+ * - #AFE_PORT_SAMPLE_RATE_8K
+ * - #AFE_PORT_SAMPLE_RATE_16K
+ * - #AFE_PORT_SAMPLE_RATE_48K
+ * - #AFE_PORT_SAMPLE_RATE_96K
+ * - #AFE_PORT_SAMPLE_RATE_192K
+ */
+} __packed;
+
+
 union afe_port_config {
struct afe_param_id_hdmi_multi_chan_audio_cfg hdmi_multi_ch;
+   struct afe_param_id_slimbus_cfg   slim_cfg;
 } __packed;
 
 struct q6afe_port {
@@ -117,6 +198,20 @@ struct afe_port_map {
 
 static struct afe_port_map port_maps[AFE_PORT_MAX] = {
[HDMI_RX] = { AFE_PORT_ID_MULTICHAN_HDMI_RX, HDMI_RX, 1, 1},
+   [SLIMBUS_0_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_RX,
+   SLIMBUS_0_RX, 1, 1},
+   [SLIMBUS_1_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_RX,
+   SLIMBUS_1_RX, 1, 1},
+   [SLIMBUS_2_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_RX,
+   SLIMBUS_2_RX, 1, 1},
+   [SLIMBUS_3_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_RX,
+   SLIMBUS_3_RX, 1, 1},
+   [SLIMBUS_4_RX] = { AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_RX,
+   SLIMBUS_4_RX, 1, 1},
+   [SLIMBUS_5_RX] = { 

[PATCH v5 14/23] ASoC: qdsp6: q6asm: Add support to audio stream apis

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to open, write and media format commands
in the q6asm module.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/qdsp6/q6asm.c | 744 ++-
 sound/soc/qcom/qdsp6/q6asm.h |  49 +++
 2 files changed, 792 insertions(+), 1 deletion(-)

diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c
index 51a5681dd61f..7f10d5f3c58b 100644
--- a/sound/soc/qcom/qdsp6/q6asm.c
+++ b/sound/soc/qcom/qdsp6/q6asm.c
@@ -9,6 +9,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -17,10 +19,36 @@
 #include "q6dsp-errno.h"
 #include "q6dsp-common.h"
 
+#define ASM_STREAM_CMD_CLOSE   0x00010BCD
+#define ASM_STREAM_CMD_FLUSH   0x00010BCE
+#define ASM_SESSION_CMD_PAUSE  0x00010BD3
+#define ASM_DATA_CMD_EOS   0x00010BDB
+#define ASM_NULL_POPP_TOPOLOGY 0x00010C68
+#define ASM_STREAM_CMD_FLUSH_READBUFS  0x00010C09
+#define ASM_STREAM_CMD_SET_ENCDEC_PARAM0x00010C10
+#define ASM_STREAM_POSTPROC_TOPO_ID_NONE   0x00010C68
 #define ASM_CMD_SHARED_MEM_MAP_REGIONS 0x00010D92
 #define ASM_CMDRSP_SHARED_MEM_MAP_REGIONS  0x00010D93
 #define ASM_CMD_SHARED_MEM_UNMAP_REGIONS   0x00010D94
-
+#define ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2   0x00010D98
+#define ASM_DATA_EVENT_WRITE_DONE_V2   0x00010D99
+#define ASM_PARAM_ID_ENCDEC_ENC_CFG_BLK_V2 0x00010DA3
+#define ASM_SESSION_CMD_RUN_V2 0x00010DAA
+#define ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2 0x00010DA5
+#define ASM_DATA_CMD_WRITE_V2  0x00010DAB
+#define ASM_DATA_CMD_READ_V2   0x00010DAC
+#define ASM_SESSION_CMD_SUSPEND0x00010DEC
+#define ASM_STREAM_CMD_OPEN_WRITE_V3   0x00010DB3
+#define ASM_STREAM_CMD_OPEN_READ_V3 0x00010DB4
+#define ASM_DATA_EVENT_READ_DONE_V2 0x00010D9A
+#define ASM_STREAM_CMD_OPEN_READWRITE_V20x00010D8D
+
+
+#define ASM_LEGACY_STREAM_SESSION  0
+/* Bit shift for the stream_perf_mode subfield. */
+#define ASM_SHIFT_STREAM_PERF_MODE_FLAG_IN_OPEN_READ  29
+#define ASM_END_POINT_DEVICE_MATRIX0
+#define ASM_DEFAULT_APP_TYPE   0
 #define ASM_SYNC_IO_MODE   0x0001
 #define ASM_ASYNC_IO_MODE  0x0002
 #define ASM_TUN_READ_IO_MODE   0x0004  /* tunnel read write mode */
@@ -46,6 +74,96 @@ struct avs_cmd_shared_mem_unmap_regions {
u32 mem_map_handle;
 } __packed;
 
+struct asm_data_cmd_media_fmt_update_v2 {
+   u32 fmt_blk_size;
+} __packed;
+
+struct asm_multi_channel_pcm_fmt_blk_v2 {
+   struct apr_hdr hdr;
+   struct asm_data_cmd_media_fmt_update_v2 fmt_blk;
+   u16 num_channels;
+   u16 bits_per_sample;
+   u32 sample_rate;
+   u16 is_signed;
+   u16 reserved;
+   u8 channel_mapping[PCM_FORMAT_MAX_NUM_CHANNEL];
+} __packed;
+
+struct asm_stream_cmd_set_encdec_param {
+   u32  param_id;
+   u32  param_size;
+} __packed;
+
+struct asm_enc_cfg_blk_param_v2 {
+   u32  frames_per_buf;
+   u32  enc_cfg_blk_size;
+} __packed;
+
+struct asm_multi_channel_pcm_enc_cfg_v2 {
+   struct apr_hdr hdr;
+   struct asm_stream_cmd_set_encdec_param  encdec;
+   struct asm_enc_cfg_blk_param_v2 encblk;
+   uint16_t  num_channels;
+   uint16_t  bits_per_sample;
+   uint32_t  sample_rate;
+   uint16_t  is_signed;
+   uint16_t  reserved;
+   uint8_t   channel_mapping[8];
+} __packed;
+
+struct asm_data_cmd_read_v2 {
+   struct apr_hdr   hdr;
+   u32  buf_addr_lsw;
+   u32  buf_addr_msw;
+   u32  mem_map_handle;
+   u32  buf_size;
+   u32  seq_id;
+} __packed;
+
+struct asm_data_cmd_read_v2_done {
+   u32 status;
+   u32 buf_addr_lsw;
+   u32 buf_addr_msw;
+};
+
+struct asm_stream_cmd_open_read_v3 {
+   struct apr_hdr hdr;
+   u32mode_flags;
+   u32src_endpointype;
+   u32preprocopo_id;
+   u32enc_cfg_id;
+   u16bits_per_sample;
+   u16reserved;
+} __packed;
+
+struct asm_data_cmd_write_v2 {
+   struct apr_hdr hdr;
+   u32 buf_addr_lsw;
+   u32 buf_addr_msw;
+   u32 mem_map_handle;
+   u32 buf_size;
+   u32 seq_id;
+   u32 timestamp_lsw;
+   u32 timestamp_msw;
+   u32 flags;
+} __packed;
+
+struct asm_stream_cmd_open_write_v3 {
+   struct apr_hdr hdr;
+   uint32_t mode_flags;
+   uint16_t sink_endpointype;
+   uint16_t bits_per_sample;
+   uint32_t 

[PATCH v5 16/23] ASoC: qdsp6: q6routing: Add q6routing driver

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to q6 routing driver which configures route
between ASM and AFE module using ADM apis.

This driver uses dapm widgets to setup the matrix between AFE ports and
ASM streams.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/Kconfig   |   4 +
 sound/soc/qcom/qdsp6/Makefile|   1 +
 sound/soc/qcom/qdsp6/q6routing.c | 392 +++
 sound/soc/qcom/qdsp6/q6routing.h |   9 +
 4 files changed, 406 insertions(+)
 create mode 100644 sound/soc/qcom/qdsp6/q6routing.c
 create mode 100644 sound/soc/qcom/qdsp6/q6routing.h

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index 488ee93ee084..7a868a6fac1b 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -53,6 +53,9 @@ config SND_SOC_QDSP6_AFE
 config SND_SOC_QDSP6_ADM
tristate
 
+config SND_SOC_QDSP6_ROUTING
+   tristate
+
 config SND_SOC_QDSP6_ASM
tristate
 
@@ -65,6 +68,7 @@ config SND_SOC_QDSP6
select SND_SOC_QDSP6_COMMON
select SND_SOC_QDSP6_AFE
select SND_SOC_QDSP6_ADM
+   select SND_SOC_QDSP6_ROUTING
select SND_SOC_QDSP6_ASM
select SND_SOC_QDSP6_CORE
help
diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile
index 61f089bc0d25..6640bceccc18 100644
--- a/sound/soc/qcom/qdsp6/Makefile
+++ b/sound/soc/qcom/qdsp6/Makefile
@@ -1,5 +1,6 @@
 obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o
 obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o
 obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o
+obj-$(CONFIG_SND_SOC_QDSP6_ROUTING) += q6routing.o
 obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o
 obj-$(CONFIG_SND_SOC_QDSP6_CORE) += q6core.o
diff --git a/sound/soc/qcom/qdsp6/q6routing.c b/sound/soc/qcom/qdsp6/q6routing.c
new file mode 100644
index ..b72bd9045fea
--- /dev/null
+++ b/sound/soc/qcom/qdsp6/q6routing.c
@@ -0,0 +1,392 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2011-2017, The Linux Foundation
+// Copyright (c) 2018, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "q6afe.h"
+#include "q6asm.h"
+#include "q6adm.h"
+#include "q6routing.h"
+
+struct session_data {
+   int state;
+   int port_id;
+   int path_type;
+   int app_type;
+   int acdb_id;
+   int sample_rate;
+   int bits_per_sample;
+   int channels;
+   int perf_mode;
+   int numcopps;
+   int fedai_id;
+   unsigned long copp_map;
+};
+
+struct msm_routing_data {
+   struct session_data sessions[MAX_SESSIONS];
+   struct session_data port_data[AFE_MAX_PORTS];
+   struct device *dev;
+   struct mutex lock;
+};
+
+static struct msm_routing_data *routing_data;
+
+/**
+ * q6routing_stream_open() - Register a new stream for route setup
+ *
+ * @fedai_id: Frontend dai id.
+ * @perf_mode: Performance mode.
+ * @stream_id: ASM stream id to map.
+ * @stream_type: Direction of stream
+ *
+ * Return: Will be an negative on error or a zero on success.
+ */
+int q6routing_stream_open(int fedai_id, int perf_mode,
+  int stream_id, int stream_type)
+{
+   int j, topology, num_copps = 0;
+   struct route_payload payload;
+   int copp_idx;
+   struct session_data *session, *pdata;
+
+   if (!routing_data) {
+   pr_err("Routing driver not yet ready\n");
+   return -EINVAL;
+   }
+
+   session = _data->sessions[stream_id - 1];
+   pdata = _data->port_data[session->port_id];
+
+   mutex_lock(_data->lock);
+   session->fedai_id = fedai_id;
+
+   session->path_type = pdata->path_type;
+   session->sample_rate = pdata->sample_rate;
+   session->channels = pdata->channels;
+   session->bits_per_sample = pdata->bits_per_sample;
+
+   payload.num_copps = 0; /* only RX needs to use payload */
+   topology = NULL_COPP_TOPOLOGY;
+   copp_idx = q6adm_open(routing_data->dev, session->port_id,
+ session->path_type, session->sample_rate,
+ session->channels, topology, perf_mode,
+ session->bits_per_sample, 0, 0);
+
+   if (copp_idx < 0) {
+   mutex_unlock(_data->lock);
+   return -EINVAL;
+   }
+
+   set_bit(copp_idx, >copp_map);
+
+   for_each_set_bit(j, >copp_map, MAX_COPPS_PER_PORT) {
+   payload.port_id[num_copps] = session->port_id;
+   payload.copp_idx[num_copps] = j;
+   num_copps++;
+   }
+
+   if (num_copps) {
+   payload.num_copps = num_copps;
+   payload.session_id = stream_id;
+   q6adm_matrix_map(routing_data->dev, session->path_type,
+   

Re: [PATCH 4.16 00/68] 4.16.3-stable review

2018-04-18 Thread Guenter Roeck
On Tue, Apr 17, 2018 at 05:57:13PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.16.3 release.
> There are 68 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu Apr 19 15:57:33 UTC 2018.
> Anything received after that time might be too late.
> 

Build results:
total: 142 pass: 142 fail: 0
Qemu test results:
total: 139 pass: 139 fail: 0

Details are available at http://kerneltests.org/builders.

Guenter


Re: PATCH V4 0/5 nvme-pci: fixes on nvme_timeout and nvme_dev_disable

2018-04-18 Thread Ming Lei
On Wed, Apr 18, 2018 at 10:24:28PM +0800, jianchao.wang wrote:
> Hi Ming
> 
> On 04/17/2018 11:17 PM, Ming Lei wrote:
> > Looks blktest(block/011) can trigger IO hang easily on NVMe PCI device,
> > and all are related with nvme_dev_disable():
> > 
> > 1) admin queue may be disabled by nvme_dev_disable() from timeout path
> > during resetting, then reset can't move on
> > 
> > 2) the nvme_dev_disable() called from nvme_reset_work() may cause double
> > completion on timed-out request 
> > 
> > So could you share us what your plan is about this patchset?
> 
> Regarding to this patchset, it is mainly to fix the dependency between
> nvme_timeout and nvme_dev_disable, as your can see:
> nvme_timeout will invoke nvme_dev_disable, and nvme_dev_disable have to
> depend on nvme_timeout when controller no response.

Do you mean nvme_disable_io_queues()? If yes, this one has been handled
by wait_for_completion_io_timeout() already, and looks the block timeout
can be disabled simply. Or are there others?

> Till now, some parts
> of the patchset looks bad and seem to have a lot of work need to be done.
> :)

Yeah, this part is much more complicated than I thought.

I think it is a good topic to discuss in the coming LSF/MM, and the NVMe
timeout(EH) may need to be refactored/cleaned up, and current issues
should be addressed in clean way.

Guys, are there other issues wrt. NVMe timeout & reset except for the
above?

Thanks,
Ming


Re: [PATCH v5 01/10] bindings: PCI: designware: Example update

2018-04-18 Thread Rob Herring
On Tue, Apr 17, 2018 at 9:34 AM, Gustavo Pimentel
 wrote:
> Replaces "ctrlreg" reg-name by "dbi" to be coherent with similar drivers,
> however it still be compatible with any previous DT that uses the old
> reg-name.
>
> Replaces the PCIe base address example by a real PCIe base address in use.
>
> Signed-off-by: Gustavo Pimentel 
> ---
> Changes v1->v2:
>  - Removed any iATU reference or changes to avoid confusion.
>  - Add "snps,dw-pcie" compatible string following Kishon's suggestion.
> Changes v2->v3:
>  - Nothing changed, just to follow the patch set version.
> Changes v3->v4:
>  - Reverted "snps,dw-pcie-rc" compatible string requested by Rob Herring.
> Changes v4->v5:
>  - Nothing changed, just to follow the patch set version.
>
>  Documentation/devicetree/bindings/pci/designware-pcie.txt | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)

Reviewed-by: Rob Herring 


[PATCH v2] serial: imx: warn user when using unsupported configuration

2018-04-18 Thread Stefan Agner
When using half-duplex mode (which disables receiver during txing)
the RTS signal cannot be driven low during transmission. This seems
to be a limitation of the i.MX UART IP: The RTS (CTS_B) signal is
controlled by the receiver. When the receiver is disabled, the
signal stays in UART logic idle state which is high...

If SER_RS485_RTS_ON_SEND is used, RTS needs to be high active during
transmission. Since this is the default state of the RTS (CTS_B)
signal when the receiver is off, half-duplex mode in this
configuration works fine.

However, a low-active RTS signal (flag SER_RS485_RTS_ON_SEND not set)
cannot be generated when the receiver is turned off.

Print an error if the user selects this unsupported configuration
(both SER_RS485_RTS_ON_SEND and SER_RS485_RX_DURING_TX unset) and
configure the closest working configuration (set the
SER_RS485_RX_DURING_TX flag).

Signed-off-by: Stefan Agner 
---
Changes since v1:
- Consistently check for sport->have_rtscts && !(rs485conf->flags &
  SER_RS485_RTS_ON_SEND)
- Don't break printed message

 drivers/tty/serial/imx.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 91f3a1a5cb7f..1c1080fc8084 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1833,6 +1833,11 @@ static int imx_uart_rs485_config(struct uart_port *port,
rs485conf->flags &= ~SER_RS485_ENABLED;
 
if (rs485conf->flags & SER_RS485_ENABLED) {
+   /* Enable receiver if low-active RTS signal is requested */
+   if (sport->have_rtscts &&
+   !(rs485conf->flags & SER_RS485_RTS_ON_SEND))
+   rs485conf->flags |= SER_RS485_RX_DURING_TX;
+
/* disable transmitter */
ucr2 = imx_uart_readl(sport, UCR2);
if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND)
@@ -2265,6 +2270,16 @@ static int imx_uart_probe(struct platform_device *pdev)
(!sport->have_rtscts && !sport->have_rtsgpio))
dev_err(>dev, "no RTS control, disabling rs485\n");
 
+   /*
+* The RTS (CTS_B) signal cannot be set low during transmission
+* in case the receiver is off (limitation of the i.MX UART IP).
+*/
+   if (sport->port.rs485.flags & SER_RS485_ENABLED && sport->have_rtscts &&
+   (!(sport->port.rs485.flags & SER_RS485_RTS_ON_SEND) &&
+!(sport->port.rs485.flags & SER_RS485_RX_DURING_TX)))
+   dev_err(>dev,
+   "low-active RTS not possible when receiver is off, 
enabling receiver\n");
+
imx_uart_rs485_config(>port, >port.rs485);
 
/* Disable interrupts before requesting them */
-- 
2.17.0



Re: [PATCH v2] perf list: Add s390 support for detailed/verbose pmu event description

2018-04-18 Thread Thomas-Mich Richter
On 04/16/2018 04:43 PM, Mark Rutland wrote:
> On Mon, Apr 16, 2018 at 03:23:14PM +0200, Thomas Richter wrote:
>> From: Thomas Richter 
>>
>> Perf list with flags -d and -v print a description (-d) or
>> a very verbose explanation (-v) of CPU specific counter events.
>> These descriptions are provided with the json files in
>> directory pmu-events/arch/s390/*.json.
>>
>> Display of these descriptions on s390 requires the
>> corresponding json files.
>>
>> On s390 this does not work because function is_pmu_core()
>> does not detect the s390 directory name where the
>> CPU specific events are listed. On x86 it is
>>   /sys/bus/event_source/devices/cpu
>> whereas on s390 it is
>>   /sys/bus/event_source/devices/cpum_cf
>>   /sys/bus/event_source/devices/cpum_sf
>>
>> Fix this by adding s390 directory name testing to
>> function is_pmu_core(). This is the same approach as taken for
>> arm platform.
> 
>> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
>> index d5bf15ca..8675ddf558c6 100644
>> --- a/tools/perf/util/pmu.c
>> +++ b/tools/perf/util/pmu.c
>> @@ -562,6 +562,12 @@ static int is_pmu_core(const char *name)
>>  if (stat(path, ) == 0)
>>  return 1;
>>  
>> +/* Look for cpu sysfs (specific to s390) */
>> +scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s",
>> +  sysfs, name);
>> +if (stat(path, ) == 0 && !strncmp(name, "cpum_", 5))
>> +return 1;
>> +
> 
> This shouldn't adversely affect ARM, so FWIW:
> 
> Acked-by: Mark Rutland 
> 

Arnaldo,

with Mark Acked-by can you please apply the patch.

Thanks a lot.
-- 
Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany
--
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 
243294



[PATCH] can: dev: increase bus-off message severity

2018-04-18 Thread Jakob Unterwurzacher
bus-off is usually caused by hardware malfunction or
configuration error (baud rate mismatch) and causes a
complete loss of communication.

Increase the "bus-off" message's severity from netdev_dbg
to netdev_info to make it visible to the user.

A can interface going into bus-off is similar in severity to
ethernet's "Link is Down" message, which is also printed
at info level.

It is debatable whether the the "restarted" message should
also be changed to netdev_info to make the interface state
changes comprehensible from the kernel log.
I have chosen to keep the "restarted" message at dbg for now
as the "bus-off" message should be enough for the user to
notice and investigate the problem.

Signed-off-by: Jakob Unterwurzacher 
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/can/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index b1779566c5bb..3c71f1cb205f 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -605,7 +605,7 @@ void can_bus_off(struct net_device *dev)
 {
struct can_priv *priv = netdev_priv(dev);
 
-   netdev_dbg(dev, "bus-off\n");
+   netdev_info(dev, "bus-off\n");
 
netif_carrier_off(dev);
 
-- 
2.11.0



Re: [PATCH v2 01/12] mm: Assign id to every memcg-aware shrinker

2018-04-18 Thread Kirill Tkhai
On 18.04.2018 17:14, Tetsuo Handa wrote:
> Kirill Tkhai wrote:
>> The patch introduces shrinker::id number, which is used to enumerate
>> memcg-aware shrinkers. The number start from 0, and the code tries
>> to maintain it as small as possible.
>>
>> This will be used as to represent a memcg-aware shrinkers in memcg
>> shrinkers map.
> 
> I'm not reading this thread. But is there reason "id" needs to be managed
> using smallest numbers? Can't we use address of shrinker object as "id"
> (which will be sparse bitmap, and would be managed using linked list for now)?

Yes, it's needed to have the smallest numbers, as next patches introduce
per-memcg bitmap containing ids of shrinkers.

Kirill


Re: [PATCH v2] tracing/x86: Update syscall trace events to handle new x86 syscall func names

2018-04-18 Thread Steven Rostedt
On Wed, 18 Apr 2018 09:53:22 -0300
Arnaldo Carvalho de Melo  wrote:

> Em Tue, Apr 17, 2018 at 05:41:28PM -0400, Steven Rostedt escreveu:
> > On Tue, 17 Apr 2018 15:13:04 -0300 Arnaldo Carvalho de Melo 
> >  wrote:  
> > > Yeah, failing:  
> 
> > > [root@jouet ~]# strace -e openat -e file perf test -F -v "mmap interface" 
> > > |& grep syscalls
> > > openat(AT_FDCWD, 
> > > "/sys/kernel/debug/tracing/events/syscalls/sys_enter_getsid/format", 
> > > O_RDONLY) = 3
> > > openat(AT_FDCWD, 
> > > "/sys/kernel/debug/tracing/events/syscalls/sys_enter_getppid/format", 
> > > O_RDONLY) = -1 ENOENT (No such file or directory)  
>  
> > It doesn't have to do with the number of parameters, not everything
> > has "__x64" on it.  
>  
> > Try this patch:  
> 
> Trying...

You're keeping me in suspense!

-- Steve


[PATCH v6 2/9] PCI: dwc: Add support for endpoint mode

2018-04-18 Thread Gustavo Pimentel
The PCIe controller dual mode is capable of operating in host mode as well
as endpoint mode by configuration, therefore this patch aims to add
endpoint mode support to the designware driver.

Signed-off-by: Gustavo Pimentel 
Acked-by: Kishon Vijay Abraham I 
---
Change v1->v2:
 - Removed dw_plat_pcie_stop_link empty function.
 - Implemented Kishon's suggestions about dw-pcie-rc and dw-pcie strings.
compatibility.
 - Added second entry on pci_epf_test_ids structure.
Changes v2->v3:
 - Reverted additions in dw_pcie_ep_linkup function.
 - Replaced devm_ioremap by devm_ioremap_resource function.
 - Moved second entry in pci_epf_test_ids structure into a new patch file.
Changes v3->v4:
 - Reverted "snps,dw-pcie-rc" compatible string requested by Rob Herring.
Changes v4->v5:
 - Nothing changed, just to follow the patch set version.
Changes v5->v6:
 - Removed PCIE_DW_PLAT entry helps and description in order to be hidden.

 drivers/pci/dwc/Kconfig|  41 ++---
 drivers/pci/dwc/pcie-designware-plat.c | 149 ++---
 2 files changed, 169 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/dwc/Kconfig b/drivers/pci/dwc/Kconfig
index 2f3f5c5..62f7cdf 100644
--- a/drivers/pci/dwc/Kconfig
+++ b/drivers/pci/dwc/Kconfig
@@ -7,8 +7,7 @@ config PCIE_DW
 
 config PCIE_DW_HOST
 bool
-   depends on PCI
-   depends on PCI_MSI_IRQ_DOMAIN
+   depends on PCI && PCI_MSI_IRQ_DOMAIN
 select PCIE_DW
 
 config PCIE_DW_EP
@@ -51,17 +50,37 @@ config PCI_DRA7XX_EP
  This uses the DesignWare core.
 
 config PCIE_DW_PLAT
-   bool "Platform bus based DesignWare PCIe Controller"
-   depends on PCI
-   depends on PCI_MSI_IRQ_DOMAIN
-   select PCIE_DW_HOST
-   ---help---
-This selects the DesignWare PCIe controller support. Select this if
-you have a PCIe controller on Platform bus.
+   bool
 
-If you have a controller with this interface, say Y or M here.
+config PCIE_DW_PLAT_HOST
+   bool "Platform bus based DesignWare PCIe Controller - Host mode"
+   depends on PCI && PCI_MSI_IRQ_DOMAIN
+   select PCIE_DW_HOST
+   select PCIE_DW_PLAT
+   default y
+   help
+ Enables support for the PCIe controller in the Designware IP to
+ work in host mode. There are two instances of PCIe controller in
+ Designware IP.
+ This controller can work either as EP or RC. In order to enable
+ host-specific features PCIE_DW_PLAT_HOST must be selected and in
+ order to enable device-specific features PCI_DW_PLAT_EP must be
+ selected.
 
-If unsure, say N.
+config PCIE_DW_PLAT_EP
+   bool "Platform bus based DesignWare PCIe Controller - Endpoint mode"
+   depends on PCI && PCI_MSI_IRQ_DOMAIN
+   depends on PCI_ENDPOINT
+   select PCIE_DW_EP
+   select PCIE_DW_PLAT
+   help
+ Enables support for the PCIe controller in the Designware IP to
+ work in endpoint mode. There are two instances of PCIe controller
+ in Designware IP.
+ This controller can work either as EP or RC. In order to enable
+ host-specific features PCIE_DW_PLAT_HOST must be selected and in
+ order to enable device-specific features PCI_DW_PLAT_EP must be
+ selected.
 
 config PCI_EXYNOS
bool "Samsung Exynos PCIe controller"
diff --git a/drivers/pci/dwc/pcie-designware-plat.c 
b/drivers/pci/dwc/pcie-designware-plat.c
index 5416aa8..efc315c 100644
--- a/drivers/pci/dwc/pcie-designware-plat.c
+++ b/drivers/pci/dwc/pcie-designware-plat.c
@@ -12,19 +12,29 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "pcie-designware.h"
 
 struct dw_plat_pcie {
-   struct dw_pcie  *pci;
+   struct dw_pcie  *pci;
+   struct regmap   *regmap;
+   enum dw_pcie_device_modemode;
 };
 
+struct dw_plat_pcie_of_data {
+   enum dw_pcie_device_modemode;
+};
+
+static const struct of_device_id dw_plat_pcie_of_match[];
+
 static int dw_plat_pcie_host_init(struct pcie_port *pp)
 {
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
@@ -42,9 +52,53 @@ static const struct dw_pcie_host_ops dw_plat_pcie_host_ops = 
{
.host_init = dw_plat_pcie_host_init,
 };
 
-static int dw_plat_add_pcie_port(struct pcie_port *pp,
+static int dw_plat_pcie_establish_link(struct dw_pcie *pci)
+{
+   return 0;
+}
+
+static const struct dw_pcie_ops dw_pcie_ops = {
+   .start_link = dw_plat_pcie_establish_link,
+};
+
+static void dw_plat_pcie_ep_init(struct dw_pcie_ep *ep)
+{
+   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
+   enum pci_barno bar;
+
+   for (bar = BAR_0; bar <= BAR_5; bar++)
+   dw_pcie_ep_reset_bar(pci, bar);
+}
+
+static int dw_plat_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,
+

[PATCH v6 6/9] PCI: dwc: Define maximum number of vectors

2018-04-18 Thread Gustavo Pimentel
Adds a callback that defines the maximum number of vectors that can be use
by the Root Complex.

Since this is a parameter associated to each SoC IP setting, makes sense to
be configurable and easily visible to future modifications.

The designware IP supports a maximum of 256 vectors.

Signed-off-by: Gustavo Pimentel 
Acked-by: Joao Pinto 
---
Change v1->v2:
 - Nothing changed, just to follow the patch set version.
Change v2->v3:
 - Nothing changed, just to follow the patch set version.
Changes v3->v4:
 - Nothing changed, just to follow the patch set version.
Changes v4->v5:
 - Nothing changed, just to follow the patch set version.
Changes v5->v6:
 - Nothing changed, just to follow the patch set version.

 drivers/pci/dwc/pcie-designware-plat.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/pci/dwc/pcie-designware-plat.c 
b/drivers/pci/dwc/pcie-designware-plat.c
index efc315c..5937fed 100644
--- a/drivers/pci/dwc/pcie-designware-plat.c
+++ b/drivers/pci/dwc/pcie-designware-plat.c
@@ -48,8 +48,14 @@ static int dw_plat_pcie_host_init(struct pcie_port *pp)
return 0;
 }
 
+static void dw_plat_set_num_vectors(struct pcie_port *pp)
+{
+   pp->num_vectors = MAX_MSI_IRQS;
+}
+
 static const struct dw_pcie_host_ops dw_plat_pcie_host_ops = {
.host_init = dw_plat_pcie_host_init,
+   .set_num_vectors = dw_plat_set_num_vectors,
 };
 
 static int dw_plat_pcie_establish_link(struct dw_pcie *pci)
-- 
2.7.4




[PATCH v6 5/9] misc: pci_endpoint_test: Add designware EP entry

2018-04-18 Thread Gustavo Pimentel
Adds the designware EP device ID entry to pci_endpoint_test driver table
to allow this device to be recognize and handle by the pci_endpoint_test
driver.

Signed-off-by: Gustavo Pimentel 
Acked-by: Kishon Vijay Abraham I 
---
Change v1->v2:
 - Changed device id following Kishon's suggestion.
Change v2->v3:
 - Nothing changed, just to follow the patch set version.
Changes v3->v4:
 - Nothing changed, just to follow the patch set version.
Changes v4->v5:
 - Nothing changed, just to follow the patch set version.
Changes v5->v6:
 - Reverted Kishon's suggestion by Bjorn request.

 drivers/misc/pci_endpoint_test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index fe8897e..58a88ba 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -634,6 +634,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)
 static const struct pci_device_id pci_endpoint_test_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) },
{ PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) },
+   { PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 0xedda) },
{ }
 };
 MODULE_DEVICE_TABLE(pci, pci_endpoint_test_tbl);
-- 
2.7.4




[PATCH v6 8/9] PCI: dwc: Small computation improvement

2018-04-18 Thread Gustavo Pimentel
Replaces a simple division by 2 to a right shift rotation of 1 bit.

Probably any recent and decent compiler does this kind of substitution
in order to improve code performance. Nevertheless it's a coding good
practice whenever there is a division / multiplication by multiple of 2
to replace it by the equivalent operation in this case, the shift
rotation.

Signed-off-by: Gustavo Pimentel 
Acked-by: Jingoo Han 
Acked-by: Joao Pinto 
---
Change v1->v2:
 - Nothing changed, just to follow the patch set version.
Change v2->v3:
 - Nothing changed, just to follow the patch set version.
Changes v3->v4:
 - Added a small explication to the log description.
Changes v4->v5:
 - Nothing changed, just to follow the patch set version.
Changes v5->v6:
 - Nothing changed, just to follow the patch set version.

 drivers/pci/dwc/pcie-designware-host.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/dwc/pcie-designware-host.c 
b/drivers/pci/dwc/pcie-designware-host.c
index 5a23f78..fc55fde 100644
--- a/drivers/pci/dwc/pcie-designware-host.c
+++ b/drivers/pci/dwc/pcie-designware-host.c
@@ -332,8 +332,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
if (cfg_res) {
-   pp->cfg0_size = resource_size(cfg_res) / 2;
-   pp->cfg1_size = resource_size(cfg_res) / 2;
+   pp->cfg0_size = resource_size(cfg_res) >> 1;
+   pp->cfg1_size = resource_size(cfg_res) >> 1;
pp->cfg0_base = cfg_res->start;
pp->cfg1_base = cfg_res->start + pp->cfg0_size;
} else if (!pp->va_cfg0_base) {
@@ -377,8 +377,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
break;
case 0:
pp->cfg = win->res;
-   pp->cfg0_size = resource_size(pp->cfg) / 2;
-   pp->cfg1_size = resource_size(pp->cfg) / 2;
+   pp->cfg0_size = resource_size(pp->cfg) >> 1;
+   pp->cfg1_size = resource_size(pp->cfg) >> 1;
pp->cfg0_base = pp->cfg->start;
pp->cfg1_base = pp->cfg->start + pp->cfg0_size;
break;
-- 
2.7.4




[PATCH v3 1/5] clk: Extract OF clock helpers in

2018-04-18 Thread Geert Uytterhoeven
The use of of_clk_get_parent_{count,name}() and of_clk_init() is not
limited to clock providers.

Hence move these helpers into their own header file, so callers that are
not clock providers no longer have to include .

Suggested-by: Stephen Boyd 
Signed-off-by: Geert Uytterhoeven 
Reviewed-by: Heiko Stuebner 
---
v3:
  - Add Reviewed-by,
  - Add SPDX-License-Identifier,
  - Add to clock section in MAINTAINERS (note that Rob is still listed
as a maintainer, too, due to the include/linux/of*.h catch-all
rule),

v2:
  - New.
---
 MAINTAINERS  |  1 +
 include/linux/clk-provider.h | 14 +-
 include/linux/of_clk.h   | 30 ++
 3 files changed, 32 insertions(+), 13 deletions(-)
 create mode 100644 include/linux/of_clk.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 50927cba875771e8..abf08b50a85d969d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3556,6 +3556,7 @@ F:drivers/clk/
 X: drivers/clk/clkdev.c
 F: include/linux/clk-pr*
 F: include/linux/clk/
+F: include/linux/of_clk.h
 
 COMMON INTERNET FILE SYSTEM (CIFS)
 M: Steve French 
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 210a890008f9e129..61cb4729f22acd6b 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_COMMON_CLK
 
@@ -890,13 +891,10 @@ struct clk_hw *of_clk_hw_simple_get(struct 
of_phandle_args *clkspec,
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void 
*data);
 struct clk_hw *of_clk_hw_onecell_get(struct of_phandle_args *clkspec,
 void *data);
-unsigned int of_clk_get_parent_count(struct device_node *np);
 int of_clk_parent_fill(struct device_node *np, const char **parents,
   unsigned int size);
-const char *of_clk_get_parent_name(struct device_node *np, int index);
 int of_clk_detect_critical(struct device_node *np, int index,
unsigned long *flags);
-void of_clk_init(const struct of_device_id *matches);
 
 #else /* !CONFIG_OF */
 
@@ -943,26 +941,16 @@ of_clk_hw_onecell_get(struct of_phandle_args *clkspec, 
void *data)
 {
return ERR_PTR(-ENOENT);
 }
-static inline unsigned int of_clk_get_parent_count(struct device_node *np)
-{
-   return 0;
-}
 static inline int of_clk_parent_fill(struct device_node *np,
 const char **parents, unsigned int size)
 {
return 0;
 }
-static inline const char *of_clk_get_parent_name(struct device_node *np,
-int index)
-{
-   return NULL;
-}
 static inline int of_clk_detect_critical(struct device_node *np, int index,
  unsigned long *flags)
 {
return 0;
 }
-static inline void of_clk_init(const struct of_device_id *matches) {}
 #endif /* CONFIG_OF */
 
 /*
diff --git a/include/linux/of_clk.h b/include/linux/of_clk.h
new file mode 100644
index ..b27da9f164cbd221
--- /dev/null
+++ b/include/linux/of_clk.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * OF clock helpers
+ */
+
+#ifndef __LINUX_OF_CLK_H
+#define __LINUX_OF_CLK_H
+
+#if defined(CONFIG_COMMON_CLK) && defined(CONFIG_OF)
+
+unsigned int of_clk_get_parent_count(struct device_node *np);
+const char *of_clk_get_parent_name(struct device_node *np, int index);
+void of_clk_init(const struct of_device_id *matches);
+
+#else /* !CONFIG_COMMON_CLK || !CONFIG_OF */
+
+static inline unsigned int of_clk_get_parent_count(struct device_node *np)
+{
+   return 0;
+}
+static inline const char *of_clk_get_parent_name(struct device_node *np,
+int index)
+{
+   return NULL;
+}
+static inline void of_clk_init(const struct of_device_id *matches) {}
+
+#endif /* !CONFIG_COMMON_CLK || !CONFIG_OF */
+
+#endif /* __LINUX_OF_CLK_H */
-- 
2.7.4



Re: [PATCH 2/2] printk: wake up klogd in vprintk_emit

2018-04-18 Thread Steven Rostedt
On Wed, 18 Apr 2018 17:02:14 +0200
Petr Mladek  wrote:

> > Calling wake_up_klogd() will grab the rq lock and give us a A-B<->B-A
> > locking order.  
> 
> wake_up_klogd() uses the lockless irq_work_queue(). So it is actually
> safe.

I didn't look at the code. OK then we don't need to worry about that.

> 
> But the name is confusing. We should rename it.

Yes, I would because the old wake_up_klogd() did do a wakeup. Perhaps
we should name it: kick_klogd().

-- Steve


[PATCH net-next 2/2] netns: isolate seqnums to use per-netns locks

2018-04-18 Thread Christian Brauner
Now that it's possible to have a different set of uevents in different
network namespaces, per-network namespace uevent sequence numbers are
introduced. This increases performance as locking is now restricted to the
network namespace affected by the uevent rather than locking everything.

Since commit 692ec06 ("netns: send uevent messages") network namespaces not
owned by the intial user namespace can be sent uevents from a sufficiently
privileged userspace process.
In order to send a uevent into a network namespace not owned by the initial
user namespace we currently still need to take the *global mutex* that
locks the uevent socket list even though the list *only contains network
namespaces owned by the initial user namespace*. This needs to be done
because the uevent counter is a global variable. Taking the global lock is
performance sensitive since a user on the host can spawn a pool of n
process that each create their own new user and network namespaces and then
go on to inject uevents in parallel into the network namespace of all of
these processes. This can have a significant performance impact for the
host's udevd since it means that there can be a lot of delay between a
device being added and the corresponding uevent being sent out and
available for processing by udevd. It also means that each network
namespace not owned by the initial user namespace which userspace has sent
a uevent to will need to wait until the lock becomes available.

Implementation:
This patch gives each network namespace its own uevent sequence number.
Each network namespace not owned by the initial user namespace receives its
own mutex. The struct uevent_sock is opaque to callers outside of kobject.c
so the mutex *can* and *is* only ever accessed in lib/kobject.c. In this
file it is clearly documented which lock has to be taken. All network
namespaces owned by the initial user namespace will still share the same
lock since they are all served sequentially via the uevent socket list.
This decouples the locking and ensures that the host retrieves uevents as
fast as possible even if there are a lot of uevents injected into network
namespaces not owned by the initial user namespace.  In addition, each
network namespace not owned by the initial user namespace does not have to
wait on any other network namespace not sharing the same user namespace.

Signed-off-by: Christian Brauner 
---
 include/linux/kobject.h |   3 --
 include/net/net_namespace.h |   3 ++
 kernel/ksysfs.c |   3 +-
 lib/kobject_uevent.c| 100 
 net/core/net_namespace.c|  13 +
 5 files changed, 98 insertions(+), 24 deletions(-)

diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 7f6f93c3df9c..776391aea247 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -36,9 +36,6 @@
 extern char uevent_helper[];
 #endif
 
-/* counter to tag the uevent, read only except for the kobject core */
-extern u64 uevent_seqnum;
-
 /*
  * The actions here must match the index to the string array
  * in lib/kobject_uevent.c
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 47e35cce3b64..e4e171b1ba69 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -85,6 +85,8 @@ struct net {
struct sock *genl_sock;
 
struct uevent_sock  *uevent_sock;   /* uevent socket */
+   /* counter to tag the uevent, read only except for the kobject core */
+   u64 uevent_seqnum;
 
struct list_headdev_base_head;
struct hlist_head   *dev_name_head;
@@ -189,6 +191,7 @@ extern struct list_head net_namespace_list;
 
 struct net *get_net_ns_by_pid(pid_t pid);
 struct net *get_net_ns_by_fd(int fd);
+u64 get_ns_uevent_seqnum_by_vpid(void);
 
 #ifdef CONFIG_SYSCTL
 void ipx_register_sysctl(void);
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 46ba853656f6..83264edcecda 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include /* rcu_expedited and rcu_normal */
 
@@ -33,7 +34,7 @@ static struct kobj_attribute _name##_attr = \
 static ssize_t uevent_seqnum_show(struct kobject *kobj,
  struct kobj_attribute *attr, char *buf)
 {
-   return sprintf(buf, "%llu\n", (unsigned long long)uevent_seqnum);
+   return sprintf(buf, "%llu\n", (unsigned long 
long)get_ns_uevent_seqnum_by_vpid());
 }
 KERNEL_ATTR_RO(uevent_seqnum);
 
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index f5f5038787ac..796fd502c227 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -29,21 +29,38 @@
 #include 
 
 
-u64 uevent_seqnum;
 #ifdef CONFIG_UEVENT_HELPER
 char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH;
 #endif
 
+/*
+ * Size a buffer needs to be in order to hold the largest possible sequence
+ * number stored 

[PATCH net-next 0/2] netns: uevent performance tweaks

2018-04-18 Thread Christian Brauner
Hey,

This series deals with a bunch of performance improvements when sending out
uevents that have been extensively discussed here:
https://lkml.org/lkml/2018/4/10/592

- Only record uevent sockets from network namespaces owned by the
  initial user namespace in the global uevent socket list.
  Eric, this is the exact patch we agreed upon in
  https://lkml.org/lkml/2018/4/10/592.
  **A very detailed rationale is present in the commit message for
[PATCH 1/2] netns: restrict uevents**
- Decouple the locking for network namespaces in the global uevent socket
  list from the locking for network namespaces not in the global uevent
  socket list.
  **A very detailed rationale is present in the commit message
[PATCH 2/2] netns: isolate seqnums to use per-netns locks**

Thanks!
Christian

Christian Brauner (2):
  netns: restrict uevents
  netns: isolate seqnums to use per-netns locks

 include/linux/kobject.h |   3 -
 include/net/net_namespace.h |   3 +
 kernel/ksysfs.c |   3 +-
 lib/kobject_uevent.c| 118 
 net/core/net_namespace.c|  13 
 5 files changed, 110 insertions(+), 30 deletions(-)

-- 
2.17.0



Re: [PATCH v2] serial: imx: warn user when using unsupported configuration

2018-04-18 Thread Stefan Agner
On 18.04.2018 16:53, Uwe Kleine-König wrote:
> On Wed, Apr 18, 2018 at 04:06:38PM +0200, Stefan Agner wrote:
>> When using half-duplex mode (which disables receiver during txing)
>> the RTS signal cannot be driven low during transmission. This seems
>> to be a limitation of the i.MX UART IP: The RTS (CTS_B) signal is
>> controlled by the receiver. When the receiver is disabled, the
>> signal stays in UART logic idle state which is high...
>>
>> If SER_RS485_RTS_ON_SEND is used, RTS needs to be high active during
>> transmission. Since this is the default state of the RTS (CTS_B)
>> signal when the receiver is off, half-duplex mode in this
>> configuration works fine.
>>
>> However, a low-active RTS signal (flag SER_RS485_RTS_ON_SEND not set)
>> cannot be generated when the receiver is turned off.
>>
>> Print an error if the user selects this unsupported configuration
>> (both SER_RS485_RTS_ON_SEND and SER_RS485_RX_DURING_TX unset) and
>> configure the closest working configuration (set the
>> SER_RS485_RX_DURING_TX flag).
>>
>> Signed-off-by: Stefan Agner 
>> ---
>> Changes since v1:
>> - Consistently check for sport->have_rtscts && !(rs485conf->flags &
>>   SER_RS485_RTS_ON_SEND)
>> - Don't break printed message
>>
>>  drivers/tty/serial/imx.c | 15 +++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
>> index 91f3a1a5cb7f..1c1080fc8084 100644
>> --- a/drivers/tty/serial/imx.c
>> +++ b/drivers/tty/serial/imx.c
>> @@ -1833,6 +1833,11 @@ static int imx_uart_rs485_config(struct uart_port 
>> *port,
>>  rs485conf->flags &= ~SER_RS485_ENABLED;
>>
>>  if (rs485conf->flags & SER_RS485_ENABLED) {
>> +/* Enable receiver if low-active RTS signal is requested */
>> +if (sport->have_rtscts &&
>> +!(rs485conf->flags & SER_RS485_RTS_ON_SEND))
>> +rs485conf->flags |= SER_RS485_RX_DURING_TX;
>> +
> 
> I wonder what should happen, if the device tree has both
> 
>   uart-has-rtscts;
>   rts-gpios = <...>;

Hm, it seems that the code controls both in that case.

> 
> . I think the right thing would be to check for
> 
>   sport->have_rtscts && !sport->have_rtsgpio

I agree, since it controls both one can use the GPIO to have a working
half duplex with low-active RTS configuration.

Will send v3.

--
Stefan


Re: [PATCH v2] tracing/x86: Update syscall trace events to handle new x86 syscall func names

2018-04-18 Thread Steven Rostedt
On Wed, 18 Apr 2018 12:25:36 -0300
Arnaldo Carvalho de Melo  wrote:

> Em Wed, Apr 18, 2018 at 11:20:33AM -0400, Steven Rostedt escreveu:
> > On Wed, 18 Apr 2018 12:17:16 -0300
> > Arnaldo Carvalho de Melo  wrote:
> >   
> > > This does the trick, by not using the main syscall routine, but one
> > > called from it and not renamed, should work with older kernels.
> > > 
> > > This test should be improved to look if the desired routine is in place,
> > > if not just skip the test and tell about the unavailability of the
> > > wanted function, but that is for later.  
> > 
> > Does this mean you can give me a "Tested-by" for that last patch?  
> 
> Here it is, just written down:
> 
> Tested-by: Arnaldo Carvalho de Melo 
> 

Thanks!

-- Steve


[PATCH v5 22/23] ASoC: qcom: apq8096: Add db820c machine driver

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to DB820c machine driver.

Signed-off-by: Srinivas Kandagatla 
---
 sound/soc/qcom/Kconfig   |   9 ++
 sound/soc/qcom/Makefile  |   2 +
 sound/soc/qcom/apq8096.c | 238 +++
 3 files changed, 249 insertions(+)
 create mode 100644 sound/soc/qcom/apq8096.c

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index 5bdf39f6003f..9d8007e2f3cf 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -84,3 +84,12 @@ config SND_SOC_QDSP6
 This will enable sound soc platform specific
 audio drivers. This includes q6asm, q6adm,
 q6afe interfaces to DSP using apr.
+
+config SND_SOC_MSM8996
+   tristate "SoC Machine driver for MSM8996 and APQ8096 boards"
+   depends on QCOM_APR
+   select SND_SOC_QDSP6
+   help
+  Support for Qualcomm Technologies LPASS audio block in
+  APQ8096 SoC-based systems.
+  Say Y if you want to use audio device on this SoCs
diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile
index 0276717917c0..206945bb9ba1 100644
--- a/sound/soc/qcom/Makefile
+++ b/sound/soc/qcom/Makefile
@@ -13,9 +13,11 @@ obj-$(CONFIG_SND_SOC_LPASS_APQ8016) += 
snd-soc-lpass-apq8016.o
 # Machine
 snd-soc-storm-objs := storm.o
 snd-soc-apq8016-sbc-objs := apq8016_sbc.o
+snd-soc-apq8096-objs := apq8096.o
 
 obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o
 obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o
+obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o
 
 #DSP lib
 obj-$(CONFIG_SND_SOC_QDSP6) += qdsp6/
diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c
new file mode 100644
index ..73abf862db94
--- /dev/null
+++ b/sound/soc/qcom/apq8096.c
@@ -0,0 +1,238 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+ struct snd_pcm_hw_params *params)
+{
+   struct snd_interval *rate = hw_param_interval(params,
+   SNDRV_PCM_HW_PARAM_RATE);
+   struct snd_interval *channels = hw_param_interval(params,
+   SNDRV_PCM_HW_PARAM_CHANNELS);
+
+   rate->min = rate->max = 48000;
+   channels->min = channels->max = 2;
+
+   return 0;
+}
+
+static int apq8096_sbc_parse_of(struct snd_soc_card *card)
+{
+   struct device_node *np, *codec, *platform, *cpu, *node;
+   struct device *dev = card->dev;
+   struct snd_soc_dai_link *link;
+   int ret, num_links;
+
+   ret = snd_soc_of_parse_card_name(card, "qcom,model");
+   if (ret) {
+   dev_err(dev, "Error parsing card name: %d\n", ret);
+   return ret;
+   }
+
+   node = dev->of_node;
+
+   /* DAPM routes */
+   if (of_property_read_bool(node, "qcom,audio-routing")) {
+   ret = snd_soc_of_parse_audio_routing(card,
+   "qcom,audio-routing");
+   if (ret)
+   return ret;
+   }
+
+   /* Populate links */
+   num_links = of_get_child_count(node);
+
+   /* Allocate the DAI link array */
+   card->dai_link = kcalloc(num_links, sizeof(*link), GFP_KERNEL);
+   if (!card->dai_link)
+   return -ENOMEM;
+
+   card->num_links = num_links;
+   link = card->dai_link;
+
+   for_each_child_of_node(node, np) {
+   cpu = of_get_child_by_name(np, "cpu");
+   platform = of_get_child_by_name(np, "platform");
+   codec = of_get_child_by_name(np, "codec");
+
+   if (!cpu) {
+   dev_err(dev, "Can't find cpu DT node\n");
+   return -EINVAL;
+   }
+
+   link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0);
+   if (!link->cpu_of_node) {
+   dev_err(card->dev, "error getting cpu phandle\n");
+   return -EINVAL;
+   }
+
+   ret = snd_soc_of_get_dai_name(cpu, >cpu_dai_name);
+   if (ret) {
+   dev_err(card->dev, "error getting cpu dai name\n");
+   return ret;
+   }
+
+   if (codec && platform) {
+   link->platform_of_node = of_parse_phandle(platform,
+ "sound-dai",
+  0);
+   if (!link->platform_of_node) {
+   dev_err(card->dev, "platform dai not found\n");
+   return -EINVAL;
+   }
+
+   ret = 

[PATCH v5 11/23] ASoC: qdsp6: q6adm: Add q6adm driver

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to Q6ADM (Audio Device Manager) module in
q6dsp. ADM performs routing between audio streams and AFE ports.
It does Rate matching for streams going to devices driven by
different clocks, it handles volume ramping, Mixing with channel
and bit-width. ADM creates and destroys dynamic COPP services
for device-related audio processing as needed.

This patch adds basic support to ADM.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/Kconfig|   4 +
 sound/soc/qcom/qdsp6/Makefile |   1 +
 sound/soc/qcom/qdsp6/q6adm.c  | 633 ++
 sound/soc/qcom/qdsp6/q6adm.h  |  25 ++
 4 files changed, 663 insertions(+)
 create mode 100644 sound/soc/qcom/qdsp6/q6adm.c
 create mode 100644 sound/soc/qcom/qdsp6/q6adm.h

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index f50c76d712c0..5090ffa75648 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -50,11 +50,15 @@ config SND_SOC_QDSP6_COMMON
 config SND_SOC_QDSP6_AFE
tristate
 
+config SND_SOC_QDSP6_ADM
+   tristate
+
 config SND_SOC_QDSP6
tristate "SoC ALSA audio driver for QDSP6"
depends on QCOM_APR && HAS_DMA
select SND_SOC_QDSP6_COMMON
select SND_SOC_QDSP6_AFE
+   select SND_SOC_QDSP6_ADM
help
 To add support for MSM QDSP6 Soc Audio.
 This will enable sound soc platform specific
diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile
index 9ec951e0833b..930944425051 100644
--- a/sound/soc/qcom/qdsp6/Makefile
+++ b/sound/soc/qcom/qdsp6/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o
 obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o
+obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o
diff --git a/sound/soc/qcom/qdsp6/q6adm.c b/sound/soc/qcom/qdsp6/q6adm.c
new file mode 100644
index ..abd171659469
--- /dev/null
+++ b/sound/soc/qcom/qdsp6/q6adm.c
@@ -0,0 +1,633 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2011-2017, The Linux Foundation
+// Copyright (c) 2018, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "q6adm.h"
+#include "q6afe.h"
+#include "q6core.h"
+#include "q6dsp-errno.h"
+#include "q6dsp-common.h"
+
+#define ADM_CMD_DEVICE_OPEN_V5 0x00010326
+#define ADM_CMDRSP_DEVICE_OPEN_V5  0x00010329
+#define ADM_CMD_DEVICE_CLOSE_V50x00010327
+#define ADM_CMD_MATRIX_MAP_ROUTINGS_V5 0x00010325
+
+#define TIMEOUT_MS 1000
+#define RESET_COPP_ID 99
+#define INVALID_COPP_ID 0xFF
+/* Definition for a legacy device session. */
+#define ADM_LEGACY_DEVICE_SESSION  0
+#define ADM_MATRIX_ID_AUDIO_RX 0
+#define ADM_MATRIX_ID_AUDIO_TX 1
+
+struct copp {
+   int afe_port;
+   int copp_idx;
+   int id;
+   int topology;
+   int mode;
+   int rate;
+   int bit_width;
+   int channels;
+   int app_type;
+   int acdb_id;
+
+   struct aprv2_ibasic_rsp_result_t result;
+   struct kref refcount;
+   wait_queue_head_t wait;
+   struct list_head node;
+   struct q6adm *adm;
+};
+
+struct q6adm {
+   struct apr_device *apr;
+   struct device *dev;
+   struct q6core_svc_api_info ainfo;
+   unsigned long copp_bitmap[AFE_MAX_PORTS];
+   struct list_head copps_list;
+   spinlock_t copps_list_lock;
+   struct aprv2_ibasic_rsp_result_t result;
+   struct mutex lock;
+   wait_queue_head_t matrix_map_wait;
+   struct platform_device *pdev_routing;
+};
+
+struct adm_cmd_device_open_v5 {
+   struct apr_hdr hdr;
+   u16 flags;
+   u16 mode_of_operation;
+   u16 endpoint_id_1;
+   u16 endpoint_id_2;
+   u32 topology_id;
+   u16 dev_num_channel;
+   u16 bit_width;
+   u32 sample_rate;
+   u8 dev_channel_mapping[8];
+} __packed;
+
+struct adm_cmd_matrix_map_routings_v5 {
+   struct apr_hdr hdr;
+   u32 matrix_id;
+   u32 num_sessions;
+} __packed;
+
+struct adm_session_map_node_v5 {
+   u16 session_id;
+   u16 num_copps;
+} __packed;
+
+static struct copp *adm_find_copp(struct q6adm *adm, int port_idx,
+ int copp_idx)
+{
+   struct copp *c = NULL;
+   unsigned long flags;
+
+   spin_lock_irqsave(>copps_list_lock, flags);
+   list_for_each_entry(c, >copps_list, node) {
+   if ((port_idx == c->afe_port) && (copp_idx == c->copp_idx))
+   break;
+   }
+
+   spin_unlock_irqrestore(>copps_list_lock, flags);
+
+   return c;
+
+}
+
+static int q6adm_callback(struct apr_device *adev,
+   struct apr_client_message *data)
+{
+   struct aprv2_ibasic_rsp_result_t *result = data->payload;
+   

[PATCH v5 23/23] MAINTAINERS: Add myself as co-maintainer of qcom audio

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

Add myself as co-maintainer of qcom audio drivers

Signed-off-by: Srinivas Kandagatla 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a1410d5a621..9a78c2879a0c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11503,6 +11503,7 @@ F:  drivers/crypto/qat/
 QCOM AUDIO (ASoC) DRIVERS
 M: Patrick Lai 
 M: Banajit Goswami 
+M: Srinivas Kandagatla 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
 S: Supported
 F: sound/soc/qcom/
-- 
2.16.2



[PATCH v5 07/23] ASoC: qdsp6: q6afe: Add q6afe driver

2018-04-18 Thread srinivas . kandagatla
From: Srinivas Kandagatla 

This patch adds support to Q6AFE (Audio Front End) module on Q6DSP.

AFE module sits right at the other end of cpu where the codec/audio
devices are connected.

AFE provides abstraced interfaces to both hardware and virtual devices.
Each AFE tx/rx port can be configured to connect to one of the hardware
devices like codec, hdmi, slimbus, i2s and so on. AFE services include
starting, stopping, and if needed, any configurations of the ports.

Signed-off-by: Srinivas Kandagatla 
Reviewed-and-tested-by: Rohit kumar 
---
 sound/soc/qcom/Kconfig|   4 +
 sound/soc/qcom/Makefile   |   3 +
 sound/soc/qcom/qdsp6/Makefile |   1 +
 sound/soc/qcom/qdsp6/q6afe.c  | 503 ++
 sound/soc/qcom/qdsp6/q6afe.h  |  35 +++
 5 files changed, 546 insertions(+)
 create mode 100644 sound/soc/qcom/qdsp6/q6afe.c
 create mode 100644 sound/soc/qcom/qdsp6/q6afe.h

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index 8247ade16dbe..f50c76d712c0 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -47,10 +47,14 @@ config SND_SOC_APQ8016_SBC
 config SND_SOC_QDSP6_COMMON
tristate
 
+config SND_SOC_QDSP6_AFE
+   tristate
+
 config SND_SOC_QDSP6
tristate "SoC ALSA audio driver for QDSP6"
depends on QCOM_APR && HAS_DMA
select SND_SOC_QDSP6_COMMON
+   select SND_SOC_QDSP6_AFE
help
 To add support for MSM QDSP6 Soc Audio.
 This will enable sound soc platform specific
diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile
index d5280355c24f..0276717917c0 100644
--- a/sound/soc/qcom/Makefile
+++ b/sound/soc/qcom/Makefile
@@ -16,3 +16,6 @@ snd-soc-apq8016-sbc-objs := apq8016_sbc.o
 
 obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o
 obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o
+
+#DSP lib
+obj-$(CONFIG_SND_SOC_QDSP6) += qdsp6/
diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile
index accebdb49306..9ec951e0833b 100644
--- a/sound/soc/qcom/qdsp6/Makefile
+++ b/sound/soc/qcom/qdsp6/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o
+obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o
diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
new file mode 100644
index ..ec328fa7dd1e
--- /dev/null
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -0,0 +1,503 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2011-2017, The Linux Foundation
+// Copyright (c) 2018, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "q6dsp-errno.h"
+#include "q6core.h"
+#include "q6afe.h"
+
+/* AFE CMDs */
+#define AFE_PORT_CMD_DEVICE_START  0x000100E5
+#define AFE_PORT_CMD_DEVICE_STOP   0x000100E6
+#define AFE_PORT_CMD_SET_PARAM_V2  0x000100EF
+#define AFE_PORT_CMDRSP_GET_PARAM_V2   0x00010106
+#define AFE_PARAM_ID_HDMI_CONFIG   0x00010210
+#define AFE_MODULE_AUDIO_DEV_INTERFACE 0x0001020C
+
+/* Port IDs */
+#define AFE_API_VERSION_HDMI_CONFIG0x1
+#define AFE_PORT_ID_MULTICHAN_HDMI_RX  0x100E
+#define TIMEOUT_MS 1000
+#define AFE_CMD_RESP_AVAIL 0
+#define AFE_CMD_RESP_NONE  1
+
+struct q6afe {
+   struct apr_device *apr;
+   struct device *dev;
+   struct q6core_svc_api_info ainfo;
+   struct mutex lock;
+   struct list_head port_list;
+   spinlock_t port_list_lock;
+   struct list_head node;
+   struct platform_device *pdev_dais;
+};
+
+struct afe_port_cmd_device_start {
+   struct apr_hdr hdr;
+   u16 port_id;
+   u16 reserved;
+} __packed;
+
+struct afe_port_cmd_device_stop {
+   struct apr_hdr hdr;
+   u16 port_id;
+   u16 reserved;
+/* Reserved for 32-bit alignment. This field must be set to 0.*/
+} __packed;
+
+struct afe_port_param_data_v2 {
+   u32 module_id;
+   u32 param_id;
+   u16 param_size;
+   u16 reserved;
+} __packed;
+
+struct afe_port_cmd_set_param_v2 {
+   u16 port_id;
+   u16 payload_size;
+   u32 payload_address_lsw;
+   u32 payload_address_msw;
+   u32 mem_map_handle;
+} __packed;
+
+struct afe_param_id_hdmi_multi_chan_audio_cfg {
+   u32 hdmi_cfg_minor_version;
+   u16 datatype;
+   u16 channel_allocation;
+   u32 sample_rate;
+   u16 bit_width;
+   u16 reserved;
+} __packed;
+
+union afe_port_config {
+   struct afe_param_id_hdmi_multi_chan_audio_cfg hdmi_multi_ch;
+} __packed;
+
+struct q6afe_port {
+   wait_queue_head_t wait;
+   union afe_port_config port_cfg;
+   int token;
+   int id;
+   int cfg_type;
+   struct q6afe *afe;
+   struct list_headnode;
+};
+
+struct afe_audioif_config_command {
+   struct apr_hdr hdr;
+   struct afe_port_cmd_set_param_v2 param;
+   struct afe_port_param_data_v2 pdata;
+   

[PATCH 2/2] memory: aemif: add support for board files

2018-04-18 Thread Bartosz Golaszewski
From: Bartosz Golaszewski 

Currently aemif is supported in two places separately. By the platform
driver in drivers/memory and by a hand crafted driver in mach-davinci.

We want to drop the latter but also keep the legacy mode. Add support
for board files to the aemif driver.

The new structure in platform data currently only contains the chip
select number, since currently existing users don't require anything
else, but it can be extended in the future.

While extending the platform data struct, add kernel docs describing
its members.

Signed-off-by: Bartosz Golaszewski 
---
 drivers/memory/ti-aemif.c  | 58 +-
 include/linux/platform_data/ti-aemif.h | 25 +++
 2 files changed, 63 insertions(+), 20 deletions(-)

diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c
index 588e58d40d1b..c9577fda967c 100644
--- a/drivers/memory/ti-aemif.c
+++ b/drivers/memory/ti-aemif.c
@@ -339,9 +339,6 @@ static int aemif_probe(struct platform_device *pdev)
struct aemif_platform_data *pdata;
struct of_dev_auxdata *dev_lookup;
 
-   if (np == NULL)
-   return 0;
-
aemif = devm_kzalloc(dev, sizeof(*aemif), GFP_KERNEL);
if (!aemif)
return -ENOMEM;
@@ -363,8 +360,10 @@ static int aemif_probe(struct platform_device *pdev)
 
aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC;
 
-   if (of_device_is_compatible(np, "ti,da850-aemif"))
+   if (np && of_device_is_compatible(np, "ti,da850-aemif"))
aemif->cs_offset = 2;
+   else if (pdata)
+   aemif->cs_offset = pdata->cs_offset;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
aemif->base = devm_ioremap_resource(dev, res);
@@ -373,15 +372,23 @@ static int aemif_probe(struct platform_device *pdev)
goto error;
}
 
-   /*
-* For every controller device node, there is a cs device node that
-* describe the bus configuration parameters. This functions iterate
-* over these nodes and update the cs data array.
-*/
-   for_each_available_child_of_node(np, child_np) {
-   ret = of_aemif_parse_abus_config(pdev, child_np);
-   if (ret < 0)
-   goto error;
+   if (np) {
+   /*
+* For every controller device node, there is a cs device node
+* that describe the bus configuration parameters. This
+* functions iterate over these nodes and update the cs data
+* array.
+*/
+   for_each_available_child_of_node(np, child_np) {
+   ret = of_aemif_parse_abus_config(pdev, child_np);
+   if (ret < 0)
+   goto error;
+   }
+   } else if (pdata && pdata->num_abus_data > 0) {
+   for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) {
+   aemif->cs_data[i].cs = pdata->abus_data->cs;
+   aemif_get_hw_params(pdev, i);
+   }
}
 
for (i = 0; i < aemif->num_cs; i++) {
@@ -394,14 +401,25 @@ static int aemif_probe(struct platform_device *pdev)
}
 
/*
-* Create a child devices explicitly from here to
-* guarantee that the child will be probed after the AEMIF timing
-* parameters are set.
+* Create a child devices explicitly from here to guarantee that the
+* child will be probed after the AEMIF timing parameters are set.
 */
-   for_each_available_child_of_node(np, child_np) {
-   ret = of_platform_populate(child_np, NULL, dev_lookup, dev);
-   if (ret < 0)
-   goto error;
+   if (np) {
+   for_each_available_child_of_node(np, child_np) {
+   ret = of_platform_populate(child_np, NULL,
+  dev_lookup, dev);
+   if (ret < 0)
+   goto error;
+   }
+   } else {
+   for (i = 0; i < pdata->num_sub_devices; i++) {
+   pdata->sub_devices[i].dev.parent = dev;
+   ret = platform_device_register(>sub_devices[i]);
+   if (ret) {
+   dev_warn(dev, "Error register sub device %s\n",
+pdata->sub_devices[i].name);
+   }
+   }
}
 
return 0;
diff --git a/include/linux/platform_data/ti-aemif.h 
b/include/linux/platform_data/ti-aemif.h
index ac72e115093c..e6407bafcbf8 100644
--- a/include/linux/platform_data/ti-aemif.h
+++ b/include/linux/platform_data/ti-aemif.h
@@ -16,8 +16,33 @@
 
 #include 
 
+/**
+ * struct aemif_abus_data - Async bus configuration parameters.
+ *
+ * @cs 

  1   2   3   4   5   6   7   8   9   10   >