[PATCH] arm64: dts: qcom: c630: Add WiFi node

2019-10-17 Thread Bjorn Andersson
Specify regulators and enable the  node. The firmware uses the 8
bit version of the host capability message, so specify this quirk.

Signed-off-by: Bjorn Andersson 
---
 arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts 
b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
index 01709951fdb6..53d4d40dfe43 100644
--- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
+++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
@@ -461,3 +461,14 @@
vdda-phy-supply = <_usb2_ss_1p2>;
vdda-pll-supply = <_usb2_ss_core>;
 };
+
+ {
+   status = "okay";
+
+   vdd-0.8-cx-mx-supply = <_l5a_0p8>;
+   vdd-1.8-xo-supply = <_l7a_1p8>;
+   vdd-1.3-rfa-supply = <_l17a_1p3>;
+   vdd-3.3-ch0-supply = <_l25a_3p3>;
+
+   qcom,snoc-host-cap-8bit-quirk;
+};
-- 
2.23.0



[PATCH] arm64: dts: qcom: c630: Enable UFS device reset

2019-10-17 Thread Bjorn Andersson
Setup the TLMM UFS_RESET to make the UFS core reset the UFS memory
device during initialization.

Signed-off-by: Bjorn Andersson 
---
 arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts 
b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
index 13dc619687f3..01709951fdb6 100644
--- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
+++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
@@ -7,6 +7,7 @@
 
 /dts-v1/;
 
+#include 
 #include 
 #include "sdm845.dtsi"
 #include "pm8998.dtsi"
@@ -394,6 +395,8 @@
 _mem_hc {
status = "okay";
 
+   reset-gpios = < 150 GPIO_ACTIVE_LOW>;
+
vcc-supply = <_l20a_2p95>;
vcc-max-microamp = <60>;
 };
-- 
2.23.0



Re: [PATCH] Bluetooth: hci_qca: fix in-band sleep enablement

2019-10-17 Thread Claire Chang
Hi Balakrishna,

Sorry for the late reply. I was on vacation for the past few days.
The chipset we use is QCA6174A-3 and rjliao has already confirmed that
IBS won't work without RAM fw downloaded.
Please ignore this change.

Thanks,
Claire


On Fri, Oct 11, 2019 at 3:21 PM Balakrishna Godavarthi
 wrote:
