[RESEND v9 11/12] mfd: rk808: Add RK805 power key support

2017-08-15 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/rk808.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index c803d2d..216fbf6 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -94,6 +94,19 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static struct resource rk805_key_resources[] = {
+   {
+   .start  = RK805_IRQ_PWRON_FALL,
+   .end= RK805_IRQ_PWRON_FALL,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .start  = RK805_IRQ_PWRON_RISE,
+   .end= RK805_IRQ_PWRON_RISE,
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -103,6 +116,10 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = &rtc_resources[0],
},
+   {   .name = "rk805-pwrkey",
+   .num_resources = ARRAY_SIZE(rk805_key_resources),
+   .resources = &rk805_key_resources[0],
+   },
 };
 
 static const struct mfd_cell rk808s[] = {
-- 
1.9.1




[RESEND v9 12/12] pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

2017-08-15 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
---
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000..eee3dc2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
+Pincontrol driver for RK805 Power management IC.
+
+RK805 has 2 pins which can be configured as GPIO output only.
+
+Please refer file 
+for details of the common pinctrl bindings used by client devices,
+including the meaning of the phrase "pin configuration node".
+
+Optional Pinmux properties:
+--
+Following properties are required if default setting of pins are required
+at boot.
+- pinctrl-names: A pinctrl state named per .
+- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
+   .
+
+The pin configurations are defined as child of the pinctrl states node. Each
+sub-node have following properties:
+
+Required properties:
+--
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+
+- gpio-controller: Marks the device node as a GPIO controller.
+
+- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
+
+First 2 properties must be added in the RK805 PMIC node, documented in
+Documentation/devicetree/bindings/mfd/rk808.txt
+
+Optional properties:
+---
+Following are optional properties defined as pinmux DT binding document
+. Absence of properties will leave the configuration
+on default.
+   function,
+   output-low,
+   output-high.
+
+Valid values for function properties are: gpio.
+
+Theres is also not customised properties for any GPIO.
+
+Example:
+
+rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   ...
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <&pmic_int_l>, <&rk805_default>;
+
+   rk805_default: pinmux {
+   gpio01 {
+   pins = "gpio0", "gpio1";
+   function = "gpio";
+   output-high;
+   };
+   };
+};
-- 
1.9.1




Re: [PATCH] scsi: cxlflash: Fix an error handling path in 'cxlflash_disk_attach()'

2017-08-15 Thread Martin K. Petersen

Christophe,

> 'rc' is known to be 0 at this point.
> If 'create_context()' fails, returns -ENOMEM instead of 0 which means
> success.

Applied to 4.14/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCH] spi: rockchip: configure CTRLR1 according to size and data frame

2017-08-15 Thread Huibin Hong
CTRLR1 is number of data frames, when rx only.
When data frame is 8 bit, CTRLR1 is len-1.
When data frame is 16 bit, CTRLR1 is (len/2)-1.

Signed-off-by: Huibin Hong 
---

 drivers/spi/spi-rockchip.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 0b4a52b..6b1bac8 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -568,7 +568,13 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
 
writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0);
 
-   writel_relaxed(rs->len - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
+   if (rs->n_bytes == 1)
+   writel_relaxed(rs->len - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
+   else if (rs->n_bytes == 2)
+   writel_relaxed((rs->len / 2) - 1, rs->regs + 
ROCKCHIP_SPI_CTRLR1);
+   else
+   writel_relaxed((rs->len * 2) - 1, rs->regs + 
ROCKCHIP_SPI_CTRLR1);
+
writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_TXFTLR);
writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR);
 
-- 
1.9.1




Re: [PATCH 1/2] mm: Change the call sites of numa statistics items

2017-08-15 Thread kemi


On 2017年08月15日 17:49, Mel Gorman wrote:
> On Tue, Aug 15, 2017 at 04:45:35PM +0800, Kemi Wang wrote:
>> In this patch,  NUMA statistics is separated from zone statistics
>> framework, all the call sites of NUMA stats are changed to use
>> numa-stats-specific functions, it does not have any functionality change
>> except that the value of NUMA stats is shown behind zone page stats, and
>> the threshold size of NUMA stats is shown behind pcp threshold when users
>> *read* the zone info.
>>
>> E.g. cat /proc/zoneinfo
>> ***Base***   ***With this patch***
>> nr_free_pages 3976 nr_free_pages 3976
>> nr_zone_inactive_anon 0nr_zone_inactive_anon 0
>> nr_zone_active_anon 0  nr_zone_active_anon 0
>> nr_zone_inactive_file 0nr_zone_inactive_file 0
>> nr_zone_active_file 0  nr_zone_active_file 0
>> nr_zone_unevictable 0  nr_zone_unevictable 0
>> nr_zone_write_pending 0nr_zone_write_pending 0
>> nr_mlock 0 nr_mlock 0
>> nr_page_table_pages 0  nr_page_table_pages 0
>> nr_kernel_stack 0  nr_kernel_stack 0
>> nr_bounce0 nr_bounce0
>> nr_zspages   0 nr_zspages   0
>> numa_hit 0*nr_free_cma  0*
>> numa_miss 0numa_hit 0
>> numa_foreign 0 numa_miss0
>> numa_interleave 0  numa_foreign 0
>> numa_local   0 numa_interleave 0
>> numa_other   0 numa_local   0
>> *nr_free_cma 0*numa_other 0
>> ......
>> vm stats threshold: 10 vm stats threshold: 10
>> ...   *vm numa stats threshold: 10*
>>...
>>
>> The next patch updates the numa stats counter size and threshold.
>>
>> Signed-off-by: Kemi Wang 
>> ---
>>  drivers/base/node.c|  22 ---
>>  include/linux/mmzone.h |  25 +---
>>  include/linux/vmstat.h |  29 +
>>  mm/page_alloc.c|  10 +--
>>  mm/vmstat.c| 167 
>> +++--
>>  5 files changed, 227 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/base/node.c b/drivers/base/node.c
>> index d8dc830..12080c6 100644
>> --- a/drivers/base/node.c
>> +++ b/drivers/base/node.c
>> @@ -160,12 +160,12 @@ static ssize_t node_read_numastat(struct device *dev,
>> "interleave_hit %lu\n"
>> "local_node %lu\n"
>> "other_node %lu\n",
>> -   sum_zone_node_page_state(dev->id, NUMA_HIT),
>> -   sum_zone_node_page_state(dev->id, NUMA_MISS),
>> -   sum_zone_node_page_state(dev->id, NUMA_FOREIGN),
>> -   sum_zone_node_page_state(dev->id, NUMA_INTERLEAVE_HIT),
>> -   sum_zone_node_page_state(dev->id, NUMA_LOCAL),
>> -   sum_zone_node_page_state(dev->id, NUMA_OTHER));
>> +   sum_zone_node_numa_state(dev->id, NUMA_HIT),
>> +   sum_zone_node_numa_state(dev->id, NUMA_MISS),
>> +   sum_zone_node_numa_state(dev->id, NUMA_FOREIGN),
>> +   sum_zone_node_numa_state(dev->id, NUMA_INTERLEAVE_HIT),
>> +   sum_zone_node_numa_state(dev->id, NUMA_LOCAL),
>> +   sum_zone_node_numa_state(dev->id, NUMA_OTHER));
>>  }
> 
> The names are very similar and it would be preferred if the names were
> visually different like sum_zone_numa_stat() which is hard to confuse with
> the zone stat fields.
> 
Agree. Thanks for your suggestion.

>>  static DEVICE_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
>>  
>> @@ -181,9 +181,17 @@ static ssize_t node_read_vmstat(struct device *dev,
>>  n += sprintf(buf+n, "%s %lu\n", vmstat_text[i],
>>   sum_zone_node_page_state(nid, i));
>>  
>> -for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++)
>> +#ifdef CONFIG_NUMA
>> +for (i = 0; i < NR_VM_ZONE_NUMA_STAT_ITEMS; i++)
>>  n += sprintf(buf+n, "%s %lu\n",
>>   vmstat_text[i + NR_VM_ZONE_STAT_ITEMS],
>> + sum_zone_node_numa_state(nid, i));
>> +#endif
> 
> Similar with NR_VM_ZONE_NUMA_STAT_ITEMS, it's too similar to
> NR_VM_NODE_STAT_ITEMS>
How about NR_VM_NUMA_STAT_ITEMS? anyone has better idea?
 
>> +
>> +for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++)
>> +n += sprintf(buf+n, "%s %lu\n",
>> + vmstat_text[i + NR_VM_ZONE_STAT_ITEMS +
>> + NR_VM_ZONE_NUMA_STAT_ITEMS],
>>   node_page_state(pgdat, i));
>>  
>>  return n;
>> diff 

Re: [PATCH v2] zsmalloc: zs_page_migrate: schedule free_work if zspage is ZS_EMPTY

2017-08-15 Thread Minchan Kim
Hi Hui,

