Re: [PATCH v2 7/7] pinctrl: qcom-spmi-gpio: Migrate to pinconf-generic

2014-12-04 Thread Ivan T. Ivanov

On Thu, 2014-11-27 at 17:26 -0800, Soren Brinkmann wrote:
> 
>  static const struct pinconf_ops pmic_gpio_pinconf_ops = {
> +   .is_generic= true,
> .pin_config_group_get= pmic_gpio_config_get,
> .pin_config_group_set= pmic_gpio_config_set,
> .pin_config_group_dbg_show= pmic_gpio_config_dbg_show,
> @@ -848,6 +742,9 @@ static int pmic_gpio_probe(struct platform_device *pdev)
> pctrldesc->name = dev_name(dev);
> pctrldesc->pins = pindesc;
> pctrldesc->npins = npins;
> +   pctrldesc->num_dt_params = ARRAY_SIZE(pmic_gpio_bindings);
> +   pctrldesc->params = pmic_gpio_bindings;
> +   pctrldesc->conf_items = pmic_conf_items;
> 

What will happen if number of conf_items is less than number of params?

Ivan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()

2014-12-04 Thread Joe Perches
On Fri, 2014-12-05 at 08:18 +0100, SF Markus Elfring wrote:
> >>> It's generally nicer to replace embedded function names
> >>> with "%s: ", __func__
> >>>
> >>>   pr_warn("%s: cipher_encrypt failed\n", __func__);
> >>
> >> Do you want that I send a third patch series for the fine-tuning of these 
> >> parameters?
> > 
> > If you want.
> 
> Would "a committer" fix such a small source code adjustment also without a 
> resend of
> a patch series?

Depends on the committer.  Some might, most wouldn't.

drivers/net/ppp doesn't have a specific maintainer.

The networking maintainer generally asks for resends
of patches that don't suit his taste, but lots of
non-perfect patches still get applied there.

It's a process, and it's not immediate.  Wait to see
if these get applied as-is.  If the embedded function
name use, which is trivial, bothers you, send another
patch later on that changes it.

> Does it make sense to express such implementation details in the Linux coding
> style documentation more explicitly (besides the fact that this update 
> suggestion
> was also triggered by a warning from the script "checkpatch.pl").

Probably not.

Overly formalized coding style rules are perhaps
more of a barrier to entry than most want.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


From Abraham Karid

2014-12-04 Thread Abraham Karid
My name is Abraham Karid from Egypt, i am a journalist , you can know more 
about me on facebook with this id abka...@outlook.com , I have a good business 
for you and your family
Get back to me so that i will give you more details about it.
Thanks
Abraham Karid
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()

2014-12-04 Thread Joe Perches
On Fri, 2014-12-05 at 08:21 +0100, Julia Lawall wrote:
> On Thu, 4 Dec 2014, Joe Perches wrote:
> > It's generally nicer to replace embedded function names
> > with "%s: ", __func__
> > 
> > pr_warn("%s: cipher_encrypt failed\n", __func__);
> 
> Doing so may potentially allow some strings to be shared, thus saving a 
> little space.  Perhaps not in this case, though.

It's not necessarily a code size savings in any case.

It can be, but the real benefits are stylistic
consistency and lack of mismatch between function
name and message.

If the code is refactored or copy/pasted into another
function, a moderately common defect is not modifying
the embedded function name in the message.

There may be some smallish savings if ever these
__func__ uses were converted to use %pf via some
internal standardized mechanism.

A negative to that approach is inlined functions would
take the function name of the parent not keep the
inlined function name.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] misc: suppress build warning

2014-12-04 Thread Andrew Morton
On Thu, 4 Dec 2014 08:30:32 -0800 Greg Kroah-Hartman 
 wrote:

> On Thu, Dec 04, 2014 at 03:13:00PM +, Prabhakar Lad wrote:
> > On Thu, Dec 4, 2014 at 2:59 PM, Arnd Bergmann  wrote:
> > > On Thursday 04 December 2014 14:38:30 Lad, Prabhakar wrote:
> > >> this patch fixes following build warning:
> > >>
> > >> drivers/misc/ioc4.c: In function ___ioc4_probe___:
> > >> drivers/misc/ioc4.c:194:16: warning: ___start___ may be used 
> > >> uninitialized in this function [-Wmaybe-uninitialized]
> > >>   period = (end - start) /
> > >> ^
> > >> drivers/misc/ioc4.c:148:11: note: ___start___ was declared here
> > >>   uint64_t start, end, period;
> > >>
> > >> Signed-off-by: Lad, Prabhakar 
> > >
> > > Please explain why the compiler thinks there is a bug, why you
> > > are sure that there isn't, and why you picked '0' as the
> > > initialization value.
> > >
> > Its a false positive, to suppress the warning '0' was picked.
> 
> Are you _sure_ it's a false positive?  That odd do/while loop looks like
> it might just not ever initialize the start variable, are you sure the
> logic there is correct?
> 