>
> Hi Claire,
>
> This change will not work  as we need fw files to be loaded tofor IBS to
> active.
> may i know on which chipset you have this issue of IBS active even with
> out fw download.
>
> On 2019-10-11 12:31, Harish Bandi wrote:
> > ++ Balakrishna
> >
> > On 2019-10-09 14:21, Claire Chang wrote:
> >> Enabling in-band sleep when there is no patch/nvm-config found and
> >> bluetooth is running with the original fw/config.
> >>
> >> Fixes: ba8f35979002 ("Bluetooth: hci_qca: Avoid setup failure on
> >> missing rampatch")
> >> Fixes: 7dc5fe0814c3 ("Bluetooth: hci_qca: Avoid missing rampatch
> >> failure with userspace fw loader")
> >> Signed-off-by: Claire Chang 
> >> ---
> >>  drivers/bluetooth/hci_qca.c | 11 +++
> >>  1 file changed, 7 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> >> index e3164c200eac..367eef893a11 100644
> >> --- a/drivers/bluetooth/hci_qca.c
> >> +++ b/drivers/bluetooth/hci_qca.c
> >> @@ -1291,10 +1291,8 @@ static int qca_setup(struct hci_uart *hu)
> >>  /* Setup patch / NVM configurations */
> >>  ret = qca_uart_setup(hdev, qca_baudrate, soc_type, soc_ver,
> >>  firmware_name);
> >> -if (!ret) {
> >> -set_bit(QCA_IBS_ENABLED, >flags);
> >> -qca_debugfs_init(hdev);
> >> -} else if (ret == -ENOENT) {
> >> +
> >> +if (ret == -ENOENT) {
> >>  /* No patch/nvm-config found, run with original fw/config */
> >>  ret = 0;
> >>  } else if (ret == -EAGAIN) {
> >> @@ -1305,6 +1303,11 @@ static int qca_setup(struct hci_uart *hu)
> >>  ret = 0;
> >>  }
> >>
> >> +if (!ret) {
> >> +set_bit(QCA_IBS_ENABLED, >flags);
> >> +qca_debugfs_init(hdev);
> >> +}
> >> +
> >>  /* Setup bdaddr */
> >>  if (qca_is_wcn399x(soc_type))
> >>  hu->hdev->set_bdaddr = qca_set_bdaddr;
>
> --
> Regards
> Balakrishna.


Re: [PATCH v2 4/5] cpufreq: vexpress-spc: remove lots of debug messages

2019-10-17 Thread Viresh Kumar
On 17-10-19, 13:35, Sudeep Holla wrote:
> This driver have been used and tested for year now and the extensive
> debug/log messages in the driver are not really required anymore.
> Get rid of those unnecessary log messages.
> 
> Signed-off-by: Sudeep Holla 
> ---
>  drivers/cpufreq/vexpress-spc-cpufreq.c | 72 +-
>  1 file changed, 13 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c 
> b/drivers/cpufreq/vexpress-spc-cpufreq.c
>  static void put_cluster_clk_and_freq_table(struct device *cpu_dev,
> @@ -324,11 +296,9 @@ static void put_cluster_clk_and_freq_table(struct device 
> *cpu_dev,
>  
>   for_each_present_cpu(i) {
>   struct device *cdev = get_cpu_device(i);
> - if (!cdev) {
> - pr_err("%s: failed to get cpu%d device\n", __func__, i);
> - return;
> - }
>  
> + if (!cdev)
> + return;

We had a blank line after this, which isn't there in your version
anymore. Please keep that here and few more places below.

>   _put_cluster_clk_and_freq_table(cdev, cpumask);
>   }
>  
> @@ -354,19 +324,12 @@ static int _get_cluster_clk_and_freq_table(struct 
> device *cpu_dev,
>   goto out;
>  
>   ret = dev_pm_opp_init_cpufreq_table(cpu_dev, _table[cluster]);
> - if (ret) {
> - dev_err(cpu_dev, "%s: failed to init cpufreq table, cpu: %d, 
> err: %d\n",
> - __func__, cpu_dev->id, ret);
> + if (ret)
>   goto out;
> - }
>  
>   clk[cluster] = clk_get(cpu_dev, NULL);
> - if (!IS_ERR(clk[cluster])) {
> - dev_dbg(cpu_dev, "%s: clk: %p & freq table: %p, cluster: %d\n",
> - __func__, clk[cluster], freq_table[cluster],
> - cluster);
> + if (!IS_ERR(clk[cluster]))
>   return 0;
> - }
>  
>   dev_err(cpu_dev, "%s: Failed to get clk for cpu: %d, cluster: %d\n",
>   __func__, cpu_dev->id, cluster);
> @@ -401,11 +364,9 @@ static int get_cluster_clk_and_freq_table(struct device 
> *cpu_dev,
>*/
>   for_each_present_cpu(i) {
>   struct device *cdev = get_cpu_device(i);
> - if (!cdev) {
> - pr_err("%s: failed to get cpu%d device\n", __func__, i);
> - return -ENODEV;
> - }
>  
> + if (!cdev)
> + return -ENODEV;
>   ret = _get_cluster_clk_and_freq_table(cdev, cpumask);
>   if (ret)
>   goto put_clusters;
> @@ -419,19 +380,14 @@ static int get_cluster_clk_and_freq_table(struct device 
> *cpu_dev,
>   clk_big_min = get_table_min(freq_table[0]);
>   clk_little_max = VIRT_FREQ(1, get_table_max(freq_table[1]));
>  
> - pr_debug("%s: cluster: %d, clk_big_min: %d, clk_little_max: %d\n",
> - __func__, cluster, clk_big_min, clk_little_max);
> -
>   return 0;
>  
>  put_clusters:
>   for_each_present_cpu(i) {
>   struct device *cdev = get_cpu_device(i);
> - if (!cdev) {
> - pr_err("%s: failed to get cpu%d device\n", __func__, i);
> - return -ENODEV;
> - }
>  
> + if (!cdev)
> + return -ENODEV;
>   _put_cluster_clk_and_freq_table(cdev, cpumask);
>   }
>  
> @@ -500,8 +456,6 @@ static int ve_spc_cpufreq_exit(struct cpufreq_policy 
> *policy)
>   }
>  
>   put_cluster_clk_and_freq_table(cpu_dev, policy->related_cpus);
> - dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu);
> -
>   return 0;
>  }
>  
> -- 
> 2.17.1

-- 
viresh


[PATCH v2] arm64: dts: qcom: c630: Enable adsp, cdsp and mpss

2019-10-17 Thread Bjorn Andersson
Specify the firmware-name for the adsp, cdsp and mpss and enable the
nodes.

Signed-off-by: Bjorn Andersson 
---
 .../boot/dts/qcom/sdm850-lenovo-yoga-c630.dts  | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts 
b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
index ded120d3aef5..13dc619687f3 100644
--- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
+++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
@@ -20,6 +20,11 @@
};
 };
 
+_pas {
+   firmware-name = "qcom/LENOVO/81JL/qcadsp850.mbn";
+   status = "okay";
+};
+
 _rsc {
pm8998-rpmh-regulators {
compatible = "qcom,pm8998-rpmh-regulators";
@@ -229,6 +234,11 @@
status = "disabled";
 };
 
+_pas {
+   firmware-name = "qcom/LENOVO/81JL/qccdsp850.mbn";
+   status = "okay";
+};
+
  {
protected-clocks = ,
   ,
@@ -296,6 +306,10 @@
};
 };
 
+_pil {
+   firmware-name = "qcom/LENOVO/81JL/qcdsp1v2850.mbn", 
"qcom/LENOVO/81JL/qcdsp2850.mbn";
+};
+
 _i2c12_default {
drive-strength = <2>;
bias-disable;
-- 
2.23.0



Re: [PATCH] cpufreq: flush any pending policy update work scheduled before freeing

2019-10-17 Thread Sudeep Holla
On Thu, Oct 17, 2019 at 11:26:54PM +0200, Rafael J. Wysocki wrote:
> On Thu, Oct 17, 2019 at 9:36 PM Rafael J. Wysocki  wrote:
> >
> > On Thu, Oct 17, 2019 at 6:35 PM Sudeep Holla  wrote:
> > >
> > > dev_pm_qos_remove_request ends calling {max,min}_freq_req QoS notifiers
> > > which schedule policy update work. It may end up racing with the freeing
> > > the policy and unregistering the driver.
> > >
> > > One possible race is as below where the cpufreq_driver is unregistered
> > > but the scheduled work gets executed at later stage when cpufreq_driver
> > > is NULL(i.e. after freeing the policy and driver)
> > >
> > > Unable to handle kernel NULL pointer dereference at virtual address 
> > > 001c
> > > pgd = (ptrval)
> > > [001c] *pgd=8080204003, *pmd=
> > > Internal error: Oops: 206 [#1] SMP THUMB2
> > > Modules linked in:
> > > CPU: 0 PID: 34 Comm: kworker/0:1 Not tainted 
> > > 5.4.0-rc3-6-g67f5a8081a4b #86
> > > Hardware name: ARM-Versatile Express
> > > Workqueue: events handle_update
> > > PC is at cpufreq_set_policy+0x58/0x228
> > > LR is at dev_pm_qos_read_value+0x77/0xac
> > > Control: 70c5387d  Table: 80203000  DAC: fffd
> > > Process kworker/0:1 (pid: 34, stack limit = 0x(ptrval))
> > > (cpufreq_set_policy) from 
> > > (refresh_frequency_limits.part.24+0x37/0x48)
> > > (refresh_frequency_limits.part.24) from (handle_update+0x2f/0x38)
> > > (handle_update) from (process_one_work+0x16d/0x3cc)
> > > (process_one_work) from (worker_thread+0xff/0x414)
> > > (worker_thread) from (kthread+0xff/0x100)
> > > (kthread) from (ret_from_fork+0x11/0x28)
> > >
> > > Cc: "Rafael J. Wysocki" 
> > > Cc: Viresh Kumar 
> > > Signed-off-by: Sudeep Holla 
> > > ---
> > >  drivers/cpufreq/cpufreq.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > Hi Rafael, Viresh,
> > >
> > > This fixed the boot issue I reported[1] on TC2 with bL switcher enabled.
> > > I have based this patch on -rc3 and not on top of your patches. This
> > > only fixes the boot issue but I hit the other crashes while continuously
> > > switching on and off the bL switcher that register/unregister the driver
> > > Your patch series fixes them. I can based this on top of those if you
> > > prefer.
> > >
> > > Regards,
> > > Sudeep
> > >
> > > [1] https://lore.kernel.org/linux-pm/20191015155735.GA29105@bogus/
> > >
> > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > index c52d6fa32aac..b703c29a84be 100644
> > > --- a/drivers/cpufreq/cpufreq.c
> > > +++ b/drivers/cpufreq/cpufreq.c
> > > @@ -1278,6 +1278,9 @@ static void cpufreq_policy_free(struct 
> > > cpufreq_policy *policy)
> > > }
> > >
> > > dev_pm_qos_remove_request(policy->min_freq_req);
> > > +   /* flush the pending policy->update work before freeing the 
> > > policy */
> > > +   if (work_pending(>update))
> >
> > Isn't this racy?
> >
> > It still may be running if the pending bit is clear and we still need
> > to wait for it then, don't we?
> >
> > Why don't you do an unconditional flush_work() here?
> 
> You may as well do a cancel_work_sync() here, because whether or not
> the last update of the policy happens before it goes away is a matter
> of timing in any case

In fact that's the first thing I tried to fix the issue I was seeing.
But I then thought it would be better to complete the update as the PM
QoS were getting updated back to DEFAULT values for the device. Even
this works.

What is your preference ? flush_work or cancel_work_sync ? I will
update accordingly. I may need to do some more testing with
cancel_work_sync as I just checked that quickly to confirm the race.

--
Regards,
Sudeep


Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.

2019-10-17 Thread John Stultz
On Wed, Oct 16, 2019 at 12:27 AM Hans de Goede  wrote:
> On 10/15/19 7:39 AM, John Stultz wrote:
> > On Thu, Oct 3, 2019 at 1:51 PM Hans de Goede  wrote:
> >> On 03-10-2019 22:37, John Stultz wrote:
> >>> Fair point. I'm sort of taking a larger patchset and trying to break
> >>> it up into more easily reviewable chunks, but I guess here I mis-cut.
> >>>
> >>> The user is the hikey960 gpio hub driver here:
> >>> 
> >>> https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00f
> >>
> >> Hmm, that seems to tie the TypeC data-role to the power-role, which
> >> is not going to work with role swapping.
> >
> > Thanks again for the feedback here. Sorry for the slow response. Been
> > reworking some of the easier changes but am starting to look at how to
> > address your feedback here.
> >
> >> What is controlling the usb-role-switch, and thus ultimately
> >> causing the notifier you are suggesting to get called ?
> >
> > The tcpm_mux_set() call via tcpm_state_machine_work()
> >
> >> Things like TYPEC_VBUS_POWER_OFF and TYPEC_VBUS_POWER_ON
> >> really beg to be modeled as a regulator and then the
> >> Type-C controller (using e.g. the drivers/usb/typec/tcpm/tcpm.c
> >> framework) can use that regulator to control things.
> >> in case of the tcpm.c framework it can then use that
> >> regulator to implement the set_vbus callback.
> >
> > So I'm looking at the bindings and I'm not sure exactly how to tie a
> > regulator style driver into the tcpm for this?
> > Looking at the driver I just see this commented out bit:
> > 
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/typec/tcpm/tcpm.c#n3075
> >
> > Do you happen to have a pointer to something closer to what you are 
> > describing?
>
> Look at the tcpm_set_vbus implementation in drivers/usb/typec/tcpm/fusb302.c
> you need to do something similar in your Type-C controller driver and
> export the GPIO as as a gpio-controlled regulator and tie the regulator to
> the connector.

Thanks for the suggestion, I really appreciate it! One more question
though, since I'm using the tcpci_rt1711h driver, which re-uses the
somewhat sparse tcpci.c implementation, would you recommend trying to
add generic regulator support to the tcpci code or trying to extend
the implementation somehow allow the tcpci_rt1711h driver replace just
the set_vbus function?

thanks
-john


Re: [PATCH V3] mm/page_alloc: Add alloc_contig_pages()

2019-10-17 Thread Anshuman Khandual



On 10/18/2019 02:44 AM, John Hubbard wrote:
> On 10/17/19 1:24 AM, Anshuman Khandual wrote:
>> HugeTLB helper alloc_gigantic_page() implements fairly generic allocation
>> method where it scans over various zones looking for a large contiguous pfn
>> range before trying to allocate it with alloc_contig_range(). Other than
>> deriving the requested order from 'struct hstate', there is nothing HugeTLB
>> specific in there. This can be made available for general use to allocate
>> contiguous memory which could not have been allocated through the buddy
>> allocator.
>>
>> alloc_gigantic_page() has been split carving out actual allocation method
>> which is then made available via new alloc_contig_pages() helper wrapped
>> under CONFIG_CONTIG_ALLOC. All references to 'gigantic' have been replaced
>> with more generic term 'contig'. Allocated pages here should be freed with
>> free_contig_range() or by calling __free_page() on each allocated page.
>>
>> Cc: Mike Kravetz 
>> Cc: Andrew Morton 
>> Cc: Vlastimil Babka 
>> Cc: Michal Hocko 
>> Cc: David Rientjes 
>> Cc: Andrea Arcangeli 
>> Cc: Oscar Salvador 
>> Cc: Mel Gorman 
>> Cc: Mike Rapoport 
>> Cc: Dan Williams 
>> Cc: Pavel Tatashin 
>> Cc: Matthew Wilcox 
>> Cc: David Hildenbrand 
>> Cc: linux-kernel@vger.kernel.org
>> Acked-by: David Hildenbrand 
>> Acked-by: Michal Hocko 
>> Signed-off-by: Anshuman Khandual 
>> ---
>> This is based on https://patchwork.kernel.org/patch/11190213/
> 
> Hi Anshuman,
> 
> I'm having trouble finding a tree that this applies cleanly too,
> which one did you use? (latest linux-next, or linux.git would be
> nice).

Hello John,

Yeah, it is bit non-trivial because v5 of the pgtable tests are still
on the latest linux-next (20191015 or 20191017). You will need to
revert the following patches.

1. mm/hugetlb: make alloc_gigantic_page() available for general use
2. mm/debug: add tests validating architecture page table helpers
3. mm-debug-add-tests-validating-architecture-page-table-helpers-fix

and apply the following patch (https://patchwork.kernel.org/patch/11190213/)

1. hugetlbfs: don't access uninitialized memmaps in pfn_range_valid_gigantic()

After which this particular patch here will apply cleanly. Hope this helps.

- Anshuman
> 
> 
> thanks,
> 
> John Hubbard
> NVIDIA
> 
> 
>>
>> Changes in V3:
>>
>> - Added an in-code comment per Michal and David
>>
>> Changes in V2:
>>
>> - Rephrased patch subject per David
>> - Fixed all typos per David
>> - s/order/contiguous
>>
>> Changes from [V5,1/2] mm/hugetlb: Make alloc_gigantic_page()...
>>
>> - alloc_contig_page() takes nr_pages instead of order per Michal
>> - s/gigantic/contig on all related functions
>>
>>  include/linux/gfp.h |   2 +
>>  mm/hugetlb.c|  77 +
>>  mm/page_alloc.c | 101 
>>  3 files changed, 105 insertions(+), 75 deletions(-)
>>
>> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
>> index fb07b503dc45..1a11d4857027 100644
>> --- a/include/linux/gfp.h
>> +++ b/include/linux/gfp.h
>> @@ -589,6 +589,8 @@ static inline bool pm_suspended_storage(void)
>>  /* The below functions must be run on a range from a single zone. */
>>  extern int alloc_contig_range(unsigned long start, unsigned long end,
>>unsigned migratetype, gfp_t gfp_mask);
>> +extern struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t 
>> gfp_mask,
>> +   int nid, nodemask_t *nodemask);
>>  #endif
>>  void free_contig_range(unsigned long pfn, unsigned int nr_pages);
>>  
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index 985ee15eb04b..a5c2c880af27 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -1023,85 +1023,12 @@ static void free_gigantic_page(struct page *page, 
>> unsigned int order)
>>  }
>>  
>>  #ifdef CONFIG_CONTIG_ALLOC
>> -static int __alloc_gigantic_page(unsigned long start_pfn,
>> -unsigned long nr_pages, gfp_t gfp_mask)
>> -{
>> -unsigned long end_pfn = start_pfn + nr_pages;
>> -return alloc_contig_range(start_pfn, end_pfn, MIGRATE_MOVABLE,
>> -  gfp_mask);
>> -}
>> -
>> -static bool pfn_range_valid_gigantic(struct zone *z,
>> -unsigned long start_pfn, unsigned long nr_pages)
>> -{
>> -unsigned long i, end_pfn = start_pfn + nr_pages;
>&g

linux-next: manual merge of the char-misc tree with the char-misc.current tree

2019-10-17 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the char-misc tree got a conflict in:

  drivers/android/binder.c

between commit:

  45d02f79b539 ("binder: Don't modify VMA bounds in ->mmap handler")

from the char-misc.current tree and commit:

  990be7476485 ("binder: Use common definition of SZ_1K")

from the char-misc 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/android/binder.c
index 265d9dd46a5e,bef788058bc3..
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@@ -92,11 -93,10 +93,6 @@@ static atomic_t binder_last_id
  static int proc_show(struct seq_file *m, void *unused);
  DEFINE_SHOW_ATTRIBUTE(proc);
  
- /* This is only defined in include/asm-arm/sizes.h */
- #ifndef SZ_1K
- #define SZ_1K   0x400
 -#ifndef SZ_4M
 -#define SZ_4M   0x40
--#endif
--
  #define FORBIDDEN_MMAP_FLAGS(VM_WRITE)
  
  enum {


pgpYHOFt_RnJr.pgp
Description: OpenPGP digital signature


[PATCH] x86: Don't use MWAIT if explicitly requested

2019-10-17 Thread Zhenzhong Duan
If 'idle=nomwait' is specified or process matching what's in
processor_idle_dmi_table, we should't use MWAIT at bootup stage before
cpuidle driver loaded, even if it's preferred by default on Intel.

Add a check so that HALT instruction is used in those cases.

Signed-off-by: Zhenzhong Duan 
Cc: Thomas Gleixner 
Cc: Borislav Petkov 
Cc: Ingo Molnar 
Cc: "H. Peter Anvin" 
Cc: Boris Ostrovsky 
---
 arch/x86/kernel/process.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 5e94c43..37fc577 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -667,6 +667,10 @@ static void amd_e400_idle(void)
  */
 static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
 {
+   /* Don't use MWAIT-C1 if explicitly requested */
+   if (boot_option_idle_override == IDLE_NOMWAIT)
+   return 0;
+
if (c->x86_vendor != X86_VENDOR_INTEL)
return 0;
 
-- 
1.8.3.1



Re: [PATCH v2 5/5] cpufreq: vexpress-spc: fix some coding style issues

2019-10-17 Thread Viresh Kumar
On 17-10-19, 13:35, Sudeep Holla wrote:
> Fix the following checkpatch checks/warnings:
> 
> CHECK: Unnecessary parentheses around the code
> CHECK: Alignment should match open parenthesis
> CHECK: Prefer kernel type 'u32' over 'uint32_t'
> WARNING: Missing a blank line after declarations
> 
> Signed-off-by: Sudeep Holla 
> ---
>  drivers/cpufreq/vexpress-spc-cpufreq.c | 43 --
>  1 file changed, 20 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c 
> b/drivers/cpufreq/vexpress-spc-cpufreq.c
> index 81064430317f..8ecb2961be86 100644
> --- a/drivers/cpufreq/vexpress-spc-cpufreq.c
> +++ b/drivers/cpufreq/vexpress-spc-cpufreq.c
> @@ -79,8 +79,8 @@ static unsigned int find_cluster_maxfreq(int cluster)
>   for_each_online_cpu(j) {
>   cpu_freq = per_cpu(cpu_last_req_freq, j);
>  
> - if ((cluster == per_cpu(physical_cluster, j)) &&
> - (max_freq < cpu_freq))
> + if (cluster == per_cpu(physical_cluster, j) &&
> + max_freq < cpu_freq)
>   max_freq = cpu_freq;
>   }
>  
> @@ -188,22 +188,19 @@ static int ve_spc_cpufreq_set_target(struct 
> cpufreq_policy *policy,
>   freqs_new = freq_table[cur_cluster][index].frequency;
>  
>   if (is_bL_switching_enabled()) {
> - if ((actual_cluster == A15_CLUSTER) &&
> - (freqs_new < clk_big_min)) {
> + if (actual_cluster == A15_CLUSTER && freqs_new < clk_big_min)
>   new_cluster = A7_CLUSTER;
> - } else if ((actual_cluster == A7_CLUSTER) &&
> - (freqs_new > clk_little_max)) {
> + else if (actual_cluster == A7_CLUSTER &&
> +  freqs_new > clk_little_max)
>   new_cluster = A15_CLUSTER;
> - }
>   }
>  
>   ret = ve_spc_cpufreq_set_rate(cpu, actual_cluster, new_cluster,
> freqs_new);
>  
> - if (!ret) {
> + if (!ret)

That's not the standard way in Linux I believe. We do use {} even when
the body is single line but broken into two, like below.

>   arch_set_freq_scale(policy->related_cpus, freqs_new,
>   policy->cpuinfo.max_freq);
> - }
>  
>   return ret;
>  }
> @@ -222,7 +219,8 @@ static inline u32 get_table_count(struct 
> cpufreq_frequency_table *table)
>  static inline u32 get_table_min(struct cpufreq_frequency_table *table)
>  {
>   struct cpufreq_frequency_table *pos;
> - uint32_t min_freq = ~0;
> + u32 min_freq = ~0;
> +
>   cpufreq_for_each_entry(pos, table)
>   if (pos->frequency < min_freq)
>   min_freq = pos->frequency;
> @@ -233,7 +231,8 @@ static inline u32 get_table_min(struct 
> cpufreq_frequency_table *table)
>  static inline u32 get_table_max(struct cpufreq_frequency_table *table)
>  {
>   struct cpufreq_frequency_table *pos;
> - uint32_t max_freq = 0;
> + u32 max_freq = 0;
> +
>   cpufreq_for_each_entry(pos, table)
>   if (pos->frequency > max_freq)
>   max_freq = pos->frequency;
> @@ -255,14 +254,11 @@ static int merge_cluster_tables(void)
>   freq_table[MAX_CLUSTERS] = table;
>  
>   /* Add in reverse order to get freqs in increasing order */
> - for (i = MAX_CLUSTERS - 1; i >= 0; i--) {
> + for (i = MAX_CLUSTERS - 1; i >= 0; i--)
>   for (j = 0; freq_table[i][j].frequency != CPUFREQ_TABLE_END;
> - j++) {
> - table[k].frequency = VIRT_FREQ(i,
> - freq_table[i][j].frequency);
> - k++;
> - }
> - }
> +  j++, k++)

same here, please keep {}.

> + table[k].frequency =
> + VIRT_FREQ(i, freq_table[i][j].frequency);
>  
>   table[k].driver_data = k;
>   table[k].frequency = CPUFREQ_TABLE_END;
> @@ -332,13 +328,13 @@ static int _get_cluster_clk_and_freq_table(struct 
> device *cpu_dev,
>   return 0;
>  
>   dev_err(cpu_dev, "%s: Failed to get clk for cpu: %d, cluster: %d\n",
> - __func__, cpu_dev->id, cluster);
> + __func__, cpu_dev->id, cluster);
>   ret = PTR_ERR(clk[cluster]);
>   dev_pm_opp_free_cpufreq_table(cpu_dev, _table[cluster]);
>  
>  out:
>   dev_err(cpu_dev, "%s: Failed to get data for cluster: %d\n", __func__,
> - cluster);
> + cluster);
>   return ret;
>  }
>  
> @@ -406,7 +402,7 @@ static int ve_spc_cpufreq_init(struct cpufreq_policy 
> *policy)
>   cpu_dev = get_cpu_device(policy->cpu);
>   if (!cpu_dev) {
>   pr_err("%s: failed to get cpu%d device\n", __func__,
> - policy->cpu);
> +policy->cpu);
>   return -ENODEV;
> 

Re: [PATCH 07/15] riscv: implement remote sfence.i using IPIs

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> The RISC-V ISA only supports flushing the instruction cache for the
> local CPU core.  Currently we always offload the remote TLB flushing to
> the SBI, which then issues an IPI under the hoods.  But with M-mode
> we do not have an SBI so we have to do it ourselves.   IPI to the
> other nodes using the existing kernel helpers instead if we have
> native clint support and thus can IPI directly from the kernel.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/include/asm/sbi.h |  3 +++
>  arch/riscv/mm/cacheflush.c   | 24 ++--
>  2 files changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
> index b167af3e7470..0cb74eccc73f 100644
> --- a/arch/riscv/include/asm/sbi.h
> +++ b/arch/riscv/include/asm/sbi.h
> @@ -94,5 +94,8 @@ static inline void sbi_remote_sfence_vma_asid(const 
> unsigned long *hart_mask,
>  {
> SBI_CALL_4(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask, start, size, asid);
>  }
> +#else /* CONFIG_RISCV_SBI */
> +/* stub to for code is only reachable under IS_ENABLED(CONFIG_RISCV_SBI): */
> +void sbi_remote_fence_i(const unsigned long *hart_mask);
>  #endif /* CONFIG_RISCV_SBI */
>  #endif /* _ASM_RISCV_SBI_H */
> diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c
> index 3f15938dec89..794c9ab256eb 100644
> --- a/arch/riscv/mm/cacheflush.c
> +++ b/arch/riscv/mm/cacheflush.c
> @@ -10,9 +10,17 @@
>
>  #include 
>
> +static void ipi_remote_fence_i(void *info)
> +{
> +   return local_flush_icache_all();
> +}
> +
>  void flush_icache_all(void)
>  {
> -   sbi_remote_fence_i(NULL);
> +   if (IS_ENABLED(CONFIG_RISCV_SBI))
> +   sbi_remote_fence_i(NULL);
> +   else
> +   on_each_cpu(ipi_remote_fence_i, NULL, 1);
>  }
>
>  /*
> @@ -28,7 +36,7 @@ void flush_icache_all(void)
>  void flush_icache_mm(struct mm_struct *mm, bool local)
>  {
> unsigned int cpu;
> -   cpumask_t others, hmask, *mask;
> +   cpumask_t others, *mask;
>
> preempt_disable();
>
> @@ -46,10 +54,7 @@ void flush_icache_mm(struct mm_struct *mm, bool local)
>  */
> cpumask_andnot(, mm_cpumask(mm), cpumask_of(cpu));
> local |= cpumask_empty();
> -   if (mm != current->active_mm || !local) {
> -   riscv_cpuid_to_hartid_mask(, );
> -   sbi_remote_fence_i(hmask.bits);
> -   } else {
> +   if (mm == current->active_mm && local) {
> /*
>  * It's assumed that at least one strongly ordered operation 
> is
>  * performed on this hart between setting a hart's cpumask bit
> @@ -59,6 +64,13 @@ void flush_icache_mm(struct mm_struct *mm, bool local)
>  * with flush_icache_deferred().
>  */
> smp_mb();
> +   } else if (IS_ENABLED(CONFIG_RISCV_SBI)) {
> +   cpumask_t hartid_mask;
> +
> +   riscv_cpuid_to_hartid_mask(, _mask);
> +   sbi_remote_fence_i(cpumask_bits(_mask));
> +   } else {
> +   on_each_cpu_mask(, ipi_remote_fence_i, NULL, 1);
> }
>
> preempt_enable();
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH v2 2/5] cpufreq: merge arm_big_little and vexpress-spc

2019-10-17 Thread Sudeep Holla
On Fri, Oct 18, 2019 at 11:17:40AM +0530, Viresh Kumar wrote:
> On 17-10-19, 13:35, Sudeep Holla wrote:
> > diff --git a/drivers/cpufreq/arm_big_little.c 
> > b/drivers/cpufreq/vexpress-spc-cpufreq.c
> > similarity index 90%
> > rename from drivers/cpufreq/arm_big_little.c
> > rename to drivers/cpufreq/vexpress-spc-cpufreq.c
> > index 7fe52fcddcf1..b7e1aa000c80 100644
> > --- a/drivers/cpufreq/arm_big_little.c
> > +++ b/drivers/cpufreq/vexpress-spc-cpufreq.c
> > @@ -1,20 +1,12 @@
> > +// SPDX-License-Identifier: GPL-2.0
> >  /*
> > - * ARM big.LITTLE Platforms CPUFreq support
> > + * Versatile Express SPC CPUFreq Interface driver
> >   *
> > - * Copyright (C) 2013 ARM Ltd.
> > - * Sudeep KarkadaNagesha 
> > + * Copyright (C) 2019 ARM Ltd.
>
> Should this be 2013-2019 instead ?
>

Sure.

--
Regards,
Sudeep


Re: [PATCH 08/15] riscv: add support for MMIO access to the timer registers

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> When running in M-mode we can't use the SBI to set the timer, and
> don't have access to the time CSR as that usually is emulated by
> M-mode.  Instead provide code that directly accesses the MMIO for
> the timer.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/include/asm/sbi.h  |  3 ++-
>  arch/riscv/include/asm/timex.h| 19 +--
>  drivers/clocksource/timer-riscv.c | 21 +
>  3 files changed, 36 insertions(+), 7 deletions(-)
>
> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
> index 0cb74eccc73f..a4774bafe033 100644
> --- a/arch/riscv/include/asm/sbi.h
> +++ b/arch/riscv/include/asm/sbi.h
> @@ -95,7 +95,8 @@ static inline void sbi_remote_sfence_vma_asid(const 
> unsigned long *hart_mask,
> SBI_CALL_4(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask, start, size, asid);
>  }
>  #else /* CONFIG_RISCV_SBI */
> -/* stub to for code is only reachable under IS_ENABLED(CONFIG_RISCV_SBI): */
> +/* stubs to for code is only reachable under IS_ENABLED(CONFIG_RISCV_SBI): */
> +void sbi_set_timer(uint64_t stime_value);
>  void sbi_remote_fence_i(const unsigned long *hart_mask);
>  #endif /* CONFIG_RISCV_SBI */
>  #endif /* _ASM_RISCV_SBI_H */
> diff --git a/arch/riscv/include/asm/timex.h b/arch/riscv/include/asm/timex.h
> index c7ef131b9e4c..e17837d61667 100644
> --- a/arch/riscv/include/asm/timex.h
> +++ b/arch/riscv/include/asm/timex.h
> @@ -7,12 +7,25 @@
>  #define _ASM_RISCV_TIMEX_H
>
>  #include 
> +#include 
>
>  typedef unsigned long cycles_t;
>
> +extern u64 __iomem *riscv_time_val;
> +extern u64 __iomem *riscv_time_cmp;
> +
> +#ifdef CONFIG_64BIT
> +#define mmio_get_cycles()  readq_relaxed(riscv_time_val)
> +#else
> +#define mmio_get_cycles()  readl_relaxed(riscv_time_val)
> +#define mmio_get_cycles_hi()   readl_relaxed(((u32 *)riscv_time_val) + 1)
> +#endif
> +
>  static inline cycles_t get_cycles(void)
>  {
> -   return csr_read(CSR_TIME);
> +   if (IS_ENABLED(CONFIG_RISCV_SBI))
> +   return csr_read(CSR_TIME);
> +   return mmio_get_cycles();
>  }
>  #define get_cycles get_cycles
>
> @@ -24,7 +37,9 @@ static inline u64 get_cycles64(void)
>  #else /* CONFIG_64BIT */
>  static inline u32 get_cycles_hi(void)
>  {
> -   return csr_read(CSR_TIMEH);
> +   if (IS_ENABLED(CONFIG_RISCV_SBI))
> +   return csr_read(CSR_TIMEH);
> +   return mmio_get_cycles_hi();
>  }
>
>  static inline u64 get_cycles64(void)
> diff --git a/drivers/clocksource/timer-riscv.c 
> b/drivers/clocksource/timer-riscv.c
> index 5d2fdc3e28a9..2b9fbc4ebe49 100644
> --- a/drivers/clocksource/timer-riscv.c
> +++ b/drivers/clocksource/timer-riscv.c
> @@ -3,9 +3,9 @@
>   * Copyright (C) 2012 Regents of the University of California
>   * Copyright (C) 2017 SiFive
>   *
> - * All RISC-V systems have a timer attached to every hart.  These timers can 
> be
> - * read from the "time" and "timeh" CSRs, and can use the SBI to setup
> - * events.
> + * All RISC-V systems have a timer attached to every hart.  These timers can
> + * either be read from the "time" and "timeh" CSRs, and can use the SBI to
> + * setup events, or directly accessed using MMIO registers.
>   */
>  #include 
>  #include 
> @@ -13,14 +13,27 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>
> +u64 __iomem *riscv_time_cmp;
> +u64 __iomem *riscv_time_val;
> +
> +static inline void mmio_set_timer(u64 val)
> +{
> +   writeq_relaxed(val,
> +   riscv_time_cmp + cpuid_to_hartid_map(smp_processor_id()));
> +}
> +
>  static int riscv_clock_next_event(unsigned long delta,
> struct clock_event_device *ce)
>  {
> csr_set(CSR_XIE, XIE_XTIE);
> -   sbi_set_timer(get_cycles64() + delta);
> +   if (IS_ENABLED(CONFIG_RISCV_SBI))
> +   sbi_set_timer(get_cycles64() + delta);
> +   else
> +   mmio_set_timer(get_cycles64() + delta);
> return 0;
>  }
>
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH] cpufreq: flush any pending policy update work scheduled before freeing

2019-10-17 Thread Sudeep Holla
On Thu, Oct 17, 2019 at 09:36:30PM +0200, Rafael J. Wysocki wrote:
> On Thu, Oct 17, 2019 at 6:35 PM Sudeep Holla  wrote:
> >
> > dev_pm_qos_remove_request ends calling {max,min}_freq_req QoS notifiers
> > which schedule policy update work. It may end up racing with the freeing
> > the policy and unregistering the driver.
> >
> > One possible race is as below where the cpufreq_driver is unregistered
> > but the scheduled work gets executed at later stage when cpufreq_driver
> > is NULL(i.e. after freeing the policy and driver)
> >
> > Unable to handle kernel NULL pointer dereference at virtual address 001c
> > pgd = (ptrval)
> > [001c] *pgd=8080204003, *pmd=
> > Internal error: Oops: 206 [#1] SMP THUMB2
> > Modules linked in:
> > CPU: 0 PID: 34 Comm: kworker/0:1 Not tainted 5.4.0-rc3-6-g67f5a8081a4b 
> > #86
> > Hardware name: ARM-Versatile Express
> > Workqueue: events handle_update
> > PC is at cpufreq_set_policy+0x58/0x228
> > LR is at dev_pm_qos_read_value+0x77/0xac
> > Control: 70c5387d  Table: 80203000  DAC: fffd
> > Process kworker/0:1 (pid: 34, stack limit = 0x(ptrval))
> > (cpufreq_set_policy) from 
> > (refresh_frequency_limits.part.24+0x37/0x48)
> > (refresh_frequency_limits.part.24) from (handle_update+0x2f/0x38)
> > (handle_update) from (process_one_work+0x16d/0x3cc)
> > (process_one_work) from (worker_thread+0xff/0x414)
> > (worker_thread) from (kthread+0xff/0x100)
> > (kthread) from (ret_from_fork+0x11/0x28)
> >
> > Cc: "Rafael J. Wysocki" 
> > Cc: Viresh Kumar 
> > Signed-off-by: Sudeep Holla 
> > ---
> >  drivers/cpufreq/cpufreq.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > Hi Rafael, Viresh,
> >
> > This fixed the boot issue I reported[1] on TC2 with bL switcher enabled.
> > I have based this patch on -rc3 and not on top of your patches. This
> > only fixes the boot issue but I hit the other crashes while continuously
> > switching on and off the bL switcher that register/unregister the driver
> > Your patch series fixes them. I can based this on top of those if you
> > prefer.
> >
> > Regards,
> > Sudeep
> >
> > [1] https://lore.kernel.org/linux-pm/20191015155735.GA29105@bogus/
> >
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index c52d6fa32aac..b703c29a84be 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -1278,6 +1278,9 @@ static void cpufreq_policy_free(struct cpufreq_policy 
> > *policy)
> > }
> >
> > dev_pm_qos_remove_request(policy->min_freq_req);
> > +   /* flush the pending policy->update work before freeing the policy 
> > */
> > +   if (work_pending(>update))
>
> Isn't this racy?
>
> It still may be running if the pending bit is clear and we still need
> to wait for it then, don't we?
>

Yes, we could end up in such situation.

> Why don't you do an unconditional flush_work() here?
>

Yes that should be fine.

--
Regards,
Sudeep


Re: [PATCH 3/8] riscv: init: merge split string literals in preprocessor directive

2019-10-17 Thread Luc Van Oostenryck
On Thu, Oct 17, 2019 at 09:38:18PM -0700, Paul Walmsley wrote:
> On Fri, 18 Oct 2019, Luc Van Oostenryck wrote:
> 
> > On Thu, Oct 17, 2019 at 05:49:24PM -0700, Paul Walmsley wrote:
> > > sparse complains loudly when string literals associated with
> > > preprocessor directives are split into multiple, separately quoted
> > > strings across different lines:
> > 
> > ...
> >  
> > >  #ifndef __riscv_cmodel_medany
> > > -#error "setup_vm() is called from head.S before relocate so it should "
> > > - "not use absolute addressing."
> > > +#error "setup_vm() is called from head.S before relocate so it should 
> > > not use absolute addressing."
> > >  #endif

...
 
> On the other hand, gcc seems to support the non-backslashed syntax.  So if 
> the intention is for sparse to follow the gcc practice, and to be used 
> beyond the kernel, maybe it's worth aligning sparse to gcc?  Only if 
> you're bored, I suppose...

I quickly checked and gcc also complain about the second line:
$ cat y.c 
#ifndef __riscv_cmodel_medany
#error "setup_vm() is called from head.S before relocate so it should "
   "not use absolute addressing."
#endif

$ gcc -c y.c
y.c:2:2: error: #error "setup_vm() is called from head.S before relocate so it 
should "
 #error "setup_vm() is called from head.S before relocate so it should "
  ^
y.c:3:8: error: expected identifier or '(' before string constant
"not use absolute addressing."
^~

So it seems that gcc doesn't join these lines.
Fell free to add my:
Reviewed-by: Luc Van Oostenryck 

-- Luc


Re: [PATCH v2 2/5] cpufreq: merge arm_big_little and vexpress-spc

2019-10-17 Thread Viresh Kumar
On 17-10-19, 13:35, Sudeep Holla wrote:
> diff --git a/drivers/cpufreq/arm_big_little.c 
> b/drivers/cpufreq/vexpress-spc-cpufreq.c
> similarity index 90%
> rename from drivers/cpufreq/arm_big_little.c
> rename to drivers/cpufreq/vexpress-spc-cpufreq.c
> index 7fe52fcddcf1..b7e1aa000c80 100644
> --- a/drivers/cpufreq/arm_big_little.c
> +++ b/drivers/cpufreq/vexpress-spc-cpufreq.c
> @@ -1,20 +1,12 @@
> +// SPDX-License-Identifier: GPL-2.0
>  /*
> - * ARM big.LITTLE Platforms CPUFreq support
> + * Versatile Express SPC CPUFreq Interface driver
>   *
> - * Copyright (C) 2013 ARM Ltd.
> - * Sudeep KarkadaNagesha 
> + * Copyright (C) 2019 ARM Ltd.

Should this be 2013-2019 instead ?

> + * Sudeep Holla 
>   *
>   * Copyright (C) 2013 Linaro.
>   * Viresh Kumar 
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> - * kind, whether express or implied; without even the implied warranty
> - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
>   */

-- 
viresh


Re: [PATCH] lib/vdso: Use __arch_use_vsyscall() to indicate fallback

2019-10-17 Thread Andy Lutomirski
On Thu, Oct 17, 2019 at 7:57 PM Huacai Chen  wrote:
>
> In do_hres(), we currently use whether the return value of __arch_get_
> hw_counter() is negtive to indicate fallback, but this is not a good
> idea. Because:
>
> 1, ARM64 returns ULL_MAX but MIPS returns 0 when clock_mode is invalid;
> 2, For a 64bit counter, a "negtive" value of counter is actually valid.

s/negtive/negative

What's the actual bug?  Is it that MIPS is returning 0 but the check
is < 0?  Sounds like MIPS should get fixed.

>
> To solve this problem, we use U64_MAX as the only "invalid" return
> value -- this is still not fully correct, but has no problem in most
> cases.

I'm sort of okay with that, but...

> Moreover, all vdso time-related functions should rely on the
> return value of __arch_use_vsyscall(), because update_vdso_data() and
> update_vsyscall_tz() also rely on it. So, in the core functions of
> __cvdso_gettimeofday(), __cvdso_clock_gettime() and __cvdso_clock_
> getres(), if __arch_use_vsyscall() returns false, we use the fallback
> functions directly.

__arch_use_vsyscall() is not currently intended for use in the vDSO at all.

>
> Fixes: 00b26474c2f1613d7ab894c5 ("lib/vdso: Provide generic VDSO 
> implementation")
> Cc: sta...@vger.kernel.org
> Cc: Arnd Bergmann 
> Cc: Paul Burton 
> Cc: linux-m...@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Signed-off-by: Huacai Chen 
> ---
>  arch/arm64/include/asm/vdso/vsyscall.h |  2 +-
>  arch/mips/include/asm/vdso/vsyscall.h  |  2 +-
>  include/asm-generic/vdso/vsyscall.h|  2 +-
>  lib/vdso/gettimeofday.c| 12 +++-
>  4 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/include/asm/vdso/vsyscall.h 
> b/arch/arm64/include/asm/vdso/vsyscall.h
> index 0c731bf..406e6de 100644
> --- a/arch/arm64/include/asm/vdso/vsyscall.h
> +++ b/arch/arm64/include/asm/vdso/vsyscall.h
> @@ -31,7 +31,7 @@ int __arm64_get_clock_mode(struct timekeeper *tk)
>  #define __arch_get_clock_mode __arm64_get_clock_mode
>
>  static __always_inline
> -int __arm64_use_vsyscall(struct vdso_data *vdata)
> +int __arm64_use_vsyscall(const struct vdso_data *vdata)
>  {
> return !vdata[CS_HRES_COARSE].clock_mode;
>  }
> diff --git a/arch/mips/include/asm/vdso/vsyscall.h 
> b/arch/mips/include/asm/vdso/vsyscall.h
> index 1953147..8b10dd7 100644
> --- a/arch/mips/include/asm/vdso/vsyscall.h
> +++ b/arch/mips/include/asm/vdso/vsyscall.h
> @@ -29,7 +29,7 @@ int __mips_get_clock_mode(struct timekeeper *tk)
>  #define __arch_get_clock_mode __mips_get_clock_mode
>
>  static __always_inline
> -int __mips_use_vsyscall(struct vdso_data *vdata)
> +int __mips_use_vsyscall(const struct vdso_data *vdata)
>  {
> return (vdata[CS_HRES_COARSE].clock_mode != VDSO_CLOCK_NONE);
>  }
> diff --git a/include/asm-generic/vdso/vsyscall.h 
> b/include/asm-generic/vdso/vsyscall.h
> index e94b1978..ac05a625 100644
> --- a/include/asm-generic/vdso/vsyscall.h
> +++ b/include/asm-generic/vdso/vsyscall.h
> @@ -26,7 +26,7 @@ static __always_inline int __arch_get_clock_mode(struct 
> timekeeper *tk)
>  #endif /* __arch_get_clock_mode */
>
>  #ifndef __arch_use_vsyscall
> -static __always_inline int __arch_use_vsyscall(struct vdso_data *vdata)
> +static __always_inline int __arch_use_vsyscall(const struct vdso_data *vdata)
>  {
> return 1;
>  }
> diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
> index e630e7f..4ad062e 100644
> --- a/lib/vdso/gettimeofday.c
> +++ b/lib/vdso/gettimeofday.c
> @@ -9,6 +9,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  /*
>   * The generic vDSO implementation requires that gettimeofday.h
> @@ -50,7 +51,7 @@ static int do_hres(const struct vdso_data *vd, clockid_t 
> clk,
> cycles = __arch_get_hw_counter(vd->clock_mode);
> ns = vdso_ts->nsec;
> last = vd->cycle_last;
> -   if (unlikely((s64)cycles < 0))
> +   if (unlikely(cycles == U64_MAX))
> return -1;

I would actually prefer:

if (unlikely(cycles < last))

or perhaps:

if (unlikely((s64)(cycles-last) < 0))

which would have the nice side effect of getting rid of the annoying
x86 special case in vdso_calc_delta().  The former version is
compatible with U64_MAX, whereas the latter version would need the
error case to return last-1 or similar.  The benefit of the latter
version is that it can survive wrap-around.

>
> ns += vdso_calc_delta(cycles, last, vd->mask, vd->mult);
> @@ -91,6 +92,9 @@ __cvdso_clock_gettime_common(clockid_t clock, struct 
> __kernel_timespec *ts)
> if (unlikely((u32) clock >= MAX_CLOCKS))
> return -1;
>
> +   if (!__arch_use_vsyscall(vd))
> +   return -1;
> +

NAK.  I don't think this is helpful or correct.  It doesn't appear to
do anything valid, and it's racy.

> /*
>  * Convert the clockid to a bitmask and use it to check which
>  * clocks are handled in 

BUG: unable to handle kernel paging request in is_bpf_text_address

2019-10-17 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:283ea345 coccinelle: api/devm_platform_ioremap_resource: r..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=122f199b60
kernel config:  https://syzkaller.appspot.com/x/.config?x=f0a8b0a0736a2ac1
dashboard link: https://syzkaller.appspot.com/bug?extid=710043c5d1d5b5013bc7
compiler:   clang version 9.0.0 (/home/glider/llvm/clang  
80fee25776c2fb61e74c1ecb1a523375c2500b69)

syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=142676bb60
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11a2cebb60

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

BUG: unable to handle page fault for address: c90001923030
#PF: supervisor read access in kernel mode
#PF: error_code(0x) - not-present page
PGD aa551067 P4D aa551067 PUD aa552067 PMD a572b067 PTE 8000a1173163
Oops:  [#1] PREEMPT SMP KASAN
CPU: 0 PID: 7982 Comm: syz-executor912 Not tainted 5.4.0-rc3+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:bpf_jit_binary_hdr include/linux/filter.h:787 [inline]
RIP: 0010:bpf_get_prog_addr_region kernel/bpf/core.c:531 [inline]
RIP: 0010:bpf_tree_comp kernel/bpf/core.c:600 [inline]
RIP: 0010:__lt_find include/linux/rbtree_latch.h:115 [inline]
RIP: 0010:latch_tree_find include/linux/rbtree_latch.h:208 [inline]
RIP: 0010:bpf_prog_kallsyms_find kernel/bpf/core.c:674 [inline]
RIP: 0010:is_bpf_text_address+0x184/0x3b0 kernel/bpf/core.c:709
Code: 89 df e8 ff dd 2e 00 48 8b 1b 48 8d 7b 30 48 89 f8 48 c1 e8 03 48 b9  
00 00 00 00 00 fc ff df 80 3c 08 00 74 05 e8 dc dd 2e 00 <4c> 8b 63 30 48  
c7 c0 00 f0 ff ff 49 21 c4 48 83 c3 02 48 89 d8 48

RSP: 0018:88809569f9c8 EFLAGS: 00010246
RAX: 192000324606 RBX: c90001923000 RCX: dc00
RDX: 88809d900500 RSI: 8880a8227838 RDI: c90001923030
RBP: 88809569fa00 R08: 817d9d5a R09: ed1015d46b05
R10: ed1015d46b05 R11:  R12: 88809d900500
R13:  R14:  R15: 8880a8227838
FS:  00728880() GS:8880aea0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: c90001923030 CR3: 96dc4000 CR4: 001406f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 kernel_text_address kernel/extable.c:147 [inline]
 __kernel_text_address+0x9a/0x110 kernel/extable.c:102
 unwind_get_return_address+0x4c/0x90 arch/x86/kernel/unwind_frame.c:19
 arch_stack_walk+0x98/0xe0 arch/x86/kernel/stacktrace.c:26
 stack_trace_save+0xb6/0x150 kernel/stacktrace.c:123
 save_stack mm/kasan/common.c:69 [inline]
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc+0x11c/0x1b0 mm/kasan/common.c:510
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:518
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc mm/slab.c:3319 [inline]
 kmem_cache_alloc+0x1f5/0x2e0 mm/slab.c:3483
 getname_flags+0xba/0x640 fs/namei.c:138
 getname+0x19/0x20 fs/namei.c:209
 do_sys_open+0x261/0x560 fs/open.c:1091
 __do_sys_open fs/open.c:1115 [inline]
 __se_sys_open fs/open.c:1110 [inline]
 __x64_sys_open+0x87/0x90 fs/open.c:1110
 do_syscall_64+0xf7/0x1c0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4011a0
Code: 01 f0 ff ff 0f 83 c0 0b 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f  
44 00 00 83 3d 2d 15 2d 00 00 75 14 b8 02 00 00 00 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 94 0b 00 00 c3 48 83 ec 08 e8 fa 00 00 00

RSP: 002b:7ffd6d953f58 EFLAGS: 0246 ORIG_RAX: 0002
RAX: ffda RBX: 7ffd6d953f84 RCX: 004011a0
RDX: 7ffd6d953f8a RSI: 00080001 RDI: 004a2422
RBP: 7ffd6d953f80 R08:  R09: 0004
R10:  R11: 0246 R12: 004021c0
R13:  R14:  R15: 
Modules linked in:
CR2: c90001923030
---[ end trace a62c6ddd9792af6a ]---
RIP: 0010:bpf_jit_binary_hdr include/linux/filter.h:787 [inline]
RIP: 0010:bpf_get_prog_addr_region kernel/bpf/core.c:531 [inline]
RIP: 0010:bpf_tree_comp kernel/bpf/core.c:600 [inline]
RIP: 0010:__lt_find include/linux/rbtree_latch.h:115 [inline]
RIP: 0010:latch_tree_find include/linux/rbtree_latch.h:208 [inline]
RIP: 0010:bpf_prog_kallsyms_find kernel/bpf/core.c:674 [inline]
RIP: 0010:is_bpf_text_address+0x184/0x3b0 kernel/bpf/core.c:709
Code: 89 df e8 ff dd 2e 00 48 8b 1b 48 8d 7b 30 48 89 f8 48 c1 e8 03 48 b9  
00 00 00 00 00 fc ff df 80 3c 08 00 74 05 e8 dc dd 2e 00 <4c> 8b 63 30 48  
c7 c0 00 f0 ff ff 49 21 c4 48 83 c3 02 48 89 d8 48

RSP: 0018:88809569f9c8 EFLAGS: 00010246
RAX: 192000324606 RBX: c90001923000 RCX: dc00
RDX: 88809d900500 RSI: 8880a8227838 RDI: 

Re: [PATCH 12/15] riscv: clear the instruction cache and all registers when booting

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> When we get booted we want a clear slate without any leaks from previous
> supervisors or the firmware.  Flush the instruction cache and then clear
> all registers to known good values.  This is really important for the
> upcoming nommu support that runs on M-mode, but can't really harm when
> running in S-mode either.  Vaguely based on the concepts from opensbi.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/include/asm/csr.h |  1 +
>  arch/riscv/kernel/head.S | 88 +++-
>  2 files changed, 88 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h
> index d0b5113e1a54..ee0101278608 100644
> --- a/arch/riscv/include/asm/csr.h
> +++ b/arch/riscv/include/asm/csr.h
> @@ -83,6 +83,7 @@
>  /* symbolic CSR names: */
>  #define CSR_MHARTID0xf14
>  #define CSR_MSTATUS0x300
> +#define CSR_MISA   0x301
>  #define CSR_MIE0x304
>  #define CSR_MTVEC  0x305
>  #define CSR_MSCRATCH   0x340
> diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
> index 583784cb3a32..25867b99cc95 100644
> --- a/arch/riscv/kernel/head.S
> +++ b/arch/riscv/kernel/head.S
> @@ -11,6 +11,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  __INIT
> @@ -51,12 +52,18 @@ _start_kernel:
> csrw CSR_XIP, zero
>
>  #ifdef CONFIG_RISCV_M_MODE
> +   /* flush the instruction cache */
> +   fence.i
> +
> +   /* Reset all registers except ra, a0, a1 */
> +   call reset_regs
> +
> /*
>  * The hartid in a0 is expected later on, and we have no firmware
>  * to hand it to us.
>  */
> csrr a0, CSR_MHARTID
> -#endif
> +#endif /* CONFIG_RISCV_M_MODE */
>
> /* Load the global pointer */
>  .option push
> @@ -203,6 +210,85 @@ relocate:
> j .Lsecondary_park
>  END(_start)
>
> +#ifdef CONFIG_RISCV_M_MODE
> +ENTRY(reset_regs)
> +   li  sp, 0
> +   li  gp, 0
> +   li  tp, 0
> +   li  t0, 0
> +   li  t1, 0
> +   li  t2, 0
> +   li  s0, 0
> +   li  s1, 0
> +   li  a2, 0
> +   li  a3, 0
> +   li  a4, 0
> +   li  a5, 0
> +   li  a6, 0
> +   li  a7, 0
> +   li  s2, 0
> +   li  s3, 0
> +   li  s4, 0
> +   li  s5, 0
> +   li  s6, 0
> +   li  s7, 0
> +   li  s8, 0
> +   li  s9, 0
> +   li  s10, 0
> +   li  s11, 0
> +   li  t3, 0
> +   li  t4, 0
> +   li  t5, 0
> +   li  t6, 0
> +   csrwsscratch, 0
> +
> +#ifdef CONFIG_FPU
> +   csrrt0, CSR_MISA
> +   andit0, t0, (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D)
> +   bnezt0, .Lreset_regs_done
> +
> +   li  t1, SR_FS
> +   csrsCSR_XSTATUS, t1
> +   fmv.s.x f0, zero
> +   fmv.s.x f1, zero
> +   fmv.s.x f2, zero
> +   fmv.s.x f3, zero
> +   fmv.s.x f4, zero
> +   fmv.s.x f5, zero
> +   fmv.s.x f6, zero
> +   fmv.s.x f7, zero
> +   fmv.s.x f8, zero
> +   fmv.s.x f9, zero
> +   fmv.s.x f10, zero
> +   fmv.s.x f11, zero
> +   fmv.s.x f12, zero
> +   fmv.s.x f13, zero
> +   fmv.s.x f14, zero
> +   fmv.s.x f15, zero
> +   fmv.s.x f16, zero
> +   fmv.s.x f17, zero
> +   fmv.s.x f18, zero
> +   fmv.s.x f19, zero
> +   fmv.s.x f20, zero
> +   fmv.s.x f21, zero
> +   fmv.s.x f22, zero
> +   fmv.s.x f23, zero
> +   fmv.s.x f24, zero
> +   fmv.s.x f25, zero
> +   fmv.s.x f26, zero
> +   fmv.s.x f27, zero
> +   fmv.s.x f28, zero
> +   fmv.s.x f29, zero
> +   fmv.s.x f30, zero
> +   fmv.s.x f31, zero
> +   csrwfcsr, 0
> +   /* note that the caller must clear SR_FS */
> +#endif /* CONFIG_FPU */
> +.Lreset_regs_done:
> +   ret
> +END(reset_regs)
> +#endif /* CONFIG_RISCV_M_MODE */
> +
>  __PAGE_ALIGNED_BSS
> /* Empty zero page */
> .balign PAGE_SIZE
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH 13/15] riscv: add nommu support

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> The kernel runs in M-mode without using page tables, and thus can't run
> bare metal without help from additional firmware.
>
> Most of the patch is just stubbing out code not needed without page
> tables, but there is an interesting detail in the signals implementation:
>
>  - The normal RISC-V syscall ABI only implements rt_sigreturn as VDSO
>entry point, but the ELF VDSO is not supported for nommu Linux.
>We instead copy the code to call the syscall onto the stack.
>
> In addition to enabling the nommu code a new defconfig for a small
> kernel image that can run in nommu mode on qemu is also provided, to run
> a kernel in qemu you can use the following command line:
>
> qemu-system-riscv64 -smp 2 -m 64 -machine virt -nographic \
> -kernel arch/riscv/boot/loader \
> -drive file=rootfs.ext2,format=raw,id=hd0 \
> -device virtio-blk-device,drive=hd0
>
> Contains contributions from Damien Le Moal .
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/Kconfig  | 26 ++---
>  arch/riscv/configs/nommu_virt_defconfig | 78 +
>  arch/riscv/include/asm/cache.h  |  8 +++
>  arch/riscv/include/asm/elf.h|  4 +-
>  arch/riscv/include/asm/fixmap.h |  2 +
>  arch/riscv/include/asm/futex.h  |  6 ++
>  arch/riscv/include/asm/io.h |  4 ++
>  arch/riscv/include/asm/mmu.h|  3 +
>  arch/riscv/include/asm/page.h   | 10 +++-
>  arch/riscv/include/asm/pgalloc.h|  2 +
>  arch/riscv/include/asm/pgtable.h| 64 +++-
>  arch/riscv/include/asm/tlbflush.h   | 12 +++-
>  arch/riscv/include/asm/uaccess.h|  4 ++
>  arch/riscv/kernel/Makefile  |  3 +-
>  arch/riscv/kernel/entry.S   | 11 
>  arch/riscv/kernel/head.S|  6 ++
>  arch/riscv/kernel/signal.c  | 17 +-
>  arch/riscv/lib/Makefile | 11 ++--
>  arch/riscv/mm/Makefile  |  3 +-
>  arch/riscv/mm/cacheflush.c  |  2 +
>  arch/riscv/mm/context.c |  2 +
>  arch/riscv/mm/init.c| 13 -
>  22 files changed, 236 insertions(+), 55 deletions(-)
>  create mode 100644 arch/riscv/configs/nommu_virt_defconfig
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index b85492c42ccb..babc8a0d3d2e 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -26,14 +26,14 @@ config RISCV
> select GENERIC_IRQ_SHOW
> select GENERIC_PCI_IOMAP
> select GENERIC_SCHED_CLOCK
> -   select GENERIC_STRNCPY_FROM_USER
> -   select GENERIC_STRNLEN_USER
> +   select GENERIC_STRNCPY_FROM_USER if MMU
> +   select GENERIC_STRNLEN_USER if MMU
> select GENERIC_SMP_IDLE_THREAD
> select GENERIC_ATOMIC64 if !64BIT
> select HAVE_ARCH_AUDITSYSCALL
> select HAVE_ASM_MODVERSIONS
> select HAVE_MEMBLOCK_NODE_MAP
> -   select HAVE_DMA_CONTIGUOUS
> +   select HAVE_DMA_CONTIGUOUS if MMU
> select HAVE_FUTEX_CMPXCHG if FUTEX
> select HAVE_PERF_EVENTS
> select HAVE_PERF_REGS
> @@ -50,6 +50,7 @@ config RISCV
> select PCI_DOMAINS_GENERIC if PCI
> select PCI_MSI if PCI
> select RISCV_TIMER
> +   select UACCESS_MEMCPY if !MMU
> select GENERIC_IRQ_MULTI_HANDLER
> select GENERIC_ARCH_TOPOLOGY if SMP
> select ARCH_HAS_PTE_SPECIAL
> @@ -60,7 +61,7 @@ config RISCV
> select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
> select SPARSEMEM_STATIC if 32BIT
> select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
> -   select HAVE_ARCH_MMAP_RND_BITS
> +   select HAVE_ARCH_MMAP_RND_BITS if MMU
>
>  config ARCH_MMAP_RND_BITS_MIN
> default 18 if 64BIT
> @@ -75,6 +76,7 @@ config ARCH_MMAP_RND_BITS_MAX
>  # set if we run in machine mode, cleared if we run in supervisor mode
>  config RISCV_M_MODE
> bool
> +   default !MMU
>
>  # set if we are running in S-mode and can use SBI calls
>  config RISCV_SBI
> @@ -83,7 +85,11 @@ config RISCV_SBI
> default y
>
>  config MMU
> -   def_bool y
> +   bool "MMU-based Paged Memory Management Support"
> +   default y
> +   help
> + Select if you want MMU-based virtualised addressing space
> + support by paged memory management. If unsure, say 'Y'.
>
>  config ZONE_DMA32
> bool
> @@ -102,6 +108,7 @@ config PA_BITS
>  config PAGE_OFFSET
> hex
> default 0xC000 if 32BIT && MAXPHYSMEM_2GB
> +   default 0x8000 if 64BIT && !MMU
> default 0x8000 if 64BIT && MAXPHYSMEM_2GB
> default 0xffe0 if 64BIT && MAXPHYSMEM_128GB
>
> @@ -145,7 +152,7 @@ config GENERIC_HWEIGHT
> def_bool y
>
>  config FIX_EARLYCON_MEM
> -   def_bool y
> +   def_bool CONFIG_MMU
>
>  config PGTABLE_LEVELS
> int
> @@ -170,6 

Re: [RFT][PATCH 0/3] cpufreq / PM: QoS: Introduce frequency QoS and use it in cpufreq

2019-10-17 Thread Viresh Kumar
On 17-10-19, 18:34, Rafael J. Wysocki wrote:
> [BTW, Viresh, it looks like cpufreq_set_policy() should still ensure
> that the new min is less than the new max, because the QoS doesn't do
> that.]

The ->verify() callback does that for us I believe.

-- 
viresh


Re: [RFT][PATCH 1/3] PM: QoS: Introduce frequency QoS

2019-10-17 Thread Viresh Kumar
On 17-10-19, 16:16, Rafael J. Wysocki wrote:
> [Also note that the current code in device PM QoS uses MIN and MAX
> here in the same way. :-)]

Stupid me, enough embarrassment for the day :(

-- 
viresh


Re: [PATCH] cpufreq: flush any pending policy update work scheduled before freeing

2019-10-17 Thread Viresh Kumar
On 17-10-19, 17:35, Sudeep Holla wrote:
> dev_pm_qos_remove_request ends calling {max,min}_freq_req QoS notifiers
> which schedule policy update work.

I don't think that's correct. We remove the notifiers first and then
only remove the requests. Though it is possible due to the other bug
we are discussing where the notifier doesn't really get removed from
the right CPU, but even that patch didn't fix your issue.

Looks like we are still missing something ?

> It may end up racing with the freeing
> the policy and unregistering the driver.
> 
> One possible race is as below where the cpufreq_driver is unregistered
> but the scheduled work gets executed at later stage when cpufreq_driver
> is NULL(i.e. after freeing the policy and driver)
> 
> Unable to handle kernel NULL pointer dereference at virtual address 001c
> pgd = (ptrval)
> [001c] *pgd=8080204003, *pmd=
> Internal error: Oops: 206 [#1] SMP THUMB2
> Modules linked in:
> CPU: 0 PID: 34 Comm: kworker/0:1 Not tainted 5.4.0-rc3-6-g67f5a8081a4b #86
> Hardware name: ARM-Versatile Express
> Workqueue: events handle_update
> PC is at cpufreq_set_policy+0x58/0x228
> LR is at dev_pm_qos_read_value+0x77/0xac
> Control: 70c5387d  Table: 80203000  DAC: fffd
> Process kworker/0:1 (pid: 34, stack limit = 0x(ptrval))
>   (cpufreq_set_policy) from (refresh_frequency_limits.part.24+0x37/0x48)
>   (refresh_frequency_limits.part.24) from (handle_update+0x2f/0x38)
>   (handle_update) from (process_one_work+0x16d/0x3cc)
>   (process_one_work) from (worker_thread+0xff/0x414)
>   (worker_thread) from (kthread+0xff/0x100)
>   (kthread) from (ret_from_fork+0x11/0x28)
> 
> Cc: "Rafael J. Wysocki" 
> Cc: Viresh Kumar 
> Signed-off-by: Sudeep Holla 
> ---
>  drivers/cpufreq/cpufreq.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> Hi Rafael, Viresh,
> 
> This fixed the boot issue I reported[1] on TC2 with bL switcher enabled.
> I have based this patch on -rc3 and not on top of your patches. This
> only fixes the boot issue but I hit the other crashes while continuously
> switching on and off the bL switcher that register/unregister the driver
> Your patch series fixes them. I can based this on top of those if you
> prefer.
> 
> Regards,
> Sudeep
> 
> [1] https://lore.kernel.org/linux-pm/20191015155735.GA29105@bogus/
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index c52d6fa32aac..b703c29a84be 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1278,6 +1278,9 @@ static void cpufreq_policy_free(struct cpufreq_policy 
> *policy)
>   }
>  
>   dev_pm_qos_remove_request(policy->min_freq_req);
> + /* flush the pending policy->update work before freeing the policy */
> + if (work_pending(>update))
> + flush_work(>update);

This diff surely makes sense even without the QoS stuff, this race can
still happen, very unlikely though.

And yes, you must use the other variant that Rafael suggested, we are
already doing similar thing in a bunch of cpufreq governors :)

And I will probably add this after calling
dev_pm_qos_remove_notifier() for the MAX policy as this doesn't and
shouldn't depend on removing the qos request.

>   kfree(policy->min_freq_req);
>  
>   cpufreq_policy_put_kobj(policy);
> -- 
> 2.17.1

-- 
viresh


Re: [PATCH 02/15] riscv: cleanup do_trap_break

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:07 PM Christoph Hellwig  wrote:
>
> If we always compile the get_break_insn_length inline function we can
> remove the ifdefs and let dead code elimination take care of the warn
> branch that is now unreadable because the report_bug stub always
> returns BUG_TRAP_TYPE_BUG.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/kernel/traps.c | 26 ++
>  1 file changed, 6 insertions(+), 20 deletions(-)
>
> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> index 1ac75f7d0bff..10a17e545f43 100644
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -111,7 +111,6 @@ DO_ERROR_INFO(do_trap_ecall_s,
>  DO_ERROR_INFO(do_trap_ecall_m,
> SIGILL, ILL_ILLTRP, "environment call from M-mode");
>
> -#ifdef CONFIG_GENERIC_BUG
>  static inline unsigned long get_break_insn_length(unsigned long pc)
>  {
> bug_insn_t insn;
> @@ -120,28 +119,15 @@ static inline unsigned long 
> get_break_insn_length(unsigned long pc)
> return 0;
> return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 
> 2UL);
>  }
> -#endif /* CONFIG_GENERIC_BUG */
>
>  asmlinkage void do_trap_break(struct pt_regs *regs)
>  {
> -   if (user_mode(regs)) {
> -   force_sig_fault(SIGTRAP, TRAP_BRKPT,
> -   (void __user *)(regs->sepc));
> -   return;
> -   }
> -#ifdef CONFIG_GENERIC_BUG
> -   {
> -   enum bug_trap_type type;
> -
> -   type = report_bug(regs->sepc, regs);
> -   if (type == BUG_TRAP_TYPE_WARN) {
> -   regs->sepc += get_break_insn_length(regs->sepc);
> -   return;
> -   }
> -   }
> -#endif /* CONFIG_GENERIC_BUG */
> -
> -   die(regs, "Kernel BUG");
> +   if (user_mode(regs))
> +   force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user 
> *)regs->sepc);
> +   else if (report_bug(regs->sepc, regs) == BUG_TRAP_TYPE_WARN)
> +   regs->sepc += get_break_insn_length(regs->sepc);
> +   else
> +   die(regs, "Kernel BUG");
>  }
>
>  #ifdef CONFIG_GENERIC_BUG
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH v3 04/10] sched/fair: rework load_balance

2019-10-17 Thread Parth Shah



On 10/16/19 5:26 PM, Vincent Guittot wrote:
> On Wed, 16 Oct 2019 at 09:21, Parth Shah  wrote:
>>
>>
>>
>> On 9/19/19 1:03 PM, Vincent Guittot wrote:
>>
>> [...]
>>
>>> Signed-off-by: Vincent Guittot 
>>> ---
>>>  kernel/sched/fair.c | 585 
>>> ++--
>>>  1 file changed, 380 insertions(+), 205 deletions(-)
>>>
>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>>> index 017aad0..d33379c 100644
>>> --- a/kernel/sched/fair.c
>>> +++ b/kernel/sched/fair.c
>>> @@ -7078,11 +7078,26 @@ static unsigned long __read_mostly 
>>> max_load_balance_interval = HZ/10;
>>>
>>>  enum fbq_type { regular, remote, all };
>>>
>>> +/*
>>> + * group_type describes the group of CPUs at the moment of the load 
>>> balance.
>>> + * The enum is ordered by pulling priority, with the group with lowest 
>>> priority
>>> + * first so the groupe_type can be simply compared when selecting the 
>>> busiest
>>> + * group. see update_sd_pick_busiest().
>>> + */
>>>  enum group_type {
>>> - group_other = 0,
>>> + group_has_spare = 0,
>>> + group_fully_busy,
>>>   group_misfit_task,
>>> + group_asym_packing,
>>>   group_imbalanced,
>>> - group_overloaded,
>>> + group_overloaded
>>> +};
>>> +
>>> +enum migration_type {
>>> + migrate_load = 0,
>>> + migrate_util,
>>> + migrate_task,
>>> + migrate_misfit
>>>  };
>>>
>>>  #define LBF_ALL_PINNED   0x01
>>> @@ -7115,7 +7130,7 @@ struct lb_env {
>>>   unsigned intloop_max;
>>>
>>>   enum fbq_type   fbq_type;
>>> - enum group_type src_grp_type;
>>> + enum migration_type balance_type;
>>>   struct list_headtasks;
>>>  };
>>>
>>> @@ -7347,7 +7362,7 @@ static int detach_tasks(struct lb_env *env)
>>>  {
>>>   struct list_head *tasks = >src_rq->cfs_tasks;
>>>   struct task_struct *p;
>>> - unsigned long load;
>>> + unsigned long util, load;
>>>   int detached = 0;
>>>
>>>   lockdep_assert_held(>src_rq->lock);
>>> @@ -7380,19 +7395,53 @@ static int detach_tasks(struct lb_env *env)
>>>   if (!can_migrate_task(p, env))
>>>   goto next;
>>>
>>> - load = task_h_load(p);
>>> + switch (env->balance_type) {
>>> + case migrate_load:
>>> + load = task_h_load(p);
>>>
>>> - if (sched_feat(LB_MIN) && load < 16 && 
>>> !env->sd->nr_balance_failed)
>>> - goto next;
>>> + if (sched_feat(LB_MIN) &&
>>> + load < 16 && !env->sd->nr_balance_failed)
>>> + goto next;
>>>
>>> - if ((load / 2) > env->imbalance)
>>> - goto next;
>>> + if ((load / 2) > env->imbalance)
>>> + goto next;
>>> +
>>> + env->imbalance -= load;
>>> + break;
>>> +
>>> + case migrate_util:
>>> + util = task_util_est(p);
>>> +
>>> + if (util > env->imbalance)
>>
>> Can you please explain what would happen for
>> `if (util/2 > env->imbalance)` ?
>> just like when migrating load, even util shouldn't be migrated if
>> env->imbalance is just near the utilization of the task being moved, isn't 
>> it?
> 
> I have chosen uti and not util/2 to be conservative because
> migrate_util is used to fill spare capacity.
> With `if (util/2 > env->imbalance)`, we can more easily overload the
> local group or pick too much utilization from the overloaded group.
> 

fair enough. I missed the point that unlike migrate_load, with
migrate_util, env->imbalance is just spare capacity of the local group.

Thanks,
Parth

>>
>>> + goto next;
>>> +
>>> + env->imbalance -= util;
>>> + break;
>>> +[ ... ]
>>
>> Thanks,
>> Parth
>>



Re: [PATCH 09/15] riscv: provide native clint access for M-mode

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> RISC-V has the concept of a cpu level interrupt controller.  The
> interface for it is split between a standardized part that is exposed
> as bits in the mstatus/sstatus register and the mie/mip/sie/sip
> CRS.  But the bit to actually trigger IPIs is not standardized and
> just mentioned as implementable using MMIO.
>
> Add support for IPIs using MMIO using the SiFive clint layout (which is
> also shared by Ariane, Kendrye and the Qemu virt platform).  Additional
> the MMIO block also support the time value and timer compare registers,
> so they are also set up using the same OF node.  Support for other
> layouts should also be relatively easy to add in the future.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/include/asm/clint.h | 39 ++
>  arch/riscv/include/asm/sbi.h   |  2 ++
>  arch/riscv/kernel/Makefile |  1 +
>  arch/riscv/kernel/clint.c  | 44 ++
>  arch/riscv/kernel/setup.c  |  2 ++
>  arch/riscv/kernel/smp.c| 16 ++---
>  arch/riscv/kernel/smpboot.c|  4 
>  7 files changed, 105 insertions(+), 3 deletions(-)
>  create mode 100644 arch/riscv/include/asm/clint.h
>  create mode 100644 arch/riscv/kernel/clint.c
>
> diff --git a/arch/riscv/include/asm/clint.h b/arch/riscv/include/asm/clint.h
> new file mode 100644
> index ..02a26b68f21d
> --- /dev/null
> +++ b/arch/riscv/include/asm/clint.h
> @@ -0,0 +1,39 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#ifndef _ASM_CLINT_H
> +#define _ASM_CLINT_H 1
> +
> +#include 
> +#include 
> +
> +#ifdef CONFIG_RISCV_M_MODE
> +extern u32 __iomem *clint_ipi_base;
> +
> +void clint_init_boot_cpu(void);
> +
> +static inline void clint_send_ipi_single(unsigned long hartid)
> +{
> +   writel(1, clint_ipi_base + hartid);
> +}
> +
> +static inline void clint_send_ipi_mask(const struct cpumask *hartid_mask)
> +{
> +   int hartid;
> +
> +   for_each_cpu(hartid, hartid_mask)
> +   clint_send_ipi_single(hartid);
> +}
> +
> +static inline void clint_clear_ipi(unsigned long hartid)
> +{
> +   writel(0, clint_ipi_base + hartid);
> +}
> +#else /* CONFIG_RISCV_M_MODE */
> +#define clint_init_boot_cpu()  do { } while (0)
> +
> +/* stubs to for code is only reachable under 
> IS_ENABLED(CONFIG_RISCV_M_MODE): */
> +void clint_send_ipi_single(unsigned long hartid);
> +void clint_send_ipi_mask(const struct cpumask *hartid_mask);
> +void clint_clear_ipi(unsigned long hartid);
> +#endif /* CONFIG_RISCV_M_MODE */
> +
> +#endif /* _ASM_CLINT_H */
> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
> index a4774bafe033..407d1024f9eb 100644
> --- a/arch/riscv/include/asm/sbi.h
> +++ b/arch/riscv/include/asm/sbi.h
> @@ -97,6 +97,8 @@ static inline void sbi_remote_sfence_vma_asid(const 
> unsigned long *hart_mask,
>  #else /* CONFIG_RISCV_SBI */
>  /* stubs to for code is only reachable under IS_ENABLED(CONFIG_RISCV_SBI): */
>  void sbi_set_timer(uint64_t stime_value);
> +void sbi_clear_ipi(void);
> +void sbi_send_ipi(const unsigned long *hart_mask);
>  void sbi_remote_fence_i(const unsigned long *hart_mask);
>  #endif /* CONFIG_RISCV_SBI */
>  #endif /* _ASM_RISCV_SBI_H */
> diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
> index d8c35fa93cc6..2dca51046899 100644
> --- a/arch/riscv/kernel/Makefile
> +++ b/arch/riscv/kernel/Makefile
> @@ -29,6 +29,7 @@ obj-y += vdso.o
>  obj-y  += cacheinfo.o
>  obj-y  += vdso/
>
> +obj-$(CONFIG_RISCV_M_MODE) += clint.o
>  obj-$(CONFIG_FPU)  += fpu.o
>  obj-$(CONFIG_SMP)  += smpboot.o
>  obj-$(CONFIG_SMP)  += smp.o
> diff --git a/arch/riscv/kernel/clint.c b/arch/riscv/kernel/clint.c
> new file mode 100644
> index ..3647980d14c3
> --- /dev/null
> +++ b/arch/riscv/kernel/clint.c
> @@ -0,0 +1,44 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2019 Christoph Hellwig.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * This is the layout used by the SiFive clint, which is also shared by the 
> qemu
> + * virt platform, and the Kendryte KD210 at least.
> + */
> +#define CLINT_IPI_OFF  0
> +#define CLINT_TIME_CMP_OFF 0x4000
> +#define CLINT_TIME_VAL_OFF 0xbff8
> +
> +u32 __iomem *clint_ipi_base;
> +
> +void clint_init_boot_cpu(void)
> +{
> +   struct device_node *np;
> +   void __iomem *base;
> +
> +   np = of_find_compatible_node(NULL, NULL, "riscv,clint0");
> +   if (!np) {
> +   panic("clint not found");
> +   return;
> +   }
> +
> +   base = of_iomap(np, 0);
> +   if (!base)
> +   panic("could not map CLINT");
> +
> +   clint_ipi_base = base + CLINT_IPI_OFF;
> +   riscv_time_cmp = base + CLINT_TIME_CMP_OFF;
> +   riscv_time_val = base + CLINT_TIME_VAL_OFF;
> +
> +   

[PATCH net] net: hns3: fix mis-counting IRQ vector numbers issue

2019-10-17 Thread Huazhong Tan
From: Yonglong Liu 

Currently, the num_msi_left means the vector numbers of NIC,
but if the PF supported RoCE, it contains the vector numbers
of NIC and RoCE(Not expected).

This may cause interrupts lost in some case, because of the
NIC module used the vector resources which belongs to RoCE.

This patch adds a new variable num_nic_msi to store the vector
numbers of NIC, and adjust the default TQP numbers and rss_size
according to the value of num_nic_msi.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility 
Layer Support")
Signed-off-by: Yonglong Liu 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h|  2 ++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 21 +++-
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h|  1 +
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  | 11 +++--
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  | 28 +++---
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h  |  1 +
 6 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h 
b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index c4b7bf8..75ccc1e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -32,6 +32,8 @@
 
 #define HNAE3_MOD_VERSION "1.0"
 
+#define HNAE3_MIN_VECTOR_NUM   2 /* first one for misc, another for IO */
+
 /* Device IDs */
 #define HNAE3_DEV_ID_GE0xA220
 #define HNAE3_DEV_ID_25GE  0xA221
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index fd7f943..e02e01b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -906,6 +906,9 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number),
HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S);
 
+   /* nic's msix numbers is always equals to the roce's. */
+   hdev->num_nic_msi = hdev->num_roce_msi;
+
/* PF should have NIC vectors and Roce vectors,
 * NIC vectors are queued before Roce vectors.
 */
@@ -915,6 +918,15 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
hdev->num_msi =
hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number),
HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S);
+
+   hdev->num_nic_msi = hdev->num_msi;
+   }
+
+   if (hdev->num_nic_msi < HNAE3_MIN_VECTOR_NUM) {
+   dev_err(>pdev->dev,
+   "Just %u msi resources, not enough for pf(min:2).\n",
+   hdev->num_nic_msi);
+   return -EINVAL;
}
 
return 0;
@@ -1507,6 +1519,10 @@ static int  hclge_assign_tqp(struct hclge_vport *vport, 
u16 num_tqps)
kinfo->rss_size = min_t(u16, hdev->rss_size_max,
vport->alloc_tqps / hdev->tm_info.num_tc);
 
+   /* ensure one to one mapping between irq and queue at default */
+   kinfo->rss_size = min_t(u16, kinfo->rss_size,
+   (hdev->num_nic_msi - 1) / hdev->tm_info.num_tc);
+
return 0;
 }
 
