Re: [RFC][PATCH 00/16] sched: Core scheduling

2019-02-26 Thread Aubrey Li
On Tue, Feb 26, 2019 at 4:26 PM Aubrey Li  wrote:
>
> On Sat, Feb 23, 2019 at 3:27 AM Tim Chen  wrote:
> >
> > On 2/22/19 6:20 AM, Peter Zijlstra wrote:
> > > On Fri, Feb 22, 2019 at 01:17:01PM +0100, Paolo Bonzini wrote:
> > >> On 18/02/19 21:40, Peter Zijlstra wrote:
> > >>> On Mon, Feb 18, 2019 at 09:49:10AM -0800, Linus Torvalds wrote:
> >  On Mon, Feb 18, 2019 at 9:40 AM Peter Zijlstra  
> >  wrote:
> > >
> > > However; whichever way around you turn this cookie; it is expensive 
> > > and nasty.
> > 
> >  Do you (or anybody else) have numbers for real loads?
> > 
> >  Because performance is all that matters. If performance is bad, then
> >  it's pointless, since just turning off SMT is the answer.
> > >>>
> > >>> Not for these patches; they stopped crashing only yesterday and I
> > >>> cleaned them up and send them out.
> > >>>
> > >>> The previous version; which was more horrible; but L1TF complete, was
> > >>> between OK-ish and horrible depending on the number of VMEXITs a
> > >>> workload had.
> > >>>
> > >>> If there were close to no VMEXITs, it beat smt=off, if there were lots
> > >>> of VMEXITs it was far far worse. Supposedly hosting people try their
> > >>> very bestest to have no VMEXITs so it mostly works for them (with the
> > >>> obvious exception of single VCPU guests).
> > >>
> > >> If you are giving access to dedicated cores to guests, you also let them
> > >> do PAUSE/HLT/MWAIT without vmexits and the host just thinks it's a CPU
> > >> bound workload.
> > >>
> > >> In any case, IIUC what you are looking for is:
> > >>
> > >> 1) take a benchmark that *is* helped by SMT, this will be something CPU
> > >> bound.
> > >>
> > >> 2) compare two runs, one without SMT and without core scheduler, and one
> > >> with SMT+core scheduler.
> > >>
> > >> 3) find out whether performance is helped by SMT despite the increased
> > >> overhead of the core scheduler
> > >>
> > >> Do you want some other load in the host, so that the scheduler actually
> > >> does do something?  Or is the point just that you show that the
> > >> performance isn't affected when the scheduler does not have anything to
> > >> do (which should be obvious, but having numbers is always better)?
> > >
> > > Well, what _I_ want is for all this to just go away :-)
> > >
> > > Tim did much of testing last time around; and I don't think he did
> > > core-pinning of VMs much (although I'm sure he did some of that). I'm
> >
> > Yes. The last time around I tested basic scenarios like:
> > 1. single VM pinned on a core
> > 2. 2 VMs pinned on a core
> > 3. system oversubscription (no pinning)
> >
> > In general, CPU bound benchmarks and even things without too much I/O
> > causing lots of VMexits perform better with HT than without for Peter's
> > last patchset.
> >
> > > still a complete virt noob; I can barely boot a VM to save my life.
> > >
> > > (you should be glad to not have heard my cursing at qemu cmdline when
> > > trying to reproduce some of Tim's results -- lets just say that I can
> > > deal with gpg)
> > >
> > > I'm sure he tried some oversubscribed scenarios without pinning.
> >
> > We did try some oversubscribed scenarios like SPECVirt, that tried to
> > squeeze tons of VMs on a single system in over subscription mode.
> >
> > There're two main problems in the last go around:
> >
> > 1. Workload with high rate of Vmexits (SpecVirt is one)
> > were a major source of pain when we tried Peter's previous patchset.
> > The switch from vcpus to qemu and back in previous version of Peter's patch
> > requires some coordination between the hyperthread siblings via IPI.  And 
> > for
> > workload that does this a lot, the overhead quickly added up.
> >
> > For Peter's new patch, this overhead hopefully would be reduced and give
> > better performance.
> >
> > 2. Load balancing is quite tricky.  Peter's last patchset did not have
> > load balancing for consolidating compatible running threads.
> > I did some non-sophisticated load balancing
> > to pair vcpus up.  But the constant vcpu migrations overhead probably ate up
> > any improvements from better load pairing.  So I didn't get much
> > improvement in the over-subscription case when turning on load balancing
> > to consolidate the VCPUs of the same VM. We'll probably have to try
> > out this incarnation of Peter's patch and see how well the load balancing
> > works.
> >
> > I'll try to line up some benchmarking folks to do some tests.
>
> I can help to do some basic tests.
>
> Cgroup bias looks weird to me. If I have hundreds of cgroups, should I turn
> core scheduling(cpu.tag) on one by one? Or Is there a global knob I missed?
>

I encountered the following panic when I turned core sched on in a
cgroup when the cgroup
was running a best effort workload with high CPU utilization.

Feb 27 01:51:53 aubrey-ivb kernel: [  508.981348] core sched enabled
[  508.990627] BUG: unable to handle kernel NULL pointer dereference
at 008
[  

Re: [PATCH 1/5] ocxl: Rename struct link to ocxl_link

2019-02-26 Thread Andrew Donnellan
On 27/2/19 6:34 pm, Alastair D'Silva wrote:>>> diff --git 
a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index

e6a607488f8a..16eb8a60d5c7 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -152,7 +152,7 @@ static long afu_ioctl_enable_p9_wait(struct
ocxl_context *ctx,

if (status == ATTACHED) {
int rc;
-   struct link *link = ctx->afu->fn->link;
+   void *link = ctx->afu->fn->link;


This doesn't look like a rename...


That corrects the type to what the member (and prototype for 
ocxl_link_update_pe) declare it as.

The struct link there is bogus, it shouldn't even compile (since the intended 
struct link is defined in a different compilation unit), but instead picks up a 
different definition of 'struct link' from elsewhere.



Given there's only a handful of struct links defined across the entire 
kernel, I'm going to guess that the definition it's picking up is in 
fact the ocxl one.


I think the better solution here is to move struct ocxl_link into 
ocxl_internal.h, change ocxl_fn::link to be struct ocxl_link * rather 
than void *, and update the function signature for ocxl_link_update_pe() 
as well.


--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



Re: [PATCH v2 1/3] Bluetooth: btusb: add QCA6174A compatible properties

2019-02-26 Thread Marcel Holtmann
Hi Brian,

> We may need to specify a GPIO wake pin for this device, so add a
> compatible property for it.
> 
> There are at least to USB PID/VID variations of this chip: one with a
> Lite-On ID and one with an Atheros ID.
> 
> Signed-off-by: Brian Norris 
> Reviewed-by: Matthias Kaehlcke 
> ---
> v2:
> * drop leading zeroes from VID, per documented binding
> ---
> drivers/bluetooth/btusb.c | 2 ++
> 1 file changed, 2 insertions(+)

all 3 patches have been applied to bluetooth-next tree.

Regards

Marcel



[PATCH v2] posix-cpu-timers: Avoid undefined behaviour in timespec64_to_ns()

2019-02-26 Thread Xiongfeng Wang
When I ran Syzkaller testsuite, I got the following call trace.

UBSAN: Undefined behaviour in ./include/linux/time64.h:120:27
signed integer overflow:
8243129037239968815 * 10 cannot be represented in type 'long long int'
CPU: 5 PID: 28854 Comm: syz-executor.1 Not tainted 4.19.24 #4
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0xca/0x13e lib/dump_stack.c:113
 ubsan_epilogue+0xe/0x81 lib/ubsan.c:159
 handle_overflow+0x193/0x1e2 lib/ubsan.c:190
 timespec64_to_ns include/linux/time64.h:120 [inline]
 posix_cpu_timer_set+0x95a/0xb70 kernel/time/posix-cpu-timers.c:687
 do_timer_settime+0x198/0x2a0 kernel/time/posix-timers.c:892
 __do_sys_timer_settime kernel/time/posix-timers.c:918 [inline]
 __se_sys_timer_settime kernel/time/posix-timers.c:904 [inline]
 __x64_sys_timer_settime+0x18d/0x260 kernel/time/posix-timers.c:904
 do_syscall_64+0xc8/0x580 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x462eb9
Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 
c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:7f14e4127c58 EFLAGS: 0246 ORIG_RAX: 00df
RAX: ffda RBX: 0073bfa0 RCX: 00462eb9
RDX: 2080 RSI:  RDI: 
RBP: 0004 R08:  R09: 
R10:  R11: 0246 R12: 7f14e41286bc
R13: 004c54cc R14: 00704278 R15: 


It is because 'it_interval.tv_sec' is larger than 'KTIME_SEC_MAX' and
'it_interval.tv_sec * NSEC_PER_SEC' overflows in 'timespec64_to_ns()'.

This patch use 'timespec64_valid_restrict()' to check whether
'it_interval.tv_sec' is larger than 'KTIME_SEC_MAX'.

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

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 0e84bb7..97b773c 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -853,8 +853,8 @@ static int do_timer_settime(timer_t timer_id, int flags,
unsigned long flag;
int error = 0;
 
-   if (!timespec64_valid(_spec64->it_interval) ||
-   !timespec64_valid(_spec64->it_value))
+   if (!timespec64_valid_strict(_spec64->it_interval) ||
+   !timespec64_valid_strict(_spec64->it_value))
return -EINVAL;
 
if (old_spec64)
-- 
1.7.12.4



Re: [PATCH] cpufreq: kyro: Reduce frame-size of qcom_cpufreq_kryo_probe()

2019-02-26 Thread Viresh Kumar
On 20-02-19, 16:44, Viresh Kumar wrote:
> With the introduction of commit 846a415bf440 ("arm64: default NR_CPUS to
> 256"), we have started getting following compilation warning:
> 
> qcom-cpufreq-kryo.c:168:1: warning: the frame size of 2160 bytes is larger 
> than 2048 bytes [-Wframe-larger-than=]
> 
> Fix that by dynamically allocating opp_tables and freeing it later.
> 
> Compile tested only.
> 
> Signed-off-by: Viresh Kumar 
> ---
>  drivers/cpufreq/qcom-cpufreq-kryo.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c 
> b/drivers/cpufreq/qcom-cpufreq-kryo.c
> index 1c8583cc06a2..6888cb6db2ef 100644
> --- a/drivers/cpufreq/qcom-cpufreq-kryo.c
> +++ b/drivers/cpufreq/qcom-cpufreq-kryo.c
> @@ -75,7 +75,7 @@ static enum _msm8996_version 
> qcom_cpufreq_kryo_get_msm_id(void)
>  
>  static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
>  {
> - struct opp_table *opp_tables[NR_CPUS] = {0};
> + struct opp_table **opp_tables;
>   enum _msm8996_version msm8996_version;
>   struct nvmem_cell *speedbin_nvmem;
>   struct device_node *np;
> @@ -133,6 +133,10 @@ static int qcom_cpufreq_kryo_probe(struct 
> platform_device *pdev)
>   }
>   kfree(speedbin);
>  
> + opp_tables = kcalloc(num_possible_cpus(), sizeof(*opp_tables), 
> GFP_KERNEL);
> + if (!opp_tables)
> + return -ENOMEM;
> +
>   for_each_possible_cpu(cpu) {
>   cpu_dev = get_cpu_device(cpu);
>   if (NULL == cpu_dev) {
> @@ -149,6 +153,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device 
> *pdev)
>   }
>   }
>  
> + kfree(opp_tables);
> +
>   cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1,
> NULL, 0);
>   if (!IS_ERR(cpufreq_dt_pdev))

We can fail here and then we will try to use opp_tables which is already freed.

I wonder how this stupid patch made it through the reviews :)

> @@ -163,6 +169,7 @@ static int qcom_cpufreq_kryo_probe(struct platform_device 
> *pdev)
>   break;
>   dev_pm_opp_put_supported_hw(opp_tables[cpu]);
>   }
> + kfree(opp_tables);
>  
>   return ret;
>  }

Having said that, there is another problem which I just noticed in the remove()
path where we don't call dev_pm_opp_put_supported_hw(). That will create
problems if we try to remove module of this driver and then reinstall it as the
OPP table was never freed. The fix for that problem needs to go into stable
kernels past 4.18 and so I will abandon this patch and send a new fix which will
fix the issues of $subject patch as well.

-- 
viresh


Re: [PATCH 0/2] Reduce delay after sending baudrate request for WCN3990

2019-02-26 Thread Marcel Holtmann
Hi Matthias,

> The current 300ms delay after a baudrate change is extremely long.
> For WCM3990 it is sufficient to wait 10ms after the baudrate change
> request has been sent over the wire.
> 
> Also use msleep() instead of a set_current_state() / schedule_timeout()
> combo.
> 
> Matthias Kaehlcke (2):
>  hci_qca: Use msleep() instead of open coding it
>  hci_qca: Reduce delay after sending baudrate request for WCN3990
> 
> drivers/bluetooth/hci_qca.c | 30 +-
> 1 file changed, 21 insertions(+), 9 deletions(-)

patch 1/2 has been applied to bluetooth-next tree. The patch 2/2 fails to apply.

Regards

Marcel



Re: [PATCH v2 1/3] Bluetooth: hci_qca: Pass boolean 'on/off' to qca_send_power_pulse()

2019-02-26 Thread Marcel Holtmann
Hi Matthias,

> There are only two types of power pulses 'on' or 'off', pass a boolean
> instead of the power pulse 'command'.
> 
> Signed-off-by: Matthias Kaehlcke 
> Reviewed-by: Balakrishna Godavarthi 
> ---
> Changes in v2:
> - added 'Reviewed-by: Balakrishna Godavarthi ' tag
> ---
> drivers/bluetooth/hci_qca.c | 9 +
> 1 file changed, 5 insertions(+), 4 deletions(-)

all 3 patches have been applied to bluetooth-next tree.

Regards

Marcel



Re: [PATCH] Bluetooth: hci_bcm: fix double-free irq on removal

2019-02-26 Thread Marcel Holtmann
Hi Andreas,

>>> after rmmod hci_uart a warning about doubly freed
>>> interrupts appears, so do it only once. Instead disable it.
>>> It is already implicitely freed by the devm framework.
>>> 
>>> [  230.782948] [ cut here ]
>>> [  230.787708] WARNING: CPU: 0 PID: 2715 at kernel/irq/devres.c:146 
>>> devm_free_irq+0x59/0x60
>>> [  230.798345] Modules linked in: usb_f_ecm u_ether libcomposite spidev 
>>> hidp rfcomm hci_uart(-) btbcm bluetooth ecdh_generic brcmfmac brcmutil 
>>> cfg80211 rfkill evdev sun8i_codec_analog sun8i_adda_pr_regmap snd_soc_core 
>>> snd_pcm_dmaengine pwrseq_simple snd_pcm snd_timer snd soundcore hih6130 
>>> cpufreq_dt uio_pdrv_genirq gpio_keys uio thermal_sys
>>> [  230.828282] CPU: 0 PID: 2715 Comm: rmmod Not tainted 5.0.0-rc8+ #14
>>> [  230.834540] Hardware name: Allwinner sun8i Family
>>> [  230.839266] [] (unwind_backtrace) from [] 
>>> (show_stack+0x11/0x14)
>>> [  230.847014] [] (show_stack) from [] 
>>> (dump_stack+0x67/0x74)
>>> [  230.854240] [] (dump_stack) from [] 
>>> (__warn+0xb9/0xcc)
>>> [  230.861115] [] (__warn) from [] 
>>> (warn_slowpath_null+0x2f/0x34)
>>> [  230.868681] [] (warn_slowpath_null) from [] 
>>> (devm_free_irq+0x59/0x60)
>>> [  230.876881] [] (devm_free_irq) from [] 
>>> (bcm_close+0x35/0xa8 [hci_uart])
>>> [  230.885264] [] (bcm_close [hci_uart]) from [] 
>>> (hci_uart_unregister_device+0x33/0x3c [hci_uart])
>>> [  230.895708] [] (hci_uart_unregister_device [hci_uart]) from 
>>> [] (bcm_serdev_remove+0xf/0x10 [hci_uart])
>>> [  230.906755] [] (bcm_serdev_remove [hci_uart]) from 
>>> [] (serdev_drv_remove+0x13/0x20)
>>> [  230.916150] [] (serdev_drv_remove) from [] 
>>> (device_release_driver_internal+0xf7/0x158)
>>> [  230.925799] [] (device_release_driver_internal) from 
>>> [] (driver_detach+0x49/0x78)
>>> [  230.935013] [] (driver_detach) from [] 
>>> (bus_remove_driver+0x31/0x70)
>>> [  230.943108] [] (bus_remove_driver) from [] 
>>> (bcm_deinit+0x1b/0xcc4 [hci_uart])
>>> [  230.951994] [] (bcm_deinit [hci_uart]) from [] 
>>> (hci_uart_exit+0x1b/0x34 [hci_uart])
>>> [  230.961389] [] (hci_uart_exit [hci_uart]) from [] 
>>> (sys_delete_module+0x135/0x178)
>>> [  230.970603] [] (sys_delete_module) from [] 
>>> (ret_fast_syscall+0x1/0x62)
>>> [  230.978855] Exception stack(0xd66b7fa8 to 0xd66b7ff0)
>>> [  230.983906] 7fa0:   00c3dd00  00c3dd3c 0800 
>>> 88297c00 88297c00
>>> [  230.992078] 7fc0: 00c3dd00  bef05e82 0081 bef05b88 0001 
>>> bef05d7c 
>>> [  231.000245] 7fe0: 0045bf6c bef05b24 00441303 b6edab26
>>> [  231.005332] ---[ end trace dc4caa46c945c790 ]---
>>> [  231.009946] [ cut here ]
>>> [  231.014567] WARNING: CPU: 0 PID: 2715 at kernel/irq/manage.c:1600 
>>> __free_irq+0x83/0x20c
>>> [  231.025070] Trying to free already-free IRQ 92
>>> [  231.029505] Modules linked in: usb_f_ecm u_ether libcomposite spidev 
>>> hidp rfcomm hci_uart(-) btbcm bluetooth ecdh_generic brcmfmac brcmutil 
>>> cfg80211 rfkill evdev sun8i_codec_analog sun8i_adda_pr_regmap snd_soc_core 
>>> snd_pcm_dmaengine pwrseq_simple snd_pcm snd_timer snd soundcore hih6130 
>>> cpufreq_dt uio_pdrv_genirq gpio_keys uio thermal_sys
>>> [  231.059389] CPU: 0 PID: 2715 Comm: rmmod Tainted: GW 
>>> 5.0.0-rc8+ #14
>>> [  231.067032] Hardware name: Allwinner sun8i Family
>>> [  231.071740] [] (unwind_backtrace) from [] 
>>> (show_stack+0x11/0x14)
>>> [  231.079481] [] (show_stack) from [] 
>>> (dump_stack+0x67/0x74)
>>> [  231.086701] [] (dump_stack) from [] 
>>> (__warn+0xb9/0xcc)
>>> [  231.093574] [] (__warn) from [] 
>>> (warn_slowpath_fmt+0x33/0x48)
>>> [  231.101054] [] (warn_slowpath_fmt) from [] 
>>> (__free_irq+0x83/0x20c)
>>> [  231.108966] [] (__free_irq) from [] 
>>> (free_irq+0x27/0x5c)
>>> [  231.116012] [] (free_irq) from [] 
>>> (devm_free_irq+0x3f/0x60)
>>> [  231.123326] [] (devm_free_irq) from [] 
>>> (bcm_close+0x35/0xa8 [hci_uart])
>>> [  231.131690] [] (bcm_close [hci_uart]) from [] 
>>> (hci_uart_unregister_device+0x33/0x3c [hci_uart])
>>> [  231.142133] [] (hci_uart_unregister_device [hci_uart]) from 
>>> [] (bcm_serdev_remove+0xf/0x10 [hci_uart])
>>> [  231.153174] [] (bcm_serdev_remove [hci_uart]) from 
>>> [] (serdev_drv_remove+0x13/0x20)
>>> [  231.162562] [] (serdev_drv_remove) from [] 
>>> (device_release_driver_internal+0xf7/0x158)
>>> [  231.172209] [] (device_release_driver_internal) from 
>>> [] (driver_detach+0x49/0x78)
>>> [  231.181422] [] (driver_detach) from [] 
>>> (bus_remove_driver+0x31/0x70)
>>> [  231.189517] [] (bus_remove_driver) from [] 
>>> (bcm_deinit+0x1b/0xcc4 [hci_uart])
>>> [  231.198399] [] (bcm_deinit [hci_uart]) from [] 
>>> (hci_uart_exit+0x1b/0x34 [hci_uart])
>>> [  231.207793] [] (hci_uart_exit [hci_uart]) from [] 
>>> (sys_delete_module+0x135/0x178)
>>> [  231.217005] [] (sys_delete_module) from [] 
>>> (ret_fast_syscall+0x1/0x62)
>>> [  231.225256] Exception stack(0xd66b7fa8 to 0xd66b7ff0)
>>> [  

Re: [RFC PATCH 0/4] tracing/probes: uaccess: Add support user-space access

2019-02-26 Thread Masami Hiramatsu
On Tue, 26 Feb 2019 16:38:50 -0500
Joel Fernandes  wrote:

> On Mon, Feb 25, 2019 at 11:04:42PM +0900, Masami Hiramatsu wrote:

> > Note that kprobe event provides these methods, but it doesn't
> > change it from kernel to user automatically because we do not
> > know whether the given address is in userspace or kernel on
> > some arch.
> > Moreover, from perf-probe, at this moment it is not able to
> > switch. Since __user is not for compiler but checker, we have
> > no clue which data structure is in user-space, in debuginfo.
> > 
> > BTW, according to Linus's comment, I implemented probe_user_read()
> > and strncpy_from_unsafe_user() APIs. And since those use
> > "access_ok()" inside it, if CONFIG_DEBUG_ATOMIC_SLEEP=y on x86,
> > it will get a warn message at once. It should be solved before
> > merging this series.
> 
> I was wondering why access_ok() can sleep. In the arm64 and x86
> implementation, I don't see access_ok() itself causing a user pointer
> dereference access that can cause a page fault. It seems to just be checking
> the validity of the ranges.
> 
> Any idea why the access_ok() code has these comments?
> "Context: User context only. This function may sleep if pagefaults are
> enabled."

Because access_ok() is used only for preparing accessing user-space,
and the user-space access may cause page-fault and sleep.

IMHO, checking in access_ok() inside it is reasonable, but as it
commented, it is for "if pagefaults are enabled.". What we need another 
access_ok() for the case when pagefaults are disabled, that is what PeterZ
suggested in below mail.

https://lore.kernel.org/lkml/20190225150603.ge32...@hirez.programming.kicks-ass.net/T/#u


Thank you,

> 
> My _guess_ is this is because whatever calls access_ok() may also call
> something else that *does* fault next, if that's the case then that
> WARN_ON_IN_IRQ() in access_ok() is fine, but at least I guess the comments
> should be more clear that it is not access_ok() itself that sleeps.
> 
> thanks for any help on understanding this,
> 
>  - Joel
> 
> 
> > 
> > Thank you,
> > 
> > ---
> > 
> > Masami Hiramatsu (4):
> >   uaccess: Make sure kernel_uaccess_faults_ok is updated before 
> > pagefault
> >   uaccess: Add non-pagefault user-space read functions
> >   tracing/probe: Add ustring type for user-space string
> >   tracing/probe: Support user-space dereference
> > 
> > 
> >  Documentation/trace/kprobetrace.rst  |   13 ++-
> >  Documentation/trace/uprobetracer.rst |9 +-
> >  fs/namespace.c   |2 
> >  include/linux/uaccess.h  |   13 +++
> >  kernel/trace/trace.c |7 +-
> >  kernel/trace/trace_kprobe.c  |   65 
> >  kernel/trace/trace_probe.c   |   39 --
> >  kernel/trace/trace_probe.h   |3 +
> >  kernel/trace/trace_probe_tmpl.h  |   36 +++--
> >  kernel/trace/trace_uprobe.c  |   19 +
> >  mm/maccess.c |  138 
> > ++
> >  11 files changed, 302 insertions(+), 42 deletions(-)
> > 
> > --
> > Masami Hiramatsu (Linaro) 


-- 
Masami Hiramatsu 


RE: [PATCH 1/5] ocxl: Rename struct link to ocxl_link

2019-02-26 Thread Alastair D'Silva
> -Original Message-
> From: Andrew Donnellan 
> Sent: Wednesday, 27 February 2019 6:16 PM
> To: Alastair D'Silva ; alast...@d-silva.org
> Cc: Greg Kurz ; Frederic Barrat ;
> Arnd Bergmann ; Greg Kroah-Hartman
> ; linuxppc-...@lists.ozlabs.org; linux-
> ker...@vger.kernel.org
> Subject: Re: [PATCH 1/5] ocxl: Rename struct link to ocxl_link
> 
> On 27/2/19 3:57 pm, Alastair D'Silva wrote:
> > From: Alastair D'Silva 
> >
> > The term 'link' is ambiguous (especially when the struct is used for a
> > list), so rename it for clarity.
> >
> > Signed-off-by: Alastair D'Silva 
> > Reviewed-by: Greg Kurz 
> > ---
> >   drivers/misc/ocxl/file.c |  2 +-
> >   drivers/misc/ocxl/link.c | 36 ++--
> >   2 files changed, 19 insertions(+), 19 deletions(-)
> >
> > diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index
> > e6a607488f8a..16eb8a60d5c7 100644
> > --- a/drivers/misc/ocxl/file.c
> > +++ b/drivers/misc/ocxl/file.c
> > @@ -152,7 +152,7 @@ static long afu_ioctl_enable_p9_wait(struct
> > ocxl_context *ctx,
> >
> > if (status == ATTACHED) {
> > int rc;
> > -   struct link *link = ctx->afu->fn->link;
> > +   void *link = ctx->afu->fn->link;
> 
> This doesn't look like a rename...

That corrects the type to what the member (and prototype for 
ocxl_link_update_pe) declare it as.

The struct link there is bogus, it shouldn't even compile (since the intended 
struct link is defined in a different compilation unit), but instead picks up a 
different definition of 'struct link' from elsewhere.

-- 
Alastair D'Silva   mob: 0423 762 819
skype: alastair_dsilva msn: alast...@d-silva.org
blog: http://alastair.d-silva.orgTwitter: @EvilDeece



Re: [PATCH] x86/boot/KASLR: skip the specified crashkernel reserved region

2019-02-26 Thread Borislav Petkov
+ Kees.

@Kees, you might want to go upthread a bit for context.

On Wed, Feb 27, 2019 at 09:30:34AM +0800, Baoquan He wrote:
> Agree that 'crashkernel=x' should be encouraged to use as the first
> choice when reserve crashkernel. If we decide to not obsolete
> 'crashkernel=x@y', it will leave a unstable kernel parameter.

Is anyone even talking about obsoleting this?

And if anyone is, anyone can think a bit why we can't do this.

> Another worry is that KASLR won't always fail 'crashkernel=x@y',
> customer may set and check in testing stage, then later in production
> environment one time of neglect to not check may cause carashed kernel
> uncaptured.
>
> IMHO, 'crashkernel=x@y' is similar to those specified memmap=ss[#$!]nn
> which have been avoided in boot stage KASLR.

So my worry is that by specifying too many exclusion ranges, we might
limit the kaslr space too much and make it too predictable. Especially
since distros slap those things automatically and most users take them
for granted.

But I might be way off here because of something else I'm missing ...

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


[PATCH] arm64: dts: qcom: Add Dragonboard 845c

2019-02-26 Thread Bjorn Andersson
This adds an initial dts for the Dragonboard 845. Supported
functionality includes Debug UART, UFS, USB-C (peripheral), USB-A
(host), Ethernet, microSD-card and Bluetooth.

Initializing the SMMU is clearing the mapping used for the splash screen
framebuffer, which causes the baord to reboot. This can be worked around
using:

  fastboot oem select-display-panel none

Ethernet and the second USB-A port depends on a functional firmware
loader for the uPD720201.

Signed-off-by: Bjorn Andersson 
---

This depends on the addition of the PCIe controller and PHY nodes, from
https://lore.kernel.org/lkml/20190227070022.31975-1-bjorn.anders...@linaro.org/

 arch/arm64/boot/dts/qcom/Makefile  |   1 +
 arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 570 +
 2 files changed, 571 insertions(+)
 create mode 100644 arch/arm64/boot/dts/qcom/sdm845-db845c.dts

diff --git a/arch/arm64/boot/dts/qcom/Makefile 
b/arch/arm64/boot/dts/qcom/Makefile
index 21d548f02d39..b3fe72ff2955 100644
--- a/arch/arm64/boot/dts/qcom/Makefile
+++ b/arch/arm64/boot/dts/qcom/Makefile
@@ -7,6 +7,7 @@ dtb-$(CONFIG_ARCH_QCOM) += msm8992-bullhead-rev-101.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= msm8994-angler-rev-101.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= msm8996-mtp.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= msm8998-mtp.dtb
+dtb-$(CONFIG_ARCH_QCOM)+= sdm845-db845c.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= sdm845-mtp.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= qcs404-evb-1000.dtb
 dtb-$(CONFIG_ARCH_QCOM)+= qcs404-evb-4000.dtb
diff --git a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts 
b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
new file mode 100644
index ..0a5cfab6f6e2
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
@@ -0,0 +1,570 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+
+#include 
+#include 
+#include 
+#include "sdm845.dtsi"
+#include "pm8998.dtsi"
+#include "pmi8998.dtsi"
+
+/ {
+   model = "Thundercomm Dragonboard 845c";
+   compatible = "thundercomm,db845c", "qcom,sdm845";
+
+   aliases {
+   serial0 = 
+   hsuart0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   dc12v: dc12v-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "DC12V";
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   regulator-always-on;
+   };
+
+   lt9611_1v8: lt9611-vdd18-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "LT9611_1V8";
+
+   vin-supply = <_5v>;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+
+   gpio = < 89 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   };
+
+   lt9611_3v3: lt9611-3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "LT9611_3V3";
+
+   vin-supply = <_3v3>;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+
+   // TODO: make it possible to drive same GPIO from two clients
+   // gpio = < 89 GPIO_ACTIVE_HIGH>;
+   // enable-active-high;
+   };
+
+   pcie0_1p05v: pcie-0-1p05v-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "PCIE0_1.05V";
+
+   vin-supply = <>;
+   regulator-min-microvolt = <105>;
+   regulator-max-microvolt = <105>;
+
+   // TODO: make it possible to drive same GPIO from two clients
+   // gpio = < 90 GPIO_ACTIVE_HIGH>;
+   // enable-active-high;
+   };
+
+   pcie0_3p3v_dual: vldo-3v3-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "VLDO_3V3";
+
+   vin-supply = <>;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+
+   gpio = < 90 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   };
+
+   gpio_keys {
+   compatible = "gpio-keys";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   autorepeat;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_up_pin_a>;
+
+   vol-up {
+   label = "Volume Up";
+   linux,code = ;
+   gpios = <_gpio 6 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   user4 {
+   label = "db845c:green:user4";
+   gpios = <_gpio 13 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   default-state = "off";
+   };
+
+   wlan {
+   label 

Re: [PATCH v2 2/2] Input: add Apple SPI keyboard and trackpad driver.

2019-02-26 Thread Life is hard, and then you die


On Tue, Feb 26, 2019 at 11:20:59AM +0200, Andy Shevchenko wrote:
> On Thu, Feb 21, 2019 at 02:56:09AM -0800, Ronald Tschalär wrote:
> > The keyboard and trackpad on recent MacBook's (since 8,1) and
> > MacBookPro's (13,* and 14,*) are attached to an SPI controller instead
> > of USB, as previously. The higher level protocol is not publicly
> > documented and hence has been reverse engineered. As a consequence there
> > are still a number of unknown fields and commands. However, the known
> > parts have been working well and received extensive testing and use.
> > 
> > In order for this driver to work, the proper SPI drivers need to be
> > loaded too; for MB8,1 these are spi_pxa2xx_platform and spi_pxa2xx_pci;
> > for all others they are spi_pxa2xx_platform and intel_lpss_pci. For this
> > reason enabling this driver in the config implies enabling the above
> > drivers.
> 
> > +config KEYBOARD_APPLESPI
> > +   tristate "Apple SPI keyboard and trackpad"
> 
> > +   depends on ACPI && SPI && EFI
> 
> I would rather want to see separate line for SPI...
> 
> > +   depends on X86 || COMPILE_TEST
> 
> ...like here
> 
>   depends on SPI

Sure. Generally, what is the criteria/rule here for splitting
conjunctions into separate 'depends'?

[snip]
> + #define DEV(applespi)   (&(applespi)->spi->dev)
[snip]
> > +   if (memcmp(applespi->tx_status, status_ok, APPLESPI_STATUS_SIZE)) {
> 
> > +   dev_warn(DEV(applespi), "Error writing to device: %*ph\n",
> 
> Hmm... DEV() is too generic name for custom macro. And frankly I don't think
> it's good to have in the first place.

Yeah, I've been having trouble coming up with a better (but still
succinct) name - CORE_DEV()? RAW_DEV()? DEV_OF()? However, because
this expression is used in many places throughout the driver (mostly,
but not only, for logging statements) I feel like it's good to factor
it out. But I'll defer to your .

[snip]
> > +static void
> > +applespi_remap_fn_key(struct keyboard_protocol *keyboard_protocol)
> > +{
> > +   unsigned char tmp;
> 
> > +   unsigned long *modifiers =
> > +   (unsigned long *)_protocol->modifiers;
> 
> I would leave it on one online despite checkpatch warning (also, instead of
> (unsigned long *) the (void *) might be used as a small trick).
> 
> > +
> > +   if (!fnremap || fnremap > ARRAY_SIZE(applespi_controlcodes) ||
> > +   !applespi_controlcodes[fnremap - 1])
> > +   return;
> > +
> > +   tmp = keyboard_protocol->fn_pressed;
> > +   keyboard_protocol->fn_pressed = test_bit(fnremap - 1, modifiers);
> > +   if (tmp)
> 
> > +   __set_bit(fnremap - 1, modifiers);
> > +   else
> > +   __clear_bit(fnremap - 1, modifiers);
> 
> Oh, this is not good. modifiers should be really unsigned long bounary,
> otherwise it is potential overflow.
> 
> Best to fix is to define them as unsigned long in the first place.

Can't do that directly, because keyboard_protocol->modifiers is a
field in the data received from the device, i.e. defined by that
protocol. Instead I could make a copy of the modifiers and pass that
around separately (i.e. in addition to the keyboard_protocol struct).

However, the implied size assertions here would basically still apply:

  MAX_MODIFIERS == sizeof(keyboard_protocol->modifiers) * 8
  ARRAY_SIZE(applespi_controlcodes) == sizeof(keyboard_protocol->modifiers) * 8

(hmm, MAX_MODIFIERS is really redundant - getting rid of it...)

Would using compiletime_assert()'s be an acceptable alternate approach
here? It would serve to both document the size constraint and to
protect against overflow due to an error in some future edit. E.g.

 applespi_remap_fn_key(struct keyboard_protocol *keyboard_protocol)
 {
unsigned char tmp;
unsigned long *modifiers = (void *)_protocol->modifiers;
+
+   compiletime_assert(ARRAY_SIZE(applespi_controlcodes) ==
+  sizeof_field(struct keyboard_protocol, modifiers) * 
8,
+  "applespi_controlcodes has wrong number of entries");
 
if (!fnremap || fnremap > ARRAY_SIZE(applespi_controlcodes) ||
!applespi_controlcodes[fnremap - 1])
return;
 
tmp = keyboard_protocol->fn_pressed;
keyboard_protocol->fn_pressed = test_bit(fnremap - 1, modifiers);
if (tmp)
 
__set_bit(fnremap - 1, modifiers);
else
__clear_bit(fnremap - 1, modifiers);
 }

> > +}
> 
> > +  applespi->last_keys_fn_pressed[i]);
> > +   input_report_key(applespi->keyboard_input_dev, key, 0);
> > +   applespi->last_keys_fn_pressed[i] = 0;
> > +   }
> 
> > +   for (i = 0; i < MAX_MODIFIERS; i++) {
> 
> > +   u8 *modifiers = _protocol->modifiers;
> > +
> > +   if (test_bit(i, (unsigned long *)modifiers))
> 
> Oh, this is not good idea, see above.

See above. (I presume duplicating the compiletime_assert() here isn't
necessary, if going that route?)


  

[PATCH 4/5] Add driver for SUNIX Multi-I/O board

2019-02-26 Thread Morris Ku
Support SUNIX serial board.

---
 char/snx/snx_serial.c | 4771 +
 1 file changed, 4771 insertions(+)
 create mode 100644 char/snx/snx_serial.c

diff --git a/char/snx/snx_serial.c b/char/snx/snx_serial.c
new file mode 100644
index ..94caac1a
--- /dev/null
+++ b/char/snx/snx_serial.c
@@ -0,0 +1,4771 @@
+#include "snx_common.h"
+#include "driver_extd.h"
+
+#define SNX_ioctl_DBG  0
+#defineEEPROM_ACCESS_DELAY_COUNT   10
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
+   static DEFINE_SEMAPHORE(ser_port_sem);
+#else
+   static DECLARE_MUTEX(ser_port_sem);
+#endif
+
+
+#define SNX_HIGH_BITS_OFFSET   ((sizeof(long)-sizeof(int))*8)
+#define sunix_ser_users(state) ((state)->count + ((state)->info ? 
(state)->info->blocked_open : 0))
+
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0))
+static struct tty_port snx_service_port;
+#endif
+
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0))
+
+struct serial_uart_config {
+   char*name;
+   int dfl_xmit_fifo_size;
+   int flags;
+};
+#endif
+
+static const struct serial_uart_config snx_uart_config[PORT_SER_MAX_UART + 1] 
= {
+   { "unknown",1,  0 },
+   { "8250",   1,  0 },
+   { "16450",  1,  0 },
+   { "16550",  1,  0 },
+   { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO },
+   { "Cirrus", 1,  0 },
+   { "ST16650",1,  0 },
+   { "ST16650V2",  32, UART_CLEAR_FIFO | UART_USE_FIFO },
+   { "TI16750",64, UART_CLEAR_FIFO | UART_USE_FIFO },
+};
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
+static int sunix_ser_refcount;
+static struct tty_struct   
*sunix_ser_tty[SNX_SER_TOTAL_MAX + 1];
+static struct termios  
*sunix_ser_termios[SNX_SER_TOTAL_MAX + 1];
+static struct termios  
*sunix_ser_termios_locked[SNX_SER_TOTAL_MAX + 1];
+#endif
+
+
+static _INLINE_ void snx_ser_handle_cts_change(struct snx_ser_port *, unsigned 
int);
+static _INLINE_ void snx_ser_update_mctrl(struct snx_ser_port *, unsigned int, 
unsigned int);
+static void snx_ser_write_wakeup(struct snx_ser_port *);
+static void snx_ser_stop(struct tty_struct *);
+static void __snx_ser_start(struct tty_struct *);
+static void snx_ser_start(struct tty_struct *);
+static void snx_ser_tasklet_action(unsigned long);
+
+
+static void snx_ser_shutdown(struct snx_ser_state *);
+static _INLINE_ void __snx_ser_put_char(struct snx_ser_port *, struct circ_buf 
*, unsigned char);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26))
+static int  snx_ser_put_char(struct tty_struct *, unsigned char);
+#else
+static void snx_ser_put_char(struct tty_struct *, unsigned char);
+#endif
+static void snx_ser_flush_chars(struct tty_struct *);
+static int  snx_ser_chars_in_buffer(struct tty_struct *);
+static void snx_ser_flush_buffer(struct tty_struct *);
+static void snx_ser_send_xchar(struct tty_struct *, char);
+static void snx_ser_throttle(struct tty_struct *);
+static void snx_ser_unthrottle(struct tty_struct *);
+static int  snx_ser_get_info(struct snx_ser_state *, struct serial_struct 
*);
+static int  snx_ser_set_info(struct snx_ser_state *, struct serial_struct 
*);
+static int  snx_ser_write_room(struct tty_struct *);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10))
+static int  snx_ser_write(struct tty_struct *, const unsigned char *, int);
+#else
+static int  snx_ser_write(struct tty_struct *, int, const unsigned char *, 
int);
+#endif
+static int  snx_ser_get_lsr_info(struct snx_ser_state *, unsigned int *);
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+static int  snx_ser_tiocmget(struct tty_struct *);
+static int  snx_ser_tiocmset(struct tty_struct *, unsigned int, unsigned 
int);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
+static int  snx_ser_tiocmget(struct tty_struct *, struct file *);
+static int  snx_ser_tiocmset(struct tty_struct *, struct file *, unsigned 
int, unsigned int);
+#else
+static int  snx_ser_get_modem_info(struct snx_ser_state *, unsigned int *);
+static int  snx_ser_set_modem_info(struct snx_ser_state *, unsigned int, 
unsigned int *);
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
+static int  snx_ser_break_ctl(struct tty_struct *, int);
+#else
+static void snx_ser_break_ctl(struct tty_struct *, int);
+#endif
+static int  snx_ser_wait_modem_status(struct snx_ser_state *, unsigned 
long);
+static int  snx_ser_get_count(struct snx_ser_state *, struct 
serial_icounter_struct *);
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+static int  snx_ser_ioctl(struct tty_struct *, unsigned int, unsigned 
long);
+#else
+static int  snx_ser_ioctl(struct tty_struct *, struct file *, 

[PATCH 5/5] Add driver for SUNIX parallel board

2019-02-26 Thread Morris Ku
Support SUNIX parallel board.

---
 char/snx/snx_ieee1284.c |  207 ++
 char/snx/snx_ieee1284_ops.c |  257 
 char/snx/snx_lp.c   | 1019 +
 char/snx/snx_parallel.c |  437 +
 char/snx/snx_ppdev.c| 1209 +++
 char/snx/snx_share.c|  974 
 6 files changed, 4103 insertions(+)
 create mode 100644 char/snx/snx_ieee1284.c
 create mode 100644 char/snx/snx_ieee1284_ops.c
 create mode 100644 char/snx/snx_lp.c
 create mode 100644 char/snx/snx_parallel.c
 create mode 100644 char/snx/snx_ppdev.c
 create mode 100644 char/snx/snx_share.c

diff --git a/char/snx/snx_ieee1284.c b/char/snx/snx_ieee1284.c
new file mode 100644
index ..f357d9bd
--- /dev/null
+++ b/char/snx/snx_ieee1284.c
@@ -0,0 +1,207 @@
+#include "snx_common.h"
+
+
+static void sunix_parport_ieee1284_wakeup(struct snx_parport *port)
+{
+   up(>physport->ieee1284.irq);
+}
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0))
+static struct snx_parport *port_from_cookie[SNX_PAR_TOTAL_MAX];
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+
+static void sunix_timeout_waiting_on_port(struct timer_list *t)
+{
+   struct snx_parport *port = from_timer(port, t, timer);
+
+   sunix_parport_ieee1284_wakeup(port);
+}
+#else
+
+static void sunix_timeout_waiting_on_port(unsigned long cookie)
+{
+   sunix_parport_ieee1284_wakeup(port_from_cookie[cookie % 
SNX_PAR_TOTAL_MAX]);
+}
+#endif
+
+
+
+int sunix_parport_wait_event(struct snx_parport *port, signed long timeout)
+{
+   int ret;
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+#else
+   struct timer_list timer;
+#endif
+
+   if (!port->physport->cad->timeout) {
+   return 1;
+   }
+
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+
+   timer_setup(>timer, sunix_timeout_waiting_on_port, 0);
+   mod_timer(>timer, jiffies + timeout);
+#else
+   init_timer ();
+   timer.expires = jiffies + timeout;
+   timer.function = sunix_timeout_waiting_on_port;
+   port_from_cookie[port->number % PARPORT_MAX] = port;
+   timer.data = port->number;
+
+   add_timer ();
+
+#endif
+   ret = down_interruptible(>physport->ieee1284.irq);
+
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
+   if (!del_timer(>timer) && !ret)
+#else
+   if (!del_timer() && !ret)
+#endif
+
+   {
+   ret = 1;
+   }
+
+   return ret;
+}
+
+
+int sunix_parport_poll_peripheral(struct snx_parport *port, unsigned char 
mask, unsigned char result, int usec)
+{
+   int count = usec / 5 + 2;
+   int i;
+   unsigned char status;
+
+   for (i = 0; i < count; i++) {
+   status = sunix_parport_read_status(port);
+
+   if ((status & mask) == result) {
+   return 0;
+   }
+
+   if (signal_pending(current)) {
+   return -EINTR;
+   }
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 19))
+   if (need_resched()) {
+   break;
+   }
+#else
+   if (current->need_resched) {
+   break;
+   }
+#endif
+   if (i >= 2) {
+   udelay (5);
+   }
+   }
+
+   return 1;
+}
+
+
+int sunix_parport_wait_peripheral(struct snx_parport *port, unsigned char 
mask, unsigned char result)
+{
+   int ret;
+   int usec;
+   unsigned long deadline;
+   unsigned char status;
+
+   usec = port->physport->spintime;// usecs of fast polling
+
+   if (!port->physport->cad->timeout) {
+   usec = 35000;
+   }
+
+   ret = sunix_parport_poll_peripheral(port, mask, result, usec);
+
+   if (ret != 1) {
+   return ret;
+   }
+
+   if (!port->physport->cad->timeout) {
+   return 1;
+   }
+
+   deadline = jiffies + (HZ + 24) / 25;
+
+   while (time_before(jiffies, deadline)) {
+   int ret;
+
+   if (signal_pending(current)) {
+   return -EINTR;
+   }
+
+   //if ((ret = sunix_parport_wait_event(port, (HZ + 99) / 100)) < 
0) {
+   ret = sunix_parport_wait_event (port, (HZ + 99) / 100);
+   if (ret < 0) {
+   return ret;
+   }
+
+   status = sunix_parport_read_status(port);
+   if ((status & mask) == result) {
+   return 0;
+   }
+
+   if (!ret) {
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 13))
+   __set_current_state (TASK_INTERRUPTIBLE);
+   schedule_timeout ((HZ + 99) / 100);
+#else
+   schedule_timeout_interruptible(msecs_to_jiffies(10));
+#endif
+   }
+   }
+
+   return 1;
+}
+
+
+int 

[PATCH 3/5] Add SUNIX Multi-I/O board driver

2019-02-26 Thread Morris Ku
Add driver, Kconfig and Makefile entry.
---
 char/snx/Kconfig|7 +
 char/snx/Makefile   |9 +
 char/snx/snx_devtable.c |  669 +
 char/snx/snx_main.c | 1583 +++
 4 files changed, 2268 insertions(+)
 create mode 100644 char/snx/Kconfig
 create mode 100644 char/snx/Makefile
 create mode 100644 char/snx/snx_devtable.c
 create mode 100644 char/snx/snx_main.c

diff --git a/char/snx/Kconfig b/char/snx/Kconfig
new file mode 100644
index ..d203c850
--- /dev/null
+++ b/char/snx/Kconfig
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Character device configuration
+#
+
+config SNX
+   tristate "SUNIX Multi-IO Board Drvier"
diff --git a/char/snx/Makefile b/char/snx/Makefile
new file mode 100644
index ..47348926
--- /dev/null
+++ b/char/snx/Makefile
@@ -0,0 +1,9 @@
+#
+# drivers/char/snx/Makefile
+#
+# Makefile for the sunix multi-io device drivers.
+#
+
+obj-$(CONFIG_SNX) += snx.o
+
+snx-y := snx_main.o snx_devtable.o snx_serial.o snx_parallel.o snx_share.o 
snx_ieee1284.o snx_ieee1284_ops.o snx_ppdev.o snx_lp.o
diff --git a/char/snx/snx_devtable.c b/char/snx/snx_devtable.c
new file mode 100644
index ..9084f006
--- /dev/null
+++ b/char/snx/snx_devtable.c
@@ -0,0 +1,669 @@
+#include "snx_common.h"
+
+
+PCI_BOARD snx_pci_board_conf[] = {
+   // mode none
+   {
+   // VenIDDevID   SubVenID
SubSysIDSerPort ParPort IntrBar 
IntrOffset  NameBoardFlag   part_number
+   VENID_GOLDEN,   DEVID_G_SERIAL, SUBVENID_GOLDEN,
SUBDEVID_TEST,  0,  0,  0,  0x00,   
"none", BOARDFLAG_NONE, PART_NUMBER_NONE, CARD_TYPE_UART_ONLY, 
GPIO_NONE,
+   {
+   //  typebar1ofs1len1bar2
ofs2len2intmask flags
+   {   'n',-1, 0,  0,  
-1, 0,  0,  0x, 
SUNNONE_HWID},
+   },
+   },
+
+   // mode 4027A
+   {
+   VENID_GOLDEN,   DEVID_G_SERIAL, SUBVENID_GOLDEN,
SUBDEVID_4027A, 1,  0,  0,  0x1C,   
"4027", BOARDFLAG_NONE, PART_NUMBER_NONE, CARD_TYPE_UART_ONLY, 
GPIO_NONE,
+   {
+   //  typebar1ofs1len1bar2
ofs2len2intmask flags
+   {   's',0,  0,  8,  
-1, 0,  0,  0x0001, 
SUN1889_HWID},
+   },
+   },
+
+   // mode 4027D
+   {
+   VENID_GOLDEN,   DEVID_G_SERIAL, SUBVENID_GOLDEN,
SUBDEVID_4027D, 1,  0,  0,  0x00,   
"4027", BOARDFLAG_REMAP, PART_NUMBER_NONE, CARD_TYPE_UART_ONLY, 
GPIO_NONE,
+   {
+   //  typebar1ofs1len1bar2
ofs2len2intmask flags
+   {   's',2,  0,  8,  
-1, 0,  0,  0x, 
SUN1699_HWID},
+   },
+   },
+
+   // mode 4037A, 4037AL
+   {
+   VENID_GOLDEN,   DEVID_G_SERIAL, SUBVENID_GOLDEN,
SUBDEVID_4037A, 2,  0,  0,  0x1C,   
"4037", BOARDFLAG_NONE, PART_NUMBER_NONE, CARD_TYPE_UART_ONLY, 
GPIO_NONE,
+   {
+   //  typebar1ofs1len1bar2
ofs2len2intmask flags
+   {   's',0,  0,  8,  
-1, 0,  0,  0x0001, 
SUN1889_HWID},
+   {   's',0,  8,  8,  
-1, 0,  0,  0x0002, 
SUN1889_HWID},
+   },
+   },
+
+   // mode 4037D
+   {
+   VENID_GOLDEN,   DEVID_G_SERIAL, SUBVENID_GOLDEN,
SUBDEVID_4037D, 2,  0,  0,  0x00,   
"4037", BOARDFLAG_REMAP, PART_NUMBER_NONE, CARD_TYPE_UART_ONLY, 
GPIO_NONE,
+   {
+   //  typebar1ofs1len1bar2
ofs2len2intmask flags
+   {   's',2,  0,  8,  
-1, 0,  0,  0x, 
SUN1699_HWID},
+   {   's',3,  0,  8,  
-1, 0,  0, 

[PATCH 2/5] Add header files for SUNIX Multi-I/O board driver

2019-02-26 Thread Morris Ku
This patch add header files.

---
 char/snx/driver_extd.h |  209 +++
 char/snx/snx_common.h  | 1339 
 char/snx/snx_lp.h  |  143 +
 char/snx/snx_ppdev.h   |   41 ++
 4 files changed, 1732 insertions(+)
 create mode 100644 char/snx/driver_extd.h
 create mode 100644 char/snx/snx_common.h
 create mode 100644 char/snx/snx_lp.h
 create mode 100644 char/snx/snx_ppdev.h

diff --git a/char/snx/driver_extd.h b/char/snx/driver_extd.h
new file mode 100644
index ..3569ae36
--- /dev/null
+++ b/char/snx/driver_extd.h
@@ -0,0 +1,209 @@
+/
+ *
+ *  Module  :
+ *  Description : driver definition file
+ *
+ *
+ *  Author(s)   : Morris Ku
+ *  Company : SUNIX Co., Ltd.
+ *  Maintain: Moris Ku
+ /
+
+
+#ifndef _SNXHW_DRVR_EXTR_H_
+#define _SNXHW_DRVR_EXTR_H_
+
+
+// ioctl define
+#ifndef SNX_IOCTL
+#define SNX_IOCTL 0x900
+#endif
+
+
+/***
+   The IOCTL function codes.
+***/
+
+
+// common func
+#define SNX_COMM_GET_BOARD_CNT  (SNX_IOCTL + 100)
+#define SNX_COMM_GET_BOARD_INFO (SNX_IOCTL + 101)
+
+
+// gpio func
+#define SNX_GPIO_GET(SNX_IOCTL + 200)
+#define SNX_GPIO_SET(SNX_IOCTL + 201)
+#define SNX_GPIO_READ   (SNX_IOCTL + 202)
+#define SNX_GPIO_WRITE  (SNX_IOCTL + 203)
+#define SNX_GPIO_SET_DEFAULT(SNX_IOCTL + 204)
+#define SNX_GPIO_WRITE_DEFAULT  (SNX_IOCTL + 205)
+#define SNX_GPIO_GET_INPUT_INVERT   (SNX_IOCTL + 206)
+#define SNX_GPIO_SET_INPUT_INVERT   (SNX_IOCTL + 207)
+
+
+// uart func
+#define SNX_UART_GET_TYPE   (SNX_IOCTL + 300)
+#define SNX_UART_SET_TYPE   (SNX_IOCTL + 301)
+#define SNX_UART_GET_ACS(SNX_IOCTL + 302)
+#define SNX_UART_SET_ACS(SNX_IOCTL + 303)
+
+
+/***
+   The IOCTL function struct define.
+***/
+
+
+#define SNX_BOARD_MAX_UARTCNT 32
+
+
+// gpio define
+#define SNX_GPIO_IN   0
+#define SNX_GPIO_OUT  1
+#define SNX_GPIO_LOW  0
+#define SNX_GPIO_HI   1
+#define SNX_GPIO_INPUT_INVERT_D   0
+#define SNX_GPIO_INPUT_INVERT_E   1
+
+
+// uart define
+#define SNX_UART_RS2320
+#define SNX_UART_RS4221
+#define SNX_UART_RS4852
+#define SNX_UART_A422485  3
+#define SNX_UART_ACS_D0
+#define SNX_UART_ACS_E1
+
+
+// board gpio type define
+#define SNX_GPIO_TYPE_STANDARD0
+#define SNX_GPIO_TYPE_CASHDRAWER  1
+
+
+// board uart type define
+#define SNX_UART_TYPE_RS232   0
+#define SNX_UART_TYPE_RS4224851
+#define SNX_UART_TYPE_3IN12
+
+
+typedef struct _SNX_DRVR_BOARD_CNT {
+  int cnt;  // total sunix board 
installed
+
+} SNX_DRVR_BOARD_CNT, *PSNX_DRVR_BOARD_CNT;
+
+
+typedef struct _SNX_DRVR_UART_INFO {
+  int status;   // port status, see 
com port status define
+  int node_num; // device node number
+  int uart_type;// port uart type
+
+
+} SNX_DRVR_UART_INFO, *PSNX_DRVR_UART_INFO;
+
+
+typedef struct _SNX_DRVR_BOARD_INFO {
+  int board_id; // board uniqe id, (1 
~ 255)
+  int subvender_id; // sub-vender id (ex. 
0x1fd4)
+  int subsystem_id; // sub-system id (ex. 
0x0004)
+  int oem_id;   // oemid (3 bytes)
+  int uart_cnt; // uart count
+  SNX_DRVR_UART_INFO  uart_info[SNX_BOARD_MAX_UARTCNT]; // uart info
+  int gpio_chl_cnt; // gpio channel count
+  int board_uart_type;  // board uart type, 
refer to board uart type define
+  int board_gpio_type;  // board gpio type, 
refer to board gpio type define
+
+} SNX_DRVR_BOARD_INFO, *PSNX_DRVR_BOARD_INFO;
+
+
+typedef struct _SNX_DRVR_GPIO_GET {
+  int board_id; // board uniqe id, (1 
~ 255)
+  unsigned char   bank1_direct; // bank1 direction 
(chl 1  ~ 8)
+  unsigned char   bank2_direct; // bank2 direction 
(chl 9  ~ 16)
+  unsigned char   bank3_direct; // bank3 direction 
(chl 17 ~ 24)
+  unsigned char   bank4_direct; // bank4 direction 
(chl 25 ~ 32)
+
+} SNX_DRVR_GPIO_GET, *PSNX_DRVR_GPIO_GET;
+
+

[PATCH 1/5] Add support SUNIX Multi-I/O board

2019-02-26 Thread Morris Ku
Add Kconfig and Makefile entry.

---
 Kconfig  | 2 ++
 Makefile | 1 +
 2 files changed, 3 insertions(+)

diff --git a/Kconfig b/Kconfig
index 4f9f9905..645dcc85 100644
--- a/Kconfig
+++ b/Kconfig
@@ -228,4 +228,6 @@ source "drivers/siox/Kconfig"
 
 source "drivers/slimbus/Kconfig"
 
+source "drivers/char/snx/Kconfig"
+
 endmenu
diff --git a/Makefile b/Makefile
index e1ce029d..c9393c75 100644
--- a/Makefile
+++ b/Makefile
@@ -186,3 +186,4 @@ obj-$(CONFIG_MULTIPLEXER)   += mux/
 obj-$(CONFIG_UNISYS_VISORBUS)  += visorbus/
 obj-$(CONFIG_SIOX) += siox/
 obj-$(CONFIG_GNSS) += gnss/
+obj-$(CONFIG_SNX)  += snx/
-- 
2.17.1



Re: [PATCH 1/5] ocxl: Rename struct link to ocxl_link

2019-02-26 Thread Andrew Donnellan

On 27/2/19 3:57 pm, Alastair D'Silva wrote:

From: Alastair D'Silva 

The term 'link' is ambiguous (especially when the struct is used for a
list), so rename it for clarity.

Signed-off-by: Alastair D'Silva 
Reviewed-by: Greg Kurz 
---
  drivers/misc/ocxl/file.c |  2 +-
  drivers/misc/ocxl/link.c | 36 ++--
  2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index e6a607488f8a..16eb8a60d5c7 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -152,7 +152,7 @@ static long afu_ioctl_enable_p9_wait(struct ocxl_context 
*ctx,
  
  		if (status == ATTACHED) {

int rc;
-   struct link *link = ctx->afu->fn->link;
+   void *link = ctx->afu->fn->link;


This doesn't look like a rename...

  
  			rc = ocxl_link_update_pe(link, ctx->pasid, ctx->tidr);

if (rc)
diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
index d50b861d7e57..8d2690a1a9de 100644
--- a/drivers/misc/ocxl/link.c
+++ b/drivers/misc/ocxl/link.c
@@ -76,7 +76,7 @@ struct spa {
   * limited number of opencapi slots on a system and lookup is only
   * done when the device is probed
   */
-struct link {
+struct ocxl_link {
struct list_head list;
struct kref ref;
int domain;
@@ -179,7 +179,7 @@ static void xsl_fault_handler_bh(struct work_struct 
*fault_work)
  
  static irqreturn_t xsl_fault_handler(int irq, void *data)

  {
-   struct link *link = (struct link *) data;
+   struct ocxl_link *link = (struct ocxl_link *) data;
struct spa *spa = link->spa;
u64 dsisr, dar, pe_handle;
struct pe_data *pe_data;
@@ -256,7 +256,7 @@ static int map_irq_registers(struct pci_dev *dev, struct 
spa *spa)
>reg_tfc, >reg_pe_handle);
  }
  
-static int setup_xsl_irq(struct pci_dev *dev, struct link *link)

+static int setup_xsl_irq(struct pci_dev *dev, struct ocxl_link *link)
  {
struct spa *spa = link->spa;
int rc;
@@ -311,7 +311,7 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link 
*link)
return rc;
  }
  
-static void release_xsl_irq(struct link *link)

+static void release_xsl_irq(struct ocxl_link *link)
  {
struct spa *spa = link->spa;
  
@@ -323,7 +323,7 @@ static void release_xsl_irq(struct link *link)

unmap_irq_registers(spa);
  }
  
-static int alloc_spa(struct pci_dev *dev, struct link *link)

+static int alloc_spa(struct pci_dev *dev, struct ocxl_link *link)
  {
struct spa *spa;
  
@@ -350,7 +350,7 @@ static int alloc_spa(struct pci_dev *dev, struct link *link)

return 0;
  }
  
-static void free_spa(struct link *link)

+static void free_spa(struct ocxl_link *link)
  {
struct spa *spa = link->spa;
  
@@ -364,12 +364,12 @@ static void free_spa(struct link *link)

}
  }
  
-static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link)

+static int alloc_link(struct pci_dev *dev, int PE_mask, struct ocxl_link 
**out_link)
  {
-   struct link *link;
+   struct ocxl_link *link;
int rc;
  
-	link = kzalloc(sizeof(struct link), GFP_KERNEL);

+   link = kzalloc(sizeof(struct ocxl_link), GFP_KERNEL);
if (!link)
return -ENOMEM;
  
@@ -405,7 +405,7 @@ static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link)

return rc;
  }
  
-static void free_link(struct link *link)

+static void free_link(struct ocxl_link *link)
  {
release_xsl_irq(link);
free_spa(link);
@@ -415,7 +415,7 @@ static void free_link(struct link *link)
  int ocxl_link_setup(struct pci_dev *dev, int PE_mask, void **link_handle)
  {
int rc = 0;
-   struct link *link;
+   struct ocxl_link *link;
  
  	mutex_lock(_list_lock);

list_for_each_entry(link, _list, list) {
@@ -442,7 +442,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_setup);
  
  static void release_xsl(struct kref *ref)

  {
-   struct link *link = container_of(ref, struct link, ref);
+   struct ocxl_link *link = container_of(ref, struct ocxl_link, ref);
  
  	list_del(>list);

/* call platform code before releasing data */
@@ -452,7 +452,7 @@ static void release_xsl(struct kref *ref)
  
  void ocxl_link_release(struct pci_dev *dev, void *link_handle)

  {
-   struct link *link = (struct link *) link_handle;
+   struct ocxl_link *link = (struct ocxl_link *) link_handle;
  
  	mutex_lock(_list_lock);

kref_put(>ref, release_xsl);
@@ -488,7 +488,7 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 
pidr, u32 tidr,
void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr),
void *xsl_err_data)
  {
-   struct link *link = (struct link *) link_handle;
+   struct ocxl_link *link = (struct ocxl_link *) link_handle;
struct spa *spa = link->spa;
struct 

Re: CONFIG_KCOV causing crash in svm_vcpu_run()

2019-02-26 Thread Eric Biggers
Reviving this old thread because it wasn't fully fixed after all...

On Tue, May 15, 2018 at 07:33:48AM +0200, Dmitry Vyukov wrote:
> On Mon, May 14, 2018 at 7:25 PM, Eric Biggers  wrote:
> > On Mon, May 14, 2018 at 07:14:41AM +0200, Dmitry Vyukov wrote:
> >> On Mon, May 14, 2018 at 5:02 AM, Eric Biggers  wrote:
> >> > Sorry, messed up address for KVM mailing list.  See message below.
> >> >
> >> > On Sun, May 13, 2018 at 08:00:07PM -0700, Eric Biggers wrote:
> >> >> With CONFIG_KCOV=y and an AMD processor, running the following program 
> >> >> crashes
> >> >> the kernel with no output (I'm testing in a VM, so it's using nested
> >> >> virtualization):
> >> >>
> >> >>   #include 
> >> >>   #include 
> >> >>   #include 
> >> >>
> >> >>   int main()
> >> >>   {
> >> >>   int dev, vm, cpu;
> >> >>   char page[4096] __attribute__((aligned(4096))) = { 0 };
> >> >>   struct kvm_userspace_memory_region memreg = {
> >> >>   .memory_size = 4096,
> >> >>   .userspace_addr = (unsigned long)page,
> >> >>   };
> >> >>   dev = open("/dev/kvm", O_RDONLY);
> >> >>   vm = ioctl(dev, KVM_CREATE_VM, 0);
> >> >>   cpu = ioctl(vm, KVM_CREATE_VCPU, 0);
> >> >>   ioctl(vm, KVM_SET_USER_MEMORY_REGION, );
> >> >>   ioctl(cpu, KVM_RUN, 0);
> >> >>   }
> >> >>
> >> >> It bisects down to commit b2ac58f90540e39 ("KVM/SVM: Allow direct 
> >> >> access to
> >> >> MSR_IA32_SPEC_CTRL").  The bug is apparently that due to the new code 
> >> >> for
> >> >> managing the SPEC_CTRL MSR, __sanitizer_cov_trace_pc() is being called 
> >> >> from
> >> >> svm_vcpu_run() before the host's MSR_GS_BASE has been restored, which 
> >> >> causes a
> >> >> crash somehow.  The following patch fixes it, though I don't know that 
> >> >> it's the
> >> >> right solution; maybe KCOV should be disabled in the function instead, 
> >> >> or maybe
> >> >> there's a more fundamental problem.  What do people think?
> >>
> >>
> >> If __sanitizer_cov_trace_pc() crashes, I would expect there must be
> >> few more of them here:
> >>
> >> if (unlikely(!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)))
> >> svm->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL);
> >>
> >> if (svm->spec_ctrl)
> >> native_wrmsrl(MSR_IA32_SPEC_CTRL, 0);
> >>
> >> Compiler inserts these callbacks into every basic block/edge.. Aren't 
> >> there?
> >>
> >> Unfortunately we don't have an attribute that disables instrumentation
> >> of a single function. This is currently possible only on file level.
> >>
> >
> > Yes, due to the code dealing with MSR_IA32_SPEC_CTRL, there were several 
> > calls
> > to __sanitizer_cov_trace_pc() before the write to MSR_GS_BASE.  The patch I
> > tested moves the write to MSR_GS_BASE to before all of them, so it's once 
> > again
> > the first thing after the asm block.  Again I'm not sure it's the proper
> > solution, but it did make it stop crashing.
> 
> From KCOV perspective:
> This is definitely the simplest and less intrusive solution.
> It's somewhat unreliable. But it's hard to tell if/when it will
> actually break in practice. Compiler can decide to insert the callback
> after asm block, or a branch can be added to wrmsrl (e.g. under some
> debug config). More reliable solution would be to restore registers in
> asm block itself, or move this to a separate file and disable
> instrumentation of that file (though, will not save from non-inlined
> wrmsrl). But again, the proposed solution may work well for the next
> 10 years, so additional complexity may not worth it.
> 
> Btw, I don't see anything about fs/gs in vmx_vcpu_run. Is it VMLAUNCH
> that saves/restores them?

So it turns out there *is* a branch in wrmsrl() when CONFIG_PARAVIRT=y &&
CONFIG_PARAVIRT_DEBUG=y, and that causes the same crash: the compiler inserts a
call to __sanitizer_cov_trace_pc() prior to the GS_BASE register being restored
in svm_vcpu_run().

#ifdef CONFIG_PARAVIRT_DEBUG
#define PVOP_TEST_NULL(op)  BUG_ON(pv_ops.op == NULL)
#else
#define PVOP_TEST_NULL(op)  ((void)pv_ops.op)
#endif

Dmitry, in the long run maybe this should be solved by adding a function
attribute to gcc that disables coverage for a function?

But for now maybe CONFIG_KCOV should depend on !CONFIG_PARAVIRT_DEBUG?  Or does
anyone have a better idea?  Alternatively as Dmitry suggested, svm_vcpu_run()
could be moved to a separate file and compiled with different flags...

- Eric


[PATCH -next] habanalabs: goya: Make some functions static

2019-02-26 Thread Yue Haibing
From: YueHaibing 

Fixes the following sparse warnings:

drivers/misc/habanalabs/goya/goya.c:1233:5: warning: symbol 
'goya_init_cpu_queues' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:2914:5: warning: symbol 'goya_suspend' was 
not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:2939:5: warning: symbol 'goya_resume' was 
not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:2952:5: warning: symbol 'goya_mmap' was not 
declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:2957:5: warning: symbol 'goya_cb_mmap' was 
not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:2973:6: warning: symbol 
'goya_ring_doorbell' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3063:6: warning: symbol 
'goya_flush_pq_write' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3068:6: warning: symbol 
'goya_dma_alloc_coherent' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3074:6: warning: symbol 
'goya_dma_free_coherent' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3080:6: warning: symbol 
'goya_get_int_queue_base' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3138:5: warning: symbol 
'goya_send_job_on_qman0' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3295:5: warning: symbol 'goya_test_queue' 
was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3411:6: warning: symbol 
'goya_dma_pool_zalloc' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3420:6: warning: symbol 
'goya_dma_pool_free' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3426:6: warning: symbol 
'goya_cpu_accessible_dma_pool_alloc' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3442:6: warning: symbol 
'goya_cpu_accessible_dma_pool_free' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3452:5: warning: symbol 'goya_dma_map_sg' 
was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3461:6: warning: symbol 'goya_dma_unmap_sg' 
was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:3467:5: warning: symbol 
'goya_get_dma_desc_list_size' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:396:5: warning: symbol 
'goya_send_pci_access_msg' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:417:5: warning: symbol 'goya_pci_bars_map' 
was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:4202:5: warning: symbol 
'goya_parse_cb_no_mmu' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:4253:5: warning: symbol 
'goya_parse_cb_no_ext_quque' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:4286:5: warning: symbol 'goya_cs_parser' 
was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:4299:6: warning: symbol 
'goya_add_end_of_cb_packets' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:557:6: warning: symbol 
'goya_reset_link_through_bridge' was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:774:5: warning: symbol 'goya_early_fini' 
was not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:857:6: warning: symbol 'goya_late_fini' was 
not declared. Should it be static?
drivers/misc/habanalabs/goya/goya.c:971:5: warning: symbol 'goya_sw_fini' was 
not declared. Should it be static?

Signed-off-by: YueHaibing 
---
 drivers/misc/habanalabs/goya/goya.c | 86 +++--
 1 file changed, 44 insertions(+), 42 deletions(-)

diff --git a/drivers/misc/habanalabs/goya/goya.c 
b/drivers/misc/habanalabs/goya/goya.c
index fc53cdb..e0f1ba6 100644
--- a/drivers/misc/habanalabs/goya/goya.c
+++ b/drivers/misc/habanalabs/goya/goya.c
@@ -393,7 +393,7 @@ static void goya_get_fixed_properties(struct hl_device 
*hdev)
prop->high_pll = PLL_HIGH_DEFAULT;
 }
 
-int goya_send_pci_access_msg(struct hl_device *hdev, u32 opcode)
+static int goya_send_pci_access_msg(struct hl_device *hdev, u32 opcode)
 {
struct armcp_packet pkt;
 
@@ -414,7 +414,7 @@ int goya_send_pci_access_msg(struct hl_device *hdev, u32 
opcode)
  * Returns 0 on success
  *
  */
-int goya_pci_bars_map(struct hl_device *hdev)
+static int goya_pci_bars_map(struct hl_device *hdev)
 {
struct pci_dev *pdev = hdev->pdev;
int rc;
@@ -554,7 +554,7 @@ static int goya_iatu_write(struct hl_device *hdev, u32 
addr, u32 data)
return 0;
 }
 
-void goya_reset_link_through_bridge(struct hl_device *hdev)
+static void goya_reset_link_through_bridge(struct hl_device *hdev)
 {
struct pci_dev *pdev = hdev->pdev;
struct pci_dev *parent_port;
@@ -771,7 +771,7 @@ static int goya_early_init(struct hl_device *hdev)
  * Unmap PCI bars
  *
  */
-int 

[PATCH v2] arm64: dts: qcom: sdm845: Add GEN2 PCIe controller and PHY

2019-02-26 Thread Bjorn Andersson
SDM845 sports two PCIe controller/phy pairs; one GEN2 and one GEN3. Add
the nodes for the GEN2 pair.

Signed-off-by: Bjorn Andersson 
---

Changes since v1:
- "reg" is spelled without a 't'

 arch/arm64/boot/dts/qcom/sdm845.dtsi | 103 +++
 1 file changed, 103 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi 
b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 5308f1671824..35887fedfd0e 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -1024,6 +1024,109 @@
};
};
 
+   pcie0: pci@1c0 {
+   compatible = "qcom,pcie-sdm845", "snps,dw-pcie";
+   reg = <0 0x01c0 0 0x2000>,
+ <0 0x6000 0 0xf1d>,
+ <0 0x6f20 0 0xa8>,
+ <0 0x6010 0 0x10>;
+   reg-names = "parf", "dbi", "elbi", "config";
+   device_type = "pci";
+   linux,pci-domain = <0>;
+   bus-range = <0x00 0xff>;
+   num-lanes = <1>;
+
+   #address-cells = <3>;
+   #size-cells = <2>;
+
+   ranges = <0x0100 0x0 0x6020 0 0x6020 0x0 
0x10>,
+<0x0200 0x0 0x6030 0 0x6030 0x0 
0xd0>;
+
+   interrupts = ;
+   interrupt-names = "msi";
+   #interrupt-cells = <1>;
+   interrupt-map-mask = <0 0 0 0x7>;
+   interrupt-map = <0 0 0 1  0 149 
IRQ_TYPE_LEVEL_HIGH>, /* int_a */
+   <0 0 0 2  0 150 
IRQ_TYPE_LEVEL_HIGH>, /* int_b */
+   <0 0 0 3  0 151 
IRQ_TYPE_LEVEL_HIGH>, /* int_c */
+   <0 0 0 4  0 152 
IRQ_TYPE_LEVEL_HIGH>; /* int_d */
+
+   clocks = < GCC_PCIE_0_PIPE_CLK>,
+< GCC_PCIE_0_AUX_CLK>,
+< GCC_PCIE_0_CFG_AHB_CLK>,
+< GCC_PCIE_0_MSTR_AXI_CLK>,
+< GCC_PCIE_0_SLV_AXI_CLK>,
+< GCC_PCIE_0_SLV_Q2A_AXI_CLK>,
+< GCC_AGGRE_NOC_PCIE_TBU_CLK>;
+   clock-names = "pipe",
+ "aux",
+ "cfg",
+ "bus_master",
+ "bus_slave",
+ "slave_q2a",
+ "tbu";
+
+   iommu-map = <0x0 _smmu 0x1c10 0x1>,
+   <0x100 _smmu 0x1c11 0x1>,
+   <0x200 _smmu 0x1c12 0x1>,
+   <0x300 _smmu 0x1c13 0x1>,
+   <0x400 _smmu 0x1c14 0x1>,
+   <0x500 _smmu 0x1c15 0x1>,
+   <0x600 _smmu 0x1c16 0x1>,
+   <0x700 _smmu 0x1c17 0x1>,
+   <0x800 _smmu 0x1c18 0x1>,
+   <0x900 _smmu 0x1c19 0x1>,
+   <0xa00 _smmu 0x1c1a 0x1>,
+   <0xb00 _smmu 0x1c1b 0x1>,
+   <0xc00 _smmu 0x1c1c 0x1>,
+   <0xd00 _smmu 0x1c1d 0x1>,
+   <0xe00 _smmu 0x1c1e 0x1>,
+   <0xf00 _smmu 0x1c1f 0x1>;
+
+   resets = < GCC_PCIE_0_BCR>;
+   reset-names = "pci";
+
+   power-domains = < PCIE_0_GDSC>;
+
+   phys = <_lane>;
+   phy-names = "pciephy";
+
+   status = "disabled";
+   };
+
+   pcie0_phy: phy@1c06000 {
+   compatible = "qcom,sdm845-qmp-pcie-phy";
+   reg = <0 0x01c06000 0 0x18c>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   clocks = < GCC_PCIE_PHY_AUX_CLK>,
+< GCC_PCIE_0_CFG_AHB_CLK>,
+< GCC_PCIE_0_CLKREF_CLK>,
+< GCC_PCIE_PHY_REFGEN_CLK>;
+   clock-names = "aux", "cfg_ahb", "ref", "refgen";
+
+   resets = < GCC_PCIE_0_PHY_BCR>;
+   reset-names = "phy";
+
+   assigned-clocks = < GCC_PCIE_PHY_REFGEN_CLK>;
+   assigned-clock-rates = <1>;
+
+   status = "disabled";
+
+   pcie0_lane: lanes@1c06200 {
+  

[PATCH] phy: renesas: rcar-gen2: Fix memory leak at error paths

2019-02-26 Thread Yoshihiro Shimoda
This patch fixes memory leak at error paths of the probe function.
In for_each_child_of_node, if the loop returns, the driver should
call of_put_node() before returns.

Reported-by: Julia Lawall 
Fixes: 1233f59f745 ("phy: Renesas R-Car Gen2 PHY driver")
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/phy/renesas/phy-rcar-gen2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/phy/renesas/phy-rcar-gen2.c 
b/drivers/phy/renesas/phy-rcar-gen2.c
index 72eeb06..570b4e4 100644
--- a/drivers/phy/renesas/phy-rcar-gen2.c
+++ b/drivers/phy/renesas/phy-rcar-gen2.c
@@ -285,6 +285,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
error = of_property_read_u32(np, "reg", _num);
if (error || channel_num > 2) {
dev_err(dev, "Invalid \"reg\" property\n");
+   of_node_put(np);
return error;
}
channel->select_mask = select_mask[channel_num];
@@ -300,6 +301,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
   _gen2_phy_ops);
if (IS_ERR(phy->phy)) {
dev_err(dev, "Failed to create PHY\n");
+   of_node_put(np);
return PTR_ERR(phy->phy);
}
phy_set_drvdata(phy->phy, phy);
-- 
2.7.4



Re: [PATCH v8 02/11] powerpc: prepare string/mem functions for KASAN

2019-02-26 Thread Daniel Axtens
Christophe Leroy  writes:

> CONFIG_KASAN implements wrappers for memcpy() memmove() and memset()
> Those wrappers are doing the verification then call respectively
> __memcpy() __memmove() and __memset(). The arches are therefore
> expected to rename their optimised functions that way.
>
> For files on which KASAN is inhibited, #defines are used to allow
> them to directly call optimised versions of the functions without
> going through the KASAN wrappers.
>
> See commit 393f203f5fd5 ("x86_64: kasan: add interceptors for
> memset/memmove/memcpy functions") for details.
>
> Other string / mem functions do not (yet) have kasan wrappers,
> we therefore have to fallback to the generic versions when
> KASAN is active, otherwise KASAN checks will be skipped.
>
> Signed-off-by: Christophe Leroy 
> ---
>  arch/powerpc/include/asm/kasan.h   | 15 +++
>  arch/powerpc/include/asm/string.h  | 32 +---
>  arch/powerpc/kernel/prom_init_check.sh | 10 +-
>  arch/powerpc/lib/Makefile  | 11 ---
>  arch/powerpc/lib/copy_32.S | 15 +--
>  arch/powerpc/lib/mem_64.S  | 11 +++
>  arch/powerpc/lib/memcpy_64.S   |  5 +++--
>  7 files changed, 80 insertions(+), 19 deletions(-)
>  create mode 100644 arch/powerpc/include/asm/kasan.h
>
> diff --git a/arch/powerpc/include/asm/kasan.h 
> b/arch/powerpc/include/asm/kasan.h
> new file mode 100644
> index ..c3161b8fc017
> --- /dev/null
> +++ b/arch/powerpc/include/asm/kasan.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __ASM_KASAN_H
> +#define __ASM_KASAN_H
> +
> +#ifdef CONFIG_KASAN
> +#define _GLOBAL_KASAN(fn).weak fn ; _GLOBAL(__##fn) ; _GLOBAL(fn)
> +#define _GLOBAL_TOC_KASAN(fn).weak fn ; _GLOBAL_TOC(__##fn) ; 
> _GLOBAL_TOC(fn)
> +#define EXPORT_SYMBOL_KASAN(fn)  EXPORT_SYMBOL(__##fn) ; 
> EXPORT_SYMBOL(fn)

[FWIW, and this shouldn't block your patch:] This doesn't seem to work
with the 64bit elf abi v1, as we have symbols and dot symbols - our
_GLOBAL* doesn't just create a symtab entry. I don't fully understand
the inner workings just yet, but Aneesh and Balbir have solutions that
use .set instead of creating two entries.

What I am also struggling with is why we export the __symbol
version. I know the x86 version does this, but I can't figure that out
either - why would a module need an uninstrumented copy?

Anyway, I am getting some issues such as:

WARNING: EXPORT symbol "__memcpy" [vmlinux] version generation failed, symbol 
will not be versioned.
WARNING: EXPORT symbol "__memset" [vmlinux] version generation failed, symbol 
will not be versioned.
WARNING: EXPORT symbol "__memmove" [vmlinux] version generation failed, symbol 
will not be versioned.

I think Balbir and Aneesh avoided this by just not ever exporting the
__symbol versions, but perhaps that won't fly for the final version. It
looks like we can also avoid this by jumping through some extra hoops
and creating new weak symbols - I'll keep working on it and let you know
how I go.

As I said, I don't think this should necessarily block your patches -
it's just notes on ppc64 progress.

Regards,
Daniel

> +#else
> +#define _GLOBAL_KASAN(fn)_GLOBAL(fn)
> +#define _GLOBAL_TOC_KASAN(fn)_GLOBAL_TOC(fn)
> +#define EXPORT_SYMBOL_KASAN(fn)  EXPORT_SYMBOL(fn)
> +#endif
> +
> +#endif
> diff --git a/arch/powerpc/include/asm/string.h 
> b/arch/powerpc/include/asm/string.h
> index 1647de15a31e..9bf6dffb4090 100644
> --- a/arch/powerpc/include/asm/string.h
> +++ b/arch/powerpc/include/asm/string.h
> @@ -4,14 +4,17 @@
>  
>  #ifdef __KERNEL__
>  
> +#ifndef CONFIG_KASAN
>  #define __HAVE_ARCH_STRNCPY
>  #define __HAVE_ARCH_STRNCMP
> +#define __HAVE_ARCH_MEMCHR
> +#define __HAVE_ARCH_MEMCMP
> +#define __HAVE_ARCH_MEMSET16
> +#endif
> +
>  #define __HAVE_ARCH_MEMSET
>  #define __HAVE_ARCH_MEMCPY
>  #define __HAVE_ARCH_MEMMOVE
> -#define __HAVE_ARCH_MEMCMP
> -#define __HAVE_ARCH_MEMCHR
> -#define __HAVE_ARCH_MEMSET16
>  #define __HAVE_ARCH_MEMCPY_FLUSHCACHE
>  
>  extern char * strcpy(char *,const char *);
> @@ -27,7 +30,27 @@ extern int memcmp(const void *,const void 
> *,__kernel_size_t);
>  extern void * memchr(const void *,int,__kernel_size_t);
>  extern void * memcpy_flushcache(void *,const void *,__kernel_size_t);
>  
> +void *__memset(void *s, int c, __kernel_size_t count);
> +void *__memcpy(void *to, const void *from, __kernel_size_t n);
> +void *__memmove(void *to, const void *from, __kernel_size_t n);
> +
> +#if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
> +/*
> + * For files that are not instrumented (e.g. mm/slub.c) we
> + * should use not instrumented version of mem* functions.
> + */
> +#define memcpy(dst, src, len) __memcpy(dst, src, len)
> +#define memmove(dst, src, len) __memmove(dst, src, len)
> +#define memset(s, c, n) __memset(s, c, n)
> +
> +#ifndef __NO_FORTIFY
> +#define __NO_FORTIFY /* FORTIFY_SOURCE uses 

Re: [PATCH] powerpc/fsl: Fix the flush of branch predictor.

2019-02-26 Thread Diana Madalina Craciun
Reviewed-by: Diana Craciun 

Thanks for fixing it!

On 2/26/2019 8:18 PM, Christophe Leroy wrote:
> The commit identified below adds MC_BTB_FLUSH macro only when
> CONFIG_PPC_FSL_BOOK3E is defined. This results in the following error
> on some configs (seen several times with kisskb randconfig_defconfig)
>
> arch/powerpc/kernel/exceptions-64e.S:576: Error: Unrecognized opcode: 
> `mc_btb_flush'
> make[3]: *** [scripts/Makefile.build:367: 
> arch/powerpc/kernel/exceptions-64e.o] Error 1
> make[2]: *** [scripts/Makefile.build:492: arch/powerpc/kernel] Error 2
> make[1]: *** [Makefile:1043: arch/powerpc] Error 2
> make: *** [Makefile:152: sub-make] Error 2
>
> This patch adds a blank definition of MC_BTB_FLUSH for other cases.
>
> Fixes: 10c5e83afd4a ("powerpc/fsl: Flush the branch predictor at each kernel 
> entry (64bit)")
> Cc: Diana Craciun 
> Signed-off-by: Christophe Leroy 
> ---
>  arch/powerpc/kernel/exceptions-64e.S | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/kernel/exceptions-64e.S 
> b/arch/powerpc/kernel/exceptions-64e.S
> index 4549ce8d4637..49381f32b374 100644
> --- a/arch/powerpc/kernel/exceptions-64e.S
> +++ b/arch/powerpc/kernel/exceptions-64e.S
> @@ -338,6 +338,7 @@ ret_from_mc_except:
>  #define GEN_BTB_FLUSH
>  #define CRIT_BTB_FLUSH
>  #define DBG_BTB_FLUSH
> +#define MC_BTB_FLUSH
>  #define GDBELL_BTB_FLUSH
>  #endif
>  




Re: [PATCH 0/5] PCI: dwc: support remove

2019-02-26 Thread Jisheng Zhang
On Tue, 26 Feb 2019 15:11:03 -0600 Bjorn Helgaas wrote:

> 
> 
> On Tue, Feb 26, 2019 at 5:55 AM Jisheng Zhang
>  wrote:
> >
> > Currently, the PCI dwc host users don't support the remove, but nothing
> > prevent us from supporting it. To achieve this goal, we need to ensure
> > we can do necessary clean up work.
> >
> > Jisheng Zhang (5):
> >   PCI: dwc: fix dw_pcie_free_msi() if msi_irq is invalid
> >   PCI: dwc: free the page for MSI irq in dw_pcie_free_msi()
> >   PCI: dwc: free msi in the error code path of dw_pcie_host_init()
> >   PCI: dwc: use devm_pci_alloc_host_bridge() to simplify the code
> >   PCI: dwc: save root bus for driver remove  
> 
> If you post a v2 of this series, please:
> 
> Capitalize the first word of each subject, e.g., "PCI: dwc: Fix
> dw_pcie_free_msi() if msi_irq is invalid"
> s/irq/IRQ/
> s/msi/MSI/

Thanks for the review. Will do when post a v2. I'm still trying to
collect more code review comments.

Thanks


linux-next: Tree for Feb 27

2019-02-26 Thread Stephen Rothwell
Hi all,

Changes since 20190226:

The mmc-fixes tree still has its build failure for which I reverted a commit.

The hwmon-staging tree lost its build failure.

The net-next tree gained a conflict against the rdma tree.

The vhost tree gained a conflict against the iommu tree.

Non-merge commits (relative to Linus' tree): 10271
 10297 files changed, 462743 insertions(+), 241783 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a
multi_v7_defconfig for arm and a native build of tools/perf. After
the final fixups (if any), I do an x86_64 modules_install followed by
builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit),
ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc
and sparc64 defconfig. And finally, a simple boot test of the powerpc
pseries_le_defconfig kernel in qemu (with and without kvm enabled).

Below is a summary of the state of the merge.

I am currently merging 297 trees (counting Linus' and 69 trees of bug
fix patches pending for the current merge release).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (7d762d69145a afs: Fix manually set volume location 
server list)
Merging fixes/master (ed3ce4cfc919 adfs: mark expected switch fall-throughs)
Merging kspp-gustavo/for-next/kspp (6f6c95f09001 ASN.1: mark expected switch 
fall-through)
Merging kbuild-current/fixes (207a369e3c08 sh: fix build error for invisible 
CONFIG_BUILTIN_DTB_SOURCE)
Merging arc-current/for-curr (85d6adcbbe6d ARC: boot log: cut down on verbosity)
Merging arm-current/fixes (d410a8a49e3e ARM: 8849/1: NOMMU: Fix encodings for 
PMSAv8's PRBAR4/PRLAR4)
Merging arm64-fixes/for-next/fixes (74698f6971f2 arm64: Relax GIC version check 
during early boot)
Merging m68k-current/for-linus (bed1369f5190 m68k: Fix memblock-related crashes)
Merging powerpc-fixes/fixes (8f5b27347e88 powerpc/powernv/sriov: Register IOMMU 
groups for VFs)
Merging sparc/master (7d762d69145a afs: Fix manually set volume location server 
list)
Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2)
Merging net/master (3da1ed7ac398 net: avoid use IPCB in cipso_v4_error)
Merging bpf/master (781e62823cb8 bpf: decrease usercnt if bpf_map_new_fd() 
fails in bpf_map_get_fd_by_id())
Merging ipsec/master (660899ddf06a xfrm: Fix inbound traffic via XFRM 
interfaces across network namespaces)
Merging netfilter/master (ecef67cb10db tun: remove unnecessary memory barrier)
Merging ipvs/master (b2e3d68d1251 netfilter: nft_compat: destroy function must 
not have side effects)
Merging wireless-drivers/master (d04ca383860b mt76x0u: fix suspend/resume)
Merging mac80211/master (51d0af222f6f mac80211: allocate tailroom for forwarded 
mesh packets)
Merging rdma-fixes/for-rc (f09ef134a7ca iw_cxgb4: cq/qp mask depends on bar2 
pages in a host page)
Merging sound-current/for-linus (268836649c07 Merge tag 'asoc-fix-v5.0-rc6' of 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus)
Merging sound-asoc-fixes/for-linus (b5e806ae4ad8 Merge branch 'asoc-5.0' into 
asoc-linus)
Merging regmap-fixes/for-linus (f17b5f06cb92 Linux 5.0-rc4)
Merging regulator-fixes/for-linus (8cd0aeaa0868 Merge branch 'regulator-5.0' 
into regulator-linus)
Merging spi-fixes/for-linus (22e78ec655e8 Merge branch 'spi-5.0' into spi-linus)
Merging pci-current/for-linus (f57a98e1b713 PCI: Work around Synopsys duplicate 
Device ID (HAPS USB3, NXP i.MX))
Merging driver-core.current/driver-core-linus (d13937116f1e Linux 5.0-rc6)
Merging tty.current/tty-linus (d13937116f1e Linux 5.0-rc6)
Merging usb.current/usb-linus (d13937116f1e Linux 5.0-rc6)
Merging usb-gadget-fixes/fixes (a53469a68eb8 usb: phy: am335x: fix race 
condition in _probe)
Merging usb-serial-fixes/usb-linus (8d7fa3d4ea3f USB: serial: ftdi_sio: add ID 
for Hjelmslund Electronics USB485)
Merging usb-chipidea-fix

[PATCH v4 5/5] arm64: dts: imx8mq-evk: Enable wm8524 codec

2019-02-26 Thread Daniel Baluta
This uses simple-audio-card machine driver adding 1 CPU DAI
and 1 Codec DAI.

Signed-off-by: Daniel Baluta 
---
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts | 29 
 1 file changed, 29 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-evk.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
index 58de4a3d6029..77f590c13ee0 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
@@ -31,6 +31,35 @@
gpio = < 19 GPIO_ACTIVE_HIGH>;
enable-active-high;
};
+
+   wm8524: audio-codec-0 {
+   #sound-dai-cells = <0>;
+   compatible = "wlf,wm8524";
+   clocks = < IMX8MQ_CLK_SAI2_ROOT>;
+   clock-names = "mclk";
+   wlf,mute-gpios = < 8 GPIO_ACTIVE_LOW>;
+   };
+
+   sound-wm8524 {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "wm8524-audio";
+   simple-audio-card,format = "i2s";
+   simple-audio-card,frame-master = <>;
+   simple-audio-card,bitclock-master = <>;
+   simple-audio-card,widgets =
+   "Line", "Left Line Out Jack",
+   "Line", "Right Line Out Jack";
+   simple-audio-card,routing =
+   "Left Line Out Jack", "LINEVOUTL",
+   "Right Line Out Jack", "LINEVOUTR";
+   cpudai: simple-audio-card,cpu {
+   sound-dai = <>;
+   };
+   link_codec: simple-audio-card,codec {
+   sound-dai = <>;
+   clocks = < IMX8MQ_CLK_SAI2_ROOT>;
+   };
+   };
 };
 
  {
-- 
2.17.1



[PATCH v4 3/5] arm64: dts: imx8mq: Add SAI2 node

2019-02-26 Thread Daniel Baluta
SAI2 is part of AIPS-3 memory region.

Signed-off-by: Daniel Baluta 
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 9d48450453fb..565f4175e73b 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -489,6 +489,22 @@
status = "disabled";
};
 
+   sai2: sai@308b {
+   #sound-dai-cells = <0>;
+   compatible = "fsl,imx8mq-sai",
+"fsl,imx6sx-sai";
+   reg = <0x308b 0x1>;
+   interrupts = ;
+   clocks = < IMX8MQ_CLK_SAI2_IPG>,
+< IMX8MQ_CLK_DUMMY>,
+< IMX8MQ_CLK_SAI2_ROOT>,
+< IMX8MQ_CLK_DUMMY>, < 
IMX8MQ_CLK_DUMMY>;
+   clock-names = "bus", "mclk0", "mclk1", "mclk2", 
"mclk3";
+   dmas = < 10 24 0>, < 11 24 0>;
+   dma-names = "rx", "tx";
+   status = "disabled";
+   };
+
i2c1: i2c@30a2 {
compatible = "fsl,imx8mq-i2c", "fsl,imx21-i2c";
reg = <0x30a2 0x1>;
-- 
2.17.1



[PATCH v4 1/5] arm64: dts: imx8mq: Add SDMA nodes

2019-02-26 Thread Daniel Baluta
SDMA1 is part of AIPS-3 region and SDMA2 is part
of AIPS-1 region.

Signed-off-by: Anson Huang 
[initial submit in i.MX internal tree]
Signed-off-by: Daniel Baluta 
[adaptation for linux-next]
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 9155bd4784eb..9d48450453fb 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -234,6 +234,17 @@
status = "disabled";
};
 
+   sdma2: sdma@302c {
+   compatible = "fsl,imx8mq-sdma","fsl,imx7d-sdma";
+   reg = <0x302c 0x1>;
+   interrupts = ;
+   clocks = < IMX8MQ_CLK_SDMA2_ROOT>,
+< IMX8MQ_CLK_SDMA2_ROOT>;
+   clock-names = "ipg", "ahb";
+   #dma-cells = <3>;
+   fsl,sdma-ram-script-name = 
"imx/sdma/sdma-imx7d.bin";
+   };
+
iomuxc: iomuxc@3033 {
compatible = "fsl,imx8mq-iomuxc";
reg = <0x3033 0x1>;
@@ -575,6 +586,17 @@
status = "disabled";
};
 
+   sdma1: sdma@30bd {
+   compatible = "fsl, 
imx8mq-sdma","fsl,imx7d-sdma";
+   reg = <0x30bd 0x1>;
+   interrupts = ;
+   clocks = < IMX8MQ_CLK_SDMA1_ROOT>,
+< IMX8MQ_CLK_SDMA1_ROOT>;
+   clock-names = "ipg", "ahb";
+   #dma-cells = <3>;
+   fsl,sdma-ram-script-name = 
"imx/sdma/sdma-imx7d.bin";
+   };
+
fec1: ethernet@30be {
compatible = "fsl,imx8mq-fec", "fsl,imx6sx-fec";
reg = <0x30be 0x1>;
-- 
2.17.1



[PATCH v4 4/5] arm64: dts: imx8mq-evk: Enable SAI2 node

2019-02-26 Thread Daniel Baluta
This sets up clock hierarchy and pin configuration.

Use PLL1 to derive a proper rate for playing files
with a rate multiple of 8000.

Signed-off-by: Daniel Baluta 
---
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-evk.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
index 54737bf1772f..58de4a3d6029 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
@@ -52,6 +52,15 @@
};
 };
 
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_sai2>;
+   assigned-clocks = < IMX8MQ_CLK_SAI2>;
+   assigned-clock-parents = < IMX8MQ_AUDIO_PLL1_OUT>;
+   assigned-clock-rates = <24576000>;
+   status = "okay";
+};
+
  {
clock-frequency = <10>;
pinctrl-names = "default";
@@ -223,6 +232,16 @@
>;
};
 
+   pinctrl_sai2: sai2grp {
+   fsl,pins = <
+   MX8MQ_IOMUXC_SAI2_TXFS_SAI2_TX_SYNC 0xd6
+   MX8MQ_IOMUXC_SAI2_TXC_SAI2_TX_BCLK  0xd6
+   MX8MQ_IOMUXC_SAI2_MCLK_SAI2_MCLK0xd6
+   MX8MQ_IOMUXC_SAI2_TXD0_SAI2_TX_DATA00xd6
+   MX8MQ_IOMUXC_GPIO1_IO08_GPIO1_IO8   0xd6
+   >;
+   };
+
pinctrl_i2c1: i2c1grp {
fsl,pins = <
MX8MQ_IOMUXC_I2C1_SCL_I2C1_SCL  
0x407f
-- 
2.17.1



[PATCH v4 0/5] Enable wm8524 on i.MX8MQ-EVK

2019-02-26 Thread Daniel Baluta
On i.MX8MQ-EVK we can start the party using the wm8524 codec
which gets it's data through the SAI2 interface.

In order to make it work this patch series enables the SDMA nodes,
sets the correct pinctrl configuration and uses the simple card
machine driver to put everything together.

Changes since v3:
- use "arm64: dts: imx8mq-evk" prefix for patches specific to 8MQ-EVK
- squash together patches for setting up SAI (previous 3/5 and 4/5)
- add back and document "fsl, imx8mq-sdma" compatbile string

Changes since v2:
- s/QM/MQ after Chris comments

Changes since v1:
- added cover letter
- remove "fsl,imx8mq-sdma" compatible for sdma.

Daniel Baluta (5):
  arm64: dts: imx8mq: Add SDMA nodes
  bindings: fsl-imx-sdma: Document fsl,imx8mq-sdma compatbile string
  arm64: dts: imx8mq: Add SAI2 node
  arm64: dts: imx8mq-evk: Enable SAI2 node
  arm64: dts: imx8mq-evk: Enable wm8524 codec

 .../devicetree/bindings/dma/fsl-imx-sdma.txt  |  1 +
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts  | 48 +++
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 38 +++
 3 files changed, 87 insertions(+)

-- 
2.17.1



[PATCH v4 2/5] bindings: fsl-imx-sdma: Document fsl,imx8mq-sdma compatbile string

2019-02-26 Thread Daniel Baluta
Add imx8mq sdma support.

Signed-off-by: Daniel Baluta 
---
 Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt 
b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt
index 3c9a57a8443b..9d8bbac27d8b 100644
--- a/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt
+++ b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt
@@ -9,6 +9,7 @@ Required properties:
   "fsl,imx53-sdma"
   "fsl,imx6q-sdma"
   "fsl,imx7d-sdma"
+  "fsl,imx8mq-sdma"
   The -to variants should be preferred since they allow to determine the
   correct ROM script addresses needed for the driver to work without additional
   firmware.
-- 
2.17.1



Re: [PATCH v2 0/3] Bluetooth: hci_qca: Add delay after power-off pulse

2019-02-26 Thread Bjorn Andersson
On Tue, Feb 26, 2019 at 11:47 AM Matthias Kaehlcke  wrote:
>
> Initialization of the QCA WCN3990 often fails at boot time:
>
>  [   15.205224] Bluetooth: hci0: setting up wcn3990
>  [   17.341062] Bluetooth: hci0: command 0xfc00 tx timeout
>  [   22.101453] ERROR: Bluetooth initialization failed
>  [   25.337740] Bluetooth: hci0: Reading QCA version information failed (-110)
>
> A short delay after sending a power-off pulse (which is done immediately
> before sending a power-on pulse) fixes this.
>
> Also move the delays to qca_send_power_pulse(), since they are directly
> related with sending the pulses. Change the interface of
> qca_send_power_pulse() to receive a boolean instead of a power pulse
> command, this improves readability of the function with the delays
> added.
>

For the series:

Reviewed-by: Bjorn Andersson 

Regards,
Bjorn

> Matthias Kaehlcke (3):
>   Bluetooth: hci_qca: Pass boolean 'on/off' to qca_send_power_pulse()
>   Bluetooth: hci_qca: Move boot delay to qca_send_power_pulse()
>   Bluetooth: hci_qca: Add delay after power-off pulse
>
>  drivers/bluetooth/hci_qca.c | 21 +++--
>  1 file changed, 11 insertions(+), 10 deletions(-)
>
> --
> 2.21.0.rc2.261.ga7da99ff1b-goog
>


Re: [PATCH] MIPS: fix memory setup for platforms with PHY_OFFSET != 0

2019-02-26 Thread Mike Rapoport
Hi,

On Tue, Feb 26, 2019 at 03:06:32PM +0100, Thomas Bogendoerfer wrote:
> For platforms, which use a PHY_OFFSET != 0, symbol _end also

Nit: PHYS_OFFSET, the same typo in subject

> contains that offset. So when calling memblock_reserve() for
> reserving kernel and initrd the size argument needs to be
> adjusted.

The changelog mentions initrd, but the patch changes only the kernel
reservation. Can you please update the changelog to match the code?

> Fixes: bcec54bf3118 ("mips: switch to NO_BOOTMEM")
> Signed-off-by: Thomas Bogendoerfer 

With the amends above

Acked-by: Mike Rapoport 

> ---
>  arch/mips/kernel/setup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index 8c6c48ed786a..d2e5a5ad0e6f 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -384,7 +384,8 @@ static void __init bootmem_init(void)
>   init_initrd();
>   reserved_end = (unsigned long) PFN_UP(__pa_symbol(&_end));
> 
> - memblock_reserve(PHYS_OFFSET, reserved_end << PAGE_SHIFT);
> + memblock_reserve(PHYS_OFFSET,
> +  (reserved_end << PAGE_SHIFT) - PHYS_OFFSET);
> 
>   /*
>* max_low_pfn is not a number of pages. The number of pages
> -- 
> 2.13.7
> 

-- 
Sincerely yours,
Mike.



Re: kernel BUG at include/linux/mm.h:LINE! (3)

2019-02-26 Thread Dmitry Vyukov
On Wed, Feb 27, 2019 at 7:11 AM Eric Biggers  wrote:
>
> On Tue, Feb 26, 2019 at 10:02:04PM -0800, syzbot wrote:
> > Hello,
> >
> > syzbot found the following crash on:
> >
> > HEAD commit:8e7f81e2ebc4 Add linux-next specific files for 20190226
> > git tree:   linux-next
> > console output: https://syzkaller.appspot.com/x/log.txt?x=10381714c0
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=2fa10211b8a4a56e
> > dashboard link: https://syzkaller.appspot.com/bug?extid=a5b71df98b247d973f8c
> > compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14eda192c0
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=164831e0c0
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+a5b71df98b247d973...@syzkaller.appspotmail.com
> >
> > page:ea00025c3ac0 count:0 mapcount:0 mapping: index:0x0
> > flags: 0x1fffc00()
> > raw: 01fffc00 ea00024bf988 ea00021dd448 
> > raw:    
> > page dumped because: VM_BUG_ON_PAGE(page_ref_count(page) == 0)
> > [ cut here ]
> > kernel BUG at include/linux/mm.h:579!
> > invalid opcode:  [#1] PREEMPT SMP KASAN
> > CPU: 0 PID: 7779 Comm: syz-executor379 Not tainted 5.0.0-rc8-next-20190226
> > #43
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > Google 01/01/2011
> > RIP: 0010:put_page_testzero include/linux/mm.h:579 [inline]
> > RIP: 0010:put_page include/linux/mm.h:1025 [inline]
> > RIP: 0010:generic_pipe_buf_release+0x120/0x160 fs/pipe.c:224
> > Code: bd ff 4c 89 e7 e8 90 43 db ff e8 bb 29 bd ff 5b 41 5c 41 5d 5d c3 e8
> > af 29 bd ff 48 c7 c6 20 98 75 87 4c 89 e7 e8 c0 db e4 ff <0f> 0b e8 99 29 bd
> > ff 4d 8d 65 ff e9 3d ff ff ff 48 89 df e8 e8 f8
> > RSP: 0018:8880a503f920 EFLAGS: 00010293
> > RAX: 88808d2ec6c0 RBX: ea00025c3af4 RCX: 
> > RDX:  RSI: 81982852 RDI: ea00025c3af8
> > RBP: 8880a503f938 R08: 003e R09: ed1015d05011
> > R10: ed1015d05010 R11: 8880ae828087 R12: ea00025c3ac0
> > R13:  R14: 88809b6e8a40 R15: 8880952c4000
> > FS:  016a0880() GS:8880ae80() knlGS:
> > CS:  0010 DS:  ES:  CR0: 80050033
> > CR2: 20f50f90 CR3: 97b89000 CR4: 001406f0
> > Call Trace:
> >  pipe_buf_release include/linux/pipe_fs_i.h:129 [inline]
> >  iter_file_splice_write+0x7d1/0xbe0 fs/splice.c:759
> >  do_splice_from fs/splice.c:847 [inline]
> >  direct_splice_actor+0x126/0x1a0 fs/splice.c:1019
> >  splice_direct_to_actor+0x369/0x970 fs/splice.c:974
> >  do_splice_direct+0x1da/0x2a0 fs/splice.c:1062
> >  do_sendfile+0x597/0xd00 fs/read_write.c:1442
> >  __do_sys_sendfile64 fs/read_write.c:1503 [inline]
> >  __se_sys_sendfile64 fs/read_write.c:1489 [inline]
> >  __x64_sys_sendfile64+0x1dd/0x220 fs/read_write.c:1489
> >  do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
> >  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> > RIP: 0033:0x443d29
> > Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7
> > 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff
> > 0f 83 7b d8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
> > RSP: 002b:7fffc1e47c88 EFLAGS: 0246 ORIG_RAX: 0028
> > RAX: ffda RBX: 004002e0 RCX: 00443d29
> > RDX:  RSI: 0003 RDI: 0003
> > RBP: 006ce018 R08: 004002e0 R09: 004002e0
> > R10: 000102000300 R11: 0246 R12: 00401a30
> > R13: 00401ac0 R14:  R15: 
> > Modules linked in:
> > ---[ end trace 9daff95e0e1a45ff ]---
> > RIP: 0010:put_page_testzero include/linux/mm.h:579 [inline]
> > RIP: 0010:put_page include/linux/mm.h:1025 [inline]
> > RIP: 0010:generic_pipe_buf_release+0x120/0x160 fs/pipe.c:224
> > Code: bd ff 4c 89 e7 e8 90 43 db ff e8 bb 29 bd ff 5b 41 5c 41 5d 5d c3 e8
> > af 29 bd ff 48 c7 c6 20 98 75 87 4c 89 e7 e8 c0 db e4 ff <0f> 0b e8 99 29 bd
> > ff 4d 8d 65 ff e9 3d ff ff ff 48 89 df e8 e8 f8
> > RSP: 0018:8880a503f920 EFLAGS: 00010293
> > RAX: 88808d2ec6c0 RBX: ea00025c3af4 RCX: 
> > RDX:  RSI: 81982852 RDI: ea00025c

Re: [PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc

2019-02-26 Thread Joe Perches
On Tue, 2019-02-26 at 22:09 -0800, Robert Eshleman wrote:
> This patch replaces a pci_alloc_consistent and memset(,0) call
> with a single call to pci_zalloc_consistent.
[]
> diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
[]
> @@ -845,17 +845,16 @@ static int tlan_init(struct net_device *dev)
>  
>   dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS)
>   * (sizeof(struct tlan_list));
> - priv->dma_storage = pci_alloc_consistent(priv->pci_dev,
> -  dma_size,
> -  >dma_storage_dma);
> + priv->dma_storage = pci_zalloc_consistent(priv->pci_dev,
> +   dma_size,
> +   >dma_storage_dma);
>   priv->dma_size = dma_size;
>  
> - if (priv->dma_storage == NULL) {
> + if (!priv->dma_storage) {
>   pr_err("Could not allocate lists and buffers for %s\n",
>  dev->name);

unrelated trivia:

This pr_err (and likely others in this file)
could be replace by netdev_err




RE: [PATCH v4] arm64: Add workaround for Fujitsu A64FX erratum 010001

2019-02-26 Thread Zhang, Lei
Hi James,

> -Original Message-
> From: linux-arm-kernel  On
> Behalf Of James Morse
> Sent: Tuesday, February 26, 2019 2:29 AM
> To: Zhang, Lei/張 雷 
> Cc: Mark Rutland ; 'Catalin Marinas'
> ; 'Will Deacon' ;
> 'linux-kernel@vger.kernel.org' ;
> 'linux-arm-ker...@lists.infradead.org' 
> Subject: Re: [PATCH v4] arm64: Add workaround for Fujitsu A64FX erratum
> 010001
> 
> Hi Zhang,
> 
> On 23/02/2019 13:06, Zhang, Lei wrote:
> > Zhang, Lei wrote:
> >> I think you mean it may be a problem to modify the KPTI trampoline
> >> because some patches about KPTI will be merged to mainline in the near
> future.
> >> I understood that.
> >> I should discuss with my colleagues whether we can set NFDx=0 all of
> >> time on A64FX.
> >
> > The result of our investigation also supports your suggestion.
> > We surely agree with you that your proposed method (never set NFDx=1
> > on A64FX) is the best to resolve this erratum.
> >
> > For this erratum, James's patch should be merged to mainline instead
> > of my previous patches (v1 to v4).
> > Since KPTI fully covers the effect of NFD1 for A64FX, KPTI is
> > recommended to be used in conjunction with James’s patch.
> 
> >> And thanks for your patch.
> >> If we can set NFDx=0 all of time, I will review, test and report the 
> >> result.
> >
> > I have already tested James's patch on A64FX, and the result is no problem 
> > at
> all.
> >
> > Tested-by:zhang.lei
> 
> Thanks, I'll post it properly with this tag.
[>] 
I saw v5 patch you posted. Thanks a lot.

> 
> 
> >> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index
> >> a4168d366127..b0b7f1c4e816 100644
> >> --- a/arch/arm64/Kconfig
> >> +++ b/arch/arm64/Kconfig
> >> @@ -643,6 +643,25 @@ config QCOM_FALKOR_ERRATUM_E1041
> >>
> >>  If unsure, say Y.
> >>
> >> +config FUJITSU_ERRATUM_010001
> >> +  bool "Fujitsu-A64FX erratum E#010001: Undefined fault may occur
> wrongly"
> >> +  default y
> >> +  help
> >> +This option adds workaround for Fujitsu-A64FX erratum E#010001.
> >> +On some variants of the Fujitsu-A64FX cores version (1.0, 1.1),
> memory
> >> +accesses may cause undefined fault (Data abort, DFSC=0b11).
> >> +This fault occurs under a specific hardware condition when a
> >> +load/store instruction performs an address translation using:
> >> +case-1  TTBR0_EL1 with TCR_EL1.NFD0 == 1.
> >> +case-2  TTBR0_EL2 with TCR_EL2.NFD0 == 1.
> >> +case-3  TTBR1_EL1 with TCR_EL1.NFD1 == 1.
> >> +case-4  TTBR1_EL2 with TCR_EL2.NFD1 == 1.
> >> +
> >> +The workaround is to ensure these bits are clear in TCR_ELx.
> >> +The workaround only affect the Fujitsu-A64FX.
> >
> > I think it is better to add a notice here as follows:
> >
> >   Recommend to enable KPTI (UNMAP_KERNEL_AT_EL0 = y).
> 
> That unmap option is on by default, you can't turn it off without
> CONFIG_EXPERT. While I agree, I don't think we need to spell this out.
[>] 
I agree with you (that there is no need to mention here). 
Thank you for your suggestion.
 
Best Regards,
Zhang Lei



Re: [PATCH v2] ARM: tegra: enforce PM requirement

2019-02-26 Thread Sameer Pujar



On 2/26/2019 10:22 PM, Dmitry Osipenko wrote:

26.02.2019 12:13, Russell King - ARM Linux admin пишет:

On Tue, Feb 26, 2019 at 01:55:37PM +0530, Sameer Pujar wrote:

The requirement for this came while adding runtime PM support for HDA
driver. There were concerns about driver explicitly handling !PM case.
In general, drivers need to handle !PM case with work arounds for
managing clocks and power explicitly, which is not really necessary
when PM support on tegra is in good shape. In fact ARM 64-bit Tegra
platforms enforce PM support and there is no reason why this cannot be
done for 32-bit.

More details with regards to above can be found in following patch,
http://patchwork.ozlabs.org/patch/1036645/

This patch selects PM unconditionally and drivers can rely on runtime
PM framework for clock and power management.

What if the drivers are re-used on another SoC IP?  Doesn't this lead
to unexpected failures?

If you want to do this, maybe also make those drivers depend on PM as
well?

The commit message is inaccurate, it is intended for the Tegra HDA driver and not for 
some generic driver. The overall final intent is to remove dependency on the PM 
availability for all of Tegra drivers to "make Tegra maintainers life easier".
Wanted to convey that finally it would be the case for all Tegra 
drivers. I will update commit message to make it more clear.


[PATCH RFC v6] integrity: support EC-RDSA signatures for asymmetric_verify

2019-02-26 Thread Vitaly Chikunov
Allow to use EC-RDSA signatures for IMA by determining signature type by
the hash algorithm name. This works good for EC-RDSA since Streebog and
EC-RDSA should always be used together.

Cc: Mimi Zohar 
Cc: Dmitry Kasatkin 
Cc: linux-integr...@vger.kernel.org
Signed-off-by: Vitaly Chikunov 
---
Changes since v5:

- This should go over "[PATCH v5 00/10] crypto: add EC-RDSA (GOST 34.10)
  algorithm" instead of "[PATCH v5 10/10] integrity: support EC-RDSA signatures
  for asymmetric_verify."

- Comparison of hash algo by enum id instead of text name, as suggested by
  Thiago Jung Bauermann and Mimi Zohar.

 security/integrity/digsig_asymmetric.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/security/integrity/digsig_asymmetric.c 
b/security/integrity/digsig_asymmetric.c
index d775e03fbbcc..99080871eb9f 100644
--- a/security/integrity/digsig_asymmetric.c
+++ b/security/integrity/digsig_asymmetric.c
@@ -104,9 +104,16 @@ int asymmetric_verify(struct key *keyring, const char *sig,
 
memset(, 0, sizeof(pks));
 
-   pks.pkey_algo = "rsa";
pks.hash_algo = hash_algo_name[hdr->hash_algo];
-   pks.encoding = "pkcs1";
+   if (hdr->hash_algo == HASH_ALGO_STREEBOG_256 ||
+   hdr->hash_algo == HASH_ALGO_STREEBOG_512) {
+   /* EC-RDSA and Streebog should go together. */
+   pks.pkey_algo = "ecrdsa";
+   pks.encoding = "raw";
+   } else {
+   pks.pkey_algo = "rsa";
+   pks.encoding = "pkcs1";
+   }
pks.digest = (u8 *)data;
pks.digest_size = datalen;
pks.s = hdr->sig;
-- 
2.11.0



Re: [PATCH v2] ARM: tegra: enforce PM requirement

2019-02-26 Thread Sameer Pujar



On 2/26/2019 8:16 PM, Dmitry Osipenko wrote:

26.02.2019 11:25, Sameer Pujar пишет:

The requirement for this came while adding runtime PM support for HDA
driver. There were concerns about driver explicitly handling !PM case.
In general, drivers need to handle !PM case with work arounds for
managing clocks and power explicitly, which is not really necessary
when PM support on tegra is in good shape. In fact ARM 64-bit Tegra
platforms enforce PM support and there is no reason why this cannot be
done for 32-bit.

More details with regards to above can be found in following patch,
http://patchwork.ozlabs.org/patch/1036645/

I think you meant this: https://patchwork.ozlabs.org/patch/1031007/

my bad! Thanks for pointing.


[PATCH] sched/cputime: Remove unnecessary assignment statement

2019-02-26 Thread Ketan Patil
The original code assigns the value from rtime to utime variable,
and then jumps to the update label. And the value of utime is then
updated, so the earlier value of utime is not used. Hence remove
that unnecessary assignment statement.

This fixes one of the coverity defects.

Based on work by Ishan Mittal 

Signed-off-by: Ketan Patil 
---
 kernel/sched/cputime.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index ba4a143..ad64771 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -616,10 +616,8 @@ void cputime_adjust(struct task_cputime *curr, struct 
prev_cputime *prev,
 * Once a task gets some ticks, the monotonicy code at 'update:'
 * will ensure things converge to the observed ratio.
 */
-   if (stime == 0) {
-   utime = rtime;
+   if (stime == 0)
goto update;
-   }
 
if (utime == 0) {
stime = rtime;
-- 
2.7.4



Re: kernel BUG at include/linux/mm.h:LINE! (3)

2019-02-26 Thread Eric Biggers
On Tue, Feb 26, 2019 at 10:02:04PM -0800, syzbot wrote:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:8e7f81e2ebc4 Add linux-next specific files for 20190226
> git tree:   linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=10381714c0
> kernel config:  https://syzkaller.appspot.com/x/.config?x=2fa10211b8a4a56e
> dashboard link: https://syzkaller.appspot.com/bug?extid=a5b71df98b247d973f8c
> compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14eda192c0
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=164831e0c0
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+a5b71df98b247d973...@syzkaller.appspotmail.com
> 
> page:ea00025c3ac0 count:0 mapcount:0 mapping: index:0x0
> flags: 0x1fffc00()
> raw: 01fffc00 ea00024bf988 ea00021dd448 
> raw:    
> page dumped because: VM_BUG_ON_PAGE(page_ref_count(page) == 0)
> [ cut here ]
> kernel BUG at include/linux/mm.h:579!
> invalid opcode:  [#1] PREEMPT SMP KASAN
> CPU: 0 PID: 7779 Comm: syz-executor379 Not tainted 5.0.0-rc8-next-20190226
> #43
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> RIP: 0010:put_page_testzero include/linux/mm.h:579 [inline]
> RIP: 0010:put_page include/linux/mm.h:1025 [inline]
> RIP: 0010:generic_pipe_buf_release+0x120/0x160 fs/pipe.c:224
> Code: bd ff 4c 89 e7 e8 90 43 db ff e8 bb 29 bd ff 5b 41 5c 41 5d 5d c3 e8
> af 29 bd ff 48 c7 c6 20 98 75 87 4c 89 e7 e8 c0 db e4 ff <0f> 0b e8 99 29 bd
> ff 4d 8d 65 ff e9 3d ff ff ff 48 89 df e8 e8 f8
> RSP: 0018:8880a503f920 EFLAGS: 00010293
> RAX: 88808d2ec6c0 RBX: ea00025c3af4 RCX: 
> RDX:  RSI: 81982852 RDI: ea00025c3af8
> RBP: 8880a503f938 R08: 003e R09: ed1015d05011
> R10: ed1015d05010 R11: 8880ae828087 R12: ea00025c3ac0
> R13:  R14: 88809b6e8a40 R15: 8880952c4000
> FS:  016a0880() GS:8880ae80() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 20f50f90 CR3: 97b89000 CR4: 001406f0
> Call Trace:
>  pipe_buf_release include/linux/pipe_fs_i.h:129 [inline]
>  iter_file_splice_write+0x7d1/0xbe0 fs/splice.c:759
>  do_splice_from fs/splice.c:847 [inline]
>  direct_splice_actor+0x126/0x1a0 fs/splice.c:1019
>  splice_direct_to_actor+0x369/0x970 fs/splice.c:974
>  do_splice_direct+0x1da/0x2a0 fs/splice.c:1062
>  do_sendfile+0x597/0xd00 fs/read_write.c:1442
>  __do_sys_sendfile64 fs/read_write.c:1503 [inline]
>  __se_sys_sendfile64 fs/read_write.c:1489 [inline]
>  __x64_sys_sendfile64+0x1dd/0x220 fs/read_write.c:1489
>  do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
>  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x443d29
> Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7
> 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff
> 0f 83 7b d8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:7fffc1e47c88 EFLAGS: 0246 ORIG_RAX: 0028
> RAX: ffda RBX: 004002e0 RCX: 00443d29
> RDX:  RSI: 0003 RDI: 0003
> RBP: 006ce018 R08: 004002e0 R09: 004002e0
> R10: 000102000300 R11: 0246 R12: 00401a30
> R13: 00401ac0 R14:  R15: 
> Modules linked in:
> ---[ end trace 9daff95e0e1a45ff ]---
> RIP: 0010:put_page_testzero include/linux/mm.h:579 [inline]
> RIP: 0010:put_page include/linux/mm.h:1025 [inline]
> RIP: 0010:generic_pipe_buf_release+0x120/0x160 fs/pipe.c:224
> Code: bd ff 4c 89 e7 e8 90 43 db ff e8 bb 29 bd ff 5b 41 5c 41 5d 5d c3 e8
> af 29 bd ff 48 c7 c6 20 98 75 87 4c 89 e7 e8 c0 db e4 ff <0f> 0b e8 99 29 bd
> ff 4d 8d 65 ff e9 3d ff ff ff 48 89 df e8 e8 f8
> RSP: 0018:8880a503f920 EFLAGS: 00010293
> RAX: 88808d2ec6c0 RBX: ea00025c3af4 RCX: 
> RDX:  RSI: 81982852 RDI: ea00025c3af8
> RBP: 8880a503f938 R08: 003e R09: ed1015d05011
> R10: ed1015d05010 R11: 8880ae828087 R12: ea00025c3ac0
> R13:  R14: 88809b6e8a40 R15: 8880952c4000
> FS:  016a0880() GS:8880ae80() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 20f50f90 CR3: 97b89000 CR4: 001406f0
> 
> 
> 

[PATCH 7/8] net: seeq: replace kmalloc / memset(,0) with kzalloc

2019-02-26 Thread Robert Eshleman
This patch reduces a call to memset(,0) by replacing
a kmalloc call with a kzalloc call.

Signed-off-by: Robert Eshleman 
---
 drivers/net/ethernet/seeq/ether3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/seeq/ether3.c 
b/drivers/net/ethernet/seeq/ether3.c
index d1bb73bf9914..7456cf08a48f 100644
--- a/drivers/net/ethernet/seeq/ether3.c
+++ b/drivers/net/ethernet/seeq/ether3.c
@@ -223,7 +223,7 @@ ether3_addr(char *addr, struct expansion_card *ec)
 static int
 ether3_ramtest(struct net_device *dev, unsigned char byte)
 {
-   unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL);
+   unsigned char *buffer = kzalloc(RX_END, GFP_KERNEL);
int i,ret = 0;
int max_errors = 4;
int bad = -1;
@@ -231,7 +231,6 @@ ether3_ramtest(struct net_device *dev, unsigned char byte)
if (!buffer)
return 1;
 
-   memset(buffer, byte, RX_END);
ether3_setbuffer(dev, buffer_write, 0);
ether3_writebuffer(dev, buffer, TX_END);
ether3_setbuffer(dev, buffer_write, RX_START);
-- 
2.20.1



[PATCH 8/8] net: ethernet: ixp4xx_eth: remove memset(,0) with zalloc

2019-02-26 Thread Robert Eshleman
This patch removes a call to memset(,0) by replacing the
prior call to dma_pool_alloc with a call to dma_pool_zalloc.

Signed-off-by: Robert Eshleman 
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c 
b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index aee55c03def0..8471e1857d53 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1107,11 +1107,10 @@ static int init_queues(struct port *port)
if (!dma_pool)
return -ENOMEM;
}
-
-   if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL,
- >desc_tab_phys)))
+   port->desc_tab = dma_pool_zalloc(dma_pool, GFP_KERNEL,
+>desc_tab_phys);
+   if (!port->desc_tab)
return -ENOMEM;
-   memset(port->desc_tab, 0, POOL_ALLOC_SIZE);
memset(port->rx_buff_tab, 0, sizeof(port->rx_buff_tab)); /* tables */
memset(port->tx_buff_tab, 0, sizeof(port->tx_buff_tab));
 
-- 
2.20.1



[PATCH 1/8] net/mlx4: use kzalloc instead of kmalloc

2019-02-26 Thread Robert Eshleman
This patch replaces a kmalloc/memset(,0) call with a call to kzalloc.
It also removes a memset(,0) call that always follows a *zalloc call.

Signed-off-by: Robert Eshleman 
---
 drivers/net/ethernet/mellanox/mlx4/cmd.c   | 1 -
 drivers/net/ethernet/mellanox/mlx4/en_rx.c | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c 
b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index e65bc3c95630..7bfa6e850e5f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -3307,7 +3307,6 @@ int mlx4_get_counter_stats(struct mlx4_dev *dev, int 
counter_index,
if (IS_ERR(mailbox))
return PTR_ERR(mailbox);
 
-   memset(mailbox->buf, 0, sizeof(struct mlx4_counter));
if_stat_in_mod = counter_index;
if (reset)
if_stat_in_mod |= MLX4_QUERY_IF_STAT_RESET;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c 
b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 9a0881cb7f51..f55805d206ef 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -1044,7 +1044,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv 
*priv, int qpn,
struct mlx4_qp_context *context;
int err = 0;
 
-   context = kmalloc(sizeof(*context), GFP_KERNEL);
+   context = kzalloc(sizeof(*context), GFP_KERNEL);
if (!context)
return -ENOMEM;
 
@@ -1055,7 +1055,6 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv 
*priv, int qpn,
}
qp->event = mlx4_en_sqp_event;
 
-   memset(context, 0, sizeof(*context));
mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0,
qpn, ring->cqn, -1, context);
context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);
-- 
2.20.1



[PATCH 2/8] net/mlxsw: use pci_zalloc_consistent instead of pci_alloc_consistent

2019-02-26 Thread Robert Eshleman
This patch replaces a call to pci_alloc_consistent and then
memset(0,) with a single call to pci_zalloc_consistent.

Signed-off-by: Robert Eshleman 
---
 drivers/net/ethernet/mellanox/mlxsw/pci.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c 
b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index a2321fe8d6a0..388f349573f3 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -830,12 +830,11 @@ static int mlxsw_pci_queue_init(struct mlxsw_pci 
*mlxsw_pci, char *mbox,
tasklet_init(>tasklet, q_ops->tasklet, (unsigned long) q);
 
mem_item->size = MLXSW_PCI_AQ_SIZE;
-   mem_item->buf = pci_alloc_consistent(mlxsw_pci->pdev,
-mem_item->size,
-_item->mapaddr);
+   mem_item->buf = pci_zalloc_consistent(mlxsw_pci->pdev,
+ mem_item->size,
+ _item->mapaddr);
if (!mem_item->buf)
return -ENOMEM;
-   memset(mem_item->buf, 0, mem_item->size);
 
q->elem_info = kcalloc(q->count, sizeof(*q->elem_info), GFP_KERNEL);
if (!q->elem_info) {
-- 
2.20.1



[PATCH 4/8] qed: remove unnecessary memsets

2019-02-26 Thread Robert Eshleman
This patch replaces unnecessary memset(,0) calls with
simply assigning structs to zero.

Signed-off-by: Robert Eshleman 
---
 drivers/net/ethernet/qlogic/qed/qed_cxt.c |  4 +-
 drivers/net/ethernet/qlogic/qed/qed_hw.c  |  3 +-
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 70 ---
 3 files changed, 25 insertions(+), 52 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c 
b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
index c2ad405b2f50..0452ef2fdf1d 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
@@ -902,12 +902,10 @@ static int qed_cxt_src_t2_alloc(struct qed_hwfn *p_hwfn)
struct qed_cxt_mngr *p_mngr = p_hwfn->p_cxt_mngr;
u32 conn_num, total_size, ent_per_page, psz, i;
struct qed_ilt_client_cfg *p_src;
-   struct qed_src_iids src_iids;
+   struct qed_src_iids src_iids = {0};
struct qed_dma_mem *p_t2;
int rc;
 
-   memset(_iids, 0, sizeof(src_iids));
-
/* if the SRC ILT client is inactive - there are no connection
 * requiring the searcer, leave.
 */
diff --git a/drivers/net/ethernet/qlogic/qed/qed_hw.c 
b/drivers/net/ethernet/qlogic/qed/qed_hw.c
index 70504dcf4087..b8ca3a31409b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hw.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_hw.c
@@ -831,7 +831,7 @@ int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
struct qed_ptt *p_ptt, const char *phase)
 {
u32 size = PAGE_SIZE / 2, val;
-   struct qed_dmae_params params;
+   struct qed_dmae_params params = {0};
int rc = 0;
dma_addr_t p_phys;
void *p_virt;
@@ -864,7 +864,6 @@ int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
   (u64)p_phys,
   p_virt, (u64)(p_phys + size), (u8 *)p_virt + size, size);
 
-   memset(, 0, sizeof(params));
rc = qed_dmae_host2host(p_hwfn, p_ptt, p_phys, p_phys + size,
size / 4 /* size_in_dwords */, );
if (rc) {
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index e7f18e34ff0d..e1b72fc819a9 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -642,10 +642,9 @@ int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
u32 *o_mcp_resp,
u32 *o_mcp_param)
 {
-   struct qed_mcp_mb_params mb_params;
+   struct qed_mcp_mb_params mb_params = {0};
int rc;
 
-   memset(_params, 0, sizeof(mb_params));
mb_params.cmd = cmd;
mb_params.param = param;
 
@@ -667,10 +666,9 @@ qed_mcp_nvm_wr_cmd(struct qed_hwfn *p_hwfn,
   u32 *o_mcp_resp,
   u32 *o_mcp_param, u32 i_txn_size, u32 *i_buf)
 {
-   struct qed_mcp_mb_params mb_params;
+   struct qed_mcp_mb_params mb_params = {0};
int rc;
 
-   memset(_params, 0, sizeof(mb_params));
mb_params.cmd = cmd;
mb_params.param = param;
mb_params.p_data_src = i_buf;
@@ -695,11 +693,10 @@ int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
   u32 *o_mcp_resp,
   u32 *o_mcp_param, u32 *o_txn_size, u32 *o_buf)
 {
-   struct qed_mcp_mb_params mb_params;
+   struct qed_mcp_mb_params mb_params = {0};
u8 raw_data[MCP_DRV_NVM_BUF_LEN];
int rc;
 
-   memset(_params, 0, sizeof(mb_params));
mb_params.cmd = cmd;
mb_params.param = param;
mb_params.p_data_dst = raw_data;
@@ -821,13 +818,12 @@ __qed_mcp_load_req(struct qed_hwfn *p_hwfn,
   struct qed_load_req_in_params *p_in_params,
   struct qed_load_req_out_params *p_out_params)
 {
-   struct qed_mcp_mb_params mb_params;
-   struct load_req_stc load_req;
+   struct qed_mcp_mb_params mb_params = {0};
+   struct load_req_stc load_req = {0};
struct load_rsp_stc load_rsp;
u32 hsi_ver;
int rc;
 
-   memset(_req, 0, sizeof(load_req));
load_req.drv_ver_0 = p_in_params->drv_ver_0;
load_req.drv_ver_1 = p_in_params->drv_ver_1;
load_req.fw_ver = p_in_params->fw_ver;
@@ -843,7 +839,6 @@ __qed_mcp_load_req(struct qed_hwfn *p_hwfn,
  DRV_ID_MCP_HSI_VER_CURRENT :
  (p_in_params->hsi_ver << DRV_ID_MCP_HSI_VER_SHIFT);
 
-   memset(_params, 0, sizeof(mb_params));
mb_params.cmd = DRV_MSG_CODE_LOAD_REQ;
mb_params.param = PDA_COMP | hsi_ver | p_hwfn->cdev->drv_type;
mb_params.p_data_src = _req;
@@ -959,12 +954,11 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
 struct qed_ptt *p_ptt,
 struct qed_load_req_params *p_params)
 {
-   struct qed_load_req_out_params out_params;
-   struct qed_load_req_in_params in_params;
+   struct qed_load_req_out_params out_params = {0};
+   struct qed_load_req_in_params in_params = {0};
u8 mfw_drv_role, 

[PATCH 3/8] tlan: use pci_zalloc instead of pci_alloc

2019-02-26 Thread Robert Eshleman
This patch replaces a pci_alloc_consistent and memset(,0) call
with a single call to pci_zalloc_consistent.

Signed-off-by: Robert Eshleman 
---
 drivers/net/ethernet/ti/tlan.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
index b4ab1a5f6cd0..e1f7e71c3b21 100644
--- a/drivers/net/ethernet/ti/tlan.c
+++ b/drivers/net/ethernet/ti/tlan.c
@@ -845,17 +845,16 @@ static int tlan_init(struct net_device *dev)
 
dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS)
* (sizeof(struct tlan_list));
-   priv->dma_storage = pci_alloc_consistent(priv->pci_dev,
-dma_size,
->dma_storage_dma);
+   priv->dma_storage = pci_zalloc_consistent(priv->pci_dev,
+ dma_size,
+ >dma_storage_dma);
priv->dma_size = dma_size;
 
-   if (priv->dma_storage == NULL) {
+   if (!priv->dma_storage) {
pr_err("Could not allocate lists and buffers for %s\n",
   dev->name);
return -ENOMEM;
}
-   memset(priv->dma_storage, 0, dma_size);
priv->rx_list = (struct tlan_list *)
ALIGN((unsigned long)priv->dma_storage, 8);
priv->rx_list_dma = ALIGN(priv->dma_storage_dma, 8);
-- 
2.20.1



[PATCH 5/8] at12: use pci_zalloc instead of pci_alloc

2019-02-26 Thread Robert Eshleman
This patch replaces a pci_alloc and memset(,0) call
with a single call to pci_zalloc.

Signed-off-by: Robert Eshleman 
---
 drivers/net/ethernet/atheros/atlx/atl2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c 
b/drivers/net/ethernet/atheros/atlx/atl2.c
index bb41becb6609..a145c2d1b1d2 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -300,11 +300,10 @@ static s32 atl2_setup_ring_resources(struct atl2_adapter 
*adapter)
adapter->txs_ring_size * 4 + 7 +/* dword align */
adapter->rxd_ring_size * 1536 + 127;/* 128bytes align */
 
-   adapter->ring_vir_addr = pci_alloc_consistent(pdev, size,
-   >ring_dma);
+   adapter->ring_vir_addr = pci_zalloc_consistent(pdev, size,
+  >ring_dma);
if (!adapter->ring_vir_addr)
return -ENOMEM;
-   memset(adapter->ring_vir_addr, 0, adapter->ring_size);
 
/* Init TXD Ring */
adapter->txd_dma = adapter->ring_dma ;
-- 
2.20.1



Re: [PATCH -next] scsi: libfc: Fix potential NULL pointer dereference

2019-02-26 Thread YueHaibing


Friendly ping:

Who can review or take this, please?

Thanks

On 2019/1/30 18:11, YueHaibing wrote:
> There is a potential NULL pointer dereference in case
> fc_rport_create() fails and returns NULL.
> 
> Fixes: 2580064b5ec6 ("scsi: libfc: Replace ->rport_create callback with 
> function call")
> Signed-off-by: YueHaibing 
> ---
>  drivers/scsi/libfc/fc_lport.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
> index ff943f4..e2a3551 100644
> --- a/drivers/scsi/libfc/fc_lport.c
> +++ b/drivers/scsi/libfc/fc_lport.c
> @@ -250,6 +250,10 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
>   }
>   mutex_lock(>disc.disc_mutex);
>   lport->ptp_rdata = fc_rport_create(lport, remote_fid);
> + if (!lport->ptp_rdata) {
> + mutex_unlock(>disc.disc_mutex);
> + return;
> + }
>   kref_get(>ptp_rdata->kref);
>   lport->ptp_rdata->ids.port_name = remote_wwpn;
>   lport->ptp_rdata->ids.node_name = remote_wwnn;
> 



[PATCH 6/8] netxen: remove unnecessary memset(,0) calls

2019-02-26 Thread Robert Eshleman
This patch reduces calls to memset(,0) by replacing memset(,0)
calls that only zero-out newly declared structs with simply
assigning those structs to zero structs.

It also removes a pci_alloc_consistent call followed by a memset(,0)
call by simply using pci_zalloc_consistent.

Signed-off-by: Robert Eshleman 
---
 .../ethernet/qlogic/netxen/netxen_nic_ctx.c   | 36 +++
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c 
b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
index 7503aa222392..f2010c032361 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
@@ -99,8 +99,7 @@ netxen_issue_cmd(struct netxen_adapter *adapter, struct 
netxen_cmd_args *cmd)
 static int
 netxen_get_minidump_template_size(struct netxen_adapter *adapter)
 {
-   struct netxen_cmd_args cmd;
-   memset(, 0, sizeof(cmd));
+   struct netxen_cmd_args cmd = {0};
cmd.req.cmd = NX_CDRP_CMD_TEMP_SIZE;
memset(, 1, sizeof(struct _cdrp_cmd));
netxen_issue_cmd(adapter, );
@@ -120,7 +119,7 @@ netxen_get_minidump_template(struct netxen_adapter *adapter)
dma_addr_t md_template_addr;
void *addr;
u32 size;
-   struct netxen_cmd_args cmd;
+   struct netxen_cmd_args cmd = {0};
size = adapter->mdump.md_template_size;
 
if (size == 0) {
@@ -135,7 +134,6 @@ netxen_get_minidump_template(struct netxen_adapter *adapter)
return -ENOMEM;
}
 
-   memset(, 0, sizeof(cmd));
memset(, 1, sizeof(struct _cdrp_cmd));
cmd.req.cmd = NX_CDRP_CMD_GET_TEMP_HDR;
cmd.req.arg1 = LSD(md_template_addr);
@@ -233,9 +231,8 @@ nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu)
 {
u32 rcode = NX_RCODE_SUCCESS;
struct netxen_recv_context *recv_ctx = >recv_ctx;
-   struct netxen_cmd_args cmd;
+   struct netxen_cmd_args cmd = {0};
 
-   memset(, 0, sizeof(cmd));
cmd.req.cmd = NX_CDRP_CMD_SET_MTU;
cmd.req.arg1 = recv_ctx->context_id;
cmd.req.arg2 = mtu;
@@ -254,9 +251,8 @@ int
 nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter,
u32 speed, u32 duplex, u32 autoneg)
 {
-   struct netxen_cmd_args cmd;
+   struct netxen_cmd_args cmd = {0};
 
-   memset(, 0, sizeof(cmd));
cmd.req.cmd = NX_CDRP_CMD_CONFIG_GBE_PORT;
cmd.req.arg1 = speed;
cmd.req.arg2 = duplex;
@@ -276,7 +272,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
nx_cardrsp_sds_ring_t *prsp_sds;
struct nx_host_rds_ring *rds_ring;
struct nx_host_sds_ring *sds_ring;
-   struct netxen_cmd_args cmd;
+   struct netxen_cmd_args cmd = {0};
 
dma_addr_t hostrq_phys_addr, cardrsp_phys_addr;
u64 phys_addr;
@@ -359,7 +355,6 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
}
 
phys_addr = hostrq_phys_addr;
-   memset(, 0, sizeof(cmd));
cmd.req.arg1 = (u32)(phys_addr >> 32);
cmd.req.arg2 = (u32)(phys_addr & 0x);
cmd.req.arg3 = rq_size;
@@ -413,9 +408,8 @@ static void
 nx_fw_cmd_destroy_rx_ctx(struct netxen_adapter *adapter)
 {
struct netxen_recv_context *recv_ctx = >recv_ctx;
-   struct netxen_cmd_args cmd;
+   struct netxen_cmd_args cmd = {0};
 
-   memset(, 0, sizeof(cmd));
cmd.req.arg1 = recv_ctx->context_id;
cmd.req.arg2 = NX_DESTROY_CTX_RESET;
cmd.req.arg3 = 0;
@@ -520,9 +514,8 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
 static void
 nx_fw_cmd_destroy_tx_ctx(struct netxen_adapter *adapter)
 {
-   struct netxen_cmd_args cmd;
+   struct netxen_cmd_args cmd = {0};
 
-   memset(, 0, sizeof(cmd));
cmd.req.arg1 = adapter->tx_context_id;
cmd.req.arg2 = NX_DESTROY_CTX_RESET;
cmd.req.arg3 = 0;
@@ -538,9 +531,8 @@ int
 nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val)
 {
u32 rcode;
-   struct netxen_cmd_args cmd;
+   struct netxen_cmd_args cmd = {0};
 
-   memset(, 0, sizeof(cmd));
cmd.req.arg1 = reg;
cmd.req.arg2 = 0;
cmd.req.arg3 = 0;
@@ -561,9 +553,8 @@ int
 nx_fw_cmd_set_phy(struct netxen_adapter *adapter, u32 reg, u32 val)
 {
u32 rcode;
-   struct netxen_cmd_args cmd;
+   struct netxen_cmd_args cmd = {0};
 
-   memset(, 0, sizeof(cmd));
cmd.req.arg1 = reg;
cmd.req.arg2 = val;
cmd.req.arg3 = 0;
@@ -763,15 +754,14 @@ int netxen_alloc_hw_resources(struct netxen_adapter 
*adapter)
recv_ctx = >recv_ctx;
tx_ring = adapter->tx_ring;
 
-   addr = pci_alloc_consistent(pdev,
-   sizeof(struct netxen_ring_ctx) + sizeof(uint32_t),
-   _ctx->phys_addr);
-   if (addr == NULL) {
+   addr = pci_zalloc_consistent(pdev,
+sizeof(struct 

RE: question about drivers/phy/renesas/phy-rcar-gen2.c

2019-02-26 Thread Julia Lawall



On Wed, 27 Feb 2019, Yoshihiro Shimoda wrote:

> Hello,
>
> > From: Julia Lawall, Sent: Tuesday, February 26, 2019 6:01 PM
> >
> > On Tue, 26 Feb 2019, Yoshihiro Shimoda wrote:
> >
> > > Hello,
> > > (Sergei made this code, so I added his email as CC)
> > >
> > > I'm sorry for the delayed response.
> > >
> > > > From: Julia Lawall, Sent: Sunday, February 3, 2019 4:03 PM
> > > >
> > > > Hello,
> > > >
> > > > I was wondering whether phy-rcar-gen2.c would use dynamically allocated
> > > > device nodes?
> > >
> > > I'm sorry, but what is "dynamically allocated device nodes"?
> >
> > Device nodes for which there will be a meor leak if one doesn't put
> > of_node_put.
>
> Thank you. I understood it.
>
> > julia
> >
> > >
> > > Best regards,
> > > Yoshihiro Shimoda
> > >
> > > >  If so, it looks like the following code could cause a
> > > > use-after-free, due to not incrementing th reference count:
> > > >
> > > > for_each_child_of_node(dev->of_node, np) {
> > > > struct rcar_gen2_channel *channel = drv->channels + i;
> > > > u32 channel_num;
> > > > int error, n;
> > > >
> > > > channel->of_node = np;
>
> IIUC, since the channel->of_node will be used for comparing the pointer
> in rcar_gen2_phy_xlate(), it is not use-after-free.
> However, the for_each_child_of_node() in rcar_gen2_phy_probe() will return
> without of_put_node() at error paths. So, I'll submit a bugfix patch later.
>
> Thank you very much for your report!

Thanks for taking care of it.

julia

>
> Best regards,
> Yoshihiro Shimoda
>
> > > > ...
> > > > }
> > > >
> > > > On the other hand, if the reference cound it incrememnted, preventing
> > > > memory leaks in the case where the probe function fails would entail 
> > > > some
> > > > complex rewriting of the code, so I thought it would be better to ask
> > > > first.
> > > >
> > > > thanks,
> > > > julia
> > >
>


[PATCH 0/8] net: ethernet: reduce calls to memset(,0)

2019-02-26 Thread Robert Eshleman
This patch series removes calls to memset(,0) that are
redundant when used in conjunction with a zalloc call or
by simple zero-assignment of structs.

Robert Eshleman (8):
  net/mlx4: use kzalloc instead of kmalloc
  net/mlxsw: use pci_zalloc_consistent instead of pci_alloc_consistent
  tlan: use pci_zalloc instead of pci_alloc
  qed: remove unnecessary memsets
  at12: use pci_zalloc instead of pci_alloc
  netxen: remove unnecessary memset(,0) calls
  net: seeq: replace kmalloc / memset(,0) with kzalloc
  net: ethernet: ixp4xx_eth: remove memset(,0) with zalloc

 drivers/net/ethernet/atheros/atlx/atl2.c  |  5 +-
 drivers/net/ethernet/mellanox/mlx4/cmd.c  |  1 -
 drivers/net/ethernet/mellanox/mlx4/en_rx.c|  3 +-
 drivers/net/ethernet/mellanox/mlxsw/pci.c |  7 +-
 .../ethernet/qlogic/netxen/netxen_nic_ctx.c   | 36 --
 drivers/net/ethernet/qlogic/qed/qed_cxt.c |  4 +-
 drivers/net/ethernet/qlogic/qed/qed_hw.c  |  3 +-
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 70 ++-
 drivers/net/ethernet/seeq/ether3.c|  3 +-
 drivers/net/ethernet/ti/tlan.c|  9 ++-
 drivers/net/ethernet/xscale/ixp4xx_eth.c  |  7 +-
 11 files changed, 52 insertions(+), 96 deletions(-)

-- 
2.20.1



kernel BUG at include/linux/mm.h:LINE! (3)

2019-02-26 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:8e7f81e2ebc4 Add linux-next specific files for 20190226
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=10381714c0
kernel config:  https://syzkaller.appspot.com/x/.config?x=2fa10211b8a4a56e
dashboard link: https://syzkaller.appspot.com/bug?extid=a5b71df98b247d973f8c
compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14eda192c0
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=164831e0c0

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+a5b71df98b247d973...@syzkaller.appspotmail.com

page:ea00025c3ac0 count:0 mapcount:0 mapping: index:0x0
flags: 0x1fffc00()
raw: 01fffc00 ea00024bf988 ea00021dd448 
raw:    
page dumped because: VM_BUG_ON_PAGE(page_ref_count(page) == 0)
[ cut here ]
kernel BUG at include/linux/mm.h:579!
invalid opcode:  [#1] PREEMPT SMP KASAN
CPU: 0 PID: 7779 Comm: syz-executor379 Not tainted 5.0.0-rc8-next-20190226  
#43
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:put_page_testzero include/linux/mm.h:579 [inline]
RIP: 0010:put_page include/linux/mm.h:1025 [inline]
RIP: 0010:generic_pipe_buf_release+0x120/0x160 fs/pipe.c:224
Code: bd ff 4c 89 e7 e8 90 43 db ff e8 bb 29 bd ff 5b 41 5c 41 5d 5d c3 e8  
af 29 bd ff 48 c7 c6 20 98 75 87 4c 89 e7 e8 c0 db e4 ff <0f> 0b e8 99 29  
bd ff 4d 8d 65 ff e9 3d ff ff ff 48 89 df e8 e8 f8

RSP: 0018:8880a503f920 EFLAGS: 00010293
RAX: 88808d2ec6c0 RBX: ea00025c3af4 RCX: 
RDX:  RSI: 81982852 RDI: ea00025c3af8
RBP: 8880a503f938 R08: 003e R09: ed1015d05011
R10: ed1015d05010 R11: 8880ae828087 R12: ea00025c3ac0
R13:  R14: 88809b6e8a40 R15: 8880952c4000
FS:  016a0880() GS:8880ae80() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 20f50f90 CR3: 97b89000 CR4: 001406f0
Call Trace:
 pipe_buf_release include/linux/pipe_fs_i.h:129 [inline]
 iter_file_splice_write+0x7d1/0xbe0 fs/splice.c:759
 do_splice_from fs/splice.c:847 [inline]
 direct_splice_actor+0x126/0x1a0 fs/splice.c:1019
 splice_direct_to_actor+0x369/0x970 fs/splice.c:974
 do_splice_direct+0x1da/0x2a0 fs/splice.c:1062
 do_sendfile+0x597/0xd00 fs/read_write.c:1442
 __do_sys_sendfile64 fs/read_write.c:1503 [inline]
 __se_sys_sendfile64 fs/read_write.c:1489 [inline]
 __x64_sys_sendfile64+0x1dd/0x220 fs/read_write.c:1489
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x443d29
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 7b d8 fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7fffc1e47c88 EFLAGS: 0246 ORIG_RAX: 0028
RAX: ffda RBX: 004002e0 RCX: 00443d29
RDX:  RSI: 0003 RDI: 0003
RBP: 006ce018 R08: 004002e0 R09: 004002e0
R10: 000102000300 R11: 0246 R12: 00401a30
R13: 00401ac0 R14:  R15: 
Modules linked in:
---[ end trace 9daff95e0e1a45ff ]---
RIP: 0010:put_page_testzero include/linux/mm.h:579 [inline]
RIP: 0010:put_page include/linux/mm.h:1025 [inline]
RIP: 0010:generic_pipe_buf_release+0x120/0x160 fs/pipe.c:224
Code: bd ff 4c 89 e7 e8 90 43 db ff e8 bb 29 bd ff 5b 41 5c 41 5d 5d c3 e8  
af 29 bd ff 48 c7 c6 20 98 75 87 4c 89 e7 e8 c0 db e4 ff <0f> 0b e8 99 29  
bd ff 4d 8d 65 ff e9 3d ff ff ff 48 89 df e8 e8 f8

RSP: 0018:8880a503f920 EFLAGS: 00010293
RAX: 88808d2ec6c0 RBX: ea00025c3af4 RCX: 
RDX:  RSI: 81982852 RDI: ea00025c3af8
RBP: 8880a503f938 R08: 003e R09: ed1015d05011
R10: ed1015d05010 R11: 8880ae828087 R12: ea00025c3ac0
R13:  R14: 88809b6e8a40 R15: 8880952c4000
FS:  016a0880() GS:8880ae80() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 20f50f90 CR3: 97b89000 CR4: 001406f0


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkal...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with  
syzbot.

syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches


[PATCH -next] media: rockchip-vpu: Remove duplicated include from rockchip_vpu_drv.c

2019-02-26 Thread Yue Haibing
From: YueHaibing 

Remove duplicated include.

Signed-off-by: YueHaibing 
---
 drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c 
b/drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c
index 962412c..5761146 100644
--- a/drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c
+++ b/drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "rockchip_vpu_common.h"
-- 
2.7.0




[PATCH -next] staging: rtl8723bs: Remove duplicated include from drv_types.h

2019-02-26 Thread Yue Haibing
From: YueHaibing 

Remove duplicated include.

Signed-off-by: YueHaibing 
---
 drivers/staging/rtl8723bs/include/drv_types.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/include/drv_types.h 
b/drivers/staging/rtl8723bs/include/drv_types.h
index 062fda9..bafb2c3 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -65,7 +65,6 @@ enum _NIC_VERSION {
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.7.0




[PATCH] regulator: wm8400: Fix trivial typo

2019-02-26 Thread Axel Lin
Use WM8400_DC2_ENA_MASK for DCDC2 enable_mask.
The define is the same as WM8400_DC1_ENA_MASK, just a cleanup.

Signed-off-by: Axel Lin 
---
 drivers/regulator/wm8400-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/wm8400-regulator.c 
b/drivers/regulator/wm8400-regulator.c
index 40c4e6628471..5ce86b92851b 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -194,7 +194,7 @@ static struct regulator_desc regulators[] = {
.id = WM8400_DCDC2,
.ops = _dcdc_ops,
.enable_reg = WM8400_DCDC2_CONTROL_1,
-   .enable_mask = WM8400_DC1_ENA_MASK,
+   .enable_mask = WM8400_DC2_ENA_MASK,
.n_voltages = WM8400_DC2_VSEL_MASK + 1,
.vsel_reg = WM8400_DCDC2_CONTROL_1,
.vsel_mask = WM8400_DC2_VSEL_MASK,
-- 
2.17.1



Re: [PATCH 2/2] drivers/misc: Add Aspeed P2A control driver

2019-02-26 Thread Andrew Jeffery



On Wed, 27 Feb 2019, at 13:04, Patrick Venture wrote:
> On Tue, Feb 26, 2019 at 5:05 PM Andrew Jeffery  wrote:
> >
> >
> >
> > On Wed, 27 Feb 2019, at 08:12, Patrick Venture wrote:
> > > On Sun, Feb 24, 2019 at 5:26 PM Andrew Jeffery  wrote:
> > > >
> > > > On Fri, 22 Feb 2019, at 08:55, Patrick Venture wrote:
> > > > > The ASPEED AST2400, and AST2500 in some configurations include a
> > > > > PCI-to-AHB MMIO bridge.  This bridge allows a server to read and write
> > > > > in the BMC's memory space.
> > > >
> > > > Bit of a nit, but I think s/memory space/physical address space/ makes
> > > > the power of the interface a bit clearer.
> > > >
> > > > >  This feature is especially useful when using
> > > > > this bridge to send large files to the BMC.
> > > > >
> > > > > The host may use this to send down a firmware image by staging data 
> > > > > at a
> > > > > specific memory address, and in a coordinated effort with the BMC's
> > > > > software stack and kernel, transmit the bytes.
> > > > >
> > > > > This driver enables the BMC to unlock the PCI bridge on demand, and
> > > > > configure it via ioctl to allow the host to write bytes to an agreed
> > > > > upon location.  In the primary use-case, the region to use is known
> > > > > apriori on the BMC, and the host requests this information.  Once this
> > > > > request is received, the BMC's software stack will enable the bridge 
> > > > > and
> > > > > the region and then using some software flow control (possibly via 
> > > > > IPMI
> > > > > packets), copy the bytes down.  Once the process is complete, the BMC
> > > > > will disable the bridge and unset any region involved.
> > > >
> > > > I feel the description is a little subtle. You mention locations and 
> > > > regions
> > > > without really defining their relationship. We have the means to prevent
> > > > writes via the P2A to following regions in the BMC's physical address 
> > > > space:
> > > >
> > > > * BMC flash MMIO window
> > > > * System flash MMIO windows
> > > > * SOC IO (peripheral MMIO)
> > > > * DRAM
> > > >
> > > > So what I think should be made clear is once we allow the host to write
> > > > to e.g. DRAM, it can write to *all* of DRAM, regardless of what 
> > > > location the
> > > > BMC recommended, i.e. the BMC is at the mercy of the host wrt
> > > > confidentiality once the P2A is enabled (host can always read anywhere)
> > > > and integrity when the DRAM write filter is disabled.
> > >
> > > Ok, I can try to work that phrasing in.
> > >
> > > >
> > > > There is no way to specify and constrain P2A writes to specific 
> > > > locations
> > > > in DRAM.
> > > >
> > > > >
> > > > > The default behavior of this bridge when present is: enabled and all
> > > > > regions marked read-write.  This driver will fix the regions to be
> > > > > read-only and then disable the bridge entirely.
> > > > >
> > > > > Signed-off-by: Patrick Venture 
> > > > > ---
> > > > >  drivers/misc/Kconfig |   8 +
> > > > >  drivers/misc/Makefile|   1 +
> > > > >  drivers/misc/aspeed-p2a-ctrl.c   | 498 
> > > > > +++
> > > > >  include/uapi/linux/aspeed-p2a-ctrl.h |  46 +++
> > > > >  4 files changed, 553 insertions(+)
> > > > >  create mode 100644 drivers/misc/aspeed-p2a-ctrl.c
> > > > >  create mode 100644 include/uapi/linux/aspeed-p2a-ctrl.h
> > > > >
> > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > > > > index f417b06e11c5..54ed265a26f0 100644
> > > > > --- a/drivers/misc/Kconfig
> > > > > +++ b/drivers/misc/Kconfig
> > > > > @@ -485,6 +485,14 @@ config VEXPRESS_SYSCFG
> > > > > bus. System Configuration interface is one of the possible 
> > > > > means
> > > > > of generating transactions on this bus.
> > > > >
> > > > > +config ASPEED_P2A_CTRL
> > > > > + depends on (ARCH_ASPEED || COMPILE_TEST)
> > > > > + tristate "Aspeed ast2400/2500 HOST P2A VGA MMIO to BMC bridge 
> > > > > control"
> > > > > + help
> > > > > +   Control Aspeed ast2400/2500 HOST P2A VGA MMIO to BMC mappings
> > > > > through
> > > > > +   ioctl()s, the driver also provides an interface for userspace
> > > > > mappings to
> > > > > +   a pre-defined region.
> > > > > +
> > > > >  config ASPEED_LPC_CTRL
> > > > >   depends on (ARCH_ASPEED || COMPILE_TEST) && REGMAP && MFD_SYSCON
> > > > >   tristate "Aspeed ast2400/2500 HOST LPC to BMC bridge control"
> > > > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > > > > index e39ccbbc1b3a..57577aee354f 100644
> > > > > --- a/drivers/misc/Makefile
> > > > > +++ b/drivers/misc/Makefile
> > > > > @@ -55,6 +55,7 @@ obj-$(CONFIG_VEXPRESS_SYSCFG)   += 
> > > > > vexpress-syscfg.o
> > > > >  obj-$(CONFIG_CXL_BASE)   += cxl/
> > > > >  obj-$(CONFIG_ASPEED_LPC_CTRL)+= aspeed-lpc-ctrl.o
> > > > >  obj-$(CONFIG_ASPEED_LPC_SNOOP)   += aspeed-lpc-snoop.o
> > > > > +obj-$(CONFIG_ASPEED_P2A_CTRL)+= aspeed-p2a-ctrl.o
> > > 

Re: [-next] um: Remove duplicated include from vector_user.c

2019-02-26 Thread YueHaibing


Friendly ping:

Who can take this, please?

On 2019/1/21 2:54, Anton Ivanov wrote:
> 
> 
> On 1/3/19 3:12 AM, YueHaibing wrote:
>> Remove duplicated include.
>>
>> Signed-off-by: YueHaibing 
>> ---
>>   arch/um/drivers/vector_user.c | 3 ---
>>   1 file changed, 3 deletions(-)
>>
>> diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
>> index d2c17dd..b3f7b3c 100644
>> --- a/arch/um/drivers/vector_user.c
>> +++ b/arch/um/drivers/vector_user.c
>> @@ -16,14 +16,12 @@
>>   #include 
>>   #include 
>>   #include 
>> -#include 
>>   #include 
>>   #include 
>>   #include 
>>   #include 
>>   #include 
>>   #include 
>> -#include 
>>   #include 
>>   #include 
>>   #include 
>> @@ -31,7 +29,6 @@
>>   #include 
>>   #include 
>>   #include 
>> -#include 
>>   #include "vector_user.h"
>> #define ID_GRE 0
>>
> 
> Reviewed-by: Anton Ivanov 
> Acked-by: Anton Ivanov 



[PATCH 3/3] staging: erofs: fix mis-acted TAIL merging behavior

2019-02-26 Thread Gao Xiang
EROFS has an optimized path called TAIL merging, which is designed
to merge multiple reads and the corresponding decompressions into
one if these requests read continuous pages almost at the same time.

In general, it behaves as follows:
 
  ... |  TAIL  .  HEAD  |  PAGE  |  PAGE  |  TAIL. HEAD | ...
 _|_combined page A_|||_combined page B_|
1  ]  ->  [  2  ]  ->  [ 3
If the above three reads are requested in the order 1-2-3, it will
generate a large work chain rather than 3 individual work chains
to reduce scheduling overhead and boost up sequential read.

However, if Read 2 is processed slightly earlier than Read 1,
currently it still generates 2 individual work chains (chain 1, 2)
but it does in-place decompression for combined page A, moreover,
if chain 2 decompresses ahead of chain 1, it will be a race and
lead to corrupted decompressed page. This patch fixes it.

Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
Cc:  # 4.19+
Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/unzip_vle.c | 70 +--
 1 file changed, 45 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/erofs/unzip_vle.c 
b/drivers/staging/erofs/unzip_vle.c
index 74c13b0a3d33..02f34a83147d 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -107,15 +107,30 @@ enum z_erofs_vle_work_role {
Z_EROFS_VLE_WORK_SECONDARY,
Z_EROFS_VLE_WORK_PRIMARY,
/*
-* The current work has at least been linked with the following
-* processed chained works, which means if the processing page
-* is the tail partial page of the work, the current work can
-* safely use the whole page, as illustrated below:
-* +--+---+
-* |  tail page   |  head page (of the previous work) |
-* +--+---+
-*   /\  which belongs to the current work
-* [  (*) this page can be used for the current work itself.  ]
+* The current work was the tail of an exist chain, and the previous
+* processed chained works are all decided to be hooked up to it.
+* A new chain should be created for the remaining unprocessed works,
+* therefore different from Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED,
+* the next work cannot reuse the whole page in the following scenario:
+*  
+* |  tail (partial) page |   head (partial) page   |
+* |  (belongs to the next work)  |  (belongs to the current work)  |
+* |___PRIMARY_FOLLOWED___|PRIMARY_HOOKED___|
+*/
+   Z_EROFS_VLE_WORK_PRIMARY_HOOKED,
+   /*
+* The current work has been linked with the processed chained works,
+* and could be also linked with the potential remaining works, which
+* means if the processing page is the tail partial page of the work,
+* the current work can safely use the whole page (since the next work
+* is under control) for in-place decompression, as illustrated below:
+*  
+* |  tail (partial) page  |  head (partial) page   |
+* | (of the current work) | (of the previous work) |
+* |  PRIMARY_FOLLOWED or  ||
+* |_PRIMARY_HOOKED|PRIMARY_FOLLOWED|
+*
+* [  (*) the above page can be used for the current work itself.  ]
 */
Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED,
Z_EROFS_VLE_WORK_MAX
@@ -309,10 +324,10 @@ static int z_erofs_vle_work_add_page(
return ret ? 0 : -EAGAIN;
 }
 
-static inline bool try_to_claim_workgroup(
-   struct z_erofs_vle_workgroup *grp,
-   z_erofs_vle_owned_workgrp_t *owned_head,
-   bool *hosted)
+static enum z_erofs_vle_work_role
+try_to_claim_workgroup(struct z_erofs_vle_workgroup *grp,
+  z_erofs_vle_owned_workgrp_t *owned_head,
+  bool *hosted)
 {
DBG_BUGON(*hosted == true);
 
@@ -326,6 +341,9 @@ static inline bool try_to_claim_workgroup(
 
*owned_head = >next;
*hosted = true;
+   /* lucky, I am the followee :) */
+   return Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED;
+
} else if (grp->next == Z_EROFS_VLE_WORKGRP_TAIL) {
/*
 * type 2, link to the end of a existing open chain,
@@ -335,12 +353,11 @@ static inline bool try_to_claim_workgroup(
if (cmpxchg(>next, Z_EROFS_VLE_WORKGRP_TAIL,
*owned_head) != Z_EROFS_VLE_WORKGRP_TAIL)
 

[PATCH 1/3] staging: erofs: compressed_pages should not be accessed again after freed

2019-02-26 Thread Gao Xiang
This patch resolves the following page use-after-free issue,
z_erofs_vle_unzip:
...
for (i = 0; i < nr_pages; ++i) {
...
z_erofs_onlinepage_endio(page);  (1)
}

for (i = 0; i < clusterpages; ++i) {
page = compressed_pages[i];

if (page->mapping == mngda)  (2)
continue;
/* recycle all individual staging pages */
(void)z_erofs_gather_if_stagingpage(page_pool, page); (3)
WRITE_ONCE(compressed_pages[i], NULL);
}
...

After (1) is executed, page is freed and could be then reused, if
compressed_pages is scanned after that, it could fall info (2) or
(3) by mistake and that could finally be in a mess.

This patch aims to solve the above issue only with little changes
as much as possible in order to make the fix backport easier.

Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
Cc:  # 4.19+
Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/unzip_vle.c | 38 ++-
 drivers/staging/erofs/unzip_vle.h |  3 +--
 drivers/staging/erofs/unzip_vle_lz4.c | 19 --
 3 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/erofs/unzip_vle.c 
b/drivers/staging/erofs/unzip_vle.c
index a127d8db76d8..416dde4e8ea1 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -986,11 +986,10 @@ static int z_erofs_vle_unzip(struct super_block *sb,
if (llen > grp->llen)
llen = grp->llen;
 
-   err = z_erofs_vle_unzip_fast_percpu(compressed_pages,
-   clusterpages, pages, llen, work->pageofs,
-   z_erofs_onlinepage_endio);
+   err = z_erofs_vle_unzip_fast_percpu(compressed_pages, clusterpages,
+   pages, llen, work->pageofs);
if (err != -ENOTSUPP)
-   goto out_percpu;
+   goto out;
 
if (sparsemem_pages >= nr_pages)
goto skip_allocpage;
@@ -1011,8 +1010,25 @@ static int z_erofs_vle_unzip(struct super_block *sb,
erofs_vunmap(vout, nr_pages);
 
 out:
+   /* must handle all compressed pages before endding pages */
+   for (i = 0; i < clusterpages; ++i) {
+   page = compressed_pages[i];
+
+#ifdef EROFS_FS_HAS_MANAGED_CACHE
+   if (page->mapping == MNGD_MAPPING(sbi))
+   continue;
+#endif
+   /* recycle all individual staging pages */
+   (void)z_erofs_gather_if_stagingpage(page_pool, page);
+
+   WRITE_ONCE(compressed_pages[i], NULL);
+   }
+
for (i = 0; i < nr_pages; ++i) {
page = pages[i];
+   if (!page)
+   continue;
+
DBG_BUGON(!page->mapping);
 
/* recycle all individual staging pages */
@@ -1025,20 +1041,6 @@ static int z_erofs_vle_unzip(struct super_block *sb,
z_erofs_onlinepage_endio(page);
}
 
-out_percpu:
-   for (i = 0; i < clusterpages; ++i) {
-   page = compressed_pages[i];
-
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-   if (page->mapping == MNGD_MAPPING(sbi))
-   continue;
-#endif
-   /* recycle all individual staging pages */
-   (void)z_erofs_gather_if_stagingpage(page_pool, page);
-
-   WRITE_ONCE(compressed_pages[i], NULL);
-   }
-
if (pages == z_pagemap_global)
mutex_unlock(_pagemap_global_lock);
else if (unlikely(pages != pages_onstack))
diff --git a/drivers/staging/erofs/unzip_vle.h 
b/drivers/staging/erofs/unzip_vle.h
index 9dafa8dc712c..517e5ce8c5e9 100644
--- a/drivers/staging/erofs/unzip_vle.h
+++ b/drivers/staging/erofs/unzip_vle.h
@@ -218,8 +218,7 @@ int z_erofs_vle_plain_copy(struct page **compressed_pages,
 int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages,
  unsigned int clusterpages,
  struct page **pages, unsigned int outlen,
- unsigned short pageofs,
- void (*endio)(struct page *));
+ unsigned short pageofs);
 int z_erofs_vle_unzip_vmap(struct page **compressed_pages,
   unsigned int clusterpages,
   void *vaddr, unsigned int llen,
diff --git a/drivers/staging/erofs/unzip_vle_lz4.c 
b/drivers/staging/erofs/unzip_vle_lz4.c
index 8e8d705a6861..48b263a2731a 100644
--- a/drivers/staging/erofs/unzip_vle_lz4.c
+++ b/drivers/staging/erofs/unzip_vle_lz4.c
@@ -125,8 +125,7 @@ int z_erofs_vle_unzip_fast_percpu(struct page 
**compressed_pages,
  unsigned int clusterpages,
  struct page **pages,
  unsigned int outlen,
- unsigned short pageofs,
- void 

[PATCH 2/3] staging: erofs: fix illegal address access under memory pressure

2019-02-26 Thread Gao Xiang
Considering a read request with two decompressed file pages,
If a decompression work cannot be started on the previous page
due to memory pressure but in-memory LTP map lookup is done,
builder->work should be still NULL.

Moreover, if the current page also belongs to the same map,
it won't try to start the decompression work again and then
run into trouble.

This patch aims to solve the above issue only with little changes
as much as possible in order to make the fix backport easier.

kernel message is:
<4>[1051408.015930s]SLUB: Unable to allocate memory on node -1, 
gfp=0x2408040(GFP_NOFS|__GFP_ZERO)
<4>[1051408.015930s]  cache: erofs_compress, object size: 144, buffer size: 
144, default order: 0, min order: 0
<4>[1051408.015930s]  node 0: slabs: 98, objs: 2744, free: 0
  * Cannot allocate the decompression work

<3>[1051408.015960s]erofs: z_erofs_vle_normalaccess_readpages, readahead error 
at page 1008 of nid 5391488
  * Note that the previous page was failed to read

<0>[1051408.015960s]Internal error: Accessing user space memory outside 
uaccess.h routines: 9605 [#1] PREEMPT SMP
...
<4>[1051408.015991s]Hardware name: kirin710 (DT)
...
<4>[1051408.016021s]PC is at z_erofs_vle_work_add_page+0xa0/0x17c
<4>[1051408.016021s]LR is at z_erofs_do_read_page+0x12c/0xcf0
...
<4>[1051408.018096s][] z_erofs_vle_work_add_page+0xa0/0x17c
<4>[1051408.018096s][] 
z_erofs_vle_normalaccess_readpages+0x1a0/0x37c
<4>[1051408.018096s][] read_pages+0x70/0x190
<4>[1051408.018127s][] __do_page_cache_readahead+0x194/0x1a8
<4>[1051408.018127s][] filemap_fault+0x398/0x684
<4>[1051408.018127s][] __do_fault+0x8c/0x138
<4>[1051408.018127s][] handle_pte_fault+0x730/0xb7c
<4>[1051408.018127s][] __handle_mm_fault+0xac/0xf4
<4>[1051408.018157s][] handle_mm_fault+0x7c/0x118
<4>[1051408.018157s][] do_page_fault+0x354/0x474
<4>[1051408.018157s][] do_translation_fault+0x40/0x48
<4>[1051408.018157s][] do_mem_abort+0x80/0x100
<4>[1051408.018310s]---[ end trace 9f4009a3283bd78b ]---

Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
Cc:  # 4.19+
Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/unzip_vle.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/erofs/unzip_vle.c 
b/drivers/staging/erofs/unzip_vle.c
index 416dde4e8ea1..74c13b0a3d33 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -698,8 +698,12 @@ static int z_erofs_do_read_page(struct 
z_erofs_vle_frontend *fe,
 
/* lucky, within the range of the current map_blocks */
if (offset + cur >= map->m_la &&
-   offset + cur < map->m_la + map->m_llen)
+   offset + cur < map->m_la + map->m_llen) {
+   /* didn't get a valid unzip work previously (very rare) */
+   if (!builder->work)
+   goto restart_now;
goto hitted;
+   }
 
/* go ahead the next map_blocks */
debugln("%s: [out-of-range] pos %llu", __func__, offset + cur);
@@ -713,6 +717,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend 
*fe,
if (unlikely(err))
goto err_out;
 
+restart_now:
if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED)))
goto hitted;
 
-- 
2.14.5



Re: [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs

2019-02-26 Thread Wei Yang
On Tue, Feb 26, 2019 at 11:10:06AM -0500, Michael S. Tsirkin wrote:
>On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote:
>> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
>> to define the attribute.
>> 
>> Signed-off-by: Wei Yang 
>> ---
>>  drivers/firmware/qemu_fw_cfg.c | 13 -
>>  1 file changed, 4 insertions(+), 9 deletions(-)
>> 
>> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
>> index 039e0f91dba8..a1293cbd7adb 100644
>> --- a/drivers/firmware/qemu_fw_cfg.c
>> +++ b/drivers/firmware/qemu_fw_cfg.c
>> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct 
>> platform_device *pdev)
>>  return 0;
>>  }
>>  
>> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char 
>> *buf)
>> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
>> +   char *buf)
>>  {
>>  return sprintf(buf, "%u\n", fw_cfg_rev);
>>  }
>> -
>> -static const struct {
>> -struct attribute attr;
>> -ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
>> -} fw_cfg_rev_attr = {
>> -.attr = { .name = "rev", .mode = S_IRUSR },
>> -.show = fw_cfg_showrev,
>> -};
>> +static const struct kobj_attribute fw_cfg_rev_attr =
>> +__ATTR_RO_MODE(fw_cfg_rev, 0400);
>>  
>>  /* fw_cfg_sysfs_entry type */
>>  struct fw_cfg_sysfs_entry {
>
>
>Looks like this will change the name from "rev" to "fw_cfg_rev".
>That's a userspace visible change which we should not do lightly.

You are right, I should keep the interface untouched.

To keep it user un-visible, we could change like below:

-   __ATTR_RO(fw_cfg_rev);
+   __ATTR_RO(rev);

Is this better for you?

>> -- 
>> 2.19.1

-- 
Wei Yang
Help you, Help me


Re: [PATCH 2/2] drivers/misc: Add Aspeed P2A control driver

2019-02-26 Thread Florian Fainelli



On 2/21/2019 2:25 PM, Patrick Venture wrote:
> The ASPEED AST2400, and AST2500 in some configurations include a
> PCI-to-AHB MMIO bridge.  This bridge allows a server to read and write
> in the BMC's memory space.  This feature is especially useful when using
> this bridge to send large files to the BMC.
> 
> The host may use this to send down a firmware image by staging data at a
> specific memory address, and in a coordinated effort with the BMC's
> software stack and kernel, transmit the bytes.
> 
> This driver enables the BMC to unlock the PCI bridge on demand, and
> configure it via ioctl to allow the host to write bytes to an agreed
> upon location.  In the primary use-case, the region to use is known
> apriori on the BMC, and the host requests this information.  Once this
> request is received, the BMC's software stack will enable the bridge and
> the region and then using some software flow control (possibly via IPMI
> packets), copy the bytes down.  Once the process is complete, the BMC
> will disable the bridge and unset any region involved.
> 
> The default behavior of this bridge when present is: enabled and all
> regions marked read-write.  This driver will fix the regions to be
> read-only and then disable the bridge entirely.

A complete drive by review, so I could be completely off here (most
likely am), but have you considered using virtio and doing some sort of
rudimentary features (regions here) negotiation over that interface?

If I get your description right in premise maybe emulating the AHB side
on the BMC as a PCI end-point device driver, and using it as a seemingly
regular PCI EP from the host side with BARs and stuff might make sense
here and be less of a security hole than it currently looks like.
-- 
Florian


[PATCH 1/5] ocxl: Rename struct link to ocxl_link

2019-02-26 Thread Alastair D'Silva
From: Alastair D'Silva 

The term 'link' is ambiguous (especially when the struct is used for a
list), so rename it for clarity.

Signed-off-by: Alastair D'Silva 
Reviewed-by: Greg Kurz 
---
 drivers/misc/ocxl/file.c |  2 +-
 drivers/misc/ocxl/link.c | 36 ++--
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index e6a607488f8a..16eb8a60d5c7 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -152,7 +152,7 @@ static long afu_ioctl_enable_p9_wait(struct ocxl_context 
*ctx,
 
if (status == ATTACHED) {
int rc;
-   struct link *link = ctx->afu->fn->link;
+   void *link = ctx->afu->fn->link;
 
rc = ocxl_link_update_pe(link, ctx->pasid, ctx->tidr);
if (rc)
diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
index d50b861d7e57..8d2690a1a9de 100644
--- a/drivers/misc/ocxl/link.c
+++ b/drivers/misc/ocxl/link.c
@@ -76,7 +76,7 @@ struct spa {
  * limited number of opencapi slots on a system and lookup is only
  * done when the device is probed
  */
-struct link {
+struct ocxl_link {
struct list_head list;
struct kref ref;
int domain;
@@ -179,7 +179,7 @@ static void xsl_fault_handler_bh(struct work_struct 
*fault_work)
 
 static irqreturn_t xsl_fault_handler(int irq, void *data)
 {
-   struct link *link = (struct link *) data;
+   struct ocxl_link *link = (struct ocxl_link *) data;
struct spa *spa = link->spa;
u64 dsisr, dar, pe_handle;
struct pe_data *pe_data;
@@ -256,7 +256,7 @@ static int map_irq_registers(struct pci_dev *dev, struct 
spa *spa)
>reg_tfc, >reg_pe_handle);
 }
 
-static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
+static int setup_xsl_irq(struct pci_dev *dev, struct ocxl_link *link)
 {
struct spa *spa = link->spa;
int rc;
@@ -311,7 +311,7 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link 
*link)
return rc;
 }
 
-static void release_xsl_irq(struct link *link)
+static void release_xsl_irq(struct ocxl_link *link)
 {
struct spa *spa = link->spa;
 
@@ -323,7 +323,7 @@ static void release_xsl_irq(struct link *link)
unmap_irq_registers(spa);
 }
 
-static int alloc_spa(struct pci_dev *dev, struct link *link)
+static int alloc_spa(struct pci_dev *dev, struct ocxl_link *link)
 {
struct spa *spa;
 
@@ -350,7 +350,7 @@ static int alloc_spa(struct pci_dev *dev, struct link *link)
return 0;
 }
 
-static void free_spa(struct link *link)
+static void free_spa(struct ocxl_link *link)
 {
struct spa *spa = link->spa;
 
@@ -364,12 +364,12 @@ static void free_spa(struct link *link)
}
 }
 
-static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link)
+static int alloc_link(struct pci_dev *dev, int PE_mask, struct ocxl_link 
**out_link)
 {
-   struct link *link;
+   struct ocxl_link *link;
int rc;
 
-   link = kzalloc(sizeof(struct link), GFP_KERNEL);
+   link = kzalloc(sizeof(struct ocxl_link), GFP_KERNEL);
if (!link)
return -ENOMEM;
 
@@ -405,7 +405,7 @@ static int alloc_link(struct pci_dev *dev, int PE_mask, 
struct link **out_link)
return rc;
 }
 
-static void free_link(struct link *link)
+static void free_link(struct ocxl_link *link)
 {
release_xsl_irq(link);
free_spa(link);
@@ -415,7 +415,7 @@ static void free_link(struct link *link)
 int ocxl_link_setup(struct pci_dev *dev, int PE_mask, void **link_handle)
 {
int rc = 0;
-   struct link *link;
+   struct ocxl_link *link;
 
mutex_lock(_list_lock);
list_for_each_entry(link, _list, list) {
@@ -442,7 +442,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_setup);
 
 static void release_xsl(struct kref *ref)
 {
-   struct link *link = container_of(ref, struct link, ref);
+   struct ocxl_link *link = container_of(ref, struct ocxl_link, ref);
 
list_del(>list);
/* call platform code before releasing data */
@@ -452,7 +452,7 @@ static void release_xsl(struct kref *ref)
 
 void ocxl_link_release(struct pci_dev *dev, void *link_handle)
 {
-   struct link *link = (struct link *) link_handle;
+   struct ocxl_link *link = (struct ocxl_link *) link_handle;
 
mutex_lock(_list_lock);
kref_put(>ref, release_xsl);
@@ -488,7 +488,7 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 
pidr, u32 tidr,
void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr),
void *xsl_err_data)
 {
-   struct link *link = (struct link *) link_handle;
+   struct ocxl_link *link = (struct ocxl_link *) link_handle;
struct spa *spa = link->spa;
struct ocxl_process_element *pe;
int pe_handle, rc = 0;
@@ -558,7 +558,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_add_pe);
 

[PATCH 0/5] ocxl: OpenCAPI Cleanup

2019-02-26 Thread Alastair D'Silva
From: Alastair D'Silva 

Some minor cleanups for the OpenCAPI driver as a prerequisite
for an ocxl driver refactoring to allow the driver core to
be utilised by external drivers.

Alastair D'Silva (5):
  ocxl: Rename struct link to ocxl_link
  ocxl: Clean up printf formats
  ocxl: read_pasid never returns an error, so make it void
  ocxl: Remove superfluous 'extern' from headers
  ocxl: Remove some unused exported symbols

 drivers/misc/ocxl/config.c| 17 ++
 drivers/misc/ocxl/context.c   |  2 +-
 drivers/misc/ocxl/file.c  |  2 +-
 drivers/misc/ocxl/link.c  | 36 ++---
 drivers/misc/ocxl/ocxl_internal.h | 86 +++
 drivers/misc/ocxl/trace.h | 10 ++--
 include/misc/ocxl.h   | 53 ++-
 7 files changed, 99 insertions(+), 107 deletions(-)

-- 
2.20.1



[PATCH 2/5] ocxl: Clean up printf formats

2019-02-26 Thread Alastair D'Silva
From: Alastair D'Silva 

Use %# instead of using a literal '0x'

Signed-off-by: Alastair D'Silva 
---
 drivers/misc/ocxl/config.c  |  6 +++---
 drivers/misc/ocxl/context.c |  2 +-
 drivers/misc/ocxl/trace.h   | 10 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
index 8f2c5d8bd2ee..0ee7856b033d 100644
--- a/drivers/misc/ocxl/config.c
+++ b/drivers/misc/ocxl/config.c
@@ -178,9 +178,9 @@ static int read_dvsec_vendor(struct pci_dev *dev)
pci_read_config_dword(dev, pos + OCXL_DVSEC_VENDOR_DLX_VERS, );
 
dev_dbg(>dev, "Vendor specific DVSEC:\n");
-   dev_dbg(>dev, "  CFG version = 0x%x\n", cfg);
-   dev_dbg(>dev, "  TLX version = 0x%x\n", tlx);
-   dev_dbg(>dev, "  DLX version = 0x%x\n", dlx);
+   dev_dbg(>dev, "  CFG version = %#x\n", cfg);
+   dev_dbg(>dev, "  TLX version = %#x\n", tlx);
+   dev_dbg(>dev, "  DLX version = %#x\n", dlx);
return 0;
 }
 
diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c
index c10a940e3b38..3498a0199bde 100644
--- a/drivers/misc/ocxl/context.c
+++ b/drivers/misc/ocxl/context.c
@@ -134,7 +134,7 @@ static vm_fault_t ocxl_mmap_fault(struct vm_fault *vmf)
vm_fault_t ret;
 
offset = vmf->pgoff << PAGE_SHIFT;
-   pr_debug("%s: pasid %d address 0x%lx offset 0x%llx\n", __func__,
+   pr_debug("%s: pasid %d address %#lx offset %#llx\n", __func__,
ctx->pasid, vmf->address, offset);
 
if (offset < ctx->afu->irq_base_offset)
diff --git a/drivers/misc/ocxl/trace.h b/drivers/misc/ocxl/trace.h
index bcb7ff330c1e..8d2f53812edd 100644
--- a/drivers/misc/ocxl/trace.h
+++ b/drivers/misc/ocxl/trace.h
@@ -28,7 +28,7 @@ DECLARE_EVENT_CLASS(ocxl_context,
__entry->tidr = tidr;
),
 
-   TP_printk("linux pid=%d spa=0x%p pasid=0x%x pidr=0x%x tidr=0x%x",
+   TP_printk("linux pid=%d spa=%p pasid=%#x pidr=%#x tidr=%#x",
__entry->pid,
__entry->spa,
__entry->pasid,
@@ -61,7 +61,7 @@ TRACE_EVENT(ocxl_terminate_pasid,
__entry->rc = rc;
),
 
-   TP_printk("pasid=0x%x rc=%d",
+   TP_printk("pasid=%#x rc=%d",
__entry->pasid,
__entry->rc
)
@@ -87,7 +87,7 @@ DECLARE_EVENT_CLASS(ocxl_fault_handler,
__entry->tfc = tfc;
),
 
-   TP_printk("spa=%p pe=0x%llx dsisr=0x%llx dar=0x%llx tfc=0x%llx",
+   TP_printk("spa=%p pe=%#llx dsisr=%#llx dar=%#llx tfc=%#llx",
__entry->spa,
__entry->pe,
__entry->dsisr,
@@ -127,7 +127,7 @@ TRACE_EVENT(ocxl_afu_irq_alloc,
__entry->irq_offset = irq_offset;
),
 
-   TP_printk("pasid=0x%x irq_id=%d virq=%u hw_irq=%d irq_offset=0x%llx",
+   TP_printk("pasid=%#x irq_id=%d virq=%u hw_irq=%d irq_offset=0x%llx",
__entry->pasid,
__entry->irq_id,
__entry->virq,
@@ -150,7 +150,7 @@ TRACE_EVENT(ocxl_afu_irq_free,
__entry->irq_id = irq_id;
),
 
-   TP_printk("pasid=0x%x irq_id=%d",
+   TP_printk("pasid=%#x irq_id=%d",
__entry->pasid,
__entry->irq_id
)
-- 
2.20.1



[PATCH 4/5] ocxl: Remove superfluous 'extern' from headers

2019-02-26 Thread Alastair D'Silva
From: Alastair D'Silva 

The 'extern' keyword adds no value here.

Signed-off-by: Alastair D'Silva 
---
 drivers/misc/ocxl/ocxl_internal.h | 54 +++
 include/misc/ocxl.h   | 36 ++---
 2 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/drivers/misc/ocxl/ocxl_internal.h 
b/drivers/misc/ocxl/ocxl_internal.h
index a32f2151029f..321b29e77f45 100644
--- a/drivers/misc/ocxl/ocxl_internal.h
+++ b/drivers/misc/ocxl/ocxl_internal.h
@@ -16,7 +16,6 @@
 
 extern struct pci_driver ocxl_pci_driver;
 
-
 struct ocxl_fn {
struct device dev;
int bar_used[3];
@@ -92,41 +91,40 @@ struct ocxl_process_element {
__be32 software_state;
 };
 
+struct ocxl_afu *ocxl_afu_get(struct ocxl_afu *afu);
+void ocxl_afu_put(struct ocxl_afu *afu);
 
-extern struct ocxl_afu *ocxl_afu_get(struct ocxl_afu *afu);
-extern void ocxl_afu_put(struct ocxl_afu *afu);
-
-extern int ocxl_create_cdev(struct ocxl_afu *afu);
-extern void ocxl_destroy_cdev(struct ocxl_afu *afu);
-extern int ocxl_register_afu(struct ocxl_afu *afu);
-extern void ocxl_unregister_afu(struct ocxl_afu *afu);
+int ocxl_create_cdev(struct ocxl_afu *afu);
+void ocxl_destroy_cdev(struct ocxl_afu *afu);
+int ocxl_register_afu(struct ocxl_afu *afu);
+void ocxl_unregister_afu(struct ocxl_afu *afu);
 
-extern int ocxl_file_init(void);
-extern void ocxl_file_exit(void);
+int ocxl_file_init(void);
+void ocxl_file_exit(void);
 
-extern int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size);
-extern void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
-extern int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
-extern void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
+int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size);
+void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
+int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
+void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
 
-extern struct ocxl_context *ocxl_context_alloc(void);
-extern int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
+struct ocxl_context *ocxl_context_alloc(void);
+int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
struct address_space *mapping);
-extern int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
-extern int ocxl_context_mmap(struct ocxl_context *ctx,
+int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
+int ocxl_context_mmap(struct ocxl_context *ctx,
struct vm_area_struct *vma);
-extern int ocxl_context_detach(struct ocxl_context *ctx);
-extern void ocxl_context_detach_all(struct ocxl_afu *afu);
-extern void ocxl_context_free(struct ocxl_context *ctx);
+int ocxl_context_detach(struct ocxl_context *ctx);
+void ocxl_context_detach_all(struct ocxl_afu *afu);
+void ocxl_context_free(struct ocxl_context *ctx);
 
-extern int ocxl_sysfs_add_afu(struct ocxl_afu *afu);
-extern void ocxl_sysfs_remove_afu(struct ocxl_afu *afu);
+int ocxl_sysfs_add_afu(struct ocxl_afu *afu);
+void ocxl_sysfs_remove_afu(struct ocxl_afu *afu);
 
-extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, u64 *irq_offset);
-extern int ocxl_afu_irq_free(struct ocxl_context *ctx, u64 irq_offset);
-extern void ocxl_afu_irq_free_all(struct ocxl_context *ctx);
-extern int ocxl_afu_irq_set_fd(struct ocxl_context *ctx, u64 irq_offset,
+int ocxl_afu_irq_alloc(struct ocxl_context *ctx, u64 *irq_offset);
+int ocxl_afu_irq_free(struct ocxl_context *ctx, u64 irq_offset);
+void ocxl_afu_irq_free_all(struct ocxl_context *ctx);
+int ocxl_afu_irq_set_fd(struct ocxl_context *ctx, u64 irq_offset,
int eventfd);
-extern u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, u64 irq_offset);
+u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, u64 irq_offset);
 
 #endif /* _OCXL_INTERNAL_H_ */
diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
index 9ff6ddc28e22..4544573cc93c 100644
--- a/include/misc/ocxl.h
+++ b/include/misc/ocxl.h
@@ -53,7 +53,7 @@ struct ocxl_fn_config {
  * Read the configuration space of a function and fill in a
  * ocxl_fn_config structure with all the function details
  */
-extern int ocxl_config_read_function(struct pci_dev *dev,
+int ocxl_config_read_function(struct pci_dev *dev,
struct ocxl_fn_config *fn);
 
 /*
@@ -62,14 +62,14 @@ extern int ocxl_config_read_function(struct pci_dev *dev,
  * AFU indexes can be sparse, so a driver should check all indexes up
  * to the maximum found in the function description
  */
-extern int ocxl_config_check_afu_index(struct pci_dev *dev,
+int ocxl_config_check_afu_index(struct pci_dev *dev,
struct ocxl_fn_config *fn, int afu_idx);
 
 /*
  * Read the configuration space of a function for the AFU specified by
  * the index 'afu_idx'. Fills in a ocxl_afu_config structure
  */
-extern int ocxl_config_read_afu(struct pci_dev *dev,
+int 

[PATCH 5/5] ocxl: Remove some unused exported symbols

2019-02-26 Thread Alastair D'Silva
From: Alastair D'Silva 

Remove some unused exported symbols.

Signed-off-by: Alastair D'Silva 
---
 drivers/misc/ocxl/config.c|  2 --
 drivers/misc/ocxl/ocxl_internal.h | 26 +-
 include/misc/ocxl.h   | 23 ---
 3 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
index 026ac2ac4f9c..c90c2e4875bf 100644
--- a/drivers/misc/ocxl/config.c
+++ b/drivers/misc/ocxl/config.c
@@ -299,7 +299,6 @@ int ocxl_config_check_afu_index(struct pci_dev *dev,
}
return 1;
 }
-EXPORT_SYMBOL_GPL(ocxl_config_check_afu_index);
 
 static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
struct ocxl_afu_config *afu)
@@ -535,7 +534,6 @@ int ocxl_config_get_pasid_info(struct pci_dev *dev, int 
*count)
 {
return pnv_ocxl_get_pasid_count(dev, count);
 }
-EXPORT_SYMBOL_GPL(ocxl_config_get_pasid_info);
 
 void ocxl_config_set_afu_pasid(struct pci_dev *dev, int pos, int pasid_base,
u32 pasid_count_log)
diff --git a/drivers/misc/ocxl/ocxl_internal.h 
b/drivers/misc/ocxl/ocxl_internal.h
index 321b29e77f45..cd5a1e3cc950 100644
--- a/drivers/misc/ocxl/ocxl_internal.h
+++ b/drivers/misc/ocxl/ocxl_internal.h
@@ -107,10 +107,34 @@ void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, 
u32 size);
 int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
 void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
 
+/*
+ * Get the max PASID value that can be used by the function
+ */
+int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
+
+int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
+
+/*
+ * Check if an AFU index is valid for the given function.
+ *
+ * AFU indexes can be sparse, so a driver should check all indexes up
+ * to the maximum found in the function description
+ */
+int ocxl_config_check_afu_index(struct pci_dev *dev,
+   struct ocxl_fn_config *fn, int afu_idx);
+
+/**
+ * Update values within a Process Element
+ *
+ * link_handle: the link handle associated with the process element
+ * pasid: the PASID for the AFU context
+ * tid: the new thread id for the process element
+ */
+int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
+
 struct ocxl_context *ocxl_context_alloc(void);
 int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
struct address_space *mapping);
-int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
 int ocxl_context_mmap(struct ocxl_context *ctx,
struct vm_area_struct *vma);
 int ocxl_context_detach(struct ocxl_context *ctx);
diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
index 4544573cc93c..9530d3be1b30 100644
--- a/include/misc/ocxl.h
+++ b/include/misc/ocxl.h
@@ -56,15 +56,6 @@ struct ocxl_fn_config {
 int ocxl_config_read_function(struct pci_dev *dev,
struct ocxl_fn_config *fn);
 
-/*
- * Check if an AFU index is valid for the given function.
- *
- * AFU indexes can be sparse, so a driver should check all indexes up
- * to the maximum found in the function description
- */
-int ocxl_config_check_afu_index(struct pci_dev *dev,
-   struct ocxl_fn_config *fn, int afu_idx);
-
 /*
  * Read the configuration space of a function for the AFU specified by
  * the index 'afu_idx'. Fills in a ocxl_afu_config structure
@@ -74,11 +65,6 @@ int ocxl_config_read_afu(struct pci_dev *dev,
struct ocxl_afu_config *afu,
u8 afu_idx);
 
-/*
- * Get the max PASID value that can be used by the function
- */
-int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
-
 /*
  * Tell an AFU, by writing in the configuration space, the PASIDs that
  * it can use. Range starts at 'pasid_base' and its size is a multiple
@@ -188,15 +174,6 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 
pidr, u32 tidr,
void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr),
void *xsl_err_data);
 
-/**
- * Update values within a Process Element
- *
- * link_handle: the link handle associated with the process element
- * pasid: the PASID for the AFU context
- * tid: the new thread id for the process element
- */
-int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
-
 /*
  * Remove a Process Element from the Shared Process Area for a link
  */
-- 
2.20.1



[PATCH 3/5] ocxl: read_pasid never returns an error, so make it void

2019-02-26 Thread Alastair D'Silva
From: Alastair D'Silva 

No need for a return value in read_pasid as it only returns 0.

Signed-off-by: Alastair D'Silva 
Reviewed-by: Greg Kurz 
---
 drivers/misc/ocxl/config.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
index 0ee7856b033d..026ac2ac4f9c 100644
--- a/drivers/misc/ocxl/config.c
+++ b/drivers/misc/ocxl/config.c
@@ -68,7 +68,7 @@ static int find_dvsec_afu_ctrl(struct pci_dev *dev, u8 
afu_idx)
return 0;
 }
 
-static int read_pasid(struct pci_dev *dev, struct ocxl_fn_config *fn)
+static void read_pasid(struct pci_dev *dev, struct ocxl_fn_config *fn)
 {
u16 val;
int pos;
@@ -89,7 +89,6 @@ static int read_pasid(struct pci_dev *dev, struct 
ocxl_fn_config *fn)
 out:
dev_dbg(>dev, "PASID capability:\n");
dev_dbg(>dev, "  Max PASID log = %d\n", fn->max_pasid_log);
-   return 0;
 }
 
 static int read_dvsec_tl(struct pci_dev *dev, struct ocxl_fn_config *fn)
@@ -205,11 +204,7 @@ int ocxl_config_read_function(struct pci_dev *dev, struct 
ocxl_fn_config *fn)
 {
int rc;
 
-   rc = read_pasid(dev, fn);
-   if (rc) {
-   dev_err(>dev, "Invalid PASID configuration: %d\n", rc);
-   return -ENODEV;
-   }
+   read_pasid(dev, fn);
 
rc = read_dvsec_tl(dev, fn);
if (rc) {
-- 
2.20.1



[PATCH v4 10/10] ARM: multi_v7_defconfig: add ARCH_MILBEAUT and ARCH_MILBEAUT_M10V

2019-02-26 Thread Sugaya Taichi
Add and enable the Milbeaut M10V architecture. These configs select those
of the clock, timer and serial driver for M10V.

Signed-off-by: Sugaya Taichi 
---
 arch/arm/configs/multi_v7_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index 5bee34a..6753805 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -54,6 +54,8 @@ CONFIG_SOC_VF610=y
 CONFIG_ARCH_KEYSTONE=y
 CONFIG_ARCH_MEDIATEK=y
 CONFIG_ARCH_MESON=y
+CONFIG_ARCH_MILBEAUT=y
+CONFIG_ARCH_MILBEAUT_M10V=y
 CONFIG_ARCH_MVEBU=y
 CONFIG_MACH_ARMADA_370=y
 CONFIG_MACH_ARMADA_375=y
-- 
1.9.1



[PATCH v4 07/10] dt-bindings: serial: Add Milbeaut serial driver description

2019-02-26 Thread Sugaya Taichi
Add DT bindings document for Milbeaut serial driver.

Signed-off-by: Sugaya Taichi 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/serial/milbeaut-uart.txt| 21 +
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/milbeaut-uart.txt

diff --git a/Documentation/devicetree/bindings/serial/milbeaut-uart.txt 
b/Documentation/devicetree/bindings/serial/milbeaut-uart.txt
new file mode 100644
index 000..3d2fb1a
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/milbeaut-uart.txt
@@ -0,0 +1,21 @@
+Socionext Milbeaut UART controller
+
+Required properties:
+- compatible: should be "socionext,milbeaut-usio-uart".
+- reg: offset and length of the register set for the device.
+- interrupts: two interrupts specifier.
+- interrupt-names: should be "rx", "tx".
+- clocks: phandle to the input clock.
+
+Optional properties:
+- auto-flow-control: flow control enable.
+
+Example:
+   usio1: usio_uart@1e700010 {
+   compatible = "socionext,milbeaut-usio-uart";
+   reg = <0x1e700010 0x10>;
+   interrupts = <0 141 0x4>, <0 149 0x4>;
+   interrupt-names = "rx", "tx";
+   clocks = < 2>;
+   auto-flow-control;
+   };
-- 
1.9.1



[PATCH v4 06/10] clocksource/drivers/timer-milbeaut: Introduce timer for Milbeaut SoCs

2019-02-26 Thread Sugaya Taichi
Add timer driver for Milbeaut SoCs series.

The timer has two 32-bit width down counters, one of which is configured
as a clockevent device and the other is configured as a clock source.

Signed-off-by: Sugaya Taichi 
Acked-by: Daniel Lezcano 
---
 drivers/clocksource/Kconfig  |   9 ++
 drivers/clocksource/Makefile |   1 +
 drivers/clocksource/timer-milbeaut.c | 161 +++
 3 files changed, 171 insertions(+)
 create mode 100644 drivers/clocksource/timer-milbeaut.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index a9e26f6..9101b8f 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -634,4 +634,13 @@ config GX6605S_TIMER
help
  This option enables support for gx6605s SOC's timer.
 
+config MILBEAUT_TIMER
+   bool "Milbeaut timer driver" if COMPILE_TEST
+   depends on OF
+   depends on ARM
+   select TIMER_OF
+   select CLKSRC_MMIO
+   help
+ Enables the support for Milbeaut timer driver.
+
 endmenu
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index cdd210f..6f2543b 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_CLKSRC_TI_32K)   += timer-ti-32k.o
 obj-$(CONFIG_CLKSRC_NPS)   += timer-nps.o
 obj-$(CONFIG_OXNAS_RPS_TIMER)  += timer-oxnas-rps.o
 obj-$(CONFIG_OWL_TIMER)+= timer-owl.o
+obj-$(CONFIG_MILBEAUT_TIMER)   += timer-milbeaut.o
 obj-$(CONFIG_SPRD_TIMER)   += timer-sprd.o
 obj-$(CONFIG_NPCM7XX_TIMER)+= timer-npcm7xx.o
 obj-$(CONFIG_RDA_TIMER)+= timer-rda.o
diff --git a/drivers/clocksource/timer-milbeaut.c 
b/drivers/clocksource/timer-milbeaut.c
new file mode 100644
index 000..f2019a8
--- /dev/null
+++ b/drivers/clocksource/timer-milbeaut.c
@@ -0,0 +1,161 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Socionext Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "timer-of.h"
+
+#define MLB_TMR_TMCSR_OFS  0x0
+#define MLB_TMR_TMR_OFS0x4
+#define MLB_TMR_TMRLR1_OFS 0x8
+#define MLB_TMR_TMRLR2_OFS 0xc
+#define MLB_TMR_REGSZPCH   0x10
+
+#define MLB_TMR_TMCSR_OUTL BIT(5)
+#define MLB_TMR_TMCSR_RELD BIT(4)
+#define MLB_TMR_TMCSR_INTE BIT(3)
+#define MLB_TMR_TMCSR_UF   BIT(2)
+#define MLB_TMR_TMCSR_CNTE BIT(1)
+#define MLB_TMR_TMCSR_TRG  BIT(0)
+
+#define MLB_TMR_TMCSR_CSL_DIV2 0
+#define MLB_TMR_DIV_CNT2
+
+#define MLB_TMR_SRC_CH  (1)
+#define MLB_TMR_EVT_CH  (0)
+
+#define MLB_TMR_SRC_CH_OFS (MLB_TMR_REGSZPCH * MLB_TMR_SRC_CH)
+#define MLB_TMR_EVT_CH_OFS (MLB_TMR_REGSZPCH * MLB_TMR_EVT_CH)
+
+#define MLB_TMR_SRC_TMCSR_OFS  (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMCSR_OFS)
+#define MLB_TMR_SRC_TMR_OFS(MLB_TMR_SRC_CH_OFS + MLB_TMR_TMR_OFS)
+#define MLB_TMR_SRC_TMRLR1_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMRLR1_OFS)
+#define MLB_TMR_SRC_TMRLR2_OFS (MLB_TMR_SRC_CH_OFS + MLB_TMR_TMRLR2_OFS)
+
+#define MLB_TMR_EVT_TMCSR_OFS  (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMCSR_OFS)
+#define MLB_TMR_EVT_TMR_OFS(MLB_TMR_EVT_CH_OFS + MLB_TMR_TMR_OFS)
+#define MLB_TMR_EVT_TMRLR1_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMRLR1_OFS)
+#define MLB_TMR_EVT_TMRLR2_OFS (MLB_TMR_EVT_CH_OFS + MLB_TMR_TMRLR2_OFS)
+
+#define MLB_TIMER_RATING   500
+
+static irqreturn_t mlb_timer_interrupt(int irq, void *dev_id)
+{
+   struct clock_event_device *clk = dev_id;
+   struct timer_of *to = to_timer_of(clk);
+   u32 val;
+
+   val = readl_relaxed(timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
+   val &= ~MLB_TMR_TMCSR_UF;
+   writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
+
+   clk->event_handler(clk);
+
+   return IRQ_HANDLED;
+}
+
+static int mlb_set_state_periodic(struct clock_event_device *clk)
+{
+   struct timer_of *to = to_timer_of(clk);
+   u32 val = MLB_TMR_TMCSR_CSL_DIV2;
+
+   writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
+
+   writel_relaxed(to->of_clk.period, timer_of_base(to) +
+   MLB_TMR_EVT_TMRLR1_OFS);
+   val |= MLB_TMR_TMCSR_RELD | MLB_TMR_TMCSR_CNTE |
+   MLB_TMR_TMCSR_TRG | MLB_TMR_TMCSR_INTE;
+   writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
+   return 0;
+}
+
+static int mlb_set_state_oneshot(struct clock_event_device *clk)
+{
+   struct timer_of *to = to_timer_of(clk);
+   u32 val = MLB_TMR_TMCSR_CSL_DIV2;
+
+   writel_relaxed(val, timer_of_base(to) + MLB_TMR_EVT_TMCSR_OFS);
+   return 0;
+}
+
+static int mlb_clkevt_next_event(unsigned long event,
+  struct clock_event_device *clk)
+{
+   struct timer_of *to = to_timer_of(clk);
+
+   writel_relaxed(event, timer_of_base(to) + MLB_TMR_EVT_TMRLR1_OFS);
+   writel_relaxed(MLB_TMR_TMCSR_CSL_DIV2 |
+   MLB_TMR_TMCSR_CNTE | MLB_TMR_TMCSR_INTE |
+   

[PATCH v4 09/10] ARM: configs: Add Milbeaut M10V defconfig

2019-02-26 Thread Sugaya Taichi
This patch adds the minimal defconfig for the Milbeaut M10V.

Signed-off-by: Sugaya Taichi 
---
 arch/arm/configs/milbeaut_m10v_defconfig | 119 +++
 1 file changed, 119 insertions(+)
 create mode 100644 arch/arm/configs/milbeaut_m10v_defconfig

diff --git a/arch/arm/configs/milbeaut_m10v_defconfig 
b/arch/arm/configs/milbeaut_m10v_defconfig
new file mode 100644
index 000..7c07f98
--- /dev/null
+++ b/arch/arm/configs/milbeaut_m10v_defconfig
@@ -0,0 +1,119 @@
+CONFIG_SYSVIPC=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_CGROUPS=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_EMBEDDED=y
+CONFIG_PERF_EVENTS=y
+CONFIG_ARCH_MILBEAUT=y
+CONFIG_ARCH_MILBEAUT_M10V=y
+CONFIG_ARM_THUMBEE=y
+# CONFIG_VDSO is not set
+# CONFIG_CACHE_L2X0 is not set
+CONFIG_ARM_ERRATA_430973=y
+CONFIG_ARM_ERRATA_720789=y
+CONFIG_ARM_ERRATA_754322=y
+CONFIG_ARM_ERRATA_754327=y
+CONFIG_ARM_ERRATA_764369=y
+CONFIG_ARM_ERRATA_775420=y
+CONFIG_ARM_ERRATA_798181=y
+CONFIG_SMP=y
+# CONFIG_SMP_ON_UP is not set
+# CONFIG_ARM_CPU_TOPOLOGY is not set
+CONFIG_HAVE_ARM_ARCH_TIMER=y
+CONFIG_NR_CPUS=16
+CONFIG_THUMB2_KERNEL=y
+# CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11 is not set
+# CONFIG_ARM_PATCH_IDIV is not set
+CONFIG_HIGHMEM=y
+CONFIG_FORCE_MAX_ZONEORDER=12
+CONFIG_SECCOMP=y
+CONFIG_KEXEC=y
+CONFIG_EFI=y
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_STAT=y
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
+CONFIG_CPUFREQ_DT=y
+CONFIG_QORIQ_CPUFREQ=y
+CONFIG_CPU_IDLE=y
+CONFIG_ARM_CPUIDLE=y
+CONFIG_VFP=y
+CONFIG_NEON=y
+CONFIG_KERNEL_MODE_NEON=y
+CONFIG_EFI_VARS=m
+CONFIG_EFI_CAPSULE_LOADER=m
+CONFIG_ARM_CRYPTO=y
+CONFIG_CRYPTO_SHA1_ARM_NEON=m
+CONFIG_CRYPTO_SHA1_ARM_CE=m
+CONFIG_CRYPTO_SHA2_ARM_CE=m
+CONFIG_CRYPTO_SHA512_ARM=m
+CONFIG_CRYPTO_AES_ARM=m
+CONFIG_CRYPTO_AES_ARM_BS=m
+CONFIG_CRYPTO_AES_ARM_CE=m
+CONFIG_CRYPTO_GHASH_ARM_CE=m
+CONFIG_CRYPTO_CRC32_ARM_CE=m
+CONFIG_CRYPTO_CHACHA20_NEON=m
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_CMDLINE_PARTITION=y
+CONFIG_CMA=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_DMA_CMA=y
+CONFIG_CMA_SIZE_MBYTES=64
+CONFIG_OF_OVERLAY=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=65536
+CONFIG_SRAM=y
+CONFIG_INPUT_FF_MEMLESS=m
+CONFIG_INPUT_MATRIXKMAP=y
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+CONFIG_SERIO_LIBPS2=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_SERIAL_DEV_BUS=y
+# CONFIG_HW_RANDOM is not set
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_GENERIC_PLATFORM=y
+# CONFIG_HWMON is not set
+CONFIG_MEDIA_SUPPORT=m
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_MEDIA_CONTROLLER=y
+# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
+# CONFIG_HID is not set
+# CONFIG_USB_SUPPORT is not set
+CONFIG_SYNC_FILE=y
+# CONFIG_VIRTIO_MENU is not set
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_SOC_BRCMSTB=y
+CONFIG_MEMORY=y
+# CONFIG_ARM_PMU is not set
+CONFIG_EXT4_FS=y
+CONFIG_AUTOFS4_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_NTFS_FS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_CONFIGFS_FS=y
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_UTF8=y
+CONFIG_KEYS=y
+CONFIG_CRYPTO_MANAGER=y
+# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
+CONFIG_CRYPTO_SEQIV=m
+# CONFIG_CRYPTO_ECHAINIV is not set
+CONFIG_CRYPTO_AES=y
+# CONFIG_CRYPTO_HW is not set
+CONFIG_CRC_CCITT=m
+CONFIG_CRC_ITU_T=m
+CONFIG_PRINTK_TIME=y
+CONFIG_MAGIC_SYSRQ=y
-- 
1.9.1



[PATCH v4 08/10] ARM: dts: milbeaut: Add device tree set for the Milbeaut M10V board

2019-02-26 Thread Sugaya Taichi
Add devicetree for Milbeaut M10V SoC and M10V Evaluation board.

Signed-off-by: Sugaya Taichi 
---
 arch/arm/boot/dts/Makefile  |  1 +
 arch/arm/boot/dts/milbeaut-m10v-evb.dts | 32 +++
 arch/arm/boot/dts/milbeaut-m10v.dtsi| 95 +
 3 files changed, 128 insertions(+)
 create mode 100644 arch/arm/boot/dts/milbeaut-m10v-evb.dts
 create mode 100644 arch/arm/boot/dts/milbeaut-m10v.dtsi

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index bd40148..f697d87 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -1233,6 +1233,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt7623n-bananapi-bpi-r2.dtb \
mt8127-moose.dtb \
mt8135-evbp1.dtb
+dtb-$(CONFIG_ARCH_MILBEAUT) += milbeaut-m10v-evb.dtb
 dtb-$(CONFIG_ARCH_ZX) += zx296702-ad1.dtb
 dtb-$(CONFIG_ARCH_ASPEED) += \
aspeed-ast2500-evb.dtb \
diff --git a/arch/arm/boot/dts/milbeaut-m10v-evb.dts 
b/arch/arm/boot/dts/milbeaut-m10v-evb.dts
new file mode 100644
index 000..614f60c
--- /dev/null
+++ b/arch/arm/boot/dts/milbeaut-m10v-evb.dts
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Socionext Milbeaut M10V Evaluation Board */
+/dts-v1/;
+#include "milbeaut-m10v.dtsi"
+
+/ {
+   model = "Socionext M10V EVB";
+   compatible = "socionext,milbeaut-m10v-evb", "socionext,sc2000a";
+
+   aliases {
+   serial0 = 
+   };
+
+   chosen {
+   bootargs = "rootwait earlycon";
+   stdout-path = "serial0:115200n8";
+   };
+
+   clocks {
+   uclk40xi: uclk40xi {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <4000>;
+   };
+   };
+
+   memory@4000 {
+   device_type = "memory";
+   reg = <0x4000  0x8000>;
+   };
+
+};
diff --git a/arch/arm/boot/dts/milbeaut-m10v.dtsi 
b/arch/arm/boot/dts/milbeaut-m10v.dtsi
new file mode 100644
index 000..aa7c6ca
--- /dev/null
+++ b/arch/arm/boot/dts/milbeaut-m10v.dtsi
@@ -0,0 +1,95 @@
+// SPDX-License-Identifier: GPL-2.0
+#include 
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "socionext,sc2000a";
+   interrupt-parent = <>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   enable-method = "socionext,milbeaut-m10v-smp";
+   cpu@f00 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a7";
+   reg = <0xf00>;
+   };
+   cpu@f01 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a7";
+   reg = <0xf01>;
+   };
+   cpu@f02 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a7";
+   reg = <0xf02>;
+   };
+   cpu@f03 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a7";
+   reg = <0xf03>;
+   };
+   };
+
+   timer { /* The Generic Timer */
+   compatible = "arm,armv7-timer";
+   interrupts = ,
+   ,
+   ,
+   ;
+   clock-frequency = <4000>;
+   always-on;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   interrupt-parent = <>;
+
+   gic: interrupt-controller@1d00 {
+   compatible = "arm,cortex-a7-gic";
+   interrupt-controller;
+   #interrupt-cells = <3>;
+   reg = <0x1d001000 0x1000>,
+ <0x1d002000 0x1000>; /* CPU I/f base and size */
+   };
+
+   timer@1e50 { /* 32-bit Reload Timers */
+   compatible = "socionext,milbeaut-timer";
+   reg = <0x1e50 0x20>;
+   interrupts = <0 91 4>;
+   };
+
+   uart1: serial@1e700010 { /* PE4, PE5 */
+   /* Enable this as ttyUSI0 */
+   compatible = "socionext,milbeaut-usio-uart";
+   reg = <0x1e700010 0x10>;
+   interrupts = <0 141 0x4>, <0 149 0x4>;
+   interrupt-names = "rx", "tx";
+   };
+
+   };
+
+   sram@0 {
+   compatible = "mmio-sram";
+   reg = <0x0 0x1>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x0 0x1>;
+   smp-sram@f100 {
+   compatible = 

[PATCH v4 04/10] ARM: milbeaut: Add basic support for Milbeaut m10v SoC

2019-02-26 Thread Sugaya Taichi
This adds the basic M10V SoC support under arch/arm.
Since all cores are activated in the custom bootloader before booting
linux, it is necessary to wait for the secondary-cores using cpu-enable-
method and special sram.

Signed-off-by: Sugaya Taichi 
---
 arch/arm/Kconfig |   2 +
 arch/arm/Makefile|   1 +
 arch/arm/mach-milbeaut/Kconfig   |  20 ++
 arch/arm/mach-milbeaut/Makefile  |   1 +
 arch/arm/mach-milbeaut/platsmp.c | 143 +++
 5 files changed, 167 insertions(+)
 create mode 100644 arch/arm/mach-milbeaut/Kconfig
 create mode 100644 arch/arm/mach-milbeaut/Makefile
 create mode 100644 arch/arm/mach-milbeaut/platsmp.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 26524b7..bf46372 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -750,6 +750,8 @@ source "arch/arm/mach-mediatek/Kconfig"
 
 source "arch/arm/mach-meson/Kconfig"
 
+source "arch/arm/mach-milbeaut/Kconfig"
+
 source "arch/arm/mach-mmp/Kconfig"
 
 source "arch/arm/mach-moxart/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 9db3c58..0e9 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -190,6 +190,7 @@ machine-$(CONFIG_ARCH_MV78XX0)  += mv78xx0
 machine-$(CONFIG_ARCH_MVEBU)   += mvebu
 machine-$(CONFIG_ARCH_MXC) += imx
 machine-$(CONFIG_ARCH_MEDIATEK)+= mediatek
+machine-$(CONFIG_ARCH_MILBEAUT)+= milbeaut
 machine-$(CONFIG_ARCH_MXS) += mxs
 machine-$(CONFIG_ARCH_NETX)+= netx
 machine-$(CONFIG_ARCH_NOMADIK) += nomadik
diff --git a/arch/arm/mach-milbeaut/Kconfig b/arch/arm/mach-milbeaut/Kconfig
new file mode 100644
index 000..6a576fd
--- /dev/null
+++ b/arch/arm/mach-milbeaut/Kconfig
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
+menuconfig ARCH_MILBEAUT
+   bool "Socionext Milbeaut SoCs"
+   depends on ARCH_MULTI_V7
+   select ARM_GIC
+   help
+ This enables support for Socionext Milbeaut SoCs
+
+if ARCH_MILBEAUT
+
+config ARCH_MILBEAUT_M10V
+   bool "Milbeaut SC2000/M10V platform"
+   select ARM_ARCH_TIMER
+   select MILBEAUT_TIMER
+   select PINCTRL
+   select PINCTRL_MILBEAUT
+   help
+ Support for Socionext's MILBEAUT M10V based systems
+
+endif
diff --git a/arch/arm/mach-milbeaut/Makefile b/arch/arm/mach-milbeaut/Makefile
new file mode 100644
index 000..ce5ea06
--- /dev/null
+++ b/arch/arm/mach-milbeaut/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_SMP) += platsmp.o
diff --git a/arch/arm/mach-milbeaut/platsmp.c b/arch/arm/mach-milbeaut/platsmp.c
new file mode 100644
index 000..591543c
--- /dev/null
+++ b/arch/arm/mach-milbeaut/platsmp.c
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright:  (C) 2018 Socionext Inc.
+ * Copyright:  (C) 2015 Linaro Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define M10V_MAX_CPU   4
+#define KERNEL_UNBOOT_FLAG 0x12345678
+
+static void __iomem *m10v_smp_base;
+
+static int m10v_boot_secondary(unsigned int l_cpu, struct task_struct *idle)
+{
+   unsigned int mpidr, cpu, cluster;
+
+   if (!m10v_smp_base)
+   return -ENXIO;
+
+   mpidr = cpu_logical_map(l_cpu);
+   cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
+   cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
+
+   if (cpu >= M10V_MAX_CPU)
+   return -EINVAL;
+
+   pr_info("%s: cpu %u l_cpu %u cluster %u\n",
+   __func__, cpu, l_cpu, cluster);
+
+   writel(__pa_symbol(secondary_startup), m10v_smp_base + cpu * 4);
+   arch_send_wakeup_ipi_mask(cpumask_of(l_cpu));
+
+   return 0;
+}
+
+static void m10v_smp_init(unsigned int max_cpus)
+{
+   unsigned int mpidr, cpu, cluster;
+   struct device_node *np;
+
+   np = of_find_compatible_node(NULL, NULL, "socionext,milbeaut-smp-sram");
+   if (!np)
+   return;
+
+   m10v_smp_base = of_iomap(np, 0);
+   if (!m10v_smp_base)
+   return;
+
+   mpidr = read_cpuid_mpidr();
+   cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
+   cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
+   pr_info("MCPM boot on cpu_%u cluster_%u\n", cpu, cluster);
+
+   for (cpu = 0; cpu < M10V_MAX_CPU; cpu++)
+   writel(KERNEL_UNBOOT_FLAG, m10v_smp_base + cpu * 4);
+}
+
+static void m10v_cpu_die(unsigned int l_cpu)
+{
+   gic_cpu_if_down(0);
+   v7_exit_coherency_flush(louis);
+   wfi();
+}
+
+static int m10v_cpu_kill(unsigned int l_cpu)
+{
+   unsigned int mpidr, cpu;
+
+   mpidr = cpu_logical_map(l_cpu);
+   cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
+
+   writel(KERNEL_UNBOOT_FLAG, m10v_smp_base + cpu * 4);
+
+   return 1;
+}
+
+static struct smp_operations m10v_smp_ops __initdata = {
+   .smp_prepare_cpus   = m10v_smp_init,
+   .smp_boot_secondary = m10v_boot_secondary,
+   .cpu_die= 

[PATCH v4 02/10] dt-bindings: arm: Add SMP enable-method for Milbeaut

2019-02-26 Thread Sugaya Taichi
This adds a compatible string "socionext,milbeaut-m10v-smp"
for Milbeaut M10V to the 32 bit ARM CPU device tree binding.

Signed-off-by: Sugaya Taichi 
Reviewed-by: Rob Herring 
---
 Documentation/devicetree/bindings/arm/cpus.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/cpus.yaml 
b/Documentation/devicetree/bindings/arm/cpus.yaml
index 298c17b..365dcf3 100644
--- a/Documentation/devicetree/bindings/arm/cpus.yaml
+++ b/Documentation/devicetree/bindings/arm/cpus.yaml
@@ -228,6 +228,7 @@ patternProperties:
 - renesas,r9a06g032-smp
 - rockchip,rk3036-smp
 - rockchip,rk3066-smp
+   - socionext,milbeaut-m10v-smp
 - ste,dbx500-smp
 
   cpu-release-addr:
-- 
1.9.1



[PATCH v4 03/10] dt-bindings: Add documentation for Milbeaut SoCs

2019-02-26 Thread Sugaya Taichi
This adds a DT binding documentation for the M10V and its evaluation
board.

Signed-off-by: Sugaya Taichi 
---
 .../bindings/arm/socionext/milbeaut.yaml   | 22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/socionext/milbeaut.yaml

diff --git a/Documentation/devicetree/bindings/arm/socionext/milbeaut.yaml 
b/Documentation/devicetree/bindings/arm/socionext/milbeaut.yaml
new file mode 100644
index 000..aae53fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/socionext/milbeaut.yaml
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/milbeaut.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Milbeaut platforms device tree bindings
+
+maintainers:
+  - Taichi Sugaya 
+  - Takao Orito 
+
+properties:
+  $nodename:
+const: '/'
+  compatible:
+oneOf:
+  - items:
+  - enum:
+  - socionext,milbeaut-m10v-evb
+  - const: socionext,sc2000a
+...
-- 
1.9.1



[PATCH v4 01/10] dt-bindings: sram: milbeaut: Add binding for Milbeaut smp-sram

2019-02-26 Thread Sugaya Taichi
The Milbeaut M10V SoC needs a part of sram for smp, so this adds the
M10V sram compatible and binding.

Signed-off-by: Sugaya Taichi 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/sram/milbeaut-smp-sram.txt | 24 ++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sram/milbeaut-smp-sram.txt

diff --git a/Documentation/devicetree/bindings/sram/milbeaut-smp-sram.txt 
b/Documentation/devicetree/bindings/sram/milbeaut-smp-sram.txt
new file mode 100644
index 000..194f6a3
--- /dev/null
+++ b/Documentation/devicetree/bindings/sram/milbeaut-smp-sram.txt
@@ -0,0 +1,24 @@
+Milbeaut SRAM for smp bringup
+
+Milbeaut SoCs use a part of the sram for the bringup of the secondary cores.
+Once they get powered up in the bootloader, they stay at the specific part
+of the sram.
+Therefore the part needs to be added as the sub-node of mmio-sram.
+
+Required sub-node properties:
+- compatible : should be "socionext,milbeaut-smp-sram"
+
+Example:
+
+sram: sram@0 {
+compatible = "mmio-sram";
+reg = <0x0 0x1>;
+#address-cells = <1>;
+#size-cells = <1>;
+ranges = <0 0x0 0x1>;
+
+smp-sram@f100 {
+compatible = "socionext,milbeaut-smp-sram";
+reg = <0xf100 0x20>;
+};
+};
-- 
1.9.1



[PATCH v4 05/10] dt-bindings: timer: Add Milbeaut M10V timer description

2019-02-26 Thread Sugaya Taichi
Add DT bindings document for Milbeaut M10V timer.

Signed-off-by: Sugaya Taichi 
Reviewed-by: Rob Herring 
---
 .../bindings/timer/socionext,milbeaut-timer.txt | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/timer/socionext,milbeaut-timer.txt

diff --git 
a/Documentation/devicetree/bindings/timer/socionext,milbeaut-timer.txt 
b/Documentation/devicetree/bindings/timer/socionext,milbeaut-timer.txt
new file mode 100644
index 000..ac44c4b
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/socionext,milbeaut-timer.txt
@@ -0,0 +1,17 @@
+Milbeaut SoCs Timer Controller
+
+Required properties:
+
+- compatible : should be "socionext,milbeaut-timer".
+- reg : Specifies base physical address and size of the registers.
+- interrupts : The interrupt of the first timer.
+- clocks: phandle to the input clk.
+
+Example:
+
+timer {
+   compatible = "socionext,milbeaut-timer";
+   reg = <0x1e50 0x20>
+   interrupts = <0 91 4>;
+   clocks = < 4>;
+};
-- 
1.9.1



[PATCH v4 00/10] Add basic support for Socionext Milbeaut M10V SoC

2019-02-26 Thread Sugaya Taichi
Hi,

Here is the series of patches the initial support for SC2000(M10V) of
Milbeaut SoCs. "M10V" is the internal name of SC2000, so commonly used in
source code.

SC2000 is a SoC of the Milbeaut series. equipped with a DSP optimized for
computer vision. It also features advanced functionalities such as 360-degree,
real-time spherical stitching with multi cameras, image stabilization for
without mechanical gimbals, and rolling shutter correction. More detail is
below:
https://www.socionext.com/en/products/assp/milbeaut/SC2000.html

Specifications for developers are below:
 - Quad-core 32bit Cortex-A7 on ARMv7-A architecture
 - NEON support
 - DSP
 - GPU
 - MAX 3GB DDR3
 - Cortex-M0 for power control
 - NAND Flash Interface
 - SD UHS-I
 - SD UHS-II
 - SDIO
 - USB2.0 HOST / Device
 - USB3.0 HOST / Device
 - PCI express Gen2
 - Ethernet Engine
 - I2C
 - UART
 - SPI
 - PWM

Support is quite minimal for now, since it only includes timer, clock,
pictrl and serial controller drivers, so we can only boot to userspace
through initramfs. Support for the other peripherals  will come eventually.

Changes since v3:
* Add "Reviewed" tag to the dt-binding of the serial driver.
* Fix schema string in milbeaut soc binding.
* Refine defconfig for milbeaut M10V.
* Add milbeaut architecture config to multi_v7_defconfig.

Changes since v2:
* Drop clk, pinctrl, and serial driver.
* Drop unneeded options from defconfig.
* Convert milbeaut soc binding to yaml.
* Fix serial driver binding.
* Change serial id of aliases in DT.
* Add platform checking when entering suspend/resume.
* Drop pr_err()s.

Changes since v1:
* Change file names.
* Change #define names.
* Refine cpu-enable-method and bindigs.
* Add documentation for Milbeaut SoCs.
* Add more infomation for timer driver.
* Add sched_clock to timer driver.
* Refine whole of clk driver.
* Add earlycon instead of earlyprintk.
* Refine Device Tree.


Sugaya Taichi (10):
  dt-bindings: sram: milbeaut: Add binding for Milbeaut smp-sram
  dt-bindings: arm: Add SMP enable-method for Milbeaut
  dt-bindings: Add documentation for Milbeaut SoCs
  ARM: milbeaut: Add basic support for Milbeaut m10v SoC
  dt-bindings: timer: Add Milbeaut M10V timer description
  clocksource/drivers/timer-milbeaut: Introduce timer for Milbeaut SoCs
  dt-bindings: serial: Add Milbeaut serial driver description
  ARM: dts: milbeaut: Add device tree set for the Milbeaut M10V board
  ARM: configs: Add Milbeaut M10V defconfig
  ARM: multi_v7_defconfig: add ARCH_MILBEAUT and ARCH_MILBEAUT_M10V

 Documentation/devicetree/bindings/arm/cpus.yaml|   1 +
 .../bindings/arm/socionext/milbeaut.yaml   |  22 +++
 .../devicetree/bindings/serial/milbeaut-uart.txt   |  21 +++
 .../devicetree/bindings/sram/milbeaut-smp-sram.txt |  24 +++
 .../bindings/timer/socionext,milbeaut-timer.txt|  17 +++
 arch/arm/Kconfig   |   2 +
 arch/arm/Makefile  |   1 +
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/milbeaut-m10v-evb.dts|  32 
 arch/arm/boot/dts/milbeaut-m10v.dtsi   |  95 
 arch/arm/configs/milbeaut_m10v_defconfig   | 119 +++
 arch/arm/configs/multi_v7_defconfig|   2 +
 arch/arm/mach-milbeaut/Kconfig |  20 +++
 arch/arm/mach-milbeaut/Makefile|   1 +
 arch/arm/mach-milbeaut/platsmp.c   | 143 ++
 drivers/clocksource/Kconfig|   9 ++
 drivers/clocksource/Makefile   |   1 +
 drivers/clocksource/timer-milbeaut.c   | 161 +
 18 files changed, 672 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/socionext/milbeaut.yaml
 create mode 100644 Documentation/devicetree/bindings/serial/milbeaut-uart.txt
 create mode 100644 Documentation/devicetree/bindings/sram/milbeaut-smp-sram.txt
 create mode 100644 
Documentation/devicetree/bindings/timer/socionext,milbeaut-timer.txt
 create mode 100644 arch/arm/boot/dts/milbeaut-m10v-evb.dts
 create mode 100644 arch/arm/boot/dts/milbeaut-m10v.dtsi
 create mode 100644 arch/arm/configs/milbeaut_m10v_defconfig
 create mode 100644 arch/arm/mach-milbeaut/Kconfig
 create mode 100644 arch/arm/mach-milbeaut/Makefile
 create mode 100644 arch/arm/mach-milbeaut/platsmp.c
 create mode 100644 drivers/clocksource/timer-milbeaut.c

-- 
1.9.1



Re: [PATCH] rapidio/mport_cdev: mark expected switch fall-through

2019-02-26 Thread Gustavo A. R. Silva
Hi all,

Friendly ping:

Who can review or take this, please?

Thanks
--
Gustavo

On 2/12/19 11:50 AM, Gustavo A. R. Silva wrote:
> n preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
> 
> This patch fixes the following warning:
> 
> drivers/rapidio/devices/rio_mport_cdev.c: In function ‘mport_release_mapping’:
> drivers/rapidio/devices/rio_mport_cdev.c:2151:3: warning: this statement may 
> fall through [-Wimplicit-fallthrough=]
>rio_unmap_inb_region(mport, map->phys_addr);
>^~~
>   CC  drivers/regulator/fixed-helper.o
>   CC  drivers/pinctrl/stm32/pinctrl-stm32f429.o
> drivers/rapidio/devices/rio_mport_cdev.c:2152:2: note: here
>   case MAP_DMA:
>   ^~~~
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Signed-off-by: Gustavo A. R. Silva 
> ---
>  drivers/rapidio/devices/rio_mport_cdev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/rapidio/devices/rio_mport_cdev.c 
> b/drivers/rapidio/devices/rio_mport_cdev.c
> index cbe467ff1aba..1e1f42e210a0 100644
> --- a/drivers/rapidio/devices/rio_mport_cdev.c
> +++ b/drivers/rapidio/devices/rio_mport_cdev.c
> @@ -2149,6 +2149,7 @@ static void mport_release_mapping(struct kref *ref)
>   switch (map->dir) {
>   case MAP_INBOUND:
>   rio_unmap_inb_region(mport, map->phys_addr);
> + /* fall through */
>   case MAP_DMA:
>   dma_free_coherent(mport->dev.parent, map->size,
> map->virt_addr, map->phys_addr);
> 


[PATCH 4/8] PCI: rockchip: fix a leaked reference by adding missing of_node_put

2019-02-26 Thread Wen Yang
The call to of_get_child_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/pcie-rockchip-host.c:729:2-8: ERROR: missing 
of_node_put; acquired a node pointer with refcount incremented on line 718, but 
without a corresponding object release within this function.
./drivers/pci/controller/pcie-rockchip-host.c:732:1-7: ERROR: missing 
of_node_put; acquired a node pointer with refcount incremented on line 718, but 
without a corresponding object release within this function.

Signed-off-by: Wen Yang 
Cc: Shawn Lin 
Cc: Lorenzo Pieralisi 
Cc: Bjorn Helgaas 
Cc: Heiko Stuebner 
Cc: linux-...@vger.kernel.org
Cc: linux-rockc...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/pcie-rockchip-host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/pcie-rockchip-host.c 
b/drivers/pci/controller/pcie-rockchip-host.c
index 1372d27..8d20f17 100644
--- a/drivers/pci/controller/pcie-rockchip-host.c
+++ b/drivers/pci/controller/pcie-rockchip-host.c
@@ -724,6 +724,7 @@ static int rockchip_pcie_init_irq_domain(struct 
rockchip_pcie *rockchip)
 
rockchip->irq_domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
_domain_ops, rockchip);
+   of_node_put(intc);
if (!rockchip->irq_domain) {
dev_err(dev, "failed to get a INTx IRQ domain\n");
return -EINVAL;
-- 
2.9.5



[PATCH 8/8] PCI: rpadlpar: fix a leaked reference by adding missing of_node_put

2019-02-26 Thread Wen Yang
The call to of_find_node_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pci/hotplug/rpadlpar_core.c:55:1-7: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 42, but without a 
corresponding object release within this function

Signed-off-by: Wen Yang 
Cc: Tyrel Datwyler 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Bjorn Helgaas 
Cc: linux-...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/hotplug/rpadlpar_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/hotplug/rpadlpar_core.c 
b/drivers/pci/hotplug/rpadlpar_core.c
index e2356a9..f3f42ff 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -52,6 +52,7 @@ static struct device_node *find_vio_slot_node(char *drc_name)
break;
}
 
+   of_node_put(parent);
return dn;
 }
 
-- 
2.9.5



Re: [PATCH v2 1/1] lib/string: Add strscpy_pad() function

2019-02-26 Thread Tobin C. Harding
On Mon, Feb 25, 2019 at 01:38:44PM -0800, Kees Cook wrote:
> On Sun, Feb 24, 2019 at 8:16 PM Tobin C. Harding  wrote:
> >
> > We have a function to copy strings safely and we have a function to copy
> > strings and zero the tail of the destination (if source string is
> > shorter than destination buffer) but we do not have a function to do
> > both at once.  This means developers must write this themselves if they
> > desire this functionality.  This is a chore, and also leaves us open to
> > off by one errors unnecessarily.
> >
> > Add a function that calls strscpy() then memset()s the tail to zero if
> > the source string is shorter than the destination buffer.
> >
> > Add test module for the new code.
> >
> > Signed-off-by: Tobin C. Harding 
> > [...]
> > +ssize_t strscpy_pad(char *dest, const char *src, size_t count)
> > +{
> > +   ssize_t written;
> > +
> > +   written = strscpy(dest, src, count);
> > +   if (written < 0 || written == count - 1)
> > +   return written;
> 
> *thread merge* Yeah, good point. written will be -E2BIG for both count
> = 0 and count = 1.
> 
> > +
> > +   memset(dest + written + 1, 0, count - written - 1);
> > +
> > +   return written;
> > +}
> > +EXPORT_SYMBOL(strscpy_pad);
> > +
> >  #ifndef __HAVE_ARCH_STRCAT
> >  /**
> >   * strcat - Append one %NUL-terminated string to another
> > diff --git a/lib/test_strscpy.c b/lib/test_strscpy.c
> > new file mode 100644
> > index ..5ec6a196f4e2
> > --- /dev/null
> > +++ b/lib/test_strscpy.c
> > @@ -0,0 +1,175 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/*
> > + * Kernel module for testing 'strscpy' family of functions.
> > + */
> > +
> > +static unsigned total_tests __initdata;
> > +static unsigned failed_tests __initdata;
> > +
> > +static void __init do_test(int count, char *src, int expected,
> > +  int chars, int terminator, int pad)
> > +{
> > +   char buf[6];
> 
> I would make this "6" a define, since you use it in more than one
> place. Actually... no, never mind. The other places can use
> "sizeof(buf)" instead of "6". Noted below...
> 
> But I'd add an explicit check for "expected + 1 < sizeof(buf)" just
> for future test-addition sanity.
> 
> > +   int written;
> > +   int poison;
> > +   int index;
> > +   int i;
> > +   const char POISON = 'z';
> > +
> > +   total_tests++;
> > +   memset(buf, POISON, sizeof(buf));
> > +
> > +   /* Verify the return value */
> > +
> 
> Needless blank line.
> 
> > +   written = strscpy_pad(buf, src, count);
> > +   if ((written) != (expected)) {
> > +   pr_err("%d != %d (written, expected)\n", written, expected);
> > +   goto fail;
> > +   }
> > +
> > +   /* Verify the state of the buffer */
> > +
> 
> Same.
> 
> > +   if (count && written == -E2BIG) {
> > +   if (strncmp(buf, src, count - 1) != 0) {
> > +   pr_err("buffer state invalid for -E2BIG\n");
> > +   goto fail;
> > +   }
> > +   if (buf[count - 1] != '\0') {
> > +   pr_err("too big string is not null terminated 
> > correctly\n");
> > +   goto fail;
> > +   }
> > +   }
> > +
> > +   /* Verify the copied content */
> > +   for (i = 0; i < chars; i++) {
> > +   if (buf[i] != src[i]) {
> > +   pr_err("buf[i]==%c != src[i]==%c\n", buf[i], 
> > src[i]);
> > +   goto fail;
> > +   }
> > +   }
> > +
> > +   /* Verify the null terminator */
> > +   if (terminator) {
> > +   if (buf[count - 1] != '\0') {
> > +   pr_err("string is not null terminated correctly\n");
> > +   goto fail;
> > +   }
> > +   }
> > +
> > +   /* Verify the padding */
> > +   for (i = 0; i < pad; i++) {
> > +   index = chars + terminator + i;
> > +   if (buf[index] != '\0') {
> > +   pr_err("padding missing at index: %d\n", i);
> > +   goto fail;
> > +   }
> > +   }
> > +
> > +   /* Verify the rest is left untouched */
> > +   poison = 6 - chars - terminator - pad;
> 
> instead of "6", use "sizeof(buf)".
> 
> > +   for (i = 0; i < poison; i++) {
> > +   index = 6 - 1 - i; /* Check from the end back */
> 
> Same.
> 
> > +   if (buf[index] != POISON) {
> > +   pr_err("poison value missing at index: %d\n", i);
> > +   goto fail;
> > +   }
> > +   }
> > +
> > +   return;
> > +fail:
> > +   pr_info("%s(%d, '%s', %d, %d, %d, %d)\n", __func__,
> > +   count, src, expected, chars, terminator, pad);
> > +   

[PATCH 5/8] PCI: aardvark: fix a leaked reference by adding missing of_node_put

2019-02-26 Thread Wen Yang
The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/pci-aardvark.c:826:1-7: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 798, but without a 
corresponding object release within this function.

Signed-off-by: Wen Yang 
Cc: Thomas Petazzoni 
Cc: Lorenzo Pieralisi 
Cc: Bjorn Helgaas 
Cc: linux-...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/pci-aardvark.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/controller/pci-aardvark.c 
b/drivers/pci/controller/pci-aardvark.c
index 750081c..56ecb16 100644
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
@@ -794,6 +794,7 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
struct device_node *node = dev->of_node;
struct device_node *pcie_intc_node;
struct irq_chip *irq_chip;
+   int ret = 0;
 
pcie_intc_node =  of_get_next_child(node, NULL);
if (!pcie_intc_node) {
@@ -806,8 +807,8 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq",
dev_name(dev));
if (!irq_chip->name) {
-   of_node_put(pcie_intc_node);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto out_put_node;
}
 
irq_chip->irq_mask = advk_pcie_irq_mask;
@@ -819,11 +820,13 @@ static int advk_pcie_init_irq_domain(struct advk_pcie 
*pcie)
  _pcie_irq_domain_ops, pcie);
if (!pcie->irq_domain) {
dev_err(dev, "Failed to get a INTx IRQ domain\n");
-   of_node_put(pcie_intc_node);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto out_put_node;
}
 
-   return 0;
+out_put_node:
+   of_node_put(pcie_intc_node);
+   return ret;
 }
 
 static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie)
-- 
2.9.5



[PATCH 3/8] PCI: dwc: layerscape: fix a leaked reference by adding missing of_node_put

2019-02-26 Thread Wen Yang
The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/dwc/pci-layerscape.c:204:1-7: ERROR: missing 
of_node_put; acquired a node pointer with refcount incremented on line 198, but 
without a corresponding object release within this function.

Signed-off-by: Wen Yang 
Cc: Minghuan Lian 
Cc: Mingkai Hu 
Cc: Roy Zang 
Cc: Lorenzo Pieralisi 
Cc: Bjorn Helgaas 
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/dwc/pci-layerscape.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/dwc/pci-layerscape.c 
b/drivers/pci/controller/dwc/pci-layerscape.c
index ce45bde2..3a5fa26 100644
--- a/drivers/pci/controller/dwc/pci-layerscape.c
+++ b/drivers/pci/controller/dwc/pci-layerscape.c
@@ -201,6 +201,7 @@ static int ls_pcie_msi_host_init(struct pcie_port *pp)
return -EINVAL;
}
 
+   of_node_put(msi_node);
return 0;
 }
 
-- 
2.9.5



[PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put

2019-02-26 Thread Wen Yang
The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/dwc/pci-dra7xx.c:252:2-8: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 241, but without a 
corresponding object release within this function.
./drivers/pci/controller/dwc/pci-dra7xx.c:255:1-7: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 241, but without a 
corresponding object release within this function.

Signed-off-by: Wen Yang 
Cc: Kishon Vijay Abraham I 
Cc: Lorenzo Pieralisi 
Cc: Bjorn Helgaas 
Cc: linux-o...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/dwc/pci-dra7xx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c 
b/drivers/pci/controller/dwc/pci-dra7xx.c
index ae84a69..627c91d 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -247,6 +247,7 @@ static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp)
 
dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
   _domain_ops, pp);
+   of_node_put(pcie_intc_node);
if (!dra7xx->irq_domain) {
dev_err(dev, "Failed to get a INTx IRQ domain\n");
return -ENODEV;
-- 
2.9.5



[PATCH 7/8] PCI: mediatek: fix a leaked reference by adding missing of_node_put

2019-02-26 Thread Wen Yang
The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/pcie-mediatek.c:577:2-8: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 567, but without a 
corresponding object release within this function.
./drivers/pci/controller/pcie-mediatek.c:583:3-9: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 567, but without a 
corresponding object release within this function.
./drivers/pci/controller/pcie-mediatek.c:586:1-7: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 567, but without a 
corresponding object release within this function.

Signed-off-by: Wen Yang 
Cc: Ryder Lee 
Cc: Lorenzo Pieralisi 
Cc: Bjorn Helgaas 
Cc: Matthias Brugger 
Cc: linux-...@vger.kernel.org
Cc: linux-media...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
---
 drivers/pci/controller/pcie-mediatek.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/pcie-mediatek.c 
b/drivers/pci/controller/pcie-mediatek.c
index 55e471c..e91716a 100644
--- a/drivers/pci/controller/pcie-mediatek.c
+++ b/drivers/pci/controller/pcie-mediatek.c
@@ -572,6 +572,7 @@ static int mtk_pcie_init_irq_domain(struct mtk_pcie_port 
*port,
 
port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
 _domain_ops, port);
+   of_node_put(pcie_intc_node);
if (!port->irq_domain) {
dev_err(dev, "failed to get INTx IRQ domain\n");
return -ENODEV;
-- 
2.9.5



[PATCH 6/8] PCI: iproc: fix a leaked reference by adding missing of_node_put

2019-02-26 Thread Wen Yang
The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
iproc_msi_init also calls of_node_get to increase refcount
(proc_msi_init -> iproc_msi_alloc_domains -> pci_msi_create_irq_domain
-> msi_create_irq_domain -> irq_domain_create_linear -> __irq_domain_add),
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/pcie-iproc.c:1323:3-9: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 1299, but without a 
corresponding object release within this function.
./drivers/pci/controller/pcie-iproc.c:1330:1-7: ERROR: missing of_node_put; 
acquired a node pointer with refcount incremented on line 1299, but without a 
corresponding object release within this function.

Signed-off-by: Wen Yang 
Cc: Lorenzo Pieralisi 
Cc: Bjorn Helgaas 
Cc: Ray Jui 
Cc: Scott Branden 
Cc: bcm-kernel-feedback-l...@broadcom.com
Cc: linux-...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/pcie-iproc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pcie-iproc.c 
b/drivers/pci/controller/pcie-iproc.c
index c20fd6b..9998c5c 100644
--- a/drivers/pci/controller/pcie-iproc.c
+++ b/drivers/pci/controller/pcie-iproc.c
@@ -1320,14 +1320,18 @@ static int iproc_pcie_msi_enable(struct iproc_pcie 
*pcie)
if (pcie->need_msi_steer) {
ret = iproc_pcie_msi_steer(pcie, msi_node);
if (ret)
-   return ret;
+   goto out_put_node;
}
 
/*
 * If another MSI controller is being used, the call below should fail
 * but that is okay
 */
-   return iproc_msi_init(pcie, msi_node);
+   ret = iproc_msi_init(pcie, msi_node);
+
+out_put_node:
+   of_node_put(msi_node);
+   return ret;
 }
 
 static void iproc_pcie_msi_disable(struct iproc_pcie *pcie)
-- 
2.9.5



[PATCH 2/8] PCI: uniphier: fix a leaked reference by adding missing of_node_put

2019-02-26 Thread Wen Yang
The call to of_get_child_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/dwc/pcie-uniphier.c:283:2-8: ERROR: missing 
of_node_put; acquired a node pointer with refcount incremented on line 274, but 
without a corresponding object release within this function.
./drivers/pci/controller/dwc/pcie-uniphier.c:290:2-8: ERROR: missing 
of_node_put; acquired a node pointer with refcount incremented on line 274, but 
without a corresponding object release within this function.
./drivers/pci/controller/dwc/pcie-uniphier.c:296:1-7: ERROR: missing 
of_node_put; acquired a node pointer with refcount incremented on line 274, but 
without a corresponding object release within this function.

Signed-off-by: Wen Yang 
Cc: Kunihiko Hayashi 
Cc: Lorenzo Pieralisi 
Cc: Bjorn Helgaas 
Cc: Masahiro Yamada 
Cc: linux-...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/dwc/pcie-uniphier.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-uniphier.c 
b/drivers/pci/controller/dwc/pcie-uniphier.c
index d5dc402..3f30ee4 100644
--- a/drivers/pci/controller/dwc/pcie-uniphier.c
+++ b/drivers/pci/controller/dwc/pcie-uniphier.c
@@ -270,6 +270,7 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port 
*pp)
struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci);
struct device_node *np = pci->dev->of_node;
struct device_node *np_intc;
+   int ret = 0;
 
np_intc = of_get_child_by_name(np, "legacy-interrupt-controller");
if (!np_intc) {
@@ -280,20 +281,24 @@ static int uniphier_pcie_config_legacy_irq(struct 
pcie_port *pp)
pp->irq = irq_of_parse_and_map(np_intc, 0);
if (!pp->irq) {
dev_err(pci->dev, "Failed to get an IRQ entry in 
legacy-interrupt-controller\n");
-   return -EINVAL;
+   ret = -EINVAL;
+   goto out_put_node;
}
 
priv->legacy_irq_domain = irq_domain_add_linear(np_intc, PCI_NUM_INTX,
_intx_domain_ops, pp);
if (!priv->legacy_irq_domain) {
dev_err(pci->dev, "Failed to get INTx domain\n");
-   return -ENODEV;
+   ret = -ENODEV;
+   goto out_put_node;
}
 
irq_set_chained_handler_and_data(pp->irq, uniphier_pcie_irq_handler,
 pp);
 
-   return 0;
+out_put_node:
+   of_node_put(np_intc);
+   return ret;
 }
 
 static int uniphier_pcie_host_init(struct pcie_port *pp)
-- 
2.9.5



Re: [PATCH v4 01/12] clk: mediatek: Disable tuner_en before change PLL rate

2019-02-26 Thread Weiyi Lu
On Wed, 2019-02-27 at 11:51 +0800, Weiyi Lu wrote:
> On Tue, 2019-02-26 at 16:59 +0100, Matthias Brugger wrote:
> > 
> > On 01/02/2019 09:30, Weiyi Lu wrote:
> > > From: Owen Chen 
> > > 
> > > PLLs with tuner_en bit, such as APLL1, need to disable
> > > tuner_en before apply new frequency settings, or the new frequency
> > > settings (pcw) will not be applied.
> > > The tuner_en bit will be disabled during changing PLL rate
> > > and be restored after new settings applied.
> > > Another minor change is to correct the macro name of pcw change bit
> > > to CON1_PCW_CHG because PCW_CHG(BIT31) is on CON1.
> > > 
> > > Fixes: e2f744a82d725 (clk: mediatek: Add MT2712 clock support)
> > > Cc: 
> > > Signed-off-by: Owen Chen 
> > > ---
> > >  drivers/clk/mediatek/clk-pll.c | 33 +++--
> > >  1 file changed, 31 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/clk/mediatek/clk-pll.c 
> > > b/drivers/clk/mediatek/clk-pll.c
> > > index f54e4015b0b1..f0ff5f535c7e 100644
> > > --- a/drivers/clk/mediatek/clk-pll.c
> > > +++ b/drivers/clk/mediatek/clk-pll.c
> > > @@ -27,7 +27,7 @@
> > >  #define CON0_BASE_EN BIT(0)
> > >  #define CON0_PWR_ON  BIT(0)
> > >  #define CON0_ISO_EN  BIT(1)
> > > -#define CON0_PCW_CHG BIT(31)
> > > +#define CON1_PCW_CHG BIT(31)
> > >  
> > >  #define AUDPLL_TUNER_EN  BIT(31)
> > >  
> > > @@ -93,9 +93,31 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll 
> > > *pll, u32 pcw,
> > >  {
> > >   u32 con1, val;
> > >   int pll_en;
> > > + u32 tuner_en = 0;
> > > + u32 tuner_en_mask;
> > > + void __iomem *tuner_en_addr = NULL;
> > >  
> > >   pll_en = readl(pll->base_addr + REG_CON0) & CON0_BASE_EN;
> > >  
> > > + /* disable tuner */
> > > + if (pll->tuner_en_addr) {
> > > + tuner_en_addr = pll->tuner_en_addr;
> > > + tuner_en_mask = BIT(pll->data->tuner_en_bit);
> > > + } else if (pll->tuner_addr) {
> > > + tuner_en_addr = pll->tuner_addr;
> > > + tuner_en_mask = AUDPLL_TUNER_EN;
> > > + }
> > > +
> > > + if (tuner_en_addr) {
> > > + val = readl(tuner_en_addr);
> > > + tuner_en = val & tuner_en_mask;
> > > +
> > > + if (tuner_en) {
> > > + val &= ~tuner_en_mask;
> > > + writel(val, tuner_en_addr);
> > > + }
> > > + }
> > > +
> > 
> > Why don't we use a flag here, it would make the code easier to understand.
> > I think it would also help if you put this code in a separate function.
> > 
> > Regards,
> > Matthias
> > 
> 
> Hi Matthias,
> 
> I guess you suggest to add a flag (e.g. CLK_TUNER_SUPPORT) and declare
> the PLL clock with this flag. And inside this mtk_pll_set_rate_regs()
> function, we could modify it as below. Am I right?
> 
> if (pll->data->flags & CLK_TUNER_SUPPORT)
> disable_tuner();
> [...]
> if (pll->data->flags & CLK_TUNER_SUPPORT)
> enable_tuner();
> 
> 
> But I thought this flag might be a customized flags and can only be put
> in clk-mtk.h not clk-provider.h so far. And it might cause 
> potential problem of clock flag re-definition. May I have more
> suggestion?
> 

Please ignore the potential problem I mentioned, I just checked it
carefully and that redefinition problem won't happen in current flow.
Sorry for having you confused.
But I still need to confirm with you if the method in previous mail is
correct? Thanks.

> > 
> > >   /* set postdiv */
> > >   val = readl(pll->pd_addr);
> > >   val &= ~(POSTDIV_MASK << pll->data->pd_shift);
> > > @@ -116,12 +138,19 @@ static void mtk_pll_set_rate_regs(struct 
> > > mtk_clk_pll *pll, u32 pcw,
> > >   con1 = readl(pll->base_addr + REG_CON1);
> > >  
> > >   if (pll_en)
> > > - con1 |= CON0_PCW_CHG;
> > > + con1 |= CON1_PCW_CHG;
> > >  
> > >   writel(con1, pll->base_addr + REG_CON1);
> > >   if (pll->tuner_addr)
> > >   writel(con1 + 1, pll->tuner_addr);
> > >  
> > > + /* restore tuner_en */
> > > + if (tuner_en_addr && tuner_en) {
> > > + val = readl(tuner_en_addr);
> > > + val |= tuner_en_mask;
> > > + writel(val, tuner_en_addr);
> > > + }
> > > +
> > >   if (pll_en)
> > >   udelay(20);
> > >  }
> > > 
> 




Re: [RFC PATCH 11/20] ia64: Add unconditional mmiowb() to arch_spin_unlock()

2019-02-26 Thread Nicholas Piggin
Will Deacon's on February 23, 2019 4:50 am:
> The mmiowb() macro is horribly difficult to use and drivers will continue
> to work most of the time if they omit a call when it is required.
> 
> Rather than rely on driver authors getting this right, push mmiowb() into
> arch_spin_unlock() for ia64. If this is deemed to be a performance issue,
> a subsequent optimisation could make use of ARCH_HAS_MMIOWB to elide
> the barrier in cases where no I/O writes were performned inside the
> critical section.

mmiowb() was always the wrong approach. IIRC what happened is that an
ia64 platform found that real wmb() semantics were too expensive, so 
they kind of "relaxed" it, breaking everything, and then said drivers
that wanted to unbreak themselves had to add these mmiowb() in.

The right way to go of course would have been to implement wmb()
the way existing drivers expected, and add a faster io_wmb() that
only ordered mmio stores from the CPU added to the few drivers that
the platform cared about.

I think it was argued the wmb() was still technically correct because
the reordering did not happen at the CPU, but somewhere else in the 
interconnect or PCI controller. But that was just a crazy burden to
put on driver writers, and it was why the documentation was always
incomprehensible.

Not sure why Linus ever went along with it, but awesome you're removing
it. Thank you!

Thanks,
Nick


Re: [PATCH v2 2/7] dt-bindings: phy: Add binding for Qualcomm PCIe2 PHY

2019-02-26 Thread Bjorn Andersson
On Fri 22 Feb 11:57 PST 2019, Rob Herring wrote:

> On Mon, Feb 18, 2019 at 10:04:02PM -0800, Bjorn Andersson wrote:
> > The Qualcomm PCIe2 PHY is a Synopsys based PCIe PHY found in a number of
> > Qualcomm platforms, add a binding to describe this.
> > 
> > Signed-off-by: Bjorn Andersson 
> > ---
> >  .../bindings/phy/qcom-pcie2-phy.txt   | 40 +++
> >  1 file changed, 40 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/phy/qcom-pcie2-phy.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/phy/qcom-pcie2-phy.txt 
> > b/Documentation/devicetree/bindings/phy/qcom-pcie2-phy.txt
> > new file mode 100644
> > index ..7da02f9d78c7
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/phy/qcom-pcie2-phy.txt
> > @@ -0,0 +1,40 @@
> > +Qualcomm PCIe2 PHY controller
> > +=
> > +
> > +The Qualcomm PCIe2 PHY is a Synopsys based phy found in a number of 
> > Qualcomm
> > +platforms.
> > +
> > +Required properties:
> > + - compatible: compatible list, should be:
> > +  "qcom,qcs404-pcie2-phy", "qcom,pcie2-phy"
> > +
> > + - reg: offset and length of the PHY register set.
> > + - #phy-cells: must be 0.
> > +
> > + - clocks: a clock-specifier pair for the "pipe" clock
> > +
> > + - vdda-vp-supply: phandle to low voltage regulator
> > + - vdda-vph-supply: phandle to high voltage regulator
> > +
> > + - resets: reset-specifier pairs for the "phy" and "pipe" resets
> > + - reset-names: list of resets, should contain:
> > +   "phy" and "pipe"
> > +
> > + - clock-output-names: name of the outgoing clock signal from the PHY PLL
> 
> Not valid to have this without '#clock-cells'.
> 

This happens to work today as we don't describe 's dependency on
this, but just rely on the global clock namespace. But it should be
there, so I'll respin this.

> Though I'm confused how this and the input clock name seem to match.
> 

The PHY generates the clock we call "pcie_0_pipe_clk" which is fed into
the global clock controller (gcc), where it can be gated (and divided)
and then fed back to both the PHY and the controller as
"gcc_pcie_0_pipe_clk".


Thanks for the review Rob.

Regards,
Bjorn

> > +
> > +Example:
> > + phy@7786000 {
> > +   compatible = "qcom,qcs404-pcie2-phy", "qcom,pcie2-phy";
> > +   reg = <0x07786000 0xb8>;
> > +
> > +   clocks = < GCC_PCIE_0_PIPE_CLK>;
> > +   resets = < GCC_PCIEPHY_0_PHY_BCR>,
> > +< GCC_PCIE_0_PIPE_ARES>;
> > +   reset-names = "phy", "pipe";
> > +
> > +   vdda-vp-supply = <_l3_1p05>;
> > +   vdda-vph-supply = <_l5_1p8>;
> > +
> > +   clock-output-names = "pcie_0_pipe_clk";
> > +   #phy-cells = <0>;
> > + };
> > -- 
> > 2.18.0
> > 


linux-next: manual merge of the vhost tree with the iommu tree

2019-02-26 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the vhost tree got conflicts in:

  drivers/iommu/Kconfig
  drivers/iommu/Makefile

between commit:

  004240dcc222 ("iommu/hyper-v: Add Hyper-V stub IOMMU driver")

from the iommu tree and commit:

  d906f4225497 ("iommu: Add virtio-iommu driver")

from the vhost tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/iommu/Kconfig
index 6f07f3b21816,d507fd754214..
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@@ -437,13 -435,15 +437,24 @@@ config QCOM_IOMM
help
  Support for IOMMU on certain Qualcomm SoCs.
  
 +config HYPERV_IOMMU
 +  bool "Hyper-V x2APIC IRQ Handling"
 +  depends on HYPERV
 +  select IOMMU_API
 +  default HYPERV
 +  help
 +Stub IOMMU driver to handle IRQs as to allow Hyper-V Linux
 +guests to run with x2APIC mode enabled.
 +
+ config VIRTIO_IOMMU
+   bool "Virtio IOMMU driver"
+   depends on VIRTIO=y
+   depends on ARM64
+   select IOMMU_API
+   select INTERVAL_TREE
+   help
+ Para-virtualised IOMMU driver with virtio.
+ 
+ Say Y here if you intend to run this kernel as a guest.
+ 
  endif # IOMMU_SUPPORT
diff --cc drivers/iommu/Makefile
index 8c71a15e986b,48d831a39281..
--- a/drivers/iommu/Makefile
+++ b/drivers/iommu/Makefile
@@@ -32,4 -32,4 +32,5 @@@ obj-$(CONFIG_EXYNOS_IOMMU) += exynos-io
  obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o
  obj-$(CONFIG_S390_IOMMU) += s390-iommu.o
  obj-$(CONFIG_QCOM_IOMMU) += qcom_iommu.o
 +obj-$(CONFIG_HYPERV_IOMMU) += hyperv-iommu.o
+ obj-$(CONFIG_VIRTIO_IOMMU) += virtio-iommu.o


pgpGFfujaRSm4.pgp
Description: OpenPGP digital signature


[sgi-xp] Missing break or false positive?

2019-02-26 Thread Gustavo A. R. Silva
Hi all,

I'm taking a look into the following piece of code in 
drivers/misc/sgi-xp/xpc_uv.c:

 561 case XPC_ACTIVATE_MQ_MSG_CHCTL_OPENCOMPLETE_UV: {
 562 struct xpc_activate_mq_msg_chctl_opencomplete_uv *msg;
 563 
 564 if (!part_setup)
 565 break;
 566 
 567 msg = container_of(msg_hdr, struct
 568 xpc_activate_mq_msg_chctl_opencomplete_uv, 
hdr);
 569 spin_lock_irqsave(>chctl_lock, irq_flags);
 570 part->chctl.flags[msg->ch_number] |= 
XPC_CHCTL_OPENCOMPLETE;
 571 spin_unlock_irqrestore(>chctl_lock, irq_flags);
 572 
 573 xpc_wakeup_channel_mgr(part);
 574 }

and I'm trying to figure out if the following warning is due to a missing break
at the end of the case, or if this is just a false positive and a /* fall 
through */
annotation should be added:

drivers/misc/sgi-xp/xpc_uv.c: In function ‘xpc_handle_activate_mq_msg_uv’:
drivers/misc/sgi-xp/xpc_uv.c:573:3: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
   xpc_wakeup_channel_mgr(part);
   ^~~~
drivers/misc/sgi-xp/xpc_uv.c:575:2: note: here
  case XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV:
  ^~~~

The piece of code above was introduced by the following commit in 2009:

efdd06ed181a88a11e612238c1ac04668e665395

The cases are pretty similar, and the fact that this code was introduced
in the middle of the switch statement and not at the end or the beginning,
leads me to believe that this is a false positive.  On the other hand,
all the other cases end with a break or a return but this one.  So, I
better ask your opinions about this.

Thanks
--
Gustavo


Realtek r8822be kernel module does not negotiate 802.11ac connection

2019-02-26 Thread David R. Bergstein
This message is in regard to a bug I have open on bugs.launchpad.net,
1813372, linked below.  This issue, originally identified in an Ubuntu
kernel, has been duplicated in the most current mainline kernel,
5.0-rc8, and is in regard to problems attaining a wireless connection at
802.11ac speeds.

https://bugs.launchpad.net/bugs/1813372

At your earliest convenience, please see the bug report above, and
advise if a fix will be available for the r8822be kernel module.

Sincerely,

David R. Bergstein




signature.asc
Description: OpenPGP digital signature


[RFC dma-buf 3/3] dma-buf: add show_fdinfo handler

2019-02-26 Thread Chenbo Feng
From: Greg Hackmann 

The show_fdinfo handler exports the same information available through
debugfs on a per-buffer basis.

Signed-off-by: Greg Hackmann 
Signed-off-by: Chenbo Feng 
---
 drivers/dma-buf/dma-buf.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index e0d9cdd3520b..2da3e2653f92 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -377,6 +377,20 @@ static long dma_buf_ioctl(struct file *file,
}
 }
 
+static void dma_buf_show_fdinfo(struct seq_file *m, struct file *file)
+{
+   struct dma_buf *dmabuf = file->private_data;
+
+   seq_printf(m, "size:\t%zu\n", dmabuf->size);
+   /* Don't count the temporary reference taken inside procfs seq_show */
+   seq_printf(m, "count:\t%ld\n", file_count(dmabuf->file) - 1);
+   seq_printf(m, "exp_name:\t%s\n", dmabuf->exp_name);
+   mutex_lock(>lock);
+   if (dmabuf->name)
+   seq_printf(m, "name:\t%s\n", dmabuf->name);
+   mutex_unlock(>lock);
+}
+
 static const struct file_operations dma_buf_fops = {
.release= dma_buf_release,
.mmap   = dma_buf_mmap_internal,
@@ -386,6 +400,7 @@ static const struct file_operations dma_buf_fops = {
 #ifdef CONFIG_COMPAT
.compat_ioctl   = dma_buf_ioctl,
 #endif
+   .show_fdinfo= dma_buf_show_fdinfo,
 };
 
 /*
-- 
2.21.0.rc2.261.ga7da99ff1b-goog



[RFC dma-buf 2/3] dma-buf: add DMA_BUF_{GET,SET}_NAME ioctls

2019-02-26 Thread Chenbo Feng
From: Greg Hackmann 

This patch adds complimentary DMA_BUF_SET_NAME and DMA_BUF_GET_NAME
ioctls, which lets userspace processes attach a free-form name to each
buffer.

This information can be extremely helpful for tracking and accounting
shared buffers.  For example, on Android, we know what each buffer will
be used for at allocation time: GL, multimedia, camera, etc.  The
userspace allocator can use DMA_BUF_SET_NAME to associate that
information with the buffer, so we can later give developers a
breakdown of how much memory they're allocating for graphics, camera,
etc.

Signed-off-by: Greg Hackmann 
Signed-off-by: Chenbo Feng 
---
 drivers/dma-buf/dma-buf.c| 42 ++--
 include/linux/dma-buf.h  |  5 -
 include/uapi/linux/dma-buf.h |  4 
 3 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index d72352356ac5..e0d9cdd3520b 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -297,6 +297,36 @@ static __poll_t dma_buf_poll(struct file *file, poll_table 
*poll)
return events;
 }
 
+static long dma_buf_set_name(struct dma_buf *dmabuf, const char __user *buf)
+{
+   char *name = strndup_user(buf, DMA_BUF_NAME_LEN);
+
+   if (IS_ERR(name))
+   return PTR_ERR(name);
+
+   mutex_lock(>lock);
+   kfree(dmabuf->name);
+   dmabuf->name = name;
+   mutex_unlock(>lock);
+
+   return 0;
+}
+
+static long dma_buf_get_name(struct dma_buf *dmabuf, char __user *buf)
+{
+   const char *name = "";
+   long ret = 0;
+
+   mutex_lock(>lock);
+   if (dmabuf->name)
+   name = dmabuf->name;
+   if (copy_to_user(buf, name, strlen(name) + 1))
+   ret = -EFAULT;
+   mutex_unlock(>lock);
+
+   return ret;
+}
+
 static long dma_buf_ioctl(struct file *file,
  unsigned int cmd, unsigned long arg)
 {
@@ -335,6 +365,13 @@ static long dma_buf_ioctl(struct file *file,
ret = dma_buf_begin_cpu_access(dmabuf, direction);
 
return ret;
+
+   case DMA_BUF_SET_NAME:
+   return dma_buf_set_name(dmabuf, (const char __user *)arg);
+
+   case DMA_BUF_GET_NAME:
+   return dma_buf_get_name(dmabuf, (char __user *)arg);
+
default:
return -ENOTTY;
}
@@ -1083,12 +1120,13 @@ static int dma_buf_debug_show(struct seq_file *s, void 
*unused)
continue;
}
 
-   seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\t%08lu\n",
+   seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\t%08lu\t%s\n",
buf_obj->size,
buf_obj->file->f_flags, buf_obj->file->f_mode,
file_count(buf_obj->file),
buf_obj->exp_name,
-   file_inode(buf_obj->file)->i_ino);
+   file_inode(buf_obj->file)->i_ino,
+   buf_obj->name ?: "");
 
robj = buf_obj->resv;
while (true) {
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 58725f890b5b..582998e19df6 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -255,10 +255,12 @@ struct dma_buf_ops {
  * @file: file pointer used for sharing buffers across, and for refcounting.
  * @attachments: list of dma_buf_attachment that denotes all devices attached.
  * @ops: dma_buf_ops associated with this buffer object.
- * @lock: used internally to serialize list manipulation, attach/detach and 
vmap/unmap
+ * @lock: used internally to serialize list manipulation, attach/detach and
+ *vmap/unmap, and accesses to name
  * @vmapping_counter: used internally to refcnt the vmaps
  * @vmap_ptr: the current vmap ptr if vmapping_counter > 0
  * @exp_name: name of the exporter; useful for debugging.
+ * @name: userspace-provided name; useful for accounting and debugging.
  * @owner: pointer to exporter module; used for refcounting when exporter is a
  * kernel module.
  * @list_node: node for dma_buf accounting and debugging.
@@ -286,6 +288,7 @@ struct dma_buf {
unsigned vmapping_counter;
void *vmap_ptr;
const char *exp_name;
+   const char *name;
struct module *owner;
struct list_head list_node;
void *priv;
diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h
index d75df5210a4a..4e9c5fe7aecd 100644
--- a/include/uapi/linux/dma-buf.h
+++ b/include/uapi/linux/dma-buf.h
@@ -35,7 +35,11 @@ struct dma_buf_sync {
 #define DMA_BUF_SYNC_VALID_FLAGS_MASK \
(DMA_BUF_SYNC_RW | DMA_BUF_SYNC_END)
 
+#define DMA_BUF_NAME_LEN   32
+
 #define DMA_BUF_BASE   'b'
 #define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
+#define DMA_BUF_SET_NAME   _IOW(DMA_BUF_BASE, 1, const char *)

  1   2   3   4   5   6   7   8   9   10   >