As long as IOC4_CALIBRATE_END is greater than IOC4_CALIBRATE_DISCARD (it is),
`start' is written to.

It would be nice to simplify the code, but I'm not sure how.

And I really dislike this initialize-it-to-zero-to-stop-the-warning
thing which we do all over the place.  The reader doesn't know *why*
it's initialized to zero and the initialization can conceal bugs if we
get a code path which should have written to it but forgot to.  And it
adds unneeded code to vlinux.

I much prefer unintialized_var() which fixes the documentation issue
and doesn't add code.  But Linus and Ingo had a dummy-spit over it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 net-next 2/2 tuntap: Increase the number of queues in tun.

2014-12-04 Thread Jason Wang

On 12/04/2014 06:20 PM, Michael S. Tsirkin wrote:
> On Thu, Dec 04, 2014 at 03:03:34AM +0008, Jason Wang wrote:
>> > 
>> > 
>> > On Wed, Dec 3, 2014 at 5:52 PM, Michael S. Tsirkin  wrote:
>>> > >On Wed, Dec 03, 2014 at 12:49:37PM +0530, Pankaj Gupta wrote:
 > >> Networking under kvm works best if we allocate a per-vCPU RX and TX
 > >> queue in a virtual NIC. This requires a per-vCPU queue on the host
 > >>side.
 > >> It is now safe to increase the maximum number of queues.
 > >> Preceding patche: 'net: allow large number of rx queues'
>>> > >
>>> > >s/patche/patch/
>>> > >
 > >> made sure this won't cause failures due to high order memory
 > >> allocations. Increase it to 256: this is the max number of vCPUs
 > >> KVM supports.
 > >> Signed-off-by: Pankaj Gupta 
 > >> Reviewed-by: David Gibson 
>>> > >
>>> > >Hmm it's kind of nasty that each tun device is now using x16 memory.
>>> > >Maybe we should look at using a flex array instead, and removing the
>>> > >limitation altogether (e.g. make it INT_MAX)?
>> > 
>> > But this only happens when IFF_MULTIQUEUE were used.
> I refer to this field:
> struct tun_file __rcu   *tfiles[MAX_TAP_QUEUES];
> if we make MAX_TAP_QUEUES 256, this will use 4K bytes,
> apparently unconditionally.
>
>

How about just allocate one tfile if IFF_MULTIQUEUE were disabled?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] PCI: Add disabling pm async quirk for JMicron chips

2014-12-04 Thread Chuansheng Liu
Some history from
commit e6b7e41cdd8c ("ata: Disabling the async PM for JMicron chip 363/361")
==
Since v3.15, the PM feature of async noirq
commit 76569faa62c4 ("PM / sleep: Asynchronous threads for resume_noirq") is 
introduced.

Then Jay hit one system resuming issue that one of the JMicron controller
can not be powered up successfully.

His device tree is like below:
 +-1c.4-[02]--+-00.0  JMicron Technology Corp. JMB363 SATA/IDE 
Controller
 |\-00.1  JMicron Technology Corp. JMB363 SATA/IDE 
Controller

After investigation, we found the the Micron chip 363 included
one SATA controller(:02:00.0) and one PATA controller(:02:00.1),
these two controllers do not have parent-children relationship,
but the PATA controller only can be powered on after the SATA controller
has finished the powering on.

If we enabled the async noirq(), then the below error is hit during noirq
phase:
pata_jmicron :02:00.1: Refused to change power state, currently in D3
Here for JMicron chip 363/361, we need forcedly to disable the async method.

Bug detail: https://bugzilla.kernel.org/show_bug.cgi?id=81551
==

After that, Barto reported the same issue, but his Jmicron chip is JMB368,
so it can not be covered by
commit e6b7e41cdd8c ("ata: Disabling the async PM for JMicron chip 363/361").

Bug link:
https://bugzilla.kernel.org/show_bug.cgi?id=84861

Here we think Jmicron chips have the same issue as describled in
commit e6b7e41cdd8c ("ata: Disabling the async PM for JMicron chip 363/361"),

so here add one quirk to disable the JMicron chips' PM async feature.

Cc: sta...@vger.kernel.org # 3.15+
Signed-off-by: Chuansheng Liu 
---
 drivers/pci/quirks.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 90acb32..1963080 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1501,6 +1501,21 @@ static void quirk_jmicron_ata(struct pci_dev *pdev)
pci_read_config_dword(pdev, PCI_CLASS_REVISION, );
pdev->class = class >> 8;
 }
+
+/*
+ * For JMicron chips, we need to disable the async_suspend method, otherwise
+ * they will hit the power-on issue when doing device resume, add one quirk
+ * solution to disable the async_suspend method.
+ */
+static void pci_async_suspend_fixup(struct pci_dev *pdev)
+{
+   /*
+* disabling the async_suspend method for JMicron chips to
+* avoid device resuming issue.
+*/
+   device_disable_async_suspend(>dev);
+}
+
 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB360, 
quirk_jmicron_ata);
 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361, 
quirk_jmicron_ata);
 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB362, 
quirk_jmicron_ata);
@@ -1519,6 +1534,8 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, 
PCI_DEVICE_ID_JMICRON_JMB3
 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, 
PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata);
 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, 
PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata);
 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, 
PCI_DEVICE_ID_JMICRON_JMB369, quirk_jmicron_ata);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_JMICRON, PCI_ANY_ID,
+   pci_async_suspend_fixup);
 
 #endif
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4] clocksource: arch_timer: Allow the device tree to specify uninitialized timer registers

2014-12-04 Thread Olof Johansson
On Wed, Oct 08, 2014 at 12:33:47AM -0700, Sonny Rao wrote:
> From: Doug Anderson 
> 
> Some 32-bit (ARMv7) systems are architected like this:
> 
> * The firmware doesn't know and doesn't care about hypervisor mode and
>   we don't want to add the complexity of hypervisor there.
> 
> * The firmware isn't involved in SMP bringup or resume.
> 
> * The ARCH timer come up with an uninitialized offset (CNTVOFF)
>   between the virtual and physical counters.  Each core gets a
>   different random offset.
> 
> * The device boots in "Secure SVC" mode.
> 
> * Nothing has touched the reset value of CNTHCTL.PL1PCEN or
>   CNTHCTL.PL1PCTEN (both default to 1 at reset)
> 
> On systems like the above, it doesn't make sense to use the virtual
> counter.  There's nobody managing the offset and each time a core goes
> down and comes back up it will get reinitialized to some other random
> value.
> 
> This adds an optional property which can inform the kernel of this
> situation, and firmware is free to remove the property if it is going
> to initialize the CNTVOFF registers when each CPU comes out of reset.
> 
> Currently, the best course of action in this case is to use the
> physical timer, which is why it is important that CNTHCTL hasn't been
> changed from its reset value and it's a reasonable assumption given
> that the firmware has never entered HYP mode.
> 
> Note that it's been said that on ARMv8 systems the firmware and
> kernel really can't be architected as described above.  That means
> using the physical timer like this really only makes sense for ARMv7
> systems.
> 
> Signed-off-by: Doug Anderson 
> Signed-off-by: Sonny Rao 
> Reviewed-by: Mark Rutland 
> ---
> Changes in v2:
> - Add "#ifdef CONFIG_ARM" as per Will Deacon
> 
> Changes in v3:
> - change property name to arm,cntvoff-not-fw-configured and specify
>   that the value of CNTHCTL.PL1PC(T)EN must still be the reset value
>   of 1 as per Mark Rutland
> 
> Changes in v4:
> - change property name to arm,cpu-registers-not-fw-configured and
>   specify that all cpu registers must have architected reset values
>   per Mark Rutland
> - change from "#ifdef CONFIG_ARM" to "if (IS_ENABLED(CONFIG_ARM))" per
>   Arnd Bergmann


Applied to next/drivers (and next/dt for rk3288 dependency). Thanks, all!


-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5] clocksource: arch_timer: Fix code to use physical timers when requested

2014-12-04 Thread Olof Johansson
On Sun, Nov 23, 2014 at 11:02:44PM -0800, Sonny Rao wrote:
> This is a bug fix for using physical arch timers when
> the arch_timer_use_virtual boolean is false.  It restores the
> arch_counter_get_cntpct() function after removal in
> 
> 0d651e4e "clocksource: arch_timer: use virtual counters"
> 
> We need this on certain ARMv7 systems which are architected like this:
> 
> * The firmware doesn't know and doesn't care about hypervisor mode and
>   we don't want to add the complexity of hypervisor there.
> 
> * The firmware isn't involved in SMP bringup or resume.
> 
> * The ARCH timer come up with an uninitialized offset between the
>   virtual and physical counters.  Each core gets a different random
>   offset.
> 
> * The device boots in "Secure SVC" mode.
> 
> * Nothing has touched the reset value of CNTHCTL.PL1PCEN or
>   CNTHCTL.PL1PCTEN (both default to 1 at reset)
> 
> One example of such as system is RK3288 where it is much simpler to
> use the physical counter since there's nobody managing the offset and
> each time a core goes down and comes back up it will get reinitialized
> to some other random value.
> 
> Fixes: 0d651e4e65e9 ("clocksource: arch_timer: use virtual counters")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Sonny Rao 
> Acked-by: Olof Johansson 

Applied to a topic branch in arm-soc so we can include it in next/dt and
next/drivers as appropriate for rk3288.


Thanks, all!


-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH] net/socket.c : introduce helper function do_sock_sendmsg to replace reduplicate code

2014-12-04 Thread Gu Zheng
Introduce helper function do_sock_sendmsg() to simplify sock_sendmsg{_nosec},
and replace reduplicate code.

Signed-off-by: Gu Zheng 
---
 net/socket.c |   22 ++
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index fe20c31..2a6f3c6 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -651,7 +651,8 @@ static inline int __sock_sendmsg(struct kiocb *iocb, struct 
socket *sock,
return err ?: __sock_sendmsg_nosec(iocb, sock, msg, size);
 }
 
-int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
+static int do_sock_sendmsg(struct socket *sock, struct msghdr *msg,
+  size_t size, bool nosec)
 {
struct kiocb iocb;
struct sock_iocb siocb;
@@ -659,25 +660,22 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg, 
size_t size)
 
init_sync_kiocb(, NULL);
iocb.private = 
-   ret = __sock_sendmsg(, sock, msg, size);
+   ret = nosec ? __sock_sendmsg_nosec(, sock, msg, size) :
+ __sock_sendmsg(, sock, msg, size);
if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb();
return ret;
 }
+
+int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
+{
+   return do_sock_sendmsg(sock, msg, size, false);
+}
 EXPORT_SYMBOL(sock_sendmsg);
 
 static int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg, size_t 
size)
 {
-   struct kiocb iocb;
-   struct sock_iocb siocb;
-   int ret;
-
-   init_sync_kiocb(, NULL);
-   iocb.private = 
-   ret = __sock_sendmsg_nosec(, sock, msg, size);
-   if (-EIOCBQUEUED == ret)
-   ret = wait_on_sync_kiocb();
-   return ret;
+   return do_sock_sendmsg(sock, msg, size, true);
 }
 
 int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
-- 
1.7.7

.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH] net: introduce helper macra CMSG_FOREACH_HDR

2014-12-04 Thread Gu Zheng
Introduce helper macra CMSG_FOREACH_HDR as a wrapper of the enumerating
cmsghdr from msghdr, just cleanup. 

Signed-off-by: Gu Zheng 
---
 .../networking/timestamping/timestamping.c |4 +---
 .../networking/timestamping/txtimestamp.c  |4 +---
 crypto/af_alg.c|2 +-
 include/linux/socket.h |4 
 net/core/scm.c |3 +--
 net/dccp/proto.c   |5 ++---
 net/ipv4/ip_sockglue.c |2 +-
 net/ipv6/datagram.c|2 +-
 net/iucv/af_iucv.c |4 +---
 net/rds/send.c |4 ++--
 net/rxrpc/ar-output.c  |2 +-
 net/sctp/socket.c  |3 +--
 12 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/Documentation/networking/timestamping/timestamping.c 
b/Documentation/networking/timestamping/timestamping.c
index 5cdfd74..3106e88 100644
--- a/Documentation/networking/timestamping/timestamping.c
+++ b/Documentation/networking/timestamping/timestamping.c
@@ -169,9 +169,7 @@ static void printpacket(struct msghdr *msg, int res,
   res,
   inet_ntoa(from_addr->sin_addr),
   msg->msg_controllen);
-   for (cmsg = CMSG_FIRSTHDR(msg);
-cmsg;
-cmsg = CMSG_NXTHDR(msg, cmsg)) {
+   CMSG_FOREACH_HDR(cmsg, msg) {
printf("   cmsg len %zu: ", cmsg->cmsg_len);
switch (cmsg->cmsg_level) {
case SOL_SOCKET:
diff --git a/Documentation/networking/timestamping/txtimestamp.c 
b/Documentation/networking/timestamping/txtimestamp.c
index b32fc2a..e44ef35 100644
--- a/Documentation/networking/timestamping/txtimestamp.c
+++ b/Documentation/networking/timestamping/txtimestamp.c
@@ -149,9 +149,7 @@ static void __recv_errmsg_cmsg(struct msghdr *msg, int 
payload_len)
struct scm_timestamping *tss = NULL;
struct cmsghdr *cm;
 
-   for (cm = CMSG_FIRSTHDR(msg);
-cm && cm->cmsg_len;
-cm = CMSG_NXTHDR(msg, cm)) {
+   CMSG_FOREACH_HDR(cmsg, msg) {
if (cm->cmsg_level == SOL_SOCKET &&
cm->cmsg_type == SCM_TIMESTAMPING) {
tss = (void *) CMSG_DATA(cm);
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 6a3ad80..3df7d53 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -399,7 +399,7 @@ int af_alg_cmsg_send(struct msghdr *msg, struct 
af_alg_control *con)
 {
struct cmsghdr *cmsg;
 
-   for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
+   CMSG_FOREACH_HDR(cmsg, msg) {
if (!CMSG_OK(msg, cmsg))
return -EINVAL;
if (cmsg->cmsg_level != SOL_ALG)
diff --git a/include/linux/socket.h b/include/linux/socket.h
index bb9b836..d4b592f 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -94,6 +94,10 @@ struct cmsghdr {
 (cmsg)->cmsg_len <= (unsigned long) \
 ((mhdr)->msg_controllen - \
  ((char *)(cmsg) - (char *)(mhdr)->msg_control)))
+#define CMSG_FOREACH_HDR(cmsg, msg)  \
+   for (cmsg = CMSG_FIRSTHDR(msg); \
+cmsg; \
+cmsg = CMSG_NXTHDR(msg, cmsg))
 
 /*
  * Get the next cmsg header
diff --git a/net/core/scm.c b/net/core/scm.c
index b442e7e..e938c49 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -129,8 +129,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, 
struct scm_cookie *p)
struct cmsghdr *cmsg;
int err;
 
-   for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg))
-   {
+   CMSG_FOREACH_HDR(cmsg, msg) {
err = -EINVAL;
 
/* Verify that cmsg_len is at least sizeof(struct cmsghdr) */
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 5ab6627..d449cc5 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -703,7 +703,7 @@ EXPORT_SYMBOL_GPL(compat_dccp_getsockopt);
 
 static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb)
 {
-   struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg);
+   struct cmsghdr *cmsg;
 
/*
 * Assign an (opaque) qpolicy priority value to skb->priority.
@@ -717,8 +717,7 @@ static int dccp_msghdr_parse(struct msghdr *msg, struct 
sk_buff *skb)
 */
skb->priority = 0;
 
-   for (; cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
-
+   CMSG_FOREACH_HDR(cmsg, msg) {
if (!CMSG_OK(msg, cmsg))
return -EINVAL;
 
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 9daf217..14a6f71 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -192,7 +192,7 @@ int ip_cmsg_send(struct net *net, struct msghdr *msg, 
struct ipcm_cookie *ipc,
int 

Re: [PATCH 0/9] Final set of XSAVES patches

2014-12-04 Thread Paolo Bonzini


On 05/12/2014 02:15, Wanpeng Li wrote:
> Hi Paolo,
> On Thu, Dec 04, 2014 at 04:57:05PM +0100, Paolo Bonzini wrote:
>> These are all the patches needed to support XSAVES.
>>
> 
> I think you miss to add your patch "kvm: x86: mask out XSAVES" to 
> this patchset,

That one is already on kvm/next, so it is more or less frozen.

> I test the whole patchset w/ that patch applied on 
> skylake-client machine, and it looks good, please feel free to add 
> my tested-by to this patchset.
> 
> Tested-by: Wanpeng Li 

Awesome, thanks!

Paolo

>> Paolo Bonzini (5):
>>  x86: export get_xsave_addr
>>  KVM: x86: support XSAVES usage in the host
>>  KVM: x86: use F() macro throughout cpuid.c
>>  KVM: cpuid: set CPUID(EAX=0xd,ECX=1).EBX correctly
>>  KVM: cpuid: mask more bits in leaf 0xd and subleaves
>>
>> Wanpeng Li (4):
>>  kvm: x86: Add kvm_x86_ops hook that enables XSAVES for guest
>>  kvm: x86: handle XSAVES vmcs and vmexit
>>  kvm: vmx: add MSR logic for XSAVES
>>  kvm: vmx: add nested virtualization support for xsaves
>>
>> arch/x86/include/asm/kvm_host.h |  2 +
>> arch/x86/include/asm/vmx.h  |  3 ++
>> arch/x86/include/uapi/asm/vmx.h |  6 ++-
>> arch/x86/kernel/xsave.c |  1 +
>> arch/x86/kvm/cpuid.c| 47 ++---
>> arch/x86/kvm/svm.c  |  6 +++
>> arch/x86/kvm/vmx.c  | 80 +++-
>> arch/x86/kvm/x86.c  | 90 
>> +
>> 8 files changed, 210 insertions(+), 25 deletions(-)
>>
>> -- 
>> 1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v15 0/3] Add drm driver for Rockchip Socs

2014-12-04 Thread Dave Airlie
On 5 December 2014 at 05:29, Daniel Kurtz  wrote:
> On Tue, Dec 2, 2014 at 1:31 AM, Heiko Stübner  wrote:
>> Hi Mark,
>>
>> Am Dienstag, 2. Dezember 2014, 17:13:20 schrieb Mark Yao:
>>> This a series of patches is a DRM Driver for Rockchip Socs, add support
>>> for vop devices. Future patches will add additional encoders/connectors,
>>> such as eDP, HDMI.
>>>
>>> The basic "crtc" for rockchip is a "VOP" - Video Output Processor.
>>> the vop devices found on Rockchip rk3288 Soc, rk3288 soc have two similar
>>> Vop devices. Vop devices support iommu mapping, we use dma-mapping API with
>>> ARM_DMA_USE_IOMMU.
>>
>> [...]
>>
>>> Changes in v15:
>>> - remove depends on ARM_DMA_USE_IOMMU & IOMMU_API which cause
>>>   recursive dependency problem
>
> I thought the recommended solution for this was to fix OMAP3 to not
> select  ARM_DMA_USE_IOMMU and OMAP_IOMMU, not to drop the 'depends on'
> in drm/rockchip?

Lets fix that up once we get this merged, if I had a tree based on the
iommu I'd have
it -next now.

can I get a pull for that?
Dave.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 0/5] Add Spreadtrum Sharkl64 Platform support

2014-12-04 Thread Olof Johansson
On Thu, Dec 04, 2014 at 07:34:15PM +0800, Chunyan Zhang wrote:
> Spreadtrum is a rapid growing chip vendor providing smart phone total 
> solutions.
> 
> Sharkl64 Platform is nominated as a SoC infrastructure that supports 4G/3G/2G
> standards based on ARMv8 multiple core architecture.Now we have only one
> SoC(SC9836) based on this Platform in developing.
> 
> This patchset adds Sharkl64 support in arm64 device tree and the serial driver
> of SC9836-UART.
> 
> This patchset also has patches which address "sprd" prefix and DT compatible
> strings for nodes which appear un-documented.
> 
> This version code was tesed both on Fast Mode and sc9836-fpga board.
> We use the latest boot-wrapper-aarch64 as the bootloader.

Hi,

We only got 3 of the 5 patches of this version (1, 2 and 4). Can you
resend the dts patch to us (I'm guessing the serial one will go through Greg).


Thanks,

-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()

2014-12-04 Thread Julia Lawall


On Thu, 4 Dec 2014, Joe Perches wrote:

> On Thu, 2014-12-04 at 23:10 +0100, SF Markus Elfring wrote:
> > The mppe_rekey() function contained a few update candidates.
> > * Curly brackets were still used around a single function call "printk".
> > * Unwanted space characters
> > 
> > Let us improve these implementation details according to the current Linux
> > coding style convention.
> 
> trivia:
> 
> > diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
> []
> > @@ -172,9 +172,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, 
> > int initial_key)
> > setup_sg(sg_in, state->sha1_digest, state->keylen);
> > setup_sg(sg_out, state->session_key, state->keylen);
> > if (crypto_blkcipher_encrypt(, sg_out, sg_in,
> > -state->keylen) != 0) {
> > -   printk(KERN_WARNING "mppe_rekey: cipher_encrypt 
> > failed\n");
> > -   }
> > +state->keylen) != 0)
> > +   pr_warn("mppe_rekey: cipher_encrypt failed\n");
> 
> It's generally nicer to replace embedded function names
> with "%s: ", __func__
> 
>   pr_warn("%s: cipher_encrypt failed\n", __func__);

Doing so may potentially allow some strings to be shared, thus saving a 
little space.  Perhaps not in this case, though.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()

2014-12-04 Thread SF Markus Elfring
>>> It's generally nicer to replace embedded function names
>>> with "%s: ", __func__
>>>
>>> pr_warn("%s: cipher_encrypt failed\n", __func__);
>>
>> Do you want that I send a third patch series for the fine-tuning of these 
>> parameters?
> 
> If you want.

Would "a committer" fix such a small source code adjustment also without a 
resend of
a patch series?


> I just wanted you to be aware of it for future patches.

Thanks for your tip.

Does it make sense to express such implementation details in the Linux coding
style documentation more explicitly (besides the fact that this update 
suggestion
was also triggered by a warning from the script "checkpatch.pl").

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[V6 PATCH 1/1] driver:mtd:spi-nor: Add quad I/O support for Micron spi nor

2014-12-04 Thread beanhuo
This patch adds code which enables Quad I/O mode on Micron SPI NOR flashes.

For Micron SPI NOR flash,enabling or disabling quad I/O protocol can be done
By two methods, which are to use EVCR(Enhanced Volatile Configuration Register)
and the ENTER QUAD I/O MODE command.There is no difference between these two
methods.Unfortunately,for some Micron spi nor flashes,there no ENTER Quad I/O
command(35h),such as n25q064.But for all current Micron spi nor,if it support
quad I/O mode,using EVCR definitely be supported.It is a recommended method to
enable Quad I/O mode by EVCR,Quad I/O protocol bit 7.When EVCR bit 7 is reset
to 0,the SPI NOR flash will operate in quad I/O mode.

This patch has been tested on N25Q512A and MT25TL256BAA1ESF.Micron spi nor of 
spi_nor_ids[] table all support this method.

Signed-off-by: bean huo 
Acked-by: Marek Vasut 
---
v1-v2:
Modified to that capture wait_till_ready()
return value,if error,directly return its
the value.
 v2-v3:
Directly use the reurning error value of
read_reg and write_reg,instead of -EINVAL.
 v3-v4:
Modify commit logs that wraped into 80 columns.
 v4-v5:
Rebuild new patch based on latest linux-mtd.
 v5-v6:
Rebuild patch based on latest l2-mtd.
add some comments.
Add SPI_NOR_QUAD_READ flag in the spi_nor_ids[] for Micron spi nor.

 drivers/mtd/spi-nor/spi-nor.c |   61 +++--
 include/linux/mtd/spi-nor.h   |7 +
 2 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 0f8ec3c..128941e 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -560,14 +560,14 @@ static const struct spi_device_id spi_nor_ids[] = {
{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) 
},
 
/* Micron */
-   { "n25q032", INFO(0x20ba16, 0, 64 * 1024,   64, 0) },
-   { "n25q064", INFO(0x20ba17, 0, 64 * 1024,  128, 0) },
-   { "n25q128a11",  INFO(0x20bb18, 0, 64 * 1024,  256, 0) },
-   { "n25q128a13",  INFO(0x20ba18, 0, 64 * 1024,  256, 0) },
-   { "n25q256a",INFO(0x20ba19, 0, 64 * 1024,  512, SECT_4K) },
-   { "n25q512a",INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
-   { "n25q512ax3",  INFO(0x20ba20, 0, 64 * 1024, 1024, USE_FSR) },
-   { "n25q00",  INFO(0x20ba21, 0, 64 * 1024, 2048, USE_FSR) },
+   { "n25q032", INFO(0x20ba16, 0, 64 * 1024,   64, SPI_NOR_QUAD_READ) 
},
+   { "n25q064", INFO(0x20ba17, 0, 64 * 1024,  128, SPI_NOR_QUAD_READ) 
},
+   { "n25q128a11",  INFO(0x20bb18, 0, 64 * 1024,  256, SPI_NOR_QUAD_READ) 
},
+   { "n25q128a13",  INFO(0x20ba18, 0, 64 * 1024,  256, SPI_NOR_QUAD_READ) 
},
+   { "n25q256a",INFO(0x20ba19, 0, 64 * 1024,  512, SECT_4K | 
SPI_NOR_QUAD_READ) },
+   { "n25q512a",INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ) },
+   { "n25q512ax3",  INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ) },
+   { "n25q00",  INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | 
SPI_NOR_QUAD_READ) },
 
/* PMC */
{ "pm25lv512",   INFO(0,0, 32 * 1024,2, SECT_4K_PMC) },
@@ -891,6 +891,44 @@ static int spansion_quad_enable(struct spi_nor *nor)
return 0;
 }
 
+static int micron_quad_enable(struct spi_nor *nor)
+{
+   int ret, val;
+
+   ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, , 1);
+   if (ret < 0) {
+   dev_err(nor->dev, "error %d reading EVCR\n", ret);
+   return ret;
+   }
+
+   write_enable(nor);
+
+   /* set EVCR ,enable quad I/O */
+   nor->cmd_buf[0] = val & ~EVCR_QUAD_EN_MICRON;
+   ret = nor->write_reg(nor, SPINOR_OP_WD_EVCR, nor->cmd_buf, 1, 0);
+   if (ret < 0) {
+   dev_err(nor->dev, "error while writing EVCR register\n");
+   return ret;
+   }
+
+   ret = spi_nor_wait_till_ready(nor);
+   if (ret)
+   return ret;
+
+   /* read EVCR and check it */
+   ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, , 1);
+   if (ret < 0) {
+   dev_err(nor->dev, "error %d reading EVCR\n", ret);
+   return ret;
+   }
+   if (val & EVCR_QUAD_EN_MICRON) {
+   dev_err(nor->dev, "Micron EVCR Quad bit not clear\n");
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 static int set_quad_mode(struct spi_nor *nor, struct flash_info *info)
 {
int status;
@@ -903,6 +941,13 @@ static int set_quad_mode(struct spi_nor *nor, struct 
flash_info *info)
return -EINVAL;
}
return status;
+   case CFI_MFR_ST:
+   status = micron_quad_enable(nor);
+   if (status) {
+   dev_err(nor->dev, "Micron quad-read not enabled\n");
+   return -EINVAL;
+   }
+ 

Re: [PATCH v17 1/7] mm: support madvise(MADV_FREE)

2014-12-04 Thread Minchan Kim
On Wed, Dec 03, 2014 at 11:13:29AM +0100, Michal Hocko wrote:
> On Wed 03-12-14 09:00:26, Minchan Kim wrote:
> > On Tue, Dec 02, 2014 at 11:01:25AM +0100, Michal Hocko wrote:
> > > On Mon 01-12-14 08:56:52, Minchan Kim wrote:
> > > [...]
> > > > From 2edd6890f92fa4943ce3c452194479458582d88c Mon Sep 17 00:00:00 2001
> > > > From: Minchan Kim 
> > > > Date: Mon, 1 Dec 2014 08:53:55 +0900
> > > > Subject: [PATCH] madvise.2: Document MADV_FREE
> > > > 
> > > > Signed-off-by: Minchan Kim 
> > > > ---
> > > >  man2/madvise.2 | 13 +
> > > >  1 file changed, 13 insertions(+)
> > > > 
> > > > diff --git a/man2/madvise.2 b/man2/madvise.2
> > > > index 032ead7..33aa936 100644
> > > > --- a/man2/madvise.2
> > > > +++ b/man2/madvise.2
> > > > @@ -265,6 +265,19 @@ file (see
> > > >  .BR MADV_DODUMP " (since Linux 3.4)"
> > > >  Undo the effect of an earlier
> > > >  .BR MADV_DONTDUMP .
> > > > +.TP
> > > > +.BR MADV_FREE " (since Linux 3.19)"
> > > > +Gives the VM system the freedom to free pages, and tells the system 
> > > > that
> > > > +information in the specified page range is no longer important.
> > > > +This is an efficient way of allowing
> > > > +.BR malloc (3)
> > > 
> > > This might be rather misleading. Only some malloc implementations are
> > > using this feature (jemalloc, right?). So either be specific about which
> > > implementation or do not add it at all.
> > 
> > Make sense. I don't think it's a good idea to say specific example
> > in man page, which is rather arguable and limit the idea.
> > 
> > > 
> > > > +to free pages anywhere in the address space, while keeping the address 
> > > > space
> > > > +valid. The next time that the page is referenced, the page might be 
> > > > demand
> > > > +zeroed, or might contain the data that was there before the MADV_FREE 
> > > > call.
> > > > +References made to that address space range will not make the VM 
> > > > system page the
> > > > +information back in from backing store until the page is modified 
> > > > again.
> > > 
> > > I am not sure I understand the last sentence. So say I did MADV_FREE and
> > > the reclaim has dropped that page. I know that the file backed mappings
> > > are not supported yet but assume they were for a second... Now, I do
> > > read from that location again what is the result?
> > 
> > Zero page.
> 
> OK, it felt strange at first but now that I am thinking about it some
> more it starts making sense. So the semantic is: Either zero page
> (disconnected from the backing store) or the original content after
> madvise(MADV_FREE). The page gets connected to the backing store after
> it gets modified again. If this is the case then the sentence in the man
> page makes perfect sense.
> 
> What made me confused was that I expected file backed pages would get a
> fresh page from the origin but this would be awkward I guess. 
> 
> > > If we consider anon mappings then the backing store is misleading as
> > > well because memory was dropped and so always newly allocated.
> > 
> > When I read the sentence at first, I thought backing store means swap
> > so I don't have any trouble to understand it. But I agree your opinion.
> > Target for man page is not a kernel developer but application developer.
> > 
> > > I would rather drop the whole sentence and rather see an explanation
> > > what is the difference between to MADV_DONT_NEED.
> > > "
> > > Unlike MADV_DONT_NEED the memory is freed lazily e.g. when the VM system
> > > is under memory pressure.
> > > "
> > 
> > It's a good idea but I don't think it's enough. At least we should explan
> > cancel of delay free logic(ie, write). So, How about this?
> > 
> > MADV_FREE " (since Linux 3.19)"
> > 
> > Gives the VM system the freedom to free pages, and tells the system that
> > it's okay to free pages if the VM system has reasons(e.g., memory pressure).
> > So, it looks like delayed MADV_DONTNEED.
> > The next time that the page is referenced, the page might be demand
> > zeroed if the VM system freed the page. Otherwise, it might contain the data
> > that was there before the MADV_FREE call if the VM system didn't free the 
> > page.
> > New write in the page after the MADV_FREE call makes the VM system not free
> > the page any more.
> 
> Dunno, I guess the original content was slightly better. Or the
> following wording from UNIX man pages is even more descriptive
> (http://www.lehman.cuny.edu/cgi-bin/man-cgi?madvise+3)
> "
> Tell the kernel that contents in the specified address range are no
> longer important and the range will be overwritten. When there is
> demand for memory, the system will free pages associated with the
> specified address range. In this instance, the next time a page in the
> address range is referenced, it will contain all zeroes.  Otherwise,
> it will con- tain the data that was there prior to the MADV_FREE
> call. References made to the address range will not make the system read
> from backing store (swap space) until the page is modified 

Re: [PATCH 2/2] acpi:apd:add AMD ACPI2Platform device support

2014-12-04 Thread Ken Xue
On Thu, 2014-12-04 at 13:58 +0200, Mika Westerberg wrote:
> On Wed, Dec 03, 2014 at 08:34:32PM +0800, Ken Xue wrote:
> > This is a new feature to interpret AMD specific ACPI device to
> > platform device such as I2C, UART found on AMD CZ and later
> > chipsets. It based on INTEL LPSS and acpi soc.
> > 
> > Signed-off-by: Ken Xue 
> > ---
> >  arch/x86/Kconfig| 11 +++
> >  drivers/acpi/Makefile   |  2 +-
> >  drivers/acpi/acpi_apd.c | 82 
> > +
> >  drivers/acpi/internal.h |  6 
> >  drivers/acpi/scan.c |  1 +
> >  5 files changed, 101 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/acpi/acpi_apd.c
> 
> Trying to compile this with !X86_AMD_PLATFORM_DEVICE gives me
> 
> drivers/acpi/acpi_apd.c:74:13: error: redefinition of ‘acpi_apd_init’
>  void __init acpi_apd_init(void)
>  ^
> In file included from drivers/acpi/acpi_apd.c:22:0:
> drivers/acpi/internal.h:74:20: note: previous definition of ‘acpi_apd_init’ 
> was here
>  static inline void acpi_apd_init(void) {}
> ^
> scripts/Makefile.build:257: recipe for target 'drivers/acpi/acpi_apd.o' failed
> make[2]: *** [drivers/acpi/acpi_apd.o] Error 1
> make[2]: *** Waiting for unfinished jobs
> 
> 
[Ken] sorry for it. it is my mistake.

> > 
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index ded8a67..6402c79f 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -495,6 +495,17 @@ config X86_INTEL_LPSS
> >   things like clock tree (common clock framework) and pincontrol
> >   which are needed by the LPSS peripheral drivers.
> >  
> > +config X86_AMD_PLATFORM_DEVICE
> > +   bool "AMD ACPI2Platform devices support"
> > +   depends on ACPI
> > +   select COMMON_CLK
> > +   select PINCTRL
> > +   ---help---
> > + Select to interpret AMD specific ACPI device to platform device
> > + such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
> > + this option enables things like clock tree (common clock framework)
> > + and pinctrl.
> > +
> >  config IOSF_MBI
> > tristate "Intel SoC IOSF Sideband support for SoC platforms"
> > depends on PCI
> > diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> > index ae3397d..b07003a 100644
> > --- a/drivers/acpi/Makefile
> > +++ b/drivers/acpi/Makefile
> > @@ -40,7 +40,7 @@ acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o
> >  acpi-y += ec.o
> >  acpi-$(CONFIG_ACPI_DOCK)   += dock.o
> >  acpi-y += pci_root.o pci_link.o pci_irq.o
> > -acpi-y += acpi_soc.o acpi_lpss.o
> > +acpi-y += acpi_soc.o acpi_lpss.o acpi_apd.o
> >  acpi-y += acpi_platform.o
> >  acpi-y += acpi_pnp.o
> >  acpi-y += int340x_thermal.o
> > diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
> > new file mode 100644
> > index 000..9afc144
> > --- /dev/null
> > +++ b/drivers/acpi/acpi_apd.c
> > @@ -0,0 +1,82 @@
> > +/*
> > + * AMD ACPI support for  ACPI2platform device.
> > + *
> > + * Copyright (c) 2014, AMD Corporation.
> > + * Authors: Ken Xue 
> > + * Wu, Jeff 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> 
> Are you sure you need all those headers?
> 
[ken] refine it with next release.

> > +#include "internal.h"
> > +#include "acpi_soc.h"
> > +
> > +struct acpi_soc asoc;
> > +
> > +#ifdef CONFIG_X86_AMD_PLATFORM_DEVICE
> > +#define APD_ADDR(desc) ((unsigned long))
> > +
> > +static int acpi_apd_setup(struct acpi_soc_dev_private_data *pdata)
> > +{
> > +   struct acpi_soc_dev_desc *dev_desc = pdata->dev_desc;
> > +   struct clk *clk = ERR_PTR(-ENODEV);
> > +
> > +   if (dev_desc->clk)
> > +   return 0;
> > +
> > +   if (dev_desc->fixed_clk_rate) {
> > +   clk = clk_register_fixed_rate(>adev->dev,
> > +   dev_name(>adev->dev),
> > +   NULL, CLK_IS_ROOT,
> > +   dev_desc->fixed_clk_rate);
> > +   dev_desc->clk = clk;
> > +   clk_register_clkdev(clk, NULL, dev_name(>adev->dev));
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static struct acpi_soc_dev_desc cz_i2c_desc = {
> > +   .setup = acpi_apd_setup,
> > +   .fixed_clk_rate = 13300,
> > +};
> > +
> > +static struct acpi_soc_dev_desc cz_uart_desc = {
> > +   .setup = acpi_apd_setup,
> > +   .fixed_clk_rate = 4800,
> > +};
> > +
> > +#else
> > +
> > +#define APD_ADDR(desc) (0UL)
> > +
> > +#endif /* CONFIG_X86_AMD_PLATFORM_DEVICE */
> > +
> > +static struct 

Re: [PATCH] arch: uapi: asm: mman.h: Let MADV_FREE have same value for all architectures

2014-12-04 Thread Minchan Kim
On Fri, Dec 05, 2014 at 06:58:29AM +0800, Chen Gang wrote:
> For uapi, need try to let all macros have same value, and MADV_FREE is
> added into main branch recently, so need redefine MADV_FREE for it.
> 
> At present, '8' can be shared with all architectures, so redefine it to
> '8'.
> 
> Signed-off-by: Chen Gang 


Hello Chen,

Thanks for looking at this.
Feel free to add my sign.

Acked-by: Minchan Kim 

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2 1/1] Drivers: hv: vmbus: Implement a clockevent device

2014-12-04 Thread Jason Wang



On Fri, Dec 5, 2014 at 10:18 AM, K. Y. Srinivasan  
wrote:

Implement a clockevent device based on the timer support
available on Hyper-V.

Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/include/uapi/asm/hyperv.h |   11 +
 drivers/hv/hv.c|   78 


 drivers/hv/hyperv_vmbus.h  |   21 ++
 drivers/hv/vmbus_drv.c |   40 +-
 4 files changed, 148 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h

index 462efe7..90c458e 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -187,6 +187,17 @@
 #define HV_X64_MSR_SINT14  0x409E
 #define HV_X64_MSR_SINT15  0x409F
 
+/*

+ * Synthetic Timer MSRs. Four timers per vcpu.
+ */
+#define HV_X64_MSR_STIMER0_CONFIG  0x40B0
+#define HV_X64_MSR_STIMER0_COUNT   0x40B1
+#define HV_X64_MSR_STIMER1_CONFIG  0x40B2
+#define HV_X64_MSR_STIMER1_COUNT   0x40B3
+#define HV_X64_MSR_STIMER2_CONFIG  0x40B4
+#define HV_X64_MSR_STIMER2_COUNT   0x40B5
+#define HV_X64_MSR_STIMER3_CONFIG  0x40B6
+#define HV_X64_MSR_STIMER3_COUNT   0x40B7
 
 #define HV_X64_MSR_HYPERCALL_ENABLE		0x0001

 #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT12
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 3e4235c..e2749c0 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -28,7 +28,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include "hyperv_vmbus.h"
 
 /* The one and only */

@@ -37,6 +39,10 @@ struct hv_context hv_context = {
.hypercall_page = NULL,
 };
 
+#define HV_TIMER_FREQUENCY (10 * 1000 * 1000) /* 100ns period */

+#define HV_MAX_MAX_DELTA_TICKS 0x
+#define HV_MIN_DELTA_TICKS 1
+
 /*
  * query_hypervisor_info - Get version info of the windows hypervisor
  */
@@ -144,6 +150,8 @@ int hv_init(void)
   sizeof(int) * NR_CPUS);
memset(hv_context.event_dpc, 0,
   sizeof(void *) * NR_CPUS);
+   memset(hv_context.clk_evt, 0,
+  sizeof(void *) * NR_CPUS);
 
 	max_leaf = query_hypervisor_info();
 
@@ -258,10 +266,63 @@ u16 hv_signal_event(void *con_id)

return status;
 }
 
+static int hv_ce_set_next_event(unsigned long delta,

+   struct clock_event_device *evt)
+{
+   cycle_t current_tick;
+
+   WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+
+   rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+   current_tick += delta;
+   wrmsrl(HV_X64_MSR_STIMER0_COUNT, current_tick);
+   return 0;
+}
+
+static void hv_ce_setmode(enum clock_event_mode mode,
+ struct clock_event_device *evt)
+{
+   union hv_timer_config timer_cfg;
+
+   switch (mode) {
+   case CLOCK_EVT_MODE_PERIODIC:
+   /* unsupported */
+   break;
+
+   case CLOCK_EVT_MODE_ONESHOT:
+   timer_cfg.enable = 1;
+   timer_cfg.auto_enable = 1;
+   timer_cfg.sintx = VMBUS_MESSAGE_SINT;
+   wrmsrl(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
+   break;
+
+   case CLOCK_EVT_MODE_UNUSED:
+   case CLOCK_EVT_MODE_SHUTDOWN:
+   wrmsrl(HV_X64_MSR_STIMER0_COUNT, 0);
+   wrmsrl(HV_X64_MSR_STIMER0_CONFIG, 0);
+   break;
+   case CLOCK_EVT_MODE_RESUME:
+   break;
+   }
+}
+
+static void hv_init_clockevent_device(struct clock_event_device 
*dev, int cpu)

+{
+   dev->name = "Hyper-V clockevent";
+   dev->features = CLOCK_EVT_FEAT_ONESHOT;
+   dev->cpumask = cpumask_of(cpu);
+   dev->rating = 1000,
+   dev->owner = THIS_MODULE,
+
+   dev->set_mode = hv_ce_setmode;
+   dev->set_next_event = hv_ce_set_next_event;
+}
+
 
 int hv_synic_alloc(void)

 {
size_t size = sizeof(struct tasklet_struct);
+   size_t ced_size = sizeof(struct clock_event_device);
int cpu;
 
 	for_each_online_cpu(cpu) {

@@ -272,6 +333,13 @@ int hv_synic_alloc(void)
}
tasklet_init(hv_context.event_dpc[cpu], vmbus_on_event, cpu);
 
+		hv_context.clk_evt[cpu] = kzalloc(ced_size, GFP_ATOMIC);

+   if (hv_context.clk_evt[cpu] == NULL) {
+   pr_err("Unable to allocate clock event device\n");
+   goto err;
+   }
+   hv_init_clockevent_device(hv_context.clk_evt[cpu], cpu);
+
hv_context.synic_message_page[cpu] =
(void *)get_zeroed_page(GFP_ATOMIC);
 
@@ -305,6 +373,7 @@ err:

 static void hv_synic_free_cpu(int cpu)
 {
kfree(hv_context.event_dpc[cpu]);
+   kfree(hv_context.clk_evt[cpu]);
if (hv_context.synic_event_page[cpu])
free_page((unsigned 

Re: [PATCH 1/2] acpi:soc: merge common codes for creating platform device

2014-12-04 Thread Ken Xue
On Thu, 2014-12-04 at 15:04 +0200, Mika Westerberg wrote:
> On Wed, Dec 03, 2014 at 08:33:37PM +0800, Ken Xue wrote:
> > This patch is supposed to deliver some common codes for AMD APD and
> > INTEL LPSS. It can help to convert some specific acpi devices to be
> > platform devices.
> > 
> > Signed-off-by: Ken Xue 
> > ---
> >  drivers/acpi/Makefile   |   2 +-
> >  drivers/acpi/acpi_soc.c | 211 
> > 
> >  drivers/acpi/acpi_soc.h |  90 +
> >  3 files changed, 302 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/acpi/acpi_soc.c
> >  create mode 100644 drivers/acpi/acpi_soc.h
> > 
> > diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> > index c3b2fcb..ae3397d 100644
> > --- a/drivers/acpi/Makefile
> > +++ b/drivers/acpi/Makefile
> > @@ -40,7 +40,7 @@ acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o
> >  acpi-y += ec.o
> >  acpi-$(CONFIG_ACPI_DOCK)   += dock.o
> >  acpi-y += pci_root.o pci_link.o pci_irq.o
> > -acpi-y += acpi_lpss.o
> > +acpi-y += acpi_soc.o acpi_lpss.o
> 
> I think you need to convert acpi_lpss.c to use this new acpi_soc.c.
> 
[ken] I would like to merge lpss. But you know that I am lack of INTEL
platforms to verify codes before submit. And i am a little worried about
i may not cover so much rich features of lpss well. so, can we merge
lpss after current patch? or what's your plan?

> >  acpi-y += acpi_platform.o
> >  acpi-y += acpi_pnp.o
> >  acpi-y += int340x_thermal.o
> > diff --git a/drivers/acpi/acpi_soc.c b/drivers/acpi/acpi_soc.c
> > new file mode 100644
> > index 000..25089a0
> > --- /dev/null
> > +++ b/drivers/acpi/acpi_soc.c
> > @@ -0,0 +1,211 @@
> > +/*
> > + * ACPI SOC support for Intel Lynxpoint LPSS and AMD APD.
> > + *
> > + * Copyright (C) 2015, Intel Corporation & AMD Corporation
> > + * Authors: Ken Xue 
> > + * Mika Westerberg 
> > + * Rafael J. Wysocki 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "internal.h"
> > +#include "acpi_soc.h"
> > +
> > +ACPI_MODULE_NAME("acpi_soc");
> > +
> > +/* A list for all acpi soc device */
> > +static LIST_HEAD(a_soc_list);
> > +
> > +static int is_memory(struct acpi_resource *res, void *not_used)
> > +{
> > +   struct resource r;
> > +
> > +   return !acpi_dev_resource_memory(res, );
> > +}
> > +
> > +static int acpi_soc_create_device(struct acpi_device *adev,
> > +  const struct acpi_device_id *id)
> > +{
> > +   struct acpi_soc_dev_desc *dev_desc;
> > +   struct acpi_soc_dev_private_data *pdata;
> > +   struct resource_list_entry *rentry;
> > +   struct list_head resource_list;
> > +   struct platform_device *pdev;
> > +   int ret;
> > +
> > +   dev_desc = (struct acpi_soc_dev_desc *)id->driver_data;
> > +   if (!dev_desc) {
> > +   pdev = acpi_create_platform_device(adev);
> > +   return IS_ERR_OR_NULL(pdev) ? PTR_ERR(pdev) : 1;
> > +   }
> > +   pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
> > +   if (!pdata)
> > +   return -ENOMEM;
> > +
> > +   INIT_LIST_HEAD(_list);
> > +   ret = acpi_dev_get_resources(adev, _list, is_memory, NULL);
> > +   if (ret < 0)
> > +   goto err_out;
> > +
> > +   list_for_each_entry(rentry, _list, node)
> > +   if (resource_type(>res) == IORESOURCE_MEM) {
> > +   if (dev_desc->mem_size_override)
> > +   pdata->mmio_size = dev_desc->mem_size_override;
> > +   else
> > +   pdata->mmio_size = resource_size(>res);
> > +   pdata->mmio_base = ioremap(rentry->res.start,
> > +  pdata->mmio_size);
> > +   break;
> > +   }
> > +
> > +   acpi_dev_free_resource_list(_list);
> > +
> > +   pdata->adev = adev;
> > +   pdata->dev_desc = dev_desc;
> > +
> > +   if (dev_desc->setup)
> > +   dev_desc->setup(pdata);
> > +
> > +   /*
> > +* This works around a known issue in ACPI tables where acpi soc devices
> > +* have _PS0 and _PS3 without _PSC (and no power resources), so
> > +* acpi_bus_init_power() will assume that the BIOS has put them into D0.
> > +*/
> > +   ret = acpi_device_fix_up_power(adev);
> > +   if (ret) {
> > +   /* Skip the device, but continue the namespace scan. */
> > +   ret = 0;
> > +   goto err_out;
> > +   }
> > +
> > +   adev->driver_data = pdata;
> > +   pdev = acpi_create_platform_device(adev);
> > +   if 

Re: [PATCH] staging: kernel: fixed style errors in pid.c

2014-12-04 Thread Joe Perches
On Fri, 2014-12-05 at 15:27 +0900, Joshua I. James wrote:
> Fixed style errors identified by checkpatch.

Your subject is not correct.

This is not staging.

Please submit patches only for drivers/staging until
until you are _very_ familiar with kernel style.

And most whitespace only changes to kernel/... are not
particularly welcomed by the most experienced kernel
developers.

> diff --git a/kernel/pid.c b/kernel/pid.c
[]
> @@ -471,8 +478,10 @@ EXPORT_SYMBOL_GPL(get_task_pid);
>  struct task_struct *get_pid_task(struct pid *pid, enum pid_type type)
>  {
>   struct task_struct *result;
> +
>   rcu_read_lock();
>   result = pid_task(pid, type);
> +

Unnecessary blank line added here.

btw: using scripts/checkpatch.pl --fix-inplace --strict
would have been better.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC V2] mm:add zero_page _mapcount when mapped into user space

2014-12-04 Thread Konstantin Khlebnikov
On Thu, Dec 4, 2014 at 3:28 PM, Kirill A. Shutemov  wrote:
> On Thu, Dec 04, 2014 at 02:10:53PM +0800, Wang, Yalin wrote:
>> > -Original Message-
>> > From: Kirill A. Shutemov [mailto:kir...@shutemov.name]
>> > Sent: Tuesday, December 02, 2014 7:30 PM
>> > To: Wang, Yalin
>> > Cc: 'linux-kernel@vger.kernel.org'; 'linux...@kvack.org'; 'linux-arm-
>> > ker...@lists.infradead.org'
>> > Subject: Re: [RFC V2] mm:add zero_page _mapcount when mapped into user
>> > space
>> >
>> > On Tue, Dec 02, 2014 at 05:27:36PM +0800, Wang, Yalin wrote:
>> > > This patch add/dec zero_page's _mapcount to make sure the mapcount is
>> > > correct for zero_page, so that when read from /proc/kpagecount,
>> > > zero_page's mapcount is also correct, userspace process like procrank
>> > > can calculate PSS correctly.

Instead of tweaking mapcount you could mark zero-pages in /proc/kpageflags
and handle them accordingly in userspace. Or mark zero pages with special
magic _mapcount and detect it in /proc/kpagecount.

>> >
>> > I don't have specific code path to point to, but I would expect zero page
>> > with non-zero mapcount would cause a problem with rmap.
>> >
>> > How do you test the change?
>> >
>> I just test it to see the mapcount from /proc/pid/pagemap  and 
>> /proc/kpagecount ,
>> It works well,
>
> I took a closer look and your patch is broken in multiple places:
>  - on zap_pte_range() you don't decrement mapcount;
>  - you don't update rss counters for mm;
>  - copy_one_pte() doesn't increase mapcount;
>  - ...
>
> Basically, each and every vm_normal_page() call must be audited. As first
> step. And you totally skip huge zero page.
>
> Proper mapcount handling for zero page would require a lot more work and I
> don't think it worth it. Gain is too small.
>
> NAK.
>
>> The problem is that when I see /proc/pid/smaps ,
>> The Rss / Pss don't calculate zero_page map,
>> Because smaps_pte_entry() --> vm_normal_page( ),
>> Will return NULL for zero_page,
>>
>> But when userspace process cat /proc/pid/pagemap  ,
>> It will see zero_page mapped,
>> And will treat as Rss ,
>> This is weird, should we also omit zero_page in /proc/pid/pagemap ?
>> Or add zero_page as Rss in /proc/pid/smaps ?
>>
>> I think we should add zero_page into Rss ,
>> Because it is really mapped into userspace address space.
>> And will let userspace memory analysis more accurate .
>
> It would be easier for userspace to find out pfn of zero page and take it
> into account.
>
> Note: some architectures have multiple zero page due to coloring.
>
> --
>  Kirill A. Shutemov
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org;> em...@kvack.org 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] sched/fair: fix find_idlest_cpu return -1

2014-12-04 Thread Hillf Danton
Cc: pang.xun...@zte.com.cn
> 
> From: zhang jun 
> 
> find_idlest_cpu return -1 is not reasonable, set default value to this_cpu.
> 
> Signed-off-by: zhang jun 
> Signed-off-by: Chuansheng Liu 
> Signed-off-by: Changcheng Liu 
> Cc: Hillf Danton 
> Cc: Vincent Guittot 
> Cc:  # 3.14.25
> ---
>  kernel/sched/fair.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 9b4c4f3..9d18887 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4151,7 +4151,7 @@ static int
>  find_idlest_cpu(struct sched_group *group, struct task_struct *p, int 
> this_cpu)
>  {
>   unsigned long load, min_load = ULONG_MAX;
> - int idlest = -1;
> + int idlest = this_cpu;
>   int i;
> 
>   /* Traverse only the allowed CPUs */
> @@ -4284,7 +4284,7 @@ select_task_rq_fair(struct task_struct *p, int 
> prev_cpu, int sd_flag, int wake_f
>   }
> 
>   new_cpu = find_idlest_cpu(group, p, cpu);
> - if (new_cpu == -1 || new_cpu == cpu) {
> + if (new_cpu == cpu) {
>   /* Now try balancing at a lower domain level of cpu */
>   sd = sd->child;
>   continue;
> --
> 1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: frequent lockups in 3.18rc4

2014-12-04 Thread Linus Torvalds
On Thu, Dec 4, 2014 at 9:00 PM, Sasha Levin  wrote:
>
> Just to add to this: I've enabled the simplest level of verbosity in the fault
> injection options, and RCU stalls are again easy to trigger:

Where do you log to?

In particular, do you have some serial line logging enabled (perhaps
even without anybody listening)? Or network logging?

We've definitely had cases where logging itself is so slow that it
triggers watchdogs etc. Logging to a serial line can take for*ever* in
modern terms..

  Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2014-12-04 Thread Andy Yan
Rockchip RK3288 hdmi is compatible with dw_hdmi

this patch is depend on patch by Mark Yao
drm: rockchip: Add basic drm driver
see https://lkml.org/lkml/2014/12/2/161

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17:
- parse resource and irq in platform driver

Changes in v16: None
Changes in v15:
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12:
- add comment for the depend on patch

Changes in v11: None
Changes in v10:
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c|   3 +
 drivers/gpu/drm/rockchip/Kconfig|  10 +
 drivers/gpu/drm/rockchip/Makefile   |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 341 
 include/drm/bridge/dw_hdmi.h|   1 +
 5 files changed, 357 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index cecc46a..01c95a8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -852,6 +852,9 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, 
unsigned char prep,
dw_hdmi_phy_gen2_txpwron(hdmi, 1);
dw_hdmi_phy_gen2_pddq(hdmi, 0);
 
+   if (hdmi->dev_type == RK3288_HDMI)
+   dw_hdmi_phy_enable_spare(hdmi, 1);
+
/*Wait for PHY PLL lock */
msec = 5;
do {
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index ca9f085..6ebebe8 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -15,3 +15,13 @@ config DRM_ROCKCHIP
  management to userspace. This driver does not provide
  2D or 3D acceleration; acceleration is performed by other
  IP found on the SoC.
+
+config ROCKCHIP_DW_HDMI
+bool "Rockchip specific extensions for Synopsys DW HDMI"
+depends on DRM_ROCKCHIP
+select DRM_DW_HDMI
+help
+ This selects support for Rockchip SoC specific extensions
+ for the Synopsys DesignWare HDMI driver. If you want to
+ enable HDMI on RK3288 based SoC, you should selet this
+ option.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index 2cb0672..beed7df 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -5,4 +5,6 @@
 rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
rockchip_drm_gem.o
 
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
+
 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_drm_vop.o
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
new file mode 100644
index 000..11d54b0
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -0,0 +1,341 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+
+#define GRF_SOC_CON60x025c
+#define HDMI_SEL_VOP_LIT(1 << 4)
+
+struct rockchip_hdmi {
+   struct device *dev;
+   struct regmap *regmap;
+   struct drm_encoder encoder;
+};
+
+#define to_rockchip_hdmi(x)container_of(x, struct rockchip_hdmi, x)
+
+static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
+   {
+   2700, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   3600, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   4000, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   5400, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6500, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6600, {
+  

Re: [PATCH 2/2] ftracetest: Add --verbose option for showing echo output

2014-12-04 Thread Masami Hiramatsu
(2014/12/05 14:52), Namhyung Kim wrote:
> On Fri, Dec 05, 2014 at 02:23:23PM +0900, Masami Hiramatsu wrote:
>> (2014/12/05 14:08), Namhyung Kim wrote:
>>> On Thu, Dec 04, 2014 at 02:41:23PM -0500, Masami Hiramatsu wrote:
 Add --verbose/-v option for showing echo output in testcases.
 This is good for checking the progress of testcases which
 take a longer time to run.

 To implement this feature, all the testcase failures are
 captured in ftracetest and send signal to set SIG_RESULT=FAIL.

 Signed-off-by: Masami Hiramatsu 
 ---
>>>
>>> [SNIP]
 -  # setup PID and PPID, $$ is not updated.
 -  (cd $TRACING_DIR; read PID _ < /proc/self/stat ;
 -   set -e; set -x; . $1) >> $testlog 2>&1
 -  eval_result $? $SIG_RESULT
 +  if [ $VERBOSE -ne 0 ]; then
 +__run_test $1 2>> $testlog | tee -a $testlog
>>>
>>> Shouldn't it be
>>>
>>>__run_test $1 2>&1 | tee -a $testlog
>>>
>>> ?
>>
>> No, that outputs both stdout and stderr to $testlog and console.
>> What I'd like to do above is only stdout to $testlog and console and
>> stderr goes only to $testlog. (Note that __run_test set -x which outputs
>> every executed command to stderr)
> 
> Hmm.. so the actual output of the failing command is not shown on
> console even when -v option is given, right?

No, if a command fails, the testcase is automatically terminated
(by set -e) and $testlog is dumped on console, so that tester can
trace back the log.

> Anyway I worried about that the order of messages might be mixed..
> 
>   echo msg1 > /dev/stdout
>   echo msg2 > /dev/stderr
>   echo msg3 > /dev/stdout
>   echo msg4 > /dev/stderr
> 
> So the output in this case can be like msg2, msg4, msg1, and msg3..?

I'm not sure this can happen... Would you have any other good way to
solve this?

Thank you,

-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu...@hitachi.com


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 11/12] dt-bindings: Add documentation for rockchip dw hdmi

2014-12-04 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v18:
- correct some spelling mistakes in dw_hdmi-rockchip bindings doc

Changes in v17: None
Changes in v16:
- modify clocks bindings
- descrbie ddc-i2c-bus as optional

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- Add documentation for rockchip dw hdmi

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/video/dw_hdmi-rockchip.txt | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt

diff --git a/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt 
b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
new file mode 100644
index 000..668091f
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
@@ -0,0 +1,46 @@
+Rockchip specific extensions to the Synopsys Designware HDMI
+
+
+Required properties:
+- compatible: "rockchip,rk3288-dw-hdmi";
+- reg: Physical base address and length of the controller's registers.
+- clocks: phandle to hdmi iahb and isfr clocks.
+- clock-names: should be "iahb" "isfr"
+- rockchip,grf: this soc should set GRF regs to mux vopl/vopb.
+- interrupts: HDMI interrupt number
+- ports: contain a port node with endpoint definitions as defined in
+  Documentation/devicetree/bindings/media/video-interfaces.txt. For
+  vopb,set the reg = <0> and set the reg = <1> for vopl.
+- reg-io-width: the width of the reg:1,4, the value should be 4 on
+  rk3288 platform
+
+Optional properties
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clocks, clock-names: phandle to the HDMI CEC clock, name should be "cec"
+
+Example:
+hdmi: hdmi@ff98 {
+   compatible = "rockchip,rk3288-dw-hdmi";
+   reg = <0xff98 0x2>;
+   reg-io-width = <4>;
+   ddc-i2c-bus = <>;
+   rockchip,grf = <>;
+   interrupts = ;
+   clocks = <  PCLK_HDMI_CTRL>, < SCLK_HDMI_HDCP>;
+   clock-names = "iahb", "isfr";
+   status = "disabled";
+   ports {
+   hdmi_in: port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   hdmi_in_vopb: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <_out_hdmi>;
+   };
+   hdmi_in_vopl: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <_out_hdmi>;
+   };
+   };
+   };
+};
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 10/12] drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare

2014-12-04 Thread Andy Yan
RK3288 HDMI will not work without the spare bit of
HDMI_PHY_CONF0 enable

Signed-off-by: Andy Yan 
---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 7 +++
 drivers/gpu/drm/bridge/dw_hdmi.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 2264ec1..cecc46a 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -713,6 +713,13 @@ static void dw_hdmi_phy_enable_tmds(struct dw_hdmi *hdmi, 
u8 enable)
 HDMI_PHY_CONF0_ENTMDS_MASK);
 }
 
+static void dw_hdmi_phy_enable_spare(struct dw_hdmi *hdmi, u8 enable)
+{
+   hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
+HDMI_PHY_CONF0_SPARECTRL_OFFSET,
+HDMI_PHY_CONF0_SPARECTRL_MASK);
+}
+
 static void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable)
 {
hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
diff --git a/drivers/gpu/drm/bridge/dw_hdmi.h b/drivers/gpu/drm/bridge/dw_hdmi.h
index baa7849..175dbc8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.h
+++ b/drivers/gpu/drm/bridge/dw_hdmi.h
@@ -837,7 +837,8 @@ enum {
HDMI_PHY_CONF0_PDZ_OFFSET = 7,
HDMI_PHY_CONF0_ENTMDS_MASK = 0x40,
HDMI_PHY_CONF0_ENTMDS_OFFSET = 6,
-   HDMI_PHY_CONF0_SPARECTRL = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_MASK = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_OFFSET = 5,
HDMI_PHY_CONF0_GEN2_PDDQ_MASK = 0x10,
HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET = 4,
HDMI_PHY_CONF0_GEN2_TXPWRON_MASK = 0x8,
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 09/12] drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done

2014-12-04 Thread Andy Yan
HDMI_IH_I2CMPHY_STAT0 is a clear on write register, which indicates i2cm
operation status(i2c transfer done or error), every hdmi phy register
configuration must check this register to make sure the configuration
has complete. But the indication bit should be cleared after check, otherwise
the corresponding bit will hold on forever, this may give a wrong signal for
next check.

Signed-off-by: Andy Yan 
---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index d5bec0c..2264ec1 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -666,11 +666,15 @@ static inline void hdmi_phy_test_dout(struct dw_hdmi 
*hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct dw_hdmi *hdmi, int msec)
 {
-   while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
+   u32 val;
+
+   while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
if (msec-- == 0)
return false;
udelay(1000);
}
+   hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0);
+
return true;
 }
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sched/fair: tiny clearup of -1

2014-12-04 Thread jun . zhang
From: zhang jun 

find_idlest_cpu don't return -1, so clearup it.

Signed-off-by: zhang jun 
Signed-off-by: Chuansheng Liu 
Signed-off-by: Changcheng Liu 
Cc: Greg Kroah-Hartman 
Cc: Hillf Danton 
Cc: Vincent Guittot 
---
 kernel/sched/fair.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ef2b104..bbf965f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4596,7 +4596,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, 
int sd_flag, int wake_f
}
 
new_cpu = find_idlest_cpu(group, p, cpu);
-   if (new_cpu == -1 || new_cpu == cpu) {
+   if (new_cpu == cpu) {
/* Now try balancing at a lower domain level of cpu */
sd = sd->child;
continue;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 08/12] drm: bridge/dw_hdmi: add mode_valid support

2014-12-04 Thread Andy Yan
some platform may not support all the display mode,
add mode_valid interface check it

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14:
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index d49861c..d5bec0c 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -1405,6 +1405,20 @@ static int dw_hdmi_connector_get_modes(struct 
drm_connector *connector)
return 0;
 }
 
+static enum drm_mode_status
+dw_hdmi_connector_mode_valid(struct drm_connector *connector,
+struct drm_display_mode *mode)
+{
+   struct dw_hdmi *hdmi = container_of(connector,
+  struct dw_hdmi, connector);
+   enum drm_mode_status mode_status = MODE_OK;
+
+   if (hdmi->plat_data->mode_valid)
+   mode_status = hdmi->plat_data->mode_valid(connector, mode);
+
+   return mode_status;
+}
+
 static struct drm_encoder *dw_hdmi_connector_best_encoder(struct drm_connector
   *connector)
 {
@@ -1429,6 +1443,7 @@ static struct drm_connector_funcs dw_hdmi_connector_funcs 
= {
 
 static struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = {
.get_modes = dw_hdmi_connector_get_modes,
+   .mode_valid = dw_hdmi_connector_mode_valid,
.best_encoder = dw_hdmi_connector_best_encoder,
 };
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 07/12] drm: bridge/dw_hdmi: add support for multi-byte register width access

2014-12-04 Thread Andy Yan
On rockchip rk3288, only word(32-bit) accesses are
permitted for hdmi registers.  Byte width accesses (writeb,
readb) generate an imprecise external abort.

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15:
- remove unio of the multi-byte register access, adviced by Philipp Zabel

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4: None
Changes in v3:
- split multi-register access to one indepent patch

 drivers/gpu/drm/bridge/dw_hdmi.c | 44 ++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index e0a7bc3..d49861c 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -128,18 +128,41 @@ struct dw_hdmi {
 
unsigned int sample_rate;
int ratio;
+
+   void (*write)(struct dw_hdmi *hdmi, u8 val, int offset);
+   u8 (*read)(struct dw_hdmi *hdmi, int offset);
 };
 
-static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+static void dw_hdmi_writel(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   writel(val, hdmi->regs + (offset << 2));
+}
+
+static u8 dw_hdmi_readl(struct dw_hdmi *hdmi, int offset)
+{
+   return readl(hdmi->regs + (offset << 2));
+}
+
+static void dw_hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+static u8 dw_hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   hdmi->write(hdmi, val, offset);
+}
+
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+{
+   return hdmi->read(hdmi, offset);
+}
+
 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
@@ -1511,6 +1534,7 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
struct device_node *ddc_node;
struct dw_hdmi *hdmi;
int ret;
+   u32 val = 1;
 
hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
@@ -1523,6 +1547,22 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
hdmi->ratio = 100;
hdmi->encoder = encoder;
 
+   of_property_read_u32(np, "reg-io-width", );
+
+   switch (val) {
+   case 4:
+   hdmi->write = dw_hdmi_writel;
+   hdmi->read = dw_hdmi_readl;
+   break;
+   case 1:
+   hdmi->write = dw_hdmi_writeb;
+   hdmi->read = dw_hdmi_readb;
+   break;
+   default:
+   dev_err(dev, "reg-io-width must be 1 or 4\n");
+   return -EINVAL;
+   }
+
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: kernel: fixed style errors in pid.c

2014-12-04 Thread Joshua I. James
From: "Joshua I. James" 

Fixed style errors identified by checkpatch.

ERROR: space prohibited after that open square bracket '['
WARNING: Missing a blank line after declarations
ERROR: space required before the open parenthesis '('
WARNING: line over 80 characters
WARNING: quoted string split across lines

Signed-off-by: Joshua I. James 
---
 kernel/pid.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/kernel/pid.c b/kernel/pid.c
index 9b9a266..8e92d38 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -72,7 +72,7 @@ struct pid_namespace init_pid_ns = {
.refcount   = ATOMIC_INIT(2),
},
.pidmap = {
-   [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
+   [0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
},
.last_pid = 0,
.nr_hashed = PIDNS_HASH_ADDING,
@@ -142,6 +142,7 @@ static void set_last_pid(struct pid_namespace *pid_ns, int 
base, int pid)
 {
int prev;
int last_write = base;
+
do {
prev = last_write;
last_write = cmpxchg(_ns->last_pid, prev, pid);
@@ -250,6 +251,7 @@ EXPORT_SYMBOL_GPL(put_pid);
 static void delayed_put_pid(struct rcu_head *rhp)
 {
struct pid *pid = container_of(rhp, struct pid, rcu);
+
put_pid(pid);
 }
 
@@ -263,8 +265,9 @@ void free_pid(struct pid *pid)
for (i = 0; i <= pid->level; i++) {
struct upid *upid = pid->numbers + i;
struct pid_namespace *ns = upid->ns;
+
hlist_del_rcu(>pid_chain);
-   switch(--ns->nr_hashed) {
+   switch (--ns->nr_hashed) {
case 2:
case 1:
/* When all that is left in the pid namespace
@@ -383,6 +386,7 @@ EXPORT_SYMBOL_GPL(find_vpid);
 void attach_pid(struct task_struct *task, enum pid_type type)
 {
struct pid_link *link = >pids[type];
+
hlist_add_head_rcu(>node, >pid->tasks[type]);
 }
 
@@ -429,12 +433,15 @@ void transfer_pid(struct task_struct *old, struct 
task_struct *new,
 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
 {
struct task_struct *result = NULL;
+
if (pid) {
struct hlist_node *first;
+
first = 
rcu_dereference_check(hlist_first_rcu(>tasks[type]),
  lockdep_tasklist_lock_is_held());
if (first)
-   result = hlist_entry(first, struct task_struct, 
pids[(type)].node);
+   result = hlist_entry(first, struct task_struct,
+   pids[(type)].node);
}
return result;
 }
@@ -446,8 +453,7 @@ EXPORT_SYMBOL(pid_task);
 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
 {
rcu_lockdep_assert(rcu_read_lock_held(),
-  "find_task_by_pid_ns() needs rcu_read_lock()"
-  " protection");
+   "find_task_by_pid_ns() needs rcu_read_lock() protection");
return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
 }
 
@@ -459,6 +465,7 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
 {
struct pid *pid;
+
rcu_read_lock();
if (type != PIDTYPE_PID)
task = task->group_leader;
@@ -471,8 +478,10 @@ EXPORT_SYMBOL_GPL(get_task_pid);
 struct task_struct *get_pid_task(struct pid *pid, enum pid_type type)
 {
struct task_struct *result;
+
rcu_read_lock();
result = pid_task(pid, type);
+
if (result)
get_task_struct(result);
rcu_read_unlock();
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 06/12] dt-bindings: add document for dw_hdmi

2014-12-04 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v18:
- add port bindings
- correct some spelling mistakes in dw_hdmi bindings doc

Changes in v17: None
Changes in v16:
- describe ddc-i2c-bus as optional
- add common clocks bindings

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 50 ++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..a905c14
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,50 @@
+DesignWare HDMI bridge bindings
+
+Required properties:
+- compatible: platform specific such as:
+   * "snps,dw-hdmi-tx"
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"
+- reg: Physical base address and length of the controller's registers.
+- interrupts: The HDMI interrupt number
+- clocks, clock-names : must have the phandles to the HDMI iahb and isfr 
clocks,
+  as described in Documentation/devicetree/bindings/clock/clock-bindings.txt,
+  the clocks are soc specific, the clock-names should be "iahb", "isfr"
+-port@[X]: SoC specific port nodes with endpoint definitions as defined
+   in Documentation/devicetree/bindings/media/video-interfaces.txt,
+   please refer to the SoC specific binding document:
+* Documentation/devicetree/bindings/drm/imx/hdmi.txt
+* Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
+
+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clocks, clock-names: phandle to the HDMI CEC clock, name should be "cec"
+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";
+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <>;
+   clocks = < 123>, < 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <_di1_hdmi>;
+   };
+   };
+   };
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[git pull] drm intel fixes

2014-12-04 Thread Dave Airlie

Hi Linus,

two intel stable fixes, that should be it from me for this round.

Dave.

The following changes since commit ebea76f5b95caddb59f49a3e288da26358e6ab1f:

  Merge tag 'media/v3.18-rc8' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media (2014-12-04 
16:06:02 -0800)

are available in the git repository at:


  git://people.freedesktop.org/~airlied/linux drm-fixes

for you to fetch changes up to 3e3282c0a23d8eb9438dcf4ac908a5eb48c7038b:

  Merge tag 'drm-intel-fixes-2014-12-04' of 
git://anongit.freedesktop.org/drm-intel into drm-fixes (2014-12-05 11:12:29 
+1000)



Daniel Vetter (2):
  drm/i915: More cautious with pch fifo underruns
  drm/i915: Unlock panel even when LVDS is disabled

Dave Airlie (1):
  Merge tag 'drm-intel-fixes-2014-12-04' of 
git://anongit.freedesktop.org/drm-intel into drm-fixes

 drivers/gpu/drm/i915/intel_display.c |  2 --
 drivers/gpu/drm/i915/intel_lvds.c| 22 +++---
 2 files changed, 11 insertions(+), 13 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 05/12] drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi

2014-12-04 Thread Andy Yan
the original imx hdmi driver is under drm/imx/,
which depends on imx-drm, so move the imx hdmi
driver out to drm/bridge and rename it to dw_hdmi

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17:
- remove prompt message of dw_hdmi, adviced by Russel King

Changes in v16: None
Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 278 +++--
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |  43 
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 .../drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c}| 110 
 include/drm/bridge/dw_hdmi.h   |  60 +
 8 files changed, 262 insertions(+), 238 deletions(-)
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (84%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (98%)
 rename drivers/gpu/drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c} (58%)
 create mode 100644 include/drm/bridge/dw_hdmi.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 884923f..4d822f0 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -3,3 +3,8 @@ config DRM_PTN3460
depends on DRM
select DRM_KMS_HELPER
---help---
+
+config DRM_DW_HDMI
+   bool
+   depends on DRM
+   select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index b4733e1..d8a8cfd 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
+obj-$(CONFIG_DRM_DW_HDMI) += dw_hdmi.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
similarity index 84%
rename from drivers/gpu/drm/imx/imx-hdmi.c
rename to drivers/gpu/drm/bridge/dw_hdmi.c
index 409fb4f..e0a7bc3 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -6,12 +6,11 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
- * SH-Mobile High-Definition Multimedia Interface (HDMI) driver
- * for SLISHDMI13T and SLIPHDMIT IP cores
+ * Designware High-Definition Multimedia Interface (HDMI) driver
  *
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
-
+#include 
 #include 
 #include 
 #include 
@@ -24,8 +23,9 @@
 #include 
 #include 
 #include 
+#include 
 
-#include "imx-hdmi.h"
+#include "dw_hdmi.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -101,18 +101,19 @@ struct hdmi_data_info {
struct hdmi_vmode video_mode;
 };
 
-struct imx_hdmi {
+struct dw_hdmi {
struct drm_connector connector;
struct drm_encoder *encoder;
struct drm_bridge *bridge;
 
-   enum imx_hdmi_devtype dev_type;
+   enum dw_hdmi_devtype dev_type;
struct device *dev;
struct clk *isfr_clk;
struct clk *iahb_clk;
 
struct hdmi_data_info hdmi_data;
-   const struct imx_hdmi_plat_data *plat_data;
+   const struct dw_hdmi_plat_data *plat_data;
+
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -129,17 +130,17 @@ struct imx_hdmi {
int ratio;
 };
 
-static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct imx_hdmi *hdmi, int offset)
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
-static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
+static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
 
@@ -147,13 +148,13 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
hdmi_writeb(hdmi, val, reg);
 }
 
-static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
+static void hdmi_mask_writeb(struct dw_hdmi *hdmi, u8 data, unsigned int reg,
 u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
 
-static void hdmi_set_clock_regenerator_n(struct imx_hdmi *hdmi,
+static void hdmi_set_clock_regenerator_n(struct dw_hdmi *hdmi,
 unsigned int value)
 {
hdmi_writeb(hdmi, value & 0xff, HDMI_AUD_N1);
@@ -164,7 +165,7 @@ static void 

[PATCH v18 04/12] drm: imx: imx-hdmi: split phy configuration to platform driver

2014-12-04 Thread Andy Yan
hdmi phy configuration is platform specific, which can be adusted
according to the board to get the best SI

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13:
- split phy configuration from patch#4

Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c   | 85 +++-
 drivers/gpu/drm/imx/imx-hdmi.h   | 29 
 drivers/gpu/drm/imx/imx-hdmi_pltfm.c | 57 
 3 files changed, 101 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index d72f82c..409fb4f 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -713,76 +713,14 @@ static void imx_hdmi_phy_sel_interface_control(struct 
imx_hdmi *hdmi, u8 enable)
 HDMI_PHY_CONF0_SELDIPIF_MASK);
 }
 
-enum {
-   RES_8,
-   RES_10,
-   RES_12,
-   RES_MAX,
-};
-
-struct mpll_config {
-   unsigned long mpixelclock;
-   struct {
-   u16 cpce;
-   u16 gmp;
-   } res[RES_MAX];
-};
-
-static const struct mpll_config mpll_config[] = {
-   {
-   4525, {
-   { 0x01e0, 0x },
-   { 0x21e1, 0x },
-   { 0x41e2, 0x }
-   },
-   }, {
-   9250, {
-   { 0x0140, 0x0005 },
-   { 0x2141, 0x0005 },
-   { 0x4142, 0x0005 },
-   },
-   }, {
-   14850, {
-   { 0x00a0, 0x000a },
-   { 0x20a1, 0x000a },
-   { 0x40a2, 0x000a },
-   },
-   }, {
-   ~0UL, {
-   { 0x00a0, 0x000a },
-   { 0x2001, 0x000f },
-   { 0x4002, 0x000f },
-   },
-   }
-};
-
-struct curr_ctrl {
-   unsigned long mpixelclock;
-   u16 curr[RES_MAX];
-};
-
-static const struct curr_ctrl curr_ctrl[] = {
-   /*  pixelclk bpp8bpp10   bpp12 */
-   {
-5400, { 0x091c, 0x091c, 0x06dc },
-   }, {
-5840, { 0x091c, 0x06dc, 0x06dc },
-   }, {
-7200, { 0x06dc, 0x06dc, 0x091c },
-   }, {
-7425, { 0x06dc, 0x0b5c, 0x091c },
-   }, {
-   11880, { 0x091c, 0x091c, 0x06dc },
-   }, {
-   21600, { 0x06dc, 0x0b5c, 0x091c },
-   }
-};
-
 static int hdmi_phy_configure(struct imx_hdmi *hdmi, unsigned char prep,
  unsigned char res, int cscon)
 {
unsigned res_idx, i;
u8 val, msec;
+   const struct mpll_config *mpll_config = hdmi->plat_data->mpll_cfg;
+   const struct curr_ctrl   *curr_ctrl = hdmi->plat_data->cur_ctr;
+   const struct sym_term *sym_term =  hdmi->plat_data->sym_term;
 
if (prep)
return -EINVAL;
@@ -828,7 +766,7 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
hdmi_phy_test_clear(hdmi, 0);
 
/* PLL/MPLL Cfg - always match on final entry */
-   for (i = 0; i < ARRAY_SIZE(mpll_config) - 1; i++)
+   for (i = 0; mpll_config[i].mpixelclock != (~0UL); i++)
if (hdmi->hdmi_data.video_mode.mpixelclock <=
mpll_config[i].mpixelclock)
break;
@@ -836,12 +774,12 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].cpce, 0x06);
hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].gmp, 0x15);
 
-   for (i = 0; i < ARRAY_SIZE(curr_ctrl); i++)
+   for (i = 0; curr_ctrl[i].mpixelclock != (~0UL); i++)
if (hdmi->hdmi_data.video_mode.mpixelclock <=
curr_ctrl[i].mpixelclock)
break;
 
-   if (i >= ARRAY_SIZE(curr_ctrl)) {
+   if (curr_ctrl[i].mpixelclock == (~0UL)) {
dev_err(hdmi->dev, "Pixel clock %d - unsupported by HDMI\n",
hdmi->hdmi_data.video_mode.mpixelclock);
return -EINVAL;
@@ -852,10 +790,17 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
 
hdmi_phy_i2c_write(hdmi, 0x, 0x13);  /* PLLPHBYCTRL */
hdmi_phy_i2c_write(hdmi, 0x0006, 0x17);
+
+   for (i = 0; sym_term[i].mpixelclock != (~0UL); i++)
+   if (hdmi->hdmi_data.video_mode.mpixelclock <=
+   sym_term[i].mpixelclock)
+   break;
+
/* RESISTANCE TERM 133Ohm Cfg */
-   hdmi_phy_i2c_write(hdmi, 0x0005, 0x19);  /* TXTERM */
+   

Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()

2014-12-04 Thread Julia Lawall
On Thu, 4 Dec 2014, Joe Perches wrote:

> On Thu, 2014-12-04 at 23:27 +0100, SF Markus Elfring wrote:
> > >> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
> > > []
> > >> @@ -172,9 +172,8 @@ static void mppe_rekey(struct ppp_mppe_state * 
> > >> state, int initial_key)
> > >>  setup_sg(sg_in, state->sha1_digest, state->keylen);
> > >>  setup_sg(sg_out, state->session_key, state->keylen);
> > >>  if (crypto_blkcipher_encrypt(, sg_out, sg_in,
> > >> - state->keylen) != 0) {
> > >> -printk(KERN_WARNING "mppe_rekey: cipher_encrypt 
> > >> failed\n");
> > >> -}
> > >> + state->keylen) != 0)
> > >> +pr_warn("mppe_rekey: cipher_encrypt failed\n");
> > > 
> > > It's generally nicer to replace embedded function names
> > > with "%s: ", __func__
> > > 
> > >   pr_warn("%s: cipher_encrypt failed\n", __func__);
> > 
> > Do you want that I send a third patch series for the fine-tuning of these 
> > parameters?
> 
> If you want.
> 
> I just wanted you to be aware of it for future patches.

Markus, are you sure that you cannot use netdev_warn in this case?

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 03/12] drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode

2014-12-04 Thread Andy Yan
IMX6 and Rockchip RK3288 and JZ4780 (Ingenic Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they
also have some lightly differences, such as phy pll configuration,
register width, 4K support, clk useage, and the crtc mux configuration
is also platform specific.

To reuse the imx hdmi driver, convert it to drm_bridge

handle encoder in imx-hdmi_pltfm.c, as most of the encoder
operation are platform specific such as crtc select and
panel format set

This patch depends on Russell King's patch:
 drm: imx: convert imx-drm to use the generic DRM OF helper
 
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2014-July/053484.html

Signed-off-by: Andy Yan 
Signed-off-by: Yakir Yang 

---

Changes in v18:
- remove a multiple blank lines in imx-hdmi.c
- fix a checkpatch warning in imx-hdmi_pltfm.c

Changes in v17:
- remove platform device stuff, adviced by Russell King

Changes in v16:
- use the common binding for the clocks

Changes in v15: None
Changes in v14:
- add defer probing, adviced by Philipp Zabel

Changes in v13:
- split platform specific phy configuration

Changes in v12:
- squash patch 

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 support)

Changes in v9: None
Changes in v8: None
Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/imx/Makefile |   2 +-
 drivers/gpu/drm/imx/imx-hdmi.c   | 258 +--
 drivers/gpu/drm/imx/imx-hdmi.h   |  15 ++
 drivers/gpu/drm/imx/imx-hdmi_pltfm.c | 203 +++
 4 files changed, 315 insertions(+), 163 deletions(-)
 create mode 100644 drivers/gpu/drm/imx/imx-hdmi_pltfm.c

diff --git a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile
index 582c438..63cf56a 100644
--- a/drivers/gpu/drm/imx/Makefile
+++ b/drivers/gpu/drm/imx/Makefile
@@ -9,4 +9,4 @@ obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o
 
 imx-ipuv3-crtc-objs  := ipuv3-crtc.o ipuv3-plane.o
 obj-$(CONFIG_DRM_IMX_IPUV3)+= imx-ipuv3-crtc.o
-obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o
+obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o imx-hdmi_pltfm.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 7a54d20..d72f82c 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -12,25 +12,20 @@
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "imx-hdmi.h"
-#include "imx-drm.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -54,11 +49,6 @@ enum hdmi_datamap {
YCbCr422_12B = 0x12,
 };
 
-enum imx_hdmi_devtype {
-   IMX6Q_HDMI,
-   IMX6DL_HDMI,
-};
-
 static const u16 csc_coeff_default[3][4] = {
{ 0x2000, 0x, 0x, 0x },
{ 0x, 0x2000, 0x, 0x },
@@ -113,7 +103,8 @@ struct hdmi_data_info {
 
 struct imx_hdmi {
struct drm_connector connector;
-   struct drm_encoder encoder;
+   struct drm_encoder *encoder;
+   struct drm_bridge *bridge;
 
enum imx_hdmi_devtype dev_type;
struct device *dev;
@@ -121,6 +112,7 @@ struct imx_hdmi {
struct clk *iahb_clk;
 
struct hdmi_data_info hdmi_data;
+   const struct imx_hdmi_plat_data *plat_data;
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -137,13 +129,6 @@ struct imx_hdmi {
int ratio;
 };
 
-static void imx_hdmi_set_ipu_di_mux(struct imx_hdmi *hdmi, int ipu_di)
-{
-   regmap_update_bits(hdmi->regmap, IOMUXC_GPR3,
-  IMX6Q_GPR3_HDMI_MUX_CTL_MASK,
-  ipu_di << IMX6Q_GPR3_HDMI_MUX_CTL_SHIFT);
-}
-
 static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
@@ -1371,6 +1356,50 @@ static void imx_hdmi_poweroff(struct imx_hdmi *hdmi)
imx_hdmi_phy_disable(hdmi);
 }
 
+static void imx_hdmi_bridge_mode_set(struct drm_bridge *bridge,
+struct drm_display_mode *mode,
+struct drm_display_mode *adjusted_mode)
+{
+   struct imx_hdmi *hdmi = bridge->driver_private;
+
+   imx_hdmi_setup(hdmi, mode);
+
+   /* Store the display mode for plugin/DKMS poweron events */
+   memcpy(>previous_mode, mode, sizeof(hdmi->previous_mode));
+}
+
+static bool imx_hdmi_bridge_mode_fixup(struct drm_bridge *bridge,
+  const struct drm_display_mode *mode,
+  struct drm_display_mode *adjusted_mode)
+{
+   return true;
+}
+
+static void imx_hdmi_bridge_disable(struct drm_bridge *bridge)
+{
+   struct imx_hdmi *hdmi = bridge->driver_private;
+
+

Re: [RFC v2] percpu: Add a separate function to merge free areas

2014-12-04 Thread Konstantin Khlebnikov
On Fri, Dec 5, 2014 at 12:20 AM, Christoph Lameter  wrote:
> On Thu, 4 Dec 2014, Tejun Heo wrote:
>
>> Docker usage is pretty wide-spread now, making what used to be
>> siberia-cold paths hot enough to cause actual scalability issues.
>> Besides, we're now using percpu_ref for things like aio and cgroup
>> control structures which can be created and destroyed quite
>> frequently.  I don't think we can say these are "weird" use cases
>> anymore.
>
> Well then lets write a scalable percpu allocator.

percpu allocator maybe be overkill but I think it's worth to make
kmem_cache-like thing with pool of objects.

>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org;> em...@kvack.org 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 02/12] drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter

2014-12-04 Thread Andy Yan
drm driver may probe before the i2c bus, so the driver should
defer probing until it is available

Signed-off-by: Andy Yan 
Reviewed-by: Daniel Kurtz 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12:
- refactor of_node_put(ddc_node)

Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- defer probe ddc i2c adapter

Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 7fd90ae..7a54d20 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -1611,10 +1611,12 @@ static int imx_hdmi_bind(struct device *dev, struct 
device *master, void *data)
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-   if (!hdmi->ddc)
+   of_node_put(ddc_node);
+   if (!hdmi->ddc) {
dev_dbg(hdmi->dev, "failed to read ddc node\n");
+   return -EPROBE_DEFER;
+   }
 
-   of_node_put(ddc_node);
} else {
dev_dbg(hdmi->dev, "no ddc property found\n");
}
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v18 01/12] drm: imx: imx-hdmi: make checkpatch happy

2014-12-04 Thread Andy Yan
CHECK: Alignment should match open parenthesis
+   if ((hdmi->vic == 10) || (hdmi->vic == 11) ||
+   (hdmi->vic == 12) || (hdmi->vic == 13) ||

CHECK: braces {} should be used on all arms of this statement
+   if (hdmi->hdmi_data.video_mode.mdvi)
[...]
+   else {
[...]

Signed-off-by: Andy Yan 
Reviewed-by: Daniel Kurtz 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13:
- patch against drm-next

Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- rearrange the patch order

Changes in v5: None
Changes in v4:
- fix checkpatch CHECK

Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c | 109 -
 1 file changed, 52 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index aaec6b2..7fd90ae 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -163,7 +163,7 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
 }
 
 static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
- u8 shift, u8 mask)
+u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
@@ -327,7 +327,7 @@ static unsigned int hdmi_compute_cts(unsigned int freq, 
unsigned long pixel_clk,
 }
 
 static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi,
-   unsigned long pixel_clk)
+unsigned long pixel_clk)
 {
unsigned int clk_n, clk_cts;
 
@@ -338,7 +338,7 @@ static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi,
 
if (!clk_cts) {
dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n",
-__func__, pixel_clk);
+   __func__, pixel_clk);
return;
}
 
@@ -477,13 +477,11 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi 
*hdmi)
u16 coeff_b = (*csc_coeff)[1][i];
u16 coeff_c = (*csc_coeff)[2][i];
 
-   hdmi_writeb(hdmi, coeff_a & 0xff,
-   HDMI_CSC_COEF_A1_LSB + i * 2);
+   hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2);
hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2);
-   hdmi_writeb(hdmi, coeff_c & 0xff,
-   HDMI_CSC_COEF_C1_LSB + i * 2);
+   hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2);
}
 
@@ -535,21 +533,22 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
struct hdmi_data_info *hdmi_data = >hdmi_data;
u8 val, vp_conf;
 
-   if (hdmi_data->enc_out_format == RGB
-   || hdmi_data->enc_out_format == YCBCR444) {
-   if (!hdmi_data->enc_color_depth)
+   if (hdmi_data->enc_out_format == RGB ||
+   hdmi_data->enc_out_format == YCBCR444) {
+   if (!hdmi_data->enc_color_depth) {
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
-   else if (hdmi_data->enc_color_depth == 8) {
+   } else if (hdmi_data->enc_color_depth == 8) {
color_depth = 4;
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
-   } else if (hdmi_data->enc_color_depth == 10)
+   } else if (hdmi_data->enc_color_depth == 10) {
color_depth = 5;
-   else if (hdmi_data->enc_color_depth == 12)
+   } else if (hdmi_data->enc_color_depth == 12) {
color_depth = 6;
-   else if (hdmi_data->enc_color_depth == 16)
+   } else if (hdmi_data->enc_color_depth == 16) {
color_depth = 7;
-   else
+   } else {
return;
+   }
} else if (hdmi_data->enc_out_format == YCBCR422_8BITS) {
if (!hdmi_data->enc_color_depth ||
hdmi_data->enc_color_depth == 8)
@@ -561,8 +560,9 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
else
return;
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422;
-   } else
+   } else {
return;
+   }
 
/* set the packetizer registers */
val = ((color_depth << HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET) &
@@ -623,34 +623,34 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
 }
 
 static inline void hdmi_phy_test_clear(struct imx_hdmi *hdmi,
-   

[PATCH v18 0/12] dw-hdmi: convert imx hdmi to bridge/dw_hdmi

2014-12-04 Thread Andy Yan

We found Freescale imx6 and Rockchip rk3288 and Ingenic JZ4780 (Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they also have some
lightly differences, such as phy pll configuration, register width(imx hdmi
register is one byte, but rk3288 is 4 bytes width and can only be accessed
by word), 4K support(imx6 doesn't support 4k, but rk3288 does), and HDMI2.0
support.

To reuse the imx-hdmi driver, we make this patch set:
(1): fix some CodingStyle warning to make checkpatch happy
(2): convert imx-hdmi to drm_bridge
(3): split platform specific code
(4): move imx-hdmi to bridge/dw_hdmi
(5): extend dw_hdmi.c to support rk3288 hdmi
(6): add rockchip rk3288 platform specific code dw_hdmi-rockchip.c

Changes in v18:
- remove a multiple blank lines in imx-hdmi.c
- fix a checkpatch warning in imx-hdmi_pltfm.c
- add port bindings
- correct some spelling mistakes in dw_hdmi bindings doc
- correct some spelling mistakes in dw_hdmi-rockchip bindings doc

Changes in v17:
- remove platform device stuff, adviced by Russell King
- remove prompt message of dw_hdmi, adviced by Russel King
- parse resource and irq in platform driver

Changes in v16:
- use the common binding for the clocks
- describe ddc-i2c-bus as optional
- add common clocks bindings
- modify clocks bindings
- descrbie ddc-i2c-bus as optional

Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver
- remove unio of the multi-byte register access, adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14:
- add defer probing, adviced by Philipp Zabel
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13:
- patch against drm-next
- split platform specific phy configuration
- split phy configuration from patch#4

Changes in v12:
- refactor of_node_put(ddc_node)
- squash patch 
- add comment for the depend on patch

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 support)
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description
- Add documentation for rockchip dw hdmi

Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6:
- rearrange the patch order
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4:
- fix checkpatch CHECK
- defer probe ddc i2c adapter

Changes in v3:
- split multi-register access to one indepent patch

Andy Yan (12):
  drm: imx: imx-hdmi: make checkpatch happy
  drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter
  drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode
  drm: imx: imx-hdmi: split phy configuration to platform driver
  drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi
  dt-bindings: add document for dw_hdmi
  drm: bridge/dw_hdmi: add support for multi-byte register width access
  drm: bridge/dw_hdmi: add mode_valid support
  drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done
  drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare
  dt-bindings: Add documentation for rockchip dw hdmi
  drm: bridge/dw_hdmi: add rockchip rk3288 support

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt |  50 ++
 .../devicetree/bindings/video/dw_hdmi-rockchip.txt |  46 ++
 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 717 ++---
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |   4 +-
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 drivers/gpu/drm/imx/dw_hdmi-imx.c  | 258 
 drivers/gpu/drm/rockchip/Kconfig   |  10 +
 drivers/gpu/drm/rockchip/Makefile  |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c| 341 ++
 include/drm/bridge/dw_hdmi.h   |  61 ++
 13 files changed,  insertions(+), 387 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (72%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (99%)
 create mode 100644 drivers/gpu/drm/imx/dw_hdmi-imx.c
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
 create mode 100644 include/drm/bridge/dw_hdmi.h

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please 

[PATCH] sched/fair: fix find_idlest_cpu return -1

2014-12-04 Thread jun . zhang
From: zhang jun 

find_idlest_cpu return -1 is not reasonable, set default value to this_cpu.

Signed-off-by: zhang jun 
Signed-off-by: Chuansheng Liu 
Signed-off-by: Changcheng Liu 
Cc: Hillf Danton 
Cc: Vincent Guittot 
Cc:  # 3.14.25
---
 kernel/sched/fair.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9b4c4f3..9d18887 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4151,7 +4151,7 @@ static int
 find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
 {
unsigned long load, min_load = ULONG_MAX;
-   int idlest = -1;
+   int idlest = this_cpu;
int i;
 
/* Traverse only the allowed CPUs */
@@ -4284,7 +4284,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, 
int sd_flag, int wake_f
}
 
new_cpu = find_idlest_cpu(group, p, cpu);
-   if (new_cpu == -1 || new_cpu == cpu) {
+   if (new_cpu == cpu) {
/* Now try balancing at a lower domain level of cpu */
sd = sd->child;
continue;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] mm: Fix a deadlock in the hotplug code

2014-12-04 Thread Yasuaki Ishimatsu
(2014/12/03 5:46), K. Y. Srinivasan wrote:
> Andy Whitcroft  initially saw this deadlock. We have
> seen this as well. Here is the original description of the problem (and a
> potential solution) from Andy:
> 
> https://lkml.org/lkml/2014/3/14/451
> 
> Here is an excerpt from that mail:
> 
> "We are seeing machines lockup with what appears to be an ABBA deadlock in
> the memory hotplug system.  These are from the 3.13.6 based Ubuntu kernels.
> The hv_balloon driver is adding memory using add_memory() which takes the
> hotplug lock, and then emits a udev event, and then attempts to lock the
> sysfs device.  In response to the udev event udev opens the sysfs device
> and locks it, then attempts to grab the hotplug lock to online the memory.
> This seems to be inverted nesting in the two cases, leading to the hangs 
> below:
> 
> [  240.608612] INFO: task kworker/0:2:861 blocked for more than 120 seconds.
> [  240.608705] INFO: task systemd-udevd:1906 blocked for more than 120 
> seconds.
> 
> I note that the device hotplug locking allows complete retries (via
> ERESTARTSYS) and if we could detect this at the online stage it
> could be used to get us out.  But before I go down this road I wanted
> to make sure I am reading this right.  Or indeed if the hv_balloon driver
> is just doing this wrong."
> 
> This patch is based on Andy's analysis and suggestion.

How about use lock_device_hotplug() before calling add_memory() in 
hv_mem_hot_add()?
Commit 0f1cfe9d0d06 (mm/hotplug: remove stop_machine() from try_offline_node()) 
said:

  ---
lock_device_hotplug() serializes hotplug & online/offline operations.  The
lock is held in common sysfs online/offline interfaces and ACPI hotplug
code paths.

And here are the code paths:

- CPU & Mem online/offline via sysfs online
store_online()->lock_device_hotplug()

- Mem online via sysfs state:
store_mem_state()->lock_device_hotplug()

- ACPI CPU & Mem hot-add:
acpi_scan_bus_device_check()->lock_device_hotplug()

- ACPI CPU & Mem hot-delete:
acpi_scan_hot_remove()->lock_device_hotplug()
  ---

CPU & Memory online/offline/hotplug are serialized by lock_device_hotplug().
So using lock_device_hotplug() solves the ABBA issue.

Thanks,
Yasuaki Ishimatsu

> 
> Signed-off-by: K. Y. Srinivasan 
> ---
>   mm/memory_hotplug.c |   24 +---
>   1 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 9fab107..e195269 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -104,19 +104,27 @@ void put_online_mems(void)
>   
>   }
>   
> -static void mem_hotplug_begin(void)
> +static int mem_hotplug_begin(bool trylock)
>   {
>   mem_hotplug.active_writer = current;
>   
>   memhp_lock_acquire();
>   for (;;) {
> - mutex_lock(_hotplug.lock);
> + if (trylock) {
> + if (!mutex_trylock(_hotplug.lock)) {
> + mem_hotplug.active_writer = NULL;
> + return -ERESTARTSYS;
> + }
> + } else {
> + mutex_lock(_hotplug.lock);
> + }
>   if (likely(!mem_hotplug.refcount))
>   break;
>   __set_current_state(TASK_UNINTERRUPTIBLE);
>   mutex_unlock(_hotplug.lock);
>   schedule();
>   }
> + return 0;
>   }
>   
>   static void mem_hotplug_done(void)
> @@ -969,7 +977,9 @@ int __ref online_pages(unsigned long pfn, unsigned long 
> nr_pages, int online_typ
>   int ret;
>   struct memory_notify arg;
>   
> - mem_hotplug_begin();
> + ret = mem_hotplug_begin(true);
> + if (ret)
> + return ret;
>   /*
>* This doesn't need a lock to do pfn_to_page().
>* The section can't be removed here because of the
> @@ -1146,7 +1156,7 @@ int try_online_node(int nid)
>   if (node_online(nid))
>   return 0;
>   
> - mem_hotplug_begin();
> + mem_hotplug_begin(false);
>   pgdat = hotadd_new_pgdat(nid, 0);
>   if (!pgdat) {
>   pr_err("Cannot online node %d due to NULL pgdat\n", nid);
> @@ -1236,7 +1246,7 @@ int __ref add_memory(int nid, u64 start, u64 size)
>   new_pgdat = !p;
>   }
>   
> - mem_hotplug_begin();
> + mem_hotplug_begin(false);
>   
>   new_node = !node_online(nid);
>   if (new_node) {
> @@ -1684,7 +1694,7 @@ static int __ref __offline_pages(unsigned long 
> start_pfn,
>   if (!test_pages_in_a_zone(start_pfn, end_pfn))
>   return -EINVAL;
>   
> - mem_hotplug_begin();
> + mem_hotplug_begin(false);
>   
>   zone = page_zone(pfn_to_page(start_pfn));
>   node = zone_to_nid(zone);
> @@ -2002,7 +2012,7 @@ void __ref remove_memory(int nid, u64 start, u64 size)
>   
>   BUG_ON(check_hotplug_memory_range(start, size));
>   
> - mem_hotplug_begin();
> + 

RE: [PATCH v6 2/10] xfs: Add support FALLOC_FL_INSERT_RANGE for fallocate

2014-12-04 Thread Namjae Jeon
> >
> > >
> > > That said, I wonder whether we even care about a merge in the right
> > > shift case since we haven't punched a hole in the file and thus have not
> > > changed the "neighbors" of any of the extents we're shuffling around. I
> > > would think any extents that are already contiguous as such are already
> > > a single extent.
> > yes, in case of insert range it is highly unlikely that a merge is required.
> > But we have kept this code as part of a generic API for shifting extents.
> >
> 
> I'm not opposed to that in principle, but the right shift is a separate
> invocation (at least in this incarnation) so it's of no consequence to
> the left shift if we were to drop it here. As far as I can tell, it's
> also broken in that if we ever were to hit it, it looks like it would
> perform a left-shift-merge in the middle of a broader right-shift
> sequence and probably corrupt the file and cause the insert range to
> fail.
> 
> To fix it, I suspect we'd have to write a new helper to do the
> right-shift-merge appropriately and then probably want a way to test it.
> The only thing that comes to mind to accomplish that is to perhaps hook
> up the bmap split mechanism to an XFS ioctl() such that it could be
> invoked by xfs_io or some such tool. Unless I'm missing something,
> that's a bunch of extra work to handle a condition that probably should
> never occur.
> 
> As it is, I'd suggest we drop it, add a small comment as to why there's
> no merge in that case, and perhaps consider an assert or warn_on_once
> type sanity check should we come across something unexpected in this
> codepath (like separate, but contiguous extents).
Okay, I agree, will drop it and add warn_on_once.

> 
> > > > +   }
> > > > +
> > > > +   /*
> > > > +* Convert to a btree if necessary.
> > > > +*/
> > > > +   if (xfs_bmap_needs_btree(ip, whichfork)) {
> > > > +   int tmp_logflags; /* partial log flag return val */
> > > > +
> > > > +   ASSERT(cur == NULL);
> > > > +   error = xfs_bmap_extents_to_btree(tp, ip, firstfsb, 
> > > > free_list,
> > > > +   , 0, _logflags, whichfork);
> > > > +   logflags |= tmp_logflags;
> > > > +   }
> > >
> > > Hmm, looks Ok, but it would be nice if we had a test case for this
> > > convert to btree scenario. I suspect something that falloc's just the
> > > right number extents for a known fs format and does an insert range
> > > right in the middle of one would suffice (and probably only require a
> > > few seconds to run).
> > Okay, I will prepare a testcase for convert to btree scenario of insert
> > range.
> > for collapse range we have generic/017 which tests multiple collapse
> > calls on same file. I can write same test for insert range which will
> > insert a single block hole at every alternate block in the file.
> > Each insert range call will split the extent into 2 extents. This test
> > need not be fs specfic so can be used for ext4 also.
> >
> 
> That sounds like a nice idea. If you start with 1 or some sufficiently
> small number of extents, that should catch the inode format conversion
> induced by insert range at some point.
> 
> It might also be interesting to consider following the insert range
> sequence with collapse range of all/some of the previously inserted
> ranges. That should give us some test coverage of the collapse extent
> merge code, if we're lacking that right now.
Good idea, I will do it.

> 
> > >
> > > > +
> > > > +del_cursor:
> > > > +   if (cur) {
> > > > +   cur->bc_private.b.allocated = 0;
> > > > +   xfs_btree_del_cursor(cur,
> > > > +   error ? XFS_BTREE_ERROR : 
> > > > XFS_BTREE_NOERROR);
> > > > +   }
> > > > +   xfs_trans_log_inode(tp, ip, logflags);
> > > > +   return error;
> > > > +}
> > > > +
> > > > +int
> > > > +xfs_bmap_split_extent(
> > > > +   struct xfs_inode*ip,
> > > > +   xfs_fileoff_t   split_fsb)
> > >
> > > You can line up the above params with the local vars below.
> > Okay.
> >
> > >
> > > > +{
> > > > +   struct xfs_mount*mp = ip->i_mount;
> > > > +   struct xfs_trans*tp;
> > > > +   struct xfs_bmap_freefree_list;
> > > > +   xfs_fsblock_t   firstfsb;
> > > > +   int committed;
> > > > +   int error;
> > > > +
> > > > +   tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
> > > > +   error = xfs_trans_reserve(tp, _RES(mp)->tr_write,
> > > > +   XFS_DIOSTRAT_SPACE_RES(mp, 0), 0);
> > > > +   if (error) {
> > > > +   xfs_trans_cancel(tp, 0);
> > > > +   return error;
> > > > +   }
> > > > +
> > > > +   xfs_ilock(ip, XFS_ILOCK_EXCL);
> > > > +   error = xfs_trans_reserve_quota(tp, mp, ip->i_udquot,
> > > > +   ip->i_gdquot, ip->i_pdquot,
> > > > + 

[PATCH] xen: fix sparse warning in p2m.c

2014-12-04 Thread Juergen Gross
The patch "Speed up set_phys_to_machine() by using read-only mappings"
introduced a sparse warning:

arch/x86/xen/p2m.c:628:13: sparse: incorrect type in argument 1
   (different address spaces)

Avoid the warning.

Signed-off-by: Juergen Gross 
---
 arch/x86/xen/p2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 8b5db51..2defca9 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -615,6 +615,7 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long 
mfn)
 {
pte_t *ptep;
unsigned int level;
+   unsigned long __user *addr;
 
/* don't track P2M changes in autotranslate guests */
if (unlikely(xen_feature(XENFEAT_auto_translated_physmap)))
@@ -625,7 +626,8 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long 
mfn)
return true;
}
 
-   if (likely(!__put_user(mfn, xen_p2m_addr + pfn)))
+   addr = (unsigned long __user *)xen_p2m_addr + pfn;
+   if (likely(!__put_user(mfn, addr)))
return true;
 
ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn), );
-- 
2.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] xen: fix sparse warning in page.h

2014-12-04 Thread Juergen Gross
The inline function mfn_to_pfn_no_overrides() uses __get_user() to
access the machine_to_phys_mapping array to avoid crashes when
using out of bounds indices e.g. for I/O addresses.

Avoid sparse warnings by attributing the accessed address with __user.

Signed-off-by: Juergen Gross 
---
 arch/x86/include/asm/xen/page.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index f5d5de4..6deff84 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -113,6 +113,7 @@ static inline unsigned long 
mfn_to_pfn_no_overrides(unsigned long mfn)
 {
unsigned long pfn;
int ret;
+   unsigned long __user *addr;
 
if (xen_feature(XENFEAT_auto_translated_physmap))
return mfn;
@@ -125,7 +126,8 @@ static inline unsigned long 
mfn_to_pfn_no_overrides(unsigned long mfn)
 * In such cases it doesn't matter what we return (we return garbage),
 * but we must handle the fault without crashing!
 */
-   ret = __get_user(pfn, _to_phys_mapping[mfn]);
+   addr = (unsigned long __user *)(_to_phys_mapping[mfn]);
+   ret = __get_user(pfn, addr);
if (ret < 0)
return ~0;
 
-- 
2.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/12] ip_generic_getfrag, udplite_getfrag: switch to passing msghdr

2014-12-04 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 include/net/udplite.h | 3 ++-
 net/ipv4/ip_output.c  | 6 +++---
 net/ipv4/raw.c| 2 +-
 net/ipv4/udp.c| 4 ++--
 net/ipv6/raw.c| 2 +-
 net/ipv6/udp.c| 2 +-
 net/l2tp/l2tp_ip6.c   | 2 +-
 7 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/net/udplite.h b/include/net/udplite.h
index 9a28a51..d5baaba 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -19,7 +19,8 @@ extern struct udp_table   udplite_table;
 static __inline__ int udplite_getfrag(void *from, char *to, int  offset,
  int len, int odd, struct sk_buff *skb)
 {
-   return memcpy_fromiovecend(to, (struct iovec *) from, offset, len);
+   struct msghdr *msg = from;
+   return memcpy_fromiovecend(to, msg->msg_iov, offset, len);
 }
 
 /* Designate sk as UDP-Lite socket */
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 4a929ad..cdedcf1 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -752,14 +752,14 @@ EXPORT_SYMBOL(ip_fragment);
 int
 ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct 
sk_buff *skb)
 {
-   struct iovec *iov = from;
+   struct msghdr *msg = from;
 
if (skb->ip_summed == CHECKSUM_PARTIAL) {
-   if (memcpy_fromiovecend(to, iov, offset, len) < 0)
+   if (memcpy_fromiovecend(to, msg->msg_iov, offset, len) < 0)
return -EFAULT;
} else {
__wsum csum = 0;
-   if (csum_partial_copy_fromiovecend(to, iov, offset, len, ) 
< 0)
+   if (csum_partial_copy_fromiovecend(to, msg->msg_iov, offset, 
len, ) < 0)
return -EFAULT;
skb->csum = csum_block_add(skb->csum, csum, odd);
}
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 5c901eb..5d83bd2 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -478,7 +478,7 @@ static int raw_getfrag(void *from, char *to, int offset, 
int len, int odd,
 
offset -= rfv->hlen;
 
-   return ip_generic_getfrag(rfv->msg->msg_iov, to, offset, len, odd, skb);
+   return ip_generic_getfrag(rfv->msg, to, offset, len, odd, skb);
 }
 
 static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index b2d6068..0cac250 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1036,7 +1036,7 @@ back_from_confirm:
 
/* Lockless fast path for the non-corking case. */
if (!corkreq) {
-   skb = ip_make_skb(sk, fl4, getfrag, msg->msg_iov, ulen,
+   skb = ip_make_skb(sk, fl4, getfrag, msg, ulen,
  sizeof(struct udphdr), , ,
  msg->msg_flags);
err = PTR_ERR(skb);
@@ -1067,7 +1067,7 @@ back_from_confirm:
 
 do_append_data:
up->len += ulen;
-   err = ip_append_data(sk, fl4, getfrag, msg->msg_iov, ulen,
+   err = ip_append_data(sk, fl4, getfrag, msg, ulen,
 sizeof(struct udphdr), , ,
 corkreq ? msg->msg_flags|MSG_MORE : 
msg->msg_flags);
if (err)
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 942f67b..11a9283 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -727,7 +727,7 @@ static int raw6_getfrag(void *from, char *to, int offset, 
int len, int odd,
 
offset -= rfv->hlen;
 
-   return ip_generic_getfrag(rfv->msg->msg_iov, to, offset, len, odd, skb);
+   return ip_generic_getfrag(rfv->msg, to, offset, len, odd, skb);
 }
 
 static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 7cfb5d74..5a164b6 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1299,7 +1299,7 @@ do_append_data:
dontfrag = np->dontfrag;
up->len += ulen;
getfrag  =  is_udplite ?  udplite_getfrag : ip_generic_getfrag;
-   err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,
+   err = ip6_append_data(sk, getfrag, msg, ulen,
sizeof(struct udphdr), hlimit, tclass, opt, ,
(struct rt6_info *)dst,
corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags, dontfrag);
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index 2177b96..8611f1b 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -619,7 +619,7 @@ static int l2tp_ip6_sendmsg(struct kiocb *iocb, struct sock 
*sk,
 
 back_from_confirm:
lock_sock(sk);
-   err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov,
+   err = ip6_append_data(sk, ip_generic_getfrag, msg,
  ulen, transhdrlen, hlimit, tclass, opt,
  , (struct rt6_info *)dst,
  msg->msg_flags, dontfrag);
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org

[PATCH 10/12] ppp_read(): switch to skb_copy_datagram_iter()

2014-12-04 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/net/ppp/ppp_generic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 794a473..af034db 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -417,6 +417,7 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
ssize_t ret;
struct sk_buff *skb = NULL;
struct iovec iov;
+   struct iov_iter to;
 
ret = count;
 
@@ -462,7 +463,8 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
ret = -EFAULT;
iov.iov_base = buf;
iov.iov_len = count;
-   if (skb_copy_datagram_iovec(skb, 0, , skb->len))
+   iov_iter_init(, READ, , 1, count);
+   if (skb_copy_datagram_iter(skb, 0, , skb->len))
goto outf;
ret = skb->len;
 
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/12] switch tcp_sock->ucopy from iovec (ucopy.iov) to msghdr (ucopy.msg)

2014-12-04 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 include/linux/tcp.h  | 2 +-
 net/ipv4/tcp.c   | 2 +-
 net/ipv4/tcp_input.c | 7 +++
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index f566b85..5d9cc9c 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -162,7 +162,7 @@ struct tcp_sock {
struct {
struct sk_buff_head prequeue;
struct task_struct  *task;
-   struct iovec*iov;
+   struct msghdr   *msg;
int memory;
int len;
} ucopy;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index dc13a36..4a96f37 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1729,7 +1729,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, 
struct msghdr *msg,
if (!user_recv && !(flags & (MSG_TRUNC | MSG_PEEK))) {
user_recv = current;
tp->ucopy.task = user_recv;
-   tp->ucopy.iov = msg->msg_iov;
+   tp->ucopy.msg = msg;
}
 
tp->ucopy.len = len;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 69de1a1..075ab4d 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4421,7 +4421,7 @@ static void tcp_data_queue(struct sock *sk, struct 
sk_buff *skb)
__set_current_state(TASK_RUNNING);
 
local_bh_enable();
-   if (!skb_copy_datagram_iovec(skb, 0, tp->ucopy.iov, 
chunk)) {
+   if (!skb_copy_datagram_msg(skb, 0, tp->ucopy.msg, 
chunk)) {
tp->ucopy.len -= chunk;
tp->copied_seq += chunk;
eaten = (chunk == skb->len);
@@ -4941,10 +4941,9 @@ static int tcp_copy_to_iovec(struct sock *sk, struct 
sk_buff *skb, int hlen)
 
local_bh_enable();
if (skb_csum_unnecessary(skb))
-   err = skb_copy_datagram_iovec(skb, hlen, tp->ucopy.iov, chunk);
+   err = skb_copy_datagram_msg(skb, hlen, tp->ucopy.msg, chunk);
else
-   err = skb_copy_and_csum_datagram_iovec(skb, hlen,
-  tp->ucopy.iov);
+   err = skb_copy_and_csum_datagram_msg(skb, hlen, tp->ucopy.msg);
 
if (!err) {
tp->ucopy.len -= chunk;
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/12] vmci: propagate msghdr all way down to __qp_memcpy_from_queue()

2014-12-04 Thread Al Viro
From: Al Viro 

... and switch it to memcpy_to_msg()

Signed-off-by: Al Viro 
---
 drivers/misc/vmw_vmci/vmci_queue_pair.c | 17 +
 include/linux/vmw_vmci_api.h|  5 +++--
 net/vmw_vsock/vmci_transport.c  |  4 ++--
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c 
b/drivers/misc/vmw_vmci/vmci_queue_pair.c
index 1b7b303..7aaaf51 100644
--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
+++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vmci_handle_array.h"
 #include "vmci_queue_pair.h"
@@ -429,11 +430,11 @@ static int __qp_memcpy_from_queue(void *dest,
to_copy = size - bytes_copied;
 
if (is_iovec) {
-   struct iovec *iov = (struct iovec *)dest;
+   struct msghdr *msg = dest;
int err;
 
/* The iovec will track bytes_copied internally. */
-   err = memcpy_toiovec(iov, (u8 *)va + page_offset,
+   err = memcpy_to_msg(msg, (u8 *)va + page_offset,
 to_copy);
if (err != 0) {
if (kernel_if->host)
@@ -3264,13 +3265,13 @@ EXPORT_SYMBOL_GPL(vmci_qpair_enquev);
  * of bytes dequeued or < 0 on error.
  */
 ssize_t vmci_qpair_dequev(struct vmci_qp *qpair,
- void *iov,
+ struct msghdr *msg,
  size_t iov_size,
  int buf_type)
 {
ssize_t result;
 
-   if (!qpair || !iov)
+   if (!qpair)
return VMCI_ERROR_INVALID_ARGS;
 
qp_lock(qpair);
@@ -3279,7 +3280,7 @@ ssize_t vmci_qpair_dequev(struct vmci_qp *qpair,
result = qp_dequeue_locked(qpair->produce_q,
   qpair->consume_q,
   qpair->consume_q_size,
-  iov, iov_size,
+  msg, iov_size,
   qp_memcpy_from_queue_iov,
   true);
 
@@ -3308,13 +3309,13 @@ EXPORT_SYMBOL_GPL(vmci_qpair_dequev);
  * of bytes peeked or < 0 on error.
  */
 ssize_t vmci_qpair_peekv(struct vmci_qp *qpair,
-void *iov,
+struct msghdr *msg,
 size_t iov_size,
 int buf_type)
 {
ssize_t result;
 
-   if (!qpair || !iov)
+   if (!qpair)
return VMCI_ERROR_INVALID_ARGS;
 
qp_lock(qpair);
@@ -3323,7 +3324,7 @@ ssize_t vmci_qpair_peekv(struct vmci_qp *qpair,
result = qp_dequeue_locked(qpair->produce_q,
   qpair->consume_q,
   qpair->consume_q_size,
-  iov, iov_size,
+  msg, iov_size,
   qp_memcpy_from_queue_iov,
   false);
 
diff --git a/include/linux/vmw_vmci_api.h b/include/linux/vmw_vmci_api.h
index 023430e..5691f75 100644
--- a/include/linux/vmw_vmci_api.h
+++ b/include/linux/vmw_vmci_api.h
@@ -24,6 +24,7 @@
 #define VMCI_KERNEL_API_VERSION_2 2
 #define VMCI_KERNEL_API_VERSION   VMCI_KERNEL_API_VERSION_2
 
+struct msghdr;
 typedef void (vmci_device_shutdown_fn) (void *device_registration,
void *user_data);
 
@@ -75,8 +76,8 @@ ssize_t vmci_qpair_peek(struct vmci_qp *qpair, void *buf, 
size_t buf_size,
 ssize_t vmci_qpair_enquev(struct vmci_qp *qpair,
  void *iov, size_t iov_size, int mode);
 ssize_t vmci_qpair_dequev(struct vmci_qp *qpair,
- void *iov, size_t iov_size, int mode);
-ssize_t vmci_qpair_peekv(struct vmci_qp *qpair, void *iov, size_t iov_size,
+ struct msghdr *msg, size_t iov_size, int mode);
+ssize_t vmci_qpair_peekv(struct vmci_qp *qpair, struct msghdr *msg, size_t 
iov_size,
 int mode);
 
 #endif /* !__VMW_VMCI_API_H__ */
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
index c1c0389..20a0ba3 100644
--- a/net/vmw_vsock/vmci_transport.c
+++ b/net/vmw_vsock/vmci_transport.c
@@ -1840,9 +1840,9 @@ static ssize_t vmci_transport_stream_dequeue(
int flags)
 {
if (flags & MSG_PEEK)
-   return vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg->msg_iov, 
len, 0);
+   return vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0);
else
-   return vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg->msg_iov, 
len, 0);
+   return vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0);
 }
 
 static ssize_t 

[PATCH 05/12] switch l2cap ->memcpy_fromiovec() to msghdr

2014-12-04 Thread Al Viro
From: Al Viro 

it'll die soon enough - now that kvec-backed iov_iter works regardless
of set_fs(), both instances will become copy_from_iter() as soon as
we introduce ->msg_iter...

Signed-off-by: Al Viro 
---
 include/net/bluetooth/l2cap.h | 6 +++---
 net/bluetooth/l2cap_core.c| 4 ++--
 net/bluetooth/l2cap_sock.c| 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 061e648..4e23674 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -608,7 +608,7 @@ struct l2cap_ops {
   unsigned long len, int nb);
int (*memcpy_fromiovec) (struct l2cap_chan *chan,
 unsigned char *kdata,
-struct iovec *iov,
+struct msghdr *msg,
 int len);
 };
 
@@ -905,13 +905,13 @@ static inline long l2cap_chan_no_get_sndtimeo(struct 
l2cap_chan *chan)
 
 static inline int l2cap_chan_no_memcpy_fromiovec(struct l2cap_chan *chan,
 unsigned char *kdata,
-struct iovec *iov,
+struct msghdr *msg,
 int len)
 {
/* Following is safe since for compiler definitions of kvec and
 * iovec are identical, yielding the same in-core layout and alignment
 */
-   struct kvec *vec = (struct kvec *)iov;
+   struct kvec *vec = (struct kvec *)msg->msg_iov;
 
while (len > 0) {
if (vec->iov_len) {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8e12731..5201d61 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2097,7 +2097,7 @@ static inline int l2cap_skbuff_fromiovec(struct 
l2cap_chan *chan,
int sent = 0;
 
if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count),
-   msg->msg_iov, count))
+   msg, count))
return -EFAULT;
 
sent += count;
@@ -2118,7 +2118,7 @@ static inline int l2cap_skbuff_fromiovec(struct 
l2cap_chan *chan,
*frag = tmp;
 
if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count),
-   msg->msg_iov, count))
+   msg, count))
return -EFAULT;
 
sent += count;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index b0efb72..205b298 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1338,9 +1338,9 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct 
l2cap_chan *chan,
 
 static int l2cap_sock_memcpy_fromiovec_cb(struct l2cap_chan *chan,
  unsigned char *kdata,
- struct iovec *iov, int len)
+ struct msghdr *msg, int len)
 {
-   return memcpy_fromiovec(kdata, iov, len);
+   return memcpy_from_msg(kdata, msg, len);
 }
 
 static void l2cap_sock_ready_cb(struct l2cap_chan *chan)
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/12] first fruits - kill l2cap ->memcpy_fromiovec()

2014-12-04 Thread Al Viro
From: Al Viro 

Just use copy_from_iter().  That's what this method is trying to do
in all cases, in a very convoluted fashion.

Signed-off-by: Al Viro 
---
 include/net/bluetooth/l2cap.h | 29 -
 net/bluetooth/6lowpan.c   |  3 +--
 net/bluetooth/a2mp.c  |  3 +--
 net/bluetooth/l2cap_core.c|  7 +++
 net/bluetooth/l2cap_sock.c|  8 
 net/bluetooth/smp.c   |  4 +---
 6 files changed, 6 insertions(+), 48 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index bca6fc0..692f786 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -606,10 +606,6 @@ struct l2cap_ops {
struct sk_buff  *(*alloc_skb) (struct l2cap_chan *chan,
   unsigned long hdr_len,
   unsigned long len, int nb);
-   int (*memcpy_fromiovec) (struct l2cap_chan *chan,
-unsigned char *kdata,
-struct msghdr *msg,
-int len);
 };
 
 struct l2cap_conn {
@@ -903,31 +899,6 @@ static inline long l2cap_chan_no_get_sndtimeo(struct 
l2cap_chan *chan)
return 0;
 }
 
-static inline int l2cap_chan_no_memcpy_fromiovec(struct l2cap_chan *chan,
-unsigned char *kdata,
-struct msghdr *msg,
-int len)
-{
-   /* Following is safe since for compiler definitions of kvec and
-* iovec are identical, yielding the same in-core layout and alignment
-*/
-   struct kvec *vec = (struct kvec *)msg->msg_iter.iov;
-
-   while (len > 0) {
-   if (vec->iov_len) {
-   int copy = min_t(unsigned int, len, vec->iov_len);
-   memcpy(kdata, vec->iov_base, copy);
-   len -= copy;
-   kdata += copy;
-   vec->iov_base += copy;
-   vec->iov_len -= copy;
-   }
-   vec++;
-   }
-
-   return 0;
-}
-
 extern bool disable_ertm;
 
 int l2cap_init_sockets(void);
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index d8c67a5..76617be 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -541,7 +541,7 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff 
*skb,
iv.iov_len = skb->len;
 
memset(, 0, sizeof(msg));
-   iov_iter_init(_iter, WRITE, (struct iovec *) , 1, skb->len);
+   iov_iter_kvec(_iter, WRITE | ITER_KVEC, , 1, skb->len);
 
err = l2cap_chan_send(chan, , skb->len);
if (err > 0) {
@@ -1050,7 +1050,6 @@ static const struct l2cap_ops bt_6lowpan_chan_ops = {
.suspend= chan_suspend_cb,
.get_sndtimeo   = chan_get_sndtimeo_cb,
.alloc_skb  = chan_alloc_skb_cb,
-   .memcpy_fromiovec   = l2cap_chan_no_memcpy_fromiovec,
 
.teardown   = l2cap_chan_no_teardown,
.defer  = l2cap_chan_no_defer,
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 716d2a3..cedfbda 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -60,7 +60,7 @@ void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 
len, void *data)
 
memset(, 0, sizeof(msg));
 
-   iov_iter_init(_iter, WRITE, (struct iovec *), 1, total_len);
+   iov_iter_kvec(_iter, WRITE | ITER_KVEC, , 1, total_len);
 
l2cap_chan_send(chan, , total_len);
 
@@ -719,7 +719,6 @@ static const struct l2cap_ops a2mp_chan_ops = {
.resume = l2cap_chan_no_resume,
.set_shutdown = l2cap_chan_no_set_shutdown,
.get_sndtimeo = l2cap_chan_no_get_sndtimeo,
-   .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
 };
 
 static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 5201d61..1754040 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2096,8 +2096,7 @@ static inline int l2cap_skbuff_fromiovec(struct 
l2cap_chan *chan,
struct sk_buff **frag;
int sent = 0;
 
-   if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count),
-   msg, count))
+   if (copy_from_iter(skb_put(skb, count), count, >msg_iter) != count)
return -EFAULT;
 
sent += count;
@@ -2117,8 +2116,8 @@ static inline int l2cap_skbuff_fromiovec(struct 
l2cap_chan *chan,
 
*frag = tmp;
 
-   if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count),
-   msg, count))
+   if (copy_from_iter(skb_put(*frag, count), count,
+   

[PATCH 07/12] put iov_iter into msghdr

2014-12-04 Thread Al Viro
From: Al Viro 

Note that the code _using_ ->msg_iter at that point will be very
unhappy with anything other than unshifted iovec-backed iov_iter.
We still need to convert users to proper primitives.

Signed-off-by: Al Viro 
---
 crypto/algif_hash.c|  4 ++--
 crypto/algif_skcipher.c|  4 ++--
 drivers/net/macvtap.c  |  8 ++--
 drivers/net/tun.c  |  8 ++--
 drivers/vhost/net.c|  8 +++-
 fs/afs/rxrpc.c | 14 ++
 include/linux/skbuff.h | 16 ++--
 include/linux/socket.h |  3 +--
 include/net/bluetooth/l2cap.h  |  2 +-
 include/net/udplite.h  |  3 ++-
 net/atm/common.c   |  5 +
 net/bluetooth/6lowpan.c|  6 +++---
 net/bluetooth/a2mp.c   |  3 +--
 net/bluetooth/smp.c|  3 +--
 net/caif/caif_socket.c |  2 +-
 net/compat.c   | 10 ++
 net/ipv4/ip_output.c   |  6 --
 net/ipv4/ping.c|  3 ++-
 net/ipv4/raw.c |  3 ++-
 net/ipv4/tcp.c |  6 +++---
 net/ipv4/tcp_output.c  |  2 +-
 net/ipv6/ping.c|  3 ++-
 net/ipv6/raw.c |  3 ++-
 net/netlink/af_netlink.c   |  2 +-
 net/packet/af_packet.c |  7 ++-
 net/rds/recv.c |  7 ---
 net/rds/send.c |  4 +---
 net/rxrpc/ar-output.c  |  8 +++-
 net/sctp/socket.c  |  5 +
 net/socket.c   | 27 ---
 net/tipc/msg.c |  4 ++--
 net/tipc/socket.c  |  4 ++--
 net/unix/af_unix.c | 10 ++
 net/vmw_vsock/vmci_transport.c |  3 ++-
 34 files changed, 92 insertions(+), 114 deletions(-)

diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 35c93ff..83cd2cc 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -42,7 +42,7 @@ static int hash_sendmsg(struct kiocb *unused, struct socket 
*sock,
struct alg_sock *ask = alg_sk(sk);
struct hash_ctx *ctx = ask->private;
unsigned long iovlen;
-   struct iovec *iov;
+   const struct iovec *iov;
long copied = 0;
int err;
 
@@ -58,7 +58,7 @@ static int hash_sendmsg(struct kiocb *unused, struct socket 
*sock,
 
ctx->more = 0;
 
-   for (iov = msg->msg_iov, iovlen = msg->msg_iovlen; iovlen > 0;
+   for (iov = msg->msg_iter.iov, iovlen = msg->msg_iter.nr_segs; iovlen > 
0;
 iovlen--, iov++) {
unsigned long seglen = iov->iov_len;
char __user *from = iov->iov_base;
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index c3b482b..4f45dab 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -429,13 +429,13 @@ static int skcipher_recvmsg(struct kiocb *unused, struct 
socket *sock,
struct skcipher_sg_list *sgl;
struct scatterlist *sg;
unsigned long iovlen;
-   struct iovec *iov;
+   const struct iovec *iov;
int err = -EAGAIN;
int used;
long copied = 0;
 
lock_sock(sk);
-   for (iov = msg->msg_iov, iovlen = msg->msg_iovlen; iovlen > 0;
+   for (iov = msg->msg_iter.iov, iovlen = msg->msg_iter.nr_segs; iovlen > 
0;
 iovlen--, iov++) {
unsigned long seglen = iov->iov_len;
char __user *from = iov->iov_base;
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 22b4cf2..4fb1222 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -1092,9 +1092,7 @@ static int macvtap_sendmsg(struct kiocb *iocb, struct 
socket *sock,
   struct msghdr *m, size_t total_len)
 {
struct macvtap_queue *q = container_of(sock, struct macvtap_queue, 
sock);
-   struct iov_iter from;
-   iov_iter_init(, WRITE, m->msg_iov, m->msg_iovlen, total_len);
-   return macvtap_get_user(q, m, , m->msg_flags & MSG_DONTWAIT);
+   return macvtap_get_user(q, m, >msg_iter, m->msg_flags & 
MSG_DONTWAIT);
 }
 
 static int macvtap_recvmsg(struct kiocb *iocb, struct socket *sock,
@@ -1102,12 +1100,10 @@ static int macvtap_recvmsg(struct kiocb *iocb, struct 
socket *sock,
   int flags)
 {
struct macvtap_queue *q = container_of(sock, struct macvtap_queue, 
sock);
-   struct iov_iter to;
int ret;
if (flags & ~(MSG_DONTWAIT|MSG_TRUNC))
return -EINVAL;
-   iov_iter_init(, READ, m->msg_iov, m->msg_iovlen, total_len);
-   ret = macvtap_do_read(q, , flags & MSG_DONTWAIT);
+   ret = macvtap_do_read(q, >msg_iter, flags & MSG_DONTWAIT);
if (ret > total_len) {
m->msg_flags |= MSG_TRUNC;
ret = flags & MSG_TRUNC ? ret : total_len;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6d44da1..8d8bede 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1446,13 +1446,11 @@ static int tun_sendmsg(struct kiocb *iocb, 

[PATCH 09/12] switch memcpy_to_msg() and skb_copy{,_and_csum}_datagram_msg() to primitives

2014-12-04 Thread Al Viro
From: Al Viro 

... making both non-draining.  That means that tcp_recvmsg() becomes
non-draining.  And _that_ would break iscsit_do_rx_data() unless we
a) make sure tcp_recvmsg() is uniformly non-draining (it is)
b) make sure it copes with arbitrary (including shifted)
iov_iter (it does, all it uses is iov_iter primitives)
c) make iscsit_do_rx_data() initialize ->msg_iter only once.

Fortunately, (c) is doable with minimal work and we are rid of one
the two places where kernel send/recvmsg users would be unhappy with
non-draining behaviour.

Actually, that makes all but one of ->recvmsg() instances iov_iter-clean.
The exception is skcipher_recvmsg() and it also isn't hard to convert
to primitives (iov_iter_get_pages() is needed there).  That'll wait
a bit - there's some interplay with ->sendmsg() path for that one.

Signed-off-by: Al Viro 
---
 drivers/target/iscsi/iscsi_target_util.c | 12 +++
 include/linux/skbuff.h   | 16 +++---
 net/core/datagram.c  | 54 +++-
 3 files changed, 28 insertions(+), 54 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_util.c 
b/drivers/target/iscsi/iscsi_target_util.c
index ce87ce9..7c6a95b 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -1326,21 +1326,19 @@ static int iscsit_do_rx_data(
struct iscsi_conn *conn,
struct iscsi_data_count *count)
 {
-   int data = count->data_length, rx_loop = 0, total_rx = 0, iov_len;
-   struct kvec *iov_p;
+   int data = count->data_length, rx_loop = 0, total_rx = 0;
struct msghdr msg;
 
if (!conn || !conn->sock || !conn->conn_ops)
return -1;
 
memset(, 0, sizeof(struct msghdr));
-
-   iov_p = count->iov;
-   iov_len = count->iov_count;
+   iov_iter_kvec(_iter, READ | ITER_KVEC,
+ count->iov, count->iov_count, data);
 
while (total_rx < data) {
-   rx_loop = kernel_recvmsg(conn->sock, , iov_p, iov_len,
-   (data - total_rx), MSG_WAITALL);
+   rx_loop = sock_recvmsg(conn->sock, ,
+ (data - total_rx), MSG_WAITALL);
if (rx_loop <= 0) {
pr_debug("rx_loop: %d total_rx: %d\n",
rx_loop, total_rx);
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4199dfa..45ac95c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2649,17 +2649,10 @@ int skb_copy_datagram_iter(const struct sk_buff *from, 
int offset,
 static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
struct msghdr *msg, int size)
 {
-   /* XXX: stripping const */
-   return skb_copy_datagram_iovec(from, offset, (struct iovec 
*)msg->msg_iter.iov, size);
-}
-int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int hlen,
-struct iovec *iov);
-static inline int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, int hlen,
-   struct msghdr *msg)
-{
-   /* XXX: stripping const */
-   return skb_copy_and_csum_datagram_iovec(skb, hlen, (struct iovec 
*)msg->msg_iter.iov);
+   return skb_copy_datagram_iter(from, offset, >msg_iter, size);
 }
+int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, int hlen,
+  struct msghdr *msg);
 int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
 struct iov_iter *from, int len);
 int zerocopy_sg_from_iter(struct sk_buff *skb, struct iov_iter *frm);
@@ -2695,8 +2688,7 @@ static inline int memcpy_from_msg(void *data, struct 
msghdr *msg, int len)
 
 static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
 {
-   /* XXX: stripping const */
-   return memcpy_toiovec((struct iovec *)msg->msg_iter.iov, data, len);
+   return copy_to_iter(data, len, >msg_iter) == len ? 0 : -EFAULT;
 }
 
 struct skb_checksum_ops {
diff --git a/net/core/datagram.c b/net/core/datagram.c
index b6e303b..41075ed 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -615,27 +615,25 @@ int zerocopy_sg_from_iter(struct sk_buff *skb, struct 
iov_iter *from)
 EXPORT_SYMBOL(zerocopy_sg_from_iter);
 
 static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
- u8 __user *to, int len,
+ struct iov_iter *to, int len,
  __wsum *csump)
 {
int start = skb_headlen(skb);
int i, copy = start - offset;
struct sk_buff *frag_iter;
int pos = 0;
+   int n;
 
/* Copy header. */
if (copy > 0) {
-   int err = 0;
if (copy > len)
copy = len;
-   *csump = 

Re: [PATCH] tinification: Make SRCU optional by using CONFIG_SRCU

2014-12-04 Thread Josh Triplett
On Thu, Dec 04, 2014 at 10:30:20PM -0500, Pranith Kumar wrote:
> On Thu, Dec 4, 2014 at 9:05 PM, Lai Jiangshan  wrote:
> > On 12/05/2014 08:11 AM, Paul E. McKenney wrote:
> >> On Thu, Dec 04, 2014 at 06:50:24PM -0500, Pranith Kumar wrote:
> >>>
> >>> +config SRCU
> >>> +bool "Sleepable form of RCU"
> >
> > Why it has a title? Somebody need to select it manually for third party 
> > kernel module?
> 
> Yes, it is a choice given to enable SRCU even when no in-kernel module uses 
> it.

That makes sense for testing purposes, but I don't think it makes sense
for the final patch.  I'd suggest making it a completely automatic
symbol with no title.

> >
> >>> +def_bool n

You already say "bool" above, and "default n" is the default default, so
you can omit this line entirely.

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/12] bury memcpy_toiovec()

2014-12-04 Thread Al Viro
From: Al Viro 

no users left

Signed-off-by: Al Viro 
---
 include/linux/uio.h |  1 -
 lib/iovec.c | 25 -
 2 files changed, 26 deletions(-)

diff --git a/include/linux/uio.h b/include/linux/uio.h
index bd8569a..a41e252 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -131,7 +131,6 @@ size_t csum_and_copy_to_iter(void *addr, size_t bytes, 
__wsum *csum, struct iov_
 size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct 
iov_iter *i);
 
 int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
-int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len);
 int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
int offset, int len);
 int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
diff --git a/lib/iovec.c b/lib/iovec.c
index df3abd1..2d99cb4 100644
--- a/lib/iovec.c
+++ b/lib/iovec.c
@@ -29,31 +29,6 @@ EXPORT_SYMBOL(memcpy_fromiovec);
 
 /*
  * Copy kernel to iovec. Returns -EFAULT on error.
- *
- * Note: this modifies the original iovec.
- */
-
-int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
-{
-   while (len > 0) {
-   if (iov->iov_len) {
-   int copy = min_t(unsigned int, iov->iov_len, len);
-   if (copy_to_user(iov->iov_base, kdata, copy))
-   return -EFAULT;
-   kdata += copy;
-   len -= copy;
-   iov->iov_len -= copy;
-   iov->iov_base += copy;
-   }
-   iov++;
-   }
-
-   return 0;
-}
-EXPORT_SYMBOL(memcpy_toiovec);
-
-/*
- * Copy kernel to iovec. Returns -EFAULT on error.
  */
 
 int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/12] raw.c: stick msghdr into raw_frag_vec

2014-12-04 Thread Al Viro
From: Al Viro 

we'll want access to ->msg_iter

Signed-off-by: Al Viro 
---
 net/ipv4/raw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 43385a9..5c901eb 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -82,7 +82,7 @@
 #include 
 
 struct raw_frag_vec {
-   struct iovec *iov;
+   struct msghdr *msg;
union {
struct icmphdr icmph;
char c[1];
@@ -440,7 +440,7 @@ static int raw_probe_proto_opt(struct raw_frag_vec *rfv, 
struct flowi4 *fl4)
/* We only need the first two bytes. */
rfv->hlen = 2;
 
-   err = memcpy_fromiovec(rfv->hdr.c, rfv->iov, rfv->hlen);
+   err = memcpy_from_msg(rfv->hdr.c, rfv->msg, rfv->hlen);
if (err)
return err;
 
@@ -478,7 +478,7 @@ static int raw_getfrag(void *from, char *to, int offset, 
int len, int odd,
 
offset -= rfv->hlen;
 
-   return ip_generic_getfrag(rfv->iov, to, offset, len, odd, skb);
+   return ip_generic_getfrag(rfv->msg->msg_iov, to, offset, len, odd, skb);
 }
 
 static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
@@ -600,7 +600,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, 
struct msghdr *msg,
   daddr, saddr, 0, 0);
 
if (!inet->hdrincl) {
-   rfv.iov = msg->msg_iov;
+   rfv.msg = msg;
rfv.hlen = 0;
 
err = raw_probe_proto_opt(, );
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/12] skb_copy_datagram_iovec() can die

2014-12-04 Thread Al Viro
From: Al Viro 

no callers other than itself.

Signed-off-by: Al Viro 
---
 include/linux/skbuff.h |  2 --
 net/core/datagram.c| 84 --
 2 files changed, 86 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 45ac95c..f676e54 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2642,8 +2642,6 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, 
unsigned flags, int noblock,
  int *err);
 unsigned int datagram_poll(struct file *file, struct socket *sock,
   struct poll_table_struct *wait);
-int skb_copy_datagram_iovec(const struct sk_buff *from, int offset,
-   struct iovec *to, int size);
 int skb_copy_datagram_iter(const struct sk_buff *from, int offset,
   struct iov_iter *to, int size);
 static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 41075ed..df493d6 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -310,90 +310,6 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff 
*skb, unsigned int flags)
 EXPORT_SYMBOL(skb_kill_datagram);
 
 /**
- * skb_copy_datagram_iovec - Copy a datagram to an iovec.
- * @skb: buffer to copy
- * @offset: offset in the buffer to start copying from
- * @to: io vector to copy to
- * @len: amount of data to copy from buffer to iovec
- *
- * Note: the iovec is modified during the copy.
- */
-int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset,
-   struct iovec *to, int len)
-{
-   int start = skb_headlen(skb);
-   int i, copy = start - offset;
-   struct sk_buff *frag_iter;
-
-   trace_skb_copy_datagram_iovec(skb, len);
-
-   /* Copy header. */
-   if (copy > 0) {
-   if (copy > len)
-   copy = len;
-   if (memcpy_toiovec(to, skb->data + offset, copy))
-   goto fault;
-   if ((len -= copy) == 0)
-   return 0;
-   offset += copy;
-   }
-
-   /* Copy paged appendix. Hmm... why does this look so complicated? */
-   for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-   int end;
-   const skb_frag_t *frag = _shinfo(skb)->frags[i];
-
-   WARN_ON(start > offset + len);
-
-   end = start + skb_frag_size(frag);
-   if ((copy = end - offset) > 0) {
-   int err;
-   u8  *vaddr;
-   struct page *page = skb_frag_page(frag);
-
-   if (copy > len)
-   copy = len;
-   vaddr = kmap(page);
-   err = memcpy_toiovec(to, vaddr + frag->page_offset +
-offset - start, copy);
-   kunmap(page);
-   if (err)
-   goto fault;
-   if (!(len -= copy))
-   return 0;
-   offset += copy;
-   }
-   start = end;
-   }
-
-   skb_walk_frags(skb, frag_iter) {
-   int end;
-
-   WARN_ON(start > offset + len);
-
-   end = start + frag_iter->len;
-   if ((copy = end - offset) > 0) {
-   if (copy > len)
-   copy = len;
-   if (skb_copy_datagram_iovec(frag_iter,
-   offset - start,
-   to, copy))
-   goto fault;
-   if ((len -= copy) == 0)
-   return 0;
-   offset += copy;
-   }
-   start = end;
-   }
-   if (!len)
-   return 0;
-
-fault:
-   return -EFAULT;
-}
-EXPORT_SYMBOL(skb_copy_datagram_iovec);
-
-/**
  * skb_copy_datagram_iter - Copy a datagram to an iovec iterator.
  * @skb: buffer to copy
  * @offset: offset in the buffer to start copying from
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/12] ipv6 equivalent of "ipv4: Avoid reading user iov twice after raw_probe_proto_opt"

2014-12-04 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 net/ipv6/raw.c | 112 -
 1 file changed, 56 insertions(+), 56 deletions(-)

diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 8baa53e..942f67b 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -672,65 +672,62 @@ error:
return err;
 }
 
-static int rawv6_probe_proto_opt(struct flowi6 *fl6, struct msghdr *msg)
+struct raw6_frag_vec {
+   struct msghdr *msg;
+   int hlen;
+   char c[4];
+};
+
+static int rawv6_probe_proto_opt(struct raw6_frag_vec *rfv, struct flowi6 *fl6)
 {
-   struct iovec *iov;
-   u8 __user *type = NULL;
-   u8 __user *code = NULL;
-   u8 len = 0;
-   int probed = 0;
-   int i;
-
-   if (!msg->msg_iov)
-   return 0;
+   int err = 0;
+   switch (fl6->flowi6_proto) {
+   case IPPROTO_ICMPV6:
+   rfv->hlen = 2;
+   err = memcpy_from_msg(rfv->c, rfv->msg, rfv->hlen);
+   if (!err) {
+   fl6->fl6_icmp_type = rfv->c[0];
+   fl6->fl6_icmp_code = rfv->c[1];
+   }
+   break;
+   case IPPROTO_MH:
+   rfv->hlen = 4;
+   err = memcpy_from_msg(rfv->c, rfv->msg, rfv->hlen);
+   if (!err)
+   fl6->fl6_mh_type = rfv->c[2];
+   }
+   return err;
+}
 
-   for (i = 0; i < msg->msg_iovlen; i++) {
-   iov = >msg_iov[i];
-   if (!iov)
-   continue;
+static int raw6_getfrag(void *from, char *to, int offset, int len, int odd,
+  struct sk_buff *skb)
+{
+   struct raw6_frag_vec *rfv = from;
 
-   switch (fl6->flowi6_proto) {
-   case IPPROTO_ICMPV6:
-   /* check if one-byte field is readable or not. */
-   if (iov->iov_base && iov->iov_len < 1)
-   break;
-
-   if (!type) {
-   type = iov->iov_base;
-   /* check if code field is readable or not. */
-   if (iov->iov_len > 1)
-   code = type + 1;
-   } else if (!code)
-   code = iov->iov_base;
-
-   if (type && code) {
-   if (get_user(fl6->fl6_icmp_type, type) ||
-   get_user(fl6->fl6_icmp_code, code))
-   return -EFAULT;
-   probed = 1;
-   }
-   break;
-   case IPPROTO_MH:
-   if (iov->iov_base && iov->iov_len < 1)
-   break;
-   /* check if type field is readable or not. */
-   if (iov->iov_len > 2 - len) {
-   u8 __user *p = iov->iov_base;
-   if (get_user(fl6->fl6_mh_type, [2 - len]))
-   return -EFAULT;
-   probed = 1;
-   } else
-   len += iov->iov_len;
+   if (offset < rfv->hlen) {
+   int copy = min(rfv->hlen - offset, len);
 
-   break;
-   default:
-   probed = 1;
-   break;
-   }
-   if (probed)
-   break;
+   if (skb->ip_summed == CHECKSUM_PARTIAL)
+   memcpy(to, rfv->c + offset, copy);
+   else
+   skb->csum = csum_block_add(
+   skb->csum,
+   csum_partial_copy_nocheck(rfv->c + offset,
+ to, copy, 0),
+   odd);
+
+   odd = 0;
+   offset += copy;
+   to += copy;
+   len -= copy;
+
+   if (!len)
+   return 0;
}
-   return 0;
+
+   offset -= rfv->hlen;
+
+   return ip_generic_getfrag(rfv->msg->msg_iov, to, offset, len, odd, skb);
 }
 
 static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
@@ -745,6 +742,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock 
*sk,
struct ipv6_txoptions *opt = NULL;
struct ip6_flowlabel *flowlabel = NULL;
struct dst_entry *dst = NULL;
+   struct raw6_frag_vec rfv;
struct flowi6 fl6;
int addr_len = msg->msg_namelen;
int hlimit = -1;
@@ -848,7 +846,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock 
*sk,
opt = ipv6_fixup_options(_space, opt);
 
fl6.flowi6_proto = proto;
-   err = rawv6_probe_proto_opt(, msg);
+   rfv.msg = msg;
+   rfv.hlen = 0;
+   err = 

Re: [PATCH v2 1/3] i2c: cadence: Handle > 252 byte transfers

2014-12-04 Thread Harini Katakam
Hi,

On Fri, Dec 5, 2014 at 11:11 AM, rajeev kumar
 wrote:
> On Wed, Dec 3, 2014 at 6:05 PM, Harini Katakam  wrote:
>> The I2C controller sends a NACK to the slave when transfer size register
>> reaches zero, irrespective of the hold bit. So, in order to handle transfers
>> greater than 252 bytes, the transfer size register has to be maintained at a
>> value >= 1. This patch implements the same.
>
> Why 252 Bytes ?  Is it word allign or what ?
>

It is the maximum transfer size that can be written that is a multiple of
the data interrupt (this occurs when the fifo has 14 bytes).
I will include an explanation in driver as well.

Regards,
Harini
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


the next chunk of iov_iter-net stuff for review

2014-12-04 Thread Al Viro
OK, here's the tentative next batch (covers most of the ->recvmsg()
side of conversion).  That's on top of merge of net-next#master with
vfs#iov_iter (the latter had been posted earlier today, Cc'd to netdev among
other places).  This series corresponds to vfs#for-davem.  Review and comments
would be very welcome...

Shortlog:
Al Viro (12):
  raw.c: stick msghdr into raw_frag_vec
  ipv6 equivalent of "ipv4: Avoid reading user iov twice after 
raw_probe_proto_opt"
  ip_generic_getfrag, udplite_getfrag: switch to passing msghdr
  switch tcp_sock->ucopy from iovec (ucopy.iov) to msghdr (ucopy.msg)
  switch l2cap ->memcpy_fromiovec() to msghdr
  vmci: propagate msghdr all way down to __qp_memcpy_from_queue()
  put iov_iter into msghdr
  first fruits - kill l2cap ->memcpy_fromiovec()
  switch memcpy_to_msg() and skb_copy{,_and_csum}_datagram_msg() to 
primitives
  ppp_read(): switch to skb_copy_datagram_iter()
  skb_copy_datagram_iovec() can die
  bury memcpy_toiovec()
Diffstat:
 crypto/algif_hash.c  |   4 +-
 crypto/algif_skcipher.c  |   4 +-
 drivers/misc/vmw_vmci/vmci_queue_pair.c  |  17 ++--
 drivers/net/macvtap.c|   8 +-
 drivers/net/ppp/ppp_generic.c|   4 +-
 drivers/net/tun.c|   8 +-
 drivers/target/iscsi/iscsi_target_util.c |  12 ++-
 drivers/vhost/net.c  |   8 +-
 fs/afs/rxrpc.c   |  14 ++--
 include/linux/skbuff.h   |  22 ++---
 include/linux/socket.h   |   3 +-
 include/linux/tcp.h  |   2 +-
 include/linux/uio.h  |   1 -
 include/linux/vmw_vmci_api.h |   5 +-
 include/net/bluetooth/l2cap.h|  29 ---
 include/net/udplite.h|   4 +-
 lib/iovec.c  |  25 --
 net/atm/common.c |   5 +-
 net/bluetooth/6lowpan.c  |   7 +-
 net/bluetooth/a2mp.c |   4 +-
 net/bluetooth/l2cap_core.c   |   7 +-
 net/bluetooth/l2cap_sock.c   |   8 --
 net/bluetooth/smp.c  |   5 +-
 net/caif/caif_socket.c   |   2 +-
 net/compat.c |  10 ++-
 net/core/datagram.c  | 138 +--
 net/ipv4/ip_output.c |   8 +-
 net/ipv4/ping.c  |   3 +-
 net/ipv4/raw.c   |  11 +--
 net/ipv4/tcp.c   |   8 +-
 net/ipv4/tcp_input.c |   7 +-
 net/ipv4/tcp_output.c|   2 +-
 net/ipv4/udp.c   |   4 +-
 net/ipv6/ping.c  |   3 +-
 net/ipv6/raw.c   | 115 +-
 net/ipv6/udp.c   |   2 +-
 net/l2tp/l2tp_ip6.c  |   2 +-
 net/netlink/af_netlink.c |   2 +-
 net/packet/af_packet.c   |   7 +-
 net/rds/recv.c   |   7 +-
 net/rds/send.c   |   4 +-
 net/rxrpc/ar-output.c|   8 +-
 net/sctp/socket.c|   5 +-
 net/socket.c |  27 +++---
 net/tipc/msg.c   |   4 +-
 net/tipc/socket.c|   4 +-
 net/unix/af_unix.c   |  10 +--
 net/vmw_vsock/vmci_transport.c   |   7 +-
 48 files changed, 204 insertions(+), 402 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 6/6] mmc: rtsx: swap function position to avoid pre declaration

2014-12-04 Thread micky_ching
From: Micky Ching 

move function sd_read_data()/sd_write_data() behind
sd_send_cmd_get_rsp() to avoid pre-declaration.

Signed-off-by: Micky Ching 
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 200 +++---
 1 file changed, 100 insertions(+), 100 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c 
b/drivers/mmc/host/rtsx_pci_sdmmc.c
index b2dfba2..26c6a7c 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -215,106 +215,6 @@ static void sdmmc_post_req(struct mmc_host *mmc, struct 
mmc_request *mrq,
data->host_cookie = 0;
 }
 
-static int sd_read_data(struct realtek_pci_sdmmc *host, struct mmc_command 
*cmd,
-   u16 byte_cnt, u8 *buf, int buf_len, int timeout)
-{
-   struct rtsx_pcr *pcr = host->pcr;
-   int err;
-   u8 trans_mode;
-
-   dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
-   __func__, cmd->opcode, cmd->arg);
-
-   if (!buf)
-   buf_len = 0;
-
-   if (cmd->opcode == MMC_SEND_TUNING_BLOCK)
-   trans_mode = SD_TM_AUTO_TUNING;
-   else
-   trans_mode = SD_TM_NORMAL_READ;
-
-   rtsx_pci_init_cmd(pcr);
-   sd_cmd_set_sd_cmd(pcr, cmd);
-   sd_cmd_set_data_len(pcr, 1, byte_cnt);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CFG2, 0xFF,
-   SD_CALCULATE_CRC7 | SD_CHECK_CRC16 |
-   SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_6);
-   if (trans_mode != SD_TM_AUTO_TUNING)
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   CARD_DATA_SOURCE, 0x01, PINGPONG_BUFFER);
-
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_TRANSFER,
-   0xFF, trans_mode | SD_TRANSFER_START);
-   rtsx_pci_add_cmd(pcr, CHECK_REG_CMD, SD_TRANSFER,
-   SD_TRANSFER_END, SD_TRANSFER_END);
-
-   err = rtsx_pci_send_cmd(pcr, timeout);
-   if (err < 0) {
-   sd_print_debug_regs(host);
-   dev_dbg(sdmmc_dev(host),
-   "rtsx_pci_send_cmd fail (err = %d)\n", err);
-   return err;
-   }
-
-   if (buf && buf_len) {
-   err = rtsx_pci_read_ppbuf(pcr, buf, buf_len);
-   if (err < 0) {
-   dev_dbg(sdmmc_dev(host),
-   "rtsx_pci_read_ppbuf fail (err = %d)\n", err);
-   return err;
-   }
-   }
-
-   return 0;
-}
-
-static int sd_write_data(struct realtek_pci_sdmmc *host,
-   struct mmc_command *cmd, u16 byte_cnt, u8 *buf, int buf_len,
-   int timeout)
-{
-   struct rtsx_pcr *pcr = host->pcr;
-   int err;
-
-   dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
-   __func__, cmd->opcode, cmd->arg);
-
-   if (!buf)
-   buf_len = 0;
-
-   sd_send_cmd_get_rsp(host, cmd);
-   if (cmd->error)
-   return cmd->error;
-
-   if (buf && buf_len) {
-   err = rtsx_pci_write_ppbuf(pcr, buf, buf_len);
-   if (err < 0) {
-   dev_dbg(sdmmc_dev(host),
-   "rtsx_pci_write_ppbuf fail (err = %d)\n", err);
-   return err;
-   }
-   }
-
-   rtsx_pci_init_cmd(pcr);
-   sd_cmd_set_data_len(pcr, 1, byte_cnt);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CFG2, 0xFF,
-   SD_CALCULATE_CRC7 | SD_CHECK_CRC16 |
-   SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_0);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_TRANSFER, 0xFF,
-   SD_TRANSFER_START | SD_TM_AUTO_WRITE_3);
-   rtsx_pci_add_cmd(pcr, CHECK_REG_CMD, SD_TRANSFER,
-   SD_TRANSFER_END, SD_TRANSFER_END);
-
-   err = rtsx_pci_send_cmd(pcr, timeout);
-   if (err < 0) {
-   sd_print_debug_regs(host);
-   dev_dbg(sdmmc_dev(host),
-   "rtsx_pci_send_cmd fail (err = %d)\n", err);
-   return err;
-   }
-
-   return 0;
-}
-
 static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
struct mmc_command *cmd)
 {
@@ -433,6 +333,106 @@ out:
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
 }
 
+static int sd_read_data(struct realtek_pci_sdmmc *host, struct mmc_command 
*cmd,
+   u16 byte_cnt, u8 *buf, int buf_len, int timeout)
+{
+   struct rtsx_pcr *pcr = host->pcr;
+   int err;
+   u8 trans_mode;
+
+   dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
+   __func__, cmd->opcode, cmd->arg);
+
+   if (!buf)
+   buf_len = 0;
+
+   if (cmd->opcode == MMC_SEND_TUNING_BLOCK)
+   trans_mode = SD_TM_AUTO_TUNING;
+   else
+   trans_mode = SD_TM_NORMAL_READ;
+
+   rtsx_pci_init_cmd(pcr);
+   sd_cmd_set_sd_cmd(pcr, cmd);
+   sd_cmd_set_data_len(pcr, 1, byte_cnt);
+  

[PATCH v4 5/6] mmc: rtsx: add support for sdio card

2014-12-04 Thread micky_ching
From: Micky Ching 

Modify transfer mode for support sdio card,
send cmd and data at the same time for read data transfer,
but send data after cmd for write data transfer.

Signed-off-by: Micky Ching 
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 231 ++
 1 file changed, 135 insertions(+), 96 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c 
b/drivers/mmc/host/rtsx_pci_sdmmc.c
index b96c9ed..b2dfba2 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -214,34 +215,27 @@ static void sdmmc_post_req(struct mmc_host *mmc, struct 
mmc_request *mrq,
data->host_cookie = 0;
 }
 
-static int sd_read_data(struct realtek_pci_sdmmc *host, u8 *cmd, u16 byte_cnt,
-   u8 *buf, int buf_len, int timeout)
+static int sd_read_data(struct realtek_pci_sdmmc *host, struct mmc_command 
*cmd,
+   u16 byte_cnt, u8 *buf, int buf_len, int timeout)
 {
struct rtsx_pcr *pcr = host->pcr;
-   int err, i;
+   int err;
u8 trans_mode;
 
-   dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD%d\n", __func__, cmd[0] - 0x40);
+   dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
+   __func__, cmd->opcode, cmd->arg);
 
if (!buf)
buf_len = 0;
 
-   if ((cmd[0] & 0x3F) == MMC_SEND_TUNING_BLOCK)
+   if (cmd->opcode == MMC_SEND_TUNING_BLOCK)
trans_mode = SD_TM_AUTO_TUNING;
else
trans_mode = SD_TM_NORMAL_READ;
 
rtsx_pci_init_cmd(pcr);
-
-   for (i = 0; i < 5; i++)
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD0 + i, 0xFF, cmd[i]);
-
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, (u8)byte_cnt);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BYTE_CNT_H,
-   0xFF, (u8)(byte_cnt >> 8));
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 1);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0);
-
+   sd_cmd_set_sd_cmd(pcr, cmd);
+   sd_cmd_set_data_len(pcr, 1, byte_cnt);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CFG2, 0xFF,
SD_CALCULATE_CRC7 | SD_CHECK_CRC16 |
SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_6);
@@ -274,16 +268,23 @@ static int sd_read_data(struct realtek_pci_sdmmc *host, 
u8 *cmd, u16 byte_cnt,
return 0;
 }
 
-static int sd_write_data(struct realtek_pci_sdmmc *host, u8 *cmd, u16 byte_cnt,
-   u8 *buf, int buf_len, int timeout)
+static int sd_write_data(struct realtek_pci_sdmmc *host,
+   struct mmc_command *cmd, u16 byte_cnt, u8 *buf, int buf_len,
+   int timeout)
 {
struct rtsx_pcr *pcr = host->pcr;
-   int err, i;
-   u8 trans_mode;
+   int err;
+
+   dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
+   __func__, cmd->opcode, cmd->arg);
 
if (!buf)
buf_len = 0;
 
+   sd_send_cmd_get_rsp(host, cmd);
+   if (cmd->error)
+   return cmd->error;
+
if (buf && buf_len) {
err = rtsx_pci_write_ppbuf(pcr, buf, buf_len);
if (err < 0) {
@@ -293,30 +294,13 @@ static int sd_write_data(struct realtek_pci_sdmmc *host, 
u8 *cmd, u16 byte_cnt,
}
}
 
-   trans_mode = cmd ? SD_TM_AUTO_WRITE_2 : SD_TM_AUTO_WRITE_3;
rtsx_pci_init_cmd(pcr);
-
-   if (cmd) {
-   dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d\n", __func__,
-   cmd[0] - 0x40);
-
-   for (i = 0; i < 5; i++)
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
-   SD_CMD0 + i, 0xFF, cmd[i]);
-   }
-
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, (u8)byte_cnt);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BYTE_CNT_H,
-   0xFF, (u8)(byte_cnt >> 8));
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 1);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0);
-
+   sd_cmd_set_data_len(pcr, 1, byte_cnt);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CFG2, 0xFF,
SD_CALCULATE_CRC7 | SD_CHECK_CRC16 |
-   SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_6);
-
+   SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_0);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_TRANSFER, 0xFF,
-   trans_mode | SD_TRANSFER_START);
+   SD_TRANSFER_START | SD_TM_AUTO_WRITE_3);
rtsx_pci_add_cmd(pcr, CHECK_REG_CMD, SD_TRANSFER,
SD_TRANSFER_END, SD_TRANSFER_END);
 
@@ -449,71 +433,113 @@ out:
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
 }
 
-static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
+static int 

[PATCH v4 1/6] mfd: rtsx: add func to split u32 into register

2014-12-04 Thread micky_ching
From: Micky Ching 

Add helper function to write u32 to registers, if we want to put u32
value to 4 continuous register, this can help us reduce tedious work.

Signed-off-by: Micky Ching 
Acked-by: Lee Jones 
---
 include/linux/mfd/rtsx_pci.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 74346d5..9234449 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -558,6 +558,7 @@
 #define SD_SAMPLE_POINT_CTL0xFDA7
 #define SD_PUSH_POINT_CTL  0xFDA8
 #define SD_CMD00xFDA9
+#define   SD_CMD_START 0x40
 #define SD_CMD10xFDAA
 #define SD_CMD20xFDAB
 #define SD_CMD30xFDAC
@@ -967,4 +968,12 @@ static inline u8 *rtsx_pci_get_cmd_data(struct rtsx_pcr 
*pcr)
return (u8 *)(pcr->host_cmds_ptr);
 }
 
+static inline void rtsx_pci_write_be32(struct rtsx_pcr *pcr, u16 reg, u32 val)
+{
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg, 0xFF, val >> 24);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 1, 0xFF, val >> 16);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 2, 0xFF, val >> 8);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 3, 0xFF, val);
+}
+
 #endif
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/6] mmc: rtsx: init cookie at probe/card_event

2014-12-04 Thread micky_ching
From: Micky Ching 

host->cookie is used for handle async request,
we should init it to negative value when new card inserted,
make cookie value invalid.

Signed-off-by: Micky Ching 
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c 
b/drivers/mmc/host/rtsx_pci_sdmmc.c
index b1390f0..90b7b6d 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -1321,6 +1321,7 @@ static void rtsx_pci_sdmmc_card_event(struct 
platform_device *pdev)
 {
struct realtek_pci_sdmmc *host = platform_get_drvdata(pdev);
 
+   host->cookie = -1;
mmc_detect_change(host->mmc, 0);
 }
 
@@ -1353,6 +1354,7 @@ static int rtsx_pci_sdmmc_drv_probe(struct 
platform_device *pdev)
host->pcr = pcr;
host->mmc = mmc;
host->pdev = pdev;
+   host->cookie = -1;
host->power_state = SDMMC_POWER_OFF;
INIT_WORK(>work, sd_request);
platform_set_drvdata(pdev, host);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/6] mmc: rtsx: add helper function to simplify code

2014-12-04 Thread micky_ching
From: Micky Ching 

To support sdio card, transfer mode need make a change,
this need to split code and use it in different place,
Add new function to simplify repeat operation.

Signed-off-by: Micky Ching 
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 95 +--
 1 file changed, 51 insertions(+), 44 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c 
b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 90b7b6d..b96c9ed 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -99,6 +99,50 @@ static void sd_print_debug_regs(struct realtek_pci_sdmmc 
*host)
 #define sd_print_debug_regs(host)
 #endif /* DEBUG */
 
+static void sd_cmd_set_sd_cmd(struct rtsx_pcr *pcr, struct mmc_command *cmd)
+{
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD0, 0xFF,
+   SD_CMD_START | cmd->opcode);
+   rtsx_pci_write_be32(pcr, SD_CMD1, cmd->arg);
+}
+
+static void sd_cmd_set_data_len(struct rtsx_pcr *pcr, u16 blocks, u16 blksz)
+{
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, blocks);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, blocks >> 8);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, blksz);
+   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, blksz >> 8);
+}
+
+static int sd_response_type(struct mmc_command *cmd)
+{
+   switch (mmc_resp_type(cmd)) {
+   case MMC_RSP_NONE:
+   return SD_RSP_TYPE_R0;
+   case MMC_RSP_R1:
+   return SD_RSP_TYPE_R1;
+   case MMC_RSP_R1 & ~MMC_RSP_CRC:
+   return SD_RSP_TYPE_R1 | SD_NO_CHECK_CRC7;
+   case MMC_RSP_R1B:
+   return SD_RSP_TYPE_R1b;
+   case MMC_RSP_R2:
+   return SD_RSP_TYPE_R2;
+   case MMC_RSP_R3:
+   return SD_RSP_TYPE_R3;
+   default:
+   return -EINVAL;
+   }
+}
+
+static int sd_status_index(int resp_type)
+{
+   if (resp_type == SD_RSP_TYPE_R0)
+   return 0;
+   else if (resp_type == SD_RSP_TYPE_R2)
+   return 16;
+
+   return 5;
+}
 /*
  * sd_pre_dma_transfer - do dma_map_sg() or using cookie
  *
@@ -297,47 +341,18 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc 
*host,
int timeout = 100;
int i;
u8 *ptr;
-   int stat_idx = 0;
-   u8 rsp_type;
-   int rsp_len = 5;
+   int rsp_type;
+   int stat_idx;
bool clock_toggled = false;
 
dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
__func__, cmd_idx, arg);
 
-   /* Response type:
-* R0
-* R1, R5, R6, R7
-* R1b
-* R2
-* R3, R4
-*/
-   switch (mmc_resp_type(cmd)) {
-   case MMC_RSP_NONE:
-   rsp_type = SD_RSP_TYPE_R0;
-   rsp_len = 0;
-   break;
-   case MMC_RSP_R1:
-   rsp_type = SD_RSP_TYPE_R1;
-   break;
-   case MMC_RSP_R1 & ~MMC_RSP_CRC:
-   rsp_type = SD_RSP_TYPE_R1 | SD_NO_CHECK_CRC7;
-   break;
-   case MMC_RSP_R1B:
-   rsp_type = SD_RSP_TYPE_R1b;
-   break;
-   case MMC_RSP_R2:
-   rsp_type = SD_RSP_TYPE_R2;
-   rsp_len = 16;
-   break;
-   case MMC_RSP_R3:
-   rsp_type = SD_RSP_TYPE_R3;
-   break;
-   default:
-   dev_dbg(sdmmc_dev(host), "cmd->flag is not valid\n");
-   err = -EINVAL;
+   rsp_type = sd_response_type(cmd);
+   if (rsp_type < 0)
goto out;
-   }
+
+   stat_idx = sd_status_index(rsp_type);
 
if (rsp_type == SD_RSP_TYPE_R1b)
timeout = 3000;
@@ -352,13 +367,7 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc 
*host,
}
 
rtsx_pci_init_cmd(pcr);
-
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD0, 0xFF, 0x40 | cmd_idx);
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD1, 0xFF, (u8)(arg >> 24));
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD2, 0xFF, (u8)(arg >> 16));
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD3, 0xFF, (u8)(arg >> 8));
-   rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD4, 0xFF, (u8)arg);
-
+   sd_cmd_set_sd_cmd(pcr, cmd);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CFG2, 0xFF, rsp_type);
rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_DATA_SOURCE,
0x01, PINGPONG_BUFFER);
@@ -372,12 +381,10 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc 
*host,
/* Read data from ping-pong buffer */
for (i = PPBUF_BASE2; i < PPBUF_BASE2 + 16; i++)
rtsx_pci_add_cmd(pcr, READ_REG_CMD, (u16)i, 0, 0);
-   stat_idx = 16;
} else if (rsp_type != SD_RSP_TYPE_R0) {
/* Read data from SD_CMDx registers */
for (i = SD_CMD0; i <= SD_CMD4; i++)
rtsx_pci_add_cmd(pcr, 

[PATCH v4 0/6] mmc: rtsx: add support for sdio card

2014-12-04 Thread micky_ching
From: Micky Ching 

v4:
  split patch in more detailed patches. no code changes diff v3.

v3:
  rtsx_pci_sdmmc.c:
- dump_reg_range
  - remove unused pointer check
  - fix start index
v2:
  rtsx_pci.h:
- remove unused rtsx_pci_write_le32
- add SD_CMD_START
  rtsx_pci_sdmmc.c:
- dump_reg_range
  - alloc data on stack
- remove forward declaration
- use SD_CMD_START replace magic number 0x40
- move initialize assignment to error handling

This patch is used to change transfer mode for sdio card support
by SD interface.



Micky Ching (6):
  mfd: rtsx: add func to split u32 into register
  mmc: rtsx: add dump_reg_range to simplify dump register
  mmc: rtsx: init cookie at probe/card_event
  mmc: rtsx: add helper function to simplify code
  mmc: rtsx: add support for sdio card
  mmc: rtsx: swap function position to avoid pre declaration

 drivers/mmc/host/rtsx_pci_sdmmc.c | 522 +-
 include/linux/mfd/rtsx_pci.h  |   9 +
 2 files changed, 296 insertions(+), 235 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/6] mmc: rtsx: add dump_reg_range to simplify dump register

2014-12-04 Thread micky_ching
From: Micky Ching 

Add a new function to dump register within a range.
We print 1 register a line before this patch,
this may make debug info too long when we add more register to dump.

The new dump_reg_range() dump to 8 register a line,
and it is easy to use.

Signed-off-by: Micky Ching 
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 38 +-
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c 
b/drivers/mmc/host/rtsx_pci_sdmmc.c
index c70b602..b1390f0 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -71,25 +71,29 @@ static inline void sd_clear_error(struct realtek_pci_sdmmc 
*host)
 }
 
 #ifdef DEBUG
-static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)
+static void dump_reg_range(struct realtek_pci_sdmmc *host, u16 start, u16 end)
 {
-   struct rtsx_pcr *pcr = host->pcr;
-   u16 i;
-   u8 *ptr;
+   u16 len = end - start + 1;
+   int i;
+   u8 data[8];
+
+   for (i = 0; i < len; i += 8) {
+   int j;
+   int n = min(8, len - i);
+
+   memset(, 0, sizeof(data));
+   for (j = 0; j < n; j++)
+   rtsx_pci_read_register(host->pcr, start + i + j,
+   data + j);
+   dev_dbg(sdmmc_dev(host), "0x%04X(%d): %8ph\n",
+   start + i, n, data);
+   }
+}
 
-   /* Print SD host internal registers */
-   rtsx_pci_init_cmd(pcr);
-   for (i = 0xFDA0; i <= 0xFDAE; i++)
-   rtsx_pci_add_cmd(pcr, READ_REG_CMD, i, 0, 0);
-   for (i = 0xFD52; i <= 0xFD69; i++)
-   rtsx_pci_add_cmd(pcr, READ_REG_CMD, i, 0, 0);
-   rtsx_pci_send_cmd(pcr, 100);
-
-   ptr = rtsx_pci_get_cmd_data(pcr);
-   for (i = 0xFDA0; i <= 0xFDAE; i++)
-   dev_dbg(sdmmc_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
-   for (i = 0xFD52; i <= 0xFD69; i++)
-   dev_dbg(sdmmc_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
+static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)
+{
+   dump_reg_range(host, 0xFDA0, 0xFDB3);
+   dump_reg_range(host, 0xFD52, 0xFD69);
 }
 #else
 #define sd_print_debug_regs(host)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] ftracetest: Add --verbose option for showing echo output

2014-12-04 Thread Namhyung Kim
On Fri, Dec 05, 2014 at 02:23:23PM +0900, Masami Hiramatsu wrote:
> (2014/12/05 14:08), Namhyung Kim wrote:
> > On Thu, Dec 04, 2014 at 02:41:23PM -0500, Masami Hiramatsu wrote:
> >> Add --verbose/-v option for showing echo output in testcases.
> >> This is good for checking the progress of testcases which
> >> take a longer time to run.
> >>
> >> To implement this feature, all the testcase failures are
> >> captured in ftracetest and send signal to set SIG_RESULT=FAIL.
> >>
> >> Signed-off-by: Masami Hiramatsu 
> >> ---
> > 
> > [SNIP]
> >> -  # setup PID and PPID, $$ is not updated.
> >> -  (cd $TRACING_DIR; read PID _ < /proc/self/stat ;
> >> -   set -e; set -x; . $1) >> $testlog 2>&1
> >> -  eval_result $? $SIG_RESULT
> >> +  if [ $VERBOSE -ne 0 ]; then
> >> +__run_test $1 2>> $testlog | tee -a $testlog
> > 
> > Shouldn't it be
> > 
> >__run_test $1 2>&1 | tee -a $testlog
> > 
> > ?
> 
> No, that outputs both stdout and stderr to $testlog and console.
> What I'd like to do above is only stdout to $testlog and console and
> stderr goes only to $testlog. (Note that __run_test set -x which outputs
> every executed command to stderr)

Hmm.. so the actual output of the failing command is not shown on
console even when -v option is given, right?

Anyway I worried about that the order of messages might be mixed..

  echo msg1 > /dev/stdout
  echo msg2 > /dev/stderr
  echo msg3 > /dev/stdout
  echo msg4 > /dev/stderr

So the output in this case can be like msg2, msg4, msg1, and msg3..?

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2 V7] intel_pstate: add kernel parameter to force loading on Sun X86 servers.

2014-12-04 Thread ethan zhao

Linda,

On 2014/12/5 12:56, Linda Knippers wrote:

Hi Ethan,

On 12/4/2014 10:38 PM, ethan zhao wrote:

Linda,

On 2014/12/5 7:03, Linda Knippers wrote:

On 12/4/2014 5:38 PM, Kristen Carlson Accardi wrote:

On Thu, 04 Dec 2014 23:10:58 +0100
"Rafael J. Wysocki"  wrote:


On Thursday, December 04, 2014 11:07:31 AM Ethan Zhao wrote:

To force loading on Oracle Sun X86 servers, provide one kernel command line
parameter

intel_pstate = ora_force

I would suggest to change the name of the option to "oracle_force" or
"sun_force"
for clarity.

Anyway, I need an ACK from Kristen if this patch is to be applied.


For those who be aware of the risk of no power capping capabily working and
try to get better performance with this driver.

Signed-off-by: Ethan Zhao 
---
   v2: change to hardware vendor specific naming parameter.
   v4: refine code and doc.
   v5: fix a typo in doc.
   v7: change enum PCC to PPC.

   Documentation/kernel-parameters.txt | 5 +
   drivers/cpufreq/intel_pstate.c  | 6 +-
   2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/kernel-parameters.txt
b/Documentation/kernel-parameters.txt
index 479f332..7d0983e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1446,6 +1446,11 @@ bytes respectively. Such letter suffixes can also be
entirely omitted.
  disable
Do not enable intel_pstate as the default
scaling driver for the supported processors
+   ora_force
+ Force loading intel_pstate on Oracle Sun Servers(X86).
+ only for those who be aware of the risk of no power capping
+ capability working and try to get better performance with this
+ driver.

That is not sufficiently clear.  What does "risk of no power capping capability
working" mean, in particular?


 intremap=[X86-64, Intel-IOMMU]
   onenable Interrupt Remapping (default)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 1bb62ca..2654e13 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -866,6 +866,7 @@ static struct cpufreq_driver intel_pstate_driver = {
   };
 static int __initdata no_load;
+static unsigned int  ora_force;
 static int intel_pstate_msrs_not_valid(void)
   {
@@ -1003,7 +1004,8 @@ static bool intel_pstate_platform_pwr_mgmt_exists(void)
   case PSS:
   return intel_pstate_no_acpi_pss();
   case PPC:
-return intel_pstate_has_acpi_ppc();
+return intel_pstate_has_acpi_ppc() &&
+(!ora_force);
   }
   }
   @@ -1078,6 +1080,8 @@ static int __init intel_pstate_setup(char *str)
 if (!strcmp(str, "disable"))
   no_load = 1;
+if (!strcmp(str, "ora_force"))
+ora_force = 1;
   return 0;
   }
   early_param("intel_pstate", intel_pstate_setup);

And can anyone please remind me what was wrong with a "force" option that would
work for everyone, not just Oracle/Sun?


That was my suggestion as well (i.e. a parameter to bypass the vendor
checks), but Linda didn't like it.  My personal opinion is that unless
it's generic, I don't really feel like having a force option solely for
oracle.  I'm not convinced you want this for production machines, and I
think for debug purposes I don't want a vendor specific param.

I'd be happy with it if it somehow disabled what the platform is doing,
but it doesn't.  I don't see the point of forcing intel_pstate if you
can't force the platform to stop doing power management at the same time.
Even if it's for test/debug purposes, I'm not sure what you're testing
when you have dueling power management.

   Most of the power management functions is done by SP(service processor) on 
Sun
X86
   servers, the 'force' parameter is not supposed to disable whole platform
working I think,
   with intel_pstate,  it doesn't do CPU power capping issued via _PPC
notification. but all
  other rest parts of the power management still work. There is no scene as HP
proliant OS
  mode that OS could control everything(sorry, I don't know Proliant 
Architecture).

  So at least, it doesn't make sense to Oracle Sun X86 servers, provide an OS
option to stop
  all PM functions even disable ACPI at all.

  If the users could be aware of that the power capping doesn't work with CPUs.
they could
  load intel_pstate driver, though there may be faulty in SP . they still could
monitor and
  manage the power consumption of other parts in the server.

  Perhaps this is what we would test/have tested with intel_pstate.

  There is a public manual about PM command in Sun server SP may could help you
to understand
  the  difference.
  https://docs.oracle.com/cd/E19121-01/sf.x4150/820-6412-12/820-6412-12.pdf

I've tried to put the pieces together so tell me if I've got this right.
  Sorry, I have a little 

Re: [PATCH v2 0/2] mmc: rtsx: add support for sdio card

2014-12-04 Thread 敬锐

On 12/04/2014 09:52 PM, Ulf Hansson wrote:
>> v3:
>> >   rtsx_pci_sdmmc.c:
>> > - dump_reg_range
>> >   - remove unused pointer check
>> >   - fix start index
> I can't find v3.
>
> Kind regards
> Uffe
>
Sorry for mistake, This is v3, but subject is wrong.

Re: [PATCH v2 1/3] i2c: cadence: Handle > 252 byte transfers

2014-12-04 Thread rajeev kumar
On Wed, Dec 3, 2014 at 6:05 PM, Harini Katakam  wrote:
> The I2C controller sends a NACK to the slave when transfer size register
> reaches zero, irrespective of the hold bit. So, in order to handle transfers
> greater than 252 bytes, the transfer size register has to be maintained at a
> value >= 1. This patch implements the same.

Why 252 Bytes ?  Is it word allign or what ?

> The interrupt status is cleared at the beginning of the isr instead of
> the end, to avoid missing any interrupts - this is in sync with the new
> transfer handling.
>

No need to write this, actually this is the correct way of handling interrupt.

> Signed-off-by: Harini Katakam 
> ---
>
> v2:
> No changes
>
> ---
>  drivers/i2c/busses/i2c-cadence.c |  156 
> --
>  1 file changed, 81 insertions(+), 75 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-cadence.c 
> b/drivers/i2c/busses/i2c-cadence.c
> index 63f3f03..e54899e 100644
> --- a/drivers/i2c/busses/i2c-cadence.c
> +++ b/drivers/i2c/busses/i2c-cadence.c
> @@ -126,6 +126,7 @@
>   * @suspended: Flag holding the device's PM status
>   * @send_count:Number of bytes still expected to send
>   * @recv_count:Number of bytes still expected to receive
> + * @curr_recv_count:   Number of bytes to be received in current transfer

Please do the alignment properly

>   * @irq:   IRQ number
>   * @input_clk: Input clock to I2C controller
>   * @i2c_clk:   Maximum I2C clock speed
> @@ -144,6 +145,7 @@ struct cdns_i2c {
> u8 suspended;
> unsigned int send_count;
> unsigned int recv_count;
> +   unsigned int curr_recv_count;

same here..

> int irq;
> unsigned long input_clk;
> unsigned int i2c_clk;
> @@ -180,14 +182,15 @@ static void cdns_i2c_clear_bus_hold(struct cdns_i2c *id)
>   */
>  static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
>  {
> -   unsigned int isr_status, avail_bytes;
> -   unsigned int bytes_to_recv, bytes_to_send;
> +   unsigned int isr_status, avail_bytes, updatetx;
> +   unsigned int bytes_to_send;

why you are mixing tab and space..

> struct cdns_i2c *id = ptr;
> /* Signal completion only after everything is updated */
> int done_flag = 0;
> irqreturn_t status = IRQ_NONE;
>
> isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
> +   cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
>
> /* Handling nack and arbitration lost interrupt */
> if (isr_status & (CDNS_I2C_IXR_NACK | CDNS_I2C_IXR_ARB_LOST)) {
> @@ -195,89 +198,91 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
> status = IRQ_HANDLED;
> }
>
> -   /* Handling Data interrupt */
> -   if ((isr_status & CDNS_I2C_IXR_DATA) &&
> -   (id->recv_count >= CDNS_I2C_DATA_INTR_DEPTH)) {
> -   /* Always read data interrupt threshold bytes */
> -   bytes_to_recv = CDNS_I2C_DATA_INTR_DEPTH;
> -   id->recv_count -= CDNS_I2C_DATA_INTR_DEPTH;
> -   avail_bytes = cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET);
> -
> -   /*
> -* if the tranfer size register value is zero, then
> -* check for the remaining bytes and update the
> -* transfer size register.
> -*/
> -   if (!avail_bytes) {
> -   if (id->recv_count > CDNS_I2C_TRANSFER_SIZE)
> -   cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE,
> -   CDNS_I2C_XFER_SIZE_OFFSET);
> -   else
> -   cdns_i2c_writereg(id->recv_count,
> -   CDNS_I2C_XFER_SIZE_OFFSET);
> -   }
> +   updatetx = 0;
> +   if (id->recv_count > id->curr_recv_count)
> +   updatetx = 1;
> +
> +   /* When receiving, handle data and transfer complete interrupts */

Breaking statement

> +   if (id->p_recv_buf &&
> +   ((isr_status & CDNS_I2C_IXR_COMP) ||
> +(isr_status & CDNS_I2C_IXR_DATA))) {
> +   while (cdns_i2c_readreg(CDNS_I2C_SR_OFFSET) &
> +  CDNS_I2C_SR_RXDV) {
> +   if ((id->recv_count < CDNS_I2C_FIFO_DEPTH) &&
> +   !id->bus_hold_flag)
> +   cdns_i2c_clear_bus_hold(id);

make it simple. you can use extra variables also.

>
> -   /* Process the data received */
> -   while (bytes_to_recv--)
> *(id->p_recv_buf)++ =
> cdns_i2c_readreg(CDNS_I2C_DATA_OFFSET);
> +   id->recv_count--;
> +   id->curr_recv_count--;
>
> -   if (!id->bus_hold_flag &&
> -   (id->recv_count <= CDNS_I2C_FIFO_DEPTH))
> -  

Re: [PATCH 2/2] ftracetest: Add --verbose option for showing echo output

2014-12-04 Thread Masami Hiramatsu
(2014/12/05 14:08), Namhyung Kim wrote:
> On Thu, Dec 04, 2014 at 02:41:23PM -0500, Masami Hiramatsu wrote:
>> Add --verbose/-v option for showing echo output in testcases.
>> This is good for checking the progress of testcases which
>> take a longer time to run.
>>
>> To implement this feature, all the testcase failures are
>> captured in ftracetest and send signal to set SIG_RESULT=FAIL.
>>
>> Signed-off-by: Masami Hiramatsu 
>> ---
> 
> [SNIP]
>> -  # setup PID and PPID, $$ is not updated.
>> -  (cd $TRACING_DIR; read PID _ < /proc/self/stat ;
>> -   set -e; set -x; . $1) >> $testlog 2>&1
>> -  eval_result $? $SIG_RESULT
>> +  if [ $VERBOSE -ne 0 ]; then
>> +__run_test $1 2>> $testlog | tee -a $testlog
> 
> Shouldn't it be
> 
>__run_test $1 2>&1 | tee -a $testlog
> 
> ?

No, that outputs both stdout and stderr to $testlog and console.
What I'd like to do above is only stdout to $testlog and console and
stderr goes only to $testlog. (Note that __run_test set -x which outputs
every executed command to stderr)

Thank you,

> 
> Thanks,
> Namhyung
> 
> 
>> +  else
>> +__run_test $1 >> $testlog 2>&1
>> +  fi
>> +  eval_result $SIG_RESULT
>>if [ $? -eq 0 ]; then
>>  # Remove test log if the test was done as it was expected.
>>  [ $KEEP_LOG -eq 0 ] && rm $testlog
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu...@hitachi.com


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 0/5] ARM64: Add kernel probes(Kprobes) support

2014-12-04 Thread William Cohen
On 12/03/2014 08:16 PM, William Cohen wrote:
> On 12/03/2014 05:54 PM, David Long wrote:
>> On 12/03/14 09:54, William Cohen wrote:
>>> On 12/01/2014 04:37 AM, Masami Hiramatsu wrote:
 (2014/11/29 1:01), Steve Capper wrote:
> On 27 November 2014 at 06:07, Masami Hiramatsu
>  wrote:
>> (2014/11/27 3:59), Steve Capper wrote:
>>> The crash is extremely easy to reproduce.
>>>
>>> I've not observed any missed events on a kprobe on an arm64 system
>>> that's still alive.
>>> My (limited!) understanding is that this suggests there could be a
>>> problem with how missed events from a recursive call to memcpy are
>>> being handled.
>>
>> I think so too. BTW, could you bisect that? :)
>>
>
> I can't bisect, but the following functions look suspicious to me
> (again I'm new to kprobes...):
> kprobes_save_local_irqflag
> kprobes_restore_local_irqflag
>
> I think these are breaking somehow when nested (i.e. from a recursive 
> probe).

 Agreed. On x86, prev_kprobe has old_flags and saved_flags, this
 at least must have saved_irqflag and save/restore it in
 save/restore_previous_kprobe().

 What about adding this?

   struct prev_kprobe {
   struct kprobe *kp;
   unsigned int status;
 +unsigned long saved_irqflag;
   };

 and

   static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)
   {
   kcb->prev_kprobe.kp = kprobe_running();
   kcb->prev_kprobe.status = kcb->kprobe_status;
 +kcb->prev_kprobe.saved_irqflag = kcb->saved_irqflag;
   }

   static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb)
   {
   __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp);
   kcb->kprobe_status = kcb->prev_kprobe.status;
 +kcb->saved_irqflag = kcb->prev_kprobe.saved_irqflag;
   }


>>>
>>> I have noticed with the aarch64 kprobe patches and recent kernel I can get 
>>> the machine to end up getting stuck and printing out endless strings of
>>>
>>> [187694.855843] Unexpected kernel single-step exception at EL1
>>> [187694.861385] Unexpected kernel single-step exception at EL1
>>> [187694.866926] Unexpected kernel single-step exception at EL1
>>> [187694.872467] Unexpected kernel single-step exception at EL1
>>> [187694.878009] Unexpected kernel single-step exception at EL1
>>> [187694.883550] Unexpected kernel single-step exception at EL1
>>>
>>> I can reproduce this pretty easily on my machine with functioncallcount.stp 
>>> from 
>>> https://sourceware.org/systemtap/examples/profiling/functioncallcount.stp 
>>> and the following steps:
>>>
>>> # stap -p4 -k -m mm_probes -w functioncallcount.stp "*@mm/*.c" -c "sleep 1"
>>> # staprun mm_probes.ko -c "sleep 1"
>>>
>>> -Will
>>
>> I did a fresh checkout and build of systemtap and tried the above.  I'm not 
>> yet seeing this problem.  It does remind me of the problem we saw before 
>> debug exception handling in entry.S was patched in v3.18-rc1, but you say 
>> you are using recent kernel sources.
>>
> 
> Hi Dave,
> 
> I saw this problem with a 3.18.0-rc5 based kernel.  Today I built a kernel 
> based on  3.18.0-0.rc6.git0.1.x1 with the patches and I didn't see the 
> problem with the unexpected kernel single-step exception.  I am not sure if 
> maybe there was some problem function being probed in the 3.18.0-rc5 kernel 
> but not with the 3.18.0-rc6 kernel or maybe some difference in the config 
> between the kernels. It seemed wiser to mention it.
> 

I saw this problem with the 3.18.0-rc6 kernel today. Note that this kernel did 
not have the patch for save_irqflag masami suggested above.  It seems to be an 
intermittent problem and doesn't occur every time.  The particular systemtap 
test that is triggering the problem installs a lot of probe points and this 
could be triggering some problem with nested kprobes.

-Will
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] ftracetest: Add --verbose option for showing echo output

2014-12-04 Thread Namhyung Kim
On Thu, Dec 04, 2014 at 02:41:23PM -0500, Masami Hiramatsu wrote:
> Add --verbose/-v option for showing echo output in testcases.
> This is good for checking the progress of testcases which
> take a longer time to run.
> 
> To implement this feature, all the testcase failures are
> captured in ftracetest and send signal to set SIG_RESULT=FAIL.
> 
> Signed-off-by: Masami Hiramatsu 
> ---

[SNIP]
> -  # setup PID and PPID, $$ is not updated.
> -  (cd $TRACING_DIR; read PID _ < /proc/self/stat ;
> -   set -e; set -x; . $1) >> $testlog 2>&1
> -  eval_result $? $SIG_RESULT
> +  if [ $VERBOSE -ne 0 ]; then
> +__run_test $1 2>> $testlog | tee -a $testlog

Shouldn't it be

   __run_test $1 2>&1 | tee -a $testlog

?

Thanks,
Namhyung


> +  else
> +__run_test $1 >> $testlog 2>&1
> +  fi
> +  eval_result $SIG_RESULT
>if [ $? -eq 0 ]; then
>  # Remove test log if the test was done as it was expected.
>  [ $KEEP_LOG -eq 0 ] && rm $testlog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: frequent lockups in 3.18rc4

2014-12-04 Thread Sasha Levin
On 12/02/2014 06:32 PM, Sasha Levin wrote:
> On 12/02/2014 02:32 PM, Dave Jones wrote:
>> > On Mon, Dec 01, 2014 at 06:08:38PM -0500, Chris Mason wrote:
>> >  > I'm not sure if this is related, but running trinity here, I noticed it
>> >  > was stuck at 100% system time on every CPU.  perf report tells me we are
>> >  > spending all of our time in spin_lock under the sync system call.
>> >  > 
>> >  > I think it's coming from contention in the bdi_queue_work() call from
>> >  > inside sync_inodes_sb, which is spin_lock_bh(). 
>> >  > 
>> >  > I wonder if we're just spinning so hard on this one bh lock that we're
>> >  > starving the watchdog?
>> >  > 
>> >  > Dave, do you have spinlock debugging on?  
>> > 
>> > That has been a constant, yes. I can try with that disabled some time.
> Here's my side of the story: I was observing RCU lockups which went away when
> I disabled verbose printing for fault injections. It seems that printing one
> line ~10 times a second can cause that...

Just to add to this: I've enabled the simplest level of verbosity in the fault
injection options, and RCU stalls are again easy to trigger:

[ 3926.110026] INFO: rcu_preempt detected stalls on CPUs/tasks:
[ 3926.110026] INFO: rcu_sched detected stalls on CPUs/tasks:
[ 3926.110026]  0: (62 ticks this GP) idle=b63/142/0 
softirq=20384/20384 last_accelerate: f772/8874, nonlazy_posted: 619783, ..
[ 3926.110026]  (detected by 2, t=30002 jiffies, g=-222, c=-223, q=0)
[ 3926.110026] Task dump for CPU 0:
[ 3926.110026] kworker/dying   R  running task13464 7  2 0x00080008
[ 3926.110026]  814db441 88006aa3bd68 814db441 
e8fff3c6c9d4
[ 3926.110026]   88006aa3bd88 814db76b 
93a27440
[ 3926.110026]  dfffe900 88006aa26890 88006aa26000 
88006aa3b5d8
[ 3926.110026] Call Trace:
[ 3926.110026]  [] ? get_parent_ip+0x11/0x50
[ 3926.110026]  [] ? get_parent_ip+0x11/0x50
[ 3926.110026]  [] ? preempt_count_sub+0x11b/0x1d0
[ 3926.110026]  [] ? do_exit+0x1687/0x3f20
[ 3926.110026]  [] ? worker_thread+0xa28/0x1760
[ 3926.110026]  [] ? process_one_work+0x17a0/0x17a0
[ 3926.110026]  [] ? kthread+0x229/0x320
[ 3926.110026]  [] ? kthread_worker_fn+0x7d0/0x7d0
[ 3926.110026]  [] ? ret_from_fork+0x7c/0xb0
[ 3926.110026]  [] ? kthread_worker_fn+0x7d0/0x7d0
[ 3926.110033]
[ 3926.110033]  0: (62 ticks this GP) idle=b63/142/0 
softirq=20384/20384 last_accelerate: f772/8876, nonlazy_posted: 619783, ..
[ 3926.110033]  (detected by 10, t=30004 jiffies, g=15638, c=15637, q=63609)
[ 3926.110033] Task dump for CPU 0:
[ 3926.110033] kworker/dying   R  running task13464 7  2 0x00080008
[ 3926.110033]  814db441 88006aa3bd68 814db441 
e8fff3c6c9d4
[ 3926.110033]   88006aa3bd88 814db76b 
93a27440
[ 3926.110033]  dfffe900 88006aa26890 88006aa26000 
88006aa3b5d8
[ 3926.110033] Call Trace:
[ 3926.110033]  [] ? get_parent_ip+0x11/0x50
[ 3926.110033]  [] ? get_parent_ip+0x11/0x50
[ 3926.110033]  [] ? preempt_count_sub+0x11b/0x1d0
[ 3926.110033]  [] ? do_exit+0x1687/0x3f20
[ 3926.110033]  [] ? worker_thread+0xa28/0x1760
[ 3926.110033]  [] ? process_one_work+0x17a0/0x17a0
[ 3926.110033]  [] ? kthread+0x229/0x320
[ 3926.110033]  [] ? kthread_worker_fn+0x7d0/0x7d0
[ 3926.110033]  [] ? ret_from_fork+0x7c/0xb0
[ 3926.110033]  [] ? kthread_worker_fn+0x7d0/0x7d0


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2 V7] intel_pstate: add kernel parameter to force loading on Sun X86 servers.

2014-12-04 Thread Linda Knippers

Hi Ethan,

On 12/4/2014 10:38 PM, ethan zhao wrote:
> Linda,
> 
> On 2014/12/5 7:03, Linda Knippers wrote:
>> On 12/4/2014 5:38 PM, Kristen Carlson Accardi wrote:
>>> On Thu, 04 Dec 2014 23:10:58 +0100
>>> "Rafael J. Wysocki"  wrote:
>>>
 On Thursday, December 04, 2014 11:07:31 AM Ethan Zhao wrote:
> To force loading on Oracle Sun X86 servers, provide one kernel command 
> line
> parameter
>
>intel_pstate = ora_force
 I would suggest to change the name of the option to "oracle_force" or
 "sun_force"
 for clarity.

 Anyway, I need an ACK from Kristen if this patch is to be applied.

> For those who be aware of the risk of no power capping capabily working 
> and
> try to get better performance with this driver.
>
> Signed-off-by: Ethan Zhao 
> ---
>   v2: change to hardware vendor specific naming parameter.
>   v4: refine code and doc.
>   v5: fix a typo in doc.
>   v7: change enum PCC to PPC.
>
>   Documentation/kernel-parameters.txt | 5 +
>   drivers/cpufreq/intel_pstate.c  | 6 +-
>   2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/kernel-parameters.txt
> b/Documentation/kernel-parameters.txt
> index 479f332..7d0983e 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -1446,6 +1446,11 @@ bytes respectively. Such letter suffixes can also 
> be
> entirely omitted.
>  disable
>Do not enable intel_pstate as the default
>scaling driver for the supported processors
> +   ora_force
> + Force loading intel_pstate on Oracle Sun Servers(X86).
> + only for those who be aware of the risk of no power capping
> + capability working and try to get better performance with 
> this
> + driver.
 That is not sufficiently clear.  What does "risk of no power capping 
 capability
 working" mean, in particular?

> intremap=[X86-64, Intel-IOMMU]
>   onenable Interrupt Remapping (default)
> diff --git a/drivers/cpufreq/intel_pstate.c 
> b/drivers/cpufreq/intel_pstate.c
> index 1bb62ca..2654e13 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -866,6 +866,7 @@ static struct cpufreq_driver intel_pstate_driver = {
>   };
> static int __initdata no_load;
> +static unsigned int  ora_force;
> static int intel_pstate_msrs_not_valid(void)
>   {
> @@ -1003,7 +1004,8 @@ static bool 
> intel_pstate_platform_pwr_mgmt_exists(void)
>   case PSS:
>   return intel_pstate_no_acpi_pss();
>   case PPC:
> -return intel_pstate_has_acpi_ppc();
> +return intel_pstate_has_acpi_ppc() &&
> +(!ora_force);
>   }
>   }
>   @@ -1078,6 +1080,8 @@ static int __init intel_pstate_setup(char *str)
> if (!strcmp(str, "disable"))
>   no_load = 1;
> +if (!strcmp(str, "ora_force"))
> +ora_force = 1;
>   return 0;
>   }
>   early_param("intel_pstate", intel_pstate_setup);
 And can anyone please remind me what was wrong with a "force" option that 
 would
 work for everyone, not just Oracle/Sun?

>>> That was my suggestion as well (i.e. a parameter to bypass the vendor
>>> checks), but Linda didn't like it.  My personal opinion is that unless
>>> it's generic, I don't really feel like having a force option solely for
>>> oracle.  I'm not convinced you want this for production machines, and I
>>> think for debug purposes I don't want a vendor specific param.
>> I'd be happy with it if it somehow disabled what the platform is doing,
>> but it doesn't.  I don't see the point of forcing intel_pstate if you
>> can't force the platform to stop doing power management at the same time.
>> Even if it's for test/debug purposes, I'm not sure what you're testing
>> when you have dueling power management.
>   Most of the power management functions is done by SP(service processor) on 
> Sun
> X86
>   servers, the 'force' parameter is not supposed to disable whole platform
> working I think,
>   with intel_pstate,  it doesn't do CPU power capping issued via _PPC
> notification. but all
>  other rest parts of the power management still work. There is no scene as HP
> proliant OS
>  mode that OS could control everything(sorry, I don't know Proliant 
> Architecture).
> 
>  So at least, it doesn't make sense to Oracle Sun X86 servers, provide an OS
> option to stop
>  all PM functions even disable ACPI at all.
> 
>  If the users could be aware of that the power capping doesn't work with CPUs.
> they could
>  load intel_pstate driver, though 

[PATCH v13 7/7] ARM: kprobes: enable OPTPROBES for ARM 32

2014-12-04 Thread Wang Nan
This patch introduce kprobeopt for ARM 32.

Limitations:
 - Currently only kernel compiled with ARM ISA is supported.

 - Offset between probe point and optinsn slot must not larger than
   32MiB. Masami Hiramatsu suggests replacing 2 words, it will make
   things complex. Futher patch can make such optimization.

Kprobe opt on ARM is relatively simpler than kprobe opt on x86 because
ARM instruction is always 4 bytes aligned and 4 bytes long. This patch
replace probed instruction by a 'b', branch to trampoline code and then
calls optimized_callback(). optimized_callback() calls opt_pre_handler()
to execute kprobe handler. It also emulate/simulate replaced instruction.

When unregistering kprobe, the deferred manner of unoptimizer may leave
branch instruction before optimizer is called. Different from x86_64,
which only copy the probed insn after optprobe_template_end and
reexecute them, this patch call singlestep to emulate/simulate the insn
directly. Futher patch can optimize this behavior.

Signed-off-by: Wang Nan 
Acked-by: Masami Hiramatsu 
Cc: Jon Medhurst (Tixy) 
Cc: Russell King - ARM Linux 
Cc: Will Deacon 
---
v1 -> v2:
 - Improvement: if replaced instruction is conditional, generate a
   conditional branch instruction for it;
 - Introduces RELATIVEJUMP_OPCODES due to ARM kprobe_opcode_t is 4
   bytes;
 - Removes size field in struct arch_optimized_insn;
 - Use arm_gen_branch() to generate branch instruction;
 - Remove all recover logic: ARM doesn't use tail buffer, no need
   recover replaced instructions like x86;
 - Remove incorrect CONFIG_THUMB checking;
 - can_optimize() always returns true if address is well aligned;
 - Improve optimized_callback: using opt_pre_handler();
 - Bugfix: correct range checking code and improve comments;
 - Fix commit message.

v2 -> v3:
 - Rename RELATIVEJUMP_OPCODES to MAX_COPIED_INSNS;
 - Remove unneeded checking:
  arch_check_optimized_kprobe(), can_optimize();
 - Add missing flush_icache_range() in arch_prepare_optimized_kprobe();
 - Remove unneeded 'return;'.

v3 -> v4:
 - Use __mem_to_opcode_arm() to translate copied_insn to ensure it
   works in big endian kernel;
 - Replace 'nop' placeholder in trampoline code template with
   '.long 0' to avoid confusion: reader may regard 'nop' as an
   instruction, but it is value in fact.

v4 -> v5:
 - Don't optimize stack store operations.
 - Introduce prepared field to arch_optimized_insn to indicate whether
   it is prepared. Similar to size field with x86. See v1 -> v2.

v5 -> v6:
 - Dynamically reserve stack according to instruction.
 - Rename: kprobes-opt.c -> kprobes-opt-arm.c.
 - Set op->optinsn.insn after all works are done.

v6 -> v7:
  - Using checker to check stack consumption.

v7 -> v8:
  - Small code adjustments.

v8 -> v9:
  - Utilize original kprobe passed to arch_prepare_optimized_kprobe()
to avoid copy ainsn twice.
  - A bug in arch_prepare_optimized_kprobe() is found and fixed.

v9 -> v10:
  - Commit message improvements.

v10 -> v11:
  - Move to arch/arm/probes/, insn.h is moved to arch/arm/include/asm.
  - Code cleanup.
  - Bugfix based on Tixy's test result:
- Trampoline deal with ARM -> Thumb transision instructions and
  AEABI stack alignment requirement correctly.
- Trampoline code buffer should start at 4 byte aligned address.
  We enforces it in this series by using macro to wrap 'code' var.

v11 -> v12:
  - Remove trampoline code stack trick and use r4 to save original
stack.
  - Remove trampoline code buffer alignment trick.
  - Names of files are changed.

v12 -> v13:
  - Assume stack always aligned by 4-bytes in any case.
  - Comments update.
---
 arch/arm/Kconfig|   1 +
 arch/arm/{kernel => include/asm}/insn.h |   0
 arch/arm/include/asm/kprobes.h  |  29 +++
 arch/arm/kernel/Makefile|   2 +-
 arch/arm/kernel/ftrace.c|   3 +-
 arch/arm/kernel/jump_label.c|   3 +-
 arch/arm/probes/kprobes/Makefile|   1 +
 arch/arm/probes/kprobes/opt-arm.c   | 313 
 8 files changed, 347 insertions(+), 5 deletions(-)
 rename arch/arm/{kernel => include/asm}/insn.h (100%)
 create mode 100644 arch/arm/probes/kprobes/opt-arm.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 89c4b5c..2471240 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -59,6 +59,7 @@ config ARM
select HAVE_MEMBLOCK
select HAVE_MOD_ARCH_SPECIFIC if ARM_UNWIND
select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
+   select HAVE_OPTPROBES if !THUMB2_KERNEL
select HAVE_PERF_EVENTS
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
diff --git a/arch/arm/kernel/insn.h b/arch/arm/include/asm/insn.h
similarity index 100%
rename from arch/arm/kernel/insn.h
rename to arch/arm/include/asm/insn.h
diff --git a/arch/arm/include/asm/kprobes.h b/arch/arm/include/asm/kprobes.h
index 56f9ac6..50ff3bc 100644
--- a/arch/arm/include/asm/kprobes.h
+++ 

[PATCH v13 6/7] kprobes: Pass the original kprobe for preparing optimized kprobe

2014-12-04 Thread Wang Nan
From: Masami Hiramatsu 

Pass the original kprobe for preparing an optimized kprobe arch-dep
part, since for some architecture (e.g. ARM32) requires the information
in original kprobe.

Signed-off-by: Masami Hiramatsu 
Signed-off-by: Wang Nan 
---
 arch/x86/kernel/kprobes/opt.c | 3 ++-
 include/linux/kprobes.h   | 3 ++-
 kernel/kprobes.c  | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index f1314d0..7028296 100644
--- a/arch/x86/kernel/kprobes/opt.c
+++ b/arch/x86/kernel/kprobes/opt.c
@@ -320,7 +320,8 @@ void arch_remove_optimized_kprobe(struct optimized_kprobe 
*op)
  * Target instructions MUST be relocatable (checked inside)
  * This is called when new aggr(opt)probe is allocated or reused.
  */
-int arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
+int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
+ struct kprobe *__unused)
 {
u8 *buf;
int ret;
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index f7296e5..7ab2c93 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -308,7 +308,8 @@ struct optimized_kprobe {
 /* Architecture dependent functions for direct jump optimization */
 extern int arch_prepared_optinsn(struct arch_optimized_insn *optinsn);
 extern int arch_check_optimized_kprobe(struct optimized_kprobe *op);
-extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op);
+extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
+struct kprobe *orig);
 extern void arch_remove_optimized_kprobe(struct optimized_kprobe *op);
 extern void arch_optimize_kprobes(struct list_head *oplist);
 extern void arch_unoptimize_kprobes(struct list_head *oplist,
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 3995f54..9f28aa7 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -717,7 +717,7 @@ static void prepare_optimized_kprobe(struct kprobe *p)
struct optimized_kprobe *op;
 
op = container_of(p, struct optimized_kprobe, kp);
-   arch_prepare_optimized_kprobe(op);
+   arch_prepare_optimized_kprobe(op, p);
 }
 
 /* Allocate new optimized_kprobe and try to prepare optimized instructions */
@@ -731,7 +731,7 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p)
 
INIT_LIST_HEAD(>list);
op->kp.addr = p->addr;
-   arch_prepare_optimized_kprobe(op);
+   arch_prepare_optimized_kprobe(op, p);
 
return >kp;
 }
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v13 4/7] ARM: kprobes: disallow probing stack consuming instructions

2014-12-04 Thread Wang Nan
This patch prohibits probing instructions for which the stack
requirements are unable to be determined statically. Some test cases
are found not work again after the modification, this patch also
removes them.

Signed-off-by: Wang Nan 
Reviewed-by: Jon Medhurst 
---
v1 -> v2:
 - Use MAX_STACK_SIZE macro instead of hard coded stack size.

v2 -> v3:
 - Commit message improvements.

v3 -> v4:
 - Commit message improvements.

v4 -> v5:
 - Move to arch/arm/probes.
---
 arch/arm/include/asm/kprobes.h |  1 -
 arch/arm/include/asm/probes.h  | 12 
 arch/arm/kernel/entry-armv.S   |  3 ++-
 arch/arm/probes/kprobes/core.c |  9 +
 arch/arm/probes/kprobes/test-arm.c | 16 ++--
 5 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/kprobes.h b/arch/arm/include/asm/kprobes.h
index 49fa0df..56f9ac6 100644
--- a/arch/arm/include/asm/kprobes.h
+++ b/arch/arm/include/asm/kprobes.h
@@ -22,7 +22,6 @@
 
 #define __ARCH_WANT_KPROBES_INSN_SLOT
 #define MAX_INSN_SIZE  2
-#define MAX_STACK_SIZE 64  /* 32 would probably be OK */
 
 #define flush_insn_slot(p) do { } while (0)
 #define kretprobe_blacklist_size   0
diff --git a/arch/arm/include/asm/probes.h b/arch/arm/include/asm/probes.h
index ccf9af3..f0a1ee8 100644
--- a/arch/arm/include/asm/probes.h
+++ b/arch/arm/include/asm/probes.h
@@ -19,6 +19,8 @@
 #ifndef _ASM_PROBES_H
 #define _ASM_PROBES_H
 
+#ifndef __ASSEMBLY__
+
 typedef u32 probes_opcode_t;
 
 struct arch_probes_insn;
@@ -41,4 +43,14 @@ struct arch_probes_insn {
int stack_space;
 };
 
+#endif /* __ASSEMBLY__ */
+
+/*
+ * We assume one instruction can consume at most 64 bytes stack, which is
+ * 'push {r0-r15}'. Instructions consume more or unknown stack space like
+ * 'str r0, [sp, #-80]' and 'str r0, [sp, r1]' should be prohibit to probe.
+ * Both kprobe and jprobe use this macro.
+ */
+#define MAX_STACK_SIZE 64
+
 #endif
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 2fd..672b219 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -31,6 +31,7 @@
 
 #include "entry-header.S"
 #include 
+#include 
 
 /*
  * Interrupt handling.
@@ -249,7 +250,7 @@ __und_svc:
@ If a kprobe is about to simulate a "stmdb sp..." instruction,
@ it obviously needs free stack space which then will belong to
@ the saved context.
-   svc_entry 64
+   svc_entry MAX_STACK_SIZE
 #else
svc_entry
 #endif
diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c
index 74f3dc3..3a58db4 100644
--- a/arch/arm/probes/kprobes/core.c
+++ b/arch/arm/probes/kprobes/core.c
@@ -115,6 +115,15 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
break;
}
 
+   /*
+* Never instrument insn like 'str r0, [sp, +/-r1]'. Also, insn likes
+* 'str r0, [sp, #-68]' should also be prohibited.
+* See __und_svc.
+*/
+   if ((p->ainsn.stack_space < 0) ||
+   (p->ainsn.stack_space > MAX_STACK_SIZE))
+   return -EINVAL;
+
return 0;
 }
 
diff --git a/arch/arm/probes/kprobes/test-arm.c 
b/arch/arm/probes/kprobes/test-arm.c
index d9a1255..fdeb300 100644
--- a/arch/arm/probes/kprobes/test-arm.c
+++ b/arch/arm/probes/kprobes/test-arm.c
@@ -476,7 +476,8 @@ void kprobe_arm_test_cases(void)
TEST_GROUP("Extra load/store instructions")
 
TEST_RPR(  "strhr",0, VAL1,", [r",1, 48,", -r",2, 24,"]")
-   TEST_RPR(  "streqh  r",14,VAL2,", [r",13,0, ", r",12, 48,"]")
+   TEST_RPR(  "streqh  r",14,VAL2,", [r",11,0, ", r",12, 48,"]")
+   TEST_UNSUPPORTED(  "streqh  r14, [r13, r12]")
TEST_RPR(  "strhr",1, VAL1,", [r",2, 24,", r",3,  48,"]!")
TEST_RPR(  "strneh  r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
TEST_RPR(  "strhr",2, VAL1,", [r",3, 24,"], r",4, 48,"")
@@ -565,7 +566,8 @@ void kprobe_arm_test_cases(void)
 
 #if __LINUX_ARM_ARCH__ >= 5
TEST_RPR(  "strdr",0, VAL1,", [r",1, 48,", -r",2,24,"]")
-   TEST_RPR(  "strccd  r",8, VAL2,", [r",13,0, ", r",12,48,"]")
+   TEST_RPR(  "strccd  r",8, VAL2,", [r",11,0, ", r",12,48,"]")
+   TEST_UNSUPPORTED(  "strccd r8, [r13, r12]")
TEST_RPR(  "strdr",4, VAL1,", [r",2, 24,", r",3, 48,"]!")
TEST_RPR(  "strcsd  r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
TEST_RPR(  "strdr",2, VAL1,", [r",5, 24,"], r",4,48,"")
@@ -638,13 +640,15 @@ void kprobe_arm_test_cases(void)
TEST_RP( "str"byte" r",2, VAL1,", [r",3, 24,"], #48")   
\
TEST_RP( "str"byte" r",10,VAL2,", [r",9, 64,"], #-48")  
\
TEST_RPR("str"byte" r",0, VAL1,", [r",1, 48,", -r",2, 24,"]")   
\
-   TEST_RPR("str"byte" r",14,VAL2,", [r",13,0, ", r",12, 48,"]")   
\
+   TEST_RPR("str"byte" 

[PATCH v13 3/7] ARM: kprobes: collects stack consumption for store instructions

2014-12-04 Thread Wang Nan
This patch uses the previously introduced checker functionality on
store instructions to record their stack consumption information to
arch_probes_insn.

Signed-off-by: Wang Nan 
Signed-off-by: Jon Medhurst 
Reviewed-by: Jon Medhurst 
---
v1 -> v2:
 - Bugfix and code improvements following Tixy's suggestion. See:
http://www.spinics.net/lists/arm-kernel/msg372912.html

v2 -> v3:
 - Totaly reconstructed following Tixy' instruction. See:
   https://lkml.org/lkml/2014/10/27/662 .
   Add his SOB.

v3 -> v4:
 - Commit message improvements.
 - Comments improvements and code cleanup.
 - A bug is found and fixed in decode table in arm_check_stack().

v4 -> v5:
 - Bugs in thumb2 decoding table is found by Tixy and fixed.

v5 -> v6:
 - Move to arch/arm/probes/ .
---
 arch/arm/include/asm/probes.h |   1 +
 arch/arm/probes/decode.c  |  10 +++
 arch/arm/probes/kprobes/Makefile  |   6 +-
 arch/arm/probes/kprobes/actions-arm.c |   3 +-
 arch/arm/probes/kprobes/actions-thumb.c   |   5 +-
 arch/arm/probes/kprobes/checkers-arm.c|  99 +++
 arch/arm/probes/kprobes/checkers-common.c | 101 +++
 arch/arm/probes/kprobes/checkers-thumb.c  | 110 ++
 arch/arm/probes/kprobes/checkers.h|  54 +++
 9 files changed, 383 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/probes/kprobes/checkers-arm.c
 create mode 100644 arch/arm/probes/kprobes/checkers-common.c
 create mode 100644 arch/arm/probes/kprobes/checkers-thumb.c
 create mode 100644 arch/arm/probes/kprobes/checkers.h

diff --git a/arch/arm/include/asm/probes.h b/arch/arm/include/asm/probes.h
index 806cfe6..ccf9af3 100644
--- a/arch/arm/include/asm/probes.h
+++ b/arch/arm/include/asm/probes.h
@@ -38,6 +38,7 @@ struct arch_probes_insn {
probes_check_cc *insn_check_cc;
probes_insn_singlestep_t*insn_singlestep;
probes_insn_fn_t*insn_fn;
+   int stack_space;
 };
 
 #endif
diff --git a/arch/arm/probes/decode.c b/arch/arm/probes/decode.c
index c7d4420..f9d7c42 100644
--- a/arch/arm/probes/decode.c
+++ b/arch/arm/probes/decode.c
@@ -425,6 +425,16 @@ probes_decode_insn(probes_opcode_t insn, struct 
arch_probes_insn *asi,
 */
probes_opcode_t origin_insn = insn;
 
+   /*
+* stack_space is initialized to 0 here. Checker functions
+* should update is value if they find this is a stack store
+* instruction: positive value means bytes of stack usage,
+* negitive value means unable to determine stack usage
+* statically. For instruction doesn't store to stack, checker
+* do nothing with it.
+*/
+   asi->stack_space = 0;
+
if (emulate)
insn = prepare_emulated_insn(insn, asi, thumb);
 
diff --git a/arch/arm/probes/kprobes/Makefile b/arch/arm/probes/kprobes/Makefile
index eb38a42..bc8d504 100644
--- a/arch/arm/probes/kprobes/Makefile
+++ b/arch/arm/probes/kprobes/Makefile
@@ -1,11 +1,11 @@
-obj-$(CONFIG_KPROBES)  += core.o actions-common.o
+obj-$(CONFIG_KPROBES)  += core.o actions-common.o checkers-common.o
 obj-$(CONFIG_ARM_KPROBES_TEST) += test-kprobes.o
 test-kprobes-objs  := test-core.o
 
 ifdef CONFIG_THUMB2_KERNEL
-obj-$(CONFIG_KPROBES)  += actions-thumb.o
+obj-$(CONFIG_KPROBES)  += actions-thumb.o checkers-thumb.o
 test-kprobes-objs  += test-thumb.o
 else
-obj-$(CONFIG_KPROBES)  += actions-arm.o
+obj-$(CONFIG_KPROBES)  += actions-arm.o checkers-arm.o
 test-kprobes-objs  += test-arm.o
 endif
diff --git a/arch/arm/probes/kprobes/actions-arm.c 
b/arch/arm/probes/kprobes/actions-arm.c
index 3c3afa4..1e67839 100644
--- a/arch/arm/probes/kprobes/actions-arm.c
+++ b/arch/arm/probes/kprobes/actions-arm.c
@@ -64,6 +64,7 @@
 
 #include "../decode-arm.h"
 #include "core.h"
+#include "checkers.h"
 
 #if  __LINUX_ARM_ARCH__ >= 6
 #define BLX(reg)   "blx"reg"   \n\t"
@@ -342,4 +343,4 @@ const union decode_action 
kprobes_arm_actions[NUM_PROBES_ARM_ACTIONS] = {
[PROBES_LDMSTM] = {.decoder = kprobe_decode_ldmstm}
 };
 
-const struct decode_checker *kprobes_arm_checkers[] = {NULL};
+const struct decode_checker *kprobes_arm_checkers[] = {arm_stack_checker, 
NULL};
diff --git a/arch/arm/probes/kprobes/actions-thumb.c 
b/arch/arm/probes/kprobes/actions-thumb.c
index 2796121..07cfd9b 100644
--- a/arch/arm/probes/kprobes/actions-thumb.c
+++ b/arch/arm/probes/kprobes/actions-thumb.c
@@ -15,6 +15,7 @@
 
 #include "../decode-thumb.h"
 #include "core.h"
+#include "checkers.h"
 
 /* These emulation encodings are functionally equivalent... */
 #define t32_emulate_rd8rn16rm0ra12_noflags \
@@ -665,5 +666,5 @@ const union decode_action 
kprobes_t32_actions[NUM_PROBES_T32_ACTIONS] = {
.handler = t32_emulate_rdlo12rdhi8rn16rm0_noflags},
 };
 
-const struct decode_checker 

[PATCH v13 5/7] ARM: kprobes: Add test cases for stack consuming instructions

2014-12-04 Thread Wang Nan
From: Jon Medhurst 

These have extra 'checker' functions associated with them so
lets make sure those get covered by testing.

Signed-off-by: Jon Medhurst 
Signed-off-by: Wang Nan 
---
v1 -> v2:
 - Move to arch/arm/probes/ .
---
 arch/arm/probes/kprobes/test-arm.c   | 17 +++--
 arch/arm/probes/kprobes/test-thumb.c | 12 
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/arch/arm/probes/kprobes/test-arm.c 
b/arch/arm/probes/kprobes/test-arm.c
index fdeb300..9b3b1b4 100644
--- a/arch/arm/probes/kprobes/test-arm.c
+++ b/arch/arm/probes/kprobes/test-arm.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "test-core.h"
 
@@ -478,6 +479,7 @@ void kprobe_arm_test_cases(void)
TEST_RPR(  "strhr",0, VAL1,", [r",1, 48,", -r",2, 24,"]")
TEST_RPR(  "streqh  r",14,VAL2,", [r",11,0, ", r",12, 48,"]")
TEST_UNSUPPORTED(  "streqh  r14, [r13, r12]")
+   TEST_UNSUPPORTED(  "streqh  r14, [r12, r13]")
TEST_RPR(  "strhr",1, VAL1,", [r",2, 24,", r",3,  48,"]!")
TEST_RPR(  "strneh  r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
TEST_RPR(  "strhr",2, VAL1,", [r",3, 24,"], r",4, 48,"")
@@ -502,6 +504,9 @@ void kprobe_arm_test_cases(void)
TEST_RP(   "strplh  r",12,VAL2,", [r",11,24,", #-4]!")
TEST_RP(   "strhr",2, VAL1,", [r",3, 24,"], #48")
TEST_RP(   "strhr",10,VAL2,", [r",9, 64,"], #-48")
+   TEST_RP(   "strhr",3, VAL1,", [r",13,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"]!")
+   TEST_UNSUPPORTED("strh r3, [r13, #-"__stringify(MAX_STACK_SIZE)"-8]!")
+   TEST_RP(   "strhr",4, VAL1,", [r",14,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"-8]!")
TEST_UNSUPPORTED(__inst_arm(0xe1efc3b0) "   @ strh r12, [pc, #48]!")
TEST_UNSUPPORTED(__inst_arm(0xe0c9f3b0) "   @ strh pc, [r9], #48")
 
@@ -568,6 +573,7 @@ void kprobe_arm_test_cases(void)
TEST_RPR(  "strdr",0, VAL1,", [r",1, 48,", -r",2,24,"]")
TEST_RPR(  "strccd  r",8, VAL2,", [r",11,0, ", r",12,48,"]")
TEST_UNSUPPORTED(  "strccd r8, [r13, r12]")
+   TEST_UNSUPPORTED(  "strccd r8, [r12, r13]")
TEST_RPR(  "strdr",4, VAL1,", [r",2, 24,", r",3, 48,"]!")
TEST_RPR(  "strcsd  r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
TEST_RPR(  "strdr",2, VAL1,", [r",5, 24,"], r",4,48,"")
@@ -591,6 +597,9 @@ void kprobe_arm_test_cases(void)
TEST_RP(   "strvcd  r",12,VAL2,", [r",11,24,", #-16]!")
TEST_RP(   "strdr",2, VAL1,", [r",4, 24,"], #48")
TEST_RP(   "strdr",10,VAL2,", [r",9, 64,"], #-48")
+   TEST_RP(   "strdr",6, VAL1,", [r",13,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"]!")
+   TEST_UNSUPPORTED("strd r6, [r13, #-"__stringify(MAX_STACK_SIZE)"-8]!")
+   TEST_RP(   "strdr",4, VAL1,", [r",12,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"-8]!")
TEST_UNSUPPORTED(__inst_arm(0xe1efc3f0) "   @ strd r12, [pc, #48]!")
 
TEST_P("ldrdr0, [r",0, 24,", #-8]")
@@ -639,16 +648,20 @@ void kprobe_arm_test_cases(void)
TEST_RP( "str"byte" r",12,VAL2,", [r",11,24,", #-4]!")  
\
TEST_RP( "str"byte" r",2, VAL1,", [r",3, 24,"], #48")   
\
TEST_RP( "str"byte" r",10,VAL2,", [r",9, 64,"], #-48")  
\
+   TEST_RP( "str"byte" r",3, VAL1,", [r",13,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"]!") \
+   TEST_UNSUPPORTED("str"byte" r3, [r13, 
#-"__stringify(MAX_STACK_SIZE)"-8]!") \
+   TEST_RP( "str"byte" r",4, VAL1,", [r",10,TEST_MEMORY_SIZE,", 
#-"__stringify(MAX_STACK_SIZE)"-8]!") \
TEST_RPR("str"byte" r",0, VAL1,", [r",1, 48,", -r",2, 24,"]")   
\
TEST_RPR("str"byte" r",14,VAL2,", [r",11,0, ", r",12, 48,"]")   
\
-   TEST_UNSUPPORTED("str"byte" r14, [r13, r12]")   \
+   TEST_UNSUPPORTED("str"byte" r14, [r13, r12]")   
\
+   TEST_UNSUPPORTED("str"byte" r14, [r12, r13]")   
\
TEST_RPR("str"byte" r",1, VAL1,", [r",2, 24,", r",3,  48,"]!")  
\
TEST_RPR("str"byte" r",12,VAL2,", [r",11,48,", -r",10,24,"]!")  
\
TEST_RPR("str"byte" r",2, VAL1,", [r",3, 24,"], r",4, 48,"")
\
TEST_RPR("str"byte" r",10,VAL2,", [r",9, 48,"], -r",11,24,"")   
\
TEST_RPR("str"byte" r",0, VAL1,", [r",1, 24,", r",2,  32,", asl 
#1]")\
TEST_RPR("str"byte" r",14,VAL2,", [r",11,0, ", r",12, 32,", lsr 
#2]")\
-   TEST_UNSUPPORTED("str"byte" r14, [r13, r12, lsr #2]")\
+   TEST_UNSUPPORTED("str"byte" r14, [r13, r12, lsr #2]")   
\
TEST_RPR("str"byte" r",1, VAL1,", [r",2, 24,", r",3,  32,", asr 
#3]!")\
TEST_RPR("str"byte" r",12,VAL2,", [r",11,24,", r",10, 

[PATCH v13 2/7] ARM: kprobes: introduces checker

2014-12-04 Thread Wang Nan
This patch introdces 'checker' to decoding phase, and calls checkers
when instruction decoding. This allows further decoding for specific
instructions.  This patch introduces a stub call of checkers in kprobe
arch_prepare_kprobe() as an example and for further expansion.

Signed-off-by: Wang Nan 
Reviewed-by: Jon Medhurst 
Reviewed-by: Masami Hiramatsu 
---
v1 -> v2:
 - kprobe checker stubs are introduced in this patch.

v2 -> v3:
 - Code cleanups following Masami Hiramatsu and Tixy's advises.
 - Commit message improvements.

v3 -> v4:
 - Move to arch/arm/probes.
---
 arch/arm/probes/decode-arm.c|  5 +--
 arch/arm/probes/decode-arm.h|  3 +-
 arch/arm/probes/decode-thumb.c  | 10 +++---
 arch/arm/probes/decode-thumb.h  |  6 ++--
 arch/arm/probes/decode.c| 60 +
 arch/arm/probes/decode.h| 11 +-
 arch/arm/probes/kprobes/actions-arm.c   |  2 ++
 arch/arm/probes/kprobes/actions-thumb.c |  3 ++
 arch/arm/probes/kprobes/core.c  |  6 +++-
 arch/arm/probes/kprobes/core.h  |  7 ++--
 arch/arm/probes/uprobes/core.c  |  2 +-
 11 files changed, 95 insertions(+), 20 deletions(-)

diff --git a/arch/arm/probes/decode-arm.c b/arch/arm/probes/decode-arm.c
index e39cc75..f46d8fc 100644
--- a/arch/arm/probes/decode-arm.c
+++ b/arch/arm/probes/decode-arm.c
@@ -726,10 +726,11 @@ static void __kprobes arm_singlestep(probes_opcode_t insn,
  */
 enum probes_insn __kprobes
 arm_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-  bool emulate, const union decode_action *actions)
+  bool emulate, const union decode_action *actions,
+  const struct decode_checker *checkers[])
 {
asi->insn_singlestep = arm_singlestep;
asi->insn_check_cc = probes_condition_checks[insn>>28];
return probes_decode_insn(insn, asi, probes_decode_arm_table, false,
- emulate, actions);
+ emulate, actions, checkers);
 }
diff --git a/arch/arm/probes/decode-arm.h b/arch/arm/probes/decode-arm.h
index 9c56b40..a7b0398 100644
--- a/arch/arm/probes/decode-arm.h
+++ b/arch/arm/probes/decode-arm.h
@@ -70,6 +70,7 @@ extern const union decode_item probes_decode_arm_table[];
 
 enum probes_insn arm_probes_decode_insn(probes_opcode_t,
struct arch_probes_insn *, bool emulate,
-   const union decode_action *actions);
+   const union decode_action *actions,
+   const struct decode_checker *checkers[]);
 
 #endif
diff --git a/arch/arm/probes/decode-thumb.c b/arch/arm/probes/decode-thumb.c
index 2f0453a..985e7dd 100644
--- a/arch/arm/probes/decode-thumb.c
+++ b/arch/arm/probes/decode-thumb.c
@@ -863,20 +863,22 @@ static void __kprobes thumb32_singlestep(probes_opcode_t 
opcode,
 
 enum probes_insn __kprobes
 thumb16_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-  bool emulate, const union decode_action *actions)
+  bool emulate, const union decode_action *actions,
+  const struct decode_checker *checkers[])
 {
asi->insn_singlestep = thumb16_singlestep;
asi->insn_check_cc = thumb_check_cc;
return probes_decode_insn(insn, asi, probes_decode_thumb16_table, true,
- emulate, actions);
+ emulate, actions, checkers);
 }
 
 enum probes_insn __kprobes
 thumb32_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-  bool emulate, const union decode_action *actions)
+  bool emulate, const union decode_action *actions,
+  const struct decode_checker *checkers[])
 {
asi->insn_singlestep = thumb32_singlestep;
asi->insn_check_cc = thumb_check_cc;
return probes_decode_insn(insn, asi, probes_decode_thumb32_table, true,
- emulate, actions);
+ emulate, actions, checkers);
 }
diff --git a/arch/arm/probes/decode-thumb.h b/arch/arm/probes/decode-thumb.h
index 039013c..8457add 100644
--- a/arch/arm/probes/decode-thumb.h
+++ b/arch/arm/probes/decode-thumb.h
@@ -91,9 +91,11 @@ extern const union decode_item probes_decode_thumb16_table[];
 
 enum probes_insn __kprobes
 thumb16_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-   bool emulate, const union decode_action *actions);
+   bool emulate, const union decode_action *actions,
+   const struct decode_checker *checkers[]);
 enum probes_insn __kprobes
 thumb32_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
-   bool emulate, const union decode_action *actions);
+   bool emulate, const union decode_action *actions,
+   const struct 

[PATCH v13 1/7] ARM: probes: move all probe code to dedicate directory

2014-12-04 Thread Wang Nan
In discussion on LKML (https://lkml.org/lkml/2014/11/28/158), Russell
King suggests to move all probe related code to arch/arm/probes. This
patch does the work. Due to dependency on 'arch/arm/kernel/patch.h', this
patch also moves patch.h to 'arch/arm/include/asm/patch.h', and related
'#include' directives are also midified to '#include '.

Following is an overview of this patch:

 ./arch/arm/kernel/   ./arch/arm/probes/
 |-- Makefile |-- Makefile
 |-- probes-arm.c  ==>|-- decode-arm.c
 |-- probes-arm.h  ==>|-- decode-arm.h
 |-- probes-thumb.c==>|-- decode-thumb.c
 |-- probes-thumb.h==>|-- decode-thumb.h
 |-- probes.c  ==>|-- decode.c
 |-- probes.h  ==>|-- decode.h
 ||-- kprobes
 ||   |-- Makefile
 |-- kprobes-arm.c ==>|   |-- actions-arm.c
 |-- kprobes-common.c  ==>|   |-- actions-common.c
 |-- kprobes-thumb.c   ==>|   |-- actions-thumb.c
 |-- kprobes.c ==>|   |-- core.c
 |-- kprobes.h ==>|   |-- core.h
 |-- kprobes-test-arm.c==>|   |-- test-arm.c
 |-- kprobes-test.c==>|   |-- test-core.c
 |-- kprobes-test.h==>|   |-- test-core.h
 |-- kprobes-test-thumb.c  ==>|   `-- test-thumb.c
 |`-- uprobes
 ||-- Makefile
 |-- uprobes-arm.c ==>|-- actions-arm.c
 |-- uprobes.c ==>|-- core.c
 |-- uprobes.h ==>`-- core.h
 |
 `-- patch.h   ==>arch/arm/include/asm/patch.h

Signed-off-by: Wang Nan 
---
v1 -> v2:
 - Rename source files to describe their functions.
 - Add Makefiles in kprobes and uprobes directories.
---
 arch/arm/Makefile|  1 +
 arch/arm/{kernel => include/asm}/patch.h |  0
 arch/arm/kernel/Makefile | 16 ++--
 arch/arm/kernel/jump_label.c |  2 +-
 arch/arm/kernel/patch.c  |  3 +--
 arch/arm/probes/Makefile |  7 +++
 arch/arm/{kernel/probes-arm.c => probes/decode-arm.c}|  7 ---
 arch/arm/{kernel/probes-arm.h => probes/decode-arm.h}|  4 +++-
 .../arm/{kernel/probes-thumb.c => probes/decode-thumb.c} |  6 +++---
 .../arm/{kernel/probes-thumb.h => probes/decode-thumb.h} |  4 +++-
 arch/arm/{kernel/probes.c => probes/decode.c}|  4 ++--
 arch/arm/{kernel/probes.h => probes/decode.h}|  2 +-
 arch/arm/probes/kprobes/Makefile | 11 +++
 .../kprobes-arm.c => probes/kprobes/actions-arm.c}   |  6 +++---
 .../kprobes-common.c => probes/kprobes/actions-common.c} |  4 ++--
 .../kprobes-thumb.c => probes/kprobes/actions-thumb.c}   |  6 +++---
 arch/arm/{kernel/kprobes.c => probes/kprobes/core.c} |  8 
 arch/arm/{kernel/kprobes.h => probes/kprobes/core.h} |  3 ++-
 .../kprobes-test-arm.c => probes/kprobes/test-arm.c} |  2 +-
 .../kprobes-test.c => probes/kprobes/test-core.c}|  8 
 .../kprobes-test.h => probes/kprobes/test-core.h}|  2 +-
 .../kprobes-test-thumb.c => probes/kprobes/test-thumb.c} |  4 ++--
 arch/arm/probes/uprobes/Makefile |  2 ++
 .../uprobes-arm.c => probes/uprobes/actions-arm.c}   |  6 +++---
 arch/arm/{kernel/uprobes.c => probes/uprobes/core.c} |  6 +++---
 arch/arm/{kernel/uprobes.h => probes/uprobes/core.h} |  0
 26 files changed, 69 insertions(+), 55 deletions(-)
 rename arch/arm/{kernel => include/asm}/patch.h (100%)
 create mode 100644 arch/arm/probes/Makefile
 rename arch/arm/{kernel/probes-arm.c => probes/decode-arm.c} (99%)
 rename arch/arm/{kernel/probes-arm.h => probes/decode-arm.h} (97%)
 rename arch/arm/{kernel/probes-thumb.c => probes/decode-thumb.c} (99%)
 rename arch/arm/{kernel/probes-thumb.h => probes/decode-thumb.h} (97%)
 rename arch/arm/{kernel/probes.c => probes/decode.c} (99%)
 rename arch/arm/{kernel/probes.h => probes/decode.h} (99%)
 create mode 100644 arch/arm/probes/kprobes/Makefile
 rename arch/arm/{kernel/kprobes-arm.c => probes/kprobes/actions-arm.c} (99%)
 rename arch/arm/{kernel/kprobes-common.c => probes/kprobes/actions-common.c} 
(98%)
 rename arch/arm/{kernel/kprobes-thumb.c => probes/kprobes/actions-thumb.c} 
(99%)
 rename arch/arm/{kernel/kprobes.c => probes/kprobes/core.c} (99%)
 rename arch/arm/{kernel/kprobes.h => probes/kprobes/core.h} (96%)
 rename arch/arm/{kernel/kprobes-test-arm.c => probes/kprobes/test-arm.c} (99%)
 rename arch/arm/{kernel/kprobes-test.c => probes/kprobes/test-core.c} (99%)
 rename arch/arm/{kernel/kprobes-test.h => probes/kprobes/test-core.h} (99%)
 rename arch/arm/{kernel/kprobes-test-thumb.c => probes/kprobes/test-thumb.c} 
(99%)
 create mode 100644 arch/arm/probes/uprobes/Makefile
 rename 

[PATCH v13 0/7] ARM: kprobes: OPTPROBES and other improvements.

2014-12-04 Thread Wang Nan
This is v12 of optprobe related patch series. Most of this series are
comments and commit message fixes, except a minor modification in opt-arm.c
related on stack operations. Also, author of one patch is fixed.

Previous discussions can be found:

https://lkml.org/lkml/2014/12/4/4
https://lkml.org/lkml/2014/12/1/64
https://lkml.org/lkml/2014/11/22/18
https://lkml.org/lkml/2014/11/21/55
https://lkml.org/lkml/2014/11/18/26
https://lkml.org/lkml/2014/11/19/31
https://lkml.org/lkml/2014/11/18/41
https://lkml.org/lkml/2014/10/25/48
https://lkml.org/lkml/2014/10/22/254
https://lkml.org/lkml/2014/8/27/255
https://lkml.org/lkml/2014/8/12/12
https://lkml.org/lkml/2014/8/8/992
https://lkml.org/lkml/2014/8/8/5
https://lkml.org/lkml/2014/8/5/63


Jon Medhurst (1):
  ARM: kprobes: Add test cases for stack consuming instructions

Masami Hiramatsu (1):
  kprobes: Pass the original kprobe for preparing optimized kprobe

Wang Nan (5):
  ARM: probes: move all probe code to dedicate directory
  ARM: kprobes: introduces checker
  ARM: kprobes: collects stack consumption for store instructions
  ARM: kprobes: disallow probing stack consuming instructions
  ARM: kprobes: enable OPTPROBES for ARM 32

 arch/arm/Kconfig   |   1 +
 arch/arm/Makefile  |   1 +
 arch/arm/{kernel => include/asm}/insn.h|   0
 arch/arm/include/asm/kprobes.h |  30 +-
 arch/arm/{kernel => include/asm}/patch.h   |   0
 arch/arm/include/asm/probes.h  |  13 +
 arch/arm/kernel/Makefile   |  16 +-
 arch/arm/kernel/entry-armv.S   |   3 +-
 arch/arm/kernel/ftrace.c   |   3 +-
 arch/arm/kernel/jump_label.c   |   5 +-
 arch/arm/kernel/patch.c|   3 +-
 arch/arm/probes/Makefile   |   7 +
 .../{kernel/probes-arm.c => probes/decode-arm.c}   |  12 +-
 .../{kernel/probes-arm.h => probes/decode-arm.h}   |   7 +-
 .../probes-thumb.c => probes/decode-thumb.c}   |  16 +-
 .../probes-thumb.h => probes/decode-thumb.h}   |  10 +-
 arch/arm/{kernel/probes.c => probes/decode.c}  |  74 -
 arch/arm/{kernel/probes.h => probes/decode.h}  |  13 +-
 arch/arm/probes/kprobes/Makefile   |  12 +
 .../kprobes-arm.c => probes/kprobes/actions-arm.c} |   9 +-
 .../kprobes/actions-common.c}  |   4 +-
 .../kprobes/actions-thumb.c}   |  10 +-
 arch/arm/probes/kprobes/checkers-arm.c |  99 +++
 arch/arm/probes/kprobes/checkers-common.c  | 101 +++
 arch/arm/probes/kprobes/checkers-thumb.c   | 110 
 arch/arm/probes/kprobes/checkers.h |  54 
 .../{kernel/kprobes.c => probes/kprobes/core.c}|  23 +-
 .../{kernel/kprobes.h => probes/kprobes/core.h}|  10 +-
 arch/arm/probes/kprobes/opt-arm.c  | 313 +
 .../kprobes/test-arm.c}|  31 +-
 .../kprobes-test.c => probes/kprobes/test-core.c}  |   8 +-
 .../kprobes-test.h => probes/kprobes/test-core.h}  |   2 +-
 .../kprobes/test-thumb.c}  |  16 +-
 arch/arm/probes/uprobes/Makefile   |   2 +
 .../uprobes-arm.c => probes/uprobes/actions-arm.c} |   6 +-
 .../{kernel/uprobes.c => probes/uprobes/core.c}|   8 +-
 .../{kernel/uprobes.h => probes/uprobes/core.h}|   0
 arch/x86/kernel/kprobes/opt.c  |   3 +-
 include/linux/kprobes.h|   3 +-
 kernel/kprobes.c   |   4 +-
 40 files changed, 951 insertions(+), 91 deletions(-)
 rename arch/arm/{kernel => include/asm}/insn.h (100%)
 rename arch/arm/{kernel => include/asm}/patch.h (100%)
 create mode 100644 arch/arm/probes/Makefile
 rename arch/arm/{kernel/probes-arm.c => probes/decode-arm.c} (99%)
 rename arch/arm/{kernel/probes-arm.h => probes/decode-arm.h} (93%)
 rename arch/arm/{kernel/probes-thumb.c => probes/decode-thumb.c} (98%)
 rename arch/arm/{kernel/probes-thumb.h => probes/decode-thumb.h} (90%)
 rename arch/arm/{kernel/probes.c => probes/decode.c} (85%)
 rename arch/arm/{kernel/probes.h => probes/decode.h} (97%)
 create mode 100644 arch/arm/probes/kprobes/Makefile
 rename arch/arm/{kernel/kprobes-arm.c => probes/kprobes/actions-arm.c} (98%)
 rename arch/arm/{kernel/kprobes-common.c => probes/kprobes/actions-common.c} 
(98%)
 rename arch/arm/{kernel/kprobes-thumb.c => probes/kprobes/actions-thumb.c} 
(98%)
 create mode 100644 arch/arm/probes/kprobes/checkers-arm.c
 create mode 100644 arch/arm/probes/kprobes/checkers-common.c
 create mode 100644 arch/arm/probes/kprobes/checkers-thumb.c
 create mode 100644 arch/arm/probes/kprobes/checkers.h
 rename arch/arm/{kernel/kprobes.c => probes/kprobes/core.c} (96%)
 rename arch/arm/{kernel/kprobes.h => probes/kprobes/core.h} (83%)
 create mode 100644 arch/arm/probes/kprobes/opt-arm.c
 

[PATCH] staging: kernel: fixed style warnings in acct.c

2014-12-04 Thread Joshua I. James
From: "Joshua I. James" 

Fixed style errors identified by checkpatch.

Output of checkpatch:
WARNING: Missing a blank line after declarations
WARNING: line over 80 characters
ERROR: spaces required around that '==' (ctx:VxV)
+#if ACCT_VERSION==2

Signed-off-by: Joshua I. James 
---
 kernel/acct.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/kernel/acct.c b/kernel/acct.c
index 33738ef..322159c 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -105,6 +105,7 @@ static int check_free_space(struct bsd_acct_struct *acct)
 
if (acct->active) {
u64 suspend = sbuf.f_blocks * SUSPEND;
+
do_div(suspend, 100);
if (sbuf.f_bavail <= suspend) {
acct->active = 0;
@@ -112,6 +113,7 @@ static int check_free_space(struct bsd_acct_struct *acct)
}
} else {
u64 resume = sbuf.f_blocks * RESUME;
+
do_div(resume, 100);
if (sbuf.f_bavail >= resume) {
acct->active = 1;
@@ -152,8 +154,10 @@ again:
 
 static void close_work(struct work_struct *work)
 {
-   struct bsd_acct_struct *acct = container_of(work, struct 
bsd_acct_struct, work);
+   struct bsd_acct_struct *acct =
+   container_of(work, struct bsd_acct_struct, work);
struct file *file = acct->file;
+
if (file->f_op->flush)
file->f_op->flush(file, NULL);
__fput_sync(file);
@@ -165,6 +169,7 @@ static void acct_kill(struct bsd_acct_struct *acct,
 {
if (acct) {
struct pid_namespace *ns = acct->ns;
+
do_acct_process(acct);
INIT_WORK(>work, close_work);
init_completion(>done);
@@ -182,6 +187,7 @@ static void acct_kill(struct bsd_acct_struct *acct,
 static void acct_pin_kill(struct fs_pin *pin)
 {
struct bsd_acct_struct *acct;
+
acct = container_of(pin, struct bsd_acct_struct, pin);
mutex_lock(>lock);
if (!acct->ns) {
@@ -448,15 +454,17 @@ static void fill_ac(acct_t *ac)
 #endif
do_div(elapsed, AHZ);
ac->ac_btime = get_seconds() - elapsed;
-#if ACCT_VERSION==2
+#if ACCT_VERSION == 2
ac->ac_ahz = AHZ;
 #endif
 
spin_lock_irq(>sighand->siglock);
tty = current->signal->tty; /* Safe as we hold the siglock */
ac->ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0;
-   ac->ac_utime = 
encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime)));
-   ac->ac_stime = 
encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_stime)));
+   ac->ac_utime = encode_comp_t(jiffies_to_AHZ(
+   cputime_to_jiffies(pacct->ac_utime)));
+   ac->ac_stime = encode_comp_t(jiffies_to_AHZ(
+   cputime_to_jiffies(pacct->ac_stime)));
ac->ac_flag = pacct->ac_flag;
ac->ac_mem = encode_comp_t(pacct->ac_mem);
ac->ac_minflt = encode_comp_t(pacct->ac_minflt);
@@ -504,8 +512,8 @@ static void do_acct_process(struct bsd_acct_struct *acct)
 
ac.ac_pid = task_tgid_nr_ns(current, ns);
rcu_read_lock();
-   ac.ac_ppid = 
task_tgid_nr_ns(rcu_dereference(current->real_parent),
-ns);
+   ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(
+   current->real_parent), ns);
rcu_read_unlock();
}
 #endif
@@ -516,6 +524,7 @@ static void do_acct_process(struct bsd_acct_struct *acct)
if (file_start_write_trylock(file)) {
/* it's been opened O_APPEND, so position is irrelevant */
loff_t pos = 0;
+
__kernel_write(file, (char *), sizeof(acct_t), );
file_end_write(file);
}
@@ -573,6 +582,7 @@ static void slow_acct_process(struct pid_namespace *ns)
 {
for ( ; ns; ns = ns->parent) {
struct bsd_acct_struct *acct = acct_get(ns);
+
if (acct) {
do_acct_process(acct);
mutex_unlock(>lock);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the drm tree with Linus' tree

2014-12-04 Thread Stephen Rothwell
Hi Dave,

Today's linux-next merge of the drm tree got a conflict in
drivers/gpu/drm/radeon/radeon_cs.c between commit 86b276385c6a
("drm/radeon: sync all BOs involved in a CS v2") from Linus' tree and
commit 975700d2cc84 ("drm/radeon: split semaphore and sync object
handling v2") from the drm tree.

I fixed it up (I think - see below) and can carry the fix as necessary
(no action is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/gpu/drm/radeon/radeon_cs.c
index 6f377de099f9,75f22e5e999f..
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@@ -251,19 -251,22 +251,20 @@@ static int radeon_cs_get_ring(struct ra
  
  static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
  {
 -  int i, r = 0;
 +  struct radeon_cs_reloc *reloc;
 +  int r;
  
 -  for (i = 0; i < p->nrelocs; i++) {
 +  list_for_each_entry(reloc, >validated, tv.head) {
struct reservation_object *resv;
  
 -  if (!p->relocs[i].robj)
 -  continue;
 -
 -  resv = p->relocs[i].robj->tbo.resv;
 +  resv = reloc->robj->tbo.resv;
-   r = radeon_semaphore_sync_resv(p->rdev, p->ib.semaphore, resv,
-  reloc->tv.shared);
+   r = radeon_sync_resv(p->rdev, >ib.sync, resv,
 -   p->relocs[i].tv.shared);
++   reloc->tv.shared);
+ 
if (r)
 -  break;
 +  return r;
}
 -  return r;
 +  return 0;
  }
  
  /* XXX: note that this is called from the legacy UMS CS ioctl as well */


pgpilYgd9GqK3.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the drm tree with Linus' tree

2014-12-04 Thread Stephen Rothwell
Hi Dave,

Today's linux-next merge of the drm tree got a conflict in
drivers/gpu/drm/nouveau/nouveau_drm.c between commit 8b62c8c6df08
("nouveau: move the hotplug ignore to correct place") from Linus' tree
and commit 7bb6d4428d3d ("drm/nouveau: move the (far too many...)
different s/r paths to the same place") from the drm tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/gpu/drm/nouveau/nouveau_drm.c
index 62b97c4eef8d,afb93bb72f97..
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@@ -667,7 -647,30 +647,29 @@@ nouveau_do_resume(struct drm_device *de
return 0;
  }
  
- int nouveau_pmops_resume(struct device *dev)
+ int
+ nouveau_pmops_suspend(struct device *dev)
+ {
+   struct pci_dev *pdev = to_pci_dev(dev);
+   struct drm_device *drm_dev = pci_get_drvdata(pdev);
+   int ret;
+ 
+   if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
+   drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
+   return 0;
+ 
+   ret = nouveau_do_suspend(drm_dev, false);
+   if (ret)
+   return ret;
+ 
+   pci_save_state(pdev);
+   pci_disable_device(pdev);
 -  pci_ignore_hotplug(pdev);
+   pci_set_power_state(pdev, PCI_D3hot);
+   return 0;
+ }
+ 
+ int
+ nouveau_pmops_resume(struct device *dev)
  {
struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev);
@@@ -701,6 -706,105 +705,106 @@@ nouveau_pmops_thaw(struct device *dev
return nouveau_do_resume(drm_dev, false);
  }
  
+ static int
+ nouveau_pmops_runtime_suspend(struct device *dev)
+ {
+   struct pci_dev *pdev = to_pci_dev(dev);
+   struct drm_device *drm_dev = pci_get_drvdata(pdev);
+   int ret;
+ 
+   if (nouveau_runtime_pm == 0) {
+   pm_runtime_forbid(dev);
+   return -EBUSY;
+   }
+ 
+   /* are we optimus enabled? */
+   if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && 
!nouveau_is_v1_dsm()) {
+   DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
+   pm_runtime_forbid(dev);
+   return -EBUSY;
+   }
+ 
+   nv_debug_level(SILENT);
+   drm_kms_helper_poll_disable(drm_dev);
+   vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
+   nouveau_switcheroo_optimus_dsm();
+   ret = nouveau_do_suspend(drm_dev, true);
+   pci_save_state(pdev);
+   pci_disable_device(pdev);
++  pci_ignore_hotplug(pdev);
+   pci_set_power_state(pdev, PCI_D3cold);
+   drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
+   return ret;
+ }
+ 
+ static int
+ nouveau_pmops_runtime_resume(struct device *dev)
+ {
+   struct pci_dev *pdev = to_pci_dev(dev);
+   struct drm_device *drm_dev = pci_get_drvdata(pdev);
+   struct nvif_device *device = _drm(drm_dev)->device;
+   int ret;
+ 
+   if (nouveau_runtime_pm == 0)
+   return -EINVAL;
+ 
+   pci_set_power_state(pdev, PCI_D0);
+   pci_restore_state(pdev);
+   ret = pci_enable_device(pdev);
+   if (ret)
+   return ret;
+   pci_set_master(pdev);
+ 
+   ret = nouveau_do_resume(drm_dev, true);
+   drm_kms_helper_poll_enable(drm_dev);
+   /* do magic */
+   nvif_mask(device, 0x88488, (1 << 25), (1 << 25));
+   vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
+   drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
+   nv_debug_level(NORMAL);
+   return ret;
+ }
+ 
+ static int
+ nouveau_pmops_runtime_idle(struct device *dev)
+ {
+   struct pci_dev *pdev = to_pci_dev(dev);
+   struct drm_device *drm_dev = pci_get_drvdata(pdev);
+   struct nouveau_drm *drm = nouveau_drm(drm_dev);
+   struct drm_crtc *crtc;
+ 
+   if (nouveau_runtime_pm == 0) {
+   pm_runtime_forbid(dev);
+   return -EBUSY;
+   }
+ 
+   /* are we optimus enabled? */
+   if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && 
!nouveau_is_v1_dsm()) {
+   DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
+   pm_runtime_forbid(dev);
+   return -EBUSY;
+   }
+ 
+   /* if we have a hdmi audio device - make sure it has a driver loaded */
+   if (drm->hdmi_device) {
+   if (!drm->hdmi_device->driver) {
+   DRM_DEBUG_DRIVER("failing to power off - no HDMI audio 
driver loaded\n");
+   pm_runtime_mark_last_busy(dev);
+   return -EBUSY;
+   }
+   }
+ 
+   list_for_each_entry(crtc, >dev->mode_config.crtc_list, head) {
+   if (crtc->enabled) {
+   DRM_DEBUG_DRIVER("failing to power off - crtc 
active\n");
+   return -EBUSY;
+   }
+

[PATCH] misc: pass miscdevice through file's private_data

2014-12-04 Thread Tom Van Braeckel
Make the miscdevice accessible through the file's private_data.

Previously, this was done only when an open() operation had been registered.
But it's also useful in other file operations so we pass it on unconditionally.

All drivers that use private_data and misc_register() were checked to ensure
they register an open() operation in order to verify that this improvement
does not break any existing driver that uses the misc subsystem.

Signed-off-by: Tom Van Braeckel 
---
 drivers/char/misc.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index ffa97d2..d6445de 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -140,12 +140,17 @@ static int misc_open(struct inode * inode, struct file * 
file)
goto fail;
}
 
+   /*
+* Place the miscdevice in the file's
+* private_data so it can be used by the
+* file operations, including f_op->open below
+*/
+   file->private_data = c;
+
err = 0;
replace_fops(file, new_fops);
-   if (file->f_op->open) {
-   file->private_data = c;
+   if (file->f_op->open)
err = file->f_op->open(inode,file);
-   }
 fail:
mutex_unlock(_mtx);
return err;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: vt6655: Declare vnt_init() static

2014-12-04 Thread Sören Brinkmann
Fix sparse warning:
  drivers/staging/vt6655/device_main.c:1672:5: warning: symbol 'vnt_init' was 
not declared. Should it be static?

Signed-off-by: Sören Brinkmann 
---
 drivers/staging/vt6655/device_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index 83e4162c0094..a3f5cd84259a 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1669,7 +1669,7 @@ static const struct ieee80211_ops vnt_mac_ops = {
.reset_tsf  = vnt_reset_tsf,
 };
 
-int vnt_init(struct vnt_private *priv)
+static int vnt_init(struct vnt_private *priv)
 {
SET_IEEE80211_PERM_ADDR(priv->hw, priv->abyCurrentNetAddr);
 
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Re: [PATCH] optimize ktime_divns for constant divisors

2014-12-04 Thread Nicolas Pitre
On Fri, 5 Dec 2014, pang.xun...@zte.com.cn wrote:

> Nicolas,
> 
> On Thursday 04 December 2014 15:23:37: Nicolas Pitre wrote:
> > Nicolas Pitre  
> > 
> > u64 ktime_to_us(ktime_t kt)
> > {
> >u64 ns = ktime_to_ns(kt);
> >u32 x_lo, x_hi, y_lo, y_hi;
> >u64 res, carry;
> > 
> >x_hi = ns >> 32;
> >x_lo = ns;
> >y_hi = 0x83126e97;
> >y_lo = 0x8d4fdf3b;
> > 
> >res = (u64)x_lo * y_lo;
> >carry = (u64)(u32)res + y_lo;
> >res = (res >> 32) + (carry >> 32);
> > 
> >res += (u64)x_lo * y_hi;
> >carry = (u64)(u32)res + (u64)x_hi * y_lo;
> >res = (res >> 32) + (carry >> 32);
> > 
> >res += (u64)x_hi * y_hi;
> >return res >> 9;
> > }
> 
> What's the first carry operation for?

Hmmm... OK there is a bug.

The code should actually be:

res = (u64)x_lo * y_lo;
carry = (u64)(u32)res + y_lo;
res = (res >> 32) + (carry >> 32) + y_hi;

(the addition of y_hi was missing on the third line of the above block)

The equation is: res = (y + x*y) >> 9

> Moreover, I think the carry operations can be omitted, like below:
> u64 ktime_to_us(ktime_t kt)
> {
>  u64 ns = ktime_to_ns(kt);
>  u32 x_lo, x_hi, y_lo, y_hi;
>  u64 res;
> 
>  x_hi = ns >> 32;
>  x_lo = ns;
>  y_hi = 0x83126e97;
>  y_lo = 0x8d4fdf3b;
> 
>  res = (u64)x_lo * y_lo;
>  res = (res >> 32);

See above. y must be added to res before shifting, and that may cause an 
overflow.

>  res += (u64)x_lo * y_hi + (u64)x_hi * y_lo;

That, too, risk overflowing.

Let's say x_lo = 0x and x_hi = 0x.  You get:

0x * 0x83126e97 ->  0x83126e967ced9169
0x * 0x8d4fdf3b ->  0x8d4fdf3a72b020c5
   ---
   0x110624dd0ef9db22e

Therefore the sum doesn't fit into a u64 variable.

It is possible to skip carry handling but only when the MSB of both 
constants are zero.  Here it is not the case.

>  res = (res >> 32);
> 
>  res += (u64)x_hi * y_hi;
> 
>  return res >> 9;
> }
> 
> Also, I ran this code using ktime "1225", and it results as
> 12249 due to the y_lo deviation,

Please see bug fix above.

> maybe can use 0x8d4fdf3c instead?

No, that won't work with 0xfd97 for example.


Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/3] i2c: cadence: Handle > 252 byte transfers

2014-12-04 Thread Harini Katakam
Hi,

On Fri, Dec 5, 2014 at 12:02 AM, Wolfram Sang  wrote:
>
>> + /*
>> +  * If the device is sending data If there is further
>> +  * data to be sent. Calculate the available space
>> +  * in FIFO and fill the FIFO with that many bytes.
>> +  */
>
> This comment looks broken. In general, I think there should be more
> comments explaining why things have to be done this way.
>

There's some grammatical errors here. Let me correct it and add more
comments.

Regards,
Harini
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: ethernet: rocker: Add select to CONFIG_BRIDGE in Kconfig

2014-12-04 Thread David Miller
From: Andreas Ruprecht 
Date: Thu, 04 Dec 2014 18:36:37 +0100

> On 04.12.2014 17:34, Jim Davis wrote:
>> Building with the attached random configuration file,
>> 
>> drivers/built-in.o: In function `rocker_port_fdb_learn_work':
>> /home/jim/linux/drivers/net/ethernet/rocker/rocker.c:3014: undefined
>> reference to `br_fdb_external_learn_del'
>> /home/jim/linux/drivers/net/ethernet/rocker/rocker.c:3016: undefined
>> reference to `br_fdb_external_learn_add'
>> 
> 
> Hi,
> 
> the problem here is that CONFIG_BRIDGE is set to 'm' (leading to
> inclusion of the two functions above in the kernel module) while
> CONFIG_ROCKER is set to 'y', requiring the functions at link time.
> 
> Is the attached patch sufficient to fix this?