@@ -2285,7 +2301,8 @@ static int hclge_init_msi(struct hclge_dev *hdev)
int vectors;
int i;
 
-   vectors = pci_alloc_irq_vectors(pdev, 1, hdev->num_msi,
+   vectors = pci_alloc_irq_vectors(pdev, HNAE3_MIN_VECTOR_NUM,
+   hdev->num_msi,
PCI_IRQ_MSI | PCI_IRQ_MSIX);
if (vectors < 0) {
dev_err(>dev,
@@ -2300,6 +2317,7 @@ static int hclge_init_msi(struct hclge_dev *hdev)
 
hdev->num_msi = vectors;
hdev->num_msi_left = vectors;
+
hdev->base_msi_vector = pdev->irq;
hdev->roce_base_vector = hdev->base_msi_vector +
hdev->roce_base_msix_offset;
@@ -3903,6 +3921,7 @@ static int hclge_get_vector(struct hnae3_handle *handle, 
u16 vector_num,
int alloc = 0;
int i, j;
 
+   vector_num = min_t(u16, hdev->num_nic_msi - 1, vector_num);
vector_num = min(hdev->num_msi_left, vector_num);
 
for (j = 0; j < vector_num; j++) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 3e9574a..c3d56b8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -763,6 +763,7 @@ struct hclge_dev {
u32 base_msi_vector;
u16 *vector_status;
int *vector_irq;
+   u16 num_nic_msi;/* Num of nic vectors for this PF */
u16 num_roce_msi;   /* Num of roce vectors for 

Re: [PATCH 11/15] riscv: use the correct interrupt levels for M-mode

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> The numerical levels for External/Timer/Software interrupts differ
> between S-mode and M-mode.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/kernel/irq.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c
> index 804ff70bb853..dbd1fd7c22e4 100644
> --- a/arch/riscv/kernel/irq.c
> +++ b/arch/riscv/kernel/irq.c
> @@ -14,9 +14,15 @@
>  /*
>   * Possible interrupt causes:
>   */
> -#define INTERRUPT_CAUSE_SOFTWARE   IRQ_S_SOFT
> -#define INTERRUPT_CAUSE_TIMER  IRQ_S_TIMER
> -#define INTERRUPT_CAUSE_EXTERNAL   IRQ_S_EXT
> +#ifdef CONFIG_RISCV_M_MODE
> +# define INTERRUPT_CAUSE_SOFTWARE  IRQ_M_SOFT
> +# define INTERRUPT_CAUSE_TIMER IRQ_M_TIMER
> +# define INTERRUPT_CAUSE_EXTERNAL  IRQ_M_EXT
> +#else
> +# define INTERRUPT_CAUSE_SOFTWARE  IRQ_S_SOFT
> +# define INTERRUPT_CAUSE_TIMER IRQ_S_TIMER
> +# define INTERRUPT_CAUSE_EXTERNAL  IRQ_S_EXT
> +#endif /* CONFIG_RISCV_M_MODE */
>
>  int arch_show_interrupts(struct seq_file *p, int prec)
>  {
> --
> 2.20.1
>

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH v4 1/2] clk: qcom: Add MSM8998 GPU Clock Controller (GPUCC) driver

2019-10-17 Thread Taniya Das

Hi Jeffrey,

On 10/2/2019 6:46 AM, Jeffrey Hugo wrote:

The GPUCC manages the clocks for the Adreno GPU found on MSM8998.

Signed-off-by: Jeffrey Hugo 
---
  drivers/clk/qcom/Kconfig |   9 +
  drivers/clk/qcom/Makefile|   1 +
  drivers/clk/qcom/gpucc-msm8998.c | 346 +++
  3 files changed, 356 insertions(+)
  create mode 100644 drivers/clk/qcom/gpucc-msm8998.c

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 96efee18fa6c..31a70168327c 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -230,6 +230,15 @@ config MSM_MMCC_8998
  Say Y if you want to support multimedia devices such as display,
  graphics, video encode/decode, camera, etc.
  
+config MSM_GPUCC_8998

+   tristate "MSM8998 Graphics Clock Controller"
+   select MSM_GCC_8998
+   select QCOM_GDSC
+   help
+ Support for the graphics clock controller on MSM8998 devices.
+ Say Y if you want to support graphics controller devices and
+ functionality such as 3D graphics.
+
  config QCS_GCC_404
tristate "QCS404 Global Clock Controller"
help
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index 0ac3c1459313..616b68f91db6 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_MSM_GCC_8994) += gcc-msm8994.o
  obj-$(CONFIG_MSM_GCC_8996) += gcc-msm8996.o
  obj-$(CONFIG_MSM_LCC_8960) += lcc-msm8960.o
  obj-$(CONFIG_MSM_GCC_8998) += gcc-msm8998.o
+obj-$(CONFIG_MSM_GPUCC_8998) += gpucc-msm8998.o
  obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8960.o
  obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o
  obj-$(CONFIG_MSM_MMCC_8996) += mmcc-msm8996.o
diff --git a/drivers/clk/qcom/gpucc-msm8998.c b/drivers/clk/qcom/gpucc-msm8998.c
new file mode 100644
index ..f0ccb4963885
--- /dev/null
+++ b/drivers/clk/qcom/gpucc-msm8998.c
@@ -0,0 +1,346 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019, Jeffrey Hugo
+ */
+


Copyright (c) 2019, The Linux Foundation. All rights reserved.


+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "common.h"
+#include "clk-regmap.h"
+#include "clk-regmap-divider.h"
+#include "clk-alpha-pll.h"
+#include "clk-rcg.h"
+#include "clk-branch.h"
+#include "reset.h"
+#include "gdsc.h"
+
+enum {
+   P_XO,
+   P_GPLL0,
+   P_GPUPLL0_OUT_EVEN,
+};
+
+/* Instead of going directly to the block, XO is routed through this branch */
+static struct clk_branch gpucc_cxo_clk = {
+   .halt_reg = 0x1020,
+   .clkr = {
+   .enable_reg = 0x1020,
+   .enable_mask = BIT(0),
+   .hw.init = &(struct clk_init_data){
+   .name = "gpucc_cxo_clk",
+   .parent_data = &(const struct clk_parent_data){
+   .fw_name = "xo",
+   .name = "xo"
+   },
+   .num_parents = 1,
+   .ops = _branch2_ops,
+   .flags = CLK_IS_CRITICAL,
+   },
+   },
+};
+
+static const struct clk_div_table post_div_table_fabia_even[] = {
+   { 0x0, 1 },
+   { 0x1, 2 },
+   { 0x3, 4 },
+   { 0x7, 8 },
+   { }
+};
+
+static struct clk_alpha_pll gpupll0 = {
+   .offset = 0x0,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "gpupll0",
+   .parent_hws = (const struct clk_hw *[]){ _cxo_clk.clkr.hw 
},
+   .num_parents = 1,
+   .ops = _alpha_pll_fixed_fabia_ops,
+   },
+};
+
+static struct clk_alpha_pll_postdiv gpupll0_out_even = {
+   .offset = 0x0,
+   .post_div_shift = 8,
+   .post_div_table = post_div_table_fabia_even,
+   .num_post_div = ARRAY_SIZE(post_div_table_fabia_even),
+   .width = 4,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "gpupll0_out_even",
+   .parent_hws = (const struct clk_hw *[]){  },
+   .num_parents = 1,
+   .ops = _alpha_pll_postdiv_fabia_ops,
+   },
+};
+
+static const struct parent_map gpu_xo_gpll0_map[] = {
+   { P_XO, 0 },
+   { P_GPLL0, 5 },
+};
+
+static const struct clk_parent_data gpu_xo_gpll0[] = {
+   { .hw = _cxo_clk.clkr.hw },
+   { .fw_name = "gpll0", .name = "gpll0" },
+};
+
+static const struct parent_map gpu_xo_gpupll0_map[] = {
+   { P_XO, 0 },
+   { P_GPUPLL0_OUT_EVEN, 1 },
+};
+
+static const struct clk_parent_data gpu_xo_gpupll0[] = {
+   { .hw = _cxo_clk.clkr.hw },
+   { .hw = _out_even.clkr.hw },
+};
+
+static const struct freq_tbl ftbl_rbcpr_clk_src[] = {
+   F(1920, P_XO, 1, 0, 0),
+   F(5000, P_GPLL0, 12, 0, 0),
+   { }
+};
+
+static 

Re: [PATCH] cpufreq: powernv: fix stack bloat and NR_CPUS limitation

2019-10-17 Thread Viresh Kumar
On 17-10-19, 17:04, John Hubbard wrote:
> The following build warning occurred on powerpc 64-bit builds:
> 
> drivers/cpufreq/powernv-cpufreq.c: In function 'init_chip_info':
> drivers/cpufreq/powernv-cpufreq.c:1070:1: warning: the frame size of 1040 
> bytes is larger than 1024 bytes [-Wframe-larger-than=]

How come we are catching this warning after 4 years ?

> 
> This is due to putting 1024 bytes on the stack:
> 
> unsigned int chip[256];
> 
> ...and while looking at this, it also has a bug: it fails with a stack
> overrun, if CONFIG_NR_CPUS > 256.
> 
> Fix both problems by dynamically allocating based on CONFIG_NR_CPUS.
> 
> Fixes: 053819e0bf840 ("cpufreq: powernv: Handle throttling due to Pmax 
> capping at chip level")
> Cc: Shilpasri G Bhat 
> Cc: Preeti U Murthy 
> Cc: Viresh Kumar 
> Cc: Rafael J. Wysocki 
> Cc: linux...@vger.kernel.org
> Cc: linuxppc-...@lists.ozlabs.org
> Signed-off-by: John Hubbard 
> ---
> 
> Hi,
> 
> I have only compile-tested this, so I would appreciate if anyone
> could do a basic runtime test on it. But (famous last words) it
> seems simple enough that I'm confident it's correct. oh boy. :)
> 
> thanks,
> John Hubbard
> NVIDIA
> 
>  drivers/cpufreq/powernv-cpufreq.c | 17 +
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/powernv-cpufreq.c 
> b/drivers/cpufreq/powernv-cpufreq.c
> index 6061850e59c9..78e04402125f 100644
> --- a/drivers/cpufreq/powernv-cpufreq.c
> +++ b/drivers/cpufreq/powernv-cpufreq.c
> @@ -1041,9 +1041,14 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
>  
>  static int init_chip_info(void)
>  {
> - unsigned int chip[256];
> + unsigned int *chip;
>   unsigned int cpu, i;
>   unsigned int prev_chip_id = UINT_MAX;
> + int ret = 0;
> +
> + chip = kcalloc(CONFIG_NR_CPUS, sizeof(int), GFP_KERNEL);

   sizeof(*chip)

> + if (!chips)

   (!chip)

> + return -ENOMEM;
>  
>   for_each_possible_cpu(cpu) {
>   unsigned int id = cpu_to_chip_id(cpu);
> @@ -1055,8 +1060,10 @@ static int init_chip_info(void)
>   }
>  
>   chips = kcalloc(nr_chips, sizeof(struct chip), GFP_KERNEL);
> - if (!chips)
> - return -ENOMEM;
> + if (!chips) {
> + ret = -ENOMEM;
> + goto free_and_return;
> + }
>  
>   for (i = 0; i < nr_chips; i++) {
>   chips[i].id = chip[i];
> @@ -1066,7 +1073,9 @@ static int init_chip_info(void)
>   per_cpu(chip_info, cpu) =  [i];
>   }
>  
> - return 0;
> +free_and_return:
> + kfree(chip);
> + return ret;
>  }
>  
>  static inline void clean_chip_info(void)
> -- 
> 2.23.0

-- 
viresh


[PATCH v4 1/2] dt-bindings: iio: accel: bma400: add bindings

2019-10-17 Thread Dan Robertson
Add devicetree binding for the Bosch BMA400 3-axes ultra-low power
accelerometer sensor.

Signed-off-by: Dan Robertson 
---
 .../devicetree/bindings/iio/accel/bma400.yaml | 39 +++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/accel/bma400.yaml

diff --git a/Documentation/devicetree/bindings/iio/accel/bma400.yaml 
b/Documentation/devicetree/bindings/iio/accel/bma400.yaml
new file mode 100644
index ..e0a85dc7bf34
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/accel/bma400.yaml
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/accel/bma400.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Bosch BMA400 triaxial acceleration sensor
+
+maintainers:
+  - Dan Robertson 
+
+description: |
+  Acceleration and temerature iio sensors with an i2c interface
+
+  Specifications about the sensor can be found at:
+
https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMA400-DS000.pdf
+
+properties:
+  compatible:
+enum:
+  - bosch,bma400
+
+  reg:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+i2c0 {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  bma400@14 {
+compatible = "bosch,bma400";
+reg = <0x14>;
+  };
+};




[PATCH v4 2/2] iio: (bma400) add driver for the BMA400

2019-10-17 Thread Dan Robertson
Add a IIO driver for the Bosch BMA400 3-axes ultra-low power accelerometer.
The driver supports reading from the acceleration and temperature
registers. The driver also supports reading and configuring the output data
rate, oversampling ratio, and scale.

Signed-off-by: Dan Robertson 
---
 drivers/iio/accel/Kconfig   |  18 +
 drivers/iio/accel/Makefile  |   2 +
 drivers/iio/accel/bma400.h  |  85 
 drivers/iio/accel/bma400_core.c | 796 
 drivers/iio/accel/bma400_i2c.c  |  60 +++
 5 files changed, 961 insertions(+)
 create mode 100644 drivers/iio/accel/bma400.h
 create mode 100644 drivers/iio/accel/bma400_core.c
 create mode 100644 drivers/iio/accel/bma400_i2c.c

diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index 9b9656ce37e6..a1081b902d16 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -112,6 +112,24 @@ config BMA220
  To compile this driver as a module, choose M here: the
  module will be called bma220_spi.
 
+config BMA400
+   tristate "Bosch BMA400 3-Axis Accelerometer Driver"
+   depends on I2C
+   select REGMAP
+   select BMA400_I2C if (I2C)
+   help
+ Say Y here if you want to build a driver for the Bosch BMA400
+ triaxial acceleration sensor.
+
+ To compile this driver as a module, choose M here: the
+ module will be called bma400_core and you will also get
+ bma400_i2c for I2C.
+
+config BMA400_I2C
+   tristate
+   depends on BMA400
+   select REGMAP_I2C
+
 config BMC150_ACCEL
tristate "Bosch BMC150 Accelerometer Driver"
select IIO_BUFFER
diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
index 56bd0215e0d4..3a051cf37f40 100644
--- a/drivers/iio/accel/Makefile
+++ b/drivers/iio/accel/Makefile
@@ -14,6 +14,8 @@ obj-$(CONFIG_ADXL372_I2C) += adxl372_i2c.o
 obj-$(CONFIG_ADXL372_SPI) += adxl372_spi.o
 obj-$(CONFIG_BMA180) += bma180.o
 obj-$(CONFIG_BMA220) += bma220_spi.o
+obj-$(CONFIG_BMA400) += bma400_core.o
+obj-$(CONFIG_BMA400_I2C) += bma400_i2c.o
 obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel-core.o
 obj-$(CONFIG_BMC150_ACCEL_I2C) += bmc150-accel-i2c.o
 obj-$(CONFIG_BMC150_ACCEL_SPI) += bmc150-accel-spi.o
diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h
new file mode 100644
index ..3a3860220a68
--- /dev/null
+++ b/drivers/iio/accel/bma400.h
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * bma400.h - Register constants and other forward declarations
+ *needed by the bma400 sources.
+ *
+ * Copyright 2019 Dan Robertson 
+ */
+
+#ifndef _BMA400_H_
+#define _BMA400_H_
+
+#include 
+
+/*
+ * Read-Only Registers
+ */
+
+/* Status and ID registers */
+#define BMA400_CHIP_ID_REG  0x00
+#define BMA400_ERR_REG  0x02
+#define BMA400_STATUS_REG   0x03
+
+/* Acceleration registers */
+#define BMA400_X_AXIS_LSB_REG   0x04
+#define BMA400_X_AXIS_MSB_REG   0x05
+#define BMA400_Y_AXIS_LSB_REG   0x06
+#define BMA400_Y_AXIS_MSB_REG   0x07
+#define BMA400_Z_AXIS_LSB_REG   0x08
+#define BMA400_Z_AXIS_MSB_REG   0x09
+
+/* Sensor time registers */
+#define BMA400_SENSOR_TIME0 0x0a
+#define BMA400_SENSOR_TIME1 0x0b
+#define BMA400_SENSOR_TIME2 0x0c
+
+/* Event and interrupt registers */
+#define BMA400_EVENT_REG0x0d
+#define BMA400_INT_STAT0_REG0x0e
+#define BMA400_INT_STAT1_REG0x0f
+#define BMA400_INT_STAT2_REG0x10
+
+/* Temperature register */
+#define BMA400_TEMP_DATA_REG0x11
+
+/* FIFO length and data registers */
+#define BMA400_FIFO_LENGTH0_REG 0x12
+#define BMA400_FIFO_LENGTH1_REG 0x13
+#define BMA400_FIFO_DATA_REG0x14
+
+/* Step count registers */
+#define BMA400_STEP_CNT0_REG0x15
+#define BMA400_STEP_CNT1_REG0x16
+#define BMA400_STEP_CNT3_REG0x17
+#define BMA400_STEP_STAT_REG0x18
+
+/*
+ * Read-write configuration registers
+ */
+#define BMA400_ACC_CONFIG0_REG  0x19
+#define BMA400_ACC_CONFIG1_REG  0x1a
+#define BMA400_ACC_CONFIG2_REG  0x1b
+#define BMA400_CMD_REG  0x7e
+
+/* Chip ID of BMA 400 devices found in the chip ID register. */
+#define BMA400_ID_REG_VAL   0x90
+
+#define BMA400_TWO_BITS_MASK0x03
+#define BMA400_LP_OSR_MASK  0x60
+#define BMA400_NP_OSR_MASK  0x30
+#define BMA400_ACC_ODR_MASK 0x0f
+#define BMA400_ACC_SCALE_MASK   0xc0
+
+#define BMA400_LP_OSR_SHIFT 0x05
+#define BMA400_NP_OSR_SHIFT 0x04
+#define BMA400_SCALE_SHIFT  0x06
+
+#define BMA400_ACC_ODR_MIN  0x05
+
+extern const struct regmap_config bma400_regmap_config;
+
+int bma400_probe(struct device *dev, struct regmap *regmap, const char *name);
+
+int bma400_remove(struct device *dev);
+
+#endif
diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
new file mode 100644
index ..80f1ee6713fa
--- /dev/null
+++ b/drivers/iio/accel/bma400_core.c
@@ -0,0 +1,796 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * 

Re: [PATCH 10/15] riscv: read the hart ID from mhartid on boot

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> From: Damien Le Moal 
>
> When in M-Mode, we can use the mhartid CSR to get the ID of the running
> HART. Doing so, direct M-Mode boot without firmware is possible.
>
> Signed-off-by: Damien Le Moal 
> Signed-off-by: Christoph Hellwig 
> Reviewed-by: Atish Patra 
> ---
>  arch/riscv/include/asm/csr.h | 1 +
>  arch/riscv/kernel/head.S | 8 
>  2 files changed, 9 insertions(+)
>
> diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h
> index 0dae5c361f29..d0b5113e1a54 100644
> --- a/arch/riscv/include/asm/csr.h
> +++ b/arch/riscv/include/asm/csr.h
> @@ -81,6 +81,7 @@
>  #define SIE_SEIE   (_AC(0x1, UL) << IRQ_S_EXT)
>
>  /* symbolic CSR names: */
> +#define CSR_MHARTID0xf14
>  #define CSR_MSTATUS0x300
>  #define CSR_MIE0x304
>  #define CSR_MTVEC  0x305
> diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
> index 679e63d29edb..583784cb3a32 100644
> --- a/arch/riscv/kernel/head.S
> +++ b/arch/riscv/kernel/head.S
> @@ -50,6 +50,14 @@ _start_kernel:
> csrw CSR_XIE, zero
> csrw CSR_XIP, zero
>
> +#ifdef CONFIG_RISCV_M_MODE
> +   /*
> +* The hartid in a0 is expected later on, and we have no firmware
> +* to hand it to us.
> +*/
> +   csrr a0, CSR_MHARTID
> +#endif
> +
> /* Load the global pointer */
>  .option push
>  .option norelax
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


[PATCH v3 0/2] iio: add driver for Bosch BMA400 accelerometer

2019-10-17 Thread Dan Robertson
This patchset adds a IIO driver for the Bosch BMA400 3-axes ultra low-power
accelerometer. The initial implementation of the driver adds read support for
the acceleration and temperature data registers. The driver also has support
for reading and writing to the output data rate, oversampling ratio, and scale
configuration registers.

I've ran some basic tests with libiio and I've run the device tree checks. Are
there other tests that are recommended to be run for a new device?

Thanks again for the reviews!

Cheers,

 - Dan


Changes in v4:

 * Fix error in DT bindings
 * Fix typo when setting the OSR
 * Simplified the cached sample frequency
 * Fix the MODULE_LICENSE

Changes in v3:

 * Use yaml format for DT bindings
 * Remove strict dependency on OF
 * Tidy Kconfig dependencies
 * Stylistic changes
 * Do not soft-reset device on remove

Changes in v2:

 * Implemented iio_info -> read_avail
 * Stylistic changes
 * Implemented devicetree bindings


Dan Robertson (2):
  dt-bindings: iio: accel: bma400: add bindings
  iio: (bma400) add driver for the BMA400

 .../devicetree/bindings/iio/accel/bma400.yaml |  39 +
 drivers/iio/accel/Kconfig |  18 +
 drivers/iio/accel/Makefile|   2 +
 drivers/iio/accel/bma400.h|  85 ++
 drivers/iio/accel/bma400_core.c   | 796 ++
 drivers/iio/accel/bma400_i2c.c|  60 ++
 6 files changed, 1000 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/accel/bma400.yaml
 create mode 100644 drivers/iio/accel/bma400.h
 create mode 100644 drivers/iio/accel/bma400_core.c
 create mode 100644 drivers/iio/accel/bma400_i2c.c





Re: [PATCH 3/8] riscv: init: merge split string literals in preprocessor directive

2019-10-17 Thread Luc Van Oostenryck
On Thu, Oct 17, 2019 at 09:38:18PM -0700, Paul Walmsley wrote:
> On Fri, 18 Oct 2019, Luc Van Oostenryck wrote:
> 
> > On Thu, Oct 17, 2019 at 05:49:24PM -0700, Paul Walmsley wrote:
> > > sparse complains loudly when string literals associated with
> > > preprocessor directives are split into multiple, separately quoted
> > > strings across different lines:
> > 
> > ...
> >  
> > >  #ifndef __riscv_cmodel_medany
> > > -#error "setup_vm() is called from head.S before relocate so it should "
> > > - "not use absolute addressing."
> > > +#error "setup_vm() is called from head.S before relocate so it should 
> > > not use absolute addressing."
> > >  #endif
> > 
> > Using a blacslash should do the trick :
> > #error "blablablablablablablablablablablabla" \
> > "and blablabla again"
> > Or if need I cn fix Sparse if needed and desiable.
> 
> Thanks for the kind offer!
> 
> The backslashless syntax is pretty horrible to my eyes.  As far as I can 
> tell from a brief glance, the instance fixed by this patch was the only 
> instance of its kind in the kernel.  The existing kernel precedents appear 
> to be to simply use a single long line.  Example:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/compiler-gcc.h#n3
> 
> So, from a kernel point of view, we should just fix this specific 
> instance.  It doesn't seem worth changing sparse for such a rare case.
> 
> On the other hand, gcc seems to support the non-backslashed syntax.  So if 
> the intention is for sparse to follow the gcc practice, and to be used 
> beyond the kernel, maybe it's worth aligning sparse to gcc?  Only if 
> you're bored, I suppose...

I'll first see what is acceptable for the point of view of the standard
(and maybe some justifications from GCC).

-- Luc 


Re: [PATCH 04/15] riscv: don't allow selecting SBI based drivers for M-mode

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:07 PM Christoph Hellwig  wrote:
>
> From: Damien Le Moal 
>
> When running in M-mode we can't use SBI based drivers.  Add a new
> CONFIG_RISCV_SBI that drivers that do SBI calls can depend on
> instead.
>
> Signed-off-by: Damien Le Moal 
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/Kconfig | 6 ++
>  drivers/tty/hvc/Kconfig| 2 +-
>  drivers/tty/serial/Kconfig | 2 +-
>  3 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 86b7e8b0471c..b85492c42ccb 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -76,6 +76,12 @@ config ARCH_MMAP_RND_BITS_MAX
>  config RISCV_M_MODE
> bool
>
> +# set if we are running in S-mode and can use SBI calls
> +config RISCV_SBI
> +   bool
> +   depends on !RISCV_M_MODE
> +   default y
> +
>  config MMU
> def_bool y
>
> diff --git a/drivers/tty/hvc/Kconfig b/drivers/tty/hvc/Kconfig
> index 4d22b91f..4487a6b9acc8 100644
> --- a/drivers/tty/hvc/Kconfig
> +++ b/drivers/tty/hvc/Kconfig
> @@ -89,7 +89,7 @@ config HVC_DCC
>
>  config HVC_RISCV_SBI
> bool "RISC-V SBI console support"
> -   depends on RISCV
> +   depends on RISCV_SBI
> select HVC_DRIVER
> help
>   This enables support for console output via RISC-V SBI calls, which
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index 67a9eb3f94ce..540142c5b7b3 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -88,7 +88,7 @@ config SERIAL_EARLYCON_ARM_SEMIHOST
>
>  config SERIAL_EARLYCON_RISCV_SBI
> bool "Early console using RISC-V SBI"
> -   depends on RISCV
> +   depends on RISCV_SBI
> select SERIAL_CORE
> select SERIAL_CORE_CONSOLE
> select SERIAL_EARLYCON
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH 06/15] riscv: cleanup the default power off implementation

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> Move the sbi poweroff to a separate function and file that is only
> compiled if CONFIG_SBI is set.  Provide a new default fallback
> power off that just sits in a wfi loop to save some power.
>
> Signed-off-by: Christoph Hellwig 
> Reviewed-by: Atish Patra 
> ---
>  arch/riscv/kernel/Makefile |  1 +
>  arch/riscv/kernel/reset.c  |  5 ++---
>  arch/riscv/kernel/sbi.c| 17 +
>  3 files changed, 20 insertions(+), 3 deletions(-)
>  create mode 100644 arch/riscv/kernel/sbi.c
>
> diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
> index 696020ff72db..d8c35fa93cc6 100644
> --- a/arch/riscv/kernel/Makefile
> +++ b/arch/riscv/kernel/Makefile
> @@ -41,5 +41,6 @@ obj-$(CONFIG_DYNAMIC_FTRACE)  += mcount-dyn.o
>  obj-$(CONFIG_PERF_EVENTS)  += perf_event.o
>  obj-$(CONFIG_PERF_EVENTS)  += perf_callchain.o
>  obj-$(CONFIG_HAVE_PERF_REGS)   += perf_regs.o
> +obj-$(CONFIG_RISCV_SBI)+= sbi.o
>
>  clean:
> diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
> index d0fe623bfb8f..5e4e69859af1 100644
> --- a/arch/riscv/kernel/reset.c
> +++ b/arch/riscv/kernel/reset.c
> @@ -4,12 +4,11 @@
>   */
>
>  #include 
> -#include 
>
>  static void default_power_off(void)
>  {
> -   sbi_shutdown();
> -   while (1);
> +   while (1)
> +   wait_for_interrupt();
>  }
>
>  void (*pm_power_off)(void) = default_power_off;
> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
> new file mode 100644
> index ..f6c7c3e82d28
> --- /dev/null
> +++ b/arch/riscv/kernel/sbi.c
> @@ -0,0 +1,17 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include 
> +#include 
> +#include 
> +
> +static void sbi_power_off(void)
> +{
> +   sbi_shutdown();
> +}
> +
> +static int __init sbi_init(void)
> +{
> +   pm_power_off = sbi_power_off;
> +   return 0;
> +}
> +early_initcall(sbi_init);
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH 4/8] riscv: ensure RISC-V C model definitions are passed to static analyzers

