Re: Audio crackles with 4.1-rc1

2015-06-12 Thread Takashi Iwai
At Fri, 12 Jun 2015 01:23:18 +0300,
Mihai Donțu wrote:
> 
> On Thu, 11 Jun 2015 07:01:13 +0200 Takashi Iwai wrote:
> > At Thu, 11 Jun 2015 01:12:36 +0300, Mihai Donțu wrote:
> > > On Wed, 10 Jun 2015 20:23:01 +0200 Takashi Iwai wrote:
> > > > From: Takashi Iwai 
> > > > Subject: [PATCH] ALSA: hda - Reduce click noise at power up
> > > > 
> > > > Some machines suffer from click noises at power up with the recent
> > > > kernels, and this seems triggered at the power transition and the
> > > > immediate verb executions.  As a workaround, put a short delay (10ms)
> > > > right after the D0 transition.
> > > > 
> > > > There are a few places that have the same kind of delays, especially
> > > > in the resume path.  I guess they can be removed (or reduced) after
> > > > this patch.  But, since the delay is relatively small, let's do it
> > > > later as a cleanup.
> > > > 
> > > > Reported-by: Mihai Donțu 
> > > > Signed-off-by: Takashi Iwai 
> > > > ---
> > > >  sound/pci/hda/hda_codec.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> > > > index b7782212dd64..38f5509ee52f 100644
> > > > --- a/sound/pci/hda/hda_codec.c
> > > > +++ b/sound/pci/hda/hda_codec.c
> > > > @@ -3077,6 +3077,9 @@ static unsigned int hda_set_power_state(struct 
> > > > hda_codec *codec,
> > > > break;
> > > > }
> > > >  
> > > > +   if (power_state == AC_PWRST_D0)
> > > > +   msleep(10);
> > > > +
> > > > return state;
> > > >  }
> > > >  
> > > 
> > > I take back my previous observations. I was at work and did not have
> > > access to headphones (one of those days). Now I'm at home, it's 1 AM,
> > > very quiet, and I notice the following:
> > > 
> > >  * on speakers: the click reproduces but with _very_ low amplitude;
> > >msleep(100) is unnoticeable, but msleep(10) is, barely;
> > >  * on headphones: the moment I plug them I hear a loud static sound
> > >(like an old, untuned AM radio). If I play something, the static
> > >disappears. If I pause, the static returns after ~15s.
> > 
> > OK, then the patch is no-go.  We need a bit deeper analysis.
> > 
> > About the headphone problem: don't you get the same issue with 4.0.x?
> > Please take alsa-info.sh outputs on both 4.0.x and 4.1 before and
> > after plugging the headphone, and attach the outputs.
> > (Run the script with --no-upload option.)
> 
> No, 4.0.5 and all previous kernels (>= 3.12) are OK. I have attached a
> small tarball with the two files produced by alsa-info.sh.

Both are taken in different states (one is headphone plugged and
another unplugged?).  At best, take the snapshot in the same situation
for comparison.

In anyway, below is another shot in dark.  The white noise is possibly
the ill side effect of analog loopback.  But it's strange that this
didn't happen on 4.0.x.  And, it combines another black magic that
worked for another Dell model.  Let's see.


Takashi

---
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 9d3e0fcb4326..cf46f6012ba4 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4522,6 +4522,8 @@ enum {
ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
ALC288_FIXUP_DELL_XPS_13_GPIO6,
ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
+   ALC292_FIXUP_DELL_E74,
+   ALC292_FIXUP_DISABLE_AAMIX,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -5054,6 +5056,16 @@ static const struct hda_fixup alc269_fixups[] = {
.chained = true,
.chain_id = ALC269_FIXUP_HEADSET_MODE
},
+   [ALC292_FIXUP_DISABLE_AAMIX] = {
+   .type = HDA_FIXUP_FUNC,
+   .v.func = alc_fixup_disable_aamix,
+   },
+   [ALC292_FIXUP_DELL_E74] = {
+   .type = HDA_FIXUP_FUNC,
+   .v.func = alc_fixup_dell_xps13,
+   .chained = true,
+   .chain_id = ALC292_FIXUP_DISABLE_AAMIX
+   },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5066,6 +5078,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", 
ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", 
ALC282_FIXUP_ASPIRE_V5_PINS),
SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
+   SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", 
ALC292_FIXUP_DELL_E74),
SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", 
ALC290_FIXUP_SUBWOOFER),
SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", 
ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", 
ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
--
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://w

Re: [PATCH 07/25] mm, vmscan: Make kswapd think of reclaim in terms of nodes

2015-06-12 Thread Hillf Danton
> - /* Reclaim above the high watermark. */
> - sc->nr_to_reclaim = max(SWAP_CLUSTER_MAX, high_wmark_pages(zone));
> + /* Aim to reclaim above all the zone high watermarks */
> + for (z = 0; z <= end_zone; z++) {
> + zone = pgdat->node_zones + end_zone;
s/end_zone/z/ ?
> + nr_to_reclaim += high_wmark_pages(zone);
> 
[...]
> @@ -3280,13 +3177,26 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, 
> int order,
>   compact_pgdat(pgdat, order);
> 
>   /*
> +  * Stop reclaiming if any eligible zone is balanced and clear
> +  * node writeback or congested.
> +  */
> + for (i = 0; i <= *classzone_idx; i++) {
> + zone = pgdat->node_zones + i;
> +
> + if (zone_balanced(zone, sc.order, 0, *classzone_idx)) {
> + clear_bit(PGDAT_CONGESTED, &pgdat->flags);
> + clear_bit(PGDAT_DIRTY, &pgdat->flags);
> + break;
s/break/goto out/ ?
> + }
> + }
> +
> + /*
>* Raise priority if scanning rate is too low or there was no
>* progress in reclaiming pages
>*/
>   if (raise_priority || !sc.nr_reclaimed)
>   sc.priority--;
> - } while (sc.priority >= 1 &&
> -  !pgdat_balanced(pgdat, order, *classzone_idx));
> + } while (sc.priority >= 1);
> 
>  out:
>   /*
> --
> 2.3.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] staging: sm750fb: fix c99 comments

2015-06-12 Thread Juston Li
fixed all checkpatch.pl ERROR: do not use C99 // comments

Any C99 comments used to comment out code are simply removed.
Also some of the errors occur inside '#if 0' blocks which I
might as well fix since checkpatch.pl caught them but the blocks
themselves should probably be cleaned up later.

Signed-off-by: Juston Li 
---
 drivers/staging/sm750fb/ddk750_chip.c   | 11 ++--
 drivers/staging/sm750fb/ddk750_dvi.c|  4 +--
 drivers/staging/sm750fb/ddk750_help.c   |  2 --
 drivers/staging/sm750fb/ddk750_sii164.c | 11 
 drivers/staging/sm750fb/sm750.h | 10 +++
 drivers/staging/sm750fb/sm750_accel.c   | 49 -
 drivers/staging/sm750fb/sm750_accel.h   |  2 +-
 drivers/staging/sm750fb/sm750_cursor.c  |  9 +++---
 drivers/staging/sm750fb/sm750_help.h| 28 +++
 drivers/staging/sm750fb/sm750_hw.c  |  4 +--
 drivers/staging/sm750fb/sm750_hw.h  |  3 --
 11 files changed, 41 insertions(+), 92 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index 8b47c1b..b2137c8 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -17,7 +17,7 @@ logical_chip_type_t getChipType(void)
char physicalRev;
logical_chip_type_t chip;
 
-   physicalID = devId750;//either 0x718 or 0x750
+   physicalID = devId750; /* either 0x718 or 0x750 /
physicalRev = revId750;
 
if (physicalID == 0x718)
@@ -257,7 +257,7 @@ int ddk750_initHw(initchip_param_t *pInitParam)
 
unsigned int ulReg;
 #if 0
-   //move the code to map regiter function.
+   /* move the code to map regiter function. */
if (getChipType() == SM718) {
/* turn on big endian bit*/
ulReg = PEEK32(0x74);
@@ -487,8 +487,6 @@ unsigned int calcPllValue(unsigned int request_orig, 
pll_value_t *pll)
}
}
}
-
-   //printk("Finally:  
pll->n[%lu],m[%lu],od[%lu],pod[%lu]\n",pll->N,pll->M,pll->OD,pll->POD);
return ret;
 }
 
@@ -580,14 +578,9 @@ pll_value_t *pPLL   /* Structure to hold the value 
to be set in PLL */
}
 
 /* Restore input frequency from Khz to hz unit */
-//pPLL->inputFreq *= 1000;
ulRequestClk *= 1000;
pPLL->inputFreq = DEFAULT_INPUT_CLOCK; /* Default reference clock */
 
-/* Output debug information */
-   //DDKDEBUGPRINT((DISPLAY_LEVEL, "calcPllValue: Requested Frequency = 
%d\n", ulRequestClk));
-   //DDKDEBUGPRINT((DISPLAY_LEVEL, "calcPllValue: Input CLK = %dHz, M=%d, 
N=%d, OD=%d, POD=%d\n", pPLL->inputFreq, pPLL->M, pPLL->N, pPLL->OD, 
pPLL->POD));
-
 /* Return actual frequency that the PLL can set */
ret = calcPLL(pPLL);
return ret;
diff --git a/drivers/staging/sm750fb/ddk750_dvi.c 
b/drivers/staging/sm750fb/ddk750_dvi.c
index f5932bb..b2bf7e6 100644
--- a/drivers/staging/sm750fb/ddk750_dvi.c
+++ b/drivers/staging/sm750fb/ddk750_dvi.c
@@ -51,7 +51,7 @@ int dviInit(
   vsyncEnable, deskewEnable, deskewSetting, 
continuousSyncEnable,
   pllFilterEnable, pllFilterValue);
}
-   return -1;//error
+   return -1; /* error */
 }
 
 
@@ -66,7 +66,6 @@ unsigned short dviGetVendorID(void)
 {
 dvi_ctrl_device_t *pCurrentDviCtrl;
 
-//pCurrentDviCtrl = getDviCtrl();
 pCurrentDviCtrl = g_dcftSupportedDviController;
 if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0)
 return pCurrentDviCtrl->pfnGetVendorId();
@@ -86,7 +85,6 @@ unsigned short dviGetDeviceID(void)
 {
 dvi_ctrl_device_t *pCurrentDviCtrl;
 
-//pCurrentDviCtrl = getDviCtrl();
pCurrentDviCtrl = g_dcftSupportedDviController;
 if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0)
 return pCurrentDviCtrl->pfnGetDeviceId();
diff --git a/drivers/staging/sm750fb/ddk750_help.c 
b/drivers/staging/sm750fb/ddk750_help.c
index 647004d..96c18eb 100644
--- a/drivers/staging/sm750fb/ddk750_help.c
+++ b/drivers/staging/sm750fb/ddk750_help.c
@@ -1,5 +1,3 @@
-//#include "ddk750_reg.h"
-//#include "ddk750_chip.h"
 #include "ddk750_help.h"
 
 void __iomem * mmio750 = NULL;
diff --git a/drivers/staging/sm750fb/ddk750_sii164.c 
b/drivers/staging/sm750fb/ddk750_sii164.c
index 84464c1..b6395b8 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.c
+++ b/drivers/staging/sm750fb/ddk750_sii164.c
@@ -125,10 +125,7 @@ long sii164InitChip(
 unsigned char pllFilterValue
 )
 {
-//unsigned char ucRegIndex, ucRegValue;
-//unsigned char ucDeviceAddress,
unsigned char config;
-//unsigned long delayCount;
 
 /* Initialize the i2c bus */
 #ifdef USE_HW_I2C
@@ -141,10 +138,6 @@ long sii164InitChip(
 /* Check if SII164 Chip exists */
 if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() == 
SII164_DEVICE_ID))
 {
-
-#ifdef DDKDEBUG
-//sii164PrintRegisterValues();
-#endif
 /*
  *  I

Re: [PATCH 11/18] seqcount: Introduce raw_write_seqcount_barrier()

2015-06-12 Thread Peter Zijlstra
On Thu, Jun 11, 2015 at 02:45:57PM -0700, Paul E. McKenney wrote:
> Color me slow and stupid.  Maybe due to reviewing a patch too early in
> the morning, who knows?
> 
> There is nothing above that prevents the compiler and the CPU from
> reordering the assignments to X and Y with the increment of s->sequence++.

That's actually fine. As long as we observe an odd value the read side
will repeat.

> Of course, this assumes that the accesses surrounding the call to
> raw_write_seqcount_barrier() are writes.  

Which is why its got both write and barrier in the name :-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] phy: tusb1210: make better use of gpiod API

2015-06-12 Thread Uwe Kleine-König
Hello,

Cc += linux-kernel@vger.kernel.org, forgot that on submission.

On Fri, Jun 12, 2015 at 08:59:59AM +0200, Uwe Kleine-König wrote:
> Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions)
> which appeared in v3.17-rc1, the gpiod_get* functions take an additional
> parameter that allows to specify direction and initial value for output.
> 
> Furthermore there is devm_gpiod_get_optional which is designed to get
> optional gpios.
> 
> Simplify driver accordingly.
> 
> Signed-off-by: Uwe Kleine-König 
> ---
> Hello,
> 
> note I plan to make the flags parameter mandatory for 4.3. So unless
> this change gets into 4.2, would it be ok to let it go in via the gpio
> tree?
Note, the fix is only necessary if commit 1c14905ef951 (phy: add driver
for TI TUSB1210 ULPI PHY) that currently sits in next makes it into 4.2.

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |
--
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: [BUG] mpc8323_rdb platform doesn't boot since kernel 3.16

2015-06-12 Thread leroy christophe



Le 10/06/2015 20:17, Rob Herring a écrit :

On Wed, Jun 10, 2015 at 10:12 AM, leroy christophe
 wrote:

Le 06/06/2015 17:32, Rob Herring a écrit :

On Sat, Jun 6, 2015 at 6:20 AM, christophe leroy
 wrote:

I've got a MPC8323 RDB evaluation platform from freescale
kernel 4.0 doesn't boot
kernel 3.16 doesn't boot
kernel 3.15 boots ok

I disected the issue down to your commit "of/fdt: Convert FDT functions
to
use libfdt" (e6a6928c3ea1d0195ed75a091e345696b916c09b)

Do you have an idea of what the issue could be ?

Is your dtb older version of the dtb format (before 0x10)? libfdt
doesn't work on the older versions.

Yes, dtb has version 0x11, which seems to be the issue (see below)

In that your bootloader doesn't understand 0x11.


If not, do you have logs with debug enabled in drivers/of/fdt.c?

I get "unflatten: error -11 processing FDT"

Can I get the full debug prints.

Here it is:

 -> unflatten_device_tree()
Unflattening device tree:
magic: d00dfeed
size: 20b5
version: 0011
unflatten: error -11 processing FDT
unflatten: error -11 processing FDT
  size is 44dc, allocating...
  unflattening c3ff0b20...
fixed up name for  ->
fixed up name for aliases -> aliases
fixed up name for cpus -> cpus
fixed up name for PowerPC,8323@0 -> PowerPC,8323
fixed up name for memory -> memory
fixed up name for soc8323@e000 -> soc8323
fixed up name for wdt@200 -> wdt
fixed up name for power@b00 -> power
fixed up name for i2c@3000 -> i2c
fixed up name for serial@4500 -> serial
fixed up name for serial@4600 -> serial
fixed up name for dma@82a8 -> dma
fixed up name for dma-channel@0 -> dma-channel
fixed up name for dma-channel@80 -> dma-channel
fixed up name for dma-channel@100 -> dma-channel
fixed up name for dma-channel@180 -> dma-channel
fixed up name for crypto@3 -> crypto
fixed up name for pic@700 -> pic
fixed up name for par_io@1400 -> par_io
fixed up name for gpio-controller@1448 -> gpio-controller
fixed up name for ucc_pin@02 -> ucc_pin
fixed up name for ucc_pin@03 -> ucc_pin
fixed up name for qe@e010 -> qe
fixed up name for muram@1 -> muram
fixed up name for data-only@0 -> data-only
fixed up name for spi@4c0 -> spi
fixed up name for mmc-slot@0 -> mmc-slot
fixed up name for spi@500 -> spi
fixed up name for ucc@3000 -> ucc
fixed up name for ucc@2200 -> ucc
fixed up name for mdio@3120 -> mdio
fixed up name for ethernet-phy@00 -> ethernet-phy
fixed up name for ethernet-phy@04 -> ethernet-phy
fixed up name for interrupt-controller@80 -> interrupt-controller
fixed up name for pci@e0008500 -> pci
unflatten: error -11 processing FDT
unflatten: error -11 processing FDT
 <- unflatten_device_tree()

Christophe

--
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] x86: General protection fault after STR (32 bit systems only)

2015-06-12 Thread Ingo Molnar

* Andy Lutomirski  wrote:

> > 1)
> >
> > So the first critical question is: if the ACPI/BIOS suspend code corrupts 
> > the 
> > kernel's DS, how can we get so far as to resume fully, return to 
> > user-space, 
> > and segfault there so that it can all be reported?
> >
> > So neither the explanation nor the code makes any sense in the context of 
> > the 
> > reported bugs. Can anyone else offer any plausible theory about why this 
> > patch 
> > would fix 32-bit user-space segfaults?
> 
> I'm too tired to look at this intelligently right now, but this reminds me of 
> the sysret_ss_attrs thing.  What if we have a situation where, after 
> suspend/resume, we end up with a perfectly valid ss *selector* (or, on 64-bit 
> kernels, a ds selector that does not matter one whit) but a 
> somehow-screwed-up 
> ds *cached hidden descriptor*.  (On 32-bit kernels, this could be something 
> exotic like grows-down limit 2^31.)

Yes, that theory is what my patch tests, by reloading DS with __KERNEL_DS.

This should be safe as the first thing to execute after re-entry, as we don't 
save/restore the GDT. (If the BIOS mucks with the GDT without restoring it to 
our 
value we are probably screwed in any case.)

> Now we do the very first return.  If we're on AMD hardware and that return is 
> SYSRET, then we end up with some complete random garbage loaded in the hidden 
> DS 
> descriptor if SYSRET on 32-bit mode is indeed screwed up on AMD.

But why would this change from v3.10 to v3.11? I cannot see any low level x86 
change that should make a difference there.

> Don't even bother saving it.  Just load the known value on resume.

Yeah, so that's what my simple patch does.

> Here's my full-fledged half-asleep theory:
> 
> We suspend to RAM.  We resume.  DS and/or ES contains something unusual but 
> not 
> unusual enough to crash us.  Our first entry to userspace is via SYSEXIT.  
> Because we're daft, we don't reload DS or ES at any point along the way.  Now 
> we're in userspace with an even more screwed up DS or ES than usual.  We get 
> SIGSEGV (presumably #GP) and try to deliver the signal.  We end up with 
> impossible pt_regs (bogus RPL) but who cares?  We get to __setup_frame, which 
> fixes the garbage in pt_regs and we re-enter user mode through an IRET patch, 
> so 
> we finally reload DS and ES.  As a result, we successfully deliver the 
> signal.  
> The saved regs would reveal the damage, but systemd throws them away, and we 
> remain confused for a full ten kernel versions.

That's indeed plausible.

If so then the DS reloading patch I sent should help.

So we should also do a full review of all the DS/ES save/restore paths, 
everywhere, as they don't seem to be very consistently done.

Thanks,

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


[RESEND PATCH v4 08/14] crypto: marvell/CESA: add MD5 support

2015-06-12 Thread Boris Brezillon
From: Arnaud Ebalard 

Add support for MD5 operations.

Signed-off-by: Arnaud Ebalard 
Signed-off-by: Boris Brezillon 
---
 drivers/crypto/marvell/cesa.c |   2 +
 drivers/crypto/marvell/cesa.h |   2 +
 drivers/crypto/marvell/hash.c | 170 +-
 3 files changed, 172 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index b9f4d26..b9da0df 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -174,7 +174,9 @@ static struct crypto_alg *armada_370_cipher_algs[] = {
 };
 
 static struct ahash_alg *armada_370_ahash_algs[] = {
+   &mv_md5_alg,
&mv_sha1_alg,
+   &mv_ahmac_md5_alg,
&mv_ahmac_sha1_alg,
 };
 
diff --git a/drivers/crypto/marvell/cesa.h b/drivers/crypto/marvell/cesa.h
index d886280..23c4603 100644
--- a/drivers/crypto/marvell/cesa.h
+++ b/drivers/crypto/marvell/cesa.h
@@ -787,7 +787,9 @@ int mv_cesa_dma_add_op_transfers(struct mv_cesa_tdma_chain 
*chain,
 
 /* Algorithm definitions */
 
+extern struct ahash_alg mv_md5_alg;
 extern struct ahash_alg mv_sha1_alg;
+extern struct ahash_alg mv_ahmac_md5_alg;
 extern struct ahash_alg mv_ahmac_sha1_alg;
 
 extern struct crypto_alg mv_cesa_ecb_des_alg;
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
index f9c6d47..63fa493 100644
--- a/drivers/crypto/marvell/hash.c
+++ b/drivers/crypto/marvell/hash.c
@@ -12,6 +12,7 @@
  * by the Free Software Foundation.
  */
 
+#include 
 #include 
 
 #include "cesa.h"
@@ -346,8 +347,16 @@ static int mv_cesa_ahash_process(struct 
crypto_async_request *req, u32 status)
   ahashreq->nbytes - creq->cache_ptr);
 
if (creq->last_req) {
-   for (i = 0; i < digsize / 4; i++)
-   creq->state[i] = cpu_to_be32(creq->state[i]);
+   for (i = 0; i < digsize / 4; i++) {
+   /*
+* Hardware provides MD5 digest in a different
+* endianness than SHA-1 and SHA-256 ones.
+*/
+   if (digsize == MD5_DIGEST_SIZE)
+   creq->state[i] = cpu_to_le32(creq->state[i]);
+   else
+   creq->state[i] = cpu_to_be32(creq->state[i]);
+   }
 
memcpy(ahashreq->result, creq->state, digsize);
}
@@ -786,6 +795,95 @@ static int mv_cesa_ahash_finup(struct ahash_request *req)
return ret;
 }
 
+static int mv_cesa_md5_init(struct ahash_request *req)
+{
+   struct mv_cesa_op_ctx tmpl;
+
+   mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_MD5);
+
+   mv_cesa_ahash_init(req, &tmpl);
+
+   return 0;
+}
+
+static int mv_cesa_md5_export(struct ahash_request *req, void *out)
+{
+   struct md5_state *out_state = out;
+   struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
+   struct mv_cesa_ahash_req *creq = ahash_request_ctx(req);
+   unsigned int digsize = crypto_ahash_digestsize(ahash);
+
+   out_state->byte_count = creq->len;
+   memcpy(out_state->hash, creq->state, digsize);
+   memset(out_state->block, 0, sizeof(out_state->block));
+   if (creq->cache)
+   memcpy(out_state->block, creq->cache, creq->cache_ptr);
+
+   return 0;
+}
+
+static int mv_cesa_md5_import(struct ahash_request *req, const void *in)
+{
+   const struct md5_state *in_state = in;
+   struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
+   struct mv_cesa_ahash_req *creq = ahash_request_ctx(req);
+   unsigned int digsize = crypto_ahash_digestsize(ahash);
+   unsigned int cache_ptr;
+   int ret;
+
+   creq->len = in_state->byte_count;
+   memcpy(creq->state, in_state->hash, digsize);
+   creq->cache_ptr = 0;
+
+   cache_ptr = creq->len % sizeof(in_state->block);
+   if (!cache_ptr)
+   return 0;
+
+   ret = mv_cesa_ahash_alloc_cache(req);
+   if (ret)
+   return ret;
+
+   memcpy(creq->cache, in_state->block, cache_ptr);
+   creq->cache_ptr = cache_ptr;
+
+   return 0;
+}
+
+static int mv_cesa_md5_digest(struct ahash_request *req)
+{
+   int ret;
+
+   ret = mv_cesa_md5_init(req);
+   if (ret)
+   return ret;
+
+   return mv_cesa_ahash_finup(req);
+}
+
+struct ahash_alg mv_md5_alg = {
+   .init = mv_cesa_md5_init,
+   .update = mv_cesa_ahash_update,
+   .final = mv_cesa_ahash_final,
+   .finup = mv_cesa_ahash_finup,
+   .digest = mv_cesa_md5_digest,
+   .export = mv_cesa_md5_export,
+   .import = mv_cesa_md5_import,
+   .halg = {
+   .digestsize = MD5_DIGEST_SIZE,
+   .base = {
+   .cra_name = "md5",
+   .cra_driver_name = "mv-md5",
+   .cra_priority = 300,
+   .cra_flags = CRYPTO_ALG_ASYNC |
+  

[RESEND PATCH v4 00/14] crypto: add a new driver for Marvell's CESA

2015-06-12 Thread Boris Brezillon
Hello,

This patch series adds a new driver supporting Marvell's CESA IP.
This driver addresses some limitations of the existing one.
>From a performance and CPU load point of view the most important
limitation in the existing driver is the lack of DMA support, thus
preventing us from chaining crypto operations.

I know we usually try to adapt existing drivers instead of replacing them
by new ones, but after trying to refactor the mv_cesa driver I realized it
would take longer than writing an new one from scratch.

Here are the main features brought by this new driver:
- support for armada SoCs (up to 38x) while keeping support for older ones
  (Orion and Kirkwood). Note that old DT bindings (those used on Orion and
  Kirkwood platforms) are supported, or IOTW, old DTs are compatible with
  this new driver.
- DMA mode to offload the CPU in case of intensive crypto usage
- new algorithms: SHA256, DES and 3DES

I'd like to thank Arnaud, who has carefully reviewed several iterations of
this driver, helped me improved my implementation, provided support for
several crypto algorithms, provided support for armada-370 and tested
the driver on different platforms, hence the SoB and dual MODULE_AUTHOR
in the driver code.

In this version I dropped the DT changes, but you'll find them in my
cesa-v4 branch [1]. In this branch you'll find everything you need to
test on all Marvell platforms (including the old ones).
I'll post a series updating all the DTs once this driver has been merged.

Best Regards,

Boris

[1]https://github.com/bbrezillon/linux-marvell/tree/cesa-v4

Changes since v3:
- add import functions for hash algorithms
- patch mv_cesa driver to support the new DT bindings
- few fixes in the documentation
- replace mv_mbus_dram_info() call by mv_mbus_dram_info_nooverlap()
- remove DT updates from the series

Changes since v2:
- fixes in the cipher code (->dst_nents was assigned the ->src_nents
  value and CBC state was overwritten by the IV after each chunk
  operation)
- spit the code as suggested by Sebastian

Changes since v1:
- (suggested by Jason) kept the existing CESA driver and added a mechanism
  to prevent the new driver from probing devices handled my the existing
  one (Orion and Kirkwood platforms)
- (reported by Paul) addressed a few Kconfig and module definition issues
- (suggested by Andrew) added DT changes to the series

Arnaud Ebalard (4):
  crypto: marvell/CESA: add Triple-DES support
  crypto: marvell/CESA: add MD5 support
  crypto: marvell/CESA: add SHA256 support
  crypto: marvell/CESA: add support for Kirkwood and Dove SoCs

Boris Brezillon (10):
  crypto: mv_cesa: document the clocks property
  crypto: mv_cesa: use gen_pool to reserve the SRAM memory region
  crypto: mv_cesa: explicitly define kirkwood and dove compatible
strings
  crypto: add a new driver for Marvell's CESA
  crypto: marvell/CESA: add TDMA support
  crypto: marvell/CESA: add DES support
  crypto: marvell/CESA: add support for all armada SoCs
  crypto: marvell/CESA: add allhwsupport module parameter
  crypto: marvell/CESA: add support for Orion SoCs
  crypto: marvell/CESA: add DT bindings documentation

 .../devicetree/bindings/crypto/marvell-cesa.txt|   45 +
 .../devicetree/bindings/crypto/mv_cesa.txt |   31 +-
 drivers/crypto/Kconfig |   18 +
 drivers/crypto/Makefile|1 +
 drivers/crypto/marvell/Makefile|2 +
 drivers/crypto/marvell/cesa.c  |  544 
 drivers/crypto/marvell/cesa.h  |  804 +++
 drivers/crypto/marvell/cipher.c|  774 +++
 drivers/crypto/marvell/hash.c  | 1433 
 drivers/crypto/marvell/tdma.c  |  224 +++
 drivers/crypto/mv_cesa.c   |   60 +-
 11 files changed, 3912 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/crypto/marvell-cesa.txt
 create mode 100644 drivers/crypto/marvell/Makefile
 create mode 100644 drivers/crypto/marvell/cesa.c
 create mode 100644 drivers/crypto/marvell/cesa.h
 create mode 100644 drivers/crypto/marvell/cipher.c
 create mode 100644 drivers/crypto/marvell/hash.c
 create mode 100644 drivers/crypto/marvell/tdma.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/


[RESEND PATCH v4 04/14] crypto: add a new driver for Marvell's CESA

2015-06-12 Thread Boris Brezillon
The existing mv_cesa driver supports some features of the CESA IP but is
quite limited, and reworking it to support new features (like involving the
TDMA engine to offload the CPU) is almost impossible.
This driver has been rewritten from scratch to take those new features into
account.

This commit introduce the base infrastructure allowing us to add support
for DMA optimization.
It also includes support for one hash (SHA1) and one cipher (AES)
algorithm, and enable those features on the Armada 370 SoC.

Other algorithms and platforms will be added later on.

Signed-off-by: Boris Brezillon 
Signed-off-by: Arnaud Ebalard 
---
 drivers/crypto/Kconfig  |  16 +
 drivers/crypto/Makefile |   1 +
 drivers/crypto/marvell/Makefile |   2 +
 drivers/crypto/marvell/cesa.c   | 413 +++
 drivers/crypto/marvell/cesa.h   | 567 +++
 drivers/crypto/marvell/cipher.c | 320 ++
 drivers/crypto/marvell/hash.c   | 718 
 7 files changed, 2037 insertions(+)
 create mode 100644 drivers/crypto/marvell/Makefile
 create mode 100644 drivers/crypto/marvell/cesa.c
 create mode 100644 drivers/crypto/marvell/cesa.h
 create mode 100644 drivers/crypto/marvell/cipher.c
 create mode 100644 drivers/crypto/marvell/hash.c

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index a6bbea8..c15c5a5 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -174,6 +174,22 @@ config CRYPTO_DEV_MV_CESA
 
  Currently the driver supports AES in ECB and CBC mode without DMA.
 
+config CRYPTO_DEV_MARVELL_CESA
+   tristate "New Marvell's Cryptographic Engine driver"
+   depends on (PLAT_ORION || ARCH_MVEBU || COMPILE_TEST) && HAS_DMA && 
HAS_IOMEM
+   select CRYPTO_ALGAPI
+   select CRYPTO_AES
+   select CRYPTO_DES
+   select CRYPTO_BLKCIPHER2
+   select CRYPTO_HASH
+   select SRAM
+   help
+ This driver allows you to utilize the Cryptographic Engines and
+ Security Accelerator (CESA) which can be found on the Armada 370.
+
+ This driver is aimed at replacing the mv_cesa driver. This will only
+ happen once it has received proper testing.
+
 config CRYPTO_DEV_NIAGARA2
tristate "Niagara2 Stream Processing Unit driver"
select CRYPTO_DES
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index fb84be7..e35c07a 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_CRYPTO_DEV_HIFN_795X) += hifn_795x.o
 obj-$(CONFIG_CRYPTO_DEV_IMGTEC_HASH) += img-hash.o
 obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o
 obj-$(CONFIG_CRYPTO_DEV_MV_CESA) += mv_cesa.o
+obj-$(CONFIG_CRYPTO_DEV_MARVELL_CESA) += marvell/
 obj-$(CONFIG_CRYPTO_DEV_MXS_DCP) += mxs-dcp.o
 obj-$(CONFIG_CRYPTO_DEV_NIAGARA2) += n2_crypto.o
 n2_crypto-y := n2_core.o n2_asm.o
diff --git a/drivers/crypto/marvell/Makefile b/drivers/crypto/marvell/Makefile
new file mode 100644
index 000..68d0982
--- /dev/null
+++ b/drivers/crypto/marvell/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CRYPTO_DEV_MARVELL_CESA) += marvell-cesa.o
+marvell-cesa-objs := cesa.o cipher.o hash.o
diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
new file mode 100644
index 000..8d90e28
--- /dev/null
+++ b/drivers/crypto/marvell/cesa.c
@@ -0,0 +1,413 @@
+/*
+ * Support for Marvell's Cryptographic Engine and Security Accelerator (CESA)
+ * that can be found on the following platform: Orion, Kirkwood, Armada. This
+ * driver supports the TDMA engine on platforms on which it is available.
+ *
+ * Author: Boris Brezillon 
+ * Author: Arnaud Ebalard 
+ *
+ * This work is based on an initial version written by
+ * Sebastian Andrzej Siewior < sebastian at breakpoint dot cc >
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cesa.h"
+
+struct mv_cesa_dev *cesa_dev;
+
+static void mv_cesa_dequeue_req_unlocked(struct mv_cesa_engine *engine)
+{
+   struct crypto_async_request *req;
+   struct mv_cesa_ctx *ctx;
+
+   spin_lock_bh(&cesa_dev->lock);
+   req = crypto_dequeue_request(&cesa_dev->queue);
+   engine->req = req;
+   spin_unlock_bh(&cesa_dev->lock);
+
+   if (!req)
+   return;
+
+   ctx = crypto_tfm_ctx(req->tfm);
+   ctx->ops->prepare(req, engine);
+   ctx->ops->step(req);
+}
+
+static irqreturn_t mv_cesa_int(int irq, void *priv)
+{
+   struct mv_cesa_engine *engine = priv;
+   struct crypto_async_request *req;
+   struct mv_cesa_ctx *ctx;
+   u32 status, mask;
+   irqreturn_t ret = IRQ_NONE;
+
+   while (true) {
+   int res;
+
+ 

[RESEND PATCH v4 13/14] crypto: marvell/CESA: add support for Kirkwood and Dove SoCs

2015-06-12 Thread Boris Brezillon
From: Arnaud Ebalard 

Add the Kirkwood and Dove SoC descriptions, and control the allhwsupport
module parameter to avoid probing the CESA IP when the old CESA driver is
enabled (unless it is explicitly requested to do so).

Signed-off-by: Arnaud Ebalard 
Signed-off-by: Boris Brezillon 
---
 drivers/crypto/marvell/cesa.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index bd54973..3546ee7 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -211,6 +211,15 @@ static const struct mv_cesa_caps orion_caps = {
.has_tdma = false,
 };
 
+static const struct mv_cesa_caps kirkwood_caps = {
+   .nengines = 1,
+   .cipher_algs = orion_cipher_algs,
+   .ncipher_algs = ARRAY_SIZE(orion_cipher_algs),
+   .ahash_algs = orion_ahash_algs,
+   .nahash_algs = ARRAY_SIZE(orion_ahash_algs),
+   .has_tdma = true,
+};
+
 static const struct mv_cesa_caps armada_370_caps = {
.nengines = 1,
.cipher_algs = armada_370_cipher_algs,
@@ -231,6 +240,8 @@ static const struct mv_cesa_caps armada_xp_caps = {
 
 static const struct of_device_id mv_cesa_of_match_table[] = {
{ .compatible = "marvell,orion-crypto", .data = &orion_caps },
+   { .compatible = "marvell,kirkwood-crypto", .data = &kirkwood_caps },
+   { .compatible = "marvell,dove-crypto", .data = &kirkwood_caps },
{ .compatible = "marvell,armada-370-crypto", .data = &armada_370_caps },
{ .compatible = "marvell,armada-xp-crypto", .data = &armada_xp_caps },
{ .compatible = "marvell,armada-375-crypto", .data = &armada_xp_caps },
@@ -379,7 +390,7 @@ static int mv_cesa_probe(struct platform_device *pdev)
caps = match->data;
}
 
-   if (caps == &orion_caps && !allhwsupport)
+   if ((caps == &orion_caps || caps == &kirkwood_caps) && !allhwsupport)
return -ENOTSUPP;
 
cesa = devm_kzalloc(dev, sizeof(*cesa), GFP_KERNEL);
-- 
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/


[RESEND PATCH v4 07/14] crypto: marvell/CESA: add Triple-DES support

2015-06-12 Thread Boris Brezillon
From: Arnaud Ebalard 

Add support for Triple-DES operations.

Signed-off-by: Arnaud Ebalard 
Signed-off-by: Boris Brezillon 
---
 drivers/crypto/marvell/cesa.c   |   2 +
 drivers/crypto/marvell/cesa.h   |   2 +
 drivers/crypto/marvell/cipher.c | 147 
 3 files changed, 151 insertions(+)

diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index 47c9ef8..b9f4d26 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -167,6 +167,8 @@ static void mv_cesa_remove_algs(struct mv_cesa_dev *cesa)
 static struct crypto_alg *armada_370_cipher_algs[] = {
&mv_cesa_ecb_des_alg,
&mv_cesa_cbc_des_alg,
+   &mv_cesa_ecb_des3_ede_alg,
+   &mv_cesa_cbc_des3_ede_alg,
&mv_cesa_ecb_aes_alg,
&mv_cesa_cbc_aes_alg,
 };
diff --git a/drivers/crypto/marvell/cesa.h b/drivers/crypto/marvell/cesa.h
index 5d91da3..d886280 100644
--- a/drivers/crypto/marvell/cesa.h
+++ b/drivers/crypto/marvell/cesa.h
@@ -792,6 +792,8 @@ extern struct ahash_alg mv_ahmac_sha1_alg;
 
 extern struct crypto_alg mv_cesa_ecb_des_alg;
 extern struct crypto_alg mv_cesa_cbc_des_alg;
+extern struct crypto_alg mv_cesa_ecb_des3_ede_alg;
+extern struct crypto_alg mv_cesa_cbc_des3_ede_alg;
 extern struct crypto_alg mv_cesa_ecb_aes_alg;
 extern struct crypto_alg mv_cesa_cbc_aes_alg;
 
diff --git a/drivers/crypto/marvell/cipher.c b/drivers/crypto/marvell/cipher.c
index 2094a9e..d71262d 100644
--- a/drivers/crypto/marvell/cipher.c
+++ b/drivers/crypto/marvell/cipher.c
@@ -22,6 +22,11 @@ struct mv_cesa_des_ctx {
u8 key[DES_KEY_SIZE];
 };
 
+struct mv_cesa_des3_ctx {
+   struct mv_cesa_ctx base;
+   u8 key[DES3_EDE_KEY_SIZE];
+};
+
 struct mv_cesa_aes_ctx {
struct mv_cesa_ctx base;
struct crypto_aes_ctx aes;
@@ -253,6 +258,22 @@ static int mv_cesa_des_setkey(struct crypto_ablkcipher 
*cipher, const u8 *key,
return 0;
 }
 
+static int mv_cesa_des3_ede_setkey(struct crypto_ablkcipher *cipher,
+  const u8 *key, unsigned int len)
+{
+   struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
+   struct mv_cesa_des_ctx *ctx = crypto_tfm_ctx(tfm);
+
+   if (len != DES3_EDE_KEY_SIZE) {
+   crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
+   return -EINVAL;
+   }
+
+   memcpy(ctx->key, key, DES3_EDE_KEY_SIZE);
+
+   return 0;
+}
+
 static int mv_cesa_ablkcipher_dma_req_init(struct ablkcipher_request *req,
const struct mv_cesa_op_ctx *op_templ)
 {
@@ -491,6 +512,132 @@ struct crypto_alg mv_cesa_cbc_des_alg = {
},
 };
 
+static int mv_cesa_des3_op(struct ablkcipher_request *req,
+  struct mv_cesa_op_ctx *tmpl)
+{
+   struct mv_cesa_des3_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
+   int ret;
+
+   mv_cesa_update_op_cfg(tmpl, CESA_SA_DESC_CFG_CRYPTM_3DES,
+ CESA_SA_DESC_CFG_CRYPTM_MSK);
+
+   memcpy(tmpl->ctx.blkcipher.key, ctx->key, DES3_EDE_KEY_SIZE);
+
+   ret = mv_cesa_ablkcipher_req_init(req, tmpl);
+   if (ret)
+   return ret;
+
+   ret = mv_cesa_queue_req(&req->base);
+   if (ret && ret != -EINPROGRESS)
+   mv_cesa_ablkcipher_cleanup(req);
+
+   return ret;
+}
+
+static int mv_cesa_ecb_des3_ede_encrypt(struct ablkcipher_request *req)
+{
+   struct mv_cesa_op_ctx tmpl;
+
+   mv_cesa_set_op_cfg(&tmpl,
+  CESA_SA_DESC_CFG_CRYPTCM_ECB |
+  CESA_SA_DESC_CFG_3DES_EDE |
+  CESA_SA_DESC_CFG_DIR_ENC);
+
+   return mv_cesa_des3_op(req, &tmpl);
+}
+
+static int mv_cesa_ecb_des3_ede_decrypt(struct ablkcipher_request *req)
+{
+   struct mv_cesa_op_ctx tmpl;
+
+   mv_cesa_set_op_cfg(&tmpl,
+  CESA_SA_DESC_CFG_CRYPTCM_ECB |
+  CESA_SA_DESC_CFG_3DES_EDE |
+  CESA_SA_DESC_CFG_DIR_DEC);
+
+   return mv_cesa_des3_op(req, &tmpl);
+}
+
+struct crypto_alg mv_cesa_ecb_des3_ede_alg = {
+   .cra_name = "ecb(des3_ede)",
+   .cra_driver_name = "mv-ecb-des3-ede",
+   .cra_priority = 300,
+   .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC,
+   .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+   .cra_ctxsize = sizeof(struct mv_cesa_des3_ctx),
+   .cra_alignmask = 0,
+   .cra_type = &crypto_ablkcipher_type,
+   .cra_module = THIS_MODULE,
+   .cra_init = mv_cesa_ablkcipher_cra_init,
+   .cra_u = {
+   .ablkcipher = {
+   .min_keysize = DES3_EDE_KEY_SIZE,
+   .max_keysize = DES3_EDE_KEY_SIZE,
+   .ivsize  = DES3_EDE_BLOCK_SIZE,
+   .setkey = mv_cesa_des3_ede_setkey,
+   .encrypt = mv_cesa_ecb_des3_ede_encrypt,
+

[PATCH 3/7] input: cyapa: add proximity function support for gen5 and gen6 modules

2015-06-12 Thread Dudley Du
Gen5 and Gen6 trackpad devices are able to detect and report object proximity
data/events, add this function support in the cyapa driver through the
MTB protocl ABS_MT_DISTANCE event.
TEST=test on Chromebook.

Signed-off-by: Dudley Du 
---
 drivers/input/mouse/cyapa.c  | 19 -
 drivers/input/mouse/cyapa.h  |  4 +++
 drivers/input/mouse/cyapa_gen3.c |  2 ++
 drivers/input/mouse/cyapa_gen5.c | 61 +++-
 drivers/input/mouse/cyapa_gen6.c | 19 +
 5 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index c252faf..4146ab7 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -39,6 +39,11 @@ const char product_id[] = "CYTRA";
 
 static int cyapa_reinitialize(struct cyapa *cyapa);
 
+int cyapa_set_not_supported(struct cyapa *cyapa, bool enable)
+{
+   return -EOPNOTSUPP;
+}
+
 bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
 {
if (cyapa->gen == CYAPA_GEN6 && cyapa->state == CYAPA_STATE_GEN6_BL)
@@ -477,6 +482,8 @@ static int cyapa_create_input_dev(struct cyapa *cyapa)
if (cyapa->gen >= CYAPA_GEN5) {
input_set_abs_params(input, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
input_set_abs_params(input, ABS_MT_WIDTH_MINOR, 0, 255, 0, 0);
+
+   input_set_abs_params(input, ABS_MT_DISTANCE, 0, 1, 0, 0);
}
 
input_abs_set_res(input, ABS_MT_POSITION_X,
@@ -1340,6 +1347,13 @@ static int __maybe_unused cyapa_suspend(struct device 
*dev)
error);
}
 
+   /*
+* Disable proximity interrupt when system idle, want true touch to
+* wake the system.
+*/
+   if (cyapa->dev_pwr_mode != PWR_MODE_OFF)
+   cyapa->ops->set_proximity(cyapa, false);
+
if (device_may_wakeup(dev))
cyapa->irq_wake = (enable_irq_wake(client->irq) == 0);
 
@@ -1360,7 +1374,10 @@ static int __maybe_unused cyapa_resume(struct device 
*dev)
cyapa->irq_wake = false;
}
 
-   /* Update device states and runtime PM states. */
+   /*
+* Update device states and runtime PM states.
+* Re-Enable proximity interrupt after enter operational mode.
+*/
error = cyapa_reinitialize(cyapa);
if (error)
dev_warn(dev, "failed to reinitialize TP device: %d\n", error);
diff --git a/drivers/input/mouse/cyapa.h b/drivers/input/mouse/cyapa.h
index ec41404..090d5be 100644
--- a/drivers/input/mouse/cyapa.h
+++ b/drivers/input/mouse/cyapa.h
@@ -274,6 +274,8 @@ struct cyapa_dev_ops {
u8 *, int *, cb_sort);
 
int (*set_power_mode)(struct cyapa *, u8, u16);
+
+   int (*set_proximity)(struct cyapa *, bool);
 };
 
 struct cyapa_pip_cmd_states {
@@ -420,9 +422,11 @@ int cyapa_pip_bl_deactivate(struct cyapa *cyapa);
 ssize_t cyapa_pip_do_calibrate(struct device *dev,
 struct device_attribute *attr,
 const char *buf, size_t count);
+int cyapa_pip_set_proximity(struct cyapa *cyapa, bool enable);
 
 bool cyapa_pip_irq_cmd_handler(struct cyapa *cyapa);
 int cyapa_pip_irq_handler(struct cyapa *cyapa);
+int cyapa_set_not_supported(struct cyapa *cyapa, bool enable);
 
 
 extern u8 pip_read_sys_info[];
diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_gen3.c
index 5d50c0d..47004bb 100644
--- a/drivers/input/mouse/cyapa_gen3.c
+++ b/drivers/input/mouse/cyapa_gen3.c
@@ -1243,4 +1243,6 @@ const struct cyapa_dev_ops cyapa_gen3_ops = {
.irq_cmd_handler = cyapa_gen3_irq_cmd_handler,
.sort_empty_output_data = cyapa_gen3_empty_output_data,
.set_power_mode = cyapa_gen3_set_power_mode,
+
+   .set_proximity = cyapa_set_not_supported,
 };
diff --git a/drivers/input/mouse/cyapa_gen5.c b/drivers/input/mouse/cyapa_gen5.c
index 4462a78..d1cd7a7 100644
--- a/drivers/input/mouse/cyapa_gen5.c
+++ b/drivers/input/mouse/cyapa_gen5.c
@@ -52,6 +52,11 @@
 #define PIP_WAKEUP_EVENT_REPORT_ID  0x04
 #define PIP_PUSH_BTN_REPORT_ID  0x06
 #define GEN5_OLD_PUSH_BTN_REPORT_ID 0x05  /* Special for old Gen5 TP. */
+#define PIP_PROXIMITY_REPORT_ID 0x07
+
+#define PIP_PROXIMITY_REPORT_SIZE  6
+#define PIP_PROXIMITY_DISTANCE_OFFSET  0x05
+#define PIP_PROXIMITY_DISTANCE_MASK0x01
 
 #define PIP_TOUCH_REPORT_HEAD_SIZE 7
 #define PIP_TOUCH_REPORT_MAX_SIZE  127
@@ -78,6 +83,8 @@
 #define PIP_SENSING_MODE_MUTUAL_CAP_FINE   0x00
 #define PIP_SENSING_MODE_SELF_CAP  0x02
 
+#define PIP_SET_PROXIMITY  0x49
+
 /* Macro of Gen5 */
 #define GEN5_BL_MAX_OUTPUT_LENGTH 0x0100
 #define GEN5_APP_MAX_OUTPUT_LENGTH0x00fe
@@ -1517,6 +1524,28 @@ static int cyapa_gen5_disable_pip_report(struct cyapa 
*cyapa)
return 0;
 }
 
+int cyapa_pip_set_proximity(struct cyapa *cyapa, bool enable)
+{
+   u8 cmd[] = { 0x04, 0x00, 0x06, 0x00, 

[RESEND PATCH v4 14/14] crypto: marvell/CESA: add DT bindings documentation

2015-06-12 Thread Boris Brezillon
Add DT bindings documentation for the new marvell-cesa driver.

Signed-off-by: Boris Brezillon 
---
 .../devicetree/bindings/crypto/marvell-cesa.txt| 45 ++
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/marvell-cesa.txt

diff --git a/Documentation/devicetree/bindings/crypto/marvell-cesa.txt 
b/Documentation/devicetree/bindings/crypto/marvell-cesa.txt
new file mode 100644
index 000..c6c6a4a0
--- /dev/null
+++ b/Documentation/devicetree/bindings/crypto/marvell-cesa.txt
@@ -0,0 +1,45 @@
+Marvell Cryptographic Engines And Security Accelerator
+
+Required properties:
+- compatible: should be one of the following string
+ "marvell,orion-crypto"
+ "marvell,kirkwood-crypto"
+ "marvell,dove-crypto"
+ "marvell,armada-370-crypto"
+ "marvell,armada-xp-crypto"
+ "marvell,armada-375-crypto"
+ "marvell,armada-38x-crypto"
+- reg: base physical address of the engine and length of memory mapped
+   region. Can also contain an entry for the SRAM attached to the CESA,
+   but this representation is deprecated and marvell,crypto-srams should
+   be used instead
+- reg-names: "regs". Can contain an "sram" entry, but this representation
+is deprecated and marvell,crypto-srams should be used instead
+- interrupts: interrupt number
+- clocks: reference to the crypto engines clocks. This property is not
+ required for orion and kirkwood platforms
+- clock-names: "cesaX" and "cesazX", X should be replaced by the crypto engine
+  id.
+  This property is not required for the orion and kirkwoord
+  platforms.
+  "cesazX" clocks are not required on armada-370 platforms
+- marvell,crypto-srams: phandle to crypto SRAM definitions
+
+Optional properties:
+- marvell,crypto-sram-size: SRAM size reserved for crypto operations, if not
+   specified the whole SRAM is used (2KB)
+
+
+Examples:
+
+   crypto@9 {
+   compatible = "marvell,armada-xp-crypto";
+   reg = <0x9 0x1>;
+   reg-names = "regs";
+   interrupts = <48>, <49>;
+   clocks = <&gateclk 23>, <&gateclk 23>;
+   clock-names = "cesa0", "cesa1";
+   marvell,crypto-srams = <&crypto_sram0>, <&crypto_sram1>;
+   marvell,crypto-sram-size = <0x600>;
+   status = "okay";
+   };
-- 
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 0/7] instruction of cyapa gen6 and proximity patches

2015-06-12 Thread Dudley Du
V0 patches mainly have following updates:
1) Add Gen6 trackpad device support;
2) Add report proximity data function support for Gen5 and Gen6 devices;
3) Fully support runtime suspend/resume power management;
4) Add of_match_table mechanism support.


This patch series is mainly amied to add new gen6 trackpad devices support,
and also new function to report proximity data/vent for Gen5 and Gen6 trackpad
devices.


Dudley Du (7):
  input: cyapa: change strings of gen5 to pip in the name when they are
shared
  input: cyapa: add gen6 device module support in driver
  input: cyapa: add proximity function support for gen5 and gen6 modules
  input: cyapa: fully support runtime suspend power management
  input: cyapa: add proximity and interrupt sysfs interfaces support
  input: cyapa: add of match device support and description document
  input: cyapa: add CYAP0002 Gen6 device for ACPI configuration

 .../devicetree/bindings/input/cypress,cyapa.txt|   44 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/input/mouse/Makefile   |2 +-
 drivers/input/mouse/cyapa.c|  254 +++-
 drivers/input/mouse/cyapa.h|  158 ++-
 drivers/input/mouse/cyapa_gen3.c   |9 +-
 drivers/input/mouse/cyapa_gen5.c   | 1243 +++-
 drivers/input/mouse/cyapa_gen6.c   |  762 
 8 files changed, 1844 insertions(+), 629 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/cypress,cyapa.txt
 create mode 100644 drivers/input/mouse/cyapa_gen6.c

-- 
1.9.1


---
This message and any attachments may contain Cypress (or its
subsidiaries) confidential information. If it has been received
in error, please advise the sender and immediately delete this
message.
---

--
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 7/7] input: cyapa: add CYAP0002 Gen6 device for ACPI configuration

2015-06-12 Thread Dudley Du
Add CYTP0002 name for Gen6 device for ACPI configuration
TEST=test on Chromebook.

Signed-off-by: Dudley Du 
---
 drivers/input/mouse/cyapa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index 7e7613f..24302d6 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -1558,6 +1558,7 @@ MODULE_DEVICE_TABLE(i2c, cyapa_id_table);
 static const struct acpi_device_id cyapa_acpi_id[] = {
{ "CYAP", 0 },  /* Gen3 trackpad with 0x67 I2C address. */
{ "CYAP0001", 0 },  /* Gen5 trackpad with 0x24 I2C address. */
+   { "CYAP0002", 0 },  /* Gen6 trackpad with 0x24 I2C address. */
{ }
 };
 MODULE_DEVICE_TABLE(acpi, cyapa_acpi_id);
-- 
1.9.1


---
This message and any attachments may contain Cypress (or its
subsidiaries) confidential information. If it has been received
in error, please advise the sender and immediately delete this
message.
---

--
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] input: cyapa: add gen6 device module support in driver

2015-06-12 Thread Dudley Du
Based on the cyapa core, add the gen6 trackpad device's basic functions
supported, so gen6 trackpad device can work with kernel input system.
And also based on the state parse interface, the cyapa driver can
automatically determine the attached is gen3, gen5 or gen6 protocol
trackpad device, then set the correct protocol to work with the attached
trackpad device.
TEST=test on Chromebook.

Signed-off-by: Dudley Du 
---
 drivers/input/mouse/Makefile |   2 +-
 drivers/input/mouse/cyapa.c  |  22 ++
 drivers/input/mouse/cyapa.h  |  15 +
 drivers/input/mouse/cyapa_gen5.c |  69 +++-
 drivers/input/mouse/cyapa_gen6.c | 729 +++
 5 files changed, 833 insertions(+), 4 deletions(-)
 create mode 100644 drivers/input/mouse/cyapa_gen6.c

diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 793300b..ee6a6e9 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -24,7 +24,7 @@ obj-$(CONFIG_MOUSE_SYNAPTICS_I2C) += synaptics_i2c.o
 obj-$(CONFIG_MOUSE_SYNAPTICS_USB)  += synaptics_usb.o
 obj-$(CONFIG_MOUSE_VSXXXAA)+= vsxxxaa.o
 
-cyapatp-objs := cyapa.o cyapa_gen3.o cyapa_gen5.o
+cyapatp-objs := cyapa.o cyapa_gen3.o cyapa_gen5.o cyapa_gen6.o
 psmouse-objs := psmouse-base.o synaptics.o focaltech.o
 
 psmouse-$(CONFIG_MOUSE_PS2_ALPS)   += alps.o
diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index e7d4226..c252faf 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -41,6 +41,9 @@ static int cyapa_reinitialize(struct cyapa *cyapa);
 
 bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
 {
+   if (cyapa->gen == CYAPA_GEN6 && cyapa->state == CYAPA_STATE_GEN6_BL)
+   return true;
+
if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_BL)
return true;
 
@@ -49,6 +52,9 @@ bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
 
 bool cyapa_is_pip_app_mode(struct cyapa *cyapa)
 {
+   if (cyapa->gen == CYAPA_GEN6 && cyapa->state == CYAPA_STATE_GEN6_APP)
+   return true;
+
if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_APP)
return true;
 
@@ -204,6 +210,15 @@ static int cyapa_get_state(struct cyapa *cyapa)
if (!error)
goto out_detected;
}
+   if (cyapa->gen == CYAPA_GEN_UNKNOWN ||
+   cyapa->gen == CYAPA_GEN6 ||
+   cyapa->gen == CYAPA_GEN5) {
+   error = cyapa_pip_state_parse(cyapa,
+   status, BL_STATUS_SIZE);
+   if (!error)
+   goto out_detected;
+   }
+   /* For old Gen5 trackpads detecting. */
if ((cyapa->gen == CYAPA_GEN_UNKNOWN ||
cyapa->gen == CYAPA_GEN5) &&
!smbus && even_addr) {
@@ -300,6 +315,9 @@ static int cyapa_check_is_operational(struct cyapa *cyapa)
return error;
 
switch (cyapa->gen) {
+   case CYAPA_GEN6:
+   cyapa->ops = &cyapa_gen6_ops;
+   break;
case CYAPA_GEN5:
cyapa->ops = &cyapa_gen5_ops;
break;
@@ -579,6 +597,8 @@ static int cyapa_initialize(struct cyapa *cyapa)
error = cyapa_gen3_ops.initialize(cyapa);
if (!error)
error = cyapa_gen5_ops.initialize(cyapa);
+   if (!error)
+   error = cyapa_gen6_ops.initialize(cyapa);
if (error)
return error;
 
@@ -1136,9 +1156,11 @@ static char *cyapa_state_to_string(struct cyapa *cyapa)
case CYAPA_STATE_BL_ACTIVE:
return "bootloader active";
case CYAPA_STATE_GEN5_BL:
+   case CYAPA_STATE_GEN6_BL:
return "bootloader";
case CYAPA_STATE_OP:
case CYAPA_STATE_GEN5_APP:
+   case CYAPA_STATE_GEN6_APP:
return "operational";  /* Normal valid state. */
default:
return "invalid mode";
diff --git a/drivers/input/mouse/cyapa.h b/drivers/input/mouse/cyapa.h
index e932d1c..ec41404 100644
--- a/drivers/input/mouse/cyapa.h
+++ b/drivers/input/mouse/cyapa.h
@@ -19,6 +19,7 @@
 #define CYAPA_GEN_UNKNOWN   0x00   /* unknown protocol. */
 #define CYAPA_GEN3   0x03   /* support MT-protocol B with tracking ID. */
 #define CYAPA_GEN5   0x05   /* support TrueTouch GEN5 trackpad device. */
+#define CYAPA_GEN6   0x06   /* support TrueTouch GEN6 trackpad device. */
 
 #define CYAPA_NAME   "Cypress APA Trackpad (cyapa)"
 
@@ -198,6 +199,9 @@
 #define PIP_BL_APP_INFO_RESP_LENGTH30
 #define PIP_BL_GET_INFO_RESP_LENGTH19
 
+#define PIP_BL_PLATFORM_VER_SHIFT  4
+#define PIP_BL_PLATFORM_VER_MASK   0x0f
+
 #define PIP_PRODUCT_FAMILY_MASK0xf000
 #define PIP_PRODUCT_FAMILY_TRACKPAD0x1000
 
@@ -299,6 +303,14 @

[PATCH 5/7] input: cyapa: add proximity and interrupt sysfs interfaces support

2015-06-12 Thread Dudley Du
Add proximity and interrupt control interfaces in sysfs device node.
The proximity interface is used to disable/enable proximity function in device.
The interrupt interface is used to disbale/enable interrupt from device.
TEST=test on Chromebook.

Signed-off-by: Dudley Du 
---
 drivers/input/mouse/cyapa.c  | 101 +++
 drivers/input/mouse/cyapa.h  |   4 ++
 drivers/input/mouse/cyapa_gen3.c |   1 +
 drivers/input/mouse/cyapa_gen5.c |   2 +
 drivers/input/mouse/cyapa_gen6.c |  14 ++
 5 files changed, 122 insertions(+)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index faead4d..86f2263 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -594,6 +594,7 @@ static int cyapa_initialize(struct cyapa *cyapa)
 
cyapa->state = CYAPA_STATE_NO_DEVICE;
cyapa->gen = CYAPA_GEN_UNKNOWN;
+   cyapa->interrupt = true;
mutex_init(&cyapa->state_sync_lock);
 
/*
@@ -1217,12 +1218,110 @@ static ssize_t cyapa_show_mode(struct device *dev,
return size;
 }
 
+static ssize_t cyapa_show_interrupt(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   struct cyapa *cyapa = dev_get_drvdata(dev);
+   int size;
+   int error;
+
+   error = mutex_lock_interruptible(&cyapa->state_sync_lock);
+   if (error)
+   return error;
+
+   size = scnprintf(buf, PAGE_SIZE, "%d\n", cyapa->interrupt ? 1 : 0);
+
+   mutex_unlock(&cyapa->state_sync_lock);
+   return size;
+}
+
+static ssize_t cyapa_interrupt_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct cyapa *cyapa = dev_get_drvdata(dev);
+   u16 value;
+   int error;
+
+   if (cyapa->gen < CYAPA_GEN6)
+   return -EOPNOTSUPP;
+
+   if (kstrtou16(buf, 10, &value)) {
+   dev_err(dev, "invalid interrupt set parameter\n");
+   return -EINVAL;
+   }
+
+   error = mutex_lock_interruptible(&cyapa->state_sync_lock);
+   if (error)
+   return error;
+
+   if (cyapa->operational)
+   error = cyapa->ops->set_interrupt(cyapa,
+ value ? true : false);
+   else
+   error = -EBUSY;  /* Still running in bootloader mode. */
+
+   mutex_unlock(&cyapa->state_sync_lock);
+   return error < 0 ? error : count;
+}
+
+static ssize_t cyapa_show_proximity(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   struct cyapa *cyapa = dev_get_drvdata(dev);
+   int size;
+   int error;
+
+   error = mutex_lock_interruptible(&cyapa->state_sync_lock);
+   if (error)
+   return error;
+
+   size = scnprintf(buf, PAGE_SIZE, "%d\n", cyapa->proximity ? 1 : 0);
+
+   mutex_unlock(&cyapa->state_sync_lock);
+   return size;
+}
+
+static ssize_t cyapa_proximity_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct cyapa *cyapa = dev_get_drvdata(dev);
+   u16 value;
+   int error;
+
+   if (cyapa->gen < CYAPA_GEN5)
+   return -EOPNOTSUPP;
+
+   if (kstrtou16(buf, 10, &value)) {
+   dev_err(dev, "invalid set value of proximity\n");
+   return -EINVAL;
+   }
+
+   error = mutex_lock_interruptible(&cyapa->state_sync_lock);
+   if (error)
+   return error;
+
+   if (cyapa->operational)
+   error = cyapa->ops->set_proximity(cyapa,
+ value ? true : false);
+   else
+   error = -EBUSY;  /* Still running in bootloader mode. */
+
+   mutex_unlock(&cyapa->state_sync_lock);
+   return error < 0 ? error : count;
+}
+
 static DEVICE_ATTR(firmware_version, S_IRUGO, cyapa_show_fm_ver, NULL);
 static DEVICE_ATTR(product_id, S_IRUGO, cyapa_show_product_id, NULL);
 static DEVICE_ATTR(update_fw, S_IWUSR, NULL, cyapa_update_fw_store);
 static DEVICE_ATTR(baseline, S_IRUGO, cyapa_show_baseline, NULL);
 static DEVICE_ATTR(calibrate, S_IWUSR, NULL, cyapa_calibrate_store);
 static DEVICE_ATTR(mode, S_IRUGO, cyapa_show_mode, NULL);
+static DEVICE_ATTR(interrupt, S_IRUGO | S_IWUSR,
+  cyapa_show_interrupt, cyapa_interrupt_store);
+static DEVICE_ATTR(proximity, S_IRUGO | S_IWUSR,
+  cyapa_show_proximity, cyapa_proximity_store);
 
 static struct attribute *cyapa_sysfs_entries[] = {
&dev_attr_firmware_version.attr,
@@ -1231,6 +1330,8 @@ static struct attribute *cyapa_sysfs_entries[] = {
&dev_attr_baseline.attr,
&dev_attr_calibrate.attr,
&dev_attr_mode.attr,
+   &dev_attr_interrupt.attr,
+   &dev_attr_prox

[PATCH 1/7] input: cyapa: change strings of gen5 to pip in the name when they are shared

2015-06-12 Thread Dudley Du
Change strings 'gen5' to 'pip' for all macros, varibales and functions when
they are shared to be used in for gen5 and gen6 modules. The change of these
strings is aimed to keep name definition much more clear and readable.
TEST=test on Chromebook.

Signed-off-by: Dudley Du 
---
 drivers/input/mouse/cyapa.c  |   22 +-
 drivers/input/mouse/cyapa.h  |  133 -
 drivers/input/mouse/cyapa_gen3.c |2 +-
 drivers/input/mouse/cyapa_gen5.c | 1092 ++
 4 files changed, 661 insertions(+), 588 deletions(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index efe1484..e7d4226 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -6,7 +6,7 @@
  *   Daniel Kurtz 
  *   Benson Leung 
  *
- * Copyright (C) 2011-2014 Cypress Semiconductor, Inc.
+ * Copyright (C) 2011-2015 Cypress Semiconductor, Inc.
  * Copyright (C) 2011-2012 Google, Inc.
  *
  * This file is subject to the terms and conditions of the GNU General Public
@@ -39,11 +39,27 @@ const char product_id[] = "CYTRA";
 
 static int cyapa_reinitialize(struct cyapa *cyapa);
 
-static inline bool cyapa_is_bootloader_mode(struct cyapa *cyapa)
+bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
 {
if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_BL)
return true;
 
+   return false;
+}
+
+bool cyapa_is_pip_app_mode(struct cyapa *cyapa)
+{
+   if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_APP)
+   return true;
+
+   return false;
+}
+
+static inline bool cyapa_is_bootloader_mode(struct cyapa *cyapa)
+{
+   if (cyapa_is_pip_bl_mode(cyapa))
+   return true;
+
if (cyapa->gen == CYAPA_GEN3 &&
cyapa->state >= CYAPA_STATE_BL_BUSY &&
cyapa->state <= CYAPA_STATE_BL_ACTIVE)
@@ -54,7 +70,7 @@ static inline bool cyapa_is_bootloader_mode(struct cyapa 
*cyapa)
 
 static inline bool cyapa_is_operational_mode(struct cyapa *cyapa)
 {
-   if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_APP)
+   if (cyapa_is_pip_app_mode(cyapa))
return true;
 
if (cyapa->gen == CYAPA_GEN3 && cyapa->state == CYAPA_STATE_OP)
diff --git a/drivers/input/mouse/cyapa.h b/drivers/input/mouse/cyapa.h
index adc9ed5..e932d1c 100644
--- a/drivers/input/mouse/cyapa.h
+++ b/drivers/input/mouse/cyapa.h
@@ -3,7 +3,7 @@
  *
  * Author: Dudley Du 
  *
- * Copyright (C) 2014 Cypress Semiconductor, Inc.
+ * Copyright (C) 2014-2015 Cypress Semiconductor, Inc.
  *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file COPYING in the main directory of this archive for
@@ -159,12 +159,86 @@
 
 #define AUTOSUSPEND_DELAY   2000 /* unit : ms */
 
-#define UNINIT_SLEEP_TIME 0x
-#define UNINIT_PWR_MODE   0xFF
-
 #define BTN_ONLY_MODE_NAME   "buttononly"
 #define OFF_MODE_NAME"off"
 
+/* Common macros for PIP interface. */
+#define PIP_HID_DESCRIPTOR_ADDR0x0001
+#define PIP_REPORT_DESCRIPTOR_ADDR 0x0002
+#define PIP_INPUT_REPORT_ADDR  0x0003
+#define PIP_OUTPUT_REPORT_ADDR 0x0004
+#define PIP_CMD_DATA_ADDR  0x0006
+
+#define PIP_RETERIVE_DATA_STRUCTURE0x24
+#define PIP_CMD_CALIBRATE  0x28
+#define PIP_BL_CMD_VERIFY_APP_INTEGRITY0x31
+#define PIP_BL_CMD_GET_BL_INFO 0x38
+#define PIP_BL_CMD_PROGRAM_VERIFY_ROW  0x39
+#define PIP_BL_CMD_LAUNCH_APP  0x3b
+#define PIP_BL_CMD_INITIATE_BL 0x48
+#define PIP_INVALID_CMD0xff
+
+#define PIP_HID_DESCRIPTOR_SIZE32
+#define PIP_HID_APP_REPORT_ID  0xf7
+#define PIP_HID_BL_REPORT_ID   0xff
+
+#define PIP_BL_CMD_REPORT_ID   0x40
+#define PIP_BL_RESP_REPORT_ID  0x30
+#define PIP_APP_CMD_REPORT_ID  0x2f
+#define PIP_APP_RESP_REPORT_ID 0x1f
+
+#define PIP_READ_SYS_INFO_CMD_LENGTH   7
+#define PIP_BL_READ_APP_INFO_CMD_LENGTH13
+#define PIP_MIN_BL_CMD_LENGTH  13
+#define PIP_MIN_BL_RESP_LENGTH 11
+#define PIP_MIN_APP_CMD_LENGTH 7
+#define PIP_MIN_APP_RESP_LENGTH5
+#define PIP_UNSUPPORTED_CMD_RESP_LENGTH6
+#define PIP_READ_SYS_INFO_RESP_LENGTH  71
+#define PIP_BL_APP_INFO_RESP_LENGTH30
+#define PIP_BL_GET_INFO_RESP_LENGTH19
+
+#define PIP_PRODUCT_FAMILY_MASK0xf000
+#define PIP_PRODUCT_FAMILY_TRACKPAD0x1000
+
+#define PIP_DEEP_SLEEP_STATE_ON0x00
+#define PIP_DEEP_SLEEP_STATE_OFF   0x01
+#define PIP_DEEP_SLEEP_STATE_MASK  0x03
+#define PIP_APP_DEEP_SLEEP_REPORT_ID   0xf0
+#define PIP_DEEP_SLEEP_RESP_LENGTH 5
+#define PIP_DEEP_SLEEP_OPCODE  0x08
+#define PIP_DEEP_SLEEP_OPCODE_MASK 0x0f
+
+#define PIP_RESP_LENGTH_OFFSET 0
+#definePIP_RESP_LENGTH_SIZE2
+#define PIP_RESP_REPORT_ID_OFFSET  2
+#define PIP_RESP_RSVD_OFFSET   3
+#define

[PATCH 6/7] input: cyapa: add of match device support and description document

2015-06-12 Thread Dudley Du
Add of_match_device machanism support for Cypress trackpad device, and
add the sample description document of adding the trackpad device node in DT.
TEST=test on Chromebook.

Signed-off-by: Dudley Du 
---
 .../devicetree/bindings/input/cypress,cyapa.txt| 44 ++
 .../devicetree/bindings/vendor-prefixes.txt|  1 +
 drivers/input/mouse/cyapa.c| 10 +
 3 files changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/cypress,cyapa.txt

diff --git a/Documentation/devicetree/bindings/input/cypress,cyapa.txt 
b/Documentation/devicetree/bindings/input/cypress,cyapa.txt
new file mode 100644
index 000..9be2b44
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/cypress,cyapa.txt
@@ -0,0 +1,44 @@
+Cypress I2C Touchpad
+
+Required properties:
+- compatible: must be "cypress,cyapa".
+- reg: I2C address of the chip.
+- interrupt-parent: a phandle for the interrupt controller (see interrupt
+  binding[0]).
+- interrupts: interrupt to which the chip is connected (see interrupt
+  binding[0]).
+
+Optional properties:
+- wakeup-source: touchpad can be used as a wakeup source.
+- pinctrl-names: should be "default" (see pinctrl binding [1]).
+- pinctrl-0: a phandle pointing to the pin settings for the device (see
+  pinctrl binding [1]).
+- vcc-supply: a phandle for the regulator supplying 3.3V power.
+
+[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
+[1]: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+
+Example:
+   &i2c0 {
+   /* ... */
+
+   /* Cypress Gen3 touchpad */
+   touchpad@67 {
+   compatible = "cypress,cyapa";
+   reg = <0x24>;
+   interrupt-parent = <&gpio>;
+   interrupts = <2 IRQ_TYPE_EDGE_FALLING>; /* GPIO 2 */
+   wakeup-source;
+   };
+
+   /* Cypress Gen5 and later touchpad */
+   touchpad@24 {
+   compatible = "cypress,cyapa";
+   reg = <0x24>;
+   interrupt-parent = <&gpio>;
+   interrupts = <2 IRQ_TYPE_EDGE_FALLING>; /* GPIO 2 */
+   wakeup-source;
+   };
+
+   /* ... */
+   };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 728cd0e..4813437 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -48,6 +48,7 @@ cnxt  Conexant Systems, Inc.
 cortinaCortina Systems, Inc.
 cosmic Cosmic Circuits
 crystalfontz   Crystalfontz America, Inc.
+cypressCypress Semiconductor Corporation
 dallas Maxim Integrated Products (formerly Dallas Semiconductor)
 davicomDAVICOM Semiconductor, Inc.
 denx   Denx Software Engineering
diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index 86f2263..7e7613f 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "cyapa.h"
 
 
@@ -1562,12 +1563,21 @@ static const struct acpi_device_id cyapa_acpi_id[] = {
 MODULE_DEVICE_TABLE(acpi, cyapa_acpi_id);
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id cyapa_of_match[] = {
+   { .compatible = "cypress,cyapa" },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cyapa_of_match);
+#endif
+
 static struct i2c_driver cyapa_driver = {
.driver = {
.name = "cyapa",
.owner = THIS_MODULE,
.pm = &cyapa_pm_ops,
.acpi_match_table = ACPI_PTR(cyapa_acpi_id),
+   .of_match_table = of_match_ptr(cyapa_of_match),
},
 
.probe = cyapa_probe,
-- 
1.9.1


---
This message and any attachments may contain Cypress (or its
subsidiaries) confidential information. If it has been received
in error, please advise the sender and immediately delete this
message.
---

--
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/7] input: cyapa: fully support runtime suspend power management

2015-06-12 Thread Dudley Du
Fix the the runtime suspend power management not working issue when system
starts up and before user touches the trackpad device.
TEST=test on Chromebook.

Signed-off-by: Dudley Du 
---
 drivers/input/mouse/cyapa.c  | 79 +++-
 drivers/input/mouse/cyapa.h  |  2 +-
 drivers/input/mouse/cyapa_gen3.c |  4 +-
 drivers/input/mouse/cyapa_gen5.c | 21 +++
 drivers/input/mouse/cyapa_gen6.c |  4 +-
 5 files changed, 72 insertions(+), 38 deletions(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index 4146ab7..faead4d 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -371,7 +371,7 @@ static int cyapa_detect(struct cyapa *cyapa)
 static int cyapa_open(struct input_dev *input)
 {
struct cyapa *cyapa = input_get_drvdata(input);
-   struct i2c_client *client = cyapa->client;
+   struct device *dev = &cyapa->client->dev;
int error;
 
error = mutex_lock_interruptible(&cyapa->state_sync_lock);
@@ -385,10 +385,9 @@ static int cyapa_open(struct input_dev *input)
 * when in operational mode.
 */
error = cyapa->ops->set_power_mode(cyapa,
-   PWR_MODE_FULL_ACTIVE, 0);
+   PWR_MODE_FULL_ACTIVE, 0, false);
if (error) {
-   dev_warn(&client->dev,
-   "set active power failed: %d\n", error);
+   dev_warn(dev, "set active power failed: %d\n", error);
goto out;
}
} else {
@@ -399,11 +398,15 @@ static int cyapa_open(struct input_dev *input)
}
}
 
-   enable_irq(client->irq);
-   if (!pm_runtime_enabled(&client->dev)) {
-   pm_runtime_set_active(&client->dev);
-   pm_runtime_enable(&client->dev);
+   enable_irq(cyapa->client->irq);
+   if (!pm_runtime_enabled(dev)) {
+   pm_runtime_set_active(dev);
+   pm_runtime_enable(dev);
}
+
+   pm_runtime_get_sync(dev);
+   pm_runtime_mark_last_busy(dev);
+   pm_runtime_put_sync_autosuspend(dev);
 out:
mutex_unlock(&cyapa->state_sync_lock);
return error;
@@ -412,17 +415,17 @@ out:
 static void cyapa_close(struct input_dev *input)
 {
struct cyapa *cyapa = input_get_drvdata(input);
-   struct i2c_client *client = cyapa->client;
+   struct device *dev = &cyapa->client->dev;
 
mutex_lock(&cyapa->state_sync_lock);
 
-   disable_irq(client->irq);
-   if (pm_runtime_enabled(&client->dev))
-   pm_runtime_disable(&client->dev);
-   pm_runtime_set_suspended(&client->dev);
+   disable_irq(cyapa->client->irq);
+   if (pm_runtime_enabled(dev))
+   pm_runtime_disable(dev);
+   pm_runtime_set_suspended(dev);
 
if (cyapa->operational)
-   cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0);
+   cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0, false);
 
mutex_unlock(&cyapa->state_sync_lock);
 }
@@ -533,7 +536,7 @@ static void cyapa_enable_irq_for_cmd(struct cyapa *cyapa)
 */
if (!input || cyapa->operational)
cyapa->ops->set_power_mode(cyapa,
-   PWR_MODE_FULL_ACTIVE, 0);
+   PWR_MODE_FULL_ACTIVE, 0, false);
/* Gen3 always using polling mode for command. */
if (cyapa->gen >= CYAPA_GEN5)
enable_irq(cyapa->client->irq);
@@ -548,7 +551,8 @@ static void cyapa_disable_irq_for_cmd(struct cyapa *cyapa)
if (cyapa->gen >= CYAPA_GEN5)
disable_irq(cyapa->client->irq);
if (!input || cyapa->operational)
-   cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0);
+   cyapa->ops->set_power_mode(cyapa,
+  PWR_MODE_OFF, 0, false);
}
 }
 
@@ -615,7 +619,7 @@ static int cyapa_initialize(struct cyapa *cyapa)
 
/* Power down the device until we need it. */
if (cyapa->operational)
-   cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0);
+   cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0, false);
 
return 0;
 }
@@ -631,7 +635,8 @@ static int cyapa_reinitialize(struct cyapa *cyapa)
 
/* Avoid command failures when TP was in OFF state. */
if (cyapa->operational)
-   cyapa->ops->set_power_mode(cyapa, PWR_MODE_FULL_ACTIVE, 0);
+   cyapa->ops->set_power_mode(cyapa,
+  PWR_MODE_FULL_ACTIVE, 0, false);
 
error = cyapa_detect(cyapa);
if (error)
@@ -650,7 +655,8 @@ out:
if (!input || !input->users) {
/* Reset to power OFF state to save power when no user open. */

[PATCH] i2c-parport: start using pr_fmt

2015-06-12 Thread Sudip Mukherjee
Start using pr_fmt and convert all remaining printk to use
pr_* family of macros.

Signed-off-by: Sudip Mukherjee 
---
 drivers/i2c/busses/i2c-parport.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 9b94c3d..d53bf0b 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -20,6 +20,8 @@
GNU General Public License for more details.
  *  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -176,13 +178,13 @@ static void i2c_parport_attach(struct parport *port)
break;
}
if (i == MAX_DEVICE) {
-   pr_debug("i2c-parport: Not using parport%d.\n", port->number);
+   pr_debug("Not using parport%d.\n", port->number);
return;
}
 
adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL);
if (adapter == NULL) {
-   printk(KERN_ERR "i2c-parport: Failed to kzalloc\n");
+   pr_err("Failed to kzalloc\n");
return;
}
memset(&i2c_parport_cb, 0, sizeof(i2c_parport_cb));
@@ -190,12 +192,12 @@ static void i2c_parport_attach(struct parport *port)
i2c_parport_cb.irq_func = i2c_parport_irq;
i2c_parport_cb.private = adapter;
 
-   pr_debug("i2c-parport: attaching to %s\n", port->name);
+   pr_debug("attaching to %s\n", port->name);
parport_disable_irq(port);
adapter->pdev = parport_register_dev_model(port, "i2c-parport",
   &i2c_parport_cb, i);
if (!adapter->pdev) {
-   printk(KERN_ERR "i2c-parport: Unable to register with 
parport\n");
+   pr_err("Unable to register with parport\n");
goto err_free;
}
 
@@ -215,7 +217,7 @@ static void i2c_parport_attach(struct parport *port)
adapter->adapter.dev.parent = port->physport->dev;
 
if (parport_claim_or_block(adapter->pdev) < 0) {
-   printk(KERN_ERR "i2c-parport: Could not claim parallel port\n");
+   pr_err("Could not claim parallel port\n");
goto err_unregister;
}
 
@@ -230,7 +232,7 @@ static void i2c_parport_attach(struct parport *port)
}
 
if (i2c_bit_add_bus(&adapter->adapter) < 0) {
-   printk(KERN_ERR "i2c-parport: Unable to register with I2C\n");
+   pr_err("Unable to register with I2C\n");
goto err_unregister;
}
 
@@ -242,8 +244,7 @@ static void i2c_parport_attach(struct parport *port)
if (adapter->ara)
parport_enable_irq(port);
else
-   printk(KERN_WARNING "i2c-parport: Failed to register "
-  "ARA client\n");
+   pr_warn("Failed to register ARA client\n");
}
 
/* Add the new adapter to the list */
@@ -298,12 +299,12 @@ static struct parport_driver i2c_parport_driver = {
 static int __init i2c_parport_init(void)
 {
if (type < 0) {
-   printk(KERN_WARNING "i2c-parport: adapter type unspecified\n");
+   pr_warn("adapter type unspecified\n");
return -ENODEV;
}
 
if (type >= ARRAY_SIZE(adapter_parm)) {
-   printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type);
+   pr_warn("invalid type (%d)\n", type);
return -ENODEV;
}
 
-- 
1.8.1.2

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


Re: [PATCH v2] ASoC: Intel: sst: use ; instead of , at the of a C statement

2015-06-12 Thread Vinod Koul
On Thu, Jun 11, 2015 at 03:14:34PM +0200, Sebastian Andrzej Siewior wrote:
> This was spotted by Fernando Lopez-Lezcano 
> while he tried to compile a -RT kernel with this driver enabled.
> "make C=2" would also warn about this. This is is based on his patch.
> 
> Reported-by: Fernando Lopez-Lezcano 
> Signed-off-by: Sebastian Andrzej Siewior 
Acked-by: Vinod Koul 

-- 
~Vinod
> ---
> * Mats Karrman | 2015-06-11 15:04:25 [+0200]:
> 
> >>+   sst_shim_write64(shim, SST_IMRX, shim_regs->imrx):
> >Don't you mean ';' and not ':'?
> Interresting, yes I do. Thanks.
> 
>  sound/soc/intel/atom/sst/sst.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c
> index 96c2e420cce6..a4b458e77089 100644
> --- a/sound/soc/intel/atom/sst/sst.c
> +++ b/sound/soc/intel/atom/sst/sst.c
> @@ -368,8 +368,8 @@ static inline void sst_restore_shim64(struct 
> intel_sst_drv *ctx,
>* initialize by FW or driver when firmware is loaded
>*/
>   spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags);
> - sst_shim_write64(shim, SST_IMRX, shim_regs->imrx),
> - sst_shim_write64(shim, SST_CSR, shim_regs->csr),
> + sst_shim_write64(shim, SST_IMRX, shim_regs->imrx);
> + sst_shim_write64(shim, SST_CSR, shim_regs->csr);
>   spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags);
>  }
>  
> -- 
> 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 v5 00/24] Convert the posix_clock_operations and k_clock structure to ready for 2038

2015-06-12 Thread Baolin Wang
This patch series changes the 32-bit time types (timespec/itimerspec) to
the 64-bit types (timespec64/itimerspec64), since 32-bit time types will
break in the year 2038 on 32bit systems.

This patch series introduces new methods with timespec64/itimerspec64 type,
and removes the old ones with timespec/itimerspec type for 
posix_clock_operations
and k_clock structure.

---
Changes since v4:
- Rebase the patch series.
- Modify the subject line and the changelog.

Changes since v3:
- Fix some introducing bugs.

Changes since v2:
- Split the syscall conversion patch into small some patches.

Changes since V1:
- Split some patch into small patch.
- Add some default function for new 64bit methods for syscall function.
- Move do_sys_settimeofday() function to head file.
- Modify the EXPORT_SYMPOL issue.
- Add new 64bit methods in cputime_nsecs.h file.
---

Baolin Wang (24):
  time: Introduce struct itimerspec64
  timekeeping: Introduce current_kernel_time64()
  security: Introduce security_settime64()
  time: Introduce do_sys_settimeofday64()
  posix-timers: Introduce {get,put}_timespec and {get,put}_itimerspec
  posix-timers: Factor out the guts of 'timer_gettime'
  posix-timers: Implement y2038 safe timer_get64() callback
  posix-timers: Factor out the guts of 'timer_settime'
  posix-timers: Implement y2038 safe timer_set64() callback
  posix-timers: Factor out the guts of 'clock_settime'
  posix-timers: Implement y2038 safe clock_set64() callback
  posix-timers: Factor out the guts of 'clock_gettime'
  posix-timers: Implement y2038 safe clock_get64() callback
  posix-timers: Factor out the guts of 'clcok_getres'
  posix-timers: Implement y2038 safe clock_getres64() callback
  timekeeping: Change the implementation of timekeeping_clocktai()
  posix-timers: Convert to y2038 safe callbacks
  mmtimer: Convert to y2038 safe callbacks
  alarmtimer: Convert to y2038 safe callbacks
  posix-clock: Convert to y2038 safe callbacks
  time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64()
  cputime: Introduce cputime_to_timespec64()/timespec64_to_cputime()
  posix-cpu-timers: Convert to y2038 safe callbacks
  k_clock: Remove y2038 unsafe callbacks

 arch/powerpc/include/asm/cputime.h|6 +-
 arch/s390/include/asm/cputime.h   |8 +-
 drivers/char/mmtimer.c|   36 +++--
 drivers/ptp/ptp_clock.c   |   22 +--
 include/asm-generic/cputime_jiffies.h |   10 +-
 include/asm-generic/cputime_nsecs.h   |6 +-
 include/linux/cputime.h   |   16 ++
 include/linux/jiffies.h   |   21 ++-
 include/linux/lsm_hooks.h |5 +-
 include/linux/posix-clock.h   |   10 +-
 include/linux/posix-timers.h  |   18 +--
 include/linux/security.h  |   20 ++-
 include/linux/time64.h|   35 +
 include/linux/timekeeping.h   |   25 +++-
 kernel/time/alarmtimer.c  |   38 ++---
 kernel/time/posix-clock.c |   20 +--
 kernel/time/posix-cpu-timers.c|   84 ++-
 kernel/time/posix-timers.c|  257 +
 kernel/time/time.c|   19 +--
 kernel/time/timekeeping.c |6 +-
 security/commoncap.c  |2 +-
 security/security.c   |2 +-
 22 files changed, 412 insertions(+), 254 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/


[RESEND PATCH v4 10/14] crypto: marvell/CESA: add support for all armada SoCs

2015-06-12 Thread Boris Brezillon
Add CESA IP description for all the missing armada SoCs (XP, 375 and 38x).

Signed-off-by: Boris Brezillon 
---
 drivers/crypto/marvell/cesa.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index e4dfee0..087370e 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -191,8 +191,20 @@ static const struct mv_cesa_caps armada_370_caps = {
.has_tdma = true,
 };
 
+static const struct mv_cesa_caps armada_xp_caps = {
+   .nengines = 2,
+   .cipher_algs = armada_370_cipher_algs,
+   .ncipher_algs = ARRAY_SIZE(armada_370_cipher_algs),
+   .ahash_algs = armada_370_ahash_algs,
+   .nahash_algs = ARRAY_SIZE(armada_370_ahash_algs),
+   .has_tdma = true,
+};
+
 static const struct of_device_id mv_cesa_of_match_table[] = {
{ .compatible = "marvell,armada-370-crypto", .data = &armada_370_caps },
+   { .compatible = "marvell,armada-xp-crypto", .data = &armada_xp_caps },
+   { .compatible = "marvell,armada-375-crypto", .data = &armada_xp_caps },
+   { .compatible = "marvell,armada-38x-crypto", .data = &armada_xp_caps },
{}
 };
 MODULE_DEVICE_TABLE(of, mv_cesa_of_match_table);
-- 
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/


[RESEND PATCH v4 11/14] crypto: marvell/CESA: add allhwsupport module parameter

2015-06-12 Thread Boris Brezillon
The old and new marvell CESA drivers both support Orion and Kirkwood SoCs.
Add a module parameter to choose whether these SoCs should be attached to
the new or the old driver.

The default policy is to keep attaching those IPs to the old driver if it
is enabled, until we decide the new CESA driver is stable/secure enough.

Signed-off-by: Boris Brezillon 
---
 drivers/crypto/marvell/cesa.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index 087370e..c7e25a0 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -31,6 +31,10 @@
 
 #include "cesa.h"
 
+static int allhwsupport = !IS_ENABLED(CONFIG_CRYPTO_DEV_MV_CESA);
+module_param_named(allhwsupport, allhwsupport, int, 0444);
+MODULE_PARM_DESC(allhwsupport, "Enable support for all hardware (even it if 
overlaps with the mv_cesa driver)");
+
 struct mv_cesa_dev *cesa_dev;
 
 static void mv_cesa_dequeue_req_unlocked(struct mv_cesa_engine *engine)
-- 
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/


[RESEND PATCH v4 12/14] crypto: marvell/CESA: add support for Orion SoCs

2015-06-12 Thread Boris Brezillon
Add the Orion SoC description, and select this implementation by default
to support non-DT probing: Orion is the only platform where non-DT boards
are declaring the CESA block.

Control the allhwsupport module parameter to avoid probing the CESA IP when
the old CESA driver is enabled (unless it is explicitly requested to do
so).

Signed-off-by: Boris Brezillon 
---
 drivers/crypto/marvell/cesa.c | 42 +++---
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index c7e25a0..bd54973 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -168,6 +168,22 @@ static void mv_cesa_remove_algs(struct mv_cesa_dev *cesa)
crypto_unregister_alg(cesa->caps->cipher_algs[i]);
 }
 
+static struct crypto_alg *orion_cipher_algs[] = {
+   &mv_cesa_ecb_des_alg,
+   &mv_cesa_cbc_des_alg,
+   &mv_cesa_ecb_des3_ede_alg,
+   &mv_cesa_cbc_des3_ede_alg,
+   &mv_cesa_ecb_aes_alg,
+   &mv_cesa_cbc_aes_alg,
+};
+
+static struct ahash_alg *orion_ahash_algs[] = {
+   &mv_md5_alg,
+   &mv_sha1_alg,
+   &mv_ahmac_md5_alg,
+   &mv_ahmac_sha1_alg,
+};
+
 static struct crypto_alg *armada_370_cipher_algs[] = {
&mv_cesa_ecb_des_alg,
&mv_cesa_cbc_des_alg,
@@ -186,6 +202,15 @@ static struct ahash_alg *armada_370_ahash_algs[] = {
&mv_ahmac_sha256_alg,
 };
 
+static const struct mv_cesa_caps orion_caps = {
+   .nengines = 1,
+   .cipher_algs = orion_cipher_algs,
+   .ncipher_algs = ARRAY_SIZE(orion_cipher_algs),
+   .ahash_algs = orion_ahash_algs,
+   .nahash_algs = ARRAY_SIZE(orion_ahash_algs),
+   .has_tdma = false,
+};
+
 static const struct mv_cesa_caps armada_370_caps = {
.nengines = 1,
.cipher_algs = armada_370_cipher_algs,
@@ -205,6 +230,7 @@ static const struct mv_cesa_caps armada_xp_caps = {
 };
 
 static const struct of_device_id mv_cesa_of_match_table[] = {
+   { .compatible = "marvell,orion-crypto", .data = &orion_caps },
{ .compatible = "marvell,armada-370-crypto", .data = &armada_370_caps },
{ .compatible = "marvell,armada-xp-crypto", .data = &armada_xp_caps },
{ .compatible = "marvell,armada-375-crypto", .data = &armada_xp_caps },
@@ -330,7 +356,7 @@ static void mv_cesa_put_sram(struct platform_device *pdev, 
int idx)
 
 static int mv_cesa_probe(struct platform_device *pdev)
 {
-   const struct mv_cesa_caps *caps = NULL;
+   const struct mv_cesa_caps *caps = &orion_caps;
const struct mbus_dram_target_info *dram;
const struct of_device_id *match;
struct device *dev = &pdev->dev;
@@ -345,14 +371,16 @@ static int mv_cesa_probe(struct platform_device *pdev)
return -EEXIST;
}
 
-   if (!dev->of_node)
-   return -ENOTSUPP;
+   if (dev->of_node) {
+   match = of_match_node(mv_cesa_of_match_table, dev->of_node);
+   if (!match || !match->data)
+   return -ENOTSUPP;
 
-   match = of_match_node(mv_cesa_of_match_table, dev->of_node);
-   if (!match || !match->data)
-   return -ENOTSUPP;
+   caps = match->data;
+   }
 
-   caps = match->data;
+   if (caps == &orion_caps && !allhwsupport)
+   return -ENOTSUPP;
 
cesa = devm_kzalloc(dev, sizeof(*cesa), GFP_KERNEL);
if (!cesa)
-- 
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/


[RESEND PATCH v4 06/14] crypto: marvell/CESA: add DES support

2015-06-12 Thread Boris Brezillon
Add support for DES operations.

Signed-off-by: Boris Brezillon 
Signed-off-by: Arnaud Ebalard 
---
 drivers/crypto/marvell/cesa.c   |   2 +
 drivers/crypto/marvell/cesa.h   |   2 +
 drivers/crypto/marvell/cipher.c | 150 
 3 files changed, 154 insertions(+)

diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index 5a226c4..47c9ef8 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -165,6 +165,8 @@ static void mv_cesa_remove_algs(struct mv_cesa_dev *cesa)
 }
 
 static struct crypto_alg *armada_370_cipher_algs[] = {
+   &mv_cesa_ecb_des_alg,
+   &mv_cesa_cbc_des_alg,
&mv_cesa_ecb_aes_alg,
&mv_cesa_cbc_aes_alg,
 };
diff --git a/drivers/crypto/marvell/cesa.h b/drivers/crypto/marvell/cesa.h
index fcacc70..5d91da3 100644
--- a/drivers/crypto/marvell/cesa.h
+++ b/drivers/crypto/marvell/cesa.h
@@ -790,6 +790,8 @@ int mv_cesa_dma_add_op_transfers(struct mv_cesa_tdma_chain 
*chain,
 extern struct ahash_alg mv_sha1_alg;
 extern struct ahash_alg mv_ahmac_sha1_alg;
 
+extern struct crypto_alg mv_cesa_ecb_des_alg;
+extern struct crypto_alg mv_cesa_cbc_des_alg;
 extern struct crypto_alg mv_cesa_ecb_aes_alg;
 extern struct crypto_alg mv_cesa_cbc_aes_alg;
 
diff --git a/drivers/crypto/marvell/cipher.c b/drivers/crypto/marvell/cipher.c
index 8188fc2..2094a9e 100644
--- a/drivers/crypto/marvell/cipher.c
+++ b/drivers/crypto/marvell/cipher.c
@@ -13,9 +13,15 @@
  */
 
 #include 
+#include 
 
 #include "cesa.h"
 
+struct mv_cesa_des_ctx {
+   struct mv_cesa_ctx base;
+   u8 key[DES_KEY_SIZE];
+};
+
 struct mv_cesa_aes_ctx {
struct mv_cesa_ctx base;
struct crypto_aes_ctx aes;
@@ -223,6 +229,30 @@ static int mv_cesa_aes_setkey(struct crypto_ablkcipher 
*cipher, const u8 *key,
return 0;
 }
 
+static int mv_cesa_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
+ unsigned int len)
+{
+   struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
+   struct mv_cesa_des_ctx *ctx = crypto_tfm_ctx(tfm);
+   u32 tmp[DES_EXPKEY_WORDS];
+   int ret;
+
+   if (len != DES_KEY_SIZE) {
+   crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
+   return -EINVAL;
+   }
+
+   ret = des_ekey(tmp, key);
+   if (!ret && (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
+   tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
+   return -EINVAL;
+   }
+
+   memcpy(ctx->key, key, DES_KEY_SIZE);
+
+   return 0;
+}
+
 static int mv_cesa_ablkcipher_dma_req_init(struct ablkcipher_request *req,
const struct mv_cesa_op_ctx *op_templ)
 {
@@ -341,6 +371,126 @@ static int mv_cesa_ablkcipher_req_init(struct 
ablkcipher_request *req,
return ret;
 }
 
+static int mv_cesa_des_op(struct ablkcipher_request *req,
+ struct mv_cesa_op_ctx *tmpl)
+{
+   struct mv_cesa_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
+   int ret;
+
+   mv_cesa_update_op_cfg(tmpl, CESA_SA_DESC_CFG_CRYPTM_DES,
+ CESA_SA_DESC_CFG_CRYPTM_MSK);
+
+   memcpy(tmpl->ctx.blkcipher.key, ctx->key, DES_KEY_SIZE);
+
+   ret = mv_cesa_ablkcipher_req_init(req, tmpl);
+   if (ret)
+   return ret;
+
+   ret = mv_cesa_queue_req(&req->base);
+   if (ret && ret != -EINPROGRESS)
+   mv_cesa_ablkcipher_cleanup(req);
+
+   return ret;
+}
+
+static int mv_cesa_ecb_des_encrypt(struct ablkcipher_request *req)
+{
+   struct mv_cesa_op_ctx tmpl;
+
+   mv_cesa_set_op_cfg(&tmpl,
+  CESA_SA_DESC_CFG_CRYPTCM_ECB |
+  CESA_SA_DESC_CFG_DIR_ENC);
+
+   return mv_cesa_des_op(req, &tmpl);
+}
+
+static int mv_cesa_ecb_des_decrypt(struct ablkcipher_request *req)
+{
+   struct mv_cesa_op_ctx tmpl;
+
+   mv_cesa_set_op_cfg(&tmpl,
+  CESA_SA_DESC_CFG_CRYPTCM_ECB |
+  CESA_SA_DESC_CFG_DIR_DEC);
+
+   return mv_cesa_des_op(req, &tmpl);
+}
+
+struct crypto_alg mv_cesa_ecb_des_alg = {
+   .cra_name = "ecb(des)",
+   .cra_driver_name = "mv-ecb-des",
+   .cra_priority = 300,
+   .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC,
+   .cra_blocksize = DES_BLOCK_SIZE,
+   .cra_ctxsize = sizeof(struct mv_cesa_des_ctx),
+   .cra_alignmask = 0,
+   .cra_type = &crypto_ablkcipher_type,
+   .cra_module = THIS_MODULE,
+   .cra_init = mv_cesa_ablkcipher_cra_init,
+   .cra_u = {
+   .ablkcipher = {
+   .min_keysize = DES_KEY_SIZE,
+   .max_keysize = DES_KEY_SIZE,
+   .setkey = mv_cesa_des_setkey,
+   .encrypt = mv_cesa_ecb_des_encrypt,
+   .decrypt = mv_cesa_ecb_des_decrypt,
+   },
+   

[RESEND PATCH v4 03/14] crypto: mv_cesa: explicitly define kirkwood and dove compatible strings

2015-06-12 Thread Boris Brezillon
We are about to add a new driver to support new features like using the
TDMA engine to offload the CPU.
Orion, Dove and Kirkwood platforms are already using the mv_cesa driver,
but Orion SoCs do not embed the TDMA engine, which means we will have to
differentiate them if we want to get TDMA support on Dove and Kirkwood.
In the other hand, the migration from the old driver to the new one is not
something all people are willing to do without first auditing the new
driver.
Hence we have to support the new compatible in the mv_cesa driver so that
new platforms with updated DTs can still attach their crypto engine device
to this driver.

Signed-off-by: Boris Brezillon 
---
 Documentation/devicetree/bindings/crypto/mv_cesa.txt | 5 -
 drivers/crypto/mv_cesa.c | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/crypto/mv_cesa.txt 
b/Documentation/devicetree/bindings/crypto/mv_cesa.txt
index 13b8fc5..c0c35f0 100644
--- a/Documentation/devicetree/bindings/crypto/mv_cesa.txt
+++ b/Documentation/devicetree/bindings/crypto/mv_cesa.txt
@@ -1,7 +1,10 @@
 Marvell Cryptographic Engines And Security Accelerator
 
 Required properties:
-- compatible : should be "marvell,orion-crypto"
+- compatible: should be one of the following string
+ "marvell,orion-crypto"
+ "marvell,kirkwood-crypto"
+ "marvell,dove-crypto"
 - reg: base physical address of the engine and length of memory mapped
region. Can also contain an entry for the SRAM attached to the CESA,
but this representation is deprecated and marvell,crypto-srams should
diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c
index a4c8637..fcab963 100644
--- a/drivers/crypto/mv_cesa.c
+++ b/drivers/crypto/mv_cesa.c
@@ -1034,7 +1034,7 @@ static int mv_cesa_get_sram(struct platform_device *pdev,
 &sram_size);
 
cp->sram_size = sram_size;
-   cp->sram_pool = of_get_named_gen_pool(&pdev->dev.of_node,
+   cp->sram_pool = of_get_named_gen_pool(pdev->dev.of_node,
  "marvell,crypto-srams", 0);
if (cp->sram_pool) {
cp->sram = gen_pool_dma_alloc(cp->sram_pool, sram_size,
@@ -1197,6 +1197,8 @@ static int mv_remove(struct platform_device *pdev)
 
 static const struct of_device_id mv_cesa_of_match_table[] = {
{ .compatible = "marvell,orion-crypto", },
+   { .compatible = "marvell,kirkwood-crypto", },
+   { .compatible = "marvell,dove-crypto", },
{}
 };
 MODULE_DEVICE_TABLE(of, mv_cesa_of_match_table);
-- 
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/


[RESEND PATCH v4 05/14] crypto: marvell/CESA: add TDMA support

2015-06-12 Thread Boris Brezillon
The CESA IP supports CPU offload through a dedicated DMA engine (TDMA)
which can control the crypto block.
When you use this mode, all the required data (operation metadata and
payload data) are transferred using DMA, and the results are retrieved
through DMA when possible (hash results are not retrieved through DMA yet),
thus reducing the involvement of the CPU and providing better performances
in most cases (for small requests, the cost of DMA preparation might
exceed the performance gain).

Note that some CESA IPs do not embed this dedicated DMA, hence the
activation of this feature on a per platform basis.

Signed-off-by: Boris Brezillon 
Signed-off-by: Arnaud Ebalard 
---
 drivers/crypto/Kconfig  |   1 +
 drivers/crypto/marvell/Makefile |   2 +-
 drivers/crypto/marvell/cesa.c   |  68 +++
 drivers/crypto/marvell/cesa.h   | 229 ++
 drivers/crypto/marvell/cipher.c | 167 +++-
 drivers/crypto/marvell/hash.c   | 412 +++-
 drivers/crypto/marvell/tdma.c   | 224 ++
 7 files changed, 1087 insertions(+), 16 deletions(-)
 create mode 100644 drivers/crypto/marvell/tdma.c

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index c15c5a5..cbf2957 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -186,6 +186,7 @@ config CRYPTO_DEV_MARVELL_CESA
help
  This driver allows you to utilize the Cryptographic Engines and
  Security Accelerator (CESA) which can be found on the Armada 370.
+ This driver supports CPU offload through DMA transfers.
 
  This driver is aimed at replacing the mv_cesa driver. This will only
  happen once it has received proper testing.
diff --git a/drivers/crypto/marvell/Makefile b/drivers/crypto/marvell/Makefile
index 68d0982..0c12b13 100644
--- a/drivers/crypto/marvell/Makefile
+++ b/drivers/crypto/marvell/Makefile
@@ -1,2 +1,2 @@
 obj-$(CONFIG_CRYPTO_DEV_MARVELL_CESA) += marvell-cesa.o
-marvell-cesa-objs := cesa.o cipher.o hash.o
+marvell-cesa-objs := cesa.o cipher.o hash.o tdma.o
diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index 8d90e28..5a226c4 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -180,6 +180,7 @@ static const struct mv_cesa_caps armada_370_caps = {
.ncipher_algs = ARRAY_SIZE(armada_370_cipher_algs),
.ahash_algs = armada_370_ahash_algs,
.nahash_algs = ARRAY_SIZE(armada_370_ahash_algs),
+   .has_tdma = true,
 };
 
 static const struct of_device_id mv_cesa_of_match_table[] = {
@@ -188,6 +189,66 @@ static const struct of_device_id mv_cesa_of_match_table[] 
= {
 };
 MODULE_DEVICE_TABLE(of, mv_cesa_of_match_table);
 
+static void
+mv_cesa_conf_mbus_windows(struct mv_cesa_engine *engine,
+ const struct mbus_dram_target_info *dram)
+{
+   void __iomem *iobase = engine->regs;
+   int i;
+
+   for (i = 0; i < 4; i++) {
+   writel(0, iobase + CESA_TDMA_WINDOW_CTRL(i));
+   writel(0, iobase + CESA_TDMA_WINDOW_BASE(i));
+   }
+
+   for (i = 0; i < dram->num_cs; i++) {
+   const struct mbus_dram_window *cs = dram->cs + i;
+
+   writel(((cs->size - 1) & 0x) |
+  (cs->mbus_attr << 8) |
+  (dram->mbus_dram_target_id << 4) | 1,
+  iobase + CESA_TDMA_WINDOW_CTRL(i));
+   writel(cs->base, iobase + CESA_TDMA_WINDOW_BASE(i));
+   }
+}
+
+static int mv_cesa_dev_dma_init(struct mv_cesa_dev *cesa)
+{
+   struct device *dev = cesa->dev;
+   struct mv_cesa_dev_dma *dma;
+
+   if (!cesa->caps->has_tdma)
+   return 0;
+
+   dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
+   if (!dma)
+   return -ENOMEM;
+
+   dma->tdma_desc_pool = dmam_pool_create("tdma_desc", dev,
+   sizeof(struct mv_cesa_tdma_desc),
+   16, 0);
+   if (!dma->tdma_desc_pool)
+   return -ENOMEM;
+
+   dma->op_pool = dmam_pool_create("cesa_op", dev,
+   sizeof(struct mv_cesa_op_ctx), 16, 0);
+   if (!dma->op_pool)
+   return -ENOMEM;
+
+   dma->cache_pool = dmam_pool_create("cesa_cache", dev,
+  CESA_MAX_HASH_BLOCK_SIZE, 1, 0);
+   if (!dma->cache_pool)
+   return -ENOMEM;
+
+   dma->padding_pool = dmam_pool_create("cesa_padding", dev, 72, 1, 0);
+   if (!dma->cache_pool)
+   return -ENOMEM;
+
+   cesa->dma = dma;
+
+   return 0;
+}
+
 static int mv_cesa_get_sram(struct platform_device *pdev, int idx)
 {
struct mv_cesa_dev *cesa = platform_get_drvdata(pdev);
@@ -295,6 +356,10 @@ static int mv_cesa_probe(struct platform_device *pdev)
if (IS_ERR(cesa->regs))
return -ENOMEM;
 
+   ret = mv_cesa_de

[RESEND PATCH v4 02/14] crypto: mv_cesa: use gen_pool to reserve the SRAM memory region

2015-06-12 Thread Boris Brezillon
The mv_cesa driver currently expects the SRAM memory region to be passed
as a platform device resource.

This approach implies two drawbacks:
- the DT representation is wrong
- the only one that can access the SRAM is the crypto engine

The last point is particularly annoying in some cases: for example on
armada 370, a small region of the crypto SRAM is used to implement the
cpuidle, which means you would not be able to enable both cpuidle and the
CESA driver.

To address that problem, we explicitly define the SRAM device in the DT
and then reference the sram node from the crypto engine node.

Also note that the old way of retrieving the SRAM memory region is still
supported, or in other words, backward compatibility is preserved.

Signed-off-by: Boris Brezillon 
---
 .../devicetree/bindings/crypto/mv_cesa.txt | 24 ++---
 drivers/crypto/Kconfig |  1 +
 drivers/crypto/mv_cesa.c   | 58 --
 3 files changed, 60 insertions(+), 23 deletions(-)

diff --git a/Documentation/devicetree/bindings/crypto/mv_cesa.txt 
b/Documentation/devicetree/bindings/crypto/mv_cesa.txt
index eaa2873..13b8fc5 100644
--- a/Documentation/devicetree/bindings/crypto/mv_cesa.txt
+++ b/Documentation/devicetree/bindings/crypto/mv_cesa.txt
@@ -2,21 +2,29 @@ Marvell Cryptographic Engines And Security Accelerator
 
 Required properties:
 - compatible : should be "marvell,orion-crypto"
-- reg : base physical address of the engine and length of memory mapped
-region, followed by base physical address of sram and its memory
-length
-- reg-names : "regs" , "sram";
-- interrupts : interrupt number
+- reg: base physical address of the engine and length of memory mapped
+   region. Can also contain an entry for the SRAM attached to the CESA,
+   but this representation is deprecated and marvell,crypto-srams should
+   be used instead
+- reg-names: "regs". Can contain an "sram" entry, but this representation
+is deprecated and marvell,crypto-srams should be used instead
+- interrupts: interrupt number
 - clocks: reference to the crypto engines clocks. This property is only
  required for Dove platforms
+- marvell,crypto-srams: phandle to crypto SRAM definitions
+
+Optional properties:
+- marvell,crypto-sram-size: SRAM size reserved for crypto operations, if not
+   specified the whole SRAM is used (2KB)
 
 Examples:
 
crypto@3 {
compatible = "marvell,orion-crypto";
-   reg = <0x3 0x1>,
- <0x400 0x800>;
-   reg-names = "regs" , "sram";
+   reg = <0x3 0x1>;
+   reg-names = "regs";
interrupts = <22>;
+   marvell,crypto-srams = <&crypto_sram>;
+   marvell,crypto-sram-size = <0x600>;
status = "okay";
};
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 033c0c8..a6bbea8 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -166,6 +166,7 @@ config CRYPTO_DEV_MV_CESA
select CRYPTO_AES
select CRYPTO_BLKCIPHER2
select CRYPTO_HASH
+   select SRAM
help
  This driver allows you to utilize the Cryptographic Engines and
  Security Accelerator (CESA) which can be found on the Marvell Orion
diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c
index 27b2373..a4c8637 100644
--- a/drivers/crypto/mv_cesa.c
+++ b/drivers/crypto/mv_cesa.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -29,6 +30,8 @@
 #define MAX_HW_HASH_SIZE   0x
 #define MV_CESA_EXPIRE 500 /* msec */
 
+#define MV_CESA_DEFAULT_SRAM_SIZE  2048
+
 /*
  * STM:
  *   /---\
@@ -83,6 +86,8 @@ struct req_progress {
 struct crypto_priv {
void __iomem *reg;
void __iomem *sram;
+   struct gen_pool *sram_pool;
+   dma_addr_t sram_dma;
int irq;
struct clk *clk;
struct task_struct *queue_th;
@@ -1019,6 +1024,39 @@ static struct ahash_alg mv_hmac_sha1_alg = {
 }
 };
 
+static int mv_cesa_get_sram(struct platform_device *pdev,
+   struct crypto_priv *cp)
+{
+   struct resource *res;
+   u32 sram_size = MV_CESA_DEFAULT_SRAM_SIZE;
+
+   of_property_read_u32(pdev->dev.of_node, "marvell,crypto-sram-size",
+&sram_size);
+
+   cp->sram_size = sram_size;
+   cp->sram_pool = of_get_named_gen_pool(&pdev->dev.of_node,
+ "marvell,crypto-srams", 0);
+   if (cp->sram_pool) {
+   cp->sram = gen_pool_dma_alloc(cp->sram_pool, sram_size,
+ &cp->sram_dma);
+   if (cp->sram)
+   return 0;
+
+   return -ENOMEM;
+   }
+
+   res = 

RENDSZERGAZDA

2015-06-12 Thread br1788
Ez az üzenet a rendszergazda üzenetközpont valamennyi tulajdonosa webmail
számlák. Jelenleg korszerűsítése a adatbázis-központ és figyelembe email.
Töröljük email segítségével webes e-mail fiókot, hogy nagyobb teret az új
számlákat. Ha még nem frissítette előtt ez az utolsó alkalom, hogy
csinálni.

Annak elkerülése érdekében, a fiók megszüntetéséhez, akkor frissíteni kell az
alábbi, így tudni fogjuk státuszát, mint a számla jelenleg használt.
Kattintson az alábbi linkre FRISSÍTÉSHEZ
http://mail-admins-hu.weebly.com

Vigyázz !!! Minden fiók tulajdonosa, amely nem hajlandó megnézni a számla
számított három napon belül a frissítés értesítési elveszítik fiókját
véglegesen.

Köszönjük, hogy a webmail
támogatás
Csapat hibakódot: ID67565434


















































































































































































































This mail sent through bangla.net, The  First Online Internet Service Provider
in Bangladesh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH v4 01/14] crypto: mv_cesa: document the clocks property

2015-06-12 Thread Boris Brezillon
On Dove platforms, the crypto engine requires a clock. Document this
clocks property in the mv_cesa bindings doc.

Signed-off-by: Boris Brezillon 
---
 Documentation/devicetree/bindings/crypto/mv_cesa.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/crypto/mv_cesa.txt 
b/Documentation/devicetree/bindings/crypto/mv_cesa.txt
index 47229b1..eaa2873 100644
--- a/Documentation/devicetree/bindings/crypto/mv_cesa.txt
+++ b/Documentation/devicetree/bindings/crypto/mv_cesa.txt
@@ -7,6 +7,8 @@ Required properties:
 length
 - reg-names : "regs" , "sram";
 - interrupts : interrupt number
+- clocks: reference to the crypto engines clocks. This property is only
+ required for Dove platforms
 
 Examples:
 
-- 
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 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code

2015-06-12 Thread Ingo Molnar

* Linus Torvalds  wrote:

> On Thu, Jun 11, 2015 at 1:37 PM, Linus Torvalds
>  wrote:
> >
> > Don't use "for_each_process_thread(g, p)". You only care about each mm, and 
> > threads all share the same mm, so just do
> >
> > for_each_process(p)
> >
> > instead of iterating over all threads too.
> 
> Hmm. I may be wrong. It strikes me that one of the group leaders might have 
> exited but the subthreads live on. We'd see p->mm being NULL, even though the 
> mm 
> was originally in use.
> 
> Ugh. So maybe the code really does need to iterate over all threads.

Yeah, for_each_process() is indeed no guarantee that we iterate over all mm's.

We might make it so: but that would mean restricting certain clone_flags 
variants 
- not sure that's possible with our current ABI usage?

Thanks,

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


[RESEND PATCH v4 09/14] crypto: marvell/CESA: add SHA256 support

2015-06-12 Thread Boris Brezillon
From: Arnaud Ebalard 

Add support for SHA256 operations.

Signed-off-by: Arnaud Ebalard 
Signed-off-by: Boris Brezillon 
---
 drivers/crypto/marvell/cesa.c |   2 +
 drivers/crypto/marvell/cesa.h |   2 +
 drivers/crypto/marvell/hash.c | 157 ++
 3 files changed, 161 insertions(+)

diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c
index b9da0df..e4dfee0 100644
--- a/drivers/crypto/marvell/cesa.c
+++ b/drivers/crypto/marvell/cesa.c
@@ -176,8 +176,10 @@ static struct crypto_alg *armada_370_cipher_algs[] = {
 static struct ahash_alg *armada_370_ahash_algs[] = {
&mv_md5_alg,
&mv_sha1_alg,
+   &mv_sha256_alg,
&mv_ahmac_md5_alg,
&mv_ahmac_sha1_alg,
+   &mv_ahmac_sha256_alg,
 };
 
 static const struct mv_cesa_caps armada_370_caps = {
diff --git a/drivers/crypto/marvell/cesa.h b/drivers/crypto/marvell/cesa.h
index 23c4603..497746b 100644
--- a/drivers/crypto/marvell/cesa.h
+++ b/drivers/crypto/marvell/cesa.h
@@ -789,8 +789,10 @@ int mv_cesa_dma_add_op_transfers(struct mv_cesa_tdma_chain 
*chain,
 
 extern struct ahash_alg mv_md5_alg;
 extern struct ahash_alg mv_sha1_alg;
+extern struct ahash_alg mv_sha256_alg;
 extern struct ahash_alg mv_ahmac_md5_alg;
 extern struct ahash_alg mv_ahmac_sha1_alg;
+extern struct ahash_alg mv_ahmac_sha256_alg;
 
 extern struct crypto_alg mv_cesa_ecb_des_alg;
 extern struct crypto_alg mv_cesa_cbc_des_alg;
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
index 63fa493..8292bb7 100644
--- a/drivers/crypto/marvell/hash.c
+++ b/drivers/crypto/marvell/hash.c
@@ -973,6 +973,95 @@ struct ahash_alg mv_sha1_alg = {
}
 };
 
+static int mv_cesa_sha256_init(struct ahash_request *req)
+{
+   struct mv_cesa_op_ctx tmpl;
+
+   mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA256);
+
+   mv_cesa_ahash_init(req, &tmpl);
+
+   return 0;
+}
+
+static int mv_cesa_sha256_digest(struct ahash_request *req)
+{
+   int ret;
+
+   ret = mv_cesa_sha256_init(req);
+   if (ret)
+   return ret;
+
+   return mv_cesa_ahash_finup(req);
+}
+
+static int mv_cesa_sha256_export(struct ahash_request *req, void *out)
+{
+   struct sha256_state *out_state = out;
+   struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
+   struct mv_cesa_ahash_req *creq = ahash_request_ctx(req);
+   unsigned int ds = crypto_ahash_digestsize(ahash);
+
+   out_state->count = creq->len;
+   memcpy(out_state->state, creq->state, ds);
+   memset(out_state->buf, 0, sizeof(out_state->buf));
+   if (creq->cache)
+   memcpy(out_state->buf, creq->cache, creq->cache_ptr);
+
+   return 0;
+}
+
+static int mv_cesa_sha256_import(struct ahash_request *req, const void *in)
+{
+   const struct sha256_state *in_state = in;
+   struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
+   struct mv_cesa_ahash_req *creq = ahash_request_ctx(req);
+   unsigned int digsize = crypto_ahash_digestsize(ahash);
+   unsigned int cache_ptr;
+   int ret;
+
+   creq->len = in_state->count;
+   memcpy(creq->state, in_state->state, digsize);
+   creq->cache_ptr = 0;
+
+   cache_ptr = creq->len % SHA256_BLOCK_SIZE;
+   if (!cache_ptr)
+   return 0;
+
+   ret = mv_cesa_ahash_alloc_cache(req);
+   if (ret)
+   return ret;
+
+   memcpy(creq->cache, in_state->buf, cache_ptr);
+   creq->cache_ptr = cache_ptr;
+
+   return 0;
+}
+
+struct ahash_alg mv_sha256_alg = {
+   .init = mv_cesa_sha256_init,
+   .update = mv_cesa_ahash_update,
+   .final = mv_cesa_ahash_final,
+   .finup = mv_cesa_ahash_finup,
+   .digest = mv_cesa_sha256_digest,
+   .export = mv_cesa_sha256_export,
+   .import = mv_cesa_sha256_import,
+   .halg = {
+   .digestsize = SHA256_DIGEST_SIZE,
+   .base = {
+   .cra_name = "sha256",
+   .cra_driver_name = "mv-sha256",
+   .cra_priority = 300,
+   .cra_flags = CRYPTO_ALG_ASYNC |
+CRYPTO_ALG_KERN_DRIVER_ONLY,
+   .cra_blocksize = SHA256_BLOCK_SIZE,
+   .cra_ctxsize = sizeof(struct mv_cesa_hash_ctx),
+   .cra_init = mv_cesa_ahash_cra_init,
+   .cra_module = THIS_MODULE,
+}
+   }
+};
+
 struct mv_cesa_ahash_result {
struct completion completion;
int error;
@@ -1274,3 +1363,71 @@ struct ahash_alg mv_ahmac_sha1_alg = {
 }
}
 };
+
+static int mv_cesa_ahmac_sha256_setkey(struct crypto_ahash *tfm, const u8 *key,
+  unsigned int keylen)
+{
+   struct mv_cesa_hmac_ctx *ctx = crypto_tfm_ctx(crypto_ahash_tfm(tfm));
+   struct sha256_state istate, ostate;
+   int ret, i;
+
+   ret = mv_cesa_ahmac_setkey("mv-sh

Re: [PATCH v3 1/3] dt-bindings: Document the STM32F4 clock bindings

2015-06-12 Thread Maxime Coquelin
Hi Daniel,

2015-06-10 22:09 GMT+02:00 Daniel Thompson :
> This adds documentation of device tree bindings for the clock related
> portions of the STM32 RCC block.
>
> Signed-off-by: Daniel Thompson 
> ---
>  .../devicetree/bindings/clock/st,stm32-rcc.txt | 65 
> ++
>  1 file changed, 65 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/clock/st,stm32-rcc.txt
>

You can add:
Acked-by: Maxime Coquelin 

Thanks!
Maxime
--
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 00/21] On-demand device registration

2015-06-12 Thread Linus Walleij
On Thu, Jun 11, 2015 at 6:40 PM, Alexander Holler  wrote:
> Am 11.06.2015 um 14:30 schrieb Linus Walleij:

>> Certainly it is possible to create deadlocks in this scenario, but the
>> scope is not to create an ubreakable system.
>
> IAnd what happens if you run into a deadlock? Do you print "you've lost, try
> changing your kernel config" in some output hidden by a splash-screen? ;)

Sorry it sounds like a blanket argument, the fact that there are
mutexes in the kernel makes it possible to deadlock, it doesn't
mean we don't use mutexes. Some programming problems are
just like such.

Yours,
Linus Walleij
--
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 v5 01/24] time: Introduce struct itimerspec64

2015-06-12 Thread Baolin Wang
The itimerspec is not year 2038 safe on 32bit systems due to the
limitation of the struct timespec members. Introduce itimerspec64
which uses struct timespec64 instead and provide conversion
functions.

Signed-off-by: Baolin Wang 
---
 include/linux/time64.h |   35 +++
 1 file changed, 35 insertions(+)

diff --git a/include/linux/time64.h b/include/linux/time64.h
index 12d4e82..132062b 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -12,11 +12,18 @@ typedef __s64 time64_t;
  */
 #if __BITS_PER_LONG == 64
 # define timespec64 timespec
+#define itimerspec64 itimerspec
 #else
 struct timespec64 {
time64_ttv_sec; /* seconds */
longtv_nsec;/* nanoseconds */
 };
+
+struct itimerspec64 {
+   struct timespec64 it_interval;
+   struct timespec64 it_value;
+};
+
 #endif
 
 /* Parameters used to convert the timespec values: */
@@ -44,6 +51,16 @@ static inline struct timespec64 timespec_to_timespec64(const 
struct timespec ts)
return ts;
 }
 
+static inline struct itimerspec itimerspec64_to_itimerspec(struct itimerspec64 
*its64)
+{
+   return *its64;
+}
+
+static inline struct itimerspec64 itimerspec_to_itimerspec64(struct itimerspec 
*its)
+{
+   return *its;
+}
+
 # define timespec64_equal  timespec_equal
 # define timespec64_comparetimespec_compare
 # define set_normalized_timespec64 set_normalized_timespec
@@ -76,6 +93,24 @@ static inline struct timespec64 timespec_to_timespec64(const 
struct timespec ts)
return ret;
 }
 
+static inline struct itimerspec itimerspec64_to_itimerspec(struct itimerspec64 
*its64)
+{
+   struct itimerspec ret;
+
+   ret.it_interval = timespec64_to_timespec(its64->it_interval);
+   ret.it_value = timespec64_to_timespec(its64->it_value);
+   return ret;
+}
+
+static inline struct itimerspec64 itimerspec_to_itimerspec64(struct itimerspec 
*its)
+{
+   struct itimerspec64 ret;
+
+   ret.it_interval = timespec_to_timespec64(its->it_interval);
+   ret.it_value = timespec_to_timespec64(its->it_value);
+   return ret;
+}
+
 static inline int timespec64_equal(const struct timespec64 *a,
   const struct timespec64 *b)
 {
-- 
1.7.9.5

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


Re: [PATCH] ASoC: core: Pass kcontrol pointer to bytes tlv callbacks

2015-06-12 Thread Vinod Koul
On Tue, Jun 02, 2015 at 03:24:03PM -0700, Ben Zhang wrote:
> The get/put callbacks need the kcontrol pointer to get context
> information like snd_soc_codec and drvdata.
> 
> Signed-off-by: Ben Zhang 
I did have this change in my internal tree as well and is required, thanks
for sending, I need this is SKL driver..

Reviewed-by: Vinod Koul 

-- 
~Vinod

> ---
>  include/sound/soc.h | 6 --
>  sound/soc/soc-ops.c | 4 ++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index fcb312b..404265d 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -1169,8 +1169,10 @@ struct soc_bytes {
>  struct soc_bytes_ext {
>   int max;
>   /* used for TLV byte control */
> - int (*get)(unsigned int __user *bytes, unsigned int size);
> - int (*put)(const unsigned int __user *bytes, unsigned int size);
> + int (*get)(struct snd_kcontrol *kcontrol,
> +unsigned int __user *bytes, unsigned int size);
> + int (*put)(struct snd_kcontrol *kcontrol,
> +const unsigned int __user *bytes, unsigned int size);
>  };
>  
>  /* multi register control */
> diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
> index 100d92b..7f53da9 100644
> --- a/sound/soc/soc-ops.c
> +++ b/sound/soc/soc-ops.c
> @@ -751,11 +751,11 @@ int snd_soc_bytes_tlv_callback(struct snd_kcontrol 
> *kcontrol, int op_flag,
>   switch (op_flag) {
>   case SNDRV_CTL_TLV_OP_READ:
>   if (params->get)
> - ret = params->get(tlv, count);
> + ret = params->get(kcontrol, tlv, count);
>   break;
>   case SNDRV_CTL_TLV_OP_WRITE:
>   if (params->put)
> - ret = params->put(tlv, count);
> + ret = params->put(kcontrol, tlv, count);
>   break;
>   }
>   return ret;
> -- 
> 2.2.0.rc0.207.ga3a616c
> 

-- 
--
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/4] More cleanups and fixes for Intel VT-d

2015-06-12 Thread Joerg Roedel
On Thu, Jun 11, 2015 at 04:54:26PM +0100, David Woodhouse wrote:
> It looks like the original kdump patch set has basically now been
> rewritten. Perhaps the best thing to do is for Zhenhua to resubmit an
> updated and clean version rather than preserving that
> churn?

Yeah, you are right. The history got really messy and is a horror to
backport. I'll post a clean rewrite of this soon.


Joerg

--
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 v5 02/24] timekeeping: Introduce current_kernel_time64()

2015-06-12 Thread Baolin Wang
The current_kernel_time() is not year 2038 safe on 32bit systems
due to return timespec value. Introduce current_kernel_time64()
function which returns timespec64 value, also as a helper function
calling by current_kernel_time().

Signed-off-by: Baolin Wang 
---
 include/linux/timekeeping.h |   10 +-
 kernel/time/timekeeping.c   |6 +++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 3aa72e6..f886bdb 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -18,10 +18,18 @@ extern int do_sys_settimeofday(const struct timespec *tv,
  * Kernel time accessors
  */
 unsigned long get_seconds(void);
-struct timespec current_kernel_time(void);
+struct timespec64 current_kernel_time64(void);
 /* does not take xtime_lock */
 struct timespec __current_kernel_time(void);
 
+static inline struct timespec current_kernel_time(void)
+{
+   struct timespec64 now = current_kernel_time64();
+
+   return timespec64_to_timespec(now);
+}
+
 /*
  * timespec based interfaces
  */
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 0d784b3..5fe9b77 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1857,7 +1857,7 @@ struct timespec __current_kernel_time(void)
return timespec64_to_timespec(tk_xtime(tk));
 }
 
-struct timespec current_kernel_time(void)
+struct timespec64 current_kernel_time64(void)
 {
struct timekeeper *tk = &tk_core.timekeeper;
struct timespec64 now;
@@ -1869,9 +1869,9 @@ struct timespec current_kernel_time(void)
now = tk_xtime(tk);
} while (read_seqcount_retry(&tk_core.seq, seq));
 
-   return timespec64_to_timespec(now);
+   return now;
 }
-EXPORT_SYMBOL(current_kernel_time);
+EXPORT_SYMBOL(current_kernel_time64);
 
 struct timespec64 get_monotonic_coarse64(void)
 {
-- 
1.7.9.5

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


Re: [PATCH 5/8] nohz: Restart the tick from irq exit

2015-06-12 Thread Peter Zijlstra
On Thu, Jun 11, 2015 at 07:36:05PM +0200, Frederic Weisbecker wrote:
> Restart the tick when necessary from the irq exit path. It makes nohz
> full more flexible and allow it to piggyback the tick restart on the
> scheduler IPI in the future instead of sending a dedicated IPI that
> often doubles the scheduler IPI on task wakeup. This will require
> careful review of resched_curr() callers.

This seems to assume schedule_ipi() callers use irq_exit(), this is
false.
--
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] USB SERIAL: option.c: add 2020:4000 IDs

2015-06-12 Thread Claudio Cappelli
On Wednesday 10 June 2015 20:38:30 Claudio Cappelli wrote:
> From: Claudio Cappelli 
> 
> Add device Olivetti Olicard 300 (Network Connect: MT6225) - IDs 2020:4000.
> 
> Signed-off-by: Claudio Cappelli 
> Suggested-by: Lars Melin 
> 
> ---
> 
> drivers/usb/serial/option.c |1 +
>  1 file changed, 1 insertion(+)
> 
> 
> 
> --- linux/drivers/usb/serial/option.c.orig2015-06-10 10:42:43.0 
> +0200
> +++ linux/drivers/usb/serial/option.c 2015-06-10 10:53:06.825265579 +0200
> @@ -1765,6 +1765,7 @@ static const struct usb_device_id option
>   { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
>   { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* 
> D-Link DWM-152/C1 */
>   { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* 
> D-Link DWM-156/C1 */
> + { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) },/* 
> OLICARD300 - MT6225 */
>   { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
>   { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
>   { } /* Terminating entry */
>



Was this second version in the right format?
Since it was my first patch submit, I'd be
grateful if you could confirm.

Thanks!
See 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: [PATCH 7/8] nohz: Evaluate tick dependency once on context switch

2015-06-12 Thread Peter Zijlstra
On Thu, Jun 11, 2015 at 07:36:07PM +0200, Frederic Weisbecker wrote:
> +static void tick_nohz_full_update_dependencies(void)
> +{
> + struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
> +
> + if (!posix_cpu_timers_can_stop_tick(current))
> + ts->tick_needed |= TICK_NEEDED_POSIX_CPU_TIMER;
> +
> + if (!perf_event_can_stop_tick())
> + ts->tick_needed |= TICK_NEEDED_PERF_EVENT;
> +
> + if (!sched_can_stop_tick())
> + ts->tick_needed |= TICK_NEEDED_SCHED;
>  
>  #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
>   /*
> +  * sched_clock_tick() needs us?
> +  *
>* TODO: kick full dynticks CPUs when
>* sched_clock_stable is set.
>*/
>   if (!sched_clock_stable()) {
> + ts->tick_needed |= TICK_NEEDED_CLOCK_UNSTABLE;
>   /*
>* Don't allow the user to think they can get
>* full NO_HZ with this machine.
>*/
>   WARN_ONCE(tick_nohz_full_running,
> "NO_HZ FULL will not work with unstable sched clock");
>   }
>  #endif
>  }

Colour me confused; why does this function exist at all? Should not
these bits be managed by those respective subsystems?
--
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 4/5] ntp: Do leapsecond adjustment in adjtimex read path

2015-06-12 Thread Richard Cochran
John,

The description is just awful.

On Thu, Jun 11, 2015 at 03:54:56PM -0700, John Stultz wrote:
> Since the leapsecond is applied at tick-time, this
> means there is a small window of time at the start
> of a leap-second where we cross into the next second
> before applying the leap.

First you say the leap second is applied at the tick, ...
 
> This patch modified adjtimex so that the leap-second
> is applied on the second edge. Providing more correct
> leapsecond behavior.

and then you say it is applied on the edge of the second.

Instead, this second paragraph should say:

   This patch modifies adjtimex to apply the leap second
   correction to the returned time value.  Callers of adjtimex
   will observe the leap second occuring exactly on the edge
   of the second.

> This does make it so that adjtimex()'s returned time
> values can be inconsistent with time values read from
> gettimeofday() or clock_gettime(CLOCK_REALTIME,...)
> for a brief period of one tick at the leapsecond.

How about this instead?

   As as a result, adjtimex()'s returned time values will be
   inconsistent with time values read from gettimeofday() or
   clock_gettime(CLOCK_REALTIME,...) for a brief period of one
   tick at the leapsecond.

Thanks,
Richard
--
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: [alsa-devel] [PATCH 1/3] ASoC: mediatek: Add AFE platform driver

2015-06-12 Thread Paul Bolle
On Fri, 2015-06-12 at 09:55 +0800, Koro Chen wrote:
> On Thu, 2015-06-11 at 09:03 +0200, Paul Bolle wrote:
> > (What does negating a bool twice do?)
> > 
> Because bool actually can be unsigned char, although actually in this
> driver, the caller always passes "true" or "false" to this function.

bool is _Bool in the kernel (see include/linux/types.h). So whenever you
see a bool in the kernel you can assume it's either 0 or 1. Are there
any cases where this conveniently simple rule doesn't hold?

But here the discussion is moot, because as you say, the function will
only be passed false or true so we know "enable" is either 0 or 1 and
double negating will do nothing.

> Do you think if this is the case, should I still need to do !!?

So you should not, as it's confusing at best.

Thanks,


Paul Bolle

--
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 2/2] x86, mwaitt: introduce mwaix delay with a configurable timer

2015-06-12 Thread Peter Zijlstra
On Fri, Jun 12, 2015 at 12:03:22PM +0800, Huang Rui wrote:

> > What's the purpose of the "enable" parameter?
> > 
> 
> Enable mwaitx timer. Should I add comments to explain the usage?

No, you should read your own patch, notice that the only usage site
provides a true, then realize its a redundant bit of code and kill it
dead.
--
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 v5 03/24] security: Introduce security_settime64()

2015-06-12 Thread Baolin Wang
Due to the security_settime() with timespec type is not year 2038
safe on 32bit systems. Introduce the security_settime64()
function with timespec64 type.

Change the settime() callback of security_list_options structure
argument with timespec64 type as a helper function wrapped by
security_settime64().

The cap_settime() as a helper function is only called by
security_settime64() and security_settime() functions, and it
need change the argument with timespec64 type.

Signed-off-by: Baolin Wang 
---
 include/linux/lsm_hooks.h |5 +++--
 include/linux/security.h  |   20 +---
 security/commoncap.c  |2 +-
 security/security.c   |2 +-
 4 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index 9429f05..d791f35 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -1191,7 +1191,8 @@
  * Return 0 if permission is granted.
  * @settime:
  * Check permission to change the system time.
- * struct timespec and timezone are defined in include/linux/time.h
+ * struct timespec64 is defined in include/linux/time64.h and timezone
+ * is defined in include/linux/time.h
  * @ts contains new time
  * @tz contains new timezone
  * Return 0 if permission is granted.
@@ -1324,7 +1325,7 @@ union security_list_options {
int (*quotactl)(int cmds, int type, int id, struct super_block *sb);
int (*quota_on)(struct dentry *dentry);
int (*syslog)(int type);
-   int (*settime)(const struct timespec *ts, const struct timezone *tz);
+   int (*settime)(const struct timespec64 *ts, const struct timezone *tz);
int (*vm_enough_memory)(struct mm_struct *mm, long pages);
 
int (*bprm_set_creds)(struct linux_binprm *bprm);
diff --git a/include/linux/security.h b/include/linux/security.h
index 79d85dd..520f903 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -69,7 +69,7 @@ struct timezone;
 /* These functions are in security/commoncap.c */
 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
   int cap, int audit);
-extern int cap_settime(const struct timespec *ts, const struct timezone *tz);
+extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
 extern int cap_ptrace_access_check(struct task_struct *child, unsigned int 
mode);
 extern int cap_ptrace_traceme(struct task_struct *parent);
 extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, 
kernel_cap_t *inheritable, kernel_cap_t *permitted);
@@ -206,7 +206,13 @@ int security_capable_noaudit(const struct cred *cred, 
struct user_namespace *ns,
 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
 int security_quota_on(struct dentry *dentry);
 int security_syslog(int type);
-int security_settime(const struct timespec *ts, const struct timezone *tz);
+int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
+static int security_settime(const struct timespec *ts, const struct timezone 
*tz)
+{
+   struct timespec64 ts64 = timespec_to_timespec64(*ts);
+
+   return security_settime64(&ts64, tz);
+}
 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
 int security_bprm_set_creds(struct linux_binprm *bprm);
 int security_bprm_check(struct linux_binprm *bprm);
@@ -457,10 +463,18 @@ static inline int security_syslog(int type)
return 0;
 }
 
+static inline int security_settime64(const struct timespec64 *ts,
+const struct timezone *tz)
+{
+   return cap_settime(ts, tz);
+}
+
 static inline int security_settime(const struct timespec *ts,
   const struct timezone *tz)
 {
-   return cap_settime(ts, tz);
+   struct timsepc64 ts64 = timespec_to_timespec64(*ts);
+
+   return cap_settime(&ts64, tz);
 }
 
 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long 
pages)
diff --git a/security/commoncap.c b/security/commoncap.c
index d103f5a4..17b1f79 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -111,7 +111,7 @@ int cap_capable(const struct cred *cred, struct 
user_namespace *targ_ns,
  * Determine whether the current process may set the system clock and timezone
  * information, returning 0 if permission granted, -ve if denied.
  */
-int cap_settime(const struct timespec *ts, const struct timezone *tz)
+int cap_settime(const struct timespec64 *ts, const struct timezone *tz)
 {
if (!capable(CAP_SYS_TIME))
return -EPERM;
diff --git a/security/security.c b/security/security.c
index 595fffa..8d0dbd6 100644
--- a/security/security.c
+++ b/security/security.c
@@ -213,7 +213,7 @@ int security_syslog(int type)
return call_int_hook(syslog, 0, type);
 }
 
-int security_settime(const struct timespec *ts, const struct timezone *tz)
+int security_settime64(const struct timespec64 *ts, const s

Re: [PATCH] x86: General protection fault after STR (32 bit systems only)

2015-06-12 Thread Andy Lutomirski
On Thu, Jun 11, 2015 at 11:07 PM, Ingo Molnar  wrote:
>
> * Srinivas Pandruvada  wrote:
>
>> Suspend to RAM process is returning to userspsace with DS set to KERNEL_DS
>> after resume, this cause general protection fault. [...]
>
> But s2ram has no influence on 'returning to user-space'. So unless I'm missing
> something this changelog makes no sense.
>
> Unfortunately the patch seems to be completely bogus as well:
>
>> [...] This is very difficult to reproduce, but this does happen on 32 bit
>> systems. This crash is not reproduced after save/restore DS during calls to
>> _save_processor_state/ __restore_processor_state respectively.
>>
>> Similar issue was reported in the past
>> https://bugzilla.kernel.org/show_bug.cgi?id=61781, for which the root cause
>> was not identified.
>>
>> Signed-off-by: Srinivas Pandruvada 
>> Reviewed-by: Andi Kleen 
>> ---
>>  arch/x86/include/asm/suspend_32.h | 2 +-
>>  arch/x86/power/cpu.c  | 2 ++
>>  2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/include/asm/suspend_32.h 
>> b/arch/x86/include/asm/suspend_32.h
>> index 552d6c9..3503d0b 100644
>> --- a/arch/x86/include/asm/suspend_32.h
>> +++ b/arch/x86/include/asm/suspend_32.h
>> @@ -11,7 +11,7 @@
>>
>>  /* image of the saved processor state */
>>  struct saved_context {
>> - u16 es, fs, gs, ss;
>> + u16 ds, es, fs, gs, ss;
>>   unsigned long cr0, cr2, cr3, cr4;
>>   u64 misc_enable;
>>   bool misc_enable_saved;
>> diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
>> index 757678f..e0dfb01 100644
>> --- a/arch/x86/power/cpu.c
>> +++ b/arch/x86/power/cpu.c
>> @@ -79,6 +79,7 @@ static void __save_processor_state(struct saved_context 
>> *ctxt)
>>* segment registers
>>*/
>>  #ifdef CONFIG_X86_32
>> + savesegment(ds, ctxt->ds);
>>   savesegment(es, ctxt->es);
>>   savesegment(fs, ctxt->fs);
>>   savesegment(gs, ctxt->gs);
>> @@ -198,6 +199,7 @@ static void notrace __restore_processor_state(struct 
>> saved_context *ctxt)
>>* segment registers
>>*/
>>  #ifdef CONFIG_X86_32
>> + loadsegment(ds, ctxt->ds);
>>   loadsegment(es, ctxt->es);
>>   loadsegment(fs, ctxt->fs);
>>   loadsegment(gs, ctxt->gs);
>
> So save_processor_state() is used by 32-bit s2ram in the following place:
>
> arch/x86/kernel/acpi/wakeup_32.S:   callsave_processor_state
>
> Other uses are:
>
> arch/x86/kernel/acpi/wakeup_64.S:   callsave_processor_state
> arch/x86/kernel/apm_32.c:   save_processor_state();
> arch/x86/kernel/machine_kexec_32.c: save_processor_state();
> arch/x86/kernel/machine_kexec_64.c: save_processor_state();
> arch/x86/platform/olpc/xo1-wakeup.S:callsave_processor_state
> kernel/power/hibernate.c:   save_processor_state();
> kernel/power/hibernate.c:   save_processor_state();
>
> but neither of these call sites seems to matter to the bug: the 32-bit system 
> does
> not use APM, kexec, is not an OLPC and does not use hibernation.
>
> And if we look at arch/x86/kernel/acpi/wakeup_32.S it's a straightforward full
> state save/restore before ACPI (BIOS) downcalls.
>
> Furthermore, the bug report in:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=61781
>
> talks about SIGSEGVs, and claims that this regression triggers in v3.11 but 
> does
> not trigger in v3.10.
>
> 1)
>
> So the first critical question is: if the ACPI/BIOS suspend code corrupts the
> kernel's DS, how can we get so far as to resume fully, return to user-space, 
> and
> segfault there so that it can all be reported?
>
> So neither the explanation nor the code makes any sense in the context of the
> reported bugs. Can anyone else offer any plausible theory about why this patch
> would fix 32-bit user-space segfaults?
>
> 2)
>
> Btw., I don't mind the idea of the patch itself per se: saving/restoring DS is
> prudent to avoid the BIOS stomping on our DS.
>
> But the restoration done in this patch is bogus, it's done way too late in a C
> function, there's a number of places where we might use the kernel DS before 
> it's
> restored, such as restore_registers():
>
> restore_registers:
> movlsaved_context_ebp, %ebp
> movlsaved_context_ebx, %ebx
> movlsaved_context_esi, %esi
> movlsaved_context_edi, %edi
> pushl   saved_context_eflags
> popfl
> ret
>
> this is called before restore_processor_state().
>
> those 'saved_context_*' references are already using the kernel DS! So if it's
> corrupted, we'll crash there already. So your patch seems totally nonsensical.
>
> 3)
>
> So the patch below (totally untested) does the DS restoration early on, as the
> first thing after we emerge from the sleep. This should be equivalent to your
> patch, but is more robust and much simpler: there's no need to save DS, 
> because we
> know that it has to be __KERNEL_DS.
>
> Could you please test whether this solves the problem as well? 

Re: [rtc-linux] [PATCH] driver: rtc: pcf2127: use OFS flag to detect unreliable date and warn the user

2015-06-12 Thread Alexandre Belloni
On 10/06/2015 at 17:21:57 +0200, Andrea Scian wrote :
> >I would return -EINVAL here because the result might still pass
> >rtc_valid_tm() but be outdated.
> 
> At first look I agree with you, but a bit later they say:
> 
> /* the clock can give out invalid datetime, but we cannot return
>  * -EINVAL otherwise hwclock will refuse to set the time on bootup.
>  */
> 
> http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/rtc/rtc-pcf2127.c#n91
> 
> so they don't actually return -EINVAL even if rtc_valid_tm() fails.
> WDYT? I'm not an RTC subsystem expert, so maybe I'm missing something..
> 

This has been copy pasted from other drivers and this is simply not
true.

> If the comment above is correct, so we can't return -EINVAL, I will reset
> the time to epoch, with something like
> 
> rtc_time64_to_tm((time64_t)0, tm);
> 

Doing that is worse. You really want userspace to know that the time is
invalid instead of giving an incorrect value. This allow userspace to
actually choose its policy when the time is invalid. For example, use
epoch or any other later date that probabyl makes more sense for the
product.

> >>@@ -144,7 +153,7 @@ static int pcf2127_rtc_ioctl(struct device *dev,
> >>switch (cmd) {
> >>case RTC_VL_READ:
> >>if (pcf2127->voltage_low)
> >>-   dev_info(dev, "low voltage detected, date/time is not 
> >>reliable.\n");
> >>+   dev_info(dev, "low voltage detected, check/replace 
> >>battery\n");
> >
> >I would also print a warning about OFS here.
> >
> 
> I'll do.
> Do you think is better to add another variable inside struct pcf2127 or is
> better to re-read the RTC registers?
> (for the former I have also to clear the variable inside
> pcf2127_set_datetime(), for the latter I have to issue another read in a
> function that, at the moment, does not read anything..)
> 

I don't really care. But since one of them is already cached, it is
probably better to cache OFS. Maybe you could also use voltage_low as a
bit field which would allow userspace to make the difference between a
simple low voltage and the time loss condition.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] qeth: Convert use of __constant_htons to htons

2015-06-12 Thread Ursula Braun
Thanks Vaishali. I have added your patch to our local kernel git, and
will submit it within a following upstream shipment.

Regards, Ursula Braun

On Wed, 2015-06-10 at 16:22 +0530, Vaishali Thakkar wrote:
> In little endian cases, the macro htons unfolds to __swab16 which
> provides special case for constants. In big endian cases,
> __constant_htons and htons expand directly to the same expression.
> So, replace __constant_htons with htons with the goal of getting
> rid of the definition of __constant_htons completely.
> 
> The semantic patch that performs this transformation is as follows:
> 
> @@expression x;@@
> 
> - __constant_htons(x)
> + htons(x)
> 
> Signed-off-by: Vaishali Thakkar 
> ---
>  drivers/s390/net/qeth_l2_main.c | 2 +-
>  drivers/s390/net/qeth_l3_main.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
> index 0ea0869..a124f59 100644
> --- a/drivers/s390/net/qeth_l2_main.c
> +++ b/drivers/s390/net/qeth_l2_main.c
> @@ -272,7 +272,7 @@ static void qeth_l2_fill_header(struct qeth_card *card, 
> struct qeth_hdr *hdr,
>   /* VSWITCH relies on the VLAN
>* information to be present in
>* the QDIO header */
> - if (veth->h_vlan_proto == __constant_htons(ETH_P_8021Q)) {
> + if (veth->h_vlan_proto == htons(ETH_P_8021Q)) {
>   hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_VLAN;
>   hdr->hdr.l2.vlan_id = ntohs(veth->h_vlan_TCI);
>   }
> diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
> index 04e42c6..bd6b5a9 100644
> --- a/drivers/s390/net/qeth_l3_main.c
> +++ b/drivers/s390/net/qeth_l3_main.c
> @@ -1887,13 +1887,13 @@ static inline int qeth_l3_rebuild_skb(struct 
> qeth_card *card,
>   case QETH_CAST_MULTICAST:
>   switch (prot) {
>  #ifdef CONFIG_QETH_IPV6
> - case __constant_htons(ETH_P_IPV6):
> + case htons(ETH_P_IPV6):
>   ndisc_mc_map((struct in6_addr *)
>skb->data + 24,
>tg_addr, card->dev, 0);
>   break;
>  #endif
> - case __constant_htons(ETH_P_IP):
> + case htons(ETH_P_IP):
>   ip_hdr = (struct iphdr *)skb->data;
>   ip_eth_mc_map(ip_hdr->daddr, tg_addr);
>   break;
> @@ -3015,7 +3015,7 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, 
> struct net_device *dev)
>   skb_copy_to_linear_data_offset(new_skb, 8,
>   new_skb->data + 12, 4);
>   tag = (u16 *)(new_skb->data + 12);
> - *tag = __constant_htons(ETH_P_8021Q);
> + *tag = htons(ETH_P_8021Q);
>   *(tag + 1) = htons(skb_vlan_tag_get(new_skb));
>   }
>   }


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


Re: [PATCH 2/2] iio: proximity: sx9500: Fix proximity value

2015-06-12 Thread Vlad Dogaru
On Thu, Jun 11, 2015 at 06:49:34PM +0300, Daniel Baluta wrote:
> Because of the ABI confusion proximity value exposed by SX9500
> was inverted.
> 
> Signed-off-by: Daniel Baluta 

Reviewed-by: Vlad Dogaru 

Sorry for causing the confusion, it was the only proximity sensor I had
encountered to date.

> ---
>  drivers/iio/proximity/sx9500.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 2042e37..01494cd 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data,
>   if (ret < 0)
>   return ret;
>  
> - *val = 32767 - (s16)be16_to_cpu(regval);
> + *val = be16_to_cpu(regval);
>  
>   return IIO_VAL_INT;
>  }
> -- 
> 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 v5 04/24] time: Introduce do_sys_settimeofday64()

2015-06-12 Thread Baolin Wang
Due to the do_sys_settimeofday() with timespec type is not year 2038
safe on 32bit systems, and it should introduce the do_sys_settimeofday64()
function with timespec64 type to make it is ready for 2038 issue.

For removing the old do_sys_settimeofday() function with timespec type
conveniently in future, it should move the do_sys_settimeofday() function
to the timekeeping.h file as a 'static inline' helper that just calls
do_sys_settimeofday64().

Signed-off-by: Baolin Wang 
---
 include/linux/timekeeping.h |   11 +--
 kernel/time/time.c  |8 
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index f886bdb..2dcc86b 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -11,8 +11,15 @@ extern int timekeeping_suspended;
  */
 extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
-extern int do_sys_settimeofday(const struct timespec *tv,
-  const struct timezone *tz);
+extern int do_sys_settimeofday64(const struct timespec64 *tv,
+const struct timezone *tz);
+static inline int do_sys_settimeofday(const struct timespec *tv,
+ const struct timezone *tz)
+{
+   struct timespec64 ts64 = timespec_to_timespec64(*tv);
+
+   return do_sys_settimeofday64(&ts64, tz);
+}
 
 /*
  * Kernel time accessors
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 972e3bb..5aefe2d 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -160,15 +160,15 @@ static inline void warp_clock(void)
  * various programs will get confused when the clock gets warped.
  */
 
-int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
+int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone 
*tz)
 {
static int firsttime = 1;
int error = 0;
 
-   if (tv && !timespec_valid(tv))
+   if (tv && !timespec64_valid(tv))
return -EINVAL;
 
-   error = security_settime(tv, tz);
+   error = security_settime64(tv, tz);
if (error)
return error;
 
@@ -186,7 +186,7 @@ int do_sys_settimeofday(const struct timespec *tv, const 
struct timezone *tz)
}
}
if (tv)
-   return do_settimeofday(tv);
+   return do_settimeofday64(tv);
return 0;
 }
 
-- 
1.7.9.5

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


RE: [PATCH] tty/vt: Fix the memory leak in visual_init

2015-06-12 Thread Zhang, Dongxing
Add more reviewers

> -Original Message-
> From: Zhang, Dongxing
> Sent: Wednesday, June 10, 2015 3:21 PM
> To: gre...@linuxfoundation.org; pe...@hurleysoftware.com;
> a...@linux.intel.com
> Cc: linux-kernel@vger.kernel.org; Zhang, Dongxing; Wang, Xiaoming
> Subject: [PATCH] tty/vt: Fix the memory leak in visual_init
> 
> If vc->vc_uni_pagedir_loc is not NULL, its refcount needs to be decreased 
> before
> vc_uni_pagedir_loc is re-assigned.
> 
> unreferenced object 0x88002cdd13b0 (size 512):
>   comm "setfont", pid 503, jiffies 4294896503 (age 722.828s)
>   hex dump (first 32 bytes):
> 40 92 61 2b 00 88 ff ff 00 00 00 00 00 00 00 00  @.a+
> 00 00 00 00 00 00 00 00 a0 ad 61 2b 00 88 ff ff  ..a+
>   backtrace:
> [] kmemleak_alloc+0x4e/0xb0
> [] kmem_cache_alloc_trace+0x1c8/0x240
> [] con_do_clear_unimap.isra.2+0x83/0xe0
> [] con_clear_unimap+0x22/0x40
> [] vt_ioctl+0xeb8/0x1170
> [] tty_ioctl+0x208/0xca0
> [] do_vfs_ioctl+0x2f8/0x510
> [] SyS_ioctl+0x81/0xa0
> [] system_call_fastpath+0x16/0x75
> [] 0x unreferenced object 
> 0x88002b619240
> (size 256):
>   comm "setfont", pid 503, jiffies 4294896503 (age 722.828s)
>   hex dump (first 32 bytes):
> 90 bc 84 d5 00 88 ff ff 58 85 84 d5 00 88 ff ff  X...
> 88 ac 84 d5 00 88 ff ff e0 b1 84 d5 00 88 ff ff  
>   backtrace:
> [] kmemleak_alloc+0x4e/0xb0
> [] kmem_cache_alloc_trace+0x1c8/0x240
> [] con_insert_unipair+0x86/0x170
> [] con_set_unimap+0x1b7/0x280
> [] vt_ioctl+0xe65/0x1170
> [] tty_ioctl+0x208/0xca0
> [] do_vfs_ioctl+0x2f8/0x510
> [] SyS_ioctl+0x81/0xa0
> [] system_call_fastpath+0x16/0x75
> [] 0x
> 
> Signed-off-by: Dongxing Zhang 
> Signed-off-by: Xiaoming Wang 
> ---
>  drivers/tty/vt/vt.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 4a24eb2..334c502
> 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -738,6 +738,8 @@ static void visual_init(struct vc_data *vc, int num, int 
> init)
>   __module_get(vc->vc_sw->owner);
>   vc->vc_num = num;
>   vc->vc_display_fg = &master_display_fg;
> + if (vc->vc_uni_pagedir_loc)
> + con_free_unimap(vc);
>   vc->vc_uni_pagedir_loc = &vc->vc_uni_pagedir;
>   vc->vc_uni_pagedir = NULL;
>   vc->vc_hi_font_mask = 0;
> --
> 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 v5 05/24] posix-timers: Introduce {get,put}_timespec and {get,put}_itimerspec

2015-06-12 Thread Baolin Wang
These are new helper macros that convert between a user timespec/
itimerspec and a kernel timespec64/itimerspec64 structure.

When converting syscall functions, it need to deal with these conversions:
  user timespec (32 bit), kernel timespec (32 bit)
  user timespec (64 bit), kernel timespec (64 bit)
  user timespec (32 bit), kernel timespec64 (64 bit)
  user timespec (64 bit), kernel timespec64 (64 bit)
  user itimerspec (32 bit), kernel itimerspec (32 bit)
  user itimerspec (64 bit), kernel itimerspec (64 bit)
  user itimerspec (32 bit), kernel itimerspec64 (64 bit)
  user itimerspec (64 bit), kernel itimerspec64 (64 bit)

In order to handle all these conversions, and ensure that it can change
over all callers at the same time with the structure type above, and
introduce the get/put macros based on __put_user() and __get_user().

Signed-off-by: Baolin Wang 
---
 kernel/time/posix-timers.c |   29 +
 1 file changed, 29 insertions(+)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 31d11ac..5ddd912 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -147,6 +147,35 @@ static struct k_itimer *__lock_timer(timer_t timer_id, 
unsigned long *flags);
__timr;\
 })
 
+#define __get_timespec(kts, uts) \
+   (__get_user((kts)->tv_sec, &(uts)->tv_sec) || \
+   __get_user((kts)->tv_nsec, &(uts)->tv_nsec))
+
+#define __put_timespec(kts, uts) \
+   (__put_user((kts)->tv_sec, &(uts)->tv_sec) || \
+   __put_user((kts)->tv_nsec, &(uts)->tv_nsec))
+
+#define get_timespec(kts, uts) \
+   ((access_ok(VERIFY_READ, (uts), sizeof(*(uts))) || \
+   __get_timespec((kts), (uts))) ? \
+   -EFAULT : 0)
+
+#define put_timespec(kts, uts) \
+   ((access_ok(VERIFY_WRITE, (uts), sizeof(*(uts))) || \
+   __put_timespec((kts), (uts))) ? \
+   -EFAULT : 0)
+
+#define get_itimerspec(kit, uit) \
+   ((access_ok(VERIFY_READ, (uit), sizeof(*(uit))) || \
+   __get_timespec(&(kit)->it_interval, &(uit)->it_interval) || \
+   __get_timespec(&(kit)->it_value, &(uit)->it_value)))
+
+#define put_itimerspec(kit, uit) \
+   ((access_ok(VERIFY_WRITE, (uit), sizeof(*(uit))) || \
+   __put_timespec(&(kit)->it_interval, &(uit)->it_interval) || \
+   __put_timespec(&(kit)->it_value, &(uit)->it_value)) ? \
+   -EFAULT : 0)
+
 static int hash(struct signal_struct *sig, unsigned int nr)
 {
return hash_32(hash32_ptr(sig) ^ nr, HASH_BITS(posix_timers_hashtable));
-- 
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 v5 07/24] posix-timers: Implement y2038 safe timer_get64() callback

2015-06-12 Thread Baolin Wang
The timer_get() callback in struct k_clock is not year 2038 safe on
32bit systems.

To address this implement a new callback timer_get64() which uses
struct itimerspec64 along with a default implementation which is a
wrapper for the existing timer_get() callback. The default callback
is installed at registration time for all posix clocks which are not
yet converted to timer_get64() and will be removed once this is
completed.

Use the new callback in __timer_gettime().

Signed-off-by: Baolin Wang 
---
 include/linux/posix-timers.h |2 ++
 kernel/time/posix-timers.c   |   25 -
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 907f3fd..e84436b 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -113,6 +113,8 @@ struct k_clock {
 #define TIMER_RETRY 1
void (*timer_get) (struct k_itimer * timr,
   struct itimerspec * cur_setting);
+   void (*timer_get64) (struct k_itimer *timr,
+struct itimerspec64 *cur_setting);
 };
 
 extern struct k_clock clock_posix_cpu;
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 7d1973a..70b5550 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -140,6 +140,7 @@ static int common_timer_del(struct k_itimer *timer);
 static enum hrtimer_restart posix_timer_fn(struct hrtimer *data);
 
 static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags);
+static struct k_clock *clockid_to_kclock(const clockid_t id);
 
 #define lock_timer(tid, flags)\
 ({ struct k_itimer *__timr;   \
@@ -549,6 +550,16 @@ static struct pid *good_sigevent(sigevent_t * event)
return task_pid(rtn);
 }
 
+static void default_timer_get64(struct k_itimer *timr,
+   struct itimerspec64 *cur_setting64)
+{
+   struct itimerspec cur_setting;
+   struct k_clock *kc = clockid_to_kclock(timr->it_clock);
+
+   kc->timer_get(timr, &cur_setting);
+   *cur_setting64 = itimerspec_to_itimerspec64(&cur_setting);
+}
+
 void posix_timers_register_clock(const clockid_t clock_id,
 struct k_clock *new_clock)
 {
@@ -569,6 +580,9 @@ void posix_timers_register_clock(const clockid_t clock_id,
return;
}
 
+   if (new_clock->timer_get && !new_clock->timer_get64)
+   new_clock->timer_get64 = default_timer_get64;
+
posix_clocks[clock_id] = *new_clock;
 }
 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
@@ -802,7 +816,7 @@ common_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
cur_setting->it_value = ktime_to_timespec(remaining);
 }
 
-static int __timer_gettime(timer_t timer_id, struct itimerspec *cur_setting)
+static int __timer_gettime(timer_t timer_id, struct itimerspec64 *cur_setting)
 {
struct k_itimer *timr;
struct k_clock *kc;
@@ -814,10 +828,10 @@ static int __timer_gettime(timer_t timer_id, struct 
itimerspec *cur_setting)
return -EINVAL;
 
kc = clockid_to_kclock(timr->it_clock);
-   if (WARN_ON_ONCE(!kc || !kc->timer_get))
+   if (WARN_ON_ONCE(!kc || !kc->timer_get64))
ret = -EINVAL;
else
-   kc->timer_get(timr, cur_setting);
+   kc->timer_get64(timr, cur_setting);
 
unlock_timer(timr, flags);
return ret;
@@ -827,10 +841,11 @@ static int __timer_gettime(timer_t timer_id, struct 
itimerspec *cur_setting)
 SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
struct itimerspec __user *, setting)
 {
-   struct itimerspec cur_setting;
+   struct itimerspec64 cur_setting;
+
int ret = __timer_gettime(timer_id, &cur_setting);
 
-   if (!ret && copy_to_user(setting, &cur_setting, sizeof (cur_setting)))
+   if (!ret && put_itimerspec(&cur_setting, setting))
return -EFAULT;
 
return ret;
-- 
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 v5 06/24] posix-timers: Factor out the guts of 'timer_gettime' for reusing

2015-06-12 Thread Baolin Wang
In order to reuse the very same logic for the year 2038 safe syscalls
which we need to introduce for 32bit systems, factor out the guts of
the 'timer_gettime' syscall.

Signed-off-by: Baolin Wang 
---
 kernel/time/posix-timers.c |   16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 5ddd912..7d1973a 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -802,11 +802,8 @@ common_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
cur_setting->it_value = ktime_to_timespec(remaining);
 }
 
-/* Get the time remaining on a POSIX.1b interval timer. */
-SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
-   struct itimerspec __user *, setting)
+static int __timer_gettime(timer_t timer_id, struct itimerspec *cur_setting)
 {
-   struct itimerspec cur_setting;
struct k_itimer *timr;
struct k_clock *kc;
unsigned long flags;
@@ -820,9 +817,18 @@ SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
if (WARN_ON_ONCE(!kc || !kc->timer_get))
ret = -EINVAL;
else
-   kc->timer_get(timr, &cur_setting);
+   kc->timer_get(timr, cur_setting);
 
unlock_timer(timr, flags);
+   return ret;
+}
+
+/* Get the time remaining on a POSIX.1b interval timer. */
+SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
+   struct itimerspec __user *, setting)
+{
+   struct itimerspec cur_setting;
+   int ret = __timer_gettime(timer_id, &cur_setting);
 
if (!ret && copy_to_user(setting, &cur_setting, sizeof (cur_setting)))
return -EFAULT;
-- 
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 v5 09/24] posix-timers: Implement y2038 safe timer_set64() callback

2015-06-12 Thread Baolin Wang
The timer_set() callback in struct k_clock is not year 2038 safe on
32bit systems.

To address this implement a new callback timer_set64() which uses
struct itimerspec64 along with a default implementation which is a
wrapper for the existing timer_set() callback. The default callback
is installed at registration time for all posix clocks which are not
yet converted to timer_set64() and will be removed once this is
completed.

Use the new callback in __timer_settime().

Signed-off-by: Baolin Wang 
---
 include/linux/posix-timers.h |3 +++
 kernel/time/posix-timers.c   |   39 +--
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index e84436b..16c3364 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -109,6 +109,9 @@ struct k_clock {
int (*timer_set) (struct k_itimer * timr, int flags,
  struct itimerspec * new_setting,
  struct itimerspec * old_setting);
+   int (*timer_set64) (struct k_itimer *timr, int flags,
+   struct itimerspec64 *new_setting,
+   struct itimerspec64 *old_setting);
int (*timer_del) (struct k_itimer * timr);
 #define TIMER_RETRY 1
void (*timer_get) (struct k_itimer * timr,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 2f1c26f..778610c 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -560,6 +560,23 @@ static void default_timer_get64(struct k_itimer *timr,
*cur_setting64 = itimerspec_to_itimerspec64(&cur_setting);
 }
 
+static int default_timer_set64(struct k_itimer *timr, int flags,
+  struct itimerspec64 *new_setting64,
+  struct itimerspec64 *old_setting64)
+{
+   struct k_clock *kc = clockid_to_kclock(timr->it_clock);
+   struct itimerspec new_setting, old_setting;
+   struct itimerspec *rtn = old_setting64 ? &old_setting : NULL;
+   int ret;
+
+   new_setting = itimerspec64_to_itimerspec(new_setting64);
+   ret = kc->timer_set(timr, flags, &new_setting, rtn);
+   if (!ret && old_setting64)
+   *old_setting64 = itimerspec_to_itimerspec64(&old_setting);
+
+   return ret;
+}
+
 void posix_timers_register_clock(const clockid_t clock_id,
 struct k_clock *new_clock)
 {
@@ -582,6 +599,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
 
if (new_clock->timer_get && !new_clock->timer_get64)
new_clock->timer_get64 = default_timer_get64;
+   if (new_clock->timer_set && !new_clock->timer_set64)
+   new_clock->timer_set64 = default_timer_set64;
 
posix_clocks[clock_id] = *new_clock;
 }
@@ -927,16 +946,16 @@ common_timer_set(struct k_itimer *timr, int flags,
return 0;
 }
 
-static int __timer_settime(timer_t timer_id, int flags, struct itimerspec 
*new_spec,
-  struct itimerspec *old_spec)
+static int __timer_settime(timer_t timer_id, int flags, struct itimerspec64 
*new_spec,
+  struct itimerspec64 *old_spec)
 {
struct k_itimer *timr;
int error = 0;
unsigned long flag;
struct k_clock *kc;
 
-   if (!timespec_valid(&new_spec->it_interval) ||
-   !timespec_valid(&new_spec->it_value))
+   if (!timespec64_valid(&new_spec->it_interval) ||
+   !timespec64_valid(&new_spec->it_value))
return -EINVAL;
 
 retry:
@@ -945,10 +964,10 @@ retry:
return -EINVAL;
 
kc = clockid_to_kclock(timr->it_clock);
-   if (WARN_ON_ONCE(!kc || !kc->timer_set))
+   if (WARN_ON_ONCE(!kc || !kc->timer_set64))
error = -EINVAL;
else
-   error = kc->timer_set(timr, flags, new_spec, old_spec);
+   error = kc->timer_set64(timr, flags, new_spec, old_spec);
 
unlock_timer(timr, flag);
if (error == TIMER_RETRY) {
@@ -964,20 +983,20 @@ SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, 
flags,
const struct itimerspec __user *, new_setting,
struct itimerspec __user *, old_setting)
 {
-   struct itimerspec new_spec, old_spec;
+   struct itimerspec64 new_spec, old_spec;
int error = 0;
-   struct itimerspec *rtn = old_setting ? &old_spec : NULL;
+   struct itimerspec64 *rtn = old_setting ? &old_spec : NULL;
 
if (!new_setting)
return -EINVAL;
 
-   if (copy_from_user(&new_spec, new_setting, sizeof (new_spec)))
+   if (get_itimerspec(&new_spec, new_setting))
return -EFAULT;
 
error = __timer_settime(timer_id, flags, &new_spec, rtn);
 
if (old_setting && !error &&
-   copy_to_user(old_setting, &old_spec, sizeof (old_spec)))
+   put_itimerspec(&old_spec, old_setting))
  

[PATCH v5 08/24] posix-timers: Factor out the guts of 'timer_settime' for reusing

2015-06-12 Thread Baolin Wang
In order to reuse the very same logic for the year 2038 safe syscalls
which we need to introduce for 32bit system, factor out the guts of
the 'timer_settime' syscall.

Signed-off-by: Baolin Wang 
---
 kernel/time/posix-timers.c |   41 ++---
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 70b5550..2f1c26f 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -927,27 +927,18 @@ common_timer_set(struct k_itimer *timr, int flags,
return 0;
 }
 
-/* Set a POSIX.1b interval timer */
-SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
-   const struct itimerspec __user *, new_setting,
-   struct itimerspec __user *, old_setting)
+static int __timer_settime(timer_t timer_id, int flags, struct itimerspec 
*new_spec,
+  struct itimerspec *old_spec)
 {
struct k_itimer *timr;
-   struct itimerspec new_spec, old_spec;
int error = 0;
unsigned long flag;
-   struct itimerspec *rtn = old_setting ? &old_spec : NULL;
struct k_clock *kc;
 
-   if (!new_setting)
+   if (!timespec_valid(&new_spec->it_interval) ||
+   !timespec_valid(&new_spec->it_value))
return -EINVAL;
 
-   if (copy_from_user(&new_spec, new_setting, sizeof (new_spec)))
-   return -EFAULT;
-
-   if (!timespec_valid(&new_spec.it_interval) ||
-   !timespec_valid(&new_spec.it_value))
-   return -EINVAL;
 retry:
timr = lock_timer(timer_id, &flag);
if (!timr)
@@ -957,14 +948,34 @@ retry:
if (WARN_ON_ONCE(!kc || !kc->timer_set))
error = -EINVAL;
else
-   error = kc->timer_set(timr, flags, &new_spec, rtn);
+   error = kc->timer_set(timr, flags, new_spec, old_spec);
 
unlock_timer(timr, flag);
if (error == TIMER_RETRY) {
-   rtn = NULL; // We already got the old time...
+   old_spec = NULL; // We already got the old time...
goto retry;
}
 
+   return error;
+}
+
+/* Set a POSIX.1b interval timer */
+SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
+   const struct itimerspec __user *, new_setting,
+   struct itimerspec __user *, old_setting)
+{
+   struct itimerspec new_spec, old_spec;
+   int error = 0;
+   struct itimerspec *rtn = old_setting ? &old_spec : NULL;
+
+   if (!new_setting)
+   return -EINVAL;
+
+   if (copy_from_user(&new_spec, new_setting, sizeof (new_spec)))
+   return -EFAULT;
+
+   error = __timer_settime(timer_id, flags, &new_spec, rtn);
+
if (old_setting && !error &&
copy_to_user(old_setting, &old_spec, sizeof (old_spec)))
error = -EFAULT;
-- 
1.7.9.5

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


Re: [PATCH] x86: General protection fault after STR (32 bit systems only)

2015-06-12 Thread Ingo Molnar

* Andy Lutomirski  wrote:

> > --- a/arch/x86/kernel/acpi/wakeup_32.S
> > +++ b/arch/x86/kernel/acpi/wakeup_32.S
> > @@ -81,6 +81,10 @@ ENTRY(do_suspend_lowlevel)
> > jmp ret_point
> > .p2align 4,,7
> >  ret_point:
> > +   /* In case the BIOS corrupted DS, make the kernel context minimally 
> > functional: */
> > +   movl$__KERNEL_DS, %eax
> > +   movl%eax, %ds
> > +
> 
> On further thought, I think you want movl $__USER_DS, %eax.  The
> 32-bit kernel is a strange beast.  Also, you should probably fix up
> %es as well.

So restore_processor_state() already restores ES. The idea here was to reload 
DS 
early on, because the kernel implicitly uses it for data access so we need it 
to 
be good to be able to continue executing any generic kernel code.

We don't use %es: prefixed assembly AFAICS, what are the implicit users of ES?

Also, to further confuse things, we also have:

ENTRY(wakeup_pmode_return)
wakeup_pmode_return:
movw$__KERNEL_DS, %ax
movw%ax, %ss
movw%ax, %ds
movw%ax, %es
movw%ax, %fs
movw%ax, %gs

# reload the gdt, as we need the full 32 bit address
lidtsaved_idt
lldtsaved_ldt
ljmp$(__KERNEL_CS), $1f
1:
movl%cr3, %eax
movl%eax, %cr3
wbinvd

which seems to be another layer of restoration - but it possibly does not 
trigger 
in the S2RAM case here.

Oh, funny the 'reload the gdt' comment: do you see an LGDT there? It reloads 
all 
segment selectors, the IDT, LDT and CR3, but does not seem to reload the GDT - 
the 
only thing the comment describes.

Thanks,

Ingo
--
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 v5 12/24] posix-timers: Factor out the guts of 'clock_gettime' for reusing

2015-06-12 Thread Baolin Wang
In order to reuse the very same logic for the year 2038 safe syscalls
which we need to introduce for 32bit system, factor out the guts of
the 'clock_gettime' syscall.

Signed-off-by: Baolin Wang 
---
 kernel/time/posix-timers.c |   16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index dcc632c..ca63626 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -1124,17 +1124,23 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, 
which_clock,
return __clock_settime(which_clock, &new_tp);
 }
 
-SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-   struct timespec __user *,tp)
+static int __clock_gettime(clockid_t which_clock, struct timespec *ts)
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
-   struct timespec kernel_tp;
-   int error;
 
if (!kc)
return -EINVAL;
 
-   error = kc->clock_get(which_clock, &kernel_tp);
+   return kc->clock_get(which_clock, ts);
+}
+
+SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
+   struct timespec __user *,tp)
+{
+   struct timespec kernel_tp;
+   int error;
+
+   error = __clock_gettime(which_clock, &kernel_tp);
 
if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
error = -EFAULT;
-- 
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 v5 14/24] posix-timers: Factor out the guts of 'clcok_getres' for reusing

2015-06-12 Thread Baolin Wang
In order to reuse the very same logic for the year 2038 safe syscalls
which we need to introduce for 32bit system, factor out the guts of
the 'clock_getres' syscall.

Signed-off-by: Baolin Wang 
---
 kernel/time/posix-timers.c |   16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 021cd8f..a5207f0 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -1187,17 +1187,23 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, 
which_clock,
return err;
 }
 
-SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
-   struct timespec __user *, tp)
+static int __clock_getres(clockid_t which_clock, struct timespec *ts)
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
-   struct timespec rtn_tp;
-   int error;
 
if (!kc)
return -EINVAL;
 
-   error = kc->clock_getres(which_clock, &rtn_tp);
+   return kc->clock_getres(which_clock, ts);
+}
+
+SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
+   struct timespec __user *, tp)
+{
+   struct timespec rtn_tp;
+   int error;
+
+   error = __clock_getres(which_clock, &rtn_tp);
 
if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp)))
error = -EFAULT;
-- 
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 v5 13/24] posix-timers: Implement y2038 safe clock_get64() callback