Do not use select, please.

You can only use select on leaf node Kconfig symbols, ie. those
which do not have any dependencies whatsoever.

Select does not recursively walk down the dependency chain turning
things on for you when you say "select X".
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 3/8] regulator: MT6397: Add support for MT6397 regulator

2014-12-04 Thread Flora Fu
Add MT6397 regulator driver.

Signed-off-by: Flora Fu 
---
 drivers/regulator/Kconfig  |   9 +
 drivers/regulator/Makefile |   1 +
 drivers/regulator/mt6397-regulator.c   | 332 +
 include/linux/regulator/mt6397-regulator.h |  49 +
 4 files changed, 391 insertions(+)
 create mode 100644 drivers/regulator/mt6397-regulator.c
 create mode 100644 include/linux/regulator/mt6397-regulator.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 55d7b7b..38a8d84 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -433,6 +433,15 @@ config REGULATOR_MC13892
  Say y here to support the regulators found on the Freescale MC13892
  PMIC.
 
+config REGULATOR_MT6397
+   tristate "MediaTek MT6397 PMIC"
+   depends on MFD_MT6397
+   help
+ Say y here to select this option to enable the power regulator of
+ MediaTek MT6397 PMIC.
+ This driver supports the control of different power rails of device
+ through regulator interface.
+
 config REGULATOR_PALMAS