2019-10-17 Thread Luc Van Oostenryck
On Thu, Oct 17, 2019 at 09:39:29PM -0700, Paul Walmsley wrote:
> On Fri, 18 Oct 2019, Luc Van Oostenryck wrote:
> > On Thu, Oct 17, 2019 at 05:49:25PM -0700, Paul Walmsley wrote:

> > >  ifeq ($(CONFIG_CMODEL_MEDANY),y)
> > >   KBUILD_CFLAGS += -mcmodel=medany
> > > + CHECKFLAGS += -D__riscv_cmodel_medany
> > 
> > I can teach sparse about this in the following days.
> 
> That would be great.  Would you be willing to follow up with me via E-mail 
> or mailing list post when it's fixed?  If so, then in the meantime, I'll 
> just drop this patch.

For sure.
-- Luc


[PATCH v12 0/5] DMA-BUF Heaps (destaging ION)

2019-10-17 Thread John Stultz
Andrew brought up a reasonable concern with the CMA heap
enumeration in the previous patch set, and I had a few other
minor cleanups to add, so here is yet another pass at the
dma-buf heaps patchset Andrew and I have been working on which
tries to destage a fair chunk of ION functionality.

The patchset implements per-heap devices which can be opened
directly and then an ioctl is used to allocate a dmabuf from the
heap.

The interface is similar, but much simpler then IONs, only
providing an ALLOC ioctl.

Also, I've provided relatively simple system and cma heaps.

I've booted and tested these patches with AOSP on the HiKey960
using the kernel tree here:
  
https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/dma-buf-heap

And the userspace changes here:
  https://android-review.googlesource.com/c/device/linaro/hikey/+/909436

Compared to ION, this patchset is missing the system-contig,
carveout and chunk heaps, as I don't have a device that uses
those, so I'm unable to do much useful validation there.
Additionally we have no upstream users of chunk or carveout,
and the system-contig has been deprecated in the common/andoid-*
kernels, so this should be ok.

I've also removed the stats accounting, since any such
accounting should be implemented by dma-buf core or the heaps
themselves.

New in v12:
* To address Andrew's concern about adding all CMA areas, the
  CMA heap only adds the default CMA region for now.
* Minor cleanups and prep for loading heaps from modules
* I have patches to add other specified CMA regions, as well as
  loading heaps from modules in my WIP tree, which I will submit
  once this set is queued, here:

https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/dma-buf-heap-WIP

thanks
-john

Cc: Laura Abbott 
Cc: Benjamin Gaignard 
Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Pratik Patel 
Cc: Brian Starkey 
Cc: Vincent Donnefort 
Cc: Sudipto Paul 
Cc: Andrew F. Davis 
Cc: Christoph Hellwig 
Cc: Chenbo Feng 
Cc: Alistair Strachan 
Cc: Hridya Valsaraju 
Cc: Hillf Danton 
Cc: dri-de...@lists.freedesktop.org

Andrew F. Davis (1):
  dma-buf: Add dma-buf heaps framework

John Stultz (4):
  dma-buf: heaps: Add heap helpers
  dma-buf: heaps: Add system heap to dmabuf heaps
  dma-buf: heaps: Add CMA heap to dmabuf heaps
  kselftests: Add dma-heap test

 MAINTAINERS   |  18 ++
 drivers/dma-buf/Kconfig   |  11 +
 drivers/dma-buf/Makefile  |   2 +
 drivers/dma-buf/dma-heap.c| 271 ++
 drivers/dma-buf/heaps/Kconfig |  14 +
 drivers/dma-buf/heaps/Makefile|   4 +
 drivers/dma-buf/heaps/cma_heap.c  | 178 
 drivers/dma-buf/heaps/heap-helpers.c  | 270 +
 drivers/dma-buf/heaps/heap-helpers.h  |  55 
 drivers/dma-buf/heaps/system_heap.c   | 124 
 include/linux/dma-heap.h  |  59 
 include/uapi/linux/dma-heap.h |  55 
 tools/testing/selftests/dmabuf-heaps/Makefile |   9 +
 .../selftests/dmabuf-heaps/dmabuf-heap.c  | 238 +++
 14 files changed, 1308 insertions(+)
 create mode 100644 drivers/dma-buf/dma-heap.c
 create mode 100644 drivers/dma-buf/heaps/Kconfig
 create mode 100644 drivers/dma-buf/heaps/Makefile
 create mode 100644 drivers/dma-buf/heaps/cma_heap.c
 create mode 100644 drivers/dma-buf/heaps/heap-helpers.c
 create mode 100644 drivers/dma-buf/heaps/heap-helpers.h
 create mode 100644 drivers/dma-buf/heaps/system_heap.c
 create mode 100644 include/linux/dma-heap.h
 create mode 100644 include/uapi/linux/dma-heap.h
 create mode 100644 tools/testing/selftests/dmabuf-heaps/Makefile
 create mode 100644 tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c

-- 
2.17.1



[PATCH v12 2/5] dma-buf: heaps: Add heap helpers

2019-10-17 Thread John Stultz
Add generic helper dmabuf ops for dma heaps, so we can reduce
the amount of duplicative code for the exported dmabufs.

This code is an evolution of the Android ION implementation, so
thanks to its original authors and maintainters:
  Rebecca Schultz Zavin, Colin Cross, Laura Abbott, and others!

Cc: Laura Abbott 
Cc: Benjamin Gaignard 
Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Pratik Patel 
Cc: Brian Starkey 
Cc: Vincent Donnefort 
Cc: Sudipto Paul 
Cc: Andrew F. Davis 
Cc: Christoph Hellwig 
Cc: Chenbo Feng 
Cc: Alistair Strachan 
Cc: Hridya Valsaraju 
Cc: Hillf Danton 
Cc: dri-de...@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard 
Reviewed-by: Brian Starkey 
Acked-by: Laura Abbott 
Tested-by: Ayan Kumar Halder 
Signed-off-by: John Stultz 
---
v2:
* Removed cache management performance hack that I had
  accidentally folded in.
* Removed stats code that was in helpers
* Lots of checkpatch cleanups
v3:
* Uninline INIT_HEAP_HELPER_BUFFER (suggested by Christoph)
* Switch to WARN on buffer destroy failure (suggested by Brian)
* buffer->kmap_cnt decrementing cleanup (suggested by Christoph)
* Extra buffer->vaddr checking in dma_heap_dma_buf_kmap
  (suggested by Brian)
* Switch to_helper_buffer from macro to inline function
  (suggested by Benjamin)
* Rename kmap->vmap (folded in from Andrew)
* Use vmap for vmapping - not begin_cpu_access (folded in from
  Andrew)
* Drop kmap for now, as its optional (folded in from Andrew)
* Fold dma_heap_map_user into the single caller (foled in from
  Andrew)
* Folded in patch from Andrew to track page list per heap not
  sglist, which simplifies the tracking logic
v4:
* Moved dma-heap.h change out to previous patch
v6:
* Minor cleanups and typo fixes suggested by Brian
v7:
* Removed stray ;
* Make init_heap_helper_buffer lowercase, as suggested by Christoph
* Add dmabuf export helper to reduce boilerplate code
v8:
* Remove unused private_flags value
* Condense dma_heap_buffer and heap_helper_buffer (suggested by
  Christoph)
* Fix indentation by using shorter argument names (suggested by
  Christoph)
* Add flush_kernel_vmap_range/invalidate_kernel_vmap_range calls
  (suggested by Christoph)
* Checkpatch whitespace fixups
v9:
* Minor cleanups suggested by Brian Starkey
v10:
* Fix missing vmalloc.h inclusion in heap helpers (found by
  kbuild test robot )
v12:
* Add symbol exports for heaps as modules
---
 drivers/dma-buf/Makefile |   1 +
 drivers/dma-buf/heaps/Makefile   |   2 +
 drivers/dma-buf/heaps/heap-helpers.c | 270 +++
 drivers/dma-buf/heaps/heap-helpers.h |  55 ++
 4 files changed, 328 insertions(+)
 create mode 100644 drivers/dma-buf/heaps/Makefile
 create mode 100644 drivers/dma-buf/heaps/heap-helpers.c
 create mode 100644 drivers/dma-buf/heaps/heap-helpers.h

diff --git a/drivers/dma-buf/Makefile b/drivers/dma-buf/Makefile
index caee5eb3d351..9c190026bfab 100644
--- a/drivers/dma-buf/Makefile
+++ b/drivers/dma-buf/Makefile
@@ -2,6 +2,7 @@
 obj-y := dma-buf.o dma-fence.o dma-fence-array.o dma-fence-chain.o \
 dma-resv.o seqno-fence.o
 obj-$(CONFIG_DMABUF_HEAPS) += dma-heap.o
+obj-$(CONFIG_DMABUF_HEAPS) += heaps/
 obj-$(CONFIG_SYNC_FILE)+= sync_file.o
 obj-$(CONFIG_SW_SYNC)  += sw_sync.o sync_debug.o
 obj-$(CONFIG_UDMABUF)  += udmabuf.o