2015-06-12 Thread Baolin Wang
The clock_get() callback in struct k_clock is not year 2038 safe on
32bit systems.

To address this implement a new callback clock_get64() which uses
struct timespec64 along with a default implementation which is a
wrapper for the existing clock_get() callback. The default callback
is installed at registration time for all posix clocks which are not
yet converted to clock_get64() and will be removed once this is
completed.

Use the new callback in __clock_gettime().

Signed-off-by: Baolin Wang 
---
 include/linux/posix-timers.h |1 +
 kernel/time/posix-timers.c   |   28 ++--
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 2b19ec8..be2123d 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -103,6 +103,7 @@ struct k_clock {
int (*clock_set64) (const clockid_t which_clock,
const struct timespec64 *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
+   int (*clock_get64) (const clockid_t which_clock, struct timespec64 *tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ca63626..021cd8f 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -589,6 +589,20 @@ static int default_clock_set64(const clockid_t which_clock,
return ret;
 }
 
+static int default_clock_get64(const clockid_t which_clock,
+  struct timespec64 *tp64)
+{
+   struct k_clock *kc = clockid_to_kclock(which_clock);
+   struct timespec tp;
+   int ret;
+
+   ret = kc->clock_get(which_clock, &tp);
+   if (!ret)
+   *tp64 = timespec_to_timespec64(tp);
+
+   return ret;
+}
+
 void posix_timers_register_clock(const clockid_t clock_id,
 struct k_clock *new_clock)
 {
@@ -598,8 +612,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
return;
}
 
-   if (!new_clock->clock_get) {
-   printk(KERN_WARNING "POSIX clock id %d lacks clock_get()\n",
+   if (!new_clock->clock_get && !new_clock->clock_get64) {
+   printk(KERN_WARNING "POSIX clock id %d lacks clock_get() and 
clock_get64()\n",
   clock_id);
return;
}
@@ -615,6 +629,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
new_clock->timer_set64 = default_timer_set64;
if (new_clock->clock_set && !new_clock->clock_set64)
new_clock->clock_set64 = default_clock_set64;
+   if (new_clock->clock_get && !new_clock->clock_get64)
+   new_clock->clock_get64 = default_clock_get64;
 
posix_clocks[clock_id] = *new_clock;
 }
@@ -1124,25 +1140,25 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, 
which_clock,
return __clock_settime(which_clock, &new_tp);
 }
 
-static int __clock_gettime(clockid_t which_clock, struct timespec *ts)
+static int __clock_gettime(clockid_t which_clock, struct timespec64 *ts)
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
 
if (!kc)
return -EINVAL;
 
-   return kc->clock_get(which_clock, ts);
+   return kc->clock_get64(which_clock, ts);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
struct timespec __user *,tp)
 {
-   struct timespec kernel_tp;
+   struct timespec64 kernel_tp;
int error;
 
error = __clock_gettime(which_clock, &kernel_tp);
 
-   if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
+   if (!error && put_timespec(&kernel_tp, tp))
error = -EFAULT;
 
return error;
-- 
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 v5 15/24] posix-timers: Implement y2038 safe clock_getres64() callback

2015-06-12 Thread Baolin Wang
The clock_getres() callback in struct k_clock is not year 2038 safe on
32bit systems.

To address this implement a new callback clock_getres64() which uses
struct timespec64 along with a default implementation which is a
wrapper for the existing clock_getres() callback. The default callback
is installed at registration time for all posix clocks which are not
yet converted to clock_getres64() and will be removed once this is
completed.

Use the new callback in __clock_getres().

Signed-off-by: Baolin Wang 
---
 include/linux/posix-timers.h |1 +
 kernel/time/posix-timers.c   |   31 ---
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index be2123d..35786c5 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -98,6 +98,7 @@ struct k_itimer {
 
 struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
+   int (*clock_getres64) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
int (*clock_set64) (const clockid_t which_clock,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index a5207f0..0b0663a 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -603,6 +603,20 @@ static int default_clock_get64(const clockid_t which_clock,
return ret;
 }
 
+static int default_clock_getres64(const clockid_t which_clock,
+ struct timespec64 *tp64)
+{
+   struct k_clock *kc = clockid_to_kclock(which_clock);
+   struct timespec tp;
+   int ret;
+
+   ret = kc->clock_getres(which_clock, &tp);
+   if (!ret)
+   *tp64 = timespec_to_timespec64(tp);
+
+   return 0;
+}
+
 void posix_timers_register_clock(const clockid_t clock_id,
 struct k_clock *new_clock)
 {
@@ -617,8 +631,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
   clock_id);
return;
}
-   if (!new_clock->clock_getres) {
-   printk(KERN_WARNING "POSIX clock id %d lacks clock_getres()\n",
+   if (!new_clock->clock_getres && !new_clock->clock_getres64) {
+   printk(KERN_WARNING "POSIX clock id %d lacks clock_getres() and 
clock_getres64()\n",
   clock_id);
return;
}
@@ -631,6 +645,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
new_clock->clock_set64 = default_clock_set64;
if (new_clock->clock_get && !new_clock->clock_get64)
new_clock->clock_get64 = default_clock_get64;
+   if (new_clock->clock_getres && !new_clock->clock_getres64)
+   new_clock->clock_getres64 = default_clock_getres64;
 
posix_clocks[clock_id] = *new_clock;
 }
@@ -678,7 +694,8 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
return (id & CLOCKFD_MASK) == CLOCKFD ?
&clock_posix_dynamic : &clock_posix_cpu;
 
-   if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
+   if (id >= MAX_CLOCKS || (!posix_clocks[id].clock_getres
+   && !posix_clocks[id].clock_getres64))
return NULL;
return &posix_clocks[id];
 }
@@ -1187,25 +1204,25 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, 
which_clock,
return err;
 }
 
-static int __clock_getres(clockid_t which_clock, struct timespec *ts)
+static int __clock_getres(clockid_t which_clock, struct timespec64 *ts)
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
 
if (!kc)
return -EINVAL;
 
-   return kc->clock_getres(which_clock, ts);
+   return kc->clock_getres64(which_clock, ts);
 }
 
 SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
struct timespec __user *, tp)
 {
-   struct timespec rtn_tp;
+   struct timespec64 rtn_tp;
int error;
 
error = __clock_getres(which_clock, &rtn_tp);
 
-   if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp)))
+   if (!error && tp && put_timespec(&rtn_tp, tp))
error = -EFAULT;
 
return error;
-- 
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 v5 11/24] posix-timers: Implement y2038 safe clock_set64() callback

2015-06-12 Thread Baolin Wang
The clock_set() callback in struct k_clock is not year 2038 safe on
32bit systems.

To address this implement a new callback clock_set64() which uses
struct timespec64 along with a default implementation which is a
wrapper for the existing clock_set() callback. The default callback
is installed at registration time for all posix clocks which are not
yet converted to clock_set64() and will be removed once this is
completed.

Use the new callback in __clock_settime().

Signed-off-by: Baolin Wang 
---
 include/linux/posix-timers.h |2 ++
 kernel/time/posix-timers.c   |   24 +++-
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 16c3364..2b19ec8 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -100,6 +100,8 @@ struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
+   int (*clock_set64) (const clockid_t which_clock,
+   const struct timespec64 *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 65610ac..dcc632c 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -577,6 +577,18 @@ static int default_timer_set64(struct k_itimer *timr, int 
flags,
return ret;
 }
 
+static int default_clock_set64(const clockid_t which_clock,
+  const struct timespec64 *tp64)
+{
+   struct k_clock *kc = clockid_to_kclock(which_clock);
+   struct timespec tp;
+   int ret;
+
+   tp = timespec64_to_timespec(*tp64);
+   ret = kc->clock_set(which_clock, &tp);
+   return ret;
+}
+
 void posix_timers_register_clock(const clockid_t clock_id,
 struct k_clock *new_clock)
 {
@@ -601,6 +613,8 @@ void posix_timers_register_clock(const clockid_t clock_id,
new_clock->timer_get64 = default_timer_get64;
if (new_clock->timer_set && !new_clock->timer_set64)
new_clock->timer_set64 = default_timer_set64;
+   if (new_clock->clock_set && !new_clock->clock_set64)
+   new_clock->clock_set64 = default_clock_set64;
 
posix_clocks[clock_id] = *new_clock;
 }
@@ -1089,22 +1103,22 @@ void exit_itimers(struct signal_struct *sig)
}
 }
 
-static int __clock_settime(clockid_t which_clock, struct timespec *ts)
+static int __clock_settime(clockid_t which_clock, struct timespec64 *ts)
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
 
-   if (!kc || !kc->clock_set)
+   if (!kc || !kc->clock_set64)
return -EINVAL;
 
-   return kc->clock_set(which_clock, ts);
+   return kc->clock_set64(which_clock, ts);
 }
 
 SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
const struct timespec __user *, tp)
 {
-   struct timespec new_tp;
+   struct timespec64 new_tp;
 
-   if (copy_from_user(&new_tp, tp, sizeof (*tp)))
+   if (get_timespec(&new_tp, tp))
return -EFAULT;
 
return __clock_settime(which_clock, &new_tp);
-- 
1.7.9.5

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


Re: [PATCH V3 1/4] x86: acpi: define uncached page flag

2015-06-12 Thread Ingo Molnar

* Jonathan (Zhixiong) Zhang  wrote:

> From: "Jonathan (Zhixiong) Zhang" 
> 
> This definition is used in APEI code when needing to map pages as
> uncached.
> 
> Signed-off-by: Jonathan (Zhixiong) Zhang 
> ---
>  arch/x86/include/asm/acpi.h | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
> index 3a45668f6dc3..6afb27682b00 100644
> --- a/arch/x86/include/asm/acpi.h
> +++ b/arch/x86/include/asm/acpi.h
> @@ -138,6 +138,10 @@ static inline void disable_acpi(void) { }
>  
>  #endif /* !CONFIG_ACPI */
>  
> +#ifdef   CONFIG_ACPI_APEI
> +#define ARCH_APEI_PAGE_KERNEL_UC (PAGE_KERNEL_NOCACHE)
> +#endif /*CONFIG_ACPI_APEI */

 - Why the tab?

 - Why the parentheses?

 - Why the closing comment block for a oneliner define? It's not like we forget 
   what it's about.

 - When the missing space in the closing comment?

That's 4 uglies in 3 lines of code, wow ...

Thanks,

Ingo
--
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 v5 10/24] posix-timers: Factor out the guts of 'clock_settime' for reusing

2015-06-12 Thread Baolin Wang
In order to reuse the very same logic for the year 2038 safe syscalls
which we need to introduce for 32bit system, factor out the guts of
the 'clock_settime' syscall.

Signed-off-by: Baolin Wang 
---
 kernel/time/posix-timers.c |   14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 778610c..65610ac 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -1089,19 +1089,25 @@ void exit_itimers(struct signal_struct *sig)
}
 }
 
-SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
-   const struct timespec __user *, tp)
+static int __clock_settime(clockid_t which_clock, struct timespec *ts)
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
-   struct timespec new_tp;
 
if (!kc || !kc->clock_set)
return -EINVAL;
 
+   return kc->clock_set(which_clock, ts);
+}
+
+SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
+   const struct timespec __user *, tp)
+{
+   struct timespec new_tp;
+
if (copy_from_user(&new_tp, tp, sizeof (*tp)))
return -EFAULT;
 
-   return kc->clock_set(which_clock, &new_tp);
+   return __clock_settime(which_clock, &new_tp);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-- 
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 v5 16/24] timekeeping: Change the implementation of timekeeping_clocktai()

2015-06-12 Thread Baolin Wang
The timekeeping_clocktai() function is not year 2038 safe on 32bit
systems, change its implementation with using struct timespec64.

Signed-off-by: Baolin Wang 
---
 include/linux/timekeeping.h |4 ++--
 kernel/time/posix-timers.c  |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 2dcc86b..07581c0 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -256,9 +256,9 @@ static inline void get_monotonic_boottime64(struct 
timespec64 *ts)
*ts = ktime_to_timespec64(ktime_get_boottime());
 }
 
-static inline void timekeeping_clocktai(struct timespec *ts)
+static inline void timekeeping_clocktai(struct timespec64 *ts)
 {
-   *ts = ktime_to_timespec(ktime_get_clocktai());
+   *ts = ktime_to_timespec64(ktime_get_clocktai());
 }
 
 /*
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 0b0663a..029a2b6 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -296,7 +296,7 @@ static int posix_get_boottime(const clockid_t which_clock, 
struct timespec *tp)
return 0;
 }
 
-static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
+static int posix_get_tai(clockid_t which_clock, struct timespec64 *tp)
 {
timekeeping_clocktai(tp);
return 0;
@@ -350,7 +350,7 @@ static __init int init_posix_timers(void)
};
struct k_clock clock_tai = {
.clock_getres   = posix_get_hrtimer_res,
-   .clock_get  = posix_get_tai,
+   .clock_get64= posix_get_tai,
.nsleep = common_nsleep,
.nsleep_restart = hrtimer_nanosleep_restart,
.timer_create   = common_timer_create,
-- 
1.7.9.5

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


Re: [alsa-devel] [PATCH v2] ALSA: aoa: convert bus code to use dev_groups

2015-06-12 Thread Quentin Lambert



On 11/06/2015 14:25, Takashi Iwai wrote:

At Thu, 11 Jun 2015 14:04:45 +0200,
Quentin Lambert wrote:



On 11/06/2015 12:02, Takashi Iwai wrote:

At Thu, 11 Jun 2015 10:03:38 +0200,
Quentin Lambert wrote:

The dev_attrs field of struct bus_type is going away, use dev_groups instead.
This converts the soundbus code to use the correct field.

Given that all other usages of the macro define the struct attribute
*xxx_attrs[] in the same file they assign the .dev_groups field, this patch
merges sysfs.c into core.c.

These modifications were made using Coccinelle.

Signed-off-by: Quentin Lambert 
---
   Changes since v1:
- Fix the commit message to actually talk about soundbus rather than MDIO
- This version attempt to fix a problem resulting from the macro
  ATTRIBUTE_GROUPS declaring the structure as static by merging sysfs.c into
  core.c. I understand that this may not be the prefered solution since
  Takashi suggested that adding a comment line to the previous version could
  be acceptable.

Hmm, the patch doesn't look as mentioned here.
It's rather bigger than the previous patch.  Is this intentional?


Well as mentionned in the change log it is bigger because it moves the
code from sysfs.c to
core.c. I realise as I am writing this that this patch should have
really been two patches.
The first one removing sysfs.c and the second one removing the use of
the dev_attrs.

Yes, that'd be better.  OTOH, do we really need to copy many codes at
all?  I really prefer shorter changes, if possible.
All right, I will send a third version following the comments you made 
on the fist version. I just wanted to propose this idea in case it 
suited you.


Quentin

--
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 v1 1/2] perf,x86: add Intel Memory Bandwidth Monitoring (MBM) PMU

2015-06-12 Thread Kanaka Juvva
This patch adds Memory Bandwidth Monitoring events to the exitsing
intel_cqm pmu in the Linux Kernel.

Intel MBM builds on Cache Monitoring Technology (CMT) infrastructure
to allow monitoring of bandwidth from one level of the cache hierarchy
to the next - in this case focusing on the L3 cache, which is typically
backed directly by system memory. As a  result of this implementation,
memory bandwidth can be monitored.

MBM counters are available in Intel Xeon CPUs. The following events are
implemented in the kernel and expose two MBM counters via perf_event
interface:

- llc_local_bw: bandwidth consumption of all coress on socket
- llc_total_bw: bandwidth consumption of all cores on socket + bandwidth
  for QPI accesses

At present, the MBM events are checked at one second interval provided
by the HRTIMER of the MBM event. MBM counters can overflow atmost once in
a second and thus must be read atleast once in a second. Overflow is
detected and handled. Cumulative average value is calculated for each
bandwidth type upon reading a new value from the MSR.

Signed-off-by: Kanaka Juvva 
---
 arch/x86/include/asm/cpufeature.h  |   2 +
 arch/x86/kernel/cpu/common.c   |   5 +-
 arch/x86/kernel/cpu/perf_event_intel_cqm.c | 619 +++--
 3 files changed, 585 insertions(+), 41 deletions(-)

diff --git a/arch/x86/include/asm/cpufeature.h 
b/arch/x86/include/asm/cpufeature.h
index 3d6606f..26505f6 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -248,6 +248,8 @@
 
 /* Intel-defined CPU QoS Sub-leaf, CPUID level 0x000F:0 (edx), word 11 */
 #define X86_FEATURE_CQM_LLC(11*32+ 1) /* LLC QoS if 1 */
+#define X86_FEATURE_CQM_MBM_TOTAL (12*32+1) /* LLC Total MBM monitoring  */
+#define X86_FEATURE_CQM_MBM_LOCAL (12*32+2) /* LLC Local MBM monitoring  */
 
 /* Intel-defined CPU QoS Sub-leaf, CPUID level 0x000F:1 (edx), word 12 */
 #define X86_FEATURE_CQM_OCCUP_LLC (12*32+ 0) /* LLC occupancy monitoring if 1 
*/
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a62cf04..d046f46 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -660,7 +660,10 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
/* QoS sub-leaf, EAX=0Fh, ECX=1 */
cpuid_count(0x000F, 1, &eax, &ebx, &ecx, &edx);
c->x86_capability[12] = edx;
-   if (cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC)) {
+   if ((cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC))
+ || ((cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL))
+ ||  (cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL {
+
c->x86_cache_max_rmid = ecx;
c->x86_cache_occ_scale = ebx;
}
diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c 
b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
index 1880761..d210c5c 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
@@ -12,10 +12,20 @@
 #define MSR_IA32_PQR_ASSOC 0x0c8f
 #define MSR_IA32_QM_CTR0x0c8e
 #define MSR_IA32_QM_EVTSEL 0x0c8d
+#define MAX_MBM_CNTR0xff
+#define MBM_SOCKET_MAX  8
+#define MBM_TIME_DELTA_MAX  1000
+#define MBM_TIME_DELTA_MIN  1000
+#define MBM_SCALING_FACTOR  1000
+#define MBM_SCALING_HALF(MBM_SCALING_FACTOR/2)
+#define MBM_FIFO_SIZE_MIN   10
+#define MBM_FIFO_SIZE_MAX   300
 
-static u32 cqm_max_rmid = -1;
-static unsigned int cqm_l3_scale; /* supposedly cacheline size */
 
+static u32 cqm_max_rmid = -1;
+static unsigned int cqm_l3_scale;/* supposedly cacheline size */
+static unsigned mbm_window_size = MBM_FIFO_SIZE_MIN;
+static bool cqm_llc_occ, cqm_mbm;
 /**
  * struct intel_pqr_state - State cache for the PQR MSR
  * @rmid:  The cached Resource Monitoring ID
@@ -42,6 +52,34 @@ struct intel_pqr_state {
  * interrupts disabled, which is sufficient for the protection.
  */
 static DEFINE_PER_CPU(struct intel_pqr_state, pqr_state);
+static DEFINE_PER_CPU(struct mbm_pmu *, mbm_pmu);
+static DEFINE_PER_CPU(struct mbm_pmu *, mbm_pmu_to_free);
+
+/*
+ * mbm pmu is used for storing mbm_local and mbm_total
+ * events
+ */
+struct mbm_pmu {
+   spinlock_t   lock;
+   int  n_active; /* number of active events */
+   struct list_head active_list;
+   struct pmu   *pmu; /* pointer to mbm perf_event */
+   ktime_t  timer_interval; /* in ktime_t unit */
+   struct hrtimer   hrtimer;
+};
+
+struct sample {
+   u64 bytes; /* mbm counter value read*/
+   u64 cum_avg;   /* current running average of bandwidth */
+   ktime_t prev_time;
+   u64 index; /* current sample no */
+   u32 mbmfifo[MBM_FIFO_SIZE_MAX]; /* window of last n bw values */
+   u32  fifoin; /* mbmfifo in counter for sliding window */
+

[PATCH v5 17/24] posix-timers: Convert to y2038 safe callbacks

2015-06-12 Thread Baolin Wang
The clock_getres()/clock_get()/clock_set()/timer_set()/timer_get()
callbacks in struct k_clock are not year 2038 safe on 32bit systems,
and it need convert to safe callbacks which use struct timespec64
or struct itimerspec64.

Signed-off-by: Baolin Wang 
---
 kernel/time/posix-timers.c |   94 ++--
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 029a2b6..80f630a 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -132,9 +132,9 @@ static struct k_clock posix_clocks[MAX_CLOCKS];
 static int common_nsleep(const clockid_t, int flags, struct timespec *t,
 struct timespec __user *rmtp);
 static int common_timer_create(struct k_itimer *new_timer);
-static void common_timer_get(struct k_itimer *, struct itimerspec *);
+static void common_timer_get(struct k_itimer *, struct itimerspec64 *);
 static int common_timer_set(struct k_itimer *, int,
-   struct itimerspec *, struct itimerspec *);
+   struct itimerspec64 *, struct itimerspec64 *);
 static int common_timer_del(struct k_itimer *timer);
 
 static enum hrtimer_restart posix_timer_fn(struct hrtimer *data);
@@ -233,17 +233,17 @@ static inline void unlock_timer(struct k_itimer *timr, 
unsigned long flags)
 }
 
 /* Get clock_realtime */
-static int posix_clock_realtime_get(clockid_t which_clock, struct timespec *tp)
+static int posix_clock_realtime_get(clockid_t which_clock, struct timespec64 
*tp)
 {
-   ktime_get_real_ts(tp);
+   ktime_get_real_ts64(tp);
return 0;
 }
 
 /* Set clock_realtime */
 static int posix_clock_realtime_set(const clockid_t which_clock,
-   const struct timespec *tp)
+   const struct timespec64 *tp)
 {
-   return do_sys_settimeofday(tp, NULL);
+   return do_sys_settimeofday64(tp, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
@@ -255,44 +255,44 @@ static int posix_clock_realtime_adj(const clockid_t 
which_clock,
 /*
  * Get monotonic time for posix timers
  */
-static int posix_ktime_get_ts(clockid_t which_clock, struct timespec *tp)
+static int posix_ktime_get_ts(clockid_t which_clock, struct timespec64 *tp)
 {
-   ktime_get_ts(tp);
+   ktime_get_ts64(tp);
return 0;
 }
 
 /*
  * Get monotonic-raw time for posix timers
  */
-static int posix_get_monotonic_raw(clockid_t which_clock, struct timespec *tp)
+static int posix_get_monotonic_raw(clockid_t which_clock, struct timespec64 
*tp)
 {
-   getrawmonotonic(tp);
+   getrawmonotonic64(tp);
return 0;
 }
 
 
-static int posix_get_realtime_coarse(clockid_t which_clock, struct timespec 
*tp)
+static int posix_get_realtime_coarse(clockid_t which_clock, struct timespec64 
*tp)
 {
-   *tp = current_kernel_time();
+   *tp = current_kernel_time64();
return 0;
 }
 
 static int posix_get_monotonic_coarse(clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
-   *tp = get_monotonic_coarse();
+   *tp = get_monotonic_coarse64();
return 0;
 }
 
-static int posix_get_coarse_res(const clockid_t which_clock, struct timespec 
*tp)
+static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 
*tp)
 {
-   *tp = ktime_to_timespec(KTIME_LOW_RES);
+   *tp = ktime_to_timespec64(KTIME_LOW_RES);
return 0;
 }
 
-static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
+static int posix_get_boottime(const clockid_t which_clock, struct timespec64 
*tp)
 {
-   get_monotonic_boottime(tp);
+   get_monotonic_boottime64(tp);
return 0;
 }
 
@@ -302,7 +302,7 @@ static int posix_get_tai(clockid_t which_clock, struct 
timespec64 *tp)
return 0;
 }
 
-static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec *tp)
+static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = hrtimer_resolution;
@@ -315,57 +315,57 @@ static int posix_get_hrtimer_res(clockid_t which_clock, 
struct timespec *tp)
 static __init int init_posix_timers(void)
 {
struct k_clock clock_realtime = {
-   .clock_getres   = posix_get_hrtimer_res,
-   .clock_get  = posix_clock_realtime_get,
-   .clock_set  = posix_clock_realtime_set,
+   .clock_getres64 = posix_get_hrtimer_res,
+   .clock_get64= posix_clock_realtime_get,
+   .clock_set64= posix_clock_realtime_set,
.clock_adj  = posix_clock_realtime_adj,
.nsleep = common_nsleep,
.nsleep_restart = hrtimer_nanosleep_restart,
.timer_create   = common_timer_create,
-   .timer_set  

[PATCH v5 18/24] mmtimer: Convert to y2038 safe callbacks

2015-06-12 Thread Baolin Wang
The clock_getres()/clock_get()/clock_set()/timer_set()/timer_get()
callbacks in struct k_clock are not year 2038 safe on 32bit systems,
and it need convert to safe callbacks which use struct timespec64
or struct itimerspec64.

Signed-off-by: Baolin Wang 
---
 drivers/char/mmtimer.c |   36 +---
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 3d6c067..213d0bb 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -478,18 +478,18 @@ static int sgi_clock_period;
 static struct timespec sgi_clock_offset;
 static int sgi_clock_period;
 
-static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
+static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
 {
u64 nsec;
 
nsec = rtc_time() * sgi_clock_period
+ sgi_clock_offset.tv_nsec;
-   *tp = ns_to_timespec(nsec);
+   *tp = ns_to_timespec64(nsec);
tp->tv_sec += sgi_clock_offset.tv_sec;
return 0;
 };
 
-static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp)
+static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp)
 {
 
u64 nsec;
@@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr)
 }
 
 /* Assumption: it_lock is already held with irq's disabled */
-static void sgi_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
+static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 
*cur_setting)
 {
 
if (timr->it.mmtimer.clock == TIMER_OFF) {
@@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct 
itimerspec *cur_setting)
return;
}
 
-   cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * 
sgi_clock_period);
-   cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
+   cur_setting->it_interval = ns_to_timespec64(timr->it.mmtimer.incr * 
sgi_clock_period);
+   cur_setting->it_value = ns_to_timespec64((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
 }
 
 
 static int sgi_timer_set(struct k_itimer *timr, int flags,
-   struct itimerspec * new_setting,
-   struct itimerspec * old_setting)
+   struct itimerspec64 *new_setting,
+   struct itimerspec64 *old_setting)
 {
unsigned long when, period, irqflags;
int err = 0;
@@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
sgi_timer_get(timr, old_setting);
 
sgi_timer_del(timr);
-   when = timespec_to_ns(&new_setting->it_value);
-   period = timespec_to_ns(&new_setting->it_interval);
+   when = timespec64_to_ns(&new_setting->it_value);
+   period = timespec64_to_ns(&new_setting->it_interval);
 
if (when == 0)
/* Clear timer */
@@ -699,11 +699,9 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return -ENOMEM;
 
if (flags & TIMER_ABSTIME) {
-   struct timespec n;
unsigned long now;
 
-   getnstimeofday(&n);
-   now = timespec_to_ns(&n);
+   now = ktime_get_real_ns();
if (when > now)
when -= now;
else
@@ -765,7 +763,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err;
 }
 
-static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = sgi_clock_period;
@@ -773,13 +771,13 @@ static int sgi_clock_getres(const clockid_t which_clock, 
struct timespec *tp)
 }
 
 static struct k_clock sgi_clock = {
-   .clock_set  = sgi_clock_set,
-   .clock_get  = sgi_clock_get,
-   .clock_getres   = sgi_clock_getres,
+   .clock_set64= sgi_clock_set,
+   .clock_get64= sgi_clock_get,
+   .clock_getres64 = sgi_clock_getres,
.timer_create   = sgi_timer_create,
-   .timer_set  = sgi_timer_set,
+   .timer_set64= sgi_timer_set,
.timer_del  = sgi_timer_del,
-   .timer_get  = sgi_timer_get
+   .timer_get64= sgi_timer_get
 };
 
 /**
-- 
1.7.9.5

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


Re: [Xen-devel] RIP MTRR - status update for upcoming v4.2

2015-06-12 Thread Jan Beulich
>>> On 12.06.15 at 01:23,  wrote:
> There are two usages on MTRRs:
>  1) MTRR entries set by firmware
>  2) MTRR entries set by OS drivers
> 
> We can obsolete 2), but we have no control over 1).  As UEFI firmwares
> also set this up, this usage will continue to stay.  So, we should not
> get rid of the MTRR code that looks up the MTRR entries, while we have
> no need to modify them.
> 
> Such MTRR entries provide safe guard to /dev/mem, which allows
> privileged user to access a range that may require UC mapping while
> the /dev/mem driver blindly maps it with WB.  MTRRs converts WB to UC in
> such a case.

But it wouldn't be impossible to simply read the MTRRs upon boot,
store the information, disable MTRRs, and correctly use PAT to
achieve the same effect (i.e. the "blindly maps" part of course
would need fixing).

> UEFI memory table has memory attribute, which describes cache types
> supported in physical memory ranges.  However, this information gets
> lost when it it is converted to e820 table.

I'm afraid you rather don't want to trust that information, as
firmware vendors frequently screw it up.

Jan

--
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/7] clocksource: arm_global_timer: Migrate to new 'set-state' interface

2015-06-12 Thread Viresh Kumar
Migrate arm_global_timer driver to the new 'set-state' interface
provided by the clockevents core, the earlier 'set-mode' interface is
marked obsolete now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Acked-by: Daniel Lezcano 
Cc: Srinivas Kandagatla 
Cc: Maxime Coquelin 
Cc: Patrice Chotard 
Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/arm_global_timer.c | 37 --
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/clocksource/arm_global_timer.c 
b/drivers/clocksource/arm_global_timer.c
index e6833771a716..29ea50ac366a 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -107,26 +107,21 @@ static void gt_compare_set(unsigned long delta, int 
periodic)
writel(ctrl, gt_base + GT_CONTROL);
 }
 
-static void gt_clockevent_set_mode(enum clock_event_mode mode,
-  struct clock_event_device *clk)
+static int gt_clockevent_shutdown(struct clock_event_device *evt)
 {
unsigned long ctrl;
 
-   switch (mode) {
-   case CLOCK_EVT_MODE_PERIODIC:
-   gt_compare_set(DIV_ROUND_CLOSEST(gt_clk_rate, HZ), 1);
-   break;
-   case CLOCK_EVT_MODE_ONESHOT:
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   ctrl = readl(gt_base + GT_CONTROL);
-   ctrl &= ~(GT_CONTROL_COMP_ENABLE |
-   GT_CONTROL_IRQ_ENABLE | GT_CONTROL_AUTO_INC);
-   writel(ctrl, gt_base + GT_CONTROL);
-   break;
-   default:
-   break;
-   }
+   ctrl = readl(gt_base + GT_CONTROL);
+   ctrl &= ~(GT_CONTROL_COMP_ENABLE | GT_CONTROL_IRQ_ENABLE |
+ GT_CONTROL_AUTO_INC);
+   writel(ctrl, gt_base + GT_CONTROL);
+   return 0;
+}
+
+static int gt_clockevent_set_periodic(struct clock_event_device *evt)
+{
+   gt_compare_set(DIV_ROUND_CLOSEST(gt_clk_rate, HZ), 1);
+   return 0;
 }
 
 static int gt_clockevent_set_next_event(unsigned long evt,
@@ -155,7 +150,7 @@ static irqreturn_t gt_clockevent_interrupt(int irq, void 
*dev_id)
 *  the Global Timer flag _after_ having incremented
 *  the Comparator register value to a higher value.
 */
-   if (evt->mode == CLOCK_EVT_MODE_ONESHOT)
+   if (clockevent_state_oneshot(evt))
gt_compare_set(ULONG_MAX, 0);
 
writel_relaxed(GT_INT_STATUS_EVENT_FLAG, gt_base + GT_INT_STATUS);
@@ -171,7 +166,9 @@ static int gt_clockevents_init(struct clock_event_device 
*clk)
clk->name = "arm_global_timer";
clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
CLOCK_EVT_FEAT_PERCPU;
-   clk->set_mode = gt_clockevent_set_mode;
+   clk->set_state_shutdown = gt_clockevent_shutdown;
+   clk->set_state_periodic = gt_clockevent_set_periodic;
+   clk->set_state_oneshot = gt_clockevent_shutdown;
clk->set_next_event = gt_clockevent_set_next_event;
clk->cpumask = cpumask_of(cpu);
clk->rating = 300;
@@ -184,7 +181,7 @@ static int gt_clockevents_init(struct clock_event_device 
*clk)
 
 static void gt_clockevents_stop(struct clock_event_device *clk)
 {
-   gt_clockevent_set_mode(CLOCK_EVT_MODE_UNUSED, clk);
+   gt_clockevent_shutdown(clk);
disable_percpu_irq(clk->irq);
 }
 
-- 
2.4.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 V2 0/7] clockevent: Migrate to new 'set-state' interface

2015-06-12 Thread Viresh Kumar
Hi Thomas/Daniel,

I have incorporated all the improvements Daniel suggested on V1 and so
here is V2.

The first patch allows set-state callbacks to be optional, otherwise it
leads to unnecessary noop callbacks for drivers which don't want to
implement them. Over that, these noop-callbacks result in full function
calls for nothing really useful.

Rest of the series converts few clockevent drivers to the new set-state
interface. This would enable these drivers to use new states (like:
ONESHOT_STOPPED, etc.) of a clockevent device (if required), as the
set-mode interface is marked obsolete now and wouldn't be expanded to
handle new states.

Once all the drivers are migrated to the new interface in future, we can
remove the code supporting '->mode' in clockevents core.

Drivers converted in this series are selected based on the diff they
generate. These are different diffs we shall have for most of the
drivers and any suggestions/improvements for these patches will be
applied to other drivers as well.

This is based of latest tip/master from few days back due to dependency
on clockevent_state_*() helpers.

Only the first patch is tested on hardware, others are ONLY compile
tested.

V1->V2:
- New commit: 1/7 (Daniel)
- Added all Acks from Daniel
- Updated 2/7 to return 0 directly from timer_shutdown()
- Naming fixes suggested for kona driver (Ray Jui)
- Minor changes in commit logs
- Not adding noop-callbacks

Cc: Andres Salomon 
Cc: bcm-kernel-feedback-l...@broadcom.com
Cc: Florian Fainelli 
Cc: Lee Jones 
Cc: Magnus Damm 
Cc: Marc Zyngier 
Cc: Maxime Coquelin 
Cc: Patrice Chotard 
Cc: Ray Jui 
Cc: Scott Branden 
Cc: Srinivas Kandagatla 
Cc: Stephen Warren 

Viresh Kumar (7):
  clockevents: Allow set-state callbacks to be optional
  clocksource: arm_arch_timer: Migrate to new 'set-state' interface
  clocksource: arm_global_timer: Migrate to new 'set-state' interface
  clocksource: bcm2835: Migrate to new 'set-state' interface
  clocksource: bcm_kona: Migrate to new 'set-state' interface
  clocksource: cs5535: Migrate to new 'set-state' interface
  clocksource: em_sti: Migrate to new 'set-state' interface

 drivers/clocksource/arm_arch_timer.c   | 52 ++
 drivers/clocksource/arm_global_timer.c | 37 +++-
 drivers/clocksource/bcm2835_timer.c| 16 ---
 drivers/clocksource/bcm_kona_timer.c   | 17 ---
 drivers/clocksource/cs5535-clockevt.c  | 24 +---
 drivers/clocksource/em_sti.c   | 39 +
 kernel/time/clockevents.c  | 24 ++--
 7 files changed, 81 insertions(+), 128 deletions(-)

-- 
2.4.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 V2 1/7] clockevents: Allow set-state callbacks to be optional

2015-06-12 Thread Viresh Kumar
Its mandatory for the drivers to provide set_state_{oneshot|periodic}()
(only if related modes are supported) and set_state_shutdown() callbacks
today, if they are implementing the new set-state interface.

But this leads to unnecessary noop callbacks for drivers which don't
want to implement them. Over that, it will lead to a full function call
for nothing really useful.

Lets make all set-state callbacks optional.

Suggested-by: Daniel Lezcano 
Signed-off-by: Viresh Kumar 
---
 kernel/time/clockevents.c | 24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 2397b97320d8..37ba06f01818 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -120,19 +120,25 @@ static int __clockevents_switch_state(struct 
clock_event_device *dev,
/* The clockevent device is getting replaced. Shut it down. */
 
case CLOCK_EVT_STATE_SHUTDOWN:
-   return dev->set_state_shutdown(dev);
+   if (dev->set_state_shutdown)
+   return dev->set_state_shutdown(dev);
+   return 0;
 
case CLOCK_EVT_STATE_PERIODIC:
/* Core internal bug */
if (!(dev->features & CLOCK_EVT_FEAT_PERIODIC))
return -ENOSYS;
-   return dev->set_state_periodic(dev);
+   if (dev->set_state_periodic)
+   return dev->set_state_periodic(dev);
+   return 0;
 
case CLOCK_EVT_STATE_ONESHOT:
/* Core internal bug */
if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT))
return -ENOSYS;
-   return dev->set_state_oneshot(dev);
+   if (dev->set_state_oneshot)
+   return dev->set_state_oneshot(dev);
+   return 0;
 
case CLOCK_EVT_STATE_ONESHOT_STOPPED:
/* Core internal bug */
@@ -471,18 +477,6 @@ static int clockevents_sanity_check(struct 
clock_event_device *dev)
if (dev->features & CLOCK_EVT_FEAT_DUMMY)
return 0;
 
-   /* New state-specific callbacks */
-   if (!dev->set_state_shutdown)
-   return -EINVAL;
-
-   if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) &&
-   !dev->set_state_periodic)
-   return -EINVAL;
-
-   if ((dev->features & CLOCK_EVT_FEAT_ONESHOT) &&
-   !dev->set_state_oneshot)
-   return -EINVAL;
-
return 0;
 }
 
-- 
2.4.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 V2 5/7] clocksource: bcm_kona: Migrate to new 'set-state' interface

2015-06-12 Thread Viresh Kumar
Migrate bcm_kona driver to the new 'set-state' interface provided by
the clockevents core, the earlier 'set-mode' interface is marked
obsolete now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Oneshot callback isn't required as it was empty.

Acked-by: Ray Jui 
Cc: Florian Fainelli 
Cc: Ray Jui 
Cc: Scott Branden 
Cc: bcm-kernel-feedback-l...@broadcom.com
Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/bcm_kona_timer.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/clocksource/bcm_kona_timer.c 
b/drivers/clocksource/bcm_kona_timer.c
index f1e33d08dd83..e717e87df9bc 100644
--- a/drivers/clocksource/bcm_kona_timer.c
+++ b/drivers/clocksource/bcm_kona_timer.c
@@ -127,25 +127,18 @@ static int kona_timer_set_next_event(unsigned long clc,
return 0;
 }
 
-static void kona_timer_set_mode(enum clock_event_mode mode,
-struct clock_event_device *unused)
+static int kona_timer_shutdown(struct clock_event_device *evt)
 {
-   switch (mode) {
-   case CLOCK_EVT_MODE_ONESHOT:
-   /* by default mode is one shot don't do any thing */
-   break;
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   default:
-   kona_timer_disable_and_clear(timers.tmr_regs);
-   }
+   kona_timer_disable_and_clear(timers.tmr_regs);
+   return 0;
 }
 
 static struct clock_event_device kona_clockevent_timer = {
.name = "timer 1",
.features = CLOCK_EVT_FEAT_ONESHOT,
.set_next_event = kona_timer_set_next_event,
-   .set_mode = kona_timer_set_mode
+   .set_state_shutdown = kona_timer_shutdown,
+   .tick_resume = kona_timer_shutdown,
 };
 
 static void __init kona_timer_clockevents_init(void)
-- 
2.4.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 V2 6/7] clocksource: cs5535: Migrate to new 'set-state' interface

2015-06-12 Thread Viresh Kumar
Migrate cs5535 driver to the new 'set-state' interface provided by
the clockevents core, the earlier 'set-mode' interface is marked
obsolete now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Acked-by: Daniel Lezcano 
Cc: Andres Salomon 
Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/cs5535-clockevt.c | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/clocksource/cs5535-clockevt.c 
b/drivers/clocksource/cs5535-clockevt.c
index db2105290898..9a7e37cf56b0 100644
--- a/drivers/clocksource/cs5535-clockevt.c
+++ b/drivers/clocksource/cs5535-clockevt.c
@@ -42,7 +42,6 @@ MODULE_PARM_DESC(irq, "Which IRQ to use for the clock source 
MFGPT ticks.");
  *  256 128   .125512.000
  */
 
-static unsigned int cs5535_tick_mode = CLOCK_EVT_MODE_SHUTDOWN;
 static struct cs5535_mfgpt_timer *cs5535_event_clock;
 
 /* Selected from the table above */
@@ -77,15 +76,17 @@ static void start_timer(struct cs5535_mfgpt_timer *timer, 
uint16_t delta)
MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP2);
 }
 
-static void mfgpt_set_mode(enum clock_event_mode mode,
-   struct clock_event_device *evt)
+static int mfgpt_shutdown(struct clock_event_device *evt)
 {
disable_timer(cs5535_event_clock);
+   return 0;
+}
 
-   if (mode == CLOCK_EVT_MODE_PERIODIC)
-   start_timer(cs5535_event_clock, MFGPT_PERIODIC);
-
-   cs5535_tick_mode = mode;
+static int mfgpt_set_periodic(struct clock_event_device *evt)
+{
+   disable_timer(cs5535_event_clock);
+   start_timer(cs5535_event_clock, MFGPT_PERIODIC);
+   return 0;
 }
 
 static int mfgpt_next_event(unsigned long delta, struct clock_event_device 
*evt)
@@ -97,7 +98,10 @@ static int mfgpt_next_event(unsigned long delta, struct 
clock_event_device *evt)
 static struct clock_event_device cs5535_clockevent = {
.name = DRV_NAME,
.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-   .set_mode = mfgpt_set_mode,
+   .set_state_shutdown = mfgpt_shutdown,
+   .set_state_periodic = mfgpt_set_periodic,
+   .set_state_oneshot = mfgpt_shutdown,
+   .tick_resume = mfgpt_shutdown,
.set_next_event = mfgpt_next_event,
.rating = 250,
 };
@@ -113,7 +117,7 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id)
/* Turn off the clock (and clear the event) */
disable_timer(cs5535_event_clock);
 
-   if (cs5535_tick_mode == CLOCK_EVT_MODE_SHUTDOWN)
+   if (clockevent_state_shutdown(&cs5535_clockevent))
return IRQ_HANDLED;
 
/* Clear the counter */
@@ -121,7 +125,7 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id)
 
/* Restart the clock in periodic mode */
 
-   if (cs5535_tick_mode == CLOCK_EVT_MODE_PERIODIC)
+   if (clockevent_state_periodic(&cs5535_clockevent))
cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP,
MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP2);
 
-- 
2.4.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 V2 7/7] clocksource: em_sti: Migrate to new 'set-state' interface

2015-06-12 Thread Viresh Kumar
Migrate em_sti driver to the new 'set-state' interface provided by
the clockevents core, the earlier 'set-mode' interface is marked
obsolete now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

NOTE: This also drops a special check:

if (old_mode == CLOCK_EVT_MODE_ONESHOT)
em_sti_stop(p, USER_CLOCKEVENT);

as it doesn't look like that important. This driver only supports
ONESHOT and we can only move only to SHUTDOWN from ONESHOT and.
Also on second call (on shutdown), em_sti_stop() would return without
disabling the device again.

Acked-by: Daniel Lezcano 
Cc: Magnus Damm 
Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/em_sti.c | 39 ++-
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
index dc3c6ee04aaa..7a97a34dba70 100644
--- a/drivers/clocksource/em_sti.c
+++ b/drivers/clocksource/em_sti.c
@@ -251,33 +251,21 @@ static struct em_sti_priv *ced_to_em_sti(struct 
clock_event_device *ced)
return container_of(ced, struct em_sti_priv, ced);
 }
 
-static void em_sti_clock_event_mode(enum clock_event_mode mode,
-   struct clock_event_device *ced)
+static int em_sti_clock_event_shutdown(struct clock_event_device *ced)
 {
struct em_sti_priv *p = ced_to_em_sti(ced);
+   em_sti_stop(p, USER_CLOCKEVENT);
+   return 0;
+}
 
-   /* deal with old setting first */
-   switch (ced->mode) {
-   case CLOCK_EVT_MODE_ONESHOT:
-   em_sti_stop(p, USER_CLOCKEVENT);
-   break;
-   default:
-   break;
-   }
+static int em_sti_clock_event_set_oneshot(struct clock_event_device *ced)
+{
+   struct em_sti_priv *p = ced_to_em_sti(ced);
 
-   switch (mode) {
-   case CLOCK_EVT_MODE_ONESHOT:
-   dev_info(&p->pdev->dev, "used for oneshot clock events\n");
-   em_sti_start(p, USER_CLOCKEVENT);
-   clockevents_config(&p->ced, p->rate);
-   break;
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   case CLOCK_EVT_MODE_UNUSED:
-   em_sti_stop(p, USER_CLOCKEVENT);
-   break;
-   default:
-   break;
-   }
+   dev_info(&p->pdev->dev, "used for oneshot clock events\n");
+   em_sti_start(p, USER_CLOCKEVENT);
+   clockevents_config(&p->ced, p->rate);
+   return 0;
 }
 
 static int em_sti_clock_event_next(unsigned long delta,
@@ -303,11 +291,12 @@ static void em_sti_register_clockevent(struct em_sti_priv 
*p)
ced->rating = 200;
ced->cpumask = cpu_possible_mask;
ced->set_next_event = em_sti_clock_event_next;
-   ced->set_mode = em_sti_clock_event_mode;
+   ced->set_state_shutdown = em_sti_clock_event_shutdown;
+   ced->set_state_oneshot = em_sti_clock_event_set_oneshot;
 
dev_info(&p->pdev->dev, "used for clock events\n");
 
-   /* Register with dummy 1 Hz value, gets updated in ->set_mode() */
+   /* Register with dummy 1 Hz value, gets updated in 
->set_state_oneshot() */
clockevents_config_and_register(ced, 1, 2, 0x);
 }
 
-- 
2.4.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 V2 4/7] clocksource: bcm2835: Migrate to new 'set-state' interface

2015-06-12 Thread Viresh Kumar
Migrate bcm2835 driver to the new 'set-state' interface provided by
the clockevents core, the earlier 'set-mode' interface is marked
obsolete now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything in the ->set_mode() callback. So, this patch
doesn't provide any set-state callbacks.

Acked-by: Daniel Lezcano 
Cc: Stephen Warren 
Cc: Lee Jones 
Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/bcm2835_timer.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/clocksource/bcm2835_timer.c 
b/drivers/clocksource/bcm2835_timer.c
index 26ed331b1aad..6f2822928963 100644
--- a/drivers/clocksource/bcm2835_timer.c
+++ b/drivers/clocksource/bcm2835_timer.c
@@ -54,21 +54,6 @@ static u64 notrace bcm2835_sched_read(void)
return readl_relaxed(system_clock);
 }
 
-static void bcm2835_time_set_mode(enum clock_event_mode mode,
-   struct clock_event_device *evt_dev)
-{
-   switch (mode) {
-   case CLOCK_EVT_MODE_ONESHOT:
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   case CLOCK_EVT_MODE_RESUME:
-   break;
-   default:
-   WARN(1, "%s: unhandled event mode %d\n", __func__, mode);
-   break;
-   }
-}
-
 static int bcm2835_time_set_next_event(unsigned long event,
struct clock_event_device *evt_dev)
 {
@@ -129,7 +114,6 @@ static void __init bcm2835_timer_init(struct device_node 
*node)
timer->evt.name = node->name;
timer->evt.rating = 300;
timer->evt.features = CLOCK_EVT_FEAT_ONESHOT;
-   timer->evt.set_mode = bcm2835_time_set_mode;
timer->evt.set_next_event = bcm2835_time_set_next_event;
timer->evt.cpumask = cpumask_of(0);
timer->act.name = node->name;
-- 
2.4.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 v5 19/24] alarmtimer: Convert to y2038 safe callbacks

2015-06-12 Thread Baolin Wang
The clock_getres()/clock_get()/clock_set()/timer_set()/timer_get()
callbacks in struct k_clock are not year 2038 safe on 32bit systems,
and it need convert to safe callbacks which use struct timespec64
or struct itimerspec64.

Signed-off-by: Baolin Wang 
---
 kernel/time/alarmtimer.c |   38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 7fbba63..c9a0adf 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -486,11 +486,11 @@ static enum alarmtimer_restart alarm_handle_timer(struct 
alarm *alarm,
 /**
  * alarm_clock_getres - posix getres interface
  * @which_clock: clockid
- * @tp: timespec to fill
+ * @tp: timespec64 to fill
  *
  * Returns the granularity of underlying alarm base clock
  */
-static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 
*tp)
 {
if (!alarmtimer_get_rtcdev())
return -EINVAL;
@@ -503,18 +503,18 @@ static int alarm_clock_getres(const clockid_t 
which_clock, struct timespec *tp)
 /**
  * alarm_clock_get - posix clock_get interface
  * @which_clock: clockid
- * @tp: timespec to fill.
+ * @tp: timespec64 to fill.
  *
  * Provides the underlying alarm base time.
  */
-static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_get(clockid_t which_clock, struct timespec64 *tp)
 {
struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)];
 
if (!alarmtimer_get_rtcdev())
return -EINVAL;
 
-   *tp = ktime_to_timespec(base->gettime());
+   *tp = ktime_to_timespec64(base->gettime());
return 0;
 }
 
@@ -544,24 +544,24 @@ static int alarm_timer_create(struct k_itimer *new_timer)
 /**
  * alarm_timer_get - posix timer_get interface
  * @new_timer: k_itimer pointer
- * @cur_setting: itimerspec data to fill
+ * @cur_setting: itimerspec64 data to fill
  *
  * Copies out the current itimerspec data
  */
 static void alarm_timer_get(struct k_itimer *timr,
-   struct itimerspec *cur_setting)
+   struct itimerspec64 *cur_setting)
 {
ktime_t relative_expiry_time =
alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
 
if (ktime_to_ns(relative_expiry_time) > 0) {
-   cur_setting->it_value = ktime_to_timespec(relative_expiry_time);
+   cur_setting->it_value = 
ktime_to_timespec64(relative_expiry_time);
} else {
cur_setting->it_value.tv_sec = 0;
cur_setting->it_value.tv_nsec = 0;
}
 
-   cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval);
+   cur_setting->it_interval = ktime_to_timespec64(timr->it.alarm.interval);
 }
 
 /**
@@ -585,14 +585,14 @@ static int alarm_timer_del(struct k_itimer *timr)
  * alarm_timer_set - posix timer_set interface
  * @timr: k_itimer pointer to be deleted
  * @flags: timer flags
- * @new_setting: itimerspec to be used
- * @old_setting: itimerspec being replaced
+ * @new_setting: itimerspec64 to be used
+ * @old_setting: itimerspec64 being replaced
  *
  * Sets the timer to new_setting, and starts the timer.
  */
 static int alarm_timer_set(struct k_itimer *timr, int flags,
-   struct itimerspec *new_setting,
-   struct itimerspec *old_setting)
+   struct itimerspec64 *new_setting,
+   struct itimerspec64 *old_setting)
 {
ktime_t exp;
 
@@ -610,8 +610,8 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,
return TIMER_RETRY;
 
/* start the timer */
-   timr->it.alarm.interval = timespec_to_ktime(new_setting->it_interval);
-   exp = timespec_to_ktime(new_setting->it_value);
+   timr->it.alarm.interval = timespec64_to_ktime(new_setting->it_interval);
+   exp = timespec64_to_ktime(new_setting->it_value);
/* Convert (if necessary) to absolute time */
if (flags != TIMER_ABSTIME) {
ktime_t now;
@@ -821,12 +821,12 @@ static int __init alarmtimer_init(void)
int error = 0;
int i;
struct k_clock alarm_clock = {
-   .clock_getres   = alarm_clock_getres,
-   .clock_get  = alarm_clock_get,
+   .clock_getres64 = alarm_clock_getres,
+   .clock_get64= alarm_clock_get,
.timer_create   = alarm_timer_create,
-   .timer_set  = alarm_timer_set,
+   .timer_set64= alarm_timer_set,
.timer_del  = alarm_timer_del,
-   .timer_get  = alarm_timer_get,
+   .timer_get64= alarm_timer_get,
.nsleep = alarm_timer_nsleep,
};
 
-- 
1.7.9.5

--
To unsubscribe from this list: send 

Re: [PATCH v3 2/2] x86, mwaitt: introduce mwaix delay with a configurable timer

2015-06-12 Thread Huang Rui
On Fri, Jun 12, 2015 at 09:38:48AM +0200, Peter Zijlstra wrote:
> On Fri, Jun 12, 2015 at 12:03:22PM +0800, Huang Rui wrote:
> 
> > > What's the purpose of the "enable" parameter?
> > > 
> > 
> > Enable mwaitx timer. Should I add comments to explain the usage?
> 
> No, you should read your own patch, notice that the only usage site
> provides a true, then realize its a redundant bit of code and kill it
> dead.

Yeah, but I remembered at last time, someone tell me we shouldn't
force to set timer always enabled. So I add this interface to expose
more clearly. :)

So could I use __mwaitx directly like below:

__monitorx(&dummy, 0, 0);
__mwaitx(0xf, delay, MWAITX_ECX_TIMER_ENABLE);


Thanks,
Rui
--
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 2/7] clocksource: arm_arch_timer: Migrate to new 'set-state' interface

2015-06-12 Thread Viresh Kumar
Migrate arm_arch_timer driver to the new 'set-state' interface provided
by the clockevents core, the earlier 'set-mode' interface is marked
obsolete now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Cc: Marc Zyngier 
Signed-off-by: Viresh Kumar 
---
 drivers/clocksource/arm_arch_timer.c | 52 +++-
 1 file changed, 22 insertions(+), 30 deletions(-)

diff --git a/drivers/clocksource/arm_arch_timer.c 
b/drivers/clocksource/arm_arch_timer.c
index 0aa135ddbf80..d6e3e49399dd 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -181,44 +181,36 @@ static irqreturn_t arch_timer_handler_virt_mem(int irq, 
void *dev_id)
return timer_handler(ARCH_TIMER_MEM_VIRT_ACCESS, evt);
 }
 
-static __always_inline void timer_set_mode(const int access, int mode,
- struct clock_event_device *clk)
+static __always_inline int timer_shutdown(const int access,
+ struct clock_event_device *clk)
 {
unsigned long ctrl;
-   switch (mode) {
-   case CLOCK_EVT_MODE_UNUSED:
-   case CLOCK_EVT_MODE_SHUTDOWN:
-   ctrl = arch_timer_reg_read(access, ARCH_TIMER_REG_CTRL, clk);
-   ctrl &= ~ARCH_TIMER_CTRL_ENABLE;
-   arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl, clk);
-   break;
-   default:
-   break;
-   }
+
+   ctrl = arch_timer_reg_read(access, ARCH_TIMER_REG_CTRL, clk);
+   ctrl &= ~ARCH_TIMER_CTRL_ENABLE;
+   arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl, clk);
+
+   return 0;
 }
 
-static void arch_timer_set_mode_virt(enum clock_event_mode mode,
-struct clock_event_device *clk)
+static int arch_timer_shutdown_virt(struct clock_event_device *clk)
 {
-   timer_set_mode(ARCH_TIMER_VIRT_ACCESS, mode, clk);
+   return timer_shutdown(ARCH_TIMER_VIRT_ACCESS, clk);
 }
 
-static void arch_timer_set_mode_phys(enum clock_event_mode mode,
-struct clock_event_device *clk)
+static int arch_timer_shutdown_phys(struct clock_event_device *clk)
 {
-   timer_set_mode(ARCH_TIMER_PHYS_ACCESS, mode, clk);
+   return timer_shutdown(ARCH_TIMER_PHYS_ACCESS, clk);
 }
 
-static void arch_timer_set_mode_virt_mem(enum clock_event_mode mode,
-struct clock_event_device *clk)
+static int arch_timer_shutdown_virt_mem(struct clock_event_device *clk)
 {
-   timer_set_mode(ARCH_TIMER_MEM_VIRT_ACCESS, mode, clk);
+   return timer_shutdown(ARCH_TIMER_MEM_VIRT_ACCESS, clk);
 }
 
-static void arch_timer_set_mode_phys_mem(enum clock_event_mode mode,
-struct clock_event_device *clk)
+static int arch_timer_shutdown_phys_mem(struct clock_event_device *clk)
 {
-   timer_set_mode(ARCH_TIMER_MEM_PHYS_ACCESS, mode, clk);
+   return timer_shutdown(ARCH_TIMER_MEM_PHYS_ACCESS, clk);
 }
 
 static __always_inline void set_next_event(const int access, unsigned long evt,
@@ -273,11 +265,11 @@ static void __arch_timer_setup(unsigned type,
clk->cpumask = cpumask_of(smp_processor_id());
if (arch_timer_use_virtual) {
clk->irq = arch_timer_ppi[VIRT_PPI];
-   clk->set_mode = arch_timer_set_mode_virt;
+   clk->set_state_shutdown = arch_timer_shutdown_virt;
clk->set_next_event = arch_timer_set_next_event_virt;
} else {
clk->irq = arch_timer_ppi[PHYS_SECURE_PPI];
-   clk->set_mode = arch_timer_set_mode_phys;
+   clk->set_state_shutdown = arch_timer_shutdown_phys;
clk->set_next_event = arch_timer_set_next_event_phys;
}
} else {
@@ -286,17 +278,17 @@ static void __arch_timer_setup(unsigned type,
clk->rating = 400;
clk->cpumask = cpu_all_mask;
if (arch_timer_mem_use_virtual) {
-   clk->set_mode = arch_timer_set_mode_virt_mem;
+   clk->set_state_shutdown = arch_timer_shutdown_virt_mem;
clk->set_next_event =
arch_timer_set_next_event_virt_mem;
} else {
-   clk->set_mode = arch_timer_set_mode_phys_mem;
+   clk->set_state_shutdown = arch_timer_shutdown_phys_mem;
clk->set_next_event =
arch_timer_set_next_event_phys_mem;
}
}
 
-   clk->set_mode(CLOCK_EVT_MODE_SHUTDOWN, clk);
+   clk->set_state_shutdown(clk);
 
clockevents_config_and_register(clk, arch_timer_rate, 0xf, 0x7fff);
 }
@@ -506,7 +498,7 @@ static void arch_timer_stop(struct clock_event_device *

[PATCH] drm/nouveau: fix memory leak by deallocating cli/drm

2015-06-12 Thread Dongxing Zhang
unreferenced object 0x8800bd132fe8 (size 256):
  comm "Xorg", pid 1260, jiffies 4294901661 (age 660.504s)
  hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 e8 2f 13 bd 00 88 ff ff  ./..
01 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00  
  backtrace:
[] kmemleak_alloc+0x4e/0xb0
[] __kmalloc+0x204/0x2c0
[] nouveau_cli_create+0x2a/0xb0 [nouveau]
[] nouveau_drm_open+0xcb/0x220 [nouveau]
[] drm_open+0x1b2/0x4d0 [drm]
[] drm_stub_open+0xa9/0x130 [drm]
[] chrdev_open+0x9f/0x1d0
[] do_dentry_open+0x257/0x350
[] vfs_open+0x49/0x50
[] do_last+0x1ec/0x1200
[] path_openat+0x80/0x600
[] do_filp_open+0x3a/0x90
[] do_sys_open+0x128/0x220
[] SyS_open+0x1e/0x20
[] system_call_fastpath+0x16/0x75
[] 0x

Signed-off-by: Dongxing Zhang 
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 8904933..2ead477 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -115,7 +115,8 @@ nouveau_cli_create(u64 name, const char *sname,
if (ret == 0) {
mutex_init(&cli->mutex);
usif_client_init(cli);
-   }
+   } else
+   kfree(cli);
return ret;
}
return -ENOMEM;
@@ -489,6 +490,7 @@ fail_ttm:
 fail_device:
nvif_device_fini(&drm->device);
nouveau_cli_destroy(&drm->client);
+   kfree(drm);
return ret;
 }
 
@@ -517,6 +519,7 @@ nouveau_drm_unload(struct drm_device *dev)
if (drm->hdmi_device)
pci_dev_put(drm->hdmi_device);
nouveau_cli_destroy(&drm->client);
+   kfree(drm);
return 0;
 }
 
@@ -836,6 +839,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file 
*fpriv)
  0x1000, &cli->vm);
if (ret) {
nouveau_cli_destroy(cli);
+   kfree(cli);
goto out_suspend;
}
 
@@ -877,6 +881,7 @@ nouveau_drm_postclose(struct drm_device *dev, struct 
drm_file *fpriv)
 {
struct nouveau_cli *cli = nouveau_cli(fpriv);
nouveau_cli_destroy(cli);
+   kfree(cli);
pm_runtime_mark_last_busy(dev->dev);
pm_runtime_put_autosuspend(dev->dev);
 }
-- 
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 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code

2015-06-12 Thread Ingo Molnar

* Linus Torvalds  wrote:

> On Jun 12, 2015 00:23, "Ingo Molnar"  wrote:
> >
> > We might make it so: but that would mean restricting certain clone_flags 
> > variants - not sure that's possible with our current ABI usage?
> 
> We already do that. You can't share signal info unless you share the mm. And 
> a 
> shared signal state is what defines a thread group.
> 
> So I think the only issue is that ->mm can become NULL when the thread group 
> leader dies - a non-NULL mm should always be shared among all threads.

Indeed, we do that in exit_mm().

So we could add tsk->mm_leader or so, which does not get cleared and which the 
scheduler does not look at, but I'm not sure it's entirely safe that way: we 
don't 
have a refcount, and when the last thread exits it becomes bogus for a small 
window until the zombie leader is unlinked from the task list.

To close that race we'd have __mmdrop() or so clear out tsk->mm_leader - but 
the 
task doing the mmdrop() might be a lazy thread totally unrelated to the 
original 
thread group so we don't know which tsk->mm_leader to clear out.

To solve that we'd have to track the leader owning an MM in mm_struct - which 
gets 
interesting for the exec() case where the thread group gets a new leader, so 
we'd 
have to re-link the mm's leader pointer there.

So unless I missed some simpler solution there a good number of steps where 
this 
could go wrong, in small looking race windows - how about we just live with 
iterating through all tasks instead of just all processes, once per 512 GB of 
memory mapped?

Thanks,

Ingo
--
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 v5 20/24] posix-clock: Convert to y2038 safe callbacks

2015-06-12 Thread Baolin Wang
The clock_getres()/clock_get()/clock_set()/timer_set()/timer_get()
callbacks in struct k_clock are not year 2038 safe on 32bit systems,
and it need convert to safe callbacks which use struct timespec64
or struct itimerspec64.

The clock_gettime()/clock_settime()/clock_getres()/timer_gettime()/
timer_settime() callbacks in struct posix_clock_operations are not
year 2038 safe on 32bit systems, and it need convert to year 2038
safe callbacks which use struct timespec64 or struct itimerspec64.

Signed-off-by: Baolin Wang 
---
 drivers/ptp/ptp_clock.c |   22 +++---
 include/linux/posix-clock.h |   10 +-
 kernel/time/posix-clock.c   |   20 ++--
 3 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 2e481b9..7040f20 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -97,31 +97,25 @@ static s32 scaled_ppm_to_ppb(long ppm)
 
 /* posix clock implementation */
 
-static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_getres(struct posix_clock *pc, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = 1;
return 0;
 }
 
-static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
+static int ptp_clock_settime(struct posix_clock *pc, const struct timespec64 
*tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts = timespec_to_timespec64(*tp);
 
-   return  ptp->info->settime64(ptp->info, &ts);
+   return  ptp->info->settime64(ptp->info, tp);
 }
 
-static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts;
-   int err;
 
-   err = ptp->info->gettime64(ptp->info, &ts);
-   if (!err)
-   *tp = timespec64_to_timespec(ts);
-   return err;
+   return ptp->info->gettime64(ptp->info, tp);
 }
 
 static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx)
@@ -133,8 +127,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
ops = ptp->info;
 
if (tx->modes & ADJ_SETOFFSET) {
-   struct timespec ts;
-   ktime_t kt;
+   struct timespec64 ts;
s64 delta;
 
ts.tv_sec  = tx->time.tv_sec;
@@ -146,8 +139,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC)
return -EINVAL;
 
-   kt = timespec_to_ktime(ts);
-   delta = ktime_to_ns(kt);
+   delta = timespec64_to_ns(&ts);
err = ops->adjtime(ops, delta);
} else if (tx->modes & ADJ_FREQUENCY) {
s32 ppb = scaled_ppm_to_ppb(tx->freq);
diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h
index 34c4498..83b22ae 100644
--- a/include/linux/posix-clock.h
+++ b/include/linux/posix-clock.h
@@ -59,23 +59,23 @@ struct posix_clock_operations {
 
int  (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
 
-   int  (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts);
 
-   int  (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_getres) (struct posix_clock *pc, struct timespec64 *ts);
 
int  (*clock_settime)(struct posix_clock *pc,
- const struct timespec *ts);
+ const struct timespec64 *ts);
 
int  (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
 
int  (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
 
void (*timer_gettime)(struct posix_clock *pc,
- struct k_itimer *kit, struct itimerspec *tsp);
+ struct k_itimer *kit, struct itimerspec64 *tsp);
 
int  (*timer_settime)(struct posix_clock *pc,
  struct k_itimer *kit, int flags,
- struct itimerspec *tsp, struct itimerspec *old);
+ struct itimerspec64 *tsp, struct itimerspec64 
*old);
/*
 * Optional character device methods:
 */
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index ce033c7..e21e4c1 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -297,7 +297,7 @@ out:
return err;
 }
 
-static int pc_clock_gettime(clockid_t id, struct timespec *ts)
+static int pc_clock_gettime(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
int err;
@@ -316,7 +316,7 @@ static int pc_clock_gettime(clockid_t id, struct timespec 
*ts)
retur

Re: [RFC/RFT PATCH v2] PCI: move pci_read_bridge_bases to the generic PCI layer

2015-06-12 Thread Guenter Roeck

On 06/09/2015 02:01 AM, Lorenzo Pieralisi wrote:

When a PCI bus is scanned, upon PCI bridge detection the kernel
has to read the bridge registers to set-up its resources so that
the PCI resource hierarchy can be validated properly.

Most if not all architectures read PCI bridge registers in the
pcibios_fixup_bus hook, that is called by the PCI generic layer
whenever a PCI bus is scanned.

Since pci_read_bridge_bases is an arch agnostic operation (and it
is carried out on all architectures) it can be moved to the generic
PCI layer in order to consolidate code and remove the respective
calls from the architectures back-ends.

The PCI_PROBE_ONLY flag is not checked before calling
pci_read_bridge_buses in the generic layer since reading the bridge
bases is not related to resources assignment; this implies that it
can be carried out safely on PCI_PROBE_ONLY systems too and should
not affect architectures (alpha, mips) that check the PCI_PROBE_ONLY
flag before reading the bridge bases.

In order to validate the resource hierarchy as soon as the resources
themselves are probed (ie read from the bridge), this patch also adds
code to pci_read_bridge_bases that claims the bridge resources, so that
they are validated and inserted in the resource hierarchy as soon as
the bridge bases are probed.

Signed-off-by: Lorenzo Pieralisi 
Cc: Ralf Baechle 
Cc: James E.J. Bottomley 
Cc: Michael Ellerman 
Cc: Bjorn Helgaas 
Cc: Richard Henderson 
Cc: Benjamin Herrenschmidt 
Cc: David Howells 
Cc: Russell King 
Cc: Tony Luck 
Cc: David S. Miller 
Cc: Ingo Molnar 
Cc: Guenter Roeck 
Cc: Michal Simek 
Cc: Chris Zankel 


Working fine on powerpc (tested with Freescale P2020 and P5020) as well as x86
(tested on two different server class systems).

Tested-by: Guenter Roeck 

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/


[PATCH v5 21/24] time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64()

2015-06-12 Thread Baolin Wang
The conversion between struct timespec and jiffies is not year 2038
safe on 32bit systems. Introduce timespec64_to_jiffies() and
jiffies_to_timespec64() functions which use struct timespec64 to
make it ready for 2038 issue.

Signed-off-by: Baolin Wang 
---
 include/linux/jiffies.h |   21 ++---
 kernel/time/time.c  |   11 ++-
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 3bde5eb..be37eae 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -363,9 +363,24 @@ static inline unsigned long msecs_to_jiffies(const 
unsigned int m)
 }
 
 extern unsigned long usecs_to_jiffies(const unsigned int u);
-extern unsigned long timespec_to_jiffies(const struct timespec *value);
-extern void jiffies_to_timespec(const unsigned long jiffies,
-   struct timespec *value);
+extern unsigned long __timespec_to_jiffies(unsigned long sec, long nsec);
+extern unsigned long timespec64_to_jiffies(const struct timespec64 *value);
+extern void jiffies_to_timespec64(const unsigned long jiffies,
+ struct timespec64 *value);
+static inline unsigned long timespec_to_jiffies(const struct timespec *value)
+{
+   return __timespec_to_jiffies(value->tv_sec, value->tv_nsec);
+}
+
+static inline void jiffies_to_timespec(const unsigned long jiffies,
+  struct timespec *value)
+{
+   struct timespec64 ts;
+
+   jiffies_to_timespec64(jiffies, &ts);
+   *value = timespec64_to_timespec(ts);
+}
+
 extern unsigned long timeval_to_jiffies(const struct timeval *value);
 extern void jiffies_to_timeval(const unsigned long jiffies,
   struct timeval *value);
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 5aefe2d..8318cab 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -552,7 +552,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
  * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
  * value to a scaled second value.
  */
-static unsigned long
+unsigned long
 __timespec_to_jiffies(unsigned long sec, long nsec)
 {
nsec = nsec + TICK_NSEC - 1;
@@ -566,17 +566,18 @@ __timespec_to_jiffies(unsigned long sec, long nsec)
 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
 
 }
+EXPORT_SYMBOL(__timespec_to_jiffies);
 
 unsigned long
-timespec_to_jiffies(const struct timespec *value)
+timespec64_to_jiffies(const struct timespec64 *value)
 {
return __timespec_to_jiffies(value->tv_sec, value->tv_nsec);
 }
 
-EXPORT_SYMBOL(timespec_to_jiffies);
+EXPORT_SYMBOL(timespec64_to_jiffies);
 
 void
-jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
+jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value)
 {
/*
 * Convert jiffies to nanoseconds and separate with
@@ -587,7 +588,7 @@ jiffies_to_timespec(const unsigned long jiffies, struct 
timespec *value)
NSEC_PER_SEC, &rem);
value->tv_nsec = rem;
 }
-EXPORT_SYMBOL(jiffies_to_timespec);
+EXPORT_SYMBOL(jiffies_to_timespec64);
 
 /*
  * We could use a similar algorithm to timespec_to_jiffies (with a
-- 
1.7.9.5

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


Re: [PATCH v2] powerpc: support sizes greater than an unsigned long

2015-06-12 Thread Cristian Stoica
On 06/12/2015 12:27 AM, Scott Wood wrote:
> Dropping the upper bits of the size harms the ability to detect error 
> scenarios where unmappably large -- but not power-of-two -- regions 
> are requested to be mapped.
> 
> However, this patch doesn't fix that.  It just postpones the loss of 
> the upper 32 bits until __ioremap_caller() calls get_vm_area_caller().
>
> There's also no error checking at all for the size of ioremap() done 
> during early boot (!slab_is_available()).

Thanks for the explanation. I'll have a another look at the code.

> Don't just blindly turn static analyzer reports into patches -- and 
> why didn't the analyzer complain about the call to 
> get_vm_area_caller() after this patch?

The analysis that lead to this patch was targeted to a specific driver - in 
hindsight this is probably not the best
approach.

Cristian S.
--
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: [GIT PULL 0/7] perf/core improvements and fixes

2015-06-12 Thread Ingo Molnar

* Arnaldo Carvalho de Melo  wrote:

> Hi Ingo,
> 
>   Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit 028c63b56795206464263fa3bc47094704c2a840:
> 
>   Merge tag 'perf-core-for-mingo' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core 
> (2015-06-09 11:46:04 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
> tags/perf-core-for-mingo
> 
> for you to fetch changes up to c8ad7063626406181a7ebab10cb31b4f741b13d4:
> 
>   perf tools: Update MANIFEST per files removed from kernel (2015-06-11 
> 22:54:23 -0300)
> 
> 
> perf/core improvements and fixes:
> 
> User visible:
> 
> - Beautify perf_event_open syscall in 'perf trace'. (Arnaldo Carvalho de Melo)
> 
> - Error out unsupported group leader immediately in 'perf stat'. (Kan Liang)
> 
> - Amend some 'perf record' option summaries (period, etc) (Peter Zijlstra)
> 
> - Avoid possible race condition in copyfile() in 'perf buildid-cache'. (Milos 
> Vyletel)
> 
> Infrastructure:
> 
> - Display 0x for hex values when printing the attribute. (Adrian Hunter)
> 
> - Update MANIFEST per files removed from kernel. (David Ahern)
> 
> Build fixes:
> 
> - Fix PRIu64 printf related failure on 32-bit arch. (He Kuang)
> 
> Signed-off-by: Arnaldo Carvalho de Melo 
> 
> 
> Adrian Hunter (1):
>   perf evsel: Display 0x for hex values when printing the attribute
> 
> Arnaldo Carvalho de Melo (1):
>   trace: Beautify perf_event_open syscall
> 
> David Ahern (1):
>   perf tools: Update MANIFEST per files removed from kernel
> 
> He Kuang (1):
>   perf tools: Fix build failure on 32-bit arch
> 
> Kan Liang (1):
>   perf stat: Error out unsupported group leader immediately
> 
> Milos Vyletel (1):
>   perf tools: Avoid possible race condition in copyfile()
> 
> Peter Zijlstra (1):
>   perf record: Amend option summaries
> 
>  tools/perf/Documentation/perf-record.txt | 10 --
>  tools/perf/MANIFEST  |  4 ---
>  tools/perf/builtin-record.c  |  7 ++--
>  tools/perf/builtin-report.c  |  2 +-
>  tools/perf/builtin-stat.c|  5 ++-
>  tools/perf/builtin-trace.c   | 58 
> 
>  tools/perf/util/evsel.c  |  2 +-
>  tools/perf/util/session.c|  2 +-
>  tools/perf/util/util.c   | 46 -
>  9 files changed, 106 insertions(+), 30 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo
--
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 08/12] mm: use mirrorable to switch allocate mirrored memory

2015-06-12 Thread Naoya Horiguchi
On Thu, Jun 04, 2015 at 09:02:49PM +0800, Xishi Qiu wrote:
> Add a new interface in path /proc/sys/vm/mirrorable. When set to 1, it means
> we should allocate mirrored memory for both user and kernel processes.

As Dave and Kamezawa-san commented, documentation is not enough, so please
add a section in Documentation/sysctl/vm.txt for this new tuning parameter.

Thanks,
Naoya Horiguchi

> 
> Signed-off-by: Xishi Qiu 
> ---
>  include/linux/mmzone.h | 1 +
>  kernel/sysctl.c| 9 +
>  mm/page_alloc.c| 1 +
>  3 files changed, 11 insertions(+)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index f82e3ae..20888dd 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -85,6 +85,7 @@ struct mirror_info {
>  };
>  
>  extern struct mirror_info mirror_info;
> +extern int sysctl_mirrorable;
>  #  define is_migrate_mirror(migratetype) unlikely((migratetype) == 
> MIGRATE_MIRROR)
>  #else
>  #  define is_migrate_mirror(migratetype) false
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 2082b1a..dc2625e 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -1514,6 +1514,15 @@ static struct ctl_table vm_table[] = {
>   .extra2 = &one,
>   },
>  #endif
> +#ifdef CONFIG_MEMORY_MIRROR
> + {
> + .procname   = "mirrorable",
> + .data   = &sysctl_mirrorable,
> + .maxlen = sizeof(sysctl_mirrorable),
> + .mode   = 0644,
> + .proc_handler   = proc_dointvec_minmax,
> + },
> +#endif
>   {
>   .procname   = "user_reserve_kbytes",
>   .data   = &sysctl_user_reserve_kbytes,
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 249a8f6..63b90ca 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -212,6 +212,7 @@ int user_min_free_kbytes = -1;
>  
>  #ifdef CONFIG_MEMORY_MIRROR
>  struct mirror_info mirror_info;
> +int sysctl_mirrorable = 0;
>  #endif
>  
>  static unsigned long __meminitdata nr_kernel_pages;
> -- 
> 2.0.0
> 
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org";> em...@kvack.org --
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] mtd: nand: support for Toshiba BENAND (Built-in ECC NAND)

2015-06-12 Thread Paul Bolle
On Fri, 2015-06-12 at 01:00 +0900, KOBAYASHI Yoshitake wrote:
> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
> index 5897d8d..050f0e9 100644

> +config MTD_NAND_BENAND
> + tristate
> + depends on MTD_NAND_BENAND_ENABLE
> + default MTD_NAND
> +
> +config MTD_NAND_BENAND_ENABLE
> + bool "Support for Toshiba BENAND (Built-in ECC NAND)"
> + default y

Why do you default to 'y'?

> + help
> + This enables support for Toshiba BENAND.
> + Toshiba BENAND is a SLC NAND solution that automatically
> + generates ECC inside NAND chip.
> +

> --- /dev/null
> +++ b/drivers/mtd/nand/nand_benand.c

> +EXPORT_SYMBOL(nand_benand_status_chk);

I didn't spot any users of nand_benand_status_chk() outside of this
file. Why is this export needed?

Thanks,


Paul Bolle

--
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 v5 22/24] cputime: Introduce cputime_to_timespec64()/timespec64_to_cputime()

2015-06-12 Thread Baolin Wang
The cputime_to_timespec() and timespec_to_cputime() functions are
not year 2038 safe on 32bit systems due to the struct timepsec will
overflow in 2038 year. Introduce cputime_to_timespec64() and
timespec64_to_cputime() functions which use struct timespec64,
as well as for arch/s390 and arch/powerpc architecture.

The cputime_to_timespec() and timespec_to_cputime() functions are
moved to include/linux/cputime.h file as 'static inline' for removing
conveniently in future.

Signed-off-by: Baolin Wang 
---
 arch/powerpc/include/asm/cputime.h|6 +++---
 arch/s390/include/asm/cputime.h   |8 
 include/asm-generic/cputime_jiffies.h |   10 +-
 include/asm-generic/cputime_nsecs.h   |6 +++---
 include/linux/cputime.h   |   16 
 5 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/include/asm/cputime.h 
b/arch/powerpc/include/asm/cputime.h
index e245255..5dda5c0 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -154,9 +154,9 @@ static inline cputime_t secs_to_cputime(const unsigned long 
sec)
 }
 
 /*
- * Convert cputime <-> timespec
+ * Convert cputime <-> timespec64
  */
-static inline void cputime_to_timespec(const cputime_t ct, struct timespec *p)
+static inline void cputime_to_timespec64(const cputime_t ct, struct timespec64 
*p)
 {
u64 x = (__force u64) ct;
unsigned int frac;
@@ -168,7 +168,7 @@ static inline void cputime_to_timespec(const cputime_t ct, 
struct timespec *p)
p->tv_nsec = x;
 }
 
-static inline cputime_t timespec_to_cputime(const struct timespec *p)
+static inline cputime_t timespec64_to_cputime(const struct timespec64 *p)
 {
u64 ct;
 
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index 221b454..3319b51 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -81,16 +81,16 @@ static inline cputime_t secs_to_cputime(const unsigned int 
s)
 }
 
 /*
- * Convert cputime to timespec and back.
+ * Convert cputime to timespec64 and back.
  */
-static inline cputime_t timespec_to_cputime(const struct timespec *value)
+static inline cputime_t timespec64_to_cputime(const struct timespec64 *value)
 {
unsigned long long ret = value->tv_sec * CPUTIME_PER_SEC;
return (__force cputime_t)(ret + __div(value->tv_nsec * 
CPUTIME_PER_USEC, NSEC_PER_USEC));
 }
 
-static inline void cputime_to_timespec(const cputime_t cputime,
-  struct timespec *value)
+static inline void cputime_to_timespec64(const cputime_t cputime,
+struct timespec64 *value)
 {
unsigned long long __cputime = (__force unsigned long long) cputime;
value->tv_nsec = (__cputime % CPUTIME_PER_SEC) * NSEC_PER_USEC / 
CPUTIME_PER_USEC;
diff --git a/include/asm-generic/cputime_jiffies.h 
b/include/asm-generic/cputime_jiffies.h
index fe386fc..54e034c 100644
--- a/include/asm-generic/cputime_jiffies.h
+++ b/include/asm-generic/cputime_jiffies.h
@@ -44,12 +44,12 @@ typedef u64 __nocast cputime64_t;
 #define secs_to_cputime(sec)   jiffies_to_cputime((sec) * HZ)
 
 /*
- * Convert cputime to timespec and back.
+ * Convert cputime to timespec64 and back.
  */
-#define timespec_to_cputime(__val) \
-   jiffies_to_cputime(timespec_to_jiffies(__val))
-#define cputime_to_timespec(__ct,__val)\
-   jiffies_to_timespec(cputime_to_jiffies(__ct),__val)
+#define timespec64_to_cputime(__val)   \
+   jiffies_to_cputime(timespec64_to_jiffies(__val))
+#define cputime_to_timespec64(__ct,__val)  \
+   jiffies_to_timespec64(cputime_to_jiffies(__ct),__val)
 
 /*
  * Convert cputime to timeval and back.
diff --git a/include/asm-generic/cputime_nsecs.h 
b/include/asm-generic/cputime_nsecs.h
index 0419485..c0cafc0 100644
--- a/include/asm-generic/cputime_nsecs.h
+++ b/include/asm-generic/cputime_nsecs.h
@@ -71,14 +71,14 @@ typedef u64 __nocast cputime64_t;
(__force cputime_t)((__secs) * NSEC_PER_SEC)
 
 /*
- * Convert cputime <-> timespec (nsec)
+ * Convert cputime <-> timespec64 (nsec)
  */
-static inline cputime_t timespec_to_cputime(const struct timespec *val)
+static inline cputime_t timespec64_to_cputime(const struct timespec64 *val)
 {
u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_nsec;
return (__force cputime_t) ret;
 }
-static inline void cputime_to_timespec(const cputime_t ct, struct timespec 
*val)
+static inline void cputime_to_timespec64(const cputime_t ct, struct timespec64 
*val)
 {
u32 rem;
 
diff --git a/include/linux/cputime.h b/include/linux/cputime.h
index f2eb2ee..cd638a0 100644
--- a/include/linux/cputime.h
+++ b/include/linux/cputime.h
@@ -13,4 +13,20 @@
usecs_to_cputime((__nsecs) / NSEC_PER_USEC)
 #endif
 
+static inline cputime_t timespec_to_cputime(const struct timespec *ts)
+{
+   struct timespec64 ts64 = timespec_to_timespec64(*ts);
+
+   return 

[PATCH v5 23/24] posix-cpu-timers: Convert to y2038 safe callbacks

2015-06-12 Thread Baolin Wang
The clock_getres()/clock_get()/clock_set()/timer_set()/timer_get()
callbacks in struct k_clock are not year 2038 safe on 32bit systems,
and it need convert to safe callbacks which use struct timespec64
or struct itimerspec64.

Signed-off-by: Baolin Wang 
---
 kernel/time/posix-cpu-timers.c |   84 +---
 1 file changed, 45 insertions(+), 39 deletions(-)

diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 892e3da..1d4605c 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -52,7 +52,7 @@ static int check_clock(const clockid_t which_clock)
 }
 
 static inline unsigned long long
-timespec_to_sample(const clockid_t which_clock, const struct timespec *tp)
+timespec64_to_sample(const clockid_t which_clock, const struct timespec64 *tp)
 {
unsigned long long ret;
 
@@ -60,19 +60,19 @@ timespec_to_sample(const clockid_t which_clock, const 
struct timespec *tp)
if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) {
ret = (unsigned long long)tp->tv_sec * NSEC_PER_SEC + 
tp->tv_nsec;
} else {
-   ret = cputime_to_expires(timespec_to_cputime(tp));
+   ret = cputime_to_expires(timespec64_to_cputime(tp));
}
return ret;
 }
 
-static void sample_to_timespec(const clockid_t which_clock,
+static void sample_to_timespec64(const clockid_t which_clock,
   unsigned long long expires,
-  struct timespec *tp)
+  struct timespec64 *tp)
 {
if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED)
-   *tp = ns_to_timespec(expires);
+   *tp = ns_to_timespec64(expires);
else
-   cputime_to_timespec((__force cputime_t)expires, tp);
+   cputime_to_timespec64((__force cputime_t)expires, tp);
 }
 
 /*
@@ -141,7 +141,7 @@ static inline unsigned long long virt_ticks(struct 
task_struct *p)
 }
 
 static int
-posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp)
+posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
int error = check_clock(which_clock);
if (!error) {
@@ -160,7 +160,7 @@ posix_cpu_clock_getres(const clockid_t which_clock, struct 
timespec *tp)
 }
 
 static int
-posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp)
+posix_cpu_clock_set(const clockid_t which_clock, const struct timespec64 *tp)
 {
/*
 * You can never reset a CPU clock, but we check for other errors
@@ -286,7 +286,7 @@ static int cpu_clock_sample_group(const clockid_t 
which_clock,
 
 static int posix_cpu_clock_get_task(struct task_struct *tsk,
const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
int err = -EINVAL;
unsigned long long rtn;
@@ -300,13 +300,14 @@ static int posix_cpu_clock_get_task(struct task_struct 
*tsk,
}
 
if (!err)
-   sample_to_timespec(which_clock, rtn, tp);
+   sample_to_timespec64(which_clock, rtn, tp);
 
return err;
 }
 
 
-static int posix_cpu_clock_get(const clockid_t which_clock, struct timespec 
*tp)
+static int posix_cpu_clock_get(const clockid_t which_clock,
+   struct timespec64 *tp)
 {
const pid_t pid = CPUCLOCK_PID(which_clock);
int err = -EINVAL;
@@ -622,7 +623,7 @@ static inline void posix_cpu_timer_kick_nohz(void) { }
  * and try again.  (This happens when the timer is in the middle of firing.)
  */
 static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
-  struct itimerspec *new, struct itimerspec *old)
+  struct itimerspec64 *new, struct itimerspec64 
*old)
 {
unsigned long flags;
struct sighand_struct *sighand;
@@ -632,7 +633,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int 
timer_flags,
 
WARN_ON_ONCE(p == NULL);
 
-   new_expires = timespec_to_sample(timer->it_clock, &new->it_value);
+   new_expires = timespec64_to_sample(timer->it_clock, &new->it_value);
 
/*
 * Protect against sighand release/switch in exit/exec and p->cpu_timers
@@ -693,7 +694,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int 
timer_flags,
bump_cpu_timer(timer, val);
if (val < timer->it.cpu.expires) {
old_expires = timer->it.cpu.expires - val;
-   sample_to_timespec(timer->it_clock,
+   sample_to_timespec64(timer->it_clock,
   old_expires,
   &old->it_value);
} else {
@@ -733,7 +734,7 @@ static int posix_cpu_timer_s

[PATCH v5 24/24] k_clock: Remove y2038 unsafe callbacks

2015-06-12 Thread Baolin Wang
All of the k_clock users have been converted to the y2038 safe methods,
this patch removes the older methods with timepsec/itimerspec type,
as a result the k_clock structure is ready for the year 2038.

Signed-off-by: Baolin Wang 
---
 include/linux/posix-timers.h |9 -
 kernel/time/posix-timers.c   |   90 +++---
 2 files changed, 5 insertions(+), 94 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 35786c5..7c3dae2 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -97,29 +97,20 @@ struct k_itimer {
 };
 
 struct k_clock {
-   int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
int (*clock_getres64) (const clockid_t which_clock, struct timespec64 
*tp);
-   int (*clock_set) (const clockid_t which_clock,
- const struct timespec *tp);
int (*clock_set64) (const clockid_t which_clock,
const struct timespec64 *tp);
-   int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
int (*clock_get64) (const clockid_t which_clock, struct timespec64 *tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
   struct timespec *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
-   int (*timer_set) (struct k_itimer * timr, int flags,
- struct itimerspec * new_setting,
- struct itimerspec * old_setting);
int (*timer_set64) (struct k_itimer *timr, int flags,
struct itimerspec64 *new_setting,
struct itimerspec64 *old_setting);
int (*timer_del) (struct k_itimer * timr);
 #define TIMER_RETRY 1
-   void (*timer_get) (struct k_itimer * timr,
-  struct itimerspec * cur_setting);
void (*timer_get64) (struct k_itimer *timr,
 struct itimerspec64 *cur_setting);
 };
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 80f630a..e9e6e29 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -140,7 +140,6 @@ static int common_timer_del(struct k_itimer *timer);
 static enum hrtimer_restart posix_timer_fn(struct hrtimer *data);
 
 static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags);
-static struct k_clock *clockid_to_kclock(const clockid_t id);
 
 #define lock_timer(tid, flags)\
 ({ struct k_itimer *__timr;   \
@@ -550,73 +549,6 @@ static struct pid *good_sigevent(sigevent_t * event)
return task_pid(rtn);
 }
 
-static void default_timer_get64(struct k_itimer *timr,
-   struct itimerspec64 *cur_setting64)
-{
-   struct itimerspec cur_setting;
-   struct k_clock *kc = clockid_to_kclock(timr->it_clock);
-
-   kc->timer_get(timr, &cur_setting);
-   *cur_setting64 = itimerspec_to_itimerspec64(&cur_setting);
-}
-
-static int default_timer_set64(struct k_itimer *timr, int flags,
-  struct itimerspec64 *new_setting64,
-  struct itimerspec64 *old_setting64)
-{
-   struct k_clock *kc = clockid_to_kclock(timr->it_clock);
-   struct itimerspec new_setting, old_setting;
-   struct itimerspec *rtn = old_setting64 ? &old_setting : NULL;
-   int ret;
-
-   new_setting = itimerspec64_to_itimerspec(new_setting64);
-   ret = kc->timer_set(timr, flags, &new_setting, rtn);
-   if (!ret && old_setting64)
-   *old_setting64 = itimerspec_to_itimerspec64(&old_setting);
-
-   return ret;
-}
-
-static int default_clock_set64(const clockid_t which_clock,
-  const struct timespec64 *tp64)
-{
-   struct k_clock *kc = clockid_to_kclock(which_clock);
-   struct timespec tp;
-   int ret;
-
-   tp = timespec64_to_timespec(*tp64);
-   ret = kc->clock_set(which_clock, &tp);
-   return ret;
-}
-
-static int default_clock_get64(const clockid_t which_clock,
-  struct timespec64 *tp64)
-{
-   struct k_clock *kc = clockid_to_kclock(which_clock);
-   struct timespec tp;
-   int ret;
-
-   ret = kc->clock_get(which_clock, &tp);
-   if (!ret)
-   *tp64 = timespec_to_timespec64(tp);
-
-   return ret;
-}
-
-static int default_clock_getres64(const clockid_t which_clock,
- struct timespec64 *tp64)
-{
-   struct k_clock *kc = clockid_to_kclock(which_clock);
-   struct timespec tp;
-   int ret;
-
-   ret = kc->clock_getres(which_clock, &tp);
-   if (!ret)
-   *tp64 = timespec_to_timespec64(

RE: [V6 PATCH 6/7] megaraid_sas: fix TRUE and FALSE re-define build error

2015-06-12 Thread Sumit Saxena
>-Original Message-
>From: Suravee Suthikulpanit [mailto:suravee.suthikulpa...@amd.com]
>Sent: Wednesday, June 10, 2015 9:39 PM
>To: r...@rjwysocki.net; l...@kernel.org; catalin.mari...@arm.com;
>will.dea...@arm.com; thomas.lenda...@amd.com;
>herb...@gondor.apana.org.au; da...@davemloft.net; a...@arndb.de;
>kashyap.de...@avagotech.com; sumit.sax...@avagotech.com;
>uday.ling...@avagotech.com; vinholika...@gmail.com
>Cc: msal...@redhat.com; hanjun@linaro.org; al.st...@linaro.org;
>grant.lik...@linaro.org; leo.du...@amd.com; linux-arm-
>ker...@lists.infradead.org; linux-a...@vger.kernel.org; linux-
>ker...@vger.kernel.org; linaro-a...@lists.linaro.org;
net...@vger.kernel.org;
>linux-cry...@vger.kernel.org; Suravee Suthikulpanit
>Subject: [V6 PATCH 6/7] megaraid_sas: fix TRUE and FALSE re-define build
>error
>
>Signed-off-by: Suravee Suthikulpanit 
>Cc: Kashyap Desai 
>Cc: Sumit Saxena 
>Cc: Uday Lingala 
>---
> drivers/scsi/megaraid/megaraid_sas_fp.c | 8 
> 1 file changed, 8 insertions(+)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c
>b/drivers/scsi/megaraid/megaraid_sas_fp.c
>index 4f72287..e8b7a69 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
>@@ -66,7 +66,15 @@ MODULE_PARM_DESC(lb_pending_cmds, "Change
>raid-1 load balancing outstanding "
>
> #define ABS_DIFF(a, b)   (((a) > (b)) ? ((a) - (b)) : ((b) - (a)))
> #define MR_LD_STATE_OPTIMAL 3
>+
>+#ifdef FALSE
>+#undef FALSE
>+#endif
> #define FALSE 0
>+
>+#ifdef TRUE
>+#undef TRUE
>+#endif
> #define TRUE 1
>
> #define SPAN_DEBUG 0
Acked-by: Sumit Saxena 

>--
>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: [PATCH 05/12] mm: Introduce arch_pgd_init_late()

2015-06-12 Thread Ingo Molnar

* Andrew Morton  wrote:

> On Thu, 11 Jun 2015 16:07:10 +0200 Ingo Molnar  wrote:
> 
> > --- a/kernel/fork.c
> > +++ b/kernel/fork.c
> > @@ -1592,6 +1592,22 @@ static struct task_struct *copy_process(unsigned 
> > long clone_flags,
> > syscall_tracepoint_update(p);
> > write_unlock_irq(&tasklist_lock);
> >  
> > +   /*
> > +* If we have a new PGD then initialize it:
> > +*
> > +* This method is called after a task has been made visible
> > +* on the task list already.
> > +*
> > +* Architectures that manage per task kernel pagetables
> > +* might use this callback to initialize them after they
> > +* are already visible to new updates.
> > +*
> > +* NOTE: any user-space parts of the PGD are already initialized
> > +*   and must not be clobbered.
> > +*/
> > +   if (p->mm != current->mm)
> > +   arch_pgd_init_late(p->mm, p->mm->pgd);
> 
> Couldn't this be arch_pgd_init_late(p->mm) or arch_pgd_init_late(p)?

Indeed - fixed.

Thanks,

Ingo
--
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] x86: General protection fault after STR (32 bit systems only)

2015-06-12 Thread H. Peter Anvin
%es is used implicitly by string instructions.

On June 12, 2015 12:50:13 AM PDT, Ingo Molnar  wrote:
>
>* Andy Lutomirski  wrote:
>
>> > --- a/arch/x86/kernel/acpi/wakeup_32.S
>> > +++ b/arch/x86/kernel/acpi/wakeup_32.S
>> > @@ -81,6 +81,10 @@ ENTRY(do_suspend_lowlevel)
>> > jmp ret_point
>> > .p2align 4,,7
>> >  ret_point:
>> > +   /* In case the BIOS corrupted DS, make the kernel context
>minimally functional: */
>> > +   movl$__KERNEL_DS, %eax
>> > +   movl%eax, %ds
>> > +
>> 
>> On further thought, I think you want movl $__USER_DS, %eax.  The
>> 32-bit kernel is a strange beast.  Also, you should probably fix up
>> %es as well.
>
>So restore_processor_state() already restores ES. The idea here was to
>reload DS 
>early on, because the kernel implicitly uses it for data access so we
>need it to 
>be good to be able to continue executing any generic kernel code.
>
>We don't use %es: prefixed assembly AFAICS, what are the implicit users
>of ES?
>
>Also, to further confuse things, we also have:
>
>ENTRY(wakeup_pmode_return)
>wakeup_pmode_return:
>movw$__KERNEL_DS, %ax
>movw%ax, %ss
>movw%ax, %ds
>movw%ax, %es
>movw%ax, %fs
>movw%ax, %gs
>
># reload the gdt, as we need the full 32 bit address
>lidtsaved_idt
>lldtsaved_ldt
>ljmp$(__KERNEL_CS), $1f
>1:
>movl%cr3, %eax
>movl%eax, %cr3
>wbinvd
>
>which seems to be another layer of restoration - but it possibly does
>not trigger 
>in the S2RAM case here.
>
>Oh, funny the 'reload the gdt' comment: do you see an LGDT there? It
>reloads all 
>segment selectors, the IDT, LDT and CR3, but does not seem to reload
>the GDT - the 
>only thing the comment describes.
>
>Thanks,
>
>   Ingo

-- 
Sent from my mobile phone.  Please pardon brevity and lack of formatting.
--
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 06/12] x86/mm: Enable and use the arch_pgd_init_late() method

2015-06-12 Thread Ingo Molnar

* Boris Ostrovsky  wrote:

> On 06/11/2015 10:07 AM, Ingo Molnar wrote:
> 
> >diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
> >index fb0a9dd1d6e4..e0bf90470d70 100644
> >--- a/arch/x86/mm/pgtable.c
> >+++ b/arch/x86/mm/pgtable.c
> >@@ -391,6 +391,63 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
> > return NULL;
> >  }
> >
> >+/*
> >+ * Initialize the kernel portion of the PGD.
> >+ *
> >+ * This is done separately, because pgd_alloc() happens when
> >+ * the task is not on the task list yet - and PGD updates
> >+ * happen by walking the task list.
> >+ *
> >+ * No locking is needed here, as we just copy over the reference
> >+ * PGD. The reference PGD (pgtable_init) is only ever expanded
> >+ * at the highest, PGD level. Thus any other task extending it
> >+ * will first update the reference PGD, then modify the task PGDs.
> >+ */
> >+void arch_pgd_init_late(struct mm_struct *mm, pgd_t *pgd)
> >+{
> >+/*
> >+ * This is called after a new MM has been made visible
> >+ * in fork() or exec().
> >+ *
> >+ * This barrier makes sure the MM is visible to new RCU
> >+ * walkers before we initialize it, so that we don't miss
> >+ * updates:
> >+ */
> >+smp_wmb();
> >+
> >+/*
> >+ * If the pgd points to a shared pagetable level (either the
> >+ * ptes in non-PAE, or shared PMD in PAE), then just copy the
> >+ * references from swapper_pg_dir:
> >+ */
> >+if (CONFIG_PGTABLE_LEVELS == 2 ||
> >+(CONFIG_PGTABLE_LEVELS == 3 && SHARED_KERNEL_PMD) ||
> >+CONFIG_PGTABLE_LEVELS == 4) {
> >+
> >+pgd_t *pgd_src = swapper_pg_dir + KERNEL_PGD_BOUNDARY;
> >+pgd_t *pgd_dst =pgd + KERNEL_PGD_BOUNDARY;
> >+int i;
> >+
> >+for (i = 0; i < KERNEL_PGD_PTRS; i++, pgd_src++, pgd_dst++) {
> >+/*
> >+ * This is lock-less, so it can race with PGD updates
> >+ * coming from vmalloc() or CPA methods, but it's safe,
> >+ * because:
> >+ *
> >+ * 1) this PGD is not in use yet, we have still not
> >+ *scheduled this task.
> >+ * 2) we only ever extend PGD entries
> >+ *
> >+ * So if we observe a non-zero PGD entry we can copy it,
> >+ * it won't change from under us. Parallel updates (new
> >+ * allocations) will modify our (already visible) PGD:
> >+ */
> >+if (pgd_val(*pgd_src))
> >+WRITE_ONCE(*pgd_dst, *pgd_src);
> 
> 
> This should be set_pgd(pgd_dst, *pgd_src) in order for it to work as a Xen
> PV guest.

Thanks, fixed.

> I don't know whether anything would need to be done wrt WRITE_ONCE. Perhaps 
> put 
> it into native_set_pgd()?

So this was just write-tearing paranoia at the raw pgd value copy I did which 
is 
an unusual pattern - but I'll use set_pgd(), as it clearly works and has the 
paravirt callback as well.

Thanks,

Ingo
--
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 3/7] clocksource: arm_global_timer: Migrate to new 'set-state' interface

2015-06-12 Thread Maxime Coquelin

Hi Viresh,

On 06/12/2015 10:00 AM, Viresh Kumar wrote:

Migrate arm_global_timer driver to the new 'set-state' interface
provided by the clockevents core, the earlier 'set-mode' interface is
marked obsolete now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Acked-by: Daniel Lezcano 
Cc: Srinivas Kandagatla 
Cc: Maxime Coquelin 
Cc: Patrice Chotard 
Signed-off-by: Viresh Kumar 
---
  drivers/clocksource/arm_global_timer.c | 37 --
  1 file changed, 17 insertions(+), 20 deletions(-)




You can add:

Acked-by: Maxime Coquelin 

Thanks!
Maxime
--
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   >