tristate "TI Palmas PMIC Regulators"
depends on MFD_PALMAS
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 1029ed3..bad280e 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_REGULATOR_MAX77802) += max77802.o
 obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
 obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
 obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
+obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o
 obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o
 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
diff --git a/drivers/regulator/mt6397-regulator.c 
b/drivers/regulator/mt6397-regulator.c
new file mode 100644
index 000..a5b2f47
--- /dev/null
+++ b/drivers/regulator/mt6397-regulator.c
@@ -0,0 +1,332 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Flora Fu 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * MT6397 regulators' information
+ *
+ * @desc: standard fields of regulator description.
+ * @qi: Mask for query enable signal status of regulators
+ * @vselon_reg: Register sections for hardware control mode of bucks
+ * @vselctrl_reg: Register for controlling the buck control mode.
+ * @vselctrl_mask: Mask for query buck's voltage control mode.
+ */
+struct mt6397_regulator_info {
+   struct regulator_desc desc;
+   u32 qi;
+   u32 vselon_reg;
+   u32 vselctrl_reg;
+   u32 vselctrl_mask;
+};
+
+#define MT6397_BUCK(match, vreg, min, max, step, volt_ranges, enreg,   \
+   vosel, vosel_mask, voselon, vosel_ctrl) \
+[MT6397_ID_##vreg] = { \
+   .desc = {   \
+   .name = #vreg,  \
+   .of_match = of_match_ptr(match),\
+   .ops = _volt_range_ops,  \
+   .type = REGULATOR_VOLTAGE,  \
+   .id = MT6397_ID_##vreg, \
+   .owner = THIS_MODULE,   \
+   .n_voltages = (max - min)/step + 1, \
+   .linear_ranges = volt_ranges,   \
+   .n_linear_ranges = ARRAY_SIZE(volt_ranges), \
+   .vsel_reg = vosel,  \
+   .vsel_mask = vosel_mask,\
+   .enable_reg = enreg,\
+   .enable_mask = BIT(0),  \
+   },  \
+   .qi = BIT(13),  \
+   .vselon_reg = voselon,  \
+   .vselctrl_reg = vosel_ctrl, \
+   .vselctrl_mask = BIT(1),\
+}
+
+#define MT6397_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel,   \
+   vosel_mask) \
+[MT6397_ID_##vreg] = {

[PATCH v3 1/8] soc: mediatek: Add PMIC wrapper for MT8135 and MT6397 SoC

2014-12-04 Thread Flora Fu
Add PMIC wrapper of MT8135 to access MT6397 MFD.

Signed-off-by: Flora Fu 
---
 drivers/soc/Kconfig|   1 +
 drivers/soc/Makefile   |   1 +
 drivers/soc/mediatek/Kconfig   |  12 +
 drivers/soc/mediatek/Makefile  |   1 +
 drivers/soc/mediatek/mt8135-pmic-wrap.c| 844 +
 drivers/soc/mediatek/mt8135-pmic-wrap.h| 138 +
 include/linux/soc/mediatek/mtk-pmic-wrap.h |  25 +
 7 files changed, 1022 insertions(+)
 create mode 100644 drivers/soc/mediatek/Kconfig
 create mode 100644 drivers/soc/mediatek/Makefile
 create mode 100644 drivers/soc/mediatek/mt8135-pmic-wrap.c
 create mode 100644 drivers/soc/mediatek/mt8135-pmic-wrap.h
 create mode 100644 include/linux/soc/mediatek/mtk-pmic-wrap.h

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 76d6bd4..d8bde82 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,5 +1,6 @@
 menu "SOC (System On Chip) specific Drivers"
 
+source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/ti/Kconfig"
 source "drivers/soc/versatile/Kconfig"
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 063113d..70042b2 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -2,6 +2,7 @@
 # Makefile for the Linux Kernel SOC specific device drivers.
 #
 
+obj-$(CONFIG_ARCH_MEDIATEK)+= mediatek/
 obj-$(CONFIG_ARCH_QCOM)+= qcom/
 obj-$(CONFIG_ARCH_TEGRA)   += tegra/
 obj-$(CONFIG_SOC_TI)   += ti/
diff --git a/drivers/soc/mediatek/Kconfig b/drivers/soc/mediatek/Kconfig
new file mode 100644
index 000..746e030
--- /dev/null
+++ b/drivers/soc/mediatek/Kconfig
@@ -0,0 +1,12 @@
+#
+# MediaTek SoC drivers
+#
+config MT8135_PMIC_WRAP
+   tristate "MediaTek MT8135 PMIC Wrapper Support"
+   depends on ARCH_MEDIATEK
+   select REGMAP
+   help
+ Say yes here to add support for MediaTek MT8135 PMIC Wrapper.
+ PMIC wrapper is a proprietary hardware in MT8135 to make
+ communication protocols to access PMIC device.
+ This driver implement access protocols for MT8135.
diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
new file mode 100644
index 000..49b9588
--- /dev/null
+++ b/drivers/soc/mediatek/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_MT8135_PMIC_WRAP) += mt8135-pmic-wrap.o
diff --git a/drivers/soc/mediatek/mt8135-pmic-wrap.c 
b/drivers/soc/mediatek/mt8135-pmic-wrap.c
new file mode 100644
index 000..75aa28e
--- /dev/null
+++ b/drivers/soc/mediatek/mt8135-pmic-wrap.c
@@ -0,0 +1,844 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Flora Fu 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mt8135-pmic-wrap.h"
+
+/* macro for wrapper status */
+#define PWRAP_GET_WACS0_WDATA(x)   (((x) >> 0) & 0x)
+#define PWRAP_GET_WACS0_ADR(x) (((x) >> 16) & 0x7fff)
+#define PWRAP_GET_WACS0_WRITE(x)   (((x) >> 31) & 0x0001)
+#define PWRAP_GET_WACS0_RDATA(x)   (((x) >> 0) & 0x)
+#define PWRAP_GET_WACS0_FSM(x) (((x) >> 16) & 0x0007)
+#define PWRAP_STATE_SYNC_IDLE0 (1 << 20)
+#define PWRAP_STATE_INIT_DONE0 (1 << 21)
+
+/* macro for WACS FSM */
+#define PWRAP_WACS_FSM_IDLE0x00
+#define PWRAP_WACS_FSM_REQ 0x02
+#define PWRAP_WACS_FSM_WFDLE   0x04
+#define PWRAP_WACS_FSM_WFVLDCLR0x06
+#define PWRAP_WACS_INIT_DONE   0x01
+#define PWRAP_WACS_WACS_SYNC_IDLE  0x01
+
+/* macro for device wrapper default value */
+#define PWRAP_DEW_READ_TEST_VAL0x5aa5
+#define PWRAP_DEW_WRITE_TEST_VAL   0xa55a
+
+/* macro for manual command */
+#define PWRAP_OP_WR0x1
+#define PWRAP_OP_RD0x0
+#define PWRAP_OP_CSH   0x0
+#define PWRAP_OP_CSL   0x1
+#define PWRAP_OP_OUTS  0x8
+#define PWRAP_OP_OUTD  0x9
+#define PWRAP_OP_OUTQ  0xA
+
+static bool is_fsm_idle(u32 x)
+{
+   return PWRAP_GET_WACS0_FSM(x) == PWRAP_WACS_FSM_IDLE;
+}
+
+static bool is_fsm_vldclr(u32 x)
+{
+   return PWRAP_GET_WACS0_FSM(x) == PWRAP_WACS_FSM_WFVLDCLR;
+}
+
+static bool is_sync_idle(u32 x)
+{
+   return x & PWRAP_STATE_SYNC_IDLE0;
+}
+
+static bool is_fsm_idle_and_sync_idle(u32 x)
+{
+   return (PWRAP_GET_WACS0_FSM(x) == PWRAP_WACS_FSM_IDLE) &&
+(x & 

[PATCH v3 4/8] dt-bindings:: Add document for MT8135 PMIC Wrapper

2014-12-04 Thread Flora Fu

Signed-off-by: Flora Fu 
---
 .../soc/mediatek/mediatek,mt8135-pwrap.txt | 51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt

diff --git 
a/Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt 
b/Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt
new file mode 100644
index 000..d630fa0
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt
@@ -0,0 +1,51 @@
+MediaTek MT8135 PMIC Wrapper Driver
+
+MediaTek PMIC MFD is interfaced to host controller using SPI interface
+by a proprietary hardware called PMIC wrapper or pwrap.
+
++-+   +---+
+| |   |   |
+| Mediatek AP SoC |   |   |
+| (ex. MT8135)|   |MT6397 |
+| |   |   |
+|  ++ | (SPI bus) | ++|
+|  || |---| |||
+|  |  PMIC  | |---| |  PMIC  ||
+|  | Wrapper| |---| | Wrapper||
+|  || |---| |||
+|  ++ |   | ++|
+| |   |   |
++-+   +---+
+
+This document describes the binding for MT8135 PMIC wrapper.
+
+Required properties in pwrap device node.
+- compatible:"mediatek,mt8135-pwrap"
+- interrupts: IRQ for pwrap in SOC
+- reg: address range for pwrap registers
+- resets: reset bit for pwrap
+- clock: clock frequency selection in SPI bus
+
+Optional properities:
+- pmic: Mediatek PMIC MFD is the child device of pwrap
+  See the following for child node definitions:
+  Documentation/devicetree/bindings/mfd/mt6397.txt
+
+Example:
+   pwrap: pwrap@1000f000 {
+   compatible = "mediatek,mt8135-pwrap";
+   reg = <0 0x1000f000 0 0x1000>,
+   <0 0x11017000 0 0x1000>;
+   reg-names = "pwrap-base", "pwrap-bridge-base";
+   interrupts = ;
+   resets = < MT8135_INFRA_PMIC_WRAP_RST>,
+   < MT8135_PERI_PWRAP_BRIDGE_SW_RST>;
+   reset-names = "infra-pwrap-rst",
+   "peri-pwrap-bridge-rst";
+   clocks = <_sel>, <>;
+   clock-names = "pmicspi-sel", "pmicspi-parent";
+
+   pmic {
+   compatible = "mediatek,mt6397";
+   };
+   };
-- 
1.8.1.1.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >