Re: [PATCH v2 2/4] gpio: Allow PC/104 devices on X86_64

2016-06-04 Thread Pavel Machek
On Fri 2016-06-03 17:12:44, William Breathitt Gray wrote:
> On Fri, Jun 03, 2016 at 10:57:03PM +0200, Pavel Machek wrote:
> >Hi!
> >
> >> With the introduction of the ISA_BUS_API Kconfig option, ISA-style
> >> drivers may be built for X86_64 architectures. This patch changes the
> >> ISA Kconfig option dependency of the PC/104 drivers to ISA_BUS_API, thus
> >> allowing them to build for X86_64 as they are expected to.
> >> 
> >> Cc: Guenter Roeck 
> >> Cc: Linus Walleij 
> >> Signed-off-by: William Breathitt Gray 
> >> ---
> >>  drivers/gpio/Kconfig | 8 
> >>  1 file changed, 4 insertions(+), 4 deletions(-)
> >> 
> >> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> >> index 48da857..dc6da77 100644
> >> --- a/drivers/gpio/Kconfig
> >> +++ b/drivers/gpio/Kconfig
> >> @@ -530,7 +530,7 @@ menu "Port-mapped I/O GPIO drivers"
> >>  
> >>  config GPIO_104_DIO_48E
> >>tristate "ACCES 104-DIO-48E GPIO support"
> >> -  depends on ISA
> >> +  depends on ISA_BUS_API
> >>select GPIOLIB_IRQCHIP
> >>help
> >>  Enables GPIO support for the ACCES 104-DIO-48E series
> >
> >Should we do "depends on PC104" here, because that is what it really
> >means, and have PC104 enabled when ISA_BUS_API is enabled or something
> >like that?
> 
> Since the functionality remains the same, I'm a bit indifferent to that
> change; as long as the driver builds for systems in which it's intended
> to be used, I'm satisfied.
> 
> Differentiating between PC/104 and ISA may be a pointless endeavor
> though since both buses appear the same to software. But if it is better
> to differentiate between devices as such, then I see little harm in
> adding a PC104 Kconfig option which follows the ISA_BUS_API Kconfig
> option.

Well, they are same to the software, but not at the hardware. If I
have a development board that has PC104 (but not isa), I'd like to see
prompts for PC104 extensions, not for isa. If PC105 comes out, still
ISA compatible, I will want to see prompts for PC104 boards or PC105
boards, but not neccessarily both...

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Re: [linux-next: Tree for Jun 1] __khugepaged_exit rwsem_down_write_failed lockup

2016-06-04 Thread Sergey Senozhatsky
Hello,

On (06/03/16 15:49), Michal Hocko wrote:
> __khugepaged_exit is called during the final __mmput and it employs a
> complex synchronization dances to make sure it doesn't race with the
> khugepaged which might be scanning this mm at the same time. This is
> all caused by the fact that khugepaged doesn't pin mm_users. Things
> would simplify considerably if we simply check the mm at
> khugepaged_scan_mm_slot and if mm_users was already 0 then we know it
> is dead and we can unhash the mm_slot and move on to another one. This
> will also guarantee that __khugepaged_exit cannot race with khugepaged
> and so we can free up the slot if it is still hashed.
> 
> Signed-off-by: Michal Hocko 

with this patch and
http://ozlabs.org/~akpm/mmotm/broken-out/mm-thp-make-swapin-readahead-under-down_read-of-mmap_sem-fix-2.patch

I saw no problems during my tests (well, may be didn't test hard
enough).

-ss


Re: [PATCH v2 1/2] b43: Remove unused phy_a code

2016-06-04 Thread Michael Büsch
On Fri,  3 Jun 2016 21:11:51 -0700
Guenter Roeck  wrote:

> +static void __b43_phy_initg(struct b43_wldev *dev)
> +{
> + struct b43_phy *phy = &dev->phy;
> +
> + might_sleep();
> +
> + if (phy->rev >= 6) {
> + if (b43_phy_read(dev, B43_PHY_ENCORE) & B43_PHY_ENCORE_EN)
> + b43_phy_set(dev, B43_PHY_ENCORE, 0x0010);
> + else
> + b43_phy_mask(dev, B43_PHY_ENCORE, ~0x1010);
> + }
> +
> + b43_wa_all(dev);
> +
> + if (dev->dev->bus_sprom->boardflags_lo & B43_BFL_PACTRL)
> + b43_phy_maskset(dev, B43_PHY_OFDM(0x6E), 0xE000, 0x3CF);
> +}
> +
>  static void b43_phy_initg(struct b43_wldev *dev)
>  {
>   struct b43_phy *phy = &dev->phy;
> @@ -1999,7 +2019,7 @@ static void b43_phy_initg(struct b43_wldev *dev)
>   b43_phy_initb6(dev);
>  
>   if (phy->rev >= 2 || phy->gmode)
> - b43_phy_inita(dev);
> + __b43_phy_initg(dev);

This actually is correctly called inita(), because there are A-phy parts
in the G-phy.
So I wasn't 100% correct saying that _all_ a-phy code is unused.
I'm Ok with moving that into the g-phy file though. But don't rename it.


-- 
Michael


pgp_lzos00RtM.pgp
Description: OpenPGP digital signature


[PATCH] staging: sm750fb: deleted couple of blank lines at the very end

2016-06-04 Thread Mikulas Tomanka
Signed-off-by: Mikulas Tomanka 
---
 drivers/staging/sm750fb/ddk750_chip.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index f80ee77..5e2d6d2 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -383,5 +383,3 @@ unsigned int formatPllReg(pll_value_t *pPLL)
 
return reg;
 }
-
-
-- 
2.8.3



Re: [PATCH V3 1/2] irqchip/gicv3-its: split its_alloc_tables() into two functions

2016-06-04 Thread Marc Zyngier
On Mon, 9 May 2016 15:58:25 -0500
Shanker Donthineni  wrote:

> The function is getting out of control, it has too many goto
> statements and would be too complicated for adding a feature
> two-level device table. So, it is time for us to cleanup and
> move some of the logic to a separate function without affecting
> the existing functionality.
> 
> Signed-off-by: Shanker Donthineni 
> ---
>  drivers/irqchip/irq-gic-v3-its.c   | 256 
> -
>  include/linux/irqchip/arm-gic-v3.h |   3 +
>  2 files changed, 144 insertions(+), 115 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c 
> b/drivers/irqchip/irq-gic-v3-its.c
> index 6bd881b..b23e00c 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -55,13 +55,15 @@ struct its_collection {
>  };
>  
>  /*
> - * The ITS_BASER structure - contains memory information and cached
> - * value of BASER register configuration.
> + * The ITS_BASER structure - contains memory information, cached value
> + * of BASER register configuration, ioremaped address and page size.
>   */
>  struct its_baser {
> + void __iomem*hwreg;

I'm not overly fond of caching arbitrary device addresses, and I'd be
happier if you had the GITS_BASERn index in there, together with a
couple of helpers to perform the access:

void its_write_baser(struct its_node *its, struct its_baser *baser,
 u64 val);
u64 its_read_baser(struct its_node *its, struct its_baser *baser);

and keep the offset computing out of sight.

>   void*base;
>   u64 val;
>   u32 order;
> + u32 psz;
>  };
>  
>  /*
> @@ -823,27 +825,135 @@ static void its_free_tables(struct its_node *its)
>   }
>  }
>  
> +static int its_baser_setup(struct its_node *its, struct its_baser *baser,
> +   u32 order, u64 indirect)

Please move the indirect support to the next patch. I'd like to see
something that doesn't have any semantic change.

> +{
> + u64 val = readq_relaxed(baser->hwreg);
> + u64 type = GITS_BASER_TYPE(val);
> + u64 entry_size = GITS_BASER_ENTRY_SIZE(val);
> + int psz, alloc_pages;
> + u64 cache, shr, tmp;
> + void *base;
> +
> + /* Do first attempt with the requested attributes */
> + cache = baser->val & GITS_BASER_CACHEABILITY_MASK;
> + shr = baser->val & GITS_BASER_SHAREABILITY_MASK;
> + psz = baser->psz;
> +
> +retry_alloc_baser:
> + alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz);
> + if (alloc_pages > GITS_BASER_PAGES_MAX) {
> + pr_warn("ITS@%lx: %s too large, reduce ITS pages %u->%u\n",
> + its->phys_base, its_base_type_string[type],
> + alloc_pages, GITS_BASER_PAGES_MAX);
> + alloc_pages = GITS_BASER_PAGES_MAX;
> + order = get_order(GITS_BASER_PAGES_MAX * psz);
> + }
> +
> + base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
> + if (!base)
> + return -ENOMEM;
> +
> +retry_baser:
> + val = (virt_to_phys(base)|
> + (type << GITS_BASER_TYPE_SHIFT)  |
> + ((entry_size - 1) << GITS_BASER_ENTRY_SIZE_SHIFT) |
> + ((alloc_pages - 1) << GITS_BASER_PAGES_SHIFT)|
> + cache|
> + shr  |
> + indirect |

See my comment on the next patch. This should be a bool, and used with
something like:
[...]
indirect ? GITS_BASER_INDIRECT : 0  |
[...]

(and of course moved to the next patch, together with the rest of the
indirect support.

> + GITS_BASER_VALID);
> +
> + switch (psz) {
> + case SZ_4K:
> + val |= GITS_BASER_PAGE_SIZE_4K;
> + break;
> + case SZ_16K:
> + val |= GITS_BASER_PAGE_SIZE_16K;
> + break;
> + case SZ_64K:
> + val |= GITS_BASER_PAGE_SIZE_64K;
> + break;
> + }
> +
> + writeq_relaxed(val, baser->hwreg);
> + tmp = readq_relaxed(baser->hwreg);
> +
> + if ((val ^ tmp) & GITS_BASER_SHAREABILITY_MASK) {
> + /*
> +  * Shareability didn't stick. Just use
> +  * whatever the read reported, which is likely
> +  * to be the only thing this redistributor
> +  * supports. If that's zero, make it
> +  * non-cacheable as well.
> +  */
> + shr = tmp & GITS_BASER_SHAREABILITY_MASK;
> + if (!shr) {
> + cache = GITS_BASER_nC;
> + __flush_dcache_area(base, PAGE_ORDER_TO_SIZE(order));
> + }
> + goto retry_baser;
> + }
> +
> + if ((val ^ tmp) & GITS_BASER_PAGE_SIZE_MASK) {
> +   

Re: [PATCH] sd: remove redundant check for BLK_DEF_MAX_SECTORS

2016-06-04 Thread Tom Yan
The main point there is not to check q->limits.max_sectors against
BLK_DEF_MAX_SECTORS, but sdkp->opt_xfer_blocks against
SD_DEF_XFER_BLOCKS et al.? `rw_max = BLK_DEF_MAX_SECTORS;` there is
merely the fallback when sdkp->opt_xfer_blocks does not pass the
conditions. With your patch `rw_max` can be indeterminate in those
circumstances.

On 4 June 2016 at 11:57, Long Li  wrote:
> q->limits.max_sectors is already checked against BLK_DEF_MAX_SECTORS in 
> __scsi_alloc_queue(), when it calls blk_queue_max_hw_sectors(). There is no 
> need to check it again in sd.
>
> This change also allows a SCSI driver set an maximum sector size bigger than 
> BLK_DEF_MAX_SECTORS, without returning values on optional VPD page 0xb0 
> "Block Limits".
>
> Signed-off-by: Long Li 
>
> ---
>  drivers/scsi/sd.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 60bff78..d8c4047 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2870,11 +2870,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
> logical_to_bytes(sdp, sdkp->opt_xfer_blocks) >= PAGE_SIZE) {
> q->limits.io_opt = logical_to_bytes(sdp, 
> sdkp->opt_xfer_blocks);
> rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
> -   } else
> -   rw_max = BLK_DEF_MAX_SECTORS;
> -
> -   /* Combine with controller limits */
> -   q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));
> +   q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));
> +   }
>
> set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity));
> sd_config_write_same(sdkp);
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ASoC: sgtl5000: only check VDDD-supply, not revision

2016-06-04 Thread Clemens Gruber
Hi Eric,

On Sat, Jun 04, 2016 at 07:18:28AM +0200, Eric Nelson wrote:
> AFAIK, the SGTL5000 versions < 0x11 are like Sasquatch: I've seen
> no real proof of their existence. I tried to chase down when this
> code was introduced, but it seems to have been around since
> the dawn of the driver.

> 
> Clemens, if you're really trying to control an external regulator,
> I think you'll need lots more than this patch. There are some
> fundamental flaws in regulator handling and I put together some
> RFC patches to address them in February 2015:
>   
> http://mailman.alsa-project.org/pipermail/alsa-devel/2015-February/thread.html#88353
> 
> The long and short of it is that at least one of the regulators
> would need to be initialized before the SGTL5000 probes.

Thank you very much for your input on this. So we can assume that no
user of the sgtl5000 is controlling an external VDDD regulator, because
this does not work without your patch series from Februar 2015.

As far as not enabling the internal LDO when using external VDDD and
avoiding the misleading "Using internal LDO..." message at boot, do you
think my patch would be OK?

Regards,
Clemens


Re: [PATCH V3 2/2] irqchip/gicv3-its: Implement two-level(indirect) device table support

2016-06-04 Thread Marc Zyngier
On Mon, 9 May 2016 15:58:26 -0500
Shanker Donthineni  wrote:

Hi Shanker,

> Since device IDs are extremely sparse, the single, a.k.a flat table is
> not sufficient for the following two reasons.
> 
> 1) According to ARM-GIC spec, ITS hw can access maximum of 256(pages)*
>64K(pageszie) bytes. In the best case, it supports upto DEVid=21
 pagesize
