Re: [PATCH 3/3] mailbox: Add support for ST's Mailbox IP

2015-03-18 Thread Jassi Brar
On Wed, Mar 18, 2015 at 9:04 PM, Lee Jones  wrote:
> On Wed, 18 Mar 2015, Jassi Brar wrote:
>
>> On Wed, Mar 18, 2015 at 6:47 PM, Lee Jones  wrote:
>> > On Tue, 03 Mar 2015, Jassi Brar wrote:
>> >
>> >> On 3 March 2015 at 17:04, Arnd Bergmann  wrote:
>> >> > On Tuesday 03 March 2015 10:41:23 Lee Jones wrote:
>> >> >> +
>> >> >> +/*
>> >> >> + * struct sti_mbox_msg - sti mailbox message description
>> >> >> + * @dsize: data payload size
>> >> >> + * @pdata: message data payload
>> >> >> + */
>> >> >> +struct sti_mbox_msg {
>> >> >> +   u32 dsize;
>> >> >> +   u8  *pdata;
>> >> >> +};
>> >> >
>> >> > As mentioned in another thread, we may just want to add a 'size'
>> >> > argument to the message send function, and a default helper for
>> >> > messages with size of 32 bits.
>> >> >
>> >> Case-a) 'size' is a member of the payload structure itself
>> >> The extra 'size' argument would only be used for sanity check.
>> >> This driver seems so. Lee, can you not do without 'dsize'?
>> >>
>> >> Case-b) 'size' is not a member of payload structure:
>> >>  b1)  payload is fixed length, that is 'size' := sizeof(struct 
>> >> my_payload)
>> >> Here the size argument is redundant.
>> >>
>> >>  b2)  payload length varies
>> >> This case is highly unlikely because there would be no way
>> >> for remote to know how many bytes to read as the payload. Not to mean
>> >> we can't do without the 'size' argument.
>> >>
>> >> Your opinion has huge weight, but I would like to be enlightened
>> >> before agreeing.
>> >
>> > Let's simplify this.
>> >
>> > If you want to have varying length payloads, you have to carry the
>> > size in the payload.  If you wish to force fixed size payloads, then
>> > you may do without a size segment.
>> >
>> > Do you really want to force all users of Mailbox to use fixed size
>> > payloads?
>> >
>> No. I only observed the fact that every known mailbox controller
>> driver already has a way to figure out the payload length because
>> either the protocol uses fixed length payloads or has the 'size' field
>> in every payload.
>> I am yet to see a platform that uses both, then the 'size' argument
>> will be helpful but still not necessary.
>
> I see.  So your real concern is that controllers shouldn't have two
> means of obtaining size.
>
I think right now there's not much need to expand the api for 'u32'
sized payloads.

> Arnd's idea of placing the message size as part of the send_message()
> call is fine, but it's still going to end up in the payload isn't it?
>
... or it will be implied by sizeof(struct my_packet) if the protocol
has finite set of payloads.

> And what about receiving?
>
Similar to sending - controller driver passes pointer to RX buffer
which the client parses. Remember the protocol would already have a
way to communicate payload length.
--
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 3/4] ptp/pch:Replace timespec with ktime_t in ptp_pch.c

2015-03-18 Thread Baolin Wang
This patch changes the 32-bit time type (timespec) to the 64-bit one
(ktime_t), since 32-bit time types will break in the year 2038.

This patch implements the getktime/setktime interfaces with
"ktime_t" type, and removed the gettime/settime interfaces with
"timespec" type in ptp_pch.c file.

Signed-off-by: Baolin Wang 
---
 drivers/ptp/ptp_pch.c |   21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/ptp/ptp_pch.c b/drivers/ptp/ptp_pch.c
index 2554872..c759225 100644
--- a/drivers/ptp/ptp_pch.c
+++ b/drivers/ptp/ptp_pch.c
@@ -449,36 +449,27 @@ static int ptp_pch_adjtime(struct ptp_clock_info *ptp, 
s64 delta)
return 0;
 }
 
-static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
+static int ptp_pch_getktime(struct ptp_clock_info *ptp, ktime_t *kt)
 {
-   u64 ns;
-   u32 remainder;
unsigned long flags;
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
struct pch_ts_regs __iomem *regs = pch_dev->regs;
 
spin_lock_irqsave(_dev->register_lock, flags);
-   ns = pch_systime_read(regs);
+   *kt = ns_to_ktime(pch_systime_read(regs));
spin_unlock_irqrestore(_dev->register_lock, flags);
 
-   ts->tv_sec = div_u64_rem(ns, 10, );
-   ts->tv_nsec = remainder;
return 0;
 }
 
-static int ptp_pch_settime(struct ptp_clock_info *ptp,
-  const struct timespec *ts)
+static int ptp_pch_setktime(struct ptp_clock_info *ptp, ktime_t kt)
 {
-   u64 ns;
unsigned long flags;
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
struct pch_ts_regs __iomem *regs = pch_dev->regs;
 
-   ns = ts->tv_sec * 10ULL;
-   ns += ts->tv_nsec;
-
spin_lock_irqsave(_dev->register_lock, flags);
-   pch_systime_write(regs, ns);
+   pch_systime_write(regs, ktime_to_ns(kt));
spin_unlock_irqrestore(_dev->register_lock, flags);
 
return 0;
@@ -518,8 +509,8 @@ static struct ptp_clock_info ptp_pch_caps = {
.pps= 0,
.adjfreq= ptp_pch_adjfreq,
.adjtime= ptp_pch_adjtime,
-   .gettime= ptp_pch_gettime,
-   .settime= ptp_pch_settime,
+   .getktime   = ptp_pch_getktime,
+   .setktime   = ptp_pch_setktime,
.enable = ptp_pch_enable,
 };
 
-- 
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 4/4] ptp/ixp46x:Replace timespec with ktime_t in ptp_ixp46x.c

2015-03-18 Thread Baolin Wang
This patch changes the 32-bit time type (timespec) to the 64-bit one
(ktime_t), since 32-bit time types will break in the year 2038.

This patch implements the getktime/setktime interfaces with
"ktime_t" type, and removes the gettime/settime interfaces with
"timespec" type in ptp_ixp46x.c file.

Signed-off-by: Baolin Wang 
---
 drivers/ptp/ptp_ixp46x.c |   21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/ptp/ptp_ixp46x.c b/drivers/ptp/ptp_ixp46x.c
index 604d340..102b673 100644
--- a/drivers/ptp/ptp_ixp46x.c
+++ b/drivers/ptp/ptp_ixp46x.c
@@ -175,39 +175,30 @@ static int ptp_ixp_adjtime(struct ptp_clock_info *ptp, 
s64 delta)
return 0;
 }
 
-static int ptp_ixp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
+static int ptp_ixp_getktime(struct ptp_clock_info *ptp, ktime_t *kt)
 {
-   u64 ns;
-   u32 remainder;
unsigned long flags;
struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps);
struct ixp46x_ts_regs *regs = ixp_clock->regs;
 
spin_lock_irqsave(_lock, flags);
 
-   ns = ixp_systime_read(regs);
+   *kt = ns_to_ktime(ixp_systime_read(regs));
 
spin_unlock_irqrestore(_lock, flags);
 
-   ts->tv_sec = div_u64_rem(ns, 10, );
-   ts->tv_nsec = remainder;
return 0;
 }
 
-static int ptp_ixp_settime(struct ptp_clock_info *ptp,
-  const struct timespec *ts)
+static int ptp_ixp_setktime(struct ptp_clock_info *ptp, ktime_t kt)
 {
-   u64 ns;
unsigned long flags;
struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps);
struct ixp46x_ts_regs *regs = ixp_clock->regs;
 
-   ns = ts->tv_sec * 10ULL;
-   ns += ts->tv_nsec;
-
spin_lock_irqsave(_lock, flags);
 
-   ixp_systime_write(regs, ns);
+   ixp_systime_write(regs, ktime_to_ns(kt));
 
spin_unlock_irqrestore(_lock, flags);
 
@@ -248,8 +239,8 @@ static struct ptp_clock_info ptp_ixp_caps = {
.pps= 0,
.adjfreq= ptp_ixp_adjfreq,
.adjtime= ptp_ixp_adjtime,
-   .gettime= ptp_ixp_gettime,
-   .settime= ptp_ixp_settime,
+   .getktime   = ptp_ixp_getktime,
+   .setktime   = ptp_ixp_setktime,
.enable = ptp_ixp_enable,
 };
 
-- 
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 2/4] ptp/clcok:Introduce the setktime/getktime interfaces with "ktime_t" type

2015-03-18 Thread Baolin Wang
This patch introduces another two options to get/set time with "ktime_t"
type in ptp clock operation.

Original code will set/get time through the settime/gettime interfaces
with "timespec" type, that will cause break issue in year 2038. And now
introducing the new setktime/getktime interfaces with "ktime_t" type to
use firstly.

Signed-off-by: Baolin Wang 
---
 drivers/ptp/ptp_clock.c |   20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 296b0ec..46425ad 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -106,14 +106,30 @@ static int ptp_clock_getres(struct posix_clock *pc, 
struct timespec *tp)
 
 static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
 {
+   ktime_t kt;
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   return ptp->info->settime(ptp->info, tp);
+
+   if (ptp->info->setktime) {
+   kt = timespec_to_ktime(*tp);
+   return ptp->info->setktime(ptp->info, kt);
+   } else {
+   return ptp->info->settime(ptp->info, tp);
+   }
 }
 
 static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)
 {
+   ktime_t kt;
+   int ret;
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   return ptp->info->gettime(ptp->info, tp);
+
+   if (ptp->info->getktime) {
+   ret = ptp->info->getktime(ptp->info, );
+   *tp = ktime_to_timespec(kt);
+   return ret;
+   } else {
+   return ptp->info->gettime(ptp->info, tp);
+   }
 }
 
 static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx)
-- 
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 1/4] ptp/chardev:Introduce another option to get/set time in ptp_clock_info structure

2015-03-18 Thread Baolin Wang
This patch introduces two options with "ktime_t" type to get/set time
in ptp_clock_info structure that will avoid breaking in the year 2038.

In ptp_chardev.c file, replace the gettime interface with getktime
interface using the "ktime_t" type to get the ptp clock time.

The patch's goal is to remove the original code using the "timespec" type,
and I expect to be done with that in the following merge window.

Signed-off-by: Baolin Wang 
---
 drivers/ptp/ptp_chardev.c|   27 ++-
 include/linux/ptp_clock_kernel.h |2 ++
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index f8a7609..4e14cc6 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -125,8 +125,10 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, 
unsigned long arg)
struct ptp_clock_info *ops = ptp->info;
struct ptp_clock_time *pct;
struct timespec ts;
+   struct timespec64 ts64;
int enable, err = 0;
unsigned int i, pin_index;
+   ktime_t kt;
 
switch (cmd) {
 
@@ -197,18 +199,25 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, 
unsigned long arg)
}
pct = >ts[0];
for (i = 0; i < sysoff->n_samples; i++) {
-   getnstimeofday();
-   pct->sec = ts.tv_sec;
-   pct->nsec = ts.tv_nsec;
+   ktime_get_real_ts64();
+   pct->sec = ts64.tv_sec;
+   pct->nsec = ts64.tv_nsec;
pct++;
-   ptp->info->gettime(ptp->info, );
-   pct->sec = ts.tv_sec;
-   pct->nsec = ts.tv_nsec;
+   if (ptp->info->getktime) {
+   ptp->info->getktime(ptp->info, );
+   ts64 = ktime_to_timespec64(kt);
+   pct->sec =  ts64.tv_sec;
+   pct->nsec = ts64.tv_nsec;
+   } else {
+   ptp->info->gettime(ptp->info, );
+   pct->sec = ts.tv_sec;
+   pct->nsec = ts.tv_nsec;
+   }
pct++;
}
-   getnstimeofday();
-   pct->sec = ts.tv_sec;
-   pct->nsec = ts.tv_nsec;
+   ktime_get_real_ts64();
+   pct->sec = ts64.tv_sec;
+   pct->nsec = ts64.tv_nsec;
if (copy_to_user((void __user *)arg, sysoff, sizeof(*sysoff)))
err = -EFAULT;
break;
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
index 0d8ff3f..86decc2 100644
--- a/include/linux/ptp_clock_kernel.h
+++ b/include/linux/ptp_clock_kernel.h
@@ -105,7 +105,9 @@ struct ptp_clock_info {
int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta);
int (*adjtime)(struct ptp_clock_info *ptp, s64 delta);
int (*gettime)(struct ptp_clock_info *ptp, struct timespec *ts);
+   int (*getktime)(struct ptp_clock_info *ptp, ktime_t *kt);
int (*settime)(struct ptp_clock_info *ptp, const struct timespec *ts);
+   int (*setktime)(struct ptp_clock_info *ptp, ktime_t kt);
int (*enable)(struct ptp_clock_info *ptp,
  struct ptp_clock_request *request, int on);
int (*verify)(struct ptp_clock_info *ptp, unsigned int pin,
-- 
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 0/4] Introduce another options to set/get time with "ktime_t" type

2015-03-18 Thread Baolin Wang
This patch series change the 32-bit time type (timespec) to the 64-bit one
(ktime_t), since 32-bit time types will break in the year 2038.

This patch series introduce another two optinos to set/get time with "ktime_t" 
type,
and remove the old ones with "timespec" type.

Next step will replace the other drivers' "timespec" type with "ktime_t" type.

Baolin Wang (4):
  ptp/chardev:Introduce another option to get/set time in
ptp_clock_info structure
  ptp/clcok:Introduce the setktime/getktime interfaces with "ktime_t"
type
  ptp/pch:Replace timespec with ktime_t in ptp_pch.c
  ptp/ixp46x:Replace timespec with ktime_t in ptp_ixp46x.c

 drivers/ptp/ptp_chardev.c|   27 ++-
 drivers/ptp/ptp_clock.c  |   20 ++--
 drivers/ptp/ptp_ixp46x.c |   21 ++---
 drivers/ptp/ptp_pch.c|   21 ++---
 include/linux/ptp_clock_kernel.h |2 ++
 5 files changed, 50 insertions(+), 41 deletions(-)

-- 
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] f2fs: enable fast symlink by utilizing inline data

2015-03-18 Thread Wanpeng Li
Fast symlink can utilize inline data flow to avoid using any 
i_addr region, since we need to handle many cases such as 
truncation, roll-forward recovery, and fsck/dump tools.

Signed-off-by: Wanpeng Li 
---
 fs/f2fs/inline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index d67bc0d..b7baad6 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -18,7 +18,7 @@ bool f2fs_may_inline(struct inode *inode)
if (f2fs_is_atomic_file(inode))
return false;
 
-   if (!S_ISREG(inode->i_mode))
+   if (!S_ISREG(inode->i_mode) && !S_ISLNK(inode->i_mode))
return false;
 
if (i_size_read(inode) > MAX_INLINE_DATA)
-- 
2.1.0

--
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 v9 01/10] iommu/vt-d: New function to attach domain with id

2015-03-18 Thread Li, Zhen-Hua
Allow specification of the domain-id for the new domain.
This patch only adds a new function iommu_attach_domain_with_id, it is like
the function iommu_attach_domain(), only adding a parameter "did".

Bill Sumner:
(In older versions) Add new 'did' parameter to iommu_attach_domain();
The caller of this function.

Li, Zhenhua:
New function iommu_attach_domain_with_id(), instead of updating funtion
iommu_attach_domain();

Signed-off-by: Bill Sumner 
Signed-off-by: Li, Zhen-Hua 
---
 drivers/iommu/intel-iommu.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index ae4c1a8..76674a1 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1558,6 +1558,16 @@ static int iommu_attach_domain(struct dmar_domain 
*domain,
return num;
 }
 
+static int iommu_attach_domain_with_id(struct dmar_domain *domain,
+  struct intel_iommu *iommu,
+  int domain_number)
+{
+   if (domain_number >= 0)
+   return domain_number;
+
+   return iommu_attach_domain(domain, iommu);
+}
+
 static int iommu_attach_vm_domain(struct dmar_domain *domain,
  struct intel_iommu *iommu)
 {
@@ -2225,6 +2235,7 @@ static struct dmar_domain *get_domain_for_dev(struct 
device *dev, int gaw)
u16 dma_alias;
unsigned long flags;
u8 bus, devfn;
+   int did = -1;   /* Default to "no domain_id supplied" */
 
domain = find_domain(dev);
if (domain)
@@ -2258,7 +2269,7 @@ static struct dmar_domain *get_domain_for_dev(struct 
device *dev, int gaw)
domain = alloc_domain(0);
if (!domain)
return NULL;
-   domain->id = iommu_attach_domain(domain, iommu);
+   domain->id = iommu_attach_domain_with_id(domain, iommu, did);
if (domain->id < 0) {
free_domain_mem(domain);
return NULL;
-- 
2.0.0-rc0

--
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 v9 02/10] iommu/vt-d: Items required for kdump

2015-03-18 Thread Li, Zhen-Hua
Add context entry functions needed for kdump.

Bill Sumner:
Original version;

Li, Zhenhua:
Changed the name of new functions, make them consistent with current
context get/set functions.
Remove the structure dve which is not used in new version.

Signed-off-by: Bill Sumner 
Signed-off-by: Li, Zhen-Hua 
---
 drivers/iommu/intel-iommu.c | 56 +
 1 file changed, 56 insertions(+)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 76674a1..577d5de 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -211,6 +212,12 @@ get_context_addr_from_root(struct root_entry *root)
NULL);
 }
 
+static inline unsigned long
+get_context_phys_from_root(struct root_entry *root)
+{
+   return  root_present(root) ? (root->val & VTD_PAGE_MASK) : 0;
+}
+
 /*
  * low 64 bits:
  * 0: present
@@ -231,6 +238,32 @@ static inline bool context_present(struct context_entry 
*context)
 {
return (context->lo & 1);
 }
+
+static inline int context_fault_enable(struct context_entry *c)
+{
+   return((c->lo >> 1) & 0x1);
+}
+
+static inline int context_translation_type(struct context_entry *c)
+{
+   return((c->lo >> 2) & 0x3);
+}
+
+static inline u64 context_address_root(struct context_entry *c)
+{
+   return((c->lo >> VTD_PAGE_SHIFT));
+}
+
+static inline int context_address_width(struct context_entry *c)
+{
+   return((c->hi >> 0) & 0x7);
+}
+
+static inline int context_domain_id(struct context_entry *c)
+{
+   return((c->hi >> 8) & 0x);
+}
+
 static inline void context_set_present(struct context_entry *context)
 {
context->lo |= 1;
@@ -316,6 +349,29 @@ static inline int first_pte_in_page(struct dma_pte *pte)
return !((unsigned long)pte & ~VTD_PAGE_MASK);
 }
 
+
+#ifdef CONFIG_CRASH_DUMP
+
+/*
+ * Fix Crashdump failure caused by leftover DMA through a hardware IOMMU
+ *
+ * Fixes the crashdump kernel to deal with an active iommu and legacy
+ * DMA from the (old) panicked kernel in a manner similar to how legacy
+ * DMA is handled when no hardware iommu was in use by the old kernel --
+ * allow the legacy DMA to continue into its current buffers.
+ *
+ * In the crashdump kernel, this code:
+ * 1. skips disabling the IOMMU's translating.
+ * 2. Do not re-enable IOMMU's translating.
+ * 3. In kdump kernel, use the old root entry table.
+ * 4. Allocate pages for new context entry, copy data from old context entries
+ *in the old kernel to the new ones.
+ *
+ */
+
+
+#endif /* CONFIG_CRASH_DUMP */
+
 /*
  * This domain is a statically identity mapping domain.
  * 1. This domain creats a static 1:1 mapping to all usable memory.
-- 
2.0.0-rc0

--
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 v9 04/10] iommu/vt-d: functions to copy data from old mem

2015-03-18 Thread Li, Zhen-Hua
Add some functions to copy the data from old kernel.
These functions are used to copy context tables and page tables.

To avoid calling iounmap between spin_lock_irqsave and spin_unlock_irqrestore,
use a link here, store the pointers , and then use iounmap to free them in
another place.

Li, Zhen-hua:
The functions and logics.

Takao Indoh:
Check if pfn is ram:
if (page_is_ram(pfn))

Signed-off-by: Li, Zhen-Hua 
Signed-off-by: Takao Indoh 
---
 drivers/iommu/intel-iommu.c | 102 
 include/linux/intel-iommu.h |   9 
 2 files changed, 111 insertions(+)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index f7dbe70..7f3484a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -374,6 +374,17 @@ static struct context_entry 
*device_to_existing_context_entry(
u8 bus, u8 devfn);
 
 
+/*
+ * A structure used to store the address allocated by ioremap();
+ * The we need to call iounmap() to free them out of spin_lock_irqsave/unlock;
+ */
+struct iommu_remapped_entry {
+   struct list_head list;
+   void __iomem *mem;
+};
+static LIST_HEAD(__iommu_remapped_mem);
+static DEFINE_MUTEX(__iommu_mem_list_lock);
+
 #endif /* CONFIG_CRASH_DUMP */
 
 /*
@@ -4822,4 +4833,95 @@ static struct context_entry 
*device_to_existing_context_entry(
return ret;
 }
 
+/*
+ * Copy memory from a physically-addressed area into a virtually-addressed area
+ */
+int __iommu_load_from_oldmem(void *to, unsigned long from, unsigned long size)
+{
+   unsigned long pfn;  /* Page Frame Number */
+   size_t csize = (size_t)size;/* Num(bytes to copy) */
+   unsigned long offset;   /* Lower 12 bits of to */
+   void __iomem *virt_mem;
+   struct iommu_remapped_entry *mapped;
+
+   pfn = from >> VTD_PAGE_SHIFT;
+   offset = from & (~VTD_PAGE_MASK);
+
+   if (page_is_ram(pfn)) {
+   memcpy(to, pfn_to_kaddr(pfn) + offset, csize);
+   } else{
+
+   mapped = kzalloc(sizeof(struct iommu_remapped_entry),
+   GFP_KERNEL);
+   if (!mapped)
+   return -ENOMEM;
+
+   virt_mem = ioremap_cache((unsigned long)from, size);
+   if (!virt_mem) {
+   kfree(mapped);
+   return -ENOMEM;
+   }
+   memcpy(to, virt_mem, size);
+
+   mutex_lock(&__iommu_mem_list_lock);
+   mapped->mem = virt_mem;
+   list_add_tail(>list, &__iommu_remapped_mem);
+   mutex_unlock(&__iommu_mem_list_lock);
+   }
+   return size;
+}
+
+/*
+ * Copy memory from a virtually-addressed area into a physically-addressed area
+ */
+int __iommu_save_to_oldmem(unsigned long to, void *from, unsigned long size)
+{
+   unsigned long pfn;  /* Page Frame Number */
+   size_t csize = (size_t)size;/* Num(bytes to copy) */
+   unsigned long offset;   /* Lower 12 bits of to */
+   void __iomem *virt_mem;
+   struct iommu_remapped_entry *mapped;
+
+   pfn = to >> VTD_PAGE_SHIFT;
+   offset = to & (~VTD_PAGE_MASK);
+
+   if (page_is_ram(pfn)) {
+   memcpy(pfn_to_kaddr(pfn) + offset, from, csize);
+   } else{
+   mapped = kzalloc(sizeof(struct iommu_remapped_entry),
+   GFP_KERNEL);
+   if (!mapped)
+   return -ENOMEM;
+
+   virt_mem = ioremap_cache((unsigned long)to, size);
+   if (!virt_mem) {
+   kfree(mapped);
+   return -ENOMEM;
+   }
+   memcpy(virt_mem, from, size);
+   mutex_lock(&__iommu_mem_list_lock);
+   mapped->mem = virt_mem;
+   list_add_tail(>list, &__iommu_remapped_mem);
+   mutex_unlock(&__iommu_mem_list_lock);
+   }
+   return size;
+}
+
+/*
+ * Free the mapped memory for ioremap;
+ */
+int __iommu_free_mapped_mem(void)
+{
+   struct iommu_remapped_entry *mem_entry, *tmp;
+
+   mutex_lock(&__iommu_mem_list_lock);
+   list_for_each_entry_safe(mem_entry, tmp, &__iommu_remapped_mem, list) {
+   iounmap(mem_entry->mem);
+   list_del(_entry->list);
+   kfree(mem_entry);
+   }
+   mutex_unlock(&__iommu_mem_list_lock);
+   return 0;
+}
+
 #endif /* CONFIG_CRASH_DUMP */
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index a65208a..8ffa523 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -368,4 +369,12 @@ extern int dmar_ir_support(void);
 
 extern const struct attribute_group *intel_iommu_groups[];
 
+#ifdef CONFIG_CRASH_DUMP
+extern int __iommu_load_from_oldmem(void *to, unsigned long 

[PATCH v9 03/10] iommu/vt-d: Function to get old context entry

2015-03-18 Thread Li, Zhen-Hua
Interface for when a new domain in the crashdump kernel needs some
values from the panicked kernel's context entries.

Signed-off-by: Li, Zhen-Hua 
---
 drivers/iommu/intel-iommu.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 577d5de..f7dbe70 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -369,6 +369,10 @@ static inline int first_pte_in_page(struct dma_pte *pte)
  *
  */
 
+static struct context_entry *device_to_existing_context_entry(
+   struct intel_iommu *iommu,
+   u8 bus, u8 devfn);
+
 
 #endif /* CONFIG_CRASH_DUMP */
 
@@ -4796,3 +4800,26 @@ static void __init check_tylersburg_isoch(void)
printk(KERN_WARNING "DMAR: Recommended TLB entries for ISOCH unit is 
16; your BIOS set %d\n",
   vtisochctrl);
 }
+
+#ifdef CONFIG_CRASH_DUMP
+
+static struct context_entry *device_to_existing_context_entry(
+   struct intel_iommu *iommu,
+   u8 bus, u8 devfn)
+{
+   struct root_entry *root;
+   struct context_entry *context;
+   struct context_entry *ret;
+   unsigned long flags;
+
+   ret = NULL;
+   spin_lock_irqsave(>lock, flags);
+   root = >root_entry[bus];
+   context = get_context_addr_from_root(root);
+   if (context && context_present(context+devfn))
+   ret = [devfn];
+   spin_unlock_irqrestore(>lock, flags);
+   return ret;
+}
+
+#endif /* CONFIG_CRASH_DUMP */
-- 
2.0.0-rc0

--
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 v9 05/10] iommu/vt-d: Add functions to load and save old re

2015-03-18 Thread Li, Zhen-Hua
Add functions to load root entry table from old kernel, and to save updated
root entry table.
Add two member in struct intel_iommu, to store the RTA in old kernel, and
the mapped virt address of it.

We use the old RTA in dump kernel, and when the iommu->root_entry is used as
a cache in kdump kernel, its phys address will not be save to RTA register,
but when its data is changed, we will save the new data to old root entry table.

Li, Zhen-hua:
The functions and logics.

Takao Indoh:
Add __iommu_flush_cache.

Signed-off-by: Li, Zhen-Hua 
Signed-off-by: Takao Indoh 
---
 drivers/iommu/intel-iommu.c | 52 +
 include/linux/intel-iommu.h |  5 +
 2 files changed, 57 insertions(+)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 7f3484a..1cb9780 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -373,6 +373,9 @@ static struct context_entry 
*device_to_existing_context_entry(
struct intel_iommu *iommu,
u8 bus, u8 devfn);
 
+static void __iommu_load_old_root_entry(struct intel_iommu *iommu);
+
+static void __iommu_update_old_root_entry(struct intel_iommu *iommu, int 
index);
 
 /*
  * A structure used to store the address allocated by ioremap();
@@ -4924,4 +4927,53 @@ int __iommu_free_mapped_mem(void)
return 0;
 }
 
+/*
+ * Load the old root entry table to new root entry table.
+ */
+static void __iommu_load_old_root_entry(struct intel_iommu *iommu)
+{
+   if ((!iommu)
+   || (!iommu->root_entry)
+   || (!iommu->root_entry_old_virt)
+   || (!iommu->root_entry_old_phys))
+   return;
+   memcpy(iommu->root_entry, iommu->root_entry_old_virt, PAGE_SIZE);
+
+   __iommu_flush_cache(iommu, iommu->root_entry, PAGE_SIZE);
+}
+
+/*
+ * When the data in new root entry table is changed, this function
+ * must be called to save the updated data to old root entry table.
+ */
+static void __iommu_update_old_root_entry(struct intel_iommu *iommu, int index)
+{
+   u8 start;
+   unsigned long size;
+   void __iomem *to;
+   void *from;
+
+   if ((!iommu)
+   || (!iommu->root_entry)
+   || (!iommu->root_entry_old_virt)
+   || (!iommu->root_entry_old_phys))
+   return;
+
+   if (index < -1 || index >= ROOT_ENTRY_NR)
+   return;
+
+   if (index == -1) {
+   start = 0;
+   size = ROOT_ENTRY_NR * sizeof(struct root_entry);
+   } else {
+   start = index * sizeof(struct root_entry);
+   size = sizeof(struct root_entry);
+   }
+   to = iommu->root_entry_old_virt;
+   from = iommu->root_entry;
+   memcpy(to + start, from + start, size);
+
+   __iommu_flush_cache(iommu, to + start, size);
+}
+
 #endif /* CONFIG_CRASH_DUMP */
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 8ffa523..8e29b97 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -329,6 +329,11 @@ struct intel_iommu {
spinlock_t  lock; /* protect context, domain ids */
struct root_entry *root_entry; /* virtual address */
 
+#ifdef CONFIG_CRASH_DUMP
+   void __iomem *root_entry_old_virt; /* mapped from old root entry */
+   unsigned long root_entry_old_phys; /* root entry in old kernel */
+#endif
+
struct iommu_flush flush;
 #endif
struct q_inval  *qi;/* Queued invalidation info */
-- 
2.0.0-rc0

--
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 v9 10/10] iommu/vt-d: Use old irte in kdump kernel

2015-03-18 Thread Li, Zhen-Hua
Fix the intr-remapping fault.

[1.594890] dmar: DRHD: handling fault status reg 2
[1.594894] dmar: INTR-REMAP: Request device [[41:00.0] fault index 4d
[1.594894] INTR-REMAP:[fault reason 34] Present field in the IRTE entry
is clear

Use old irte in kdump kernel, do not disable and re-enable interrupt
remapping.

Signed-off-by: Li, Zhen-Hua 
---
 drivers/iommu/intel_irq_remapping.c | 43 +++--
 1 file changed, 37 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/intel_irq_remapping.c 
b/drivers/iommu/intel_irq_remapping.c
index 20c060b..4e5a02d 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -199,6 +199,11 @@ static int modify_irte(int irq, struct irte *irte_modified)
 
set_64bit(>low, irte_modified->low);
set_64bit(>high, irte_modified->high);
+
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel())
+   __iommu_update_old_irte(iommu, index);
+#endif
__iommu_flush_cache(iommu, irte, sizeof(*irte));
 
rc = qi_flush_iec(iommu, index, 0);
@@ -260,6 +265,11 @@ static int clear_entries(struct irq_2_iommu *irq_iommu)
bitmap_release_region(iommu->ir_table->bitmap, index,
  irq_iommu->irte_mask);
 
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel())
+   __iommu_update_old_irte(iommu, -1);
+#endif
+
return qi_flush_iec(iommu, index, irq_iommu->irte_mask);
 }
 
@@ -662,11 +672,20 @@ static int __init intel_enable_irq_remapping(void)
 */
dmar_fault(-1, iommu);
 
-   /*
-* Disable intr remapping and queued invalidation, if already
-* enabled prior to OS handover.
-*/
-   iommu_disable_irq_remapping(iommu);
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel()) {
+   /* Do notdisable irq and then re-enable again. */
+   } else {
+#endif
+   /*
+* Disable intr remapping and queued invalidation,
+* if already enabled prior to OS handover.
+*/
+   iommu_disable_irq_remapping(iommu);
+
+#ifdef CONFIG_CRASH_DUMP
+   }
+#endif
 
dmar_disable_qi(iommu);
}
@@ -702,7 +721,19 @@ static int __init intel_enable_irq_remapping(void)
 * Setup Interrupt-remapping for all the DRHD's now.
 */
for_each_iommu(iommu, drhd) {
-   iommu_set_irq_remapping(iommu, eim);
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel()) {
+   unsigned long long q;
+
+   q = dmar_readq(iommu->reg + DMAR_IRTA_REG);
+   iommu->ir_table->base_old_phys = q & VTD_PAGE_MASK;
+   iommu->ir_table->base_old_virt = ioremap_cache(
+   iommu->ir_table->base_old_phys,
+   INTR_REMAP_TABLE_ENTRIES*sizeof(struct irte));
+   __iommu_load_old_irte(iommu);
+   } else
+#endif
+   iommu_set_irq_remapping(iommu, eim);
setup = 1;
}
 
-- 
2.0.0-rc0

--
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 v9 09/10] iommu/vt-d: Copy functions for irte

2015-03-18 Thread Li, Zhen-Hua
Functions to copy the irte data from the old kernel into the kdump kernel.

Signed-off-by: Li, Zhen-Hua 
---
 drivers/iommu/intel_irq_remapping.c | 62 +
 include/linux/intel-iommu.h |  4 +++
 2 files changed, 66 insertions(+)

diff --git a/drivers/iommu/intel_irq_remapping.c 
b/drivers/iommu/intel_irq_remapping.c
index 14de1ab..20c060b 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -17,6 +18,11 @@
 
 #include "irq_remapping.h"
 
+#ifdef CONFIG_CRASH_DUMP
+static int __iommu_load_old_irte(struct intel_iommu *iommu);
+static int __iommu_update_old_irte(struct intel_iommu *iommu, int index);
+#endif /* CONFIG_CRASH_DUMP */
+
 struct ioapic_scope {
struct intel_iommu *iommu;
unsigned int id;
@@ -1302,3 +1308,59 @@ int dmar_ir_hotplug(struct dmar_drhd_unit *dmaru, bool 
insert)
 
return ret;
 }
+
+#ifdef CONFIG_CRASH_DUMP
+
+static int __iommu_load_old_irte(struct intel_iommu *iommu)
+{
+   if ((!iommu)
+   || (!iommu->ir_table)
+   || (!iommu->ir_table->base)
+   || (!iommu->ir_table->base_old_phys)
+   || (!iommu->ir_table->base_old_virt))
+   return -1;
+
+   memcpy(iommu->ir_table->base,
+   iommu->ir_table->base_old_virt,
+   INTR_REMAP_TABLE_ENTRIES*sizeof(struct irte));
+
+   __iommu_flush_cache(iommu, iommu->ir_table->base,
+   INTR_REMAP_TABLE_ENTRIES*sizeof(struct irte));
+
+   return 0;
+}
+
+static int __iommu_update_old_irte(struct intel_iommu *iommu, int index)
+{
+   int start;
+   unsigned long size;
+   void __iomem *to;
+   void *from;
+
+   if ((!iommu)
+   || (!iommu->ir_table)
+   || (!iommu->ir_table->base)
+   || (!iommu->ir_table->base_old_phys)
+   || (!iommu->ir_table->base_old_virt))
+   return -1;
+
+   if (index < -1 || index >= INTR_REMAP_TABLE_ENTRIES)
+   return -1;
+
+   if (index == -1) {
+   start = 0;
+   size = INTR_REMAP_TABLE_ENTRIES * sizeof(struct irte);
+   } else {
+   start = index * sizeof(struct irte);
+   size = sizeof(struct irte);
+   }
+
+   to = iommu->ir_table->base_old_virt;
+   from = iommu->ir_table->base;
+   memcpy(to + start, from + start, size);
+
+   __iommu_flush_cache(iommu, to + start, size);
+
+   return 0;
+}
+#endif /* CONFIG_CRASH_DUMP */
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 8e29b97..76c6ea5 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -290,6 +290,10 @@ struct q_inval {
 struct ir_table {
struct irte *base;
unsigned long *bitmap;
+#ifdef CONFIG_CRASH_DUMP
+   void __iomem *base_old_virt;
+   unsigned long base_old_phys;
+#endif
 };
 #endif
 
-- 
2.0.0-rc0

--
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 v9 08/10] iommu/vt-d: assign new page table for dma_map

2015-03-18 Thread Li, Zhen-Hua
When a device driver issues the first dma_map command for a device, we
assign a new and empty page-table, thus removing all mappings from the
old kernel for the device.

Signed-off-by: Li, Zhen-Hua 
---
 drivers/iommu/intel-iommu.c | 54 ++---
 1 file changed, 46 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 312f06b..6b691d4 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "irq_remapping.h"
 
@@ -3121,14 +3122,30 @@ static struct dmar_domain 
*__get_valid_domain_for_dev(struct device *dev)
return NULL;
}
 
-   /* make sure context mapping is ok */
-   if (unlikely(!domain_context_mapped(dev))) {
-   ret = domain_context_mapping(domain, dev, 
CONTEXT_TT_MULTI_LEVEL);
-   if (ret) {
-   printk(KERN_ERR "Domain context map for %s failed",
-  dev_name(dev));
-   return NULL;
-   }
+   /* if in kdump kernel, we need to unmap the mapped dma pages,
+* detach this device first.
+*/
+   if (likely(domain_context_mapped(dev))) {
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel()) {
+   unmap_device_dma(domain, dev);
+   domain = get_domain_for_dev(dev,
+   DEFAULT_DOMAIN_ADDRESS_WIDTH);
+   if (!domain) {
+   pr_err("Allocating domain for %s failed",
+  dev_name(dev));
+   return NULL;
+   }
+   } else
+#endif
+   return domain;
+   }
+
+   ret = domain_context_mapping(domain, dev, CONTEXT_TT_MULTI_LEVEL);
+   if (ret) {
+   pr_err("Domain context map for %s failed",
+  dev_name(dev));
+   return NULL;
}
 
return domain;
@@ -5177,4 +5194,25 @@ static int intel_iommu_load_translation_tables(struct 
dmar_drhd_unit *drhd)
return ret;
 }
 
+static void unmap_device_dma(struct dmar_domain *domain, struct device *dev)
+{
+   struct intel_iommu *iommu;
+   struct context_entry *ce;
+   struct iova *iova;
+   u8 bus, devfn;
+   phys_addr_t phys_addr;
+   dma_addr_t dev_addr;
+
+   iommu = device_to_iommu(dev, , );
+   ce = device_to_context_entry(iommu, bus, devfn);
+   phys_addr = context_address_root(ce) << VTD_PAGE_SHIFT;
+   dev_addr = phys_to_dma(dev, phys_addr);
+
+   iova = find_iova(>iovad, IOVA_PFN(dev_addr));
+   if (iova)
+   intel_unmap(dev, dev_addr);
+
+   domain_remove_one_dev_info(domain, dev);
+}
+
 #endif /* CONFIG_CRASH_DUMP */
-- 
2.0.0-rc0

--
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 v9 06/10] iommu/vt-d: datatypes and functions used for kdump

2015-03-18 Thread Li, Zhen-Hua
Populate it with support functions to copy iommu translation tables from
from the panicked kernel into the kdump kernel in the event of a crash.

Functions:
Use old root entry table, and load the old data to root_entry as cache.
Malloc new context table and copy old context table to the new one.

Bill Sumner:
Original version, the creation of the data types and functions.

Li, Zhenhua:
Update the caller of context_get_* and context_put*, use context_*
and context_set_* for replacement.
Update the name of the function that loads root entry table.
Use new function to copy old context entry tables and page tables.
Use "unsigned long" for physical address.
Remove the functions to copy page table in Bill's version.
Remove usage of dve and ppap in Bill's version.

Signed-off-by: Bill Sumner 
Signed-off-by: Li, Zhen-Hua 
---
 drivers/iommu/intel-iommu.c | 113 
 1 file changed, 113 insertions(+)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 1cb9780..44f3369 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -388,6 +388,18 @@ struct iommu_remapped_entry {
 static LIST_HEAD(__iommu_remapped_mem);
 static DEFINE_MUTEX(__iommu_mem_list_lock);
 
+/* 
+ * Copy iommu translation tables from old kernel into new  kernel.
+ * Entry to this set of functions is: intel_iommu_load_translation_tables()
+ * 
+ */
+
+static int copy_root_entry_table(struct intel_iommu *iommu);
+
+static int intel_iommu_load_translation_tables(struct dmar_drhd_unit *drhd);
+
+static void unmap_device_dma(struct dmar_domain *domain, struct device *dev);
+
 #endif /* CONFIG_CRASH_DUMP */
 
 /*
@@ -4976,4 +4988,105 @@ static void __iommu_update_old_root_entry(struct 
intel_iommu *iommu, int index)
__iommu_flush_cache(iommu, to + start, size);
 }
 
+/*
+ * Load root entry tables from old kernel.
+ */
+static int copy_root_entry_table(struct intel_iommu *iommu)
+{
+   u32 bus;/* Index: root-entry-table */
+   struct root_entry  *re; /* Virt(iterator: new table) */
+   unsigned long context_old_phys; /* Phys(context table entry) */
+   struct context_entry *context_new_virt; /* Virt(new context_entry) */
+
+   /*
+* A new root entry table has been allocated ,
+* we need copy re from old kernel to the new allocated one.
+*/
+
+   if (!iommu->root_entry_old_phys)
+   return -ENOMEM;
+
+   for (bus = 0, re = iommu->root_entry; bus < 256; bus += 1, re += 1) {
+   if (!root_present(re))
+   continue;
+
+   context_old_phys = get_context_phys_from_root(re);
+
+   if (!context_old_phys)
+   continue;
+
+   context_new_virt =
+   (struct context_entry *)alloc_pgtable_page(iommu->node);
+
+   if (!context_new_virt)
+   return -ENOMEM;
+
+   __iommu_load_from_oldmem(context_new_virt,
+   context_old_phys,
+   VTD_PAGE_SIZE);
+
+   __iommu_flush_cache(iommu, context_new_virt, VTD_PAGE_SIZE);
+
+   set_root_value(re, virt_to_phys(context_new_virt));
+   }
+
+   return 0;
+}
+
+/*
+ * Interface to the "load translation tables" set of functions
+ * from mainline code.
+ */
+static int intel_iommu_load_translation_tables(struct dmar_drhd_unit *drhd)
+{
+   struct intel_iommu *iommu;  /* Virt(iommu hardware registers) */
+   unsigned long long q;   /* quadword scratch */
+   int ret = 0;/* Integer return code */
+   unsigned long flags;
+
+   iommu = drhd->iommu;
+   q = dmar_readq(iommu->reg + DMAR_RTADDR_REG);
+   if (!q)
+   return -1;
+
+   spin_lock_irqsave(>lock, flags);
+
+   /* Load the root-entry table from the old kernel
+* foreach context_entry_table in root_entry
+*   Copy each entry table from old kernel
+*/
+   if (!iommu->root_entry) {
+   iommu->root_entry =
+   (struct root_entry *)alloc_pgtable_page(iommu->node);
+   if (!iommu->root_entry) {
+   spin_unlock_irqrestore(>lock, flags);
+   return -ENOMEM;
+   }
+   }
+
+   iommu->root_entry_old_phys = q & VTD_PAGE_MASK;
+   if (!iommu->root_entry_old_phys) {
+   pr_err("Could not read old root entry address.");
+   return -1;
+   }
+
+   iommu->root_entry_old_virt = ioremap_cache(iommu->root_entry_old_phys,
+   VTD_PAGE_SIZE);
+   if 

[PATCH v9 07/10] iommu/vt-d: enable kdump support in iommu module

2015-03-18 Thread Li, Zhen-Hua
Modify the operation of the following functions when called during crash dump:
device_to_context_entry
free_context_table
get_domain_for_dev
init_dmars
intel_iommu_init

Bill Sumner:
Original version.

Zhenhua:
The name of new calling functions.
Do not disable and re-enable TE in kdump kernel.
Use the did and gaw from old context entry;

Signed-off-by: Bill Sumner 
Signed-off-by: Li, Zhen-Hua 
---
 drivers/iommu/intel-iommu.c | 118 ++--
 1 file changed, 103 insertions(+), 15 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 44f3369..312f06b 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -841,6 +841,11 @@ static struct context_entry * 
device_to_context_entry(struct intel_iommu *iommu,
set_root_value(root, phy_addr);
set_root_present(root);
__iommu_flush_cache(iommu, root, sizeof(*root));
+
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel())
+   __iommu_update_old_root_entry(iommu, bus);
+#endif
}
spin_unlock_irqrestore(>lock, flags);
return [devfn];
@@ -892,7 +897,8 @@ static void free_context_table(struct intel_iommu *iommu)
 
spin_lock_irqsave(>lock, flags);
if (!iommu->root_entry) {
-   goto out;
+   spin_unlock_irqrestore(>lock, flags);
+   return;
}
for (i = 0; i < ROOT_ENTRY_NR; i++) {
root = >root_entry[i];
@@ -900,10 +906,23 @@ static void free_context_table(struct intel_iommu *iommu)
if (context)
free_pgtable_page(context);
}
+
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel()) {
+   iommu->root_entry_old_phys = 0;
+   root = iommu->root_entry_old_virt;
+   iommu->root_entry_old_virt = NULL;
+   }
+#endif
free_pgtable_page(iommu->root_entry);
iommu->root_entry = NULL;
-out:
+
spin_unlock_irqrestore(>lock, flags);
+
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel())
+   iounmap(root);
+#endif
 }
 
 static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
@@ -2322,6 +2341,9 @@ static struct dmar_domain *get_domain_for_dev(struct 
device *dev, int gaw)
unsigned long flags;
u8 bus, devfn;
int did = -1;   /* Default to "no domain_id supplied" */
+#ifdef CONFIG_CRASH_DUMP
+   struct context_entry *ce = NULL;
+#endif /* CONFIG_CRASH_DUMP */
 
domain = find_domain(dev);
if (domain)
@@ -2355,6 +2377,22 @@ static struct dmar_domain *get_domain_for_dev(struct 
device *dev, int gaw)
domain = alloc_domain(0);
if (!domain)
return NULL;
+
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel()) {
+   /*
+* if this device had a did in the old kernel
+* use its values instead of generating new ones
+*/
+   ce = device_to_existing_context_entry(iommu, bus, devfn);
+
+   if (ce) {
+   did = context_domain_id(ce);
+   gaw = agaw_to_width(context_address_width(ce));
+   }
+   }
+#endif /* CONFIG_CRASH_DUMP */
+
domain->id = iommu_attach_domain_with_id(domain, iommu, did);
if (domain->id < 0) {
free_domain_mem(domain);
@@ -2889,14 +2927,33 @@ static int __init init_dmars(void)
if (ret)
goto free_iommu;
 
-   /*
-* TBD:
-* we could share the same root & context tables
-* among all IOMMU's. Need to Split it later.
-*/
-   ret = iommu_alloc_root_entry(iommu);
-   if (ret)
-   goto free_iommu;
+#ifdef CONFIG_CRASH_DUMP
+   if (is_kdump_kernel()) {
+   pr_info("IOMMU Copying translate tables from panicked 
kernel\n");
+   ret = intel_iommu_load_translation_tables(drhd);
+   if (ret) {
+   pr_err("IOMMU: Copy translate tables failed\n");
+
+   /* Best to stop trying */
+   goto free_iommu;
+   }
+   pr_info("IOMMU: root_cache:0x%12.12llx 
phys:0x%12.12llx\n",
+   (u64)iommu->root_entry,
+   (u64)iommu->root_entry_old_phys);
+   } else {
+#endif /* CONFIG_CRASH_DUMP */
+   /*
+* TBD:
+* we could share the same root & context tables
+* among all IOMMU's. Need to Split it later.
+*/
+   ret = iommu_alloc_root_entry(iommu);
+   if (ret)
+  

[PATCH v9 0/10] iommu/vt-d: Fix intel vt-d faults in kdump kernel

2015-03-18 Thread Li, Zhen-Hua
This patchset is an update of Bill Sumner's patchset, implements a fix for:
If a kernel boots with intel_iommu=on on a system that supports intel vt-d, 
when a panic happens, the kdump kernel will boot with these faults:

dmar: DRHD: handling fault status reg 102
dmar: DMAR:[DMA Read] Request device [01:00.0] fault addr fff8
DMAR:[fault reason 01] Present bit in root entry is clear

dmar: DRHD: handling fault status reg 2
dmar: INTR-REMAP: Request device [[61:00.0] fault index 42
INTR-REMAP:[fault reason 34] Present field in the IRTE entry is clear

On some system, the interrupt remapping fault will also happen even if the 
intel_iommu is not set to on, because the interrupt remapping will be enabled 
when x2apic is needed by the system.

The cause of the DMA fault is described in Bill's original version, and the 
INTR-Remap fault is caused by a similar reason. In short, the initialization 
of vt-d drivers causes the in-flight DMA and interrupt requests get wrong 
response.

To fix this problem, we modifies the behaviors of the intel vt-d in the 
crashdump kernel:

For DMA Remapping:
1. To accept the vt-d hardware in an active state,
2. Do not disable and re-enable the translation, keep it enabled.
3. Use the old root entry table, do not rewrite the RTA register.
4. Malloc and use new context entry table, copy data from the old ones that
   used by the old kernel.
5. Keep using the old page tables before driver is loaded.
6. After device driver is loaded, when it issues the first dma_map command, 
   free the dmar_domain structure for this device, and generate a new one, so 
   that the device can be assigned a new and empty page table. 
7. When a new context entry table is generated, we also save its address to 
   the old root entry table.

For Interrupt Remapping:
1. To accept the vt-d hardware in an active state,
2. Do not disable and re-enable the interrupt remapping, keep it enabled.
3. Use the old interrupt remapping table, do not rewrite the IRTA register.
4. When ioapic entry is setup, the interrupt remapping table is changed, and 
   the updated data will be stored to the old interrupt remapping table.

Advantages of this approach:
1. All manipulation of the IO-device is done by the Linux device-driver
   for that device.
2. This approach behaves in a manner very similar to operation without an
   active iommu.
3. Any activity between the IO-device and its RMRR areas is handled by the
   device-driver in the same manner as during a non-kdump boot.
4. If an IO-device has no driver in the kdump kernel, it is simply left alone.
   This supports the practice of creating a special kdump kernel without
   drivers for any devices that are not required for taking a crashdump. 
5. Minimal code-changes among the existing mainline intel vt-d code.

Summary of changes in this patch set:
1. Added some useful function for root entry table in code intel-iommu.c
2. Added new members to struct root_entry and struct irte;
3. Functions to load old root entry table to iommu->root_entry from the memory 
   of old kernel.
4. Functions to malloc new context entry table and copy the data from the old
   ones to the malloced new ones.
5. Functions to enable support for DMA remapping in kdump kernel.
6. Functions to load old irte data from the old kernel to the kdump kernel.
7. Some code changes that support other behaviours that have been listed.
8. In the new functions, use physical address as "unsigned long" type, not 
   pointers.

Original version by Bill Sumner:
https://lkml.org/lkml/2014/1/10/518
https://lkml.org/lkml/2014/4/15/716
https://lkml.org/lkml/2014/4/24/836

Zhenhua's updates:
https://lkml.org/lkml/2014/10/21/134
https://lkml.org/lkml/2014/12/15/121
https://lkml.org/lkml/2014/12/22/53
https://lkml.org/lkml/2015/1/6/1166
https://lkml.org/lkml/2015/1/12/35

Changelog[v9]:
1. Add new function iommu_attach_domain_with_id.
2. Do not copy old page tables, keep using the old ones.
3. Remove functions:
   intel_iommu_did_to_domain_values_entry
   intel_iommu_get_dids_from_old_kernel
   device_to_domain_id
   copy_page_addr
   copy_page_table
   copy_context_entry
   copy_context_entry_table
4. Add new function device_to_existing_context_entry.

Changelog[v8]:
1. Add a missing __iommu_flush_cache in function copy_page_table.

Changelog[v7]:
1. Use __iommu_flush_cache to flush the data to hardware.

Changelog[v6]:
1. Use "unsigned long" as type of physical address.
2. Use new function unmap_device_dma to unmap the old dma.
3. Some small incorrect bits order for aw shift.

Changelog[v5]:
1. Do not disable and re-enable traslation and interrupt remapping. 
2. Use old root entry table.
3. Use old interrupt remapping table.
4. New functions to copy data from old kernel, and save to old kernel mem.
5. New functions to save updated root entry table 

[PATCH] [RFC] mm/compaction: initialize compaction information

2015-03-18 Thread Gioh Kim
I tried to start compaction via /proc/sys/vm/compact_memory
as soon as I turned on my ARM-based platform.
But the compaction didn't start.
I found some variables in struct zone are not initalized.

I think zone->compact_cached_free_pfn and some cache values for compaction
are initalized when the kernel starts compaction, not via
/proc/sys/vm/compact_memory.
If my guess is correct, an initialization are needed for that case.


Signed-off-by: Gioh Kim 
---
 mm/compaction.c |8 
 1 file changed, 8 insertions(+)

diff --git a/mm/compaction.c b/mm/compaction.c
index 8c0d945..944a9cc 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1299,6 +1299,14 @@ static int compact_zone(struct zone *zone, struct 
compact_control *cc)
__reset_isolation_suitable(zone);
 
/*
+* If this is activated by /proc/sys/vm/compact_memory
+* and the first try, cached information for compaction is not
+* initialized.
+*/
+   if (cc->order == -1 && zone->compact_cached_free_pfn == 0)
+   __reset_isolation_suitable(zone);
+
+   /*
 * Setup to move all movable pages to the end of the zone. Used cached
 * information on where the scanners should start but check that it
 * is initialised by ensuring the values are within zone boundaries.
-- 
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] f2fs: enable inline data by default

2015-03-18 Thread Wanpeng Li
Enable inline_data feature by default since it brings us better 
performance and space utilization and now has already stable.

Signed-off-by: Wanpeng Li 
---
 Documentation/filesystems/f2fs.txt |  2 --
 fs/f2fs/f2fs.h | 11 +--
 fs/f2fs/inline.c   |  3 ---
 fs/f2fs/super.c|  7 ---
 4 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/Documentation/filesystems/f2fs.txt 
b/Documentation/filesystems/f2fs.txt
index 48e2123..6c9c947 100644
--- a/Documentation/filesystems/f2fs.txt
+++ b/Documentation/filesystems/f2fs.txt
@@ -122,8 +122,6 @@ active_logs=%u Support configuring the number of 
active logs. In the
 disable_ext_identify   Disable the extension list configured by mkfs, so f2fs
does not aware of cold files such as media files.
 inline_xattr   Enable the inline xattrs feature.
-inline_dataEnable the inline data feature: New created 
small(<~3.4k)
-   files can be written into inode block.
 inline_dentry  Enable the inline dir feature: data in new created
directory entries can be written into inode block. The
space of inode block which is used to store inline
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f2909c6..5849520 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -45,12 +45,11 @@
 #define F2FS_MOUNT_POSIX_ACL   0x0020
 #define F2FS_MOUNT_DISABLE_EXT_IDENTIFY0x0040
 #define F2FS_MOUNT_INLINE_XATTR0x0080
-#define F2FS_MOUNT_INLINE_DATA 0x0100
-#define F2FS_MOUNT_INLINE_DENTRY   0x0200
-#define F2FS_MOUNT_FLUSH_MERGE 0x0400
-#define F2FS_MOUNT_NOBARRIER   0x0800
-#define F2FS_MOUNT_FASTBOOT0x1000
-#define F2FS_MOUNT_EXTENT_CACHE0x2000
+#define F2FS_MOUNT_INLINE_DENTRY   0x0100
+#define F2FS_MOUNT_FLUSH_MERGE 0x0200
+#define F2FS_MOUNT_NOBARRIER   0x0400
+#define F2FS_MOUNT_FASTBOOT0x0800
+#define F2FS_MOUNT_EXTENT_CACHE0x1000
 
 #define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option)
 #define set_opt(sbi, option)   (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index d3e0599..d67bc0d 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -15,9 +15,6 @@
 
 bool f2fs_may_inline(struct inode *inode)
 {
-   if (!test_opt(F2FS_I_SB(inode), INLINE_DATA))
-   return false;
-
if (f2fs_is_atomic_file(inode))
return false;
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index fc6857f..f008222 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -52,7 +52,6 @@ enum {
Opt_active_logs,
Opt_disable_ext_identify,
Opt_inline_xattr,
-   Opt_inline_data,
Opt_inline_dentry,
Opt_flush_merge,
Opt_nobarrier,
@@ -74,7 +73,6 @@ static match_table_t f2fs_tokens = {
{Opt_active_logs, "active_logs=%u"},
{Opt_disable_ext_identify, "disable_ext_identify"},
{Opt_inline_xattr, "inline_xattr"},
-   {Opt_inline_data, "inline_data"},
{Opt_inline_dentry, "inline_dentry"},
{Opt_flush_merge, "flush_merge"},
{Opt_nobarrier, "nobarrier"},
@@ -354,9 +352,6 @@ static int parse_options(struct super_block *sb, char 
*options)
case Opt_disable_ext_identify:
set_opt(sbi, DISABLE_EXT_IDENTIFY);
break;
-   case Opt_inline_data:
-   set_opt(sbi, INLINE_DATA);
-   break;
case Opt_inline_dentry:
set_opt(sbi, INLINE_DENTRY);
break;
@@ -594,8 +589,6 @@ static int f2fs_show_options(struct seq_file *seq, struct 
dentry *root)
 #endif
if (test_opt(sbi, DISABLE_EXT_IDENTIFY))
seq_puts(seq, ",disable_ext_identify");
-   if (test_opt(sbi, INLINE_DATA))
-   seq_puts(seq, ",inline_data");
if (test_opt(sbi, INLINE_DENTRY))
seq_puts(seq, ",inline_dentry");
if (!f2fs_readonly(sbi->sb) && test_opt(sbi, FLUSH_MERGE))
-- 
2.1.0

--
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: Linux Kernel Scheduling Addition Notification : Hybrid Sleepers and Unfair scheduling

2015-03-18 Thread Mike Galbraith
On Wed, 2015-03-18 at 21:32 -0700, Mitchell Erblich wrote:

(again, not one on topic word)

>   How rude is that?

Shrug, s/rude/dense maybe.  Whatever.  Byebye.

-Mike

--
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 6/8] rbtree: Implement generic latch_tree

2015-03-18 Thread Andrew Morton
On Wed, 18 Mar 2015 14:36:32 +0100 Peter Zijlstra  wrote:

>  include/linux/rbtree_latch.h |  223 
> +++

Did it really need to all be inlined?

How much of this code is unneeded on uniprocessor?
--
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 3/3] mailbox: Add support for ST's Mailbox IP

2015-03-18 Thread Jassi Brar
On Wed, Mar 18, 2015 at 8:56 PM, Lee Jones  wrote:
> On Wed, 18 Mar 2015, Jassi Brar wrote:

>> >> > +   mbox->irq = 
>> >> > irq_create_mapping(mbinst->irq_domain,
>> >> > +  mbox->rx_id);
>> >> >
>> >> simply assigning same IRQ to all controller DT nodes and using
>> >> IRQF_SHARED for the common handler, wouldn't work?
>> >
>> > I do have intentions to simplify this driver somewhat, but that will
>> > take some time as it will require a great deal of consultation and
>> > testing from the ST side.  This is the current internal implementation
>> > which is used in the wild and has been fully tested.  If you'll allow
>> > me to conduct my adaptions subsequently we can have full history and a
>> > possible reversion plan if anything untoward take place i.e. I mess
>> > something up.
>> >
>> OK, but wouldn't that break the bindings of this driver when you
>> eventually do that?
>
> That's going to happen regardless, since these bindings are already in
> use internally.  Mainline (i.e. v4.0+) isn't going to be used in
> products for years to come, so we have a lot of time until any new
> bindings become ABI.
>
I thought time starts from upstream. It doesn't seem right to
knowingly introduce a binding that we are going to break in coming
weeks. For this reason, it needs ACK from some DT maintainer.


>> >> > + * struct sti_mbox_msg - sti mailbox message description
>> >> > + * @dsize: data payload size
>> >> > + * @pdata: message data payload
>> >> > + */
>> >> > +struct sti_mbox_msg {
>> >> > +   u32 dsize;
>> >> > +   u8  *pdata;
>> >> > +};
>> >> >
>> >> There isn't any client driver in this patchset to tell exactly, but it
>> >> seems the header could be split into one shared between mailbox
>> >> clients and provider and another internal to client/provider ?
>> >
>> > I believe only the above will be required by the client.  Seems silly
>> > to create a client specific header just for that, don't you think?
>> >
>> Do you mean to have copies of the structure in controller and client driver? 
>> :O
>
> I do not.  I planned on sharing the main header with with client
> also.
>
> But I guess by your reaction you suggest having a teeny client header
> as the best way forward then.
>
Yes, please. And also no header that's included by exactly one file.
--
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/4] ARM: EXYNOS: cpuidle: add AFTR mode support for Exynos3250

2015-03-18 Thread Chanwoo Choi
Hi Bartlomiej,

I tested this patch-set for AFTR mode.
When CPU1 is offline state, I checked that CPU0 enter the AFTR mode.

Tested-by: Chanwoo Choi 

Best Regards,
Chanwoo Choi

On 03/19/2015 01:00 AM, Bartlomiej Zolnierkiewicz wrote:
> Hi,
> 
> This patch series adds support for AFTR idle mode on boards with
> Exynos3250 SoC and allows EXYNOS cpuidle driver usage on these
> boards.
> 
> It has been tested on Samsung Rinato board (Gear 2).
> 
> Depends on:
> - for-next branch (commit: 77105c882ba6) of linux-samsung.git
>   kernel tree
> 
> Changes since v3:
> - enhanced patch description for patch #1
> - added Reviewed-by/Tested-by tags from Krzysztof
> - enhanced C2_STATE BOOT mode flag comment
> - moved exynos_{set,clear}_boot_flag() to firmware.c
> - added patch description to patch #3
> 
> Changes since v2:
> - rebased on top of for-next branch (commit: 77105c882ba6) of
>   linux-samsung.git kernel tree
> 
> Changes since v1:
> - rebased on top of for-next branch (commit: ce275c369a0b) of
>   linux-samsung.git kernel tree
> - fixed lockup on hotplug by using dsb_sev() instead of IPI in
>   exynos_boot_secondary() on Exynos3250
> 
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R Institute Poland
> Samsung Electronics
> 
> 
> Bartlomiej Zolnierkiewicz (4):
>   ARM: EXYNOS: fix CPU1 hotplug on Exynos3250
>   ARM: EXYNOS: add code for setting/clearing boot flag
>   ARM: EXYNOS: cpuidle: add AFTR mode support for Exynos3250
>   ARM: EXYNOS: cpuidle: allow driver usage on Exynos3250 SoC
> 
>  arch/arm/mach-exynos/common.h   |  6 ++
>  arch/arm/mach-exynos/exynos.c   |  1 +
>  arch/arm/mach-exynos/firmware.c | 33 -
>  arch/arm/mach-exynos/platsmp.c  | 23 ---
>  arch/arm/mach-exynos/pm.c   | 12 +++-
>  arch/arm/mach-exynos/regs-pmu.h |  3 +++
>  arch/arm/mach-exynos/smc.h  |  9 +
>  7 files changed, 82 insertions(+), 5 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/


[GIT] IDE

2015-03-18 Thread David Miller

Just one fix to convert a by-hand conversion of jiffies to
msecs, from Nicholas McGuire.

Please pull, thanks a lot!

The following changes since commit 7b09ac704bac2de5bf0362793edc22a0094e381c:

  Merge tag 'sound-4.0-rc5' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound (2015-03-18 11:17:03 
-0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide.git 

for you to fetch changes up to 842159640782539a80153c040d6fc2b80756aa3a:

  ide_tape: convert jiffies with jiffies_to_msecs (2015-03-18 23:25:57 -0400)


Nicholas Mc Guire (1):
  ide_tape: convert jiffies with jiffies_to_msecs

 drivers/ide/ide-tape.c | 4 ++--
 1 file changed, 2 insertions(+), 2 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/


[GIT] Sparc

2015-03-18 Thread David Miller

1) Some command cases of semtimedop() not even handled due to
   miscoded comparison on sparc64.  From Rob Gardner.

2) Due to two bugs, /proc/kcore wan't working properly on sparc.

3) Make sure fatal traps stop all running cpus, from Dave
   Kleikamp.

Please pull, thanks!

The following changes since commit a38ecbbd0be025a6ecbbfd22d2575a5b46317117:

  Merge branch 'x86-urgent-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip (2015-03-01 12:22:44 
-0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git 

for you to fetch changes up to 3c08158e0ef5d6a2d4ae21d9eda218c468bc774f:

  sparc: Fix /proc/kcore (2015-03-18 19:15:28 -0700)


Dave Kleikamp (1):
  sparc64: fatal trap should stop all cpus

David S. Miller (1):
  sparc: Fix /proc/kcore

Ricardo Ribalda (1):
  sparc: io_64.h: Replace io function-link macros

Rickard Strandqvist (2):
  arch: sparc: kernel: traps_64.c: Remove some unused functions
  arch: sparc: kernel: starfire.c: Remove unused function

Rob Gardner (1):
  sparc: semtimedop() unreachable due to comparison error

 arch/sparc/Kconfig|  3 +++
 arch/sparc/include/asm/io_64.h| 20 ++--
 arch/sparc/include/asm/starfire.h |  1 -
 arch/sparc/kernel/entry.h |  4 
 arch/sparc/kernel/smp_64.c| 27 ---
 arch/sparc/kernel/starfire.c  |  5 -
 arch/sparc/kernel/sys_sparc_64.c  |  2 +-
 arch/sparc/kernel/traps_64.c  | 30 ++
 arch/sparc/mm/init_64.c   |  2 +-
 9 files changed, 41 insertions(+), 53 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/


[GIT] Networking

2015-03-18 Thread David Miller

1) Fix packet header offset calculation in _decode_session6(), from
   Hajime Tazaki.