diff --git a/drivers/dma-buf/heaps/Makefile b/drivers/dma-buf/heaps/Makefile
new file mode 100644
index ..de49898112db
--- /dev/null
+++ b/drivers/dma-buf/heaps/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-y  += heap-helpers.o
diff --git a/drivers/dma-buf/heaps/heap-helpers.c 
b/drivers/dma-buf/heaps/heap-helpers.c
new file mode 100644
index ..fb9835126893
--- /dev/null
+++ b/drivers/dma-buf/heaps/heap-helpers.c
@@ -0,0 +1,270 @@
+// SPDX-License-Identifier: GPL-2.0
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "heap-helpers.h"
+
+void init_heap_helper_buffer(struct heap_helper_buffer *buffer,
+void (*free)(struct heap_helper_buffer *))
+{
+   buffer->priv_virt = NULL;
+   mutex_init(>lock);
+   buffer->vmap_cnt = 0;
+   buffer->vaddr = NULL;
+   buffer->pagecount = 0;
+   buffer->pages = NULL;
+   INIT_LIST_HEAD(>attachments);
+   buffer->free = free;
+}
+EXPORT_SYMBOL_GPL(init_heap_helper_buffer);
+
+struct dma_buf *heap_helper_export_dmabuf(struct heap_helper_buffer *buffer,
+ int fd_flags)
+{
+   DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
+
+   exp_info.ops = _helper_ops;
+   exp_info.size = buffer->size;
+   exp_info.flags = fd_flags;
+   exp_info.priv = buffer;
+
+   return dma_buf_export(_info);
+}
+EXPORT_SYMBOL_GPL(heap_helper_export_dmabuf);
+
+static void *dma_heap_map_kernel(struct heap_helper_buffer *buffer)
+{
+   void *vaddr;
+
+   vaddr = 

[PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage

2019-10-17 Thread Bjorn Andersson
Since the introduction of '5451781dadf8 ("regulator: core: Only count
load for enabled consumers")' in v5.0, the requested load of a regulator
consumer is only accounted for when said consumer is voted enabled.

So there's no need to vote for load ever time the regulator is
enabled or disabled.

Signed-off-by: Bjorn Andersson 
---
 drivers/bluetooth/hci_qca.c | 33 ++---
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index e3164c200eac..c07c529b0d81 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1393,13 +1393,6 @@ static int qca_enable_regulator(struct qca_vreg vregs,
if (ret)
return ret;
 
-   if (vregs.load_uA)
-   ret = regulator_set_load(regulator,
-vregs.load_uA);
-
-   if (ret)
-   return ret;
-
return regulator_enable(regulator);
 
 }
@@ -1409,8 +1402,6 @@ static void qca_disable_regulator(struct qca_vreg vregs,
 {
regulator_disable(regulator);
regulator_set_voltage(regulator, 0, vregs.max_uV);
-   if (vregs.load_uA)
-   regulator_set_load(regulator, 0);
 
 }
 
@@ -1462,18 +1453,30 @@ static int qca_power_setup(struct hci_uart *hu, bool on)
 static int qca_init_regulators(struct qca_power *qca,
const struct qca_vreg *vregs, size_t num_vregs)
 {
+   struct regulator_bulk_data *bulk;
+   int ret;
int i;
 
-   qca->vreg_bulk = devm_kcalloc(qca->dev, num_vregs,
- sizeof(struct regulator_bulk_data),
- GFP_KERNEL);
-   if (!qca->vreg_bulk)
+   bulk = devm_kcalloc(qca->dev, num_vregs, sizeof(*bulk), GFP_KERNEL);
+   if (!bulk)
return -ENOMEM;
 
for (i = 0; i < num_vregs; i++)
-   qca->vreg_bulk[i].supply = vregs[i].name;
+   bulk[i].supply = vregs[i].name;
+
+   ret = devm_regulator_bulk_get(qca->dev, num_vregs, bulk);
+   if (ret < 0)
+   return ret;
 
-   return devm_regulator_bulk_get(qca->dev, num_vregs, qca->vreg_bulk);
+   for (i = 0; i < num_vregs; i++) {
+   ret = regulator_set_load(bulk[i].consumer, vregs[i].load_uA);
+   if (ret)
+   return ret;
+   }
+
+   qca->vreg_bulk = bulk;
+
+   return 0;
 }
 
 static int qca_serdev_probe(struct serdev_device *serdev)
-- 
2.23.0



[PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup()

2019-10-17 Thread Bjorn Andersson
Split and rename qca_power_setup() in order to simplify each code path
and to clarify that it is unrelated to qca_power_off() and
qca_power_setup().

Signed-off-by: Bjorn Andersson 
---
 drivers/bluetooth/hci_qca.c | 61 ++---
 1 file changed, 36 insertions(+), 25 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 01f941e9adf3..c591a8ba9d93 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -160,7 +160,8 @@ struct qca_serdev {
const char *firmware_name;
 };
 
-static int qca_power_setup(struct hci_uart *hu, bool on);
+static int qca_regulator_enable(struct qca_serdev *qcadev);
+static void qca_regulator_disable(struct qca_serdev *qcadev);
 static void qca_power_shutdown(struct hci_uart *hu);
 static int qca_power_off(struct hci_dev *hdev);
 
@@ -516,7 +517,7 @@ static int qca_open(struct hci_uart *hu)
} else {
hu->init_speed = qcadev->init_speed;
hu->oper_speed = qcadev->oper_speed;
-   ret = qca_power_setup(hu, true);
+   ret = qca_regulator_enable(qcadev);
if (ret) {
destroy_workqueue(qca->workqueue);
kfree_skb(qca->rx_skb);
@@ -1186,7 +1187,7 @@ static int qca_wcn3990_init(struct hci_uart *hu)
qcadev = serdev_device_get_drvdata(hu->serdev);
if (!qcadev->bt_power->vregs_on) {
serdev_device_close(hu->serdev);
-   ret = qca_power_setup(hu, true);
+   ret = qca_regulator_enable(qcadev);
if (ret)
return ret;
 
@@ -1351,9 +1352,12 @@ static const struct qca_vreg_data qca_soc_data_wcn3998 = 
{
 
 static void qca_power_shutdown(struct hci_uart *hu)
 {
+   struct qca_serdev *qcadev;
struct qca_data *qca = hu->priv;
unsigned long flags;
 
+   qcadev = serdev_device_get_drvdata(hu->serdev);
+
/* From this point we go into power off state. But serial port is
 * still open, stop queueing the IBS data and flush all the buffered
 * data in skb's.
@@ -1365,7 +1369,7 @@ static void qca_power_shutdown(struct hci_uart *hu)
 
host_set_baudrate(hu, 2400);
qca_send_power_pulse(hu, false);
-   qca_power_setup(hu, false);
+   qca_regulator_disable(qcadev);
 }
 
 static int qca_power_off(struct hci_dev *hdev)
@@ -1381,36 +1385,43 @@ static int qca_power_off(struct hci_dev *hdev)
return 0;
 }
 
-static int qca_power_setup(struct hci_uart *hu, bool on)
+static int qca_regulator_enable(struct qca_serdev *qcadev)
 {
-   struct regulator_bulk_data *vreg_bulk;
-   struct qca_serdev *qcadev;
-   int num_vregs;
-   int ret = 0;
+   struct qca_power *power = qcadev->bt_power;
+   int ret;
 
-   qcadev = serdev_device_get_drvdata(hu->serdev);
-   if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_bulk)
-   return -EINVAL;
+   /* Already enabled */
+   if (power->vregs_on)
+   return 0;
 
-   vreg_bulk = qcadev->bt_power->vreg_bulk;
-   num_vregs = qcadev->bt_power->num_vregs;
-   BT_DBG("on: %d (%d regulators)", on, num_vregs);
-   if (on && !qcadev->bt_power->vregs_on) {
-   ret = regulator_bulk_enable(num_vregs, vreg_bulk);
-   if (ret)
-   return ret;
+   BT_DBG("enabling %d regulators)", power->num_vregs);
 
-   qcadev->bt_power->vregs_on = true;
-   } else if (!on && qcadev->bt_power->vregs_on) {
-   /* turn off regulator in reverse order */
-   regulator_bulk_disable(num_vregs, vreg_bulk);
+   ret = regulator_bulk_enable(power->num_vregs, power->vreg_bulk);
+   if (ret)
+   return ret;
 
-   qcadev->bt_power->vregs_on = false;
-   }
+   power->vregs_on = true;
 
return 0;
 }
 
+static void qca_regulator_disable(struct qca_serdev *qcadev)
+{
+   struct qca_power *power;
+
+   if (!qcadev)
+   return;
+
+   power = qcadev->bt_power;
+
+   /* Already disabled? */
+   if (!power->vregs_on)
+   return;
+
+   regulator_bulk_disable(power->num_vregs, power->vreg_bulk);
+   power->vregs_on = false;
+}
+
 static int qca_init_regulators(struct qca_power *qca,
const struct qca_vreg *vregs, size_t num_vregs)
 {
-- 
2.23.0



[PATCH v12 4/5] dma-buf: heaps: Add CMA heap to dmabuf heaps

2019-10-17 Thread John Stultz
This adds a CMA heap, which allows userspace to allocate
a dma-buf of contiguous memory out of a CMA region.

This code is an evolution of the Android ION implementation, so
thanks to its original author and maintainters:
  Benjamin Gaignard, Laura Abbott, and others!

NOTE: This patch only adds the default CMA heap. We will enable
selectively adding other CMA memory regions to the dmabuf heaps
interface with a later patch (which requires a dt binding)

Cc: Laura Abbott 
Cc: Benjamin Gaignard 
Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Pratik Patel 
Cc: Brian Starkey 
Cc: Vincent Donnefort 
Cc: Sudipto Paul 
Cc: Andrew F. Davis 
Cc: Christoph Hellwig 
Cc: Chenbo Feng 
Cc: Alistair Strachan 
Cc: Hridya Valsaraju 
Cc: Hillf Danton 
Cc: dri-de...@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard 
Reviewed-by: Brian Starkey 
Acked-by: Laura Abbott 
Tested-by: Ayan Kumar Halder 
Signed-off-by: John Stultz 
---
v2:
* Switch allocate to return dmabuf fd
* Simplify init code
* Checkpatch fixups
v3:
* Switch to inline function for to_cma_heap()
* Minor cleanups suggested by Brian
* Fold in new registration style from Andrew
* Folded in changes from Andrew to use simplified page list
  from the heap helpers
v4:
* Use the fd_flags when creating dmabuf fd (Suggested by
  Benjamin)
* Use precalculated pagecount (Suggested by Andrew)
v6:
* Changed variable names to improve clarity, as suggested
  by Brian
v7:
* Use newly lower-cased init_heap_helper_buffer helper
* Use new dmabuf export helper
v8:
* Make struct dma_heap_ops const (Suggested by Christoph)
* Condense dma_heap_buffer and heap_helper_buffer (suggested by
  Christoph)
* Checkpatch whitespace fixups
v9:
* Removing needless check noted by Brian Starkey
* Rename dma_heap_get_data->dma_heap_get_drvdata suggested
  by Hilf Danton
* Check signals after clearing memory pages to avoid doing
  needless work if the task is killed as suggested by Hilf
v12:
* Rework to only add the default CMA heap
---
 drivers/dma-buf/heaps/Kconfig|   8 ++
 drivers/dma-buf/heaps/Makefile   |   1 +
 drivers/dma-buf/heaps/cma_heap.c | 178 +++
 3 files changed, 187 insertions(+)
 create mode 100644 drivers/dma-buf/heaps/cma_heap.c

diff --git a/drivers/dma-buf/heaps/Kconfig b/drivers/dma-buf/heaps/Kconfig
index 205052744169..a5eef06c4226 100644
--- a/drivers/dma-buf/heaps/Kconfig
+++ b/drivers/dma-buf/heaps/Kconfig
@@ -4,3 +4,11 @@ config DMABUF_HEAPS_SYSTEM
help
  Choose this option to enable the system dmabuf heap. The system heap
  is backed by pages from the buddy allocator. If in doubt, say Y.
+
+config DMABUF_HEAPS_CMA
+   bool "DMA-BUF CMA Heap"
+   depends on DMABUF_HEAPS && DMA_CMA
+   help
+ Choose this option to enable dma-buf CMA heap. This heap is backed
+ by the Contiguous Memory Allocator (CMA). If your system has these
+ regions, you should say Y here.
diff --git a/drivers/dma-buf/heaps/Makefile b/drivers/dma-buf/heaps/Makefile
index d1808eca2581..6e54cdec3da0 100644
--- a/drivers/dma-buf/heaps/Makefile
+++ b/drivers/dma-buf/heaps/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-y  += heap-helpers.o
 obj-$(CONFIG_DMABUF_HEAPS_SYSTEM)  += system_heap.o
+obj-$(CONFIG_DMABUF_HEAPS_CMA) += cma_heap.o
diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
new file mode 100644
index ..064926b5d735
--- /dev/null
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -0,0 +1,178 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * DMABUF CMA heap exporter
+ *
+ * Copyright (C) 2012, 2019 Linaro Ltd.
+ * Author:  for ST-Ericsson.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "heap-helpers.h"
+
+struct cma_heap {
+   struct dma_heap *heap;
+   struct cma *cma;
+};
+
+static void cma_heap_free(struct heap_helper_buffer *buffer)
+{
+   struct cma_heap *cma_heap = dma_heap_get_drvdata(buffer->heap);
+   unsigned long nr_pages = buffer->pagecount;
+   struct page *cma_pages = buffer->priv_virt;
+
+   /* free page list */
+   kfree(buffer->pages);
+   /* release memory */
+   cma_release(cma_heap->cma, cma_pages, nr_pages);
+   kfree(buffer);
+}
+
+/* dmabuf heap CMA operations functions */
+static int cma_heap_allocate(struct dma_heap *heap,
+unsigned long len,
+unsigned long fd_flags,
+unsigned long heap_flags)
+{
+   struct cma_heap *cma_heap = dma_heap_get_drvdata(heap);
+   struct heap_helper_buffer *helper_buffer;
+   struct page *cma_pages;
+   size_t size = PAGE_ALIGN(len);
+   unsigned long nr_pages = size >> PAGE_SHIFT;
+   unsigned long align = get_order(size);
+   struct dma_buf *dmabuf;
+   int ret = -ENOMEM;
+   pgoff_t pg;
+
+   if (align > 

[PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup

2019-10-17 Thread Bjorn Andersson
Clean up the regulator usage in hci_qca and in particular don't
regulator_set_voltage() for fixed voltages. It cleans up the driver, but more
important it makes bluetooth work on my Lenovo Yoga C630, where the regulator
for vddch0 is defined with a voltage range that doesn't overlap the values in
the driver.

Bjorn Andersson (4):
  Bluetooth: hci_qca: Update regulator_set_load() usage
  Bluetooth: hci_qca: Don't vote for specific voltage
  Bluetooth: hci_qca: Use regulator bulk enable/disable
  Bluetooth: hci_qca: Split qca_power_setup()

 drivers/bluetooth/hci_qca.c | 135 +++-
 1 file changed, 55 insertions(+), 80 deletions(-)

-- 
2.23.0



[PATCH 3/4] Bluetooth: hci_qca: Use regulator bulk enable/disable

2019-10-17 Thread Bjorn Andersson
With the regulator_set_load() and regulator_set_voltage() out of the
enable/disable code paths the code can now use the standard
regulator bulk enable/disable API.

By cloning num_vregs into struct qca_power there's no need to lug around
a reference to the struct qca_vreg_data, which further simplifies
qca_power_setup().

Signed-off-by: Bjorn Andersson 
---
 drivers/bluetooth/hci_qca.c | 55 +
 1 file changed, 13 insertions(+), 42 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 54aafcc69d06..01f941e9adf3 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -144,8 +144,8 @@ struct qca_vreg_data {
  */
 struct qca_power {
struct device *dev;
-   const struct qca_vreg_data *vreg_data;
struct regulator_bulk_data *vreg_bulk;
+   int num_vregs;
bool vregs_on;
 };
 
@@ -1381,63 +1381,34 @@ static int qca_power_off(struct hci_dev *hdev)
return 0;
 }
 
-static int qca_enable_regulator(struct qca_vreg vregs,
-   struct regulator *regulator)
-{
-   return regulator_enable(regulator);
-
-}
-
-static void qca_disable_regulator(struct qca_vreg vregs,
- struct regulator *regulator)
-{
-   regulator_disable(regulator);
-
-}
-
 static int qca_power_setup(struct hci_uart *hu, bool on)
 {
-   struct qca_vreg *vregs;
struct regulator_bulk_data *vreg_bulk;
struct qca_serdev *qcadev;
-   int i, num_vregs, ret = 0;
+   int num_vregs;
+   int ret = 0;
 
qcadev = serdev_device_get_drvdata(hu->serdev);
-   if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_data ||
-   !qcadev->bt_power->vreg_bulk)
+   if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_bulk)
return -EINVAL;
 
-   vregs = qcadev->bt_power->vreg_data->vregs;
vreg_bulk = qcadev->bt_power->vreg_bulk;
-   num_vregs = qcadev->bt_power->vreg_data->num_vregs;
-   BT_DBG("on: %d", on);
+   num_vregs = qcadev->bt_power->num_vregs;
+   BT_DBG("on: %d (%d regulators)", on, num_vregs);
if (on && !qcadev->bt_power->vregs_on) {
-   for (i = 0; i < num_vregs; i++) {
-   ret = qca_enable_regulator(vregs[i],
-  vreg_bulk[i].consumer);
-   if (ret)
-   break;
-   }
+   ret = regulator_bulk_enable(num_vregs, vreg_bulk);
+   if (ret)
+   return ret;
 
-   if (ret) {
-   BT_ERR("failed to enable regulator:%s", vregs[i].name);
-   /* turn off regulators which are enabled */
-   for (i = i - 1; i >= 0; i--)
-   qca_disable_regulator(vregs[i],
- vreg_bulk[i].consumer);
-   } else {
-   qcadev->bt_power->vregs_on = true;
-   }
+   qcadev->bt_power->vregs_on = true;
} else if (!on && qcadev->bt_power->vregs_on) {
/* turn off regulator in reverse order */
-   i = qcadev->bt_power->vreg_data->num_vregs - 1;
-   for ( ; i >= 0; i--)
-   qca_disable_regulator(vregs[i], vreg_bulk[i].consumer);
+   regulator_bulk_disable(num_vregs, vreg_bulk);
 
qcadev->bt_power->vregs_on = false;
}
 
-   return ret;
+   return 0;
 }
 
 static int qca_init_regulators(struct qca_power *qca,
@@ -1465,6 +1436,7 @@ static int qca_init_regulators(struct qca_power *qca,
}
 
qca->vreg_bulk = bulk;
+   qca->num_vregs = num_vregs;
 
return 0;
 }
@@ -1493,7 +1465,6 @@ static int qca_serdev_probe(struct serdev_device *serdev)
return -ENOMEM;
 
qcadev->bt_power->dev = >dev;
-   qcadev->bt_power->vreg_data = data;
err = qca_init_regulators(qcadev->bt_power, data->vregs,
  data->num_vregs);
if (err) {
-- 
2.23.0



[PATCH v12 3/5] dma-buf: heaps: Add system heap to dmabuf heaps

2019-10-17 Thread John Stultz
This patch adds system heap to the dma-buf heaps framework.

This allows applications to get a page-allocator backed dma-buf
for non-contiguous memory.

This code is an evolution of the Android ION implementation, so
thanks to its original authors and maintainters:
  Rebecca Schultz Zavin, Colin Cross, Laura Abbott, and others!

Cc: Laura Abbott 
Cc: Benjamin Gaignard 
Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Pratik Patel 
Cc: Brian Starkey 
Cc: Vincent Donnefort 
Cc: Sudipto Paul 
Cc: Andrew F. Davis 
Cc: Christoph Hellwig 
Cc: Chenbo Feng 
Cc: Alistair Strachan 
Cc: Hridya Valsaraju 
Cc: Hillf Danton 
Cc: dri-de...@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard 
Reviewed-by: Brian Starkey 
Acked-by: Laura Abbott 
Tested-by: Ayan Kumar Halder 
Signed-off-by: John Stultz 
---
v2:
* Switch allocate to return dmabuf fd
* Simplify init code
* Checkpatch fixups
* Droped dead system-contig code
v3:
* Whitespace fixups from Benjamin
* Make sure we're zeroing the allocated pages (from Liam)
* Use PAGE_ALIGN() consistently (suggested by Brian)
* Fold in new registration style from Andrew
* Avoid needless dynamic allocation of sys_heap (suggested by
  Christoph)
* Minor cleanups
* Folded in changes from Andrew to use simplified page list
  from the heap helpers
v4:
* Optimization to allocate pages in chunks, similar to old
  pagepool code
* Use fd_flags when creating dmabuf fd (Suggested by Benjamin)
v5:
* Back out large order page allocations (was leaking memory,
  as the page array didn't properly track order size)
v6:
* Minor whitespace change suggested by Brian
* Remove unused variable
v7:
* Use newly lower-cased init_heap_helper_buffer helper
* Add system heap DOS avoidance suggested by Laura from ION code
* Use new dmabuf export helper
v8:
* Make struct dma_heap_ops consts (suggested by Christoph)
* Get rid of needless struct system_heap (suggested by Christoph)
* Condense dma_heap_buffer and heap_helper_buffer (suggested by
  Christoph)
* Add forgotten include file to fix build issue on x86
v12:
* Minor tweaks to prep loading heap from module
---
 drivers/dma-buf/Kconfig |   2 +
 drivers/dma-buf/heaps/Kconfig   |   6 ++
 drivers/dma-buf/heaps/Makefile  |   1 +
 drivers/dma-buf/heaps/system_heap.c | 124 
 4 files changed, 133 insertions(+)
 create mode 100644 drivers/dma-buf/heaps/Kconfig
 create mode 100644 drivers/dma-buf/heaps/system_heap.c

diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig
index bffa58fc3e6e..0613bb7770f5 100644
--- a/drivers/dma-buf/Kconfig
+++ b/drivers/dma-buf/Kconfig
@@ -53,4 +53,6 @@ menuconfig DMABUF_HEAPS
  allows userspace to allocate dma-bufs that can be shared
  between drivers.
 
+source "drivers/dma-buf/heaps/Kconfig"
+
 endmenu
diff --git a/drivers/dma-buf/heaps/Kconfig b/drivers/dma-buf/heaps/Kconfig
new file mode 100644
index ..205052744169
--- /dev/null
+++ b/drivers/dma-buf/heaps/Kconfig
@@ -0,0 +1,6 @@
+config DMABUF_HEAPS_SYSTEM
+   bool "DMA-BUF System Heap"
+   depends on DMABUF_HEAPS
+   help
+ Choose this option to enable the system dmabuf heap. The system heap
+ is backed by pages from the buddy allocator. If in doubt, say Y.
diff --git a/drivers/dma-buf/heaps/Makefile b/drivers/dma-buf/heaps/Makefile
index de49898112db..d1808eca2581 100644
--- a/drivers/dma-buf/heaps/Makefile
+++ b/drivers/dma-buf/heaps/Makefile
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-y  += heap-helpers.o
+obj-$(CONFIG_DMABUF_HEAPS_SYSTEM)  += system_heap.o
diff --git a/drivers/dma-buf/heaps/system_heap.c 
b/drivers/dma-buf/heaps/system_heap.c
new file mode 100644
index ..455782efbb32
--- /dev/null
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * DMABUF System heap exporter
+ *
+ * Copyright (C) 2011 Google, Inc.
+ * Copyright (C) 2019 Linaro Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "heap-helpers.h"
+
+struct dma_heap *sys_heap;
+
+static void system_heap_free(struct heap_helper_buffer *buffer)
+{
+   pgoff_t pg;
+
+   for (pg = 0; pg < buffer->pagecount; pg++)
+   __free_page(buffer->pages[pg]);
+   kfree(buffer->pages);
+   kfree(buffer);
+}
+
+static int system_heap_allocate(struct dma_heap *heap,
+   unsigned long len,
+   unsigned long fd_flags,
+   unsigned long heap_flags)
+{
+   struct heap_helper_buffer *helper_buffer;
+   struct dma_buf *dmabuf;
+   int ret = -ENOMEM;
+   pgoff_t pg;
+
+   helper_buffer = kzalloc(sizeof(*helper_buffer), GFP_KERNEL);
+   if (!helper_buffer)
+   return -ENOMEM;
+
+   init_heap_helper_buffer(helper_buffer, system_heap_free);
+   helper_buffer->flags = heap_flags;
+  

[PATCH v12 5/5] kselftests: Add dma-heap test

2019-10-17 Thread John Stultz
Add very trivial allocation and import test for dma-heaps,
utilizing the vgem driver as a test importer.

A good chunk of this code taken from:
  tools/testing/selftests/android/ion/ionmap_test.c
  Originally by Laura Abbott 

Cc: Benjamin Gaignard 
Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Pratik Patel 
Cc: Brian Starkey 
Cc: Vincent Donnefort 
Cc: Sudipto Paul 
Cc: Andrew F. Davis 
Cc: Christoph Hellwig 
Cc: Chenbo Feng 
Cc: Alistair Strachan 
Cc: Hridya Valsaraju 
Cc: Hillf Danton 
Cc: dri-de...@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard 
Reviewed-by: Brian Starkey 
Acked-by: Laura Abbott 
Tested-by: Ayan Kumar Halder 
Signed-off-by: John Stultz 
---
v2:
* Switched to use reworked dma-heap apis
v3:
* Add simple mmap
* Utilize dma-buf testdev to test importing
v4:
* Rework to use vgem
* Pass in fd_flags to match interface changes
* Skip . and .. dirs
v6:
* Number of style/cleanups suggested by Brian
v7:
* Whitespace fixup for checkpatch
v8:
* More checkpatch whitespace fixups
v9:
* Better handling error returns out to main, suggested
  by Brian Starkey
* Switch to using snprintf, suggested by Brian
---
 tools/testing/selftests/dmabuf-heaps/Makefile |   9 +
 .../selftests/dmabuf-heaps/dmabuf-heap.c  | 238 ++
 2 files changed, 247 insertions(+)
 create mode 100644 tools/testing/selftests/dmabuf-heaps/Makefile
 create mode 100644 tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c

diff --git a/tools/testing/selftests/dmabuf-heaps/Makefile 
b/tools/testing/selftests/dmabuf-heaps/Makefile
new file mode 100644
index ..8c4c36e2972d
--- /dev/null
+++ b/tools/testing/selftests/dmabuf-heaps/Makefile
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+CFLAGS += -static -O3 -Wl,-no-as-needed -Wall
+#LDLIBS += -lrt -lpthread -lm
+
+# these are all "safe" tests that don't modify
+# system time or require escalated privileges
+TEST_GEN_PROGS = dmabuf-heap
+
+include ../lib.mk
diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c 
b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
new file mode 100644
index ..b36dd9f35c19
--- /dev/null
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -0,0 +1,238 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "../../../../include/uapi/linux/dma-heap.h"
+
+#define DEVPATH "/dev/dma_heap"
+
+static int check_vgem(int fd)
+{
+   drm_version_t version = { 0 };
+   char name[5];
+   int ret;
+
+   version.name_len = 4;
+   version.name = name;
+
+   ret = ioctl(fd, DRM_IOCTL_VERSION, );
+   if (ret)
+   return 0;
+
+   return !strcmp(name, "vgem");
+}
+
+static int open_vgem(void)
+{
+   int i, fd;
+   const char *drmstr = "/dev/dri/card";
+
+   fd = -1;
+   for (i = 0; i < 16; i++) {
+   char name[80];
+
+   snprintf(name, 80, "%s%u", drmstr, i);
+
+   fd = open(name, O_RDWR);
+   if (fd < 0)
+   continue;
+
+   if (!check_vgem(fd)) {
+   close(fd);
+   fd = -1;
+   continue;
+   } else {
+   break;
+   }
+   }
+   return fd;
+}
+
+static int import_vgem_fd(int vgem_fd, int dma_buf_fd, uint32_t *handle)
+{
+   struct drm_prime_handle import_handle = {
+   .fd = dma_buf_fd,
+   .flags = 0,
+   .handle = 0,
+};
+   int ret;
+
+   ret = ioctl(vgem_fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, _handle);
+   if (ret == 0)
+   *handle = import_handle.handle;
+   return ret;
+}
+
+static void close_handle(int vgem_fd, uint32_t handle)
+{
+   struct drm_gem_close close = {
+   .handle = handle,
+   };
+
+   ioctl(vgem_fd, DRM_IOCTL_GEM_CLOSE, );
+}
+
+static int dmabuf_heap_open(char *name)
+{
+   int ret, fd;
+   char buf[256];
+
+   ret = snprintf(buf, 256, "%s/%s", DEVPATH, name);
+   if (ret < 0) {
+   printf("snprintf failed!\n");
+   return ret;
+   }
+
+   fd = open(buf, O_RDWR);
+   if (fd < 0)
+   printf("open %s failed!\n", buf);
+   return fd;
+}
+
+static int dmabuf_heap_alloc(int fd, size_t len, unsigned int flags,
+int *dmabuf_fd)
+{
+   struct dma_heap_allocation_data data = {
+   .len = len,
+   .fd_flags = O_RDWR | O_CLOEXEC,
+   .heap_flags = flags,
+   };
+   int ret;
+
+   if (!dmabuf_fd)
+   return -EINVAL;
+
+   ret = ioctl(fd, DMA_HEAP_IOC_ALLOC, );
+   if (ret < 0)
+   return ret;
+   *dmabuf_fd = (int)data.fd;
+   return ret;
+}
+
+static void dmabuf_sync(int fd, int start_stop)
+{
+   struct dma_buf_sync sync = {
+   

[PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage

2019-10-17 Thread Bjorn Andersson
Devices with specific voltage requirements should not request voltage
from the driver, but instead rely on the system configuration to define
appropriate voltages for each rail.

This ensures that PMIC and board variations are accounted for, something
that the 0.1V range in the hci_qca driver currently tries to address.
But on the Lenovo Yoga C630 (with wcn3990) vddch0 is 3.1V, which means
the driver will fail to set the voltage.

Signed-off-by: Bjorn Andersson 
---
 drivers/bluetooth/hci_qca.c | 26 --
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index c07c529b0d81..54aafcc69d06 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -130,8 +130,6 @@ enum qca_speed_type {
  */
 struct qca_vreg {
const char *name;
-   unsigned int min_uV;
-   unsigned int max_uV;
unsigned int load_uA;
 };
 
@@ -1332,10 +1330,10 @@ static const struct hci_uart_proto qca_proto = {
 static const struct qca_vreg_data qca_soc_data_wcn3990 = {
.soc_type = QCA_WCN3990,
.vregs = (struct qca_vreg []) {
-   { "vddio",   180, 190,  15000  },
-   { "vddxo",   180, 190,  8  },
-   { "vddrf",   130, 135,  30 },
-   { "vddch0",  330, 340,  45 },
+   { "vddio", 15000  },
+   { "vddxo", 8  },
+   { "vddrf", 30 },
+   { "vddch0", 45 },
},
.num_vregs = 4,
 };
@@ -1343,10 +1341,10 @@ static const struct qca_vreg_data qca_soc_data_wcn3990 
= {
 static const struct qca_vreg_data qca_soc_data_wcn3998 = {
.soc_type = QCA_WCN3998,
.vregs = (struct qca_vreg []) {
-   { "vddio",   180, 190,  1  },
-   { "vddxo",   180, 190,  8  },
-   { "vddrf",   130, 1352000,  30 },
-   { "vddch0",  330, 330,  45 },
+   { "vddio", 1  },
+   { "vddxo", 8  },
+   { "vddrf", 30 },
+   { "vddch0", 45 },
},
.num_vregs = 4,
 };
@@ -1386,13 +1384,6 @@ static int qca_power_off(struct hci_dev *hdev)
 static int qca_enable_regulator(struct qca_vreg vregs,
struct regulator *regulator)
 {
-   int ret;
-
-   ret = regulator_set_voltage(regulator, vregs.min_uV,
-   vregs.max_uV);
-   if (ret)
-   return ret;
-
return regulator_enable(regulator);
 
 }
@@ -1401,7 +1392,6 @@ static void qca_disable_regulator(struct qca_vreg vregs,
  struct regulator *regulator)
 {
regulator_disable(regulator);
-   regulator_set_voltage(regulator, 0, vregs.max_uV);
 
 }
 
-- 
2.23.0



Re: [PATCH 01/15] riscv: cleanup

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:07 PM Christoph Hellwig  wrote:
>
> Remove various not required ifdefs and externs.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/include/asm/bug.h | 16 +++-
>  1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
> index 07ceee8b1747..75604fec1b1b 100644
> --- a/arch/riscv/include/asm/bug.h
> +++ b/arch/riscv/include/asm/bug.h
> @@ -12,7 +12,6 @@
>
>  #include 
>
> -#ifdef CONFIG_GENERIC_BUG
>  #define __INSN_LENGTH_MASK  _UL(0x3)
>  #define __INSN_LENGTH_32_UL(0x3)
>  #define __COMPRESSED_INSN_MASK _UL(0x)
> @@ -20,7 +19,6 @@
>  #define __BUG_INSN_32  _UL(0x00100073) /* ebreak */
>  #define __BUG_INSN_16  _UL(0x9002) /* c.ebreak */
>
> -#ifndef __ASSEMBLY__
>  typedef u32 bug_insn_t;
>
>  #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> @@ -43,6 +41,7 @@ typedef u32 bug_insn_t;
> RISCV_SHORT " %2"
>  #endif
>
> +#ifdef CONFIG_GENERIC_BUG
>  #define __BUG_FLAGS(flags) \
>  do {   \
> __asm__ __volatile__ (  \
> @@ -58,14 +57,10 @@ do {  
>   \
>   "i" (flags),  \
>   "i" (sizeof(struct bug_entry)));  \
>  } while (0)
> -
> -#endif /* !__ASSEMBLY__ */
>  #else /* CONFIG_GENERIC_BUG */
> -#ifndef __ASSEMBLY__
>  #define __BUG_FLAGS(flags) do {\
> __asm__ __volatile__ ("ebreak\n");  \
>  } while (0)
> -#endif /* !__ASSEMBLY__ */
>  #endif /* CONFIG_GENERIC_BUG */
>
>  #define BUG() do { \
> @@ -79,15 +74,10 @@ do {  
>   \
>
>  #include 
>
> -#ifndef __ASSEMBLY__
> -
>  struct pt_regs;
>  struct task_struct;
>
> -extern void die(struct pt_regs *regs, const char *str);
> -extern void do_trap(struct pt_regs *regs, int signo, int code,
> -   unsigned long addr);
> -
> -#endif /* !__ASSEMBLY__ */
> +void die(struct pt_regs *regs, const char *str);
> +void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr);
>
>  #endif /* _ASM_RISCV_BUG_H */
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH 05/15] riscv: poison SBI calls for M-mode

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig  wrote:
>
> There is no SBI when we run in M-mode, so fail the compile for any code
> trying to use SBI calls.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/riscv/include/asm/sbi.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
> index 21134b3ef404..b167af3e7470 100644
> --- a/arch/riscv/include/asm/sbi.h
> +++ b/arch/riscv/include/asm/sbi.h
> @@ -8,6 +8,7 @@
>
>  #include 
>
> +#ifdef CONFIG_RISCV_SBI
>  #define SBI_SET_TIMER 0
>  #define SBI_CONSOLE_PUTCHAR 1
>  #define SBI_CONSOLE_GETCHAR 2
> @@ -93,5 +94,5 @@ static inline void sbi_remote_sfence_vma_asid(const 
> unsigned long *hart_mask,
>  {
> SBI_CALL_4(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask, start, size, asid);
>  }
> -
> -#endif
> +#endif /* CONFIG_RISCV_SBI */
> +#endif /* _ASM_RISCV_SBI_H */
> --
> 2.20.1
>
>
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

LGTM.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: RISC-V nommu support v5

2019-10-17 Thread Paul Walmsley
On Fri, 18 Oct 2019, Anup Patel wrote:

> It will be really cool to have this series for Linux-5.4-rcX.

It's way too big to go in via the -rc series.  I'm hoping to have it ready 
to go for v5.5-rc1.


- Paul


Re: [PATCH 5/8] riscv: add missing prototypes

2019-10-17 Thread Luc Van Oostenryck
On Thu, Oct 17, 2019 at 05:49:26PM -0700, Paul Walmsley wrote:
> sparse identifies these missing prototypes when building arch/riscv:
> 
> arch/riscv/kernel/cpu.c:149:29: warning: symbol 'cpuinfo_op' was not 
> declared. Should it be static?
> arch/riscv/kernel/irq.c:27:29: warning: symbol 'do_IRQ' was not declared. 
> Should it be static?
> arch/riscv/kernel/irq.c:57:13: warning: symbol 'init_IRQ' was not declared. 
> Should it be static?
> arch/riscv/kernel/syscall_table.c:15:6: warning: symbol 'sys_call_table' was 
> not declared. Should it be static?
> arch/riscv/kernel/time.c:15:13: warning: symbol 'time_init' was not declared. 
> Should it be static?
> arch/riscv/kernel/smpboot.c:135:24: warning: symbol 'smp_callin' was not 
> declared. Should it be static?
> arch/riscv/kernel/smp.c:72:5: warning: symbol 'setup_profiling_timer' was not 
> declared. Should it be static?
> arch/riscv/mm/init.c:151:7: warning: symbol 'trampoline_pg_dir' was not 
> declared. Should it be static?
> arch/riscv/mm/init.c:157:7: warning: symbol 'early_pg_dir' was not declared. 
> Should it be static?
> arch/riscv/kernel/process.c:32:6: warning: symbol 'show_regs' was not 
> declared. Should it be static?
> arch/riscv/kernel/ptrace.c:151:6: warning: symbol 'do_syscall_trace_enter' 
> was not declared. Should it be static?
> arch/riscv/kernel/ptrace.c:165:6: warning: symbol 'do_syscall_trace_exit' was 
> not declared. Should it be static?
> 
> Fix by adding the missing prototypes to the appropriate header files.

For functions defined in C but used ony in assembly, you can also simply mark
them as '__visible'  (aka __attribute__((exrernally_visible)) ).
 
Best regards,
-- Luc


[PATCH v3 0/3] Logitech G920 fixes

2019-10-17 Thread Andrey Smirnov
Everyone:

This series contains patches to fix a couple of regressions in G920
wheel support by hid-logitech-hidpp driver. Without the patches the
wheel remains stuck in autocentering mode ("resisting" any attempt to
trun) as well as missing support for any FF action.

Thanks,
Andrey Smirnov

Changes since [v2]:

 - Fixes a buggy validity check "HID: logitech-hidpp: rework
   device validation" as pointed out by Benjamin Tissoires

 - Marked "HID: logitech-hidpp: do all FF cleanup in
   hidpp_ff_destroy()" as 5.2+ for stable

Changes since [v1]:

 - "HID: logitech-hidpp: split g920_get_config()" is changed to
   not rely on devres and be a self contained patch

 - Quirk driven behaviour of "HID: logitech-hidpp: add G920 device
   validation quirk" is replaced with generic validation algorithm
   of "HID: logitech-hidpp: rework device validation"

 - Fix for a poteintial race condition is added in
   "HID: logitech-hidpp: do all FF cleanup in hidpp_ff_destroy()"
   as per suggestion by Benjamin Tissoires

 - Collected Tested-by from Sam Bazely for "HID: logitech-hidpp:
   split g920_get_config()" since that patch didn't change
   significantly since [v1]

 - Specified stable kernel versions I think the patches should
   apply to (hopefully I got that right)

[v2] lore.kernel.org/lkml/20191016182935.5616-1-andrew.smir...@gmail.com
[v1] lore.kernel.org/lkml/20191007051240.4410-1-andrew.smir...@gmail.com

Andrey Smirnov (3):
  HID: logitech-hidpp: split g920_get_config()
  HID: logitech-hidpp: rework device validation
  HID: logitech-hidpp: do all FF cleanup in hidpp_ff_destroy()

 drivers/hid/hid-logitech-hidpp.c | 237 +--
 1 file changed, 131 insertions(+), 106 deletions(-)

-- 
2.21.0



Re: [PATCH v2 31/33] tools lib bpf: Renaming pr_warning to pr_warn

2019-10-17 Thread Alexei Starovoitov
On Fri, Oct 18, 2019 at 11:18:48AM +0800, Kefeng Wang wrote:
> For kernel logging macro, pr_warning is completely removed and
> replaced by pr_warn, using pr_warn in tools lib bpf for symmetry
> to kernel logging macro, then we could drop pr_warning in the
> whole linux code.
> 
> Cc: Alexei Starovoitov 
> Cc: Daniel Borkmann 
> Cc: Martin KaFai Lau 
> Cc: Song Liu 
> Cc: Yonghong Song 
> Cc: b...@vger.kernel.org
> Acked-by: Andrii Nakryiko 
> Reviewed-by: Sergey Senozhatsky 
> Signed-off-by: Kefeng Wang 
> ---
>  tools/lib/bpf/btf.c |  56 +--
>  tools/lib/bpf/btf_dump.c|  18 +-
>  tools/lib/bpf/libbpf.c  | 679 
>  tools/lib/bpf/libbpf_internal.h |   8 +-
>  tools/lib/bpf/xsk.c |   4 +-
>  5 files changed, 379 insertions(+), 386 deletions(-)

Nack.
I prefer this type of renaming to go via bpf tree.
It's not a kernel patch. It's touching user space library
which is under heavy development.
Doing any other way will cause a ton of conflicts.



Re: linux-next: build warning after merge of the block tree

2019-10-17 Thread Stephen Rothwell
Hi Jens,

On Thu, 17 Oct 2019 18:56:39 -0600 Jens Axboe  wrote:
>
> I'll fix these warnings up, guessing it's 32-bit?

Thanks.  Yeah 32 bit.

-- 
Cheers,
Stephen Rothwell


pgpAAZTHyaXeP.pgp
Description: OpenPGP digital signature


[PATCH v3 2/3] HID: logitech-hidpp: rework device validation

2019-10-17 Thread Andrey Smirnov
G920 device only advertises REPORT_ID_HIDPP_LONG and
REPORT_ID_HIDPP_VERY_LONG in its HID report descriptor, so querying
for REPORT_ID_HIDPP_SHORT with optional=false will always fail and
prevent G920 to be recognized as a valid HID++ device.

To fix this and improve some other aspects, modify
hidpp_validate_device() as follows:

  - Inline the code of hidpp_validate_report() to simplify
distingushing between non-present and invalid report descriptors

  - Drop the check for id >= HID_MAX_IDS || id < 0 since all of our
IDs are static and known to satisfy that at compile time

  - Change the algorithms to check all possible report
types (including very long report) and deem the device as a valid
HID++ device if it supports at least one

  - Treat invalid report length as a hard stop for the validation
algorithm, meaning that if any of the supported reports has
invalid length we assume the worst and treat the device as a
generic HID device.

  - Fold initialization of hidpp->very_long_report_length into
hidpp_validate_device() since it already fetches very long report
length and validates its value

Fixes: fe3ee1ec007b ("HID: logitech-hidpp: allow non HID++ devices to be 
handled by this module")
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204191
Reported-by: Sam Bazely 
Signed-off-by: Andrey Smirnov 
Cc: Jiri Kosina 
Cc: Benjamin Tissoires 
Cc: Henrik Rydberg 
Cc: Pierre-Loup A. Griffais 
Cc: Austin Palmer 
Cc: linux-in...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: sta...@vger.kernel.org # 5.2+
---
 drivers/hid/hid-logitech-hidpp.c | 54 ++--
 1 file changed, 30 insertions(+), 24 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 85911586b3b6..6e669eb7dc69 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -3498,34 +3498,45 @@ static int hidpp_get_report_length(struct hid_device 
*hdev, int id)
return report->field[0]->report_count + 1;
 }
 
-static bool hidpp_validate_report(struct hid_device *hdev, int id,
- int expected_length, bool optional)
+static bool hidpp_validate_device(struct hid_device *hdev)
 {
-   int report_length;
+   struct hidpp_device *hidpp = hid_get_drvdata(hdev);
+   int id, report_length, supported_reports = 0;
+
+   id = REPORT_ID_HIDPP_SHORT;
+   report_length = hidpp_get_report_length(hdev, id);
+   if (report_length) {
+   if (report_length < HIDPP_REPORT_SHORT_LENGTH)
+   goto bad_device;
 
-   if (id >= HID_MAX_IDS || id < 0) {
-   hid_err(hdev, "invalid HID report id %u\n", id);
-   return false;
+   supported_reports++;
}
 
+   id = REPORT_ID_HIDPP_LONG;
report_length = hidpp_get_report_length(hdev, id);
-   if (!report_length)
-   return optional;
+   if (report_length) {
+   if (report_length < HIDPP_REPORT_LONG_LENGTH)
+   goto bad_device;
 
-   if (report_length < expected_length) {
-   hid_warn(hdev, "not enough values in hidpp report %d\n", id);
-   return false;
+   supported_reports++;
}
 
-   return true;
-}
+   id = REPORT_ID_HIDPP_VERY_LONG;
+   report_length = hidpp_get_report_length(hdev, id);
+   if (report_length) {
+   if (report_length < HIDPP_REPORT_LONG_LENGTH ||
+   report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH)
+   goto bad_device;
 
-static bool hidpp_validate_device(struct hid_device *hdev)
-{
-   return hidpp_validate_report(hdev, REPORT_ID_HIDPP_SHORT,
-HIDPP_REPORT_SHORT_LENGTH, false) &&
-  hidpp_validate_report(hdev, REPORT_ID_HIDPP_LONG,
-HIDPP_REPORT_LONG_LENGTH, true);
+   supported_reports++;
+   hidpp->very_long_report_length = report_length;
+   }
+
+   return supported_reports;
+
+bad_device:
+   hid_warn(hdev, "not enough values in hidpp report %d\n", id);
+   return false;
 }
 
 static bool hidpp_application_equals(struct hid_device *hdev,
@@ -3572,11 +3583,6 @@ static int hidpp_probe(struct hid_device *hdev, const 
struct hid_device_id *id)
return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
}
 
-   hidpp->very_long_report_length =
-   hidpp_get_report_length(hdev, REPORT_ID_HIDPP_VERY_LONG);
-   if (hidpp->very_long_report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH)
-   hidpp->very_long_report_length = 
HIDPP_REPORT_VERY_LONG_MAX_LENGTH;
-
if (id->group == HID_GROUP_LOGITECH_DJ_DEVICE)
hidpp->quirks |= HIDPP_QUIRK_UNIFYING;
 
-- 
2.21.0



[PATCH v3 1/3] HID: logitech-hidpp: split g920_get_config()

2019-10-17 Thread Andrey Smirnov
Original version of g920_get_config() contained two kind of actions:

1. Device specific communication to query/set some parameters
   which requires active communication channel with the device,
   or, put in other way, for the call to be sandwiched between
   hid_device_io_start() and hid_device_io_stop().

2. Input subsystem specific FF controller initialization which, in
   order to access a valid 'struct hid_input' via
   'hid->inputs.next', requires claimed hidinput which means be
   executed after the call to hid_hw_start() with connect_mask
   containing HID_CONNECT_HIDINPUT.

Location of g920_get_config() can only fulfill requirements for #1 and
not #2, which might result in following backtrace:

[   88.312258] logitech-hidpp-device 0003:046D:C262.0005: HID++ 4.2 device 
connected.
[   88.320298] BUG: kernel NULL pointer dereference, address: 0018
[   88.320304] #PF: supervisor read access in kernel mode
[   88.320307] #PF: error_code(0x) - not-present page
[   88.320309] PGD 0 P4D 0
[   88.320315] Oops:  [#1] SMP PTI
[   88.320320] CPU: 1 PID: 3080 Comm: systemd-udevd Not tainted 5.4.0-rc1+ #31
[   88.320322] Hardware name: Apple Inc. MacBookPro11,1/Mac-189A3D4F975D5FFC, 
BIOS 149.0.0.0.0 09/17/2018
[   88.320334] RIP: 0010:hidpp_probe+0x61f/0x948 [hid_logitech_hidpp]
[   88.320338] Code: 81 00 00 48 89 ef e8 f0 d6 ff ff 41 89 c6 85 c0 75 b5 0f 
b6 44 24 28 48 8b 5d 00 88 44 24 1e 89 44 24 0c 48 8b 83 18 1c 00 00 <48> 8b 48 
18 48 8b 83 10 19 00 00 48 8b 40 40 48 89 0c 24 0f b7 80
[   88.320341] RSP: 0018:b0a6824aba68 EFLAGS: 00010246
[   88.320345] RAX:  RBX: 93a50756e000 RCX: 00010408
[   88.320347] RDX:  RSI: 93a51f0ad0a0 RDI: 0002d0a0
[   88.320350] RBP: 93a50416da28 R08: 93a50416da70 R09: 93a50416da70
[   88.320352] R10: 00148ae9e60c R11: 000f1525 R12: 93a50756e000
[   88.320354] R13: 93a50756f8d0 R14:  R15: 93a50756fc38
[   88.320358] FS:  7f8d8c1e0940() GS:93a51f08() 
knlGS:
[   88.320361] CS:  0010 DS:  ES:  CR0: 80050033
[   88.320363] CR2: 0018 CR3: 0003996d8003 CR4: 001606e0
[   88.320366] Call Trace:
[   88.320377]  ? _cond_resched+0x15/0x30
[   88.320387]  ? create_pinctrl+0x2f/0x3c0
[   88.320393]  ? kernfs_link_sibling+0x94/0xe0
[   88.320398]  ? _cond_resched+0x15/0x30
[   88.320402]  ? kernfs_activate+0x5f/0x80
[   88.320406]  ? kernfs_add_one+0xe2/0x130
[   88.320411]  hid_device_probe+0x106/0x170
[   88.320419]  really_probe+0x147/0x3c0
[   88.320424]  driver_probe_device+0xb6/0x100
[   88.320428]  device_driver_attach+0x53/0x60
[   88.320433]  __driver_attach+0x8a/0x150
[   88.320437]  ? device_driver_attach+0x60/0x60
[   88.320440]  bus_for_each_dev+0x78/0xc0
[   88.320445]  bus_add_driver+0x14d/0x1f0
[   88.320450]  driver_register+0x6c/0xc0
[   88.320453]  ? 0xc0d67000
[   88.320457]  __hid_register_driver+0x4c/0x80
[   88.320464]  do_one_initcall+0x46/0x1f4
[   88.320469]  ? _cond_resched+0x15/0x30
[   88.320474]  ? kmem_cache_alloc_trace+0x162/0x220
[   88.320481]  ? do_init_module+0x23/0x230
[   88.320486]  do_init_module+0x5c/0x230
[   88.320491]  load_module+0x26e1/0x2990
[   88.320502]  ? ima_post_read_file+0xf0/0x100
[   88.320508]  ? __do_sys_finit_module+0xaa/0x110
[   88.320512]  __do_sys_finit_module+0xaa/0x110
[   88.320520]  do_syscall_64+0x5b/0x180
[   88.320525]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[   88.320528] RIP: 0033:0x7f8d8d1f01fd
[   88.320532] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 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 8b 0d 5b 8c 0c 00 f7 d8 64 89 01 48
[   88.320535] RSP: 002b:7ffefa3bb068 EFLAGS: 0246 ORIG_RAX: 
0139
[   88.320539] RAX: ffda RBX: 55922040cb40 RCX: 7f8d8d1f01fd
[   88.320541] RDX:  RSI: 7f8d8ce4984d RDI: 0006
[   88.320543] RBP: 0002 R08:  R09: 0007
[   88.320545] R10: 0006 R11: 0246 R12: 7f8d8ce4984d
[   88.320547] R13:  R14: 55922040efc0 R15: 55922040cb40
[   88.320551] Modules linked in: hid_logitech_hidpp(+) fuse rfcomm ccm 
xt_CHECKSUM xt_MASQUERADE bridge stp llc nf_nat_tftp nf_conntrack_tftp 
nf_conntrack_netbios_ns nf_conntrack_broadcast xt_CT ip6t_rpfilter ip6t_REJECT 
nf_reject_ipv6 xt_conntrack ebtable_nat ip6table_nat ip6table_mangle 
ip6table_raw ip6table_security iptable_nat nf_nat tun iptable_mangle 
iptable_raw iptable_security nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 
libcrc32c ip_set nfnetlink ebtable_filter ebtables ip6table_filter ip6_tables 
cmac bnep sunrpc dm_crypt nls_utf8 hfsplus intel_rapl_msr intel_rapl_common 
ath9k_htc ath9k_common x86_pkg_temp_thermal intel_powerclamp b43 ath9k_hw 
coretemp 

[PATCH] mm,thp: recheck each page before collapsing file THP

2019-10-17 Thread Song Liu
In collapse_file(), after locking the page, it is necessary to recheck
that the page is up-to-date, clean, and pointing to the proper mapping.
If any check fails, abort the collapse.

Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Cc: Kirill A. Shutemov 
Cc: Johannes Weiner 
Cc: Hugh Dickins 
Cc: William Kucharski 
Cc: Andrew Morton 
Signed-off-by: Song Liu 
---
 mm/khugepaged.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 0a1b4b484ac5..7da49b643c4d 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1619,6 +1619,14 @@ static void collapse_file(struct mm_struct *mm,
result = SCAN_PAGE_LOCK;
goto xa_locked;
}
+
+   /* double check the page is correct and clean */
+   if (unlikely(!PageUptodate(page)) ||
+   unlikely(PageDirty(page)) ||
+   unlikely(page->mapping != mapping)) {
+   result = SCAN_FAIL;
+   goto out_unlock;
+   }
}
 
/*
-- 
2.17.1



Re: [PATCH v1 4/4] net: dsa: add support for Atheros AR9331 build-in switch

2019-10-17 Thread Oleksij Rempel
On Thu, Oct 17, 2019 at 11:35:48AM -0700, Florian Fainelli wrote:
> 
> 
> On 10/13/2019 11:15 PM, Oleksij Rempel wrote:
> > Provide basic support for Atheros AR9331 build-in switch. So far it
> > works as port multiplexer without any hardware offloading support.
> 
> I glanced through the functional parts of the code, and it looks pretty
> straight forward, since there is no offloading done so far, do you plan
> on adding bridge offload eventually if nothing more?

Currently not. There are following reasons:
- I do it for the Freifunk project. It is currently not clear, what
  functionality has higher priority.
- there are not many ar9331 based devices with enough RAM to run any
  thing modern. There is even less devices using more then one switch
  port.
- IPv6 support is important for this project, but old Atheros switches have some
  known issues with IPv6 packages in hardware bridge mode. So, this
  functionality will need more testing.

> When you submit v2, I would suggest splitting the tagger code from the
> switch driver code, just to make them easier to review.

ok.

Regards,
Oleksij
-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


Re: [PATCH 4/8] riscv: ensure RISC-V C model definitions are passed to static analyzers

2019-10-17 Thread Paul Walmsley
On Fri, 18 Oct 2019, Luc Van Oostenryck wrote:

> On Thu, Oct 17, 2019 at 05:49:25PM -0700, Paul Walmsley wrote:
> > Static analysis tools such as sparse don't set the RISC-V C model
> > preprocessor directives such as "__riscv_cmodel_medany", set by the C
> > compilers.  This causes the static analyzers to evaluate different
> > preprocessor paths than C compilers would.  Fix this by defining the
> > appropriate C model macros in the static analyzer command lines.
> > 
> > Signed-off-by: Paul Walmsley 
> > ---
> >  arch/riscv/Makefile | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> > index f5e914210245..0247a90bd4d8 100644
> > --- a/arch/riscv/Makefile
> > +++ b/arch/riscv/Makefile
> > @@ -47,9 +47,11 @@ KBUILD_CFLAGS += 
> > -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
> >  
> >  ifeq ($(CONFIG_CMODEL_MEDLOW),y)
> > KBUILD_CFLAGS += -mcmodel=medlow
> > +   CHECKFLAGS += -D__riscv_cmodel_medlow
> >  endif
> >  ifeq ($(CONFIG_CMODEL_MEDANY),y)
> > KBUILD_CFLAGS += -mcmodel=medany
> > +   CHECKFLAGS += -D__riscv_cmodel_medany
> 
> I can teach sparse about this in the following days.

That would be great.  Would you be willing to follow up with me via E-mail 
or mailing list post when it's fixed?  If so, then in the meantime, I'll 
just drop this patch.


- Paul


Re: [PATCH 2/3] HID: google: Add of_match table to Whiskers switch device.

2019-10-17 Thread Ikjoon Jang
A gentle ping on adding DT binding for Hammer (2/2).

On Sat, Oct 5, 2019 at 6:14 PM Ikjoon Jang  wrote:
>
> Add a device tree match table.
>
> Change-Id: Iaee68311073cefa4b99cde182bd37d1a67c94ea6
> Signed-off-by: Ikjoon Jang 
> ---
>  drivers/hid/hid-google-hammer.c | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
> index 31e4a39946f5..bf2b6c6c9787 100644
> --- a/drivers/hid/hid-google-hammer.c
> +++ b/drivers/hid/hid-google-hammer.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -272,12 +273,21 @@ static const struct acpi_device_id cbas_ec_acpi_ids[] = 
> {
>  };
>  MODULE_DEVICE_TABLE(acpi, cbas_ec_acpi_ids);
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id cbas_ec_of_match[] = {
> +   { .compatible = "google,cros-cbas" },
> +   { },
> +};
> +MODULE_DEVICE_TABLE(of, cbas_ec_of_match);
> +#endif
> +
>  static struct platform_driver cbas_ec_driver = {
> .probe = cbas_ec_probe,
> .remove = cbas_ec_remove,
> .driver = {
> .name = "cbas_ec",
> .acpi_match_table = ACPI_PTR(cbas_ec_acpi_ids),
> +   .of_match_table = of_match_ptr(cbas_ec_of_match),
> .pm = _ec_pm_ops,
> },
>  };
> --
> 2.23.0.581.g78d2f28ef7-goog
>


Re: [PATCH v2] cpufreq: powernv: fix stack bloat and NR_CPUS limitation

2019-10-17 Thread Viresh Kumar
On 17-10-19, 21:55, John Hubbard wrote:
> The following build warning occurred on powerpc 64-bit builds:
> 
> drivers/cpufreq/powernv-cpufreq.c: In function 'init_chip_info':
> drivers/cpufreq/powernv-cpufreq.c:1070:1: warning: the frame size of 1040 
> bytes is larger than 1024 bytes [-Wframe-larger-than=]
> 
> This is due to putting 1024 bytes on the stack:
> 
> unsigned int chip[256];
> 
> ...and while looking at this, it also has a bug: it fails with a stack
> overrun, if CONFIG_NR_CPUS > 256.
> 
> Fix both problems by dynamically allocating based on CONFIG_NR_CPUS.
> 
> Fixes: 053819e0bf840 ("cpufreq: powernv: Handle throttling due to Pmax 
> capping at chip level")
> Cc: Shilpasri G Bhat 
> Cc: Preeti U Murthy 
> Cc: Viresh Kumar 
> Cc: Rafael J. Wysocki 
> Cc: linux...@vger.kernel.org
> Cc: linuxppc-...@lists.ozlabs.org
> Signed-off-by: John Hubbard 
> ---
> 
> Changes since v1: includes Viresh's review commit fixes.
> 
>  drivers/cpufreq/powernv-cpufreq.c | 17 +
>  1 file changed, 13 insertions(+), 4 deletions(-)

Acked-by: Viresh Kumar 

-- 
viresh


[PATCH v2 22/33] sh/intc: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Yoshinori Sato 
Cc: Rich Felker 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/sh/intc/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 46f0f322d4d8..8485e812d9b2 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -100,8 +100,8 @@ static void __init intc_register_irq(struct intc_desc *desc,
primary = 1;
 
if (!data[0] && !data[1])
-   pr_warning("missing unique irq mask for irq %d (vect 0x%04x)\n",
-  irq, irq2evt(irq));
+   pr_warn("missing unique irq mask for irq %d (vect 0x%04x)\n",
+   irq, irq2evt(irq));
 
data[0] = data[0] ? data[0] : intc_get_mask_handle(desc, d, enum_id, 1);
data[1] = data[1] ? data[1] : intc_get_prio_handle(desc, d, enum_id, 1);
-- 
2.20.1



Re: [PATCH 2/2] Fix a NULL-ptr-deref bug in ath10k_usb_alloc_urb_from_pipe

2019-10-17 Thread Guenter Roeck
On Sun, Sep 01, 2019 at 11:06:05AM +0300, Kalle Valo wrote:
> Guenter Roeck  writes:
> 
> > Hi,
> >
> > On Sat, Aug 03, 2019 at 08:31:01PM -0400, Hui Peng wrote:
> >> The `ar_usb` field of `ath10k_usb_pipe_usb_pipe` objects
> >> are initialized to point to the containing `ath10k_usb` object
> >> according to endpoint descriptors read from the device side, as shown
> >> below in `ath10k_usb_setup_pipe_resources`:
> >> 
> >> for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
> >> endpoint = _desc->endpoint[i].desc;
> >> 
> >> // get the address from endpoint descriptor
> >> pipe_num = ath10k_usb_get_logical_pipe_num(ar_usb,
> >> endpoint->bEndpointAddress,
> >> );
> >> ..
> >> // select the pipe object
> >> pipe = _usb->pipes[pipe_num];
> >> 
> >> // initialize the ar_usb field
> >> pipe->ar_usb = ar_usb;
> >> }
> >> 
> >> The driver assumes that the addresses reported in endpoint
> >> descriptors from device side  to be complete. If a device is
> >> malicious and does not report complete addresses, it may trigger
> >> NULL-ptr-deref `ath10k_usb_alloc_urb_from_pipe` and
> >> `ath10k_usb_free_urb_to_pipe`.
> >> 
> >> This patch fixes the bug by preventing potential NULL-ptr-deref.
> >> 
> >> Signed-off-by: Hui Peng 
> >> Reported-by: Hui Peng 
> >> Reported-by: Mathias Payer 
> >
> > This patch fixes CVE-2019-15099, which has CVSS scores of 7.5 (CVSS 3.0)
> > and 7.8 (CVSS 2.0). Yet, I don't find it in the upstream kernel or in Linux
> > next.
> >
> > Is the patch going to be applied to the upstream kernel anytime soon ?
> 
> Same answer as in patch 1:
> 
> https://patchwork.kernel.org/patch/11074655/
> 

Sorry to bring this up again. The ath6k patch made it into the upstream
kernel, but the ath10k patch didn't. Did it get lost, or was there a
reason not to apply this patch ?

Thanks,
Guenter


[PATCH v2 11/33] clocksource: samsung_pwm_timer: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Daniel Lezcano 
Acked-by: Daniel Lezcano 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/clocksource/samsung_pwm_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/samsung_pwm_timer.c 
b/drivers/clocksource/samsung_pwm_timer.c
index 895f53eb5771..0274219e1720 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -430,7 +430,7 @@ static int __init samsung_pwm_alloc(struct device_node *np,
 
of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) {
if (val >= SAMSUNG_PWM_NUM) {
-   pr_warning("%s: invalid channel index in 
samsung,pwm-outputs property\n",
+   pr_warn("%s: invalid channel index in 
samsung,pwm-outputs property\n",
__func__);
continue;
}
-- 
2.20.1



[PATCH v2 17/33] oprofile: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Robert Richter 
Acked-by: Robert Richter 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/oprofile/oprofile_perf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/oprofile/oprofile_perf.c b/drivers/oprofile/oprofile_perf.c
index 4b150a754890..98a63a5f8763 100644
--- a/drivers/oprofile/oprofile_perf.c
+++ b/drivers/oprofile/oprofile_perf.c
@@ -46,8 +46,8 @@ static void op_overflow_handler(struct perf_event *event,
if (id != num_counters)
oprofile_add_sample(regs, id);
else
-   pr_warning("oprofile: ignoring spurious overflow "
-   "on cpu %u\n", cpu);
+   pr_warn("oprofile: ignoring spurious overflow on cpu %u\n",
+   cpu);
 }
 
 /*
@@ -88,8 +88,8 @@ static int op_create_counter(int cpu, int event)
 
if (pevent->state != PERF_EVENT_STATE_ACTIVE) {
perf_event_release_kernel(pevent);
-   pr_warning("oprofile: failed to enable event %d "
-   "on CPU %d\n", event, cpu);
+   pr_warn("oprofile: failed to enable event %d on CPU %d\n",
+   event, cpu);
return -EBUSY;
}
 
-- 
2.20.1



[PATCH v2 21/33] scsi: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/scsi/a3000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c
index 222c77c9621f..b6a0432f305a 100644
--- a/drivers/scsi/a3000.c
+++ b/drivers/scsi/a3000.c
@@ -39,7 +39,7 @@ static irqreturn_t a3000_intr(int irq, void *data)
spin_unlock_irqrestore(instance->host_lock, flags);
return IRQ_HANDLED;
}
-   pr_warning("Non-serviced A3000 SCSI-interrupt? ISTR = %02x\n", status);
+   pr_warn("Non-serviced A3000 SCSI-interrupt? ISTR = %02x\n", status);
return IRQ_NONE;
 }
 
-- 
2.20.1



Re: [PATCH] cpufreq: powernv: fix stack bloat and NR_CPUS limitation

2019-10-17 Thread Viresh Kumar
On 17-10-19, 21:34, John Hubbard wrote:
> On 10/17/19 9:27 PM, Viresh Kumar wrote:
> > On 17-10-19, 17:04, John Hubbard wrote:
> >> The following build warning occurred on powerpc 64-bit builds:
> >>
> >> drivers/cpufreq/powernv-cpufreq.c: In function 'init_chip_info':
> >> drivers/cpufreq/powernv-cpufreq.c:1070:1: warning: the frame size of 1040 
> >> bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > 
> > How come we are catching this warning after 4 years ?
> > 
> 
> Newer compilers. And btw, I don't spend a lot of time in powerpc
> code, so I just recently ran this, and I guess everyone has been on less
> new compilers so far, it seems.
> 
> I used a gcc 8.1 cross compiler in this case:

Hmm, okay.

I hope you haven't missed my actual review comments on your patch,
just wanted to make sure we don't end up waiting for each other
indefinitely here :)

-- 
viresh


[PATCH v2 04/33] riscv: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: Albert Ou 
Acked-by: Palmer Dabbelt 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 arch/riscv/kernel/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index 70bb94ae61c5..b7401858d872 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -315,8 +315,8 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char 
*strtab,
/* Ignore unresolved weak symbol */
if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
continue;
-   pr_warning("%s: Unknown symbol %s\n",
-  me->name, strtab + sym->st_name);
+   pr_warn("%s: Unknown symbol %s\n",
+   me->name, strtab + sym->st_name);
return -ENOENT;
}
 
-- 
2.20.1



[PATCH v2 06/33] sparc: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: "David S. Miller" 
Cc: Andrew Morton 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 arch/sparc/kernel/smp_64.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index a8275fea4b70..9b4506373353 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1673,9 +1673,9 @@ void __init setup_per_cpu_areas(void)
pcpu_alloc_bootmem,
pcpu_free_bootmem);
if (rc)
-   pr_warning("PERCPU: %s allocator failed (%d), "
-  "falling back to page size\n",
-  pcpu_fc_names[pcpu_chosen_fc], rc);
+   pr_warn("PERCPU: %s allocator failed (%d), "
+   "falling back to page size\n",
+   pcpu_fc_names[pcpu_chosen_fc], rc);
}
if (rc < 0)
rc = pcpu_page_first_chunk(PERCPU_MODULE_RESERVE,
-- 
2.20.1



[PATCH] staging: rtl8192e: initializing the wep buffer

2019-10-17 Thread Kangjie Lu
The "wep" buffer is not initialized. To avoid memory disclosures,
the fix initializes it, as peer functions like rtllib_ccmp_set_key
do.

Signed-off-by: Kangjie Lu 
---
 drivers/staging/rtl8192e/rtllib_crypt_wep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c 
b/drivers/staging/rtl8192e/rtllib_crypt_wep.c
index b1ea650036d2..0931777ed157 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c
@@ -232,6 +232,7 @@ static int prism2_wep_set_key(void *key, int len, u8 *seq, 
void *priv)
if (len < 0 || len > WEP_KEY_LEN)
return -1;
 
+   memset(wep, 0, sizeof(*wep));
memcpy(wep->key, key, len);
wep->key_len = len;
 
-- 
2.17.1



[PATCH v2 05/33] sh: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Stephen Rothwell 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 arch/sh/boards/mach-sdk7786/nmi.c| 2 +-
 arch/sh/drivers/pci/fixups-sdk7786.c | 2 +-
 arch/sh/kernel/io_trapped.c  | 2 +-
 arch/sh/kernel/setup.c   | 2 +-
 arch/sh/mm/consistent.c  | 5 ++---
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/sh/boards/mach-sdk7786/nmi.c 
b/arch/sh/boards/mach-sdk7786/nmi.c
index c2e09d798537..afba49679a12 100644
--- a/arch/sh/boards/mach-sdk7786/nmi.c
+++ b/arch/sh/boards/mach-sdk7786/nmi.c
@@ -37,7 +37,7 @@ static int __init nmi_mode_setup(char *str)
nmi_mode = NMI_MODE_ANY;
else {
nmi_mode = NMI_MODE_UNKNOWN;
-   pr_warning("Unknown NMI mode %s\n", str);
+   pr_warn("Unknown NMI mode %s\n", str);
}
 
printk("Set NMI mode to %d\n", nmi_mode);
diff --git a/arch/sh/drivers/pci/fixups-sdk7786.c 
b/arch/sh/drivers/pci/fixups-sdk7786.c
index 8cbfa5310a4b..6972af7b4e93 100644
--- a/arch/sh/drivers/pci/fixups-sdk7786.c
+++ b/arch/sh/drivers/pci/fixups-sdk7786.c
@@ -53,7 +53,7 @@ static int __init sdk7786_pci_init(void)
 
/* Warn about forced rerouting if slot#3 is occupied */
if ((data & PCIECR_PRST3) == 0) {
-   pr_warning("Unreachable card detected in slot#3\n");
+   pr_warn("Unreachable card detected in slot#3\n");
return -EBUSY;
}
} else
diff --git a/arch/sh/kernel/io_trapped.c b/arch/sh/kernel/io_trapped.c
index bacad6da4fe4..60c828a2b8a2 100644
--- a/arch/sh/kernel/io_trapped.c
+++ b/arch/sh/kernel/io_trapped.c
@@ -99,7 +99,7 @@ int register_trapped_io(struct trapped_io *tiop)
 
return 0;
  bad:
-   pr_warning("unable to install trapped io filter\n");
+   pr_warn("unable to install trapped io filter\n");
return -1;
 }
 EXPORT_SYMBOL_GPL(register_trapped_io);
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 914174a125a4..d232cfa01877 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -355,7 +355,7 @@ void __init setup_arch(char **cmdline_p)
 /* processor boot mode configuration */
 int generic_mode_pins(void)
 {
-   pr_warning("generic_mode_pins(): missing mode pin configuration\n");
+   pr_warn("generic_mode_pins(): missing mode pin configuration\n");
return 0;
 }
 
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 792f36129062..3169a343a5ab 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -43,8 +43,7 @@ int __init platform_resource_setup_memory(struct 
platform_device *pdev,
 
r = pdev->resource + pdev->num_resources - 1;
if (r->flags) {
-   pr_warning("%s: unable to find empty space for resource\n",
-   name);
+   pr_warn("%s: unable to find empty space for resource\n", name);
return -EINVAL;
}
 
@@ -54,7 +53,7 @@ int __init platform_resource_setup_memory(struct 
platform_device *pdev,
 
buf = dma_alloc_coherent(>dev, memsize, _handle, GFP_KERNEL);
if (!buf) {
-   pr_warning("%s: unable to allocate memory\n", name);
+   pr_warn("%s: unable to allocate memory\n", name);
return -ENOMEM;
}
 
-- 
2.20.1



[PATCH v2 31/33] tools lib bpf: Renaming pr_warning to pr_warn

2019-10-17 Thread Kefeng Wang
For kernel logging macro, pr_warning is completely removed and
replaced by pr_warn, using pr_warn in tools lib bpf for symmetry
to kernel logging macro, then we could drop pr_warning in the
whole linux code.

Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
Cc: Martin KaFai Lau 
Cc: Song Liu 
Cc: Yonghong Song 
Cc: b...@vger.kernel.org
Acked-by: Andrii Nakryiko 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 tools/lib/bpf/btf.c |  56 +--
 tools/lib/bpf/btf_dump.c|  18 +-
 tools/lib/bpf/libbpf.c  | 679 
 tools/lib/bpf/libbpf_internal.h |   8 +-
 tools/lib/bpf/xsk.c |   4 +-
 5 files changed, 379 insertions(+), 386 deletions(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 3eae8d1addfa..d72e9a79dce1 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -390,14 +390,14 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
GElf_Ehdr ehdr;
 
if (elf_version(EV_CURRENT) == EV_NONE) {
-   pr_warning("failed to init libelf for %s\n", path);
+   pr_warn("failed to init libelf for %s\n", path);
return ERR_PTR(-LIBBPF_ERRNO__LIBELF);
}
 
fd = open(path, O_RDONLY);
if (fd < 0) {
err = -errno;
-   pr_warning("failed to open %s: %s\n", path, strerror(errno));
+   pr_warn("failed to open %s: %s\n", path, strerror(errno));
return ERR_PTR(err);
}
 
@@ -405,19 +405,19 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
 
elf = elf_begin(fd, ELF_C_READ, NULL);
if (!elf) {
-   pr_warning("failed to open %s as ELF file\n", path);
+   pr_warn("failed to open %s as ELF file\n", path);
goto done;
}
if (!gelf_getehdr(elf, )) {
-   pr_warning("failed to get EHDR from %s\n", path);
+   pr_warn("failed to get EHDR from %s\n", path);
goto done;
}
if (!btf_check_endianness()) {
-   pr_warning("non-native ELF endianness is not supported\n");
+   pr_warn("non-native ELF endianness is not supported\n");
goto done;
}
if (!elf_rawdata(elf_getscn(elf, ehdr.e_shstrndx), NULL)) {
-   pr_warning("failed to get e_shstrndx from %s\n", path);
+   pr_warn("failed to get e_shstrndx from %s\n", path);
goto done;
}
 
@@ -427,29 +427,29 @@ struct btf *btf__parse_elf(const char *path, struct 
btf_ext **btf_ext)
 
idx++;
if (gelf_getshdr(scn, ) != ) {
-   pr_warning("failed to get section(%d) header from %s\n",
-  idx, path);
+   pr_warn("failed to get section(%d) header from %s\n",
+   idx, path);
goto done;
}
name = elf_strptr(elf, ehdr.e_shstrndx, sh.sh_name);
if (!name) {
-   pr_warning("failed to get section(%d) name from %s\n",
-  idx, path);
+   pr_warn("failed to get section(%d) name from %s\n",
+   idx, path);
goto done;
}
if (strcmp(name, BTF_ELF_SEC) == 0) {
btf_data = elf_getdata(scn, 0);
if (!btf_data) {
-   pr_warning("failed to get section(%d, %s) data 
from %s\n",
-  idx, name, path);
+   pr_warn("failed to get section(%d, %s) data 
from %s\n",
+   idx, name, path);
goto done;
}
continue;
} else if (btf_ext && strcmp(name, BTF_EXT_ELF_SEC) == 0) {
btf_ext_data = elf_getdata(scn, 0);
if (!btf_ext_data) {
-   pr_warning("failed to get section(%d, %s) data 
from %s\n",
-  idx, name, path);
+   pr_warn("failed to get section(%d, %s) data 
from %s\n",
+   idx, name, path);
goto done;
}
continue;
@@ -600,9 +600,9 @@ int btf__load(struct btf *btf)
   log_buf, log_buf_size, false);
if (btf->fd < 0) {
err = -errno;
-   pr_warning("Error loading BTF: %s(%d)\n", strerror(errno), 
errno);
+   pr_warn("Error loading BTF: %s(%d)\n", strerror(errno), errno);
if (*log_buf)
-   pr_warning("%s\n", log_buf);
+   pr_warn("%s\n", 

[PATCH v2 08/33] acpi: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: "Rafael J. Wysocki" 
Cc: Len Brown 
Cc: James Morse 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/acpi/apei/apei-base.c | 36 +--
 drivers/acpi/apei/einj.c  |  4 ++--
 drivers/acpi/apei/erst-dbg.c  |  5 ++---
 drivers/acpi/apei/ghes.c  | 25 
 drivers/acpi/apei/hest.c  | 14 +++---
 drivers/acpi/battery.c|  2 +-
 drivers/acpi/resource.c   |  4 ++--
 7 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index 131c35ee9ed3..1bb2a94f49a3 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -170,7 +170,7 @@ int __apei_exec_run(struct apei_exec_context *ctx, u8 
action,
if (ip == ctx->ip) {
if (entry->instruction >= ctx->instructions ||
!ctx->ins_table[entry->instruction].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
"Invalid action table, unknown instruction type: %d\n",
   entry->instruction);
return -EINVAL;
@@ -211,7 +211,7 @@ static int apei_exec_for_each_entry(struct 
apei_exec_context *ctx,
if (end)
*end = i;
if (ins >= ctx->instructions || !ins_table[ins].run) {
-   pr_warning(FW_WARN APEI_PFX
+   pr_warn(FW_WARN APEI_PFX
"Invalid action table, unknown instruction type: %d\n",
   ins);
return -EINVAL;
@@ -579,18 +579,18 @@ static int apei_check_gar(struct acpi_generic_address 
*reg, u64 *paddr,
space_id = reg->space_id;
*paddr = get_unaligned(>address);
if (!*paddr) {
-   pr_warning(FW_BUG APEI_PFX
-  "Invalid physical address in GAR 
[0x%llx/%u/%u/%u/%u]\n",
-  *paddr, bit_width, bit_offset, access_size_code,
-  space_id);
+   pr_warn(FW_BUG APEI_PFX
+   "Invalid physical address in GAR 
[0x%llx/%u/%u/%u/%u]\n",
+   *paddr, bit_width, bit_offset, access_size_code,
+   space_id);
return -EINVAL;
}
 
if (access_size_code < 1 || access_size_code > 4) {
-   pr_warning(FW_BUG APEI_PFX
-  "Invalid access size code in GAR 
[0x%llx/%u/%u/%u/%u]\n",
-  *paddr, bit_width, bit_offset, access_size_code,
-  space_id);
+   pr_warn(FW_BUG APEI_PFX
+   "Invalid access size code in GAR 
[0x%llx/%u/%u/%u/%u]\n",
+   *paddr, bit_width, bit_offset, access_size_code,
+   space_id);
return -EINVAL;
}
*access_bit_width = 1UL << (access_size_code + 2);
@@ -604,19 +604,19 @@ static int apei_check_gar(struct acpi_generic_address 
*reg, u64 *paddr,
*access_bit_width = 64;
 
if ((bit_width + bit_offset) > *access_bit_width) {
-   pr_warning(FW_BUG APEI_PFX
-  "Invalid bit width + offset in GAR 
[0x%llx/%u/%u/%u/%u]\n",
-  *paddr, bit_width, bit_offset, access_size_code,
-  space_id);
+   pr_warn(FW_BUG APEI_PFX
+   "Invalid bit width + offset in GAR 
[0x%llx/%u/%u/%u/%u]\n",
+   *paddr, bit_width, bit_offset, access_size_code,
+   space_id);
return -EINVAL;
}
 
if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY &&
space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
-   pr_warning(FW_BUG APEI_PFX
-  "Invalid address space type in GAR 
[0x%llx/%u/%u/%u/%u]\n",
-  *paddr, bit_width, bit_offset, access_size_code,
-  space_id);
+   pr_warn(FW_BUG APEI_PFX
+   "Invalid address space type in GAR 
[0x%llx/%u/%u/%u/%u]\n",
+   *paddr, bit_width, bit_offset, access_size_code,
+   space_id);
return -EINVAL;
}
 
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index e430cf4caec2..086373f8ccb1 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -172,7 +172,7 @@ static int einj_get_available_error_type(u32 *type)
 static int einj_timedout(u64 *t)
 {
if ((s64)*t < SPIN_UNIT) {
-   pr_warning(FW_WARN "Firmware does not respond in 

[PATCH v2 03/33] ia64: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Tony Luck 
Cc: Fenghua Yu 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 arch/ia64/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index bb320c6d0cc9..c49fcef754de 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -289,7 +289,7 @@ static void __init setup_crashkernel(unsigned long total, 
int *n)
}
 
if (!check_crashkernel_memory(base, size)) {
-   pr_warning("crashkernel: There would be kdump memory "
+   pr_warn("crashkernel: There would be kdump memory "
"at %ld GB but this is unusable because it "
"must\nbe below 4 GB. Change the memory "
"configuration of the machine.\n",
-- 
2.20.1



Re: [PATCH 03/15] riscv: abstract out CSR names for supervisor vs machine mode

2019-10-17 Thread Anup Patel
On Thu, Oct 17, 2019 at 11:07 PM Christoph Hellwig  wrote:
>
> Many of the privileged CSRs exist in a supervisor and machine version
> that are used very similarly.  Provide a new X-naming layer so that
> we don't have to ifdef everywhere for M-mode Linux support.
>
> Contains contributions from Damien Le Moal .
>
> Signed-off-by: Christoph Hellwig 
> Reviewed-by: Atish Patra 
> ---
>  arch/riscv/Kconfig |  4 ++
>  arch/riscv/include/asm/asm.h   |  6 +++
>  arch/riscv/include/asm/csr.h   | 58 +++--
>  arch/riscv/include/asm/irqflags.h  | 12 +++---
>  arch/riscv/include/asm/processor.h |  2 +-
>  arch/riscv/include/asm/ptrace.h| 16 +++
>  arch/riscv/include/asm/switch_to.h | 10 ++---
>  arch/riscv/kernel/asm-offsets.c|  8 ++--
>  arch/riscv/kernel/entry.S  | 68 --
>  arch/riscv/kernel/fpu.S|  8 ++--
>  arch/riscv/kernel/head.S   | 12 +++---
>  arch/riscv/kernel/irq.c|  4 +-
>  arch/riscv/kernel/process.c| 15 ---
>  arch/riscv/kernel/signal.c | 21 +
>  arch/riscv/kernel/traps.c  | 16 +++
>  arch/riscv/lib/uaccess.S   | 12 +++---
>  arch/riscv/mm/extable.c|  4 +-
>  arch/riscv/mm/fault.c  |  6 +--
>  drivers/clocksource/timer-riscv.c  |  8 ++--
>  drivers/irqchip/irq-sifive-plic.c  |  4 +-
>  20 files changed, 181 insertions(+), 113 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 8eebbc8860bb..86b7e8b0471c 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -72,6 +72,10 @@ config ARCH_MMAP_RND_BITS_MAX
> default 24 if 64BIT # SV39 based
> default 17
>
> +# set if we run in machine mode, cleared if we run in supervisor mode
> +config RISCV_M_MODE
> +   bool
> +
>  config MMU
> def_bool y
>
> diff --git a/arch/riscv/include/asm/asm.h b/arch/riscv/include/asm/asm.h
> index 9c992a88d858..e362fb741c76 100644
> --- a/arch/riscv/include/asm/asm.h
> +++ b/arch/riscv/include/asm/asm.h
> @@ -66,4 +66,10 @@
>  #error "Unexpected __SIZEOF_SHORT__"
>  #endif
>
> +#ifdef CONFIG_RISCV_M_MODE
> +# define Xret  mret
> +#else
> +# define Xret  sret
> +#endif
> +
>  #endif /* _ASM_RISCV_ASM_H */
> diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h
> index a18923fa23c8..0dae5c361f29 100644
> --- a/arch/riscv/include/asm/csr.h
> +++ b/arch/riscv/include/asm/csr.h
> @@ -11,8 +11,11 @@
>
>  /* Status register flags */
>  #define SR_SIE _AC(0x0002, UL) /* Supervisor Interrupt Enable */
> +#define SR_MIE _AC(0x0008, UL) /* Machine Interrupt Enable */
>  #define SR_SPIE_AC(0x0020, UL) /* Previous Supervisor IE 
> */
> +#define SR_MPIE_AC(0x0080, UL) /* Previous Machine IE */
>  #define SR_SPP _AC(0x0100, UL) /* Previously Supervisor */
> +#define SR_MPP _AC(0x1800, UL) /* Previously Machine */
>  #define SR_SUM _AC(0x0004, UL) /* Supervisor User Memory Access 
> */
>
>  #define SR_FS  _AC(0x6000, UL) /* Floating-point Status */
> @@ -44,8 +47,8 @@
>  #define SATP_MODE  SATP_MODE_39
>  #endif
>
> -/* SCAUSE */
> -#define SCAUSE_IRQ_FLAG(_AC(1, UL) << (__riscv_xlen - 1))
> +/* *CAUSE */
> +#define XCAUSE_IRQ_FLAG(_AC(1, UL) << (__riscv_xlen - 1))
>
>  #define IRQ_U_SOFT 0
>  #define IRQ_S_SOFT 1
> @@ -67,11 +70,26 @@
>  #define EXC_LOAD_PAGE_FAULT13
>  #define EXC_STORE_PAGE_FAULT   15
>
> -/* SIE (Interrupt Enable) and SIP (Interrupt Pending) flags */
> +/* SIE/SIP (Machine Interrupt Enable/Pending) flags */
> +#define MIE_MSIE   (_AC(0x1, UL) << IRQ_M_SOFT)
> +#define MIE_MTIE   (_AC(0x1, UL) << IRQ_M_TIMER)
> +#define MIE_MEIE   (_AC(0x1, UL) << IRQ_M_EXT)
> +
> +/* SIE/SIP (Supervisor Interrupt Enable/Pending) flags */
>  #define SIE_SSIE   (_AC(0x1, UL) << IRQ_S_SOFT)
>  #define SIE_STIE   (_AC(0x1, UL) << IRQ_S_TIMER)
>  #define SIE_SEIE   (_AC(0x1, UL) << IRQ_S_EXT)
>
> +/* symbolic CSR names: */
> +#define CSR_MSTATUS0x300
> +#define CSR_MIE0x304
> +#define CSR_MTVEC  0x305
> +#define CSR_MSCRATCH   0x340
> +#define CSR_MEPC   0x341
> +#define CSR_MCAUSE 0x342
> +#define CSR_MTVAL  0x343
> +#define CSR_MIP0x344
> +
>  #define CSR_CYCLE  0xc00
>  #define CSR_TIME   0xc01
>  #define CSR_INSTRET0xc02
> @@ -89,6 +107,40 @@
>  #define CSR_TIMEH  0xc81
>  #define CSR_INSTRETH   0xc82
>
> +#ifdef CONFIG_RISCV_M_MODE
> +# define CSR_XSTATUS   CSR_MSTATUS
> +# define CSR_XIE   CSR_MIE
> +# define CSR_XTVEC CSR_MTVEC
> +# define CSR_XSCRATCH  CSR_MSCRATCH
> +# define CSR_XEPC  CSR_MEPC
> +# define CSR_XCAUSE

[PATCH v2 09/33] drbd: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Philipp Reisner 
Cc: Lars Ellenberg 
Cc: Jens Axboe 
Cc: drbd-...@lists.linbit.com
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/block/drbd/drbd_nl.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 5d52a2d32155..de2f94d0103a 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -268,19 +268,18 @@ static int drbd_adm_prepare(struct drbd_config_context 
*adm_ctx,
/* some more paranoia, if the request was over-determined */
if (adm_ctx->device && adm_ctx->resource &&
adm_ctx->device->resource != adm_ctx->resource) {
-   pr_warning("request: minor=%u, resource=%s; but that minor 
belongs to resource %s\n",
-   adm_ctx->minor, adm_ctx->resource->name,
-   adm_ctx->device->resource->name);
+   pr_warn("request: minor=%u, resource=%s; but that minor belongs 
to resource %s\n",
+   adm_ctx->minor, adm_ctx->resource->name,
+   adm_ctx->device->resource->name);
drbd_msg_put_info(adm_ctx->reply_skb, "minor exists in 
different resource");
return ERR_INVALID_REQUEST;
}
if (adm_ctx->device &&
adm_ctx->volume != VOLUME_UNSPECIFIED &&
adm_ctx->volume != adm_ctx->device->vnr) {
-   pr_warning("request: minor=%u, volume=%u; but that minor is 
volume %u in %s\n",
-   adm_ctx->minor, adm_ctx->volume,
-   adm_ctx->device->vnr,
-   adm_ctx->device->resource->name);
+   pr_warn("request: minor=%u, volume=%u; but that minor is volume 
%u in %s\n",
+   adm_ctx->minor, adm_ctx->volume,
+   adm_ctx->device->vnr, adm_ctx->device->resource->name);
drbd_msg_put_info(adm_ctx->reply_skb, "minor exists as 
different volume");
return ERR_INVALID_REQUEST;
}
-- 
2.20.1



Re: [PATCH 0/8] riscv: resolve most warnings from sparse

2019-10-17 Thread Anup Patel
On Fri, Oct 18, 2019 at 6:19 AM Paul Walmsley  wrote:
>
> Resolve most warnings from the 'sparse' static analysis tool for the
> arch/riscv codebase.  This makes life easier for us as maintainers,
> and makes it easier for developers to use static analysis tools on
> their own changes.
>
> This patch series incorporates some changes based on feedback from
> Christoph Hellwig .
>
> Applies on the current riscv fixes branch that is based on v5.4-rc3.

This series certainly conflict's with Christoph's NOMMU series so
please rebase it on NOMMU series.

Regards,
Anup

>
>
> - Paul
>
>
> Paul Walmsley (8):
>   riscv: add prototypes for assembly language functions from entry.S
>   riscv: add prototypes for assembly language functions from head.S
>   riscv: init: merge split string literals in preprocessor directive
>   riscv: ensure RISC-V C model definitions are passed to static
> analyzers
>   riscv: add missing prototypes
>   riscv: mark some code and data as file-static
>   riscv: add missing header file includes
>   riscv: fp: add missing __user pointer annotations
>
> Kernel object size difference:
>textdata bss dec hex filename
> 6664206 2136568  312608 9113382  8b0f26 vmlinux.orig
> 6664186 2136552  312608 9113346  8b0f02 vmlinux.patched
>
>  arch/riscv/Makefile |  2 ++
>  arch/riscv/include/asm/irq.h|  6 ++
>  arch/riscv/include/asm/pgtable.h|  2 ++
>  arch/riscv/include/asm/processor.h  |  4 
>  arch/riscv/include/asm/ptrace.h |  4 
>  arch/riscv/include/asm/smp.h|  2 ++
>  arch/riscv/include/asm/switch_to.h  |  1 +
>  arch/riscv/kernel/cpufeature.c  |  1 +
>  arch/riscv/kernel/entry.h   | 29 +
>  arch/riscv/kernel/head.h| 21 +
>  arch/riscv/kernel/module-sections.c |  1 +
>  arch/riscv/kernel/process.c |  2 ++
>  arch/riscv/kernel/reset.c   |  1 +
>  arch/riscv/kernel/setup.c   |  2 ++
>  arch/riscv/kernel/signal.c  |  6 --
>  arch/riscv/kernel/smp.c |  2 ++
>  arch/riscv/kernel/smpboot.c |  3 +++
>  arch/riscv/kernel/stacktrace.c  |  6 --
>  arch/riscv/kernel/syscall_table.c   |  1 +
>  arch/riscv/kernel/time.c|  1 +
>  arch/riscv/kernel/traps.c   |  2 ++
>  arch/riscv/kernel/vdso.c|  3 ++-
>  arch/riscv/mm/context.c |  1 +
>  arch/riscv/mm/fault.c   |  2 ++
>  arch/riscv/mm/init.c| 17 ++---
>  arch/riscv/mm/sifive_l2_cache.c |  2 +-
>  26 files changed, 111 insertions(+), 13 deletions(-)
>  create mode 100644 arch/riscv/kernel/entry.h
>  create mode 100644 arch/riscv/kernel/head.h
>
> --
> 2.23.0
>


[PATCH v2 30/33] tools lib api: Renaming pr_warning to pr_warn

2019-10-17 Thread Kefeng Wang
For kernel logging macro, pr_warning is completely removed and
replaced by pr_warn, using pr_warn in tools lib api for symmetry
to kernel logging macro, then we could drop pr_warning in the
whole linux code.

Changing __pr_warning to __pr_warn to be consistent.

Cc: Arnaldo Carvalho de Melo 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 tools/lib/api/debug-internal.h | 4 ++--
 tools/lib/api/debug.c  | 4 ++--
 tools/lib/api/fs/fs.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/lib/api/debug-internal.h b/tools/lib/api/debug-internal.h
index 80c783497d25..5a5820c11db8 100644
--- a/tools/lib/api/debug-internal.h
+++ b/tools/lib/api/debug-internal.h
@@ -10,11 +10,11 @@ do {\
(func)("libapi: " fmt, ##__VA_ARGS__); \
 } while (0)
 
-extern libapi_print_fn_t __pr_warning;
+extern libapi_print_fn_t __pr_warn;
 extern libapi_print_fn_t __pr_info;
 extern libapi_print_fn_t __pr_debug;
 
-#define pr_warning(fmt, ...)   __pr(__pr_warning, fmt, ##__VA_ARGS__)
+#define pr_warn(fmt, ...)  __pr(__pr_warn, fmt, ##__VA_ARGS__)
 #define pr_info(fmt, ...)  __pr(__pr_info, fmt, ##__VA_ARGS__)
 #define pr_debug(fmt, ...) __pr(__pr_debug, fmt, ##__VA_ARGS__)
 
diff --git a/tools/lib/api/debug.c b/tools/lib/api/debug.c
index 69b1ba3d1ee3..7708f0558e8c 100644
--- a/tools/lib/api/debug.c
+++ b/tools/lib/api/debug.c
@@ -15,7 +15,7 @@ static int __base_pr(const char *format, ...)
return err;
 }
 
-libapi_print_fn_t __pr_warning = __base_pr;
+libapi_print_fn_t __pr_warn= __base_pr;
 libapi_print_fn_t __pr_info= __base_pr;
 libapi_print_fn_t __pr_debug;
 
@@ -23,7 +23,7 @@ void libapi_set_print(libapi_print_fn_t warn,
  libapi_print_fn_t info,
  libapi_print_fn_t debug)
 {
-   __pr_warning = warn;
+   __pr_warn= warn;
__pr_info= info;
__pr_debug   = debug;
 }
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 7aba8243a0e7..11b3885e833e 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -381,8 +381,8 @@ int filename__read_str(const char *filename, char **buf, 
size_t *sizep)
n = read(fd, bf + size, alloc_size - size);
if (n < 0) {
if (size) {
-   pr_warning("read failed %d: %s\n", errno,
-strerror_r(errno, sbuf, sizeof(sbuf)));
+   pr_warn("read failed %d: %s\n", errno,
+   strerror_r(errno, sbuf, sizeof(sbuf)));
err = 0;
} else
err = -errno;
-- 
2.20.1



Re: [PATCH 4/8] riscv: ensure RISC-V C model definitions are passed to static analyzers

2019-10-17 Thread Luc Van Oostenryck
On Thu, Oct 17, 2019 at 05:49:25PM -0700, Paul Walmsley wrote:
> Static analysis tools such as sparse don't set the RISC-V C model
> preprocessor directives such as "__riscv_cmodel_medany", set by the C
> compilers.  This causes the static analyzers to evaluate different
> preprocessor paths than C compilers would.  Fix this by defining the
> appropriate C model macros in the static analyzer command lines.
> 
> Signed-off-by: Paul Walmsley 
> ---
>  arch/riscv/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index f5e914210245..0247a90bd4d8 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -47,9 +47,11 @@ KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
>  
>  ifeq ($(CONFIG_CMODEL_MEDLOW),y)
>   KBUILD_CFLAGS += -mcmodel=medlow
> + CHECKFLAGS += -D__riscv_cmodel_medlow
>  endif
>  ifeq ($(CONFIG_CMODEL_MEDANY),y)
>   KBUILD_CFLAGS += -mcmodel=medany
> + CHECKFLAGS += -D__riscv_cmodel_medany

I can teach sparse about this in the following days.

-- Luc Van Oostenryck


[PATCH v2 26/33] trace: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Steven Rostedt 
Cc: Ingo Molnar 
Acked-by: Steven Rostedt (VMware) 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 kernel/trace/trace_benchmark.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_benchmark.c b/kernel/trace/trace_benchmark.c
index 80e0b2aca703..2e9a4746ea85 100644
--- a/kernel/trace/trace_benchmark.c
+++ b/kernel/trace/trace_benchmark.c
@@ -178,14 +178,14 @@ static int benchmark_event_kthread(void *arg)
 int trace_benchmark_reg(void)
 {
if (!ok_to_run) {
-   pr_warning("trace benchmark cannot be started via kernel 
command line\n");
+   pr_warn("trace benchmark cannot be started via kernel command 
line\n");
return -EBUSY;
}
 
bm_event_thread = kthread_run(benchmark_event_kthread,
  NULL, "event_benchmark");
if (IS_ERR(bm_event_thread)) {
-   pr_warning("trace benchmark failed to create kernel thread\n");
+   pr_warn("trace benchmark failed to create kernel thread\n");
return PTR_ERR(bm_event_thread);
}
 
-- 
2.20.1



[PATCH v2 16/33] of: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Rob Herring 
Cc: Frank Rowand 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/of/fdt.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d01d834b26b0..2cdf64d2456f 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -412,8 +412,8 @@ void *__unflatten_device_tree(const void *blob,
/* Second pass, do actual unflattening */
unflatten_dt_nodes(blob, mem, dad, mynodes);
if (be32_to_cpup(mem + size) != 0xdeadbeef)
-   pr_warning("End of tree marker overwritten: %08x\n",
-  be32_to_cpup(mem + size));
+   pr_warn("End of tree marker overwritten: %08x\n",
+   be32_to_cpup(mem + size));
 
if (detached && mynodes) {
of_node_set_flag(*mynodes, OF_DETACHED);
@@ -1120,25 +1120,25 @@ void __init __weak early_init_dt_add_memory_arch(u64 
base, u64 size)
size &= PAGE_MASK;
 
if (base > MAX_MEMBLOCK_ADDR) {
-   pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
-   base, base + size);
+   pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
+   base, base + size);
return;
}
 
if (base + size - 1 > MAX_MEMBLOCK_ADDR) {
-   pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
-   ((u64)MAX_MEMBLOCK_ADDR) + 1, base + size);
+   pr_warn("Ignoring memory range 0x%llx - 0x%llx\n",
+   ((u64)MAX_MEMBLOCK_ADDR) + 1, base + size);
size = MAX_MEMBLOCK_ADDR - base + 1;
}
 
if (base + size < phys_offset) {
-   pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
-  base, base + size);
+   pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
+   base, base + size);
return;
}
if (base < phys_offset) {
-   pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
-  base, phys_offset);
+   pr_warn("Ignoring memory range 0x%llx - 0x%llx\n",
+   base, phys_offset);
size -= phys_offset - base;
base = phys_offset;
}
-- 
2.20.1



[PATCH v2 33/33] checkpatch: Drop pr_warning check

2019-10-17 Thread Kefeng Wang
For now, all pr_warning are removed, delete pr_warning check in
checkpatch.

Cc: Andy Whitcroft 
Cc: Joe Perches 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 scripts/checkpatch.pl | 9 -
 1 file changed, 9 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a85d719df1f4..ac9b6a3f1547 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4135,15 +4135,6 @@ sub process {
 "Prefer [subsystem eg: 
netdev]_$level2([subsystem]dev, ... then dev_$level2(dev, ... then 
pr_$level(...  to printk(KERN_$orig ...\n" . $herecurr);
}
 
-   if ($line =~ /\bpr_warning\s*\(/) {
-   if (WARN("PREFER_PR_LEVEL",
-"Prefer pr_warn(... to pr_warning(...\n" . 
$herecurr) &&
-   $fix) {
-   $fixed[$fixlinenr] =~
-   s/\bpr_warning\b/pr_warn/;
-   }
-   }
-
if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
my $orig = $1;
my $level = lc($orig);
-- 
2.20.1



[PATCH v2 15/33] macintosh: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Benjamin Herrenschmidt 
Cc: linuxppc-...@lists.ozlabs.org
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/macintosh/windfarm_fcu_controls.c |  4 +---
 drivers/macintosh/windfarm_lm87_sensor.c  |  4 ++--
 drivers/macintosh/windfarm_pm72.c | 22 +++---
 drivers/macintosh/windfarm_rm31.c |  6 +++---
 4 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/macintosh/windfarm_fcu_controls.c 
b/drivers/macintosh/windfarm_fcu_controls.c
index 3c971297b6dc..67daeec94b44 100644
--- a/drivers/macintosh/windfarm_fcu_controls.c
+++ b/drivers/macintosh/windfarm_fcu_controls.c
@@ -468,9 +468,7 @@ static void wf_fcu_lookup_fans(struct wf_fcu_priv *pv)
else
id = ((*reg) - 0x30) / 2;
if (id > 7) {
-   pr_warning("wf_fcu: Can't parse "
-  "fan ID in device-tree for %pOF\n",
-  np);
+   pr_warn("wf_fcu: Can't parse fan ID in 
device-tree for %pOF\n", np);
break;
}
wf_fcu_add_fan(pv, name, type, id);
diff --git a/drivers/macintosh/windfarm_lm87_sensor.c 
b/drivers/macintosh/windfarm_lm87_sensor.c
index e44525b19071..b03a33b803b7 100644
--- a/drivers/macintosh/windfarm_lm87_sensor.c
+++ b/drivers/macintosh/windfarm_lm87_sensor.c
@@ -124,8 +124,8 @@ static int wf_lm87_probe(struct i2c_client *client,
}
}
if (!name) {
-   pr_warning("wf_lm87: Unsupported sensor %pOF\n",
-  client->dev.of_node);
+   pr_warn("wf_lm87: Unsupported sensor %pOF\n",
+   client->dev.of_node);
return -ENODEV;
}
 
diff --git a/drivers/macintosh/windfarm_pm72.c 
b/drivers/macintosh/windfarm_pm72.c
index c5da0fc24884..e81746b87cff 100644
--- a/drivers/macintosh/windfarm_pm72.c
+++ b/drivers/macintosh/windfarm_pm72.c
@@ -285,8 +285,8 @@ static void cpu_fans_tick_split(void)
/* Apply result directly to exhaust fan */
err = wf_control_set(cpu_rear_fans[cpu], sp->target);
if (err) {
-   pr_warning("wf_pm72: Fan %s reports error %d\n",
-  cpu_rear_fans[cpu]->name, err);
+   pr_warn("wf_pm72: Fan %s reports error %d\n",
+   cpu_rear_fans[cpu]->name, err);
failure_state |= FAILURE_FAN;
break;
}
@@ -296,8 +296,8 @@ static void cpu_fans_tick_split(void)
DBG_LOTS("  CPU%d: intake = %d RPM\n", cpu, intake);
err = wf_control_set(cpu_front_fans[cpu], intake);
if (err) {
-   pr_warning("wf_pm72: Fan %s reports error %d\n",
-  cpu_front_fans[cpu]->name, err);
+   pr_warn("wf_pm72: Fan %s reports error %d\n",
+   cpu_front_fans[cpu]->name, err);
failure_state |= FAILURE_FAN;
break;
}
@@ -367,22 +367,22 @@ static void cpu_fans_tick_combined(void)
for (cpu = 0; cpu < nr_chips; cpu++) {
err = wf_control_set(cpu_rear_fans[cpu], sp->target);
if (err) {
-   pr_warning("wf_pm72: Fan %s reports error %d\n",
-  cpu_rear_fans[cpu]->name, err);
+   pr_warn("wf_pm72: Fan %s reports error %d\n",
+   cpu_rear_fans[cpu]->name, err);
failure_state |= FAILURE_FAN;
}
err = wf_control_set(cpu_front_fans[cpu], intake);
if (err) {
-   pr_warning("wf_pm72: Fan %s reports error %d\n",
-  cpu_front_fans[cpu]->name, err);
+   pr_warn("wf_pm72: Fan %s reports error %d\n",
+   cpu_front_fans[cpu]->name, err);
failure_state |= FAILURE_FAN;
}
err = 0;
if (cpu_pumps[cpu])
err = wf_control_set(cpu_pumps[cpu], pump);
if (err) {
-   pr_warning("wf_pm72: Pump %s reports error %d\n",
-  cpu_pumps[cpu]->name, err);
+   pr_warn("wf_pm72: Pump %s reports error %d\n",
+   cpu_pumps[cpu]->name, err);
failure_state |= FAILURE_FAN;
}
}
@@ -561,7 +561,7 @@ static void drives_fan_tick(void)
 
 

[PATCH v2 27/33] lib: cpu_rmap: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Andrew Morton 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 lib/cpu_rmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/cpu_rmap.c b/lib/cpu_rmap.c
index 075f3788bbe4..f08d9c56f712 100644
--- a/lib/cpu_rmap.c
+++ b/lib/cpu_rmap.c
@@ -255,7 +255,7 @@ irq_cpu_rmap_notify(struct irq_affinity_notify *notify, 
const cpumask_t *mask)
 
rc = cpu_rmap_update(glue->rmap, glue->index, mask);
if (rc)
-   pr_warning("irq_cpu_rmap_notify: update failed: %d\n", rc);
+   pr_warn("irq_cpu_rmap_notify: update failed: %d\n", rc);
 }
 
 /**
-- 
2.20.1



[PATCH] media: rcar_drif: fix a memory disclosure

2019-10-17 Thread Kangjie Lu
"f->fmt.sdr.reserved" is uninitialized. As other peer drivers
like msi2500 and airspy do, the fix initializes it to avoid
memory disclosures.

Signed-off-by: Kangjie Lu 
---
 drivers/media/platform/rcar_drif.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/rcar_drif.c 
b/drivers/media/platform/rcar_drif.c
index 608e5217ccd5..0f267a237b42 100644
--- a/drivers/media/platform/rcar_drif.c
+++ b/drivers/media/platform/rcar_drif.c
@@ -912,6 +912,7 @@ static int rcar_drif_g_fmt_sdr_cap(struct file *file, void 
*priv,
 {
struct rcar_drif_sdr *sdr = video_drvdata(file);
 
+   memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
f->fmt.sdr.pixelformat = sdr->fmt->pixelformat;
f->fmt.sdr.buffersize = sdr->fmt->buffersize;
 
-- 
2.17.1



[PATCH v2 12/33] crypto: n2: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Herbert Xu 
Cc: "David S. Miller" 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/crypto/n2_core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c
index dc15b06e96ab..40b81013213e 100644
--- a/drivers/crypto/n2_core.c
+++ b/drivers/crypto/n2_core.c
@@ -381,8 +381,8 @@ static int n2_hash_cra_init(struct crypto_tfm *tfm)
fallback_tfm = crypto_alloc_ahash(fallback_driver_name, 0,
  CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback_tfm)) {
-   pr_warning("Fallback driver '%s' could not be loaded!\n",
-  fallback_driver_name);
+   pr_warn("Fallback driver '%s' could not be loaded!\n",
+   fallback_driver_name);
err = PTR_ERR(fallback_tfm);
goto out;
}
@@ -418,16 +418,16 @@ static int n2_hmac_cra_init(struct crypto_tfm *tfm)
fallback_tfm = crypto_alloc_ahash(fallback_driver_name, 0,
  CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback_tfm)) {
-   pr_warning("Fallback driver '%s' could not be loaded!\n",
-  fallback_driver_name);
+   pr_warn("Fallback driver '%s' could not be loaded!\n",
+   fallback_driver_name);
err = PTR_ERR(fallback_tfm);
goto out;
}
 
child_shash = crypto_alloc_shash(n2alg->child_alg, 0, 0);
if (IS_ERR(child_shash)) {
-   pr_warning("Child shash '%s' could not be loaded!\n",
-  n2alg->child_alg);
+   pr_warn("Child shash '%s' could not be loaded!\n",
+   n2alg->child_alg);
err = PTR_ERR(child_shash);
goto out_free_fallback;
}
-- 
2.20.1



[PATCH v2 18/33] platform/x86: eeepc-laptop: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Corentin Chary 
Cc: Darren Hart 
Cc: Andy Shevchenko 
Cc: Andy Shevchenko 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/platform/x86/eeepc-laptop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/eeepc-laptop.c 
b/drivers/platform/x86/eeepc-laptop.c
index f3f74a9c109e..776868d5e458 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -578,7 +578,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop 
*eeepc, acpi_handle handle)
 
port = acpi_get_pci_dev(handle);
if (!port) {
-   pr_warning("Unable to find port\n");
+   pr_warn("Unable to find port\n");
goto out_unlock;
}
 
-- 
2.20.1



[PATCH v2 29/33] printk: Drop pr_warning

2019-10-17 Thread Kefeng Wang
With all pr_warning are removed, saftely drop pr_warning definition.

Cc: Petr Mladek 
Cc: Sergey Senozhatsky 
Cc: Steven Rostedt 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 include/linux/printk.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index c09d67edda3a..1e6108b8d15f 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -302,9 +302,8 @@ extern int kptr_restrict;
printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
 #define pr_err(fmt, ...) \
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning(fmt, ...) \
+#define pr_warn(fmt, ...) \
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warn pr_warning
 #define pr_notice(fmt, ...) \
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
 #define pr_info(fmt, ...) \
-- 
2.20.1



[PATCH v2 02/33] arm64: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Will Deacon 
Cc: Mark Rutland 
Cc: Catalin Marinas 
Acked-by: Will Deacon 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 arch/arm64/kernel/hw_breakpoint.c |  8 
 arch/arm64/kernel/smp.c   | 11 +--
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/kernel/hw_breakpoint.c 
b/arch/arm64/kernel/hw_breakpoint.c
index 38ee1514cd9c..0b727edf4104 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -51,7 +51,7 @@ int hw_breakpoint_slots(int type)
case TYPE_DATA:
return get_num_wrps();
default:
-   pr_warning("unknown slot type: %d\n", type);
+   pr_warn("unknown slot type: %d\n", type);
return 0;
}
 }
@@ -112,7 +112,7 @@ static u64 read_wb_reg(int reg, int n)
GEN_READ_WB_REG_CASES(AARCH64_DBG_REG_WVR, AARCH64_DBG_REG_NAME_WVR, 
val);
GEN_READ_WB_REG_CASES(AARCH64_DBG_REG_WCR, AARCH64_DBG_REG_NAME_WCR, 
val);
default:
-   pr_warning("attempt to read from unknown breakpoint register 
%d\n", n);
+   pr_warn("attempt to read from unknown breakpoint register 
%d\n", n);
}
 
return val;
@@ -127,7 +127,7 @@ static void write_wb_reg(int reg, int n, u64 val)
GEN_WRITE_WB_REG_CASES(AARCH64_DBG_REG_WVR, AARCH64_DBG_REG_NAME_WVR, 
val);
GEN_WRITE_WB_REG_CASES(AARCH64_DBG_REG_WCR, AARCH64_DBG_REG_NAME_WCR, 
val);
default:
-   pr_warning("attempt to write to unknown breakpoint register 
%d\n", n);
+   pr_warn("attempt to write to unknown breakpoint register %d\n", 
n);
}
isb();
 }
@@ -145,7 +145,7 @@ static enum dbg_active_el debug_exception_level(int 
privilege)
case AARCH64_BREAKPOINT_EL1:
return DBG_ACTIVE_EL1;
default:
-   pr_warning("invalid breakpoint privilege level %d\n", 
privilege);
+   pr_warn("invalid breakpoint privilege level %d\n", privilege);
return -EINVAL;
}
 }
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index dc9fe879c279..ab149bcc3dc7 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -345,8 +345,7 @@ void __cpu_die(unsigned int cpu)
 */
err = op_cpu_kill(cpu);
if (err)
-   pr_warn("CPU%d may not have shut down cleanly: %d\n",
-   cpu, err);
+   pr_warn("CPU%d may not have shut down cleanly: %d\n", cpu, err);
 }
 
 /*
@@ -976,8 +975,8 @@ void smp_send_stop(void)
udelay(1);
 
if (num_online_cpus() > 1)
-   pr_warning("SMP: failed to stop secondary CPUs %*pbl\n",
-  cpumask_pr_args(cpu_online_mask));
+   pr_warn("SMP: failed to stop secondary CPUs %*pbl\n",
+   cpumask_pr_args(cpu_online_mask));
 
sdei_mask_local_cpu();
 }
@@ -1017,8 +1016,8 @@ void crash_smp_send_stop(void)
udelay(1);
 
if (atomic_read(_for_crash_ipi) > 0)
-   pr_warning("SMP: failed to stop secondary CPUs %*pbl\n",
-  cpumask_pr_args());
+   pr_warn("SMP: failed to stop secondary CPUs %*pbl\n",
+   cpumask_pr_args());
 
sdei_mask_local_cpu();
 }
-- 
2.20.1



[PATCH v2 19/33] platform/x86: asus-laptop: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Corentin Chary 
Cc: Darren Hart 
Cc: Andy Shevchenko 
Cc: Andy Shevchenko 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/platform/x86/asus-laptop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/asus-laptop.c 
b/drivers/platform/x86/asus-laptop.c
index fc6446209854..a666fbc2e73b 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1148,7 +1148,7 @@ static void asus_als_switch(struct asus_laptop *asus, int 
value)
ret = write_acpi_int(asus->handle, METHOD_ALS_CONTROL, value);
}
if (ret)
-   pr_warning("Error setting light sensor switch\n");
+   pr_warn("Error setting light sensor switch\n");
 
asus->light_switch = value;
 }
-- 
2.20.1



[PATCH v2 25/33] dma-debug: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Christoph Hellwig 
Cc: Marek Szyprowski 
Cc: Robin Murphy 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 kernel/dma/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index 099002d84f46..a26170469543 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -161,7 +161,7 @@ static inline void dump_entry_trace(struct dma_debug_entry 
*entry)
 {
 #ifdef CONFIG_STACKTRACE
if (entry) {
-   pr_warning("Mapped at:\n");
+   pr_warn("Mapped at:\n");
stack_trace_print(entry->stack_entries, entry->stack_len, 0);
}
 #endif
-- 
2.20.1



[PATCH v2 24/33] vgacon: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Bartlomiej Zolnierkiewicz 
Cc: linux-fb...@vger.kernel.org
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/video/console/vgacon.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index c6b3bdbbdbc9..de7b8382aba9 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -113,9 +113,9 @@ static int __init text_mode(char *str)
 {
vgacon_text_mode_force = true;
 
-   pr_warning("You have booted with nomodeset. This means your GPU drivers 
are DISABLED\n");
-   pr_warning("Any video related functionality will be severely degraded, 
and you may not even be able to suspend the system properly\n");
-   pr_warning("Unless you actually understand what nomodeset does, you 
should reboot without enabling it\n");
+   pr_warn("You have booted with nomodeset. This means your GPU drivers 
are DISABLED\n");
+   pr_warn("Any video related functionality will be severely degraded, and 
you may not even be able to suspend the system properly\n");
+   pr_warn("Unless you actually understand what nomodeset does, you should 
reboot without enabling it\n");
 
return 1;
 }
-- 
2.20.1



[PATCH v2 32/33] tools perf: Renaming pr_warning to pr_warn

2019-10-17 Thread Kefeng Wang
For kernel logging macro, pr_warning is completely removed and
replaced by pr_warn, using pr_warn in tools perf for symmetry
to kernel logging macro, then we could drop pr_warning in the
whole linux code.

Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Mark Rutland 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 tools/perf/arch/x86/util/intel-pt.c  |   2 +-
 tools/perf/builtin-annotate.c|   7 +-
 tools/perf/builtin-buildid-cache.c   |  28 +++---
 tools/perf/builtin-diff.c|  12 +--
 tools/perf/builtin-help.c|  10 +-
 tools/perf/builtin-inject.c  |   8 +-
 tools/perf/builtin-probe.c   |  14 +--
 tools/perf/builtin-record.c  |  10 +-
 tools/perf/builtin-report.c  |   2 +-
 tools/perf/builtin-script.c  |  14 +--
 tools/perf/builtin-stat.c|  18 ++--
 tools/perf/builtin-timechart.c   |  12 +--
 tools/perf/builtin-top.c |   2 +-
 tools/perf/builtin-trace.c   |   8 +-
 tools/perf/lib/internal.h|   2 +-
 tools/perf/ui/browsers/scripts.c |   2 +-
 tools/perf/util/bpf-loader.c |   6 +-
 tools/perf/util/bpf-prologue.c   |   4 +-
 tools/perf/util/callchain.c  |   2 +-
 tools/perf/util/config.c |   8 +-
 tools/perf/util/data-convert-bt.c|   4 +-
 tools/perf/util/data.c   |   2 +-
 tools/perf/util/debug.c  |   4 +-
 tools/perf/util/debug.h  |   2 +-
 tools/perf/util/event.c  |   4 +-
 tools/perf/util/evlist.c |   4 +-
 tools/perf/util/evsel.c  |  19 ++--
 tools/perf/util/header.c |  20 ++--
 tools/perf/util/jitdump.c|   4 +-
 tools/perf/util/llvm-utils.c |  18 ++--
 tools/perf/util/machine.c|   2 +-
 tools/perf/util/parse-branch-options.c   |   3 +-
 tools/perf/util/perf-hooks.c |   6 +-
 tools/perf/util/probe-event.c|  90 +-
 tools/perf/util/probe-file.c |  36 +++
 tools/perf/util/probe-finder.c   | 115 +++
 tools/perf/util/record.c |  18 ++--
 tools/perf/util/session.c|   2 +-
 tools/perf/util/srcline.c|   6 +-
 tools/perf/util/synthetic-events.c   |  10 +-
 tools/perf/util/thread-stack.c   |   4 +-
 tools/perf/util/thread_map.c |   2 +-
 tools/perf/util/trace-event-parse.c  |   2 +-
 tools/perf/util/unwind-libunwind-local.c |   9 +-
 44 files changed, 273 insertions(+), 284 deletions(-)

diff --git a/tools/perf/arch/x86/util/intel-pt.c 
b/tools/perf/arch/x86/util/intel-pt.c
index d6d26256915f..7ce07da4abb1 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -530,7 +530,7 @@ static int intel_pt_validate_config(struct perf_pmu 
*intel_pt_pmu,
 */
if (perf_pmu__scan_file(intel_pt_pmu, "format/pt", "%c", ) == 1 &&
!(evsel->core.attr.config & 1)) {
-   pr_warning("pt=0 doesn't make sense, forcing pt=1\n");
+   pr_warn("pt=0 doesn't make sense, forcing pt=1\n");
evsel->core.attr.config |= 1;
}
 
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 8db8fc9bddef..9be57f894d09 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -269,8 +269,8 @@ static int process_sample_event(struct perf_tool *tool,
int ret = 0;
 
if (machine__resolve(machine, , sample) < 0) {
-   pr_warning("problem processing %d event, skipping it.\n",
-  event->header.type);
+   pr_warn("problem processing %d event, skipping it.\n",
+   event->header.type);
return -1;
}
 
@@ -279,8 +279,7 @@ static int process_sample_event(struct perf_tool *tool,
 
if (!al.filtered &&
perf_evsel__add_sample(evsel, sample, , ann, machine)) {
-   pr_warning("problem incrementing symbol count, "
-  "skipping event\n");
+   pr_warn("problem incrementing symbol count, skipping event\n");
ret = -1;
}
 out_put:
diff --git a/tools/perf/builtin-buildid-cache.c 
b/tools/perf/builtin-buildid-cache.c
index 39efa51d7fb3..3d81f8a94c55 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -282,11 +282,11 @@ static bool dso__missing_buildid_cache(struct dso *dso, 
int parm __maybe_unused)
if (errno == ENOENT)
return false;
 
-   pr_warning("Problems with %s file, consider removing it from 
the cache\n",
-  filename);
+   pr_warn("Problems with %s file, consider 

[PATCH v2 23/33] fs: afs: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: David Howells 
Cc: linux-...@lists.infradead.org
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 fs/afs/flock.c |  4 ++--
 fs/afs/inode.c | 13 ++---
 fs/afs/yfsclient.c |  4 ++--
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/fs/afs/flock.c b/fs/afs/flock.c
index d5e5a6ddc847..0f2a94ba73cb 100644
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -346,8 +346,8 @@ void afs_lock_work(struct work_struct *work)
if (ret < 0) {
trace_afs_flock_ev(vnode, NULL, afs_flock_extend_fail,
   ret);
-   pr_warning("AFS: Failed to extend lock on {%llx:%llx} 
error %d\n",
-  vnode->fid.vid, vnode->fid.vnode, ret);
+   pr_warn("AFS: Failed to extend lock on {%llx:%llx} 
error %d\n",
+   vnode->fid.vid, vnode->fid.vnode, ret);
}
 
spin_lock(>lock);
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 46d2d7cb461d..281470fe1183 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -34,8 +34,7 @@ static noinline void dump_vnode(struct afs_vnode *vnode, 
struct afs_vnode *paren
 {
static unsigned long once_only;
 
-   pr_warn("kAFS: AFS vnode with undefined type %u\n",
-   vnode->status.type);
+   pr_warn("kAFS: AFS vnode with undefined type %u\n", vnode->status.type);
pr_warn("kAFS: A=%d m=%o s=%llx v=%llx\n",
vnode->status.abort_code,
vnode->status.mode,
@@ -175,11 +174,11 @@ static void afs_apply_status(struct afs_fs_cursor *fc,
BUG_ON(test_bit(AFS_VNODE_UNSET, >flags));
 
if (status->type != vnode->status.type) {
-   pr_warning("Vnode %llx:%llx:%x changed type %u to %u\n",
-  vnode->fid.vid,
-  vnode->fid.vnode,
-  vnode->fid.unique,
-  status->type, vnode->status.type);
+   pr_warn("Vnode %llx:%llx:%x changed type %u to %u\n",
+   vnode->fid.vid,
+   vnode->fid.vnode,
+   vnode->fid.unique,
+   status->type, vnode->status.type);
afs_protocol_error(NULL, -EBADMSG, afs_eproto_bad_status);
return;
}
diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c
index 3ee7abf4b2d0..9ac035c17dc4 100644
--- a/fs/afs/yfsclient.c
+++ b/fs/afs/yfsclient.c
@@ -152,8 +152,8 @@ static void yfs_check_req(struct afs_call *call, __be32 *bp)
pr_err("kAFS: %s: Request buffer overflow (%zu>%u)\n",
   call->type->name, len, call->request_size);
else if (len < call->request_size)
-   pr_warning("kAFS: %s: Request buffer underflow (%zu<%u)\n",
-  call->type->name, len, call->request_size);
+   pr_warn("kAFS: %s: Request buffer underflow (%zu<%u)\n",
+   call->type->name, len, call->request_size);
 }
 
 /*
-- 
2.20.1



[PATCH v2 28/33] ASoC: samsung: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Krzysztof Kozlowski 
Cc: Sangbeom Kim 
Cc: Sylwester Nawrocki 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 sound/soc/samsung/s3c-i2s-v2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c
index 7e196b599be1..593be1b668d6 100644
--- a/sound/soc/samsung/s3c-i2s-v2.c
+++ b/sound/soc/samsung/s3c-i2s-v2.c
@@ -672,13 +672,13 @@ static int s3c2412_i2s_suspend(struct snd_soc_dai *dai)
iismod = readl(i2s->regs + S3C2412_IISMOD);
 
if (iismod & S3C2412_IISCON_RXDMA_ACTIVE)
-   pr_warning("%s: RXDMA active?\n", __func__);
+   pr_warn("%s: RXDMA active?\n", __func__);
 
if (iismod & S3C2412_IISCON_TXDMA_ACTIVE)
-   pr_warning("%s: TXDMA active?\n", __func__);
+   pr_warn("%s: TXDMA active?\n", __func__);
 
if (iismod & S3C2412_IISCON_IIS_ACTIVE)
-   pr_warning("%s: IIS active\n", __func__);
+   pr_warn("%s: IIS active\n", __func__);
}
 
return 0;
-- 
2.20.1



[PATCH v2 14/33] idsn: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Karsten Keil 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/isdn/hardware/mISDN/avmfritz.c  | 16 
 drivers/isdn/hardware/mISDN/hfcmulti.c  |  8 
 drivers/isdn/hardware/mISDN/hfcpci.c|  3 +--
 drivers/isdn/hardware/mISDN/hfcsusb.c   |  4 ++--
 drivers/isdn/hardware/mISDN/mISDNipac.c |  4 ++--
 drivers/isdn/hardware/mISDN/mISDNisar.c | 10 +-
 drivers/isdn/hardware/mISDN/netjet.c|  8 
 drivers/isdn/hardware/mISDN/w6692.c | 12 ++--
 drivers/isdn/mISDN/hwchannel.c  |  7 +++
 9 files changed, 35 insertions(+), 37 deletions(-)

diff --git a/drivers/isdn/hardware/mISDN/avmfritz.c 
b/drivers/isdn/hardware/mISDN/avmfritz.c
index 1137dd152b5c..ecc1ef6c386d 100644
--- a/drivers/isdn/hardware/mISDN/avmfritz.c
+++ b/drivers/isdn/hardware/mISDN/avmfritz.c
@@ -402,8 +402,8 @@ hdlc_empty_fifo(struct bchannel *bch, int count)
} else {
cnt = bchannel_get_rxbuf(bch, count);
if (cnt < 0) {
-   pr_warning("%s.B%d: No bufferspace for %d bytes\n",
-  fc->name, bch->nr, count);
+   pr_warn("%s.B%d: No bufferspace for %d bytes\n",
+   fc->name, bch->nr, count);
return;
}
p = skb_put(bch->rx_skb, count);
@@ -538,8 +538,8 @@ HDLC_irq(struct bchannel *bch, u32 stat)
}
if (stat & HDLC_INT_RPR) {
if (stat & HDLC_STAT_RDO) {
-   pr_warning("%s: ch%d stat %x RDO\n",
-  fc->name, bch->nr, stat);
+   pr_warn("%s: ch%d stat %x RDO\n",
+   fc->name, bch->nr, stat);
hdlc->ctrl.sr.xml = 0;
hdlc->ctrl.sr.cmd |= HDLC_CMD_RRS;
write_ctrl(bch, 1);
@@ -561,8 +561,8 @@ HDLC_irq(struct bchannel *bch, u32 stat)
HDLC_STAT_CRCVFR) {
recv_Bchannel(bch, 0, false);
} else {
-   pr_warning("%s: got invalid frame\n",
-  fc->name);
+   pr_warn("%s: got invalid frame\n",
+   fc->name);
skb_trim(bch->rx_skb, 0);
}
}
@@ -574,8 +574,8 @@ HDLC_irq(struct bchannel *bch, u32 stat)
 * restart transmitting the whole frame on HDLC
 * in transparent mode we send the next data
 */
-   pr_warning("%s: ch%d stat %x XDU %s\n", fc->name, bch->nr,
-  stat, bch->tx_skb ? "tx_skb" : "no tx_skb");
+   pr_warn("%s: ch%d stat %x XDU %s\n", fc->name, bch->nr,
+   stat, bch->tx_skb ? "tx_skb" : "no tx_skb");
if (bch->tx_skb && bch->tx_skb->len) {
if (!test_bit(FLG_TRANSPARENT, >Flags))
bch->tx_idx = 0;
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c 
b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 86669ec8b977..7013a3f08429 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -2248,8 +2248,8 @@ hfcmulti_rx(struct hfc_multi *hc, int ch)
if (bch) {
maxlen = bchannel_get_rxbuf(bch, Zsize);
if (maxlen < 0) {
-   pr_warning("card%d.B%d: No bufferspace for %d bytes\n",
-  hc->id + 1, bch->nr, Zsize);
+   pr_warn("card%d.B%d: No bufferspace for %d bytes\n",
+   hc->id + 1, bch->nr, Zsize);
return;
}
sp = >rx_skb;
@@ -2260,8 +2260,8 @@ hfcmulti_rx(struct hfc_multi *hc, int ch)
if (*sp == NULL) {
*sp = mI_alloc_skb(maxlen, GFP_ATOMIC);
if (*sp == NULL) {
-   pr_warning("card%d: No mem for dch rx_skb\n",
-  hc->id + 1);
+   pr_warn("card%d: No mem for dch rx_skb\n",
+   hc->id + 1);
return;
}
}
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c 
b/drivers/isdn/hardware/mISDN/hfcpci.c
index 2330a7d24267..abdf787c1a71 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -566,8 +566,7 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo 

[PATCH v2 13/33] ide: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: "David S. Miller" 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/ide/tx4938ide.c | 2 +-
 drivers/ide/tx4939ide.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c
index 40a3f55b08dd..962eb92501b5 100644
--- a/drivers/ide/tx4938ide.c
+++ b/drivers/ide/tx4938ide.c
@@ -46,7 +46,7 @@ static void tx4938ide_tune_ebusc(unsigned int ebus_ch,
while ((shwt * 4 + wt + (wt ? 2 : 3)) * cycle < t->cycle)
shwt++;
if (shwt > 7) {
-   pr_warning("tx4938ide: SHWT violation (%d)\n", shwt);
+   pr_warn("tx4938ide: SHWT violation (%d)\n", shwt);
shwt = 7;
}
pr_debug("tx4938ide: ebus %d, bus cycle %dns, WT %d, SHWT %d\n",
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index 88d132edc4e3..d5e871fe840d 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -363,9 +363,9 @@ static int tx4939ide_dma_test_irq(ide_drive_t *drive)
case TX4939IDE_INT_HOST | TX4939IDE_INT_XFEREND:
dma_stat = tx4939ide_readb(base, TX4939IDE_DMA_Stat);
if (!(dma_stat & ATA_DMA_INTR))
-   pr_warning("%s: weird interrupt status. "
-  "DMA_Stat %#02x int_ctl %#04x\n",
-  hwif->name, dma_stat, ctl);
+   pr_warn("%s: weird interrupt status. "
+   "DMA_Stat %#02x int_ctl %#04x\n",
+   hwif->name, dma_stat, ctl);
found = 1;
break;
}
-- 
2.20.1



[PATCH v2 20/33] platform/x86: intel_oaktrail: Use pr_warn instead of pr_warning

2019-10-17 Thread Kefeng Wang
As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
pr_warning"), removing pr_warning so all logging messages use a
consistent _warn style. Let's do it.

Cc: Corentin Chary 
Cc: Darren Hart 
Cc: Andy Shevchenko 
Cc: Andy Shevchenko 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Kefeng Wang 
---
 drivers/platform/x86/intel_oaktrail.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/intel_oaktrail.c 
b/drivers/platform/x86/intel_oaktrail.c
index 3c0438ba385e..1a09a75bd16d 100644
--- a/drivers/platform/x86/intel_oaktrail.c
+++ b/drivers/platform/x86/intel_oaktrail.c
@@ -243,7 +243,7 @@ static int oaktrail_backlight_init(void)
 
if (IS_ERR(bd)) {
oaktrail_bl_device = NULL;
-   pr_warning("Unable to register backlight device\n");
+   pr_warn("Unable to register backlight device\n");
return PTR_ERR(bd);
}
 
@@ -313,20 +313,20 @@ static int __init oaktrail_init(void)
 
ret = platform_driver_register(_driver);
if (ret) {
-   pr_warning("Unable to register platform driver\n");
+   pr_warn("Unable to register platform driver\n");
goto err_driver_reg;
}
 
oaktrail_device = platform_device_alloc(DRIVER_NAME, -1);
if (!oaktrail_device) {
-   pr_warning("Unable to allocate platform device\n");
+   pr_warn("Unable to allocate platform device\n");
ret = -ENOMEM;
goto err_device_alloc;
}
 
ret = platform_device_add(oaktrail_device);
if (ret) {
-   pr_warning("Unable to add platform device\n");
+   pr_warn("Unable to add platform device\n");
goto err_device_add;
}
 
@@ -338,7 +338,7 @@ static int __init oaktrail_init(void)
 
ret = oaktrail_rfkill_init();
if (ret) {
-   pr_warning("Setup rfkill failed\n");
+   pr_warn("Setup rfkill failed\n");
goto err_rfkill;
}
 
-- 
2.20.1



  1   2   3   4   5   6   7   8   9   10   >