>sparse with minimum device table entry size 8bytes.
> 
> 2) The maximum memory size that is possible without memblock depends on
>MAX_ORDER. 4MB on 4K page size kernel with default MAX_ORDER, so it
>supports DEVid range 19bits.
> 
> The two-level device table feature brings us two advantages, the first
> is a very high possibility of supporting upto 32bit sparse, and the
> second one is the best utilization of memory allocation.
> 
> The feature is enabled automatically during driver probe if a single
> ITS page is not adequate for flat table and the hardware is capable
> of two-level table walk.
> 
> Signed-off-by: Shanker Donthineni 
> ---
> 
> Changes since v2:
>   Fixed a porting bug device 'id' validation check in its_alloc_device_table()
> 
> Changes since v1:
>   Most of this patch has been rewritten after refactoring its_alloc_tables().
>   Always enable device two-level if the memory requirement is more than 
> PAGE_SIZE.
>   Fixed the coding bug that breaks on the BE machine.
>   Edited the commit text.
> 
>  drivers/irqchip/irq-gic-v3-its.c | 97 
> +---
>  1 file changed, 80 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c 
> b/drivers/irqchip/irq-gic-v3-its.c
> index b23e00c..60a1060 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -938,6 +938,18 @@ retry_baser:
>   return 0;
>  }
>  
> +/**
> + * Find out whether an implemented baser register supports a single, flat 
> table
> + * or a two-level table by reading bit offset at '62' after writing '1' to 
> it.
> + */
> +static u64 its_baser_check_indirect(struct its_baser *baser)
> +{
> + u64 val = GITS_BASER_InnerShareable | GITS_BASER_WaWb;
> +
> + writeq_relaxed(val | GITS_BASER_INDIRECT, baser->hwreg);
> + return (readq_relaxed(baser->hwreg) & GITS_BASER_INDIRECT); 

That's a bit ugly. You're returning a mask for the indirect bit, and
treat it either as a boolean or a mask. I'd rather you return a
boolean, treat as such in most of this code, and only turn it into a
mask when you compute the GITS_BASER value.

> +}
> +
>  static int its_alloc_tables(const char *node_name, struct its_node *its)
>  {
>   u64 typer = readq_relaxed(its->base + GITS_TYPER);
> @@ -964,6 +976,7 @@ static int its_alloc_tables(const char *node_name, struct 
> its_node *its)
>   u64 entry_size = GITS_BASER_ENTRY_SIZE(val);
>   int order = get_order(psz);
>   struct its_baser *baser = its->tables + i;
> + u64 indirect = 0;

The scope of this flag is confusingly wide. Once an indirect table has
been created, all the following tables are indirect too, which is
definitely not what we want (only the device table should be
indirected).

>  
>   if (type == GITS_BASER_TYPE_NONE)
>   continue;
> @@ -977,17 +990,27 @@ static int its_alloc_tables(const char *node_name, 
> struct its_node *its)
>* Allocate as many entries as required to fit the
>* range of device IDs that the ITS can grok... The ID
>* space being incredibly sparse, this results in a
> -  * massive waste of memory.
> +  * massive waste of memory if two-level device table
> +  * feature is not supported by hardware.
>*
>* For other tables, only allocate a single page.
>*/
>   if (type == GITS_BASER_TYPE_DEVICE) {
> - /*
> -  * 'order' was initialized earlier to the default page
> -  * granule of the the ITS.  We can't have an allocation
> -  * smaller than that.  If the requested allocation
> -  * is smaller, round up to the default page granule.
> -  */
> + if ((entry_size << ids) > psz)
> + indirect = its_baser_check_indirect(baser);
> +
> + if (indirect) {
> + /*
> +  * The size of the lvl2 table is equal to ITS
> +  * page size which is 'psz'. For computing lvl1
> +  * table size, subtract ID bits that sparse
> +  * lvl2 table from 'ids' which is reported by
> +  * ITS hardware times lvl1 table entry size.
> +  */
> + ids -= ilog2(psz / entry_size);
> + entry_siz

[PATCH] sparc32: remove stale RTC_PORT definition

2016-06-04 Thread Arnd Bergmann
sparc32:allmodconfig fails to build in next-20160602 as follows.

In file included from drivers/block/floppy.c:185:0:
include/linux/mc146818rtc.h: In function 'mc146818_is_updating':
include/linux/mc146818rtc.h:138:9: error: 'rtc_port' undeclared (first use in 
this function)
include/linux/mc146818rtc.h:138:9: note: each undeclared identifier is reported 
only once for each function it appears in
include/linux/mc146818rtc.h: In function 'mc146818_get_time':
include/linux/mc146818rtc.h:172:17: error: 'rtc_port' undeclared (first use in 
this function)
include/linux/mc146818rtc.h: In function 'mc146818_set_time':
include/linux/mc146818rtc.h:278:8: error: 'rtc_port' undeclared (first use in 
this function)
scripts/Makefile.build:295: recipe for target 'drivers/block/floppy.o' failed

The reason is a duplicate definition of the RTC_PORT macro. The
one in arch/sparc/include/asm/io_32.h was apparently used a long time
ago for the drivers/char/rtc.c driver that is not available on SPARC
any more, since we now select 'RTC_CLASS' unconditionally.

Removing the macro fixes the build problem, and for consistency,
this also removes the RTC_ALWAYS_BCD macro and the comment for both.

Signed-off-by: Arnd Bergmann 
Reported-by: Guenter Roeck 
Fixes: fd09cc80165c ("rtc: cmos: move mc146818rtc code out of 
asm-generic/rtc.h")
---
I thought I'd sent this out yesterday, but cannot find an indication of
that now, and Alexandre didn't seem to get it. This should probably
go through the rtc tree that introduced the build failure after my
earlier patches

 arch/sparc/include/asm/io_32.h | 10 --
 1 file changed, 10 deletions(-)

diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 57f26c398dc9..4dd268a3a8b0 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -140,16 +140,6 @@ void ioport_unmap(void __iomem *);
 struct pci_dev;
 void pci_iounmap(struct pci_dev *dev, void __iomem *);
 
-
-
-/*
- * At the moment, we do not use CMOS_READ anywhere outside of rtc.c,
- * so rtc_port is static in it. This should not change unless a new
- * hardware pops up.
- */
-#define RTC_PORT(x)   (rtc_port + (x))
-#define RTC_ALWAYS_BCD  0
-
 static inline int sbus_can_dma_64bit(void)
 {
return 0; /* actually, sparc_cpu_model==sun4d */
-- 
2.7.0



Re: Build failure in -next due to 'rtc: cmos: move mc146818rtc code out of asm-generic/rtc.h'

2016-06-04 Thread Arnd Bergmann
On Saturday, June 4, 2016 12:16:57 AM CEST Alexandre Belloni wrote:
> 
> Arnd, do you mind sending a proper patch that I'll apply before 'rtc:
> cmos: move mc146818rtc code out of asm-generic/rtc.h'? Else, I could
> squash it in but I think the former is cleaner.
> 

I thought I had already sent id, but just in case I've done it once more now.
See "sparc32: remove stale RTC_PORT definition"

Arnd



Re: [PATCH V4 2/9] genirq: Look-up trigger type if not specified by caller

2016-06-04 Thread Marc Zyngier
On Thu, 12 May 2016 16:19:25 +0100
Jon Hunter  wrote:

> For some devices the IRQ trigger type for a device is read from
> firmware, such as device-tree. The IRQ trigger type is typically read
> when the mapping for IRQ is created, which is before the IRQ is
> requested. Hence, the IRQ trigger type is programmed when mapping the
> IRQ and not when requesting the IRQ.
> 
> Although this works for most cases, in order to support IRQ chips which
> require runtime power management, which may not be accessible prior
> to requesting the IRQ, it is desirable to look-up the IRQ trigger type
> when it is requested. Therefore, if the IRQ trigger type is not
> specified when __setup_irq() is called, look-up the saved IRQ trigger
> type. This will allow us to defer the programming of the trigger type
> from when the IRQ is mapped to when it is actually requested.
> 
> Signed-off-by: Jon Hunter 

Reviewed-by: Marc Zyngier 

M.
-- 
Jazz is not dead. It just smells funny.


REF:- INSTRUCTION TO CREDIT YOUR ACCOUNT WITH THE SUM OF (US$5Million)

2016-06-04 Thread WESMINISTER BANK PLC UK
WESMINISTER BANK PLC,
10 Southwark Street ,
London Bridge , London - UK
SE1 1TT
RC: 121878
Our Ref: NTB/WESTMIN/INTER-15
Your Ref: Affidavit: AFX 076GD7B24
Tell=+447035969549
Fax+448435643403

REF:- INSTRUCTION TO CREDIT YOUR ACCOUNT WITH THE SUM OF (US$5Million)

This is the second time we are notifying you about this said fund. After due 
vetting and evaluation of your file that
Was
sent to us by the Nigerian Government in conjunction with the Ministry
of Finance and Central Bank of the Federal Republic of Nigeria.

This bank has an instruction to see to the immediate release of the sum of 
(US$5Million) of your claim that
has been holding since is transferred into your bank Account from their 
Domiciliary Account with this bank.

We were meant to understand from our findings that you have been going through 
hard ways by
Paying a lot of charges to see to the release of your fund (US$5Million),
Which has been the handwork of some miscreant elements from that Country.

We advice that you stop further communication with any correspondence from any 
bank, or anywhere
Concerning your funds as you will receive your fund from this bank if you 
follow our instruction.

Do not go through anybody again but through this Bank if you really want your 
fund.
Finally, you are advice to re-confirm these to us,
Your Full Name,
Contact address,
Occupation
Telephone and Fax Number for easy communication.
We need your second email gmail or hotmail for security and private reasons.

Yours sincerely,
Mr Anthony M. Smith
Head Of Account Department,
WesMinister Bank, London United Kingdom.
Here is my private! Email address (michaelsm...@post.cz)


Re: [PATCH V4 3/9] irqdomain: Don't set type when mapping an IRQ

2016-06-04 Thread Marc Zyngier
On Thu, 12 May 2016 16:19:26 +0100
Jon Hunter  wrote:

> Some IRQ chips, such as GPIO controllers or secondary level interrupt
> controllers, may require require additional runtime power management
> control to ensure they are accessible. For such IRQ chips, it makes sense
> to enable the IRQ chip when interrupts are requested and disabled them
> again once all interrupts have been freed.
> 
> When mapping an IRQ, the IRQ type settings are read and then programmed.
> The mapping of the IRQ happens before the IRQ is requested and so the
> programming of the type settings occurs before the IRQ is requested. This
> is a problem for IRQ chips that require additional power management
> control because they may not be accessible yet. Therefore, when mapping
> the IRQ, don't program the type settings, just save them and then program
> these saved settings when the IRQ is requested (so long as if they are not
> overridden via the call to request the IRQ).
> 
> Add a stub function for irq_domain_free_irqs() to avoid any compilation
> errors when CONFIG_IRQ_DOMAIN_HIERARCHY is not selected.
> 
> Signed-off-by: Jon Hunter 

Reviewed-by: Marc Zyngier 

As discussed just before the 4.7 merge window, this patch is going to
uncover quite a few broken configurations (the main one being the PPI
triggers for the ARM architected timer, which seems to be wrong on a lot
of different platforms).

I'm proposing to put this patch[1] in the same queue in order to
uncover the guilty ones, but we have to be prepared for more breakage
(I've also identified kvmtool as a sinner).

Thanks,

M.
[1] https://lkml.org/lkml/2016/5/9/546
-- 
Jazz is not dead. It just smells funny.


Re: [PATCH V4 4/9] genirq: Add runtime power management support for IRQ chips

2016-06-04 Thread Marc Zyngier
On Thu, 12 May 2016 16:19:27 +0100
Jon Hunter  wrote:

> Some IRQ chips may be located in a power domain outside of the CPU
> subsystem and hence will require device specific runtime power
> management. In order to support such IRQ chips, add a pointer for a
> device structure to the irq_chip structure, and if this pointer is
> populated by the IRQ chip driver and CONFIG_PM is selected in the kernel
> configuration, then the pm_runtime_get/put APIs for this chip will be
> called when an IRQ is requested/freed, respectively.
> 
> Signed-off-by: Jon Hunter 
> Reviewed-by: Kevin Hilman 

Reviewed-by: Marc Zyngier 

M.
-- 
Jazz is not dead. It just smells funny.


Re: [PATCH V4 7/9] irqchip/gic: Prepare for adding platform driver

2016-06-04 Thread Marc Zyngier
On Thu, 12 May 2016 16:19:30 +0100
Jon Hunter  wrote:

> To support GICs that require runtime power management, it is necessary
> to add a platform driver, so that the probing of the chip can be
> deferred if resources, such as a power-domain, is not yet available.
> 
> To prepare for adding a platform driver:
>  1. Drop the __init section from the gic_dist_config() so this can be
> re-used by the platform driver.
>  2. Add prototypes for functions required by the platform driver to a
> local header file so they can be re-used.
> 
> Signed-off-by: Jon Hunter 
> ---
>  drivers/irqchip/irq-gic-common.c |  4 ++--
>  drivers/irqchip/irq-gic.c| 18 ++
>  drivers/irqchip/irq-gic.h| 28 
>  3 files changed, 40 insertions(+), 10 deletions(-)
>  create mode 100644 drivers/irqchip/irq-gic.h
> 
> diff --git a/drivers/irqchip/irq-gic-common.c 
> b/drivers/irqchip/irq-gic-common.c
> index 97c0028e8388..c510cbd264b1 100644
> --- a/drivers/irqchip/irq-gic-common.c
> +++ b/drivers/irqchip/irq-gic-common.c
> @@ -77,8 +77,8 @@ int gic_configure_irq(unsigned int irq, unsigned int type,
>   return ret;
>  }
>  
> -void __init gic_dist_config(void __iomem *base, int gic_irqs,
> - void (*sync_access)(void))
> +void gic_dist_config(void __iomem *base, int gic_irqs,
> +  void (*sync_access)(void))
>  {
>   unsigned int i;
>  
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index e043a19631b1..9f8ab124898b 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -48,6 +48,7 @@
>  #include 
>  #include 
>  
> +#include "irq-gic.h"
>  #include "irq-gic-common.h"
>  
>  #ifdef CONFIG_ARM64
> @@ -363,7 +364,7 @@ static void __exception_irq_entry gic_handle_irq(struct 
> pt_regs *regs)
>   } while (1);
>  }
>  
> -static void gic_handle_cascade_irq(struct irq_desc *desc)
> +void gic_handle_cascade_irq(struct irq_desc *desc)
>  {
>   struct gic_chip_data *chip_data = irq_desc_get_handler_data(desc);
>   struct irq_chip *chip = irq_desc_get_chip(desc);
> @@ -447,7 +448,7 @@ static void gic_cpu_if_up(struct gic_chip_data *gic)
>  }
>  
>  
> -static void __init gic_dist_init(struct gic_chip_data *gic)
> +static void gic_dist_init(struct gic_chip_data *gic)
>  {
>   unsigned int i;
>   u32 cpumask;
> @@ -532,7 +533,7 @@ int gic_cpu_if_down(unsigned int gic_nr)
>   * this function, no interrupts will be delivered by the GIC, and another
>   * platform-specific wakeup source must be enabled.
>   */
> -static void gic_dist_save(struct gic_chip_data *gic)
> +void gic_dist_save(struct gic_chip_data *gic)
>  {
>   unsigned int gic_irqs;
>   void __iomem *dist_base;
> @@ -571,7 +572,7 @@ static void gic_dist_save(struct gic_chip_data *gic)
>   * handled normally, but any edge interrupts that occured will not be seen by
>   * the GIC and need to be handled by the platform-specific wakeup source.
>   */
> -static void gic_dist_restore(struct gic_chip_data *gic)
> +void gic_dist_restore(struct gic_chip_data *gic)
>  {
>   unsigned int gic_irqs;
>   unsigned int i;
> @@ -617,7 +618,7 @@ static void gic_dist_restore(struct gic_chip_data *gic)
>   writel_relaxed(GICD_ENABLE, dist_base + GIC_DIST_CTRL);
>  }
>  
> -static void gic_cpu_save(struct gic_chip_data *gic)
> +void gic_cpu_save(struct gic_chip_data *gic)
>  {
>   int i;
>   u32 *ptr;
> @@ -647,7 +648,7 @@ static void gic_cpu_save(struct gic_chip_data *gic)
>  
>  }
>  
> -static void gic_cpu_restore(struct gic_chip_data *gic)
> +void gic_cpu_restore(struct gic_chip_data *gic)
>  {
>   int i;
>   u32 *ptr;
> @@ -724,7 +725,7 @@ static struct notifier_block gic_notifier_block = {
>   .notifier_call = gic_notifier,
>  };
>  
> -static int __init gic_pm_init(struct gic_chip_data *gic)
> +static int gic_pm_init(struct gic_chip_data *gic)
>  {
>   gic->saved_ppi_enable = __alloc_percpu(DIV_ROUND_UP(32, 32) * 4,
>   sizeof(u32));
> @@ -754,7 +755,7 @@ free_ppi_enable:
>   return -ENOMEM;
>  }
>  #else
> -static int __init gic_pm_init(struct gic_chip_data *gic)
> +static int gic_pm_init(struct gic_chip_data *gic)
>  {
>   return 0;
>  }
> @@ -1178,6 +1179,7 @@ static int __init __gic_init_bases(struct gic_chip_data 
> *gic,
>   set_smp_cross_call(gic_raise_softirq);
>   register_cpu_notifier(&gic_cpu_notifier);
>  #endif
> +
>   set_handle_irq(gic_handle_irq);
>   if (static_key_true(&supports_deactivate))
>   pr_info("GIC: Using split EOI/Deactivate mode\n");
> diff --git a/drivers/irqchip/irq-gic.h b/drivers/irqchip/irq-gic.h
> new file mode 100644
> index ..646e92614b2c
> --- /dev/null
> +++ b/drivers/irqchip/irq-gic.h
> @@ -0,0 +1,28 @@
> +/*
> + * Copyright (C) 2016 NVIDIA CORPORATION, All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or 

Re: [PATCH V4 9/9] irqchip/gic: Add platform driver for non-root GICs that require RPM

2016-06-04 Thread Marc Zyngier
On Thu, 12 May 2016 16:19:32 +0100
Jon Hunter  wrote:

> Add a platform driver to support non-root GICs that require runtime
> power-management. Currently, only non-root GICs are supported because
> the functions, smp_cross_call() and set_handle_irq(), that need to
> be called for a root controller are located in the __init section and
> so cannot be called by the platform driver.
> 
> The GIC platform driver re-uses many functions from the existing GIC
> driver including some functions to save and restore the GIC context
> during power transitions. The functions for saving and restoring the
> GIC context are currently only defined if CONFIG_CPU_PM is enabled and
> to ensure that these functions are always defined when the platform
> driver is enabled, a dependency on CONFIG_ARM_GIC_PM (which selects the
> platform driver) has been added.
> 
> In order to re-use the private GIC initialisation code, a new public
> function, of_gic_init(), has been added which calls various private
> functions to initialise the GIC.
> 
> There is no specific suspend handling for GICs registered as platform
> devices. Non-wakeup interrupts will be disabled by the kernel during
> late suspend, however, this alone will not power down the GIC if
> interrupts have been requested and not freed. Therefore, requestors of
> non-wakeup interrupts will need to free them on entering suspend in
> order to power-down the GIC.
> 
> Signed-off-by: Jon Hunter 
> ---
>  drivers/irqchip/Kconfig  |   6 ++
>  drivers/irqchip/Makefile |   1 +
>  drivers/irqchip/irq-gic-pm.c | 187 
> +++
>  drivers/irqchip/irq-gic.c|  34 +++-
>  drivers/irqchip/irq-gic.h|   2 +
>  5 files changed, 227 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/irqchip/irq-gic-pm.c
> 
> diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
> index 81f88ada3a61..68f65c84fdfd 100644
> --- a/drivers/irqchip/Kconfig
> +++ b/drivers/irqchip/Kconfig
> @@ -8,6 +8,12 @@ config ARM_GIC
>   select IRQ_DOMAIN_HIERARCHY
>   select MULTI_IRQ_HANDLER
>  
> +config ARM_GIC_PM
> + bool
> + depends on PM
> + select ARM_GIC
> + select PM_CLK
> +
>  config ARM_GIC_MAX_NR
>   int
>   default 2 if ARCH_REALVIEW
> diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
> index f828244b44c2..eab28e80cd8d 100644
> --- a/drivers/irqchip/Makefile
> +++ b/drivers/irqchip/Makefile
> @@ -24,6 +24,7 @@ obj-$(CONFIG_ARCH_SUNXI)+= irq-sun4i.o
>  obj-$(CONFIG_ARCH_SUNXI) += irq-sunxi-nmi.o
>  obj-$(CONFIG_ARCH_SPEAR3XX)  += spear-shirq.o
>  obj-$(CONFIG_ARM_GIC)+= irq-gic.o irq-gic-common.o
> +obj-$(CONFIG_ARM_GIC_PM) += irq-gic-pm.o
>  obj-$(CONFIG_REALVIEW_DT)+= irq-gic-realview.o
>  obj-$(CONFIG_ARM_GIC_V2M)+= irq-gic-v2m.o
>  obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-common.o
> diff --git a/drivers/irqchip/irq-gic-pm.c b/drivers/irqchip/irq-gic-pm.c
> new file mode 100644
> index ..a14331007bcf
> --- /dev/null
> +++ b/drivers/irqchip/irq-gic-pm.c
> @@ -0,0 +1,187 @@
> +/*
> + * Copyright (C) 2016 NVIDIA CORPORATION, All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see .
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "irq-gic.h"
> +
> +struct gic_clk_data {
> + unsigned int num_clocks;
> + const char *const *clocks;
> +};
> +
> +static int gic_runtime_resume(struct device *dev)
> +{
> + struct gic_chip_data *gic = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = pm_clk_resume(dev);
> + if (ret)
> + return ret;
> +
> + /*
> +  * On the very first resume, the pointer to the driver data
> +  * will be NULL and this is intentional, because we do not
> +  * want to restore the GIC on the very first resume. So if
> +  * the pointer is not valid just return.
> +  */
> + if (!gic)
> + return 0;
> +
> + gic_dist_restore(gic);
> + gic_cpu_restore(gic);
> +
> + return 0;
> +}
> +
> +static int gic_runtime_suspend(struct device *dev)
> +{
> + struct gic_chip_data *gic = dev_get_drvdata(dev);
> +
> + gic_dist_save(gic);
> + gic_cpu_save(gic);
> +
> + return pm_clk_suspend(dev);
> +}
> +
> +static int gic_get_clocks(struct d

Re: [PATCH] Drivers: ssb: Fix bare unsigned and changed to trailing comments

2016-06-04 Thread Julian Calaby
Hi Hugh,

On Sat, Jun 4, 2016 at 10:39 AM, Hugh Sipiere  wrote:
> I changed drivers/ssb/driver_gpio.c to better fit the coding style.
> I changed unsigned to unsigned int
> Two comments were changed to not end on a line with the text.
>
> Signed-off-by: Hugh Sipiere 

You should separate the changes into two patches, one to change
"unsigned" to "unsigned int" and one to fix the comments.

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions ***

2016-06-04 Thread Arnd Bergmann
On Friday, June 3, 2016 3:28:59 PM CEST Binoy Jayan wrote:
> 
> These are a set of patches which removes semaphores from:
> 
> drivers/staging/rtl8188eu
> 
> These are part of a bigger effort to eliminate all semaphores 
> from the linux kernel.
> 
> They build correctly (individually and as a whole).
> NB: I have not tested this as I do not have the following hardware:
> 
> "Realtek RTL8188EU Wireless LAN NIC driver"
> 
> 

The patches all look good to me. Patch three again could use some
information describing that it replaces an interruptible semaphore
with an uninterruptible mutex, fixing a bug in the process.

BTW, there is no need to list the dependencies in each patch
when posting a series, as the default assumption is that they
need to be applied in sequence.

Reviewed-by: Arnd Bergmann 


Re: [PATCH v2 7/9] ARM: bcm2835: Add devicetree for the Raspberry Pi 3.

2016-06-04 Thread Arnd Bergmann
On Friday, June 3, 2016 12:39:15 PM CEST Gerd Hoffmann wrote:
>   Hi,
> 
> > I tried
> > 
> > subdir-y += ../../../arm64/boot/dts/broadcom
> 
> Hmm, works for me too now, probably had a typo somewhere.
> 
> But it works for "make dtbs" only, "make dtbs_install" ignores it.

Right: this is no good ;-)

make -f /git/arm-soc/scripts/Makefile.dtbinst 
obj=arch/arm/boot/dts/../../../arm64/boot/dts/broadcom
  mkdir -p 
/tmp/boot//dtbs/4.7.0-rc1-00345-gd2a060ee0c24-dirty/../../../arm64/boot/dts/broadcom;
 cp arch/arm/boot/dts/../../../arm64/boot/dts/broadcom/ns2-svk.dtb 
/tmp/boot//dtbs/4.7.0-rc1-00345-gd2a060ee0c24-dirty/../../../arm64/boot/dts/broadcom

Maybe we can have a symlink there? I've tried that without success too,
but it shouldn't be that hard to get right.

Arnd


Re: [PATCH] sparc32: remove stale RTC_PORT definition

2016-06-04 Thread Alexandre Belloni
On 04/06/2016 at 11:36:44 +0200, Arnd Bergmann wrote :
> sparc32:allmodconfig fails to build in next-20160602 as follows.
> 
> In file included from drivers/block/floppy.c:185:0:
> include/linux/mc146818rtc.h: In function 'mc146818_is_updating':
> include/linux/mc146818rtc.h:138:9: error: 'rtc_port' undeclared (first use in 
> this function)
> include/linux/mc146818rtc.h:138:9: note: each undeclared identifier is 
> reported only once for each function it appears in
> include/linux/mc146818rtc.h: In function 'mc146818_get_time':
> include/linux/mc146818rtc.h:172:17: error: 'rtc_port' undeclared (first use 
> in this function)
> include/linux/mc146818rtc.h: In function 'mc146818_set_time':
> include/linux/mc146818rtc.h:278:8: error: 'rtc_port' undeclared (first use in 
> this function)
> scripts/Makefile.build:295: recipe for target 'drivers/block/floppy.o' failed
> 
> The reason is a duplicate definition of the RTC_PORT macro. The
> one in arch/sparc/include/asm/io_32.h was apparently used a long time
> ago for the drivers/char/rtc.c driver that is not available on SPARC
> any more, since we now select 'RTC_CLASS' unconditionally.
> 
> Removing the macro fixes the build problem, and for consistency,
> this also removes the RTC_ALWAYS_BCD macro and the comment for both.
> 
> Signed-off-by: Arnd Bergmann 
> Reported-by: Guenter Roeck 
> Fixes: fd09cc80165c ("rtc: cmos: move mc146818rtc code out of 
> asm-generic/rtc.h")
> ---
> I thought I'd sent this out yesterday, but cannot find an indication of
> that now, and Alexandre didn't seem to get it. This should probably
> go through the rtc tree that introduced the build failure after my
> earlier patches
> 
>  arch/sparc/include/asm/io_32.h | 10 --
>  1 file changed, 10 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


Re: [PATCH 0/10 -v3] Handle oom bypass more gracefully

2016-06-04 Thread Tetsuo Handa
Michal Hocko wrote:
> On Fri 03-06-16 14:20:30, Michal Hocko wrote:
> [...]
> > Do no take me wrong but I would rather make sure that the current pile
> > is reviewed and no unintentional side effects are introduced than open
> > yet another can of worms.
> 
> And just to add. You have found many buugs in the previous versions of
> the patch series so I would really appreciate your Acked-by or
> Reviewed-by if you feel confortable with those changes or express your
> concerns.
> 
> Thanks!

I think we can send

"[PATCH 01/10] proc, oom: drop bogus task_lock and mm check",
"[PATCH 02/10] proc, oom: drop bogus sighand lock",
"[PATCH 03/10] proc, oom_adj: extract oom_score_adj setting into a helper"
(with
int err = 0;
 
task = get_proc_task(file_inode(file));
-   if (!task) {
-   err = -ESRCH;
-   goto out;
-   }
+   if (!task)
+   return -ESRCH;
 
mutex_lock(&oom_adj_mutex);
if (legacy) {

part from "[PATCH 04/10] mm, oom_adj: make sure processes sharing mm have same 
view of oom_score_adj"
folded into "[PATCH 03/10]"),
"[PATCH 08/10] mm, oom: task_will_free_mem should skip oom_reaped tasks" and
"[RFC PATCH 09/10] mm, oom_reaper: do not attempt to reap a task more than 
twice"

to linux-next, for these patches do not involve user visible changes.

Regarding "[PATCH 04/10] mm, oom_adj: make sure processes sharing mm have same 
view of oom_score_adj"
"[PATCH 05/10] mm, oom: skip vforked tasks from being selected" and
"[PATCH 06/10] mm, oom: kill all tasks sharing the mm", I don't want to
involve user visible changes without get-acquainted period, for

  An alternative would be to keep the task alive and skip the oom reaper and
  risk all the weird corner cases where the OOM killer cannot make forward
  progress because the oom victim hung somewhere on the way to exit.

can be avoided by introducing a simple timer (or do equivalent thing using
the OOM reaper by always waking up the OOM reaper).

If we introduce a simple timer (or do equivalent thing using the OOM reaper
by always waking up the OOM reaper), we can remove the "can_oom_reap" variable
in oom_kill_process() and threfore "[RFC PATCH 10/10] mm, oom: hide mm which
is shared with kthread or global init" will become unneeded.

"[PATCH 07/10] mm, oom: fortify task_will_free_mem" will be decided after
we guaranteed forward progress of the most subtle and unlikely situation
which I think we cannot help depending on either timer or the OOM reaper.


Re: [PATCH v1] KVM: VMX: enable guest access to LMCE related MSRs

2016-06-04 Thread Boris Petkov
Haozhong Zhang  wrote:

>On Intel platforms, this patch adds LMCE to KVM MCE supported
>capabilities and handles guest access to LMCE related MSRs.
>
>Signed-off-by: Ashok Raj 
>Signed-off-by: Haozhong Zhang 

SOB chain needs correction wrt who the author is and who the submitter. 


-- 
Sent from a small device: formatting sux and brevity is inevitable. 


Re: [PATCH] libnvdimm, nfit: treat volatile virtual CD region as read-only pmem

2016-06-04 Thread joeyli
Hi Dan, 

Thanks for your review.

On Fri, Jun 03, 2016 at 12:27:34PM -0700, Dan Williams wrote:
> On Fri, Jun 3, 2016 at 12:13 AM, Lee, Chun-Yi  wrote:
> > This patch adds codes to treat a volatile virtual CD region as a
> > read-only pmem region, then read-only /dev/pmem* device can be mounted
> > with iso9660.
> >
> > It's useful to work with the httpboot in EFI firmware to pull a remote
> > ISO file to the local memory region for booting and installation.
> >
> > Wiki page of UEFI HTTPBoot with OVMF:
> > https://en.opensuse.org/UEFI_HTTPBoot_with_OVMF
> >
> > Signed-off-by: Lee, Chun-Yi 
> > Cc: Gary Lin 
> > Cc: Dan Williams 
> > Cc: Ross Zwisler 
> > Cc: "Rafael J. Wysocki" 
> > ---
> >  drivers/acpi/nfit.c  |  8 +++-
> >  drivers/nvdimm/region_devs.c | 26 +-
> >  include/linux/libnvdimm.h|  2 ++
> >  3 files changed, 34 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
> > index 2215fc8..b100a17 100644
> > --- a/drivers/acpi/nfit.c
> > +++ b/drivers/acpi/nfit.c
> > @@ -1949,6 +1949,7 @@ static int acpi_nfit_init_mapping(struct 
> > acpi_nfit_desc *acpi_desc,
> > switch (nfit_spa_type(spa)) {
> > case NFIT_SPA_PM:
> > case NFIT_SPA_VOLATILE:
> > +   case NFIT_SPA_VCD:
> > nd_mapping->start = memdev->address;
> > nd_mapping->size = memdev->region_size;
> > break;
> 
> Why do we need to distinguish NFIT_SPA_VOLATILE vs NFIT_SPA_VCD, i.e.
> what happens if something writes to a VCD device?

Actually I didn't try to write SPA-VCD device before. Every time I mount it
that the system responses read-only:

# mount /dev/pmem0 /mnt/
mount: /dev/pmem0 is write-protected, mounting read-only

If it can be written, then I think there have no difference between
NFIT_SPA_VOLATILE with NFIT_SPA_VCD region.

I implemented this patch to treat VCD region as read-only pmem because the
pmem region generates /dev/pmem* device that it can be mounted.

Maybe I missed. Does NFIT_SPA_VOLATILE region also generate a device in /dev
that it can be mounted with filesystem? Then I think treat the VCD region as
a read-only VOLATILE region that's also a solution.


Thanks a lot!
Joey Lee


Re: [PATCH][RT] netpoll: Always take poll_lock when doing polling

2016-06-04 Thread Steven Rostedt
On Thu, 2 Jun 2016 18:12:35 +0200
Sebastian Andrzej Siewior  wrote:

> * Steven Rostedt | 2016-05-26 19:56:41 [-0400]:
> 
> >[ Alison, can you try this patch ]
> 
> Alison, did you try it?
> 
> Sebastian

This patch may help too...

-- Steve

>From 729e35706b8352d83692764adbeca429bb26ba7f Mon Sep 17 00:00:00 2001
From: Steven Rostedt 
Date: Tue, 5 Jan 2016 14:53:09 -0500
Subject: [PATCH] softirq: Perform softirqs in local_bh_enable() for a limited
 amount of time

To prevent starvation of tasks like ksoftirqd, if the task that is
processing its softirqs takes more than 2 jiffies to do so, and the
softirqs are constantly being re-added, then defer the processing to
ksoftirqd.

Signed-off-by: Steven Rostedt 
Signed-off-by: Luis Claudio R. Goncalves 
---
 kernel/softirq.c |   53 ++---
 1 file changed, 34 insertions(+), 19 deletions(-)

Index: linux-rt.git/kernel/softirq.c
===
--- linux-rt.git.orig/kernel/softirq.c  2016-06-04 07:01:54.584296827 -0400
+++ linux-rt.git/kernel/softirq.c   2016-06-04 07:06:35.449913451 -0400
@@ -206,6 +206,22 @@ static void handle_softirq(unsigned int
}
 }
 
+/*
+ * We restart softirq processing for at most MAX_SOFTIRQ_RESTART times,
+ * but break the loop if need_resched() is set or after 2 ms.
+ * The MAX_SOFTIRQ_TIME provides a nice upper bound in most cases, but in
+ * certain cases, such as stop_machine(), jiffies may cease to
+ * increment and so we need the MAX_SOFTIRQ_RESTART limit as
+ * well to make sure we eventually return from this method.
+ *
+ * These limits have been established via experimentation.
+ * The two things to balance is latency against fairness -
+ * we want to handle softirqs as soon as possible, but they
+ * should not be able to lock up the box.
+ */
+#define MAX_SOFTIRQ_TIME  msecs_to_jiffies(2)
+#define MAX_SOFTIRQ_RESTART 10
+
 #ifndef CONFIG_PREEMPT_RT_FULL
 static inline int ksoftirqd_softirq_pending(void)
 {
@@ -349,22 +365,6 @@ void __local_bh_enable_ip(unsigned long
 }
 EXPORT_SYMBOL(__local_bh_enable_ip);
 
-/*
- * We restart softirq processing for at most MAX_SOFTIRQ_RESTART times,
- * but break the loop if need_resched() is set or after 2 ms.
- * The MAX_SOFTIRQ_TIME provides a nice upper bound in most cases, but in
- * certain cases, such as stop_machine(), jiffies may cease to
- * increment and so we need the MAX_SOFTIRQ_RESTART limit as
- * well to make sure we eventually return from this method.
- *
- * These limits have been established via experimentation.
- * The two things to balance is latency against fairness -
- * we want to handle softirqs as soon as possible, but they
- * should not be able to lock up the box.
- */
-#define MAX_SOFTIRQ_TIME  msecs_to_jiffies(2)
-#define MAX_SOFTIRQ_RESTART 10
-
 #ifdef CONFIG_TRACE_IRQFLAGS
 /*
  * When we run softirqs from irq_exit() and thus on the hardirq stack we need
@@ -537,11 +537,17 @@ static void do_single_softirq(int which)
  */
 static void do_current_softirqs(void)
 {
-   while (current->softirqs_raised) {
-   int i = __ffs(current->softirqs_raised);
+   unsigned long end = jiffies + MAX_SOFTIRQ_TIME;
+   unsigned int softirqs_raised = current->softirqs_raised;
+
+restart:
+   current->softirqs_raised &= ~softirqs_raised;
+
+   while (softirqs_raised) {
+   int i = __ffs(softirqs_raised);
unsigned int pending, mask = (1U << i);
 
-   current->softirqs_raised &= ~mask;
+   softirqs_raised &= ~mask;
local_irq_enable();
 
/*
@@ -568,6 +574,15 @@ static void do_current_softirqs(void)
unlock_softirq(i);
local_irq_disable();
}
+
+   softirqs_raised = current->softirqs_raised;
+   if (softirqs_raised) {
+   if (time_before(jiffies, end))
+   goto restart;
+
+   __this_cpu_read(ksoftirqd)->softirqs_raised |= softirqs_raised;
+   wakeup_softirqd();
+   }
 }
 
 void __local_bh_disable(void)


Re: [PATCH v2 2/4] gpio: Allow PC/104 devices on X86_64

2016-06-04 Thread William Breathitt Gray
On Sat, Jun 04, 2016 at 09:14:08AM +0200, Pavel Machek wrote:
>On Fri 2016-06-03 17:12:44, William Breathitt Gray wrote:
>> On Fri, Jun 03, 2016 at 10:57:03PM +0200, Pavel Machek wrote:
>> >Should we do "depends on PC104" here, because that is what it really
>> >means, and have PC104 enabled when ISA_BUS_API is enabled or something
>> >like that?
>> 
>> Since the functionality remains the same, I'm a bit indifferent to that
>> change; as long as the driver builds for systems in which it's intended
>> to be used, I'm satisfied.
>> 
>> Differentiating between PC/104 and ISA may be a pointless endeavor
>> though since both buses appear the same to software. But if it is better
>> to differentiate between devices as such, then I see little harm in
>> adding a PC104 Kconfig option which follows the ISA_BUS_API Kconfig
>> option.
>
>Well, they are same to the software, but not at the hardware. If I
>have a development board that has PC104 (but not isa), I'd like to see
>prompts for PC104 extensions, not for isa. If PC105 comes out, still
>ISA compatible, I will want to see prompts for PC104 boards or PC105
>boards, but not neccessarily both...

I think I see the merit of a prompt for PC104 devices. I've encountered
a use case recently which I'm curious about in this scenario. Given the
compatibility with ISA, manufacturers may occasionally develop variants
of existing ISA devices by duplicating the firmware on a PC/104 form
factor.

I'm working on an IIO DAC driver for the Measurement Computing CIO-DAC
family (CIO-DAC08, CIO-DAC16, and PC104-DAC06); while not a GPIO driver,
I believe it can serve as a decent example. Interestingly, while the
CIO-DAC08 and CIO-DAC16 are true ISA devices, the PC104-DAC06 is a
PC/104 variant compatible with the others in the family. The IIO DAC
driver works just as well with the PC104-DAC06, as it does with the true
ISA devices in the family.

What would the Kconfig depends line look in this scenario? I imagine
simply "depends on PC104" would be inappropriate since there are a
number of true ISA devices supported by the driver, but "depends on
ISA_BUS_API || PC104" seems somewhat redundant when the PC104 Kconfig
option implies ISA_BUS_API. This situation isn't that much of an issue
overall, but I anticipate encountering it occassionally as I develop
future PC/104 drivers.

William Breathitt Gray


Re: [PATCH V5 1/7] ARM64, ACPI, PCI: I/O Remapping Table (IORT) initial support.

2016-06-04 Thread Marc Zyngier
On Tue, 31 May 2016 13:19:38 +0200
Tomasz Nowicki  wrote:

> IORT shows representation of IO topology for ARM based systems.
> It describes how various components are connected together on
> parent-child basis e.g. PCI RC -> SMMU -> ITS. Also see IORT spec.
> 
> Initial support allows to:
> - register ITS MSI chip along with ITS translation ID and domain token
> - deregister ITS MSI chip based on ITS translation ID
> - find registered domain token based on ITS translation ID
> - map MSI RID based on PCI device and requester ID
> - find domain token based on PCI device and requester ID
> 
> Signed-off-by: Tomasz Nowicki 
> ---
>  drivers/acpi/Kconfig  |   3 +
>  drivers/acpi/Makefile |   1 +
>  drivers/acpi/iort.c   | 344 
> ++
>  include/linux/iort.h  |  38 ++
>  4 files changed, 386 insertions(+)
>  create mode 100644 drivers/acpi/iort.c
>  create mode 100644 include/linux/iort.h
> 
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index b7e2e77..848471f 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -57,6 +57,9 @@ config ACPI_SYSTEM_POWER_STATES_SUPPORT
>  config ACPI_CCA_REQUIRED
>   bool
>  
> +config IORT_TABLE
> + bool
> +
>  config ACPI_DEBUGGER
>   bool "AML debugger interface"
>   select ACPI_DEBUG
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 251ce85..c7c9b29 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -82,6 +82,7 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
>  obj-$(CONFIG_ACPI_BGRT)  += bgrt.o
>  obj-$(CONFIG_ACPI_CPPC_LIB)  += cppc_acpi.o
>  obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o
> +obj-$(CONFIG_IORT_TABLE) += iort.o
>  
>  # processor has its own "processor." module_param namespace
>  processor-y  := processor_driver.o
> diff --git a/drivers/acpi/iort.c b/drivers/acpi/iort.c
> new file mode 100644
> index 000..226eb6d
> --- /dev/null
> +++ b/drivers/acpi/iort.c
> @@ -0,0 +1,344 @@
> +/*
> + * Copyright (C) 2016, Semihalf
> + *   Author: Tomasz Nowicki 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * This file implements early detection/parsing of I/O mapping
> + * reported to OS through firmware via I/O Remapping Table (IORT)
> + * IORT document number: ARM DEN 0049A
> + */
> +
> +#define pr_fmt(fmt)  "ACPI: IORT: " fmt
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct iort_its_msi_chip {
> + struct list_headlist;
> + struct fwnode_handle*fw_node;
> + u32 translation_id;
> +};
> +
> +typedef acpi_status (*iort_find_node_callback)
> + (struct acpi_iort_node *node, void *context);
> +
> +/* Root pointer to the mapped IORT table */
> +static struct acpi_table_header *iort_table;
> +
> +static LIST_HEAD(iort_msi_chip_list);
> +
> +/**
> + * iort_register_domain_token() - register domain token and related ITS ID
> + * to the list from where we can get it back
> + * later on.
> + * @translation_id: ITS ID
> + * @token: domain token
> + *
> + * Returns: 0 on success, -ENOMEM if not memory when allocating list element.
> + */
> +int iort_register_domain_token(int trans_id, struct fwnode_handle *fw_node)
> +{
> + struct iort_its_msi_chip *its_msi_chip;
> +
> + its_msi_chip = kzalloc(sizeof(*its_msi_chip), GFP_KERNEL);
> + if (!its_msi_chip)
> + return -ENOMEM;
> +
> + its_msi_chip->fw_node = fw_node;
> + its_msi_chip->translation_id = trans_id;
> +
> + list_add(&its_msi_chip->list, &iort_msi_chip_list);

No locking? How do you handle concurrent accesses?

> + return 0;
> +}
> +
> +/**
> + * iort_unregister_domain_token() - unregister domain token based on ITS ID.
> + * @translation_id: ITS ID
> + *
> + * Returns: none.
> + */
> +void iort_deregister_domain_token(int trans_id)
> +{
> + struct iort_its_msi_chip *its_msi_chip, *t;
> +
> + list_for_each_entry_safe(its_msi_chip, t, &iort_msi_chip_list, list) {
> + if (its_msi_chip->translation_id == trans_id) {
> + list_del(&its_msi_chip->list);
> + kfree(its_msi_chip);
> + break;
> + }
> + }
> +}

Same here.

> +
> +/**
> + * iort_find_its_domain_token() - find domain token based on given ITS ID.
> + * @translation_id: ITS ID
> + *
> + * Returns: domain token when find on the list, NULL otherwise.
> + */
> +struct fwnode_handle *iort_its_find_domain_to

[PATCH] drivers: ssb: Fix comments to suit coding style

2016-06-04 Thread Hugh Sipière
I changed it so that these two comments do not end on a line with text.

Signed-off-by: Hugh Sipière 
---
 drivers/ssb/driver_gpio.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/ssb/driver_gpio.c b/drivers/ssb/driver_gpio.c
index 180e027..f2435f3 100644
--- a/drivers/ssb/driver_gpio.c
+++ b/drivers/ssb/driver_gpio.c
@@ -231,7 +231,8 @@ static int ssb_gpio_chipco_init(struct ssb_bus *bus)
chip->ngpio = 16;
/* There is just one SoC in one device and its GPIO addresses should be
 * deterministic to address them more easily. The other buses could get
-* a random base number. */
+* a random base number.
+*/
if (bus->bustype == SSB_BUSTYPE_SSB)
chip->base  = 0;
else
@@ -424,7 +425,8 @@ static int ssb_gpio_extif_init(struct ssb_bus *bus)
chip->ngpio = 5;
/* There is just one SoC in one device and its GPIO addresses should be
 * deterministic to address them more easily. The other buses could get
-* a random base number. */
+* a random base number.
+*/
if (bus->bustype == SSB_BUSTYPE_SSB)
chip->base  = 0;
else
-- 
2.5.5



Re: Patch for CVE-2016-0774 missing from stable 3.4 and 3.10 kernels

2016-06-04 Thread Willy Tarreau
Hi,

On Mon, Mar 28, 2016 at 04:53:48PM -0700, Jeffrey Vander Stoep wrote:
> https://lkml.org/lkml/2016/2/23/812 "pipe: Fix buffer offset after
> partially failed read" is missing from the stable 3.4.y and 3.10.y
> kernels. It has been included in 3.2.y and 3.14.y.
> 
> I am able to cause a kernel panic without this patch.

Just a heads up on this one, it is *not* included in 3.14 as of 3.14.71.
It's in 3.2 and 3.4 however. Greg, you can pick commit feae3ca2e5e1a
from kernel 3.2, it will apply with an offset.

Regards,
Willy


Re: [PATCH 21/23] arm64: ilp32: introduce ilp32-specific handlers for sigframe and ucontext

2016-06-04 Thread Zhangjian (Bamvor)

Hi,

I found an issue of unwind with the following code. The correct backtrace
should be:
(gdb) where
#0 0x004004d0 in my_sig (sig=11) at test_force3.c:16
#1 
#2 func2 (num=0) at test_force3.c:22
#3 0x00400540 in func1 (num=1) at test_force3.c:28
#4 0x00400574 in main (argc=1, argv=0xffd7bc04) at test_force3.c:33

Without my patch, the backtrace is:
(gdb) where
#0 0x00400490 in my_sig (sig=11) at test_force3.c:16
#1 
#2 0x004004e4 in main (argc=1, argv=0xffe6f8f4) at test_force3.c:33

With my patch which fix the wrong frame pointer(setup_return calculate the 
offset
of fp through ilp32_sigframe instead of sigfreame), the backtrace is:
(gdb) where
#0 0x00400490 in my_sig (sig=11) at test_force3.c:16
#1 
#2 func1 () at test_force3.c:28
#3 0x004004e4 in main (argc=1, argv=0xffe6f8f4) at test_force3.c:33

I am not sure there is still some issue in kernel. But it seem that the gdb of 
ilp32
does not work correctly when unwind without framepointer.

The test code is:

#include 
#include 
#include 
#include 

void my_sig(int sig)
{
printf("sig=%d\n", sig);
*(int *)0 = 0x0;
}


void func2()
{
*(int *)0 = 0x0;
}

void func1()
{
func2();
}

int main(int argc, char **argv)
{
signal(11, my_sig);
func1();
return 0;
}


The full patch is as follows:

From 7e364a765097f57aed2d73f94c1688c2e7343e79 Mon Sep 17 00:00:00 2001
From: Bamvor Jian Zhang 
Date: Sat, 4 Jun 2016 14:30:05 +0800
Subject: [PATCH] arm64: ilp32: fix for wrong fp offset when calculate the
 new fp

ILP32 define its own sigframe(ilp32_sigframe) because of the
difference uc_context. setup_return do not use ilp32 specific
sigframe to calculate the new offset of fp which lead to wrong
fp in signal handler. At this circumstance, gdb backtrace will miss
one item:
(gdb) where

It should be:
(gdb) where

The test code is as follows:

void my_sig(int sig)
{
printf("sig=%d\n", sig);
*(int *)0 = 0x0;
}

void func2(int num)
{
printf("%s: %d\n", __FUNCTION__, num);
*(int *)0 = 0x0;
func2(num-1);
}

void func1(int num)
{
printf("%s\n", __FUNCTION__);
func2(num - 1);
}

int main(int argc, char **argv)
{
signal(11, my_sig);
func1(argc);
return 0;
}

This patch fix this by passing the correct offset of fp to
setup_return.
Test pass on both ILP32 and LP64 in aarch64 EE.

Signed-off-by: Bamvor Jian Zhang 
---
 arch/arm64/include/asm/signal_common.h | 3 ++-
 arch/arm64/kernel/signal.c | 9 +
 arch/arm64/kernel/signal_ilp32.c   | 4 ++--
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/include/asm/signal_common.h 
b/arch/arm64/include/asm/signal_common.h
index de93c71..a5d7b63 100644
--- a/arch/arm64/include/asm/signal_common.h
+++ b/arch/arm64/include/asm/signal_common.h
@@ -29,6 +29,7 @@ int setup_sigcontex(struct sigcontext __user *uc_mcontext,
struct pt_regs *regs);
 int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sf);
 void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
-   void __user *frame, off_t sigframe_off, int usig);
+   void __user *frame, off_t sigframe_off, off_t fp_off,
+   int usig);

 #endif /* __ASM_SIGNAL_COMMON_H */
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 038bebe..e66a6e9 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -256,14 +256,14 @@ static struct rt_sigframe __user *get_sigframe(struct 
ksignal *ksig,
 }

 void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
-void __user *frame, off_t sigframe_off, int usig)
+void __user *frame, off_t sigframe_off, off_t fp_off,
+int usig)
 {
__sigrestore_t sigtramp;

regs->regs[0] = usig;
regs->sp = (unsigned long)frame;
-   regs->regs[29] = regs->sp + sigframe_off +
-   offsetof(struct sigframe, fp);
+   regs->regs[29] = regs->sp + sigframe_off + fp_off;
regs->pc = (unsigned long)ka->sa.sa_handler;

if (ka->sa.sa_flags & SA_RESTORER)
@@ -294,7 +294,8 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, 
sigset_t *set,
err |= setup_sigframe(&frame->sig, regs, set);
if (err == 0) {
setup_return(regs, &ksig->ka, frame,
-   offsetof(struct rt_sigframe, sig), usig);
+   offsetof(struct rt_sigframe, sig),
+   offsetof(struct sigframe, fp), usig);
if (ksig->ka.sa.sa_flags & SA_SIGINFO) {
err |= copy_siginfo_to_user(&frame->info, &ksig->info);
regs->regs[1] = (unsigned long)&frame->info;
diff --git a/arch/arm64/kernel/signal_ilp32.c b/arch/arm64/kernel/signal_ilp32.c
index a8ea73e..9030f14 100644
--- a/arch/arm64/kernel/signal_ilp32.c
+++ b/arch/arm64/kernel/signal_i

[PATCH v2 01/38] kernel-doc/rst: fix use of uninitialized value

2016-06-04 Thread Jani Nikula
I'm not quite sure why the errors below are happening, but this fixes
them.

Use of uninitialized value in string ne at ./scripts/kernel-doc line 1819,  
line 6494.
Use of uninitialized value $_[0] in join or string at ./scripts/kernel-doc line 
1759,  line 6494.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 2fc8fad5195e..babb374c043d 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1803,7 +1803,8 @@ sub output_function_rst(%) {
} else {
print "  ``$parameter``\n";
}
-   if ($args{'parameterdescs'}{$parameter_name} ne $undescribed) {
+   if (defined($args{'parameterdescs'}{$parameter_name}) &&
+   $args{'parameterdescs'}{$parameter_name} ne $undescribed) {
my $oldprefix = $lineprefix;
$lineprefix = "";
output_highlight_rst($args{'parameterdescs'}{$parameter_name});
-- 
2.1.4



[PATCH v2 00/38] Documentation/sphinx

2016-06-04 Thread Jani Nikula
Jon, this is v2 of [1] and [2], with a considerable amount of polish and
fixes added. We started dogfooding this within drm-intel, and Daniel has
reviewed the lot and contributed a number of fixes, most notably
accurate file and line number references from Sphinx build
errors/warnings to the kernel-doc comments in source code.

We believe this is now in good shape for merging for v4.8. It's all in
my sphinx-for-docs-next branch that you've already looked at; pull
details below.

When this lands in docs-next and we can backmerge to drm, we'll plunge
ahead and convert gpu.tmpl to rst, and have that ready for v4.8. We
think it's best to contribute that via the drm tree, as it'll involve
splitting up the documentation and likely numerous updates to kernel-doc
comments.

I plan to update Documentation/kernel-doc-nano-HOWTO.txt for Sphinx and
rst, obviously converting it to rst while at it.

BR,
Jani.



[1] http://mid.gmane.org/cover.1463748027.git.jani.nik...@intel.com
[2] http://mid.gmane.org/877fec7gfm@intel.com

The following changes since commit 1a695a905c18548062509178b98bc91e67510864:

  Linux 4.7-rc1 (2016-05-29 09:29:24 -0700)

are available in the git repository at:

  git://people.freedesktop.org/~jani/drm sphinx-for-docs-next

for you to fetch changes up to d90368f2fa7ded7c56d214aef087e88bba5199e7:

  doc/sphinx: Track line-number of starting blocks (2016-06-04 11:35:59 +0300)


Daniel Vetter (6):
  doc/sphinx: Pass right filename as source
  scripts/kernel-doc: Remove duplicated DOC: start handling
  doc/sphinx: Stop touching state_machine internals
  scripts/kernel-doc: Also give functions symbolic names
  scripts/kernel-doc: Add option to inject line numbers
  doc/sphinx: Track line-number of starting blocks

Jani Nikula (31):
  kernel-doc/rst: fix use of uninitialized value
  kernel-doc: support printing exported and non-exported symbols
  Documentation/sphinx: add basic working Sphinx configuration and build
  Documentation: add .gitignore
  Documentation/sphinx: add Sphinx kernel-doc directive extension
  Documentation/sphinx: configure the kernel-doc extension
  Documentation/sphinx: set version and release properly
  sphinx: update docbook->rst conversion script match C domain spec
  Documentation/sphinx: nicer referencing of struct in docbook->rst 
conversion
  kernel-doc: add names for states and substates
  kernel-doc: add names for output selection
  kernel-doc/rst: do not output DOC: section titles for requested ones
  kernel-doc/rst: reference functions according to C domain spec
  kernel-doc/rst: &foo references are more universal than structs
  kernel-doc/rst: add support for &union foo and &typedef foo references
  kernel-doc/rst: add support for struct/union/enum member references
  kernel-doc/rst: drop redundant unescape in highlighting
  kernel-doc/rst: highlight function/struct/enum purpose lines too
  kernel-doc: do not regard $, %, or & prefixes as special in section names
  kernel-doc: fix wrong code indentation
  kernel-doc/rst: blank lines in output are not needed
  kernel-doc: strip leading blank lines from inline doc comments
  kernel-doc/rst: change the output layout
  kernel-doc: improve handling of whitespace on the first line param 
description
  kernel-doc: strip leading whitespace from continued param descs
  kernel-doc/rst: use *undescribed* instead of _undescribed_
  kernel-doc/rst: remove fixme comment
  kernel-doc: limit the "section header:" detection to a select few
  kernel-doc: concatenate contents of colliding sections
  kernel-doc: reset contents and section harder
  Documentation/sphinx: fix kernel-doc extension on python3

Jonathan Corbet (1):
  sphinx: cheesy script to convert .tmpl files

 Documentation/.gitignore  |   1 +
 Documentation/DocBook/Makefile|   7 +-
 Documentation/Makefile.sphinx |  63 +
 Documentation/conf.py | 414 ++
 Documentation/index.rst   |  23 ++
 Documentation/sphinx/convert_template.sed |  18 ++
 Documentation/sphinx/kernel-doc.py| 127 +
 Documentation/sphinx/post_convert.sed |  23 ++
 Documentation/sphinx/tmplcvt  |  19 ++
 Makefile  |   5 +-
 scripts/kernel-doc| 392 ++--
 11 files changed, 948 insertions(+), 144 deletions(-)
 create mode 100644 Documentation/.gitignore
 create mode 100644 Documentation/Makefile.sphinx
 create mode 100644 Documentation/conf.py
 create mode 100644 Documentation/index.rst
 create mode 100644 Documentation/sphinx/convert_template.sed
 create mode 100644 Documentation/sphinx/kernel-doc.py
 create mode 100644 Documentation/sphinx/post_convert.sed
 create mode 100755 Do

[PATCH v2 02/38] kernel-doc: support printing exported and non-exported symbols

2016-06-04 Thread Jani Nikula
Currently we use docproc to figure out which symbols are exported, and
then docproc calls kernel-doc on specific functions, to get
documentation on exported functions. According to git blame and docproc
comments, this is due to historical reasons, as functions and their
corresponding EXPORT_SYMBOL* may have been in different files. However
for more than ten years the recommendation in CodingStyle has been to
place the EXPORT_SYMBOL* immediately after the closing function brace
line.

Additionally, the kernel-doc comments for functions are generally placed
above the function definition in the .c files (i.e. where the
EXPORT_SYMBOL* is) rather than above the declaration in the .h
files. There are some exceptions to this, but AFAICT none of these are
included in DocBook documentation using the "!E" docproc directive.

Therefore, assuming the EXPORT_SYMBOL* and kernel-doc are with the
function definition, kernel-doc can extract the exported vs. not
information by making two passes on the input file. Add support for that
via the new -export and -internal parameters.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index babb374c043d..3ad54abe0989 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -59,6 +59,12 @@ Output format selection (mutually exclusive):
   -textOutput plain text format.
 
 Output selection (mutually exclusive):
+  -export  Only output documentation for symbols that have been
+   exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL()
+   in the same FILE.
+  -internalOnly output documentation for symbols that have NOT been
+   exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL()
+   in the same FILE.
   -function NAME   Only output documentation for the given function(s)
or DOC: section title(s). All other functions and DOC:
sections are ignored. May be specified multiple times.
@@ -380,6 +386,7 @@ my $doc_block = $doc_com . 'DOC:\s*(.*)?';
 my $doc_split_start = '^\s*/\*\*\s*$';
 my $doc_split_sect = '\s*\*\s*(@[\w\s]+):(.*)';
 my $doc_split_end = '^\s*\*/\s*$';
+my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;';
 
 my %constants;
 my %parameterdescs;
@@ -444,6 +451,12 @@ while ($ARGV[0] =~ m/^-(.*)/) {
$function_only = 2;
$function = shift @ARGV;
$function_table{$function} = 1;
+} elsif ($cmd eq "-export") { # only exported symbols
+   $function_only = 3;
+   %function_table = ()
+} elsif ($cmd eq "-internal") { # only non-exported symbols
+   $function_only = 4;
+   %function_table = ()
 } elsif ($cmd eq "-v") {
$verbose = 1;
 } elsif (($cmd eq "-h") || ($cmd eq "--help")) {
@@ -1971,8 +1984,10 @@ sub output_declaration {
 my $functype = shift;
 my $func = "output_${functype}_$output_mode";
 if (($function_only==0) ||
-   ( $function_only == 1 && defined($function_table{$name})) ||
-   ( $function_only == 2 && !($functype eq "function" && 
defined($function_table{$name}
+   ( ($function_only == 1 || $function_only == 3) &&
+ defined($function_table{$name})) ||
+   ( ($function_only == 2 || $function_only == 4) &&
+ !($functype eq "function" && defined($function_table{$name}
 {
&$func(@_);
$section_counter++;
@@ -2675,6 +2690,16 @@ sub process_file($) {
return;
 }
 
+# two passes for -export and -internal
+if ($function_only == 3 || $function_only == 4) {
+   while () {
+   if (/$export_symbol/o) {
+   $function_table{$2} = 1;
+   }
+   }
+   seek(IN, 0, 0);
+}
+
 $. = 1;
 
 $section_counter = 0;
-- 
2.1.4



[PATCH v2 14/38] kernel-doc/rst: reference functions according to C domain spec

2016-06-04 Thread Jani Nikula
The Sphinx C domain spec says function references should include the
parens ().

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 659d529b99d8..e8651d7cf1cd 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -280,7 +280,7 @@ my $blankline_text = "";
 # rst-mode
 my @highlights_rst = (
[$type_constant, "``\$1``"],
-   [$type_func, "\\:c\\:func\\:`\$1`"],
+   [$type_func, "\\:c\\:func\\:`\$1()`"],
[$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
[$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
[$type_struct, "\\:c\\:type\\:`struct \$1 <\$1>`"],
-- 
2.1.4



[PATCH v2 11/38] kernel-doc: add names for states and substates

2016-06-04 Thread Jani Nikula
Make the state machine a bit more readable by adding constants for
parser states and inline member documentation parser substates. While at
it, rename the "split" documentation to "inline" documentation.

No functional changes.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 91 --
 1 file changed, 48 insertions(+), 43 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 3ad54abe0989..cb5fd248ac57 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -350,24 +350,29 @@ my $section_counter = 0;
 
 my $lineprefix="";
 
-# states
-# 0 - normal code
-# 1 - looking for function name
-# 2 - scanning field start.
-# 3 - scanning prototype.
-# 4 - documentation block
-# 5 - gathering documentation outside main block
+# Parser states
+use constant {
+STATE_NORMAL=> 0, # normal code
+STATE_NAME  => 1, # looking for function name
+STATE_FIELD => 2, # scanning field start
+STATE_PROTO => 3, # scanning prototype
+STATE_DOCBLOCK  => 4, # documentation block
+STATE_INLINE=> 5, # gathering documentation outside main block
+};
 my $state;
 my $in_doc_sect;
 
-# Split Doc State
-# 0 - Invalid (Before start or after finish)
-# 1 - Is started (the /** was found inside a struct)
-# 2 - The @parameter header was found, start accepting multi paragraph text.
-# 3 - Finished (the */ was found)
-# 4 - Error - Comment without header was found. Spit a warning as it's not
-# proper kernel-doc and ignore the rest.
-my $split_doc_state;
+# Inline documentation state
+use constant {
+STATE_INLINE_NA => 0, # not applicable ($state != STATE_INLINE)
+STATE_INLINE_NAME   => 1, # looking for member name (@foo:)
+STATE_INLINE_TEXT   => 2, # looking for member documentation
+STATE_INLINE_END=> 3, # done
+STATE_INLINE_ERROR  => 4, # error - Comment without header was found.
+  # Spit a warning as it's not
+  # proper kernel-doc and ignore the rest.
+};
+my $inline_doc_state;
 
 #declaration types: can be
 # 'function', 'struct', 'union', 'enum', 'typedef'
@@ -383,9 +388,9 @@ my $doc_decl = $doc_com . '(\w+)';
 my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)';
 my $doc_content = $doc_com_body . '(.*)';
 my $doc_block = $doc_com . 'DOC:\s*(.*)?';
-my $doc_split_start = '^\s*/\*\*\s*$';
-my $doc_split_sect = '\s*\*\s*(@[\w\s]+):(.*)';
-my $doc_split_end = '^\s*\*/\s*$';
+my $doc_inline_start = '^\s*/\*\*\s*$';
+my $doc_inline_sect = '\s*\*\s*(@[\w\s]+):(.*)';
+my $doc_inline_end = '^\s*\*/\s*$';
 my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;';
 
 my %constants;
@@ -2497,8 +2502,8 @@ sub reset_state {
 $struct_actual = "";
 $prototype = "";
 
-$state = 0;
-$split_doc_state = 0;
+$state = STATE_NORMAL;
+$inline_doc_state = STATE_INLINE_NA;
 }
 
 sub tracepoint_munge($) {
@@ -2707,14 +2712,14 @@ sub process_file($) {
while (s/\\\s*$//) {
$_ .= ;
}
-   if ($state == 0) {
+   if ($state == STATE_NORMAL) {
if (/$doc_start/o) {
-   $state = 1; # next line is always the function name
+   $state = STATE_NAME;# next line is always the function name
$in_doc_sect = 0;
}
-   } elsif ($state == 1) { # this line is the function name (always)
+   } elsif ($state == STATE_NAME) {# this line is the function name 
(always)
if (/$doc_block/o) {
-   $state = 4;
+   $state = STATE_DOCBLOCK;
$contents = "";
if ( $1 eq "" ) {
$section = $section_intro;
@@ -2728,7 +2733,7 @@ sub process_file($) {
$identifier = $1;
}
 
-   $state = 2;
+   $state = STATE_FIELD;
if (/-(.*)/) {
# strip leading/trailing/multiple spaces
$descr= $1;
@@ -2766,9 +2771,9 @@ sub process_file($) {
print STDERR "${file}:$.: warning: Cannot understand $_ on line 
$.",
" - I thought it was a doc line\n";
++$warnings;
-   $state = 0;
+   $state = STATE_NORMAL;
}
-   } elsif ($state == 2) { # look for head: lines, and include content
+   } elsif ($state == STATE_FIELD) {   # look for head: lines, and 
include content
if (/$doc_sect/o) {
$newsection = $1;
$newcontents = $2;
@@ -2806,7 +2811,7 @@ sub process_file($) {
}
 
$prototype = "";
-   $state = 3;
+   $state = STATE_PROTO;
$brcount = 0;
 #  print STDERR "end of doc comment, looking for prototype\n";
} elsif (/$doc_content/) {
@@ -2834,9 +2839,9 @@ sub process_file($) {
print STDERR

[PATCH v2 17/38] kernel-doc/rst: add support for struct/union/enum member references

2016-06-04 Thread Jani Nikula
Link "&foo->bar", "&foo->bar()", "&foo.bar", and "&foo.bar()" to the
struct/union/enum foo definition. The members themselves do not
currently have anchors to link to, but this is better than nothing, and
promotes a universal notation.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 5 +
 1 file changed, 5 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 446c0912395e..e0fd14f6d711 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -214,6 +214,8 @@ my $type_enum_full = '\&(enum)\s*([_\w]+)';
 my $type_struct_full = '\&(struct)\s*([_\w]+)';
 my $type_typedef_full = '\&(typedef)\s*([_\w]+)';
 my $type_union_full = '\&(union)\s*([_\w]+)';
+my $type_member = '\&([_\w]+)((\.|->)[_\w]+)';
+my $type_member_func = $type_member . '\(\)';
 
 # Output conversion substitutions.
 #  One for each output format
@@ -282,6 +284,9 @@ my $blankline_text = "";
 # rst-mode
 my @highlights_rst = (
[$type_constant, "``\$1``"],
+   # Note: need to escape () to avoid func matching later
+   [$type_member_func, "\\:c\\:type\\:`\$1\$2() 
<\$1>`"],
+   [$type_member, "\\:c\\:type\\:`\$1\$2 <\$1>`"],
[$type_func, "\\:c\\:func\\:`\$1()`"],
[$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
[$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
-- 
2.1.4



[PATCH v2 03/38] Documentation/sphinx: add basic working Sphinx configuration and build

2016-06-04 Thread Jani Nikula
Add basic configuration and makefile to build documentation from any
.rst files under Documentation using Sphinx. For starters, there's just
the placeholder index.rst.

At the top level Makefile, hook Sphinx documentation targets alongside
(but independent of) the DocBook toolchain, having both be run on the
various 'make *docs' targets.

All Sphinx processing is placed into Documentation/Makefile.sphinx. Both
that and the Documentation/DocBook/Makefile are now expected to handle
all the documentation targets, explicitly ignoring them if they're not
relevant for that particular toolchain. The changes to the existing
DocBook Makefile are kept minimal.

There is graceful handling of missing Sphinx and rst2pdf (which is
needed for pdf output) by checking for the tool and python module,
respectively, with informative messages to the user.

If the Read the Docs theme (sphinx_rtd_theme) is available, use it, but
otherwise gracefully fall back to the Sphinx default theme, with an
informative message to the user, and slightly less pretty HTML output.

Sphinx can now handle htmldocs, pdfdocs (if rst2pdf is available),
epubdocs and xmldocs targets. The output documents are written into per
output type subdirectories under Documentation/output.

Finally, you can pass options to sphinx-build using the SPHINXBUILD make
variable. For example, 'make SPHINXOPTS=-v htmldocs' for more verbose
output from Sphinx.

This is based on the original work by Jonathan Corbet, but he probably
wouldn't recognize this as his own anymore.

Signed-off-by: Jani Nikula 
---
 Documentation/DocBook/Makefile |   7 +-
 Documentation/Makefile.sphinx  |  61 +++
 Documentation/conf.py  | 387 +
 Documentation/index.rst|  23 +++
 Makefile   |   5 +-
 5 files changed, 478 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/Makefile.sphinx
 create mode 100644 Documentation/conf.py
 create mode 100644 Documentation/index.rst

diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index d70f9b68174e..e0c7e1e0590b 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -33,10 +33,6 @@ PDF_METHOD   = $(prefer-db2x)
 PS_METHOD  = $(prefer-db2x)
 
 
-###
-# The targets that may be used.
-PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs 
cleandocs
-
 targets += $(DOCBOOKS)
 BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
 xmldocs: $(BOOKS)
@@ -63,6 +59,9 @@ installmandocs: mandocs
sort -k 2 -k 1 | uniq -f 1 | sed -e 's: :/:' | \
xargs install -m 644 -t /usr/local/man/man9/
 
+# no-op for the DocBook toolchain
+epubdocs:
+
 ###
 #External programs used
 KERNELDOCXMLREF = $(srctree)/scripts/kernel-doc-xml-ref
diff --git a/Documentation/Makefile.sphinx b/Documentation/Makefile.sphinx
new file mode 100644
index ..25a7970bfe5c
--- /dev/null
+++ b/Documentation/Makefile.sphinx
@@ -0,0 +1,61 @@
+# -*- makefile -*-
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXBUILD   = sphinx-build
+SPHINXOPTS=
+PAPER =
+BUILDDIR  = $(obj)/output
+
+# User-friendly check for sphinx-build
+HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; 
else echo 0; fi)
+
+ifeq ($(HAVE_SPHINX),0)
+
+.DEFAULT:
+   $(warning The '$(SPHINXBUILD)' command was not found. Make sure you 
have Sphinx installed and in PATH, or set the SPHINXBUILD make variable to 
point to the full path of the '$(SPHINXBUILD)' executable.)
+   @echo "  SKIPSphinx $@ target."
+
+else # HAVE_SPHINX
+
+# User-friendly check for rst2pdf
+HAVE_RST2PDF := $(shell if python -c "import rst2pdf" >/dev/null 2>&1; then 
echo 1; else echo 0; fi)
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/.doctrees $(PAPEROPT_$(PAPER)) -c 
$(srctree)/$(src) $(SPHINXOPTS) $(srctree)/$(src)
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+quiet_cmd_sphinx = SPHINX  $@
+  cmd_sphinx = $(SPHINXBUILD) -b $2 $(ALLSPHINXOPTS) $(BUILDDIR)/$2
+
+htmldocs:
+   $(call cmd,sphinx,html)
+
+pdfdocs:
+ifeq ($(HAVE_RST2PDF),0)
+   $(warning The Python 'rst2pdf' module was not found. Make sure you have 
the module installed to produce PDF output.)
+   @echo "  SKIPSphinx $@ target."
+else # HAVE_RST2PDF
+   $(call cmd,sphinx,pdf)
+endif # HAVE_RST2PDF
+
+epubdocs:
+   $(call cmd,sphinx,epub)
+
+xmldocs:
+   $(call cmd,sphinx,xml)
+
+# no-ops for the Sphinx toolchain
+sgmldocs:
+psdocs:
+mandocs:
+installmandocs:
+
+cleandocs:
+   $(Q)rm -rf $(BUILDDIR)
+
+endif # HAVE_SPHINX
diff --git a/Documentation/conf.py b/Documentation/conf.py
new file mode 100644
index ..0f0e20757bb1
--- /dev/null
+++ b/Documentation/conf.py
@@

[PATCH v2 12/38] kernel-doc: add names for output selection

2016-06-04 Thread Jani Nikula
Make the output selection a bit more readable by adding constants for
the various types of output selection. While at it, actually call the
variable for choosing what to output $output_selection.

No functional changes.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 47 ++-
 1 file changed, 30 insertions(+), 17 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index cb5fd248ac57..dd08944b0a6f 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -312,7 +312,15 @@ my $no_doc_sections = 0;
 my @highlights = @highlights_man;
 my $blankline = $blankline_man;
 my $modulename = "Kernel API";
-my $function_only = 0;
+
+use constant {
+OUTPUT_ALL  => 0, # output all symbols and doc sections
+OUTPUT_INCLUDE  => 1, # output only specified symbols
+OUTPUT_EXCLUDE  => 2, # output everything except specified symbols
+OUTPUT_EXPORTED => 3, # output exported symbols
+OUTPUT_INTERNAL => 4, # output non-exported symbols
+};
+my $output_selection = OUTPUT_ALL;
 my $show_not_found = 0;
 
 my @build_time;
@@ -449,18 +457,18 @@ while ($ARGV[0] =~ m/^-(.*)/) {
 } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling 
document
$modulename = shift @ARGV;
 } elsif ($cmd eq "-function") { # to only output specific functions
-   $function_only = 1;
+   $output_selection = OUTPUT_INCLUDE;
$function = shift @ARGV;
$function_table{$function} = 1;
-} elsif ($cmd eq "-nofunction") { # to only output specific functions
-   $function_only = 2;
+} elsif ($cmd eq "-nofunction") { # output all except specific functions
+   $output_selection = OUTPUT_EXCLUDE;
$function = shift @ARGV;
$function_table{$function} = 1;
 } elsif ($cmd eq "-export") { # only exported symbols
-   $function_only = 3;
+   $output_selection = OUTPUT_EXPORTED;
%function_table = ()
 } elsif ($cmd eq "-internal") { # only non-exported symbols
-   $function_only = 4;
+   $output_selection = OUTPUT_INTERNAL;
%function_table = ()
 } elsif ($cmd eq "-v") {
$verbose = 1;
@@ -530,15 +538,17 @@ sub dump_doc_section {
 return;
 }
 
-if (($function_only == 0) ||
-   ( $function_only == 1 && defined($function_table{$name})) ||
-   ( $function_only == 2 && !defined($function_table{$name})))
+if (($output_selection == OUTPUT_ALL) ||
+   ($output_selection == OUTPUT_INCLUDE &&
+defined($function_table{$name})) ||
+   ($output_selection == OUTPUT_EXCLUDE &&
+!defined($function_table{$name})))
 {
dump_section($file, $name, $contents);
output_blockhead({'sectionlist' => \@sectionlist,
  'sections' => \%sections,
  'module' => $modulename,
- 'content-only' => ($function_only != 0), });
+ 'content-only' => ($output_selection != OUTPUT_ALL), 
});
 }
 }
 
@@ -1988,11 +1998,13 @@ sub output_declaration {
 my $name = shift;
 my $functype = shift;
 my $func = "output_${functype}_$output_mode";
-if (($function_only==0) ||
-   ( ($function_only == 1 || $function_only == 3) &&
- defined($function_table{$name})) ||
-   ( ($function_only == 2 || $function_only == 4) &&
- !($functype eq "function" && defined($function_table{$name}
+if (($output_selection == OUTPUT_ALL) ||
+   (($output_selection == OUTPUT_INCLUDE ||
+ $output_selection == OUTPUT_EXPORTED) &&
+defined($function_table{$name})) ||
+   (($output_selection == OUTPUT_EXCLUDE ||
+ $output_selection == OUTPUT_INTERNAL) &&
+!($functype eq "function" && defined($function_table{$name}
 {
&$func(@_);
$section_counter++;
@@ -2696,7 +2708,8 @@ sub process_file($) {
 }
 
 # two passes for -export and -internal
-if ($function_only == 3 || $function_only == 4) {
+if ($output_selection == OUTPUT_EXPORTED ||
+   $output_selection == OUTPUT_INTERNAL) {
while () {
if (/$export_symbol/o) {
$function_table{$2} = 1;
@@ -2929,7 +2942,7 @@ sub process_file($) {
 }
 if ($initial_section_counter == $section_counter) {
print STDERR "${file}:1: warning: no structured comments found\n";
-   if (($function_only == 1) && ($show_not_found == 1)) {
+   if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) {
print STDERR "Was looking for '$_'.\n" for keys %function_table;
}
if ($output_mode eq "xml") {
-- 
2.1.4



[PATCH v2 16/38] kernel-doc/rst: add support for &union foo and &typedef foo references

2016-06-04 Thread Jani Nikula
Let the user use "&union foo" and "&typedef foo" to reference foo. The
difference to using "union &foo", "typedef &foo", or just "&foo" (which
are valid too) is that "union" and "typedef" become part of the link
text.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 4 
 1 file changed, 4 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e7aa792e7f1b..446c0912395e 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -212,6 +212,8 @@ my $type_struct_xml = '\\&((struct\s*)*[_\w]+)';
 my $type_env = '(\$\w+)';
 my $type_enum_full = '\&(enum)\s*([_\w]+)';
 my $type_struct_full = '\&(struct)\s*([_\w]+)';
+my $type_typedef_full = '\&(typedef)\s*([_\w]+)';
+my $type_union_full = '\&(union)\s*([_\w]+)';
 
 # Output conversion substitutions.
 #  One for each output format
@@ -283,6 +285,8 @@ my @highlights_rst = (
[$type_func, "\\:c\\:func\\:`\$1()`"],
[$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
[$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
+   [$type_typedef_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
+   [$type_union_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
# in rst this can refer to any type
[$type_struct, "\\:c\\:type\\:`\$1`"],
[$type_param, "**\$1**"]
-- 
2.1.4



[PATCH v2 15/38] kernel-doc/rst: &foo references are more universal than structs

2016-06-04 Thread Jani Nikula
It's possible to use &foo to reference structs, enums, typedefs, etc. in
the Sphinx C domain. Thus do not prefix the links with "struct".

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e8651d7cf1cd..e7aa792e7f1b 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -283,7 +283,8 @@ my @highlights_rst = (
[$type_func, "\\:c\\:func\\:`\$1()`"],
[$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
[$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"],
-   [$type_struct, "\\:c\\:type\\:`struct \$1 <\$1>`"],
+   # in rst this can refer to any type
+   [$type_struct, "\\:c\\:type\\:`\$1`"],
[$type_param, "**\$1**"]
  );
 my $blankline_rst = "\n";
-- 
2.1.4



[PATCH v2 08/38] sphinx: cheesy script to convert .tmpl files

2016-06-04 Thread Jani Nikula
From: Jonathan Corbet 

This script uses pandoc to convert existing DocBook template files to RST
templates.  A couple of sed scripts are need to massage things both before
and after the conversion, but the result is then usable with no hand
editing.

[Jani: Change usage to tmplcvt  . Fix escaping for docproc
directives. Add support the new kernel-doc extension.]

Signed-off-by: Jonathan Corbet 
Signed-off-by: Jani Nikula 
---
 Documentation/sphinx/convert_template.sed | 14 ++
 Documentation/sphinx/post_convert.sed | 19 +++
 Documentation/sphinx/tmplcvt  | 19 +++
 3 files changed, 52 insertions(+)
 create mode 100644 Documentation/sphinx/convert_template.sed
 create mode 100644 Documentation/sphinx/post_convert.sed
 create mode 100755 Documentation/sphinx/tmplcvt

diff --git a/Documentation/sphinx/convert_template.sed 
b/Documentation/sphinx/convert_template.sed
new file mode 100644
index ..d53bb8220a26
--- /dev/null
+++ b/Documentation/sphinx/convert_template.sed
@@ -0,0 +1,14 @@
+#
+# Pandoc doesn't grok  or , so convert them
+# ahead of time.
+#
+# Use "$bq" instead of "`" so that pandoc won't mess with it.
+#
+s%\([^<(]\+\)()%:c:func:$bq\1$bq%g
+s%\([^<(]\+\)%:c:func:$bq\1$bq%g
+s%struct *\([^<]\+\)%:ref:$bqstruct \1$bq%g
+s%\([^<]\+\)%:ref:$bqstruct \1$bq%g
+#
+# Wrap docproc directives in para and code blocks.
+#
+s%^\(!.*\)$%DOCPROC: \1%
diff --git a/Documentation/sphinx/post_convert.sed 
b/Documentation/sphinx/post_convert.sed
new file mode 100644
index ..ce17049f6a8e
--- /dev/null
+++ b/Documentation/sphinx/post_convert.sed
@@ -0,0 +1,19 @@
+#
+# pandoc thinks that both "_" needs to be escaped.  Remove the extra
+# backslashes.  Also put in proper backquotes now that pandoc won't quote
+# them.
+#
+s/$bq/`/g
+s/\\_/_/g
+#
+# Unwrap docproc directives.
+#
+s/^``DOCPROC: !E\(.*\)``$/.. kernel-doc:: \1\n   :export:/
+s/^``DOCPROC: !I\(.*\)``$/.. kernel-doc:: \1\n   :internal:/
+s/^``DOCPROC: !F\([^ ]*\) \(.*\)``$/.. kernel-doc:: \1\n   :functions: \2/
+s/^``DOCPROC: !P\([^ ]*\) \(.*\)``$/.. kernel-doc:: \1\n   :doc: \2/
+s/^``DOCPROC: \(!.*\)``$/.. WARNING: DOCPROC directive not supported: \1/
+#
+# Trim trailing whitespace.
+#
+s/[[:space:]]*$//
diff --git a/Documentation/sphinx/tmplcvt b/Documentation/sphinx/tmplcvt
new file mode 100755
index ..909a73065e0a
--- /dev/null
+++ b/Documentation/sphinx/tmplcvt
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Convert a template file into something like RST
+#
+# fix 
+# feed to pandoc
+# fix \_
+# title line?
+#
+
+in=$1
+rst=$2
+tmp=$rst.tmp
+
+cp $in $tmp
+sed --in-place -f convert_template.sed $tmp
+pandoc -s -S -f docbook -t rst -o $rst $tmp
+sed --in-place -f post_convert.sed $rst
+rm $tmp
-- 
2.1.4



[PATCH v2 18/38] kernel-doc/rst: drop redundant unescape in highlighting

2016-06-04 Thread Jani Nikula
This bit is already done by xml_unescape() above.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e0fd14f6d711..8f9eac509377 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1796,7 +1796,6 @@ sub output_highlight_rst {
if ($line eq "") {
print $lineprefix, $blankline;
} else {
-   $line =~ s/\\/\&/g;
print $lineprefix, $line;
}
print "\n";
-- 
2.1.4



[PATCH v2 13/38] kernel-doc/rst: do not output DOC: section titles for requested ones

2016-06-04 Thread Jani Nikula
If the user requests a specific DOC: section by name, do not output its
section title. In these cases, the surrounding context already has a
heading, and the DOC: section title is only used as an identifier and a
heading for clarity in the source file.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index dd08944b0a6f..659d529b99d8 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1764,7 +1764,9 @@ sub output_blockhead_rst(%) {
 my ($parameter, $section);
 
 foreach $section (@{$args{'sectionlist'}}) {
-   print "**$section**\n\n";
+   if ($output_selection != OUTPUT_INCLUDE) {
+   print "**$section**\n\n";
+   }
output_highlight_rst($args{'sections'}{$section});
print "\n";
 }
-- 
2.1.4



[PATCH v2 10/38] Documentation/sphinx: nicer referencing of struct in docbook->rst conversion

2016-06-04 Thread Jani Nikula
Add "struct" in the label of the reference.

Signed-off-by: Jani Nikula 
---
 Documentation/sphinx/convert_template.sed | 10 +++---
 Documentation/sphinx/post_convert.sed | 10 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Documentation/sphinx/convert_template.sed 
b/Documentation/sphinx/convert_template.sed
index 0553eabeac79..c1503fcca4ec 100644
--- a/Documentation/sphinx/convert_template.sed
+++ b/Documentation/sphinx/convert_template.sed
@@ -2,12 +2,16 @@
 # Pandoc doesn't grok  or , so convert them
 # ahead of time.
 #
-# Use "$bq" instead of "`" so that pandoc won't mess with it.
+# Use the following escapes to pass through pandoc:
+#  $bq = "`"
+#  $lt = "<"
+#  $gt = ">"
 #
 s%\([^<(]\+\)()%:c:func:$bq\1()$bq%g
 s%\([^<(]\+\)%:c:func:$bq\1()$bq%g
-s%struct *\([^<]\+\)%:c:type:$bq\1$bq%g
-s%\([^<]\+\)%:c:type:$bq\1$bq%g
+s%struct *\([^<]\+\)%:c:type:$bqstruct \1 
$lt\1$gt$bq%g
+s%struct \([^<]\+\)%:c:type:$bqstruct \1 $lt\1$gt$bq%g
+s%\([^<]\+\)%:c:type:$bqstruct \1 $lt\1$gt$bq%g
 #
 # Wrap docproc directives in para and code blocks.
 #
diff --git a/Documentation/sphinx/post_convert.sed 
b/Documentation/sphinx/post_convert.sed
index ce17049f6a8e..392770bac53b 100644
--- a/Documentation/sphinx/post_convert.sed
+++ b/Documentation/sphinx/post_convert.sed
@@ -1,9 +1,13 @@
 #
-# pandoc thinks that both "_" needs to be escaped.  Remove the extra
-# backslashes.  Also put in proper backquotes now that pandoc won't quote
-# them.
+# Unescape.
 #
 s/$bq/`/g
+s/$lt//g
+#
+# pandoc thinks that both "_" needs to be escaped.  Remove the extra
+# backslashes.
+#
 s/\\_/_/g
 #
 # Unwrap docproc directives.
-- 
2.1.4



[PATCH v2 04/38] Documentation: add .gitignore

2016-06-04 Thread Jani Nikula
The Sphinx output directory is generated.

Signed-off-by: Jani Nikula 
---
 Documentation/.gitignore | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 Documentation/.gitignore

diff --git a/Documentation/.gitignore b/Documentation/.gitignore
new file mode 100644
index ..53752db253e3
--- /dev/null
+++ b/Documentation/.gitignore
@@ -0,0 +1 @@
+output
-- 
2.1.4



[PATCH v2 05/38] Documentation/sphinx: add Sphinx kernel-doc directive extension

2016-06-04 Thread Jani Nikula
Add an extension to handle kernel-doc directives, to call kernel-doc
according to the arguments and parameters given to the reStructuredText
directive.

The syntax for the kernel-doc directive is:

.. kernel-doc:: FILENAME
   :export:
   :internal:
   :functions: FUNCTION [FUNCTION ...]
   :doc: SECTION TITLE

Of the directive options export, internal, functions, and doc, currently
only one option may be given at a time.

The FILENAME is relative from the kernel source tree root.

The extension notifies Sphinx about the document dependency on FILENAME,
causing the document to be rebuilt when the file has been changed.

Signed-off-by: Jani Nikula 
---
 Documentation/sphinx/kernel-doc.py | 102 +
 1 file changed, 102 insertions(+)
 create mode 100644 Documentation/sphinx/kernel-doc.py

diff --git a/Documentation/sphinx/kernel-doc.py 
b/Documentation/sphinx/kernel-doc.py
new file mode 100644
index ..87a1332fe934
--- /dev/null
+++ b/Documentation/sphinx/kernel-doc.py
@@ -0,0 +1,102 @@
+# coding=utf-8
+#
+# Copyright © 2016 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+# Authors:
+#Jani Nikula 
+
+import os
+import subprocess
+import sys
+
+from docutils import nodes, statemachine
+from docutils.parsers.rst import directives
+from sphinx.util.compat import Directive
+
+class KernelDocDirective(Directive):
+"""Extract kernel-doc comments from the specified file"""
+required_argument = 1
+optional_arguments = 4
+option_spec = {
+'doc': directives.unchanged_required,
+'functions': directives.unchanged_required,
+'export': directives.flag,
+'internal': directives.flag,
+}
+has_content = False
+
+def run(self):
+env = self.state.document.settings.env
+cmd = [env.config.kerneldoc_bin, '-rst']
+
+filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
+
+# Tell sphinx of the dependency
+env.note_dependency(os.path.abspath(filename))
+
+tab_width = self.options.get('tab-width', 
self.state.document.settings.tab_width)
+source = self.state_machine.input_lines.source(self.lineno - 
self.state_machine.input_offset - 1)
+
+# FIXME: make this nicer and more robust against errors
+if 'export' in self.options:
+cmd += ['-export']
+elif 'internal' in self.options:
+cmd += ['-internal']
+elif 'doc' in self.options:
+cmd += ['-function', str(self.options.get('doc'))]
+elif 'functions' in self.options:
+for f in str(self.options.get('functions')).split(' '):
+cmd += ['-function', f]
+
+cmd += [filename]
+
+try:
+env.app.verbose('calling kernel-doc \'%s\'' % (" ".join(cmd)))
+
+p = subprocess.Popen(cmd, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, universal_newlines=True)
+out, err = p.communicate()
+
+# assume the kernel sources are utf-8
+out, err = unicode(out, 'utf-8'), unicode(err, 'utf-8')
+
+if p.returncode != 0:
+sys.stderr.write(err)
+
+env.app.warn('kernel-doc \'%s\' failed with return code %d' % 
(" ".join(cmd), p.returncode))
+return [nodes.error(None, nodes.paragraph(text = "kernel-doc 
missing"))]
+elif env.config.kerneldoc_verbosity > 0:
+sys.stderr.write(err)
+
+lines = statemachine.string2lines(out, tab_width, 
convert_whitespace=True)
+self.state_machine.insert_input(lines, source)
+return []
+except Exception as e:
+env.app.warn('kernel-doc \'%s\' processing failed with: %s' %
+ (" ".join(cmd), str(e)))
+return [nodes.error(None, nodes.paragraph(text = "kernel-doc 
missing"))]
+
+def setup(app):
+app.add_config_v

[PATCH v2 36/38] scripts/kernel-doc: Also give functions symbolic names

2016-06-04 Thread Jani Nikula
From: Daniel Vetter 

state3 = prototype parsing, so name them accordingly.

Cc: Jani Nikula 
Cc: linux-...@vger.kernel.org
Cc: Jonathan Corbet 
Signed-off-by: Daniel Vetter 
Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 9fb26d142a56..4da6f952d18b 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2593,7 +2593,7 @@ sub syscall_munge() {
}
 }
 
-sub process_state3_function($$) {
+sub process_proto_function($$) {
 my $x = shift;
 my $file = shift;
 
@@ -2623,7 +2623,7 @@ sub process_state3_function($$) {
 }
 }
 
-sub process_state3_type($$) {
+sub process_proto_type($$) {
 my $x = shift;
 my $file = shift;
 
@@ -2937,9 +2937,9 @@ sub process_file($) {
$state = STATE_INLINE;
$inline_doc_state = STATE_INLINE_NAME;
} elsif ($decl_type eq 'function') {
-   process_state3_function($_, $file);
+   process_proto_function($_, $file);
} else {
-   process_state3_type($_, $file);
+   process_proto_type($_, $file);
}
} elsif ($state == STATE_DOCBLOCK) {
if (/$doc_end/)
-- 
2.1.4



[PATCH v2 20/38] kernel-doc: do not regard $, %, or & prefixes as special in section names

2016-06-04 Thread Jani Nikula
The use of these is confusing in the script, and per this grep, they're
not used anywhere anyway:

$ git grep " \* [%$&][a-zA-Z0-9_]*:" -- *.[ch] | grep -v 
"\$\(Id\|Revision\|Date\)"

While at it, throw out the constants array, nothing is ever put there
again.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 76bad55c031e..f795660dfc7b 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -396,14 +396,12 @@ my $inline_doc_state;
 # 'function', 'struct', 'union', 'enum', 'typedef'
 my $decl_type;
 
-my $doc_special = "\@\%\$\&";
-
 my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
 my $doc_end = '\*/';
 my $doc_com = '\s*\*\s*';
 my $doc_com_body = '\s*\* ?';
 my $doc_decl = $doc_com . '(\w+)';
-my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)';
+my $doc_sect = $doc_com . '(\@?[\w\s]+):(.*)';
 my $doc_content = $doc_com_body . '(.*)';
 my $doc_block = $doc_com . 'DOC:\s*(.*)?';
 my $doc_inline_start = '^\s*/\*\*\s*$';
@@ -411,7 +409,6 @@ my $doc_inline_sect = '\s*\*\s*(@[\w\s]+):(.*)';
 my $doc_inline_end = '^\s*\*/\s*$';
 my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;';
 
-my %constants;
 my %parameterdescs;
 my @parameterlist;
 my %sections;
@@ -511,11 +508,7 @@ sub dump_section {
 my $name = shift;
 my $contents = join "\n", @_;
 
-if ($name =~ m/$type_constant/) {
-   $name = $1;
-#  print STDERR "constant section '$1' = '$contents'\n";
-   $constants{$name} = $contents;
-} elsif ($name =~ m/$type_param/) {
+if ($name =~ m/$type_param/) {
 #  print STDERR "parameter def '$1' = '$contents'\n";
$name = $1;
$parameterdescs{$name} = $contents;
@@ -2528,7 +2521,6 @@ sub dump_function($$) {
 
 sub reset_state {
 $function = "";
-%constants = ();
 %parameterdescs = ();
 %parametertypes = ();
 @parameterlist = ();
@@ -2924,7 +2916,6 @@ sub process_file($) {
dump_doc_section($file, $section, 
xml_escape($contents));
$contents = "";
$function = "";
-   %constants = ();
%parameterdescs = ();
%parametertypes = ();
@parameterlist = ();
@@ -2942,7 +2933,6 @@ sub process_file($) {
dump_doc_section($file, $section, 
xml_escape($contents));
$contents = "";
$function = "";
-   %constants = ();
%parameterdescs = ();
%parametertypes = ();
@parameterlist = ();
-- 
2.1.4



[PATCH v2 35/38] doc/sphinx: Stop touching state_machine internals

2016-06-04 Thread Jani Nikula
From: Daniel Vetter 

Instead of just forcefully inserting our kernel-doc input and letting
the state machine stumble over it the recommended way is to create
ViewList, parse that and then return the list of parsed nodes.

Suggested by Jani.

Cc: Jani Nikula 
Cc: linux-...@vger.kernel.org
Cc: Jonathan Corbet 
Signed-off-by: Daniel Vetter 
Signed-off-by: Jani Nikula 
---
 Documentation/sphinx/kernel-doc.py | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/sphinx/kernel-doc.py 
b/Documentation/sphinx/kernel-doc.py
index 9fc2c27916a9..bd422870101e 100644
--- a/Documentation/sphinx/kernel-doc.py
+++ b/Documentation/sphinx/kernel-doc.py
@@ -32,6 +32,7 @@ import subprocess
 import sys
 
 from docutils import nodes, statemachine
+from docutils.statemachine import ViewList
 from docutils.parsers.rst import directives
 from sphinx.util.compat import Directive
 
@@ -92,8 +93,14 @@ class KernelDocDirective(Directive):
 sys.stderr.write(err)
 
 lines = statemachine.string2lines(out, tab_width, 
convert_whitespace=True)
-self.state_machine.insert_input(lines, source)
-return []
+result = ViewList(lines, source)
+
+node = nodes.section()
+node.document = self.state.document
+self.state.nested_parse(result, self.content_offset, node)
+
+return node.children
+
 except Exception as e:
 env.app.warn('kernel-doc \'%s\' processing failed with: %s' %
  (" ".join(cmd), str(e)))
-- 
2.1.4



[PATCH v2 26/38] kernel-doc: strip leading whitespace from continued param descs

2016-06-04 Thread Jani Nikula
If a param description spans multiple lines, check any leading
whitespace in the first continuation line, and remove same amount of
whitespace from following lines.

This allows indentation in the multi-line parameter descriptions for
aesthetical reasons while not causing accidentally significant
indentation in the rst output.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e93e796b17ce..f6f37e71dc08 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2701,6 +2701,7 @@ sub process_file($) {
 my $in_purpose = 0;
 my $initial_section_counter = $section_counter;
 my ($orig_file) = @_;
+my $leading_space;
 
 if (defined($ENV{'SRCTREE'})) {
$file = "$ENV{'SRCTREE'}" . "/" . $orig_file;
@@ -2822,6 +2823,7 @@ sub process_file($) {
$contents .= "\n";
}
$section = $newsection;
+   $leading_space = undef;
} elsif (/$doc_end/) {
if (($contents ne "") && ($contents ne "\n")) {
dump_section($file, $section, xml_escape($contents));
@@ -2856,7 +2858,19 @@ sub process_file($) {
$declaration_purpose .= " " . xml_escape($1);
$declaration_purpose =~ s/\s+/ /g;
} else {
-   $contents .= $1 . "\n";
+   my $cont = $1;
+   if ($section =~ m/^@/ || $section eq $section_context) {
+   if (!defined $leading_space) {
+   if ($cont =~ m/^(\s+)/) {
+   $leading_space = $1;
+   } else {
+   $leading_space = "";
+   }
+   }
+
+   $cont =~ s/^$leading_space//;
+   }
+   $contents .= $cont . "\n";
}
} else {
# i dont know - bad line?  ignore.
-- 
2.1.4



[PATCH v2 28/38] kernel-doc/rst: remove fixme comment

2016-06-04 Thread Jani Nikula
Yes, for our purposes the type should contain typedef.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 19cee0cd53a3..425a94be04f6 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1897,7 +1897,6 @@ sub output_typedef_rst(%) {
 my $oldprefix = $lineprefix;
 my $name = "typedef " . $args{'typedef'};
 
-### FIXME: should the name below contain "typedef" or not?
 print "\n\n.. c:type:: " . $name . "\n\n";
 $lineprefix = "   ";
 output_highlight_rst($args{'purpose'});
-- 
2.1.4



[PATCH v2 29/38] kernel-doc: limit the "section header:" detection to a select few

2016-06-04 Thread Jani Nikula
kernel-doc currently identifies anything matching "section header:"
(specifically a string of word characters and spaces followed by a
colon) as a new section in the documentation comment, and renders the
section header accordingly.

Unfortunately, this turns all uses of colon into sections, mostly
unintentionally. Considering the output, erroneously creating sections
when not intended is always worse than erroneously not creating sections
when intended. For example, a line with "http://example.com"; turns into
a "http" heading followed by "//example.com" in normal text style, which
is quite ugly. OTOH, "WARNING: Beware of the Leopard" is just fine even
if "WARNING" does not turn into a heading.

It is virtually impossible to change all the kernel-doc comments, either
way. The compromise is to pick the most commonly used and depended on
section headers (with variants) and accept them as section headers.

The accepted section headers are, case insensitive:

 * description:
 * context:
 * return:
 * returns:

Additionally, case sensitive:

 * @return:

All of the above are commonly used in the kernel-doc comments, and will
result in worse output if not identified as section headers. Also,
kernel-doc already has some special handling for all of them, so there's
nothing particularly controversial in adding more special treatment for
them.

While at it, improve the whitespace handling surrounding section
names. Do not consider the whitespace as part of the name.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 425a94be04f6..20136564f264 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -401,7 +401,8 @@ my $doc_end = '\*/';
 my $doc_com = '\s*\*\s*';
 my $doc_com_body = '\s*\* ?';
 my $doc_decl = $doc_com . '(\w+)';
-my $doc_sect = $doc_com . '(\@?[\w\s]+):(.*)';
+# @params and a strictly limited set of supported section names
+my $doc_sect = $doc_com . '\s*(\@\w+|description|context|returns?)\s*:(.*)';
 my $doc_content = $doc_com_body . '(.*)';
 my $doc_block = $doc_com . 'DOC:\s*(.*)?';
 my $doc_inline_start = '^\s*/\*\*\s*$';
@@ -417,6 +418,8 @@ my $sectcheck;
 my $struct_actual;
 
 my $contents = "";
+
+# the canonical section names. see also $doc_sect above.
 my $section_default = "Description";   # default section
 my $section_intro = "Introduction";
 my $section = $section_default;
@@ -2798,10 +2801,22 @@ sub process_file($) {
$state = STATE_NORMAL;
}
} elsif ($state == STATE_FIELD) {   # look for head: lines, and 
include content
-   if (/$doc_sect/o) {
+   if (/$doc_sect/i) { # case insensitive for supported section names
$newsection = $1;
$newcontents = $2;
 
+   # map the supported section names to the canonical names
+   if ($newsection =~ m/^description$/i) {
+   $newsection = $section_default;
+   } elsif ($newsection =~ m/^context$/i) {
+   $newsection = $section_context;
+   } elsif ($newsection =~ m/^returns?$/i) {
+   $newsection = $section_return;
+   } elsif ($newsection =~ m/^\@return$/) {
+   # special: @return is a section, not a param description
+   $newsection = $section_return;
+   }
+
if (($contents ne "") && ($contents ne "\n")) {
if (!$in_doc_sect && $verbose) {
print STDERR "${file}:$.: warning: contents before 
sections\n";
-- 
2.1.4



[PATCH v2 37/38] scripts/kernel-doc: Add option to inject line numbers

2016-06-04 Thread Jani Nikula
From: Daniel Vetter 

Opt-in since this wreaks the rst output and must be removed
by consumers again. This is useful to adjust the linenumbers
for included kernel-doc snippets in shinx. With that sphinx
error message will be accurate when there's issues with the
rst-ness of the kernel-doc comments.

Especially when transitioning a new docbook .tmpl to .rst this
is extremely useful, since you can just use your editors compilation
quickfix list to accurately jump from error to error.

v2:
- Also make sure that we filter the LINENO for purpose/at declaration
  start so it only shows for selected blocks, not all of them (Jani).
  While at it make it a notch more accurate.
- Avoid undefined $lineno issues. I tried filtering these out at the
  callsite, but Jani spotted more when linting the entire kernel.
  Unamed unions and similar things aren't stored consistently and end
  up with an undefined line number (but also no kernel-doc text, just
  the parameter type). Simplify things and filter undefined line
  numbers in print_lineno() to catch them all.

v3: Fix LINENO 0 issue for kernel-doc comments without @param: lines
or any other special sections that directly jump to the description
after the "name - purpose" line. Only really possible for functions
without parameters. Noticed by Jani.

Cc: Jani Nikula 
Cc: linux-...@vger.kernel.org
Cc: Jonathan Corbet 
Signed-off-by: Daniel Vetter 
Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 41 +
 1 file changed, 41 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 4da6f952d18b..5192213c5005 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -74,6 +74,8 @@ Output selection (mutually exclusive):
 
 Output selection modifiers:
   -no-doc-sections Do not output DOC: sections.
+  -enable-linenoEnable output of #define LINENO lines. Only works with
+reStructuredText format.
 
 Other parameters:
   -v   Verbose output, more warnings and other information.
@@ -319,6 +321,7 @@ my $verbose = 0;
 my $output_mode = "man";
 my $output_preformatted = 0;
 my $no_doc_sections = 0;
+my $enable_lineno = 0;
 my @highlights = @highlights_man;
 my $blankline = $blankline_man;
 my $modulename = "Kernel API";
@@ -351,6 +354,7 @@ my $man_date = ('January', 'February', 'March', 'April', 
'May', 'June',
 # CAVEAT EMPTOR!  Some of the others I localised may not want to be, which
 # could cause "use of undefined value" or other bugs.
 my ($function, %function_table, %parametertypes, $declaration_purpose);
+my $declaration_start_line;
 my ($type, $declaration_name, $return_type);
 my ($newsection, $newcontents, $prototype, $brcount, %source_map);
 
@@ -411,13 +415,16 @@ my $doc_inline_end = '^\s*\*/\s*$';
 my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;';
 
 my %parameterdescs;
+my %parameterdesc_start_lines;
 my @parameterlist;
 my %sections;
 my @sectionlist;
+my %section_start_lines;
 my $sectcheck;
 my $struct_actual;
 
 my $contents = "";
+my $new_start_line = 0;
 
 # the canonical section names. see also $doc_sect above.
 my $section_default = "Description";   # default section
@@ -486,6 +493,8 @@ while ($ARGV[0] =~ m/^-(.*)/) {
usage();
 } elsif ($cmd eq '-no-doc-sections') {
$no_doc_sections = 1;
+} elsif ($cmd eq '-enable-lineno') {
+   $enable_lineno = 1;
 } elsif ($cmd eq '-show-not-found') {
$show_not_found = 1;
 }
@@ -503,6 +512,13 @@ sub get_kernel_version() {
 return $version;
 }
 
+#
+sub print_lineno {
+my $lineno = shift;
+if ($enable_lineno && defined($lineno)) {
+print "#define LINENO " . $lineno . "\n";
+}
+}
 ##
 # dumps section contents to arrays/hashes intended for that purpose.
 #
@@ -516,11 +532,15 @@ sub dump_section {
$name = $1;
$parameterdescs{$name} = $contents;
$sectcheck = $sectcheck . $name . " ";
+$parameterdesc_start_lines{$name} = $new_start_line;
+$new_start_line = 0;
 } elsif ($name eq "@\.\.\.") {
 #  print STDERR "parameter def '...' = '$contents'\n";
$name = "...";
$parameterdescs{$name} = $contents;
$sectcheck = $sectcheck . $name . " ";
+$parameterdesc_start_lines{$name} = $new_start_line;
+$new_start_line = 0;
 } else {
 #  print STDERR "other section '$name' = '$contents'\n";
if (defined($sections{$name}) && ($sections{$name} ne "")) {
@@ -530,6 +550,8 @@ sub dump_section {
} else {
$sections{$name} = $contents;
push @sectionlist, $name;
+$section_start_lines{$name} = $new_start_line;
+$new_start_line = 0;
}
 }
 }
@@ -1775,6 +1797,7 @@ sub output_blockhead_rst(%) {
if ($output_selection != OUTPUT_INCLUDE) {
print "**$section**\n\n";
}
+print_lineno($section_start_lines{$section});
output_highlight_rst($args{'section

[PATCH v2 38/38] doc/sphinx: Track line-number of starting blocks

2016-06-04 Thread Jani Nikula
From: Daniel Vetter 

Design is pretty simple: kernel-doc inserts breadcrumbs with line
numbers, and sphinx picks them up. At first I went with a sphinx
comment, but inserting those at random places seriously upsets the
parser, and must be filtered. Hence why this version now uses "#define
LINEO " since one of these ever escape into output it's pretty clear
there is a bug.

It seems to work well, and at least the 2-3 errors where sphinx
complained about something that was not correct in kernel-doc text the
line numbers matched up perfectly.

v2: Instead of noodling around in the parser state machine, create
a ViewList and parse it ourselves. This seems to be the recommended
way, per Jani's suggestion.

v3:
- Split out ViewList pach. Splitting the kernel-doc changes from the
  sphinx ones isn't possible, since emitting the LINENO lines wreaks
  havoc with the rst formatting. We must filter them.

- Improve the regex per Jani's suggestions, and compile it just once
  for speed.

- Now that LINENO lines are eaten, also add them to function parameter
  descriptions. Much less content and offset than for in-line struct
  member descriptions, but still nice to know which exact continuation
  line upsets sphinx.

- Simplify/clarify the line +/-1 business a bit.

v4: Split out the scripts/kernel-doc changes and make line-numbers
opt-in, as suggested by Jani.

Cc: Jani Nikula 
Cc: linux-...@vger.kernel.org
Cc: Jonathan Corbet 
Signed-off-by: Daniel Vetter 
Signed-off-by: Jani Nikula 
---
 Documentation/sphinx/kernel-doc.py | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/Documentation/sphinx/kernel-doc.py 
b/Documentation/sphinx/kernel-doc.py
index bd422870101e..4adfb0e91ecc 100644
--- a/Documentation/sphinx/kernel-doc.py
+++ b/Documentation/sphinx/kernel-doc.py
@@ -30,6 +30,7 @@
 import os
 import subprocess
 import sys
+import re
 
 from docutils import nodes, statemachine
 from docutils.statemachine import ViewList
@@ -50,7 +51,7 @@ class KernelDocDirective(Directive):
 
 def run(self):
 env = self.state.document.settings.env
-cmd = [env.config.kerneldoc_bin, '-rst']
+cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno']
 
 filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
 
@@ -93,7 +94,19 @@ class KernelDocDirective(Directive):
 sys.stderr.write(err)
 
 lines = statemachine.string2lines(out, tab_width, 
convert_whitespace=True)
-result = ViewList(lines, source)
+result = ViewList()
+
+lineoffset = 0;
+line_regex = re.compile("^#define LINENO ([0-9]+)$")
+for line in lines:
+match = line_regex.search(line)
+if match:
+# sphinx counts lines from 0
+lineoffset = int(match.group(1)) - 1
+# we must eat our comments since the upset the markup
+else:
+result.append(line, source, lineoffset)
+lineoffset += 1
 
 node = nodes.section()
 node.document = self.state.document
-- 
2.1.4



[PATCH v2 27/38] kernel-doc/rst: use *undescribed* instead of _undescribed_

2016-06-04 Thread Jani Nikula
The latter isn't special to rst.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index f6f37e71dc08..19cee0cd53a3 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1839,7 +1839,7 @@ sub output_function_rst(%) {
$args{'parameterdescs'}{$parameter_name} ne $undescribed) {
output_highlight_rst($args{'parameterdescs'}{$parameter_name});
} else {
-   print "  _undescribed_\n";
+   print "  *undescribed*\n";
}
print "\n";
 }
@@ -1882,7 +1882,7 @@ sub output_enum_rst(%) {
if ($args{'parameterdescs'}{$parameter} ne $undescribed) {
output_highlight_rst($args{'parameterdescs'}{$parameter});
} else {
-   print "  _undescribed_\n";
+   print "  *undescribed*\n";
}
print "\n";
 }
-- 
2.1.4



[PATCH v2 32/38] Documentation/sphinx: fix kernel-doc extension on python3

2016-06-04 Thread Jani Nikula
Reconcile differences between python2 and python3 on dealing with
stdout, stderr from Popen. This fixes "name 'unicode' is not defined"
errors on python3. We'll need to try to keep the extension working on
both python-sphinx and python3-sphinx so we don't need two copies.

Reported-and-tested-by: Marius Vlad 
Signed-off-by: Jani Nikula 
---
 Documentation/sphinx/kernel-doc.py | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Documentation/sphinx/kernel-doc.py 
b/Documentation/sphinx/kernel-doc.py
index 87a1332fe934..a6e170872c8a 100644
--- a/Documentation/sphinx/kernel-doc.py
+++ b/Documentation/sphinx/kernel-doc.py
@@ -23,6 +23,9 @@
 #
 # Authors:
 #Jani Nikula 
+#
+# Please make sure this works on both python2 and python3.
+#
 
 import os
 import subprocess
@@ -75,8 +78,10 @@ class KernelDocDirective(Directive):
 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, universal_newlines=True)
 out, err = p.communicate()
 
-# assume the kernel sources are utf-8
-out, err = unicode(out, 'utf-8'), unicode(err, 'utf-8')
+# python2 needs conversion to unicode.
+# python3 with universal_newlines=True returns strings.
+if sys.version_info.major < 3:
+out, err = unicode(out, 'utf-8'), unicode(err, 'utf-8')
 
 if p.returncode != 0:
 sys.stderr.write(err)
-- 
2.1.4



[PATCH v2 33/38] doc/sphinx: Pass right filename as source

2016-06-04 Thread Jani Nikula
From: Daniel Vetter 

With this error output becomes almost readable. The line numbers are
still totally bonghits, but that's a lot harder to pull out of
kerneldoc. We'd essentially have to insert some special markers in the
kernel-doc output, split the output along these markers and then
insert each block separately using

 state_machine.insert_input(block, source, first_line)

Cc: Jani Nikula 
Cc: linux-...@vger.kernel.org
Cc: Jonathan Corbet 
Signed-off-by: Daniel Vetter 
Signed-off-by: Jani Nikula 
---
 Documentation/sphinx/kernel-doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/sphinx/kernel-doc.py 
b/Documentation/sphinx/kernel-doc.py
index a6e170872c8a..9fc2c27916a9 100644
--- a/Documentation/sphinx/kernel-doc.py
+++ b/Documentation/sphinx/kernel-doc.py
@@ -57,7 +57,7 @@ class KernelDocDirective(Directive):
 env.note_dependency(os.path.abspath(filename))
 
 tab_width = self.options.get('tab-width', 
self.state.document.settings.tab_width)
-source = self.state_machine.input_lines.source(self.lineno - 
self.state_machine.input_offset - 1)
+source = filename
 
 # FIXME: make this nicer and more robust against errors
 if 'export' in self.options:
-- 
2.1.4



[PATCH v2 34/38] scripts/kernel-doc: Remove duplicated DOC: start handling

2016-06-04 Thread Jani Nikula
From: Daniel Vetter 

Further up in the state machinery we switch from STATE_NAME to
STATE_DOCBLOCK when we match /$doc_block/. Which means this block of
code here is entirely unreachable, unless there are multiple DOC:
sections within a single kernel-doc comment.

Getting a list of all the files with more than one DOC: section using

$ git grep -c " * DOC:" | grep -v ":1$"

and then doing a full audit of them reveals there are no such comment
blocks in the kernel.

Supporting multiple DOC: sections in a single kernel-doc comment does
not seem like a recommended way of doing things anyway, so nuke the code
for simplicity.

Cc: Jani Nikula 
Cc: linux-...@vger.kernel.org
Cc: Jonathan Corbet 
Signed-off-by: Daniel Vetter 
[Jani: amended the commit message]
Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 19 +--
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 0eb2e7b5bf10..9fb26d142a56 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2942,24 +2942,7 @@ sub process_file($) {
process_state3_type($_, $file);
}
} elsif ($state == STATE_DOCBLOCK) {
-   # Documentation block
-   if (/$doc_block/) {
-   dump_doc_section($file, $section, 
xml_escape($contents));
-   $contents = "";
-   $function = "";
-   %parameterdescs = ();
-   %parametertypes = ();
-   @parameterlist = ();
-   %sections = ();
-   @sectionlist = ();
-   $prototype = "";
-   if ( $1 eq "" ) {
-   $section = $section_intro;
-   } else {
-   $section = $1;
-   }
-   }
-   elsif (/$doc_end/)
+   if (/$doc_end/)
{
dump_doc_section($file, $section, 
xml_escape($contents));
$section = $section_default;
-- 
2.1.4



[PATCH v2 24/38] kernel-doc/rst: change the output layout

2016-06-04 Thread Jani Nikula
Move away from field lists, and simply use **strong emphasis** for
section headings on lines of their own. Do not use rst section headings,
because their nesting depth depends on the surrounding context, which
kernel-doc has no knowledge of. Also, they do not need to end up in any
table of contexts or indexes.

There are two related immediate benefits. Field lists are typically
rendered in two columns, while the new style uses the horizontal width
better. With no extra indent on the left, there's no need to be as fussy
about it. Field lists are more susceptible to indentation problems than
the new style.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e8ea295567a3..4f559de8b173 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1823,23 +1823,23 @@ sub output_function_rst(%) {
 output_highlight_rst($args{'purpose'});
 print "\n";
 
-print ":Parameters:\n\n";
-$lineprefix = "";
+print "**Parameters**\n\n";
+$lineprefix = "  ";
 foreach $parameter (@{$args{'parameterlist'}}) {
my $parameter_name = $parameter;
#$parameter_name =~ s/\[.*//;
$type = $args{'parametertypes'}{$parameter};
 
if ($type ne "") {
-   print "  ``$type $parameter``\n";
+   print "``$type $parameter``\n";
} else {
-   print "  ``$parameter``\n";
+   print "``$parameter``\n";
}
if (defined($args{'parameterdescs'}{$parameter_name}) &&
$args{'parameterdescs'}{$parameter_name} ne $undescribed) {
output_highlight_rst($args{'parameterdescs'}{$parameter_name});
} else {
-   print "\n_undescribed_\n";
+   print "  _undescribed_\n";
}
print "\n";
 }
@@ -1852,10 +1852,10 @@ sub output_section_rst(%) {
 my %args = %{$_[0]};
 my $section;
 my $oldprefix = $lineprefix;
-$lineprefix = "";
+$lineprefix = "";
 
 foreach $section (@{$args{'sectionlist'}}) {
-   print ":$section:\n\n";
+   print "**$section**\n\n";
output_highlight_rst($args{'sections'}{$section});
print "\n";
 }
@@ -1875,14 +1875,14 @@ sub output_enum_rst(%) {
 output_highlight_rst($args{'purpose'});
 print "\n";
 
-print "..\n\n:Constants:\n\n";
-$lineprefix = "";
+print "**Constants**\n\n";
+$lineprefix = "  ";
 foreach $parameter (@{$args{'parameterlist'}}) {
-   print "  `$parameter`\n";
+   print "``$parameter``\n";
if ($args{'parameterdescs'}{$parameter} ne $undescribed) {
output_highlight_rst($args{'parameterdescs'}{$parameter});
} else {
-   print "undescribed\n";
+   print "  _undescribed_\n";
}
print "\n";
 }
@@ -1918,12 +1918,12 @@ sub output_struct_rst(%) {
 output_highlight_rst($args{'purpose'});
 print "\n";
 
-print ":Definition:\n\n";
-print " ::\n\n";
+print "**Definition**\n\n";
+print "::\n\n";
 print "  " . $args{'type'} . " " . $args{'struct'} . " {\n";
 foreach $parameter (@{$args{'parameterlist'}}) {
if ($parameter =~ /^#/) {
-   print "" . "$parameter\n";
+   print "  " . "$parameter\n";
next;
}
 
@@ -1944,8 +1944,8 @@ sub output_struct_rst(%) {
 }
 print "  };\n\n";
 
-print ":Members:\n\n";
-$lineprefix = "";
+print "**Members**\n\n";
+$lineprefix = "  ";
 foreach $parameter (@{$args{'parameterlist'}}) {
($parameter =~ /^#/) && next;
 
@@ -1954,7 +1954,7 @@ sub output_struct_rst(%) {
 
($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
$type = $args{'parametertypes'}{$parameter};
-   print "  `$type $parameter`" . "\n";
+   print "``$type $parameter``\n";
output_highlight_rst($args{'parameterdescs'}{$parameter_name});
print "\n";
 }
-- 
2.1.4



[PATCH v2 21/38] kernel-doc: fix wrong code indentation

2016-06-04 Thread Jani Nikula
No functional changes.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index f795660dfc7b..c154c3205df1 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2878,7 +2878,7 @@ sub process_file($) {
   substr($contents, 0, 1) eq "\t") {
$contents = substr($contents, 1);
}
-   $contents .= "\n";
+   $contents .= "\n";
}
$inline_doc_state = STATE_INLINE_TEXT;
# Documentation block end */
-- 
2.1.4



[PATCH v2 23/38] kernel-doc: strip leading blank lines from inline doc comments

2016-06-04 Thread Jani Nikula
The inline member markup allows whitespace lines before the actual
documentation starts. Strip the leading blank lines. This improves the
rst output.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 4 
 1 file changed, 4 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index a89ff3ca366c..e8ea295567a3 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2889,6 +2889,10 @@ sub process_file($) {
} elsif (/$doc_content/) {
if ($inline_doc_state == STATE_INLINE_TEXT) {
$contents .= $1 . "\n";
+   # nuke leading blank lines
+   if ($contents =~ /^\s*$/) {
+   $contents = "";
+   }
} elsif ($inline_doc_state == STATE_INLINE_NAME) {
$inline_doc_state = STATE_INLINE_ERROR;
print STDERR "Warning(${file}:$.): ";
-- 
2.1.4



[PATCH v2 31/38] kernel-doc: reset contents and section harder

2016-06-04 Thread Jani Nikula
If the documentation comment does not have params or sections, the
section heading may leak from the previous documentation comment.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 3ac4b57ed76a..0eb2e7b5bf10 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2763,6 +2763,8 @@ sub process_file($) {
}
 
$state = STATE_FIELD;
+   $contents = "";
+   $section = $section_default;
if (/-(.*)/) {
# strip leading/trailing/multiple spaces
$descr= $1;
@@ -2960,6 +2962,7 @@ sub process_file($) {
elsif (/$doc_end/)
{
dump_doc_section($file, $section, 
xml_escape($contents));
+   $section = $section_default;
$contents = "";
$function = "";
%parameterdescs = ();
-- 
2.1.4



[PATCH v2 22/38] kernel-doc/rst: blank lines in output are not needed

2016-06-04 Thread Jani Nikula
Current approach leads to two blank lines, while one is enough.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index c154c3205df1..a89ff3ca366c 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1786,12 +1786,7 @@ sub output_highlight_rst {
 die $@ if $@;
 
 foreach $line (split "\n", $contents) {
-   if ($line eq "") {
-   print $lineprefix, $blankline;
-   } else {
-   print $lineprefix, $line;
-   }
-   print "\n";
+   print $lineprefix . $line . "\n";
 }
 }
 
-- 
2.1.4



[PATCH v2 25/38] kernel-doc: improve handling of whitespace on the first line param description

2016-06-04 Thread Jani Nikula
Handle whitespace on the first line of param text as if it was the empty
string. There is no need to add the newline in this case. This improves
the rst output in particular, where blank lines may be problematic in
parameter lists.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 4f559de8b173..e93e796b17ce 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2814,11 +2814,11 @@ sub process_file($) {
$in_doc_sect = 1;
$in_purpose = 0;
$contents = $newcontents;
+   while ((substr($contents, 0, 1) eq " ") ||
+  substr($contents, 0, 1) eq "\t") {
+   $contents = substr($contents, 1);
+   }
if ($contents ne "") {
-   while ((substr($contents, 0, 1) eq " ") ||
-   substr($contents, 0, 1) eq "\t") {
-   $contents = substr($contents, 1);
-   }
$contents .= "\n";
}
$section = $newsection;
-- 
2.1.4



[PATCH v2 30/38] kernel-doc: concatenate contents of colliding sections

2016-06-04 Thread Jani Nikula
If there are multiple sections with the same section name, the current
implementation results in several sections by the same heading, with the
content duplicated from the last section to all. Even if there's the
error message, a more graceful approach is to combine all the
identically named sections into one, with concatenated contents.

With the supported sections already limited to select few, there are
massively fewer collisions than there used to be, but this is still
useful for e.g. when function parameters are documented in the middle of
a documentation comment, with description spread out above and
below. (This is not a recommended documentation style, but used in the
kernel nonetheless.)

We can now also demote the error to a warning.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 20136564f264..3ac4b57ed76a 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -524,11 +524,13 @@ sub dump_section {
 } else {
 #  print STDERR "other section '$name' = '$contents'\n";
if (defined($sections{$name}) && ($sections{$name} ne "")) {
-   print STDERR "${file}:$.: error: duplicate section name 
'$name'\n";
-   ++$errors;
+   print STDERR "${file}:$.: warning: duplicate section name 
'$name'\n";
+   ++$warnings;
+   $sections{$name} .= $contents;
+   } else {
+   $sections{$name} = $contents;
+   push @sectionlist, $name;
}
-   $sections{$name} = $contents;
-   push @sectionlist, $name;
 }
 }
 
-- 
2.1.4



Re: [PATCH 00/10] Documentation/Sphinx

2016-06-04 Thread Jani Nikula
On Sat, 04 Jun 2016, Jonathan Corbet  wrote:
> On Mon, 30 May 2016 23:05:34 +0300
> Jani Nikula  wrote:
>
>> To be clear, the "sphinx-for-docs-next" branch of [1], [2] is what I
>> propose to merge at this time. There's the Sphinx configuration, kernel
>> build integration, Sphinx kernel-doc extension, tons of kernel-doc
>> updates, etc. 
>
> OK, I do believe that I am ready to do that.  Many, many thanks for doing
> this work!  Please drop me a note when you think that the branch is ready
> to go.

In case you missed the patch bomb in your inbox, I think it's ready
now. ;)

>> There is no DocBook tmpl conversion; all of that is left
>> to the authors (owners, maintainers) of the documents, but this enables
>> them to focus on that part.
>
> I would like to have some actual documents in there in the near future,
> so that interested folks have something to look at and start with.  Maybe
> I'll do that myself with some of the docbooks without active maintainers,
> or even, maybe, some of the .txt files :)

So we'll be working on gpu.tmpl next and I'll look at
Documentation/kernel-doc-nano-HOWTO.txt too.

BR,
Jani.



-- 
Jani Nikula, Intel Open Source Technology Center


Re: [PATCH V3 1/2] irqchip/gicv3-its: split its_alloc_tables() into two functions

2016-06-04 Thread Marc Zyngier
On Mon, 9 May 2016 15:58:25 -0500
Shanker Donthineni  wrote:

> The function is getting out of control, it has too many goto
> statements and would be too complicated for adding a feature
> two-level device table. So, it is time for us to cleanup and
> move some of the logic to a separate function without affecting
> the existing functionality.
> 
> Signed-off-by: Shanker Donthineni 
> ---
>  drivers/irqchip/irq-gic-v3-its.c   | 256 
> -
>  include/linux/irqchip/arm-gic-v3.h |   3 +
>  2 files changed, 144 insertions(+), 115 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c 
> b/drivers/irqchip/irq-gic-v3-its.c
> index 6bd881b..b23e00c 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -55,13 +55,15 @@ struct its_collection {
>  };
>  
>  /*
> - * The ITS_BASER structure - contains memory information and cached
> - * value of BASER register configuration.
> + * The ITS_BASER structure - contains memory information, cached value
> + * of BASER register configuration, ioremaped address and page size.
>   */
>  struct its_baser {
> + void __iomem*hwreg;
>   void*base;
>   u64 val;
>   u32 order;
> + u32 psz;
>  };
>  
>  /*
> @@ -823,27 +825,135 @@ static void its_free_tables(struct its_node *its)
>   }
>  }
>  
> +static int its_baser_setup(struct its_node *its, struct its_baser *baser,
> +   u32 order, u64 indirect)
> +{
> + u64 val = readq_relaxed(baser->hwreg);
> + u64 type = GITS_BASER_TYPE(val);
> + u64 entry_size = GITS_BASER_ENTRY_SIZE(val);
> + int psz, alloc_pages;
> + u64 cache, shr, tmp;
> + void *base;
> +
> + /* Do first attempt with the requested attributes */
> + cache = baser->val & GITS_BASER_CACHEABILITY_MASK;
> + shr = baser->val & GITS_BASER_SHAREABILITY_MASK;
> + psz = baser->psz;
> +
> +retry_alloc_baser:
> + alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz);
> + if (alloc_pages > GITS_BASER_PAGES_MAX) {
> + pr_warn("ITS@%lx: %s too large, reduce ITS pages %u->%u\n",
> + its->phys_base, its_base_type_string[type],
> + alloc_pages, GITS_BASER_PAGES_MAX);

By the way: as you're changing the output of various messages, please
use %pa instead of %lx (and make sure you're passing the parameter by
reference...).

Thanks,

M.
-- 
Jazz is not dead. It just smells funny.


[PATCH v2 19/38] kernel-doc/rst: highlight function/struct/enum purpose lines too

2016-06-04 Thread Jani Nikula
Let the user use @foo, &bar, %baz, etc. in the first kernel-doc purpose
line too.

Signed-off-by: Jani Nikula 
---
 scripts/kernel-doc | 37 +
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 8f9eac509377..76bad55c031e 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1805,6 +1805,7 @@ sub output_highlight_rst {
 sub output_function_rst(%) {
 my %args = %{$_[0]};
 my ($parameter, $section);
+my $oldprefix = $lineprefix;
 my $start;
 
 print ".. c:function:: ";
@@ -1829,9 +1830,13 @@ sub output_function_rst(%) {
print $type . " " . $parameter;
}
 }
-print ")\n\n" . $args{'purpose'} . "\n\n";
+print ")\n\n";
+$lineprefix = "   ";
+output_highlight_rst($args{'purpose'});
+print "\n";
 
 print ":Parameters:\n\n";
+$lineprefix = "";
 foreach $parameter (@{$args{'parameterlist'}}) {
my $parameter_name = $parameter;
#$parameter_name =~ s/\[.*//;
@@ -1844,15 +1849,14 @@ sub output_function_rst(%) {
}
if (defined($args{'parameterdescs'}{$parameter_name}) &&
$args{'parameterdescs'}{$parameter_name} ne $undescribed) {
-   my $oldprefix = $lineprefix;
-   $lineprefix = "";
output_highlight_rst($args{'parameterdescs'}{$parameter_name});
-   $lineprefix = $oldprefix;
} else {
print "\n_undescribed_\n";
}
print "\n";
 }
+
+$lineprefix = $oldprefix;
 output_section_rst(@_);
 }
 
@@ -1874,14 +1878,16 @@ sub output_section_rst(%) {
 sub output_enum_rst(%) {
 my %args = %{$_[0]};
 my ($parameter);
+my $oldprefix = $lineprefix;
 my $count;
 my $name = "enum " . $args{'enum'};
 
 print "\n\n.. c:type:: " . $name . "\n\n";
-print "" . $args{'purpose'} . "\n\n";
+$lineprefix = "   ";
+output_highlight_rst($args{'purpose'});
+print "\n";
 
 print "..\n\n:Constants:\n\n";
-my $oldprefix = $lineprefix;
 $lineprefix = "";
 foreach $parameter (@{$args{'parameterlist'}}) {
print "  `$parameter`\n";
@@ -1892,6 +1898,7 @@ sub output_enum_rst(%) {
}
print "\n";
 }
+
 $lineprefix = $oldprefix;
 output_section_rst(@_);
 }
@@ -1899,23 +1906,29 @@ sub output_enum_rst(%) {
 sub output_typedef_rst(%) {
 my %args = %{$_[0]};
 my ($parameter);
-my $count;
+my $oldprefix = $lineprefix;
 my $name = "typedef " . $args{'typedef'};
 
 ### FIXME: should the name below contain "typedef" or not?
 print "\n\n.. c:type:: " . $name . "\n\n";
-print "" . $args{'purpose'} . "\n\n";
+$lineprefix = "   ";
+output_highlight_rst($args{'purpose'});
+print "\n";
 
+$lineprefix = $oldprefix;
 output_section_rst(@_);
 }
 
 sub output_struct_rst(%) {
 my %args = %{$_[0]};
 my ($parameter);
+my $oldprefix = $lineprefix;
 my $name = $args{'type'} . " " . $args{'struct'};
 
 print "\n\n.. c:type:: " . $name . "\n\n";
-print "" . $args{'purpose'} . "\n\n";
+$lineprefix = "   ";
+output_highlight_rst($args{'purpose'});
+print "\n";
 
 print ":Definition:\n\n";
 print " ::\n\n";
@@ -1944,6 +1957,7 @@ sub output_struct_rst(%) {
 print "  };\n\n";
 
 print ":Members:\n\n";
+$lineprefix = "";
 foreach $parameter (@{$args{'parameterlist'}}) {
($parameter =~ /^#/) && next;
 
@@ -1953,13 +1967,12 @@ sub output_struct_rst(%) {
($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
$type = $args{'parametertypes'}{$parameter};
print "  `$type $parameter`" . "\n";
-   my $oldprefix = $lineprefix;
-   $lineprefix = "";
output_highlight_rst($args{'parameterdescs'}{$parameter_name});
-   $lineprefix = $oldprefix;
print "\n";
 }
 print "\n";
+
+$lineprefix = $oldprefix;
 output_section_rst(@_);
 }
 
-- 
2.1.4



[PATCH v2 09/38] sphinx: update docbook->rst conversion script match C domain spec

2016-06-04 Thread Jani Nikula
Function references should include the parens (), struct references
should not include "struct".

Signed-off-by: Jani Nikula 
---
 Documentation/sphinx/convert_template.sed | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/sphinx/convert_template.sed 
b/Documentation/sphinx/convert_template.sed
index d53bb8220a26..0553eabeac79 100644
--- a/Documentation/sphinx/convert_template.sed
+++ b/Documentation/sphinx/convert_template.sed
@@ -4,10 +4,10 @@
 #
 # Use "$bq" instead of "`" so that pandoc won't mess with it.
 #
-s%\([^<(]\+\)()%:c:func:$bq\1$bq%g
-s%\([^<(]\+\)%:c:func:$bq\1$bq%g
-s%struct *\([^<]\+\)%:ref:$bqstruct \1$bq%g
-s%\([^<]\+\)%:ref:$bqstruct \1$bq%g
+s%\([^<(]\+\)()%:c:func:$bq\1()$bq%g
+s%\([^<(]\+\)%:c:func:$bq\1()$bq%g
+s%struct *\([^<]\+\)%:c:type:$bq\1$bq%g
+s%\([^<]\+\)%:c:type:$bq\1$bq%g
 #
 # Wrap docproc directives in para and code blocks.
 #
-- 
2.1.4



[PATCH v2 07/38] Documentation/sphinx: set version and release properly

2016-06-04 Thread Jani Nikula
Read the version and release from the top level Makefile (for use when
Sphinx is invoked directly, by e.g. Read the Docs), but override them
via Sphinx command line arguments in a normal documentation build.

Signed-off-by: Jani Nikula 
---
 Documentation/Makefile.sphinx |  2 +-
 Documentation/conf.py | 29 +
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/Documentation/Makefile.sphinx b/Documentation/Makefile.sphinx
index 8a662be9bd87..addf32309bc3 100644
--- a/Documentation/Makefile.sphinx
+++ b/Documentation/Makefile.sphinx
@@ -27,7 +27,7 @@ PAPEROPT_a4 = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
 KERNELDOC   = $(srctree)/scripts/kernel-doc
 KERNELDOC_CONF  = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
-ALLSPHINXOPTS   = -d $(BUILDDIR)/.doctrees $(KERNELDOC_CONF) 
$(PAPEROPT_$(PAPER)) -c $(srctree)/$(src) $(SPHINXOPTS) $(srctree)/$(src)
+ALLSPHINXOPTS   = -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) -d 
$(BUILDDIR)/.doctrees $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) -c 
$(srctree)/$(src) $(SPHINXOPTS) $(srctree)/$(src)
 # the i18n builder cannot share the environment and doctrees with the others
 I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
diff --git a/Documentation/conf.py b/Documentation/conf.py
index 8b72577f38f5..6cc41a0555a3 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -60,10 +60,31 @@ author = 'The kernel development community'
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
-# The short X.Y version.
-version = '4.5'
-# The full version, including alpha/beta/rc tags.
-release = '4.5'
+# In a normal build, version and release are are set to KERNELVERSION and
+# KERNELRELEASE, respectively, from the Makefile via Sphinx command line
+# arguments.
+#
+# The following code tries to extract the information by reading the Makefile,
+# when Sphinx is run directly (e.g. by Read the Docs).
+try:
+makefile_version = None
+makefile_patchlevel = None
+for line in open('../Makefile'):
+key, val = [x.strip() for x in line.split('=', 2)]
+if key == 'VERSION':
+makefile_version = val
+elif key == 'PATCHLEVEL':
+makefile_patchlevel = val
+if makefile_version and makefile_patchlevel:
+break
+except:
+pass
+finally:
+if makefile_version and makefile_patchlevel:
+version = release = makefile_version + '.' + makefile_patchlevel
+else:
+sys.stderr.write('Warning: Could not extract kernel version\n')
+version = release = "unknown version"
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
-- 
2.1.4



[PATCH v2 06/38] Documentation/sphinx: configure the kernel-doc extension

2016-06-04 Thread Jani Nikula
Tell Sphinx where to find the extension, and pass on the kernel src tree
and kernel-doc paths to the extension.

With this, any .rst files under Documentation may contain the kernel-doc
rst directive to include kernel-doc documentation from any source file.

While building, it may be handy to pass kernel-doc extension
configuration on the command line. For example, 'make SPHINXOPTS="-D
kerneldoc_verbosity=0" htmldocs' silences all stderr output from
kernel-doc when the kernel-doc exit code is 0. (The stderr will be
logged unconditionally when the exit code is non-zero.)

Signed-off-by: Jani Nikula 
---
 Documentation/Makefile.sphinx |  4 +++-
 Documentation/conf.py | 10 --
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/Makefile.sphinx b/Documentation/Makefile.sphinx
index 25a7970bfe5c..8a662be9bd87 100644
--- a/Documentation/Makefile.sphinx
+++ b/Documentation/Makefile.sphinx
@@ -25,7 +25,9 @@ HAVE_RST2PDF := $(shell if python -c "import rst2pdf" 
>/dev/null 2>&1; then echo
 # Internal variables.
 PAPEROPT_a4 = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = -d $(BUILDDIR)/.doctrees $(PAPEROPT_$(PAPER)) -c 
$(srctree)/$(src) $(SPHINXOPTS) $(srctree)/$(src)
+KERNELDOC   = $(srctree)/scripts/kernel-doc
+KERNELDOC_CONF  = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
+ALLSPHINXOPTS   = -d $(BUILDDIR)/.doctrees $(KERNELDOC_CONF) 
$(PAPEROPT_$(PAPER)) -c $(srctree)/$(src) $(SPHINXOPTS) $(srctree)/$(src)
 # the i18n builder cannot share the environment and doctrees with the others
 I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
diff --git a/Documentation/conf.py b/Documentation/conf.py
index 0f0e20757bb1..8b72577f38f5 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -18,7 +18,7 @@ import os
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+sys.path.insert(0, os.path.abspath('sphinx'))
 
 # -- General configuration 
 
@@ -28,7 +28,7 @@ import os
 # Add any Sphinx extension module names here, as strings. They can be
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 # ones.
-extensions = []
+extensions = ['kernel-doc']
 
 # Gracefully handle missing rst2pdf.
 try:
@@ -385,3 +385,9 @@ epub_exclude_files = ['search.html']
 pdf_documents = [
 ('index', u'Kernel', u'Kernel', u'J. Random Bozo'),
 ]
+
+# kernel-doc extension configuration for running Sphinx directly (e.g. by Read
+# the Docs). In a normal build, these are supplied from the Makefile via 
command
+# line arguments.
+kerneldoc_bin = '../scripts/kernel-doc'
+kerneldoc_srctree = '..'
-- 
2.1.4



[PATCH] drivers: ssb: Change bare unsigned to unsigned int to suit coding style

2016-06-04 Thread Hugh Sipière
These lines just have unsigned gpio rather than unsigned int gpio.
I changed it to suit the coding style.

Signed-off-by: Hugh Sipière 
---
 drivers/ssb/driver_gpio.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/ssb/driver_gpio.c b/drivers/ssb/driver_gpio.c
index 180e027..796e220 100644
--- a/drivers/ssb/driver_gpio.c
+++ b/drivers/ssb/driver_gpio.c
@@ -23,7 +23,7 @@
  **/
 
 #if IS_ENABLED(CONFIG_SSB_EMBEDDED)
-static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
+static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned int gpio)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
@@ -38,14 +38,14 @@ static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned 
gpio)
  * ChipCommon
  **/
 
-static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned gpio)
+static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned int gpio)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
return !!ssb_chipco_gpio_in(&bus->chipco, 1 << gpio);
 }
 
-static void ssb_gpio_chipco_set_value(struct gpio_chip *chip, unsigned gpio,
+static void ssb_gpio_chipco_set_value(struct gpio_chip *chip, unsigned int 
gpio,
  int value)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
@@ -54,7 +54,7 @@ static void ssb_gpio_chipco_set_value(struct gpio_chip *chip, 
unsigned gpio,
 }
 
 static int ssb_gpio_chipco_direction_input(struct gpio_chip *chip,
-  unsigned gpio)
+  unsigned int gpio)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
@@ -63,7 +63,7 @@ static int ssb_gpio_chipco_direction_input(struct gpio_chip 
*chip,
 }
 
 static int ssb_gpio_chipco_direction_output(struct gpio_chip *chip,
-   unsigned gpio, int value)
+   unsigned int gpio, int value)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
@@ -72,7 +72,7 @@ static int ssb_gpio_chipco_direction_output(struct gpio_chip 
*chip,
return 0;
 }
 
-static int ssb_gpio_chipco_request(struct gpio_chip *chip, unsigned gpio)
+static int ssb_gpio_chipco_request(struct gpio_chip *chip, unsigned int gpio)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
@@ -85,7 +85,7 @@ static int ssb_gpio_chipco_request(struct gpio_chip *chip, 
unsigned gpio)
return 0;
 }
 
-static void ssb_gpio_chipco_free(struct gpio_chip *chip, unsigned gpio)
+static void ssb_gpio_chipco_free(struct gpio_chip *chip, unsigned int gpio)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
@@ -256,14 +256,14 @@ static int ssb_gpio_chipco_init(struct ssb_bus *bus)
 
 #ifdef CONFIG_SSB_DRIVER_EXTIF
 
-static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned gpio)
+static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned int gpio)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
return !!ssb_extif_gpio_in(&bus->extif, 1 << gpio);
 }
 
-static void ssb_gpio_extif_set_value(struct gpio_chip *chip, unsigned gpio,
+static void ssb_gpio_extif_set_value(struct gpio_chip *chip, unsigned int gpio,
 int value)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
@@ -272,7 +272,7 @@ static void ssb_gpio_extif_set_value(struct gpio_chip 
*chip, unsigned gpio,
 }
 
 static int ssb_gpio_extif_direction_input(struct gpio_chip *chip,
- unsigned gpio)
+ unsigned int gpio)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
@@ -281,7 +281,7 @@ static int ssb_gpio_extif_direction_input(struct gpio_chip 
*chip,
 }
 
 static int ssb_gpio_extif_direction_output(struct gpio_chip *chip,
-  unsigned gpio, int value)
+  unsigned int gpio, int value)
 {
struct ssb_bus *bus = gpiochip_get_data(chip);
 
-- 
2.5.5



Re: [PATCH] drivers: ssb: Fix comments to suit coding style

2016-06-04 Thread Michael Büsch
On Sat,  4 Jun 2016 12:32:13 +0100
Hugh Sipière  wrote:

> I changed it so that these two comments do not end on a line with text.
> 
> Signed-off-by: Hugh Sipière 
> ---
>  drivers/ssb/driver_gpio.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ssb/driver_gpio.c b/drivers/ssb/driver_gpio.c
> index 180e027..f2435f3 100644
> --- a/drivers/ssb/driver_gpio.c
> +++ b/drivers/ssb/driver_gpio.c
> @@ -231,7 +231,8 @@ static int ssb_gpio_chipco_init(struct ssb_bus *bus)
>   chip->ngpio = 16;
>   /* There is just one SoC in one device and its GPIO addresses should be
>* deterministic to address them more easily. The other buses could get
> -  * a random base number. */
> +  * a random base number.
> +  */
>   if (bus->bustype == SSB_BUSTYPE_SSB)
>   chip->base  = 0;
>   else
> @@ -424,7 +425,8 @@ static int ssb_gpio_extif_init(struct ssb_bus *bus)
>   chip->ngpio = 5;
>   /* There is just one SoC in one device and its GPIO addresses should be
>* deterministic to address them more easily. The other buses could get
> -  * a random base number. */
> +  * a random base number.
> +  */
>   if (bus->bustype == SSB_BUSTYPE_SSB)
>   chip->base  = 0;
>   else


What's the benefit from this change?
Will the next person submit a patch to remove wasted lines that just
contain a */?


-- 
Michael


pgpwHFL4sJekp.pgp
Description: OpenPGP digital signature


Re: [PATCH V5 5/7] irqchip, gicv3, its: Probe ITS in the ACPI way.

2016-06-04 Thread Marc Zyngier
On Tue, 31 May 2016 13:19:42 +0200
Tomasz Nowicki  wrote:

> ITS is prepared for being initialized different than DT,
> therefore we can initialize it in ACPI way. We collect register base
> address from MADT table and pass mandatory info to firmware-agnostic
> ITS init call.
> 
> Note that we are using here IORT lib to register ITS domain which
> then can be found and used on to build another PCI MSI domain
> in hierarchical stack domain.
> 
> Signed-off-by: Tomasz Nowicki 
> ---
>  drivers/irqchip/Kconfig  |  1 +
>  drivers/irqchip/irq-gic-v3-its.c | 60 
> 
>  2 files changed, 61 insertions(+)
> 
> diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
> index fa33c50..c6e652f 100644
> --- a/drivers/irqchip/Kconfig
> +++ b/drivers/irqchip/Kconfig
> @@ -32,6 +32,7 @@ config ARM_GIC_V3
>  config ARM_GIC_V3_ITS
>   bool
>   select PCI_MSI_IRQ_DOMAIN
> + select IORT_TABLE if ACPI
>  
>  config ARM_NVIC
>   bool
> diff --git a/drivers/irqchip/irq-gic-v3-its.c 
> b/drivers/irqchip/irq-gic-v3-its.c
> index 6a97ee5..c8f36a5 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -15,10 +15,13 @@
>   * along with this program.  If not, see .
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1312,6 +1315,11 @@ static int its_irq_gic_domain_alloc(struct irq_domain 
> *domain,
>   fwspec.param[0] = GIC_IRQ_TYPE_LPI;
>   fwspec.param[1] = hwirq;
>   fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
> + } else if (is_fwnode_irqchip(domain->parent->fwnode)) {
> + fwspec.fwnode = domain->parent->fwnode;
> + fwspec.param_count = 2;
> + fwspec.param[0] = hwirq;
> + fwspec.param[1] = IRQ_TYPE_EDGE_RISING;
>   } else {
>   return -EINVAL;
>   }
> @@ -1645,6 +1653,56 @@ static int __init its_of_probe(struct device_node 
> *node)
>   return 0;
>  }
>  
> +#ifdef CONFIG_ACPI
> +
> +#define ACPI_GICV3_ITS_MEM_SIZE (2 * SZ_64K)

SZ_128k?

> +
> +static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header 
> *header,
> +   const unsigned long end)
> +{
> + struct acpi_madt_generic_translator *its_entry;
> + struct fwnode_handle *dom_handle;
> + struct resource res;
> + int err;
> +
> + its_entry = (struct acpi_madt_generic_translator *)header;
> + res.start = its_entry->base_address;
> + res.end = its_entry->base_address + ACPI_GICV3_ITS_MEM_SIZE - 1;
> +
> + dom_handle = irq_domain_alloc_fwnode((void *)its_entry->base_address);
> + if (!dom_handle) {
> + pr_err("ITS@%pa: Unable to allocate GICv3 ITS domain token\n",
> +&res.start);
> + return -ENOMEM;
> + }
> +
> + err = iort_register_domain_token(its_entry->translation_id, dom_handle);
> + if (err) {
> + pr_err("ITS@%pa: Unable to register GICv3 ITS domain token (ITS 
> ID %d) to IORT\n",
> +&res.start, its_entry->translation_id);
> + goto dom_err;
> + }
> +
> + err = its_probe_one(&res, dom_handle);
> + if (!err)
> + return 0;
> +
> + iort_deregister_domain_token(its_entry->translation_id);
> +dom_err:
> + irq_domain_free_fwnode(dom_handle);
> + return err;
> +}
> +
> +void __init its_acpi_probe(void)

Should be static.

> +{
> + if (acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
> +   gic_acpi_parse_madt_its, 0) <= 0)
> + pr_info("No valid GIC ITS entries exist\n");

We already have a message further down, no need to shout twice.

> +}
> +#else
> +static inline void __init its_acpi_probe(struct irq_domain *parent_domain) { 
> }

Drop the inline, the compiler can figure out that by itself.

> +#endif
> +
>  int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
>   struct irq_domain *parent_domain)
>  {
> @@ -1654,6 +1712,8 @@ int __init its_init(struct fwnode_handle *handle, 
> struct rdists *rdists,
>   of_node = to_of_node(handle);
>   if (of_node)
>   its_of_probe(of_node);
> + else
> + its_acpi_probe();
>  
>   if (list_empty(&its_nodes)) {
>   pr_warn("ITS: No ITS available, not enabling LPIs\n");


Thanks,

M.
-- 
Jazz is not dead. It just smells funny.


Re: [PATCH] drivers: ssb: Change bare unsigned to unsigned int to suit coding style

2016-06-04 Thread Michael Büsch
On Sat,  4 Jun 2016 12:50:05 +0100
Hugh Sipière  wrote:

> These lines just have unsigned gpio rather than unsigned int gpio.
> I changed it to suit the coding style.
> 
> Signed-off-by: Hugh Sipière 

Acked-by: Michael Buesch 

Please send this to the MIPS tree, because this basically is MIPS-only
code:

MIPS
M:  Ralf Baechle 
L:  linux-m...@linux-mips.org


-- 
Michael


pgpMcuwA4VOAp.pgp
Description: OpenPGP digital signature


[PATCH] ARM: dts: omap3-gta04: Add RFID eeprom node

2016-06-04 Thread Marek Belisko
From: "H. Nikolaus Schaller" 

Define RFID eeprom node which is present on gta04
device.

Signed-off-by: H. Nikolaus Schaller 
Signed-off-by: Marek Belisko 
---
 arch/arm/boot/dts/omap3-gta04.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi 
b/arch/arm/boot/dts/omap3-gta04.dtsi
index a922472..b652dae 100644
--- a/arch/arm/boot/dts/omap3-gta04.dtsi
+++ b/arch/arm/boot/dts/omap3-gta04.dtsi
@@ -433,6 +433,12 @@
gpios = <&gpio6 0 GPIO_ACTIVE_LOW>;
ti,x-plate-ohms = <600>;
};
+
+   /* RFID EEPROM */
+   m24lr64@50 {
+   compatible = "at,24c64";
+   reg = <0x50>;
+   };
 };
 
 &i2c3 {
-- 
2.5.0



Re: [PATCH V5 7/7] acpi, gicv3, its: Use MADT ITS subtable to do PCI/MSI domain initialization.

2016-06-04 Thread Marc Zyngier
On Tue, 31 May 2016 13:19:44 +0200
Tomasz Nowicki  wrote:

> Let ACPI build ITS PCI MSI domain. ACPI is responsible for retrieving
> inner domain token and passing it on to its_pci_msi_init_one generic
> init call.
> 
> We have now full PCI MSI domain stack, thus we can enable ITS initialization
> from GICv3 core driver for ACPI scenario.
> 
> Signed-off-by: Tomasz Nowicki 
> ---
>  drivers/irqchip/irq-gic-v3-its-pci-msi.c | 42 
> +++-
>  drivers/irqchip/irq-gic-v3.c |  3 +--
>  2 files changed, 42 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c 
> b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> index 23679ae..985f5d9 100644
> --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c
> @@ -15,6 +15,7 @@
>   * along with this program.  If not, see .
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -144,10 +145,49 @@ static int __init its_pci_of_msi_init(void)
>   return 0;
>  }
>  
> +#ifdef CONFIG_ACPI
> +
> +static int __init
> +its_pci_msi_parse_madt(struct acpi_subtable_header *header,
> +const unsigned long end)
> +{
> + struct acpi_madt_generic_translator *its_entry;
> + struct fwnode_handle *dom_handle;
> + char node_name[6 + 16 + 1]; // ITS identification name

Jeezus... Where is that coming from? Is that the size of "ITS@0x"+16
hex digits and a final NUL? For the sake of keeping things
maintainable/readable, please use kasprintf/kfree.

> +
> + its_entry = (struct acpi_madt_generic_translator *)header;
> + snprintf(node_name, 23, "ITS@0x%lx", (long)its_entry->base_address);
> + dom_handle = iort_its_find_domain_token(its_entry->translation_id);
> + if (!dom_handle) {
> + pr_err("%s: Unable to locate ITS domain handle\n", node_name);
> + return 0;

return 0? not even a slap on the wrist? Hum...

> + }
> +
> + if (its_pci_msi_init_one(dom_handle, node_name))
> + return 0;

Same here.

> +
> + pr_info("PCI/MSI: %s domain created\n", node_name);
> + return 0;
> +}
> +
> +static int __init its_pci_acpi_msi_init(void)
> +{
> + acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
> +   its_pci_msi_parse_madt, 0);
> + return 0;
> +}
> +#else
> +inline static int __init its_pci_acpi_msi_init(void)

static only.

> +{
> + return 0;
> +}
> +#endif
> +
>  static int __init its_pci_msi_init(void)
>  {
>   its_pci_of_msi_init();
> + its_pci_acpi_msi_init();
> +
>   return 0;
>  }
> -
>  early_initcall(its_pci_msi_init);
> diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> index cee8296..41c1cda 100644
> --- a/drivers/irqchip/irq-gic-v3.c
> +++ b/drivers/irqchip/irq-gic-v3.c
> @@ -951,8 +951,7 @@ static int __init gic_init_bases(void __iomem *dist_base,
>  
>   set_handle_irq(gic_handle_irq);
>  
> - if (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) && gic_dist_supports_lpis() &&
> - to_of_node(handle)) /* Temp hack to prevent ITS init for ACPI */
> + if (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) && gic_dist_supports_lpis())
>   its_init(handle, &gic_data.rdists, gic_data.domain);
>  
>   gic_smp_init();

Thanks,

M.
-- 
Jazz is not dead. It just smells funny.


Re: [PATCH v2 00/38] Documentation/sphinx

2016-06-04 Thread Daniel Vetter
On Sat, Jun 04, 2016 at 02:37:01PM +0300, Jani Nikula wrote:
> Jon, this is v2 of [1] and [2], with a considerable amount of polish and
> fixes added. We started dogfooding this within drm-intel, and Daniel has
> reviewed the lot and contributed a number of fixes, most notably
> accurate file and line number references from Sphinx build
> errors/warnings to the kernel-doc comments in source code.

dogfooding = our autobuilder also already eats it:

https://01.org/linuxgraphics/gfx-docs/drm/

> We believe this is now in good shape for merging for v4.8. It's all in
> my sphinx-for-docs-next branch that you've already looked at; pull
> details below.

I've read through all the patches and things look good. Now my
python/perl/sphinx fu is by far not good enough for a full review, hence
just:

Acked-by: Daniel Vetter 

It also works really nicely, we already started to land some kernel-doc
markup fixup patches for drm.

Tested-by: Daniel Vetter 

I really think this is awesome, and it's a good foundation for more polish
in the toolchain on top (like Markus' improved tables, or some of the
ideas floating around about better linting for kernel-doc). But right now
I think the next step is to convert a pile of docs and gain some
real-world experience with the tool-chain.

> When this lands in docs-next and we can backmerge to drm, we'll plunge
> ahead and convert gpu.tmpl to rst, and have that ready for v4.8. We
> think it's best to contribute that via the drm tree, as it'll involve
> splitting up the documentation and likely numerous updates to kernel-doc
> comments.

Please send me a pull request with the tag to merge into drm-misc.

> I plan to update Documentation/kernel-doc-nano-HOWTO.txt for Sphinx and
> rst, obviously converting it to rst while at it.

Cheers, Daniel

> 
> BR,
> Jani.
> 
> 
> 
> [1] http://mid.gmane.org/cover.1463748027.git.jani.nik...@intel.com
> [2] http://mid.gmane.org/877fec7gfm@intel.com
> 
> The following changes since commit 1a695a905c18548062509178b98bc91e67510864:
> 
>   Linux 4.7-rc1 (2016-05-29 09:29:24 -0700)
> 
> are available in the git repository at:
> 
>   git://people.freedesktop.org/~jani/drm sphinx-for-docs-next
> 
> for you to fetch changes up to d90368f2fa7ded7c56d214aef087e88bba5199e7:
> 
>   doc/sphinx: Track line-number of starting blocks (2016-06-04 11:35:59 +0300)
> 
> 
> Daniel Vetter (6):
>   doc/sphinx: Pass right filename as source
>   scripts/kernel-doc: Remove duplicated DOC: start handling
>   doc/sphinx: Stop touching state_machine internals
>   scripts/kernel-doc: Also give functions symbolic names
>   scripts/kernel-doc: Add option to inject line numbers
>   doc/sphinx: Track line-number of starting blocks
> 
> Jani Nikula (31):
>   kernel-doc/rst: fix use of uninitialized value
>   kernel-doc: support printing exported and non-exported symbols
>   Documentation/sphinx: add basic working Sphinx configuration and build
>   Documentation: add .gitignore
>   Documentation/sphinx: add Sphinx kernel-doc directive extension
>   Documentation/sphinx: configure the kernel-doc extension
>   Documentation/sphinx: set version and release properly
>   sphinx: update docbook->rst conversion script match C domain spec
>   Documentation/sphinx: nicer referencing of struct in docbook->rst 
> conversion
>   kernel-doc: add names for states and substates
>   kernel-doc: add names for output selection
>   kernel-doc/rst: do not output DOC: section titles for requested ones
>   kernel-doc/rst: reference functions according to C domain spec
>   kernel-doc/rst: &foo references are more universal than structs
>   kernel-doc/rst: add support for &union foo and &typedef foo references
>   kernel-doc/rst: add support for struct/union/enum member references
>   kernel-doc/rst: drop redundant unescape in highlighting
>   kernel-doc/rst: highlight function/struct/enum purpose lines too
>   kernel-doc: do not regard $, %, or & prefixes as special in section 
> names
>   kernel-doc: fix wrong code indentation
>   kernel-doc/rst: blank lines in output are not needed
>   kernel-doc: strip leading blank lines from inline doc comments
>   kernel-doc/rst: change the output layout
>   kernel-doc: improve handling of whitespace on the first line param 
> description
>   kernel-doc: strip leading whitespace from continued param descs
>   kernel-doc/rst: use *undescribed* instead of _undescribed_
>   kernel-doc/rst: remove fixme comment
>   kernel-doc: limit the "section header:" detection to a select few
>   kernel-doc: concatenate contents of colliding sections
>   kernel-doc: reset contents and section harder
>   Documentation/sphinx: fix kernel-doc extension on python3
> 
> Jonathan Corbet (1):
>   sphinx: cheesy script to convert .tmpl files
> 
>  Documentation/.gitignore   

Re: [PATCH 5/5] intel_idle: Add S0ix validation

2016-06-04 Thread Alan
> I would expect those IP blocks to do nothing and not block lower power
> states if the firmware is not loaded. If that is not the case, I think
> that should be fixed such that those lower power states are at least
> available during suspend (if not during runtime). If your Skylake+
> system is not entering S0ix during freeze, I consider that a bug that
> needs to be addressed.

You would assume wrongly. Several parts of the system do their own
power management so if present need to have a driver loaded. Graphics
is the example everyone is familiar with but ADSP audio and ISH are two
others.

> configs, that's their decision. As I said, this does nothing in the
> !CONFIG_INTEL_PMC_CORE case, but if a finer level config is warranted,
> I can add that.

IMHO it belongs as a config item because it has a power cost, and you
can't turn it off without enabling debugfs when it's compiled in.

> I would prefer if others used this more, since there would be better
> debug coverage and I would have to fix fewer bugs.

I'd be more concerned about getting 10,000 emails bisecting the warning
to your commit 8)

Alan


Re: Dcache oops

2016-06-04 Thread Jeff Layton
On Sat, 2016-06-04 at 01:56 +0100, Al Viro wrote:
> On Fri, Jun 03, 2016 at 07:58:37PM -0400, Oleg Drokin wrote:
> 
> > 
> > > 
> > > EOPENSTALE, that is...  Oleg, could you check if the following works?
> > Yes, this one lasted for an hour with no crashing, so it must be good.
> > Thanks.
> > (note, I am not equipped to verify correctness of NFS operations, though).
> I suspect that Jeff Layton might have relevant regression tests.  
> Incidentally,
> we really need a consolidated regression testsuite, including the tests you'd
> been running.  Right now there's some stuff in xfstests, LTP and cthon; if
> anything, this mess shows just why we need all of that and then some in
> a single place.  Lustre stuff has caught a 3 years old NFS bug (missing
> d_drop() in nfs_atomic_open()) and a year-old bug in handling of EOPENSTALE
> retries on the last component of a trailing non-embedded symlink.  Neither
> is hard to trigger; it's just that relevant tests hadn't been run on NFS,
> period.
> 
> Jeff, could you verify that the following does not cause regressions in
> stale fhandles treatment?  I want to rip the damn retry logics out of
> do_last() and if the staleness had only been discovered inside of
> nfs4_file_open() just have the upper-level logics handle it by doing
> a normal LOOKUP_REVAL pass from scratch.  To hell with trying to be clever;
> a few roundtrips it saves us in some cases is not worth the complexity and
> potential for bugs.  I'm fairly sure that the time spent debugging this
> particular turd exceeds the total amount of time it has ever saved,
> and do_last() is in dire need of simplification.  All talk about "enough eyes"
> isn't worth much when the readers of code in question feel like ripping their
> eyes out...
> 

Agreed. I see no need to optimize an error case here. Any performance
hit that we'd get here is almost certainly acceptable in this
situation. The main thing is that we prevent the ESTALE from bubbling
up into userland if we can avoid it by retrying.

No, I didn't have the test for this anymore unfortunately. RHQA might
have one though.

Either way, I cooked one up that does this on the server:

#!/bin/bash

while true; do
rm -rf foo
mkdir foo
echo foo > foo/bar
usleep 10
done

...and then this on the client after mounting the fs with
lookupcache=none and noac.

#include 
#include 
#include 
#include 
#include 
#include 

int main(int argc, char **argv)
{
int fd;

while(1) {
fd = open(argv[1], O_RDONLY);
if (fd < 0) {
if (errno == ESTALE) {
printf("ESTALE");
return 1;
}
continue;
}
close(fd);
}
return 0;
}

I did see some of the OPEN compounds come back with NFS4ERR_STALE on
the PUTFH op but no corresponding ESTALE error in userland. So, this
patch does seem to do the right thing.

Reviewed-and-Tested-by: Jeff Layton 


Re: [PATCH V3 1/2] ACPI: Add support for ResourceSource/IRQ domain mapping

2016-06-04 Thread Marc Zyngier
On Fri, 13 May 2016 12:16:42 -0400
Agustin Vega-Frias  wrote:

> This allows irqchip drivers to associate an ACPI DSDT device to
> an IRQ domain and provides support for using the ResourceSource
> in Extended IRQ Resources to find the domain and map the IRQs
> specified on that domain.
> 
> Signed-off-by: Agustin Vega-Frias 
> ---
>  drivers/acpi/Makefile|   1 +
>  drivers/acpi/irqdomain.c | 108 
> +++
>  drivers/acpi/resource.c  |  23 ++
>  include/linux/acpi.h |   6 +++
>  4 files changed, 130 insertions(+), 8 deletions(-)
>  create mode 100644 drivers/acpi/irqdomain.c
> 
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index b12fa64..79db78f 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -56,6 +56,7 @@ acpi-$(CONFIG_ACPI_NUMA)+= numa.o
>  acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
>  acpi-y   += acpi_lpat.o
>  acpi-$(CONFIG_ACPI_GENERIC_GSI) += gsi.o
> +acpi-y   += irqdomain.o
>  
>  # These are (potentially) separate modules
>  
> diff --git a/drivers/acpi/irqdomain.c b/drivers/acpi/irqdomain.c
> new file mode 100644
> index 000..0fd10a9
> --- /dev/null
> +++ b/drivers/acpi/irqdomain.c
> @@ -0,0 +1,108 @@
> +/*
> + * ACPI ResourceSource/IRQ domain mapping support
> + *
> + * Copyright (c) 2016, The Linux Foundation. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * acpi_irq_domain_register_irq() - Register the mapping for an IRQ produced
> + *  by the given acpi_resource_source to a
> + *  Linux IRQ number
> + * @source: IRQ source

I'm a bit uncertain if this describe the interrupt producer (the device
that shakes an interrupt line) or the interrupt collator (the device
that presents a bunch of interrupts to a downstream element). I'm
tempted to say that this is the latter, but that's far from being clear.

> + * @rcirq: IRQ number
> + * @trigger: trigger type of the IRQ number to be mapped
> + * @polarity: polarity of the IRQ to be mapped

So if I'm right in my above understanding, you've reinvented an
existing abstraction (irq_fwspec).

> + *
> + * Returns: a valid linux IRQ number on success
> + *  -ENODEV if the given acpi_resource_source cannot be found
> + *  -EPROBE_DEFER if the IRQ domain has not been registered
> + *  -EINVAL for all other errors
> + */
> +int acpi_irq_domain_register_irq(struct acpi_resource_source *source, u32 
> rcirq,
> +  int trigger, int polarity)
> +{
> + struct irq_domain *domain;
> + struct acpi_device *device;
> + acpi_handle handle;
> + acpi_status status;
> + unsigned int type;
> + int ret;
> +
> + status = acpi_get_handle(NULL, source->string_ptr, &handle);
> + if (ACPI_FAILURE(status))
> + return -ENODEV;
> +
> + device = acpi_bus_get_acpi_device(handle);
> + if (!device)
> + return -ENODEV;
> +

So at this point, you should be able to create a irq_fwspec, and call
into irq_create_fwspec_mapping(), without the need to open-code stuff
we already have. And as a bonus point, you'd end-up with code that'd be
similar to what is in gsi.c...

> + domain = irq_find_matching_fwnode(&device->fwnode, DOMAIN_BUS_ANY);
> + if (!domain) {
> + ret = -EPROBE_DEFER;
> + goto out_put_device;
> + }
> +
> + type = acpi_dev_get_irq_type(trigger, polarity);
> + ret = irq_create_mapping(domain, rcirq);
> + if (ret)
> + irq_set_irq_type(ret, type);
> +
> +out_put_device:
> + acpi_bus_put_acpi_device(device);
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(acpi_irq_domain_register_irq);
> +
> +/**
> + * acpi_irq_domain_unregister_irq() - Delete the mapping for an IRQ produced
> + *by the given acpi_resource_source to a
> + *Linux IRQ number
> + * @source: IRQ source
> + * @rcirq: IRQ number
> + *
> + * Returns: 0 on success
> + *  -ENODEV if the given acpi_resource_source cannot be found
> + *  -EINVAL for all other errors
> + */
> +int acpi_irq_domain_unregister_irq(struct acpi_resource_source *source,
> +u32 rcirq)
> +{
> + struct irq_domain *domain;
> + struct acpi_device *device;
> + acpi_handle handle;
> + acpi_status status;
> + int re

Re: [PATCH V3 2/2] irqchip: qcom: Add IRQ combiner driver

2016-06-04 Thread Marc Zyngier
On Fri, 13 May 2016 12:16:43 -0400
Agustin Vega-Frias  wrote:

> Driver for interrupt combiners in the Top-level Control and Status
> Registers (TCSR) hardware block in Qualcomm Technologies chips.
> 
> An interrupt combiner in this block combines a set of interrupts by
> OR'ing the individual interrupt signals into a summary interrupt
> signal routed to a parent interrupt controller, and provides read-
> only, 32-bit registers to query the status of individual interrupts.
> The status bit for IRQ n is bit (n % 32) within register (n / 32)
> of the given combiner. Thus, each combiner can be described as a set
> of register offsets and the number of IRQs managed.
> 
> Signed-off-by: Agustin Vega-Frias 
> ---
>  drivers/irqchip/Kconfig |   8 +
>  drivers/irqchip/Makefile|   1 +
>  drivers/irqchip/qcom-irq-combiner.c | 344 
> 
>  3 files changed, 353 insertions(+)
>  create mode 100644 drivers/irqchip/qcom-irq-combiner.c
> 
> diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
> index f582e0d..609ff28 100644
> --- a/drivers/irqchip/Kconfig
> +++ b/drivers/irqchip/Kconfig
> @@ -245,3 +245,11 @@ config IRQ_MXS
>  config MVEBU_ODMI
>   bool
>   select GENERIC_MSI_IRQ_DOMAIN
> +
> +config QCOM_IRQ_COMBINER
> + bool "QCOM IRQ combiner support"
> + depends on ARCH_QCOM
> + select IRQ_DOMAIN
> + help
> +   Say yes here to add support for the IRQ combiner devices embedded
> +   in Qualcomm Technologies chips.
> diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
> index b03cfcb..05c688b 100644
> --- a/drivers/irqchip/Makefile
> +++ b/drivers/irqchip/Makefile
> @@ -65,3 +65,4 @@ obj-$(CONFIG_INGENIC_IRQ)   += irq-ingenic.o
>  obj-$(CONFIG_IMX_GPCV2)  += irq-imx-gpcv2.o
>  obj-$(CONFIG_PIC32_EVIC) += irq-pic32-evic.o
>  obj-$(CONFIG_MVEBU_ODMI) += irq-mvebu-odmi.o
> +obj-$(CONFIG_QCOM_IRQ_COMBINER)  += qcom-irq-combiner.o
> diff --git a/drivers/irqchip/qcom-irq-combiner.c 
> b/drivers/irqchip/qcom-irq-combiner.c
> new file mode 100644
> index 000..b4f767c
> --- /dev/null
> +++ b/drivers/irqchip/qcom-irq-combiner.c
> @@ -0,0 +1,344 @@
> +/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +/*
> + * Driver for interrupt combiners in the Top-level Control and Status
> + * Registers (TCSR) hardware block in Qualcomm Technologies chips.
> + * An interrupt combiner in this block combines a set of interrupts by
> + * OR'ing the individual interrupt signals into a summary interrupt
> + * signal routed to a parent interrupt controller, and provides read-
> + * only, 32-bit registers to query the status of individual interrupts.
> + * The status bit for IRQ n is bit (n % 32) within register (n / 32)
> + * of the given combiner. Thus, each combiner can be described as a set
> + * of register offsets and the number of IRQs managed.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define REG_SIZE 32
> +
> +struct combiner_reg {
> + void __iomem *addr;
> + unsigned long mask;
> +};
> +
> +struct combiner {
> + struct irq_chip irq_chip;
> + struct irq_domain   *domain;
> + int parent_irq;
> + u32 nirqs;
> + u32 nregs;
> + struct combiner_reg regs[0];
> +};
> +
> +static inline u32 irq_register(int irq)
> +{
> + return irq / REG_SIZE;
> +}
> +
> +static inline u32 irq_bit(int irq)
> +{
> + return irq % REG_SIZE;
> +
> +}
> +
> +static inline int irq_nr(u32 reg, u32 bit)
> +{
> + return reg * REG_SIZE + bit;
> +}
> +
> +/*
> + * Handler for the cascaded IRQ.
> + */
> +static void combiner_handle_irq(struct irq_desc *desc)
> +{
> + struct combiner *combiner = irq_desc_get_handler_data(desc);
> + struct irq_chip *chip = irq_desc_get_chip(desc);
> + u32 reg;
> +
> + chained_irq_enter(chip, desc);
> +
> + for (reg = 0; reg < combiner->nregs; reg++) {
> + int virq;
> + int hwirq;
> + u32 bit;
> + u32 status;
> +
> + if (combiner->regs[reg].mask == 0)
> + continue;
> +
> + status = readl_relaxed(combiner->regs[reg].addr);
> + status &= combiner->regs[reg].mask;
> +
> + while (status) {
> + 

Re: [PATCH 00/10] Documentation/Sphinx

2016-06-04 Thread Jani Nikula
On Fri, 03 Jun 2016, Jonathan Corbet  wrote:
> [So I'm finally trying to get into this for real, hopefully I won't be
> interrupted too many times...expect a few mails as I catch up.]
>
> On Fri, 20 May 2016 16:39:31 +0300
> Jani Nikula  wrote:
>
>> There are a few tradeoffs, of course. First, this requires that the
>> EXPORT_SYMBOL markers are placed immediately after the function being
>> exported, as kernel-doc will only look at one file at a time. This is
>> the recommendation anyway. 
>
> As I understand it, the technical reasons that kept some markers in
> separate files should no longer be relevant, so this is probably OK.  It
> would be nice to have a sense for how many sites need to be fixed.

Actually, mostly this is not a problem due to EXPORT_SYMBOL placement,
but rather due to kernel-doc comments being placed in header files above
function declarations while EXPORT_SYMBOL is where it should be next to
the function definition.

I don't think we can force people to move the kernel-doc comments for
exported functions from header files next to the function definitions.

The straightforward fix to this is to add an optional filename parameter
to the kernel-doc extension :export: argument, to pass additional files
to kernel-doc where to look for the EXPORT_SYMBOLs. For example:

.. kernel-doc:: include/drm/foo.h
   :export: drivers/gpu/drm/foo/foo.c drivers/gpu/drm/foo/bar.c

This would instruct kernel-doc to extract documentation from
include/drm/foo.h for all functions that have been exported using
EXPORT_SYMBOL (or _GPL) in include/drm/foo.h, drivers/gpu/drm/foo/foo.c,
or drivers/gpu/drm/foo/bar.c.

We have something along these lines in docproc already with the !D
directive, so nothing altogether surprising.

If my quick grep-fu serves me right, there are about a thousand exported
symbols with kernel-doc comments in the headers. It's a ballpark
figure. They come in batches; a small fraction of that many filenames in
a fraction of the :export: statements would cover most of them.

Before this fix, the workaround is to name the functions with
:functions: argument instead of using :export:.

I'm hoping this is not a blocker for merging the series. If the proposed
fix is acceptable, I'll get it done before v4.8.

BR,
Jani.


The ugly greps:

$ git grep "^EXPORT_SYMBOL" | sed 's/^[^(]*(\([a-zA-Z0-9_]*\)).*/\1/' | sort > 
exports
$ git grep -h -A1 "^/\*\*$" -- *.h | grep -v "^\(/\*\*\|--\)" | sed 's/^ \*[
 ]*\([a-zA-Z0-9_][a-zA-Z0-9_]*\).*/\1/;' | sort > comments
$ comm -1 -2 comments exports | wc -l
952




-- 
Jani Nikula, Intel Open Source Technology Center


Re: [PATCH 00/10] Documentation/Sphinx

2016-06-04 Thread Jani Nikula
On Fri, 03 Jun 2016, Jonathan Corbet  wrote:
> On Fri, 3 Jun 2016 22:24:03 +0200
> Daniel Vetter  wrote:
>
>> > This is maybe a job for a separate tool.  A related issue is the (fairly
>> > frequent) "oh look, none of the comments in $FILE are being used"
>> > realization that seems to happen fairly often.  It would be nice to check
>> > for that, but that's going to be hard to shoehorn into Sphinx.  
>> 
>> I think much more valuable would be a tool that checks whether
>> comments are pulled in anywhere (for a given source file), over the
>> entire tree. Very often entire subsystems carg-cult kernel-doc, but
>> never use it in a .tmpl, which means 0-day won't notice, and neither
>> anyone else.
>
> That is kind of what I was trying to get at, yes :)

For the 0-day, I've already got a preliminary kernel-doc-rst-lint
script, which can be used as a checker in the kernel build. This would
catch all kernel-doc comments, whether they're included to documentation
or not, and complain about kernel-doc and rst issues. It won't be as
comprehensive as a full Sphinx build in terms of validation, but it'll
cover more kernel-doc comments. It should catch the silly errors early.

BR,
Jani.



-- 
Jani Nikula, Intel Open Source Technology Center


[PATCH v2 3/2] lib/uuid.c: Silence an unchecked return value warning

2016-06-04 Thread George Spelvin
Andy Shevchenko pointed out that __uuid_to_bin doesn't need to check
the return value from hex2bin(), because the preceding uuid_is_valid()
check already took care of that.

But hex2bin() is declared __must_check, so checking anyway is the
simplest way to silence the warning.

This cancels a small fraction of the the space savings, but not all:

vs. previous patch  vs. before patch series
Before  After   Delta   Percent Orig.   Delta Percent
x86-32  90   96  +6 6.7%122 -26 -21.3%
x86-64  90   96  +6 6.7%127 -31 -24.4%
arm 92  104 +12 13.0%   116 -12 -10.3%
thumb   50   62 +12 24.0%   100 -38 -38.0%
arm64   116 124  +8 6.9%148 -24 -16.2%

Signed-off-by: George Spelvin 
---
 lib/uuid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/uuid.c b/lib/uuid.c
index 93945915..1a6dbbd2 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -104,7 +104,8 @@ static int __uuid_to_bin(const char uuid[36], __u8 b[16], 
const u8 pos[16])
return -EINVAL;
 
for (i = 0; i < 16; i++)
-   hex2bin(b + i, uuid + pos[i], 1);
+   if (hex2bin(b + i, uuid + pos[i], 1) < 0)
+   return -EINVAL;
 
return 0;
 }
-- 
2.8.1



Re: [PATCH] rtc: interface: ignore exprired timers one enqueing new timers

2016-06-04 Thread Alexandre Belloni
On 16/05/2016 at 17:22:54 +0100, Colin King wrote :
> From: Colin Ian King 
> 
> This patch fixes a RTC wakealarm issue, namely, the event fires during
> hibernate and is not cleared from the list, causing hwclock to block.
> 
> The current enqueuing does not trigger an alarm if any expired timers
> already exist on the timerqueue. This can occur when a RTC wake alarm
> is used to wake a machine out of hibernate and the resumed state has
> old expired timers that have not been removed from the timer queue.
> This fix skips over any expired timers and triggers an alarm if there
> are no pending timers on the timerqueue. Note that the skipped expired
> timer will get repead later on, so there is no need to clean it up
> immediately.
> 
> The issue can be reproduced by putting a machine into hibernate and
> waking it with the RTC wakealarm.  Running the example RTC test program
> from tools/testing/selftests/timers/rtctest.c after the hibernate will
> block indefinitely.  With the fix, it no longer blocks after the
> hibernate resume.
> 
> BugLink: http://bugs.launchpad.net/bugs/1333569
> 
> Signed-off-by: Colin Ian King 
> ---
>  drivers/rtc/interface.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


Re: [PATCH] power_supply: power_supply_read_temp only if use_cnt > 0

2016-06-04 Thread Sebastian Reichel
Hi Rhyland,

Thanks for the patch.

On Fri, Jun 03, 2016 at 04:30:50PM -0400, Rhyland Klein wrote:
> Add check to power_supply_read_temp() to only use the power_supply
> get_property() callback if the use_cnt is > 0. The use_cnt will
> be incremented at the end of __power_supply_register, so this will
> block to case where get_property can be called before the supply
> is fully registered. This fixes the issue show in the stack below:
> 
> [1.452598] power_supply_read_temp+0x78/0x80
> [1.458680] thermal_zone_get_temp+0x5c/0x11c
> [1.464765] thermal_zone_device_update+0x34/0xb4
> [1.471195] thermal_zone_device_register+0x87c/0x8cc
> [1.477974] __power_supply_register+0x364/0x424
> [1.484317] power_supply_register_no_ws+0x10/0x18
> [1.490833] bq27xxx_battery_setup+0x10c/0x164
> [1.497003] bq27xxx_battery_i2c_probe+0xd0/0x1b0
> [1.503435] i2c_device_probe+0x174/0x240
> [1.509172] driver_probe_device+0x1fc/0x29c
> [1.515167] __driver_attach+0xa4/0xa8
> [1.520643] bus_for_each_dev+0x58/0x98
> [1.526204] driver_attach+0x20/0x28
> [1.531505] bus_add_driver+0x1c8/0x22c
> [1.537067] driver_register+0x68/0x108
> [1.542630] i2c_register_driver+0x38/0x7c
> [1.548457] bq27xxx_battery_i2c_driver_init+0x18/0x20
> [1.555321] do_one_initcall+0x38/0x12c
> [1.560886] kernel_init_freeable+0x148/0x1ec
> [1.566972] kernel_init+0x10/0xfc
> [1.572101] ret_from_fork+0x10/0x40

So I guess this should be backported to stable kernels.

> Signed-off-by: Rhyland Klein 
> ---
>  drivers/power/power_supply_core.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/power_supply_core.c 
> b/drivers/power/power_supply_core.c
> index 456987c88baa..070fec621d66 100644
> --- a/drivers/power/power_supply_core.c
> +++ b/drivers/power/power_supply_core.c
> @@ -561,11 +561,16 @@ static int power_supply_read_temp(struct 
> thermal_zone_device *tzd,
>  {
>   struct power_supply *psy;
>   union power_supply_propval val;
> - int ret;
> + int ret = 0;

ret should probably be initialized to -EAGAIN to avoid val being
interpreted without get_property() having been called at all?

>   WARN_ON(tzd == NULL);
> +
>   psy = tzd->devdata;
> - ret = psy->desc->get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
> + WARN_ON(atomic_read(&psy->use_cnt) == 0);

I guess the warning can be dropped if error code is properly reported?

> + if (atomic_read(&psy->use_cnt) > 0)
> + ret = psy->desc->get_property(psy, POWER_SUPPLY_PROP_TEMP,
> +   &val);
>  
>   /* Convert tenths of degree Celsius to milli degree Celsius. */
>   if (!ret)

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCH v2 1/1] rtc: ds1685: correct check of day of month

2016-06-04 Thread Alexandre Belloni
On 22/05/2016 at 00:18:55 +0200, Heinrich Schuchardt wrote :
> The day of month is checked in ds1685_rtc_read_alarm
> and ds1685_rtc_set_alarm.
> 
> Multiple errors exist in the day of month check.
> 
> Operator ! has a higher priority than &&.
> (!(mday >= 1) && (mday <= 31)) is false for mday == 32.
> 
> When verifying the day of month the binary and the BCD mode
> have to be considered.
> 
> v2:
>   consider ds1685_rtc_read_alarm
>   consider rtc->bcd_mode as indicated by Alexandre Belloni
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  drivers/rtc/rtc-ds1685.c | 34 +-
>  1 file changed, 29 insertions(+), 5 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


Re: [PATCH] rtc-pcf2123: use sign_extend32() for sign extension

2016-06-04 Thread Alexandre Belloni
On 18/04/2016 at 12:17:44 +0200, Martin Kepplinger wrote :
> Signed-off-by: Martin Kepplinger 
> ---
>  drivers/rtc/rtc-pcf2123.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


[PATCH] net: wireless: marvell: libertas: Remove create_workqueue

2016-06-04 Thread Bhaktipriya Shridhar
alloc_workqueue replaces deprecated create_workqueue().

In if_sdio.c, the workqueue card->workqueue has workitem
&card->packet_worker, which is mapped to if_sdio_host_to_card_worker.
The workitem is involved in sending packets to firmware.
Forward progress under memory pressure is a requirement here.

In if_spi.c, the workqueue card->workqueue has workitem
&card->packet_worker, which is mapped to if_spi_host_to_card_worker.
The workitem is involved in sending command packets from the host.
Forward progress under memory pressure is a requirement here.

Dedicated workqueues have been used in both cases since the workitems
on the workqueues are involved in normal device operation with
WQ_MEM_RECLAIM set to gurantee forward progress under memory pressure.
Since there are only a fixed number of work items, explicit concurrency
limit is unnecessary.

flush_workqueue is unnecessary since destroy_workqueue() itself calls
drain_workqueue() which flushes repeatedly till the workqueue
becomes empty. Hence the calls to flush_workqueue() before
destroy_workqueue() have been dropped.

Signed-off-by: Bhaktipriya Shridhar 
---
 drivers/net/wireless/marvell/libertas/if_sdio.c | 3 +--
 drivers/net/wireless/marvell/libertas/if_spi.c  | 4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c 
b/drivers/net/wireless/marvell/libertas/if_sdio.c
index 13eae9f..47f4a14 100644
--- a/drivers/net/wireless/marvell/libertas/if_sdio.c
+++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
@@ -1228,7 +1228,7 @@ static int if_sdio_probe(struct sdio_func *func,
}

spin_lock_init(&card->lock);
-   card->workqueue = create_workqueue("libertas_sdio");
+   card->workqueue = alloc_workqueue("libertas_sdio", WQ_MEM_RECLAIM, 0);
INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker);
init_waitqueue_head(&card->pwron_waitq);

@@ -1326,7 +1326,6 @@ static void if_sdio_remove(struct sdio_func *func)
lbs_stop_card(card->priv);
lbs_remove_card(card->priv);

-   flush_workqueue(card->workqueue);
destroy_workqueue(card->workqueue);

while (card->packets) {
diff --git a/drivers/net/wireless/marvell/libertas/if_spi.c 
b/drivers/net/wireless/marvell/libertas/if_spi.c
index 82c0796..c3a53cd 100644
--- a/drivers/net/wireless/marvell/libertas/if_spi.c
+++ b/drivers/net/wireless/marvell/libertas/if_spi.c
@@ -1180,7 +1180,7 @@ static int if_spi_probe(struct spi_device *spi)
priv->fw_ready = 1;

/* Initialize interrupt handling stuff. */
-   card->workqueue = create_workqueue("libertas_spi");
+   card->workqueue = alloc_workqueue("libertas_spi", WQ_MEM_RECLAIM, 0);
INIT_WORK(&card->packet_work, if_spi_host_to_card_worker);
INIT_WORK(&card->resume_work, if_spi_resume_worker);

@@ -1208,7 +1208,6 @@ static int if_spi_probe(struct spi_device *spi)
 release_irq:
free_irq(spi->irq, card);
 terminate_workqueue:
-   flush_workqueue(card->workqueue);
destroy_workqueue(card->workqueue);
lbs_remove_card(priv); /* will call free_netdev */
 free_card:
@@ -1235,7 +1234,6 @@ static int libertas_spi_remove(struct spi_device *spi)
lbs_remove_card(priv); /* will call free_netdev */

free_irq(spi->irq, card);
-   flush_workqueue(card->workqueue);
destroy_workqueue(card->workqueue);
if (card->pdata->teardown)
card->pdata->teardown(spi);
--
2.1.4



Re: [PATCH] net: fjes: fjes_main: Remove create_workqueue

2016-06-04 Thread Bhaktipriya Shridhar
Thank you for your feedback.
Will send another patch with changed description.

Bhaktipriya.


On Fri, Jun 3, 2016 at 5:25 AM, Izumi, Taku  wrote:
> Dear Bhaktipriya,
>
> Thanks. Looks good to me.
>
> Sincerely,
> Taku Izumi
>
>> -Original Message-
>> From: Bhaktipriya Shridhar [mailto:bhaktipriy...@gmail.com]
>> Sent: Thursday, June 02, 2016 6:31 PM
>> To: David S. Miller; Izumi, Taku/泉 拓; Florian Westphal; Bhaktipriya Shridhar
>> Cc: Tejun Heo; net...@vger.kernel.org; linux-kernel@vger.kernel.org
>> Subject: [PATCH] net: fjes: fjes_main: Remove create_workqueue
>>
>> alloc_workqueue replaces deprecated create_workqueue().
>>
>> The workqueue adapter->txrx_wq has workitem
>> &adapter->raise_intr_rxdata_task per adapter. Extended Socket Network
>> Device is shared memory based, so someone's transmission denotes other's
>> reception.  raise_intr_rxdata_task raises interruption of receivers from
>> the sender in order to notify receivers.
>>
>> The workqueue adapter->control_wq has workitem
>> &adapter->interrupt_watch_task per adapter. interrupt_watch_task is used
>> to prevent delay of interrupts.
>>
>> Dedicated workqueues have been used in both cases since the workitems
>> on the workqueues are involved in normal device operation and require
>> forward progress under memory pressure.
>>
>> max_active has been set to 0 since there is no need for throttling
>> the number of active work items.
>>
>> Since network devices  may be used for memory reclaim,
>> WQ_MEM_RECLAIM has been set to guarantee forward progress.
>>
>> Signed-off-by: Bhaktipriya Shridhar 
>> ---
>>  drivers/net/fjes/fjes_main.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
>> index 86c331b..9006877 100644
>> --- a/drivers/net/fjes/fjes_main.c
>> +++ b/drivers/net/fjes/fjes_main.c
>> @@ -1187,8 +1187,9 @@ static int fjes_probe(struct platform_device *plat_dev)
>>   adapter->force_reset = false;
>>   adapter->open_guard = false;
>>
>> - adapter->txrx_wq = create_workqueue(DRV_NAME "/txrx");
>> - adapter->control_wq = create_workqueue(DRV_NAME "/control");
>> + adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 
>> 0);
>> + adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
>> +   WQ_MEM_RECLAIM, 0);
>>
>>   INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task);
>>   INIT_WORK(&adapter->raise_intr_rxdata_task,
>> --
>> 2.1.4
>>
>


[PATCH v3 1/3] mm/hugetlb: Simplify hugetlb unmap

2016-06-04 Thread Aneesh Kumar K.V
For hugetlb like THP (and unlike regular page), we do tlb flush after
dropping ptl. Because of the above, we don't need to track force_flush
like we do now. Instead we can simply call tlb_remove_page() which
will do the flush if needed.

No functionality change in this patch.

Signed-off-by: Aneesh Kumar K.V 
---
 mm/hugetlb.c | 54 +-
 1 file changed, 21 insertions(+), 33 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index d26162e81fea..741429d01668 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3138,7 +3138,6 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, 
struct vm_area_struct *vma,
unsigned long start, unsigned long end,
struct page *ref_page)
 {
-   int force_flush = 0;
struct mm_struct *mm = vma->vm_mm;
unsigned long address;
pte_t *ptep;
@@ -3157,19 +3156,22 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, 
struct vm_area_struct *vma,
tlb_start_vma(tlb, vma);
mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
address = start;
-again:
for (; address < end; address += sz) {
ptep = huge_pte_offset(mm, address);
if (!ptep)
continue;
 
ptl = huge_pte_lock(h, mm, ptep);
-   if (huge_pmd_unshare(mm, &address, ptep))
-   goto unlock;
+   if (huge_pmd_unshare(mm, &address, ptep)) {
+   spin_unlock(ptl);
+   continue;
+   }
 
pte = huge_ptep_get(ptep);
-   if (huge_pte_none(pte))
-   goto unlock;
+   if (huge_pte_none(pte)) {
+   spin_unlock(ptl);
+   continue;
+   }
 
/*
 * Migrating hugepage or HWPoisoned hugepage is already
@@ -3177,7 +3179,8 @@ again:
 */
if (unlikely(!pte_present(pte))) {
huge_pte_clear(mm, address, ptep);
-   goto unlock;
+   spin_unlock(ptl);
+   continue;
}
 
page = pte_page(pte);
@@ -3187,9 +3190,10 @@ again:
 * are about to unmap is the actual page of interest.
 */
if (ref_page) {
-   if (page != ref_page)
-   goto unlock;
-
+   if (page != ref_page) {
+   spin_unlock(ptl);
+   continue;
+   }
/*
 * Mark the VMA as having unmapped its page so that
 * future faults in this VMA will fail rather than
@@ -3205,30 +3209,14 @@ again:
 
hugetlb_count_sub(pages_per_huge_page(h), mm);
page_remove_rmap(page, true);
-   force_flush = !__tlb_remove_page(tlb, page);
-   if (force_flush) {
-   address += sz;
-   spin_unlock(ptl);
-   break;
-   }
-   /* Bail out after unmapping reference page if supplied */
-   if (ref_page) {
-   spin_unlock(ptl);
-   break;
-   }
-unlock:
+
spin_unlock(ptl);
-   }
-   /*
-* mmu_gather ran out of room to batch pages, we break out of
-* the PTE lock to avoid doing the potential expensive TLB invalidate
-* and page-free while holding it.
-*/
-   if (force_flush) {
-   force_flush = 0;
-   tlb_flush_mmu(tlb);
-   if (address < end && !ref_page)
-   goto again;
+   tlb_remove_page(tlb, page);
+   /*
+* Bail out after unmapping reference page if supplied
+*/
+   if (ref_page)
+   break;
}
mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);
tlb_end_vma(tlb, vma);
-- 
2.7.4



[PATCH v3 2/3] mm: Change the interface for __tlb_remove_page

2016-06-04 Thread Aneesh Kumar K.V
This update the generic and arch specific implementation to return true
if we need to do a tlb flush. That means if a __tlb_remove_page indicate
a flush is needed, the page we try to remove need to be tracked and
added again after the flush. We need to track it because we have already
update the pte to none and we can't just loop back.

This changes is done to enable us to do a tlb_flush when we try to flush
a range that consists of different page sizes. For architectures like
ppc64, we can do a range based tlb flush and we need to track page size
for that. When we try to remove a huge page, we will force a tlb flush
and starts a new mmu gather.

Signed-off-by: Aneesh Kumar K.V 
---
 arch/arm/include/asm/tlb.h  | 17 +
 arch/ia64/include/asm/tlb.h | 19 ++-
 arch/s390/include/asm/tlb.h |  9 +++--
 arch/sh/include/asm/tlb.h   |  8 +++-
 arch/um/include/asm/tlb.h   |  8 +++-
 include/asm-generic/tlb.h   | 44 +---
 mm/memory.c | 19 +--
 7 files changed, 94 insertions(+), 30 deletions(-)

diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h
index 3cadb726ec88..a9d2aee3826f 100644
--- a/arch/arm/include/asm/tlb.h
+++ b/arch/arm/include/asm/tlb.h
@@ -209,17 +209,26 @@ tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct 
*vma)
tlb_flush(tlb);
 }
 
-static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
+static inline bool __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
 {
+   if (tlb->nr == tlb->max)
+   return true;
tlb->pages[tlb->nr++] = page;
-   VM_BUG_ON(tlb->nr > tlb->max);
-   return tlb->max - tlb->nr;
+   return false;
 }
 
 static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
 {
-   if (!__tlb_remove_page(tlb, page))
+   if (__tlb_remove_page(tlb, page)) {
tlb_flush_mmu(tlb);
+   __tlb_remove_page(tlb, page);
+   }
+}
+
+static inline bool __tlb_remove_pte_page(struct mmu_gather *tlb,
+struct page *page)
+{
+   return __tlb_remove_page(tlb, page);
 }
 
 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
diff --git a/arch/ia64/include/asm/tlb.h b/arch/ia64/include/asm/tlb.h
index 39d64e0df1de..e7da41aa9110 100644
--- a/arch/ia64/include/asm/tlb.h
+++ b/arch/ia64/include/asm/tlb.h
@@ -205,17 +205,18 @@ tlb_finish_mmu(struct mmu_gather *tlb, unsigned long 
start, unsigned long end)
  * must be delayed until after the TLB has been flushed (see comments at the 
beginning of
  * this file).
  */
-static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
+static inline bool __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
 {
+   if (tlb->nr == tlb->max)
+   return true;
+
tlb->need_flush = 1;
 
if (!tlb->nr && tlb->pages == tlb->local)
__tlb_alloc_page(tlb);
 
tlb->pages[tlb->nr++] = page;
-   VM_BUG_ON(tlb->nr > tlb->max);
-
-   return tlb->max - tlb->nr;
+   return false;
 }
 
 static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)
@@ -235,8 +236,16 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
 
 static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
 {
-   if (!__tlb_remove_page(tlb, page))
+   if (__tlb_remove_page(tlb, page)) {
tlb_flush_mmu(tlb);
+   __tlb_remove_page(tlb, page);
+   }
+}
+
+static inline bool __tlb_remove_pte_page(struct mmu_gather *tlb,
+struct page *page)
+{
+   return __tlb_remove_page(tlb, page);
 }
 
 /*
diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h
index 7a92e69c50bc..30759b560849 100644
--- a/arch/s390/include/asm/tlb.h
+++ b/arch/s390/include/asm/tlb.h
@@ -87,10 +87,10 @@ static inline void tlb_finish_mmu(struct mmu_gather *tlb,
  * tlb_ptep_clear_flush. In both flush modes the tlb for a page cache page
  * has already been freed, so just do free_page_and_swap_cache.
  */
-static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
+static inline bool __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
 {
free_page_and_swap_cache(page);
-   return 1; /* avoid calling tlb_flush_mmu */
+   return false; /* avoid calling tlb_flush_mmu */
 }
 
 static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
@@ -98,6 +98,11 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, 
struct page *page)
free_page_and_swap_cache(page);
 }
 
+static inline bool __tlb_remove_pte_page(struct mmu_gather *tlb,
+struct page *page)
+{
+   return __tlb_remove_page(tlb, page);
+}
 /*
  * pte_free_tlb frees a pte table and clears the CRSTE for the
  * page table from the tlb.
diff -

[PATCH v3 3/3] mm/mmu_gather: Track page size with mmu gather and force flush if page size change

2016-06-04 Thread Aneesh Kumar K.V
This allows arch which need to do special handing with respect to
different page size when flushing tlb to implement the same in mmu gather

Signed-off-by: Aneesh Kumar K.V 
---
 arch/arm/include/asm/tlb.h  | 12 
 arch/ia64/include/asm/tlb.h | 12 
 arch/s390/include/asm/tlb.h | 13 +
 arch/sh/include/asm/tlb.h   | 12 
 arch/um/include/asm/tlb.h   | 12 
 include/asm-generic/tlb.h   | 27 +--
 mm/huge_memory.c|  2 +-
 mm/hugetlb.c|  2 +-
 mm/memory.c | 10 +-
 9 files changed, 93 insertions(+), 9 deletions(-)

diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h
index a9d2aee3826f..1e25cd80589e 100644
--- a/arch/arm/include/asm/tlb.h
+++ b/arch/arm/include/asm/tlb.h
@@ -225,12 +225,24 @@ static inline void tlb_remove_page(struct mmu_gather 
*tlb, struct page *page)
}
 }
 
+static inline bool __tlb_remove_page_size(struct mmu_gather *tlb,
+ struct page *page, int page_size)
+{
+   return __tlb_remove_page(tlb, page);
+}
+
 static inline bool __tlb_remove_pte_page(struct mmu_gather *tlb,
 struct page *page)
 {
return __tlb_remove_page(tlb, page);
 }
 
+static inline void tlb_remove_page_size(struct mmu_gather *tlb,
+   struct page *page, int page_size)
+{
+   return tlb_remove_page(tlb, page);
+}
+
 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
unsigned long addr)
 {
diff --git a/arch/ia64/include/asm/tlb.h b/arch/ia64/include/asm/tlb.h
index e7da41aa9110..77e541cf0e5d 100644
--- a/arch/ia64/include/asm/tlb.h
+++ b/arch/ia64/include/asm/tlb.h
@@ -242,12 +242,24 @@ static inline void tlb_remove_page(struct mmu_gather 
*tlb, struct page *page)
}
 }
 
+static inline bool __tlb_remove_page_size(struct mmu_gather *tlb,
+ struct page *page, int page_size)
+{
+   return __tlb_remove_page(tlb, page);
+}
+
 static inline bool __tlb_remove_pte_page(struct mmu_gather *tlb,
 struct page *page)
 {
return __tlb_remove_page(tlb, page);
 }
 
+static inline void tlb_remove_page_size(struct mmu_gather *tlb,
+   struct page *page, int page_size)
+{
+   return tlb_remove_page(tlb, page);
+}
+
 /*
  * Remove TLB entry for PTE mapped at virtual address ADDRESS.  This is called 
for any
  * PTE, not just those pointing to (normal) physical memory.
diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h
index 30759b560849..15711de10403 100644
--- a/arch/s390/include/asm/tlb.h
+++ b/arch/s390/include/asm/tlb.h
@@ -98,11 +98,24 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, 
struct page *page)
free_page_and_swap_cache(page);
 }
 
+static inline bool __tlb_remove_page_size(struct mmu_gather *tlb,
+ struct page *page, int page_size)
+{
+   return __tlb_remove_page(tlb, page);
+}
+
 static inline bool __tlb_remove_pte_page(struct mmu_gather *tlb,
 struct page *page)
 {
return __tlb_remove_page(tlb, page);
 }
+
+static inline void tlb_remove_page_size(struct mmu_gather *tlb,
+   struct page *page, int page_size)
+{
+   return tlb_remove_page(tlb, page);
+}
+
 /*
  * pte_free_tlb frees a pte table and clears the CRSTE for the
  * page table from the tlb.
diff --git a/arch/sh/include/asm/tlb.h b/arch/sh/include/asm/tlb.h
index 21ae8f5546b2..025cdb1032f6 100644
--- a/arch/sh/include/asm/tlb.h
+++ b/arch/sh/include/asm/tlb.h
@@ -109,12 +109,24 @@ static inline void tlb_remove_page(struct mmu_gather 
*tlb, struct page *page)
__tlb_remove_page(tlb, page);
 }
 
+static inline bool __tlb_remove_page_size(struct mmu_gather *tlb,
+ struct page *page, int page_size)
+{
+   return __tlb_remove_page(tlb, page);
+}
+
 static inline bool __tlb_remove_pte_page(struct mmu_gather *tlb,
 struct page *page)
 {
return __tlb_remove_page(tlb, page);
 }
 
+static inline void tlb_remove_page_size(struct mmu_gather *tlb,
+   struct page *page, int page_size)
+{
+   return tlb_remove_page(tlb, page);
+}
+
 #define pte_free_tlb(tlb, ptep, addr)  pte_free((tlb)->mm, ptep)
 #define pmd_free_tlb(tlb, pmdp, addr)  pmd_free((tlb)->mm, pmdp)
 #define pud_free_tlb(tlb, pudp, addr)  pud_free((tlb)->mm, pudp)
diff --git a/arch/um/include/asm/tlb.h b/arch/um/include/asm/tlb.h
index 3dc4cbb3c2c0..821ff0acfe17 100644
--- a/arch/um/include/asm/tlb.h
+++ b/arch/um/include/asm/tlb.h
@@ -110,12 +110,24 @@ static inline void tlb_remove_page(struct mmu_gather 
*tlb, struct page *page)
__tlb_remove_page(tlb, page);
 }

Re: [PATCH v4] rtc:add support for maxim rtc max6916

2016-06-04 Thread Alexandre Belloni
On 01/06/2016 at 11:59:54 +0530, venkat.prashanth2...@gmail.com wrote :
> From: VENKAT PRASHANTH B U 
> 
> This is a patch to add support for
> maxim rtc max6916
> 
> Signed-off-by: Venkat Prashanth B U 
> ---
> changelog v4:
> - fixed the line wrapping to around 72 characters
> - Aligned the values with tabs
> - inserted the correct coding style in the conditional statements
> - removed the empty lines towards the end of the code
> - fixed the checkpatch issues
> - code clean up on max6916_read_reg()
> 
> changelog v3:
> - saperated the logical code sections with an empty line
> - used indentations after if statements.
> - fixed the out of tree makefile
> - placed the test condition at the begining of the function
> 
> change log v2:
> - deleted the port i/o's
> - clock burst value is modified from 0x00 to 0x3F
> - The time in linux is in binary format so get_rtc()replaced with bcd2bin()
> - enforced the year range instead of accepting any value
> ---
> ---
>  drivers/rtc/Kconfig  |  12 
>  drivers/rtc/Makefile |   1 +
>  drivers/rtc/rtc-max6916.c| 167 
> ++
>  3 files changed, 180 insertions(+)
> 

I've applied it but you probably edited the diff by hand so I had to
edit it a bit more to get it to apply correctly. Also, I fixed the
remaining checkpatch issues.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


[PATCH v2] net: fjes: fjes_main: Remove create_workqueue

2016-06-04 Thread Bhaktipriya Shridhar
alloc_workqueue replaces deprecated create_workqueue().

The workqueue adapter->txrx_wq has workitem
&adapter->raise_intr_rxdata_task per adapter. Extended Socket Network
Device is shared memory based, so someone's transmission denotes other's
reception.  raise_intr_rxdata_task raises interruption of receivers from
the sender in order to notify receivers. Forward progress under memory
pressure is a requirement here.

The workqueue adapter->control_wq has workitem
&adapter->interrupt_watch_task per adapter. interrupt_watch_task is used
to prevent delay of interrupts. Forward progress under memory pressure
is a requirement here.

Dedicated workqueues have been used in both cases since the workitems
on the workqueues are involved in normal device operation with
WQ_MEM_RECLAIM set to gurantee forward progress under memory pressure.
Since there are only a fixed number of work items, explicit concurrency
limit is unnecessary.

Signed-off-by: Bhaktipriya Shridhar 
---
 Changes in v2:
- Changed commit description to more concise one.

 drivers/net/fjes/fjes_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index 86c331b..9006877 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1187,8 +1187,9 @@ static int fjes_probe(struct platform_device *plat_dev)
adapter->force_reset = false;
adapter->open_guard = false;

-   adapter->txrx_wq = create_workqueue(DRV_NAME "/txrx");
-   adapter->control_wq = create_workqueue(DRV_NAME "/control");
+   adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
+   adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
+ WQ_MEM_RECLAIM, 0);

INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task);
INIT_WORK(&adapter->raise_intr_rxdata_task,
--
2.1.4



Re: [33/54] MAINTAINERS: Add file patterns for wireless device tree bindings

2016-06-04 Thread Kalle Valo
Geert Uytterhoeven  wrote:
> Submitters of device tree binding documentation may forget to CC
> the subsystem maintainer if this is missing.
> 
> Signed-off-by: Geert Uytterhoeven 
> Cc: Kalle Valo 
> Cc: linux-wirel...@vger.kernel.org

Thanks, 1 patch applied to wireless-drivers.git:

182fd9eecb28 MAINTAINERS: Add file patterns for wireless device tree bindings

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9130849/



Re: [PATCH] net: wireless: marvell: libertas: Remove create_workqueue

2016-06-04 Thread Kalle Valo
Bhaktipriya Shridhar  writes:

> alloc_workqueue replaces deprecated create_workqueue().
>
> In if_sdio.c, the workqueue card->workqueue has workitem
> &card->packet_worker, which is mapped to if_sdio_host_to_card_worker.
> The workitem is involved in sending packets to firmware.
> Forward progress under memory pressure is a requirement here.
>
> In if_spi.c, the workqueue card->workqueue has workitem
> &card->packet_worker, which is mapped to if_spi_host_to_card_worker.
> The workitem is involved in sending command packets from the host.
> Forward progress under memory pressure is a requirement here.
>
> Dedicated workqueues have been used in both cases since the workitems
> on the workqueues are involved in normal device operation with
> WQ_MEM_RECLAIM set to gurantee forward progress under memory pressure.
> Since there are only a fixed number of work items, explicit concurrency
> limit is unnecessary.
>
> flush_workqueue is unnecessary since destroy_workqueue() itself calls
> drain_workqueue() which flushes repeatedly till the workqueue
> becomes empty. Hence the calls to flush_workqueue() before
> destroy_workqueue() have been dropped.
>
> Signed-off-by: Bhaktipriya Shridhar 

"libertas:" as a prefix is enough, no need to put the full path to the
title. I can fix that this time.

You can actually check yourself what prefix is commonly used in a
particular file or directory:

$ git log --oneline --no-merges -10 drivers/net/wireless/marvell/libertas/
57fbcce37be7 cfg80211: remove enum ieee80211_band
3691ac4a9c95 libertas: fix an error code in probe
143e49458424 libertas: add an cfg80211 interface for powersaving
0b8802dc5f59 libertas: fix ps-mode related removal problems
fada24a54770 libertas: go back to ps mode without commands pending
57954b94cad7 libertas: do not confirm sleep if commands are pending
fae4f9f78ab1 libertas: check whether bus can do more than polling
0a7701b4defc libertas: fix pointer bugs for PS_MODE commands
6d91ff7acc90 libertas: cleanup a variable name
0a38c8e1b592 libertas: check for NULL before use
$
-- 
Kalle Valo


Re: [PATCH V3 1/2] irqchip/gicv3-its: split its_alloc_tables() into two functions

2016-06-04 Thread Shanker Donthineni
Hi Marc,

On 06/04/2016 03:53 AM, Marc Zyngier wrote:
> On Mon, 9 May 2016 15:58:25 -0500
> Shanker Donthineni  wrote:
>
>> The function is getting out of control, it has too many goto
>> statements and would be too complicated for adding a feature
>> two-level device table. So, it is time for us to cleanup and
>> move some of the logic to a separate function without affecting
>> the existing functionality.
>>
>> Signed-off-by: Shanker Donthineni 
>> ---
>>  drivers/irqchip/irq-gic-v3-its.c   | 256
> -
>>  include/linux/irqchip/arm-gic-v3.h |   3 +
>>  2 files changed, 144 insertions(+), 115 deletions(-)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its.c
> b/drivers/irqchip/irq-gic-v3-its.c
>> index 6bd881b..b23e00c 100644
>> --- a/drivers/irqchip/irq-gic-v3-its.c
>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>> @@ -55,13 +55,15 @@ struct its_collection {
>>  };
>>  
>>  /*
>> - * The ITS_BASER structure - contains memory information and cached
>> - * value of BASER register configuration.
>> + * The ITS_BASER structure - contains memory information, cached value
>> + * of BASER register configuration, ioremaped address and page size.
>>   */
>>  struct its_baser {
>> +void __iomem*hwreg;
> I'm not overly fond of caching arbitrary device addresses, and I'd be
> happier if you had the GITS_BASERn index in there, together with a
> couple of helpers to perform the access:
>
> void its_write_baser(struct its_node *its, struct its_baser *baser,
>u64 val);
> u64 its_read_baser(struct its_node *its, struct its_baser *baser);
>
> and keep the offset computing out of sight.
Sure, I am happy to do this change and also helps the code readability.

>>  void*base;
>>  u64 val;
>>  u32 order;
>> +u32 psz;
>>  };
>>  
>>  /*
>> @@ -823,27 +825,135 @@ static void its_free_tables(struct its_node *its)
>>  }
>>  }
>>  
>> +static int its_baser_setup(struct its_node *its, struct its_baser
> *baser,
>> +  u32 order, u64 indirect)
> Please move the indirect support to the next patch. I'd like to see
> something that doesn't have any semantic change.
I'll move ITS-indirection related code logic to next patch.
>> +{
>> +u64 val = readq_relaxed(baser->hwreg);
>> +u64 type = GITS_BASER_TYPE(val);
>> +u64 entry_size = GITS_BASER_ENTRY_SIZE(val);
>> +int psz, alloc_pages;
>> +u64 cache, shr, tmp;
>> +void *base;
>> +
>> +/* Do first attempt with the requested attributes */
>> +cache = baser->val & GITS_BASER_CACHEABILITY_MASK;
>> +shr = baser->val & GITS_BASER_SHAREABILITY_MASK;
>> +psz = baser->psz;
>> +
>> +retry_alloc_baser:
>> +alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz);
>> +if (alloc_pages > GITS_BASER_PAGES_MAX) {
>> +pr_warn("ITS@%lx: %s too large, reduce ITS pages
> %u->%u\n",
>> +its->phys_base, its_base_type_string[type],
>> +alloc_pages, GITS_BASER_PAGES_MAX);
>> +alloc_pages = GITS_BASER_PAGES_MAX;
>> +order = get_order(GITS_BASER_PAGES_MAX * psz);
>> +}
>> +
>> +base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
>> +if (!base)
>> +return -ENOMEM;
>> +
>> +retry_baser:
>> +val = (virt_to_phys(base)|
>> +(type << GITS_BASER_TYPE_SHIFT)  |
>> +((entry_size - 1) << GITS_BASER_ENTRY_SIZE_SHIFT) |
>> +((alloc_pages - 1) << GITS_BASER_PAGES_SHIFT)|
>> +cache|
>> +shr  |
>> +indirect |
> See my comment on the next patch. This should be a bool, and used with
> something like:
>   [...]
>   indirect ? GITS_BASER_INDIRECT : 0  |
>   [...]
>
> (and of course moved to the next patch, together with the rest of the
> indirect support.
I'll follow your suggestion and the corresponding changes will be moved to next 
patch.
>> +GITS_BASER_VALID);
>> +
>> +switch (psz) {
>> +case SZ_4K:
>> +val |= GITS_BASER_PAGE_SIZE_4K;
>> +break;
>> +case SZ_16K:
>> +val |= GITS_BASER_PAGE_SIZE_16K;
>> +break;
>> +case SZ_64K:
>> +val |= GITS_BASER_PAGE_SIZE_64K;
>> +break;
>> +}
>> +
>> +writeq_relaxed(val, baser->hwreg);
>> +tmp = readq_relaxed(baser->hwreg);
>> +
>> +if ((val ^ tmp) & GITS_BASER_SHAREABILITY_MASK) {
>> +/*
>> + * Shareability didn't stick. Just use
>> + * whatever the read reported, which is likely
>> + * to be the only thing this redistributor
>> + * supports. If that's zero, make it
>> + * non-cacheable as well.
>> + *

Re: [PATCH 1/1] scsi: storvsc: Filter out storvsc messages CD-ROM medium not present

2016-06-04 Thread Martin K. Petersen
> "Cathy" == Cathy Avery  writes:

Cathy> When a virtual scsi DVD device is present with no image file
Cathy> attached the storvsc driver logs all resulting unnecessary sense
Cathy> errors whenever IO is issued to the device.

Tweaked whitespace and applied to 4.8/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] net: wireless: marvell: libertas: Remove create_workqueue

2016-06-04 Thread Bhaktipriya Shridhar
On Sat, Jun 4, 2016 at 7:59 PM, Kalle Valo  wrote:
>
> $ git log --oneline --no-merges -10

Sure. Will keep that in mind.

Thanks,
Bhaktipriya


  1   2   3   >