2) Fix route leak in error paths of xfrm_lookup(), from Huaibin Wang.

3) Be sure to clear state properly when scans fail in iwlwifi mvm
   code, from Luciano Coelho.

4) iwlwifi tries to stop scans that aren't actually running, also
   from Luciano Coelho.

5) mac80211 should drop mesh frames that are not encrypted, fix
   from Bob Copeland.

6) Add new device ID to b43 wireless driver for BCM432228 chips,
   from Rafał Miłecki.

7) Fix accidental addition of members after variable sized array
   in struct tc_u_hnode, from WANG Cong.

8) Don't re-enable interrupts until after we call napi_complete()
   in ibmveth and WIZnet drivers, frm Yongbae Park.

9) Fix regression in vlan tag handling of fec driver, from Fugang
   Duan.

10) If a network namespace change fails during rtnl_newlink(),
we don't unwind the device registry properly.

11) Fix two TCP regressions, from Neal Cardwell:
a) Don't allow snd_cwnd_cnt to accumulate huge values
   due to missing test in tcp_cong_avoid_ai().
b) Restore CUBIC back to advancing cwnd by 1.5x packets
   per RTT.

12) Fix performance regression in xne-netback involving push TX
notifications, from David Vrabel.

13) __skb_tstamp_tx() can be called with a NULL sk pointer, do not
dereference blindly.  From Willem de Bruijn.

14) Fix potential stack overflow in RDS protocol stack, from Arnd
Bergmann.

15) VXLAN_VID_MASK used incorrectly in new remote checksum offload
support of VXLAN driver.  Fix from Alexey Kodanev.

16) Fix too small netlink SKB allocation in inet_diag layer, from
Eric Dumazet.

17) ieee80211_check_combinations() does not count interfaces
correctly, from Andrei Otcheretianski.

18) Hardware feature determination in bxn2x driver references a
piece of software state that actually isn't initialized yet,
fix from Michal Schmidt.

19) inet_csk_wait_for_connect() needs a sched_annotate_sleep()
annoation, from Eric Dumazet.

Please pull, thanks a lot!

The following changes since commit affb8172de395a6e1db52ed9790ca0456d8c29a9:

  Merge git://git.kernel.org/pub/scm/virt/kvm/kvm (2015-03-09 18:59:50 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 

for you to fetch changes up to 8d006e0105978619fb472e150c88b0d49337fe2b:

  Revert "net: cx82310_eth: use common match macro" (2015-03-18 22:37:38 -0400)


Ahmed S. Darwish (1):
  can: kvaser_usb: Fix tx queue start/stop race conditions

Al Viro (2):
  caif: fix MSG_OOB test in caif_seqpkt_recvmsg()
  rxrpc: bogus MSG_PEEK test in rxrpc_recvmsg()

Alexey Kodanev (2):
  net: sysctl_net_core: check SNDBUF and RCVBUF for min length
  vxlan: fix wrong usage of VXLAN_VID_MASK

Ameen Ali (1):
  tulip_core.c : out-of-bounds check.

Andrei Otcheretianski (2):
  iwlwifi: mvm: Fix ROC removal
  mac80211: count interfaces correctly for combination checks

Arnd Bergmann (1):
  rds: avoid potential stack overflow

Bob Copeland (1):
  mac80211: drop unencrypted frames in mesh fwding

Dan Carpenter (1):
  isdn: icn: use strlcpy() when parsing setup options

Daniel Borkmann (1):
  act_bpf: allow non-default TC_ACT opcodes as BPF exec outcome

David S. Miller (6):
  Merge tag 'wireless-drivers-for-davem-2015-03-10' of 
git://git.kernel.org/.../kvalo/wireless-drivers
  net: Handle unregister properly when netdev namespace change fails.
  Merge tag 'linux-can-fixes-for-4.0-20150314' of 
git://git.kernel.org/.../mkl/linux-can
  Merge branch 'master' of git://git.kernel.org/.../klassert/ipsec
  Merge tag 'mac80211-for-davem-2015-03-16' of 
git://git.kernel.org/.../jberg/mac80211
  Merge branch 'mlx4-net'

David Vrabel (1):
  xen-netback: notify immediately after pushing Tx response.

Emmanuel Grumbach (2):
  iwlwifi: fix max_ht_ampdu_exponent for older devices
  iwlwifi: mvm: BT Coex - fix a NULL pointer exception

Eran Ben Elisha (2):
  net/mlx4_en: Fix off-by-one in ethtool statistics display
  net/mlx4_en: Set statistics bitmap at port init

Eric Dumazet (3):
  xps: must clear sender_cpu before forwarding
  inet_diag: fix possible overflow in inet_diag_dump_one_icsk()
  inet: Clean up inet_csk_wait_for_connect() vs. might_sleep()

Eyal Shapira (2):
  iwlwifi: mvm: rs: fix BT Coex check to look at the correct ant
  iwlwifi: mvm: disable beamformer unless FW supports it

Fabio Estevam (1):
  Revert "net: fec: fix the warning found by dma debug"

Hajime Tazaki (1):
  xfrm6: Fix a offset value for network header in _decode_session6

Hariprasad Shenai (1):
  cxgb4: fix coccinelle warnings

Jason Wang (1):
  virtio-net: correctly delete napi hash

Johannes Berg (3):
  mac80211: ask for ECSA IE to be considered for beacon parse CRC
 

Re: [PATCH v4 1/4] ARM: EXYNOS: fix CPU1 hotplug on Exynos3250

2015-03-18 Thread Chanwoo Choi
Hi Bartlomiej,

I tested this patch on Exynos3250-based Gear2 board.
Thanks for your effor to solve this issue.

Tested-by: Chanwoo Choi 

Best Regards,
Chanwoo Choi

On 03/19/2015 01:00 AM, Bartlomiej Zolnierkiewicz wrote:
> CPU1 hotplug may hang when AFTR is used.  Fix it by:
> - setting AUTOWAKEUP_EN bit in ARM_COREx_CONFIGURATION register in
>   exynos_cpu_power_up()
> - not clearing reserved bits of ARM_COREx_CONFIGURATION register in
>   exynos_cpu_power_down()
> - waiting while an undocumented register 0x0908 becomes non-zero in
>   exynos_core_restart()
> - using dsb_sev() instead of IPI in exynos_boot_secondary() on
>   Exynos3250
> 
> This patch also fixes hotplug issues during resume from S2R:
> $ echo mem > /sys/power/state
> [  156.517266] Disabling non-boot CPUs ...
> [  156.517781] IRQ18 no longer affine to CPU1
> [  156.518043] CPU1: shutdown
> [  156.544718] Enabling non-boot CPUs ...
> [  156.554925] CPU1: Software reset
> [  158.552631] CPU1: failed to come online
> [  158.552753] Error taking CPU1 up: -5
> 
> Cc: Daniel Lezcano 
> Signed-off-by: Chanwoo Choi 
> Signed-off-by: Krzysztof Kozlowski 
> Signed-off-by: Bartlomiej Zolnierkiewicz 
> Reviewed-by: Krzysztof Kozlowski 
> Tested-by: Krzysztof Kozlowski 
> Acked-by: Kyungmin Park 
> ---
>  arch/arm/mach-exynos/platsmp.c  | 23 ---
>  arch/arm/mach-exynos/regs-pmu.h |  2 ++
>  2 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
> index d2e9f12..ebd135b 100644
> --- a/arch/arm/mach-exynos/platsmp.c
> +++ b/arch/arm/mach-exynos/platsmp.c
> @@ -126,6 +126,8 @@ static inline void platform_do_lowpower(unsigned int cpu, 
> int *spurious)
>   */
>  void exynos_cpu_power_down(int cpu)
>  {
> + u32 core_conf;
> +
>   if (cpu == 0 && (soc_is_exynos5420() || soc_is_exynos5800())) {
>   /*
>* Bypass power down for CPU0 during suspend. Check for
> @@ -137,7 +139,10 @@ void exynos_cpu_power_down(int cpu)
>   if (!(val & S5P_CORE_LOCAL_PWR_EN))
>   return;
>   }
> - pmu_raw_writel(0, EXYNOS_ARM_CORE_CONFIGURATION(cpu));
> +
> + core_conf = pmu_raw_readl(EXYNOS_ARM_CORE_CONFIGURATION(cpu));
> + core_conf &= ~S5P_CORE_LOCAL_PWR_EN;
> + pmu_raw_writel(core_conf, EXYNOS_ARM_CORE_CONFIGURATION(cpu));
>  }
>  
>  /**
> @@ -148,7 +153,12 @@ void exynos_cpu_power_down(int cpu)
>   */
>  void exynos_cpu_power_up(int cpu)
>  {
> - pmu_raw_writel(S5P_CORE_LOCAL_PWR_EN,
> + u32 core_conf = S5P_CORE_LOCAL_PWR_EN;
> +
> + if (soc_is_exynos3250())
> + core_conf |= S5P_CORE_AUTOWAKEUP_EN;
> +
> + pmu_raw_writel(core_conf,
>   EXYNOS_ARM_CORE_CONFIGURATION(cpu));
>  }
>  
> @@ -226,6 +236,10 @@ static void exynos_core_restart(u32 core_id)
>   if (!of_machine_is_compatible("samsung,exynos3250"))
>   return;
>  
> + while (!pmu_raw_readl(S5P_PMU_SPARE2))
> + udelay(10);
> + udelay(10);
> +
>   val = pmu_raw_readl(EXYNOS_ARM_CORE_STATUS(core_id));
>   val |= S5P_CORE_WAKEUP_FROM_LOCAL_CFG;
>   pmu_raw_writel(val, EXYNOS_ARM_CORE_STATUS(core_id));
> @@ -346,7 +360,10 @@ static int exynos_boot_secondary(unsigned int cpu, 
> struct task_struct *idle)
>  
>   call_firmware_op(cpu_boot, core_id);
>  
> - arch_send_wakeup_ipi_mask(cpumask_of(cpu));
> + if (soc_is_exynos3250())
> + dsb_sev();
> + else
> + arch_send_wakeup_ipi_mask(cpumask_of(cpu));
>  
>   if (pen_release == -1)
>   break;
> diff --git a/arch/arm/mach-exynos/regs-pmu.h b/arch/arm/mach-exynos/regs-pmu.h
> index eb461e1..84ddce1 100644
> --- a/arch/arm/mach-exynos/regs-pmu.h
> +++ b/arch/arm/mach-exynos/regs-pmu.h
> @@ -49,6 +49,7 @@
>  #define S5P_INFORM5  0x0814
>  #define S5P_INFORM6  0x0818
>  #define S5P_INFORM7  0x081C
> +#define S5P_PMU_SPARE2   0x0908
>  #define S5P_PMU_SPARE3   0x090C
>  
>  #define EXYNOS_IROM_DATA20x0988
> @@ -182,6 +183,7 @@
>  
>  #define S5P_CORE_LOCAL_PWR_EN0x3
>  #define S5P_CORE_WAKEUP_FROM_LOCAL_CFG   (0x3 << 8)
> +#define S5P_CORE_AUTOWAKEUP_EN   (1 << 31)
>  
>  /* Only for EXYNOS4210 */
>  #define S5P_CMU_CLKSTOP_LCD1_LOWPWR  0x1154
> 

--
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: randconfig build error with next-20150318, in drivers/vfio/virqfd.c

2015-03-18 Thread Alex Williamson
On Wed, 2015-03-18 at 15:57 -0700, Jim Davis wrote:
> Building with the attached random configuration file,
> 
> drivers/vfio/virqfd.c: In function 'vfio_virqfd_enable':
> drivers/vfio/virqfd.c:132:2: error: implicit declaration of function
> 'eventfd_ctx_fileget' [-Werror=implicit-function-declaration]
>   ctx = eventfd_ctx_fileget(irqfd.file);
>   ^
> drivers/vfio/virqfd.c:132:6: warning: assignment makes pointer from integer
> without a cast
>   ctx = eventfd_ctx_fileget(irqfd.file);
>   ^
>   CC  drivers/tty/serial/serial_core.o
> cc1: some warnings being treated as errors
> scripts/Makefile.build:258: recipe for target 'drivers/vfio/virqfd.o' failed

Thank you.  We've already got a patch posted on the mailing list that
will make this code dependent on CONFIG_EVENTFD.  Thanks,

Alex

--
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 10/15] staging: rtl8723au: No spaces at the start of a line

2015-03-18 Thread M. Vefa Bicakci
Prior to this commit, a large block of constants used to represent
an AES S-box table were indented with spaces in rtl8723au's
rtw_security.c. Correct the checkpatch.pl warnings indicating that
spaces should not be used to indent lines:
WARNING: please, no spaces at the start of a line

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 140 +-
 1 file changed, 70 insertions(+), 70 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index 0557a0df52..f8d0c0a63f 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -417,76 +417,76 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, 
u32 data_len,
 #define RC4_KEY_SIZE 16/* 128-bit RC4KEY (104 bits unknown) */
 
 /* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */
-static const unsigned short Sbox1[2][256] =   /* Sbox for hash (can be in 
ROM) */
-{ {
-   0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
-   0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
-   0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
-   0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
-   0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
-   0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
-   0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
-   0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
-   0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
-   0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
-   0xA6F5, 0xB968, 0x, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
-   0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
-   0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
-   0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
-   0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
-   0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
-   0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
-   0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
-   0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
-   0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
-   0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
-   0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
-   0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
-   0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
-   0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
-   0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
-   0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
-   0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
-   0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
-   0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
-   0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
-   0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
-  },
-
-  {  /* second half of table is unsigned char-reversed version of first! */
-   0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491,
-   0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC,
-   0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB,
-   0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B,
-   0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83,
-   0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A,
-   0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F,
-   0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA,
-   0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B,
-   0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713,
-   0xF5A6, 0x68B9, 0x, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6,
-   0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85,
-   0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411,
-   0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B,
-   0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1,
-   0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF,
-   0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E,
-   0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6,
-   0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B,
-   0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD,
-   0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8,
-   0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2,
-   0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049,
-   0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810,
-   0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 

[PATCH v3 00/15] checkpatch clean-up of rtl8723au's rtw_security.c

2015-03-18 Thread M. Vefa Bicakci
These commits address a number of checkpatch.pl warnings and errors
in rtl8723au's rtw_security.c.

Prior to this set of commits, checkpatch.pl reported the following:
total: 77 errors, 138 warnings, 1621 lines checked

After applying this set of commits, checkpatch.pl reports the following:
total: 0 errors, 26 warnings, 1624 lines checked
where the only remaining warnings relate to lines longer than 80
characters and quoted strings split across multiple lines.

There are also a number of commits which improve the code in other ways.
For example, the commit titled "Reorganize a few functions to remove
indentation" reworks two functions to make them more readable, whereas
the commit titled "Rework two byte array comparisons" reworks two CRC
verifications for the same reason, and "Use __func__ in trace logs"
avoids hardcoding function names in trace logs to increase
maintainability.

All of the commits have been verified to compile successfully via the
use of the interactive rebase feature of git.

v3: Rebased onto Greg Kroah-Hartman's staging-next tree, on top of
the following commit
  5ec293650827122df300581c17ca1d5de03bac3d.
  Staging: dgnc: release the lock before testing for nullity

Please see the individual commit messages for the changes
since v2. In summary, the following commits have been updated:
- that open brace should be on the previous line
- suspect code indent for conditional statements

The following commit is new:
- Use __func__ in trace logs

Finally, the following commit has been removed:
- Do not initialize a static to 0

v2: Please see the individual commit messages for the changes
since v1. In summary, the following commits have been updated:
- Reformat whitespace to increase readability
- Fix "before/around/after" whitespace issues
- Rework two byte array comparisons

M. Vefa Bicakci (15):
  staging: rtl8723au: Reformat whitespace to increase readability
  staging: rtl8723au: Fix "before/around/after" whitespace issues
  staging: rtl8723au: else should follow close brace
  staging: rtl8723au: Fix the indentation of two lines
  staging: rtl8723au: Reorganize a few functions to remove indentation
  staging: rtl8723au: else is not generally useful after a return
  staging: rtl8723au: Remove unneeded curly braces
  staging: rtl8723au: trailing statements should be on next line
  staging: rtl8723au: that open brace should be on the previous line
  staging: rtl8723au: No spaces at the start of a line
  staging: rtl8723au: Adjust whitespace in and around comments
  staging: rtl8723au: suspect code indent for conditional statements
  staging: rtl8723au: Rework two byte array comparisons
  staging: rtl8723au: Use __func__ in trace logs
  staging: rtl8723au: Remove unneeded comments

 drivers/staging/rtl8723au/core/rtw_security.c | 799 +-
 1 file changed, 401 insertions(+), 398 deletions(-)

-- 
2.1.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 v3 04/15] staging: rtl8723au: Fix the indentation of two lines

2015-03-18 Thread M. Vefa Bicakci
Correct the indentation of two lines in rtw_tkip_encrypt23a function in
rtl8723au's rtw_security.c.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index 17234e0bf1..df1787f20e 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -679,8 +679,8 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
arcfour_encrypt(, payload, 
payload, length);
arcfour_encrypt(, 
payload+length, crc, 4);
 
-   pframe += pxmitpriv->frag_len;
-   pframe  = PTR_ALIGN(pframe, 4);
+   pframe += pxmitpriv->frag_len;
+   pframe  = PTR_ALIGN(pframe, 4);
}
}
 
-- 
2.1.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 v3 05/15] staging: rtl8723au: Reorganize a few functions to remove indentation

2015-03-18 Thread M. Vefa Bicakci
Prior to this commit, functions rtw_tkip_encrypt23a and rtw_tkip_decrypt23a had
large if blocks which contained the majority of the logic in the functions.

Rework these functions so that if the negated version of the aforementioned if
blocks' conditions are true, we return from the function with _FAIL, as
expected by the calling code.

This lets us remove two levels of indentation from the functions in
question, making them more readable.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 178 +-
 1 file changed, 88 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index df1787f20e..f7b1d45981 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -618,6 +618,9 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
struct xmit_priv *pxmitpriv = >xmitpriv;
int res = _SUCCESS;
 
+   if (pattrib->encrypt != WLAN_CIPHER_SUITE_TKIP)
+   return _FAIL;
+
if (!pxmitframe->buf_addr)
return _FAIL;
 
@@ -625,71 +628,66 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
 
pframe = pxmitframe->buf_addr + hw_hdr_offset;
/* 4 start to encrypt each fragment */
-   if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
-   if (pattrib->psta)
-   stainfo = pattrib->psta;
-   else {
-   DBG_8723A("%s, call rtw_get_stainfo()\n", __func__);
-   stainfo = rtw_get_stainfo23a(>stapriv,
->ra[0]);
-   }
-
-   if (stainfo != NULL) {
-
-   if (!(stainfo->state & _FW_LINKED)) {
-   DBG_8723A("%s, psta->state(0x%x) != 
_FW_LINKED\n", __func__, stainfo->state);
-   return _FAIL;
-   }
+   if (pattrib->psta)
+   stainfo = pattrib->psta;
+   else {
+   DBG_8723A("%s, call rtw_get_stainfo()\n", __func__);
+   stainfo = rtw_get_stainfo23a(>stapriv,
+>ra[0]);
+   }
 
-   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_tkip_encrypt23a: stainfo!= NULL!!!\n"));
+   if (stainfo == NULL) {
+   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_tkip_encrypt23a: stainfo == NULL!!!\n"));
+   DBG_8723A("%s, psta == NUL\n", __func__);
+   return _FAIL;
+   }
 
-   if (is_multicast_ether_addr(pattrib->ra))
-   prwskey = 
psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
-   else
-   prwskey = >dot118021x_UncstKey.skey[0];
+   if (!(stainfo->state & _FW_LINKED)) {
+   DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, 
stainfo->state);
+   return _FAIL;
+   }
 
-   prwskeylen = 16;
+   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt23a: 
stainfo!= NULL!!!\n"));
 
-   for (curfragnum = 0; curfragnum < pattrib->nr_frags; 
curfragnum++) {
-   iv = pframe+pattrib->hdrlen;
-   payload = 
pframe+pattrib->iv_len+pattrib->hdrlen;
+   if (is_multicast_ether_addr(pattrib->ra))
+   prwskey = 
psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
+   else
+   prwskey = >dot118021x_UncstKey.skey[0];
 
-   GET_TKIP_PN(iv, dot11txpn);
+   prwskeylen = 16;
 
-   pnl = (u16)(dot11txpn.val);
-   pnh = (u32)(dot11txpn.val>>16);
+   for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
+   iv = pframe+pattrib->hdrlen;
+   payload = pframe+pattrib->iv_len+pattrib->hdrlen;
 
-   phase1((u16 *)[0], prwskey, 
>ta[0], pnh);
+   GET_TKIP_PN(iv, dot11txpn);
 
-   phase2([0], prwskey, (u16 *)[0], 
pnl);
+   pnl = (u16)(dot11txpn.val);
+   pnh = (u32)(dot11txpn.val>>16);
 
-   if ((curfragnum + 1) == pattrib->nr_frags) {
/* 4 the last fragment */
-   length = 
pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len - pattrib->icv_len;
-   RT_TRACE(_module_rtl871x_security_c_, 
_drv_info_, ("pattrib->iv_len =%x, pattrib->icv_len =%x\n", pattrib->iv_len, 
pattrib->icv_len));
-   *((u32 *)crc) = 
cpu_to_le32(getcrc32(payload, length));/* modified by Amy*/
+   phase1((u16 *)[0], prwskey, >ta[0], 

[PATCH v3 06/15] staging: rtl8723au: else is not generally useful after a return

2015-03-18 Thread M. Vefa Bicakci
Correct a checkpatch.pl warning regarding rtl8723au's
rtw_security.c::crc32_init pointing out that having an else statement
after a break or a return is not useful.

drivers/staging/rtl8723au/core/rtw_security.c:105:
WARNING: else is not generally useful after a break or return

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 42 ++-
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index f7b1d45981..f7571cf091 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -99,31 +99,33 @@ static u8 crc32_reverseBit(u8 data)
 
 static void crc32_init(void)
 {
+   int i, j;
+   u32 c;
+   u8 *p, *p1;
+   u8 k;
 
if (bcrc32initialized == 1)
return;
-   else{
-   int i, j;
-   u32 c;
-   u8 *p = (u8 *), *p1;
-   u8 k;
-
-   c = 0x1234;
-
-   for (i = 0; i < 256; ++i) {
-   k = crc32_reverseBit((u8)i);
-   for (c = ((u32)k) << 24, j = 8; j > 0; --j) {
-   c = c & 0x8000 ? (c << 1) ^ CRC32_POLY : (c 
<< 1);
-   }
-   p1 = (u8 *)_table[i];
-
-   p1[0] = crc32_reverseBit(p[3]);
-   p1[1] = crc32_reverseBit(p[2]);
-   p1[2] = crc32_reverseBit(p[1]);
-   p1[3] = crc32_reverseBit(p[0]);
+
+   p = (u8 *) 
+   c = 0x1234;
+
+   for (i = 0; i < 256; ++i) {
+   k = crc32_reverseBit((u8)i);
+
+   for (c = ((u32)k) << 24, j = 8; j > 0; --j) {
+   c = c & 0x8000 ? (c << 1) ^ CRC32_POLY : (c << 1);
}
-   bcrc32initialized = 1;
+
+   p1 = (u8 *)_table[i];
+
+   p1[0] = crc32_reverseBit(p[3]);
+   p1[1] = crc32_reverseBit(p[2]);
+   p1[2] = crc32_reverseBit(p[1]);
+   p1[3] = crc32_reverseBit(p[0]);
}
+
+   bcrc32initialized = 1;
 }
 
 static u32 getcrc32(u8 *buf, int len)
-- 
2.1.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 v3 15/15] staging: rtl8723au: Remove unneeded comments

2015-03-18 Thread M. Vefa Bicakci
This commit removes a number of unneeded comments. Two of the
aforementioned comments were most likely meant to aid with version
control, whereas the remaining two comments relate to (now unused)
local variable names.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index cdb3707fb2..309f3d969e 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -671,14 +671,14 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last 
fragment */
length = 
pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len - pattrib->icv_len;
RT_TRACE(_module_rtl871x_security_c_, _drv_info_, 
("pattrib->iv_len =%x, pattrib->icv_len =%x\n", pattrib->iv_len, 
pattrib->icv_len));
-   *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length)); 
/* modified by Amy */
+   *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
 
arcfour_init(, rc4key, 16);
arcfour_encrypt(, payload, payload, length);
arcfour_encrypt(, payload+length, crc, 4);
} else {
length = 
pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
-   *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length)); 
/* modified by Amy */
+   *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
arcfour_init(, rc4key, 16);
arcfour_encrypt(, payload, payload, length);
arcfour_encrypt(, payload+length, crc, 4);
@@ -1272,7 +1272,7 @@ int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
/* Intermediate Buffers */
int curfragnum, length;
u32 prwskeylen;
-   u8 *pframe, *prwskey; /* *payload, *iv */
+   u8 *pframe, *prwskey;
u8 hw_hdr_offset = 0;
struct sta_info *stainfo;
struct pkt_attrib *pattrib = >attrib;
@@ -1563,7 +1563,7 @@ int rtw_aes_decrypt23a(struct rtw_adapter *padapter,
struct security_priv *psecuritypriv = >securitypriv;
struct sk_buff *skb = precvframe->pkt;
int length;
-   u8 *pframe, *prwskey; /* *payload, *iv */
+   u8 *pframe, *prwskey;
int res = _SUCCESS;
 
pframe = skb->data;
-- 
2.1.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 v3 02/15] staging: rtl8723au: Fix "before/around/after" whitespace issues

2015-03-18 Thread M. Vefa Bicakci
Correct a number of "space(s) required before/around/after" checkpatch.pl
issues in a number of functions in rtl8723au's rtw_security.c.

v2: Correct one more whitespace issue ("length-4") in
rtw_tkip_decrypt23a.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 175 +-
 1 file changed, 87 insertions(+), 88 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index 088533c5b1..cb78d6dd9c 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -129,14 +129,14 @@ static void crc32_init(void)
 static u32 getcrc32(u8 *buf, int len)
 {
u8 *p;
-   u32  crc;
+   u32 crc;
 
if (bcrc32initialized == 0) crc32_init();
 
crc = 0x;   /* preload shift register, per CRC-32 spec */
 
for (p = buf; len > 0; ++p, --len)
-   crc = crc32_table[ (crc ^ *p) & 0xff] ^ (crc >> 8);
+   crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8);
 
return ~crc;/* transmit complement, per CRC-32 spec */
 }
@@ -182,7 +182,7 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
if ((curfragnum + 1) == pattrib->nr_frags) {
/* the last fragment */
length = pattrib->last_txcmdsz - pattrib->hdrlen -
-   pattrib->iv_len- pattrib->icv_len;
+   pattrib->iv_len - pattrib->icv_len;
 
*((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
 
@@ -265,8 +265,8 @@ static u32 secmicgetuint32(u8 *p)
s32 i;
u32 res = 0;
 
-   for (i = 0; i<4; i++) {
-   res |= ((u32)(*p++)) << (8*i);
+   for (i = 0; i < 4; i++) {
+   res |= ((u32)(*p++)) << (8 * i);
}
 
return res;
@@ -277,7 +277,7 @@ static void secmicputuint32(u8 *p, u32 val)
 {
long i;
 
-   for (i = 0; i<4; i++) {
+   for (i = 0; i < 4; i++) {
*p++ = (u8) (val & 0xff);
val >>= 8;
}
@@ -310,7 +310,7 @@ void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, 
u8 b)
 {
 
/*  Append the byte to our word-sized buffer */
-   pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM);
+   pmicdata->M |= ((unsigned long)b) << (8 * pmicdata->nBytesInM);
pmicdata->nBytesInM++;
/*  Process the word if it is full. */
if (pmicdata->nBytesInM >= 4) {
@@ -334,7 +334,7 @@ void rtw_secmicappend23a(struct mic_data *pmicdata, u8 
*src, u32 nbytes)
 {
 
/*  This is simple */
-   while(nbytes > 0) {
+   while (nbytes > 0) {
rtw_secmicappend23abyte23a(pmicdata, *src++);
nbytes--;
}
@@ -351,12 +351,12 @@ void rtw_secgetmic23a(struct mic_data *pmicdata, u8 *dst)
rtw_secmicappend23abyte23a(pmicdata, 0);
rtw_secmicappend23abyte23a(pmicdata, 0);
/*  and then zeroes until the length is a multiple of 4 */
-   while(pmicdata->nBytesInM != 0) {
+   while (pmicdata->nBytesInM != 0) {
rtw_secmicappend23abyte23a(pmicdata, 0);
}
/*  The appendByte function has already computed the result. */
secmicputuint32(dst, pmicdata->L);
-   secmicputuint32(dst+4, pmicdata->R);
+   secmicputuint32(dst + 4, pmicdata->R);
/*  Reset to the empty message. */
secmicclear(pmicdata);
 
@@ -367,10 +367,10 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, 
u32 data_len,
 {
 
struct mic_data micdata;
-   u8 priority[4]={0x0, 0x0, 0x0, 0x0};
+   u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
 
rtw_secmicsetkey23a(, key);
-   priority[0]= pri;
+   priority[0] = pri;
 
/* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
if (header[1]&1) {   /* ToDS == 1 */
@@ -401,7 +401,7 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, 
u32 data_len,
 #define   Lo8(v16)   ((u8)((v16)   & 0x00FF))
 #define   Hi8(v16)   ((u8)(((v16) >> 8) & 0x00FF))
 #define  Lo16(v32)   ((u16)((v32)   & 0x))
-#define  Hi16(v32)   ((u16)(((v32) >>16) & 0x))
+#define  Hi16(v32)   ((u16)(((v32) >> 16) & 0x))
 #define  Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8))
 
 /* select the Nth 16-bit word of the temporal key unsigned char array TK[]   */
@@ -418,7 +418,7 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, 
u32 data_len,
 #define RC4_KEY_SIZE 16/* 128-bit RC4KEY (104 bits unknown) */
 
 /* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */
-static const unsigned short Sbox1[2][256]=   /* Sbox for hash (can be in 
ROM) */
+static const unsigned short Sbox1[2][256] =   /* Sbox for hash (can be in 
ROM) */
 { {
0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 

[PATCH v3 11/15] staging: rtl8723au: Adjust whitespace in and around comments

2015-03-18 Thread M. Vefa Bicakci
As the subject indicates, adjust whitespace in and around comments
in rtl8723au's rtw_security.c.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 114 +-
 1 file changed, 57 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index f8d0c0a63f..8591b49664 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -135,12 +135,12 @@ static u32 getcrc32(u8 *buf, int len)
if (bcrc32initialized == 0)
crc32_init();
 
-   crc = 0x;   /* preload shift register, per CRC-32 spec */
+   crc = 0x; /* preload shift register, per CRC-32 spec */
 
for (p = buf; len > 0; ++p, --len)
crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8);
 
-   return ~crc;/* transmit complement, per CRC-32 spec */
+   return ~crc; /* transmit complement, per CRC-32 spec */
 }
 
 /* Need to consider the fragment  situation */
@@ -152,7 +152,7 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
struct arc4context mycontext;
int curfragnum, length, index;
u32 keylength;
-   u8 *pframe, *payload, *iv;/* wepkey */
+   u8 *pframe, *payload, *iv; /* wepkey */
u8 wepkey[16];
u8 hw_hdr_offset = 0;
struct pkt_attrib *pattrib = >attrib;
@@ -373,15 +373,15 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, 
u32 data_len,
priority[0] = pri;
 
/* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
-   if (header[1]&1) {   /* ToDS == 1 */
-   rtw_secmicappend23a(, [16], 6);  /* DA */
-   if (header[1]&2)  /* From Ds == 1 */
+   if (header[1]&1) { /* ToDS == 1 */
+   rtw_secmicappend23a(, [16], 6); /* DA */
+   if (header[1]&2) /* From Ds == 1 */
rtw_secmicappend23a(, [24], 6);
else
rtw_secmicappend23a(, [10], 6);
-   } else {/* ToDS == 0 */
-   rtw_secmicappend23a(, [4], 6);   /* DA */
-   if (header[1]&2)  /* From Ds == 1 */
+   } else { /* ToDS == 0 */
+   rtw_secmicappend23a(, [4], 6); /* DA */
+   if (header[1]&2) /* From Ds == 1 */
rtw_secmicappend23a(, [16], 6);
else
rtw_secmicappend23a(, [10], 6);
@@ -403,7 +403,7 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, 
u32 data_len,
 #define  Hi16(v32)   ((u16)(((v32) >> 16) & 0x))
 #define  Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8))
 
-/* select the Nth 16-bit word of the temporal key unsigned char array TK[]   */
+/* select the Nth 16-bit word of the temporal key unsigned char array TK[] */
 #define  TK16(N) Mk16(tk[2*(N)+1], tk[2*(N)])
 
 /* S-box lookup: 16 bits --> 16 bits */
@@ -510,7 +510,7 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, 
u32 iv32)
 {
int  i;
 
-   /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */
+   /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */
p1k[0]  = Lo16(iv32);
p1k[1]  = Hi16(iv32);
p1k[2]  = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */
@@ -526,7 +526,7 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, 
u32 iv32)
p1k[2] += _S_(p1k[1] ^ TK16((i & 1) + 4));
p1k[3] += _S_(p1k[2] ^ TK16((i & 1) + 6));
p1k[4] += _S_(p1k[3] ^ TK16((i & 1) + 0));
-   p1k[4] +=  (unsigned short)i;/* avoid 
"slide attacks" */
+   p1k[4] +=  (unsigned short) i; /* avoid "slide attacks" */
}
 
 }
@@ -557,41 +557,41 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, 
u32 iv32)
 static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
 {
int  i;
-   u16 PPK[6];  /* temporary key for mixing*/
+   u16 PPK[6]; /* temporary key for mixing*/
 
-   /* Note: all adds in the PPK[] equations below are mod 2**16 */
+   /* Note: all adds in the PPK[] equations below are mod 2**16 */
for (i = 0; i < 5; i++)
-   PPK[i] = p1k[i];/* first, copy P1K to PPK  */
+   PPK[i] = p1k[i]; /* first, copy P1K to PPK */
 
-   PPK[5] = p1k[4] + iv16; /* next,  add in IV16  */
+   PPK[5] = p1k[4] + iv16; /* next,  add in IV16 */
 
-   /* Bijective non-linear mixing of the 96 bits of PPK[0..5]   */
-   PPK[0] +=_S_(PPK[5] ^ TK16(0));   /* Mix key in each "round" */
-   PPK[1] +=_S_(PPK[0] ^ TK16(1));
-   PPK[2] +=_S_(PPK[1] ^ TK16(2));
-   PPK[3] +=_S_(PPK[2] ^ TK16(3));
-   PPK[4] +=_S_(PPK[3] ^ TK16(4));
-   PPK[5] +=_S_(PPK[4] ^ TK16(5));   /* Total # 

[PATCH v3 12/15] staging: rtl8723au: suspect code indent for conditional statements

2015-03-18 Thread M. Vefa Bicakci
Correct a number of indentation-with-spaces-and-tabs issues in
rtl8723au's rtw_security.c, according to checkpatch.pl:
WARNING: suspect code indent for conditional statements

v3: Make sure that all edited lines are at most 80 characters wide.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 46 ---
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index 8591b49664..4330479ee0 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -761,8 +761,16 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 
if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) {
-   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload[length-1](%x) || 
crc[2](%x)!= payload[length-2](%x) || crc[1](%x)!= payload[length-3](%x) || 
crc[0](%x)!= payload[length-4](%x)\n",
-   crc[3], payload[length - 1], crc[2], 
payload[length - 2], crc[1], payload[length - 3], crc[0], payload[length - 4]));
+   RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+("rtw_wep_decrypt23a:icv error "
+ "crc[3](%x)!= payload[length-1](%x) || "
+ "crc[2](%x)!= payload[length-2](%x) || "
+ "crc[1](%x)!= payload[length-3](%x) || "
+ "crc[0](%x)!= payload[length-4](%x)\n",
+ crc[3], payload[length - 1],
+ crc[2], payload[length - 2],
+ crc[1], payload[length - 3],
+ crc[0], payload[length - 4]));
res = _FAIL;
}
 
@@ -909,9 +917,9 @@ static void mix_column(u8 *in, u8 *out)
 
for (i = 0; i < 4; i++) {
if ((in[i] & 0x80) == 0x80)
-   add1b[i] = 0x1b;
+   add1b[i] = 0x1b;
else
-   add1b[i] = 0x00;
+   add1b[i] = 0x00;
}
 
swap_halfs[0] = in[2]; /* Swap halfs */
@@ -966,21 +974,21 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
 
for (round = 0; round < 11; round++) {
if (round == 0) {
-   xor_128(round_key, data, ciphertext);
-   next_key(round_key, round);
+   xor_128(round_key, data, ciphertext);
+   next_key(round_key, round);
} else if (round == 10) {
-   byte_sub(ciphertext, intermediatea);
-   shift_row(intermediatea, intermediateb);
-   xor_128(intermediateb, round_key, ciphertext);
+   byte_sub(ciphertext, intermediatea);
+   shift_row(intermediatea, intermediateb);
+   xor_128(intermediateb, round_key, ciphertext);
} else { /* 1 - 9 */
-   byte_sub(ciphertext, intermediatea);
-   shift_row(intermediatea, intermediateb);
-   mix_column([0], [0]);
-   mix_column([4], [4]);
-   mix_column([8], [8]);
-   mix_column([12], [12]);
-   xor_128(intermediatea, round_key, ciphertext);
-   next_key(round_key, round);
+   byte_sub(ciphertext, intermediatea);
+   shift_row(intermediatea, intermediateb);
+   mix_column([0], [0]);
+   mix_column([4], [4]);
+   mix_column([8], [8]);
+   mix_column([12], [12]);
+   xor_128(intermediatea, round_key, ciphertext);
+   next_key(round_key, round);
}
}
 
@@ -1481,7 +1489,7 @@ static int aes_decipher(u8 *key, uint hdrlen, u8 *pframe, 
uint plen)
for (j = 0; j < 16; j++)
padded_buffer[j] = 0x00;
for (j = 0; j < payload_remainder; j++)
-   padded_buffer[j] = message[payload_index++];
+   padded_buffer[j] = message[payload_index++];
bitwise_xor(aes_out, padded_buffer, chain_buffer);
aes128k128d(key, chain_buffer, aes_out);
}
@@ -1511,7 +1519,7 @@ static int aes_decipher(u8 *key, uint hdrlen, u8 *pframe, 
uint plen)
  message, pn_vector, num_blocks+1);
 
for (j = 0; j < 16; j++)
-padded_buffer[j] = 0x00;
+   padded_buffer[j] = 0x00;
for (j = 0; j < payload_remainder; j++)
padded_buffer[j] = message[payload_index + j];
   

[PATCH v3 13/15] staging: rtl8723au: Rework two byte array comparisons

2015-03-18 Thread M. Vefa Bicakci
Prior to this commit, rtl8723au's rtw_security.c had two instances of
byte array comparisons (for CRC checks) where the individual elements
of the byte arrays were compared one by one and an error trace would
be output if the byte arrays were determined to be different.

This commit improves the readability of the CRC verification by
placing the individual 4 bytes of each byte array into an 32-bit
unsigned integer and comparing the two resulting integers.

Thanks to Larry Finger for spotting the code style issues in the
previous version of this commit, and thanks to Joe Perches for
suggesting the use of 32-bit integer comparisons instead of byte
array comparisons.

v2: Correct code style issues and compare 32-bit integers instead of
byte arrays. Update the commit message to better reflect the nature
of the changes.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 39 ++-
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index 4330479ee0..eb3544866a 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -210,7 +210,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
 struct recv_frame *precvframe)
 {
/*  exclude ICV */
-   u8 crc[4];
+   u32 actual_crc, expected_crc;
struct arc4context mycontext;
int length;
u32 keylength;
@@ -243,19 +243,14 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
arcfour_encrypt(, payload, payload, length);
 
/* calculate icv and compare the icv */
-   *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4));
+   actual_crc = le32_to_cpu(getcrc32(payload, length - 4));
+   expected_crc = le32_to_cpu(get_unaligned_le32([length - 4]));
 
-   if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
-   crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) {
+   if (actual_crc != expected_crc) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload"
- "[length-1](%x) || crc[2](%x)!= payload[length-2](%x)"
- " || crc[1](%x)!= payload[length-3](%x) || crc[0](%x)"
- "!= payload[length-4](%x)\n",
- crc[3], payload[length - 1],
- crc[2], payload[length - 2],
- crc[1], payload[length - 3],
- crc[0], payload[length - 4]));
+("rtw_wep_decrypt23a:icv CRC mismatch: "
+ "actual: %08x, expected: %08x\n",
+ actual_crc, expected_crc));
}
 }
 
@@ -702,7 +697,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
u32 pnh;
u8 rc4key[16];
u8 ttkey[16];
-   u8 crc[4];
+   u32 actual_crc, expected_crc;
struct arc4context mycontext;
int length;
u32 prwskeylen;
@@ -757,20 +752,14 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
arcfour_init(, rc4key, 16);
arcfour_encrypt(, payload, payload, length);
 
-   *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4));
+   actual_crc = le32_to_cpu(getcrc32(payload, length - 4));
+   expected_crc = le32_to_cpu(get_unaligned_le32([length - 4]));
 
-   if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
-   crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) {
+   if (actual_crc != expected_crc) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-("rtw_wep_decrypt23a:icv error "
- "crc[3](%x)!= payload[length-1](%x) || "
- "crc[2](%x)!= payload[length-2](%x) || "
- "crc[1](%x)!= payload[length-3](%x) || "
- "crc[0](%x)!= payload[length-4](%x)\n",
- crc[3], payload[length - 1],
- crc[2], payload[length - 2],
- crc[1], payload[length - 3],
- crc[0], payload[length - 4]));
+("rtw_wep_decrypt23a:icv CRC mismatch: "
+ "actual: %08x, expected: %08x\n",
+ actual_crc, expected_crc));
res = _FAIL;
}
 
-- 
2.1.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 v3 08/15] staging: rtl8723au: trailing statements should be on next line

2015-03-18 Thread M. Vefa Bicakci
Correct a number of checkpatch.pl errors in rtl8723au's rtw_security.c
related to trailing statements:
ERROR: trailing statements should be on next line

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index b4327aaf71..803f8965a4 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -132,7 +132,8 @@ static u32 getcrc32(u8 *buf, int len)
u8 *p;
u32 crc;
 
-   if (bcrc32initialized == 0) crc32_init();
+   if (bcrc32initialized == 0)
+   crc32_init();
 
crc = 0x;   /* preload shift register, per CRC-32 spec */
 
@@ -559,8 +560,10 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 
*p1k, u16 iv16)
u16 PPK[6];  /* temporary key for mixing*/
 
/* Note: all adds in the PPK[] equations below are mod 2**16 */
-   for (i = 0; i < 5; i++) PPK[i] = p1k[i];/* first, copy P1K to PPK   
   */
-   PPK[5] = p1k[4] + iv16; /* next,  add in IV16   
   */
+   for (i = 0; i < 5; i++)
+   PPK[i] = p1k[i];/* first, copy P1K to PPK  */
+
+   PPK[5] = p1k[4] + iv16; /* next,  add in IV16  */
 
/* Bijective non-linear mixing of the 96 bits of PPK[0..5]   */
PPK[0] +=_S_(PPK[5] ^ TK16(0));   /* Mix key in each "round" */
@@ -960,7 +963,8 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
u8 intermediateb[16];
u8 round_key[16];
 
-   for (i = 0; i < 16; i++) round_key[i] = key[i];
+   for (i = 0; i < 16; i++)
+   round_key[i] = key[i];
 
for (round = 0; round < 11; round++) {
if (round == 0) {
@@ -1044,7 +1048,8 @@ static void construct_mic_header2(u8 *mic_header2, u8 
*mpdu, int a4_exists,
 {
int i;
 
-   for (i = 0; i < 16; i++) mic_header2[i] = 0x00;
+   for (i = 0; i < 16; i++)
+   mic_header2[i] = 0x00;
 
mic_header2[0] = mpdu[16];/* A3 */
mic_header2[1] = mpdu[17];
@@ -1057,7 +1062,8 @@ static void construct_mic_header2(u8 *mic_header2, u8 
*mpdu, int a4_exists,
mic_header2[7] = 0x00; /* mpdu[23]; */
 
if (!qc_exists && a4_exists) {
-   for (i = 0; i < 6; i++) mic_header2[8+i] = mpdu[24+i];   /* A4 
*/
+   for (i = 0; i < 6; i++)
+   mic_header2[8+i] = mpdu[24+i];   /* A4 */
}
 
if (qc_exists && !a4_exists) {
@@ -1066,7 +1072,8 @@ static void construct_mic_header2(u8 *mic_header2, u8 
*mpdu, int a4_exists,
}
 
if (qc_exists && a4_exists) {
-   for (i = 0; i < 6; i++) mic_header2[8+i] = mpdu[24+i];   /* A4 
*/
+   for (i = 0; i < 6; i++)
+   mic_header2[8+i] = mpdu[24+i];   /* A4 */
 
mic_header2[14] = mpdu[30] & 0x0f;
mic_header2[15] = mpdu[31] & 0x00;
@@ -1084,7 +1091,9 @@ static void construct_ctr_preload(u8 *ctr_preload, int 
a4_exists, int qc_exists,
 {
int i = 0;
 
-   for (i = 0; i < 16; i++) ctr_preload[i] = 0x00;
+   for (i = 0; i < 16; i++)
+   ctr_preload[i] = 0x00;
+
i = 0;
 
ctr_preload[0] = 0x01;  /* flag */
-- 
2.1.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 v3 09/15] staging: rtl8723au: that open brace should be on the previous line

2015-03-18 Thread M. Vefa Bicakci
Correct two instances of the checkpatch.pl error indicating that the
opening curly braces should not be on new lines:
ERROR: that open brace { should be on the previous line

v3: Make sure that all edited lines are at most 80 characters wide.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index 803f8965a4..0557a0df52 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -760,8 +760,8 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 
*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4));
 
-   if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] || 
crc[1] != payload[length - 3] || crc[0] != payload[length - 4])
-   {
+   if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
+   crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload[length-1](%x) || 
crc[2](%x)!= payload[length-2](%x) || crc[1](%x)!= payload[length-3](%x) || 
crc[0](%x)!= payload[length-4](%x)\n",
crc[3], payload[length - 1], crc[2], 
payload[length - 2], crc[1], payload[length - 3], crc[0], payload[length - 4]));
res = _FAIL;
@@ -845,8 +845,7 @@ static void next_key(u8 *key, int round)
 {
u8 rcon;
u8 sbox_key[4];
-   u8 rcon_table[12] =
-   {
+   u8 rcon_table[12] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
0x1b, 0x36, 0x36, 0x36
};
-- 
2.1.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 v3 14/15] staging: rtl8723au: Use __func__ in trace logs

2015-03-18 Thread M. Vefa Bicakci
Rework the trace log-related lines in rtl8723au's rtw_security.c
to use the __func__ GCC magic variable instead of hardcoding the
function names into the trace log strings. This also corrects a
copy-paste-related typo in the function named rtw_tkip_decrypt23a.

Thanks to Jes Sorensen for the suggestion to use __func__.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 49 ---
 1 file changed, 30 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index eb3544866a..cdb3707fb2 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -248,9 +248,9 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
 
if (actual_crc != expected_crc) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-("rtw_wep_decrypt23a:icv CRC mismatch: "
+("%s:icv CRC mismatch: "
  "actual: %08x, expected: %08x\n",
- actual_crc, expected_crc));
+ __func__, actual_crc, expected_crc));
}
 }
 
@@ -634,7 +634,8 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
}
 
if (stainfo == NULL) {
-   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_tkip_encrypt23a: stainfo == NULL!!!\n"));
+   RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+("%s: stainfo == NULL!!!\n", __func__));
DBG_8723A("%s, psta == NUL\n", __func__);
return _FAIL;
}
@@ -644,7 +645,8 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
return _FAIL;
}
 
-   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt23a: 
stainfo!= NULL!!!\n"));
+   RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+("%s: stainfo!= NULL!!!\n", __func__));
 
if (is_multicast_ether_addr(pattrib->ra))
prwskey = 
psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
@@ -718,7 +720,8 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
stainfo = rtw_get_stainfo23a(>stapriv,
 >ta[0]);
if (stainfo == NULL) {
-   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_tkip_decrypt23a: stainfo == NULL!!!\n"));
+   RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+("%s: stainfo == NULL!!!\n", __func__));
return _FAIL;
}
 
@@ -731,7 +734,8 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
prwskey = 
psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
prwskeylen = 16;
} else {
-   RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_tkip_decrypt23a: stainfo!= NULL!!!\n"));
+   RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+("%s: stainfo!= NULL!!!\n", __func__));
prwskey = >dot118021x_UncstKey.skey[0];
prwskeylen = 16;
}
@@ -757,9 +761,9 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 
if (actual_crc != expected_crc) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-("rtw_wep_decrypt23a:icv CRC mismatch: "
+("%s:icv CRC mismatch: "
  "actual: %08x, expected: %08x\n",
- actual_crc, expected_crc));
+ __func__, actual_crc, expected_crc));
res = _FAIL;
}
 
@@ -1296,7 +1300,7 @@ int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
 
if (!stainfo) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-("rtw_aes_encrypt23a: stainfo == NULL!!!\n"));
+("%s: stainfo == NULL!!!\n", __func__));
DBG_8723A("%s, psta == NUL\n", __func__);
res = _FAIL;
goto out;
@@ -1307,7 +1311,7 @@ int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
return _FAIL;
}
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-("rtw_aes_encrypt23a: stainfo!= NULL!!!\n"));
+("%s: stainfo!= NULL!!!\n", __func__));
 
if (is_multicast_ether_addr(pattrib->ra))
prwskey = 
psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
@@ -1535,10 +1539,16 @@ static int aes_decipher(u8 *key, uint hdrlen, u8 
*pframe, uint plen)
for (i = 0; i < 8; i++) {
if (pframe[hdrlen + 8 + plen - 8 + i] != message[hdrlen + 8 + 
plen - 8 + i]) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-("aes_decipher:mic check error mic[%d]: 
pframe(%x) != message(%x)\n",
-   

[PATCH v3 03/15] staging: rtl8723au: else should follow close brace

2015-03-18 Thread M. Vefa Bicakci
Correct checkpatch.pl errors in rtl8723au's rtw_security.c indicating
that an else statement should follow the closing brace of the previous
if/else if code block:
ERROR: else should follow close brace '}'

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index cb78d6dd9c..17234e0bf1 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -379,8 +379,7 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, 
u32 data_len,
rtw_secmicappend23a(, [24], 6);
else
rtw_secmicappend23a(, [10], 6);
-   }
-   else{   /* ToDS == 0 */
+   } else {/* ToDS == 0 */
rtw_secmicappend23a(, [4], 6);   /* DA */
if (header[1]&2)  /* From Ds == 1 */
rtw_secmicappend23a(, [16], 6);
@@ -673,8 +672,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
arcfour_encrypt(, payload, 
payload, length);
arcfour_encrypt(, 
payload+length, crc, 4);
 
-   }
-   else {
+   } else {
length = 
pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
*((u32 *)crc) = 
cpu_to_le32(getcrc32(payload, length));/* modified by Amy*/
arcfour_init(, rc4key, 16);
@@ -686,8 +684,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
}
}
 
-   }
-   else {
+   } else {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_, 
("rtw_tkip_encrypt23a: stainfo == NULL!!!\n"));
DBG_8723A("%s, psta == NUL\n", __func__);
res = _FAIL;
-- 
2.1.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 v3 07/15] staging: rtl8723au: Remove unneeded curly braces

2015-03-18 Thread M. Vefa Bicakci
Correct a number of checkpatch.pl warnings in rtl8723au's rtw_security.c
related to the existence of unnecessary curly braces around single
statement blocks:
WARNING: braces {} are not necessary for single statement blocks

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index f7571cf091..b4327aaf71 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -113,9 +113,8 @@ static void crc32_init(void)
for (i = 0; i < 256; ++i) {
k = crc32_reverseBit((u8)i);
 
-   for (c = ((u32)k) << 24, j = 8; j > 0; --j) {
+   for (c = ((u32)k) << 24, j = 8; j > 0; --j)
c = c & 0x8000 ? (c << 1) ^ CRC32_POLY : (c << 1);
-   }
 
p1 = (u8 *)_table[i];
 
@@ -267,9 +266,8 @@ static u32 secmicgetuint32(u8 *p)
s32 i;
u32 res = 0;
 
-   for (i = 0; i < 4; i++) {
+   for (i = 0; i < 4; i++)
res |= ((u32)(*p++)) << (8 * i);
-   }
 
return res;
 }
@@ -353,9 +351,8 @@ void rtw_secgetmic23a(struct mic_data *pmicdata, u8 *dst)
rtw_secmicappend23abyte23a(pmicdata, 0);
rtw_secmicappend23abyte23a(pmicdata, 0);
/*  and then zeroes until the length is a multiple of 4 */
-   while (pmicdata->nBytesInM != 0) {
+   while (pmicdata->nBytesInM != 0)
rtw_secmicappend23abyte23a(pmicdata, 0);
-   }
/*  The appendByte function has already computed the result. */
secmicputuint32(dst, pmicdata->L);
secmicputuint32(dst + 4, pmicdata->R);
@@ -871,10 +868,8 @@ static void byte_sub(u8 *in, u8 *out)
 {
int i;
 
-   for (i = 0; i < 16; i++) {
+   for (i = 0; i < 16; i++)
out[i] = sbox(in[i]);
-   }
-
 }
 
 static void shift_row(u8 *in, u8 *out)
@@ -935,9 +930,8 @@ static void mix_column(u8 *in, u8 *out)
 
for (i = 3; i > 0; i--) { /* logical shift left 1 bit */
andf7[i] = andf7[i] << 1;
-   if ((andf7[i - 1] & 0x80) == 0x80) {
+   if ((andf7[i - 1] & 0x80) == 0x80)
andf7[i] = (andf7[i] | 0x01);
-   }
}
andf7[0] = andf7[0] << 1;
andf7[0] = andf7[0] & 0xfe;
-- 
2.1.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 v3 01/15] staging: rtl8723au: Reformat whitespace to increase readability

2015-03-18 Thread M. Vefa Bicakci
Adjust the whitespace in the signature, local variable declaration and
initialization parts of a number of functions to increase readability
in rtl8723au's rtw_security.c.

v2: Make sure that the arcfour_encrypt function's argument list is split
according to the kernel code style.

Signed-off-by: M. Vefa Bicakci 
---
 drivers/staging/rtl8723au/core/rtw_security.c | 79 +--
 1 file changed, 38 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c 
b/drivers/staging/rtl8723au/core/rtw_security.c
index 045a24c81b..088533c5b1 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -31,11 +31,11 @@ struct arc4context {
 
 static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
 {
-   u32 t, u;
-   u32 keyindex;
-   u32 stateindex;
+   u32 t, u;
+   u32 keyindex;
+   u32 stateindex;
u8 *state;
-   u32 counter;
+   u32 counter;
 
state = parc4ctx->state;
parc4ctx->x = 0;
@@ -55,7 +55,8 @@ static void arcfour_init(struct arc4context *parc4ctx, u8 
*key, u32 key_len)
}
 
 }
-static u32 arcfour_byte(   struct arc4context  *parc4ctx)
+
+static u32 arcfour_byte(struct arc4context *parc4ctx)
 {
u32 x;
u32 y;
@@ -75,16 +76,13 @@ static u32 arcfour_byte(struct arc4context  
*parc4ctx)
return state[(sx + sy) & 0xff];
 }
 
-static void arcfour_encrypt(   struct arc4context  *parc4ctx,
-   u8 *dest,
-   u8 *src,
-   u32 len)
+static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest,
+   u8 *src, u32 len)
 {
-   u32 i;
+   u32 i;
 
for (i = 0; i < len; i++)
dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
-
 }
 
 static int bcrc32initialized;
@@ -368,7 +366,7 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, 
u32 data_len,
   u8 *mic_code, u8 pri)
 {
 
-   struct mic_data micdata;
+   struct mic_data micdata;
u8 priority[4]={0x0, 0x0, 0x0, 0x0};
 
rtw_secmicsetkey23a(, key);
@@ -604,21 +602,21 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 
*p1k, u16 iv16)
 int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
struct xmit_frame *pxmitframe)
 {
-   u16 pnl;
-   u32 pnh;
-   u8  rc4key[16];
-   u8   ttkey[16];
-   u8  crc[4];
-   u8   hw_hdr_offset = 0;
+   u16 pnl;
+   u32 pnh;
+   u8 rc4key[16];
+   u8 ttkey[16];
+   u8 crc[4];
+   u8 hw_hdr_offset = 0;
struct arc4context mycontext;
-   int curfragnum, length;
-   u32 prwskeylen;
-   u8  *pframe, *payload, *iv, *prwskey;
+   int curfragnum, length;
+   u32 prwskeylen;
+   u8 *pframe, *payload, *iv, *prwskey;
union pn48 dot11txpn;
-   struct  sta_info*stainfo;
-   struct  pkt_attrib   *pattrib = >attrib;
-   struct  security_priv   *psecuritypriv = >securitypriv;
-   struct  xmit_priv   *pxmitpriv = >xmitpriv;
+   struct sta_info *stainfo;
+   struct pkt_attrib *pattrib = >attrib;
+   struct security_priv *psecuritypriv = >securitypriv;
+   struct xmit_priv *pxmitpriv = >xmitpriv;
int res = _SUCCESS;
 
if (!pxmitframe->buf_addr)
@@ -706,17 +704,17 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 {
u16 pnl;
u32 pnh;
-   u8   rc4key[16];
-   u8   ttkey[16];
-   u8  crc[4];
+   u8 rc4key[16];
+   u8 ttkey[16];
+   u8 crc[4];
struct arc4context mycontext;
-   int length;
-   u32 prwskeylen;
-   u8  *pframe, *payload, *iv, *prwskey;
+   int length;
+   u32 prwskeylen;
+   u8 *pframe, *payload, *iv, *prwskey;
union pn48 dot11txpn;
-   struct  sta_info*stainfo;
-   struct  rx_pkt_attrib *prxattrib = >attrib;
-   struct  security_priv *psecuritypriv = >securitypriv;
+   struct sta_info *stainfo;
+   struct rx_pkt_attrib *prxattrib = >attrib;
+   struct security_priv *psecuritypriv = >securitypriv;
struct sk_buff *skb = precvframe->pkt;
int res = _SUCCESS;
 
@@ -1128,8 +1126,8 @@ static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
 
 static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
 {
-   uintqc_exists, a4_exists, i, j, payload_remainder,
-   num_blocks, payload_index;
+   uint qc_exists, a4_exists, i, j, payload_remainder,
+num_blocks, payload_index;
u8 pn_vector[6];
u8 mic_iv[16];
u8 mic_header1[16];
@@ -1345,12 +1343,11 @@ out:
return res;
 }
 
-static int aes_decipher(u8 *key, uint  hdrlen,
-   u8 *pframe, uint plen)
+static int aes_decipher(u8 *key, uint hdrlen, u8 

Re: [PATCH v3 1/2] sched/deadline: don't need to check throttled status when switched to dl

2015-03-18 Thread Wanpeng Li
Hi Ingo, how about these three patches this time, sorry for my bad english.
On Tue, Mar 17, 2015 at 07:15:30PM +0800, Wanpeng Li wrote:
>After commit 40767b0dc768 ("sched/deadline: Fix deadline parameter
>modification handling") is merged, deadline task throttled status 
>is cleared each time once switch from dl class, so throttled status 
>always doesn't set when switch back, there is no need to check 
>throttled status, this patch drop the check.
>
>Acked-by: Juri Lelli 
>Signed-off-by: Wanpeng Li 
>---
>v2 -> v3:
> * update changelog
>
> kernel/sched/deadline.c | 8 
> 1 file changed, 8 deletions(-)
>
>diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
>index 27b9381..eed6529 100644
>--- a/kernel/sched/deadline.c
>+++ b/kernel/sched/deadline.c
>@@ -1722,14 +1722,6 @@ static void switched_to_dl(struct rq *rq, struct 
>task_struct *p)
> {
>   int check_resched = 1;
> 
>-  /*
>-   * If p is throttled, don't consider the possibility
>-   * of preempting rq->curr, the check will be done right
>-   * after its runtime will get replenished.
>-   */
>-  if (unlikely(p->dl.dl_throttled))
>-  return;
>-
>   if (task_on_rq_queued(p) && rq->curr != p) {
> #ifdef CONFIG_SMP
>   if (p->nr_cpus_allowed > 1 && rq->dl.overloaded &&
>-- 
>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 v2 00/16] checkpatch clean-up of rtl8723au's rtw_security.c

2015-03-18 Thread M. Vefa Bicakci
On 2015-03-16 12:01 PM, Jes Sorensen wrote:
> "M. Vefa Bicakci"  writes:
>>
[snip]
>>
>> I hope this clarifies my set-up. Is there something I am doing incorrectly?
>> If there is anything I can assist with, please let me know.
>>
>> Thank you,
>>
>> Vefa
>>
>> [1]
>> https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/log/?h=staging-next
>> [2] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/
> 
> For staging patches, you should always post patches against the
> staging-next tree. Please rebase them and repost them.
> 
> Jes

Hello Jes,

Thank you for the review!

I have addressed your comments, and I will send the third version of the commits
for review shortly.

Vefa
--
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: Linux Kernel Scheduling Addition Notification : Hybrid Sleepers and Unfair scheduling

2015-03-18 Thread Mitchell Erblich
Group,

As a contractor or employee, the code that I write while being 
employed by them is owned by the company that I work for.

It is then up to them / legal / management, etc  whether they 
offer that code implementation to kernel.org or a ISP,  insert it into their 
release,  or whatever….

My notification is to say here is a minimal TOI, explain 
additionally where necessary, that I never saw a patch offered,  it exists, and 
I would be willing to repeat the code with a different implementation for FREE 
as an individual.

If the code is within a networking area, then maybe a 
simple Request For Enhancement (RFE) that explains functionality, probably some 
minimal API, but the direction is NOT to offer an implementation of code.

 Thus  is just a legal statement that needs repeating each 
and every time that make my offer.

How rude is that?

  Thus, Mike ,, your statement is totally uncalled for, 
inappropriate… and that being behind a email address does not excuse that.

Mitchell Erblich
Kernel Engineer



On Mar 18, 2015, at 8:59 PM, Mike Galbraith  wrote:

> On Wed, 2015-03-18 at 20:43 -0700, Mitchell Erblich wrote:
> 
>> This proposal was ONLY to resolve the legal issue with public domain
>> code of notification when a patch was not offered.…
> 
> Ah, so completely off topic here.. but then you knew that.  How rude.
> 
>   -Mike
> 

--
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 v10 00/21] Introduce ACPI for ARM64 based on ACPI 5.1

2015-03-18 Thread Hanjun Guo
On 2015/3/19 3:05, Will Deacon wrote:
> Hanjun,

Hi Will,

>
> On Wed, Mar 11, 2015 at 12:39:26PM +, Hanjun Guo wrote:
>> This patch set already tested on multi platforms:
>>  - AMD Seattle board;
>>  - Cavium Thunder board;
>>  - Huawei D02 board;
>>  - Qualcomm ARM64 platform
>>
>> This version 10 patch set address some minor comments and collect ACKs and
>> Reviewed-bys for v9:
>>
>>  - new Acks from Rafael, Olof, Grant, Lorenzo
>>  - new way to handle typdef phys_cpuid_t which suggested by Rafael,
>>but no functional change
>>  - Remove if(!phys) for early ioremappings
>>  - Rework sleep function for ARM64
>>  - Introduce linux/acpi_irq.h to hold acpi_irq_init()
>>  - Disable ACPI if not HW_REDUCED_ACPI compliant
>>  - Remove the doc of why ACPI on ARM
> So I've had a look at the current state of this series and I think there
> are a few immediate things left to do:
>
>   (1) Resolve the acpi=force cmdline issue highlighted by Lorenzo and
>   Catalin

Sure, it will be done after the confirmation with Ard.

>
>   (2) I believe Sudeep and Lorenzo have concerns about patch 13 (SMP init),
>   so I'm assuming there will be additional patches from them that are
>   required.

Sorry, I assume that it is about the print information for PSCI absent for SMP 
init, right?

>
>   (3) I have an open comment about moving the IRQ domain code into the
>   core, which I'd like to see addressed.

I replied your email, please share your ideas for what I said.

>
>   (4) We need an ack from Daniel on the arch-timer patch

OK, thanks for your ping to Daniel :)

>
> If you can get that in place, I'm not opposed to putting this into
> linux-next ahead of the firmware summit in San Jose next week. Note that
> this is not a commitment for 4.1, since I'm keen to see the outcomes of
> next week before setting anything in stone.

OK, I will stick to this mailing list and respond as soon as I can.

>
> Also, there's no need to repost patches if you're just adding Acks. I
> think I'm up to speed with those on my local branch and the Tested-by
> party is starting to look a little silly.

Should I send another version, and add some incremental cleanup/fix patches
on top of that?

Thanks
Hanjun

--
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 2/4] mmc: core: Add mmc_regulator_set_vqmmc()

2015-03-18 Thread Doug Anderson
Ulf,

On Tue, Mar 17, 2015 at 3:23 AM, Ulf Hansson  wrote:
>> This will get us within .3V of whatever vmmc is.  If vmmc is 3.3V, it
>> will allow vqmmc of 3.0V - 3.6V.
>>
>> This _seems_ sane to me and given any sane system design we should be
>> fine here, I think.  I can't see someone designing a system where
>> vqmmc was not within .3V of vmmc, can you?  If we think someone will
>> actually build a system where vmmc is 3.3V and vqmmc can't go higher
>> than 2.7V then we'll either need to increase the tolerance here or add
>> a new asymmetric system call like my original patches did.
>
> I know about SoC that supports 3.4V vmmc and 2.9V vqmmc.
>
> What I think we need is the option to have a policy here. We need to
> allow voltage levels stated by the spec and at the same time try chose
> the one best suited. That's not being accomplished here.
>
> Moreover, I wonder whether it's okay (from spec perspective) to have
> vqmmc at a higher voltage level than vmmc. I don't think that's
> allowed, but I might be wrong.

OK, so sounds like I need to add a regulator_set_voltage_tol2()
function that takes in an upper tolerance and a lower.  We can use the
same rough implementation in the core we have today (if Mark is OK
with that) with regulator_set_voltage_tol() but just allow it to be
asymmetric.

>From what I see in the spec for 3.3V cards are supposed to react to a
high signal that is .625 * VDD - VDD + .3


I might not be able to get to this till next week, though...

-Doug
--
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: Linux Kernel Scheduling Addition Notification : Hybrid Sleepers and Unfair scheduling

2015-03-18 Thread Mike Galbraith
On Wed, 2015-03-18 at 20:43 -0700, Mitchell Erblich wrote:

> This proposal was ONLY to resolve the legal issue with public domain
> code of notification when a patch was not offered.…

Ah, so completely off topic here.. but then you knew that.  How rude.

-Mike

--
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 3/3] toshiba_acpi: Fix the enabling of the Special Functions

2015-03-18 Thread Darren Hart
On Fri, Mar 06, 2015 at 11:52:41AM -0700, Azael Avalos wrote:
> Hi Darren,
> 
> 2015-03-06 11:28 GMT-07:00 Darren Hart :
> > On Thu, Feb 26, 2015 at 10:57:14AM -0700, Azael Avalos wrote:
> >> Some Toshiba laptops with the "Special Functions" feature enabled
> >> fail to properly enable such feature unless a specific value is
> >> used to enable the hotkey events.
> >
> > The specific value being... HCI_HOTKEY_ENABLE_SPECIAL? And we do this for 
> > ALL
> > systems that support special keys right (and have them enabled)? Not just 
> > the
> > ones that fail to properly enable them?
> 
> For all of them supporting "special functions" and have them enabled.
> 
> >
> > The above makes it sound like a work around, but nothing in the 
> > implementation
> > suggests that to me. Is this a workaround?
> 
> This is more a fix than a workaround, on the laptops I tested this value
> is needed in order to properly activate the "special functions", if not,
> they will behave like "normal" even if the "special functions"are enabled.
> 
> Tho' I'm not sure if it's only the models I tested or all of them, as I don't
> have that much hardware to test.

OK, I'll wait for v2 and queue for 4.1.

-- 
Darren Hart
Intel Open Source Technology Center
--
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/3] toshiba_acpi: Add Hotkey Event Type function and definitions

2015-03-18 Thread Darren Hart
On Fri, Mar 06, 2015 at 11:42:50AM -0700, Azael Avalos wrote:
> Hi Darren,
> 
> 2015-03-06 11:21 GMT-07:00 Darren Hart :
> > On Thu, Feb 26, 2015 at 10:57:12AM -0700, Azael Avalos wrote:
> >
> > Hi Azael,
> >
> > I'm pretty behind on this one, apologies.
> >
> 
> No wories, we still have plenty of time for 4.1 ;-)
> I simply wanted to send these early to get as much tests as possible.
> 
> >> This patch adds support to query the "Hotkey Event Type" the system
> >> supports.
> >>
> >> There are two main event types (so far), 0x10 and 0x11, with the
> >> first beign all those laptops that have the old keyboard layout, and
> >
> > being
> >
> >> the latter all those new laptops with the new keyboard layout.
> >>
> >
> > Some concern about this binary "new" and "old". What happens in 2 years when
> > they decide to break^W change our keyboards again?
> 
> Well, a new key mapping will need to be added, and hopefully
> a new value (other than 0x10 and 0x11) to identify the "newer"
> layout, only time will tell.

OK, anything else is just idle speculation I guess. So just fix the typos and
resend please.

--
Darren

> 
> >
> >> Signed-off-by: Azael Avalos 
> >> ---
> >>  drivers/platform/x86/toshiba_acpi.c | 26 ++
> >>  1 file changed, 26 insertions(+)
> >>
> >> diff --git a/drivers/platform/x86/toshiba_acpi.c 
> >> b/drivers/platform/x86/toshiba_acpi.c
> >> index dbcb7a8..e6aa8f9 100644
> >> --- a/drivers/platform/x86/toshiba_acpi.c
> >> +++ b/drivers/platform/x86/toshiba_acpi.c
> >> @@ -116,6 +116,7 @@ MODULE_LICENSE("GPL");
> >>  #define HCI_KBD_ILLUMINATION 0x0095
> >>  #define HCI_ECO_MODE 0x0097
> >>  #define HCI_ACCELEROMETER2   0x00a6
> >> +#define HCI_HOTKEY_EVENT_TYPE0xc000
> >>  #define SCI_PANEL_POWER_ON   0x010d
> >>  #define SCI_ILLUMINATION 0x014e
> >>  #define SCI_USB_SLEEP_CHARGE 0x0150
> >> @@ -127,8 +128,11 @@ MODULE_LICENSE("GPL");
> >>
> >>  /* field definitions */
> >>  #define HCI_ACCEL_MASK   0x7fff
> >> +#define HCI_HOTKEY_EVENT_NORMAL  0x10
> >> +#define HCI_HOTKEY_EVENT_SPECIAL 0x11
> >
> > NORMAL and SPECIAL? Hrm... what comes after special? EXTRASPECIAL? ;-)
> 
> Hehe, well, those can be changed to something like
> HCI_HOTKEY_EVENT_TYPE{1, 2}
> I just named them after the "special events" feature, as the value
> returned from HCI_HOTKEY_EVENT_TYPE is related to.
> 
> >
> > Or am I not looking at this right? Is there reason to expect these two to be
> > sufficient?
> 
> We can use the SCI_KBD_FUNCTION_KEYS too, all newer laptops
> that now come with the new layout support this feature.
> I can test for its presence and also for the value returned by
> HCI_HOTKEY_EVENT_TYPE.
> 
> >
> >>  #define HCI_HOTKEY_DISABLE   0x0b
> >>  #define HCI_HOTKEY_ENABLE0x09
> >> +#define HCI_HOTKEY_ENABLE_SPECIAL0x10
> >>  #define HCI_LCD_BRIGHTNESS_BITS  3
> >>  #define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS)
> >>  #define HCI_LCD_BRIGHTNESS_LEVELS(1 << HCI_LCD_BRIGHTNESS_BITS)
> >> @@ -1149,6 +1153,28 @@ static int toshiba_usb_three_set(struct 
> >> toshiba_acpi_dev *dev, u32 state)
> >>   return 0;
> >>  }
> >>
> >> +/* Hotkey event type */
> >> +static int toshiba_hotkey_event_type_get(struct toshiba_acpi_dev *dev,
> >> +  u32 *hotkey_event_type)
> >> +{
> >> + u32 val1 = 0x03;
> >> + u32 val2 = 0;
> >> + u32 result;
> >> +
> >> + result = hci_read2(dev, HCI_HOTKEY_EVENT_TYPE, , );
> >> + if (result == TOS_FAILURE) {
> >> + pr_err("ACPI callto get Hotkey Event type failed\n");
> >
> > call to
> >
> 
> Caught this one after I sent the patches :-P
> 
> > Thanks,
> >
> > --
> > Darren Hart
> > Intel Open Source Technology Center
> 
> 
> Cheers
> Azael
> 
> 
> -- 
> -- El mundo apesta y vosotros apestais tambien --
> 

-- 
Darren Hart
Intel Open Source Technology Center
--
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 spi tree with the slave-dma tree

2015-03-18 Thread Stephen Rothwell
Hi Mark,

Today's linux-next merge of the spi tree got conflicts in
drivers/dma/intel_mid_dma_regs.h and drivers/dma/intel_mid_dma.c
between commit 3b62286d0ef7 ("dmaengine: Remove FSF mailing addresses")
from the slave-dma tree and commit 36111da7838e ("dmaengine:
intel-mid-dma: remove the driver") from the spi tree.

I fixed it up (I just removed the files) and can carry the fix as
necessary (no action is required).

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


pgpLkI09OpVVp.pgp
Description: OpenPGP digital signature


Re: [RFC][PATCH 8/9] usb: otg-fsm: Remove unused members in struct otg_fsm

2015-03-18 Thread Peter Chen
On Wed, Mar 18, 2015 at 03:56:02PM +0200, Roger Quadros wrote:
> These members are not used anywhere so remove them.
> 
> Signed-off-by: Roger Quadros 
> ---
>  include/linux/usb/otg-fsm.h | 5 -
>  1 file changed, 5 deletions(-)
> 
> diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h
> index b6ba1bf..176c4fc 100644
> --- a/include/linux/usb/otg-fsm.h
> +++ b/include/linux/usb/otg-fsm.h
> @@ -95,11 +95,6 @@ struct otg_fsm {
>   int b_hnp_enable;
>   int a_clr_err;
>  
> - /* Informative variables */
> - int a_bus_drop_inf;
> - int a_bus_req_inf;
> - int a_clr_err_inf;
> - int b_bus_req_inf;
>   /* Auxilary informative variables */
>   int a_suspend_req_inf;
>  

But the above are defined at: ch 7.4.4, On-The-Go and Embedded Host
Supplement to the USB Revision 2.0 Specification

> -- 
> 2.1.0
> 

-- 

Best Regards,
Peter Chen
--
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 v10 15/21] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi

2015-03-18 Thread Hanjun Guo
Hi Will,

On 2015/3/19 2:41, Will Deacon wrote:
> On Wed, Mar 11, 2015 at 12:39:41PM +, Hanjun Guo wrote:
>> Introduce ACPI_IRQ_MODEL_GIC which is needed for ARM64 as GIC is
>> used, and then register device's gsi with the core IRQ subsystem.
>>
>> acpi_register_gsi() is similar to DT based irq_of_parse_and_map(),
>> since gsi is unique in the system, so use hwirq number directly
>> for the mapping.
>>
>> We are going to implement stacked domains when GICv2m, GICv3, ITS
>> support are added.
>>
>> CC: Marc Zyngier 
>> Originally-by: Amit Daniel Kachhap 
>> Tested-by: Suravee Suthikulpanit 
>> Tested-by: Yijing Wang 
>> Tested-by: Mark Langsdorf 
>> Tested-by: Jon Masters 
>> Tested-by: Timur Tabi 
>> Tested-by: Robert Richter 
>> Acked-by: Robert Richter 
>> Acked-by: Rafael J. Wysocki 
>> Reviewed-by: Grant Likely 
>> Signed-off-by: Hanjun Guo 
>> ---
>>  arch/arm64/kernel/acpi.c | 73 
>> 
>>  drivers/acpi/bus.c   |  3 ++
>>  include/linux/acpi.h |  1 +
>>  3 files changed, 77 insertions(+)
>>
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index c9203c0..dec6f8a 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -76,6 +76,12 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>>  }
>>  
>>  /*
>> + * Since we're on ARM, the default interrupt routing model
>> + * clearly has to be GIC.
>> + */
>> +enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_GIC;
>> +
>> +/*
>>   * __acpi_map_table() will be called before page_init(), so early_ioremap()
>>   * or early_memremap() should be called here to for ACPI table mapping.
>>   */
>> @@ -218,6 +224,73 @@ void __init acpi_init_cpus(void)
>>  pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
>>  }
>>  
>> +int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
>> +{
>> +*irq = irq_find_mapping(NULL, gsi);
>> +
>> +return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
>> +
>> +/*
>> + * success: return IRQ number (>0)
>> + * failure: return =< 0
>> + */
>> +int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int 
>> polarity)
>> +{
>> +unsigned int irq;
>> +unsigned int irq_type;
>> +
>> +/*
>> + * ACPI have no bindings to indicate SPI or PPI, so we
>> + * use different mappings from DT in ACPI.
>> + *
>> + * For FDT
>> + * PPI interrupt: in the range [0, 15];
>> + * SPI interrupt: in the range [0, 987];
>> + *
>> + * For ACPI, GSI should be unique so using
>> + * the hwirq directly for the mapping:
>> + * PPI interrupt: in the range [16, 31];
>> + * SPI interrupt: in the range [32, 1019];
>> + */
>> +
>> +if (trigger == ACPI_EDGE_SENSITIVE &&
>> +polarity == ACPI_ACTIVE_LOW)
>> +irq_type = IRQ_TYPE_EDGE_FALLING;
>> +else if (trigger == ACPI_EDGE_SENSITIVE &&
>> +polarity == ACPI_ACTIVE_HIGH)
>> +irq_type = IRQ_TYPE_EDGE_RISING;
>> +else if (trigger == ACPI_LEVEL_SENSITIVE &&
>> +polarity == ACPI_ACTIVE_LOW)
>> +irq_type = IRQ_TYPE_LEVEL_LOW;
>> +else if (trigger == ACPI_LEVEL_SENSITIVE &&
>> +polarity == ACPI_ACTIVE_HIGH)
>> +irq_type = IRQ_TYPE_LEVEL_HIGH;
>> +else
>> +irq_type = IRQ_TYPE_NONE;
>> +
>> +/*
>> + * Since only one GIC is supported in ACPI 5.0, we can
>> + * create mapping refer to the default domain
>> + */
>> +irq = irq_create_mapping(NULL, gsi);
>> +if (!irq)
>> +return irq;
>> +
>> +/* Set irq type if specified and different than the current one */
>> +if (irq_type != IRQ_TYPE_NONE &&
>> +irq_type != irq_get_trigger_type(irq))
>> +irq_set_irq_type(irq, irq_type);
>> +return irq;
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_register_gsi);
> I see you've still got this buried in the arch code. Is there any plan to
> move it out, as I moaned about this in the last version of the series and
> nothing seems to have changed?

Ah, sorry. Last time when I was in Hongkong for LCA this Feb, I discussed with 
Lorenzo
and he had a look into that too, he also met some obstacles to do that, so 
Lorenzo
said that he will talk to you about this (Lorenzo, correct me if I'm wrong due 
to hearing
problems of much noise in that room where we were talking).

Anyway, if we move those functions to core code, such as irqdomain code, which 
will be
compiled for x86 too, we can only set those functions as _weak, or we guard 
with them
as #ifdef CONFIG_ARM64 ... #endif, so for me, it's really not a big deal to 
move those code
out of arch/arm64, but I'm still open for suggestions if you can do that in a 
proper way.

Thanks
Hanjun

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

Re: [Patch v3] apple-gmux: lock iGP IO to protect from vgaarb changes

2015-03-18 Thread Darren Hart
On Wed, Mar 11, 2015 at 10:34:45PM +0100, Bruno Prémont wrote:
> As GMUX depends on IO for iGP to be enabled and active, lock the IO at
> vgaarb level. This should prevent GPU driver for dGPU to disable IO for
> iGP while it tries to own legacy VGA IO.
> 
> This fixes usage of backlight control combined with closed nvidia
> driver on some Apple dual-GPU (intel/nvidia) systems.
> 
> On those systems loading nvidia driver disables intel IO decoding,
> disabling the gmux backlight controls as a side effect.
> Prior to commits moving boot_vga from (optional) efifb to less optional
> vgaarb this mis-behavior could be avoided by using right kernel config
> (efifb enabled but vgaarb disabled).
> 
> This patch explicitly does not try to trigger vgaarb changes in order
> to avoid confusing already running graphics drivers. If IO has been
> mis-configured by vgaarb gmux will thus fail to probe.
> It is expected to load/probe gmux prior to graphics drivers.
> 
> Fixes: ce027dac592c0ada241ce0f95ae65856828ac450 # nvidia interaction
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=86121
> Reported-by: Petri Hodju 
> Tested-by: Petri Hodju 
> Cc: Bjorn Helgaas 
> Cc: Matthew Garrett 
> Signed-off-by: Bruno Prémont 
> ---
> Resending v2 in the hope Darren won't hit quoted-printable.
> Also adding linux-pci on CC by Bjorn's request in bugzilla.

Much better, thanks. Queued.

-- 
Darren Hart
Intel Open Source Technology Center
--
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][PATCH 2/9] usb: gadget: add usb_gadget_start/stop()

2015-03-18 Thread Peter Chen
On Wed, Mar 18, 2015 at 03:55:56PM +0200, Roger Quadros wrote:
> The OTG state machine needs a mechanism to start and
> stop the gadget controller. Add usb_gadget_start()
> and usb_gadget_stop().
> 
> Signed-off-by: Roger Quadros 
> ---
>  drivers/usb/gadget/udc/udc-core.c | 166 
> +++---
>  include/linux/usb/gadget.h|   3 +
>  2 files changed, 158 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/udc-core.c 
> b/drivers/usb/gadget/udc/udc-core.c
> index 5a81cb0..69b4123 100644
> --- a/drivers/usb/gadget/udc/udc-core.c
> +++ b/drivers/usb/gadget/udc/udc-core.c
> @@ -35,6 +35,8 @@
>   * @dev - the child device to the actual controller
>   * @gadget - the gadget. For use by the class code
>   * @list - for use by the udc class driver
> + * @running - udc is running

Doesn't OTG FSM should know it?

Peter
> + * @softconnect - sysfs softconnect says OK to connect
>   *
>   * This represents the internal data structure which is used by the UDC-class
>   * to hold information about udc driver and gadget together.
> @@ -44,6 +46,8 @@ struct usb_udc {
>   struct usb_gadget   *gadget;
>   struct device   dev;
>   struct list_headlist;
> + boolrunning;
> + boolsoftconnect;
>  };
>  
>  static struct class *udc_class;
> @@ -187,7 +191,14 @@ EXPORT_SYMBOL_GPL(usb_gadget_udc_reset);
>   */
>  static inline int usb_gadget_udc_start(struct usb_udc *udc)
>  {
> - return udc->gadget->ops->udc_start(udc->gadget, udc->driver);
> + int ret;
> +
> + dev_dbg(>dev, "%s\n", __func__);
> + ret = udc->gadget->ops->udc_start(udc->gadget, udc->driver);
> + if (!ret)
> + udc->running = 1;
> +
> + return ret;
>  }
>  
>  /**
> @@ -204,10 +215,140 @@ static inline int usb_gadget_udc_start(struct usb_udc 
> *udc)
>   */
>  static inline void usb_gadget_udc_stop(struct usb_udc *udc)
>  {
> + dev_dbg(>dev, "%s\n", __func__);
>   udc->gadget->ops->udc_stop(udc->gadget);
> + udc->running = 0;
>  }
>  
>  /**
> + * usb_udc_start - Start the usb device controller only if conditions met
> + * @udc: The UDC to be started
> + *
> + * Start the UDC and connect to bus (enable pull) only if the
> + * following conditions are met
> + * - UDC is not already running
> + * - gadget function driver is loaded
> + * - userspace softconnect says OK to connect
> + *
> + * NOTE: udc_lock must be held by caller.
> + *
> + * Returs 0 on success or not ready to start, else negative errno.
> + */
> +static int usb_udc_start(struct usb_udc *udc)
> +{
> + int ret;
> +
> + if (udc->running) {
> + dev_err(>dev, "%s: not starting as already running\n",
> + __func__);
> + return -EBUSY;
> + }
> +
> + if (udc->driver && udc->softconnect) {
> + ret = usb_gadget_udc_start(udc);
> + if (ret)
> + return ret;
> +
> + usb_gadget_connect(udc->gadget);
> + }
> +
> + return 0;
> +}
> +
> +/**
> + * usb_udc_stop - Stop the usb device controller
> + * @udc: The UDC to be stopped
> + *
> + * Disconnect from bus (disable pull) and stop the UDC.
> + *
> + * NOTE: udc_lock must be held by caller.
> + *
> + * Returs 0 on success, else negative errno.
> + */
> +static int usb_udc_stop(struct usb_udc *udc)
> +{
> + if (!udc->running) {
> + dev_err(>dev, "%s: not stopping as already halted\n",
> + __func__);
> + return -EBUSY;
> + }
> +
> + usb_gadget_disconnect(udc->gadget);
> + udc->driver->disconnect(udc->gadget);
> + usb_gadget_udc_stop(udc);
> +
> + return 0;
> +}
> +
> +/**
> + * usb_gadget_start - start the usb gadget controller
> + * @gadget: the gadget device to start
> + *
> + * This is external API for use by OTG core.
> + *
> + * Start the usb device controller and connect to bus (enable pull).
> + * There is no guarantee that the controller is started
> + * as we might be missing some dependencies
> + * i.e. gadget function driver not loaded or softconnect disabled.
> + */
> +int usb_gadget_start(struct usb_gadget *gadget)
> +{
> + int ret;
> + struct usb_udc *udc = NULL;
> +
> + dev_dbg(>dev, "%s\n", __func__);
> + mutex_lock(_lock);
> + list_for_each_entry(udc, _list, list)
> + if (udc->gadget == gadget)
> + goto found;
> +
> + dev_err(gadget->dev.parent, "%s: gadget not registered.\n",
> + __func__);
> + mutex_unlock(_lock);
> + return -EINVAL;
> +
> +found:
> + ret = usb_udc_start(udc);
> + mutex_unlock(_lock);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(usb_gadget_start);
> +
> +/**
> + * usb_gadget_stop - stop the usb gadget
> + * @gadget: The gadget device we want to stop
> + *
> + * This is external API for use by OTG core.
> + *
> + * Disconnect from the bus 

linux-next: build warning after merge of the sound-asoc tree

2015-03-18 Thread Stephen Rothwell
Hi all,

After merging the sound-asoc tree, today's linux-next build (arm
multi_v7_defconfig) produced this warning:

sound/soc/soc-dapm.c: In function 'snd_soc_dapm_new_pcm':
sound/soc/soc-dapm.c:3389:4: warning: passing argument 1 of 'snprintf' discards 
'const' qualifier from pointer target type
snprintf(w_param_text[count], len,
^

Introduced by commit c66150824b8a ("ASoC: dapm: add code to configure
dai link parameters").

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


pgpK4luR0HgWi.pgp
Description: OpenPGP digital signature


Re: Linux Kernel Scheduling Addition Notification : Hybrid Sleepers and Unfair scheduling

2015-03-18 Thread Mitchell Erblich

On Mar 18, 2015, at 7:38 PM, Mike Galbraith  wrote:

> On Wed, 2015-03-18 at 16:25 -0700, Mitchell Erblich wrote:
> 
>> 
>> SCHED_IA
>>  Over 10 years ago, System V Release 4 was enhanced with additional
>> features by Sun Microsystems. One of the more minor extensions dealt
>> with the subdivision of process’s scheduling characteristics and was
>> known as he INTERACTIVE /IA scheduling class. This scheduling class
>> was targeted to frequent sleepers, with the mouse icon being one the
>> first processes/tasks..
>> 
>>  Linux has no explicit SCHED_IA scheduling policy, but does alter
>> scheduling characteristics based on some sleep behavior (example:
>> GENTLE_FAIR_SLEEPERS) within the fair share scheduling configuration
>> option.
> 
> That's about fairness, it levels the playing field sleepers vs hogs.
> 
>> Processes / tasks that are CPU bound that fit into a SLEEPER behavior
>> can have a hybrid behavior over time where during any one scheduling
>> period, it may consume its variable length allocated time. This can
>> alter its expected short latency to be current / ONPROC. To simplify
>> the implementation, it is suggested that SCHED_IA be a sub scheduling
>> policy of SCHED_NORMAL. Shouldn’t an administrator be able to classify
>> that the NORMAL long term behavior of a task, be one as a FIXED
>> sleeper?
> 
> Nope, we definitely don't want a SCHED_IA class.
> 
> Your box can't tell if you're interacting or not even if you explicitly
> define something as 'interactive'.  If I stare in fascination at an
> eye-candy screen-saver, it becomes 'interactive'.  If I'm twiddling my
> thumbs waiting for a kbuild whatever other CPU intensive job to finish,
> that job becomes the 'interactive' thing of import.  The last thing I
> want is to have to squabble with every crack-head programmer on the
> planet who thinks his/her cool app should get special treatment.
> 
> You can’t get there from here.

This proposal was ONLY to resolve the legal issue with public domain code of 
notification when a patch was not offered.…

Any “crack-head programmer”  can still set if he has the CAPABILITY to 
change the scheduling policy to a RT-FIFO or RT-RR, to give the app special 
treatment… So, this proposal does not mitigate or change that treatment, 
assuming that the same CAPABILITY is checked.

POSIX ONLY specifies RT tasks as creating a level of unfairness, where 
in some APPLICATION SPECIFIC uses of Linux, need to execute an infrequently 
executed more than what is currently FAIR. 

So, the Linux scheduler ALREADY determines if a task slept during a 
time window and if it DIDN’T, it is penalized versus the tasks that did sleep.  
 It is effectively a dynamic scheduling behavior, where sometimes your 
interactive task did not fully sleep. Thus, why not still treat it as a IA 
task, because of the nature/functionality of the task??? 

 If could be generating tones/music through the audio/speaker driver of 
the system and you want a consistent minimal latency,  else you generate warble 
on your music.  Thus, if an admin/task KNOWS that a task is essentially a 
INTERACTIVE, aka a mouse icon driver, audio driver, etc that if a admin or 
startup script has the CAPABILITY, then he can set to make sure that the 
INTERACTIVE task ALWAYS/CONSISTENTLY is treated as an INTERACTIVE task.

Doing this change allows one or more tasks to BETTER behave the 
same independently of the number of tasks that are being scheduled during the 
time window and the number of CPUs/cores without any other special scheduling.

This was a SVR4.x feature within the SunOS kernel and a number of other 
SVR4.x UNIX Kernels, that could be set via priocntl(1) (Linux does not support) 
or a start script.

>> 
>>  Thus, the first Proposal is to explicitly support the SCHED_IA
>> scheduling policy within the Linux kernel. After kernel support, any
>> application that has the same functionality as priocntl(1) then needs
>> to be altered to support this new scheduling policy.
>> 
>> 
>> Note: Administrator in this context should be a task with a UID, EUID,
>> GID, EGID, etc, that has the proper CAPABILITY to alter scheduling
>> behavior.
> 
>> 
>> SCHED_UNFAIR
> 
> Snip.. we already have truckloads of bandwidth control.
> 
>   -Mike
> 

This is NOT bandwidth control..  Allocates an increase in its time 
slice versus other tasks…

SCHED_UNFAIR pertains to a task that can sometimes run and consume a 
UN-fair number of CPU cycles. With the routing protocol OSPFv2/v3, a well known 
Link state task is specified by function, but regular tasks that INFREQUENTLY 
execute like a file system file check(fsck) becomes a boot bottleneck if it is 
actually doing work and isn’t able to do its work without a number of context 
switches. With this functionality more than a 30% or more latency decrease can 
occur, depending on the number of tasks contending for the time window.

 

Re: [RFC][PATCH 3/9] usb: otg: add OTG core

2015-03-18 Thread Peter Chen
On Wed, Mar 18, 2015 at 03:55:57PM +0200, Roger Quadros wrote:
> The OTG core instantiates the OTG Finite State Machine
> per OTG controller and manages starting/stopping the
> host and gadget controllers based on the bus state.
> 
> It provides APIs for the following tasks
> 
> - Registering an OTG capable controller
> - Registering Host and Gadget controllers to OTG core
> - Providing inputs to and kicking the OTG state machine
> 
> TODO:
> - sysfs interface to allow application inputs to OTG state machine
> - otg class?
> 
> Signed-off-by: Roger Quadros 
> ---
>  drivers/usb/Makefile |   1 +
>  drivers/usb/common/Makefile  |   1 +
>  drivers/usb/common/usb-otg.c | 732 
> +++
>  drivers/usb/common/usb-otg.h |  71 +
>  drivers/usb/core/Kconfig |   8 +
>  include/linux/usb/usb-otg.h  |  86 +
>  6 files changed, 899 insertions(+)
>  create mode 100644 drivers/usb/common/usb-otg.c
>  create mode 100644 drivers/usb/common/usb-otg.h
>  create mode 100644 include/linux/usb/usb-otg.h
> 
> diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
> index 2f1e2aa..07f59a5 100644
> --- a/drivers/usb/Makefile
> +++ b/drivers/usb/Makefile
> @@ -60,5 +60,6 @@ obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/
>  obj-$(CONFIG_USB_GADGET) += gadget/
>  
>  obj-$(CONFIG_USB_COMMON) += common/
> +obj-$(CONFIG_USB_OTG_CORE)   += common/
>  
>  obj-$(CONFIG_USBIP_CORE) += usbip/
> diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
> index ca2f8bd..573fc75 100644
> --- a/drivers/usb/common/Makefile
> +++ b/drivers/usb/common/Makefile
> @@ -7,3 +7,4 @@ usb-common-y+= common.o
>  usb-common-$(CONFIG_USB_LED_TRIG) += led.o
>  
>  obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
> +obj-$(CONFIG_USB_OTG_CORE) += usb-otg.o
> diff --git a/drivers/usb/common/usb-otg.c b/drivers/usb/common/usb-otg.c
> new file mode 100644
> index 000..1433fc9
> --- /dev/null
> +++ b/drivers/usb/common/usb-otg.c
> @@ -0,0 +1,732 @@
> +/**
> + * drivers/usb/common/usb-otg.c - USB OTG core
> + *
> + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
> + * Author: Roger Quadros 
> + *
> + * 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/* enum usb_otg_state */
> +#include 
> +#include 
> +#include 
> +
> +#include "usb-otg.h"
> +
> +/* to link timer with callback data */
> +struct otg_timer {
> + struct timer_list timer;
> + /* callback data */
> + int *timeout_bit;
> + struct otg_data *otgd;
> +};
> +
> +struct otg_data {
> + struct device *dev; /* HCD & GCD's parent device */
> +
> + struct otg_fsm fsm;
> + /* HCD, GCD and usb_otg_state are present in otg_fsm->otg
> +  * HCD is bus_to_hcd(fsm->otg->host)
> +  * GCD is fsm->otg->gadget
> +  */
> + struct otg_fsm_ops fsm_ops; /* private copy for override */
> + struct usb_otg otg;
> + struct usb_hcd *shared_hcd; /* if shared HCD registered */
> +
> + /* saved hooks to OTG device */
> + int (*start_host)(struct otg_fsm *fsm, int on);
> + int (*start_gadget)(struct otg_fsm *fsm, int on);
> +
> + struct list_head list;
> +
> + struct work_struct work;/* OTG FSM work */
> + struct workqueue_struct *wq;
> +
> + struct otg_timer timers[NUM_OTG_FSM_TIMERS];
> +
> + bool fsm_running;
> + bool gadget_can_start;  /* OTG FSM says gadget can start */
> + bool host_can_start;/* OTG FSM says host can start */
> +
> + /* use otg->fsm.lock for serializing access */
> +};

What's the relationship between struct usb_otg otg and this one?

> +
> +/* OTG device list */
> +LIST_HEAD(otg_list);
> +static DEFINE_MUTEX(otg_list_mutex);
> +
> +/**
> + * check if device is in our OTG list and return
> + * otg_data, else NULL.
> + *
> + * otg_list_mutex must be held.
> + */
> +static struct otg_data *usb_otg_device_get_otgd(struct device *parent_dev)
> +{
> + struct otg_data *otgd;
> +
> + list_for_each_entry(otgd, _list, list) {
> + if (otgd->dev == parent_dev)
> + return otgd;
> + }
> +
> + return NULL;
> +}
> +
> +/**
> + * timer callback to set timeout bit and kick FSM
> + */
> +static void set_tmout(unsigned long data)
> +{
> + struct otg_timer *tmr_data;
> +
> + tmr_data = (struct otg_timer *)data;
> +
> + if (tmr_data->timeout_bit)
> + *tmr_data->timeout_bit = 1;
> +
> + 

[patch 7/7] dt: dtb version: report dtb info

2015-03-18 Thread Frank Rowand
From: Frank Rowand 

Report the /chosen/dtb-info properties on boot.

Signed-off-by: Frank Rowand 
---

The beginning of the context for hunk 2 includes a line from
2fa645cb2703d9b3786d850db815414dfeefa51d, which is in 4.0-rc4.  The
author of that commit has submitted a request to revert the commit:
http://lkml.iu.edu/hypermail/linux/kernel/1503.2/02134.html


 drivers/of/base.c |   42 ++
 1 file changed, 42 insertions(+)

Index: b/drivers/of/base.c
===
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1880,6 +1880,7 @@ static void of_alias_add(struct alias_pr
 void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
 {
struct property *pp;
+   struct device_node *dtb_info = NULL;
 
of_aliases = of_find_node_by_path("/aliases");
of_chosen = of_find_node_by_path("/chosen");
@@ -1899,6 +1900,47 @@ void of_alias_scan(void * (*dt_alloc)(u6
}
}
 
+   dtb_info = of_find_node_by_path("/chosen/dtb-info");
+   if (dtb_info == NULL)
+   dtb_info = of_find_node_by_path("/chosen@0/dtb-info");
+
+   if (dtb_info) {
+   const char *string;
+   int len;
+
+   string = of_get_property(dtb_info, "version", );
+   if (string) {
+   pr_notice("DTB version ");
+   for ( ; len > 0;
+   len -= (strlen(string) + 1),
+   string += (strlen(string) + 1)) {
+   pr_cont("%s", string);
+   }
+   pr_cont("\n");
+   }
+
+   string = of_get_property(dtb_info, "version-linux", );
+   if (string) {
+   pr_notice("DTB linux version ");
+   for ( ; len > 0;
+   len -= (strlen(string) + 1),
+   string += (strlen(string) + 1)) {
+   pr_cont("%s", string);
+   }
+   pr_cont("\n");
+   }
+
+   string = of_get_property(dtb_info, "dts-path", );
+   if (string)
+   pr_notice("DTB source %s\n", string);
+
+   string = of_get_property(dtb_info, "dtb-path", );
+   if (string)
+   pr_notice("DTB blob %s\n", string);
+
+   of_node_put(dtb_info);
+   }
+
if (!of_aliases)
return;
 
--
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 6/7] dt: dtb version: dtsi files

2015-03-18 Thread Frank Rowand
From: Frank Rowand 

Create a .dtsi file to contain the /chosen/dtb-info node and populate the
properties in that node.

Signed-off-by: Frank Rowand 
---
 arch/arm/boot/dts/skeleton.dtsi  |2 
 include/dt-bindings/version.dtsi |   19 +

Index: b/include/dt-bindings/version.dtsi
===
--- /dev/null
+++ b/include/dt-bindings/version.dtsi
@@ -0,0 +1,19 @@
+
+#include 
+#include 
+#include 
+
+/ {
+   chosen {
+   dtb-info {
+   version = UTS_RELEASE, " ", DTB_VERSION;
+   version-linux =
+   UTS_RELEASE,
+   " (", LINUX_COMPILE_BY, "@", 
LINUX_COMPILE_HOST, ") ",
+   "(", LINUX_COMPILER, ") ",
+   UTS_VERSION;
+   dtb-path = ___DTB_DTB_PATH;
+   dts-path = ___DTB_DTS_PATH;
+   };
+   };
+};
Index: b/arch/arm/boot/dts/skeleton.dtsi
===
--- a/arch/arm/boot/dts/skeleton.dtsi
+++ b/arch/arm/boot/dts/skeleton.dtsi
@@ -11,3 +11,5 @@
aliases { };
memory { device_type = "memory"; reg = <0 0>; };
 };
+
+#include 
--
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 5/7] dt: dtb version: kbuild scripts

2015-03-18 Thread Frank Rowand
From: Frank Rowand 

After applying this patch, need to add execute permission to the new file
scripts/version_dtb_increment_once

Modify the dtb compile rules to generate dtb version header files.

Create script to increment .version_dtb just once per make of one of more
dtbs, and to generate the dtb version header files.

Signed-off-by: Frank Rowand 
---
 scripts/Makefile.lib |   20 --
 scripts/version_dtb_increment_once   |   90 +++

Index: b/scripts/Makefile.lib
===
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -159,11 +159,19 @@ cpp_flags  = -Wp,-MD,$(depfile) $(NO
 
 ld_flags   = $(LDFLAGS) $(ldflags-y)
 
+# Do not want to pull kernel header files into .dtb, so minimize the risk of
+# that by adding include/generated/ to include path instead of include/
+# Headers in include/generated/ are used by include/dt-bindings/version.dtsi
 dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc\
 -I$(srctree)/arch/$(SRCARCH)/boot/dts   \
 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include   \
 -I$(srctree)/drivers/of/testcase-data   \
--undef -D__DTS__
+-Iinclude/generated \
+-undef -D__DTS__\
+-D___DTB_DTB_PATH="\"$@\""  \
+-D___DTB_DTS_PATH="\"$<\""  \
+-D"___DTB_DTC_VERSION=\"$(shell scripts/dtc/dtc -v | cut -d" " 
-f2-)\""
+
 
 # Finds the multi-part object the current object will be linked into
 modname-multi = $(sort $(foreach m,$(multi-used),\
@@ -282,10 +290,12 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
$(call cmd,dt_S_dtb)
 
 quiet_cmd_dtc = DTC $@
-cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
-   $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
-   -i $(dir $<) $(DTC_FLAGS) \
-   -d $(depfile).dtc.tmp $(dtc-tmp) ; \
+cmd_dtc =  \
+   $(srctree)/scripts/version_dtb_increment_once ;\
+   $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ;   \
+   $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0   \
+   -i $(dir $<) $(DTC_FLAGS)  \
+   -d $(depfile).dtc.tmp $(dtc-tmp) ; \
cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
 
 $(obj)/%.dtb: $(src)/%.dts FORCE
Index: b/scripts/version_dtb_increment_once
===
--- /dev/null
+++ b/scripts/version_dtb_increment_once
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+# increment .version_dtb at most once per build
+
+# VERSION_DTB_BASE is exported instead of passed to this script as an arg.
+#
+# If the value is passed as an arg then the make dependency triggers on
+# every build of a .dtb because if_changed_dep detects that cmd_dtc has
+# changed since the previous build (see scripts/Makefile.lib).
+
+# Nice output in kbuild format
+# Will be supressed by "make -s"
+info()
+{
+   if [ "${quiet}" != "silent_" ]; then
+   printf "  %-7s %s\n" ${1} ${2}
+   fi
+}
+
+
+# flock(1) to avoid race in parallel build
+(flock 9
+
+   if [ ! -r .version_dtb -o ! -s .version_dtb ] ; then
+   rm -f .version_dtb
+   touch .version_dtb
+   fi
+
+   VERSION_DTB=`cat .version_dtb`
+   if [ "${VERSION_DTB}" != "${VERSION_DTB_BASE}" ] ; then
+   exit
+   fi
+
+   info GEN .version_dtb
+
+   VERSION_DTB=`expr 0${VERSION_DTB} + 1`
+   echo ${VERSION_DTB} > .version_dtb
+
+   # Do not expand names
+   set -f
+
+   # Fix the language to get consistent output
+   LC_ALL=C
+   export LC_ALL
+
+   if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then
+   TIMESTAMP=`date`
+   else
+   TIMESTAMP=$KBUILD_BUILD_TIMESTAMP
+   fi
+   if test -z "$KBUILD_BUILD_USER"; then
+   COMPILE_BY=$(whoami | sed 's/\\//')
+   else
+   COMPILE_BY=$KBUILD_BUILD_USER
+   fi
+   if test -z "$KBUILD_BUILD_HOST"; then
+   COMPILE_HOST=`hostname`
+   else
+   COMPILE_HOST=$KBUILD_BUILD_HOST
+   fi
+
+   DTB_COMPILER=`scripts/dtc/dtc -v | cut -d" " -f2-`
+
+   VERSION="UTS_RELEASE (${COMPILE_BY}@${COMPILE_HOST}) (${DTB_COMPILER}) 
#${VERSION_DTB} ${TIMESTAMP}"
+
+   # truncate to get same result as scripts/mkcompile_h
+   UTS_LEN=64
+   TRUNCATE="cut -b -$UTS_LEN"
+
+
+   # Generate compile_dtb.h
+   TARGET=include/generated/compile_dtb.h
+   info UPD $TARGET
+
+   ( echo /\* This file is auto 

[patch 4/7] dt: dtb version: kernel Makefile

2015-03-18 Thread Frank Rowand
From: Frank Rowand 

Capture the initial value of .version_dtb so that when multiple .dtb files are
created in a single make the make scripts will be able to increment
.version_dtb only once instead of for each .dtb.

Signed-off-by: Frank Rowand 
---
 Makefile |4 +

Index: b/Makefile
===
--- a/Makefile
+++ b/Makefile
@@ -416,6 +416,9 @@ KBUILD_LDFLAGS_MODULE := -T $(srctree)/s
 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if 
$(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
 
+VERSION_DTB_BASE := $(shell cat .version_dtb 2> /dev/null)
+
+export VERSION_DTB_BASE
 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
 export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM STRIP OBJCOPY OBJDUMP
@@ -1181,6 +1184,7 @@ CLEAN_DIRS  += $(MODVERDIR)
 MRPROPER_DIRS  += include/config usr/include include/generated  \
  arch/*/include/generated .tmp_objdiff
 MRPROPER_FILES += .config .config.old .version .old_version \
+ .version_dtb .version_dtb_flock \
  Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
  signing_key.priv signing_key.x509 x509.genkey \
  extra_certificates signing_key.x509.keyid \
--
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 3/7] dt: dtb version: arm dts Makefile

2015-03-18 Thread Frank Rowand
From: Frank Rowand 

Remove generated files from the dependencies of .dtb files, where the
generated files are created as a result of making a .dtb.

Signed-off-by: Frank Rowand 
---
 arch/arm/boot/dts/Makefile   |   10 +++

Index: b/arch/arm/boot/dts/Makefile
===
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -650,5 +650,15 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt8135-evbp1.dtb
 endif
 
+# These files are generated by a kernel make if .version has changed.
+# Do not allow them to act as a dependency for rebuilding a .dtb that
+# has included dt-bindings/version.dtsi.
+PHONY += include/generated/compile.h include/generated/utsrelease.h
+
+# This file is generated by a .dtb make if .version_dtb has changed.
+# Do not allow it to act as a dependency for rebuilding a .dtb that
+# has included dt-bindings/version.dtsi.
+PHONY += include/generated/compile_dtb.h
+
 always := $(dtb-y)
 clean-files:= *.dtb
--
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 2/7] dt: dtb version: document chosen/dtb-info node binding

2015-03-18 Thread Frank Rowand
From: Frank Rowand 

Add /chosen/dtb-node binding.

Signed-off-by: Frank Rowand 
---
 Documentation/devicetree/bindings/chosen.txt |   37 +++

Index: b/Documentation/devicetree/bindings/chosen.txt
===
--- a/Documentation/devicetree/bindings/chosen.txt
+++ b/Documentation/devicetree/bindings/chosen.txt
@@ -46,6 +46,43 @@ on PowerPC "stdout" if "stdout-path" is
 should only use the "stdout-path" property.
 
 
+dtb-info node
+
+
+Information that describes where the device tree blob (DTB) came from and the
+environment it was created in.
+
+This node is normally created by including arch/arm/boot/dts/skeleton.dtsi,
+which includes include/dt-bindings/version.dtsi.
+
+Properties:
+
+version
+   The version of the DTB.  This is analagous to the linux kernel version.
+
+   This is a format free field intended for human consumption.  User space
+   programs should not have any expections about this property.
+
+   The DTB number in this property is incremented each time a make that
+   creates one or more DTBs is invoked.  If the make creates multiple
+   DTBs then this number is only incremented once.
+
+   The DTB number is stored in file .version_dtb.
+
+version-linux
+   The version of the linux kernel most recently built in the source
+   control system that contains the source used to build the DTB.
+
+   The linux kernel version number is not incremented for a make that
+   creates a DTB.
+
+dtb-path
+   The build directory relative path of the DTB.
+
+dts-path
+   The absolute path of the .dts file compiled to create the DTB.
+
+
 Properties documented in other bindings
 ---
 #address-cells  video/simple-framebuffer-sunxi.txt
--
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 1/7] dt: dtb version: consolidate documentation of chosen node bindings

2015-03-18 Thread Frank Rowand
From: Frank Rowand 

Documentation of bindings in node /chosen are scattered in several bindings
files.  If not already in Documentation/devicetree/bindings/chosen.txt, add
a pointer in that file to where the property and node bindings are described.

This is a clean up in anticipation of adding another node binding in /chosen.

Signed-off-by: Frank Rowand 
---
 Documentation/devicetree/bindings/chosen.txt |   31 +++
 1 file changed, 31 insertions(+)

Index: b/Documentation/devicetree/bindings/chosen.txt
===
--- a/Documentation/devicetree/bindings/chosen.txt
+++ b/Documentation/devicetree/bindings/chosen.txt
@@ -44,3 +44,34 @@ Implementation note: Linux will look for
 on PowerPC "stdout" if "stdout-path" is not found.  However, the
 "linux,stdout-path" and "stdout" properties are deprecated. New platforms
 should only use the "stdout-path" property.
+
+
+Properties documented in other bindings
+---
+#address-cells  video/simple-framebuffer-sunxi.txt
+
+#size-cells video/simple-framebuffer-sunxi.txt
+
+bootargsbooting-without-of.txt
+usage-model.txt
+
+initrd-end  usage-model.txt
+initrd-startusage-model.txt
+
+interrupt-controller (obsolete) booting-without-of.txt
+
+linux,pci-probe-onlypci/host-generic-pci.txt
+
+linux,stdout-path   booting-without-of.txt
+
+ranges  video/simple-framebuffer-sunxi.txt
+
+stdout-path video/simple-framebuffer.txt
+
+
+Nodes documented in other bindings
+--
+framebuffer video/simple-framebuffer.txt
+video/simple-framebuffer-sunxi.txt
+
+linux,sysrq-reset-seq   input/input-reset.txt
--
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 0/7] dt: dtb version: add version info to dtb

2015-03-18 Thread Frank Rowand
Rob,

Can this be added to the next trees to get some test exposure before submitting
to Linus?

There is currently no way to tie a device tree blob (DTB) back to the source
and environment used to create it.  Add this information, including a DTB
version number, which is somewhat analogous to the Linux kernel version number.

The DTB version number is independent of the kernel version number, and is
incremented for each make of one or more DTBs.

The DTB information is placed in node /chosen/dtb-info.  The data for this
node will be automatically generated by the .dtb make system for any .dts
that includes arch/arm/boot/dts/skeleton.dtsi, either directly or indirectly.
This means that architectures other than arm will not receive this feature.
This can be added to other architectures by modifying their skeleton.dtsi.

There are 70 of the 557 arm .dts files that do not include skeleton.dtsi.
Thus the .dtb files created for these systems will not have the
/chosen/dtb-info node:

   armada-xp-axpwifiap.dts
   armada-xp-db.dts
   armada-xp-gp.dts
   armada-xp-lenovo-ix4-300d.dts
   armada-xp-matrix.dts
   armada-xp-netgear-rn2120.dts
   armada-xp-openblocks-ax3-4.dts
   armada-xp-synology-ds414.dts
   atlas6-evb.dts
   atlas7-evb.dts
   axm5516-amarillo.dts
   bcm2835-rpi-b-plus.dts
   bcm2835-rpi-b.dts
   ea3250.dts
   ecx-2000.dts
   highbank.dts
   hip04-d01.dts
   integratorap.dts
   integratorcp.dts
   ls1021a-qds.dts
   ls1021a-twr.dts
   meson6-atv1200.dts
   moxart-uc7112lx.dts
   mt8127-moose.dts
   mt8135-evbp1.dts
   nspire-clp.dts
   nspire-cx.dts
   nspire-tp.dts
   phy3250.dts
   picoxcell-pc7302-pc3x2.dts
   picoxcell-pc7302-pc3x3.dts
   prima2-evb.dts
   r7s72100-genmai.dts
   r8a73a4-ape6evm-reference.dts
   r8a73a4-ape6evm.dts
   r8a7790-lager.dts
   r8a7791-henninger.dts
   r8a7791-koelsch.dts
   r8a7794-alt.dts
   spear1310-evb.dts
   spear1340-evb.dts
   spear300-evb.dts
   spear310-evb.dts
   spear320-evb.dts
   spear320-hmi.dts
   spear600-evb.dts
   stih407-b2120.dts
   stih410-b2120.dts
   stih415-b2000.dts
   stih415-b2020.dts
   stih416-b2000.dts
   stih416-b2020.dts
   stih416-b2020e.dts
   stih418-b2199.dts
   sun9i-a80-optimus.dts
   vexpress-v2p-ca15-tc1.dts
   vexpress-v2p-ca15_a7.dts
   vexpress-v2p-ca5s.dts
   vexpress-v2p-ca9.dts
   vt8500-bv07.dts
   wm8505-ref.dts
   wm8650-mid.dts
   wm8750-apc8750.dts
   wm8850-w70v2.dts
   xenvm-4.2.dts
   zynq-parallella.dts
   zynq-zc702.dts
   zynq-zc706.dts
   zynq-zed.dts
   zynq-zybo.dts



An example of the DTB information reported is:

  $ echo ; cat /proc/version; echo ; echo ; dmesg | grep DTB

  Linux version 4.0.0-rc4-dirty (frank@buildhost) (gcc version 4.6.x-google 
20120106 (prerelease) (GCC) ) #5 SMP PREEMPT Wed Mar 18 20:04:48 PDT 2015


  DTB version 4.0.0-rc4-dirty (frank@buildhost) (DTC 1.4.0-dirty) #4 Wed Mar 18 
20:04:11 PDT 2015
  DTB linux version 4.0.0-rc4-dirty (frank@build_host) (gcc version 
4.6.x-google 20120106 (prerelease) (GCC) ) #3 SMP PREEMPT Wed Mar 18 20:02:46 
PDT 2015
  DTB source 
/local/nobackup/src/git_linus/linux--4.0/arch/arm/boot/dts/qcom-apq8074-dragonboard.dts
  DTB blob arch/arm/boot/dts/qcom-apq8074-dragonboard.dtb


The values of the /chosen/dtb-info/ properties are also available in
/proc/device-tree/chosen/dtb-info/
--
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] ide_tape: convert jiffies with jiffies_to_msecs

2015-03-18 Thread David Miller
From: Nicholas Mc Guire 
Date: Tue,  3 Mar 2015 05:52:51 -0500

> Use jiffies_to_msecs for converting jiffies as it handles all of the corner
> cases reliably and also helps readability. The printk format is fixed up 
> as jiffies_to_msecs returns unsigned int not unsigned long.
> 
> Signed-off-by: Nicholas Mc Guire 
> ---
> 
> v2: change printk format string from %d to %u as suggested by
> Joe Perches .

Applied, thanks.
--
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] eeprom: at24: Add support for large EEPROMs connected to SMBus adapters

2015-03-18 Thread Guenter Roeck

On 03/18/2015 06:27 AM, Wolfram Sang wrote:

On Mon, Mar 16, 2015 at 09:20:49PM -0700, Guenter Roeck wrote:

On Mon, Feb 16, 2015 at 01:09:51PM +0100, Wolfram Sang wrote:

Hi Guenter,


I wonder where we are with thisp patch; I don't recall a reply to my previous
e-mail.


Sorry for the late reply. I needed to recover from a HDD headcrash :(


Do you need some more time to think about it ? Otherwise I'll publish an
out-of-tree version of the at24 driver with the patch applied on github,
for those who might need the functionality provided by this patch.


Your last mail made me aware of why we were missing each other before. I
see your point now, but yes, still need to think about it. My plan is to
have a decision until the 3.21 merge window.


Hi Wolfram,

any news ?


Yes :)

The main misunderstanding we had before was: You were talking about
multi-master safety between transfers, while I was thinking about
multi-master safety between messages. While we need to guarantee this
for the latter, you are right about the former, sadly. True multi-master
safety between transfers is probably like a can of worms currently.

Still, I think we have a race with your patch when having two read
processes. If b) kicks in after a) has just set the eeprom pointer, a)
will not read the data it wants. For that to prevent, we should take the
adapter_lock during those two transfers needed for the read you
implemented. My preferred solution would be to have __smbus_transfer
like we have __i2c_transfer and then using that. Some mux code could
also make use out of that. But if you are going to use
adapter->algo->smbus_xfer() directly, well, then be it.



You are right, that is a problem. Not for eeprom access itself - that already
has a mutex - but for parallel access to the chip through the eeprom file
and, say, by i2cdump.

I don't call that multi-master, though, so I guess we may have a bit of a
terminology problem.

I'll see what I can come up with, but I am not sure if I'll find the time
before the 4.1 commit window opens. Company has a working solution (kind of),
so now I'll have to do this on my own time ;-).

Thanks,
Guenter

--
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] tracing: add trace event for memory-failure

2015-03-18 Thread Steven Rostedt
On Thu, 19 Mar 2015 11:04:30 +0800
Xie XiuQi  wrote:

> Memory-failure as the high level machine check handler, it's necessary
> to report memory page recovery action result to user space by ftrace.
> 
> This patch add a event at ras group for memory-failure.
> 
> The output like below:
> #  tracer: nop
> # 
> #  entries-in-buffer/entries-written: 2/2   #P:24
> # 
> #   _-=> irqs-off
> #  / _=> need-resched
> # | / _---=> hardirq/softirq
> # || / _--=> preempt-depth
> # ||| / delay
> #TASK-PID   CPU#  TIMESTAMP  FUNCTION
> #   | |   |      | |
>mce-inject-13150 [001]    277.019359: memory_failure_event: pfn 
> 0x19869: free buddy page recovery: Delayed
> 
> ---
> v1->v2:
>  - Comment update
>  - Just passing 'result' instead of 'action_name[result]',
>suggested by Steve. And hard coded there because trace-cmd
>and perf do not have a way to process enums.
> 

I'll try to fix that issue soon, such that enums will work.

> Cc: Tony Luck 
> Cc: Steven Rostedt 
> Signed-off-by: Xie XiuQi 
> ---
>  include/ras/ras_event.h | 38 ++
>  mm/memory-failure.c |  3 +++
>  2 files changed, 41 insertions(+)
> 
> diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
> index 79abb9c..ebb05f3 100644
> --- a/include/ras/ras_event.h
> +++ b/include/ras/ras_event.h
> @@ -232,6 +232,44 @@ TRACE_EVENT(aer_event,
>   __print_flags(__entry->status, "|", aer_uncorrectable_errors))
>  );
>  
> +/*
> + * memory-failure recovery action result event
> + *
> + * unsigned long pfn -   Page Number of the corrupted page
> + * char * action -   Recovery action for various type of pages
> + * int result -  Action result
> + *
> + * NOTE: 'action' and 'result' are defined at mm/memory-failure.c
> + */
> +TRACE_EVENT(memory_failure_event,
> + TP_PROTO(const unsigned long pfn,
> +  const char *action,
> +  const int result),

"const unsigned long" and "const int" is that really needed? These are
passed by value parameters. There's no need to make them const. The
"const char *" is required though.

-- Steve

> +
> + TP_ARGS(pfn, action, result),
> +
> + TP_STRUCT__entry(
> + __field(unsigned long, pfn)
> + __string(action, action)
> + __field(int, result)
> + ),
> +
> + TP_fast_assign(
> + __entry->pfn= pfn;
> + __assign_str(action, action);
> + __entry->result = result;
> + ),
> +
> + TP_printk("pfn %#lx: %s page recovery: %s",
> + __entry->pfn,
> + __get_str(action),
> + __print_symbolic(__entry->result,
> + {0, "Ignored"},
> + {1, "Failed"},
> + {2, "Delayed"},
> + {3, "Recovered"})
> + )
> +);
>  #endif /* _TRACE_HW_EVENT_MC_H */
>  
>  /* This part must be outside protection */
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index feb803b..3a71668 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -56,6 +56,7 @@
>  #include 
>  #include 
>  #include "internal.h"
> +#include 
>  
>  int sysctl_memory_failure_early_kill __read_mostly = 0;
>  
> @@ -844,6 +845,8 @@ static struct page_state {
>   */
>  static void action_result(unsigned long pfn, char *msg, int result)
>  {
> + trace_memory_failure_event(pfn, msg, result);
> +
>   pr_err("MCE %#lx: %s page recovery: %s\n",
>   pfn, msg, action_name[result]);
>  }

--
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 jkirsher-next-queue] net/mlx4_en: mlx4_en_set_tx_maxrate() can be static

2015-03-18 Thread David Miller
From: kbuild test robot 
Date: Thu, 19 Mar 2015 08:51:27 +0800

> Signed-off-by: Fengguang Wu 

Applied, thank you.
--
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] radeon: Do not directly dereference pointers to BIOS area.

2015-03-18 Thread David Miller

Use readb() and memcpy_fromio() accessors instead.

Signed-off-by: David S. Miller 

diff --git a/drivers/gpu/drm/radeon/radeon_bios.c 
b/drivers/gpu/drm/radeon/radeon_bios.c
index 63ccb8f..d27e4cc 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -76,7 +76,7 @@ static bool igp_read_bios_from_vram(struct radeon_device 
*rdev)
 
 static bool radeon_read_bios(struct radeon_device *rdev)
 {
-   uint8_t __iomem *bios;
+   uint8_t __iomem *bios, val1, val2;
size_t size;
 
rdev->bios = NULL;
@@ -86,15 +86,19 @@ static bool radeon_read_bios(struct radeon_device *rdev)
return false;
}
 
-   if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) {
+   val1 = readb([0]);
+   val2 = readb([1]);
+
+   if (size == 0 || val1 != 0x55 || val2 != 0xaa) {
pci_unmap_rom(rdev->pdev, bios);
return false;
}
-   rdev->bios = kmemdup(bios, size, GFP_KERNEL);
+   rdev->bios = kzalloc(size, GFP_KERNEL);
if (rdev->bios == NULL) {
pci_unmap_rom(rdev->pdev, bios);
return false;
}
+   memcpy_fromio(rdev->bios, bios, size);
pci_unmap_rom(rdev->pdev, bios);
return true;
 }
--
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] f2fs: add fast symlink support

2015-03-18 Thread Chao Yu
Hi Wanpeng,

> -Original Message-
> From: Wanpeng Li [mailto:wanpeng...@linux.intel.com]
> Sent: Thursday, March 19, 2015 7:02 AM
> To: Jaegeuk Kim
> Cc: Wanpeng Li; Changman Lee; Chao Yu; linux-f2fs-de...@lists.sourceforge.net;
> linux-fsde...@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v3] f2fs: add fast symlink support
> 
> Hi Jaegeuk,
> On Wed, Mar 18, 2015 at 11:05:28AM -0700, Jaegeuk Kim wrote:
> >Hi,
> >
> >On Wed, Mar 18, 2015 at 04:58:52PM +0800, Wanpeng Li wrote:
> >> Hi Jaegeuk,
> >> On Tue, Mar 17, 2015 at 10:21:27AM -0700, Jaegeuk Kim wrote:
> >> >> -   err = page_symlink(inode, symname, symlen);
> >> >> +
> >> >> +   if (symlen > MAX_FAST_SYMLINK_SIZE) {
> >> >> +   /* slow symlink */
> >> >> +   inode->i_op = _symlink_inode_operations;
> >> >> +   inode->i_mapping->a_ops = _dblock_aops;
> >> >> +   err = page_symlink(inode, symname, symlen);
> >> >> +   } else {
> >> >> +   /* fast symlink */
> >> >> +   struct page *node_page;
> >> >> +
> >> >> +   inode->i_op = _fast_symlink_inode_operations;
> >> >> +   node_page = get_node_page(sbi, inode->i_ino);
> >> >> +   memcpy((char *)_INODE(node_page)->i_addr, symname, 
> >> >> symlen);
> >> >
> >> >This is mostly likewise the inline_data flow.
> >> >As of now, I can't recommend using any i_addr region, since we need to 
> >> >handle
> >> >many cases such as truncation, roll-forward recovery, and fsck/dump tools.
> >> >
> >> >It is more sensible to enable inline_data by default, isn't it?
> >>
> >> Do you mean to replace the codes above by something like
> >> f2fs_write_inline_data()?
> >
> >I meant the mount option, inline_data.
> >Currently, f2fs doesn't set that option at mount time, but I thought that we
> >can set it by default since it becomes stable.
> 
> So I think you mean my codes should memcpy i_addr[1~872] instead of 
> i_addr[0~872], right?

I think what Jaegeuk means is that we can use inline_data in f2fs by default 
with
patch like below firstly:

>From a7320bfe94239ea4ceb193621a3a1a4d11a40d07 Mon Sep 17 00:00:00 2001
From: Chao Yu 
Date: Thu, 19 Mar 2015 10:02:08 +0800
Subject: [PATCH] f2fs: use inline_data by default

Use inline_data feature by default since it brings us better performance & space
utilization and now it is already stable.

Suggested-by: Jaegeuk Kim 
Signed-off-by: Chao Yu 
Signed-off-by: Wanpeng Li 
---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index fc6857f..8772d91 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -991,6 +991,7 @@ try_onemore:
sbi->active_logs = NR_CURSEG_TYPE;
 
set_opt(sbi, BG_GC);
+   set_opt(sbi, INLINE_DATA);
 
 #ifdef CONFIG_F2FS_FS_XATTR
set_opt(sbi, XATTR_USER);
-- 
2.3.1

Then we enable inline_data feature for symlink in f2fs_may_inline, after that
by default our symlink created has inline_data flag in it, we treat small size
symlink as an inline regular file, we can write its data page which is written
in page_symlink into inode page like normal inline data procedure.

Thanks,

> 
> Regards,
> Wanpeng Li
> 
> >
> >Thanks,
> >
> >>
> >> Regards,
> >> Wanpeng Li
> >>
> >> >
> >> >Thanks,
> >> >
> >> >> +   set_page_dirty(node_page);
> >> >> +   f2fs_put_page(node_page, 1);
> >> >> +   inode->i_size = symlen-1;
> >> >> +   set_inode_flag(F2FS_I(inode), FI_FAST_SYMLINK);
> >> >> +   mark_inode_dirty(inode);
> >> >> +   }
> >> >> alloc_nid_done(sbi, inode->i_ino);
> >> >>
> >> >> d_instantiate(dentry, inode);
> >> >> @@ -743,6 +774,20 @@ const struct inode_operations 
> >> >> f2fs_symlink_inode_operations = {
> >> >>  #endif
> >> >>  };
> >> >>
> >> >> +const struct inode_operations f2fs_fast_symlink_inode_operations = {
> >> >> +   .readlink   = generic_readlink,
> >> >> +   .follow_link= f2fs_follow_link,
> >> >> +   .put_link   = page_put_link,
> >> >> +   .getattr= f2fs_getattr,
> >> >> +   .setattr= f2fs_setattr,
> >> >> +#ifdef CONFIG_F2FS_FS_XATTR
> >> >> +   .setxattr   = generic_setxattr,
> >> >> +   .getxattr   = generic_getxattr,
> >> >> +   .listxattr  = f2fs_listxattr,
> >> >> +   .removexattr= generic_removexattr,
> >> >> +#endif
> >> >> +};
> >> >> +
> >> >>  const struct inode_operations f2fs_special_inode_operations = {
> >> >> .getattr= f2fs_getattr,
> >> >> .setattr= f2fs_setattr,
> >> >> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> >> >> index 35a9117..efe28a2b 100644
> >> >> --- a/fs/f2fs/node.c
> >> >> +++ b/fs/f2fs/node.c
> >> >> @@ -908,8 +908,9 @@ void remove_inode_page(struct inode *inode)
> >> >> }
> >> >>
> >> >> /* remove potential inline_data blocks */
> >> >> -   if (S_ISREG(inode->i_mode) || 

[PATCH] tracing: add trace event for memory-failure

2015-03-18 Thread Xie XiuQi
Memory-failure as the high level machine check handler, it's necessary
to report memory page recovery action result to user space by ftrace.

This patch add a event at ras group for memory-failure.

The output like below:
#  tracer: nop
# 
#  entries-in-buffer/entries-written: 2/2   #P:24
# 
#   _-=> irqs-off
#  / _=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
#TASK-PID   CPU#  TIMESTAMP  FUNCTION
#   | |   |      | |
   mce-inject-13150 [001]    277.019359: memory_failure_event: pfn 
0x19869: free buddy page recovery: Delayed

---
v1->v2:
 - Comment update
 - Just passing 'result' instead of 'action_name[result]',
   suggested by Steve. And hard coded there because trace-cmd
   and perf do not have a way to process enums.

Cc: Tony Luck 
Cc: Steven Rostedt 
Signed-off-by: Xie XiuQi 
---
 include/ras/ras_event.h | 38 ++
 mm/memory-failure.c |  3 +++
 2 files changed, 41 insertions(+)

diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index 79abb9c..ebb05f3 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -232,6 +232,44 @@ TRACE_EVENT(aer_event,
__print_flags(__entry->status, "|", aer_uncorrectable_errors))
 );
 
+/*
+ * memory-failure recovery action result event
+ *
+ * unsigned long pfn - Page Number of the corrupted page
+ * char * action - Recovery action for various type of pages
+ * int result   -  Action result
+ *
+ * NOTE: 'action' and 'result' are defined at mm/memory-failure.c
+ */
+TRACE_EVENT(memory_failure_event,
+   TP_PROTO(const unsigned long pfn,
+const char *action,
+const int result),
+
+   TP_ARGS(pfn, action, result),
+
+   TP_STRUCT__entry(
+   __field(unsigned long, pfn)
+   __string(action, action)
+   __field(int, result)
+   ),
+
+   TP_fast_assign(
+   __entry->pfn= pfn;
+   __assign_str(action, action);
+   __entry->result = result;
+   ),
+
+   TP_printk("pfn %#lx: %s page recovery: %s",
+   __entry->pfn,
+   __get_str(action),
+   __print_symbolic(__entry->result,
+   {0, "Ignored"},
+   {1, "Failed"},
+   {2, "Delayed"},
+   {3, "Recovered"})
+   )
+);
 #endif /* _TRACE_HW_EVENT_MC_H */
 
 /* This part must be outside protection */
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index feb803b..3a71668 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include "internal.h"
+#include 
 
 int sysctl_memory_failure_early_kill __read_mostly = 0;
 
@@ -844,6 +845,8 @@ static struct page_state {
  */
 static void action_result(unsigned long pfn, char *msg, int result)
 {
+   trace_memory_failure_event(pfn, msg, result);
+
pr_err("MCE %#lx: %s page recovery: %s\n",
pfn, msg, action_name[result]);
 }
-- 
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 v2 4/4] block: loop: support to submit I/O via kernel aio based

2015-03-18 Thread Ming Lei
On Thu, Mar 19, 2015 at 2:28 AM, Maxim Patlasov  wrote:
> On 01/13/2015 07:44 AM, Ming Lei wrote:
>>
>> Part of the patch is based on Dave's previous post.
>>
>> This patch submits I/O to fs via kernel aio, and we
>> can obtain following benefits:
>>
>> - double cache in both loop file system and backend file
>> gets avoided
>> - context switch decreased a lot, and finally CPU utilization
>> is decreased
>> - cached memory got decreased a lot
>>
>> One main side effect is that throughput is decreased when
>> accessing raw loop block(not by filesystem) with kernel aio.
>>
>> This patch has passed xfstests test(./check -g auto), and
>> both test and scratch devices are loop block, file system is ext4.
>>
>> Follows two fio tests' result:
>>
>> 1. fio test inside ext4 file system over loop block
>> 1) How to run
>> - linux kernel base: 3.19.0-rc3-next-20150108(loop-mq merged)
>> - loop over SSD image 1 in ext4
>> - linux psync, 16 jobs, size 200M, ext4 over loop block
>> - test result: IOPS from fio output
>>
>> 2) Throughput result:
>> -
>> test cases  |randread   |read   |randwrite  |write  |
>> -
>> base|16799  |59508  |31059  |58829
>> -
>> base+kernel aio |15480  |64453  |30187  |57222
>> -
>
>
> Ming, it's important to understand the overhead of aio_kernel_()
> implementation. So could you please add test results for raw SSD device to
> the table above next time (in v3 of your patches).

what aio_kernel_() does is to just call ->read_iter()/->write_iter(),
so it should not have introduced extra overload.

>From performance view, the effect is only from switching to
O_DIRECT. With O_DIRECT, double cache can be avoided,
meantime both page caches and CPU utilization can be decreased.

V3 need to rewrite against recent vfs's change(in -next already)
about splitting kiocb patches, and thanks to Christoph's patches,
aio_kernel_() can be implemented just inside loop and it may
become a bit simple.

>
> Jens, if you have some fast storage at hand, could you please measure IOPS
> for Ming's patches vs. raw block device -- to ensure that the patches do not
> impose too low limit on performance.
>
> Thanks,
> Maxim
--
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 v2 1/4] mtd: nand: add common DT init code

2015-03-18 Thread Brian Norris
These are already-documented common bindings for NAND chips. Let's
handle them in nand_base.

If NAND controller drivers need to act on this data before bringing up
the NAND chip (e.g., fill out ECC callback functions, change HW modes,
etc.), then they can do so between calling nand_scan_ident() and
nand_scan_tail().

Signed-off-by: Brian Norris 
---
 drivers/mtd/nand/nand_base.c | 41 +
 include/linux/mtd/nand.h |  5 +
 2 files changed, 46 insertions(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d4cec2f8a016..692142da62e7 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Define default oob placement schemes for large and small page devices */
 static struct nand_ecclayout nand_oob_8 = {
@@ -3779,6 +3780,39 @@ ident_done:
return type;
 }
 
+static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip,
+   struct device_node *dn)
+{
+   int ecc_mode, ecc_strength, ecc_step;
+
+   if (of_get_nand_bus_width(dn) == 16)
+   chip->options |= NAND_BUSWIDTH_16;
+
+   if (of_get_nand_on_flash_bbt(dn))
+   chip->bbt_options |= NAND_BBT_USE_FLASH;
+
+   ecc_mode = of_get_nand_ecc_mode(dn);
+   ecc_strength = of_get_nand_ecc_strength(dn);
+   ecc_step = of_get_nand_ecc_step_size(dn);
+
+   if ((ecc_step >= 0 && !(ecc_strength >= 0)) ||
+   (!(ecc_step >= 0) && ecc_strength >= 0)) {
+   pr_err("must set both strength and step size in DT\n");
+   return -EINVAL;
+   }
+
+   if (ecc_mode >= 0)
+   chip->ecc.mode = ecc_mode;
+
+   if (ecc_strength >= 0)
+   chip->ecc.strength = ecc_strength;
+
+   if (ecc_step > 0)
+   chip->ecc.size = ecc_step;
+
+   return 0;
+}
+
 /**
  * nand_scan_ident - [NAND Interface] Scan for the NAND device
  * @mtd: MTD device structure
@@ -3796,6 +3830,13 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
int i, nand_maf_id, nand_dev_id;
struct nand_chip *chip = mtd->priv;
struct nand_flash_dev *type;
+   int ret;
+
+   if (chip->dn) {
+   ret = nand_dt_init(mtd, chip, chip->dn);
+   if (ret)
+   return ret;
+   }
 
/* Set the default functions */
nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16);
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 3d4ea7eb2b68..e0f40e12a2c8 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -26,6 +26,8 @@
 
 struct mtd_info;
 struct nand_flash_dev;
+struct device_node;
+
 /* Scan and identify a NAND device */
 extern int nand_scan(struct mtd_info *mtd, int max_chips);
 /*
@@ -542,6 +544,7 @@ struct nand_buffers {
  * flash device
  * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the
  * flash device.
+ * @dn:[BOARDSPECIFIC] device node describing this 
instance
  * @read_byte: [REPLACEABLE] read one byte from the chip
  * @read_word: [REPLACEABLE] read one word from the chip
  * @write_byte:[REPLACEABLE] write a single byte to the chip 
on the
@@ -644,6 +647,8 @@ struct nand_chip {
void __iomem *IO_ADDR_R;
void __iomem *IO_ADDR_W;
 
+   struct device_node *dn;
+
uint8_t (*read_byte)(struct mtd_info *mtd);
u16 (*read_word)(struct mtd_info *mtd);
void (*write_byte)(struct mtd_info *mtd, uint8_t byte);
-- 
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 v2 3/4] mtd: nand: add NAND driver for Broadcom STB NAND controller

2015-03-18 Thread Brian Norris
This core originated in Set-Top Box chips (BCM7xxx) but is used in a
variety of other Broadcom chips, including some BCM63xxx, BCM33xx, and
iProc/Cygnus. It's been used only on ARM and MIPS SoCs, so restrict it
to those architectures.

There are multiple revisions of this core throughout the years, and
almost every version broke register compatibility in some small way, but
with some effort, this driver is able to support v4.0, v5.0, v6.x, v7.0,
and v7.1. It's been tested on v5.0, v6.0, v7.0, and v7.1 recently, so
there hopefully are no more lurking inconsistencies.

Signed-off-by: Brian Norris 
---
 drivers/mtd/nand/Kconfig|8 +
 drivers/mtd/nand/Makefile   |1 +
 drivers/mtd/nand/brcmstb_nand.c | 2196 +++
 3 files changed, 2205 insertions(+)
 create mode 100644 drivers/mtd/nand/brcmstb_nand.c

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 5b76a173cd95..6445323a8cff 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -394,6 +394,14 @@ config MTD_NAND_GPMI_NAND
 block, such as SD card. So pay attention to it when you enable
 the GPMI.
 
+config MTD_NAND_BRCMSTB
+   tristate "Broadcom STB NAND controller"
+   depends on ARM || MIPS
+   help
+ Enables the Broadcom NAND controller driver. The controller was
+ originally designed for Set-Top Box but is used on various BCM7xxx,
+ BCM3xxx, BCM63xxx, iProc/Cygnus and more.
+
 config MTD_NAND_BCM47XXNFLASH
tristate "Support for NAND flash on BCM4706 BCMA bus"
depends on BCMA_NFLASH
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 582bbd05aff7..3b1adddc83dd 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -52,5 +52,6 @@ obj-$(CONFIG_MTD_NAND_XWAY)   += xway_nand.o
 obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)   += bcm47xxnflash/
 obj-$(CONFIG_MTD_NAND_SUNXI)   += sunxi_nand.o
 obj-$(CONFIG_MTD_NAND_HISI504) += hisi504_nand.o
+obj-$(CONFIG_MTD_NAND_BRCMSTB) += brcmstb_nand.o
 
 nand-objs := nand_base.o nand_bbt.o nand_timings.o
diff --git a/drivers/mtd/nand/brcmstb_nand.c b/drivers/mtd/nand/brcmstb_nand.c
new file mode 100644
index ..da63515f763f
--- /dev/null
+++ b/drivers/mtd/nand/brcmstb_nand.c
@@ -0,0 +1,2196 @@
+/*
+ * Copyright © 2010-2015 Broadcom Corporation
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * This flag controls if WP stays on between erase/write commands to mitigate
+ * flash corruption due to power glitches. Values:
+ * 0: NAND_WP is not used or not available
+ * 1: NAND_WP is set by default, cleared for erase/write operations
+ * 2: NAND_WP is always cleared
+ */
+static int wp_on = 1;
+module_param(wp_on, int, 0444);
+
+/***
+ * Definitions
+ ***/
+
+#define DRV_NAME   "brcmstb_nand"
+
+#define CMD_NULL   0x00
+#define CMD_PAGE_READ  0x01
+#define CMD_SPARE_AREA_READ0x02
+#define CMD_STATUS_READ0x03
+#define CMD_PROGRAM_PAGE   0x04
+#define CMD_PROGRAM_SPARE_AREA 0x05
+#define CMD_COPY_BACK  0x06
+#define CMD_DEVICE_ID_READ 0x07
+#define CMD_BLOCK_ERASE0x08
+#define CMD_FLASH_RESET0x09
+#define CMD_BLOCKS_LOCK0x0a
+#define CMD_BLOCKS_LOCK_DOWN   0x0b
+#define CMD_BLOCKS_UNLOCK  0x0c
+#define CMD_READ_BLOCKS_LOCK_STATUS0x0d
+#define CMD_PARAMETER_READ 0x0e
+#define CMD_PARAMETER_CHANGE_COL   0x0f
+#define CMD_LOW_LEVEL_OP   0x10
+
+struct brcm_nand_dma_desc {
+   u32 next_desc;
+   u32 next_desc_ext;
+   u32 cmd_irq;
+   u32 dram_addr;
+   u32 dram_addr_ext;
+   u32 tfr_len;
+   u32 total_len;
+   u32 flash_addr;
+   u32 flash_addr_ext;
+   u32 cs;
+   u32 pad2[5];
+   u32 status_valid;
+} __packed;
+
+/* Bitfields for brcm_nand_dma_desc::status_valid */
+#define FLASH_DMA_ECC_ERROR(1 << 8)
+#define FLASH_DMA_CORR_ERROR   (1 << 9)
+
+/* 512B flash cache in the NAND 

[PATCH v2 2/4] Documentation: devicetree: add binding doc for Broadcom NAND controller

2015-03-18 Thread Brian Norris
Signed-off-by: Brian Norris 
---
 .../devicetree/bindings/mtd/brcm,brcmstb-nand.txt  | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/brcm,brcmstb-nand.txt

diff --git a/Documentation/devicetree/bindings/mtd/brcm,brcmstb-nand.txt 
b/Documentation/devicetree/bindings/mtd/brcm,brcmstb-nand.txt
new file mode 100644
index ..933d44943cbb
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/brcm,brcmstb-nand.txt
@@ -0,0 +1,109 @@
+* Broadcom STB NAND Controller
+
+The Broadcom Set-Top Box NAND controller supports low-level access to raw NAND
+flash chips. It has a memory-mapped register interface for both control
+registers and for its data input/output buffer. On some SoCs, this controller 
is
+paired with a custom DMA engine (inventively named "Flash DMA") which supports
+basic PROGRAM and READ functions, among other features.
+
+This controller was originally designed for STB SoCs (BCM7xxx) but is now
+available on a variety of Broadcom SoCs, including some BCM3xxx, BCM63xx, and
+iProc/Cygnus. Its history includes several similar (but not fully register
+compatible) versions.
+
+Required properties:
+- compatible   : should contain "brcm,brcmnand" and an appropriate version
+  compatibility string, like "brcm,brcmnand-v7.0"
+  Possible values:
+ brcm,brcmnand-v4.0
+ brcm,brcmnand-v5.0
+ brcm,brcmnand-v6.0
+ brcm,brcmnand-v7.0
+ brcm,brcmnand-v7.1
+ brcm,brcmnand
+- reg  : the register start and length for NAND register region.
+ (optional) Flash DMA register range (if present)
+ (optional) NAND flash cache range (if at non-standard 
offset)
+- reg-names: a list of the names corresponding to the previous register
+ ranges. Should contain "nand" and (optionally)
+ "flash-dma" and/or "nand-cache".
+- interrupts   : The NAND CTLRDY interrupt and (if Flash DMA is available)
+ FLASH_DMA_DONE
+- interrupt-names  : May be "nand_ctlrdy" or "flash_dma_done"
+- interrupt-parent : See standard interrupt bindings
+- #address-cells   : <1> - subnodes give the chip-select number
+- #size-cells  : <0>
+
+Optional properties:
+- brcm,nand-has-wp  : Some versions of this IP include a write-protect
+  (WP) control bit. It is always available on >=
+  v7.0. Use this property to describe the rare
+  earlier versions of this core that include WP
+
+* NAND chip-select
+
+Each controller (compatible: "brcm,brcmnand") may contain one or more subnodes
+to represent enabled chip-selects which (may) contain NAND flash chips. Their
+properties are as follows.
+
+Required properties:
+- compatible: should contain "brcm,nandcs"
+- reg   : a single integer representing the chip-select
+  number (e.g., 0, 1, 2, etc.)
+- #address-cells: see partition.txt
+- #size-cells   : see partition.txt
+- nand-ecc-strength : see nand.txt
+- nand-ecc-step-size: must be 512 or 1024. See nand.txt
+
+Optional properties:
+- nand-on-flash-bbt : boolean, to enable the on-flash BBT for this
+  chip-select. See nand.txt
+- brcm,nand-oob-sector-size : integer, to denote the spare area sector size
+  expected for the ECC layout in use. This size, in
+  addition to the strength and step-size,
+  determines how the hardware BCH engine will lay
+  out the parity bytes it stores on the flash.
+  This property can be automatically determined by
+  the flash geometry (particularly the NAND page
+  and OOB size) in many cases, but when booting
+  from NAND, the boot controller has only a limited
+  number of available options for its default ECC
+  layout.
+
+Each nandcs device node may optionally contain sub-nodes describing the flash
+partition mapping. See partition.txt for more detail.
+
+Example:
+
+nand@f0442800 {
+   compatible = "brcm,brcmnand-v7.0", "brcm,brcmnand";
+   reg = <0xF0442800 0x600>,
+ <0xF0443000 0x100>;
+   reg-names = "nand", "flash-dma";
+   interrupt-parent = <_intr2_intc>;
+   interrupts = <24>, <4>;
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   nandcs@1 {
+   compatible = "brcm,nandcs";
+   reg = <1>; // Chip select 1
+   nand-on-flash-bbt;
+ 

[PATCH v2 0/4] mtd: nand: add Broadcom NAND controller support

2015-03-18 Thread Brian Norris
Hi,

This is version 2 of the (long in coming) support for the Broadcom BCM7xxx
Set-Top Box NAND controller. This controller has been used in a variety of
Broadcom SoCs.

There are a few more features I'd like add in the near future, mostly to
support more SoCs, but this is the base set, which should only need relatively
minor additions to support chips like BCM63138, BCM3384, and Cygnus/iProc.
Particularly, we may need to straighten out some endianness issues for the data
path on iProc, and interrupt enabling/acking on iProc, BCM63xxx, BCM3xxx, and
others.

I think I've addressed everybody's comments, but the delta changelog is:

v1 -> v2:
 * add NAND to DTS for BCM7445 / BCM97445SVMB
 * rename DT binding file to have 'brcm,' prefix
 * catch DMA mapping errors
 * fixup timeout / error messages (hex, remove misleading info)
 * MODULE_LICENSE("GPL v2")
 * fix incorrect comments
 * print why we fail, when checking for supported controller revisions
 * disable prefetch when using Flash DMA (see FIXME); will re-enable once we
   get a good erased-page verification scheme merged

To be clear: this does NOT yet handle some of the per-SoC quirks required for
BCM53xxx/BCM4708 and Cygnus/iProc. Those patches are still WIP, and I want to
keep this patch series going while the Cygnus guys are straightening this out.

Happy reviewing!

Brian

Brian Norris (4):
  mtd: nand: add common DT init code
  Documentation: devicetree: add binding doc for Broadcom NAND
controller
  mtd: nand: add NAND driver for Broadcom STB NAND controller
  ARM: bcm7445: add NAND to DTS

 .../devicetree/bindings/mtd/brcm,brcmstb-nand.txt  |  109 +
 arch/arm/boot/dts/bcm7445-bcm97445svmb.dts |   23 +
 arch/arm/boot/dts/bcm7445.dtsi |   22 +
 drivers/mtd/nand/Kconfig   |8 +
 drivers/mtd/nand/Makefile  |1 +
 drivers/mtd/nand/brcmstb_nand.c| 2196 
 drivers/mtd/nand/nand_base.c   |   41 +
 include/linux/mtd/nand.h   |5 +
 8 files changed, 2405 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/brcm,brcmstb-nand.txt
 create mode 100644 drivers/mtd/nand/brcmstb_nand.c

-- 
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 v2 4/4] ARM: bcm7445: add NAND to DTS

2015-03-18 Thread Brian Norris
Signed-off-by: Brian Norris 
---
Light dependency on:
  http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/331921.html
for the surrounding text.

 arch/arm/boot/dts/bcm7445-bcm97445svmb.dts | 23 +++
 arch/arm/boot/dts/bcm7445.dtsi | 22 ++
 2 files changed, 45 insertions(+)

diff --git a/arch/arm/boot/dts/bcm7445-bcm97445svmb.dts 
b/arch/arm/boot/dts/bcm7445-bcm97445svmb.dts
index 9eec2ac1112f..0bb8d17e4c2d 100644
--- a/arch/arm/boot/dts/bcm7445-bcm97445svmb.dts
+++ b/arch/arm/boot/dts/bcm7445-bcm97445svmb.dts
@@ -12,3 +12,26 @@
  <0x00 0x8000 0x00 0x4000>;
};
 };
+
+ {
+   status = "okay";
+
+   nandcs@1 {
+   compatible = "brcm,nandcs";
+   reg = <1>;
+   nand-ecc-step-size = <512>;
+   nand-ecc-strength = <8>;
+   nand-on-flash-bbt;
+
+   #size-cells = <2>;
+   #address-cells = <2>;
+
+   flash1.rootfs0@0 {
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   flash1.rootfs1@8000 {
+   reg = <0x0 0x8000 0x0 0x8000>;
+   };
+   };
+};
diff --git a/arch/arm/boot/dts/bcm7445.dtsi b/arch/arm/boot/dts/bcm7445.dtsi
index 9eaeac8dce1b..c148dcf8c69b 100644
--- a/arch/arm/boot/dts/bcm7445.dtsi
+++ b/arch/arm/boot/dts/bcm7445.dtsi
@@ -108,6 +108,28 @@
brcm,int-map-mask = <0x25c>, <0x700>;
brcm,int-fwd-mask = <0x7>;
};
+
+   hif_intr2_intc: interrupt-controller@3e1000 {
+   compatible = "brcm,l2-intc";
+   reg = <0x3e1000 0x30>;
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   interrupts = <0x0 0x20 0x0>;
+   interrupt-parent = <>;
+   interrupt-names = "hif";
+   };
+
+   nand: nand@3e2800 {
+   status = "disabled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "brcm,brcmnand-v7.1", "brcm,brcmnand";
+   reg-names = "nand", "flash-dma";
+   reg = <0x3e2800 0x600>, <0x3e3000 0x2c>;
+   interrupt-parent = <_intr2_intc>;
+   interrupts = <24>, <4>;
+   interrupt-names = "nand_ctlrdy", "flash_dma_done";
+   };
};
 
smpboot {
-- 
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 1/2] time: Fix a bug in timekeeping_suspend() with no persistent clock

2015-03-18 Thread Xunlei Pang
From: Xunlei Pang 

When there's no persistent clock, normally timekeeping_suspend_time
should always be zero, but this can break in timekeeping_suspend().

At T1, there was a system suspend, so old_delta was assigned T1.
After some time, one time adjustment happened, and xtime got the
value of T1-dt(0s
---
 kernel/time/timekeeping.c | 36 +++-
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 1345e63..605da5c 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1127,7 +1127,7 @@ void __init timekeeping_init(void)
raw_spin_unlock_irqrestore(_lock, flags);
 }
 
-/* time in seconds when suspend began */
+/* time in seconds when suspend began for persistent clock */
 static struct timespec64 timekeeping_suspend_time;
 
 /**
@@ -1304,24 +1304,26 @@ int timekeeping_suspend(void)
timekeeping_forward_now(tk);
timekeeping_suspended = 1;
 
-   /*
-* To avoid drift caused by repeated suspend/resumes,
-* which each can add ~1 second drift error,
-* try to compensate so the difference in system time
-* and persistent_clock time stays close to constant.
-*/
-   delta = timespec64_sub(tk_xtime(tk), timekeeping_suspend_time);
-   delta_delta = timespec64_sub(delta, old_delta);
-   if (abs(delta_delta.tv_sec)  >= 2) {
+   if (has_persistent_clock()) {
/*
-* if delta_delta is too large, assume time correction
-* has occured and set old_delta to the current delta.
+* To avoid drift caused by repeated suspend/resumes,
+* which each can add ~1 second drift error,
+* try to compensate so the difference in system time
+* and persistent_clock time stays close to constant.
 */
-   old_delta = delta;
-   } else {
-   /* Otherwise try to adjust old_system to compensate */
-   timekeeping_suspend_time =
-   timespec64_add(timekeeping_suspend_time, delta_delta);
+   delta = timespec64_sub(tk_xtime(tk), timekeeping_suspend_time);
+   delta_delta = timespec64_sub(delta, old_delta);
+   if (abs(delta_delta.tv_sec) >= 2) {
+   /*
+* if delta_delta is too large, assume time correction
+* has occurred and set old_delta to the current delta.
+*/
+   old_delta = delta;
+   } else {
+   /* Otherwise try to adjust old_system to compensate */
+   timekeeping_suspend_time =
+   timespec64_add(timekeeping_suspend_time, 
delta_delta);
+   }
}
 
timekeeping_update(tk, TK_MIRROR);
-- 
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 2/2] time: rtc: Don't bother into rtc_resume() for the nonstop clocksource

2015-03-18 Thread Xunlei Pang
From: Xunlei Pang 

If a system does not provide a persistent_clock(), the time
will be updated on resume by rtc_resume(). With the addition
of the non-stop clocksources for suspend timing, those systems
set the time on resume in timekeeping_resume(), but may not
provide a valid persistent_clock().

This results in the rtc_resume() logic thinking no one has set
the time and it then will over-write the suspend time again,
which is not necessary and only increases clock error.

So, fix this for rtc_resume().

This patch also improves the name of persistent_clock_exist to
make it more grammatical.

Signed-off-by: Xunlei Pang 
---
 drivers/rtc/class.c |  4 +--
 include/linux/timekeeping.h |  9 ++
 kernel/time/timekeeping.c   | 68 +
 3 files changed, 55 insertions(+), 26 deletions(-)

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index d40760a..c29ba7e 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -55,7 +55,7 @@ static int rtc_suspend(struct device *dev)
struct timespec64   delta, delta_delta;
int err;
 
-   if (has_persistent_clock())
+   if (timekeeping_rtc_skipsuspend())
return 0;
 
if (strcmp(dev_name(>dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0)
@@ -102,7 +102,7 @@ static int rtc_resume(struct device *dev)
struct timespec64   sleep_time;
int err;
 
-   if (has_persistent_clock())
+   if (timekeeping_rtc_skipresume())
return 0;
 
rtc_hctosys_ret = -ENODEV;
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 3eaae47..7cbd518 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -242,6 +242,9 @@ static inline void timekeeping_clocktai(struct timespec *ts)
 /*
  * RTC specific
  */
+extern bool timekeeping_rtc_skipsuspend(void);
+extern bool timekeeping_rtc_skipresume(void);
+
 extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);
 
 /*
@@ -253,14 +256,8 @@ extern void getnstime_raw_and_real(struct timespec *ts_raw,
 /*
  * Persistent clock related interfaces
  */
-extern bool persistent_clock_exist;
 extern int persistent_clock_is_local;
 
-static inline bool has_persistent_clock(void)
-{
-   return persistent_clock_exist;
-}
-
 extern void read_persistent_clock(struct timespec *ts);
 extern void read_boot_clock(struct timespec *ts);
 extern int update_persistent_clock(struct timespec now);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 605da5c..28509a7 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -63,9 +63,6 @@ static struct tk_fast tk_fast_mono cacheline_aligned;
 /* flag for if timekeeping is suspended */
 int __read_mostly timekeeping_suspended;
 
-/* Flag for if there is a persistent clock on this platform */
-bool __read_mostly persistent_clock_exist = false;
-
 static inline void tk_normalize_xtime(struct timekeeper *tk)
 {
while (tk->tkr.xtime_nsec >= ((u64)NSEC_PER_SEC << tk->tkr.shift)) {
@@ -1072,6 +1069,12 @@ void __weak read_boot_clock(struct timespec *ts)
ts->tv_nsec = 0;
 }
 
+/* Flag for if timekeeping_resume() has injected sleeptime */
+static bool sleeptime_injected;
+
+/* Flag for if there is a persistent clock on this platform */
+static bool persistent_clock_exists;
+
 /*
  * timekeeping_init - Initializes the clocksource and common timekeeping values
  */
@@ -1091,7 +1094,7 @@ void __init timekeeping_init(void)
now.tv_sec = 0;
now.tv_nsec = 0;
} else if (now.tv_sec || now.tv_nsec)
-   persistent_clock_exist = true;
+   persistent_clock_exists = true;
 
read_boot_clock();
boot = timespec_to_timespec64(ts);
@@ -1154,11 +1157,47 @@ static void __timekeeping_inject_sleeptime(struct 
timekeeper *tk,
 
 #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_RTC_HCTOSYS_DEVICE)
 /**
+ * We have three kinds of time sources to use for sleep time
+ * injection, the preference order is:
+ * 1) non-stop clocksource
+ * 2) persistent clock (ie: RTC accessible when irqs are off)
+ * 3) RTC
+ *
+ * 1) and 2) are used by timekeeping, 3) by RTC subsystem.
+ * If system has neither 1) nor 2), 3) will be used finally.
+ *
+ *
+ * If timekeeping has injected sleeptime via either 1) or 2),
+ * 3) becomes needless, so in this case we don't need to call
+ * rtc_resume(), and this is what timekeeping_rtc_skipresume()
+ * means.
+ */
+bool timekeeping_rtc_skipresume(void)
+{
+   return sleeptime_injected;
+}
+
+/**
+ * 1) can be determined whether to use or not only when doing
+ * timekeeping_resume() which is invoked after rtc_suspend(),
+ * so we can't skip rtc_suspend() surely if system has 1).
+ *
+ * But if system has 2), 2) will definitely be used, so in this
+ * case we don't need to call rtc_suspend(), and this is what
+ * timekeeping_rtc_skipsuspend() means.
+ */
+bool timekeeping_rtc_skipsuspend(void)
+{
+ 

Re: [RFC][PATCH 1/9] usb: hcd: Introduce usb_start/stop_hcd()

2015-03-18 Thread Tony Lindgren
* Alan Stern  [150318 18:51]:
> On Wed, 18 Mar 2015, Tony Lindgren wrote:
> 
> > > If the host controller is started more than once, you will end up
> > > unregistering and re-registering the root hub.  The device core does
> > > not allow this.  Once a device has been unregistered, you must not try
> > > to register it again -- you have to allocate a new device and register
> > > it instead.
> > > 
> > > Also, although you call the driver's ->start method multiple times, the
> > > ->reset method is called only once, when the controller is first 
> > > probed.  It's not clear that this will work in a situation where the HC 
> > > and the UDC share hardware state; after the UDC is stopped it may be 
> > > necessary to reset the HC before it can run again.
> > > 
> > > It might be possible to make this work, but I suspect quite a few 
> > > drivers would need rewriting first.  As another example of the problems 
> > > you face, consider how stopping a host controller will interact with 
> > > the driver's PM support (both system suspend and runtime suspend).
> > > 
> > > It would be a lot simpler to unbind the host controller driver
> > > completely when switching to device mode and rebind it when switching
> > > back.  I guess that is the sort of heavy-duty approach you want to
> > > avoid, but it may be the only practical way forward.
> > 
> > Hmm from memory I think the OTG spec assumes the USB devices are
> > suspended when attempting the role change? I could be totally wrong,
> > it's been a really long time since I've looked at the OTG spec, but
> > maybe that would make it easier to deal with thing?
> 
> This patch deals with the host side, not the device side.  The fact
> that the device is suspended is not relevant to the issues above.

OK, got it.
 
> Besides, the problems I outlined are more connected with the way 
> Linux's host-side USB stack is organized, and not so much with the 
> details of the OTG spec.

Yes thanks for the explanation.

Regards,

Tony
--
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] Revert "net: cx82310_eth: use common match macro"

2015-03-18 Thread David Miller
From: Ondrej Zary 
Date: Wed, 18 Mar 2015 23:01:01 +0100

> This reverts commit 11ad714b98f6d9ca0067568442afe3e70eb94845 because
> it breaks cx82310_eth.
> 
> The custom USB_DEVICE_CLASS macro matches
> bDeviceClass, bDeviceSubClass and bDeviceProtocol
> but the common USB_DEVICE_AND_INTERFACE_INFO matches
> bInterfaceClass, bInterfaceSubClass and bInterfaceProtocol instead, which are
> not specified.
> 
> Signed-off-by: Ondrej Zary 

Applied, thank you.

--
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: Linux Kernel Scheduling Addition Notification : Hybrid Sleepers and Unfair scheduling

2015-03-18 Thread Mike Galbraith
On Wed, 2015-03-18 at 16:25 -0700, Mitchell Erblich wrote:

> 
> SCHED_IA
>   Over 10 years ago, System V Release 4 was enhanced with additional
> features by Sun Microsystems. One of the more minor extensions dealt
> with the subdivision of process’s scheduling characteristics and was
> known as he INTERACTIVE /IA scheduling class. This scheduling class
> was targeted to frequent sleepers, with the mouse icon being one the
> first processes/tasks..
> 
>   Linux has no explicit SCHED_IA scheduling policy, but does alter
> scheduling characteristics based on some sleep behavior (example:
> GENTLE_FAIR_SLEEPERS) within the fair share scheduling configuration
> option.

That's about fairness, it levels the playing field sleepers vs hogs.

>  Processes / tasks that are CPU bound that fit into a SLEEPER behavior
> can have a hybrid behavior over time where during any one scheduling
> period, it may consume its variable length allocated time. This can
> alter its expected short latency to be current / ONPROC. To simplify
> the implementation, it is suggested that SCHED_IA be a sub scheduling
> policy of SCHED_NORMAL. Shouldn’t an administrator be able to classify
> that the NORMAL long term behavior of a task, be one as a FIXED
> sleeper?

Nope, we definitely don't want a SCHED_IA class.

Your box can't tell if you're interacting or not even if you explicitly
define something as 'interactive'.  If I stare in fascination at an
eye-candy screen-saver, it becomes 'interactive'.  If I'm twiddling my
thumbs waiting for a kbuild whatever other CPU intensive job to finish,
that job becomes the 'interactive' thing of import.  The last thing I
want is to have to squabble with every crack-head programmer on the
planet who thinks his/her cool app should get special treatment.

You can't get there from here.
> 
>   Thus, the first Proposal is to explicitly support the SCHED_IA
> scheduling policy within the Linux kernel. After kernel support, any
> application that has the same functionality as priocntl(1) then needs
> to be altered to support this new scheduling policy.
> 
> 
> Note: Administrator in this context should be a task with a UID, EUID,
> GID, EGID, etc, that has the proper CAPABILITY to alter scheduling
> behavior.

> 
> SCHED_UNFAIR

Snip.. we already have truckloads of bandwidth control.

-Mike

--
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 00/19] dwc3: add USB OTG role switch support

2015-03-18 Thread Chanwoo Choi
Hi Robert,

Did you test the extcon-odroid-otg driver on Odroid-U3?

Thanks,
Chanwoo Choi

On 03/18/2015 11:04 PM, Robert Baldyga wrote:
> Hello,
> 
> This patchset introduces OTG feature in DWC3 DRD driver. This allows
> to change dynamically between host and peripheral mode depending on
> detected USB cable type.
> 
> DWC3 driver behaviour is changed only in situation when selected operation
> mode (dr_mode) is "otg", and hardware OTG support is available or extended
> OTG operations are supplied for given platform.
> 
> It such conditions are fulfilled, none of modes is enabled by default
> and dwc3 core Best regards,
> Robert Baldygais being uninitialized. After USB cable detection relevant
> mode is selected and dwc3 core is initialized. Cable disconnection causes
> deinitialization of dwc3 core.
> 
> File otg.c is inspired by code of DWC3 driver from Hardkernel linux
> sources [1]. I have never tested it on DWC3 version equipped with hardware
> OTG support, but I belive that this code have chance to work or at least
> it's easy to fix. I have tested this on OdroidXU3 board which has USB
> cable detection mechanism based on two gpio pins. I used extcon driver
> for those feature, which is also attached to following patchset.
> 
> I consider if ext_otg_ops it the right solution. Current solution is
> based on Hardkernel sources, but it's very likely that adding extcon
> support directly to otg.c would be generic enough, as most of cable
> detection mechanisms can be simply represented by extcon devices.
> 
> Thanks in advance for your comments.
> 
> Best regards,
> Robert Baldyga
> 
> [1] https://github.com/hardkernel/linux
> 
> Robert Baldyga (19):
>   extcon: add extcon-odroid-usbotg driver
>   dt-bindings: extcon: Add doc for extcon-odroid-usbotg
>   ARM: dts: exynos5422-odroidxu3: add odroid-usbotg extcon support
>   dwc3: gadget: add VBUS session handling
>   dwc3: gadget: enable/disable ep0 in dwc3_gadget_run_stop()
>   dwc3: gadget: check returned value in suspend/resume
>   dwc3: core: cleanup suspend/resume code
>   dwc3: core: handle event buffers in core_init/exit
>   dwc3: core: make dwc3_core_init/exit non-static
>   dwc3: add missing OTG register definitions
>   dwc3: add OTG handling code
>   dwc3: otg: add ext_otg_ops support
>   dwc3: gadget: register gadget in OTG core
>   dwc3: host: don't add XHCI device only if in OTG mode
>   dwc3: core: initialize OTG in DWC3 core
>   dwc3: exynos: add software role switching code
>   ARM: dts: exynos5420: set usb3_lpm_capable in dwc3 controllers
>   ARM: dts: exynos5420: add snps,dis_u3_susphy_quirk to dwc3 controllers
>   ARM: dts: exynos5422-odroidxu3: make usbdrd3 extcon client
> 
>  .../bindings/extcon/extcon-odroid-usbotg.txt   |  16 +
>  .../devicetree/bindings/usb/exynos-usb.txt |   4 +
>  arch/arm/boot/dts/exynos5420.dtsi  |   6 +
>  arch/arm/boot/dts/exynos5422-odroidxu3.dts |  24 +
>  drivers/extcon/Kconfig |   4 +
>  drivers/extcon/Makefile|   1 +
>  drivers/extcon/extcon-odroid-usbotg.c  | 257 +
>  drivers/usb/dwc3/Kconfig   |   1 +
>  drivers/usb/dwc3/Makefile  |   4 +
>  drivers/usb/dwc3/core.c|  66 ++-
>  drivers/usb/dwc3/core.h|  22 +
>  drivers/usb/dwc3/dwc3-exynos.c | 162 ++
>  drivers/usb/dwc3/gadget.c  | 106 ++--
>  drivers/usb/dwc3/host.c|  10 +-
>  drivers/usb/dwc3/otg.c | 577 
> +
>  drivers/usb/dwc3/otg.h | 113 
>  16 files changed, 1320 insertions(+), 53 deletions(-)
>  create mode 100644 
> Documentation/devicetree/bindings/extcon/extcon-odroid-usbotg.txt
>  create mode 100644 drivers/extcon/extcon-odroid-usbotg.c
>  create mode 100644 drivers/usb/dwc3/otg.c
>  create mode 100644 drivers/usb/dwc3/otg.h
> 

--
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 v10 08/21] ARM64 / ACPI: Introduce early_param "acpi=" to enable/disable ACPI

2015-03-18 Thread Hanjun Guo
On 2015/3/19 4:07, Ard Biesheuvel wrote:
> On 18 March 2015 at 12:35, Lorenzo Pieralisi  
> wrote:
>> On Wed, Mar 11, 2015 at 12:39:34PM +, Hanjun Guo wrote:
>>> From: Al Stone 
>>>
>>> This implements the following policy to decide whether ACPI should
>>> be used to boot the system:
>>> - acpi=off: ACPI will not be used to boot the system, even if there is
>>>   no alternative available (e.g., device tree is empty)
>>> - acpi=force: only ACPI will be used to boot the system; if that fails,
>>>   there will be no fallback to alternative methods (such as device tree)
>> I think this comment is stale. acpi=force enables ACPI and tries to
>> init the ACPI tables without even checking DT, but it does fall back to
>> DT if ACPI table init fails (by disabling ACPI and unflattening the
>> FDT).
>>
>> Am I wrong ?
>>
> No, you're right. But I would suggest that we fix the code, not the comment.

I agree. If user pass "acpi=force", I think it means ACPI only, so if
ACPI fails, we can just not going to boot the system.

>
> I think we are all in agreement on the policy, we only need to make
> disable_acpi() conditional on whether acpi_param_force is set

I prefer Catalin's suggestion, just not to unflatten the device tree,
what do you think?

If it is ok, I will add a fix patch on top of this patch set.

Thanks
Hanjun

>
>
>>> - otherwise, ACPI will be used as a fallback if the device tree turns out
>>>   to lack a platform description; the heuristic to decide this is whether
>>>   /chosen is the only node present at depth 1
>>>
>>> CC: Catalin Marinas 
>>> CC: Will Deacon 
>>> CC: Rafael J. Wysocki 
>>> Acked-by: Olof Johansson 
>>> Acked-by: Grant Likely 
>>> Tested-by: Timur Tabi 
>>> Signed-off-by: Al Stone 
>>> Signed-off-by: Graeme Gregory 
>>> Signed-off-by: Hanjun Guo 
>>> Signed-off-by: Ard Biesheuvel 
>>> ---
>>>  Documentation/kernel-parameters.txt |  3 ++-
>>>  arch/arm64/include/asm/acpi.h   |  7 +
>>>  arch/arm64/kernel/acpi.c| 52 
>>> +
>>>  3 files changed, 56 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/Documentation/kernel-parameters.txt 
>>> b/Documentation/kernel-parameters.txt
>>> index bfcb1a6..d6c35a7 100644
>>> --- a/Documentation/kernel-parameters.txt
>>> +++ b/Documentation/kernel-parameters.txt
>>> @@ -165,7 +165,7 @@ multipliers 'Kilo', 'Mega', and 'Giga', equalling 2^10, 
>>> 2^20, and 2^30
>>>  bytes respectively. Such letter suffixes can also be entirely omitted.
>>>
>>>
>>> - acpi=   [HW,ACPI,X86]
>>> + acpi=   [HW,ACPI,X86,ARM64]
>>>   Advanced Configuration and Power Interface
>>>   Format: { force | off | strict | noirq | rsdt }
>>>   force -- enable ACPI if default was off
>>> @@ -175,6 +175,7 @@ bytes respectively. Such letter suffixes can also be 
>>> entirely omitted.
>>>   strictly ACPI specification compliant.
>>>   rsdt -- prefer RSDT over (default) XSDT
>>>   copy_dsdt -- copy DSDT to memory
>>> + For ARM64, ONLY "acpi=off" or "acpi=force" are 
>>> available
>>>
>>>   See also Documentation/power/runtime_pm.txt, 
>>> pci=noacpi
>>>
>>> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
>>> index 40e0924..c5a9b97 100644
>>> --- a/arch/arm64/include/asm/acpi.h
>>> +++ b/arch/arm64/include/asm/acpi.h
>>> @@ -39,6 +39,13 @@ static inline void disable_acpi(void)
>>>   acpi_noirq = 1;
>>>  }
>>>
>>> +static inline void enable_acpi(void)
>>> +{
>>> + acpi_disabled = 0;
>>> + acpi_pci_disabled = 0;
>>> + acpi_noirq = 0;
>>> +}
>>> +
>>>  /*
>>>   * It's used from ACPI core in kdump to boot UP system with SMP kernel,
>>>   * with this check the ACPI core will not override the CPU index
>>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>>> index 7abac24..2269e30 100644
>>> --- a/arch/arm64/kernel/acpi.c
>>> +++ b/arch/arm64/kernel/acpi.c
>>> @@ -22,15 +22,49 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>>  #include 
>>>
>>> -int acpi_noirq;  /* skip ACPI IRQ initialization */
>>> -int acpi_disabled;
>>> +int acpi_noirq = 1;  /* skip ACPI IRQ initialization */
>>> +int acpi_disabled = 1;
>>>  EXPORT_SYMBOL(acpi_disabled);
>>>
>>> -int acpi_pci_disabled;   /* skip ACPI PCI scan and IRQ 
>>> initialization */
>>> +int acpi_pci_disabled = 1;   /* skip ACPI PCI scan and IRQ initialization 
>>> */
>>>  EXPORT_SYMBOL(acpi_pci_disabled);
>>>
>>> +static bool param_acpi_off __initdata;
>>> +static bool param_acpi_force __initdata;
>>> +
>>> +static int __init parse_acpi(char *arg)
>>> +{
>>> + if (!arg)
>>> + return -EINVAL;
>>> +
>>> + /* "acpi=off" disables both ACPI table parsing and interpreter */
>>> + if (strcmp(arg, "off") == 0)
>>> + param_acpi_off = true;
>>> + else if 

Re: [PATCH V2 4/4] hugetlbfs: document min_size mount option

2015-03-18 Thread Andrew Morton
On Wed, 18 Mar 2015 18:51:22 -0700 Mike Kravetz  wrote:

> > Nowhere here is the reader told the units of "size".  We should at
> > least describe that, and maybe even rename the thing to min_bytes.
> >
> 
> Ok, I will add that the size is in unit of bytes.  My choice of
> 'min_size' as a name for the new mount option was influenced by
> the existing 'size' mount option.  I'm open to any suggestions
> for the name of this new mount option.

Yes, due to the preexisting "size" I think we're stuck with "min_size".
We could use min_size_bytes I guess, but the operator needs to go look
up the units of "size" anyway.
--
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: PANIC: double fault, error_code: 0x0 in 4.0.0-rc3-2, kvm related?

2015-03-18 Thread Linus Torvalds
On Wed, Mar 18, 2015 at 5:57 PM, Andy Lutomirski  wrote:
>
>>   sp = 140735967860552,
>
> 0x7fffa55f1748
>
> Note that the double fault happened with rsp == 0x7fffa55eafb8,
> which is the saved rsp here - 0x6790.  That difference kind of large
> to make sense if this is a sysret problem.  Not that I have a better
> explanation...

Actually, that kind of large difference is what I'd expect if it's a
GP fault on sysret then cascades to more faults because our kernel
stack pointer is crap.

So it starts with getting a GP fault due to the sysret, but now we're
in la-la-land with really odd core register state, so what's not to
say that we don't get a recursive fault. We don't use the kernel stack
pointer for getting thread-info any more like we used to, but we still
have code like this in entry_64.c:

testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)

which seems to know that the thread info is below the kernel stack. So
let's say that the GP fault starts taking a recursive GP faults (or
recursive page faults) due to confusion with thread_info accesses or
something. And the stack keeps growing down, because all the faults
just fault themselves. Until finally we hit an unmapped area, and that
stops it - because while we had recursive faulting before, it was our
kernel code that was confused. But now the fault handling ends up
takiung a page fault while setting up the error information.

You would *not* expect the stack to be unmapped just under the
original %rsp value. User space has big frames and probably had deep
call chains before it ever hit the problematic case, so there's some
"slop" on the user stack. Only when we run out of slop do we get the
double-fault. Which explains why you should *not* expect the %rsp
values to be similar.

And around 30kB of stack before that happens sounds quite reasonable.

Now, to be honest, I don't see why we'd get the cascading faults, I
just get this feeling that if %rsp is crap, just about anything might
go wrong, and that if it's sysret taking a #GP fault, we're just
screwed.

 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/


Re: [PATCH] net: ethernet: pcnet32: Setup the SRAM and NOUFLO on Am79C97{3,5}

2015-03-18 Thread Don Fry
One little change to the comment is needed.  See below

Don

On Wed, 2015-03-18 at 20:10 +, Markos Chandras wrote:
> On a MIPS Malta board, tons of fifo underflow errors have been observed
> when using u-boot as bootloader instead of YAMON. The reason for that
> is that YAMON used to set the pcnet device to SRAM mode but u-boot does
> not. As a result, the default Tx threshold (64 bytes) is now too small to
> keep the fifo relatively used and it can result to Tx fifo underflow errors.
> As a result of which, it's best to setup the SRAM on supported controllers
> so we can always use the NOUFLO bit.

> + /*
> +  * The Am79C973/Am79C975 controllers come with 12K of SRAM
> +  * which we can use for the Tx/Rx buffers but most importantly,
> +  * the use of SRAM allow us to use the BCR18:NOUFLO bit to avoid
> +  * Tx fifo underflows.
> +  */
> + if (sram) {
> + /*
> +  * The SRAM is being configured in two steps. First we
> +  * set the SRAM size in the BCR25:SRAM_SIZE bits. According
> +  * to the datasheet, each bit corresponds to a 512-byte
> +  * page so we can have at most 24 pages. The SRAM_SIZE
> +  * corresponds holds the value of the upper 8 bits of
> +  * the 16-bit SRAM size. The low 8-bits start at 0x00
> +  * and end at 0xff. So the address range is from 0x
> +  * up to 0x17ff. Therefore, the SRAM_SIZE is set to 0x17.
> +  * The next step is to set the BCR24:SRAM_BND midway through
> +  * so the Tx and Rx buffers can share the SRAM equally.
> +  */

The comment specifies BCR24 but the code is changing BCR26 which matches
the documentation.  Please correct the comment to avoid confusion.

> + a->write_bcr(ioaddr, 25, 0x17);
> + a->write_bcr(ioaddr, 26, 0xc);
> + /* And finally enable the NOUFLO bit */


--
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 0/3] idle memory tracking

2015-03-18 Thread Minchan Kim
Hello,

On Wed, Mar 18, 2015 at 11:44:33PM +0300, Vladimir Davydov wrote:
> Hi,
> 
> Knowing the portion of memory that is not used by a certain application
> or memory cgroup (idle memory) can be useful for partitioning the system
> efficiently. Currently, the only means to estimate the amount of idle
> memory provided by the kernel is /proc/PID/clear_refs. However, it has
> two serious shortcomings:
> 
>  - it does not count unmapped file pages
>  - it affects the reclaimer logic
> 
> Back in 2011 an attempt was made by Michel Lespinasse to improve the
> situation (see http://lwn.net/Articles/459269/). He proposed a kernel
> space daemon which would periodically scan physical address range,
> testing and clearing ACCESS/YOUNG PTE bits, and counting pages that had
> not been referenced since the last scan. The daemon avoided interference
> with the page reclaimer by setting the new PG_young flag on referenced
> pages and making page_referenced() return >= 1 if PG_young was set.
> 
> This patch set reuses the idea of Michel's patch set, but the
> implementation is quite different. Instead of introducing a kernel space
> daemon, it only provides the userspace with the necessary means to
> estimate the amount of idle memory, leaving the daemon to be implemented
> in the userspace. In order to achieve that, it adds two new proc files,
> /proc/kpagecgroup and /proc/sys/vm/set_idle, and extends the clear_refs
> interface.
> 
> 
>  1. Write 1 to /proc/sys/vm/set_idle.
> 
> This will set the IDLE flag for all user pages. The IDLE flag is cleared
> when the page is read or the ACCESS/YOUNG bit is cleared in any PTE 
> pointing
> to the page. It is also cleared when the page is freed.

We should scan all of pages periodically? I understand why you did but
someone might not take care of unmapped pages so I hope it should be optional.
if someone just want to catch mapped file+anon pages, he can do it
by scanning of address space of the process he selects.
Even, someone might want to scan just part of address space rather than
all address space of the process. Acutally, I have such scenario.

> 
>  2. Wait some time.
> 
>  3. Write 6 to /proc/PID/clear_refs for each PID of interest.
> 
> This will clear the IDLE flag for recently accessed pages.
> 
>  4. Count the number of idle pages as reported by /proc/kpageflags. One may 
> use
> /proc/PID/pagemap and/or /proc/kpagecgroup to filter pages that belong to 
> a
> certain application/container.
> 

Adding two new page flags? I don't know it's okay for 64bit but there is no
room for 32bit. Please take care of 32 bit. It would be good feature for
embedded. How about using page_ext if you couldn't make room for page->flags
for 32bit? You would add per-page meta data in there.

Your suggestion is generic so my concern is overhead. On every iteration,
we should set/clear/investigate page flags. I don't know how much overhead
is in there but it surely could be big if memory is big.
Couldn't we do that at one go? Maybe, like mincore

int idlecore(pid_t pid, void *addr, size_t length, unsigned char *vec)

So, we could know what pages of the process[pid] were idle by vec in
[addr, lentgh] and reset idle of the pages for the process
in the system call at one go.

Anyway, Thanks for the good feature.

> An example of using this new interface is below. It is a script that
> counts the number of pages charged to a specified cgroup that have not
> been accessed for a given time interval.
> 
>  BEGIN SCRIPT 
> #! /usr/bin/python
> #
> 
> import struct
> import sys
> import os
> import stat
> import time
> 
> def get_end_pfn():
> f = open("/proc/zoneinfo", "r")
> end_pfn = 0
> for l in f.readlines():
> l = l.split()
> if l[0] == "spanned":
> end_pfn = int(l[1])
> elif l[0] == "start_pfn:":
> end_pfn += int(l[1])
> return end_pfn
> 
> def set_idle():
> open("/proc/sys/vm/set_idle", "w").write("1")
> 
> def clear_refs(target_cg_path):
> procs = open(target_cg_path + "/cgroup.procs", "r")
> for pid in procs.readlines():
> try:
> with open("/proc/" + pid.rstrip() + "/clear_refs", "w") as f:
> f.write("6")
> except IOError as e:
> print "Failed to clear_refs for pid " + pid + ": " + str(e)
> 
> def count_idle(target_cg_path):
> target_cg_ino = os.stat(target_cg_path)[stat.ST_INO]
> 
> pgflags = open("/proc/kpageflags", "rb")
> pgcgroup = open("/proc/kpagecgroup", "rb")
> 
> nidle = 0
> 
> for i in range(0, get_end_pfn()):
> cg_ino = struct.unpack('Q', pgcgroup.read(8))[0]
> flags = struct.unpack('Q', pgflags.read(8))[0]
> 
> if cg_ino != target_cg_ino:
> continue
> 
> # unevictable?
> if (flags >> 18) & 1 != 0:
> continue
> 
> # huge?
> if (flags >> 22) & 1 != 0:
> npages = 512
> else:
> 

Re: [PATCH 2/3] ARM: sun8i: Add SMP support for the Allwinner A23

2015-03-18 Thread Chen-Yu Tsai
On Wed, Mar 18, 2015 at 6:29 PM, Maxime Ripard
 wrote:
> On Wed, Mar 18, 2015 at 11:24:01AM +0800, Chen-Yu Tsai wrote:
>> The A23 is a dual Cortex-A7. Add the logic to use the IPs used to
>> control the CPU configuration and the CPU power so that we can
>> bring up secondary CPUs at boot.
>>
>> Signed-off-by: Chen-Yu Tsai 
>> ---
>>
>> We can't use of_io_request_and_map() here, as it will conflict
>> with PRCM, and leave us without a serial console.
>>
>> I think a proper way to solve this would be a syscon device or
>> something like the mfd-simple device posted by Arnd.
>>
>> ---
>>  Documentation/devicetree/bindings/arm/cpus.txt |  1 +
>>  arch/arm/mach-sunxi/platsmp.c  | 69 
>> ++
>>  2 files changed, 70 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/arm/cpus.txt 
>> b/Documentation/devicetree/bindings/arm/cpus.txt
>> index 8b9e0a95de31..40202d85b132 100644
>> --- a/Documentation/devicetree/bindings/arm/cpus.txt
>> +++ b/Documentation/devicetree/bindings/arm/cpus.txt
>> @@ -188,6 +188,7 @@ nodes to be present and contain the properties described 
>> below.
>>   # On ARM 32-bit systems this property is optional and
>> can be one of:
>>   "allwinner,sun6i-a31"
>> + "allwinner,sun8i-a23"
>>   "arm,psci"
>>   "brcm,brahma-b15"
>>   "marvell,armada-375-smp"
>> diff --git a/arch/arm/mach-sunxi/platsmp.c b/arch/arm/mach-sunxi/platsmp.c
>> index 587b0468efcc..e8483ec79d67 100644
>> --- a/arch/arm/mach-sunxi/platsmp.c
>> +++ b/arch/arm/mach-sunxi/platsmp.c
>> @@ -121,3 +121,72 @@ static struct smp_operations sun6i_smp_ops __initdata = 
>> {
>>   .smp_boot_secondary = sun6i_smp_boot_secondary,
>>  };
>>  CPU_METHOD_OF_DECLARE(sun6i_a31_smp, "allwinner,sun6i-a31", _smp_ops);
>> +
>> +static void __init sun8i_smp_prepare_cpus(unsigned int max_cpus)
>> +{
>> + struct device_node *node;
>> +
>> + node = of_find_compatible_node(NULL, NULL, "allwinner,sun8i-a23-prcm");
>> + if (!node) {
>> + pr_err("Missing A23 PRCM node in the device tree\n");
>> + return;
>> + }
>> +
>> + prcm_membase = of_iomap(node, 0);
>> + if (!prcm_membase) {
>> + pr_err("Couldn't map A23 PRCM registers\n");
>> + return;
>> + }
>> +
>> + node = of_find_compatible_node(NULL, NULL,
>> +"allwinner,sun8i-a23-cpuconfig");
>> + if (!node) {
>> + pr_err("Missing A23 CPU config node in the device tree\n");
>> + return;
>> + }
>> +
>> + cpucfg_membase = of_iomap(node, 0);
>> + if (!cpucfg_membase)
>> + pr_err("Couldn't map A23 CPU config registers\n");
>> +
>> +}
>> +
>> +static int sun8i_smp_boot_secondary(unsigned int cpu,
>> + struct task_struct *idle)
>> +{
>> + u32 reg;
>> +
>> + if (!(prcm_membase && cpucfg_membase))
>> + return -EFAULT;
>> +
>> + spin_lock(_lock);
>> +
>> + /* Set CPU boot address */
>> + writel(virt_to_phys(secondary_startup),
>> +cpucfg_membase + CPUCFG_PRIVATE0_REG);
>
> One question I couldn't find any answer to is that does the SMP bit is
> set in secondary_startup?
>
> I couldn't find where it was set, but it still looks like the right
> thing to do, so I would expect the code to do that.

I don't see it either. The sun8i code is just the sun6i code with the
power clamps removed. And sun6i secondary_startup was removed some time
ago in commit 1146b600044d ("ARM: sunxi: fix build for THUMB2_KERNEL").

ChenYu
--
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] gpio: add set_active_low() function to gpio_chip

2015-03-18 Thread Alexandre Courbot
On Thu, Mar 19, 2015 at 5:16 AM, David Cohen
 wrote:
> Some gpio controllers are capable of programming its pins' active-low
> state. Let's add this new gpio_chip function for such cases and use it
> in gpiolib.
>
> When set_active_low() is implemented, we no longer need to do soft flips
> on values from non-raw get functions.
>
> Signed-off-by: David Cohen 
> ---
>
> Hi,
>
> This is a RFC, not meant for integration (yet).
>
> We have a GPIO controller that is capable of inverting the GPIO logical value
> on hardware using a register (and GPIO voltage level if configured for 
> output):
> - If GPIO pin is configured for input, only the logical value is affected: the
>   GPIO level stays the same but the read values are inverted (it affects even
>   interrupt event triggers).
> - If GPIO pin is configured for output, the GPIO level is also inverted.
>
> Is it acceptable to expose this functionality via new gpio chip operation
> set_active_low()?

At first I thought "why not", but then I couldn't help but ask "why?"

Handling the active low state in software is basically free and
requires no extra support. What is the benefit of handling it in
hardware that would counterbalance the complexity this adds to the
GPIO framework?

Also, wouldn't that require us to reverse this active-low logic in the
*_raw functions for them to work as expected?
--
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] ARM: shmobile: cpuidle: Remove the pointless default driver

2015-03-18 Thread Simon Horman
On Tue, Mar 17, 2015 at 04:26:50PM +0100, Daniel Lezcano wrote:
> 
> Sorry Geert, I forget to Cc you.
> 
> On 03/17/2015 04:25 PM, Daniel Lezcano wrote:
> >The default idle driver uses one state with the WFI instruction.
> >The default idle routine invokes WFI when no cpuidle driver is present.
> >
> >The default cpuidle driver is pointless and does not give more than the
> >default idle routine and moreover it pulls all the mathematics tied with
> >the cpuidle governor for nothing, hence consuming more energy.
> >
> >Remove the default driver, the related code and register the driver directly.
> >
> >[compiled only - no board - no test]
> >
> >Signed-off-by: Daniel Lezcano 

Thanks Daniel,

I have queued this up for v4.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 35/35 linux-next] pinctrl: constify of_device_id array

2015-03-18 Thread Hongzhou Yang
On Mon, 2015-03-16 at 20:59 +0100, Fabian Frederick wrote:
> of_device_id is always used as const.
> (See driver.of_match_table and open firmware functions)
> 
> Signed-off-by: Fabian Frederick 
> ---
>  drivers/pinctrl/bcm/pinctrl-bcm2835.c   | 2 +-
>  drivers/pinctrl/mediatek/pinctrl-mt8135.c   | 2 +-
>  drivers/pinctrl/mediatek/pinctrl-mt8173.c   | 2 +-
>  

For the pinctrl-mt81xx driver,
Acked-by: Hongzhou Yang 

By the way, Axel has sent same patch to linux-gpio.
http://article.gmane.org/gmane.linux.kernel.gpio/6815

Thanks.
Hongzhou

--
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: [LKP] [mm] cc87317726f: WARNING: CPU: 0 PID: 1 atdrivers/iommu/io-pgtable-arm.c:413 __arm_lpae_unmap+0x341/0x380()

2015-03-18 Thread Huang Ying
On Wed, 2015-03-18 at 20:45 +0900, Tetsuo Handa wrote:
> Huang Ying wrote:
> > On Tue, 2015-03-17 at 15:24 -0400, Johannes Weiner wrote:
> > > On Tue, Mar 17, 2015 at 10:15:29AM -0700, Linus Torvalds wrote:
> > > > Explicitly adding the emails of other people involved with that commit
> > > > and the original oom thread to make sure people are aware, since this
> > > > didn't get any response.
> > > > 
> > > > Commit cc87317726f8 fixed some behavior, but also seems to have turned
> > > > an oom situation into a complete hang. So presumably we shouldn't loop
> > > > *forever*. Hmm?
> > > 
> > > It seems we are between a rock and a hard place here, as we reverted
> > > specifically to that endless looping on request of filesystem people.
> > > They said[1] they rely on these allocations never returning NULL, or
> > > they might fail inside a transactions and corrupt on-disk data.
> > > 
> > > Huang, against which kernels did you first run this test on this exact
> > > setup?  Is there a chance you could try to run a kernel without/before
> > > 9879de7373fc?  I want to make sure I'm not missing something, but all
> > > versions preceding this commit should also have the same hang.  There
> > > should only be a tiny window between 9879de7373fc and cc87317726f8 --
> > > v3.19 -- where these allocations are allowed to fail.
> > 
> > I checked the test result of v3.19-rc6.  It shows that boot will hang at
> > the same position.
> 
> OK. That's the expected result. We are discussing about how to safely
> allow small allocations to fail, including how to handle stalls caused by
> allocations without __GFP_FS.
> 
> > 
> > BTW: the test is run on 32 bit system.
> 
> That sounds like the cause of your problem. The system might be out of
> address space available for the kernel (only 1GB if x86_32). You should
> try running tests on 64 bit systems.

We run test on 32 bit and 64 bit systems.  Try to catch problems on both
platforms.  I think we still need to support 32 bit systems?

Best Regards,
Huang, Ying


--
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 3/4] cpusets,isolcpus: add file to show isolated cpus in cpuset

2015-03-18 Thread Zefan Li
On 2015/3/19 7:40, Rik van Riel wrote:
> On 03/18/2015 12:47 PM, Tejun Heo wrote:
>> On Mon, Mar 09, 2015 at 12:12:09PM -0400, r...@redhat.com wrote:
>>> From: Rik van Riel 
>>>
>>> The previous patch makes it so the code skips over isolcpus when
>>> building scheduler load balancing domains. This makes it hard to
>>> see for a user which of the CPUs in a cpuset are participating in
>>> load balancing, and which ones are isolated cpus.
>>>
>>> Add a cpuset.isolcpus file with info on which cpus in a cpuset are
>>> isolated CPUs.
>>>
>>> This file is read-only for now. In the future we could extend things
>>> so isolcpus can be changed at run time, for the root (system wide)
>>> cpuset only.
>>
>> Didn't Li say that this is trivially computable from userland?  I'm
>> not sure this knob actually belongs to cpuset.
> 
> I don't know whether the information to compute this is
> always visible from userland.  I am happy to drop this
> patch if Li prefers things that way, though.
> 

What I proposed is adding /sys/devices/system/cpu/isolated. Sysfs is
visible in containers, unless specially configured not so.

--
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 3/4] cpusets,isolcpus: add file to show isolated cpus in cpuset

2015-03-18 Thread Rik van Riel
On 03/18/2015 09:50 PM, Zefan Li wrote:
> On 2015/3/19 7:40, Rik van Riel wrote:
>> On 03/18/2015 12:47 PM, Tejun Heo wrote:
>>> On Mon, Mar 09, 2015 at 12:12:09PM -0400, r...@redhat.com wrote:
 From: Rik van Riel 

 The previous patch makes it so the code skips over isolcpus when
 building scheduler load balancing domains. This makes it hard to
 see for a user which of the CPUs in a cpuset are participating in
 load balancing, and which ones are isolated cpus.

 Add a cpuset.isolcpus file with info on which cpus in a cpuset are
 isolated CPUs.

 This file is read-only for now. In the future we could extend things
 so isolcpus can be changed at run time, for the root (system wide)
 cpuset only.
>>>
>>> Didn't Li say that this is trivially computable from userland?  I'm
>>> not sure this knob actually belongs to cpuset.
>>
>> I don't know whether the information to compute this is
>> always visible from userland.  I am happy to drop this
>> patch if Li prefers things that way, though.
>>
> 
> What I proposed is adding /sys/devices/system/cpu/isolated. Sysfs is
> visible in containers, unless specially configured not so.

OK, are you willing to take patches 1, 2, and the first hunk of patch
4 now? I can submit a patch to add /sys/devices/system/cpu/isolated
on Friday, to the appropriate maintainer.

(taking tomorrow off to go hiking on the last full day of winter)

-- 
All rights reversed
--
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   >