On Mon, Aug 14, 2017 at 05:56:30PM +0800, Hui Zhu wrote:
> After commit e2846124f9a2 ("zsmalloc: zs_page_migrate: skip unnecessary

This patch is not merged yet so the hash is invalid.
That means we may fold this patch to [1] in current mmotm.

[1] 
zsmalloc-zs_page_migrate-skip-unnecessary-loops-but-not-return-ebusy-if-zspage-is-not-inuse-fix.patch

> loops but not return -EBUSY if zspage is not inuse") zs_page_migrate
> can handle the ZS_EMPTY zspage.
> 
> But I got some false in zs_page_isolate:
>   if (get_zspage_inuse(zspage) == 0) {
>   spin_unlock(&class->lock);
>   return false;
>   }

I also realized we should make zs_page_isolate succeed on empty zspage
because we allow the empty zspage migration from now on.
Could you send a patch for that as well?

> The page of this zspage was migrated in before.
> 
> The reason is commit e2846124f9a2 ("zsmalloc: zs_page_migrate: skip
> unnecessary loops but not return -EBUSY if zspage is not inuse") just
> handle the "page" but not "newpage" then it keep the "newpage" with
> a empty zspage inside system.
> Root cause is zs_page_isolate remove it from ZS_EMPTY list but not
> call zs_page_putback "schedule_work(&pool->free_work);".  Because
> zs_page_migrate done the job without "schedule_work(&pool->free_work);"
> 
> Make this patch let zs_page_migrate wake up free_work if need.
> 
> Fixes: e2846124f9a2 ("zsmalloc: zs_page_migrate: skip unnecessary loops but 
> not return -EBUSY if zspage is not inuse")
> Signed-off-by: Hui Zhu 
> ---
>  mm/zsmalloc.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 62457eb..c6cc77c 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -2035,8 +2035,17 @@ int zs_page_migrate(struct address_space *mapping, 
> struct page *newpage,
>* Page migration is done so let's putback isolated zspage to
>* the list if @page is final isolated subpage in the zspage.
>*/
> - if (!is_zspage_isolated(zspage))
> - putback_zspage(class, zspage);
> + if (!is_zspage_isolated(zspage)) {
> + /*
> +  * Page will be freed in following part. But newpage and
> +  * zspage will stay in system if zspage is in ZS_EMPTY
> +  * list.  So call free_work to free it.
> +  * The page and class is locked, we cannot free zspage
> +  * immediately so let's defer.
> +  */

How about this?

/*
 * Since we allow empty zspage migration, putback of zspage
 * should free empty zspage. Otherwise, it could make a leak
 * until upcoming free_work is done, which isn't guaranteed.
 */
> + if (putback_zspage(class, zspage) == ZS_EMPTY)
> + schedule_work(&pool->free_work);
> + }
>  
>   reset_page(page);
>   put_page(page);
> -- 
> 1.9.1
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org";> em...@kvack.org 


Re: [PATCH v3 5/5] usb: xhci: Handle USB transaction error on address command

2017-08-15 Thread Lu Baolu
Hi,

On 08/15/2017 07:30 PM, Mathias Nyman wrote:
> On 11.08.2017 05:41, Lu Baolu wrote:
>> Xhci driver handles USB transaction errors on transfer events,
>> but transaction errors are possible on address device command
>> completion events as well.
>>
>> The xHCI specification (section 4.6.5) says: A USB Transaction
>> Error Completion Code for an Address Device Command may be due
>> to a Stall response from a device. Software should issue a Disable
>> Slot Command for the Device Slot then an Enable Slot Command to
>> recover from this error.
>>
>> This patch handles USB transaction errors on address command
>> completion events. The related discussion threads can be found
>> through below links.
>>
>> http://marc.info/?l=linux-usb&m=149362010728921&w=2
>> http://marc.info/?l=linux-usb&m=149252752825755&w=2
>>
>> Suggested-by: Mathias Nyman 
>> Signed-off-by: Lu Baolu 
>> ---
>>   drivers/usb/host/xhci.c | 5 +
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>> index d6b728d..95780f8 100644
>> --- a/drivers/usb/host/xhci.c
>> +++ b/drivers/usb/host/xhci.c
>> @@ -3822,6 +3822,11 @@ static int xhci_setup_device(struct usb_hcd *hcd, 
>> struct usb_device *udev,
>>   break;
>>   case COMP_USB_TRANSACTION_ERROR:
>>   dev_warn(&udev->dev, "Device not responding to setup %s.\n", act);
>> +
>> +ret = xhci_disable_slot(xhci, udev->slot_id);
>> +if (!ret)
>> +xhci_alloc_dev(hcd, udev);
>
> Might be a xhci->mutex locking issue here,
> both xhci_setup_device() and xhci_alloc_dev() take xhci->mutex
>

I will apply xhci->mutex in this patch for code consistency, but I think
we can drop xhci->mutex (in a separated patch) anyway.

xhci->mutex was introduced to protect two race sources of xhci->slot_id
and xhci->addr_dev by below commit:

commit a00918d0521df1c7a2ec9143142a3ea998c8526d
Author: Chris Bainbridge 
Date:   Tue May 19 16:30:51 2015 +0300

usb: host: xhci: add mutex for non-thread-safe data
   
Regression in commit 638139eb95d2 ("usb: hub: allow to process more usb
hub events in parallel")
   
The regression resulted in intermittent failure to initialise a 10-port
hub (with three internal VL812 4-port hub controllers) on boot, with a
failure rate of around 8%, due to multiple race conditions when
accessing addr_dev and slot_id in struct xhci_hcd.
   
This regression also exposed a problem with xhci_setup_device, which
"should be protected by the usb_address0_mutex" but no longer is due to
   
commit 6fecd4f2a58c ("USB: separate usb_address0 mutexes for each bus")
   
With separate buses (and locks) it is no longer the case that a single
lock will protect xhci_setup_device from accesses by two parallel
threads processing events on the two buses.
   
Fix this by adding a mutex to protect addr_dev and slot_id in struct
xhci_hcd, and by making the assignment of slot_id atomic.

[--cut---]

We have already removed these two race sources after that by below
two commits:

c2d3d49 usb: xhci: move slot_id from xhci_hcd to xhci_command structure
87e44f2 usb: xhci: remove the use of xhci->addr_dev

So we don't need xhci->mutex any more. I will try to do this in a separated
patch with more tests. For now, I will add xhci->mutex for code consistency.

Best regards,
Lu Baolu


Re: [PATCH 2/2] mm,fork: introduce MADV_WIPEONFORK

2017-08-15 Thread Rik van Riel
On Tue, 2017-08-15 at 15:51 -0700, Andrew Morton wrote:
> On Fri, 11 Aug 2017 17:28:29 -0400 r...@redhat.com wrote:
> 
> > A further complication is the proliferation of clone flags,
> > programs bypassing glibc's functions to call clone directly,
> > and programs calling unshare, causing the glibc pthread_atfork
> > hook to not get called.
> > 
> > It would be better to have the kernel take care of this
> > automatically.
> 
> I'll add "The patch also adds MADV_KEEPONFORK, to undo the effects of
> a
> prior MADV_WIPEONFORK." here.
> 
> I guess it isn't worth mentioning that these things can cause VMA
> merges and splits. 

That's the same as every other Linux specific madvise operation.

> > --- a/mm/madvise.c
> > +++ b/mm/madvise.c
> > @@ -80,6 +80,17 @@ static long madvise_behavior(struct
> > vm_area_struct *vma,
> >     }
> >     new_flags &= ~VM_DONTCOPY;
> >     break;
> > +   case MADV_WIPEONFORK:
> > +   /* MADV_WIPEONFORK is only supported on anonymous
> > memory. */
> > +   if (vma->vm_file || vma->vm_flags & VM_SHARED) {
> > +   error = -EINVAL;
> > +   goto out;
> > +   }
> > +   new_flags |= VM_WIPEONFORK;
> > +   break;
> > +   case MADV_KEEPONFORK:
> > +   new_flags &= ~VM_WIPEONFORK;
> > +   break;
> >     case MADV_DONTDUMP:
> >     new_flags |= VM_DONTDUMP;
> >     break;
> 
> It seems odd to permit MADV_KEEPONFORK against other-than-anon vmas?

Given that the only way to set VM_WIPEONFORK is through
MADV_WIPEONFORK, calling MADV_KEEPONFORK on an
other-than-anon vma would be equivalent to a noop.

If new_flags == vma->vm_flags, madvise_behavior() will
immediately exit.



Re: [PATCH v6 1/2] sched/deadline: Add support for SD_PREFER_SIBLING on find_later_rq()

2017-08-15 Thread Byungchul Park
On Tue, Aug 15, 2017 at 09:42:01PM -0400, Steven Rostedt wrote:
> > > > @@ -1385,6 +1407,17 @@ static int find_later_rq(struct task_struct 
> > > > *task)
> > > >  * already under consideration through 
> > > > later_mask.
> > > >  */
> > > > if (best_cpu < nr_cpu_ids) {
> > > > +   /*
> > > > +* If current domain is 
> > > > SD_PREFER_SIBLING
> > > > +* flaged, we have to get more chances 
> > > > to
> > > > +* check other siblings.
> 
> BTW, "we have to get more chances" doesn't really make sense. Do you
> mean "we need to try other domains"?

Yes, we need to try other domains first if current domain is
SD_PREFER_SIBLING flaged.

> > > > +*/
> > > > +   if (sd->flags & SD_PREFER_SIBLING) {
> > > > +   prefer = sd;  
> > > 
> > > Is this how the SD_PREFER_SIBLING works? According to this, the
> > > preferred sd is the next sd in for_each_domain(). Not to mention, the
> > > prefer variable stays set if the next domain has no available CPUs. Is
> > > that what we want?  
> > 
> > Maybe I don't understand what you want to say. The variable, prefer, is
> > used to pick up the smallest sched domain among SD_PREFER_SIBLING
> > domains, if more than one SD_PREFER_SIBLING domain exist in the visit.
> > 
> > The prefer variable alway points to the previous SD_PREFER_SIBLING domain.
> > And that must stay set to be used as a fallback choise if the next domain
> > has no available CPUs.
> > 
> > Could you explain what I mis-understand?
> >
> 
> I may be the one confused here ;-)
> 
> I think I misread the patch. So, the SD_PREFER_SIBLING means to try to
> find a CPU in another sd instead? Thus, we try to find a CPU in a sd
> that does not have SD_PREFER_SIBLING set. And if there is none, we use
> the preferred sd as a fallback. Is that correct?

Yes, that's what I intended. IOW:

If (we found a proper sd, not having SD_PREFER_SIBLING?)
use the sd;
else if (we found a proper sd, having SD_PREFER_SIBLING?)
use the smallest sd among SD_PREFER_SIBLING sds;

Thanks,
Byungchul


Re: [PATCH v3 1/2] dt-bindings: i2c: Add MediaTek MT7622 i2c binding

2017-08-15 Thread Sean Wang
On Tue, 2017-08-15 at 21:08 +0800, Jun Gao wrote:
> From: Jun Gao 
> 
> Add MT7622 i2c binding to binding file and change the compatible
> information formats of all SoCs to the same.
> 
> Signed-off-by: Jun Gao 
> ---
>  Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt 
> b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt
> index bd5a7be..71fc0b3 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt
> @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C 
> devices.
>  
>  Required properties:
>- compatible: value should be either of the following.
> -  "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701
> -  "mediatek,mt6577-i2c": for i2c compatible with mt6577.
> -  "mediatek,mt6589-i2c": for i2c compatible with mt6589.
> -  "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible with 
> mt7623.
> -  "mediatek,mt8173-i2c": for i2c compatible with mt8173.
> +  "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701
> +  "mediatek,mt6577-i2c": for Mediatek MT6577
> +  "mediatek,mt6589-i2c": for Mediatek MT6589
> +  "mediatek,mt7622-i2c": for Mediatek MT7622
> +  "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623
> +  "mediatek,mt8173-i2c": for Mediatek MT8173
>- reg: physical base address of the controller and dma base, length of 
> memory
>  mapped region.
>- interrupts: interrupt number to the cpu.

Hi, Jun

the patch for new soc support and clean-ups should better be in separate
patch following previous Matthias suggestion. 

http://lists.infradead.org/pipermail/linux-mediatek/2017-August/009740.html


And also spelling for Mediatek should be corrected using MediaTek.


Sean





Re: [GIT] Networking

2017-08-15 Thread Linus Torvalds
On Tue, Aug 15, 2017 at 5:52 PM, David Miller  wrote:
>
> dingtianhong (4):
>   PCI: Disable PCIe Relaxed Ordering if unsupported
>   PCI: Disable Relaxed Ordering for some Intel processors
>   PCI: Disable Relaxed Ordering Attributes for AMD A1100
>   PCI: fix oops when try to find Root Port for a PCI device

I would *really* have liked to see an ack on these from Bjorn Helgaas.
Was he even cc'd?

And while singling those commits out, I would also really have liked
to see an actual name there.

The name exists in the sign-off chain:

Signed-off-by: Ding Tianhong 

but for some reason not in the actual commit author data, where it's
just "dingtianhong".

Pulled, but slightly unhappy.

Linus


Re: [PATCH 4/6] arm64: dts: uniphier: use cross-arch include instead of symlinks

2017-08-15 Thread Masahiro Yamada
2017-08-10 1:43 GMT+09:00 Masahiro Yamada :
> On UniPhier platform, some DTSI files are shared between arm and arm64.
> Recently, inclusion of DT material of different architectures has been
> supported by the build system level.  Use #include , which
> will work without relying on the exact same hierarchy as the kernel.
>
> Signed-off-by: Masahiro Yamada 

Applied to linux-uniphier.



-- 
Best Regards
Masahiro Yamada


[PATCH v1 0/4] perf annotate: Display multiple events on the left side of annotate view

2017-08-15 Thread Jin Yao
perf record -e cycles,branches ...
perf annotate main --stdio

The result only shows cycles. It should show both cycles and
branches on the left side of annotate view. It works with
"--group", but need this to work even without groups.

The patch series supports to display multiple events on the
left side of annotate view for stdio, tui and gtk modes.

Jin Yao (4):
  perf annotate: create a new hists to manage multiple events samples
  perf annotate: Display multiple events for stdio mode
  perf annotate: Display multiple events for tui mode
  perf annotate: Display multiple events for gtk mode

 tools/perf/builtin-annotate.c |  62 +
 tools/perf/builtin-top.c  |   3 +-
 tools/perf/ui/browsers/annotate.c |  49 +++---
 tools/perf/ui/browsers/hists.c|   2 +-
 tools/perf/ui/gtk/annotate.c  |  35 ---
 tools/perf/util/annotate.c| 187 +-
 tools/perf/util/annotate.h|  16 +++-
 tools/perf/util/hist.h|   8 +-
 tools/perf/util/sort.c|  21 +
 tools/perf/util/sort.h|  13 +++
 10 files changed, 301 insertions(+), 95 deletions(-)

-- 
2.7.4



[PATCH v1 3/4] perf annotate: Display multiple events for tui mode

2017-08-15 Thread Jin Yao
For example:
perf record -e cycles,branches ./div
perf annotate main

  │for (i = 0; i < 20; i++) {
  │flag = compute_flag();
  5.77   4.85 │38:   xor%eax,%eax
  0.01   0.01 │→ callq  compute_flag
  │
  │count++;
  2.38   4.38 │  movcount,%edx
  0.00   0.00 │  add$0x1,%edx
  │
  │if (flag)
  │  test   %eax,%eax
  │srand(s_randseed);
  │
  │for (i = 0; i < 20; i++) {
  │flag = compute_flag();
  │
  │count++;
  0.60   0.44 │  mov%edx,count
  │
  │if (flag)
  3.99   4.32 │↓ je 82

Signed-off-by: Jin Yao 
---
 tools/perf/ui/browsers/annotate.c | 49 ---
 tools/perf/ui/browsers/hists.c|  2 +-
 tools/perf/util/annotate.h|  6 +++--
 tools/perf/util/hist.h|  8 ---
 4 files changed, 45 insertions(+), 20 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 80f38da..b76c238 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -428,13 +428,15 @@ static void annotate_browser__set_rb_top(struct 
annotate_browser *browser,
 }
 
 static void annotate_browser__calc_percent(struct annotate_browser *browser,
-  struct perf_evsel *evsel)
+  struct perf_evsel *evsel,
+  struct hist_entry *he)
 {
struct map_symbol *ms = browser->b.priv;
struct symbol *sym = ms->sym;
struct annotation *notes = symbol__annotation(sym);
struct disasm_line *pos, *next;
s64 len = symbol__size(sym);
+   struct hist_event *hevt;
 
browser->entries = RB_ROOT;
 
@@ -455,13 +457,25 @@ static void annotate_browser__calc_percent(struct 
annotate_browser *browser,
 
for (i = 0; i < browser->nr_events; i++) {
struct sym_hist_entry sample;
-
-   bpos->samples[i].percent = disasm__calc_percent(notes,
+   if (evsel) {
+   bpos->samples[i].percent =
+   disasm__calc_percent(notes,
evsel->idx + i,
pos->offset,
next ? next->offset : len,
&path, &sample);
-   bpos->samples[i].he = sample;
+   bpos->samples[i].he = sample;
+   } else if (he) {
+   hevt = &he->events[i];
+   notes = symbol__annotation(hevt->ms.sym);
+   bpos->samples[i].percent =
+   disasm__calc_percent(notes,
+   hevt->idx,
+   pos->offset,
+   next ? next->offset : len,
+   &path, &sample);
+   bpos->samples[i].he = sample;
+   }
 
if (max_percent < bpos->samples[i].percent)
max_percent = bpos->samples[i].percent;
@@ -567,7 +581,7 @@ static bool annotate_browser__callq(struct annotate_browser 
*browser,
}
 
pthread_mutex_unlock(¬es->lock);
-   symbol__tui_annotate(target.sym, target.map, evsel, hbt);
+   symbol__tui_annotate(target.sym, target.map, evsel, hbt, NULL);
sym_title(ms->sym, ms->map, title, sizeof(title));
ui_browser__show_title(&browser->b, title);
return true;
@@ -755,7 +769,8 @@ static void annotate_browser__update_addr_width(struct 
annotate_browser *browser
 
 static int annotate_browser__run(struct annotate_browser *browser,
 struct perf_evsel *evsel,
-struct hist_browser_timer *hbt)
+struct hist_browser_timer *hbt,
+struct hist_entry *he)
 {
struct rb_node *nd = NULL;
struct map_symbol *ms = browser->b.priv;
@@ -769,7 +784,7 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
if (ui_browser__show(&browser->b, title, help) < 0)
return -1;
 
-   annotate_browser__calc_percent(browser, evsel);
+   annotate_browser__calc_percent(browser, evsel, he);
 
if (browser->curr_hot) {
annotate_browser__set_rb_top(browser, browser

[PATCH v1 1/4] perf annotate: create a new hists to manage multiple events samples

2017-08-15 Thread Jin Yao
An issue is found during using perf annotate.

perf record -e cycles,branches ...
perf annotate main --stdio

The result only shows cycles. It should show both cycles and
branches on the left side. It works with "--group", but need
this to work even without groups.

In current design, the hists is per event. So we need a new
hists to manage the samples for multiple events and use a new
hist_event data structure to save the map/symbol information
for per event.

Signed-off-by: Jin Yao 
---
 tools/perf/builtin-annotate.c | 60 +++
 tools/perf/util/annotate.c|  8 ++
 tools/perf/util/annotate.h|  4 +++
 tools/perf/util/sort.c| 21 +++
 tools/perf/util/sort.h| 13 ++
 5 files changed, 89 insertions(+), 17 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 658c920..833866c 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -45,6 +45,7 @@ struct perf_annotate {
bool   skip_missing;
const char *sym_hist_filter;
const char *cpu_list;
+   struct hists events_hists;
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 };
 
@@ -153,6 +154,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
struct hists *hists = evsel__hists(evsel);
struct hist_entry *he;
int ret;
+   struct hist_event *hevt;
 
if (ann->sym_hist_filter != NULL &&
(al->sym == NULL ||
@@ -177,12 +179,30 @@ static int perf_evsel__add_sample(struct perf_evsel 
*evsel,
 */
process_branch_stack(sample->branch_stack, al, sample);
 
-   he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true);
-   if (he == NULL)
-   return -ENOMEM;
+   if (symbol_conf.nr_events == 1) {
+   he = hists__add_entry(hists, al, NULL, NULL, NULL,
+ sample, true);
+   if (he == NULL)
+   return -ENOMEM;
+
+   ret = hist_entry__inc_addr_samples(he, sample, evsel->idx,
+  al->addr);
+   hists__inc_nr_samples(hists, true);
+   } else {
+   he = hists__add_entry(&ann->events_hists, al, NULL,
+ NULL, NULL, sample, true);
+   if (he == NULL)
+   return -ENOMEM;
+
+   hevt = hist_entry__event_add(he, evsel);
+   if (hevt == NULL)
+   return -ENOMEM;
+
+   ret = hist_event__inc_addr_samples(hevt, sample, hevt->idx,
+  al->addr);
+   hists__inc_nr_samples(&ann->events_hists, true);
+   }
 
-   ret = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
-   hists__inc_nr_samples(hists, true);
return ret;
 }
 
@@ -304,7 +324,8 @@ static int __cmd_annotate(struct perf_annotate *ann)
int ret;
struct perf_session *session = ann->session;
struct perf_evsel *pos;
-   u64 total_nr_samples;
+   u64 total_nr_samples = 0;
+   struct hists *hists;
 
if (ann->cpu_list) {
ret = perf_session__cpu_bitmap(session, ann->cpu_list,
@@ -335,23 +356,26 @@ static int __cmd_annotate(struct perf_annotate *ann)
if (verbose > 2)
perf_session__fprintf_dsos(session, stdout);
 
-   total_nr_samples = 0;
-   evlist__for_each_entry(session->evlist, pos) {
-   struct hists *hists = evsel__hists(pos);
-   u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
+   if (symbol_conf.nr_events > 1) {
+   hists = &ann->events_hists;
+   total_nr_samples +=
+   hists->stats.nr_events[PERF_RECORD_SAMPLE];
+
+   hists__collapse_resort(hists, NULL);
+   hists__output_resort(hists, NULL);
+   hists__find_annotations(hists, NULL, ann);
+   } else {
+   evlist__for_each_entry(session->evlist, pos) {
+   hists = evsel__hists(pos);
+   total_nr_samples +=
+   hists->stats.nr_events[PERF_RECORD_SAMPLE];
 
-   if (nr_samples > 0) {
-   total_nr_samples += nr_samples;
hists__collapse_resort(hists, NULL);
/* Don't sort callchain */
perf_evsel__reset_sample_bit(pos, CALLCHAIN);
perf_evsel__output_resort(pos, NULL);
-
-   if (symbol_conf.event_group &&
-   !perf_evsel__is_group_leader(pos))
-   continue;
-
hists__find_annotations(hists, pos, ann);
+   break;
}
}
 
@@ -486,6 +510,8 @@ int cmd_annotate(int argc, const char **argv)
   

[PATCH v1 4/4] perf annotate: Display multiple events for gtk mode

2017-08-15 Thread Jin Yao
For example:
perf record -e cycles,branches ./div
perf annotate main --gtk

Both the cycles and branches are displayed at the left column in
gtk window.

Signed-off-by: Jin Yao 
---
 tools/perf/ui/gtk/annotate.c | 35 ++-
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index 0217619..f314654 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -88,7 +88,8 @@ static int perf_gtk__get_line(char *buf, size_t size, struct 
disasm_line *dl)
 
 static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
struct map *map, struct perf_evsel *evsel,
-   struct hist_browser_timer *hbt __maybe_unused)
+   struct hist_browser_timer *hbt __maybe_unused,
+   struct hist_entry *he)
 {
struct disasm_line *pos, *n;
struct annotation *notes;
@@ -98,6 +99,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, 
struct symbol *sym,
GtkWidget *view;
int i;
char s[512];
+   struct hist_event *hevt;
 
notes = symbol__annotation(sym);
 
@@ -124,17 +126,18 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, 
struct symbol *sym,
 
gtk_list_store_append(store, &iter);
 
-   if (perf_evsel__is_group_event(evsel)) {
-   for (i = 0; i < evsel->nr_members; i++) {
+   if (evsel) {
+   ret = perf_gtk__get_percent(s, sizeof(s), sym, pos,
+   evsel->idx);
+   } else if (he) {
+   for (i = 0; i < he->event_nr; i++) {
+   hevt = &he->events[i];
ret += perf_gtk__get_percent(s + ret,
 sizeof(s) - ret,
-sym, pos,
-evsel->idx + i);
+hevt->ms.sym, pos,
+hevt->idx);
ret += scnprintf(s + ret, sizeof(s) - ret, " ");
}
-   } else {
-   ret = perf_gtk__get_percent(s, sizeof(s), sym, pos,
-   evsel->idx);
}
 
if (ret)
@@ -157,19 +160,25 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, 
struct symbol *sym,
 
 static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
struct perf_evsel *evsel,
-   struct hist_browser_timer *hbt)
+   struct hist_browser_timer *hbt,
+   struct hist_entry *he)
 {
GtkWidget *window;
GtkWidget *notebook;
GtkWidget *scrolled_window;
GtkWidget *tab_label;
int err;
+   char *arch;
+
+   if (!evsel)
+   arch = perf_evsel__env_arch(he->events[0].evsel);
+   else
+   arch = perf_evsel__env_arch(evsel);
 
if (map->dso->annotate_warned)
return -1;
 
-   err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel),
- 0, NULL, NULL);
+   err = symbol__disassemble(sym, map, arch, 0, NULL, NULL);
if (err) {
char msg[BUFSIZ];
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
@@ -228,7 +237,7 @@ static int symbol__gtk_annotate(struct symbol *sym, struct 
map *map,
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window,
 tab_label);
 
-   perf_gtk__annotate_symbol(scrolled_window, sym, map, evsel, hbt);
+   perf_gtk__annotate_symbol(scrolled_window, sym, map, evsel, hbt, he);
return 0;
 }
 
@@ -236,7 +245,7 @@ int hist_entry__gtk_annotate(struct hist_entry *he,
 struct perf_evsel *evsel,
 struct hist_browser_timer *hbt)
 {
-   return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt);
+   return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt, he);
 }
 
 void perf_gtk__show_annotations(void)
-- 
2.7.4



[PATCH v1 2/4] perf annotate: Display multiple events for stdio mode

2017-08-15 Thread Jin Yao
For example:
perf record -e cycles,branches ./div
perf annotate main --stdio

 Percent |  Source code & Disassembly of div for branches,cycles 
(90966 samples)

..
 :  for (i = 0; i < 20; i++) {
 :  flag = compute_flag();
5.774.85 :4004e8:   xor%eax,%eax
0.010.01 :4004ea:   callq  400640 
 :
 :  count++;
2.384.38 :4004ef:   mov0x200b57(%rip),%edx
0.000.00 :4004f5:   add$0x1,%edx
 :
 :  if (flag)
0.000.00 :4004f8:   test   %eax,%eax
 :  srand(s_randseed);
 :
 :  for (i = 0; i < 20; i++) {
 :  flag = compute_flag();
 :
 :  count++;
0.600.44 :4004fa:   mov%edx,0x200b4c(%rip)
 :
 :  if (flag)
3.994.32 :400500:   je 400532 

Signed-off-by: Jin Yao 
---
 tools/perf/builtin-annotate.c |   2 +-
 tools/perf/builtin-top.c  |   3 +-
 tools/perf/util/annotate.c| 179 --
 tools/perf/util/annotate.h|   6 +-
 4 files changed, 145 insertions(+), 45 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 833866c..98663bd 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -240,7 +240,7 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
struct perf_annotate *ann)
 {
return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel,
-   ann->print_line, ann->full_paths, 0, 0);
+   ann->print_line, ann->full_paths, 0, 0, he);
 }
 
 static void hists__find_annotations(struct hists *hists,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index ee954bd..2287667 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -245,7 +245,8 @@ static void perf_top__show_details(struct perf_top *top)
printf("  Events  Pcnt (>=%d%%)\n", top->sym_pcnt_filter);
 
more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel,
-  0, top->sym_pcnt_filter, 
top->print_entries, 4);
+  0, top->sym_pcnt_filter,
+  top->print_entries, 4, NULL);
 
if (top->evlist->enabled) {
if (top->zero)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 16ec881..8630108 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1071,7 +1071,8 @@ static void annotate__branch_printf(struct block_range 
*br, u64 addr)
 
 static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 
start,
  struct perf_evsel *evsel, u64 len, int min_pcnt, int 
printed,
- int max_lines, struct disasm_line *queue)
+ int max_lines, struct disasm_line *queue,
+ struct hist_entry *he)
 {
static const char *prev_line;
static const char *prev_color;
@@ -1082,31 +1083,39 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
double *ppercents = &percent;
struct sym_hist_entry sample;
struct sym_hist_entry *psamples = &sample;
-   int i, nr_percent = 1;
+   int i, nr_percent;
const char *color;
struct annotation *notes = symbol__annotation(sym);
s64 offset = dl->offset;
const u64 addr = start + offset;
struct disasm_line *next;
struct block_range *br;
+   struct hist_event *hevt;
 
next = disasm__get_next_ip_line(¬es->src->source, dl);
-
-   if (perf_evsel__is_group_event(evsel)) {
-   nr_percent = evsel->nr_members;
-   ppercents = calloc(nr_percent, sizeof(double));
-   psamples = calloc(nr_percent, sizeof(struct 
sym_hist_entry));
-   if (ppercents == NULL || psamples == NULL) {
-   return -1;
-   }
+   nr_percent = (evsel) ? 1 : he->event_nr;
+   ppercents = calloc(nr_percent, sizeof(double));
+   psamples = calloc(nr_percent, sizeof(struct sym_hist_entry));
+   if (ppercents == NULL || psamples == NULL) {
+   return -1;
}
 
  

[PATCH 4/5] autofs: drop wrong comment

2017-08-15 Thread Ian Kent
From: Tomohiro Kusumi 

This comment was correct when it was added in 8d7b48e0 in 2008,
but not after 4e44b685 in 2009 which introduced find_autofs_mount().

Signed-off-by: Tomohiro Kusumi 
Signed-off-by: Ian Kent 
---
 fs/autofs4/dev-ioctl.c |5 -
 1 file changed, 5 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index b8b66d55266d..a990c9d0f893 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -258,11 +258,6 @@ static int autofs_dev_ioctl_open_mountpoint(const char 
*name, dev_t devid)
if (err)
goto out;
 
-   /*
-* Find autofs super block that has the device number
-* corresponding to the autofs fs we want to open.
-*/
-
filp = dentry_open(&path, O_RDONLY, current_cred());
path_put(&path);
if (IS_ERR(filp)) {



[PATCH 2/5] autofs: non functional header inclusion cleanup

2017-08-15 Thread Ian Kent
From: Tomohiro Kusumi 

Having header includes before any macro (without any dependency)
simply looks normal. No reason to have these macros in between.

Signed-off-by: Tomohiro Kusumi 
Signed-off-by: Ian Kent 
---
 fs/autofs4/autofs_i.h |   22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index beef981aa54f..4737615f0eaa 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -11,10 +11,21 @@
 
 #include 
 #include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 /* This is the range of ioctl() numbers we claim as ours */
 #define AUTOFS_IOC_FIRST AUTOFS_IOC_READY
@@ -24,17 +35,6 @@
 #define AUTOFS_DEV_IOCTL_IOC_COUNT \
(AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD - AUTOFS_DEV_IOCTL_VERSION_CMD)
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #ifdef pr_fmt
 #undef pr_fmt
 #endif



[PATCH 1/5] autofs: remove unused AUTOFS_IOC_EXPIRE_DIRECT/INDIRECT

2017-08-15 Thread Ian Kent
From: Tomohiro Kusumi 

These are not used by either kernel or userspace, although
AUTOFS_IOC_EXPIRE_DIRECT once seems to have been used by userspace
in around 2006-2008, which was technically just an alias of the
existing ioctl AUTOFS_IOC_EXPIRE_MULTI.

ioctls for autofs are already complicated enough that they could
be removed unless these are staying here to be able to compile
userspace code of certain period of time from a decade ago.

Edit: imk
Yes, this is indeed very old and anything that still uses must
be updated becuase it will be using broken functionality.
End edit: imk

Signed-off-by: Tomohiro Kusumi 
Signed-off-by: Ian Kent 
---
 include/uapi/linux/auto_fs4.h |2 --
 1 file changed, 2 deletions(-)

diff --git a/include/uapi/linux/auto_fs4.h b/include/uapi/linux/auto_fs4.h
index 7c6da423d54e..9453e9a07c9d 100644
--- a/include/uapi/linux/auto_fs4.h
+++ b/include/uapi/linux/auto_fs4.h
@@ -155,8 +155,6 @@ enum {
 };
 
 #define AUTOFS_IOC_EXPIRE_MULTI_IOW(AUTOFS_IOCTL, 
AUTOFS_IOC_EXPIRE_MULTI_CMD, int)
-#define AUTOFS_IOC_EXPIRE_INDIRECT AUTOFS_IOC_EXPIRE_MULTI
-#define AUTOFS_IOC_EXPIRE_DIRECT   AUTOFS_IOC_EXPIRE_MULTI
 #define AUTOFS_IOC_PROTOSUBVER _IOR(AUTOFS_IOCTL, 
AUTOFS_IOC_PROTOSUBVER_CMD, int)
 #define AUTOFS_IOC_ASKUMOUNT   _IOR(AUTOFS_IOCTL, 
AUTOFS_IOC_ASKUMOUNT_CMD, int)
 



[PATCH 5/5] autofs: use unsigned int/long instead of uint/ulong for ioctl args

2017-08-15 Thread Ian Kent
From: Tomohiro Kusumi 

The standard types unsigned int and unsigned long should be used for
.compat_ioctl. autofs is the only fs using uing/ulong for this, and
these are even the only uint/ulong in the entire autofs code.

Drop unneeded long cast in return value of autofs_dev_ioctl_compat().
It's already long.

Signed-off-by: Tomohiro Kusumi 
Signed-off-by: Ian Kent 
---
 fs/autofs4/dev-ioctl.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index a990c9d0f893..b7c816f39404 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -93,7 +93,7 @@ static int check_dev_ioctl_version(int cmd, struct 
autofs_dev_ioctl *param)
  * at the end of the struct.
  */
 static struct autofs_dev_ioctl *
-   copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
+copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
 {
struct autofs_dev_ioctl tmp, *res;
 
@@ -705,7 +705,8 @@ static int _autofs_dev_ioctl(unsigned int command,
return err;
 }
 
-static long autofs_dev_ioctl(struct file *file, uint command, ulong u)
+static long autofs_dev_ioctl(struct file *file, unsigned int command,
+unsigned long u)
 {
int err;
 
@@ -714,9 +715,10 @@ static long autofs_dev_ioctl(struct file *file, uint 
command, ulong u)
 }
 
 #ifdef CONFIG_COMPAT
-static long autofs_dev_ioctl_compat(struct file *file, uint command, ulong u)
+static long autofs_dev_ioctl_compat(struct file *file, unsigned int command,
+   unsigned long u)
 {
-   return (long) autofs_dev_ioctl(file, command, (ulong) compat_ptr(u));
+   return autofs_dev_ioctl(file, command, (unsigned long) compat_ptr(u));
 }
 #else
 #define autofs_dev_ioctl_compat NULL



[PATCH 3/5] autofs: use AUTOFS_DEV_IOCTL_SIZE

2017-08-15 Thread Ian Kent
From: Tomohiro Kusumi 

Use a macro which defines misc-dev ioctl parameter size (excluding
a path beyond &path[0]) since it's been used to initialize and copy
this structure ever since it first appeared in 8d7b48e0 in 2008.

(or simply get rid of this if this is just unnecessary abstraction
when all it needs is sizeof(struct autofs_dev_ioctl))

Edit: imk
That's a good point but I'd prefer to keep the macro define.
End edit: imk

Signed-off-by: Tomohiro Kusumi 
Signed-off-by: Ian Kent 
---
 fs/autofs4/dev-ioctl.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index ea8b3a1cddd2..b8b66d55266d 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -97,13 +97,13 @@ static struct autofs_dev_ioctl *
 {
struct autofs_dev_ioctl tmp, *res;
 
-   if (copy_from_user(&tmp, in, sizeof(tmp)))
+   if (copy_from_user(&tmp, in, AUTOFS_DEV_IOCTL_SIZE))
return ERR_PTR(-EFAULT);
 
-   if (tmp.size < sizeof(tmp))
+   if (tmp.size < AUTOFS_DEV_IOCTL_SIZE)
return ERR_PTR(-EINVAL);
 
-   if (tmp.size > (PATH_MAX + sizeof(tmp)))
+   if (tmp.size > AUTOFS_DEV_IOCTL_SIZE + PATH_MAX)
return ERR_PTR(-ENAMETOOLONG);
 
res = memdup_user(in, tmp.size);
@@ -133,8 +133,8 @@ static int validate_dev_ioctl(int cmd, struct 
autofs_dev_ioctl *param)
goto out;
}
 
-   if (param->size > sizeof(*param)) {
-   err = invalid_str(param->path, param->size - sizeof(*param));
+   if (param->size > AUTOFS_DEV_IOCTL_SIZE) {
+   err = invalid_str(param->path, param->size - 
AUTOFS_DEV_IOCTL_SIZE);
if (err) {
pr_warn(
  "path string terminator missing for cmd(0x%08x)\n",
@@ -451,7 +451,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
dev_t devid;
int err = -ENOENT;
 
-   if (param->size <= sizeof(*param)) {
+   if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
err = -EINVAL;
goto out;
}
@@ -539,7 +539,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
unsigned int devid, magic;
int err = -ENOENT;
 
-   if (param->size <= sizeof(*param)) {
+   if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
err = -EINVAL;
goto out;
}



Re: [PATCH 2/2] mm: Update NUMA counter threshold size

2017-08-15 Thread kemi

>>  
>> -static inline unsigned long zone_numa_state(struct zone *zone,
>> +static inline unsigned long zone_numa_state_snapshot(struct zone *zone,
>>  enum zone_numa_stat_item item)
>>  {
>>  long x = atomic_long_read(&zone->vm_numa_stat[item]);
>> +int cpu;
>> +
>> +for_each_online_cpu(cpu)
>> +x += per_cpu_ptr(zone->pageset, cpu)->vm_numa_stat_diff[item];
>>  
>>  return x;
>>  }
> 
> This does not appear to be related to the current patch. It either
> should be merged with the previous patch or stand on its own.
> 
OK. I can move it to an individual patch if it does not make anyone unhappy.
Since it is not graceful to introduce any functionality change in first patch.

>> diff --git a/mm/vmstat.c b/mm/vmstat.c
>> index 5a7fa30..c7f50ed 100644
>> --- a/mm/vmstat.c
>> +++ b/mm/vmstat.c
>> @@ -30,6 +30,8 @@
>>  
>>  #include "internal.h"
>>  
>> +#define NUMA_STAT_THRESHOLD  32765
>> +
> 
> This should be expressed in terms of the type and not a hard-coded value.
> 
OK, Thanks. I will follow it.


Re: [GIT PULL] seccomp updates for next

2017-08-15 Thread James Morris
On Tue, 15 Aug 2017, Kees Cook wrote:

> Hi James,
> 
> Please pull these seccomp changes for next.
> 

Pulled to -next, thanks!

-- 
James Morris




[PATCH v2] swap: choose swap device according to numa node

2017-08-15 Thread Aaron Lu
On Tue, Aug 15, 2017 at 03:09:47PM -0700, Andrew Morton wrote:
> On Tue, 15 Aug 2017 13:49:45 +0800 Aaron Lu  wrote:
> > 
> > I'm not sure what to do...any hint?
> > Adding a pr_err() perhaps?
> 
> pr_emerg(), probably.  Would it make sense to disable all swapon()s
> after this?

Right!
I should have added a check for swap_avail_heads during swap on time :)

---
From: Aaron Lu 
Subject: [PATCH v2] swap: choose swap device according to numa node

If the system has more than one swap device and swap device has the node
information, we can make use of this information to decide which swap
device to use in get_swap_pages() to get better performance.

The current code uses a priority based list, swap_avail_list, to decide
which swap device to use and if multiple swap devices share the same
priority, they are used round robin.  This patch changes the previous
single global swap_avail_list into a per-numa-node list, i.e.  for each
numa node, it sees its own priority based list of available swap devices.
Swap device's priority can be promoted on its matching node's
swap_avail_list.

The current swap device's priority is set as: user can set a >=0 value, or
the system will pick one starting from -1 then downwards.  The priority
value in the swap_avail_list is the negated value of the swap device's due
to plist being sorted from low to high.  The new policy doesn't change the
semantics for priority >=0 cases, the previous starting from -1 then
downwards now becomes starting from -2 then downwards and -1 is reserved
as the promoted value.

Take 4-node EX machine as an example, suppose 4 swap devices are
available, each sit on a different node:
swapA on node 0
swapB on node 1
swapC on node 2
swapD on node 3

After they are all swapped on in the sequence of ABCD.

Current behaviour:
their priorities will be:
swapA: -1
swapB: -2
swapC: -3
swapD: -4
And their position in the global swap_avail_list will be:
swapA   -> swapB   -> swapC   -> swapD
prio:1 prio:2 prio:3 prio:4

New behaviour:
their priorities will be(note that -1 is skipped):
swapA: -2
swapB: -3
swapC: -4
swapD: -5
And their positions in the 4 swap_avail_lists[nid] will be:
swap_avail_lists[0]: /* node 0's available swap device list */
swapA   -> swapB   -> swapC   -> swapD
prio:1 prio:3 prio:4 prio:5
swap_avali_lists[1]: /* node 1's available swap device list */
swapB   -> swapA   -> swapC   -> swapD
prio:1 prio:2 prio:4 prio:5
swap_avail_lists[2]: /* node 2's available swap device list */
swapC   -> swapA   -> swapB   -> swapD
prio:1 prio:2 prio:3 prio:5
swap_avail_lists[3]: /* node 3's available swap device list */
swapD   -> swapA   -> swapB   -> swapC
prio:1 prio:2 prio:3 prio:4

To see the effect of the patch, a test that starts N process, each mmap a
region of anonymous memory and then continually write to it at random
position to trigger both swap in and out is used.

On a 2 node Skylake EP machine with 64GiB memory, two 170GB SSD drives are
used as swap devices with each attached to a different node, the result
is:

runtime=30m/processes=32/total test size=128G/each process mmap region=4G
kernel throughput
vanilla13306
auto-binding   15169 +14%

runtime=30m/processes=64/total test size=128G/each process mmap region=2G
kernel throughput
vanilla11885
auto-binding   14879 +25%

Link: http://lkml.kernel.org/r/20170814053130.gd2...@aaronlu.sh.intel.com
Signed-off-by: Aaron Lu 
Cc: "Chen, Tim C" 
Cc: Huang Ying 
Cc: Andi Kleen 
Cc: Michal Hocko 
Cc: Minchan Kim 
Cc: Hugh Dickins 
Signed-off-by: Andrew Morton 
---
v2: added pr_emrg in swapfile_init() for -ENOMEM case and check for
swap_avail_heads during swap on time as suggested by Andrew Morton;
Documentation update as suggested by Andrew Morton;
style fix by adding a blank line in __del_from_avail_list().

 Documentation/vm/swap_numa.txt |  69 
 include/linux/swap.h   |   2 +-
 mm/swapfile.c  | 119 -
 3 files changed, 163 insertions(+), 27 deletions(-)
 create mode 100644 Documentation/vm/swap_numa.txt

diff --git a/Documentation/vm/swap_numa.txt b/Documentation/vm/swap_numa.txt
new file mode 100644
index ..d5960c9124f5
--- /dev/null
+++ b/Documentation/vm/swap_numa.txt
@@ -0,0 +1,69 @@
+Automatically bind swap device to numa node
+---
+
+If the system has more than one swap device and swap device has the node
+information, we can make use of this information to decide which swap
+device to use in get_swap_pages() to get better performance.
+
+
+How to use this feature
+---
+
+Swap device has priority and that decides the order of it to be used. To make
+use of automatically binding, there is no need to manipulate priority settings
+for swap devices. e.g. on a 2 node machine, assume

Re: Do we really need d_weak_revalidate???

2017-08-15 Thread NeilBrown
On Mon, Aug 14 2017, Jeff Layton wrote:

> On Mon, 2017-08-14 at 09:36 +1000, NeilBrown wrote:
>> On Fri, Aug 11 2017, Jeff Layton wrote:
>> 
>> > On Fri, 2017-08-11 at 05:55 +, Trond Myklebust wrote:
>> > > On Fri, 2017-08-11 at 14:31 +1000, NeilBrown wrote:
>> > > > Funny story.  4.5 years ago we discarded the FS_REVAL_DOT superblock
>> > > > flag and introduced the d_weak_revalidate dentry operation instead.
>> > > > We duly removed the flag from NFS superblocks and NFSv4 superblocks,
>> > > > and added the new dentry operation to NFS dentries  but not to
>> > > > NFSv4
>> > > > dentries.
>> > > > 
>> > > > And nobody noticed.
>> > > > 
>> > > > Until today.
>> > > > 
>> > > > A customer reports a situation where mount(,MS_REMOUNT,..) on an
>> > > > NFS
>> > > > filesystem hangs because the network has been deconfigured.  This
>> > > > makes
>> > > > perfect sense and I suggested a code change to fix the problem.
>> > > > However when a colleague was trying to reproduce the problem to
>> > > > validate
>> > > > the fix, he couldn't.  Then nor could I.
>> > > > 
>> > > > The problem is trivially reproducible with NFSv3, and not at all with
>> > > > NFSv4.  The reason is the missing d_weak_revalidate.
>> > > > 
>> > > > We could simply add d_weak_revalidate for NFSv4, but given that it
>> > > > has been missing for 4.5 years, and the only time anyone noticed was
>> > > > when the ommission resulted in a better user experience, I do wonder
>> > > > if
>> > > > we need to.  Can we just discard d_weak_revalidate?  What purpose
>> > > > does
>> > > > it serve?  I couldn't find one.
>> > > > 
>> > > > Thanks,
>> > > > NeilBrown
>> > > > 
>> > > > For reference, see
>> > > > Commit: ecf3d1f1aa74 ("vfs: kill FS_REVAL_DOT by adding a
>> > > > d_weak_revalidate dentry op")
>> > > > 
>> > > > 
>> > > > 
>> > > > To reproduce the problem at home, on a system that uses systemd:
>> > > > 1/ place (or find) a filesystem image in a file on an NFS filesystem.
>> > > > 2/ mount the nfs filesystem with "noac" - choose v3 or v4
>> > > > 3/ loop-mount the filesystem image read-only somewhere
>> > > > 4/ reboot
>> > > > 
>> > > > If you choose v4, the reboot will succeed, possibly after a 90second
>> > > > timeout.
>> > > > If you choose v3, the reboot will hang indefinitely in systemd-
>> > > > shutdown while
>> > > > remounting the nfs filesystem read-only.
>> > > > 
>> > > > If you don't use "noac" it can still hang, but only if something
>> > > > slows
>> > > > down the reboot enough that attributes have timed out by the time
>> > > > that
>> > > > systemd-shutdown runs.  This happens for our customer.
>> > > > 
>> > > > If the loop-mounted filesystem is not read-only, you get other
>> > > > problems.
>> > > > 
>> > > > We really want systemd to figure out that the loop-mount needs to be
>> > > > unmounted first.  I have ideas concerning that, but it is messy.  But
>> > > > that isn't the only bug here.
>> > > 
>> > > The main purpose of d_weak_revalidate() was to catch the issues that
>> > > arise when someone changes the contents of the current working
>> > > directory or its parent on the server. Since '.' and '..' are treated
>> > > specially in the lookup code, they would not be revalidated without
>> > > special treatment. That leads to issues when looking up files as
>> > > ./ or ../, since the client won't detect that its
>> > > dcache is stale until it tries to use the cached dentry+inode.
>> > > 
>> > > The one thing that has changed since its introduction is, I believe,
>> > > the ESTALE handling in the VFS layer. That might fix a lot of the
>> > > dcache lookup bugs that were previously handled by d_weak_revalidate().
>> > > I haven't done an audit to figure out if it actually can handle all of
>> > > them.
>> > > 
>> > 
>> > It may also be related to 8033426e6bdb2690d302872ac1e1fadaec1a5581:
>> > 
>> > vfs: allow umount to handle mountpoints without revalidating them
>> 
>> You say in the comment for that commit:
>> 
>>  but there
>> are cases where we do want to revalidate the root of the fs.
>> 
>> Do you happen to remember what those cases are?
>> 
>
> Not exactly, but I _think_ I might have been assuming that we needed to
> ensure that the inode attrs on the root were up to date after the
> pathwalk.
>
> I think that was probably wrong. d_revalidate is really intended to
> ensure that the dentry in question still points to the same inode. In
> the case of the root of the mount though, we don't really care about the
> dentry on the server at all. We're attaching the root of the mount to an
> inode and don't care of the dentry name changes. If we do need to ensure
> the inode attrs are updated, we'll just revalidate them at that point.
>
>> > 
>> > Possibly the fact that we no longer try to revalidate during unmount
>> > means that this is no longer necessary?
>> > 
>> > The original patch that added d_weak_revalidate had a reproducer in the
>> > patch description. Have you verified 

Re: [PATCH v2] zsmalloc: zs_page_migrate: schedule free_work if zspage is ZS_EMPTY

2017-08-15 Thread Hui Zhu
Hi Minchan,

2017-08-16 10:13 GMT+08:00 Minchan Kim :
> Hi Hui,
>
> On Mon, Aug 14, 2017 at 05:56:30PM +0800, Hui Zhu wrote:
>> After commit e2846124f9a2 ("zsmalloc: zs_page_migrate: skip unnecessary
>
> This patch is not merged yet so the hash is invalid.
> That means we may fold this patch to [1] in current mmotm.
>
> [1] 
> zsmalloc-zs_page_migrate-skip-unnecessary-loops-but-not-return-ebusy-if-zspage-is-not-inuse-fix.patch
>
>> loops but not return -EBUSY if zspage is not inuse") zs_page_migrate
>> can handle the ZS_EMPTY zspage.
>>
>> But I got some false in zs_page_isolate:
>>   if (get_zspage_inuse(zspage) == 0) {
>>   spin_unlock(&class->lock);
>>   return false;
>>   }
>
> I also realized we should make zs_page_isolate succeed on empty zspage
> because we allow the empty zspage migration from now on.
> Could you send a patch for that as well?

OK.  I will make a patch for that later.

Thanks,
Hui

>
>> The page of this zspage was migrated in before.
>>
>> The reason is commit e2846124f9a2 ("zsmalloc: zs_page_migrate: skip
>> unnecessary loops but not return -EBUSY if zspage is not inuse") just
>> handle the "page" but not "newpage" then it keep the "newpage" with
>> a empty zspage inside system.
>> Root cause is zs_page_isolate remove it from ZS_EMPTY list but not
>> call zs_page_putback "schedule_work(&pool->free_work);".  Because
>> zs_page_migrate done the job without "schedule_work(&pool->free_work);"
>>
>> Make this patch let zs_page_migrate wake up free_work if need.
>>
>> Fixes: e2846124f9a2 ("zsmalloc: zs_page_migrate: skip unnecessary loops but 
>> not return -EBUSY if zspage is not inuse")
>> Signed-off-by: Hui Zhu 
>> ---
>>  mm/zsmalloc.c | 13 +++--
>>  1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
>> index 62457eb..c6cc77c 100644
>> --- a/mm/zsmalloc.c
>> +++ b/mm/zsmalloc.c
>> @@ -2035,8 +2035,17 @@ int zs_page_migrate(struct address_space *mapping, 
>> struct page *newpage,
>>* Page migration is done so let's putback isolated zspage to
>>* the list if @page is final isolated subpage in the zspage.
>>*/
>> - if (!is_zspage_isolated(zspage))
>> - putback_zspage(class, zspage);
>> + if (!is_zspage_isolated(zspage)) {
>> + /*
>> +  * Page will be freed in following part. But newpage and
>> +  * zspage will stay in system if zspage is in ZS_EMPTY
>> +  * list.  So call free_work to free it.
>> +  * The page and class is locked, we cannot free zspage
>> +  * immediately so let's defer.
>> +  */
>
> How about this?
>
> /*
>  * Since we allow empty zspage migration, putback of zspage
>  * should free empty zspage. Otherwise, it could make a leak
>  * until upcoming free_work is done, which isn't guaranteed.
>  */
>> + if (putback_zspage(class, zspage) == ZS_EMPTY)
>> + schedule_work(&pool->free_work);
>> + }
>>
>>   reset_page(page);
>>   put_page(page);
>> --
>> 1.9.1
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majord...@kvack.org.  For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: mailto:"d...@kvack.org";> em...@kvack.org 


[PATCH] arm64: dts: rk3399: init vop clock rates

2017-08-15 Thread Kever Yang
We need to init vop aclk and hclk incase the U-Boot does not do
the initialize.

Signed-off-by: Kever Yang 
---

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 0b3acc9..a592c24 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1480,6 +1480,8 @@
interrupts = ;
clocks = <&cru ACLK_VOP1>, <&cru DCLK_VOP1>, <&cru HCLK_VOP1>;
clock-names = "aclk_vop", "dclk_vop", "hclk_vop";
+   assigned-clocks = <&cru ACLK_VOP1>, <&cru HCLK_VOP1>;
+   assigned-clock-rates = <4>, <1>;
iommus = <&vopl_mmu>;
power-domains = <&power RK3399_PD_VOPL>;
resets = <&cru SRST_A_VOP1>, <&cru SRST_H_VOP1>, <&cru 
SRST_D_VOP1>;
@@ -1525,6 +1527,8 @@
interrupts = ;
clocks = <&cru ACLK_VOP0>, <&cru DCLK_VOP0>, <&cru HCLK_VOP0>;
clock-names = "aclk_vop", "dclk_vop", "hclk_vop";
+   assigned-clocks = <&cru ACLK_VOP0>, <&cru HCLK_VOP0>;
+   assigned-clock-rates = <4>, <1>;
iommus = <&vopb_mmu>;
power-domains = <&power RK3399_PD_VOPB>;
resets = <&cru SRST_A_VOP0>, <&cru SRST_H_VOP0>, <&cru 
SRST_D_VOP0>;
-- 
1.9.1



Re: [PATCH 5/6] ARM: dts: uniphier: add Denali NAND controller node

2017-08-15 Thread Masahiro Yamada
2017-08-10 1:43 GMT+09:00 Masahiro Yamada :
> Add NAND controller node to LD4, Pro4, sLD8, Pro5, and PXs2.
> Set up pinctrl to enable 2 chip select lines except Pro4.  The CS1
> for Pro4 is multiplexed with other peripherals such as UART2, so
> I did not enable it.
>
> Signed-off-by: Masahiro Yamada 
> ---

With some compatibles fixed, applied to linux-uniphier.

-- 
Best Regards
Masahiro Yamada


Re: [PATCH 6/6] arm64: dts: uniphier: add Denali NAND controller nodes

2017-08-15 Thread Masahiro Yamada
2017-08-10 1:43 GMT+09:00 Masahiro Yamada :
> Add NAND controller node to LD11 and LD20.  Neither of them supports
> the CS1 line, so pinctrl is set up for a single CS line.
>
> Signed-off-by: Masahiro Yamada 
> ---

Applied to linux-uniphier.

-- 
Best Regards
Masahiro Yamada


[PATCH] usb: quirks: add delay init quirk for Corsair Strafe RGB keyboard

2017-08-15 Thread Kai-Heng Feng
Corsair Strafe RGB keyboard has trouble to initialize:

[ 1.679455] usb 3-6: new full-speed USB device number 4 using xhci_hcd
[ 6.871136] usb 3-6: unable to read config index 0 descriptor/all
[ 6.871138] usb 3-6: can't read configurations, error -110
[ 6.991019] usb 3-6: new full-speed USB device number 5 using xhci_hcd
[ 12.246642] usb 3-6: unable to read config index 0 descriptor/all
[ 12.246644] usb 3-6: can't read configurations, error -110
[ 12.366555] usb 3-6: new full-speed USB device number 6 using xhci_hcd
[ 17.622145] usb 3-6: unable to read config index 0 descriptor/all
[ 17.622147] usb 3-6: can't read configurations, error -110
[ 17.742093] usb 3-6: new full-speed USB device number 7 using xhci_hcd
[ 22.997715] usb 3-6: unable to read config index 0 descriptor/all
[ 22.997716] usb 3-6: can't read configurations, error -110

Although it may work after several times unpluging/pluging:

[ 68.195240] usb 3-6: new full-speed USB device number 11 using xhci_hcd
[ 68.337459] usb 3-6: New USB device found, idVendor=1b1c, idProduct=1b20
[ 68.337463] usb 3-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 68.337466] usb 3-6: Product: Corsair STRAFE RGB Gaming Keyboard
[ 68.337468] usb 3-6: Manufacturer: Corsair
[ 68.337470] usb 3-6: SerialNumber: 0F013021AEB8046755A93ED3F5001941

Tried three quirks: USB_QUIRK_DELAY_INIT, USB_QUIRK_NO_LPM and
USB_QUIRK_DEVICE_QUALIFIER, user confirmed that USB_QUIRK_DELAY_INIT alone
can workaround this issue. Hence add the quirk for Corsair Strafe RGB.

BugLink: https://bugs.launchpad.net/bugs/1678477
Signed-off-by: Kai-Heng Feng 
---
 drivers/usb/core/quirks.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 574da2b4529c..1ea5060dae69 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -217,6 +217,9 @@ static const struct usb_device_id usb_quirk_list[] = {
{ USB_DEVICE(0x1a0a, 0x0200), .driver_info =
USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
 
+   /* Corsair Strafe RGB */
+   { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT },
+
/* Acer C120 LED Projector */
{ USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
 
-- 
2.14.1



[GIT PULL] ARM: dts: uniphier: UniPhier DT updates for v4.14

2017-08-15 Thread Masahiro Yamada
Hi Arnd, Olof,

Here are UniPhier DT (32bit) updates for the v4.14 merge window.
Please pull!


The following changes since commit 5771a8c08880cdca3bfb4a3fc6d309d6bba20877:

  Linux v4.13-rc1 (2017-07-15 15:22:10 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-uniphier.git
tags/uniphier-dt-v4.14

for you to fetch changes up to 69f9cdc63319e5ccc210b30d1cec1dfda7096b04:

  ARM: dts: uniphier: add Denali NAND controller node (2017-08-16
01:47:01 +0900)


UniPhier ARM SoC DT updates for v4.14

- complete migrating to SPDX License Identifier
- remove support for old SoC
- add nodes for NAND, Audio pinctrl
- replace /include/ with #include


Katsuhiro Suzuki (1):
  ARM: dts: uniphier: add audio out pin-mux node

Masahiro Yamada (4):
  ARM: dts: uniphier: use SPDX-License-Identifier (2nd)
  ARM: dts: uniphier: remove sLD3 SoC support
  ARM: dts: uniphier use #include instead of /include/
  ARM: dts: uniphier: add Denali NAND controller node

 arch/arm/boot/dts/Makefile |   1 -
 arch/arm/boot/dts/uniphier-ld4-ref.dts |  10 +-
 arch/arm/boot/dts/uniphier-ld4.dtsi|  13 +-
 arch/arm/boot/dts/uniphier-ld6b-ref.dts|  10 +-
 arch/arm/boot/dts/uniphier-ld6b.dtsi   |   2 +-
 arch/arm/boot/dts/uniphier-pinctrl.dtsi|  43 +---
 arch/arm/boot/dts/uniphier-pro4-ace.dts|   2 +-
 arch/arm/boot/dts/uniphier-pro4-ref.dts|  10 +-
 arch/arm/boot/dts/uniphier-pro4-sanji.dts  |   2 +-
 arch/arm/boot/dts/uniphier-pro4.dtsi   |  13 +-
 arch/arm/boot/dts/uniphier-pro5.dtsi   |  51 ++---
 arch/arm/boot/dts/uniphier-pxs2-gentil.dts |   2 +-
 arch/arm/boot/dts/uniphier-pxs2-vodka.dts  |   2 +-
 arch/arm/boot/dts/uniphier-pxs2.dtsi   |  13 +-
 arch/arm/boot/dts/uniphier-sld3-ref.dts|  75 ---
 arch/arm/boot/dts/uniphier-sld3.dtsi   | 260 --
 arch/arm/boot/dts/uniphier-sld8-ref.dts|  10 +-
 arch/arm/boot/dts/uniphier-sld8.dtsi   |  13 +-
 18 files changed, 100 insertions(+), 432 deletions(-)
 delete mode 100644 arch/arm/boot/dts/uniphier-sld3-ref.dts
 delete mode 100644 arch/arm/boot/dts/uniphier-sld3.dtsi






-- 
Best Regards
Masahiro Yamada


[GIT PULL] arm64: dts: uniphier: UniPhier DT updates (64bit) for v4.14

2017-08-15 Thread Masahiro Yamada
Hi Arnd, Olof,

Here are UniPhier DT (64bit) updates for the v4.14 merge window.
Please pull!


The following changes since commit 5771a8c08880cdca3bfb4a3fc6d309d6bba20877:

  Linux v4.13-rc1 (2017-07-15 15:22:10 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-uniphier.git
tags/uniphier-dt64-v4.14

for you to fetch changes up to e5aefb380eafe176de066ddde1d354a167a9d474:

  arm64: dts: uniphier: add Denali NAND controller nodes (2017-08-13
08:43:27 +0900)


UniPhier ARM64 SoC DT updates for v4.14

- add nodes for NAND, Watchdog
- replace /include/ with #include
- use #include  instead of symlinks


Keiji Hayashibara (1):
  arm64: dts: uniphier: add watchdog node for LD11 and LD20

Masahiro Yamada (3):
  arm64: dts: uniphier: use #include instead of /include/
  arm64: dts: uniphier: use cross-arch include instead of symlinks
  arm64: dts: uniphier: add Denali NAND controller nodes

 .../boot/dts/socionext/uniphier-ld11-global.dts  |  6 +-
 .../boot/dts/socionext/uniphier-ld11-ref.dts |  6 +++---
 arch/arm64/boot/dts/socionext/uniphier-ld11.dtsi | 17 -
 .../boot/dts/socionext/uniphier-ld20-global.dts  |  6 +-
 .../boot/dts/socionext/uniphier-ld20-ref.dts |  6 +++---
 arch/arm64/boot/dts/socionext/uniphier-ld20.dtsi | 17 -
 .../boot/dts/socionext/uniphier-pinctrl.dtsi |  2 +-
 .../dts/socionext/uniphier-ref-daughter.dtsi |  2 +-
 .../dts/socionext/uniphier-support-card.dtsi |  2 +-
 9 files changed, 51 insertions(+), 13 deletions(-)
 mode change 12 => 100644
arch/arm64/boot/dts/socionext/uniphier-pinctrl.dtsi
 mode change 12 => 100644
arch/arm64/boot/dts/socionext/uniphier-ref-daughter.dtsi
 mode change 12 => 100644
arch/arm64/boot/dts/socionext/uniphier-support-card.dtsi


-- 
Best Regards
Masahiro Yamada


Re: [GIT] Networking

2017-08-15 Thread David Miller
From: Linus Torvalds 
Date: Tue, 15 Aug 2017 19:21:16 -0700

> On Tue, Aug 15, 2017 at 5:52 PM, David Miller  wrote:
>>
>> dingtianhong (4):
>>   PCI: Disable PCIe Relaxed Ordering if unsupported
>>   PCI: Disable Relaxed Ordering for some Intel processors
>>   PCI: Disable Relaxed Ordering Attributes for AMD A1100
>>   PCI: fix oops when try to find Root Port for a PCI device
> 
> I would *really* have liked to see an ack on these from Bjorn Helgaas.
> Was he even cc'd?
> 
> And while singling those commits out, I would also really have liked
> to see an actual name there.
> 
> The name exists in the sign-off chain:
> 
> Signed-off-by: Ding Tianhong 
> 
> but for some reason not in the actual commit author data, where it's
> just "dingtianhong".
> 
> Pulled, but slightly unhappy.

Bjorn did review these changes, and certainly shaped the final result,
but indeed I should have gotten an explicit ACK from him.

I'll make sure I do so next time.


Re: [PATCH 2/2] mm: Update NUMA counter threshold size

2017-08-15 Thread kemi


On 2017年08月16日 00:55, Tim Chen wrote:
> On 08/15/2017 02:58 AM, Mel Gorman wrote:
>> On Tue, Aug 15, 2017 at 04:45:36PM +0800, Kemi Wang wrote:

>> I'm fairly sure this pushes the size of that structure into the next
>> cache line which is not welcome.
 vm_numa_stat_diff is an always incrementing field. How much do you gain
>> if this becomes a u8 code and remove any code that deals with negative
>> values? That would double the threshold without consuming another cache line.
> 
> Doubling the threshold and counter size will help, but not as much
> as making them above u8 limit as seen in Kemi's data:
> 
>   125 537 358906028 <==> system by default (base)
>   256 468 412397590
>   32765   394(-26.6%) 488932078(+36.2%) <==> with this patchset
> 
> For small system making them u8 makes sense.  For larger ones the
> frequent local counter overflow into the global counter still
> causes a lot of cache bounce.  Kemi can perhaps collect some data
> to see what is the gain from making the counters u8. 
> 
Tim, thanks for your answer. That is what I want to clarify.

Also, pls notice that the negative threshold/2 is set to cpu local counter
(e.g. vm_numa_stat_diff[]) once per-zone counter is updated in current code
path. This weakens the benefit of changing s8 to u8 in this case. 
>>
>> Furthermore, the stats in question are only ever incremented by one.
>> That means that any calcluation related to overlap can be removed and
>> special cased that it'll never overlap by more than 1. That potentially
>> removes code that is required for other stats but not locality stats.
>> This may give enough savings to avoid moving to s16.
>>
>> Very broadly speaking, I like what you're doing but I would like to see
>> more work on reducing any unnecessary code in that path (such as dealing
>> with overlaps for single increments) and treat incrasing the cache footprint
>> only as a very last resort.
>>
Agree. I will think about it more. 

>>>  #endif
>>>  #ifdef CONFIG_SMP
>>> s8 stat_threshold;
>>> diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
>>> index 1e19379..d97cc34 100644
>>> --- a/include/linux/vmstat.h
>>> +++ b/include/linux/vmstat.h
>>> @@ -125,10 +125,14 @@ static inline unsigned long global_numa_state(enum 
>>> zone_numa_stat_item item)
>>> return x;
>>>  }
>>>  



RE: 答复: [iscsi] Deadlock occurred when network is in error

2017-08-15 Thread Tangchen (UVP)
> On Tue, 2017-08-15 at 02:16 +, Tangchen (UVP) wrote:
> > But I'm not using mq, and I run into these two problems in a non-mq system.
> > The patch you pointed out is fix for mq, so I don't think it can resolve 
> > this
> problem.
> >
> > IIUC, mq is for SSD ?  I'm not using ssd, so mq is disabled.
> 
> Hello Tangchen,
> 
> Please post replies below the original e-mail instead of above - that is the 
> reply
> style used on all Linux-related mailing lists I know of. From
> https://en.wikipedia.org/wiki/Posting_style:
> 
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing in e-mail?

Hi Bart,

Thanks for the reply. Will post the reply in e-mail. :)

> 
> Regarding your question: sorry but I quoted the wrong commit in my previous
> e-mail. The commit I should have referred to is 255ee9320e5d ("scsi: Make
> __scsi_remove_device go straight from BLOCKED to DEL"). That patch not only
> affects scsi-mq but also the single-queue code in the SCSI core.

OK, I'll try this one. Thx.

> 
> blk-mq/scsi-mq was introduced for SSDs but is not only intended for SSDs.
> The plan is to remove the blk-sq/scsi-sq code once the blk-mq/scsi-mq code
> works at least as fast as the single queue code for all supported devices.
> That includes hard disks.

OK, thanks for tell me this.

> 
> Bart.


Re: [PATCH v3 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622

2017-08-15 Thread Sean Wang
On Tue, 2017-08-15 at 21:08 +0800, Jun Gao wrote:
> From: Jun Gao 
> 
> Add i2c compatible for MT7622. Compare to MT8173 i2c controller,
> MT7622 limits message numbers to 255, and does not support 4GB
> DMA mode.
> 
> Signed-off-by: Jun Gao 

you seemed missing a Reviewed-by tag from Joe.C

http://lists.infradead.org/pipermail/linux-mediatek/2017-August/009975.html


> ---
>  drivers/i2c/busses/i2c-mt65xx.c | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index 9bedf0b..09d288c 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -172,6 +172,10 @@ struct mtk_i2c {
>   .max_comb_2nd_msg_len = 31,
>  };
>  
> +static const struct i2c_adapter_quirks mt7622_i2c_quirks = {
> + .max_num_msgs = 255,
> +};
> +
>  static const struct mtk_i2c_compatible mt6577_compat = {
>   .quirks = &mt6577_i2c_quirks,
>   .pmic_i2c = 0,
> @@ -190,6 +194,15 @@ struct mtk_i2c {
>   .support_33bits = 0,
>  };
>  
> +static const struct mtk_i2c_compatible mt7622_compat = {
> + .quirks = &mt7622_i2c_quirks,
> + .pmic_i2c = 0,
> + .dcm = 1,
> + .auto_restart = 1,
> + .aux_len_reg = 1,
> + .support_33bits = 0,
> +};
> +
>  static const struct mtk_i2c_compatible mt8173_compat = {
>   .pmic_i2c = 0,
>   .dcm = 1,
> @@ -201,6 +214,7 @@ struct mtk_i2c {
>  static const struct of_device_id mtk_i2c_of_match[] = {
>   { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat },
>   { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat },
> + { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat },
>   { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat },
>   {}
>  };




Re: [PATCH] KVM/x86: Increase max vcpu number to 352

2017-08-15 Thread Lan Tianyu
On 2017年08月15日 22:10, Konrad Rzeszutek Wilk wrote:
> On Tue, Aug 15, 2017 at 11:00:04AM +0800, Lan Tianyu wrote:
>> On 2017年08月12日 03:35, Konrad Rzeszutek Wilk wrote:
>>> On Fri, Aug 11, 2017 at 03:00:20PM +0200, Radim Krčmář wrote:
 2017-08-11 10:11+0200, David Hildenbrand:
> On 11.08.2017 09:49, Lan Tianyu wrote:
>> Hi Konrad:
>>  Thanks for your review.
>>
>> On 2017年08月11日 01:50, Konrad Rzeszutek Wilk wrote:
>>> On Thu, Aug 10, 2017 at 06:00:59PM +0800, Lan Tianyu wrote:
 Intel Xeon phi chip will support 352 logical threads. For HPC usage
 case, it will create a huge VM with vcpu number as same as host cpus. 
 This
 patch is to increase max vcpu number to 352.
>>>
>>> Why not 1024 or 4096?
>>
>> This is on demand. We can set a higher number since KVM already has
>> x2apic and vIOMMU interrupt remapping support.
>>
>>>
>>> Are there any issues with increasing the value from 288 to 352 right 
>>> now?
>>
>> No found.

 Yeah, the only issue until around 2^20 (when we reach the maximum of
 logical x2APIC addressing) should be the size of per-VM arrays when only
 few VCPUs are going to be used.
>>>
>>> Migration with 352 CPUs all being busy dirtying memory and also poking
>>> at various I/O ports (say all of them dirtying the VGA) is no problem?
>>
>> This depends on what kind of workload is running during migration. I
>> think this may affect service down time since there maybe a lot of dirty
>> memory data to transfer after stopping vcpus. This also depends on how
>> user sets "migrate_set_downtime" for qemu. But I think increasing vcpus
>> will break migration function.
> 
> OK, so let me take a step back.
> 
> I see this nice 'supported' CPU count that is exposed in kvm module.
> 
> Then there is QEMU throwing out a warning if you crank up the CPU count
> above that number.
> 
> Red Hat's web-pages talk about CPU count as well.
> 
> And I am assuming all of those are around what has been tested and
> what has shown to work. And one of those test-cases surely must
> be migration.
> 

Sorry. This is a typo. I originally meant increasing vcpu shouldn't
break migration function and just affect service downtime. If there was
such issue, we should fix it.


> Ergo, if the vCPU count increase will break migration, then it is
> a regression.
> 
> Or a fix/work needs to be done to support a higher CPU count for
> migrating?
> 
> 
> Is my understanding incorrect?

You are right.

> 
>>
>>>
>>>

>>> Also perhaps this should be made in an Kconfig entry?
>>
>> That will be anther option but I find different platforms will define
>> different MAX_VCPU. If we introduce a generic Kconfig entry, different
>> platforms should have different range.
>>>
>>>
>>> By different platforms you mean q35 vs the older one, and such?
>>
>> I meant x86, arm, sparc and other vendors' code define different max
>> vcpu number.
> 
> Right, and?

If we introduce a general kconfig of max vcpus for all vendors, it
should have different max vcpu range for different vendor.




-- 
Best regards
Tianyu Lan


Re: [PATCH] arm64: dts: rk3399: init vop clock rates

2017-08-15 Thread Mark yao

On 2017年08月16日 10:51, Kever Yang wrote:

We need to init vop aclk and hclk incase the U-Boot does not do
the initialize.

Signed-off-by: Kever Yang 
---


Looks good for me:
Reviewed-by: Mark Yao 


  arch/arm64/boot/dts/rockchip/rk3399.dtsi | 4 
  1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 0b3acc9..a592c24 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1480,6 +1480,8 @@
interrupts = ;
clocks = <&cru ACLK_VOP1>, <&cru DCLK_VOP1>, <&cru HCLK_VOP1>;
clock-names = "aclk_vop", "dclk_vop", "hclk_vop";
+   assigned-clocks = <&cru ACLK_VOP1>, <&cru HCLK_VOP1>;
+   assigned-clock-rates = <4>, <1>;
iommus = <&vopl_mmu>;
power-domains = <&power RK3399_PD_VOPL>;
resets = <&cru SRST_A_VOP1>, <&cru SRST_H_VOP1>, <&cru 
SRST_D_VOP1>;
@@ -1525,6 +1527,8 @@
interrupts = ;
clocks = <&cru ACLK_VOP0>, <&cru DCLK_VOP0>, <&cru HCLK_VOP0>;
clock-names = "aclk_vop", "dclk_vop", "hclk_vop";
+   assigned-clocks = <&cru ACLK_VOP0>, <&cru HCLK_VOP0>;
+   assigned-clock-rates = <4>, <1>;
iommus = <&vopb_mmu>;
power-domains = <&power RK3399_PD_VOPB>;
resets = <&cru SRST_A_VOP0>, <&cru SRST_H_VOP0>, <&cru 
SRST_D_VOP0>;



--
Mark Yao




[PATCH v3] zsmalloc: zs_page_migrate: schedule free_work if zspage is ZS_EMPTY

2017-08-15 Thread Hui Zhu
After commit [1] zs_page_migrate can handle the ZS_EMPTY zspage.

But I got some false in zs_page_isolate:
if (get_zspage_inuse(zspage) == 0) {
spin_unlock(&class->lock);
return false;
}
The page of this zspage was migrated in before.

The reason is commit [1] just handle the "page" but not "newpage"
then it keep the "newpage" with a empty zspage inside system.
Root cause is zs_page_isolate remove it from ZS_EMPTY list but not
call zs_page_putback "schedule_work(&pool->free_work);".  Because
zs_page_migrate done the job without "schedule_work(&pool->free_work);"

Make this patch let zs_page_migrate wake up free_work if need.

[1] 
zsmalloc-zs_page_migrate-skip-unnecessary-loops-but-not-return-ebusy-if-zspage-is-not-inuse-fix.patch

Signed-off-by: Hui Zhu 
---
 mm/zsmalloc.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 62457eb..fb99953 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2035,8 +2035,15 @@ int zs_page_migrate(struct address_space *mapping, 
struct page *newpage,
 * Page migration is done so let's putback isolated zspage to
 * the list if @page is final isolated subpage in the zspage.
 */
-   if (!is_zspage_isolated(zspage))
-   putback_zspage(class, zspage);
+   if (!is_zspage_isolated(zspage)) {
+   /*
+* Since we allow empty zspage migration, putback of zspage
+* should free empty zspage. Otherwise, it could make a leak
+* until upcoming free_work is done, which isn't guaranteed.
+*/
+   if (putback_zspage(class, zspage) == ZS_EMPTY)
+   schedule_work(&pool->free_work);
+   }
 
reset_page(page);
put_page(page);
-- 
1.9.1



[GIT PULL] (xen) stable/for-jens-4.13 for rc5

2017-08-15 Thread Konrad Rzeszutek Wilk
Hey Jens,

Please git pull the following branch:

 git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git 
stable/for-jens-4.13

which has two fixes, both of them spotted by Amazon.

 1) Fix in Xen-blkfront caused by the re-write in 4.8 time-frame.
 2) Fix in the xen_biovec_phys_mergeable which allowed guest
requests when using NVMe - to slurp up more data than allowed
leading to an XSA (which has been made public today).

Thanks!

 drivers/block/xen-blkfront.c | 6 +++---
 drivers/xen/biomerge.c   | 3 +--
 2 files changed, 4 insertions(+), 5 deletions(-)

Munehisa Kamata (1):
  xen-blkfront: use a right index when checking requests

Roger Pau Monne (1):
  xen: fix bio vec merging



Re: early x86 unseeded randomness

2017-08-15 Thread Theodore Ts'o
On Tue, Aug 15, 2017 at 04:42:47PM +0200, Thomas Gleixner wrote:
> Care to read the paper?
> 
> We tried that 6 years ago on a wide range of machines from server to stupid
> first generation in order ATOM chips. All of them exposed more or less the
> same behaviour and passed RND validation tests.

Yeah, I read the paper, It points out that in a tight loop, they *did*
see real patterns in the TSC values that they read out.  But then they
did better by adding usleep(delay).  This is critical because this was
being done in userspace, when presumably there were other processes
running (kernel threads, if nothing else).

Whether this would still realistic in early boot, when interrupts may
not have been fully enabled, and many devices not even probed yet, and
when there are no other userspace processes to schedule against ---
and where you can't use usleep because the scheduler may not have been
initialized yet --- and where udelay is *way* more boring that usleep
--- I think is something where you can't rely on that paper.

So I think a lot of care is required here.

 - Ted


Re: [PATCH] devicetree: Enable generation of __symbols__ in all dtb files

2017-08-15 Thread Frank Rowand
On 08/15/17 17:42, Tom Rini wrote:
> On Tue, Aug 15, 2017 at 04:50:40PM -0700, Frank Rowand wrote:
>> On 08/15/17 14:15, Tom Rini wrote:
>>> With support for stacked overlays being part of libfdt it is now
>>> possible and likely that overlays which require __symbols__ will be
>>> applied to the dtb files generated by the kernel.  This is done by
>>> passing -@ to dtc.  This does increase the filesize (and resident memory
>>> usage) based on the number of __symbol__ entries added to match the
>>> contents of the dts.
>>>
>>> Cc: Rob Herring 
>>> Cc: Frank Rowand 
>>> Cc: Masahiro Yamada 
>>> Cc: Michal Marek 
>>> Cc: Pantelis Antoniou 
>>> Cc: devicet...@vger.kernel.org
>>> Cc: linux-kernel@vger.kernel.org
>>> CC: linux-kbu...@vger.kernel.org
>>> Signed-off-by: Tom Rini 
>>> ---
>>> In order for a dtb file to be useful with all types of overlays, it
>>> needs to be generated with the -@ flag passed to dtc so that __symbols__
>>> are generated.  This however is not free, and increases the resulting
>>> dtb file by up to approximately 50% today.  In the current worst case
>>> this is moving from 88KiB to 133KiB.  In talking with Frank about this,
>>> he outlined 3 possible ways (with the 4th option of something else
>>> entirely).
>>>
>>> 1. Make passing -@ to dtc be dependent upon some CONFIG symbol.
>>> 2. In the kernel, if the kernel does not have overlay support, discard
>>> the __symbols__ information that we've been passed.
>>> 3. Have the bootloader pass in, or not, __symbols__ information.
>>
>> I also was hoping that other people might have ideas for additional
>> approaches.
> 
> Yes, please.
> 
>>> This patch is an attempt to implement something between the 3rd option
>>> and a different, 4th option.  Frank was thinking that we might introduce
>>> a new symbol to control generation of __symbol__ information for option
>>> 1.  I think this gets the usage backwards and will lead to confusion
>>> among users and developers.
>>>
>>> My proposal is that we do not want __symbols__ existence to be dependent
>>> on some part of the kernel configuration for a number of reasons.
>>> First, this is out of step with the rest of how dtbs are created today
>>> and more importantly, thought about.  Today, all dtb content is
>>> independent of CONFIG options.  If you build a dtb from a given kernel
>>> tree, everyone will agree on the result.  This is part of the "contract"
>>> on passing old kernels and new dtb files even.
>>
>> I hope that dtb contents are independent of CONFIG options, but I don't
>> feel confident is stating that there is not such dependency.  (Of course,
>> whether to build a dtb can be dependent on a CONFIG option in the Makefile,
>> but that is not the same concept.)
>>
>> The only existing rule that I am aware of that helps avoid a dts dependency
>> on kernel CONFIG options is that included files can not be from general 
>> kernel
>> header files; they must be in include/dt-bindings/.
> 
> I'm fairly certain for in-kernel stuff at least, the assumption is
> correct.
> 
>> Should we add text to 
>> Documentation/devicetree/bindings/submitting-patches.txt
>> that explicitly states that dts files are not allowed to contain any
>> dependency on kernel CONFIG options?
> 
> Certainly can't hurt.
> 
>>> Second, I think this is out of step with how a lot of overlay usage will
>>> occur.  My thinking is that with maximally useful overlays being
>>> available in mainline, lots of use-cases that we have today that result
>>> in a number of DTS files being included can become just overlays.  This
>>
>> I disagree with this.  My _opinion_ is that overlays should be the exception,
>> not the common case.  Overlays require extra complexity in the various
>> subsystems that interact with device trees.  For an overlay to work, these
>> subsystems must be able to react to changes made to the device tree by
>> an overlay.  The current mechanism is via notifiers, which only exist
>> for a few subsystems.
> 
> Ah.  Now, I can't blame you for thinking with your kernel hat on, but,
> you're thinking with your kernel hat on :)  (And taking mine off for a
> minute is why I changed my mind between when we talked on IRC, and what
> I posted).  Kernel run-time apply an overlay has various use cases that
> I don't want to discount, but don't want to try and go in detail on
> either.
> 
> At heart, one of the issues here is that the Linux kernel is the
> authoritative source of dts and dtb files.  Assembling a dtb and N
> overlays at some point prior to booting Linux, in order to give it a
> complete and valid system is going to be a common case.  Even setting

Yes.  When discussing overlay issues and technologies we should be very
clear about whether the context is post-boot run time loading of an
overlay or using overlays applied on top of a base dtb to create a
dtb to be fed to the kernel for booting.  These are very different
domains.

For the case of constructing a boot time dtb from a base dtb and one
or more ov

Re: [PATCH 0/2] Separate NUMA statistics from zone statistics

2017-08-15 Thread kemi


On 2017年08月15日 18:36, Jesper Dangaard Brouer wrote:
> On Tue, 15 Aug 2017 16:45:34 +0800
> Kemi Wang  wrote:
> 
>> Each page allocation updates a set of per-zone statistics with a call to
>> zone_statistics(). As discussed in 2017 MM submit, these are a substantial
>  ^^ should be "summit"

Hi, Jesper
   Thanks for reporting this issue and providing the benchmark to test raw
performance of page allocation. It is really quite helpful to figure out the
root cause.
>> source of overhead in the page allocator and are very rarely consumed. This
>> significant overhead in cache bouncing caused by zone counters (NUMA
>> associated counters) update in parallel in multi-threaded page allocation
>> (pointed out by Dave Hansen).
> 
> Hi Kemi
> 
> Thanks a lot for following up on this work. A link to the MM summit slides:
>  
> http://people.netfilter.org/hawk/presentations/MM-summit2017/MM-summit2017-JesperBrouer.pdf
> 
Thanks for adding the link here. I should have done that in this cover letter.

>> To mitigate this overhead, this patchset separates NUMA statistics from
>> zone statistics framework, and update NUMA counter threshold to a fixed
>> size of 32765, as a small threshold greatly increases the update frequency
>> of the global counter from local per cpu counter (suggested by Ying Huang).
>> The rationality is that these statistics counters don't need to be read
>> often, unlike other VM counters, so it's not a problem to use a large
>> threshold and make readers more expensive.
>>
>> With this patchset, we see 26.6% drop of CPU cycles(537-->394, see below)
>> for per single page allocation and reclaim on Jesper's page_bench03
>> benchmark. Meanwhile, this patchset keeps the same style of virtual memory
>> statistics with little end-user-visible effects (see the first patch for
>> details), except that the number of NUMA items in each cpu
>> (vm_numa_stat_diff[]) is added to zone->vm_numa_stat[] when a user *reads*
>> the value of NUMA counter to eliminate deviation.
> 
> I'm very happy to see that you found my kernel module for benchmarking useful 
> :-)
> 
>> I did an experiment of single page allocation and reclaim concurrently
>> using Jesper's page_bench03 benchmark on a 2-Socket Broadwell-based server
>> (88 processors with 126G memory) with different size of threshold of pcp
>> counter.
>>
>> Benchmark provided by Jesper D Broucer(increase loop times to 1000):
>  ^^^
> You mis-spelled my last name, it is "Brouer".
> 
Dear Jesper, I am so sorry about it, please forgive me :)

>> https://github.com/netoptimizer/prototype-kernel/tree/master/kernel/mm/bench
>>
>>Threshold   CPU cyclesThroughput(88 threads)
>>   32799 241760478
>>   64640 301628829
>>   125   537 358906028 <==> system by default
>>   256   468 412397590
>>   512   428 450550704
>>   4096  399 482520943
>>   2 394 489009617
>>   3 395 488017817
>>   32765 394(-26.6%) 488932078(+36.2%) <==> with this patchset
>>   N/A   342(-36.3%) 562900157(+56.8%) <==> disable zone_statistics
>>
>> Kemi Wang (2):
>>   mm: Change the call sites of numa statistics items
>>   mm: Update NUMA counter threshold size
>>
>>  drivers/base/node.c|  22 ---
>>  include/linux/mmzone.h |  25 +---
>>  include/linux/vmstat.h |  33 ++
>>  mm/page_alloc.c|  10 +--
>>  mm/vmstat.c| 162 
>> +++--
>>  5 files changed, 227 insertions(+), 25 deletions(-)
>>
> 
> 
> 


Re: [PATCH] CPUFREQ: Loongson2: constify platform_device_id

2017-08-15 Thread Viresh Kumar
On 13-08-17, 15:10, Arvind Yadav wrote:
> platform_device_id are not supposed to change at runtime. All functions
> working with platform_device_id provided by 
> work with const platform_device_id. So mark the non-const structs as
> const.
> 
> Signed-off-by: Arvind Yadav 
> ---
>  drivers/cpufreq/loongson2_cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/loongson2_cpufreq.c 
> b/drivers/cpufreq/loongson2_cpufreq.c
> index 9ac27b2..da34469 100644
> --- a/drivers/cpufreq/loongson2_cpufreq.c
> +++ b/drivers/cpufreq/loongson2_cpufreq.c
> @@ -114,7 +114,7 @@ static struct cpufreq_driver loongson2_cpufreq_driver = {
>   .attr = cpufreq_generic_attr,
>  };
>  
> -static struct platform_device_id platform_device_ids[] = {
> +static const struct platform_device_id platform_device_ids[] = {
>   {
>   .name = "loongson2_cpufreq",
>   },

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH 1/2] staging: typec: tcpm: Report right typec_pwr_opmode

2017-08-15 Thread Guenter Roeck

On 08/15/2017 04:22 PM, Badhri Jagan Sridharan wrote:

At present, TCPM does not take into account the actual resistor
value presented in the CC line and therefore reports TYPEC_PWR_MODE_USB
irrespective of the power_op_mode it is in.
This patch makes TCPM consider the actual value of Rp.

Signed-off-by: Badhri Jagan Sridharan 


Reviewed-by: Guenter Roeck 


---
  drivers/staging/typec/tcpm.c | 21 +++--
  1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 20eb4ebcf8c3..a24e6bbb909c 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -2123,9 +2123,23 @@ static void tcpm_swap_complete(struct tcpm_port *port, 
int result)
}
  }
  
+enum typec_pwr_opmode tcpm_get_pwr_opmode(enum typec_cc_status cc)

+{
+   switch (cc) {
+   case TYPEC_CC_RP_1_5:
+   return TYPEC_PWR_MODE_1_5A;
+   case TYPEC_CC_RP_3_0:
+   return TYPEC_PWR_MODE_3_0A;
+   case TYPEC_CC_RP_DEF:
+   default:
+   return TYPEC_PWR_MODE_USB;
+   }
+}
+
  static void run_state_machine(struct tcpm_port *port)
  {
int ret;
+   enum typec_pwr_opmode opmode;
  
  	port->enter_state = port->state;

switch (port->state) {
@@ -2201,7 +2215,8 @@ static void run_state_machine(struct tcpm_port *port)
   ret < 0 ? 0 : PD_T_PS_SOURCE_ON);
break;
case SRC_STARTUP:
-   typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB);
+   opmode =  tcpm_get_pwr_opmode(tcpm_rp_cc(port));
+   typec_set_pwr_opmode(port->typec_port, opmode);
port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->caps_count = 0;
port->message_id = 0;
@@ -2362,7 +2377,9 @@ static void run_state_machine(struct tcpm_port *port)
break;
case SNK_STARTUP:
/* XXX: callback into infrastructure */
-   typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB);
+   opmode =  tcpm_get_pwr_opmode(port->polarity ?
+ port->cc2 : port->cc1);
+   typec_set_pwr_opmode(port->typec_port, opmode);
port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->message_id = 0;
port->rx_msgid = -1;





Re: [PATCH 2/2] staging: typec: tcpm: explicit_contract is always established

2017-08-15 Thread Guenter Roeck

On 08/15/2017 04:23 PM, Badhri Jagan Sridharan wrote:

While in SNK_READY state, the explicit_contract seems to be
set to true irrespective of whether an explicit contract
was established for the current connection. TCPM also seems
to report the pwr_opmode as TYPEC_PWR_MODE_PD always once
the port gets into SNK_READY state. This isn't completely
true as port gets into the SNK_READY state for non-pd
type-c ports as well.

This patch sets the explicit_contract flag only when
the PS_READY message is received and the vbus has been
detected by the port controller.

Signed-off-by: Badhri Jagan Sridharan 


Reviewed-by: Guenter Roeck 


---
  drivers/staging/typec/tcpm.c | 11 +++
  1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index a24e6bbb909c..3e12cf101311 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -1367,6 +1367,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
tcpm_set_current_limit(port,
   port->current_limit,
   port->supply_voltage);
+   port->explicit_contract = true;
tcpm_set_state(port, SNK_READY, 0);
} else {
/*
@@ -2458,10 +2459,11 @@ static void run_state_machine(struct tcpm_port *port)
break;
case SNK_READY:
port->try_snk_count = 0;
-   port->explicit_contract = true;
-   typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_PD);
-   port->pwr_opmode = TYPEC_PWR_MODE_PD;
-
+   if (port->explicit_contract) {
+   typec_set_pwr_opmode(port->typec_port,
+TYPEC_PWR_MODE_PD);
+   port->pwr_opmode = TYPEC_PWR_MODE_PD;
+   }
tcpm_typec_connect(port);
  
  		tcpm_check_send_discover(port);

@@ -2951,6 +2953,7 @@ static void _tcpm_pd_vbus_on(struct tcpm_port *port)
port->vbus_present = true;
switch (port->state) {
case SNK_TRANSITION_SINK_VBUS:
+   port->explicit_contract = true;
tcpm_set_state(port, SNK_READY, 0);
break;
case SNK_DISCOVERY:





Re: [PATCH v4 05/20] mtd: nand: qcom: DMA mapping support for register read buffer

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

The EBI2 NAND controller directly remaps register read buffer with
dma_map_sg and DMA address of this buffer will be passed to DMA
API’s. While, on QPIC NAND controller, which uses BAM DMA, we read
the controller registers by preparing a BAM command descriptor. This
command descriptor requires the

   - controller register address
   - the DMA address in which we want to store the value read
 back from the controller register.

This command descriptor will be remapped with dma_map_sg
and its DMA address will be passed to DMA API’s. Therefore,
it's required that we also map our register read buffer for
DMA (using dma_map_single). We use the returned DMA address
for preparing entries in our command descriptor.

This patch adds the DMA mapping support for register read
buffer. This buffer will be DMA mapped during allocation
time. Before starting of any operation, this buffer will
be synced for device operation and after operation
completion, it will be synced again for CPU.



Reviewed-by: Archit Taneja 

Thanks,
Archit


Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 40 
  1 file changed, 40 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index 59b764a..590fc1d 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -234,6 +234,7 @@ struct nandc_regs {
   *by upper layers directly
   * @buf_size/count/start: markers for chip->read_buf/write_buf functions
   * @reg_read_buf: local buffer for reading back registers via DMA
+ * @reg_read_dma:  contains dma address for register read buffer
   * @reg_read_pos: marker for data read in reg_read_buf
   *
   * @regs: a contiguous chunk of memory for DMA register
@@ -279,6 +280,7 @@ struct qcom_nand_controller {
int buf_start;
  
  	__le32 *reg_read_buf;

+   dma_addr_t reg_read_dma;
int reg_read_pos;
  
  	struct nandc_regs *regs;

@@ -371,6 +373,24 @@ static inline void nandc_write(struct qcom_nand_controller 
*nandc, int offset,
iowrite32(val, nandc->base + offset);
  }
  
+static inline void nandc_read_buffer_sync(struct qcom_nand_controller *nandc,

+ bool is_cpu)
+{
+   if (!nandc->props->is_bam)
+   return;
+
+   if (is_cpu)
+   dma_sync_single_for_cpu(nandc->dev, nandc->reg_read_dma,
+   MAX_REG_RD *
+   sizeof(*nandc->reg_read_buf),
+   DMA_FROM_DEVICE);
+   else
+   dma_sync_single_for_device(nandc->dev, nandc->reg_read_dma,
+  MAX_REG_RD *
+  sizeof(*nandc->reg_read_buf),
+  DMA_FROM_DEVICE);
+}
+
  static __le32 *offset_to_nandc_reg(struct nandc_regs *regs, int offset)
  {
switch (offset) {
@@ -854,6 +874,7 @@ static void free_descs(struct qcom_nand_controller *nandc)
  static void clear_read_regs(struct qcom_nand_controller *nandc)
  {
nandc->reg_read_pos = 0;
+   nandc_read_buffer_sync(nandc, false);
  }
  
  static void pre_command(struct qcom_nand_host *host, int command)

@@ -883,6 +904,7 @@ static void parse_erase_write_errors(struct qcom_nand_host 
*host, int command)
int i;
  
  	num_cw = command == NAND_CMD_PAGEPROG ? ecc->steps : 1;

+   nandc_read_buffer_sync(nandc, true);
  
  	for (i = 0; i < num_cw; i++) {

u32 flash_status = le32_to_cpu(nandc->reg_read_buf[i]);
@@ -904,6 +926,7 @@ static void post_command(struct qcom_nand_host *host, int 
command)
  
  	switch (command) {

case NAND_CMD_READID:
+   nandc_read_buffer_sync(nandc, true);
memcpy(nandc->data_buffer, nandc->reg_read_buf,
   nandc->buf_count);
break;
@@ -1067,6 +1090,7 @@ static int parse_read_errors(struct qcom_nand_host *host, 
u8 *data_buf,
int i;
  
  	buf = (struct read_stats *)nandc->reg_read_buf;

+   nandc_read_buffer_sync(nandc, true);
  
  	for (i = 0; i < ecc->steps; i++, buf++) {

u32 flash, buffer, erased_cw;
@@ -2003,6 +2027,16 @@ static int qcom_nandc_alloc(struct qcom_nand_controller 
*nandc)
return -ENOMEM;
  
  	if (nandc->props->is_bam) {

+   nandc->reg_read_dma =
+   dma_map_single(nandc->dev, nandc->reg_read_buf,
+  MAX_REG_RD *
+  sizeof(*nandc->reg_read_buf),
+  DMA_FROM_DEVICE);
+   if (dma_mapping_error(nandc->dev, nandc->reg_read_dma)) {
+   dev_err(nandc->dev, "failed to DMA MAP reg buffer\n");
+  

Re: early x86 unseeded randomness

2017-08-15 Thread Theodore Ts'o
On Tue, Aug 15, 2017 at 07:37:05PM +0200, Thomas Gleixner wrote:
> That exploits the fact that the CPU and caches run at a different non
> synchronized clock than the memory controller and therefore the execution
> time for both the wbinvd() and the memchr_inv() measured in TSC cycles is
> non constant and random enough for the early boot randomization.

Um, can we guarantee that is always true for all systems?  Even, say,
for Silermont, Goldmont and Goldmont Plus (Intel's SOC designs) where
the memory may be located in the same chip package as the CPU/caches?

And even if this is true today, can we be sure that it will be true
for the forseeable future?  Using multiple clocks takes more power, so
I would think that on a SOC there would be a strong pressure to use a
single oscillator for the whole package.

If we really want to do this, I'd much rather *not* have code calling
tsc_early_random().  We're better off having the code call
get_random_bytes() and/or get_random_u32(), and having these systems
use RDRAND if available, and if not, falling back to
tsc_early_random() and then mixing it with whatever unpredictability
we may have been able to gather so far if the CRNG hasn't been
initialized yet.

That way something like tsc_early_random() can help, but it can't make
things worse than what we have today (excepting the performance delay
caused by adding whatever random shite that we hope is enough to
introduce unpredictability to the TSC --- for which I still remain
very skeptical).

- Ted

P.S.  As I recall hpa@ has talked to some Intel architects internally
about how much unpredictability we could really get, and how much of
it is just because there's complex state that we can't see (which if
we could see, might make it much more predictable), and as I recall
they didn't say anyhing definitively; but they were nervous.  I'm
pretty sure that for Intel architects, the right answer from their
perspective is to use RDRAND, and not to play games with the TSC.

The other thing to note here is that because Intel has RDRAND, I'm
actually not that worried about Intel; all of the
drivers/char/random.c will mix in inputs from RDRAND or RDSEED if
available.  I'm actually much more worried about architectures that
don't have a hardware random number generator (e.g., some ARM
subarchitectures and MIPS).  So while you might be able to come up
with something that could work on x86, the real question is it safely
generalizable to other, non-x86 architectures.  And that's where it
gets much more scary.


[PATCH] vmbus: suppress uevents for hv_sock devices

2017-08-15 Thread Dexuan Cui

hv_sock driver is automatically loaded when an application creates an
AF_VSOCK socket, so we don't really need to trigger uevents to the user
space udevd.

And hv_sock devices can appear and disappear frequency, e.g. 100 per
second, so triggering the udevents can cause a high cpu utilization of
udevd, e.g. 30% on a 2-cpu virtual machine. So let's suppress the
uevents to avoid this.

Signed-off-by: Dexuan Cui 
Cc: K. Y. Srinivasan 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
---
 drivers/hv/vmbus_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index ed84e96..a0cf592 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1171,6 +1171,8 @@ int vmbus_device_register(struct hv_device 
*child_device_obj)
child_device_obj->device.parent = &hv_acpi_dev->dev;
child_device_obj->device.release = vmbus_device_release;
 
+   if (is_hvsock_channel(child_device_obj->channel))
+   dev_set_uevent_suppress(&child_device_obj->device, 1);
/*
 * Register with the LDM. This will kick off the driver/device
 * binding...which will eventually call vmbus_match() and vmbus_probe()
-- 
2.7.4



Re: [PATCH v4 06/20] mtd: nand: qcom: allocate BAM transaction

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

- The BAM transaction is the core data structure which will be used
   for all the data transfers in QPIC NAND. Since the core framework
   in nand_base.c is serializing all the NAND requests so allocating
   BAM transaction before every transfer will be overhead. The memory
   for it be allocated during probe time and before every transfer,
   it will be cleared.

- The BAM transaction contains the array of
   command and data scatter gather list and indexes. For
   every transfer, all the resource will be taken from BAM
   transaction.

- The size of the buffer used for BAM transactions
   is calculated based on the NAND device with the maximum page size,
   among all the devices connected to the
   controller.


Reviewed-by: Archit Taneja 

Thanks,
Archit



Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 94 +++
  1 file changed, 94 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index 590fc1d..4f8306e 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -177,6 +177,32 @@
  #define   ECC_BCH_4BITBIT(2)
  #define   ECC_BCH_8BITBIT(3)
  
+#define QPIC_PER_CW_CMD_SGL		32

+#define QPIC_PER_CW_DATA_SGL   8
+
+/*
+ * This data type corresponds to the BAM transaction which will be used for all
+ * NAND transfers.
+ * @cmd_sgl - sgl for NAND BAM command pipe
+ * @data_sgl - sgl for NAND BAM consumer/producer pipe
+ * @cmd_sgl_pos - current index in command sgl.
+ * @cmd_sgl_start - start index in command sgl.
+ * @tx_sgl_pos - current index in data sgl for tx.
+ * @tx_sgl_start - start index in data sgl for tx.
+ * @rx_sgl_pos - current index in data sgl for rx.
+ * @rx_sgl_start - start index in data sgl for rx.
+ */
+struct bam_transaction {
+   struct scatterlist *cmd_sgl;
+   struct scatterlist *data_sgl;
+   u32 cmd_sgl_pos;
+   u32 cmd_sgl_start;
+   u32 tx_sgl_pos;
+   u32 tx_sgl_start;
+   u32 rx_sgl_pos;
+   u32 rx_sgl_start;
+};
+
  struct desc_info {
struct list_head node;
  
@@ -243,6 +269,8 @@ struct nandc_regs {

   * @cmd1/vld: some fixed controller register values
   * @props:properties of current NAND controller,
   *initialized via DT match data
+ * @max_cwperpage: maximum QPIC codewords required. calculated
+ * from all connected NAND devices pagesize
   */
  struct qcom_nand_controller {
struct nand_hw_control controller;
@@ -273,11 +301,13 @@ struct qcom_nand_controller {
};
  
  	struct list_head desc_list;

+   struct bam_transaction *bam_txn;
  
  	u8		*data_buffer;

int buf_size;
int buf_count;
int buf_start;
+   unsigned intmax_cwperpage;
  
  	__le32 *reg_read_buf;

dma_addr_t reg_read_dma;
@@ -350,6 +380,44 @@ struct qcom_nandc_props {
bool is_bam;
  };
  
+/* Frees the BAM transaction memory */

+static void free_bam_transaction(struct qcom_nand_controller *nandc)
+{
+   struct bam_transaction *bam_txn = nandc->bam_txn;
+
+   devm_kfree(nandc->dev, bam_txn);
+}
+
+/* Allocates and Initializes the BAM transaction */
+static struct bam_transaction *
+alloc_bam_transaction(struct qcom_nand_controller *nandc)
+{
+   struct bam_transaction *bam_txn;
+   size_t bam_txn_size;
+   unsigned int num_cw = nandc->max_cwperpage;
+   void *bam_txn_buf;
+
+   bam_txn_size =
+   sizeof(*bam_txn) + num_cw *
+   ((sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL) +
+   (sizeof(*bam_txn->data_sgl) * QPIC_PER_CW_DATA_SGL));
+
+   bam_txn_buf = devm_kzalloc(nandc->dev, bam_txn_size, GFP_KERNEL);
+   if (!bam_txn_buf)
+   return NULL;
+
+   bam_txn = bam_txn_buf;
+   bam_txn_buf += sizeof(*bam_txn);
+
+   bam_txn->cmd_sgl = bam_txn_buf;
+   bam_txn_buf +=
+   sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL * num_cw;
+
+   bam_txn->data_sgl = bam_txn_buf;
+
+   return bam_txn;
+}
+
  static inline struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip)
  {
return container_of(chip, struct qcom_nand_host, chip);
@@ -1920,6 +1988,8 @@ static int qcom_nand_host_setup(struct qcom_nand_host 
*host)
mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops);
  
  	cwperpage = mtd->writesize / ecc->size;

+   nandc->max_cwperpage = max_t(unsigned int, nandc->max_cwperpage,
+cwperpage);
  
  	/*

 * DATA_UD_BYTES varies based on whether the read/write command protects
@@ -2054,6 +2124,20 @@ static int qcom_nandc_alloc(struct qcom_nand_controller 
*nandc)
dev_err(nandc->dev, "failed to request cmd channel\n");
return -ENODEV;
}

Re: [PATCH v4] mtd: spi-nor: add support for GD25Q256

2017-08-15 Thread Andy Yan

Hi Cyrille:


On 2017年08月16日 00:04, Cyrille Pitchen wrote:

Hi Andy,

Le 25/07/2017 à 12:12, Andy Yan a écrit :

Add support for GD25Q256, a 32MiB SPI Nor
flash from Gigadevice.

Signed-off-by: Andy Yan 

---

Changes in v4:
- add SPI_NOR_HAS_LOCK and SPI_NOR_HAS_TB

Between v3 and v4, I see that you've also changed the procedure to the
the Quad Enable bit on all Gigadevice memories with QSPI capabilities.
This is not a detail and should have been reported here.


 Sorry, I will keep this in mind.



Changes in v3:
- rebase on top of spi-nor tree
- add SPI_NOR_4B_OPCODES flag

Changes in v2:
- drop one line unnecessary modification

  drivers/mtd/spi-nor/spi-nor.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 196b52f..e4145cd 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -986,6 +986,11 @@ static const struct flash_info spi_nor_ids[] = {
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
},
+   {
+   "gd25q256", INFO(0xc84019, 0, 64 * 1024, 512,
+   SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
+   SPI_NOR_4B_OPCODES | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
+   },
  
  	/* Intel/Numonyx -- xxxs33b */

{ "160s33b",  INFO(0x898911, 0, 64 * 1024,  32, 0) },
@@ -2365,6 +2370,7 @@ static int spi_nor_init_params(struct spi_nor *nor,
   SNOR_HWCAPS_PP_QUAD)) {
switch (JEDEC_MFR(info)) {
case SNOR_MFR_MACRONIX:
+   case SNOR_MFR_GIGADEVICE:
params->quad_enable = macronix_quad_enable;

Here, you've have changed the Quad Enable requirement for *all*
Gigadevice memories with Quad SPI capabilities.

However, I'm reading the GD25Q128 datasheet and it claims that the QE
bit is BIT(1) of the Status Register 2. Hence some
spansion*_quad_enable() should be used, as before your patch.

Then, still according to the datasheet, the GD25Q128 memory is compliant
with the JESD216 specification (minor 0) but neither with rev A (minor
5) nor rev B (minor 6).
So its Basic Flash Parameter Table is limited to 9 DWORDs instead of 16
DWORDs, hence doesn't provide the Quad Enable requirements. It means
that the SFDP tables would not help to select the right _quad_enable()
function by overriding the choice made by the switch() statement above.

tl;dr
This chunk would introduce a regression with some already supported
Gigadevice memories. So I reject this patch, sorry.


After check some other Gigadevice memories, I found it's true as 
you mentioned.

Some memories use S9 as the QE bit, but some use S6.
Do you have some ideas for this case? Add a check for the full 
jedec_id or encode

the QE bit in the flash_info?
I am a new bee in the flash failed, very appreciate for your advice.


Best regards,

Cyrille


break;
  










[PATCH] vmbus: don't acquire the mutex in vmbus_hvsock_device_unregister()

2017-08-15 Thread Dexuan Cui

Due to commit 54a66265d675 ("Drivers: hv: vmbus: Fix rescind handling"),
we need this patch to resolve the below deadlock:

after we get the mutex in vmbus_hvsock_device_unregister() and call
vmbus_device_unregister() -> device_unregister() -> ... -> device_release()
-> vmbus_device_release(), we'll get a deadlock, because
vmbus_device_release() tries to get the same mutex.

Signed-off-by: Dexuan Cui 
Cc: K. Y. Srinivasan 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
---
 drivers/hv/channel_mgmt.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 4bbb8de..0373611 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -922,14 +922,10 @@ static void vmbus_onoffer_rescind(struct 
vmbus_channel_message_header *hdr)
 
 void vmbus_hvsock_device_unregister(struct vmbus_channel *channel)
 {
-   mutex_lock(&vmbus_connection.channel_mutex);
-
BUG_ON(!is_hvsock_channel(channel));
 
channel->rescind = true;
vmbus_device_unregister(channel->device_obj);
-
-   mutex_unlock(&vmbus_connection.channel_mutex);
 }
 EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister);
 
-- 
2.7.4



Re: [PATCH net-next V2 3/3] tap: XDP support

2017-08-15 Thread Michael S. Tsirkin
On Tue, Aug 15, 2017 at 01:02:05PM +0800, Jason Wang wrote:
> 
> 
> On 2017年08月15日 00:01, Michael S. Tsirkin wrote:
> > On Sat, Aug 12, 2017 at 10:48:49AM +0800, Jason Wang wrote:
> > > 
> > > On 2017年08月12日 07:12, Jakub Kicinski wrote:
> > > > On Fri, 11 Aug 2017 19:41:18 +0800, Jason Wang wrote:
> > > > > This patch tries to implement XDP for tun. The implementation was
> > > > > split into two parts:
> > > > > 
> > > > > - fast path: small and no gso packet. We try to do XDP at page level
> > > > > before build_skb(). For XDP_TX, since creating/destroying queues
> > > > > were completely under control of userspace, it was implemented
> > > > > through generic XDP helper after skb has been built. This could be
> > > > > optimized in the future.
> > > > > - slow path: big or gso packet. We try to do it after skb was created
> > > > > through generic XDP helpers.
> > > > > 
> > > > > Test were done through pktgen with small packets.
> > > > > 
> > > > > xdp1 test shows ~41.1% improvement:
> > > > > 
> > > > > Before: ~1.7Mpps
> > > > > After:  ~2.3Mpps
> > > > > 
> > > > > xdp_redirect to ixgbe shows ~60% improvement:
> > > > > 
> > > > > Before: ~0.8Mpps
> > > > > After:  ~1.38Mpps
> > > > > 
> > > > > Suggested-by: Michael S. Tsirkin 
> > > > > Signed-off-by: Jason Wang 
> > > > Looks OK to me now :)
> > > > 
> > > > Out of curiosity, you say the build_skb() is for "small packets", and it
> > > > seems you are always reserving the 256B regardless of XDP being
> > > > installed.  Does this have no performance impact on non-XDP case?
> > > Have a test, only less than 1% were noticed which I think could be 
> > > ignored.
> > > 
> > > Thanks
> > What did you test btw?
> 
> Pktgen
> 
> >   The biggest issue would be with something like
> > UDP with short packets.
> > 
> 
> Note that we do this only when sndbuf is INT_MAX. So this is probably not an
> issue.

I'd expect to see the issue for guest to host when the packets are
queued at a UDP socket in host.

> The only thing matter is more stress to page allocator, but according
> to the result of pktgen it was very small that could be ignored.
> 
> Thanks

Besides guest to host, for bridging in host bigger truesize might affect
byte queue counts as well.

-- 
MST


Re: [PATCH net-next V2 1/3] tap: use build_skb() for small packet

2017-08-15 Thread Eric Dumazet
On Fri, 2017-08-11 at 19:41 +0800, Jason Wang wrote:
> We use tun_alloc_skb() which calls sock_alloc_send_pskb() to allocate
> skb in the past. This socket based method is not suitable for high
> speed userspace like virtualization which usually:
> 
> - ignore sk_sndbuf (INT_MAX) and expect to receive the packet as fast as
>   possible
> - don't want to be block at sendmsg()
> 
> To eliminate the above overheads, this patch tries to use build_skb()
> for small packet. We will do this only when the following conditions
> are all met:
> 
> - TAP instead of TUN
> - sk_sndbuf is INT_MAX
> - caller don't want to be blocked
> - zerocopy is not used
> - packet size is smaller enough to use build_skb()
> 
> Pktgen from guest to host shows ~11% improvement for rx pps of tap:
> 
> Before: ~1.70Mpps
> After : ~1.88Mpps
> 
> What's more important, this makes it possible to implement XDP for tap
> before creating skbs.


Well well well.

You do realize that tun_build_skb() is not thread safe ?

general protection fault:  [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 3982 Comm: syz-executor0 Not tainted 4.13.0-rc5-next-20170815+ #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: 880069f265c0 task.stack: 880067688000
RIP: 0010:__read_once_size include/linux/compiler.h:276 [inline]
RIP: 0010:compound_head include/linux/page-flags.h:146 [inline]
RIP: 0010:put_page include/linux/mm.h:811 [inline]
RIP: 0010:__skb_frag_unref include/linux/skbuff.h:2743 [inline]
RIP: 0010:skb_release_data+0x26c/0x790 net/core/skbuff.c:568
RSP: 0018:88006768ef20 EFLAGS: 00010206
RAX: 00d70cb5b39acdeb RBX: dc00 RCX: 11000ced1e13
RDX:  RSI: 88003ec28c38 RDI: 06b865ad9cd66f59
RBP: 88006768f040 R08: eaee74a0 R09: ed0007ab4200
R10: 00028c28 R11: 0010 R12: 88003c5581b0
R13: ed000ced1dfb R14: 11000ced1df3 R15: 06b865ad9cd66f39
FS:  7ffbc9ef7700() GS:88003ec0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 2001aff0 CR3: 3d623000 CR4: 06f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 skb_release_all+0x4a/0x60 net/core/skbuff.c:631
 __kfree_skb net/core/skbuff.c:645 [inline]
 kfree_skb+0x15d/0x4c0 net/core/skbuff.c:663
 __netif_receive_skb_core+0x10f8/0x33d0 net/core/dev.c:4425
 __netif_receive_skb+0x2c/0x1b0 net/core/dev.c:4456
 netif_receive_skb_internal+0x10b/0x5e0 net/core/dev.c:4527
 netif_receive_skb+0xae/0x390 net/core/dev.c:4551
 tun_rx_batched.isra.43+0x5e7/0x860 drivers/net/tun.c:1221
 tun_get_user+0x11dd/0x2150 drivers/net/tun.c:1542
 tun_chr_write_iter+0xd8/0x190 drivers/net/tun.c:1568
 call_write_iter include/linux/fs.h:1742 [inline]
 new_sync_write fs/read_write.c:457 [inline]
 __vfs_write+0x684/0x970 fs/read_write.c:470
 vfs_write+0x189/0x510 fs/read_write.c:518
 SYSC_write fs/read_write.c:565 [inline]
 SyS_write+0xef/0x220 fs/read_write.c:557
 entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x40bab1
RSP: 002b:7ffbc9ef6c00 EFLAGS: 0293 ORIG_RAX: 0001
RAX: ffda RBX: 0036 RCX: 0040bab1
RDX: 0036 RSI: 20002000 RDI: 0003
RBP: 00a5f870 R08:  R09: 
R10:  R11: 0293 R12: 
R13:  R14: 7ffbc9ef79c0 R15: 7ffbc9ef7700
Code: c6 e8 c9 78 8d fd 4c 89 e0 48 c1 e8 03 80 3c 18 00 0f 85 93 04 00 00 4d 
8b 3c 24 41 c6 45 00 00 49 8d 7f 20 48 89 f8 48 c1 e8 03 <80> 3c 18 00 0f 85 6b 
04 00 00 41 80 7d 00 00 49 8b 47 20 0f 85 
RIP: __read_once_size include/linux/compiler.h:276 [inline] RSP: 
88006768ef20
RIP: compound_head include/linux/page-flags.h:146 [inline] RSP: 88006768ef20
RIP: put_page include/linux/mm.h:811 [inline] RSP: 88006768ef20
RIP: __skb_frag_unref include/linux/skbuff.h:2743 [inline] RSP: 88006768ef20
RIP: skb_release_data+0x26c/0x790 net/core/skbuff.c:568 RSP: 88006768ef20
---[ end trace 54050eb1ec52ff83 ]---



Re: [PATCH net-next V2 1/3] tap: use build_skb() for small packet

2017-08-15 Thread Michael S. Tsirkin
On Tue, Aug 15, 2017 at 08:45:20PM -0700, Eric Dumazet wrote:
> On Fri, 2017-08-11 at 19:41 +0800, Jason Wang wrote:
> > We use tun_alloc_skb() which calls sock_alloc_send_pskb() to allocate
> > skb in the past. This socket based method is not suitable for high
> > speed userspace like virtualization which usually:
> > 
> > - ignore sk_sndbuf (INT_MAX) and expect to receive the packet as fast as
> >   possible
> > - don't want to be block at sendmsg()
> > 
> > To eliminate the above overheads, this patch tries to use build_skb()
> > for small packet. We will do this only when the following conditions
> > are all met:
> > 
> > - TAP instead of TUN
> > - sk_sndbuf is INT_MAX
> > - caller don't want to be blocked
> > - zerocopy is not used
> > - packet size is smaller enough to use build_skb()
> > 
> > Pktgen from guest to host shows ~11% improvement for rx pps of tap:
> > 
> > Before: ~1.70Mpps
> > After : ~1.88Mpps
> > 
> > What's more important, this makes it possible to implement XDP for tap
> > before creating skbs.
> 
> 
> Well well well.
> 
> You do realize that tun_build_skb() is not thread safe ?

The issue is alloc frag, isn't it?
I guess for now we can limit this to XDP mode only, and
just allocate full pages in that mode.


> general protection fault:  [#1] SMP KASAN
> Dumping ftrace buffer:
>(ftrace buffer empty)
> Modules linked in:
> CPU: 0 PID: 3982 Comm: syz-executor0 Not tainted 4.13.0-rc5-next-20170815+ #3
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> task: 880069f265c0 task.stack: 880067688000
> RIP: 0010:__read_once_size include/linux/compiler.h:276 [inline]
> RIP: 0010:compound_head include/linux/page-flags.h:146 [inline]
> RIP: 0010:put_page include/linux/mm.h:811 [inline]
> RIP: 0010:__skb_frag_unref include/linux/skbuff.h:2743 [inline]
> RIP: 0010:skb_release_data+0x26c/0x790 net/core/skbuff.c:568
> RSP: 0018:88006768ef20 EFLAGS: 00010206
> RAX: 00d70cb5b39acdeb RBX: dc00 RCX: 11000ced1e13
> RDX:  RSI: 88003ec28c38 RDI: 06b865ad9cd66f59
> RBP: 88006768f040 R08: eaee74a0 R09: ed0007ab4200
> R10: 00028c28 R11: 0010 R12: 88003c5581b0
> R13: ed000ced1dfb R14: 11000ced1df3 R15: 06b865ad9cd66f39
> FS:  7ffbc9ef7700() GS:88003ec0() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 2001aff0 CR3: 3d623000 CR4: 06f0
> DR0:  DR1:  DR2: 
> DR3:  DR6: fffe0ff0 DR7: 0400
> Call Trace:
>  skb_release_all+0x4a/0x60 net/core/skbuff.c:631
>  __kfree_skb net/core/skbuff.c:645 [inline]
>  kfree_skb+0x15d/0x4c0 net/core/skbuff.c:663
>  __netif_receive_skb_core+0x10f8/0x33d0 net/core/dev.c:4425
>  __netif_receive_skb+0x2c/0x1b0 net/core/dev.c:4456
>  netif_receive_skb_internal+0x10b/0x5e0 net/core/dev.c:4527
>  netif_receive_skb+0xae/0x390 net/core/dev.c:4551
>  tun_rx_batched.isra.43+0x5e7/0x860 drivers/net/tun.c:1221
>  tun_get_user+0x11dd/0x2150 drivers/net/tun.c:1542
>  tun_chr_write_iter+0xd8/0x190 drivers/net/tun.c:1568
>  call_write_iter include/linux/fs.h:1742 [inline]
>  new_sync_write fs/read_write.c:457 [inline]
>  __vfs_write+0x684/0x970 fs/read_write.c:470
>  vfs_write+0x189/0x510 fs/read_write.c:518
>  SYSC_write fs/read_write.c:565 [inline]
>  SyS_write+0xef/0x220 fs/read_write.c:557
>  entry_SYSCALL_64_fastpath+0x1f/0xbe
> RIP: 0033:0x40bab1
> RSP: 002b:7ffbc9ef6c00 EFLAGS: 0293 ORIG_RAX: 0001
> RAX: ffda RBX: 0036 RCX: 0040bab1
> RDX: 0036 RSI: 20002000 RDI: 0003
> RBP: 00a5f870 R08:  R09: 
> R10:  R11: 0293 R12: 
> R13:  R14: 7ffbc9ef79c0 R15: 7ffbc9ef7700
> Code: c6 e8 c9 78 8d fd 4c 89 e0 48 c1 e8 03 80 3c 18 00 0f 85 93 04 00 00 4d 
> 8b 3c 24 41 c6 45 00 00 49 8d 7f 20 48 89 f8 48 c1 e8 03 <80> 3c 18 00 0f 85 
> 6b 04 00 00 41 80 7d 00 00 49 8b 47 20 0f 85 
> RIP: __read_once_size include/linux/compiler.h:276 [inline] RSP: 
> 88006768ef20
> RIP: compound_head include/linux/page-flags.h:146 [inline] RSP: 
> 88006768ef20
> RIP: put_page include/linux/mm.h:811 [inline] RSP: 88006768ef20
> RIP: __skb_frag_unref include/linux/skbuff.h:2743 [inline] RSP: 
> 88006768ef20
> RIP: skb_release_data+0x26c/0x790 net/core/skbuff.c:568 RSP: 88006768ef20
> ---[ end trace 54050eb1ec52ff83 ]---


Re: [PATCH net-next V2 1/3] tap: use build_skb() for small packet

2017-08-15 Thread Jason Wang



On 2017年08月16日 11:45, Eric Dumazet wrote:

On Fri, 2017-08-11 at 19:41 +0800, Jason Wang wrote:

We use tun_alloc_skb() which calls sock_alloc_send_pskb() to allocate
skb in the past. This socket based method is not suitable for high
speed userspace like virtualization which usually:

- ignore sk_sndbuf (INT_MAX) and expect to receive the packet as fast as
   possible
- don't want to be block at sendmsg()

To eliminate the above overheads, this patch tries to use build_skb()
for small packet. We will do this only when the following conditions
are all met:

- TAP instead of TUN
- sk_sndbuf is INT_MAX
- caller don't want to be blocked
- zerocopy is not used
- packet size is smaller enough to use build_skb()

Pktgen from guest to host shows ~11% improvement for rx pps of tap:

Before: ~1.70Mpps
After : ~1.88Mpps

What's more important, this makes it possible to implement XDP for tap
before creating skbs.


Well well well.

You do realize that tun_build_skb() is not thread safe ?


Ok, I think the issue if skb_page_frag_refill(), need a spinlock 
probably. Will prepare a patch.


Thanks



general protection fault:  [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 3982 Comm: syz-executor0 Not tainted 4.13.0-rc5-next-20170815+ #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: 880069f265c0 task.stack: 880067688000
RIP: 0010:__read_once_size include/linux/compiler.h:276 [inline]
RIP: 0010:compound_head include/linux/page-flags.h:146 [inline]
RIP: 0010:put_page include/linux/mm.h:811 [inline]
RIP: 0010:__skb_frag_unref include/linux/skbuff.h:2743 [inline]
RIP: 0010:skb_release_data+0x26c/0x790 net/core/skbuff.c:568
RSP: 0018:88006768ef20 EFLAGS: 00010206
RAX: 00d70cb5b39acdeb RBX: dc00 RCX: 11000ced1e13
RDX:  RSI: 88003ec28c38 RDI: 06b865ad9cd66f59
RBP: 88006768f040 R08: eaee74a0 R09: ed0007ab4200
R10: 00028c28 R11: 0010 R12: 88003c5581b0
R13: ed000ced1dfb R14: 11000ced1df3 R15: 06b865ad9cd66f39
FS:  7ffbc9ef7700() GS:88003ec0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 2001aff0 CR3: 3d623000 CR4: 06f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
  skb_release_all+0x4a/0x60 net/core/skbuff.c:631
  __kfree_skb net/core/skbuff.c:645 [inline]
  kfree_skb+0x15d/0x4c0 net/core/skbuff.c:663
  __netif_receive_skb_core+0x10f8/0x33d0 net/core/dev.c:4425
  __netif_receive_skb+0x2c/0x1b0 net/core/dev.c:4456
  netif_receive_skb_internal+0x10b/0x5e0 net/core/dev.c:4527
  netif_receive_skb+0xae/0x390 net/core/dev.c:4551
  tun_rx_batched.isra.43+0x5e7/0x860 drivers/net/tun.c:1221
  tun_get_user+0x11dd/0x2150 drivers/net/tun.c:1542
  tun_chr_write_iter+0xd8/0x190 drivers/net/tun.c:1568
  call_write_iter include/linux/fs.h:1742 [inline]
  new_sync_write fs/read_write.c:457 [inline]
  __vfs_write+0x684/0x970 fs/read_write.c:470
  vfs_write+0x189/0x510 fs/read_write.c:518
  SYSC_write fs/read_write.c:565 [inline]
  SyS_write+0xef/0x220 fs/read_write.c:557
  entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x40bab1
RSP: 002b:7ffbc9ef6c00 EFLAGS: 0293 ORIG_RAX: 0001
RAX: ffda RBX: 0036 RCX: 0040bab1
RDX: 0036 RSI: 20002000 RDI: 0003
RBP: 00a5f870 R08:  R09: 
R10:  R11: 0293 R12: 
R13:  R14: 7ffbc9ef79c0 R15: 7ffbc9ef7700
Code: c6 e8 c9 78 8d fd 4c 89 e0 48 c1 e8 03 80 3c 18 00 0f 85 93 04 00 00 4d 8b 3c 
24 41 c6 45 00 00 49 8d 7f 20 48 89 f8 48 c1 e8 03 <80> 3c 18 00 0f 85 6b 04 00 
00 41 80 7d 00 00 49 8b 47 20 0f 85
RIP: __read_once_size include/linux/compiler.h:276 [inline] RSP: 
88006768ef20
RIP: compound_head include/linux/page-flags.h:146 [inline] RSP: 88006768ef20
RIP: put_page include/linux/mm.h:811 [inline] RSP: 88006768ef20
RIP: __skb_frag_unref include/linux/skbuff.h:2743 [inline] RSP: 88006768ef20
RIP: skb_release_data+0x26c/0x790 net/core/skbuff.c:568 RSP: 88006768ef20
---[ end trace 54050eb1ec52ff83 ]---





Re: [PATCH net-next V2 1/3] tap: use build_skb() for small packet

2017-08-15 Thread Jason Wang



On 2017年08月16日 11:55, Michael S. Tsirkin wrote:

On Tue, Aug 15, 2017 at 08:45:20PM -0700, Eric Dumazet wrote:

On Fri, 2017-08-11 at 19:41 +0800, Jason Wang wrote:

We use tun_alloc_skb() which calls sock_alloc_send_pskb() to allocate
skb in the past. This socket based method is not suitable for high
speed userspace like virtualization which usually:

- ignore sk_sndbuf (INT_MAX) and expect to receive the packet as fast as
   possible
- don't want to be block at sendmsg()

To eliminate the above overheads, this patch tries to use build_skb()
for small packet. We will do this only when the following conditions
are all met:

- TAP instead of TUN
- sk_sndbuf is INT_MAX
- caller don't want to be blocked
- zerocopy is not used
- packet size is smaller enough to use build_skb()

Pktgen from guest to host shows ~11% improvement for rx pps of tap:

Before: ~1.70Mpps
After : ~1.88Mpps

What's more important, this makes it possible to implement XDP for tap
before creating skbs.

Well well well.

You do realize that tun_build_skb() is not thread safe ?

The issue is alloc frag, isn't it?
I guess for now we can limit this to XDP mode only, and
just allocate full pages in that mode.




Limit this to XDP mode only does not prevent user from sending packets 
to same queue in parallel I think?


Thanks


Re: [PATCH net-next V2 1/3] tap: use build_skb() for small packet

2017-08-15 Thread Michael S. Tsirkin
On Wed, Aug 16, 2017 at 11:57:51AM +0800, Jason Wang wrote:
> 
> 
> On 2017年08月16日 11:55, Michael S. Tsirkin wrote:
> > On Tue, Aug 15, 2017 at 08:45:20PM -0700, Eric Dumazet wrote:
> > > On Fri, 2017-08-11 at 19:41 +0800, Jason Wang wrote:
> > > > We use tun_alloc_skb() which calls sock_alloc_send_pskb() to allocate
> > > > skb in the past. This socket based method is not suitable for high
> > > > speed userspace like virtualization which usually:
> > > > 
> > > > - ignore sk_sndbuf (INT_MAX) and expect to receive the packet as fast as
> > > >possible
> > > > - don't want to be block at sendmsg()
> > > > 
> > > > To eliminate the above overheads, this patch tries to use build_skb()
> > > > for small packet. We will do this only when the following conditions
> > > > are all met:
> > > > 
> > > > - TAP instead of TUN
> > > > - sk_sndbuf is INT_MAX
> > > > - caller don't want to be blocked
> > > > - zerocopy is not used
> > > > - packet size is smaller enough to use build_skb()
> > > > 
> > > > Pktgen from guest to host shows ~11% improvement for rx pps of tap:
> > > > 
> > > > Before: ~1.70Mpps
> > > > After : ~1.88Mpps
> > > > 
> > > > What's more important, this makes it possible to implement XDP for tap
> > > > before creating skbs.
> > > Well well well.
> > > 
> > > You do realize that tun_build_skb() is not thread safe ?
> > The issue is alloc frag, isn't it?
> > I guess for now we can limit this to XDP mode only, and
> > just allocate full pages in that mode.
> > 
> > 
> 
> Limit this to XDP mode only does not prevent user from sending packets to
> same queue in parallel I think?
> 
> Thanks

Yes but then you can just drop the page frag allocator since
XDP is assumed not to care about truesize for most packets.

-- 
MST


Re: [PATCH 0/5] Add clk and scpsys support for MT6755

2017-08-15 Thread Mars Cheng
Hi Rob, Stephen, Matthias

gentle ping.

Thanks.

On Tue, 2017-08-08 at 16:13 +0800, Mars Cheng wrote:
> Mars Cheng (3):
>   clk: mediatek: add mt6755 clock ID
>   clk: mediatek: add clk support for MT6755
>   soc: mediatek: add MT6755 scpsys support
> 
> wendell.lin (2):
>   dt-bindings: mediatek: add MT6755 power dt-bindings
>   dt-bindings: arm: mediatek: document clk bindings for MT6755
> 
>  .../bindings/arm/mediatek/mediatek,apmixedsys.txt  |1 +
>  .../bindings/arm/mediatek/mediatek,imgsys.txt  |1 +
>  .../bindings/arm/mediatek/mediatek,infracfg.txt|1 +
>  .../bindings/arm/mediatek/mediatek,mmsys.txt   |1 +
>  .../bindings/arm/mediatek/mediatek,topckgen.txt|1 +
>  .../bindings/arm/mediatek/mediatek,vdecsys.txt |1 +
>  .../bindings/arm/mediatek/mediatek,vencsys.txt |1 +
>  .../devicetree/bindings/soc/mediatek/scpsys.txt|3 +
>  drivers/clk/mediatek/Kconfig   |   32 +
>  drivers/clk/mediatek/Makefile  |5 +
>  drivers/clk/mediatek/clk-mt6755-img.c  |   81 +++
>  drivers/clk/mediatek/clk-mt6755-mm.c   |  148 +
>  drivers/clk/mediatek/clk-mt6755-vdec.c |   91 +++
>  drivers/clk/mediatek/clk-mt6755-venc.c |   78 +++
>  drivers/clk/mediatek/clk-mt6755.c  |  666 
> 
>  drivers/soc/mediatek/mtk-scpsys.c  |  116 
>  include/dt-bindings/clock/mt6755-clk.h |  293 +
>  include/dt-bindings/power/mt6755-power.h   |   26 +
>  18 files changed, 1546 insertions(+)
>  create mode 100644 drivers/clk/mediatek/clk-mt6755-img.c
>  create mode 100644 drivers/clk/mediatek/clk-mt6755-mm.c
>  create mode 100644 drivers/clk/mediatek/clk-mt6755-vdec.c
>  create mode 100644 drivers/clk/mediatek/clk-mt6755-venc.c
>  create mode 100644 drivers/clk/mediatek/clk-mt6755.c
>  create mode 100644 include/dt-bindings/clock/mt6755-clk.h
>  create mode 100644 include/dt-bindings/power/mt6755-power.h
> 
> 




Re: [PATCH v3] zsmalloc: zs_page_migrate: schedule free_work if zspage is ZS_EMPTY

2017-08-15 Thread Minchan Kim
On Wed, Aug 16, 2017 at 11:19:41AM +0800, Hui Zhu wrote:
> After commit [1] zs_page_migrate can handle the ZS_EMPTY zspage.
> 
> But I got some false in zs_page_isolate:
>   if (get_zspage_inuse(zspage) == 0) {
>   spin_unlock(&class->lock);
>   return false;
>   }
> The page of this zspage was migrated in before.
> 
> The reason is commit [1] just handle the "page" but not "newpage"
> then it keep the "newpage" with a empty zspage inside system.
> Root cause is zs_page_isolate remove it from ZS_EMPTY list but not
> call zs_page_putback "schedule_work(&pool->free_work);".  Because
> zs_page_migrate done the job without "schedule_work(&pool->free_work);"
> 
> Make this patch let zs_page_migrate wake up free_work if need.
> 
> [1] 
> zsmalloc-zs_page_migrate-skip-unnecessary-loops-but-not-return-ebusy-if-zspage-is-not-inuse-fix.patch
> 
> Signed-off-by: Hui Zhu 
Acked-by: Minchan Kim 

Thanks!


Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Boqun Feng
On Wed, Aug 16, 2017 at 09:16:37AM +0900, Byungchul Park wrote:
> On Tue, Aug 15, 2017 at 10:20:20AM +0200, Ingo Molnar wrote:
> > 
> > So with the latest fixes there's a new lockdep warning on one of my 
> > testboxes:
> > 
> > [   11.322487] EXT4-fs (sda2): mounted filesystem with ordered data mode. 
> > Opts: (null)
> > 
> > [   11.495661] ==
> > [   11.502093] WARNING: possible circular locking dependency detected
> > [   11.508507] 4.13.0-rc5-00497-g73135c58-dirty #1 Not tainted
> > [   11.514313] --
> > [   11.520725] umount/533 is trying to acquire lock:
> > [   11.525657]  ((complete)&barr->done){+.+.}, at: [] 
> > flush_work+0x213/0x2f0
> > [   11.534411] 
> >but task is already holding lock:
> > [   11.540661]  (lock#3){+.+.}, at: [] 
> > lru_add_drain_all_cpuslocked+0x3d/0x190
> > [   11.549613] 
> >which lock already depends on the new lock.
> > 
> > The full splat is below. The kernel config is nothing fancy - distro 
> > derived, 
> > pretty close to defconfig, with lockdep enabled.
> 
> I see...
> 
> Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be released
> Task   B : acquired of cpu_hotplug_lock -> wait for lock#3 to be released
> Task   C : acquired of lock#3 -> wait for completion of barr->done

>From the stack trace below, this barr->done is for flush_work() in
lru_add_drain_all_cpuslocked(), i.e. for work "per_cpu(lru_add_drain_work)"

> Worker D : wait for wfc.work to be released -> will complete barr->done

and this barr->done is for work "wfc.work".

So those two barr->done could not be the same instance, IIUC. Therefore
the deadlock case is not possible.

The problem here is all barr->done instances are initialized at
insert_wq_barrier() and they belongs to the same lock class, to fix
this, we need to differ barr->done with different lock classes based on
the corresponding works.

How about the this(only compilation test):

->8
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index e86733a8b344..d14067942088 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2431,6 +2431,27 @@ struct wq_barrier {
struct task_struct  *task;  /* purely informational */
 };
 
+#ifdef CONFIG_LOCKDEP_COMPLETE
+# define INIT_WQ_BARRIER_ONSTACK(barr, func, target)   
\
+do {   
\
+   INIT_WORK_ONSTACK(&(barr)->work, func); 
\
+   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
\
+   lockdep_init_map_crosslock((struct lockdep_map *)&(barr)->done.map, 
\
+  "(complete)" #barr,  
\
+  (target)->lockdep_map.key, 1);   
\
+   __init_completion(&barr->done); 
\
+   barr->task = current;   
\
+} while (0)
+#else
+# define INIT_WQ_BARRIER_ONSTACK(barr, func, target)   
\
+do {   
\
+   INIT_WORK_ONSTACK(&(barr)->work, func); 
\
+   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
\
+   init_completion(&barr->done);   
\
+   barr->task = current;   
\
+} while (0)
+#endif
+
 static void wq_barrier_func(struct work_struct *work)
 {
struct wq_barrier *barr = container_of(work, struct wq_barrier, work);
@@ -2474,10 +2495,7 @@ static void insert_wq_barrier(struct pool_workqueue *pwq,
 * checks and call back into the fixup functions where we
 * might deadlock.
 */
-   INIT_WORK_ONSTACK(&barr->work, wq_barrier_func);
-   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work));
-   init_completion(&barr->done);
-   barr->task = current;
+   INIT_WQ_BARRIER_ONSTACK(barr, wq_barrier_func, target);
 
/*
 * If @target is currently being executed, schedule the


Re: [PATCH 1/2] x86/idle: add halt poll for halt idle

2017-08-15 Thread Michael S. Tsirkin
On Thu, Jun 22, 2017 at 11:22:13AM +, root wrote:
> From: Yang Zhang 
> 
> This patch introduce a new mechanism to poll for a while before
> entering idle state.
> 
> David has a topic in KVM forum to describe the problem on current KVM VM
> when running some message passing workload in KVM forum. Also, there
> are some work to improve the performance in KVM, like halt polling in KVM.
> But we still has 4 MSR wirtes and HLT vmexit when going into halt idle
> which introduce lot of latency.
> 
> Halt polling in KVM provide the capbility to not schedule out VCPU when
> it is the only task in this pCPU. Unlike it, this patch will let VCPU polls
> for a while if there is no work inside VCPU to elimiate heavy vmexit during
> in/out idle. The potential impact is it will cost more CPU cycle since we
> are doing polling and may impact other task which waiting on the same
> physical CPU in host.

I wonder whether you considered doing this in an idle driver.
I have a prototype patch combining this with mwait within guest -
I can post it if you are interested.


> Here is the data i get when running benchmark contextswitch
> (https://github.com/tsuna/contextswitch)
> 
> before patch:
> 200 process context switches in 4822613801ns (2411.3ns/ctxsw)
> 
> after patch:
> 200 process context switches in 3584098241ns (1792.0ns/ctxsw)
> 
> Signed-off-by: Yang Zhang 
> ---
>  Documentation/sysctl/kernel.txt | 10 ++
>  arch/x86/kernel/process.c   | 21 +
>  include/linux/kernel.h  |  3 +++
>  kernel/sched/idle.c |  3 +++
>  kernel/sysctl.c |  9 +
>  5 files changed, 46 insertions(+)
> 
> diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
> index bac23c1..4e71bfe 100644
> --- a/Documentation/sysctl/kernel.txt
> +++ b/Documentation/sysctl/kernel.txt
> @@ -63,6 +63,7 @@ show up in /proc/sys/kernel:
>  - perf_event_max_stack
>  - perf_event_max_contexts_per_stack
>  - pid_max
> +- poll_threshold_ns[ X86 only ]
>  - powersave-nap   [ PPC only ]
>  - printk
>  - printk_delay
> @@ -702,6 +703,15 @@ kernel tries to allocate a number starting from this one.
>  
>  ==
>  
> +poll_threshold_ns: (X86 only)
> +
> +This parameter used to control the max wait time to poll before going
> +into real idle state. By default, the values is 0 means don't poll.
> +It is recommended to change the value to non-zero if running latency-bound
> +workloads in VM.
> +
> +==
> +
>  powersave-nap: (PPC only)
>  
>  If set, Linux-PPC will use the 'nap' mode of powersaving,
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index 0bb8842..6361783 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -39,6 +39,10 @@
>  #include 
>  #include 
>  
> +#ifdef CONFIG_HYPERVISOR_GUEST
> +unsigned long poll_threshold_ns;
> +#endif
> +
>  /*
>   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
>   * no more per-task TSS's. The TSS size is kept cacheline-aligned
> @@ -313,6 +317,23 @@ static inline void play_dead(void)
>  }
>  #endif
>  
> +#ifdef CONFIG_HYPERVISOR_GUEST
> +void arch_cpu_idle_poll(void)
> +{
> + ktime_t start, cur, stop;
> +
> + if (poll_threshold_ns) {
> + start = cur = ktime_get();
> + stop = ktime_add_ns(ktime_get(), poll_threshold_ns);
> + do {
> + if (need_resched())
> + break;
> + cur = ktime_get();
> + } while (ktime_before(cur, stop));
> + }
> +}
> +#endif
> +
>  void arch_cpu_idle_enter(void)
>  {
>   tsc_verify_tsc_adjust(false);
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 13bc08a..04cf774 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -460,6 +460,9 @@ extern __scanf(2, 0)
>  extern int sysctl_panic_on_stackoverflow;
>  
>  extern bool crash_kexec_post_notifiers;
> +#ifdef CONFIG_HYPERVISOR_GUEST
> +extern unsigned long poll_threshold_ns;
> +#endif
>  
>  /*
>   * panic_cpu is used for synchronizing panic() and crash_kexec() execution. 
> It
> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> index 2a25a9e..e789f99 100644
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -74,6 +74,7 @@ static noinline int __cpuidle cpu_idle_poll(void)
>  }
>  
>  /* Weak implementations for optional arch specific functions */
> +void __weak arch_cpu_idle_poll(void) { }
>  void __weak arch_cpu_idle_prepare(void) { }
>  void __weak arch_cpu_idle_enter(void) { }
>  void __weak arch_cpu_idle_exit(void) { }
> @@ -219,6 +220,8 @@ static void do_idle(void)
>*/
>  
>   __current_set_polling();
> + arch_cpu_idle_poll();
> +
>   tick_nohz_idle_enter();
>  
>   while (!need_resched()) {
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
>

Re: [PATCH net-next V2 1/3] tap: use build_skb() for small packet

2017-08-15 Thread Jason Wang



On 2017年08月16日 11:59, Michael S. Tsirkin wrote:

On Wed, Aug 16, 2017 at 11:57:51AM +0800, Jason Wang wrote:


On 2017年08月16日 11:55, Michael S. Tsirkin wrote:

On Tue, Aug 15, 2017 at 08:45:20PM -0700, Eric Dumazet wrote:

On Fri, 2017-08-11 at 19:41 +0800, Jason Wang wrote:

We use tun_alloc_skb() which calls sock_alloc_send_pskb() to allocate
skb in the past. This socket based method is not suitable for high
speed userspace like virtualization which usually:

- ignore sk_sndbuf (INT_MAX) and expect to receive the packet as fast as
possible
- don't want to be block at sendmsg()

To eliminate the above overheads, this patch tries to use build_skb()
for small packet. We will do this only when the following conditions
are all met:

- TAP instead of TUN
- sk_sndbuf is INT_MAX
- caller don't want to be blocked
- zerocopy is not used
- packet size is smaller enough to use build_skb()

Pktgen from guest to host shows ~11% improvement for rx pps of tap:

Before: ~1.70Mpps
After : ~1.88Mpps

What's more important, this makes it possible to implement XDP for tap
before creating skbs.

Well well well.

You do realize that tun_build_skb() is not thread safe ?

The issue is alloc frag, isn't it?
I guess for now we can limit this to XDP mode only, and
just allocate full pages in that mode.



Limit this to XDP mode only does not prevent user from sending packets to
same queue in parallel I think?

Thanks

Yes but then you can just drop the page frag allocator since
XDP is assumed not to care about truesize for most packets.



Ok, let me do some test to see the numbers between the two methods first.

Thanks


[PATCH v3 00/14] [dt-bindings] [media] Add document file and driver for Sony CXD2880 DVB-T2/T tuner + demodulator

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Hi,

This is the patch series (version 3) of Sony CXD2880 DVB-T2/T tuner + 
demodulator driver.
The driver supports DVB-API and interfaces through SPI.

We have tested the driver on Raspberry Pi 3 and got picture and sound from a 
media player.

The change history of this patch series is as below.

[Change list]
Changes in V3
(1)Total patch number was changed from 15 to 14,
   due to the all files of [PATCH v2 04/15] were removed.
   drivers/media/dvb-frontends/cxd2880/cxd2880_math.c
  -Removed
   drivers/media/dvb-frontends/cxd2880/cxd2880_math.h
  -Removed

(2)Removed another file.
   drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h
  -Removed 

(3)The detail change items of each files are as below.
[PATCH v3 01/14]
   Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt
  -no change
[PATCH v3 02/14]
   drivers/media/spi/cxd2880-spi.c
  -adjusted of indent spaces
  -removed unnecessary cast
  -changed debugging code
  -changed timeout method
  -modified coding style of if()
  -changed hexadecimal code to lower case. 
[PATCH v3 03/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880.h
  -no change
   drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
  -changed MASKUPPER/MASKLOWER with GENMASK 
   drivers/media/dvb-frontends/cxd2880/cxd2880_common.h
  -removed definition NULL and SONY_SLEEP
  -changed CXD2880_SLEEP to usleep_range
  -changed cxd2880_atomic_set to atomic_set
  -removed cxd2880_atomic struct and cxd2880_atomic_read
  -changed stop-watch function
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.c
  -removed unnecessary cast
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.h
  -modified return code 
   drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c
  -changed CXD2880_SLEEP to usleep_range
  -changed stop-watch function
  -modified return code
   #drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h
  -cxd2880_stdlib.h file was removed from V3.
[PATCH v3 04/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
  -removed unnecessary cast
  -changed cxd2880_memcpy to memcpy
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.c
  -removed unnecessary cast
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.h
  -modified return code
[PATCH v3 05/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
  -removed code relevant to ISDB-T
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
  -removed unnecessary cast
  -removed code relevant to ISDB-T
  -changed CXD2880_SLEEP to usleep_range
  -changed cxd2880_memset to memset 
  -changed cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if()
  -changed to use const values at writing a lot of registers 
   with a command. 
  -changed hexadecimal code to lower case. 
  -adjusted of indent spaces
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
  -removed code relevant to ISDB-T
  -changed cxd2880_atomic struct to atomic_t
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
  -updated version information
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
  -changed CXD2880_SLEEP to usleep_range
  -removed unnecessary cast
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h
  -modified return code
[PATCH v3 06/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
  -changed cxd2880_atomic_read to atomic_read
  -changed cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if() 
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h
  -modified return code
[PATCH v3 07/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
  -adjusted indent spaces
  -modified debugging code
  -removed unnecessary cast
  -modified return code
  -modified coding style of if() 
  -modified about measureme

Re: linux-next: manual merge of the akpm-current tree with the tip tree

2017-08-15 Thread Minchan Kim
On Mon, Aug 14, 2017 at 09:57:23PM +0200, Peter Zijlstra wrote:
> On Mon, Aug 14, 2017 at 05:38:39PM +0900, Minchan Kim wrote:
> > memory-barrier.txt always scares me. I have read it for a while
> > and IIUC, it seems semantic of spin_unlock(&same_pte) would be
> > enough without some memory-barrier inside mm_tlb_flush_nested.
> 
> Indeed, see the email I just send. Its both spin_lock() and
> spin_unlock() that we care about.
> 
> Aside from the semi permeable barrier of these primitives, RCpc ensures
> these orderings only work against the _same_ lock variable.
> 
> Let me try and explain the ordering for PPC (which is by far the worst
> we have in this regard):
> 
> 
> spin_lock(lock)
> {
>   while (test_and_set(lock))
>   cpu_relax();
>   lwsync();
> }
> 
> 
> spin_unlock(lock)
> {
>   lwsync();
>   clear(lock);
> }
> 
> Now LWSYNC has fairly 'simple' semantics, but with fairly horrible
> ramifications. Consider LWSYNC to provide _local_ TSO ordering, this
> means that it allows 'stores reordered after loads'.
> 
> For the spin_lock() that implies that all load/store's inside the lock
> do indeed stay in, but the ACQUIRE is only on the LOAD of the
> test_and_set(). That is, the actual _set_ can leak in. After all it can
> re-order stores after load (inside the lock).
> 
> For unlock it again means all load/store's prior stay prior, and the
> RELEASE is on the store clearing the lock state (nothing surprising
> here).
> 
> Now the _local_ part, the main take-away is that these orderings are
> strictly CPU local. What makes the spinlock work across CPUs (as we'd
> very much expect it to) is the address dependency on the lock variable.
> 
> In order for the spin_lock() to succeed, it must observe the clear. Its
> this link that crosses between the CPUs and builds the ordering. But
> only the two CPUs agree on this order. A third CPU not involved in
> this transaction can disagree on the order of events.

The detail explanation in your previous reply makes me comfortable
from scary memory-barrier.txt but this reply makes me scared again. ;-)

Thanks for the kind clarification, Peter!



Re: [PATCH v4 08/20] mtd: nand: qcom: support for passing flags in transfer functions

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

The BAM has multiple flags to control the transfer. This patch
adds flags parameter in register and data transfer functions and
modifies all these functions call with appropriate flags using
following rule

1. Read and write can’t go in single command descriptor so
separate SGL should be used.
2. For some of the requests, NWD flag should be set in BAM
DMA descriptor.
3. For Data write, the BAM has internal buffer for each codeword.
All write request will modify the data in internal buffer and
this buffer will be flushed to NAND device once EOT flag is set.
So for all the write requests in single codeword, the EOT should
be cleared for all tx data descriptors except the last one.

Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 122 --
  1 file changed, 70 insertions(+), 52 deletions(-)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index f52a692..d9c8a6b 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -180,6 +180,14 @@
  #define QPIC_PER_CW_CMD_SGL   32
  #define QPIC_PER_CW_DATA_SGL  8
  
+/* Flags used for BAM DMA desc preparation*/

+/* Don't set the EOT in current tx sgl */
+#define NAND_BAM_NO_EOTBIT(0)
+/* Set the NWD flag in current sgl */
+#define NAND_BAM_NWD   BIT(1)
+/* Finish writing in the current sgl and start writing in another sgl */
+#define NAND_BAM_NEXT_SGL  BIT(2)
+
  /*
   * This data type corresponds to the BAM transaction which will be used for 
all
   * NAND transfers.
@@ -731,7 +739,7 @@ static int prep_adm_dma_desc(struct qcom_nand_controller 
*nandc, bool read,
   * @num_regs: number of registers to read


Minor comment: the read_reg_dma/write_reg/read_data/write_data_dma funcs add a 
new arg, so it
would be nice to update the comment describing the function and its arguments. 
It would also
be nice to mention that the flags are presently used only for controllers using 
BAM.

With that,

Reviewed-by: Archit Taneja 

Thanks,
Archit


   */
  static int read_reg_dma(struct qcom_nand_controller *nandc, int first,
-   int num_regs)
+   int num_regs, unsigned int flags)
  {
bool flow_control = false;
void *vaddr;
@@ -755,7 +763,7 @@ static int read_reg_dma(struct qcom_nand_controller *nandc, 
int first,
   * @num_regs: number of registers to write
   */
  static int write_reg_dma(struct qcom_nand_controller *nandc, int first,
-int num_regs)
+int num_regs, unsigned int flags)
  {
bool flow_control = false;
struct nandc_regs *regs = nandc->regs;
@@ -767,6 +775,9 @@ static int write_reg_dma(struct qcom_nand_controller 
*nandc, int first,
if (first == NAND_FLASH_CMD)
flow_control = true;
  
+	if (first == NAND_EXEC_CMD)

+   flags |= NAND_BAM_NWD;
+
if (first == NAND_DEV_CMD1_RESTORE)
first = NAND_DEV_CMD1;
  
@@ -788,7 +799,7 @@ static int write_reg_dma(struct qcom_nand_controller *nandc, int first,

   * @size: DMA transaction size in bytes
   */
  static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off,
-const u8 *vaddr, int size)
+const u8 *vaddr, int size, unsigned int flags)
  {
return prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false);
  }
@@ -802,7 +813,7 @@ static int read_data_dma(struct qcom_nand_controller 
*nandc, int reg_off,
   * @size: DMA transaction size in bytes
   */
  static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off,
- const u8 *vaddr, int size)
+ const u8 *vaddr, int size, unsigned int flags)
  {
return prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false);
  }
@@ -813,9 +824,9 @@ static int write_data_dma(struct qcom_nand_controller 
*nandc, int reg_off,
   */
  static void config_nand_page_read(struct qcom_nand_controller *nandc)
  {
-   write_reg_dma(nandc, NAND_ADDR0, 2);
-   write_reg_dma(nandc, NAND_DEV0_CFG0, 3);
-   write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1);
+   write_reg_dma(nandc, NAND_ADDR0, 2, 0);
+   write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0);
+   write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, 0);
  }
  
  /*

@@ -824,11 +835,12 @@ static void config_nand_page_read(struct 
qcom_nand_controller *nandc)
   */
  static void config_nand_cw_read(struct qcom_nand_controller *nandc)
  {
-   write_reg_dma(nandc, NAND_FLASH_CMD, 1);
-   write_reg_dma(nandc, NAND_EXEC_CMD, 1);
+   write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
+   write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
  
-	read_reg_dma(nandc, NAND_FLASH_STATUS, 2);

-   read_reg_dma(nandc, N

[PATCH v3 01/14] [dt-bindings] [media] Add document file for CXD2880 SPI I/F

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the document file for Sony CXD2880 DVB-T2/T tuner + demodulator.
It contains the description of the SPI adapter binding.

No change since version 1. I should have carried the ack forward:
Acked-by: Rob Herring 

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../devicetree/bindings/media/spi/sony-cxd2880.txt | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt

diff --git a/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt 
b/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt
new file mode 100644
index ..fc5aa263abe5
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt
@@ -0,0 +1,14 @@
+Sony CXD2880 DVB-T2/T tuner + demodulator driver SPI adapter
+
+Required properties:
+- compatible: Should be "sony,cxd2880".
+- reg: SPI chip select number for the device.
+- spi-max-frequency: Maximum bus speed, should be set to <5500> (55MHz).
+
+Example:
+
+cxd2880@0 {
+   compatible = "sony,cxd2880";
+   reg = <0>; /* CE0 */
+   spi-max-frequency = <5500>; /* 55MHz */
+};
-- 
2.13.0



[PATCH v3 02/14] [media] cxd2880-spi: Add support for CXD2880 SPI interface

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the SPI adapter part of the driver for the
Sony CXD2880 DVB-T2/T tuner + demodulator.

[Change list]
Changes in V3
   drivers/media/spi/cxd2880-spi.c
  -adjusted of indent spaces
  -removed unnecessary cast
  -changed debugging code
  -changed timeout method
  -modified coding style of if()
  -changed hexadecimal code to lower case. 

Changes in V2
   drivers/media/spi/cxd2880-spi.c
  -Modified PID filter setting.

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/spi/cxd2880-spi.c | 697 
 1 file changed, 697 insertions(+)
 create mode 100644 drivers/media/spi/cxd2880-spi.c

diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c
new file mode 100644
index ..961b94daab38
--- /dev/null
+++ b/drivers/media/spi/cxd2880-spi.c
@@ -0,0 +1,697 @@
+/*
+ * cxd2880-spi.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * SPI adapter
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
+
+#include 
+#include 
+
+#include "dvb_demux.h"
+#include "dmxdev.h"
+#include "dvb_frontend.h"
+#include "cxd2880.h"
+
+#define CXD2880_MAX_FILTER_SIZE 32
+#define BURST_WRITE_MAX 128
+#define MAX_TRANS_PACKET 300
+
+struct cxd2880_ts_buf_info {
+   u8 read_ready;
+   u8 almost_full;
+   u8 almost_empty;
+   u8 overflow;
+   u8 underflow;
+   u16 packet_num;
+};
+
+struct cxd2880_pid_config {
+   u8 is_enable;
+   u16 pid;
+};
+
+struct cxd2880_pid_filter_config {
+   u8 is_negative;
+   struct cxd2880_pid_config pid_config[CXD2880_MAX_FILTER_SIZE];
+};
+
+struct cxd2880_dvb_spi {
+   struct dvb_frontend dvb_fe;
+   struct dvb_adapter adapter;
+   struct dvb_demux demux;
+   struct dmxdev dmxdev;
+   struct dmx_frontend dmx_fe;
+   struct task_struct *cxd2880_ts_read_thread;
+   struct spi_device *spi;
+   struct mutex spi_mutex; /* For SPI access exclusive control */
+   int feed_count;
+   int all_pid_feed_count;
+   u8 *ts_buf;
+   struct cxd2880_pid_filter_config filter_config;
+};
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+static int cxd2880_write_spi(struct spi_device *spi, u8 *data, u32 size)
+{
+   struct spi_message msg;
+   struct spi_transfer tx;
+   int ret = 0;
+
+   if ((!spi) || (!data)) {
+   pr_err("invalid arg\n");
+   return -EINVAL;
+   }
+
+   memset(&tx, 0, sizeof(tx));
+   tx.tx_buf = data;
+   tx.len = size;
+
+   spi_message_init(&msg);
+   spi_message_add_tail(&tx, &msg);
+   ret = spi_sync(spi, &msg);
+
+   return ret;
+}
+
+static int cxd2880_write_reg(struct spi_device *spi,
+u8 subAddress, const u8 *data, u32 size)
+{
+   u8 send_data[BURST_WRITE_MAX + 4];
+   const u8 *write_data_top = NULL;
+   int ret = 0;
+
+   if ((!spi) || (!data)) {
+   pr_err("invalid arg\n");
+   return -EINVAL;
+   }
+   if (size > BURST_WRITE_MAX) {
+   pr_err("data size > WRITE_MAX\n");
+   return -EINVAL;
+   }
+
+   if (subAddress + size > 0x100) {
+   pr_err("out of range\n");
+   return -EINVAL;
+   }
+
+   send_data[0] = 0x0e;
+   write_data_top = data;
+
+   while (size > 0) {
+   send_data[1] = subAddress;
+   if (size > 255)
+   send_data[2] = 255;
+   else
+   send_data[2] = (u8)size;
+
+   memcpy(&send_data[3], write_data_top, send_data[2]);
+
+   r

[PATCH v3 03/14] [media] cxd2880: Add common files for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

These are common files for the driver for the
Sony CXD2880 DVB-T2/T tuner + demodulator.
These contains helper functions for the driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880.h
  -no change
   drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
  -changed MASKUPPER/MASKLOWER with GENMASK 
   drivers/media/dvb-frontends/cxd2880/cxd2880_common.h
  -removed definition NULL and SONY_SLEEP
  -changed CXD2880_SLEEP to usleep_range
  -changed cxd2880_atomic_set to atomic_set
  -removed cxd2880_atomic struct and cxd2880_atomic_read
  -changed stop-watch function
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.c
  -removed unnecessary cast
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.h
  -modified return code 
   drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c
  -changed CXD2880_SLEEP to usleep_range
  -changed stop-watch function
  -modified return code
   #drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h
  -cxd2880_stdlib.h file was removed from V3.

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/cxd2880/cxd2880.h  | 46 +++
 .../media/dvb-frontends/cxd2880/cxd2880_common.c   | 38 
 .../media/dvb-frontends/cxd2880/cxd2880_common.h   | 50 
 drivers/media/dvb-frontends/cxd2880/cxd2880_io.c   | 68 ++
 drivers/media/dvb-frontends/cxd2880/cxd2880_io.h   | 62 
 .../dvb-frontends/cxd2880/cxd2880_stopwatch_port.c | 60 +++
 6 files changed, 324 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_common.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_io.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_io.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880.h
new file mode 100644
index ..281f9a784eb5
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880.h
@@ -0,0 +1,46 @@
+/*
+ * cxd2880.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver public definitions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#ifndef CXD2880_H
+#define CXD2880_H
+
+struct cxd2880_config {
+   struct spi_device *spi;
+   struct mutex *spi_mutex; /* For SPI access exclusive control */
+};
+
+#if IS_REACHABLE(CONFIG_DVB_CXD2880)
+extern struct dvb_frontend *cxd2880_attach(struct dvb_frontend *fe,
+   struct cxd2880_config *cfg);
+#else
+static inline struct dvb_frontend *cxd2880_attach(struct dvb_frontend *fe,
+   struct cxd2880_config *cfg)
+{
+   pr_warn("%s: driver disabled by Kconfig\n", __func__);
+   return NULL;
+}
+#endif /* CONFIG_DVB_CXD2880 */
+
+#endif /* CXD2880_H */
diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
new file mode 100644
index ..ffaa140bb8cb
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
@@ -0,0 +1,38 @@
+/*
+ * cxd2880_common.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * common functions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify

[PATCH v3 04/14] [media] cxd2880: Add spi device IO routines

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Add functions for initializing, reading and writing to the SPI
device for the Sony CXD2880 DVB-T2/T tuner + demodulator.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
  -removed unnecessary cast
  -changed cxd2880_memcpy to memcpy
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.c
  -removed unnecessary cast
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../dvb-frontends/cxd2880/cxd2880_devio_spi.c  | 146 +
 .../dvb-frontends/cxd2880/cxd2880_devio_spi.h  |  40 ++
 drivers/media/dvb-frontends/cxd2880/cxd2880_spi.h  |  51 +++
 .../dvb-frontends/cxd2880/cxd2880_spi_device.c | 130 ++
 .../dvb-frontends/cxd2880/cxd2880_spi_device.h |  43 ++
 5 files changed, 410 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_spi.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
new file mode 100644
index ..2cf4fb0e4610
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
@@ -0,0 +1,146 @@
+/*
+ * cxd2880_devio_spi.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * I/O interface via SPI
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "cxd2880_devio_spi.h"
+
+#define BURST_WRITE_MAX 128
+
+static int cxd2880_io_spi_read_reg(struct cxd2880_io *io,
+  enum cxd2880_io_tgt tgt,
+  u8 sub_address, u8 *data,
+  u32 size)
+{
+   int ret = 0;
+   struct cxd2880_spi *spi = NULL;
+   u8 send_data[6];
+   u8 *read_data_top = data;
+
+   if ((!io) || (!io->if_object) || (!data))
+   return -EINVAL;
+
+   if (sub_address + size > 0x100)
+   return -ERANGE;
+
+   spi = io->if_object;
+
+   if (tgt == CXD2880_IO_TGT_SYS)
+   send_data[0] = 0x0b;
+   else
+   send_data[0] = 0x0a;
+
+   send_data[3] = 0;
+   send_data[4] = 0;
+   send_data[5] = 0;
+
+   while (size > 0) {
+   send_data[1] = sub_address;
+   if (size > 255)
+   send_data[2] = 255;
+   else
+   send_data[2] = size;
+
+   ret =
+   spi->write_read(spi, send_data, sizeof(send_data),
+   read_data_top, send_data[2]);
+   if (ret)
+   return ret;
+
+   sub_address += send_data[2];
+   read_data_top += send_data[2];
+   size -= send_data[2];
+   }
+
+   return ret;
+}
+
+static int cxd2880_io_spi_write_reg(struct cxd2880_io *io,
+   enum cxd2880_io_tgt tgt,
+   u8 sub_address,
+   const u8 *data, u32 size)
+{
+   int ret = 0;
+   struct cxd2880_spi *spi = NULL;

[PATCH v3 05/14] [media] cxd2880: Add tuner part of the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This part of the driver has the main routines to handle
the tuner and demodulator functionality.  The tnrdmd_mon.* files
have monitor functions for the driver.
This is part of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
  -removed code relevant to ISDB-T
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
  -removed unnecessary cast
  -removed code relevant to ISDB-T
  -changed CXD2880_SLEEP to usleep_range
  -changed cxd2880_memset to memset 
  -changed cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if()
  -changed to use const values at writing a lot of registers 
   with a command. 
  -changed hexadecimal code to lower case. 
  -adjusted of indent spaces
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
  -removed code relevant to ISDB-T
  -changed cxd2880_atomic struct to atomic_t
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
  -updated version information
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
  -changed CXD2880_SLEEP to usleep_range
  -removed unnecessary cast
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h
  -modified return code

Changes in V2
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
  -updated version information

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h  |   46 +
 .../media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c   | 4030 
 .../media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h   |  391 ++
 .../cxd2880/cxd2880_tnrdmd_driver_version.h|   29 +
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c |  221 ++
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h |   52 +
 6 files changed, 4769 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
new file mode 100644
index ..2d35d3990060
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
@@ -0,0 +1,46 @@
+/*
+ * cxd2880_dtv.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * DTV related definitions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#ifndef CXD2880_DTV_H
+#define CXD2880_DTV_H
+
+enum cxd2880_dtv_sys {
+   CXD2880_DTV_SYS_UNKNOWN,
+   CXD2880_DTV_SYS_DVBT,
+   CXD2880_DTV_SYS_DVBT2,
+   CXD2880_DTV_SYS_ANY
+};
+
+enum cxd2880_dtv_bandwidth {
+   CXD2880_DTV_BW_UNKNOWN = 0,
+   CXD2880_DTV_BW_1_7_MHZ = 1,
+   CXD2880_DTV_BW_5_MHZ = 5,
+   CXD2880_DTV_BW_6_MHZ = 6,
+   CXD2880_DTV_BW_7_MHZ = 7,
+   CXD2880_DTV_BW_8_MHZ = 8
+};
+
+#endif
diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
new file mode 100644
index ..044dc26d2ff3
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
@@ -0,0 +1,4030 @@

Re: [PATCH v4 09/20] mtd: nand: qcom: support for read location registers

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

In EBI2, all codeword data will be read in FLASH_BUF_ACC buffer
and ADM will copy the data from source (FLASH_BUF_ACC) to
destination (memory for data read).

In QPIC, there is no FLASH_BUF_ACC and all the codeword data will
held in QPIC BAM FIFO buffers. It provides multiple READ_LOCATION
registers which will be used for copying the data from FIFO to
memory. The READ_LOCATION register will be used to read a
specific amount of data from a specific offset within the flash
buffer. It supports sequential offset requests. Each request is
composed of the following fields:

a. Offset within the flash buffer from which data should be
read
b. Amount of data to be read
c. Flag bit specifying the last read request from the flash
buffer. Following the last read request the NANDc refers to the
buffer as empty.

Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 64 +++
  1 file changed, 64 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index d9c8a6b..b452cfb 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -53,6 +53,8 @@
  #define   NAND_VERSION0xf08
  #define   NAND_READ_LOCATION_00xf20
  #define   NAND_READ_LOCATION_10xf24
+#defineNAND_READ_LOCATION_20xf28
+#defineNAND_READ_LOCATION_30xf2c
  
  /* dummy register offsets, used by write_reg_dma */

  #define   NAND_DEV_CMD1_RESTORE   0xdead
@@ -135,6 +137,11 @@
  #define   ERASED_PAGE (PAGE_ALL_ERASED | PAGE_ERASED)
  #define   ERASED_CW   (CODEWORD_ALL_ERASED | 
CODEWORD_ERASED)
  
+/* NAND_READ_LOCATION_n bits */

+#define READ_LOCATION_OFFSET   0
+#define READ_LOCATION_SIZE 16
+#define READ_LOCATION_LAST 31
+
  /* Version Mask */
  #define   NAND_VERSION_MAJOR_MASK 0xf000
  #define   NAND_VERSION_MAJOR_SHIFT28
@@ -177,6 +184,12 @@
  #define   ECC_BCH_4BITBIT(2)
  #define   ECC_BCH_8BITBIT(3)
  
+#define nandc_set_readl(nandc, reg, offset, size, is_last)	\


Minor nit, readl makes one think it's 'read long'. If it isn't too
much effort, could you s/nandc_set_readl/nandc_set_read_loc ?


+nandc_set_reg(nandc, NAND_READ_LOCATION_##reg, \
+ ((offset) << READ_LOCATION_OFFSET) |\
+ ((size) << READ_LOCATION_SIZE) |\
+ ((is_last) << READ_LOCATION_LAST))
+
  #define QPIC_PER_CW_CMD_SGL   32
  #define QPIC_PER_CW_DATA_SGL  8
  
@@ -260,6 +273,11 @@ struct nandc_regs {

__le32 orig_vld;
  
  	__le32 ecc_buf_cfg;

+   __le32 read_location0;
+   __le32 read_location1;
+   __le32 read_location2;
+   __le32 read_location3;
+
  };
  
  /*

@@ -516,6 +534,14 @@ static __le32 *offset_to_nandc_reg(struct nandc_regs 
*regs, int offset)
return ®s->orig_vld;
case NAND_EBI2_ECC_BUF_CFG:
return ®s->ecc_buf_cfg;
+   case NAND_READ_LOCATION_0:
+   return ®s->read_location0;
+   case NAND_READ_LOCATION_1:
+   return ®s->read_location1;
+   case NAND_READ_LOCATION_2:
+   return ®s->read_location2;
+   case NAND_READ_LOCATION_3:
+   return ®s->read_location3;
default:
return NULL;
}
@@ -590,6 +616,10 @@ static void update_rw_regs(struct qcom_nand_host *host, 
int num_cw, bool read)
nandc_set_reg(nandc, NAND_FLASH_STATUS, host->clrflashstatus);
nandc_set_reg(nandc, NAND_READ_STATUS, host->clrreadstatus);
nandc_set_reg(nandc, NAND_EXEC_CMD, 1);
+
+   if (read)
+   nandc_set_readl(nandc, 0, 0, host->use_ecc ?
+   host->cw_data : host->cw_size, 1);
  }
  
  /*

@@ -835,6 +865,10 @@ static void config_nand_page_read(struct 
qcom_nand_controller *nandc)
   */
  static void config_nand_cw_read(struct qcom_nand_controller *nandc)
  {
+   if (nandc->props->is_bam)
+   write_reg_dma(nandc, NAND_READ_LOCATION_0, 4,
+ NAND_BAM_NEXT_SGL);
+
write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
  
@@ -923,6 +957,7 @@ static int nandc_param(struct qcom_nand_host *host)
  
  	nandc_set_reg(nandc, NAND_DEV_CMD1_RESTORE, nandc->cmd1);

nandc_set_reg(nandc, NAND_DEV_CMD_VLD_RESTORE, nandc->vld);
+   nandc_set_readl(nandc, 0, 0, 512, 1);
  
  	write_reg_dma(nandc, NAND_DEV_CMD_VLD, 1, 0);

write_reg_dma(nandc, NAND_DEV_CMD1, 1, NAND_BAM_NEXT_SGL);
@@ -1398,6 +1433,19 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 
*data_buf,
oob_size = host->ecc_bytes_hw + host->spare_bytes;
}

[PATCH v3 06/14] [media] cxd2880: Add integration layer for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

These functions monitor the driver and watch for task completion.
This is part of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
  -changed cxd2880_atomic_read to atomic_read
  -changed cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if() 
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../media/dvb-frontends/cxd2880/cxd2880_integ.c| 98 ++
 .../media/dvb-frontends/cxd2880/cxd2880_integ.h| 44 ++
 2 files changed, 142 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
new file mode 100644
index ..d4516df49210
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
@@ -0,0 +1,98 @@
+/*
+ * cxd2880_integ.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * integration layer common functions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "cxd2880_tnrdmd.h"
+#include "cxd2880_tnrdmd_mon.h"
+#include "cxd2880_integ.h"
+
+int cxd2880_integ_init(struct cxd2880_tnrdmd *tnr_dmd)
+{
+   int ret = 0;
+   struct cxd2880_stopwatch timer;
+   unsigned int elapsed_time = 0;
+   u8 cpu_task_completed = 0;
+
+   if (!tnr_dmd)
+   return -EINVAL;
+
+   ret = cxd2880_tnrdmd_init1(tnr_dmd);
+   if (ret)
+   return ret;
+
+   ret = cxd2880_stopwatch_start(&timer);
+   if (ret)
+   return ret;
+
+   while (1) {
+   ret = cxd2880_stopwatch_elapsed(&timer, &elapsed_time);
+   if (ret)
+   return ret;
+
+   ret =
+   cxd2880_tnrdmd_check_internal_cpu_status(tnr_dmd,
+&cpu_task_completed);
+   if (ret)
+   return ret;
+
+   if (cpu_task_completed)
+   break;
+
+   if (elapsed_time > CXD2880_TNRDMD_WAIT_INIT_TIMEOUT)
+   return -ETIME;
+   ret =
+   cxd2880_stopwatch_sleep(&timer,
+   CXD2880_TNRDMD_WAIT_INIT_INTVL);
+   if (ret)
+   return ret;
+   }
+
+   ret = cxd2880_tnrdmd_init2(tnr_dmd);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+int cxd2880_integ_cancel(struct cxd2880_tnrdmd *tnr_dmd)
+{
+   if (!tnr_dmd)
+   return -EINVAL;
+
+   atomic_set(&tnr_dmd->cancel, 1);
+
+   return 0;
+}
+
+int cxd2880_integ_check_cancellation(struct cxd2880_tnrdmd *tnr_dmd)
+{
+   if (!tnr_dmd)
+   return -EINVAL;
+
+   if (atomic_read(&tnr_dmd->cancel) != 0)
+   return -ECANCELED;
+
+   return 0;
+}
diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h
new file mode 100644
index ..2b4fe5c3743b
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h
@@ -0,0 +1,44 @@
+/*
+ * cxd2880_integ.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * integration layer common interface
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Gener

[PATCH v3 07/14] [media] cxd2880: Add top level of the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This provides the main dvb frontend operation functions
for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
  -adjusted indent spaces
  -modified debugging code
  -removed unnecessary cast
  -modified return code
  -modified coding style of if() 
  -modified about measurement period of PER/BER.
  -changed hexadecimal code to lower case. 

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/cxd2880/cxd2880_top.c | 1879 +
 1 file changed, 1879 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_top.c

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
new file mode 100644
index ..306966dd186b
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
@@ -0,0 +1,1879 @@
+/*
+ * cxd2880_top.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
+
+#include 
+
+#include "dvb_frontend.h"
+#include "dvb_math.h"
+
+#include "cxd2880.h"
+#include "cxd2880_tnrdmd_mon.h"
+#include "cxd2880_tnrdmd_dvbt2_mon.h"
+#include "cxd2880_tnrdmd_dvbt_mon.h"
+#include "cxd2880_integ_dvbt2.h"
+#include "cxd2880_integ_dvbt.h"
+#include "cxd2880_devio_spi.h"
+#include "cxd2880_spi_device.h"
+#include "cxd2880_tnrdmd_driver_version.h"
+
+struct cxd2880_priv {
+   struct cxd2880_tnrdmd tnrdmd;
+   struct spi_device *spi;
+   struct cxd2880_io regio;
+   struct cxd2880_spi_device spi_device;
+   struct cxd2880_spi cxd2880_spi;
+   struct cxd2880_dvbt_tune_param dvbt_tune_param;
+   struct cxd2880_dvbt2_tune_param dvbt2_tune_param;
+   struct mutex *spi_mutex; /* For SPI access exclusive control */
+   unsigned long pre_ber_update;
+   unsigned long pre_ber_interval;
+   unsigned long post_ber_update;
+   unsigned long post_ber_interval;
+   unsigned long ucblock_update;
+   unsigned long ucblock_interval;
+};
+
+static int cxd2880_pre_bit_err_t(
+   struct cxd2880_tnrdmd *tnrdmd, u32 *pre_bit_err,
+   u32 *pre_bit_count)
+{
+   u8 rdata[2];
+   int ret = 0;
+
+   if ((!tnrdmd) || (!pre_bit_err) || (!pre_bit_count))
+   return -EINVAL;
+
+   if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
+   return -EINVAL;
+
+   if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE)
+   return -EPERM;
+
+   if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT)
+   return -EPERM;
+
+   ret = slvt_freeze_reg(tnrdmd);
+   if (ret)
+   return ret;
+
+   ret = tnrdmd->io->write_reg(tnrdmd->io,
+   CXD2880_IO_TGT_DMD,
+   0x00, 0x10);
+   if (ret) {
+   slvt_unfreeze_reg(tnrdmd);
+   return ret;
+   }
+
+   ret = tnrdmd->io->read_regs(tnrdmd->io,
+   CXD2880_IO_TGT_DMD,
+   0x39, rdata, 1);
+   if (ret) {
+   slvt_unfreeze_reg(tnrdmd);
+   return ret;
+   }
+
+   if ((rdata[0] & 0x01) == 0) {
+   slvt_unfreeze_reg(tnrdmd);
+   return -EBUSY;
+   }
+
+   ret = tnrdmd->io->read_regs(tnrdmd->io,
+   CXD2880_IO_TGT_DMD,
+   0x22, rdata, 2);
+   if (ret) {
+   slvt_unfreeze_reg(tnrdmd);
+   return ret;
+   }
+
+   *pre

[PATCH v3 08/14] [media] cxd2880: Add DVB-T control functions the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Provide definitions, interfaces and functions needed for DVB-T
of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
  -no change
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h |   91 ++
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c| 1115 
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h|   62 ++
 3 files changed, 1268 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
new file mode 100644
index ..345c094760d2
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
@@ -0,0 +1,91 @@
+/*
+ * cxd2880_dvbt.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * DVB-T related definitions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#ifndef CXD2880_DVBT_H
+#define CXD2880_DVBT_H
+
+#include "cxd2880_common.h"
+
+enum cxd2880_dvbt_constellation {
+   CXD2880_DVBT_CONSTELLATION_QPSK,
+   CXD2880_DVBT_CONSTELLATION_16QAM,
+   CXD2880_DVBT_CONSTELLATION_64QAM,
+   CXD2880_DVBT_CONSTELLATION_RESERVED_3
+};
+
+enum cxd2880_dvbt_hierarchy {
+   CXD2880_DVBT_HIERARCHY_NON,
+   CXD2880_DVBT_HIERARCHY_1,
+   CXD2880_DVBT_HIERARCHY_2,
+   CXD2880_DVBT_HIERARCHY_4
+};
+
+enum cxd2880_dvbt_coderate {
+   CXD2880_DVBT_CODERATE_1_2,
+   CXD2880_DVBT_CODERATE_2_3,
+   CXD2880_DVBT_CODERATE_3_4,
+   CXD2880_DVBT_CODERATE_5_6,
+   CXD2880_DVBT_CODERATE_7_8,
+   CXD2880_DVBT_CODERATE_RESERVED_5,
+   CXD2880_DVBT_CODERATE_RESERVED_6,
+   CXD2880_DVBT_CODERATE_RESERVED_7
+};
+
+enum cxd2880_dvbt_guard {
+   CXD2880_DVBT_GUARD_1_32,
+   CXD2880_DVBT_GUARD_1_16,
+   CXD2880_DVBT_GUARD_1_8,
+   CXD2880_DVBT_GUARD_1_4
+};
+
+enum cxd2880_dvbt_mode {
+   CXD2880_DVBT_MODE_2K,
+   CXD2880_DVBT_MODE_8K,
+   CXD2880_DVBT_MODE_RESERVED_2,
+   CXD2880_DVBT_MODE_RESERVED_3
+};
+
+enum cxd2880_dvbt_profile {
+   CXD2880_DVBT_PROFILE_HP = 0,
+   CXD2880_DVBT_PROFILE_LP
+};
+
+struct cxd2880_dvbt_tpsinfo {
+   enum cxd2880_dvbt_constellation constellation;
+   enum cxd2880_dvbt_hierarchy hierarchy;
+   enum cxd2880_dvbt_coderate rate_hp;
+   enum cxd2880_dvbt_coderate rate_lp;
+   enum cxd2880_dvbt_guard guard;
+   enum cxd2880_dvbt_mode mode;
+   u8 fnum;
+   u8 length_indicator;
+   u16 cell_id;
+   u8 cell_id_ok;
+   u8 reserved_even;
+   u8 reserved_odd;
+};
+
+#endif
diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
new file mode 100644
index ..8a16cb359171
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
@@ -0,0 +1,1115 @@
+/*
+ * cxd2880_tnrdmd_dvbt.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * control functions for DVB-T
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General

[PATCH v3 09/14] [media] cxd2880: Add DVB-T monitor and integration layer functions

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Provide monitor and integration layer functions (DVB-T)
for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
  -changed CXD2880_SLEEP to usleep_range
  -chnaged cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if() 
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.c
  -removed unnecessary cast
  -changed cxd2880_math_log to intlog10
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../dvb-frontends/cxd2880/cxd2880_integ_dvbt.c |  198 
 .../dvb-frontends/cxd2880/cxd2880_integ_dvbt.h |   58 +
 .../cxd2880/cxd2880_tnrdmd_dvbt_mon.c  | 1227 
 .../cxd2880/cxd2880_tnrdmd_dvbt_mon.h  |  106 ++
 4 files changed, 1589 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.h
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.c
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
new file mode 100644
index ..729cb0939203
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
@@ -0,0 +1,198 @@
+/*
+ * cxd2880_integ_dvbt.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * integration layer functions for DVB-T
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "cxd2880_tnrdmd_dvbt.h"
+#include "cxd2880_integ_dvbt.h"
+
+static int dvbt_wait_demod_lock(struct cxd2880_tnrdmd *tnr_dmd);
+
+int cxd2880_integ_dvbt_tune(struct cxd2880_tnrdmd *tnr_dmd,
+   struct cxd2880_dvbt_tune_param
+   *tune_param)
+{
+   int ret = 0;
+
+   if ((!tnr_dmd) || (!tune_param))
+   return -EINVAL;
+
+   if (tnr_dmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
+   return -EINVAL;
+
+   if ((tnr_dmd->state != CXD2880_TNRDMD_STATE_SLEEP) &&
+   (tnr_dmd->state != CXD2880_TNRDMD_STATE_ACTIVE))
+   return -EPERM;
+
+   atomic_set(&tnr_dmd->cancel, 0);
+
+   if ((tune_param->bandwidth != CXD2880_DTV_BW_5_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_6_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_7_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_8_MHZ)) {
+   return -EOPNOTSUPP;
+   }
+
+   ret = cxd2880_tnrdmd_dvbt_tune1(tnr_dmd, tune_param);
+   if (ret)
+   return ret;
+
+   usleep_range(CXD2880_TNRDMD_WAIT_AGC_STABLE * 1,
+CXD2880_TNRDMD_WAIT_AGC_STABLE * 1 + 1000);
+
+   ret = cxd2880_tnrdmd_dvbt_tune2(tnr_dmd, tune_param);
+   if (ret)
+   return ret;
+
+   ret = dvbt_wait_demod_lock(tnr_dmd);
+   if (ret)
+   return ret;
+
+   return ret;
+}
+
+int cxd2880_integ_dvbt_wait_ts_lock(struct cxd2880_tnrdmd *tnr_dmd)
+{
+   int ret = 0;
+   enum cxd2880_tnrdmd_lock_result lock =
+   CXD2880_TNRDMD_LOCK_RESULT_NOTDETECT;
+   struct cxd2880_stopwatch timer;
+   u8 continue_wait = 1;
+   unsigned int elapsed = 0;
+
+   if (!tnr_dmd)
+   return -EINVAL;
+
+   if (tnr_dmd->

Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Byungchul Park
On Wed, Aug 16, 2017 at 12:05:31PM +0800, Boqun Feng wrote:
> On Wed, Aug 16, 2017 at 09:16:37AM +0900, Byungchul Park wrote:
> > On Tue, Aug 15, 2017 at 10:20:20AM +0200, Ingo Molnar wrote:
> > > 
> > > So with the latest fixes there's a new lockdep warning on one of my 
> > > testboxes:
> > > 
> > > [   11.322487] EXT4-fs (sda2): mounted filesystem with ordered data mode. 
> > > Opts: (null)
> > > 
> > > [   11.495661] ==
> > > [   11.502093] WARNING: possible circular locking dependency detected
> > > [   11.508507] 4.13.0-rc5-00497-g73135c58-dirty #1 Not tainted
> > > [   11.514313] --
> > > [   11.520725] umount/533 is trying to acquire lock:
> > > [   11.525657]  ((complete)&barr->done){+.+.}, at: [] 
> > > flush_work+0x213/0x2f0
> > > [   11.534411] 
> > >but task is already holding lock:
> > > [   11.540661]  (lock#3){+.+.}, at: [] 
> > > lru_add_drain_all_cpuslocked+0x3d/0x190
> > > [   11.549613] 
> > >which lock already depends on the new lock.
> > > 
> > > The full splat is below. The kernel config is nothing fancy - distro 
> > > derived, 
> > > pretty close to defconfig, with lockdep enabled.
> > 
> > I see...
> > 
> > Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be released
> > Task   B : acquired of cpu_hotplug_lock -> wait for lock#3 to be released
> > Task   C : acquired of lock#3 -> wait for completion of barr->done
> 
> >From the stack trace below, this barr->done is for flush_work() in
> lru_add_drain_all_cpuslocked(), i.e. for work "per_cpu(lru_add_drain_work)"
> 
> > Worker D : wait for wfc.work to be released -> will complete barr->done
> 
> and this barr->done is for work "wfc.work".

I think it can be the same instance. wait_for_completion() in flush_work()
e.g. at task C in my example, waits for completion which we expect to be
done by a worker e.g. worker D in my example.

I think the problem is caused by a write-acquisition of wfc.work in
process_one_work(). The acquisition of wfc.work should be reenterable,
that is, read-acquisition, shouldn't it?

I might be wrong... Please fix me if so.

Thank you,
Byungchul

> So those two barr->done could not be the same instance, IIUC. Therefore
> the deadlock case is not possible.
> 
> The problem here is all barr->done instances are initialized at
> insert_wq_barrier() and they belongs to the same lock class, to fix
> this, we need to differ barr->done with different lock classes based on
> the corresponding works.
> 
> How about the this(only compilation test):
> 
> ->8
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index e86733a8b344..d14067942088 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -2431,6 +2431,27 @@ struct wq_barrier {
>   struct task_struct  *task;  /* purely informational */
>  };
>  
> +#ifdef CONFIG_LOCKDEP_COMPLETE
> +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target) 
> \
> +do { 
> \
> + INIT_WORK_ONSTACK(&(barr)->work, func); 
> \
> + __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> \
> + lockdep_init_map_crosslock((struct lockdep_map *)&(barr)->done.map, 
> \
> +"(complete)" #barr,  
> \
> +(target)->lockdep_map.key, 1);   
> \
> + __init_completion(&barr->done); 
> \
> + barr->task = current;   
> \
> +} while (0)
> +#else
> +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target) 
> \
> +do { 
> \
> + INIT_WORK_ONSTACK(&(barr)->work, func); 
> \
> + __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> \
> + init_completion(&barr->done);   
> \
> + barr->task = current;   
> \
> +} while (0)
> +#endif
> +
>  static void wq_barrier_func(struct work_struct *work)
>  {
>   struct wq_barrier *barr = container_of(work, struct wq_barrier, work);
> @@ -2474,10 +2495,7 @@ static void insert_wq_barrier(struct pool_workqueue 
> *pwq,
>* checks and call back into the fixup functions where we
>* might deadlock.
>*/
> - INIT_WORK_ONSTACK(&barr->work, wq_barrier_func);
> - __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work));
> - init_completion(&barr->done);
> - barr->task = current;
> + INIT_WQ_BARRIER_ONSTACK(barr, wq_barrier_func, target);
>  
>   /*
>* If @target is currently being executed, schedule the


[PATCH v3 10/14] [media] cxd2880: Add DVB-T2 control functions for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Provide definitions, interfaces and functions needed for DVB-T2
of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../media/dvb-frontends/cxd2880/cxd2880_dvbt2.h|  402 ++
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c   | 1359 
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h   |   82 ++
 3 files changed, 1843 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
new file mode 100644
index ..674ed17deef5
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
@@ -0,0 +1,402 @@
+/*
+ * cxd2880_dvbt2.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * DVB-T2 related definitions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#ifndef CXD2880_DVBT2_H
+#define CXD2880_DVBT2_H
+
+#include "cxd2880_common.h"
+
+enum cxd2880_dvbt2_profile {
+   CXD2880_DVBT2_PROFILE_BASE,
+   CXD2880_DVBT2_PROFILE_LITE,
+   CXD2880_DVBT2_PROFILE_ANY
+};
+
+enum cxd2880_dvbt2_version {
+   CXD2880_DVBT2_V111,
+   CXD2880_DVBT2_V121,
+   CXD2880_DVBT2_V131
+};
+
+enum cxd2880_dvbt2_s1 {
+   CXD2880_DVBT2_S1_BASE_SISO = 0x00,
+   CXD2880_DVBT2_S1_BASE_MISO = 0x01,
+   CXD2880_DVBT2_S1_NON_DVBT2 = 0x02,
+   CXD2880_DVBT2_S1_LITE_SISO = 0x03,
+   CXD2880_DVBT2_S1_LITE_MISO = 0x04,
+   CXD2880_DVBT2_S1_RSVD3 = 0x05,
+   CXD2880_DVBT2_S1_RSVD4 = 0x06,
+   CXD2880_DVBT2_S1_RSVD5 = 0x07,
+   CXD2880_DVBT2_S1_UNKNOWN = 0xff
+};
+
+enum cxd2880_dvbt2_base_s2 {
+   CXD2880_DVBT2_BASE_S2_M2K_G_ANY = 0x00,
+   CXD2880_DVBT2_BASE_S2_M8K_G_DVBT = 0x01,
+   CXD2880_DVBT2_BASE_S2_M4K_G_ANY = 0x02,
+   CXD2880_DVBT2_BASE_S2_M1K_G_ANY = 0x03,
+   CXD2880_DVBT2_BASE_S2_M16K_G_ANY = 0x04,
+   CXD2880_DVBT2_BASE_S2_M32K_G_DVBT = 0x05,
+   CXD2880_DVBT2_BASE_S2_M8K_G_DVBT2 = 0x06,
+   CXD2880_DVBT2_BASE_S2_M32K_G_DVBT2 = 0x07,
+   CXD2880_DVBT2_BASE_S2_UNKNOWN = 0xff
+};
+
+enum cxd2880_dvbt2_lite_s2 {
+   CXD2880_DVBT2_LITE_S2_M2K_G_ANY = 0x00,
+   CXD2880_DVBT2_LITE_S2_M8K_G_DVBT = 0x01,
+   CXD2880_DVBT2_LITE_S2_M4K_G_ANY = 0x02,
+   CXD2880_DVBT2_LITE_S2_M16K_G_DVBT2 = 0x03,
+   CXD2880_DVBT2_LITE_S2_M16K_G_DVBT = 0x04,
+   CXD2880_DVBT2_LITE_S2_RSVD1 = 0x05,
+   CXD2880_DVBT2_LITE_S2_M8K_G_DVBT2 = 0x06,
+   CXD2880_DVBT2_LITE_S2_RSVD2 = 0x07,
+   CXD2880_DVBT2_LITE_S2_UNKNOWN = 0xff
+};
+
+enum cxd2880_dvbt2_guard {
+   CXD2880_DVBT2_G1_32 = 0x00,
+   CXD2880_DVBT2_G1_16 = 0x01,
+   CXD2880_DVBT2_G1_8 = 0x02,
+   CXD2880_DVBT2_G1_4 = 0x03,
+   CXD2880_DVBT2_G1_128 = 0x04,
+   CXD2880_DVBT2_G19_128 = 0x05,
+   CXD2880_DVBT2_G19_256 = 0x06,
+   CXD2880_DVBT2_G_RSVD1 = 0x07,
+   CXD2880_DVBT2_G_UNKNOWN = 0xff
+};
+
+enum cxd2880_dvbt2_mode {
+   CXD2880_DVBT2_M2K = 0x00,
+   CXD2880_DVBT2_M8K = 0x01,
+   CXD2880_DVBT2_M4K = 0x02,
+   CXD2880_DVBT2_M1K = 0x03,
+   CXD2880

[PATCH v3 11/14] [media] cxd2880: Add DVB-T2 monitor and integration layer functions

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Provide monitor and integration layer functions (DVB-T2)
for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
  -changed CXD2880_SLEEP to usleep_range
  -replaced cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if()  
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.c
  -removed unnecessary cast
  -changed cxd2880_math_log to intlog10
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c|  312 +++
 .../dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h|   64 +
 .../cxd2880/cxd2880_tnrdmd_dvbt2_mon.c | 2622 
 .../cxd2880/cxd2880_tnrdmd_dvbt2_mon.h |  170 ++
 4 files changed, 3168 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.c
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
new file mode 100644
index ..ac049820d797
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
@@ -0,0 +1,312 @@
+/*
+ * cxd2880_integ_dvbt2.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * integration layer functions for DVB-T2
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "cxd2880_tnrdmd_dvbt2.h"
+#include "cxd2880_tnrdmd_dvbt2_mon.h"
+#include "cxd2880_integ_dvbt2.h"
+
+static int dvbt2_wait_demod_lock(struct cxd2880_tnrdmd *tnr_dmd,
+enum cxd2880_dvbt2_profile
+profile);
+
+static int dvbt2_wait_l1_post_lock(struct cxd2880_tnrdmd *tnr_dmd);
+
+int cxd2880_integ_dvbt2_tune(struct cxd2880_tnrdmd *tnr_dmd,
+struct cxd2880_dvbt2_tune_param
+*tune_param)
+{
+   int ret = 0;
+
+   if ((!tnr_dmd) || (!tune_param))
+   return -EINVAL;
+
+   if (tnr_dmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
+   return -EINVAL;
+
+   if ((tnr_dmd->state != CXD2880_TNRDMD_STATE_SLEEP) &&
+   (tnr_dmd->state != CXD2880_TNRDMD_STATE_ACTIVE))
+   return -EPERM;
+
+   atomic_set(&tnr_dmd->cancel, 0);
+
+   if ((tune_param->bandwidth != CXD2880_DTV_BW_1_7_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_5_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_6_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_7_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_8_MHZ)) {
+   return -EOPNOTSUPP;
+   }
+
+   if ((tune_param->profile != CXD2880_DVBT2_PROFILE_BASE) &&
+   (tune_param->profile != CXD2880_DVBT2_PROFILE_LITE))
+   return -EINVAL;
+
+   ret = cxd2880_tnrdmd_dvbt2_tune1(tnr_dmd, tune_param);
+   if (ret)
+   return ret;
+
+   usleep_range(CXD2880_TNRDMD_WAIT_AGC_STABLE * 1,
+CXD2880_TNRDMD_WAIT_AGC_STABLE * 1 + 1000);
+
+   ret = cxd28

[PATCH v3 12/14] [media] cxd2880: Add all Makefile files for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the Makefile files of driver
for the Sony CXD2880 DVB-T2/T tuner + demodulator.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/Makefile
  -no change
   drivers/media/dvb-frontends/cxd2880/Makefile
  -removed cxd2880_math.o \ 
   drivers/media/spi/Makefile
  -no change

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/Makefile |  1 +
 drivers/media/dvb-frontends/cxd2880/Makefile | 20 
 drivers/media/spi/Makefile   |  5 +
 3 files changed, 26 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/Makefile

diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index 3fccaf34ef52..d298c7954699 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -126,3 +126,4 @@ obj-$(CONFIG_DVB_HORUS3A) += horus3a.o
 obj-$(CONFIG_DVB_ASCOT2E) += ascot2e.o
 obj-$(CONFIG_DVB_HELENE) += helene.o
 obj-$(CONFIG_DVB_ZD1301_DEMOD) += zd1301_demod.o
+obj-$(CONFIG_DVB_CXD2880) += cxd2880/
diff --git a/drivers/media/dvb-frontends/cxd2880/Makefile 
b/drivers/media/dvb-frontends/cxd2880/Makefile
new file mode 100644
index ..ee7758b28a05
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/Makefile
@@ -0,0 +1,20 @@
+cxd2880-objs := cxd2880_common.o \
+   cxd2880_devio_spi.o \
+   cxd2880_integ.o \
+   cxd2880_integ_dvbt2.o \
+   cxd2880_integ_dvbt.o \
+   cxd2880_io.o \
+   cxd2880_spi_device.o \
+   cxd2880_stopwatch_port.o \
+   cxd2880_tnrdmd.o \
+   cxd2880_tnrdmd_dvbt2.o \
+   cxd2880_tnrdmd_dvbt2_mon.o \
+   cxd2880_tnrdmd_dvbt.o \
+   cxd2880_tnrdmd_dvbt_mon.o\
+   cxd2880_tnrdmd_mon.o\
+   cxd2880_top.o
+
+obj-$(CONFIG_DVB_CXD2880) += cxd2880.o
+
+ccflags-y += -Idrivers/media/dvb-core
+ccflags-y += -Idrivers/media/dvb-frontends
diff --git a/drivers/media/spi/Makefile b/drivers/media/spi/Makefile
index ea64013d16cc..40e0f88d9f6c 100644
--- a/drivers/media/spi/Makefile
+++ b/drivers/media/spi/Makefile
@@ -1 +1,6 @@
 obj-$(CONFIG_VIDEO_GS1662) += gs1662.o
+obj-$(CONFIG_CXD2880_SPI_DRV) += cxd2880-spi.o
+
+ccflags-y += -Idrivers/media/dvb-core
+ccflags-y += -Idrivers/media/dvb-frontends
+ccflags-y += -Idrivers/media/dvb-frontends/cxd2880
\ No newline at end of file
-- 
2.13.0



[PATCH v3 13/14] [media] cxd2880: Add all Kconfig files for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the Kconfig files of driver for
the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/Kconfig
  -no change
   drivers/media/dvb-frontends/cxd2880/Kconfig
  -no change
   drivers/media/spi/Kconfig
  -no change

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/Kconfig |  2 ++
 drivers/media/dvb-frontends/cxd2880/Kconfig |  6 ++
 drivers/media/spi/Kconfig   | 14 ++
 3 files changed, 22 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/Kconfig

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 3a260b82b3e8..6831f4a49c18 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -519,6 +519,8 @@ config DVB_GP8PSK_FE
depends on DVB_CORE
default DVB_USB_GP8PSK
 
+source "drivers/media/dvb-frontends/cxd2880/Kconfig"
+
 comment "DVB-C (cable) frontends"
depends on DVB_CORE
 
diff --git a/drivers/media/dvb-frontends/cxd2880/Kconfig 
b/drivers/media/dvb-frontends/cxd2880/Kconfig
new file mode 100644
index ..36b8b6f7c4f7
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/Kconfig
@@ -0,0 +1,6 @@
+config DVB_CXD2880
+   tristate "Sony CXD2880 DVB-T2/T tuner + demodulator"
+   depends on DVB_CORE && SPI
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Say Y when you want to support this frontend.
\ No newline at end of file
diff --git a/drivers/media/spi/Kconfig b/drivers/media/spi/Kconfig
index a21f5a39a440..b07ac86fc53c 100644
--- a/drivers/media/spi/Kconfig
+++ b/drivers/media/spi/Kconfig
@@ -12,3 +12,17 @@ config VIDEO_GS1662
 endmenu
 
 endif
+
+if SPI
+menu "Media SPI Adapters"
+
+config CXD2880_SPI_DRV
+   tristate "Sony CXD2880 SPI support"
+   depends on DVB_CORE && SPI
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Choose if you would like to have SPI interface support for Sony 
CXD2880.
+
+endmenu
+
+endif
-- 
2.13.0



Re: [PATCH] ioctl_tty.2: add TIOCGPTPEER documentation

2017-08-15 Thread Aleksa Sarai

I've applied this patch, and then tweaked the wording a little. Could
you please check the following text:

TIOCGPTPEERint flags
   (since Linux 4.13) Given  a  file  descriptor  in  fd  that
   refers  to  a  pseudoterminal  master, open (with the given
   open(2)-style flags) and return a new file descriptor  that
   refers to the peer pseudoterminal slave device.  This oper‐
   ation can be performed regardless of whether  the  pathname
   of  the  slave  device  is  accessible  through the calling
   process's mount namespaces.

   Security-conscious programs interacting with namespaces may
   wish  to  use  this  operation rather than open(2) with the
   pathname returned by ptsname(3), and similar library  func‐
   tions that have insecure APIs.


Yup, that sounds good.


I also have a question on the last sentence: what are the "similar library
functions that have insecure APIs"? It's not clear to me what you are
referring to here.


There are a few posix_-style functions provided by glibc that are just 
wrappers around the open+ptsname combo that I mention earlier in the 
sentence (and thus are vulnerable to the same issue). But if you feel 
it's confusing you can feel free to drop it.


Thanks.

--
Aleksa Sarai
Software Engineer (Containers)
SUSE Linux GmbH
https://www.cyphar.com/


[PATCH v3 14/14] [media] cxd2880 : Update MAINTAINERS file for CXD2880 driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is MAINTAINERS file update about the driver for
the Sony CXD2880 DVB-T2/T tuner + demodulator.

[Change list]
Changes in V3
   MAINTAINERS
  -no change

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 MAINTAINERS | 9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6f7721d1634c..12a80c33c194 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8302,6 +8302,15 @@ T:   git git://linuxtv.org/media_tree.git
 S: Supported
 F: drivers/media/dvb-frontends/cxd2841er*
 
+MEDIA DRIVERS FOR CXD2880
+M: Yasunari Takiguchi 
+L: linux-me...@vger.kernel.org
+W: http://linuxtv.org/
+T: git git://linuxtv.org/media_tree.git
+S: Supported
+F: drivers/media/dvb-frontends/cxd2880/*
+F: drivers/media/spi/cxd2880*
+
 MEDIA DRIVERS FOR FREESCALE IMX
 M: Steve Longerbeam 
 M: Philipp Zabel 
-- 
2.13.0



Re: [PATCH v4 10/20] mtd: nand: qcom: erased codeword detection configuration

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

The NAND controller returns ECC failure during read of completely
erased codeword. The NAND controller has hardware functionality
to detect erased codeword in case of BCH ECC algorithm. The
NAND_ERASED_CW_DETECT_CFG register controls the erased
codeword/page detection controller. This register should be reset
before every page read by setting and clearing bit 0 of
NAND_ERASED_CW_DETECT_CFG.


Reviewed-by: Archit Taneja 

Thanks,
Archit



Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 21 +
  1 file changed, 21 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index b452cfb..3d9fd7f 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -200,6 +200,11 @@
  #define NAND_BAM_NWD  BIT(1)
  /* Finish writing in the current sgl and start writing in another sgl */
  #define NAND_BAM_NEXT_SGL BIT(2)
+/*
+ * Erased codeword status is being used two times in single transfer so this
+ * flag will determine the current value of erased codeword status register
+ */
+#define NAND_ERASED_CW_SET BIT(4)
  
  /*

   * This data type corresponds to the BAM transaction which will be used for 
all
@@ -278,6 +283,8 @@ struct nandc_regs {
__le32 read_location2;
__le32 read_location3;
  
+	__le32 erased_cw_detect_cfg_clr;

+   __le32 erased_cw_detect_cfg_set;
  };
  
  /*

@@ -805,6 +812,13 @@ static int write_reg_dma(struct qcom_nand_controller 
*nandc, int first,
if (first == NAND_FLASH_CMD)
flow_control = true;
  
+	if (first == NAND_ERASED_CW_DETECT_CFG) {

+   if (flags & NAND_ERASED_CW_SET)
+   vaddr = ®s->erased_cw_detect_cfg_set;
+   else
+   vaddr = ®s->erased_cw_detect_cfg_clr;
+   }
+
if (first == NAND_EXEC_CMD)
flags |= NAND_BAM_NWD;
  
@@ -857,6 +871,9 @@ static void config_nand_page_read(struct qcom_nand_controller *nandc)

write_reg_dma(nandc, NAND_ADDR0, 2, 0);
write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0);
write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, 0);
+   write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1, 0);
+   write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1,
+ NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL);
  }
  
  /*

@@ -2258,6 +2275,10 @@ static int qcom_nand_host_setup(struct qcom_nand_host 
*host)
  
  	host->clrflashstatus = FS_READY_BSY_N;

host->clrreadstatus = 0xc0;
+   nandc->regs->erased_cw_detect_cfg_clr =
+   cpu_to_le32(CLR_ERASED_PAGE_DET);
+   nandc->regs->erased_cw_detect_cfg_set =
+   cpu_to_le32(SET_ERASED_PAGE_DET);
  
  	dev_dbg(nandc->dev,

"cfg0 %x cfg1 %x ecc_buf_cfg %x ecc_bch cfg %x cw_size %d cw_data %d 
strength %d parity_bytes %d steps %d\n",



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


linux-next: build failure after merge of the akpm-current tree

2017-08-15 Thread Stephen Rothwell
Hi all,

After merging the akpm-current tree, today's linux-next build (x86_64
allmodconfig) failed like this:

drivers/gpu/drm/i915/i915_gem_execbuffer.c: In function 'get_fence_array':
drivers/gpu/drm/i915/i915_gem_execbuffer.c:2163:20: error: 'GFP_TEMPORARY' 
undeclared (first use in this function)
 __GFP_NOWARN | GFP_TEMPORARY);
^

Caused by commit

  4d6fc0a48c52 ("mm: treewide: remove GFP_TEMPORARY allocation flag")

interacting with commit

  cf6e7bac6357 ("drm/i915: Add support for drm syncobjs")

from the drm-intel tree.

I applied the following merge fix patch (and I suspect - given the
comments in the former commit message - that this could be applied to
the drm-intel tree right now without any problems):

From: Stephen Rothwell 
Date: Wed, 16 Aug 2017 14:41:24 +1000
Subject: [PATCH] drm/i915: fix up for mm: treewide: remove GFP_TEMPORARY 
allocation flag

Signed-off-by: Stephen Rothwell 
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 8fbdefe0216e..15ab3e6792f9 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -2160,7 +2160,7 @@ get_fence_array(struct drm_i915_gem_execbuffer2 *args,
return ERR_PTR(-EFAULT);
 
fences = kvmalloc_array(args->num_cliprects, sizeof(*fences),
-   __GFP_NOWARN | GFP_TEMPORARY);
+   __GFP_NOWARN | GFP_KERNEL);
if (!fences)
return ERR_PTR(-ENOMEM);
 
-- 
2.13.2

-- 
Cheers,
Stephen Rothwell


Re: [PATCH v1 2/6] fs: use on-stack-bio if backing device has BDI_CAP_SYNC capability

2017-08-15 Thread Minchan Kim
Hi Jens,

On Mon, Aug 14, 2017 at 10:17:09AM -0600, Jens Axboe wrote:
> On 08/14/2017 09:38 AM, Jens Axboe wrote:
> > On 08/14/2017 09:31 AM, Minchan Kim wrote:
> >>> Secondly, generally you don't have slow devices and fast devices
> >>> intermingled when running workloads. That's the rare case.
> >>
> >> Not true. zRam is really popular swap for embedded devices where
> >> one of low cost product has a really poor slow nand compared to
> >> lz4/lzo [de]comression.
> > 
> > I guess that's true for some cases. But as I said earlier, the recycling
> > really doesn't care about this at all. They can happily coexist, and not
> > step on each others toes.
> 
> Dusted it off, result is here against -rc5:
> 
> http://git.kernel.dk/cgit/linux-block/log/?h=cpu-alloc-cache
> 
> I'd like to split the amount of units we cache and the amount of units
> we free, right now they are both CPU_ALLOC_CACHE_SIZE. This means that
> once we hit that count, we free all of the, and then store the one we
> were asked to free. That always keeps 1 local, but maybe it'd make more
> sense to cache just free CPU_ALLOC_CACHE_SIZE/2 (or something like that)
> so that we retain more than 1 per cpu in case and app preempts when
> sleeping for IO and the new task on that CPU then issues IO as well.
> Probably minor.
> 
> Ran a quick test on nullb0 with 32 sync readers. The test was O_DIRECT
> on the block device, so I disabled the __blkdev_direct_IO_simple()
> bypass. With the above branch, we get ~18.0M IOPS, and without we get
> ~14M IOPS. Both ran with iostats disabled, to avoid any interference
> from that.

Looks promising.
If recycling bio works well enough, I think we don't need to introduce
new split in the path for on-stack bio.
I will test your version on zram-swap!

Thanks.


[PATCH] sg: recheck MMAP_IO request length with lock held

2017-08-15 Thread Todd Poynor
Commit 1bc0eb044615 ("scsi: sg: protect accesses to 'reserved' page
array") adds needed concurrency protection for the "reserve" buffer.
Some checks that are initially made outside the lock are replicated once
the lock is taken to ensure the checks and resulting decisions are made
using consistent state.

The check that a request with flag SG_FLAG_MMAP_IO set fits in the
reserve buffer also needs to be performed again under the lock to
ensure the reserve buffer length compared against matches the value in
effect when the request is linked to the reserve buffer.  An -ENOMEM
should be returned in this case, instead of switching over to an
indirect buffer as for non-MMAP_IO requests.

Signed-off-by: Todd Poynor 
---
 drivers/scsi/sg.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index d7ff71e0c85c..3a44b4bc872b 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1735,9 +1735,12 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
!sfp->res_in_use) {
sfp->res_in_use = 1;
sg_link_reserve(sfp, srp, dxfer_len);
-   } else if ((hp->flags & SG_FLAG_MMAP_IO) && sfp->res_in_use) {
+   } else if (hp->flags & SG_FLAG_MMAP_IO) {
+   res = -EBUSY; /* sfp->res_in_use == 1 */
+   if (dxfer_len > rsv_schp->bufflen)
+   res = -ENOMEM;
mutex_unlock(&sfp->f_mutex);
-   return -EBUSY;
+   return res;
} else {
res = sg_build_indirect(req_schp, sfp, dxfer_len);
if (res) {
-- 
2.14.1.480.gb18f417b89-goog



Re: [PATCH v4 11/20] mtd: nand: qcom: enable BAM or ADM mode

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

1. DM_EN is only required for EBI2 NAND controller which uses ADM
2. BAM mode will be disabled after power on reset which needs to
be enabled before starting any BAM transfers.

Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 17 ++---
  1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index 3d9fd7f..ae873d3 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -163,6 +163,9 @@
  #define NAND_DEV_CMD_VLD_VAL  (READ_START_VLD | WRITE_START_VLD | \
 ERASE_START_VLD | SEQ_READ_START_VLD)
  
+/* NAND_CTRL bits */

+#defineBAM_MODE_EN BIT(0)
+
  /*
   * the NAND controller performs reads/writes with ECC in 516 byte chunks.
   * the driver calls the chunks 'step' or 'codeword' interchangeably
@@ -1035,7 +1038,8 @@ static int read_id(struct qcom_nand_host *host, int 
column)
nandc_set_reg(nandc, NAND_FLASH_CMD, FETCH_ID);
nandc_set_reg(nandc, NAND_ADDR0, column);
nandc_set_reg(nandc, NAND_ADDR1, 0);
-   nandc_set_reg(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
+   nandc_set_reg(nandc, NAND_FLASH_CHIP_SELECT,
+ nandc->props->is_bam ? 0 : DM_EN);


I'm not sure why the above register was configured in read_id in the first 
place. Would
it be required later if we want the controller to support multiple NAND chips? 
If not,
then we could consider dropping this. Anyway, that can be posted as a separate 
patch
later.

Reviewed-by: Archit Taneja 

Thanks,
Archit


nandc_set_reg(nandc, NAND_EXEC_CMD, 1);
  
  	write_reg_dma(nandc, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL);

@@ -2408,12 +2412,19 @@ static void qcom_nandc_unalloc(struct 
qcom_nand_controller *nandc)
  /* one time setup of a few nand controller registers */
  static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
  {
+   u32 nand_ctrl;
+
/* kill onenand */
nandc_write(nandc, SFLASHC_BURST_CFG, 0);
nandc_write(nandc, NAND_DEV_CMD_VLD, NAND_DEV_CMD_VLD_VAL);
  
-	/* enable ADM DMA */

-   nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
+   /* enable ADM or BAM DMA */
+   if (nandc->props->is_bam) {
+   nand_ctrl = nandc_read(nandc, NAND_CTRL);
+   nandc_write(nandc, NAND_CTRL, nand_ctrl | BAM_MODE_EN);
+   } else {
+   nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
+   }
  
  	/* save the original values of these registers */

nandc->cmd1 = nandc_read(nandc, NAND_DEV_CMD1);



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v2] zsmalloc: zs_page_migrate: schedule free_work if zspage is ZS_EMPTY

2017-08-15 Thread Minchan Kim
On Wed, Aug 16, 2017 at 10:49:14AM +0800, Hui Zhu wrote:
> Hi Minchan,
> 
> 2017-08-16 10:13 GMT+08:00 Minchan Kim :
> > Hi Hui,
> >
> > On Mon, Aug 14, 2017 at 05:56:30PM +0800, Hui Zhu wrote:
> >> After commit e2846124f9a2 ("zsmalloc: zs_page_migrate: skip unnecessary
> >
> > This patch is not merged yet so the hash is invalid.
> > That means we may fold this patch to [1] in current mmotm.
> >
> > [1] 
> > zsmalloc-zs_page_migrate-skip-unnecessary-loops-but-not-return-ebusy-if-zspage-is-not-inuse-fix.patch
> >
> >> loops but not return -EBUSY if zspage is not inuse") zs_page_migrate
> >> can handle the ZS_EMPTY zspage.
> >>
> >> But I got some false in zs_page_isolate:
> >>   if (get_zspage_inuse(zspage) == 0) {
> >>   spin_unlock(&class->lock);
> >>   return false;
> >>   }
> >
> > I also realized we should make zs_page_isolate succeed on empty zspage
> > because we allow the empty zspage migration from now on.
> > Could you send a patch for that as well?
> 
> OK.  I will make a patch for that later.

Please send the patch so I want to fold it to [1] before Andrew is going
to send [1] to Linus.

Thanks.


[PATCH v2 4/5] mtd: spi-nor: cadence-quadspi: Add support to enable loop-back clock circuit

2017-08-15 Thread Vignesh R
Cadence QSPI IP has a adapted loop-back circuit which can be enabled by
setting BYPASS field to 0 in READCAPTURE register. It enables use of
QSPI return clock to latch the data rather than the internal QSPI
reference clock. For high speed operations, adapted loop-back circuit
using QSPI return clock helps to increase data valid window.

Based on DT parameter cdns,rclk-en enable adapted loop-back circuit
for boards which do have QSPI return clock provided.
This patch also modifies cqspi_readdata_capture() function's bypass
parameter to bool to match how its used in the function.

Signed-off-by: Vignesh R 
---

v2:
Split doc update to separate patch

 drivers/mtd/spi-nor/cadence-quadspi.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index bb0cb02a6938..c11ced529ddd 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -78,6 +78,7 @@ struct cqspi_st {
boolis_decoded_cs;
u32 fifo_depth;
u32 fifo_width;
+   boolrclk_en;
u32 trigger_address;
u32 wr_delay;
struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
@@ -788,7 +789,7 @@ static void cqspi_config_baudrate_div(struct cqspi_st 
*cqspi)
 }
 
 static void cqspi_readdata_capture(struct cqspi_st *cqspi,
-  const unsigned int bypass,
+  const bool bypass,
   const unsigned int delay)
 {
void __iomem *reg_base = cqspi->iobase;
@@ -852,7 +853,8 @@ static void cqspi_configure(struct spi_nor *nor)
cqspi->sclk = sclk;
cqspi_config_baudrate_div(cqspi);
cqspi_delay(nor);
-   cqspi_readdata_capture(cqspi, 1, f_pdata->read_delay);
+   cqspi_readdata_capture(cqspi, !cqspi->rclk_en,
+  f_pdata->read_delay);
}
 
if (switch_cs || switch_ck)
@@ -1049,6 +1051,8 @@ static int cqspi_of_get_pdata(struct platform_device 
*pdev)
return -ENXIO;
}
 
+   cqspi->rclk_en = of_property_read_bool(np, "cdns,rclk-en");
+
return 0;
 }
 
-- 
2.14.1



Re: [PATCH][RFC] PM / Hibernate: Feed NMI wathdog when creating snapshot

2017-08-15 Thread Chen Yu
On Tue, Aug 15, 2017 at 02:41:19PM +0200, Michal Hocko wrote:
> On Tue 15-08-17 01:19:16, Chen Yu wrote:
> [...]
> > @@ -2561,8 +2562,10 @@ void mark_free_pages(struct zone *zone)
> > unsigned long i;
> >  
> > pfn = page_to_pfn(page);
> > -   for (i = 0; i < (1UL << order); i++)
> > +   for (i = 0; i < (1UL << order); i++) {
> > swsusp_set_page_free(pfn_to_page(pfn + i));
> > +   touch_nmi_watchdog();
> > +   }
> 
> this is rather excessive. Why don't you simply call touch_nmi_watchdog
> once per every 1000 pages? Or once per free_list entry?
> 
> Moreover why don't you need to touch_nmi_watchdog in the loop over all
> pfns in the zone (right above this loop)?
> --
After re-checking the code, I think we can simply disable the watchdog
temporarily, thus to avoid feeding the watchdog in the loop.
I'm sending another version based on this.
Thanks,
Yu
> Michal Hocko
> SUSE Labs


[PATCH][RFC v2] PM / Hibernate: Disable wathdog when creating snapshot

2017-08-15 Thread Chen Yu
There is a problem that when counting the pages for creating
the hibernation snapshot will take significant amount of
time, especially on system with large memory. Since the counting
job is performed with irq disabled, this might lead to NMI lockup.
The following warning were found on a system with 1.5TB DRAM:

[ 1124.758184] Freezing user space processes ... (elapsed 0.002 seconds) done.
[ 1124.768721] OOM killer disabled.
[ 1124.847009] PM: Preallocating image memory...
[ 1139.392042] NMI watchdog: Watchdog detected hard LOCKUP on cpu 27
[ 1139.392076] CPU: 27 PID: 3128 Comm: systemd-sleep Not tainted 
4.13.0-0.rc2.git0.1.fc27.x86_64 #1
[ 1139.392077] task: 9f01971ac000 task.stack: b1a3f325c000
[ 1139.392083] RIP: 0010:memory_bm_find_bit+0xf4/0x100
[ 1139.392084] RSP: 0018:b1a3f325fc20 EFLAGS: 0006
[ 1139.392084] RAX:  RBX: 13b83000 RCX: 9fbe89caf000
[ 1139.392085] RDX: b1a3f325fc30 RSI: 3200 RDI: 9fbeae80
[ 1139.392085] RBP: b1a3f325fc40 R08: 13b8 R09: 9fbe89c54878
[ 1139.392085] R10: b1a3f325fc2c R11: 13b83200 R12: 0400
[ 1139.392086] R13: fd552e0c R14: 9fc1bffd31e0 R15: 0202
[ 1139.392086] FS:  7f3189704180() GS:9fbec8ec() 
knlGS:
[ 1139.392087] CS:  0010 DS:  ES:  CR0: 80050033
[ 1139.392087] CR2: 0085da0f7398 CR3: 01771cf9a000 CR4: 007406e0
[ 1139.392088] DR0:  DR1:  DR2: 
[ 1139.392088] DR3:  DR6: fffe0ff0 DR7: 0400
[ 1139.392088] PKRU: 5554
[ 1139.392089] Call Trace:
[ 1139.392092]  ? memory_bm_set_bit+0x29/0x60
[ 1139.392094]  swsusp_set_page_free+0x2b/0x30
[ 1139.392098]  mark_free_pages+0x147/0x1c0
[ 1139.392099]  count_data_pages+0x41/0xa0
[ 1139.392101]  hibernate_preallocate_memory+0x80/0x450
[ 1139.392102]  hibernation_snapshot+0x58/0x410
[ 1139.392103]  hibernate+0x17c/0x310
[ 1139.392104]  state_store+0xdf/0xf0
[ 1139.392107]  kobj_attr_store+0xf/0x20
[ 1139.392111]  sysfs_kf_write+0x37/0x40
[ 1139.392113]  kernfs_fop_write+0x11c/0x1a0
[ 1139.392117]  __vfs_write+0x37/0x170
[ 1139.392121]  ? handle_mm_fault+0xd8/0x230
[ 1139.392122]  vfs_write+0xb1/0x1a0
[ 1139.392123]  SyS_write+0x55/0xc0
[ 1139.392126]  entry_SYSCALL_64_fastpath+0x1a/0xa5

So avoid the NMI lockup by disabling the watchdog temporarily.

Reported-by: Jan Filipcewicz 
Cc: Andrew Morton 
Cc: Michal Hocko 
Cc: Mel Gorman 
Cc: Vlastimil Babka 
Cc: "Rafael J. Wysocki" 
Cc: Len Brown 
Cc: Dan Williams 
Cc: linux...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Chen Yu 
---
 v2: Change the 'feed' action by touch_nmi_watchdog()
 to 'disable' the watchdog by lockup_detector_suspend().
---
 mm/page_alloc.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6d00f74..adff934 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -66,6 +66,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2537,10 +2538,15 @@ void mark_free_pages(struct zone *zone)
unsigned long flags;
unsigned int order, t;
struct page *page;
+   bool wd_suspended;
 
if (zone_is_empty(zone))
return;
 
+   wd_suspended = lockup_detector_suspend() ? false : true;
+   if (!wd_suspended)
+   pr_warn_once("Failed to disable lockup detector during 
hibernation.\n");
+
spin_lock_irqsave(&zone->lock, flags);
 
max_zone_pfn = zone_end_pfn(zone);
@@ -2566,6 +2572,9 @@ void mark_free_pages(struct zone *zone)
}
}
spin_unlock_irqrestore(&zone->lock, flags);
+
+   if (wd_suspended)
+   lockup_detector_resume();
 }
 #endif /* CONFIG_PM */
 
-- 
2.7.4



[PATCH v2 5/5] mtd: spi-nor: cadence-quadspi: Add runtime PM support

2017-08-15 Thread Vignesh R
Add pm_runtime* calls to cadence-quadspi driver. This is required to
switch on QSPI power domain on TI 66AK2G SoC during probe.

Signed-off-by: Vignesh R 
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index c11ced529ddd..4fd6fb9c83b3 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1224,6 +1225,13 @@ static int cqspi_probe(struct platform_device *pdev)
return -ENXIO;
}
 
+   pm_runtime_enable(&pdev->dev);
+   ret = pm_runtime_get_sync(&pdev->dev);
+   if (ret < 0) {
+   pm_runtime_put_noidle(&pdev->dev);
+   return ret;
+   }
+
ret = clk_prepare_enable(cqspi->clk);
if (ret) {
dev_err(dev, "Cannot enable QSPI clock.\n");
@@ -1275,6 +1283,9 @@ static int cqspi_remove(struct platform_device *pdev)
 
clk_disable_unprepare(cqspi->clk);
 
+   pm_runtime_put_sync(&pdev->dev);
+   pm_runtime_disable(&pdev->dev);
+
return 0;
 }
 
-- 
2.14.1



[PATCH v2 3/5] mtd: spi-nor: cadence-quadspi: Add new binding to enable loop-back circuit

2017-08-15 Thread Vignesh R
Cadence QSPI IP has a adapted loop-back circuit which can be enabled by
setting BYPASS field to 0 in READCAPTURE register. It enables use of
QSPI return clock to latch the data rather than the internal QSPI
reference clock. For high speed operations, adapted loop-back circuit
using QSPI return clock helps to increase data valid window.

Add DT parameter cdns,rclk-en to help enable adapted loop-back circuit
for boards which do have QSPI return clock provided. Update binding
documentation for the same.

Signed-off-by: Vignesh R 
---
 Documentation/devicetree/bindings/mtd/cadence-quadspi.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
index 7dbe3bd9ac56..bb2075df9b38 100644
--- a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
@@ -16,6 +16,9 @@ Required properties:
 
 Optional properties:
 - cdns,is-decoded-cs : Flag to indicate whether decoder is used or not.
+- cdns,rclk-en : Flag to indicate that QSPI return clock is used to latch
+  the read data rather than the QSPI clock. Make sure that QSPI return
+  clock is populated on the board before using this property.
 
 Optional subnodes:
 Subnodes of the Cadence Quad SPI controller are spi slave nodes with additional
-- 
2.14.1



[PATCH v2 1/5] mtd: spi-nor: cadence-quadspi: Add TI 66AK2G SoC specific compatible

2017-08-15 Thread Vignesh R
Update binding documentation to add a new compatible for TI 66AK2G SoC,
to handle TI SoC specific quirks in the driver.

Signed-off-by: Vignesh R 
---
 Documentation/devicetree/bindings/mtd/cadence-quadspi.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
index f248056da24c..7dbe3bd9ac56 100644
--- a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
@@ -1,7 +1,9 @@
 * Cadence Quad SPI controller
 
 Required properties:
-- compatible : Should be "cdns,qspi-nor".
+- compatible : should be one of the following:
+   Generic default - "cdns,qspi-nor".
+   For TI 66AK2G SoC - "ti,k2g-qspi", "cdns,qspi-nor".
 - reg : Contains two entries, each of which is a tuple consisting of a
physical address and length. The first entry is the address and
length of the controller register set. The second entry is the
-- 
2.14.1



[PATCH v2 2/5] mtd: spi-nor: cadence-quadspi: add a delay in write sequence

2017-08-15 Thread Vignesh R
As per 66AK2G02 TRM[1] SPRUHY8F section 11.15.5.3 Indirect Access
Controller programming sequence, a delay equal to couple of QSPI master
clock(~5ns) is required after setting CQSPI_REG_INDIRECTWR_START bit and
writing data to the flash. Introduce a quirk flag CQSPI_NEEDS_WR_DELAY
to handle this and set this flag for TI 66AK2G SoC.

[1]http://www.ti.com/lit/ug/spruhy8f/spruhy8f.pdf

Signed-off-by: Vignesh R 
---
v2:
Split binding doc to separate patch
Use data pointer to indicate write delay.

 drivers/mtd/spi-nor/cadence-quadspi.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index 53c7d8e0327a..bb0cb02a6938 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -38,6 +38,9 @@
 #define CQSPI_NAME "cadence-qspi"
 #define CQSPI_MAX_CHIPSELECT   16
 
+/* Quirks */
+#define CQSPI_NEEDS_WR_DELAY   BIT(0)
+
 struct cqspi_st;
 
 struct cqspi_flash_pdata {
@@ -76,6 +79,7 @@ struct cqspi_st {
u32 fifo_depth;
u32 fifo_width;
u32 trigger_address;
+   u32 wr_delay;
struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
 };
 
@@ -608,6 +612,15 @@ static int cqspi_indirect_write_execute(struct spi_nor 
*nor,
reinit_completion(&cqspi->transfer_complete);
writel(CQSPI_REG_INDIRECTWR_START_MASK,
   reg_base + CQSPI_REG_INDIRECTWR);
+   /*
+* As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access
+* Controller programming sequence, couple of cycles of
+* QSPI_REF_CLK delay is required for the above bit to
+* be internally synchronized by the QSPI module. Provide 5
+* cycles of delay.
+*/
+   if (cqspi->wr_delay)
+   ndelay(cqspi->wr_delay);
 
while (remaining > 0) {
write_bytes = remaining > page_size ? page_size : remaining;
@@ -1156,6 +1169,7 @@ static int cqspi_probe(struct platform_device *pdev)
struct cqspi_st *cqspi;
struct resource *res;
struct resource *res_ahb;
+   u32 data;
int ret;
int irq;
 
@@ -1213,6 +1227,10 @@ static int cqspi_probe(struct platform_device *pdev)
}
 
cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk);
+   data  = (u32)of_device_get_match_data(&pdev->dev);
+   if (data & CQSPI_NEEDS_WR_DELAY)
+   cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC,
+  cqspi->master_ref_clk_hz);
 
ret = devm_request_irq(dev, irq, cqspi_irq_handler, 0,
   pdev->name, cqspi);
@@ -1284,7 +1302,14 @@ static const struct dev_pm_ops cqspi__dev_pm_ops = {
 #endif
 
 static const struct of_device_id cqspi_dt_ids[] = {
-   {.compatible = "cdns,qspi-nor",},
+   {
+   .compatible = "cdns,qspi-nor",
+   .data = (void *)0,
+   },
+   {
+   .compatible = "ti,k2g-qspi",
+   .data = (void *)CQSPI_NEEDS_WR_DELAY,
+   },
{ /* end of table */ }
 };
 
-- 
2.14.1



Re: [PATCH v7 2/9] mm, swap: Add infrastructure for saving page metadata on swap

2017-08-15 Thread David Miller
From: Khalid Aziz 
Date: Wed,  9 Aug 2017 15:25:55 -0600

> @@ -1399,6 +1399,12 @@ static bool try_to_unmap_one(struct page *page, struct 
> vm_area_struct *vma,
>   (flags & TTU_MIGRATION)) {
>   swp_entry_t entry;
>   pte_t swp_pte;
> +
> + if (arch_unmap_one(mm, vma, address, pteval) < 0) {
> + set_pte_at(mm, address, pvmw.pte, pteval);
> + ret = false;
> + page_vma_mapped_walk_done(&pvmw);
> + break;
>   /*
>* Store the pfn of the page in a special migration
>* pte. do_swap_page() will wait until the migration
> @@ -1410,6 +1416,7 @@ static bool try_to_unmap_one(struct page *page, struct 
> vm_area_struct *vma,
>   if (pte_soft_dirty(pteval))
>   swp_pte = pte_swp_mksoft_dirty(swp_pte);
>   set_pte_at(mm, address, pvmw.pte, swp_pte);
> + }

This basic block doesn't look right.  I think the new closing brace is
intended to be right after the new break; statement.  If not at the
very least the indentation of the existing code in there needs to be
adjusted.



[PATCH v2 0/5] K2G: Add QSPI support

2017-08-15 Thread Vignesh R
This series adds support for Cadence QSPI IP present in TI's 66AK2G SoC.
The patches enhance the existing cadence-quadspi driver to support
loopback clock circuit, pm_runtime support and tweaks for 66AK2G SoC.


Changes in v2:
* Drop DT patches. Will be sent as separate series as requested by
 maintainer.
* Split binding docs into separate patches.
* Address comments by Rob Herring.

Vignesh R (5):
  mtd: spi-nor: cadence-quadspi: Add TI 66AK2G SoC specific compatible
  mtd: spi-nor: cadence-quadspi: add a delay in write sequence
  mtd: spi-nor: cadence-quadspi: Add new binding to enable loop-back
circuit
  mtd: spi-nor: cadence-quadspi: Add support to enable loop-back clock
circuit
  mtd: spi-nor: cadence-quadspi: Add runtime PM support

 .../devicetree/bindings/mtd/cadence-quadspi.txt|  7 +++-
 drivers/mtd/spi-nor/cadence-quadspi.c  | 46 --
 2 files changed, 49 insertions(+), 4 deletions(-)

-- 
2.14.1



[PATCH] PNP: ide: constify pnp_device_id

2017-08-15 Thread Arvind Yadav
pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by  work with
const pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/ide/ide-pnp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index f5f2b62..859ddab 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -22,7 +22,7 @@
 #define DRV_NAME "ide-pnp"
 
 /* Add your devices here :)) */
-static struct pnp_device_id idepnp_devices[] = {
+static const struct pnp_device_id idepnp_devices[] = {
/* Generic ESDI/IDE/ATA compatible hard disk controller */
{.id = "PNP0600", .driver_data = 0},
{.id = ""}
-- 
2.7.4



  1   2   3   4   5   6   7   8   9   >