Re: [PATCH v2] ath10k: Remove msdu from idr when management pkt send fails

2020-05-07 Thread Kalle Valo
 writes:

> Yes, The change you did is correct and better.

Thanks for checking.

> So should I be sending a v3 for this patch ?

No need, the patch with this change is now in my pending branch and I'll
apply it to ath-next it in the next few days.

-- 
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


RE: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)

2020-05-07 Thread Shameerali Kolothum Thodi
Hi Eric,

> -Original Message-
> From: Shameerali Kolothum Thodi
> Sent: 30 April 2020 10:38
> To: 'Auger Eric' ; Zhangfei Gao
> ; eric.auger@gmail.com;
> io...@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> k...@vger.kernel.org; kvm...@lists.cs.columbia.edu; w...@kernel.org;
> j...@8bytes.org; m...@kernel.org; robin.mur...@arm.com
> Cc: jean-phili...@linaro.org; alex.william...@redhat.com;
> jacob.jun@linux.intel.com; yi.l@intel.com; peter.mayd...@linaro.org;
> t...@semihalf.com; bbhush...@marvell.com
> Subject: RE: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)
> 
> Hi Eric,
> 
> > -Original Message-
> > From: Auger Eric [mailto:eric.au...@redhat.com]
> > Sent: 16 April 2020 08:45
> > To: Zhangfei Gao ; eric.auger@gmail.com;
> > io...@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> > k...@vger.kernel.org; kvm...@lists.cs.columbia.edu; w...@kernel.org;
> > j...@8bytes.org; m...@kernel.org; robin.mur...@arm.com
> > Cc: jean-phili...@linaro.org; Shameerali Kolothum Thodi
> > ; alex.william...@redhat.com;
> > jacob.jun@linux.intel.com; yi.l@intel.com; peter.mayd...@linaro.org;
> > t...@semihalf.com; bbhush...@marvell.com
> > Subject: Re: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)
> >
> > Hi Zhangfei,
> >
> > On 4/16/20 6:25 AM, Zhangfei Gao wrote:
> > >
> > >
> > > On 2020/4/14 下午11:05, Eric Auger wrote:
> > >> This version fixes an issue observed by Shameer on an SMMU 3.2,
> > >> when moving from dual stage config to stage 1 only config.
> > >> The 2 high 64b of the STE now get reset. Otherwise, leaving the
> > >> S2TTB set may cause a C_BAD_STE error.
> > >>
> > >> This series can be found at:
> > >> https://github.com/eauger/linux/tree/v5.6-2stage-v11_10.1
> > >> (including the VFIO part)
> > >> The QEMU fellow series still can be found at:
> > >> https://github.com/eauger/qemu/tree/v4.2.0-2stage-rfcv6
> > >>
> > >> Users have expressed interest in that work and tested v9/v10:
> > >> - https://patchwork.kernel.org/cover/11039995/#23012381
> > >> - https://patchwork.kernel.org/cover/11039995/#23197235
> > >>
> > >> Background:
> > >>
> > >> This series brings the IOMMU part of HW nested paging support
> > >> in the SMMUv3. The VFIO part is submitted separately.
> > >>
> > >> The IOMMU API is extended to support 2 new API functionalities:
> > >> 1) pass the guest stage 1 configuration
> > >> 2) pass stage 1 MSI bindings
> > >>
> > >> Then those capabilities gets implemented in the SMMUv3 driver.
> > >>
> > >> The virtualizer passes information through the VFIO user API
> > >> which cascades them to the iommu subsystem. This allows the guest
> > >> to own stage 1 tables and context descriptors (so-called PASID
> > >> table) while the host owns stage 2 tables and main configuration
> > >> structures (STE).
> > >>
> > >>
> > >
> > > Thanks Eric
> > >
> > > Tested v11 on Hisilicon kunpeng920 board via hardware zip accelerator.
> > > 1. no-sva works, where guest app directly use physical address via ioctl.
> > Thank you for the testing. Glad it works for you.
> > > 2. vSVA still not work, same as v10,
> > Yes that's normal this series is not meant to support vSVM at this stage.
> >
> > I intend to add the missing pieces during the next weeks.
> 
> Thanks for that. I have made an attempt to add the vSVA based on
> your v10 + JPBs sva patches. The host kernel and Qemu changes can
> be found here[1][2].
> 
> This basically adds multiple pasid support on top of your changes.
> I have done some basic sanity testing and we have some initial success
> with the zip vf dev on our D06 platform. Please note that the STALL event is
> not yet supported though, but works fine if we mlock() guest usr mem.

I have added STALL support for our vSVA prototype and it seems to be
working(on our hardware). I have updated the kernel and qemu branches with
the same[1][2]. I should warn you though that these are prototype code and I am 
pretty
much re-using the VFIO_IOMMU_SET_PASID_TABLE interface for almost everything.
But thought of sharing, in case if it is useful somehow!.

Thanks,
Shameer

[1]https://github.com/hisilicon/kernel-dev/commits/vsva-prototype-host-v1

[2]https://github.com/hisilicon/qemu/tree/v4.2.0-2stage-rfcv6-vsva-prototype-v1


[PATCH v3 3/4] perf stat: Copy counts from prev_raw_counts to evsel->counts

2020-05-07 Thread Jin Yao
It would be useful to support the overall statistics for perf-stat
interval mode. For example, report the summary at the end of
"perf-stat -I" output.

But since perf-stat can support many aggregation modes, such as
--per-thread, --per-socket, -M and etc, we need a solution which
doesn't bring much complexity.

The idea is to use 'evsel->prev_raw_counts' which is updated in
each interval and it's saved with the latest counts. Before reporting
the summary, we copy the counts from evsel->prev_raw_counts to
evsel->counts, and next we just follow non-interval processing.

In evsel__compute_deltas, this patch saves counts to the position
of [cpu0,thread0] for AGGR_GLOBAL. After copying counts from
evsel->prev_raw_counts to evsel->counts, we don't need to
modify process_counter_maps in perf_stat_process_counter to let it
work well.

Signed-off-by: Jin Yao 
---
 tools/perf/util/evsel.c |  1 +
 tools/perf/util/stat.c  | 24 
 tools/perf/util/stat.h  |  1 +
 3 files changed, 26 insertions(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index f3e60c45d59a..898a697c7cdd 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1288,6 +1288,7 @@ void evsel__compute_deltas(struct evsel *evsel, int cpu, 
int thread,
if (cpu == -1) {
tmp = evsel->prev_raw_counts->aggr;
evsel->prev_raw_counts->aggr = *count;
+   *perf_counts(evsel->prev_raw_counts, 0, 0) = *count;
} else {
tmp = *perf_counts(evsel->prev_raw_counts, cpu, thread);
*perf_counts(evsel->prev_raw_counts, cpu, thread) = *count;
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 89e541564ed5..ede113805ecd 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -230,6 +230,30 @@ void perf_evlist__reset_prev_raw_counts(struct evlist 
*evlist)
perf_evsel__reset_prev_raw_counts(evsel);
 }
 
+static void perf_evsel__copy_prev_raw_counts(struct evsel *evsel)
+{
+   int ncpus = evsel__nr_cpus(evsel);
+   int nthreads = perf_thread_map__nr(evsel->core.threads);
+
+   for (int thread = 0; thread < nthreads; thread++) {
+   for (int cpu = 0; cpu < ncpus; cpu++) {
+   *perf_counts(evsel->counts, cpu, thread) =
+   *perf_counts(evsel->prev_raw_counts, cpu,
+thread);
+   }
+   }
+
+   evsel->counts->aggr = evsel->prev_raw_counts->aggr;
+}
+
+void perf_evlist__copy_prev_raw_counts(struct evlist *evlist)
+{
+   struct evsel *evsel;
+
+   evlist__for_each_entry(evlist, evsel)
+   perf_evsel__copy_prev_raw_counts(evsel);
+}
+
 static void zero_per_pkg(struct evsel *counter)
 {
if (counter->per_pkg_mask)
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index b4fdfaa7f2c0..62cf72c71869 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -198,6 +198,7 @@ int perf_evlist__alloc_stats(struct evlist *evlist, bool 
alloc_raw);
 void perf_evlist__free_stats(struct evlist *evlist);
 void perf_evlist__reset_stats(struct evlist *evlist);
 void perf_evlist__reset_prev_raw_counts(struct evlist *evlist);
+void perf_evlist__copy_prev_raw_counts(struct evlist *evlist);
 
 int perf_stat_process_counter(struct perf_stat_config *config,
  struct evsel *counter);
-- 
2.17.1



[PATCH v3 1/4] perf stat: Fix wrong per-thread runtime stat for interval mode

2020-05-07 Thread Jin Yao
root@kbl-ppc:~# perf stat --per-thread -e cycles,instructions -I1000 
--interval-count 2
 1.004171683 perf-3696  8,747,311  cycles
...
 1.004171683 perf-3696691,730  instructions 
 #0.08  insn per cycle
...
 2.006490373 perf-3696  1,749,936  cycles
...
 2.006490373 perf-3696  1,484,582  instructions 
 #0.28  insn per cycle
...

Let's see interval 2.006490373

perf-3696  1,749,936  cycles
perf-3696  1,484,582  instructions  #0.28  insn 
per cycle

insn per cycle = 1,484,582 / 1,749,936 = 0.85.
But now it's 0.28, that's not correct.

stat_config.stats[] records the per-thread runtime stat. But for interval
mode, it should be reset for each interval.

So now, with this patch,

root@kbl-ppc:~# perf stat --per-thread -e cycles,instructions -I1000 
--interval-count 2
 1.005818121 perf-8633  9,898,045  cycles
...
 1.005818121 perf-8633693,298  instructions 
 #0.07  insn per cycle
...
 2.007863743 perf-8633  1,551,619  cycles
...
 2.007863743 perf-8633  1,317,514  instructions 
 #0.85  insn per cycle
...

Let's check interval 2.007863743.

insn per cycle = 1,317,514 / 1,551,619 = 0.85. It's correct.

Fixes: commit 14e72a21c783 ("perf stat: Update or print per-thread stats")
Signed-off-by: Jin Yao 
---
 tools/perf/builtin-stat.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index e0c1ad23c768..97ee941649e6 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -351,6 +351,16 @@ static void read_counters(struct timespec *rs)
}
 }
 
+static void thread_stats_reset(struct perf_stat_config *config)
+{
+   int i;
+
+   if (config->stats) {
+   for (i = 0; i < config->stats_num; i++)
+   perf_stat__reset_shadow_per_stat(&config->stats[i]);
+   }
+}
+
 static void process_interval(void)
 {
struct timespec ts, rs;
@@ -359,6 +369,7 @@ static void process_interval(void)
diff_timespec(&rs, &ts, &ref_time);
 
perf_stat__reset_shadow_per_stat(&rt_stat);
+   thread_stats_reset(&stat_config);
read_counters(&rs);
 
if (STAT_RECORD) {
-- 
2.17.1



RE: [PATCH V3 10/10] clk: imx8mp: mark memrepair clock as critical

2020-05-07 Thread Aisheng Dong
> From: Peng Fan 
> Sent: Thursday, May 7, 2020 1:56 PM
> 
> If memrepair root clock in CCM is disabled, the memory repair logic in HDMIMIX
> can’t work. So let's mark it as critical clock.

A small question here:
Is this clock critical for the whole system or only for HDMIMIX?
What if HDMIIX is not enabled?

Regards
Aisheng

> 
> Reviewed-by: Leonard Crestez 
> Signed-off-by: Peng Fan 
> ---
>  drivers/clk/imx/clk-imx8mp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c index
> b4d9db9d5bf1..a7c59d7a40de 100644
> --- a/drivers/clk/imx/clk-imx8mp.c
> +++ b/drivers/clk/imx/clk-imx8mp.c
> @@ -590,7 +590,7 @@ static int imx8mp_clocks_probe(struct platform_device
> *pdev)
>   hws[IMX8MP_CLK_VPU_G2] = imx8m_clk_hw_composite("vpu_g2",
> imx8mp_vpu_g2_sels, ccm_base + 0xa180);
>   hws[IMX8MP_CLK_CAN1] = imx8m_clk_hw_composite("can1",
> imx8mp_can1_sels, ccm_base + 0xa200);
>   hws[IMX8MP_CLK_CAN2] = imx8m_clk_hw_composite("can2",
> imx8mp_can2_sels, ccm_base + 0xa280);
> - hws[IMX8MP_CLK_MEMREPAIR] =
> imx8m_clk_hw_composite("memrepair", imx8mp_memrepair_sels, ccm_base +
> 0xa300);
> + hws[IMX8MP_CLK_MEMREPAIR] =
> +imx8m_clk_hw_composite_critical("memrepair", imx8mp_memrepair_sels,
> +ccm_base + 0xa300);
>   hws[IMX8MP_CLK_PCIE_PHY] = imx8m_clk_hw_composite("pcie_phy",
> imx8mp_pcie_phy_sels, ccm_base + 0xa380);
>   hws[IMX8MP_CLK_PCIE_AUX] = imx8m_clk_hw_composite("pcie_aux",
> imx8mp_pcie_aux_sels, ccm_base + 0xa400);
>   hws[IMX8MP_CLK_I2C5] = imx8m_clk_hw_composite("i2c5",
> imx8mp_i2c5_sels, ccm_base + 0xa480);
> --
> 2.16.4



[PATCH v3 4/4] perf stat: Report summary for interval mode

2020-05-07 Thread Jin Yao
Currently perf-stat supports to print counts at regular interval (-I),
but it's not very easy for user to get the overall statistics.

The patch uses 'evsel->prev_raw_counts' to get counts for summary.
Copy the counts to 'evsel->counts' after printing the interval results.
Next, we just follow the non-interval processing.

Let's see some examples,

 root@kbl-ppc:~# perf stat -e cycles -I1000 --interval-count 2
 #   time counts unit events
  1.000412064  2,281,114  cycles
  2.001383658  2,547,880  cycles

  Performance counter stats for 'system wide':

  4,828,994  cycles

2.002860349 seconds time elapsed

 root@kbl-ppc:~# perf stat -e cycles,instructions -I1000 --interval-count 2
 #   time counts unit events
  1.000389902  1,536,093  cycles
  1.000389902420,226  instructions  #0.27  
insn per cycle
  2.001433453  2,213,952  cycles
  2.001433453735,465  instructions  #0.33  
insn per cycle

  Performance counter stats for 'system wide':

  3,750,045  cycles
  1,155,691  instructions  #0.31  insn per cycle

2.003023361 seconds time elapsed

 root@kbl-ppc:~# perf stat -M CPI,IPC -I1000 --interval-count 2
 #   time counts unit events
  1.000435121905,303  inst_retired.any  #  2.9 
CPI
  1.000435121  2,663,333  cycles
  1.000435121914,702  inst_retired.any  #  0.3 
IPC
  1.000435121  2,676,559  cpu_clk_unhalted.thread
  2.001615941  1,951,092  inst_retired.any  #  1.8 
CPI
  2.001615941  3,551,357  cycles
  2.001615941  1,950,837  inst_retired.any  #  0.5 
IPC
  2.001615941  3,551,044  cpu_clk_unhalted.thread

  Performance counter stats for 'system wide':

  2,856,395  inst_retired.any  #  2.2 CPI
  6,214,690  cycles
  2,865,539  inst_retired.any  #  0.5 IPC
  6,227,603  cpu_clk_unhalted.thread

2.003403078 seconds time elapsed

 v3:
 ---
 Use evsel->prev_raw_counts for summary counts

 v2:
 ---
 Rebase to perf/core branch

Signed-off-by: Jin Yao 
---
 tools/perf/builtin-stat.c | 16 ++--
 tools/perf/util/stat.c|  2 +-
 tools/perf/util/stat.h|  1 +
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 97ee941649e6..f67d6a50274e 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -334,7 +334,7 @@ static void read_counters(struct timespec *rs)
evlist__for_each_entry(evsel_list, counter) {
if (evsel__cpu_iter_skip(counter, cpu))
continue;
-   if (!counter->err) {
+   if (!counter->err && !stat_config.summary) {
counter->err = read_counter_cpu(counter, rs,

counter->cpu_iter - 1);
}
@@ -364,6 +364,7 @@ static void thread_stats_reset(struct perf_stat_config 
*config)
 static void process_interval(void)
 {
struct timespec ts, rs;
+   struct stats walltime_nsecs_stats_bak;
 
clock_gettime(CLOCK_MONOTONIC, &ts);
diff_timespec(&rs, &ts, &ref_time);
@@ -377,9 +378,11 @@ static void process_interval(void)
pr_err("failed to write stat round event\n");
}
 
+   walltime_nsecs_stats_bak = walltime_nsecs_stats;
init_stats(&walltime_nsecs_stats);
update_stats(&walltime_nsecs_stats, stat_config.interval * 100);
print_counters(&rs, 0, NULL);
+   walltime_nsecs_stats = walltime_nsecs_stats_bak;
 }
 
 static void enable_counters(void)
@@ -735,6 +738,15 @@ static int __run_perf_stat(int argc, const char **argv, 
int run_idx)
 
update_stats(&walltime_nsecs_stats, t1 - t0);
 
+   if (interval) {
+   stat_config.interval = 0;
+   stat_config.summary = true;
+   perf_evlist__copy_prev_raw_counts(evsel_list);
+   perf_evlist__reset_prev_raw_counts(evsel_list);
+   thread_stats_reset(&stat_config);
+   perf_stat__reset_shadow_per_stat(&rt_stat);
+   }
+
/*
 * Closing a group leader splits the group, and as we only disable
 * group leaders, results in remaining events becoming enabled. To
@@ -2158,7 +2170,7 @@ int cmd_stat(int argc, const char **argv)
}
}
 
-   if (!forever && status != -1 && !interval)
+   if (!forever && status != -1 && (!interval || stat_config.summary))
print_counters(NULL, argc, argv);
 
if (STAT_RECORD

[PATCH v3 2/4] perf counts: Reset prev_raw_counts counts

2020-05-07 Thread Jin Yao
The evsel->prev_raw_counts is updated in perf_evsel__compute_deltas:

perf_evsel__compute_deltas()
{
tmp = *perf_counts(evsel->prev_raw_counts, cpu, thread);
*perf_counts(evsel->prev_raw_counts, cpu, thread) = *count;
}

When we want to reset the evsel->prev_raw_counts in
perf_evsel__reset_prev_raw_counts, zeroing the aggr is not enough,
we need to reset the counts too.

Signed-off-by: Jin Yao 
---
 tools/perf/util/counts.c | 5 +
 tools/perf/util/counts.h | 2 ++
 tools/perf/util/stat.c   | 1 +
 3 files changed, 8 insertions(+)

diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c
index f94e1a23dad6..af3bf36f7c63 100644
--- a/tools/perf/util/counts.c
+++ b/tools/perf/util/counts.c
@@ -64,3 +64,8 @@ void perf_evsel__free_counts(struct evsel *evsel)
perf_counts__delete(evsel->counts);
evsel->counts = NULL;
 }
+
+void perf_evsel__reset_raw_counts(struct evsel *evsel)
+{
+   perf_counts__reset(evsel->prev_raw_counts);
+}
diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h
index 92196df4945f..15bb9acb7cb0 100644
--- a/tools/perf/util/counts.h
+++ b/tools/perf/util/counts.h
@@ -42,4 +42,6 @@ void perf_evsel__reset_counts(struct evsel *evsel);
 int perf_evsel__alloc_counts(struct evsel *evsel, int ncpus, int nthreads);
 void perf_evsel__free_counts(struct evsel *evsel);
 
+void perf_evsel__reset_raw_counts(struct evsel *evsel);
+
 #endif /* __PERF_COUNTS_H */
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 774468341851..89e541564ed5 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -168,6 +168,7 @@ static void perf_evsel__reset_prev_raw_counts(struct evsel 
*evsel)
evsel->prev_raw_counts->aggr.val = 0;
evsel->prev_raw_counts->aggr.ena = 0;
evsel->prev_raw_counts->aggr.run = 0;
+   perf_evsel__reset_raw_counts(evsel);
}
 }
 
-- 
2.17.1



[PATCH v3 0/4] perf stat: Support overall statistics for interval mode

2020-05-07 Thread Jin Yao
Currently perf-stat supports to print counts at regular interval (-I),
but it's not very easy for user to get the overall statistics.

With this patchset, it supports to report the summary at the end of
interval output.

For example,

 root@kbl-ppc:~# perf stat -e cycles -I1000 --interval-count 2
 #   time counts unit events
  1.000412064  2,281,114  cycles
  2.001383658  2,547,880  cycles

  Performance counter stats for 'system wide':

  4,828,994  cycles

2.002860349 seconds time elapsed

 root@kbl-ppc:~# perf stat -e cycles,instructions -I1000 --interval-count 2
 #   time counts unit events
  1.000389902  1,536,093  cycles
  1.000389902420,226  instructions  #0.27  
insn per cycle
  2.001433453  2,213,952  cycles
  2.001433453735,465  instructions  #0.33  
insn per cycle

  Performance counter stats for 'system wide':

  3,750,045  cycles
  1,155,691  instructions  #0.31  insn per cycle

2.003023361 seconds time elapsed

 root@kbl-ppc:~# perf stat -M CPI,IPC -I1000 --interval-count 2
 #   time counts unit events
  1.000435121905,303  inst_retired.any  #  2.9 
CPI
  1.000435121  2,663,333  cycles
  1.000435121914,702  inst_retired.any  #  0.3 
IPC
  1.000435121  2,676,559  cpu_clk_unhalted.thread
  2.001615941  1,951,092  inst_retired.any  #  1.8 
CPI
  2.001615941  3,551,357  cycles
  2.001615941  1,950,837  inst_retired.any  #  0.5 
IPC
  2.001615941  3,551,044  cpu_clk_unhalted.thread

  Performance counter stats for 'system wide':

  2,856,395  inst_retired.any  #  2.2 CPI
  6,214,690  cycles
  2,865,539  inst_retired.any  #  0.5 IPC
  6,227,603  cpu_clk_unhalted.thread

2.003403078 seconds time elapsed

 v3:
 ---
 1. 'perf stat: Fix wrong per-thread runtime stat for interval mode'
is a new patch which fixes an existing issue found in test.

 2. We use the prev_raw_counts for summary counts. Drop the summary_counts in 
v2.

 3. Fix some issues.

 v2:
 ---
 Rebase to perf/core branch

Jin Yao (4):
  perf stat: Fix wrong per-thread runtime stat for interval mode
  perf counts: Reset prev_raw_counts counts
  perf stat: Copy counts from prev_raw_counts to evsel->counts
  perf stat: Report summary for interval mode

 tools/perf/builtin-stat.c | 27 +--
 tools/perf/util/counts.c  |  5 +
 tools/perf/util/counts.h  |  2 ++
 tools/perf/util/evsel.c   |  1 +
 tools/perf/util/stat.c| 27 ++-
 tools/perf/util/stat.h|  2 ++
 6 files changed, 61 insertions(+), 3 deletions(-)

-- 
2.17.1



[PATCH -next] ACPI: debug: Make two functions static

2020-05-07 Thread Zheng Zengkai
Fix sparse warnings:

drivers/acpi/acpi_dbg.c:748:12: warning:
 symbol 'acpi_aml_init' was not declared. Should it be static?
drivers/acpi/acpi_dbg.c:774:13: warning:
 symbol 'acpi_aml_exit' was not declared. Should it be static?

Reported-by: Hulk Robot 
Signed-off-by: Zheng Zengkai 
---
 drivers/acpi/acpi_dbg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index 7a265c2171c0..6041974c7627 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -745,7 +745,7 @@ static const struct acpi_debugger_ops acpi_aml_debugger = {
.notify_command_complete = acpi_aml_notify_command_complete,
 };
 
-int __init acpi_aml_init(void)
+static int __init acpi_aml_init(void)
 {
int ret;
 
@@ -771,7 +771,7 @@ int __init acpi_aml_init(void)
return 0;
 }
 
-void __exit acpi_aml_exit(void)
+static void __exit acpi_aml_exit(void)
 {
if (acpi_aml_initialized) {
acpi_unregister_debugger(&acpi_aml_debugger);
-- 
2.20.1



Re: [PATCH] x86: bitops: fix build regression

2020-05-07 Thread hpa
On May 6, 2020 11:18:09 PM PDT, Brian Gerst  wrote:
>On Tue, May 5, 2020 at 1:47 PM Nick Desaulniers
> wrote:
>>
>> From: Sedat Dilek 
>>
>> It turns out that if your config tickles __builtin_constant_p via
>> differences in choices to inline or not, this now produces invalid
>> assembly:
>>
>> $ cat foo.c
>> long a(long b, long c) {
>>   asm("orb\t%1, %0" : "+q"(c): "r"(b));
>>   return c;
>> }
>> $ gcc foo.c
>> foo.c: Assembler messages:
>> foo.c:2: Error: `%rax' not allowed with `orb'
>>
>> The "q" constraint only has meanting on -m32 otherwise is treated as
>> "r".
>>
>> This is easily reproducible via
>Clang+CONFIG_STAGING=y+CONFIG_VT6656=m,
>> or Clang+allyesconfig.
>>
>> Keep the masking operation to appease sparse (`make C=1`), add back
>the
>> cast in order to properly select the proper 8b register alias.
>>
>>  [Nick: reworded]
>>
>> Cc: sta...@vger.kernel.org
>> Cc: Jesse Brandeburg 
>> Link: https://github.com/ClangBuiltLinux/linux/issues/961
>> Link:
>https://lore.kernel.org/lkml/20200504193524.ga221...@google.com/
>> Fixes: 1651e700664b4 ("x86: Fix bitops.h warning with a moved cast")
>> Reported-by: Sedat Dilek 
>> Reported-by: kernelci.org bot 
>> Suggested-by: Andy Shevchenko 
>> Suggested-by: Ilie Halip 
>> Tested-by: Sedat Dilek 
>> Signed-off-by: Sedat Dilek 
>> Signed-off-by: Nick Desaulniers 
>> ---
>>  arch/x86/include/asm/bitops.h | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/bitops.h
>b/arch/x86/include/asm/bitops.h
>> index b392571c1f1d..139122e5b25b 100644
>> --- a/arch/x86/include/asm/bitops.h
>> +++ b/arch/x86/include/asm/bitops.h
>> @@ -54,7 +54,7 @@ arch_set_bit(long nr, volatile unsigned long *addr)
>> if (__builtin_constant_p(nr)) {
>> asm volatile(LOCK_PREFIX "orb %1,%0"
>> : CONST_MASK_ADDR(nr, addr)
>> -   : "iq" (CONST_MASK(nr) & 0xff)
>> +   : "iq" ((u8)(CONST_MASK(nr) & 0xff))
>
>I think a better fix would be to make CONST_MASK() return a u8 value
>rather than have to cast on every use.
>
>Also I question the need for the "q" constraint.  It was added in
>commit 437a0a54 as a workaround for GCC 3.4.4.  Now that the minimum
>GCC version is 4.6, is this still necessary?
>
>--
>Brian Gerst

Yes, "q" is needed on i386.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Re: [PATCH -next] ALSA: sound/ppc: Use bitwise instead of arithmetic operator for flags

2020-05-07 Thread Takashi Iwai
On Thu, 07 May 2020 05:54:07 +0200,
Samuel Zou wrote:
> 
> Fix the following coccinelle warnings:
> 
> sound/ppc/pmac.c:729:57-58: WARNING: sum of probable bitmasks, consider |
> sound/ppc/pmac.c:229:37-38: WARNING: sum of probable bitmasks, consider |
> 
> Reported-by: Hulk Robot 
> Signed-off-by: Samuel Zou 

Applied, thanks.


Takashi


Re: [PATCH -next] ALSA: portman2x4: Use bitwise instead of arithmetic operator for flags

2020-05-07 Thread Takashi Iwai
On Thu, 07 May 2020 08:48:55 +0200,
Samuel Zou wrote:
> 
> Fix the following coccinelle warning:
> 
> sound/drivers/portman2x4.c:460:34-35: WARNING: sum of probable bitmasks, 
> consider |
> 
> Reported-by: Hulk Robot 
> Signed-off-by: Samuel Zou 

Applied now.  Thanks.


Takashi


[ANNOUNCE][CFP] Linux Security Summit Europe 2020

2020-05-07 Thread Elena Reshetova
==
   ANNOUNCEMENT AND CALL FOR PARTICIPATION

LINUX SECURITY SUMMIT EUROPE 2020

 29-30 OCTOBER
DUBLIN, IRELAND
==

DESCRIPTION

Linux Security Summit Europe (LSS-EU) is a technical forum for
collaboration between Linux developers, researchers, and end-users.  Its
primary aim is to foster community efforts in analyzing and solving Linux
security challenges.

 The program committee currently seeks proposals for:

   * Refereed Presentations:
 45 minutes in length.

   * Panel Discussion Topics:
 45 minutes in length.

   * Short Topics:
 30 minutes in total, including at least 10 minutes discussion.

   * Tutorials
 90 minutes in length.

Tutorial sessions should be focused on advanced Linux security defense
topics within areas such as the kernel, compiler, and security-related
libraries.  Priority will be given to tutorials created for this conference,
and those where the presenter a leading subject matter expert on the topic.

Topic areas include, but are not limited to:

   * Kernel self-protection
   * Access control
   * Cryptography and key management
   * Integrity policy and enforcement
   * Hardware Security
   * IoT and embedded security
   * Virtualization and containers
   * System-specific system hardening
   * Case studies
   * Security tools
   * Security UX
   * Emerging technologies, threats & techniques

  Proposals should be submitted via:

   https://events.linuxfoundation.org/linux-security-summit-europe/program/cfp/

DATES

  * CFP close:July 31
  * CFP notifications:August 10
  * Schedule announced:   September 1
  * Event:October 29-30

COVID-19 SITUATION

Currently LSS-EU is planned as in-person event, however this would be
re-evaluated closer to the event itself and if the situation in Europe does
not permit such events, it would be switched to a virtual event, similarly
as this year’s LSS-NA.

WHO SHOULD ATTEND

We're seeking a diverse range of attendees and welcome participation by
people involved in Linux security development, operations, and research.

LSS-EU is a unique global event that provides the opportunity to present and
discuss your work or research with key Linux security community members and
maintainers.  It’s also useful for those who wish to keep up with the latest
in Linux security development and to provide input to the development
process.

WEB SITE

https://events.linuxfoundation.org/linux-security-summit-europe/

TWITTER

  For event updates and announcements, follow:

https://twitter.com/LinuxSecSummit

#linuxsecuritysummit

PROGRAM COMMITTEE

  The program committee for LSS 2020 is:

* James Morris, Microsoft
* Serge Hallyn, Cisco
* Paul Moore, Cisco
* Stephen Smalley, NSA
* Elena Reshetova, Intel
* John Johansen, Canonical
* Kees Cook, Google
* Casey Schaufler, Intel
* Mimi Zohar, IBM
* David A. Wheeler, Institute for Defense Analyses

  The program committee may be contacted as a group via email:
lss-pc () lists.linuxfoundation.org


Re: [PATCH] clone: only use lower 32 flag bits

2020-05-07 Thread Christian Brauner
On Wed, May 06, 2020 at 12:06:10PM -0700, Joe Perches wrote:
> On Tue, 2020-05-05 at 19:44 +0200, Christian Brauner wrote:
> > Jan reported an issue where an interaction between sign-extending clone's
> > flag argument on ppc64le and the new CLONE_INTO_CGROUP feature causes
> > clone() to consistently fail with EBADF.
> []
> > Let's fix this by always capping the upper 32 bits for the legacy clone()
> > syscall. This ensures that we can't reach clone3() only features by
> > accident via legacy clone as with the sign extension case and also that
> > legacy clone() works exactly like before, i.e. ignoring any unknown flags.
> > This solution risks no regressions and is also pretty clean.
> > 
> > I've chosen u32 and not unsigned int to visually indicate that we're
> > capping this to 32 bits.
> 
> Perhaps use the lower_32_bits macro?

Oh neat, I wasn't aware of this helper since there are no users under
kernel/*

Christian


[PATCH] drivers: block: use set_current_state macro

2020-05-07 Thread Xu Wang
Use set_current_state macro instead of current->state = TASK_RUNNING.

Signed-off-by: Xu Wang 
---
 drivers/block/swim.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 4c297f69171d..dd34504382e5 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -327,7 +327,7 @@ static inline void swim_motor(struct swim __iomem *base,
swim_select(base, RELAX);
if (swim_readbit(base, MOTOR_ON))
break;
-   current->state = TASK_INTERRUPTIBLE;
+   set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
} else if (action == OFF) {
@@ -346,7 +346,7 @@ static inline void swim_eject(struct swim __iomem *base)
swim_select(base, RELAX);
if (!swim_readbit(base, DISK_IN))
break;
-   current->state = TASK_INTERRUPTIBLE;
+   set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
}
swim_select(base, RELAX);
@@ -370,7 +370,7 @@ static inline int swim_step(struct swim __iomem *base)
 
for (wait = 0; wait < HZ; wait++) {
 
-   current->state = TASK_INTERRUPTIBLE;
+   set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
 
swim_select(base, RELAX);
-- 
2.17.1



Re: [PATCH] ARM: dts: stm32: bump PSCI to version 1.0 on stm32mp15x

2020-05-07 Thread Alexandre Torgue

Hi Etienne

On 5/6/20 7:48 PM, Etienne Carriere wrote:

From: Etienne Carriere 

Declare PSCI v1.0 support instead of v0.1 as the former is supported
by the PSCI firmware stacks stm32mp15x relies on.

Signed-off-by: Etienne Carriere 
---
  arch/arm/boot/dts/stm32mp151.dtsi | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/stm32mp151.dtsi 
b/arch/arm/boot/dts/stm32mp151.dtsi
index 3ea05ba48215..ebceead1b120 100644
--- a/arch/arm/boot/dts/stm32mp151.dtsi
+++ b/arch/arm/boot/dts/stm32mp151.dtsi
@@ -24,10 +24,8 @@
};
  
  	psci {

-   compatible = "arm,psci";
+   compatible = "arm,psci-1.0";
method = "smc";
-   cpu_off = <0x8402>;
-   cpu_on = <0x8403>;
};
  
  	intc: interrupt-controller@a0021000 {




Applied on stm32-next.

Thanks.
Alex


Re: [PATCH] xhci: Make debug message consistent with bus and port number

2020-05-07 Thread Kai-Heng Feng



> On May 7, 2020, at 14:45, Greg Kroah-Hartman  
> wrote:
> 
> On Thu, May 07, 2020 at 02:17:55PM +0800, Kai-Heng Feng wrote:
>> Current xhci debug message doesn't always output bus number, so it's
>> hard to figure out it's from USB2 or USB3 root hub.
>> 
>> In addition to that, some port numbers are offset to 0 and others are
>> offset to 1. Use the latter to match the USB core.
>> 
>> So use "bus number - port index + 1" to make debug message consistent.
>> 
>> Signed-off-by: Kai-Heng Feng 
>> ---
>> drivers/usb/host/xhci-hub.c | 41 +
>> 1 file changed, 23 insertions(+), 18 deletions(-)
>> 
>> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
>> index f37316d2c8fa..83088c262cc4 100644
>> --- a/drivers/usb/host/xhci-hub.c
>> +++ b/drivers/usb/host/xhci-hub.c
>> @@ -1241,7 +1241,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, 
>> u16 wValue,
>>  temp = readl(ports[wIndex]->addr);
>>  /* Disable port */
>>  if (link_state == USB_SS_PORT_LS_SS_DISABLED) {
>> -xhci_dbg(xhci, "Disable port %d\n", wIndex);
>> +xhci_dbg(xhci, "Disable port %d-%d\n",
>> + hcd->self.busnum, wIndex + 1);
> 
> Shouldn't xhci_dbg() show the bus number already?  

It's the PCI bus number, different to USB2/USB3 root hub bus number...

> If not, please fix
> that up there instead of having to add it to all messages "by hand".

Not all xhci debug messages need roothub number in it.

Kai-Heng

> 
> thanks,
> 
> greg k-h



Re: [f2fs-dev] [PATCH] f2fs: get parent inode when recovering pino

2020-05-07 Thread Gao Xiang
Hi Chao,

On Thu, May 07, 2020 at 02:38:39PM +0800, Chao Yu wrote:
> On 2020/5/7 6:36, Gao Xiang wrote:
> > On Wed, May 06, 2020 at 12:16:13PM -0700, Eric Biggers wrote:
> >> On Wed, May 06, 2020 at 02:47:19PM +0800, Gao Xiang wrote:
> >>> On Wed, May 06, 2020 at 09:58:22AM +0800, Gao Xiang wrote:
>  On Tue, May 05, 2020 at 06:24:28PM -0700, Eric Biggers wrote:
> > On Wed, May 06, 2020 at 08:14:07AM +0800, Gao Xiang wrote:
> >>>
> >>> Actually, I think this is wrong because the fsync can be done via a 
> >>> file
> >>> descriptor that was opened to a now-deleted link to the file.
> >>
> >> I'm still confused about this...
> >>
> >> I don't know what's wrong with this version from my limited knowledge?
> >>  inode itself is locked when fsyncing, so
> >>
> >>if the fsync inode->i_nlink == 1, this inode has only one hard link
> >>(not deleted yet) and should belong to a single directory; and
> >>
> >>the only one parent directory would not go away (not deleted as 
> >> well)
> >>since there are some dirents in it (not empty).
> >>
> >> Could kindly explain more so I would learn more about this scenario?
> >> Thanks a lot!
> >
> > i_nlink == 1 just means that there is one non-deleted link.  There can 
> > be links
> > that have since been deleted, and file descriptors can still be open to 
> > them.
> 
>  Thanks for your inspiration. You are right, thanks.
> 
>  Correct my words... I didn't check f2fs code just now, it seems f2fs 
>  doesn't
>  take inode_lock as some other fs like __generic_file_fsync or 
>  ubifs_fsync.
> 
>  And i_sem locks nlink / try_to_fix_pino similarly in some extent. It 
>  seems
>  no race by using d_find_alias here. Thanks again.
> 
> >>>
> >>> (think more little bit just now...)
> >>>
> >>>  Thread 1:   Thread 2 (fsync):
> >>>   vfs_unlink  try_to_fix_pino
> >>> f2fs_unlink
> >>>f2fs_delete_entry
> >>>  f2fs_drop_nlink  (i_sem, inode->i_nlink = 1)
> >>>
> >>>   (...   but this dentry still hashed)  i_sem, check 
> >>> inode->i_nlink = 1
> >>> i_sem d_find_alias
> >>>
> >>>   d_delete
> >>>
> >>> I'm not sure if fsync could still use some wrong alias by chance..
> >>> completely untested, maybe just noise...
>
> Another race condition could be:
>
> Thread 1 (fsync)  Thread 2 (rename)
> - f2fs_sync_fs
> - try_to_fix_pino
>   - f2fs_rename
>- down_write
>- file_lost_pino
>- up_write
>  - down_write
>  - file_got_pino
>  - up_write

Yes, IMHO, I think it could be not proper to
take dir lock in fsync path anyway...

I would suggest as before (if it needs to be fixed).
And it seems no significant performance difference.

Thanks,
Gao Xiang

>
> Thanks,
>
> >>>
> >>
> >> Right, good observation.  My patch makes it better, but it's still broken.
> >>
> >> I don't know how to fix it.  If we see i_nlink == 1 and multiple hashed
> >> dentries, there doesn't appear to be a way to distingush which one 
> >> corresponds
> >> to the remaining link on-disk (if any; it may not even be in the dcache), 
> >> and
> >> which correspond to links that vfs_unlink() has deleted from disk but 
> >> hasn't yet
> >> done d_delete() on.
> >>
> >> One idea would be choose one, then take inode_lock_shared(dir) and do
> >> __f2fs_find_entry() to check if the dentry is really still on-disk.  That's
> >> heavyweight and error-prone though, and the locking could cause problems.
> >>
> >> I'm wondering though, does f2fs really need try_to_fix_pino() at all, and 
> >> did it
> >> ever really work?  It never actually updates the f2fs_inode::i_name to 
> >> match the
> >> new directory.  So independently of this bug with deleted links, I don't 
> >> see how
> >> it can possibly work as intended.
> >
> > Part of my humble opinion would be "update pino in rename/unlink/link... 
> > such ops
> > instead of in fsync" (maybe it makes better sense of locking)... But 
> > actually I'm
> > not a f2fs folk now, just curious about what the original patch resolved 
> > with
> > these new extra igrab/iput (as I said before, I could not find some clue 
> > previously).
> >
> > Thanks,
> > Gao Xiang
> >
> >>
> >> - Eric
> >
> >
> > ___
> > Linux-f2fs-devel mailing list
> > linux-f2fs-de...@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> > .
> >


Re: [v3] nfp: abm: University research groups?

2020-05-07 Thread Markus Elfring
> > I imagined that the bug report (combined with a patch) was triggered by
> > an evolving source code analysis approach which will be explained
> > in another research paper. Is such a view appropriate?
> > https://github.com/umnsec/cheq/
>
> Could you elaborate more on "university research groups?"

You are working together for the publishing of some papers which will
eventually be presented at conferences.
You might build additional relationships and participate in further work groups.


> We are continuously working on automated kernel analysis

This is good to know.


> to improve the unfortunately very buggy kernel.

There are various software development challenges to consider.

Have you got a desire to express connections to recent research results
also in commit messages?

Regards,
Markus


[PATCH v2] virtio_net: fix lockdep warning on 32 bit

2020-05-07 Thread Michael S. Tsirkin
When we fill up a receive VQ, try_fill_recv currently tries to count
kicks using a 64 bit stats counter. Turns out, on a 32 bit kernel that
uses a seqcount. sequence counts are "lock" constructs where you need to
make sure that writers are serialized.

In turn, this means that we mustn't run two try_fill_recv concurrently.
Which of course we don't. We do run try_fill_recv sometimes from a
softirq napi context, and sometimes from a fully preemptible context,
but the later always runs with napi disabled.

However, when it comes to the seqcount, lockdep is trying to enforce the
rule that the same lock isn't accessed from preemptible and softirq
context - it doesn't know about napi being enabled/disabled. This causes
a false-positive warning:

WARNING: inconsistent lock state
...
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.

As a work around, shut down the warning by switching
to u64_stats_update_begin_irqsave - that works by disabling
interrupts on 32 bit only, is a NOP on 64 bit.

Reported-by: Thomas Gleixner 
Suggested-by: Eric Dumazet 
Signed-off-by: Michael S. Tsirkin 
---

changes from v1:
builds now. lightly tested

 drivers/net/virtio_net.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 11f722460513..ce07f52d89e7 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1243,9 +1243,11 @@ static bool try_fill_recv(struct virtnet_info *vi, 
struct receive_queue *rq,
break;
} while (rq->vq->num_free);
if (virtqueue_kick_prepare(rq->vq) && virtqueue_notify(rq->vq)) {
-   u64_stats_update_begin(&rq->stats.syncp);
+   unsigned long flags;
+
+   flags = u64_stats_update_begin_irqsave(&rq->stats.syncp);
rq->stats.kicks++;
-   u64_stats_update_end(&rq->stats.syncp);
+   u64_stats_update_end_irqrestore(&rq->stats.syncp, flags);
}
 
return !oom;
-- 
MST



[PATCH v2 -next] ASoC: SOF: Intel: Fix unused variable warning

2020-05-07 Thread YueHaibing
When CONFIG_SND_SOC_SOF_BAYTRAIL is not set, gcc warns:

sound/soc/sof/intel/byt.c:85:41: warning: ‘cht_debugfs’ defined but not used 
[-Wunused-const-variable=]
 static const struct snd_sof_debugfs_map cht_debugfs[] = {
 ^~~
Move the variable inside #ifdef

Reported-by: Hulk Robot 
Suggested-by: Joe Perches 
Signed-off-by: YueHaibing 
---
v2: Move the variable inside #ifdef as Joe's suggestion
---
 sound/soc/sof/intel/byt.c | 54 +++
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c
index f872bb1f2682..3747f2c2c28b 100644
--- a/sound/soc/sof/intel/byt.c
+++ b/sound/soc/sof/intel/byt.c
@@ -82,33 +82,6 @@ static const struct snd_sof_debugfs_map byt_debugfs[] = {
 SOF_DEBUGFS_ACCESS_ALWAYS},
 };
 
-static const struct snd_sof_debugfs_map cht_debugfs[] = {
-   {"dmac0", BYT_DSP_BAR, DMAC0_OFFSET, DMAC_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"dmac1", BYT_DSP_BAR,  DMAC1_OFFSET, DMAC_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"dmac2", BYT_DSP_BAR,  DMAC2_OFFSET, DMAC_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"ssp0",  BYT_DSP_BAR, SSP0_OFFSET, SSP_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"ssp1", BYT_DSP_BAR, SSP1_OFFSET, SSP_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"ssp2", BYT_DSP_BAR, SSP2_OFFSET, SSP_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"ssp3", BYT_DSP_BAR, SSP3_OFFSET, SSP_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"ssp4", BYT_DSP_BAR, SSP4_OFFSET, SSP_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"ssp5", BYT_DSP_BAR, SSP5_OFFSET, SSP_SIZE,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-   {"iram", BYT_DSP_BAR, IRAM_OFFSET, IRAM_SIZE,
-SOF_DEBUGFS_ACCESS_D0_ONLY},
-   {"dram", BYT_DSP_BAR, DRAM_OFFSET, DRAM_SIZE,
-SOF_DEBUGFS_ACCESS_D0_ONLY},
-   {"shim", BYT_DSP_BAR, SHIM_OFFSET, SHIM_SIZE_CHT,
-SOF_DEBUGFS_ACCESS_ALWAYS},
-};
-
 static void byt_host_done(struct snd_sof_dev *sdev);
 static void byt_dsp_done(struct snd_sof_dev *sdev);
 static void byt_get_reply(struct snd_sof_dev *sdev);
@@ -681,6 +654,33 @@ EXPORT_SYMBOL_NS(tng_chip_info, SND_SOC_SOF_MERRIFIELD);
 
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
 
+static const struct snd_sof_debugfs_map cht_debugfs[] = {
+   {"dmac0", BYT_DSP_BAR, DMAC0_OFFSET, DMAC_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"dmac1", BYT_DSP_BAR,  DMAC1_OFFSET, DMAC_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"dmac2", BYT_DSP_BAR,  DMAC2_OFFSET, DMAC_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"ssp0",  BYT_DSP_BAR, SSP0_OFFSET, SSP_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"ssp1", BYT_DSP_BAR, SSP1_OFFSET, SSP_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"ssp2", BYT_DSP_BAR, SSP2_OFFSET, SSP_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"ssp3", BYT_DSP_BAR, SSP3_OFFSET, SSP_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"ssp4", BYT_DSP_BAR, SSP4_OFFSET, SSP_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"ssp5", BYT_DSP_BAR, SSP5_OFFSET, SSP_SIZE,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+   {"iram", BYT_DSP_BAR, IRAM_OFFSET, IRAM_SIZE,
+SOF_DEBUGFS_ACCESS_D0_ONLY},
+   {"dram", BYT_DSP_BAR, DRAM_OFFSET, DRAM_SIZE,
+SOF_DEBUGFS_ACCESS_D0_ONLY},
+   {"shim", BYT_DSP_BAR, SHIM_OFFSET, SHIM_SIZE_CHT,
+SOF_DEBUGFS_ACCESS_ALWAYS},
+};
+
 static int byt_acpi_probe(struct snd_sof_dev *sdev)
 {
struct snd_sof_pdata *pdata = sdev->pdata;
-- 
2.17.1




Re: [ANNOUNCE][CFP] Power Management and Scheduling in the Linux Kernel IV edition (OSPM-summit 2020)

2020-05-07 Thread Juri Lelli
Hello,

On 19/12/19 11:35, Juri Lelli wrote:
> Power Management and Scheduling in the Linux Kernel (OSPM-summit) IV edition
> 
> May 11-13, 2019
> Scuola Superiore Sant'Anna
> Pisa, Italy
> 

Quick reminder that OSPM-summit IV edition is happening next week!

Not in Pisa (for obvious reasons :-/), but online, kindly hosted on LWN
BigBlueButton server. Thanks a lot to Jon and LWN for this opportunity.

> .:: FOCUS
> 
> The IV edition of the Power Management and Scheduling in the Linux
> Kernel (OSPM) summit aims at fostering discussions on power management
> and (real-time) scheduling techniques. Summit will be held in Pisa
> (Italy) on May 11-13, 2020.
> 
> Although scheduler techniques for reducing energy consumption while
> meeting performance and latency requirements are the prime interest of
> the summit, we welcome anybody interested in having discussions on the
> broader scope of real-time systems, real-time and non-real-time
> scheduling, tooling, debugging and tracing.
> 
> Feel free to have a look at what happened previous years:
> 
>  I   edition - https://lwn.net/Articles/721573/
>  II  edition - https://lwn.net/Articles/754923/
>  III edition - https://lwn.net/Articles/793281/

[...]

> .:: ATTENDING
> 
> Attending the OSPM-summit is free of charge, but registration to the
> event is mandatory. The event can allow a maximum of 50 people (so, be
> sure to register early!). Registrations open on February 24th, 2020.
> 
> To register fill in the registration form available at
> https://forms.gle/7LfFY8oNyRxV1wuQ7

Since we don't have real rooms constraints, registration is still open.
Everybody is more then welcome to join us. Please use the form above to
register. Details about how to join will be provided after registration
completes. You can also reach out to me directly.

Schedule (still subject to small changes) is available at
https://bit.ly/2WAtsjy (CEST tz).

> .:: ORGANIZERS (in alphabetical order)
> 
> Luca Abeni (SSSA)
> Tommaso Cucinotta (SSSA)
> Dietmar Eggemann (Arm)
> Sudeep Holla (Arm)
> Juri Lelli (Red Hat)
> Lorenzo Pieralisi (Arm)
> Morten Rasmussen (Arm)
> Claudio Scordino (Evidence SRL)

Thanks also a lot to Scuola Superiore Sant'Anna of Pisa, Arm and
Evidence for helping put this together for the 4th consecutive year.

Looking forward to meet you all soon.. virtually. :-)

Best,

Juri



Re: [PATCH 1/2] arch/x86: Rename config X86_INTEL_MEMORY_PROTECTION_KEYS to generic x86

2020-05-07 Thread Sebastian Andrzej Siewior
On 2020-05-06 15:21:29 [-0700], Dave Hansen wrote:
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index 1197b5596d5a..8630b9fa06f5 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -1886,11 +1886,11 @@ config X86_UMIP
> >   specific cases in protected and virtual-8086 modes. Emulated
> >   results are dummy.
> >  
> > -config X86_INTEL_MEMORY_PROTECTION_KEYS
> > -   prompt "Intel Memory Protection Keys"
> > +config X86_MEMORY_PROTECTION_KEYS
> > +   prompt "Memory Protection Keys"
> > def_bool y
> > # Note: only available in 64-bit mode
> > -   depends on CPU_SUP_INTEL && X86_64
> > +   depends on X86_64 && (CPU_SUP_INTEL || CPU_SUP_AMD)
> > select ARCH_USES_HIGH_VMA_FLAGS
> > select ARCH_HAS_PKEYS
> > ---help---
> 
> It's a bit of a bummer that we're going to prompt everybody doing
> oldconfig's for this new option.  But, I don't know any way for Kconfig
> to suppress it if the name is changed.  Also, I guess the def_bool=y
> means that menuconfig and olddefconfig will tend to do the right thing.

You could add a new option (X86_MEMORY_PROTECTION_KEYS) which is
def_bool X86_INTEL_MEMORY_PROTECTION_KEYS and avoiding the prompt line.
Soo it is selected based on the old option and the user isn't bother. A
few cycles later you could remove intel option and add prompt to other.
But still little work for…

> Do we *really* need to change the Kconfig name?  The text prompt, sure.
>  End users see that and having Intel in there is massively confusing.
> 
> If I have to put up with seeing 'amd64' all over my Debian package
> names, you can put up with a Kconfig name. :P

:) Right. On AMD you also use the crc32c-intel (if possible) and I
haven't seen people complain about this one.

> I'm really just wondering what the point of the churn is.

Sebastian


Re: [PATCH] xhci: Make debug message consistent with bus and port number

2020-05-07 Thread Greg Kroah-Hartman
On Thu, May 07, 2020 at 03:15:01PM +0800, Kai-Heng Feng wrote:
> 
> 
> > On May 7, 2020, at 14:45, Greg Kroah-Hartman  
> > wrote:
> > 
> > On Thu, May 07, 2020 at 02:17:55PM +0800, Kai-Heng Feng wrote:
> >> Current xhci debug message doesn't always output bus number, so it's
> >> hard to figure out it's from USB2 or USB3 root hub.
> >> 
> >> In addition to that, some port numbers are offset to 0 and others are
> >> offset to 1. Use the latter to match the USB core.
> >> 
> >> So use "bus number - port index + 1" to make debug message consistent.
> >> 
> >> Signed-off-by: Kai-Heng Feng 
> >> ---
> >> drivers/usb/host/xhci-hub.c | 41 +
> >> 1 file changed, 23 insertions(+), 18 deletions(-)
> >> 
> >> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
> >> index f37316d2c8fa..83088c262cc4 100644
> >> --- a/drivers/usb/host/xhci-hub.c
> >> +++ b/drivers/usb/host/xhci-hub.c
> >> @@ -1241,7 +1241,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 
> >> typeReq, u16 wValue,
> >>temp = readl(ports[wIndex]->addr);
> >>/* Disable port */
> >>if (link_state == USB_SS_PORT_LS_SS_DISABLED) {
> >> -  xhci_dbg(xhci, "Disable port %d\n", wIndex);
> >> +  xhci_dbg(xhci, "Disable port %d-%d\n",
> >> +   hcd->self.busnum, wIndex + 1);
> > 
> > Shouldn't xhci_dbg() show the bus number already?  
> 
> It's the PCI bus number, different to USB2/USB3 root hub bus number...

But if this is using dev_dbg(), and it is, then you know how to look
that up by seeing where that device is in sysfs at that point in time.

So why add this again?

> > If not, please fix
> > that up there instead of having to add it to all messages "by hand".
> 
> Not all xhci debug messages need roothub number in it.

Why pick these random ones?  What makes these different?

Either all or none, be consistant please.

greg k-h


[PATCH v2 05/12] bus/fsl-mc: Cache the DPRC API version

2020-05-07 Thread Diana Craciun
There are already firmware API commands that have multiple
versions. For each multiple version command, another command
to retrieve the API version is issued. This may introduce an important
overhead. The version does not change while the system is running,
so the DPRC API version can be safely cached.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc.c | 30 +-
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c
index 602f030d84eb..01bf41743efc 100644
--- a/drivers/bus/fsl-mc/dprc.c
+++ b/drivers/bus/fsl-mc/dprc.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
 /*
  * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2020 NXP
  *
  */
 #include 
@@ -8,6 +9,13 @@
 
 #include "fsl-mc-private.h"
 
+/**
+ * cache the DPRC version to reduce the number of commands
+ * towards the mc firmware
+ */
+static u16 dprc_major_ver;
+static u16 dprc_minor_ver;
+
 /**
  * dprc_open() - Open DPRC object for use
  * @mc_io: Pointer to MC portal's I/O object
@@ -443,15 +451,19 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io,
struct fsl_mc_command cmd = { 0 };
struct dprc_cmd_get_obj_region *cmd_params;
struct dprc_rsp_get_obj_region *rsp_params;
-   u16 major_ver, minor_ver;
int err;
 
-   /* prepare command */
-   err = dprc_get_api_version(mc_io, 0,
-&major_ver,
-&minor_ver);
-   if (err)
-   return err;
+/**
+ * If the DPRC object version was not yet cached, cache it now.
+ * Otherwise use the already cached value.
+ */
+   if (!dprc_major_ver && !dprc_minor_ver) {
+   err = dprc_get_api_version(mc_io, 0,
+ &dprc_major_ver,
+ &dprc_minor_ver);
+   if (err)
+   return err;
+   }
 
/**
 * MC API version 6.3 introduced a new field to the region
@@ -459,7 +471,7 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io,
 * address is set to zero to indicate it needs to be obtained elsewhere
 * (typically the device tree).
 */
-   if (major_ver > 6 || (major_ver == 6 && minor_ver >= 3))
+   if (dprc_major_ver > 6 || (dprc_major_ver == 6 && dprc_minor_ver >= 3))
cmd.header =
mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG_V2,
 cmd_flags, token);
@@ -483,7 +495,7 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io,
rsp_params = (struct dprc_rsp_get_obj_region *)cmd.params;
region_desc->base_offset = le64_to_cpu(rsp_params->base_offset);
region_desc->size = le32_to_cpu(rsp_params->size);
-   if (major_ver > 6 || (major_ver == 6 && minor_ver >= 3))
+   if (dprc_major_ver > 6 || (dprc_major_ver == 6 && dprc_minor_ver >= 3))
region_desc->base_address = le64_to_cpu(rsp_params->base_addr);
else
region_desc->base_address = 0;
-- 
2.17.1



[PATCH v2 02/12] bus/fsl-mc: Add a new parameter to dprc_scan_objects function

2020-05-07 Thread Diana Craciun
Prepare the dprc_scan_objects function to be used by
the VFIO mc driver code. The function is used to scan the mc
objects by the bus driver. The same functionality is
needed by the VFIO mc driver, but in this case the
interrupt configuration is delayed until the userspace
configures the interrupts. In order to use the same function
in both drivers add a new parameter.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc-driver.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index 035b220779d0..7a8061224df8 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -198,6 +198,8 @@ static void dprc_add_new_devices(struct fsl_mc_device 
*mc_bus_dev,
  * dprc_scan_objects - Discover objects in a DPRC
  *
  * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
+ * @alloc_interrupts: if true the function allocates the interrupt pool,
+ * otherwise the interrupt allocation is delayed
  *
  * Detects objects added and removed from a DPRC and synchronizes the
  * state of the Linux bus driver, MC by adding and removing
@@ -211,7 +213,8 @@ static void dprc_add_new_devices(struct fsl_mc_device 
*mc_bus_dev,
  * populated before they can get allocation requests from probe callbacks
  * of the device drivers for the non-allocatable devices.
  */
-static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev)
+static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
+   bool alloc_interrupts)
 {
int num_child_objects;
int dprc_get_obj_failures;
@@ -299,7 +302,7 @@ static int dprc_scan_objects(struct fsl_mc_device 
*mc_bus_dev)
 irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
}
 
-   if (!mc_bus->irq_resources) {
+   if (alloc_interrupts && !mc_bus->irq_resources) {
error = fsl_mc_populate_irq_pool(mc_bus,
FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
if (error < 0)
@@ -339,7 +342,7 @@ static int dprc_scan_container(struct fsl_mc_device 
*mc_bus_dev)
 * Discover objects in the DPRC:
 */
mutex_lock(&mc_bus->scan_mutex);
-   error = dprc_scan_objects(mc_bus_dev);
+   error = dprc_scan_objects(mc_bus_dev, true);
mutex_unlock(&mc_bus->scan_mutex);
if (error < 0) {
fsl_mc_cleanup_all_resource_pools(mc_bus_dev);
@@ -409,7 +412,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, 
void *arg)
  DPRC_IRQ_EVENT_OBJ_DESTROYED |
  DPRC_IRQ_EVENT_OBJ_CREATED)) {
 
-   error = dprc_scan_objects(mc_dev);
+   error = dprc_scan_objects(mc_dev, true);
if (error < 0) {
/*
 * If the error is -ENXIO, we ignore it, as it indicates
-- 
2.17.1



[PATCH v2 09/12] bus/fsl-mc: Add a container setup function

2020-05-07 Thread Diana Craciun
Both DPRC driver and VFIO driver use the same initialization
code for the DPRC. Introduced a new function which groups this
initialization code. The function is exported and may be
used by VFIO as well.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc-driver.c | 78 ++--
 include/linux/fsl/mc.h   |  2 +
 2 files changed, 55 insertions(+), 25 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index 07012894cc9c..ec44d025f623 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -564,16 +564,15 @@ static int dprc_setup_irq(struct fsl_mc_device *mc_dev)
 }
 
 /**
- * dprc_probe - callback invoked when a DPRC is being bound to this driver
+ * dprc_setup - opens and creates a mc_io for DPRC
  *
  * @mc_dev: Pointer to fsl-mc device representing a DPRC
  *
  * It opens the physical DPRC in the MC.
- * It scans the DPRC to discover the MC objects contained in it.
- * It creates the interrupt pool for the MC bus associated with the DPRC.
- * It configures the interrupts for the DPRC device itself.
+ * It configures the DPRC portal used to communicate with MC
  */
-static int dprc_probe(struct fsl_mc_device *mc_dev)
+
+int dprc_setup(struct fsl_mc_device *mc_dev)
 {
int error;
size_t region_size;
@@ -583,12 +582,6 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
bool msi_domain_set = false;
u16 major_ver, minor_ver;
 
-   if (!is_fsl_mc_bus_dprc(mc_dev))
-   return -EINVAL;
-
-   if (dev_get_msi_domain(&mc_dev->dev))
-   return -EINVAL;
-
if (!mc_dev->mc_io) {
/*
 * This is a child DPRC:
@@ -635,6 +628,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
} else {
dev_set_msi_domain(&mc_dev->dev, mc_msi_domain);
msi_domain_set = true;
+
}
}
 
@@ -672,35 +666,69 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
goto error_cleanup_open;
}
 
+   return 0;
+
+error_cleanup_open:
+   (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
+
+error_cleanup_msi_domain:
+   if (msi_domain_set)
+   dev_set_msi_domain(&mc_dev->dev, NULL);
+
+   if (mc_io_created) {
+   fsl_destroy_mc_io(mc_dev->mc_io);
+   mc_dev->mc_io = NULL;
+   }
+
+   return error;
+}
+EXPORT_SYMBOL_GPL(dprc_setup);
+
+/**
+ * dprc_probe - callback invoked when a DPRC is being bound to this driver
+ *
+ * @mc_dev: Pointer to fsl-mc device representing a DPRC
+ *
+ * It opens the physical DPRC in the MC.
+ * It scans the DPRC to discover the MC objects contained in it.
+ * It creates the interrupt pool for the MC bus associated with the DPRC.
+ * It configures the interrupts for the DPRC device itself.
+ */
+static int dprc_probe(struct fsl_mc_device *mc_dev)
+{
+   int error;
+
+   if (!is_fsl_mc_bus_dprc(mc_dev))
+   return -EINVAL;
+
+   if (dev_get_msi_domain(&mc_dev->dev))
+   return -EINVAL;
+
+   error = dprc_setup(mc_dev);
+   if (error < 0)
+   return error;
+
/*
 * Discover MC objects in DPRC object:
 */
error = dprc_scan_container(mc_dev, true);
if (error < 0)
-   goto error_cleanup_open;
+   goto dprc_cleanup;
 
/*
 * Configure interrupt for the DPRC object associated with this MC bus:
 */
error = dprc_setup_irq(mc_dev);
if (error < 0)
-   goto error_cleanup_open;
+   goto scan_cleanup;
 
dev_info(&mc_dev->dev, "DPRC device bound to driver");
return 0;
 
-error_cleanup_open:
-   (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
-
-error_cleanup_msi_domain:
-   if (msi_domain_set)
-   dev_set_msi_domain(&mc_dev->dev, NULL);
-
-   if (mc_io_created) {
-   fsl_destroy_mc_io(mc_dev->mc_io);
-   mc_dev->mc_io = NULL;
-   }
-
+scan_cleanup:
+   device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
+dprc_cleanup:
+   dprc_cleanup(mc_dev);
return error;
 }
 
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index 26f2b84dbe5f..df4a9bbae0f0 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -498,6 +498,8 @@ int dprc_scan_container(struct fsl_mc_device *mc_bus_dev,
 
 int dprc_cleanup(struct fsl_mc_device *mc_dev);
 
+int dprc_setup(struct fsl_mc_device *mc_dev);
+
 /*
  * Data Path Buffer Pool (DPBP) API
  * Contains initialization APIs and runtime control APIs for DPBP
-- 
2.17.1



Re: [PATCH v9 0/8] Add endpoint driver for R-Car PCIe controller

2020-05-07 Thread Lad, Prabhakar
Hi Kishon,

On Thu, May 7, 2020 at 4:13 AM Kishon Vijay Abraham I  wrote:
>
> Hi Prabhakar,
>
> On 5/5/2020 3:17 PM, Lad, Prabhakar wrote:
> > Hi Lorenzo,
> >
> > On Tue, May 5, 2020 at 10:44 AM Lorenzo Pieralisi
> >  wrote:
> >>
> >> On Thu, Apr 30, 2020 at 09:43:20AM +0100, Lad, Prabhakar wrote:
> >>> Hi Kishon,
> >>>
> >>> On Thu, Apr 23, 2020 at 7:23 PM Lad Prabhakar
> >>>  wrote:
> 
>  Hi All,
> 
>  This patch series adds support for endpoint driver for R-Car PCIe 
>  controller on
>  R-Car/RZ-G2x SoC's, this also extends the epf framework to handle 
>  multiple windows
>  supported by the controller for mapping PCI address locally.
> 
>  Note:
>  The cadence/rockchip/designware endpoint drivers are build tested only.
> 
>  Changes for v9 (Re-spun this series as there were minimal changes 
>  requested):
>  * Rebased patches on top of v5.7.rc1
>  * Replaced mdelay(1) with usleep_range(1000, 1001) in 
>  rcar_pcie_ep_assert_intx()
>  * Added a check for max_functions read from DT to restrict with
>    RCAR_EPC_MAX_FUNCTIONS
>  * Replaced MSICAP0_MMENUM with MSICAP0_MMESE
>  * Retry ioremap for other windows on failure in pci_epc_mem_alloc_addr()
>  * Fixed looping for number windows in pci_epc_mem_exit()
>  * Set maximum to 1 for max-functions in DT binding (I have restored the 
>  acks
>    from  Rob and Shimoda-san)
>  * Sorted the entry in MAINTAINERS
> 
>  Changes for v8:
>  * Dropped adding R8A774C0 (0x002d) pci-id in pci_ids.h
>  * Fixed typo in commit message for patch 2/8
>  * Reworded commit message for patch 5/8 as suggested by Bjorn
>  * Split up patch to add pci_epc_mem_init() interface to add page_size 
>  argument
>    as suggested by Bjorn.
> 
>  Changes for v7:
>  * Fixed review comments pointed by Shimoda-san
>    1] Made DT bindings dual licensed, added Shimoda-san as maintainer and 
>  fixed
>   the example as its built with #{address,size}-cells = <1>. I have 
>  still
>   restored the Ack from Rob and Shimoda-san with these changes.
>    2] Split up the patches so that they can be picked up by respective 
>  subsystem
>   patches 1/4-9/11 are now part of this series.
>    3] Dropped altering a comment in pci-epc.h
>    4] Used a local variable align_size in pci_epc_mem_alloc_addr() so 
>  that size
>   variable doesn't get overwritten in the loop.
>    5] Replaced i-=1 with i--
>    6] Replaced rcar with R-Car in patch subject and description.
>    7] Set MACCTLR in init() callback
> 
>  Changes for v6:
>  1] Rebased patches on endpoint branch of https://git.kernel.org/pub/
> scm/linux/kernel/git/lpieralisi/pci.git/
>  2] Fixed review comments from Shimoda-san
> a] Made sure defconfig changes were in separate patch
> b] Created rcar_pcie_host/rcar_pcie_ep structures
> c] Added pci-id for R8A774C0
> d] Added entry in MAINTAINERS for dt-binding
> e] Dropped unnecessary braces
>  3] Added support for msi.
> 
>  Changes for v5:
>  1] Rebased patches on next branch of https://git.kernel.org/pub/scm/
> linux/kernel/git/helgaas/pci.git
>  2] Fixed review comments reported by Kishon while fetching the matching
> window in function pci_epc_get_matching_window()
>  3] Fixed review comments reported by Bjorn
> a] Split patch up first patch so that its easier to review and 
>  incremental
> b] Fixed typos
>  4] Included Reviewed tag from Rob for the dt-binding patch
>  5] Fixed issue reported by Nathan for assigning variable to itself
> 
>  Changes for v4:
>  1] Fixed dtb_check error reported by Rob
>  2] Fixed review comments reported by Kishon
> a] Dropped pci_epc_find_best_fit_window()
> b] Fixed initializing mem ptr in __pci_epc_mem_init()
> c] Dropped map_size from pci_epc_mem_window structure
> 
>  Changes for v3:
>  1] Fixed review comments from Bjorn and Kishon.
>  3] Converted to DT schema
> 
>  Changes for v2:
>  1] Fixed review comments from Biju for dt-bindings to include an example
> for a tested platform.
>  2] Fixed review comments from Kishon to extend the features of outbound
> regions in epf framework.
>  3] Added support to parse outbound-ranges in OF.
> 
>  Lad Prabhakar (8):
>    PCI: rcar: Rename pcie-rcar.c to pcie-rcar-host.c
>    PCI: rcar: Move shareable code to a common file
>    PCI: rcar: Fix calculating mask for PCIEPAMR register
>    PCI: endpoint: Pass page size as argument to pci_epc_mem_init()
>    PCI: endpoint: Add support to handle multiple base for mapping
>  outbound memory
> >>> Could you please do the needy for the above two patches, so that this
> >>> can be picked up by Lorenz

[PATCH v2 06/12] bus/fsl-mc: Add dprc-reset-container support

2020-05-07 Thread Diana Craciun
From: Bharat Bhushan 

DPRC reset is required by VFIO-mc in order to stop a device
to further generate DMA transactions.

Signed-off-by: Bharat Bhushan 
Signed-off-by: Laurentiu Tudor 
Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc.c   | 71 +
 drivers/bus/fsl-mc/fsl-mc-private.h |  7 +++
 include/linux/fsl/mc.h  |  7 +++
 3 files changed, 85 insertions(+)

diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c
index 01bf41743efc..44bde72bdea7 100644
--- a/drivers/bus/fsl-mc/dprc.c
+++ b/drivers/bus/fsl-mc/dprc.c
@@ -80,6 +80,77 @@ int dprc_close(struct fsl_mc_io *mc_io,
 }
 EXPORT_SYMBOL_GPL(dprc_close);
 
+/**
+ * dprc_reset_container - Reset child container.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPRC object
+ * @child_container_id:ID of the container to reset
+ * @options: 32 bit options:
+ *   - 0 (no bits set) - all the objects inside the container are
+ * reset. The child containers are entered recursively and the
+ * objects reset. All the objects (including the child containers)
+ * are closed.
+ *   - bit 0 set - all the objects inside the container are reset.
+ * However the child containers are not entered recursively.
+ * This option is supported for API versions >= 6.5
+ * In case a software context crashes or becomes non-responsive, the parent
+ * may wish to reset its resources container before the software context is
+ * restarted.
+ *
+ * This routine informs all objects assigned to the child container that the
+ * container is being reset, so they may perform any cleanup operations that 
are
+ * needed. All objects handles that were owned by the child container shall be
+ * closed.
+ *
+ * Note that such request may be submitted even if the child software context
+ * has not crashed, but the resulting object cleanup operations will not be
+ * aware of that.
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dprc_reset_container(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+int child_container_id,
+u32 options)
+{
+   struct fsl_mc_command cmd = { 0 };
+   struct dprc_cmd_reset_container *cmd_params;
+   u32 cmdid = DPRC_CMDID_RESET_CONT;
+   int err;
+
+   /**
+* If the DPRC object version was not yet cached, cache it now.
+* Otherwise use the already cached value.
+*/
+   if (!dprc_major_ver && !dprc_minor_ver) {
+   err = dprc_get_api_version(mc_io, 0,
+   &dprc_major_ver,
+   &dprc_minor_ver);
+   if (err)
+   return err;
+   }
+
+   /**
+* MC API 6.5 introduced a new field in the command used to pass
+* some flags.
+* Bit 0 indicates that the child containers are not recursively reset.
+*/
+   if (dprc_major_ver > 6 || (dprc_major_ver == 6 && dprc_minor_ver >= 5))
+   cmdid = DPRC_CMDID_RESET_CONT_V2;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(cmdid, cmd_flags, token);
+   cmd_params = (struct dprc_cmd_reset_container *)cmd.params;
+   cmd_params->child_container_id = cpu_to_le32(child_container_id);
+   cmd_params->options = cpu_to_le32(options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, &cmd);
+}
+EXPORT_SYMBOL_GPL(dprc_reset_container);
+
 /**
  * dprc_set_irq() - Set IRQ information for the DPRC to trigger an interrupt.
  * @mc_io: Pointer to MC portal's I/O object
diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h 
b/drivers/bus/fsl-mc/fsl-mc-private.h
index c2a688c07ee2..fdd9e9aa6701 100644
--- a/drivers/bus/fsl-mc/fsl-mc-private.h
+++ b/drivers/bus/fsl-mc/fsl-mc-private.h
@@ -91,6 +91,8 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,
 #define DPRC_CMDID_GET_API_VERSION  DPRC_CMD(0xa05)
 
 #define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004)
+#define DPRC_CMDID_RESET_CONT   DPRC_CMD(0x005)
+#define DPRC_CMDID_RESET_CONT_V2DPRC_CMD_V2(0x005)
 
 #define DPRC_CMDID_SET_IRQ  DPRC_CMD(0x010)
 #define DPRC_CMDID_SET_IRQ_ENABLE   DPRC_CMD(0x012)
@@ -111,6 +113,11 @@ struct dprc_cmd_open {
__le32 container_id;
 };
 
+struct dprc_cmd_reset_container {
+   __le32 child_container_id;
+   __le32 options;
+};
+
 struct dprc_cmd_set_irq {
/* cmd word 0 */
__le32 irq_val;
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index 4e9b570a1845..805a19516338 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -486,6 +486,13 @@ static inline bool is_fsl_mc_bus_dpseci(const struct 
fsl_mc_device *mc_dev)
return mc_dev->dev.type == &fsl_mc_bus_dpseci_type;
 }
 
+#defin

[PATCH v2 08/12] bus/fsl-mc: Export a cleanup function for DPRC

2020-05-07 Thread Diana Craciun
Create and export a cleanup function for DPRC. The function
is used by the DPRC driver, but it will be used by the VFIO
driver as well.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc-driver.c | 52 
 include/linux/fsl/mc.h   |  2 ++
 2 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index 4f7fa5127844..07012894cc9c 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -719,33 +719,25 @@ static void dprc_teardown_irq(struct fsl_mc_device 
*mc_dev)
 }
 
 /**
- * dprc_remove - callback invoked when a DPRC is being unbound from this driver
+ * dprc_cleanup - function that cleanups a DPRC
  *
  * @mc_dev: Pointer to fsl-mc device representing the DPRC
  *
- * It removes the DPRC's child objects from Linux (not from the MC) and
- * closes the DPRC device in the MC.
- * It tears down the interrupts that were configured for the DPRC device.
+ * It closes the DPRC device in the MC.
  * It destroys the interrupt pool associated with this MC bus.
  */
-static int dprc_remove(struct fsl_mc_device *mc_dev)
+
+int dprc_cleanup(struct fsl_mc_device *mc_dev)
 {
int error;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
 
if (!is_fsl_mc_bus_dprc(mc_dev))
return -EINVAL;
-   if (!mc_dev->mc_io)
-   return -EINVAL;
 
-   if (!mc_bus->irq_resources)
+   if (!mc_dev->mc_io)
return -EINVAL;
 
-   if (dev_get_msi_domain(&mc_dev->dev))
-   dprc_teardown_irq(mc_dev);
-
-   device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
-
if (dev_get_msi_domain(&mc_dev->dev)) {
fsl_mc_cleanup_irq_pool(mc_bus);
dev_set_msi_domain(&mc_dev->dev, NULL);
@@ -762,6 +754,40 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
mc_dev->mc_io = NULL;
}
 
+   return 0;
+}
+EXPORT_SYMBOL_GPL(dprc_cleanup);
+
+/**
+ * dprc_remove - callback invoked when a DPRC is being unbound from this driver
+ *
+ * @mc_dev: Pointer to fsl-mc device representing the DPRC
+ *
+ * It removes the DPRC's child objects from Linux (not from the MC) and
+ * closes the DPRC device in the MC.
+ * It tears down the interrupts that were configured for the DPRC device.
+ * It destroys the interrupt pool associated with this MC bus.
+ */
+static int dprc_remove(struct fsl_mc_device *mc_dev)
+{
+   int error;
+   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
+
+   if (!is_fsl_mc_bus_dprc(mc_dev))
+   return -EINVAL;
+
+   if (!mc_bus->irq_resources)
+   return -EINVAL;
+
+   if (dev_get_msi_domain(&mc_dev->dev))
+   dprc_teardown_irq(mc_dev);
+
+   device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
+
+   error = dprc_cleanup(mc_dev);
+   if (error < 0)
+   dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);
+
dev_info(&mc_dev->dev, "DPRC device unbound from driver");
return 0;
 }
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index 4c95e2dcf350..26f2b84dbe5f 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -496,6 +496,8 @@ int dprc_reset_container(struct fsl_mc_io *mc_io,
 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev,
bool alloc_interrupts);
 
+int dprc_cleanup(struct fsl_mc_device *mc_dev);
+
 /*
  * Data Path Buffer Pool (DPBP) API
  * Contains initialization APIs and runtime control APIs for DPBP
-- 
2.17.1



[PATCH v2 04/12] bus/fsl-mc: Set the QMAN/BMAN region flags

2020-05-07 Thread Diana Craciun
The QMAN region is memory mapped, so it should be of type
IORESOURCE_MEM. The region flags bits were wrongly used to
pass additional information. Use the bus specific bits for
this purpose.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/fsl-mc-bus.c | 7 ++-
 drivers/bus/fsl-mc/fsl-mc-private.h | 6 --
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index 3a86f5087717..df96f1602361 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -573,11 +573,8 @@ static int fsl_mc_device_get_mmio_regions(struct 
fsl_mc_device *mc_dev,
 
regions[i].end = regions[i].start + region_desc.size - 1;
regions[i].name = "fsl-mc object MMIO region";
-   regions[i].flags = IORESOURCE_IO;
-   if (region_desc.flags & DPRC_REGION_CACHEABLE)
-   regions[i].flags |= IORESOURCE_CACHEABLE;
-   if (region_desc.flags & DPRC_REGION_SHAREABLE)
-   regions[i].flags |= IORESOURCE_MEM;
+   regions[i].flags = region_desc.flags & IORESOURCE_BITS;
+   regions[i].flags |= IORESOURCE_MEM;
}
 
mc_dev->regions = regions;
diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h 
b/drivers/bus/fsl-mc/fsl-mc-private.h
index 21ca8c756ee7..c2a688c07ee2 100644
--- a/drivers/bus/fsl-mc/fsl-mc-private.h
+++ b/drivers/bus/fsl-mc/fsl-mc-private.h
@@ -358,12 +358,6 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
 int obj_id,
 u8 irq_index,
 struct dprc_irq_cfg *irq_cfg);
-
-/* Region flags */
-/* Cacheable - Indicates that region should be mapped as cacheable */
-#define DPRC_REGION_CACHEABLE  0x0001
-#define DPRC_REGION_SHAREABLE  0x0002
-
 /**
  * enum dprc_region_type - Region type
  * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
-- 
2.17.1



[PATCH v2 03/12] bus/fsl-mc: add support for 'driver_override' in the mc-bus

2020-05-07 Thread Diana Craciun
From: Bharat Bhushan 

This patch is required for vfio-fsl-mc meta driver to successfully bind
layerscape container devices for device passthrough. This patch adds
a mechanism to allow a layerscape device to specify a driver rather than
a layerscape driver provide a device match.

Example to allow a device (dprc.1) to specifically bind
with driver (vfio-fsl-mc):
 - echo vfio-fsl-mc > /sys/bus/fsl-mc/devices/dprc.1/driver_override
 - echo dprc.1 > /sys/bus/fsl-mc/drivers/fsl_mc_dprc/unbind
 - echo dprc.1 > /sys/bus/fsl-mc/drivers/vfio-fsl-mc/bind

Signed-off-by: Bharat Bhushan 
Signed-off-by: Laurentiu Tudor 
Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/fsl-mc-bus.c | 54 +
 include/linux/fsl/mc.h  |  2 ++
 2 files changed, 56 insertions(+)

diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index 40526da5c6a6..3a86f5087717 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -3,6 +3,7 @@
  * Freescale Management Complex (MC) bus driver
  *
  * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
+ * Copyright 2019-2020 NXP
  * Author: German Rivera 
  *
  */
@@ -71,6 +72,12 @@ static int fsl_mc_bus_match(struct device *dev, struct 
device_driver *drv)
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
bool found = false;
 
+   /* When driver_override is set, only bind to the matching driver */
+   if (mc_dev->driver_override) {
+   found = !strcmp(mc_dev->driver_override, mc_drv->driver.name);
+   goto out;
+   }
+
if (!mc_drv->match_id_table)
goto out;
 
@@ -135,8 +142,52 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *attr,
 }
 static DEVICE_ATTR_RO(modalias);
 
+static ssize_t driver_override_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+   char *driver_override, *old = mc_dev->driver_override;
+   char *cp;
+
+   if (WARN_ON(dev->bus != &fsl_mc_bus_type))
+   return -EINVAL;
+
+   if (count >= (PAGE_SIZE - 1))
+   return -EINVAL;
+
+   driver_override = kstrndup(buf, count, GFP_KERNEL);
+   if (!driver_override)
+   return -ENOMEM;
+
+   cp = strchr(driver_override, '\n');
+   if (cp)
+   *cp = '\0';
+
+   if (strlen(driver_override)) {
+   mc_dev->driver_override = driver_override;
+   } else {
+   kfree(driver_override);
+   mc_dev->driver_override = NULL;
+   }
+
+   kfree(old);
+
+   return count;
+}
+
+static ssize_t driver_override_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+
+   return snprintf(buf, PAGE_SIZE, "%s\n", mc_dev->driver_override);
+}
+static DEVICE_ATTR_RW(driver_override);
+
 static struct attribute *fsl_mc_dev_attrs[] = {
&dev_attr_modalias.attr,
+   &dev_attr_driver_override.attr,
NULL,
 };
 
@@ -706,6 +757,9 @@ EXPORT_SYMBOL_GPL(fsl_mc_device_add);
  */
 void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
 {
+   kfree(mc_dev->driver_override);
+   mc_dev->driver_override = NULL;
+
/*
 * The device-specific remove callback will get invoked by device_del()
 */
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index 2b5f8366dbe1..4e9b570a1845 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -161,6 +161,7 @@ struct fsl_mc_obj_desc {
  * @regions: pointer to array of MMIO region entries
  * @irqs: pointer to array of pointers to interrupts allocated to this device
  * @resource: generic resource associated with this MC object device, if any.
+ * @driver_override: driver name to force a match
  *
  * Generic device object for MC object devices that are "attached" to a
  * MC bus.
@@ -194,6 +195,7 @@ struct fsl_mc_device {
struct fsl_mc_device_irq **irqs;
struct fsl_mc_resource *resource;
struct device_link *consumer_link;
+   char   *driver_override;
 };
 
 #define to_fsl_mc_device(_dev) \
-- 
2.17.1



[PATCH v2 11/12] bus/fsl-mc: Export IRQ pool handling functions to be used by VFIO

2020-05-07 Thread Diana Craciun
The IRQ pool handling functions can be used by both DPRC
driver and VFIO. Adapt and export those functions.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc-driver.c  |  7 +++
 drivers/bus/fsl-mc/fsl-mc-allocator.c | 12 
 drivers/bus/fsl-mc/fsl-mc-private.h   | 10 --
 include/linux/fsl/mc.h| 11 +++
 4 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index ec44d025f623..75a53c38bcd8 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -303,8 +303,8 @@ static int dprc_scan_objects(struct fsl_mc_device 
*mc_bus_dev,
}
 
if (alloc_interrupts && !mc_bus->irq_resources) {
-   error = fsl_mc_populate_irq_pool(mc_bus,
-   FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
+   error = fsl_mc_populate_irq_pool(mc_bus_dev,
+FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
if (error < 0)
return error;
}
@@ -758,7 +758,6 @@ static void dprc_teardown_irq(struct fsl_mc_device *mc_dev)
 int dprc_cleanup(struct fsl_mc_device *mc_dev)
 {
int error;
-   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
 
if (!is_fsl_mc_bus_dprc(mc_dev))
return -EINVAL;
@@ -767,7 +766,7 @@ int dprc_cleanup(struct fsl_mc_device *mc_dev)
return -EINVAL;
 
if (dev_get_msi_domain(&mc_dev->dev)) {
-   fsl_mc_cleanup_irq_pool(mc_bus);
+   fsl_mc_cleanup_irq_pool(mc_dev);
dev_set_msi_domain(&mc_dev->dev, NULL);
}
 
diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c 
b/drivers/bus/fsl-mc/fsl-mc-allocator.c
index cc7bb900f524..e71a6f52ea0c 100644
--- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
+++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
@@ -344,7 +344,7 @@ EXPORT_SYMBOL_GPL(fsl_mc_object_free);
  * Initialize the interrupt pool associated with an fsl-mc bus.
  * It allocates a block of IRQs from the GIC-ITS.
  */
-int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
+int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev,
 unsigned int irq_count)
 {
unsigned int i;
@@ -352,10 +352,14 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
struct fsl_mc_device_irq *irq_resources;
struct fsl_mc_device_irq *mc_dev_irq;
int error;
-   struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
+   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
struct fsl_mc_resource_pool *res_pool =
&mc_bus->resource_pools[FSL_MC_POOL_IRQ];
 
+   /* do nothing if the IRQ pool is already populated */
+   if (mc_bus->irq_resources)
+   return 0;
+
if (irq_count == 0 ||
irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS)
return -EINVAL;
@@ -407,9 +411,9 @@ EXPORT_SYMBOL_GPL(fsl_mc_populate_irq_pool);
  * Teardown the interrupt pool associated with an fsl-mc bus.
  * It frees the IRQs that were allocated to the pool, back to the GIC-ITS.
  */
-void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus)
+void fsl_mc_cleanup_irq_pool(struct fsl_mc_device *mc_bus_dev)
 {
-   struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
+   struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
struct fsl_mc_resource_pool *res_pool =
&mc_bus->resource_pools[FSL_MC_POOL_IRQ];
 
diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h 
b/drivers/bus/fsl-mc/fsl-mc-private.h
index fdd9e9aa6701..48255e8944bd 100644
--- a/drivers/bus/fsl-mc/fsl-mc-private.h
+++ b/drivers/bus/fsl-mc/fsl-mc-private.h
@@ -519,11 +519,6 @@ struct dpcon_cmd_set_notification {
__le64 user_ctx;
 };
 
-/**
- * Maximum number of total IRQs that can be pre-allocated for an MC bus'
- * IRQ pool
- */
-#define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256
 
 /**
  * struct fsl_mc_resource_pool - Pool of MC resources of a given
@@ -599,11 +594,6 @@ void fsl_mc_msi_domain_free_irqs(struct device *dev);
 int fsl_mc_find_msi_domain(struct device *mc_platform_dev,
   struct irq_domain **mc_msi_domain);
 
-int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
-unsigned int irq_count);
-
-void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus);
-
 int __must_check fsl_create_mc_io(struct device *dev,
  phys_addr_t mc_portal_phys_addr,
  u32 mc_portal_size,
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index df4a9bbae0f0..648ad06f58eb 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -500,6 +500,17 @@ int dprc_cleanup(struct fsl_mc_device *mc_dev);
 
 int dprc_setup(struct fsl_mc_device *mc_dev);
 
+/**
+ * Maximum number of total IRQs that can be 

[PATCH v2 00/12] bus/fsl-mc: Extend mc-bus driver functionalities in preparation for mc-bus VFIO support

2020-05-07 Thread Diana Craciun
The vfio-mc bus driver needs some additional services to be exported by the
mc-bus driver like:
- a way to reset the DPRC container
- driver_override support
- functions to setup/tear down a DPRC
- functions for allocating the pool of interrupts. In case of VFIO the
interrupts are not configured at probe time, but later by userspace
request

v1 -> v2
- Remove driver_override propagation through various functions
- Cache the DPRC API version

The patches are related with "vfio/fsl-mc: VFIO support for FSL-MC
devices" patches, but the series were split because they are targeting
different subsystems. However, the mc-bus patches may suffer changes
when addressing the VFIO review comments.

Bharat Bhushan (3):
  bus/fsl-mc: add support for 'driver_override' in the mc-bus
  bus/fsl-mc: Add dprc-reset-container support
  bus/fsl-mc: Extend ICID size from 16bit to 32bit

Diana Craciun (9):
  bus/fsl-mc: Do no longer export the total number of irqs outside
dprc_scan_objects
  bus/fsl-mc: Add a new parameter to dprc_scan_objects function
  bus/fsl-mc: Set the QMAN/BMAN region flags
  bus/fsl-mc: Cache the DPRC API version
  bus/fsl-mc: Export a dprc scan function to be used by multiple
entities
  bus/fsl-mc: Export a cleanup function for DPRC
  bus/fsl-mc: Add a container setup function
  bus/fsl_mc: Do not rely on caller to provide non NULL mc_io
  bus/fsl-mc: Export IRQ pool handling functions to be used by VFIO

 drivers/bus/fsl-mc/dprc-driver.c  | 181 --
 drivers/bus/fsl-mc/dprc.c | 103 +--
 drivers/bus/fsl-mc/fsl-mc-allocator.c |  12 +-
 drivers/bus/fsl-mc/fsl-mc-bus.c   |  64 -
 drivers/bus/fsl-mc/fsl-mc-private.h   |  28 ++--
 drivers/bus/fsl-mc/mc-io.c|   7 +-
 include/linux/fsl/mc.h|  29 -
 7 files changed, 313 insertions(+), 111 deletions(-)

-- 
2.17.1



[PATCH v2 12/12] bus/fsl-mc: Extend ICID size from 16bit to 32bit

2020-05-07 Thread Diana Craciun
From: Bharat Bhushan 

In virtual machines the device-id range is defined
between 0x1-0x2. The reason for using such a
large range is to avoid overlapping with the PCI range.

Signed-off-by: Bharat Bhushan 
Signed-off-by: Laurentiu Tudor 
Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc.c   | 2 +-
 drivers/bus/fsl-mc/fsl-mc-bus.c | 2 +-
 drivers/bus/fsl-mc/fsl-mc-private.h | 5 ++---
 include/linux/fsl/mc.h  | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c
index 44bde72bdea7..3f08752c2c19 100644
--- a/drivers/bus/fsl-mc/dprc.c
+++ b/drivers/bus/fsl-mc/dprc.c
@@ -360,7 +360,7 @@ int dprc_get_attributes(struct fsl_mc_io *mc_io,
/* retrieve response parameters */
rsp_params = (struct dprc_rsp_get_attributes *)cmd.params;
attr->container_id = le32_to_cpu(rsp_params->container_id);
-   attr->icid = le16_to_cpu(rsp_params->icid);
+   attr->icid = le32_to_cpu(rsp_params->icid);
attr->options = le32_to_cpu(rsp_params->options);
attr->portal_id = le32_to_cpu(rsp_params->portal_id);
 
diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index bf4f01ddf846..f44a5e9d0c4a 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -461,7 +461,7 @@ static int get_dprc_attr(struct fsl_mc_io *mc_io,
 }
 
 static int get_dprc_icid(struct fsl_mc_io *mc_io,
-int container_id, u16 *icid)
+int container_id, u32 *icid)
 {
struct dprc_attributes attr;
int error;
diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h 
b/drivers/bus/fsl-mc/fsl-mc-private.h
index 48255e8944bd..e6fcff12c68d 100644
--- a/drivers/bus/fsl-mc/fsl-mc-private.h
+++ b/drivers/bus/fsl-mc/fsl-mc-private.h
@@ -159,8 +159,7 @@ struct dprc_cmd_clear_irq_status {
 struct dprc_rsp_get_attributes {
/* response word 0 */
__le32 container_id;
-   __le16 icid;
-   __le16 pad;
+   __le32 icid;
/* response word 1 */
__le32 options;
__le32 portal_id;
@@ -337,7 +336,7 @@ int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
  */
 struct dprc_attributes {
int container_id;
-   u16 icid;
+   u32 icid;
int portal_id;
u64 options;
 };
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index 648ad06f58eb..10637590460c 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -187,7 +187,7 @@ struct fsl_mc_device {
struct device dev;
u64 dma_mask;
u16 flags;
-   u16 icid;
+   u32 icid;
u16 mc_handle;
struct fsl_mc_io *mc_io;
struct fsl_mc_obj_desc obj_desc;
-- 
2.17.1



[PATCH v2 01/12] bus/fsl-mc: Do no longer export the total number of irqs outside dprc_scan_objects

2020-05-07 Thread Diana Craciun
The total number of interrupts is only used for some checks
outside the dprc_scan_objects function. Furthermore, in some
situations the check is made twice. Move the bounds check inside
the function for all situations.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc-driver.c | 30 ++
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index c8b1c3842c1a..035b220779d0 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -3,6 +3,7 @@
  * Freescale data path resource container (DPRC) driver
  *
  * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
+ * Copyright 2019-2020 NXP
  * Author: German Rivera 
  *
  */
@@ -197,8 +198,6 @@ static void dprc_add_new_devices(struct fsl_mc_device 
*mc_bus_dev,
  * dprc_scan_objects - Discover objects in a DPRC
  *
  * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
- * @total_irq_count: If argument is provided the function populates the
- * total number of IRQs created by objects in the DPRC.
  *
  * Detects objects added and removed from a DPRC and synchronizes the
  * state of the Linux bus driver, MC by adding and removing
@@ -212,8 +211,7 @@ static void dprc_add_new_devices(struct fsl_mc_device 
*mc_bus_dev,
  * populated before they can get allocation requests from probe callbacks
  * of the device drivers for the non-allocatable devices.
  */
-static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
-unsigned int *total_irq_count)
+static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev)
 {
int num_child_objects;
int dprc_get_obj_failures;
@@ -294,22 +292,21 @@ static int dprc_scan_objects(struct fsl_mc_device 
*mc_bus_dev,
 * Allocate IRQ's before binding the scanned devices with their
 * respective drivers.
 */
-   if (dev_get_msi_domain(&mc_bus_dev->dev) && !mc_bus->irq_resources) {
+   if (dev_get_msi_domain(&mc_bus_dev->dev)) {
if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) {
dev_warn(&mc_bus_dev->dev,
 "IRQs needed (%u) exceed IRQs preallocated 
(%u)\n",
 irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
}
 
-   error = fsl_mc_populate_irq_pool(mc_bus,
+   if (!mc_bus->irq_resources) {
+   error = fsl_mc_populate_irq_pool(mc_bus,
FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
-   if (error < 0)
-   return error;
+   if (error < 0)
+   return error;
+   }
}
 
-   if (total_irq_count)
-   *total_irq_count = irq_count;
-
dprc_remove_devices(mc_bus_dev, child_obj_desc_array,
num_child_objects);
 
@@ -342,7 +339,7 @@ static int dprc_scan_container(struct fsl_mc_device 
*mc_bus_dev)
 * Discover objects in the DPRC:
 */
mutex_lock(&mc_bus->scan_mutex);
-   error = dprc_scan_objects(mc_bus_dev, NULL);
+   error = dprc_scan_objects(mc_bus_dev);
mutex_unlock(&mc_bus->scan_mutex);
if (error < 0) {
fsl_mc_cleanup_all_resource_pools(mc_bus_dev);
@@ -411,9 +408,8 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, 
void *arg)
  DPRC_IRQ_EVENT_CONTAINER_DESTROYED |
  DPRC_IRQ_EVENT_OBJ_DESTROYED |
  DPRC_IRQ_EVENT_OBJ_CREATED)) {
-   unsigned int irq_count;
 
-   error = dprc_scan_objects(mc_dev, &irq_count);
+   error = dprc_scan_objects(mc_dev);
if (error < 0) {
/*
 * If the error is -ENXIO, we ignore it, as it indicates
@@ -428,12 +424,6 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, 
void *arg)
 
goto out;
}
-
-   if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) {
-   dev_warn(dev,
-"IRQs needed (%u) exceed IRQs preallocated 
(%u)\n",
-irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
-   }
}
 
 out:
-- 
2.17.1



[PATCH v2 07/12] bus/fsl-mc: Export a dprc scan function to be used by multiple entities

2020-05-07 Thread Diana Craciun
Currently the DPRC scan function is used only by the bus driver.
But the same functionality will be needed by the VFIO driver.
To support this, the dprc scan function was exported and a little
bit adjusted to fit both scenarios. Also the scan mutex initialization
is done when the bus object is created, not in dprc_probe in order
to be used by both VFIO and bus driver.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/dprc-driver.c | 19 +++
 drivers/bus/fsl-mc/fsl-mc-bus.c  |  1 +
 include/linux/fsl/mc.h   |  3 +++
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index 7a8061224df8..4f7fa5127844 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -331,9 +331,10 @@ static int dprc_scan_objects(struct fsl_mc_device 
*mc_bus_dev,
  * bus driver with the actual state of the MC by adding and removing
  * devices as appropriate.
  */
-static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
+int dprc_scan_container(struct fsl_mc_device *mc_bus_dev,
+   bool alloc_interrupts)
 {
-   int error;
+   int error = 0;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
 
fsl_mc_init_all_resource_pools(mc_bus_dev);
@@ -342,16 +343,12 @@ static int dprc_scan_container(struct fsl_mc_device 
*mc_bus_dev)
 * Discover objects in the DPRC:
 */
mutex_lock(&mc_bus->scan_mutex);
-   error = dprc_scan_objects(mc_bus_dev, true);
+   error = dprc_scan_objects(mc_bus_dev, alloc_interrupts);
mutex_unlock(&mc_bus->scan_mutex);
-   if (error < 0) {
-   fsl_mc_cleanup_all_resource_pools(mc_bus_dev);
-   return error;
-   }
 
-   return 0;
+   return error;
 }
-
+EXPORT_SYMBOL_GPL(dprc_scan_container);
 /**
  * dprc_irq0_handler - Regular ISR for DPRC interrupt 0
  *
@@ -675,12 +672,10 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
goto error_cleanup_open;
}
 
-   mutex_init(&mc_bus->scan_mutex);
-
/*
 * Discover MC objects in DPRC object:
 */
-   error = dprc_scan_container(mc_dev);
+   error = dprc_scan_container(mc_dev, true);
if (error < 0)
goto error_cleanup_open;
 
diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index df96f1602361..bf4f01ddf846 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -636,6 +636,7 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
if (!mc_bus)
return -ENOMEM;
 
+   mutex_init(&mc_bus->scan_mutex);
mc_dev = &mc_bus->mc_dev;
} else {
/*
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index 805a19516338..4c95e2dcf350 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -493,6 +493,9 @@ int dprc_reset_container(struct fsl_mc_io *mc_io,
 int child_container_id,
 u32 options);
 
+int dprc_scan_container(struct fsl_mc_device *mc_bus_dev,
+   bool alloc_interrupts);
+
 /*
  * Data Path Buffer Pool (DPBP) API
  * Contains initialization APIs and runtime control APIs for DPBP
-- 
2.17.1



[PATCH v2 10/12] bus/fsl_mc: Do not rely on caller to provide non NULL mc_io

2020-05-07 Thread Diana Craciun
Before destroying the mc_io, check first that it was
allocated.

Signed-off-by: Diana Craciun 
---
 drivers/bus/fsl-mc/mc-io.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fsl-mc/mc-io.c b/drivers/bus/fsl-mc/mc-io.c
index 6ae48ad80409..e1dfe4a76519 100644
--- a/drivers/bus/fsl-mc/mc-io.c
+++ b/drivers/bus/fsl-mc/mc-io.c
@@ -129,7 +129,12 @@ int __must_check fsl_create_mc_io(struct device *dev,
  */
 void fsl_destroy_mc_io(struct fsl_mc_io *mc_io)
 {
-   struct fsl_mc_device *dpmcp_dev = mc_io->dpmcp_dev;
+   struct fsl_mc_device *dpmcp_dev;
+
+   if (!mc_io)
+   return;
+
+   dpmcp_dev = mc_io->dpmcp_dev;
 
if (dpmcp_dev)
fsl_mc_io_unset_dpmcp(mc_io);
-- 
2.17.1



Re: [PATCH v5 3/5] drivers/soc/litex: add LiteX SoC Controller driver

2020-05-07 Thread Mateusz Holenko
On Wed, Apr 29, 2020 at 5:12 AM Benjamin Herrenschmidt
 wrote:
>
> On Sat, 2020-04-25 at 13:42 +0200, Mateusz Holenko wrote:
> > From: Pawel Czarnecki 
> >
> > This commit adds driver for the FPGA-based LiteX SoC
> > Controller from LiteX SoC builder.
>
> Sorry for jumping in late, Joel only just pointed me to this :)
>
> > + * The purpose of `litex_set_reg`/`litex_get_reg` is to implement
> > + * the logic of writing to/reading from the LiteX CSR in a single
> > + * place that can be then reused by all LiteX drivers.
> > + */
> > +void litex_set_reg(void __iomem *reg, unsigned long reg_size,
> > + unsigned long val)
> > +{
> > + unsigned long shifted_data, shift, i;
> > + unsigned long flags;
> > +
> > + spin_lock_irqsave(&csr_lock, flags);
> > +
> > + for (i = 0; i < reg_size; ++i) {
> > + shift = ((reg_size - i - 1) * LITEX_SUBREG_SIZE_BIT);
> > + shifted_data = val >> shift;
> > +
> > + __raw_writel(shifted_data, reg + (LITEX_REG_SIZE * i));
> > + }
> > +
> > + spin_unlock_irqrestore(&csr_lock, flags);
> > +}
> > +
> > +unsigned long litex_get_reg(void __iomem *reg, unsigned long reg_size)
> > +{
> > + unsigned long shifted_data, shift, i;
> > + unsigned long result = 0;
> > + unsigned long flags;
> > +
> > + spin_lock_irqsave(&csr_lock, flags);
> > +
> > + for (i = 0; i < reg_size; ++i) {
> > + shifted_data = __raw_readl(reg + (LITEX_REG_SIZE * i));
> > +
> > + shift = ((reg_size - i - 1) * LITEX_SUBREG_SIZE_BIT);
> > + result |= (shifted_data << shift);
> > + }
> > +
> > + spin_unlock_irqrestore(&csr_lock, flags);
> > +
> > + return result;
> > +}
>
> I really don't like the fact that the register sizes & sub sizes are
> #defined. As your comment explains, this makes it harder to support
> other configurations. This geometry should come from the device-tree
> instead.

This is a valid point - putting those parameters into DT would indeed allow
for more flexibility. Currently we are focusing on supporting a single LiteX
configuration (32-bit/8-bit bus) and that's why those parameters got fixed.

Adding support for other configurations however is not just changing those
two parameters (which should be fairly easy by itself), but also
handling different
registers layout for a single peripheral (in different configurations
CSRs offsets and sizes may differ).

Since this adds another layer of complexity we want to start with a simpler
version that can be extended in the future.

> Also this while thing is rather gross (and the lock will not help
> performance). Why can't CSRs be normally memory mapped always instead ?

Using a different LiteX configuration 32-bit/32-bit bus would solve
the problem -
a single LiteX CSR would map nicely to a single 32-bit memory pointer and no
loop/locks would be needed.

In the default configuration (32-bit/8-bit bus) there are gaps between bytes
(as Gabriel Somlo already explained in his mail) which need to be handled
"manually".

> Even when transporting them on a HW bus that's smaller, the HW bus
> conversion should be able to do the break-down into a multi-breat
> transfer rather than doing that in SW.
>
> Or at least have a fast-path if the register size is no larger than the
> sub size, so you can use a normal ioread32/iowrite32.

Again - this is possible, but using a non-default 32-bit/32-bit bus LiteX
configuration.

> Also I wonder ... last I played with LiteX, it would re-generate the
> register layout (including the bit layout inside registers potentially)
> rather enthousiastically, making it pretty hard to have a fixed
> register layout for use by a kernel driver. Was this addressed ?

TBH I never experienced bit layout inside a register to change by itself,
but I agree that using different bus width configurations causes CSRs
to be splitted into 4/2/1 32-bit registers (changing de facto the layout
from the SW perspective) - that's why we provide helper functions
in this file.

It is possible to have different configurations of a peripheral
in LiteX that e.g, turns features on/off - this might cause some CSRs
to shift and result in incompatibilities. There are ways in LiteX
to avoid such problems if the model is properly designed, though.

Another aspect of LiteX is that the order in which separate peripherals
(modules) are created results in a different memory map of the whole SoC.
This, however, is easily addressed by using a dynamically generated DT
and do not require the code of drivers to be altered in any way.

> Cheers,
> Ben.
>
>

Thanks for your comments!


-- 
Mateusz Holenko
Antmicro Ltd | www.antmicro.com
Roosevelta 22, 60-829 Poznan, Poland


Re: [net-next PATCH v3 5/5] net: mdiobus: Introduce fwnode_mdiobus_register_phy()

2020-05-07 Thread Calvin Johnson
On Tue, May 05, 2020 at 05:22:00PM +0300, Andy Shevchenko wrote:
> On Tue, May 5, 2020 at 4:30 PM Calvin Johnson
>  wrote:
> >
> > Introduce fwnode_mdiobus_register_phy() to register PHYs on the
> > mdiobus. From the compatible string, identify whether the PHY is
> > c45 and based on this create a PHY device instance which is
> > registered on the mdiobus.
> 
> ...
> 
> > +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > +   struct fwnode_handle *child, u32 addr)
> > +{
> > +   struct phy_device *phy;
> 
> > +   bool is_c45 = false;
> 
> Redundant assignment, see below.
> 
> > +   const char *cp;
> > +   u32 phy_id;
> > +   int rc;
> > +
> 
> > +   fwnode_property_read_string(child, "compatible", &cp);
> 
> Consider rc = ...; otherwise you will have UB below.
> 
> > +   if (!strcmp(cp, "ethernet-phy-ieee802.3-c45"))
> 
> UB!

Thanks for the comments! I've considered all of them.
What is UB, by the way? :)-

Regards
Calvin


Re: [RFC 0/8] mfd: Add support for Khadas Microcontroller

2020-05-07 Thread Neil Armstrong
On 29/04/2020 21:16, Kevin Hilman wrote:
> Neil Armstrong  writes:
> 
>> The new Khadas VIM2, VIM3 and Edge boards embeds an on-board microcontroller
>> connected via I2C.
>>
>> This Microcontroller is present on the Khadas VIM1, VIM2, VIM3 and Edge
>> boards.
>>
>> It has multiple boot control features like password check, power-on
>> options, power-off control and system FAN control on recent boards.
>>
>> Thie serie adds :
>> - the bindings
>> - the MFD driver
>> - the HWMON cell driver
>> - the NVMEM cell driver
>> - updates MAINTAINERS
>> - add support into the Khadas VIM3/VIM3L DT
>>
>> Neil Armstrong (8):
>>   dt-bindings: mfd: add Khadas Microcontroller bindings
>>   mfd: add support for the Khadas System control Microcontroller
>>   hwmon: add support for the MCU controlled FAN on Khadas boards
>>   nvmem: add support for the Khadas MCU Programmable User Memory
>>   MAINTAINERS: add myself as maintainer for Khadas MCU drivers
>>   arm64: dts: meson-g12b: move G12B thermal nodes to meson-g12b.dtsi
>>   arm64: dts: meson-sm1: add cpu thermal nodes
> 
> These two could/should be sent separately from this RFC series and
> queued for v5.8.
> 
> Kevin
> 

Ok

Neil


Re: bdi: fix use-after-free for dev_name(bdi->dev) v3 (resend)

2020-05-07 Thread Ming Lei
On Mon, May 04, 2020 at 02:47:52PM +0200, Christoph Hellwig wrote:
> Hi Jens,
> 
> can you pick up this series?
> 
> the first three patches are my take on the proposal from Yufen Yu
> to fix the use after free of the device name of the bdi device.
> 
> The rest is vaguely related cleanups.
> 
> Changes since v2:
>  - switch vboxsf to a shorter bdi name
> 
> Changes since v1:
>  - use a static dev_name buffer inside struct backing_dev_info
> 

Looks fine:

Reviewed-by: Ming Lei 

-- 
Ming



[PATCH 1/4] ARM: dts: stm32: add I2C3 support on STM32F429 SoC

2020-05-07 Thread dillon . minfei
From: dillon min 

This patch adds I2C3 instances of the STM32F429 SoC

Signed-off-by: dillon min 
---
 arch/arm/boot/dts/stm32f429.dtsi | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index d777069..257b843 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -402,6 +402,18 @@
status = "disabled";
};
 
+   i2c3: i2c@40005c00 {
+   compatible = "st,stm32f4-i2c";
+   reg = <0x40005c00 0x400>;
+   interrupts = <72>,
+<73>;
+   resets = <&rcc STM32F4_APB1_RESET(I2C3)>;
+   clocks = <&rcc 0 STM32F4_APB1_CLOCK(I2C3)>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
+
dac: dac@40007400 {
compatible = "st,stm32f4-dac-core";
reg = <0x40007400 0x400>;
-- 
2.7.4



[no subject]

2020-05-07 Thread dillon . minfei


This patchset enable the stmpe811 touch screen on stm32f429-disco
board, tested with ts_print. as sdram memory shortage on this disco
board, so i didn't test ts_calibrate (kernel crashed at mmap in
open framebuffer)


RE: [PATCH] x86: bitops: fix build regression

2020-05-07 Thread David Laight
From: Brian Gerst
> Sent: 07 May 2020 07:18
...
> > --- a/arch/x86/include/asm/bitops.h
> > +++ b/arch/x86/include/asm/bitops.h
> > @@ -54,7 +54,7 @@ arch_set_bit(long nr, volatile unsigned long *addr)
> > if (__builtin_constant_p(nr)) {
> > asm volatile(LOCK_PREFIX "orb %1,%0"
> > : CONST_MASK_ADDR(nr, addr)
> > -   : "iq" (CONST_MASK(nr) & 0xff)
> > +   : "iq" ((u8)(CONST_MASK(nr) & 0xff))
> 
> I think a better fix would be to make CONST_MASK() return a u8 value
> rather than have to cast on every use.

Or assign to a local variable - then it doesn't matter how
the value is actually calculated. So:
u8 mask = CONST_MASK(nr);
asm volatile(LOCK_PREFIX "orb %1,%0"
: CONST_MASK_ADDR(nr, addr)
: "iq" mask

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)


Re: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)

2020-05-07 Thread Auger Eric
Hi Shameer,

On 5/7/20 8:59 AM, Shameerali Kolothum Thodi wrote:
> Hi Eric,
> 
>> -Original Message-
>> From: Shameerali Kolothum Thodi
>> Sent: 30 April 2020 10:38
>> To: 'Auger Eric' ; Zhangfei Gao
>> ; eric.auger@gmail.com;
>> io...@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
>> k...@vger.kernel.org; kvm...@lists.cs.columbia.edu; w...@kernel.org;
>> j...@8bytes.org; m...@kernel.org; robin.mur...@arm.com
>> Cc: jean-phili...@linaro.org; alex.william...@redhat.com;
>> jacob.jun@linux.intel.com; yi.l@intel.com; peter.mayd...@linaro.org;
>> t...@semihalf.com; bbhush...@marvell.com
>> Subject: RE: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)
>>
>> Hi Eric,
>>
>>> -Original Message-
>>> From: Auger Eric [mailto:eric.au...@redhat.com]
>>> Sent: 16 April 2020 08:45
>>> To: Zhangfei Gao ; eric.auger@gmail.com;
>>> io...@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
>>> k...@vger.kernel.org; kvm...@lists.cs.columbia.edu; w...@kernel.org;
>>> j...@8bytes.org; m...@kernel.org; robin.mur...@arm.com
>>> Cc: jean-phili...@linaro.org; Shameerali Kolothum Thodi
>>> ; alex.william...@redhat.com;
>>> jacob.jun@linux.intel.com; yi.l@intel.com; peter.mayd...@linaro.org;
>>> t...@semihalf.com; bbhush...@marvell.com
>>> Subject: Re: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)
>>>
>>> Hi Zhangfei,
>>>
>>> On 4/16/20 6:25 AM, Zhangfei Gao wrote:


 On 2020/4/14 下午11:05, Eric Auger wrote:
> This version fixes an issue observed by Shameer on an SMMU 3.2,
> when moving from dual stage config to stage 1 only config.
> The 2 high 64b of the STE now get reset. Otherwise, leaving the
> S2TTB set may cause a C_BAD_STE error.
>
> This series can be found at:
> https://github.com/eauger/linux/tree/v5.6-2stage-v11_10.1
> (including the VFIO part)
> The QEMU fellow series still can be found at:
> https://github.com/eauger/qemu/tree/v4.2.0-2stage-rfcv6
>
> Users have expressed interest in that work and tested v9/v10:
> - https://patchwork.kernel.org/cover/11039995/#23012381
> - https://patchwork.kernel.org/cover/11039995/#23197235
>
> Background:
>
> This series brings the IOMMU part of HW nested paging support
> in the SMMUv3. The VFIO part is submitted separately.
>
> The IOMMU API is extended to support 2 new API functionalities:
> 1) pass the guest stage 1 configuration
> 2) pass stage 1 MSI bindings
>
> Then those capabilities gets implemented in the SMMUv3 driver.
>
> The virtualizer passes information through the VFIO user API
> which cascades them to the iommu subsystem. This allows the guest
> to own stage 1 tables and context descriptors (so-called PASID
> table) while the host owns stage 2 tables and main configuration
> structures (STE).
>
>

 Thanks Eric

 Tested v11 on Hisilicon kunpeng920 board via hardware zip accelerator.
 1. no-sva works, where guest app directly use physical address via ioctl.
>>> Thank you for the testing. Glad it works for you.
 2. vSVA still not work, same as v10,
>>> Yes that's normal this series is not meant to support vSVM at this stage.
>>>
>>> I intend to add the missing pieces during the next weeks.
>>
>> Thanks for that. I have made an attempt to add the vSVA based on
>> your v10 + JPBs sva patches. The host kernel and Qemu changes can
>> be found here[1][2].
>>
>> This basically adds multiple pasid support on top of your changes.
>> I have done some basic sanity testing and we have some initial success
>> with the zip vf dev on our D06 platform. Please note that the STALL event is
>> not yet supported though, but works fine if we mlock() guest usr mem.
> 
> I have added STALL support for our vSVA prototype and it seems to be
> working(on our hardware). I have updated the kernel and qemu branches with
> the same[1][2]. I should warn you though that these are prototype code and I 
> am pretty
> much re-using the VFIO_IOMMU_SET_PASID_TABLE interface for almost everything.
> But thought of sharing, in case if it is useful somehow!.

Thank you very much for your work. I intend to look at your additions by
beginning of next week.

Best Regards

Eric
> 
> Thanks,
> Shameer
> 
> [1]https://github.com/hisilicon/kernel-dev/commits/vsva-prototype-host-v1
> 
> [2]https://github.com/hisilicon/qemu/tree/v4.2.0-2stage-rfcv6-vsva-prototype-v1
> 



[PATCH 2/4] ARM: dts: stm32: Add pin map for I2C3 controller on stm32f4

2020-05-07 Thread dillon . minfei
From: dillon min 

This patch adds the pin configuration for I2C3 controller on
stm32f4.

Signed-off-by: dillon min 
---
 arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi 
b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi
index 392fa14..051f336 100644
--- a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi
@@ -316,6 +316,18 @@
};
};
 
+   i2c3_pins: i2c3-0 {
+   pins {
+   pinmux = ,
+   /* I2C3_SDA */
+;
+   /* I2C3_SCL */
+   bias-disable;
+   drive-open-drain;
+   slew-rate = <3>;
+   };
+   };
+
dcmi_pins: dcmi-0 {
pins {
pinmux = , 
/* DCMI_HSYNC */
-- 
2.7.4



[PATCH 4/4] i2c: stm32f4: Fix stmpe811 get xyz data timeout issue

2020-05-07 Thread dillon . minfei
From: dillon min 

As stm32f429's internal flash is 2Mbytes and compiled kernel
image bigger than 2Mbytes, so we have to load kernel image
to sdram on stm32f429-disco board which has 8Mbytes sdram space.

based on above context, as you knows kernel running on external
sdram is more slower than internal flash. besides, we need read 4
bytes to get touch screen xyz(x, y, pressure) coordinate data in
stmpe811 interrupt.

so, in stm32f4_i2c_handle_rx_done, as i2c read slower than running
in xip mode, have to adjust 'STOP/START bit set time' from last two
bytes to last one bytes. else, will get i2c timeout in reading
touch screen coordinate.

Signed-off-by: dillon min 
---
 drivers/i2c/busses/i2c-stm32f4.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-stm32f4.c b/drivers/i2c/busses/i2c-stm32f4.c
index d6a69df..83004f2 100644
--- a/drivers/i2c/busses/i2c-stm32f4.c
+++ b/drivers/i2c/busses/i2c-stm32f4.c
@@ -439,7 +439,7 @@ static void stm32f4_i2c_handle_rx_done(struct 
stm32f4_i2c_dev *i2c_dev)
int i;
 
switch (msg->count) {
-   case 2:
+   case 1:
/*
 * In order to correctly send the Stop or Repeated Start
 * condition on the I2C bus, the STOP/START bit has to be set
@@ -454,7 +454,7 @@ static void stm32f4_i2c_handle_rx_done(struct 
stm32f4_i2c_dev *i2c_dev)
else
stm32f4_i2c_set_bits(reg, STM32F4_I2C_CR1_START);
 
-   for (i = 2; i > 0; i--)
+   for (i = 1; i > 0; i--)
stm32f4_i2c_read_msg(i2c_dev);
 
reg = i2c_dev->base + STM32F4_I2C_CR2;
@@ -463,7 +463,7 @@ static void stm32f4_i2c_handle_rx_done(struct 
stm32f4_i2c_dev *i2c_dev)
 
complete(&i2c_dev->complete);
break;
-   case 3:
+   case 2:
/*
 * In order to correctly generate the NACK pulse after the last
 * received data byte, we have to enable NACK before reading N-2
-- 
2.7.4



[PATCH 3/4] ARM: dts: stm32: enable stmpe811 on stm32429-disco board

2020-05-07 Thread dillon . minfei
From: dillon min 

Enable the stmpe811 touch screen on stm32429-disco board.

Signed-off-by: dillon min 
---
 arch/arm/boot/dts/stm32f429-disco.dts | 50 +++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f429-disco.dts 
b/arch/arm/boot/dts/stm32f429-disco.dts
index 30c0f67..f9f21c8 100644
--- a/arch/arm/boot/dts/stm32f429-disco.dts
+++ b/arch/arm/boot/dts/stm32f429-disco.dts
@@ -49,6 +49,8 @@
 #include "stm32f429.dtsi"
 #include "stm32f429-pinctrl.dtsi"
 #include 
+#include 
+#include 
 
 / {
model = "STMicroelectronics STM32F429i-DISCO board";
@@ -127,3 +129,51 @@
pinctrl-names = "default";
status = "okay";
 };
+
+&i2c3 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c3_pins>;
+   clock-frequency = <10>;
+   status = "okay";
+
+   stmpe811@41 {
+   compatible = "st,stmpe811";
+   reg = <0x41>;
+   interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
+   interrupt-parent = <&gpioa>;
+   id = <0>;
+   blocks = <0x5>;
+   irq-trigger = <0x1>;
+   /* 3.25 MHz ADC clock speed */
+   st,adc-freq = <1>;
+   /* 12-bit ADC */
+   st,mod-12b = <1>;
+   /* internal ADC reference */
+   st,ref-sel = <0>;
+   /* ADC converstion time: 80 clocks */
+   st,sample-time = <4>;
+
+   stmpe_touchscreen {
+   compatible = "st,stmpe-ts";
+   /* 8 sample average control */
+   st,ave-ctrl = <3>;
+   /* 7 length fractional part in z */
+   st,fraction-z = <7>;
+   /*
+* 50 mA typical 80 mA max touchscreen drivers
+* current limit value
+*/
+   st,i-drive = <1>;
+   /* 1 ms panel driver settling time */
+   st,settling = <3>;
+   /* 5 ms touch detect interrupt delay */
+   st,touch-det-delay = <5>;
+   };
+
+   stmpe_adc {
+   compatible = "st,stmpe-adc";
+   /* forbid to use ADC channels 3-0 (touch) */
+   st,norequest-mask = <0x0F>;
+   };
+   };
+};
-- 
2.7.4



[PATCH] tracing: Remove unused event variable in tracing_iter_reset

2020-05-07 Thread Muchun Song
We do not use the event variable, just remove it.

Signed-off-by: Muchun Song 
---
 kernel/trace/trace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8d2b988126250..6be74d2a7056f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3566,7 +3566,6 @@ static void *s_next(struct seq_file *m, void *v, loff_t 
*pos)
 
 void tracing_iter_reset(struct trace_iterator *iter, int cpu)
 {
-   struct ring_buffer_event *event;
struct ring_buffer_iter *buf_iter;
unsigned long entries = 0;
u64 ts;
@@ -3584,7 +3583,7 @@ void tracing_iter_reset(struct trace_iterator *iter, int 
cpu)
 * that a reset never took place on a cpu. This is evident
 * by the timestamp being before the start of the buffer.
 */
-   while ((event = ring_buffer_iter_peek(buf_iter, &ts))) {
+   while (ring_buffer_iter_peek(buf_iter, &ts)) {
if (ts >= iter->array_buffer->time_start)
break;
entries++;
-- 
2.11.0



Re: [RFC 1/2] PCI/IOV: Introduce pci_iov_sysfs_link() function

2020-05-07 Thread Niklas Schnelle
On 5/6/20 11:10 PM, Bjorn Helgaas wrote:
> On Wed, May 06, 2020 at 05:41:38PM +0200, Niklas Schnelle wrote:
>> currently pci_iov_add_virtfn() scans the SR-IOV bars, adds the VF to the
>> bus and also creates the sysfs links between the newly added VF and its
>> parent PF.
> 
> s/currently/Currently/
> s/bars/BARs/
> 
>> With pdev->no_vf_scan fencing off the entire pci_iov_add_virtfn() call
>> s390 as the sole pdev->no_vf_scan user thus ends up missing these sysfs
>> links which are required for example by QEMU/libvirt.
>> Instead of duplicating the code introduce a new pci_iov_sysfs_link()
>> function for establishing sysfs links.
> 
> This looks like two paragraphs missing the blank line between.
> 
> This whole thing is not "introducing" any new functionality; it's
> "refactoring" to move existing functionality around and make it
> callable separately.
You're right I'll keep it in the subject for easier reference
if that's okay with you.
> 
>> Signed-off-by: Niklas Schnelle 
> 
> With the fixes above and a few below:
> 
> Acked-by: Bjorn Helgaas 
Thank you for the very quick and useful feedback.
I've incorporated the changes and will resend with the PATCH prefix.
If/when accepted what tree should the first patch go to?

And yes I plan to let the second patch go via the s390 tree.
> 
>> ---
>>  drivers/pci/iov.c   | 36 
>>  include/linux/pci.h |  8 
>>  2 files changed, 32 insertions(+), 12 deletions(-)
>>
... snip ...


Re: [PATCH] media: usb: ttusb-dec: avoid buffer overflow in ttusb_dec_handle_irq() when DMA failures/attacks occur

2020-05-07 Thread Greg KH
On Thu, May 07, 2020 at 01:15:22PM +0800, Jia-Ju Bai wrote:
> 
> 
> On 2020/5/7 1:43, Greg KH wrote:
> > On Thu, May 07, 2020 at 12:48:47AM +0800, Jia-Ju Bai wrote:
> > > Yes, I agree that this issue is not new, because DMA attacks are old
> > > problems.
> > > But I am a little surprised that many current drivers are still vulnerable
> > > to DMA attacks.
> > Given that the attack vector is very hard to actually do, that's not
> > a suprise.
> > 
> > It's only a very recent thing that Linux drivers have started to work on
> > "we don't trust the data coming from the hardware" path.  Previously we
> > always trusted that, but did not trust data coming from userspace.  So
> > work on fixing up drivers in this area is always encouraged.
> > 
> > An example of this would be all of the fuzzing that USB drivers have
> > been getting with custom loop-back interfaces and the like over the past
> > year or so.  Expanding that to "we don't trust PCI device data" should
> > be the next step on this, and would help out your area as well.
> 
> Okay, I am glad to hear that :)
> Hardware security for the Linux kernel should receive more attention.

If you care about that, yes it should.  At the least it is providing
lots of graduate students with good research papers :)

> Last year some researchers finished an interesting work about fuzzing the
> inputs from hardware:
> https://github.com/securesystemslab/periscope

Nice!

> > > > If you trust a device enough to plug it in, well, you need to trust it
> > > > :)
> > > Well, maybe I need to trust all devices in my computer :)
> > > 
> > > Anyway, thanks a lot for your patient explanation and reply.
> > > If you have encountered other kinds of DMA-related bugs/vulnerabilities,
> > > maybe I can help to detect them using my static-analysis tool :)
> > Did you only find a problem in this one driver?  Have you run it on any
> > more "complex" drivers and gotten any good results showing either that
> > we are programming defensively in this area, or not?
> > 
> 
> At present, I only detect the cases that a DMA value *directly* taints array
> index, loop condition and important kernel-interface calls (such as
> request_irq()).
> In this one driver, I only find two problems that mentioned in this patch.
> With the kernel configuration "allyesconfig" in my x86_64 machine, I find
> nearly 200 such problems (intra-procedurally and inter-procedurally) in all
> the compiled device drivers.
> 
> I also find that several drivers check the data from DMA memory, but some of
> these checks can be bypassed.
> Here is an example in drivers/scsi/esas2r/esas2r_vda.c:
> 
> The function esas2r_read_vda() uses a DMA value "vi":
>   struct atto_ioctl_vda *vi =
>             (struct atto_ioctl_vda *)a->vda_buffer;
> 
> Then esas2r_read_vda() calls esas2r_process_vda_ioctl() with vi:
>   esas2r_process_vda_ioctl(a, vi, rq, &sgc);
> 
> In esas2r_process_vda_ioctl(), the DMA value "vi->function" is
> used at many places, such as:
>   if (vi->function >= vercnt)
>   ...
>   if (vi->version > esas2r_vdaioctl_versions[vi->function])
>   ...
> 
> However, when DMA failures or attacks occur, the value of vi->function can
> be changed at any time. In this case, vi->function can be first smaller than
> vercnt, and then it can be larger than vercnt when it is used as the array
> index of esas2r_vdaioctl_versions, causing a buffer-overflow vulnerability.
> 
> I also submitted this patch, but no one has replied yet:
> https://lore.kernel.org/lkml/20200504172412.25985-1-baijiaju1...@gmail.com/

It's only been a few days, give them time.

But, as with this patch, you might want to change your approach.  Having
the changelog say "this is a security problem!" really isn't that "real"
as the threat model is very obscure at this point in time.

Just say something like I referenced here, "read the value from memory
and test it and use that value instead of constantly reading from memory
each time in case it changes" is nicer and more realistic.  It's a
poential optimization as well, if the complier didn't already do it for
us automatically (which you really should look into...)

If you make up a large series of these, I'd be glad to take them through
one of my trees to try to fix them all up at once, that's usually a
simpler way to do cross-tree changes like this.

thanks,

greg k-h


ping; [PATCH v4] mtd: clear cache_state to avoid writing to bad blocks repeatedly

2020-05-07 Thread Xiaoming Ni

ping

On 2020/3/31 9:31, Xiaoming Ni wrote:

The function call process is as follows:
mtd_blktrans_work()
  while (1)
do_blktrans_request()
  mtdblock_writesect()
do_cached_write()
  write_cached_data() /*if cache_state is STATE_DIRTY*/
erase_write()

write_cached_data() returns failure without modifying cache_state
and cache_offset. So when do_cached_write() is called again,
write_cached_data() will be called again to perform erase_write()
on the same cache_offset.

But if this cache_offset points to a bad block, erase_write() will
always return -EIO. Writing to this mtdblk is equivalent to losing
the current data, and repeatedly writing to the bad block.

Repeatedly writing a bad block has no real benefits,
but brings some negative effects:
1 Lost subsequent data
2 Loss of flash device life
3 erase_write() bad blocks are very time-consuming. For example:
the function do_erase_oneblock() in chips/cfi_cmdset_0020.c or
chips/cfi_cmdset_0002.c may take more than 20 seconds to return

Therefore, when erase_write() returns -EIO in write_cached_data(),
clear cache_state to avoid writing to bad blocks repeatedly.

Signed-off-by: Xiaoming Ni 
Reviewed-by: Miquel Raynal 
---
  drivers/mtd/mtdblock.c | 11 +++
  1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 078e0f6..32e52d8 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -89,8 +89,6 @@ static int write_cached_data (struct mtdblk_dev *mtdblk)
  
  	ret = erase_write (mtd, mtdblk->cache_offset,

   mtdblk->cache_size, mtdblk->cache_data);
-   if (ret)
-   return ret;
  
  	/*

 * Here we could arguably set the cache state to STATE_CLEAN.
@@ -98,9 +96,14 @@ static int write_cached_data (struct mtdblk_dev *mtdblk)
 * be notified if this content is altered on the flash by other
 * means.  Let's declare it empty and leave buffering tasks to
 * the buffer cache instead.
+*
+* If this cache_offset points to a bad block, data cannot be
+* written to the device. Clear cache_state to avoid writing to
+* bad blocks repeatedly.
 */
-   mtdblk->cache_state = STATE_EMPTY;
-   return 0;
+   if (ret == 0 || ret == -EIO)
+   mtdblk->cache_state = STATE_EMPTY;
+   return ret;
  }
  
  






RE: [RFC][PATCH 1/3] evm: Move hooks outside LSM infrastructure

2020-05-07 Thread Roberto Sassu
> -Original Message-
> From: Mimi Zohar [mailto:zo...@linux.ibm.com]
> Sent: Wednesday, May 6, 2020 11:10 PM
> To: Roberto Sassu ; david.saff...@gmail.com;
> v...@zeniv.linux.org.uk; jmor...@namei.org; John Johansen
> 
> Cc: linux-fsde...@vger.kernel.org; linux-integr...@vger.kernel.org; linux-
> security-mod...@vger.kernel.org; linux-kernel@vger.kernel.org; Silviu
> Vlasceanu 
> Subject: Re: [RFC][PATCH 1/3] evm: Move hooks outside LSM infrastructure
> 
> On Wed, 2020-05-06 at 15:44 -0400, Mimi Zohar wrote:
> > Since copying the EVM HMAC or original signature isn't applicable, I
> > would prefer exploring an EVM portable and immutable signature only
> > solution.
> 
> To prevent copying the EVM xattr, we added "security.evm" to
> /etc/xattr.conf.  To support copying just the EVM portable and
> immutable signatures will require a different solution.

This patch set removes the need for ignoring security.evm. It can be always
copied, even if it is an HMAC. EVM will update it only when verification in
the pre hook is successful. Combined with the ability of protecting a subset
of files without introducing an EVM policy, these advantages seem to
outweigh the effort necessary to make the switch.

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Li Jian, Shi Yanli


[PATCH v3] dt-bindings: irqchip: renesas-intc-irqpin: Convert to json-schema

2020-05-07 Thread Geert Uytterhoeven
From: Yoshihiro Kaneko 

Convert the Renesas Interrupt Controller (INTC) for external pins Device
Tree binding documentation to json-schema.

Signed-off-by: Yoshihiro Kaneko 
Co-developed-by: Geert Uytterhoeven 
Signed-off-by: Geert Uytterhoeven 
---
v3:
  - Take over from Kaneko-san,
  - Update license,
  - Fix title,
  - Remove standard descriptions,
  - reg: fix minItems, add descriptions,
  - interrupts: fix {min,max}Items,
  - sense-bitfield-width: add enum and default, use description,
  - control-parent: use description,
  - Make clocks and power-domains required on SH/R-Mobile,
  - Group interrupts in example,

v2:
  - Correct Geert-san's E-mail address,
  - Delete Guennadi-san from the maintainer of this binding,
  - Give 'sense-bitfield-width' the uint32 type,
  - Describe 'control-parent' property as a boolean.
---
 .../renesas,intc-irqpin.txt   |  62 --
 .../renesas,intc-irqpin.yaml  | 108 ++
 2 files changed, 108 insertions(+), 62 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.yaml

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
 
b/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
deleted file mode 100644
index 772c550d3b4bcfe2..
--- 
a/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-DT bindings for the R-/SH-Mobile irqpin controller
-
-Required properties:
-
-- compatible: has to be "renesas,intc-irqpin-", "renesas,intc-irqpin"
-  as fallback.
-  Examples with soctypes are:
-- "renesas,intc-irqpin-r8a7740" (R-Mobile A1)
-- "renesas,intc-irqpin-r8a7778" (R-Car M1A)
-- "renesas,intc-irqpin-r8a7779" (R-Car H1)
-- "renesas,intc-irqpin-sh73a0" (SH-Mobile AG5)
-
-- reg: Base address and length of each register bank used by the external
-  IRQ pins driven by the interrupt controller hardware module. The base
-  addresses, length and number of required register banks varies with soctype.
-- interrupt-controller: Identifies the node as an interrupt controller.
-- #interrupt-cells: has to be <2>: an interrupt index and flags, as defined in
-  interrupts.txt in this directory.
-- interrupts: Must contain a list of interrupt specifiers. For each interrupt
-  provided by this irqpin controller instance, there must be one entry,
-  referring to the corresponding parent interrupt.
-
-Optional properties:
-
-- any properties, listed in interrupts.txt, and any standard resource 
allocation
-  properties
-- sense-bitfield-width: width of a single sense bitfield in the SENSE register,
-  if different from the default 4 bits
-- control-parent: disable and enable interrupts on the parent interrupt
-  controller, needed for some broken implementations
-- clocks: Must contain a reference to the functional clock.  This property is
-  mandatory if the hardware implements a controllable functional clock for
-  the irqpin controller instance.
-- power-domains: Must contain a reference to the power domain. This property is
-  mandatory if the irqpin controller instance is part of a controllable power
-  domain.
-
-
-Example

-
-   irqpin1: interrupt-controller@e694 {
-   compatible = "renesas,intc-irqpin-r8a7740",
-"renesas,intc-irqpin";
-   #interrupt-cells = <2>;
-   interrupt-controller;
-   reg = <0xe694 4>,
-   <0xe6900014 4>,
-   <0xe6900024 1>,
-   <0xe6900044 1>,
-   <0xe6900064 1>;
-   interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH
- 0 149 IRQ_TYPE_LEVEL_HIGH
- 0 149 IRQ_TYPE_LEVEL_HIGH
- 0 149 IRQ_TYPE_LEVEL_HIGH
- 0 149 IRQ_TYPE_LEVEL_HIGH
- 0 149 IRQ_TYPE_LEVEL_HIGH
- 0 149 IRQ_TYPE_LEVEL_HIGH
- 0 149 IRQ_TYPE_LEVEL_HIGH>;
-   clocks = <&mstp2_clks R8A7740_CLK_INTCA>;
-   power-domains = <&pd_a4s>;
-   };
diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.yaml
 
b/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.yaml
new file mode 100644
index ..800243d3ee8ef42f
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.yaml
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 
http://devicetree.org/schemas/interrupt-controller/renesas,intc-irqpin.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas Interrupt Controller (INTC) for external pin

[PATCH v2 10/10] md: use PAGE_SECTORS to clean up code

2020-05-07 Thread Zhen Lei
Execute the following shell script:

C_FILES=`find drivers/md/ -name "*.c"`

for file in $C_FILES
do
#with brace
sed -i 's/(PAGE_SIZE \/ 512)/PAGE_SECTORS/g' $file
sed -i 's/(PAGE_SIZE\/512)/PAGE_SECTORS/g' $file
sed -i 's/(PAGE_SIZE >> 9)/PAGE_SECTORS/g' $file
sed -i 's/(PAGE_SIZE>>9)/PAGE_SECTORS/g' $file

#without brace
sed -i 's/PAGE_SIZE \/ 512/PAGE_SECTORS/g' $file
sed -i 's/PAGE_SIZE\/512/PAGE_SECTORS/g' $file
sed -i 's/PAGE_SIZE >> 9/PAGE_SECTORS/g' $file
sed -i 's/PAGE_SIZE>>9/PAGE_SECTORS/g' $file
done

In addition, eliminate below scripts/checkpatch.pl warning:
#44: FILE: drivers/md/dm-kcopyd.c:587:
+   unsigned nr_pages = dm_div_up(job->dests[0].count, PAGE_SECTORS);

Change to "unsigned int nr_pages".

Signed-off-by: Zhen Lei 
---
 drivers/md/dm-kcopyd.c |  2 +-
 drivers/md/md-bitmap.c | 16 
 drivers/md/md.c|  6 +++---
 drivers/md/raid1.c | 10 +-
 drivers/md/raid10.c| 20 ++--
 drivers/md/raid5.c |  4 ++--
 6 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c
index 1bbe4a34ef4c..ad861a3d648e 100644
--- a/drivers/md/dm-kcopyd.c
+++ b/drivers/md/dm-kcopyd.c
@@ -584,7 +584,7 @@ static int run_io_job(struct kcopyd_job *job)
 static int run_pages_job(struct kcopyd_job *job)
 {
int r;
-   unsigned nr_pages = dm_div_up(job->dests[0].count, PAGE_SIZE >> 9);
+   unsigned int nr_pages = dm_div_up(job->dests[0].count, PAGE_SECTORS);
 
r = kcopyd_get_pages(job->kc, nr_pages, &job->pages);
if (!r) {
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index b952bd45bd6a..12ccf1c81661 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -161,7 +161,7 @@ static int read_sb_page(struct mddev *mddev, loff_t offset,
|| test_bit(Bitmap_sync, &rdev->flags))
continue;
 
-   target = offset + index * (PAGE_SIZE/512);
+   target = offset + index * PAGE_SECTORS;
 
if (sync_page_io(rdev, target,
 roundup(size, 
bdev_logical_block_size(rdev->bdev)),
@@ -237,17 +237,17 @@ static int write_sb_page(struct bitmap *bitmap, struct 
page *page, int wait)
if (mddev->external) {
/* Bitmap could be anywhere. */
if (rdev->sb_start + offset + (page->index
-  * (PAGE_SIZE/512))
+  * PAGE_SECTORS)
> rdev->data_offset
&&
rdev->sb_start + offset
< (rdev->data_offset + mddev->dev_sectors
-+ (PAGE_SIZE/512)))
++ PAGE_SECTORS))
goto bad_alignment;
} else if (offset < 0) {
/* DATA  BITMAP METADATA  */
if (offset
-   + (long)(page->index * (PAGE_SIZE/512))
+   + (long)(page->index * PAGE_SECTORS)
+ size/512 > 0)
/* bitmap runs in to metadata */
goto bad_alignment;
@@ -259,7 +259,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page 
*page, int wait)
/* METADATA BITMAP DATA */
if (rdev->sb_start
+ offset
-   + page->index*(PAGE_SIZE/512) + size/512
+   + page->index*PAGE_SECTORS + size/512
> rdev->data_offset)
/* bitmap runs in to data */
goto bad_alignment;
@@ -268,7 +268,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page 
*page, int wait)
}
md_super_write(mddev, rdev,
   rdev->sb_start + offset
-  + page->index * (PAGE_SIZE/512),
+  + page->index * PAGE_SECTORS,
   size,
   page);
}
@@ -1548,14 +1548,14 @@ int md_bitmap_start_sync(struct bitmap *bitmap, 
sector_t offset, sector_t *block
 * pages, otherwise resync (which is very PAGE_SIZE based) will
 * get confused.
 * So call __bitmap_start_sync repeatedly (if needed) until
-* At least PAGE_SIZE>>9 blocks are covered.
+* At least PAGE_SECTORS blocks are covered.
 * Return the 'or' of the result.
 */
int rv = 0;
sector_t blocks1;
 
*blocks = 0;
-   while (*blocks < (PAGE_SIZE>>9)) {
+   while (*blocks < PAGE_SECTORS) {
rv |= __bitmap_start_sync(b

[PATCH v2 09/10] md: use existing definition RESYNC_SECTORS

2020-05-07 Thread Zhen Lei
"RESYNC_BLOCK_SIZE/512" is equal to "RESYNC_BLOCK_SIZE >> 9", replace it
with RESYNC_SECTORS.

Signed-off-by: Zhen Lei 
---
 drivers/md/raid10.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 948afe720fca..ac4273f804e8 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4483,8 +4483,8 @@ static sector_t reshape_request(struct mddev *mddev, 
sector_t sector_nr,
last = conf->reshape_progress - 1;
sector_nr = last & ~(sector_t)(conf->geo.chunk_mask
   & conf->prev.chunk_mask);
-   if (sector_nr + RESYNC_BLOCK_SIZE/512 < last)
-   sector_nr = last + 1 - RESYNC_BLOCK_SIZE/512;
+   if (sector_nr + RESYNC_SECTORS < last)
+   sector_nr = last + 1 - RESYNC_SECTORS;
} else {
/* 'next' is after the last device address that we
 * might write to for this chunk in the new layout
@@ -4506,8 +4506,8 @@ static sector_t reshape_request(struct mddev *mddev, 
sector_t sector_nr,
last  = sector_nr | (conf->geo.chunk_mask
 & conf->prev.chunk_mask);
 
-   if (sector_nr + RESYNC_BLOCK_SIZE/512 <= last)
-   last = sector_nr + RESYNC_BLOCK_SIZE/512 - 1;
+   if (sector_nr + RESYNC_SECTORS <= last)
+   last = sector_nr + RESYNC_SECTORS - 1;
}
 
if (need_flush ||
-- 
2.26.0.106.g9fadedd




[PATCH v2 02/10] zram: abolish macro SECTORS_PER_PAGE

2020-05-07 Thread Zhen Lei
SECTORS_PER_PAGE is equivalent to PAGE_SECTORS.

Although I prefer SECTORS_PER_PAGE better than PAGE_SECTORS, the former
is more clearer, I think. But the latter was defined in
 before, rename it may impact users.

Signed-off-by: Zhen Lei 
---
 drivers/block/zram/zram_drv.c | 4 ++--
 drivers/block/zram/zram_drv.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index ebb234f36909..e2fbf7a847e7 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1551,7 +1551,7 @@ static void __zram_make_request(struct zram *zram, struct 
bio *bio)
 
index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
offset = (bio->bi_iter.bi_sector &
- (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT;
+ (PAGE_SECTORS - 1)) << SECTOR_SHIFT;
 
switch (bio_op(bio)) {
case REQ_OP_DISCARD:
@@ -1645,7 +1645,7 @@ static int zram_rw_page(struct block_device *bdev, 
sector_t sector,
}
 
index = sector >> SECTORS_PER_PAGE_SHIFT;
-   offset = (sector & (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT;
+   offset = (sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT;
 
bv.bv_page = page;
bv.bv_len = PAGE_SIZE;
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index f2fd46daa760..10fdf413dd6e 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -22,7 +22,6 @@
 #include "zcomp.h"
 
 #define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
-#define SECTORS_PER_PAGE   (1 << SECTORS_PER_PAGE_SHIFT)
 #define ZRAM_LOGICAL_BLOCK_SHIFT 12
 #define ZRAM_LOGICAL_BLOCK_SIZE(1 << ZRAM_LOGICAL_BLOCK_SHIFT)
 #define ZRAM_SECTOR_PER_LOGICAL_BLOCK  \
-- 
2.26.0.106.g9fadedd




[PATCH v2 08/10] md: use sectors_to_npage() and npage_to_sectors() to clean up code

2020-05-07 Thread Zhen Lei
1. Replace ">> (PAGE_SHIFT - 9)" with sectors_to_npage()
2. Replace "<< (PAGE_SHIFT - 9)" with npage_to_sectors()

Suggested-by: Matthew Wilcox 
Signed-off-by: Zhen Lei 
---
 drivers/md/dm-table.c|  2 +-
 drivers/md/raid1.c   |  2 +-
 drivers/md/raid10.c  |  2 +-
 drivers/md/raid5-cache.c | 11 +--
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 0a2cc197f62b..e1f176bda528 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1964,7 +1964,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct 
request_queue *q,
 #endif
 
/* Allow reads to exceed readahead limits */
-   q->backing_dev_info->io_pages = limits->max_sectors >> (PAGE_SHIFT - 9);
+   q->backing_dev_info->io_pages = sectors_to_npage(limits->max_sectors);
 }
 
 unsigned int dm_table_get_num_targets(struct dm_table *t)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index cd810e195086..44ffe1b6d77a 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2129,7 +2129,7 @@ static void process_checks(struct r1bio *r1_bio)
int vcnt;
 
/* Fix variable parts of all bios */
-   vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
+   vcnt = sectors_to_npage(r1_bio->sectors + PAGE_SIZE / 512 - 1);
for (i = 0; i < conf->raid_disks * 2; i++) {
blk_status_t status;
struct bio *b = r1_bio->bios[i];
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index ec136e44aef7..948afe720fca 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2029,7 +2029,7 @@ static void sync_request_write(struct mddev *mddev, 
struct r10bio *r10_bio)
fbio->bi_iter.bi_idx = 0;
fpages = get_resync_pages(fbio)->pages;
 
-   vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9);
+   vcnt = sectors_to_npage(r10_bio->sectors + (PAGE_SIZE >> 9) - 1);
/* now find blocks with errors */
for (i=0 ; i < conf->copies ; i++) {
int  j, d;
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 9b6da759dca2..0b9cd810466a 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -832,8 +832,7 @@ static void r5l_append_payload_meta(struct r5l_log *log, 
u16 type,
payload = page_address(io->meta_page) + io->meta_offset;
payload->header.type = cpu_to_le16(type);
payload->header.flags = cpu_to_le16(0);
-   payload->size = cpu_to_le32((1 + !!checksum2_valid) <<
-   (PAGE_SHIFT - 9));
+   payload->size = cpu_to_le32(npage_to_sectors(1 + !!checksum2_valid));
payload->location = cpu_to_le64(location);
payload->checksum[0] = cpu_to_le32(checksum1);
if (checksum2_valid)
@@ -1042,7 +1041,7 @@ int r5l_write_stripe(struct r5l_log *log, struct 
stripe_head *sh)
 
mutex_lock(&log->io_mutex);
/* meta + data */
-   reserve = (1 + write_disks) << (PAGE_SHIFT - 9);
+   reserve = npage_to_sectors(1 + write_disks);
 
if (log->r5c_journal_mode == R5C_JOURNAL_MODE_WRITE_THROUGH) {
if (!r5l_has_free_space(log, reserve)) {
@@ -2053,7 +2052,7 @@ r5l_recovery_verify_data_checksum_for_mb(struct r5l_log 
*log,
  le32_to_cpu(payload->size));
mb_offset += sizeof(struct r5l_payload_data_parity) +
sizeof(__le32) *
-   (le32_to_cpu(payload->size) >> (PAGE_SHIFT - 
9));
+   sectors_to_npage(le32_to_cpu(payload->size));
}
 
}
@@ -2199,7 +2198,7 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log,
 
mb_offset += sizeof(struct r5l_payload_data_parity) +
sizeof(__le32) *
-   (le32_to_cpu(payload->size) >> (PAGE_SHIFT - 9));
+   sectors_to_npage(le32_to_cpu(payload->size));
}
 
return 0;
@@ -2916,7 +2915,7 @@ int r5c_cache_data(struct r5l_log *log, struct 
stripe_head *sh)
 
mutex_lock(&log->io_mutex);
/* meta + data */
-   reserve = (1 + pages) << (PAGE_SHIFT - 9);
+   reserve = npage_to_sectors(1 + pages);
 
if (test_bit(R5C_LOG_CRITICAL, &conf->cache_state) &&
sh->log_start == MaxSector)
-- 
2.26.0.106.g9fadedd




[PATCH v2 06/10] mm/swap: use npage_to_sectors() and PAGE_SECTORS to clean up code

2020-05-07 Thread Zhen Lei
1. Replace "<<= (PAGE_SHIFT - 9)" with "*= PAGE_SECTORS"
2. Replace "<< (PAGE_SHIFT - 9)" with npage_to_sectors()

Suggested-by: Matthew Wilcox 
Signed-off-by: Zhen Lei 
---
 mm/page_io.c  |  4 ++--
 mm/swapfile.c | 12 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 76965be1d40e..23291a49ab91 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -38,7 +38,7 @@ static struct bio *get_swap_bio(gfp_t gfp_flags,
 
bio->bi_iter.bi_sector = map_swap_page(page, &bdev);
bio_set_dev(bio, bdev);
-   bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9;
+   bio->bi_iter.bi_sector *= PAGE_SECTORS;
bio->bi_end_io = end_io;
 
bio_add_page(bio, page, PAGE_SIZE * hpage_nr_pages(page), 0);
@@ -266,7 +266,7 @@ int swap_writepage(struct page *page, struct 
writeback_control *wbc)
 
 static sector_t swap_page_sector(struct page *page)
 {
-   return (sector_t)__page_file_index(page) << (PAGE_SHIFT - 9);
+   return npage_to_sectors((sector_t)__page_file_index(page));
 }
 
 static inline void count_swpout_vm_event(struct page *page)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 5871a2aa86a5..c8be92f972a4 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -177,8 +177,8 @@ static int discard_swap(struct swap_info_struct *si)
 
/* Do not discard the swap header page! */
se = first_se(si);
-   start_block = (se->start_block + 1) << (PAGE_SHIFT - 9);
-   nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9);
+   start_block = npage_to_sectors(se->start_block + 1);
+   nr_blocks = npage_to_sectors((sector_t)se->nr_pages - 1);
if (nr_blocks) {
err = blkdev_issue_discard(si->bdev, start_block,
nr_blocks, GFP_KERNEL, 0);
@@ -188,8 +188,8 @@ static int discard_swap(struct swap_info_struct *si)
}
 
for (se = next_se(se); se; se = next_se(se)) {
-   start_block = se->start_block << (PAGE_SHIFT - 9);
-   nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9);
+   start_block = npage_to_sectors(se->start_block);
+   nr_blocks = npage_to_sectors((sector_t)se->nr_pages);
 
err = blkdev_issue_discard(si->bdev, start_block,
nr_blocks, GFP_KERNEL, 0);
@@ -240,8 +240,8 @@ static void discard_swap_cluster(struct swap_info_struct 
*si,
start_page += nr_blocks;
nr_pages -= nr_blocks;
 
-   start_block <<= PAGE_SHIFT - 9;
-   nr_blocks <<= PAGE_SHIFT - 9;
+   start_block *= PAGE_SECTORS;
+   nr_blocks *= PAGE_SECTORS;
if (blkdev_issue_discard(si->bdev, start_block,
nr_blocks, GFP_NOIO, 0))
break;
-- 
2.26.0.106.g9fadedd




[PATCH v2 01/10] block: move PAGE_SECTORS definition into

2020-05-07 Thread Zhen Lei
Too many duplicated PAGE_SECTORS definitions, eliminate it.

Signed-off-by: Zhen Lei 
---
 drivers/block/brd.c   | 1 -
 drivers/block/null_blk_main.c | 1 -
 drivers/md/bcache/util.h  | 2 --
 include/linux/blkdev.h| 5 +++--
 include/linux/device-mapper.h | 1 -
 5 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 2fb25c348d53..30df6daa9dbc 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -26,7 +26,6 @@
 #include 
 
 #define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
-#define PAGE_SECTORS   (1 << PAGE_SECTORS_SHIFT)
 
 /*
  * Each block ramdisk device has a radix_tree brd_pages of pages that stores
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 8efd8778e209..25048ff15858 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -12,7 +12,6 @@
 #include "null_blk.h"
 
 #define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
-#define PAGE_SECTORS   (1 << PAGE_SECTORS_SHIFT)
 #define SECTOR_MASK(PAGE_SECTORS - 1)
 
 #define FREE_BATCH 16
diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
index c029f7443190..55196e0f37c3 100644
--- a/drivers/md/bcache/util.h
+++ b/drivers/md/bcache/util.h
@@ -15,8 +15,6 @@
 
 #include "closure.h"
 
-#define PAGE_SECTORS   (PAGE_SIZE / 512)
-
 struct closure;
 
 #ifdef CONFIG_BCACHE_DEBUG
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 32868fbedc9e..934f31fc15cd 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -904,11 +904,12 @@ static inline struct request_queue *bdev_get_queue(struct 
block_device *bdev)
  * multiple of 512 bytes. Hence these two constants.
  */
 #ifndef SECTOR_SHIFT
-#define SECTOR_SHIFT 9
+#define SECTOR_SHIFT   9
 #endif
 #ifndef SECTOR_SIZE
-#define SECTOR_SIZE (1 << SECTOR_SHIFT)
+#define SECTOR_SIZE(1 << SECTOR_SHIFT)
 #endif
+#define PAGE_SECTORS   (PAGE_SIZE / SECTOR_SIZE)
 
 /*
  * blk_rq_pos(): the current sector
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index af48d9da3916..83e018ed8c21 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -143,7 +143,6 @@ typedef size_t (*dm_dax_copy_iter_fn)(struct dm_target *ti, 
pgoff_t pgoff,
void *addr, size_t bytes, struct iov_iter *i);
 typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff,
size_t nr_pages);
-#define PAGE_SECTORS (PAGE_SIZE / 512)
 
 void dm_error(const char *message);
 
-- 
2.26.0.106.g9fadedd




[PATCH v2 05/10] block: abolish macro PAGE_SECTORS_SHIFT

2020-05-07 Thread Zhen Lei
The name of PAGE_SECTORS_SHIFT is quite hard to read.
1. use sectors_to_npage() to replace ">> PAGE_SECTORS_SHIFT"
2. use npage_to_sectors() to replace "<< PAGE_SECTORS_SHIFT"

Suggested-by: Matthew Wilcox 
Signed-off-by: Zhen Lei 
---
 drivers/block/brd.c   | 6 ++
 drivers/block/null_blk_main.c | 9 -
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 30df6daa9dbc..051c5a50497f 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -25,8 +25,6 @@
 
 #include 
 
-#define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
-
 /*
  * Each block ramdisk device has a radix_tree brd_pages of pages that stores
  * the pages containing the block device's contents. A brd page's ->index is
@@ -69,7 +67,7 @@ static struct page *brd_lookup_page(struct brd_device *brd, 
sector_t sector)
 * here, only deletes).
 */
rcu_read_lock();
-   idx = sector >> PAGE_SECTORS_SHIFT; /* sector to page index */
+   idx = sectors_to_npage(sector);
page = radix_tree_lookup(&brd->brd_pages, idx);
rcu_read_unlock();
 
@@ -108,7 +106,7 @@ static struct page *brd_insert_page(struct brd_device *brd, 
sector_t sector)
}
 
spin_lock(&brd->brd_lock);
-   idx = sector >> PAGE_SECTORS_SHIFT;
+   idx = sectors_to_npage(sector);
page->index = idx;
if (radix_tree_insert(&brd->brd_pages, idx, page)) {
__free_page(page);
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 25048ff15858..81485f47dcf0 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -11,7 +11,6 @@
 #include 
 #include "null_blk.h"
 
-#define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
 #define SECTOR_MASK(PAGE_SECTORS - 1)
 
 #define FREE_BATCH 16
@@ -737,7 +736,7 @@ static void null_free_sector(struct nullb *nullb, sector_t 
sector,
struct radix_tree_root *root;
 
root = is_cache ? &nullb->dev->cache : &nullb->dev->data;
-   idx = sector >> PAGE_SECTORS_SHIFT;
+   idx = sectors_to_npage(sector);
sector_bit = (sector & SECTOR_MASK);
 
t_page = radix_tree_lookup(root, idx);
@@ -808,7 +807,7 @@ static struct nullb_page *__null_lookup_page(struct nullb 
*nullb,
struct nullb_page *t_page;
struct radix_tree_root *root;
 
-   idx = sector >> PAGE_SECTORS_SHIFT;
+   idx = sectors_to_npage(sector);
sector_bit = (sector & SECTOR_MASK);
 
root = is_cache ? &nullb->dev->cache : &nullb->dev->data;
@@ -855,7 +854,7 @@ static struct nullb_page *null_insert_page(struct nullb 
*nullb,
goto out_freepage;
 
spin_lock_irq(&nullb->lock);
-   idx = sector >> PAGE_SECTORS_SHIFT;
+   idx = sectors_to_npage(sector);
t_page->page->index = idx;
t_page = null_radix_tree_insert(nullb, idx, t_page, !ignore_cache);
radix_tree_preload_end();
@@ -878,7 +877,7 @@ static int null_flush_cache_page(struct nullb *nullb, 
struct nullb_page *c_page)
 
idx = c_page->page->index;
 
-   t_page = null_insert_page(nullb, idx << PAGE_SECTORS_SHIFT, true);
+   t_page = null_insert_page(nullb, npage_to_sectors(idx), true);
 
__clear_bit(NULLB_PAGE_LOCK, c_page->bitmap);
if (test_bit(NULLB_PAGE_FREE, c_page->bitmap)) {
-- 
2.26.0.106.g9fadedd




[PATCH v2 07/10] block: use sectors_to_npage() and PAGE_SECTORS to clean up code

2020-05-07 Thread Zhen Lei
1. Replace "1 << (PAGE_SHIFT - 9)" with PAGE_SECTORS
2. Replace ">> (PAGE_SHIFT - 9)" with sectors_to_npage()

Suggested-by: Matthew Wilcox 
Signed-off-by: Zhen Lei 
---
 block/blk-settings.c| 6 +++---
 block/partitions/core.c | 5 ++---
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 14397b4c4b53..171665ed8318 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -150,7 +150,7 @@ void blk_queue_max_hw_sectors(struct request_queue *q, 
unsigned int max_hw_secto
unsigned int max_sectors;
 
if ((max_hw_sectors << 9) < PAGE_SIZE) {
-   max_hw_sectors = 1 << (PAGE_SHIFT - 9);
+   max_hw_sectors = PAGE_SECTORS;
printk(KERN_INFO "%s: set to minimum %d\n",
   __func__, max_hw_sectors);
}
@@ -159,7 +159,7 @@ void blk_queue_max_hw_sectors(struct request_queue *q, 
unsigned int max_hw_secto
max_sectors = min_not_zero(max_hw_sectors, limits->max_dev_sectors);
max_sectors = min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS);
limits->max_sectors = max_sectors;
-   q->backing_dev_info->io_pages = max_sectors >> (PAGE_SHIFT - 9);
+   q->backing_dev_info->io_pages = sectors_to_npage(max_sectors);
 }
 EXPORT_SYMBOL(blk_queue_max_hw_sectors);
 
@@ -630,7 +630,7 @@ void disk_stack_limits(struct gendisk *disk, struct 
block_device *bdev,
}
 
t->backing_dev_info->io_pages =
-   t->limits.max_sectors >> (PAGE_SHIFT - 9);
+   sectors_to_npage(t->limits.max_sectors);
 }
 EXPORT_SYMBOL(disk_stack_limits);
 
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 9ef48a8cff86..4859739a2414 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -640,8 +640,7 @@ void *read_part_sector(struct parsed_partitions *state, 
sector_t n, Sector *p)
return NULL;
}
 
-   page = read_mapping_page(mapping,
-   (pgoff_t)(n >> (PAGE_SHIFT - 9)), NULL);
+   page = read_mapping_page(mapping, (pgoff_t)sectors_to_npage(n), NULL);
if (IS_ERR(page))
goto out;
if (PageError(page))
@@ -649,7 +648,7 @@ void *read_part_sector(struct parsed_partitions *state, 
sector_t n, Sector *p)
 
p->v = page;
return (unsigned char *)page_address(page) +
-   ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << SECTOR_SHIFT);
+   ((n & (PAGE_SECTORS - 1)) << SECTOR_SHIFT);
 out_put_page:
put_page(page);
 out:
-- 
2.26.0.106.g9fadedd




[PATCH v2 00/10] clean up SECTOR related macros and sectors/pages conversions

2020-05-07 Thread Zhen Lei
v1 --> v2:
As Matthew Wilcox's suggestion, add sectors_to_npage()/npage_to_sectors()
helpers to eliminate SECTORS_PER_PAGE_SHIFT, because it's quite hard to read.
In further, I also eliminated PAGE_SECTORS_SHIFT.

I tried to eliminate all magic number "9" and "512", but it's too many, maybe
no one want to review it, so I gave up. In the process of searching, I found
the existing macro PAGE_SECTORS, it's equivalent to SECTORS_PER_PAGE. Because
PAGE_SECTORS was defined in include/linux/device-mapper.h, and SECTORS_PER_PAGE
was defined in drivers/block/zram/zram_drv.h, so I discarded SECTORS_PER_PAGE,
althrough I prefer it so much.

v1:
When I studied the code of mm/swap, I found "1 << (PAGE_SHIFT - 9)" appears
many times. So I try to clean up it.

1. Replace "1 << (PAGE_SHIFT - 9)" or similar with SECTORS_PER_PAGE
2. Replace "PAGE_SHIFT - 9" with SECTORS_PER_PAGE_SHIFT
3. Replace "9" with SECTOR_SHIFT
4. Replace "512" with SECTOR_SIZE

Zhen Lei (10):
  block: move PAGE_SECTORS definition into 
  zram: abolish macro SECTORS_PER_PAGE
  block: add sectors_to_npage()/npage_to_sectors() helpers
  zram: abolish macro SECTORS_PER_PAGE_SHIFT
  block: abolish macro PAGE_SECTORS_SHIFT
  mm/swap: use npage_to_sectors() and PAGE_SECTORS to clean up code
  block: use sectors_to_npage() and PAGE_SECTORS to clean up code
  md: use sectors_to_npage() and npage_to_sectors() to clean up code
  md: use existing definition RESYNC_SECTORS
  md: use PAGE_SECTORS to clean up code

 block/blk-settings.c  |  6 +++---
 block/partitions/core.c   |  5 ++---
 drivers/block/brd.c   |  7 ++-
 drivers/block/null_blk_main.c | 10 --
 drivers/block/zram/zram_drv.c |  8 
 drivers/block/zram/zram_drv.h |  2 --
 drivers/md/bcache/util.h  |  2 --
 drivers/md/dm-kcopyd.c|  2 +-
 drivers/md/dm-table.c |  2 +-
 drivers/md/md-bitmap.c| 16 
 drivers/md/md.c   |  6 +++---
 drivers/md/raid1.c| 10 +-
 drivers/md/raid10.c   | 28 ++--
 drivers/md/raid5-cache.c  | 11 +--
 drivers/md/raid5.c|  4 ++--
 include/linux/blkdev.h|  7 +--
 include/linux/device-mapper.h |  1 -
 mm/page_io.c  |  4 ++--
 mm/swapfile.c | 12 ++--
 19 files changed, 67 insertions(+), 76 deletions(-)

-- 
2.26.0.106.g9fadedd




[PATCH v2 03/10] block: add sectors_to_npage()/npage_to_sectors() helpers

2020-05-07 Thread Zhen Lei
Provide the conversion of "number of sectors"/"sector number" and
"number of pages"/"page number".

Suggested-by: Matthew Wilcox 
Signed-off-by: Zhen Lei 
---
 include/linux/blkdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 934f31fc15cd..5d8daaffc38b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -910,6 +910,8 @@ static inline struct request_queue *bdev_get_queue(struct 
block_device *bdev)
 #define SECTOR_SIZE(1 << SECTOR_SHIFT)
 #endif
 #define PAGE_SECTORS   (PAGE_SIZE / SECTOR_SIZE)
+#define sectors_to_npage(nr)   ((nr) / PAGE_SECTORS)
+#define npage_to_sectors(nr)   ((nr) * PAGE_SECTORS)
 
 /*
  * blk_rq_pos(): the current sector
-- 
2.26.0.106.g9fadedd




[PATCH v2 04/10] zram: abolish macro SECTORS_PER_PAGE_SHIFT

2020-05-07 Thread Zhen Lei
The name of SECTORS_PER_PAGE_SHIFT is quite hard to read. So use
sectors_to_npage() to replace ">> SECTORS_PER_PAGE_SHIFT"

Suggested-by: Matthew Wilcox 
Signed-off-by: Zhen Lei 
---
 drivers/block/zram/zram_drv.c | 4 ++--
 drivers/block/zram/zram_drv.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index e2fbf7a847e7..918b77f9bce4 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1549,7 +1549,7 @@ static void __zram_make_request(struct zram *zram, struct 
bio *bio)
struct bio_vec bvec;
struct bvec_iter iter;
 
-   index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
+   index = sectors_to_npage(bio->bi_iter.bi_sector);
offset = (bio->bi_iter.bi_sector &
  (PAGE_SECTORS - 1)) << SECTOR_SHIFT;
 
@@ -1644,7 +1644,7 @@ static int zram_rw_page(struct block_device *bdev, 
sector_t sector,
goto out;
}
 
-   index = sector >> SECTORS_PER_PAGE_SHIFT;
+   index = sectors_to_npage(sector);
offset = (sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT;
 
bv.bv_page = page;
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 10fdf413dd6e..12309175d55e 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -21,7 +21,6 @@
 
 #include "zcomp.h"
 
-#define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
 #define ZRAM_LOGICAL_BLOCK_SHIFT 12
 #define ZRAM_LOGICAL_BLOCK_SIZE(1 << ZRAM_LOGICAL_BLOCK_SHIFT)
 #define ZRAM_SECTOR_PER_LOGICAL_BLOCK  \
-- 
2.26.0.106.g9fadedd




Re: [PATCH v2] KVM: x86/pmu: Support full width counting

2020-05-07 Thread Paolo Bonzini
On 07/05/20 04:14, Like Xu wrote:
> +static inline u64 vmx_get_perf_capabilities(void)
> +{
> + u64 perf_cap = 0;
> +
> + if (boot_cpu_has(X86_FEATURE_PDCM))
> + rdmsrl(MSR_IA32_PERF_CAPABILITIES, perf_cap);
> +
> + /* Currently, KVM only supports Full-Width Writes. */
> + perf_cap &= PMU_CAP_FW_WRITES;
> +
> + return perf_cap;
> +}
> +

Since counters are virtualized, it seems to me that you can support
PMU_CAP_FW_WRITES unconditionally, even if the host lacks it.  So just
return PMU_CAP_FW_WRITES from this function.

> + case MSR_IA32_PERF_CAPABILITIES:
> + return 1; /* RO MSR */
>   default:

You need to allow writes from the host if (data &
~vmx_get_perf_capabilities()) == 0.

> - if (!msr_info->host_initiated)
> + if ((pmc = get_gp_pmc(pmu, msr, MSR_IA32_PERFCTR0)) ||
> + (pmc = get_gp_pmc(pmu, msr, MSR_IA32_PMC0))) {
> + if (data & ~pmu->counter_bitmask[KVM_PMC_GP])
> + return 1;
> + if (!fw_writes_is_enabled(pmu))
>   data = (s64)(s32)data;


You are dropping the test on msr_info->host_initiated here, you should
keep it otherwise you allow full-width write to MSR_IA32_PERFCTR0 as
well.  So:

#define MSR_PMC_FULL_WIDTH_BIT  (MSR_IA32_PMC0 - MSR_IA32_PERFCTR0)

if (!msr_info->host_initiated && !(msr & MSR_PMC_FULL_WIDTH_BIT))
data = (s64)(s32)data;

> + case MSR_IA32_PERF_CAPABILITIES:
> + if (!nested)
> + return 1;
> + msr->data = vmx_get_perf_capabilities();
> + return 0;

The !nested check is wrong.

> 
> +++ b/arch/x86/kvm/x86.c
> @@ -1220,6 +1220,13 @@ static const u32 msrs_to_save_all[] = {
>   MSR_ARCH_PERFMON_EVENTSEL0 + 12, MSR_ARCH_PERFMON_EVENTSEL0 + 13,
>   MSR_ARCH_PERFMON_EVENTSEL0 + 14, MSR_ARCH_PERFMON_EVENTSEL0 + 15,
>   MSR_ARCH_PERFMON_EVENTSEL0 + 16, MSR_ARCH_PERFMON_EVENTSEL0 + 17,
> +
> + MSR_IA32_PMC0, MSR_IA32_PMC0 + 1, MSR_IA32_PMC0 + 2,
> + MSR_IA32_PMC0 + 3, MSR_IA32_PMC0 + 4, MSR_IA32_PMC0 + 5,
> + MSR_IA32_PMC0 + 6, MSR_IA32_PMC0 + 7, MSR_IA32_PMC0 + 8,
> + MSR_IA32_PMC0 + 9, MSR_IA32_PMC0 + 10, MSR_IA32_PMC0 + 11,
> + MSR_IA32_PMC0 + 12, MSR_IA32_PMC0 + 13, MSR_IA32_PMC0 + 14,
> + MSR_IA32_PMC0 + 15, MSR_IA32_PMC0 + 16, MSR_IA32_PMC0 + 17,
>  };

This is not needed because the full-width content is already accessible
from the host via MSR_IA32_PERFCTRn.

Given the bugs, it is clear that you should also modify the pmu.c
testcase for kvm-unit-tests to cover full-width writes (and especially
the non-full-width write behavior of MSR_IA32_PERFCTRn).  Even before
the QEMU side is begin worked on, you can test it with "-cpu
host,migratable=off".

Thanks,

Paolo



RE: [PATCH] x86: bitops: fix build regression

2020-05-07 Thread hpa
On May 7, 2020 12:44:44 AM PDT, David Laight  wrote:
>From: Brian Gerst
>> Sent: 07 May 2020 07:18
>...
>> > --- a/arch/x86/include/asm/bitops.h
>> > +++ b/arch/x86/include/asm/bitops.h
>> > @@ -54,7 +54,7 @@ arch_set_bit(long nr, volatile unsigned long
>*addr)
>> > if (__builtin_constant_p(nr)) {
>> > asm volatile(LOCK_PREFIX "orb %1,%0"
>> > : CONST_MASK_ADDR(nr, addr)
>> > -   : "iq" (CONST_MASK(nr) & 0xff)
>> > +   : "iq" ((u8)(CONST_MASK(nr) & 0xff))
>> 
>> I think a better fix would be to make CONST_MASK() return a u8 value
>> rather than have to cast on every use.
>
>Or assign to a local variable - then it doesn't matter how
>the value is actually calculated. So:
>   u8 mask = CONST_MASK(nr);
>   asm volatile(LOCK_PREFIX "orb %1,%0"
>   : CONST_MASK_ADDR(nr, addr)
>   : "iq" mask
>
>   David
>
>-
>Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes,
>MK1 1PT, UK
>Registration No: 1397386 (Wales)

"const u8" please...
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


[PATCH net-next] net: phy: Make iproc_mdio_resume static

2020-05-07 Thread Zheng Zengkai
Fix sparse warnings:

drivers/net/phy/mdio-bcm-iproc.c:182:5: warning:
 symbol 'iproc_mdio_resume' was not declared. Should it be static?

Reported-by: Hulk Robot 
Signed-off-by: Zheng Zengkai 
---
 drivers/net/phy/mdio-bcm-iproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio-bcm-iproc.c b/drivers/net/phy/mdio-bcm-iproc.c
index f1ded03f0229..89bdfcc0e506 100644
--- a/drivers/net/phy/mdio-bcm-iproc.c
+++ b/drivers/net/phy/mdio-bcm-iproc.c
@@ -179,7 +179,7 @@ static int iproc_mdio_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_SLEEP
-int iproc_mdio_resume(struct device *dev)
+static int iproc_mdio_resume(struct device *dev)
 {
struct platform_device *pdev = to_platform_device(dev);
struct iproc_mdio_priv *priv = platform_get_drvdata(pdev);
-- 
2.20.1



RE: [PATCH V3 10/10] clk: imx8mp: mark memrepair clock as critical

2020-05-07 Thread Peng Fan
> Subject: RE: [PATCH V3 10/10] clk: imx8mp: mark memrepair clock as critical
> 
> > From: Peng Fan 
> > Sent: Thursday, May 7, 2020 1:56 PM
> >
> > If memrepair root clock in CCM is disabled, the memory repair logic in
> > HDMIMIX can’t work. So let's mark it as critical clock.
> 
> A small question here:
> Is this clock critical for the whole system or only for HDMIMIX?
> What if HDMIIX is not enabled?

It is not only for HDMI, but for Linux runtime, it only affect HDMI for now
per my understanding, so
Let's drop this patch from this patchset for now.

Shawn,
  Since just drop this patch 10 from v3, there is no need for me to send v4?

Thanks,
Peng.

> 
> Regards
> Aisheng
> 
> >
> > Reviewed-by: Leonard Crestez 
> > Signed-off-by: Peng Fan 
> > ---
> >  drivers/clk/imx/clk-imx8mp.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/clk/imx/clk-imx8mp.c
> > b/drivers/clk/imx/clk-imx8mp.c index b4d9db9d5bf1..a7c59d7a40de
> 100644
> > --- a/drivers/clk/imx/clk-imx8mp.c
> > +++ b/drivers/clk/imx/clk-imx8mp.c
> > @@ -590,7 +590,7 @@ static int imx8mp_clocks_probe(struct
> > platform_device
> > *pdev)
> > hws[IMX8MP_CLK_VPU_G2] = imx8m_clk_hw_composite("vpu_g2",
> > imx8mp_vpu_g2_sels, ccm_base + 0xa180);
> > hws[IMX8MP_CLK_CAN1] = imx8m_clk_hw_composite("can1",
> > imx8mp_can1_sels, ccm_base + 0xa200);
> > hws[IMX8MP_CLK_CAN2] = imx8m_clk_hw_composite("can2",
> > imx8mp_can2_sels, ccm_base + 0xa280);
> > -   hws[IMX8MP_CLK_MEMREPAIR] =
> > imx8m_clk_hw_composite("memrepair", imx8mp_memrepair_sels,
> ccm_base +
> > 0xa300);
> > +   hws[IMX8MP_CLK_MEMREPAIR] =
> > +imx8m_clk_hw_composite_critical("memrepair",
> imx8mp_memrepair_sels,
> > +ccm_base + 0xa300);
> > hws[IMX8MP_CLK_PCIE_PHY] = imx8m_clk_hw_composite("pcie_phy",
> > imx8mp_pcie_phy_sels, ccm_base + 0xa380);
> > hws[IMX8MP_CLK_PCIE_AUX] = imx8m_clk_hw_composite("pcie_aux",
> > imx8mp_pcie_aux_sels, ccm_base + 0xa400);
> > hws[IMX8MP_CLK_I2C5] = imx8m_clk_hw_composite("i2c5",
> > imx8mp_i2c5_sels, ccm_base + 0xa480);
> > --
> > 2.16.4



Re: [PATCH] xhci: Make debug message consistent with bus and port number

2020-05-07 Thread Kai-Heng Feng



> On May 7, 2020, at 15:31, Greg Kroah-Hartman  
> wrote:
> 
> On Thu, May 07, 2020 at 03:15:01PM +0800, Kai-Heng Feng wrote:
>> 
>> 
>>> On May 7, 2020, at 14:45, Greg Kroah-Hartman  
>>> wrote:
>>> 
>>> On Thu, May 07, 2020 at 02:17:55PM +0800, Kai-Heng Feng wrote:
 Current xhci debug message doesn't always output bus number, so it's
 hard to figure out it's from USB2 or USB3 root hub.
 
 In addition to that, some port numbers are offset to 0 and others are
 offset to 1. Use the latter to match the USB core.
 
 So use "bus number - port index + 1" to make debug message consistent.
 
 Signed-off-by: Kai-Heng Feng 
 ---
 drivers/usb/host/xhci-hub.c | 41 +
 1 file changed, 23 insertions(+), 18 deletions(-)
 
 diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
 index f37316d2c8fa..83088c262cc4 100644
 --- a/drivers/usb/host/xhci-hub.c
 +++ b/drivers/usb/host/xhci-hub.c
 @@ -1241,7 +1241,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 
 typeReq, u16 wValue,
temp = readl(ports[wIndex]->addr);
/* Disable port */
if (link_state == USB_SS_PORT_LS_SS_DISABLED) {
 -  xhci_dbg(xhci, "Disable port %d\n", wIndex);
 +  xhci_dbg(xhci, "Disable port %d-%d\n",
 +   hcd->self.busnum, wIndex + 1);
>>> 
>>> Shouldn't xhci_dbg() show the bus number already?  
>> 
>> It's the PCI bus number, different to USB2/USB3 root hub bus number...
> 
> But if this is using dev_dbg(), and it is, then you know how to look
> that up by seeing where that device is in sysfs at that point in time.
> 
> So why add this again?

xHCI has two HCD, one for USB2 and one for USB3.
If both of their port with same number are in use, for instance, port 1, then 
they are port 1-1 and port 2-1.
Right now the debug message only show "Port 1", we still can't find the 
corresponding port via sysfs with insufficient info.

> 
>>> If not, please fix
>>> that up there instead of having to add it to all messages "by hand".
>> 
>> Not all xhci debug messages need roothub number in it.
> 
> Why pick these random ones?  What makes these different?

It's not random. We do it when there's a port in message.
Being able to know the exact port like "port 1-1" or "port 2-1", instead of 
just "port 1", can be really helpful.

Kai-Heng

> 
> Either all or none, be consistant please.
> 
> greg k-h



[PATCH V1 0/7] Target specific DLL configuration for qcom SDHC

2020-05-07 Thread Sarthak Garg
Sarthak Garg (6):
  dt-bindings: mmc: Add information for DLL register properties
  mmc: sdhci-msm: Update dll_config_3 as per HSR
  mmc: sdhci-msm: Update DDR_CONFIG as per device tree file
  mmc: sdhci-msm: Read and use DLL Config property from device tree file
  mmc: sdhci-msm: Introduce new ops to dump vendor specific registers
  mmc: sdhci-msm: dump vendor specific registers during error

Veerabhadrarao Badiganti (1):
  mmc: host: sdhci-msm: Configure dll-user-control in dll init sequence

 .../devicetree/bindings/mmc/sdhci-msm.txt  |  14 +++
 drivers/mmc/host/sdhci-msm.c   | 103 -
 drivers/mmc/host/sdhci.c   |   3 +
 drivers/mmc/host/sdhci.h   |   1 +
 4 files changed, 118 insertions(+), 3 deletions(-)

-- 
2.7.4



RE: [PATCH] fsnotify: avoid gcc-10 zero-length-bounds warning

2020-05-07 Thread David Laight
From: Arnd Bergmann
> Sent: 05 May 2020 16:00
...
> Yes, we usually backport trivial warning fixes to stable kernels to allow
> building those with any modern compiler version.

In this case wouldn't it be better to backport a change that disables
the specific compiler warning?

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)


[PATCH V1 5/7] mmc: sdhci-msm: Read and use DLL Config property from device tree file

2020-05-07 Thread Sarthak Garg
Certain platforms require different settings in the
SDCC_HC_REG_DLL_CONFIG register. This setting can change from platform
to platform. So the driver should check whether a particular platform
require a different setting by reading the DT file and use it.

Also use msm_cm_dll_set_freq only when DLL not supplied.

Signed-off-by: Bao D. Nguyen 
Signed-off-by: Sarthak Garg 
---
 drivers/mmc/host/sdhci-msm.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index b879806..598880a 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -275,6 +275,7 @@ struct sdhci_msm_host {
u32 transfer_mode;
bool updated_ddr_cfg;
bool uses_tassadar_dll;
+   u32 dll_config;
u32 ddr_config;
 };
 
@@ -617,6 +618,9 @@ static int msm_init_cm_dll(struct sdhci_host *host)
config &= ~CORE_CLK_PWRSAVE;
writel_relaxed(config, host->ioaddr + msm_offset->core_vendor_spec);
 
+   config = msm_host->dll_config;
+   writel_relaxed(config, host->ioaddr + msm_offset->core_dll_config);
+
if (msm_host->use_14lpp_dll_reset) {
config = readl_relaxed(host->ioaddr +
msm_offset->core_dll_config);
@@ -642,7 +646,9 @@ static int msm_init_cm_dll(struct sdhci_host *host)
config |= CORE_DLL_PDN;
writel_relaxed(config, host->ioaddr +
msm_offset->core_dll_config);
-   msm_cm_dll_set_freq(host);
+
+   if (!msm_host->dll_config)
+   msm_cm_dll_set_freq(host);
 
if (msm_host->use_14lpp_dll_reset &&
!IS_ERR_OR_NULL(msm_host->xo_clk)) {
@@ -682,7 +688,8 @@ static int msm_init_cm_dll(struct sdhci_host *host)
msm_offset->core_dll_config);
 
if (msm_host->use_14lpp_dll_reset) {
-   msm_cm_dll_set_freq(host);
+   if (!msm_host->dll_config)
+   msm_cm_dll_set_freq(host);
config = readl_relaxed(host->ioaddr +
msm_offset->core_dll_config_2);
config &= ~CORE_DLL_CLOCK_DISABLE;
@@ -1944,6 +1951,8 @@ static inline void sdhci_msm_get_of_property(struct 
platform_device *pdev,
if (of_property_read_u32(node, "qcom,ddr-config",
&msm_host->ddr_config))
msm_host->ddr_config = DDR_CONFIG_POR_VAL;
+
+   of_property_read_u32(node, "qcom,dll-config", &msm_host->dll_config);
 }
 
 
-- 
2.7.4



[PATCH V1 4/7] mmc: sdhci-msm: Update DDR_CONFIG as per device tree file

2020-05-07 Thread Sarthak Garg
Certain platforms require different settings in the
SDCC_HC_REG_DDR_CONFIG register. This setting can change from platform
to platform. So the driver should check whether a particular platform
require a different setting by reading the device tree file and use it.

Signed-off-by: Bao D. Nguyen 
Signed-off-by: Sarthak Garg 
---
 drivers/mmc/host/sdhci-msm.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 0f7baaf..b879806 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -275,6 +275,7 @@ struct sdhci_msm_host {
u32 transfer_mode;
bool updated_ddr_cfg;
bool uses_tassadar_dll;
+   u32 ddr_config;
 };
 
 static const struct sdhci_msm_offset *sdhci_priv_msm_offset(struct sdhci_host 
*host)
@@ -987,7 +988,7 @@ static int sdhci_msm_cm_dll_sdc4_calibration(struct 
sdhci_host *host)
ddr_cfg_offset = msm_offset->core_ddr_config;
else
ddr_cfg_offset = msm_offset->core_ddr_config_old;
-   writel_relaxed(DDR_CONFIG_POR_VAL, host->ioaddr + ddr_cfg_offset);
+   writel_relaxed(msm_host->ddr_config, host->ioaddr + ddr_cfg_offset);
 
if (mmc->ios.enhanced_strobe) {
config = readl_relaxed(host->ioaddr +
@@ -1933,6 +1934,19 @@ static const struct sdhci_pltfm_data sdhci_msm_pdata = {
.ops = &sdhci_msm_ops,
 };
 
+static inline void sdhci_msm_get_of_property(struct platform_device *pdev,
+   struct sdhci_host *host)
+{
+   struct device_node *node = pdev->dev.of_node;
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
+
+   if (of_property_read_u32(node, "qcom,ddr-config",
+   &msm_host->ddr_config))
+   msm_host->ddr_config = DDR_CONFIG_POR_VAL;
+}
+
+
 static int sdhci_msm_probe(struct platform_device *pdev)
 {
struct sdhci_host *host;
@@ -1975,6 +1989,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
msm_offset = msm_host->offset;
 
sdhci_get_of_property(pdev);
+   sdhci_msm_get_of_property(pdev, host);
 
msm_host->saved_tuning_phase = INVALID_TUNING_PHASE;
 
-- 
2.7.4



[PATCH V1 3/7] mmc: sdhci-msm: Update dll_config_3 as per HSR

2020-05-07 Thread Sarthak Garg
Update dll_config_3 as per the host clock frequency as specified in the
DLL Hardware Reference Guide.

Signed-off-by: Sarthak Garg 
---
 drivers/mmc/host/sdhci-msm.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index dad008e..0f7baaf 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -62,6 +62,9 @@
 #define FINE_TUNE_MODE_EN  BIT(27)
 #define BIAS_OK_SIGNAL BIT(29)
 
+#define DLL_CONFIG_3_LOW_FREQ_VAL  0x08
+#define DLL_CONFIG_3_HIGH_FREQ_VAL 0x10
+
 #define CORE_VENDOR_SPEC_POR_VAL 0xa9c
 #define CORE_CLK_PWRSAVE   BIT(1)
 #define CORE_HC_MCLK_SEL_DFLT  (2 << 8)
@@ -695,6 +698,16 @@ static int msm_init_cm_dll(struct sdhci_host *host)
ENABLE_DLL_LOCK_STATUS | BIAS_OK_SIGNAL;
writel_relaxed(config, host->ioaddr +
msm_offset->core_dll_usr_ctl);
+
+   config = readl_relaxed(host->ioaddr +
+   msm_offset->core_dll_config_3);
+   config &= ~0xFF;
+   if (msm_host->clk_rate < 15000)
+   config |= DLL_CONFIG_3_LOW_FREQ_VAL;
+   else
+   config |= DLL_CONFIG_3_HIGH_FREQ_VAL;
+   writel_relaxed(config, host->ioaddr +
+   msm_offset->core_dll_config_3);
}
 
config = readl_relaxed(host->ioaddr +
-- 
2.7.4



[PATCH V1 2/7] mmc: host: sdhci-msm: Configure dll-user-control in dll init sequence

2020-05-07 Thread Sarthak Garg
From: Veerabhadrarao Badiganti 

With SDCC v5.1.0, additional setting needed for enabling DLL output.
The dll-user-control register need to be configured during dll
initialization for getting proper dll output.

Without this configuration, we don't get the DLL lock status properly.
Also update the DLL register settings according to the SDCC Hardware
Programming Guide.

Signed-off-by: Veerabhadrarao Badiganti 
Signed-off-by: Sarthak Garg 
---
 drivers/mmc/host/sdhci-msm.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index ebc2dc3..dad008e 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -57,6 +57,11 @@
 #define CORE_FLL_CYCLE_CNT BIT(18)
 #define CORE_DLL_CLOCK_DISABLE BIT(21)
 
+#define DLL_USR_CTL_POR_VAL0x10800
+#define ENABLE_DLL_LOCK_STATUS BIT(26)
+#define FINE_TUNE_MODE_EN  BIT(27)
+#define BIAS_OK_SIGNAL BIT(29)
+
 #define CORE_VENDOR_SPEC_POR_VAL 0xa9c
 #define CORE_CLK_PWRSAVE   BIT(1)
 #define CORE_HC_MCLK_SEL_DFLT  (2 << 8)
@@ -157,6 +162,7 @@ struct sdhci_msm_offset {
u32 core_dll_config_3;
u32 core_ddr_config_old; /* Applicable to sdcc minor ver < 0x49 */
u32 core_ddr_config;
+   u32 core_dll_usr_ctl; /* Present on SDCC5.1 onwards */
 };
 
 static const struct sdhci_msm_offset sdhci_msm_v5_offset = {
@@ -186,6 +192,7 @@ static const struct sdhci_msm_offset sdhci_msm_v5_offset = {
.core_dll_config_2 = 0x254,
.core_dll_config_3 = 0x258,
.core_ddr_config = 0x25c,
+   .core_dll_usr_ctl = 0x388,
 };
 
 static const struct sdhci_msm_offset sdhci_msm_mci_offset = {
@@ -231,6 +238,7 @@ struct sdhci_msm_variant_ops {
 struct sdhci_msm_variant_info {
bool mci_removed;
bool restore_dll_config;
+   bool uses_tassadar_dll;
const struct sdhci_msm_variant_ops *var_ops;
const struct sdhci_msm_offset *offset;
 };
@@ -263,6 +271,7 @@ struct sdhci_msm_host {
bool use_cdr;
u32 transfer_mode;
bool updated_ddr_cfg;
+   bool uses_tassadar_dll;
 };
 
 static const struct sdhci_msm_offset *sdhci_priv_msm_offset(struct sdhci_host 
*host)
@@ -677,6 +686,17 @@ static int msm_init_cm_dll(struct sdhci_host *host)
msm_offset->core_dll_config_2);
}
 
+   /*
+* Configure DLL user control register to enable DLL status.
+* This setting is applicable to SDCC v5.1 onwards only.
+*/
+   if (msm_host->uses_tassadar_dll) {
+   config = DLL_USR_CTL_POR_VAL | FINE_TUNE_MODE_EN |
+   ENABLE_DLL_LOCK_STATUS | BIAS_OK_SIGNAL;
+   writel_relaxed(config, host->ioaddr +
+   msm_offset->core_dll_usr_ctl);
+   }
+
config = readl_relaxed(host->ioaddr +
msm_offset->core_dll_config);
config |= CORE_DLL_EN;
@@ -1861,10 +1881,18 @@ static const struct sdhci_msm_variant_info 
sdm845_sdhci_var = {
.offset = &sdhci_msm_v5_offset,
 };
 
+static const struct sdhci_msm_variant_info sm8250_sdhci_var = {
+   .mci_removed = true,
+   .uses_tassadar_dll = true,
+   .var_ops = &v5_var_ops,
+   .offset = &sdhci_msm_v5_offset,
+};
+
 static const struct of_device_id sdhci_msm_dt_match[] = {
{.compatible = "qcom,sdhci-msm-v4", .data = &sdhci_msm_mci_var},
{.compatible = "qcom,sdhci-msm-v5", .data = &sdhci_msm_v5_var},
{.compatible = "qcom,sdm845-sdhci", .data = &sdm845_sdhci_var},
+   {.compatible = "qcom,sm8250-sdhci", .data = &sm8250_sdhci_var},
{},
 };
 
@@ -1929,6 +1957,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
msm_host->restore_dll_config = var_info->restore_dll_config;
msm_host->var_ops = var_info->var_ops;
msm_host->offset = var_info->offset;
+   msm_host->uses_tassadar_dll = var_info->uses_tassadar_dll;
 
msm_offset = msm_host->offset;
 
-- 
2.7.4



[PATCH V1 7/7] mmc: sdhci-msm: dump vendor specific registers during error

2020-05-07 Thread Sarthak Garg
Implement dump_vendor_registers host operation to print the
vendor specific registers in addition to standard SDHC
register during error conditions.

Signed-off-by: Sahitya Tummala 
Signed-off-by: Sarthak Garg 
---
 drivers/mmc/host/sdhci-msm.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 598880a..a9c2f9c 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -1874,6 +1874,36 @@ static void sdhci_msm_reset(struct sdhci_host *host, u8 
mask)
sdhci_reset(host, mask);
 }
 
+#define DRIVER_NAME "sdhci_msm"
+#define SDHCI_MSM_DUMP(f, x...) \
+   pr_err("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
+
+void sdhci_msm_dump_vendor_regs(struct sdhci_host *host)
+{
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
+   const struct sdhci_msm_offset *msm_offset = msm_host->offset;
+
+   SDHCI_MSM_DUMP("--- VENDOR REGISTER DUMP ---\n");
+
+   SDHCI_MSM_DUMP(
+   "DLL sts: 0x%08x | DLL cfg:  0x%08x | DLL cfg2: 
0x%08x\n",
+   readl_relaxed(host->ioaddr + msm_offset->core_dll_status),
+   readl_relaxed(host->ioaddr + msm_offset->core_dll_config),
+   readl_relaxed(host->ioaddr + msm_offset->core_dll_config_2));
+   SDHCI_MSM_DUMP(
+   "DLL cfg3: 0x%08x | DLL usr ctl:  0x%08x | DDR cfg: 
0x%08x\n",
+   readl_relaxed(host->ioaddr + msm_offset->core_dll_config_3),
+   readl_relaxed(host->ioaddr + msm_offset->core_dll_usr_ctl),
+   readl_relaxed(host->ioaddr + msm_offset->core_ddr_config));
+   SDHCI_MSM_DUMP(
+   "Vndr func: 0x%08x | Vndr func2 : 0x%08x Vndr func3: 
0x%08x\n",
+   readl_relaxed(host->ioaddr + msm_offset->core_vendor_spec),
+   readl_relaxed(host->ioaddr +
+   msm_offset->core_vendor_spec_func2),
+   readl_relaxed(host->ioaddr + msm_offset->core_vendor_spec3));
+}
+
 static const struct sdhci_msm_variant_ops mci_var_ops = {
.msm_readl_relaxed = sdhci_msm_mci_variant_readl_relaxed,
.msm_writel_relaxed = sdhci_msm_mci_variant_writel_relaxed,
@@ -1929,6 +1959,7 @@ static const struct sdhci_ops sdhci_msm_ops = {
.write_w = sdhci_msm_writew,
.write_b = sdhci_msm_writeb,
.irq= sdhci_msm_cqe_irq,
+   .dump_vendor_regs = sdhci_msm_dump_vendor_regs,
 };
 
 static const struct sdhci_pltfm_data sdhci_msm_pdata = {
-- 
2.7.4



[PATCH V1 6/7] mmc: sdhci-msm: Introduce new ops to dump vendor specific registers

2020-05-07 Thread Sarthak Garg
Introduce new sdhci ops to dump vendor specific registers in the
sdhci_dumpregs during error.

Signed-off-by: Sahitya Tummala 
Signed-off-by: Sarthak Garg 
---
 drivers/mmc/host/sdhci.c | 3 +++
 drivers/mmc/host/sdhci.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 1bb6b67..ed73b71 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -111,6 +111,9 @@ void sdhci_dumpregs(struct sdhci_host *host)
}
}
 
+   if (host->ops->dump_vendor_regs)
+   host->ops->dump_vendor_regs(host);
+
SDHCI_DUMP("\n");
 }
 EXPORT_SYMBOL_GPL(sdhci_dumpregs);
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 8d2a096..79432d0 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -650,6 +650,7 @@ struct sdhci_ops {
   dma_addr_t addr, int len, unsigned int cmd);
void(*request_done)(struct sdhci_host *host,
struct mmc_request *mrq);
+   void(*dump_vendor_regs)(struct sdhci_host *host);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
-- 
2.7.4



KASAN: use-after-free Write in snd_rawmidi_kernel_write1

2020-05-07 Thread butt3rflyh4ck
I report a bug (in linux-5.7-rc1) found by syzkaller.

kernel config: 
https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.7.0-rc1.config
reproducer: 
https://github.com/butterflyhack/syzkaller-fuzz/blob/master/repro.cprog

I test the reproducer in linux-5.7-rc4 and crash too.

crash log:
==
BUG: KASAN: use-after-free in _copy_from_user+0x113/0x1a0 lib/usercopy.c:13
Write of size 1 at addr 888069da43ca by task syz-executor611/6797

CPU: 0 PID: 6797 Comm: syz-executor611 Not tainted 5.7.0-rc1 #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.10.2-1ubuntu1 04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x347 mm/kasan/report.c:382
 __kasan_report.cold+0x35/0x4d mm/kasan/report.c:511
 kasan_report+0x33/0x50 mm/kasan/common.c:625
 check_memory_region_inline mm/kasan/generic.c:187 [inline]
 check_memory_region+0x141/0x190 mm/kasan/generic.c:193
 _copy_from_user+0x113/0x1a0 lib/usercopy.c:13
 copy_from_user include/linux/uaccess.h:144 [inline]
 snd_rawmidi_kernel_write1+0x320/0x6f0 sound/core/rawmidi.c:1363
 snd_rawmidi_write+0x2e4/0xb80 sound/core/rawmidi.c:1429
 __vfs_write+0x76/0x100 fs/read_write.c:495
 vfs_write+0x268/0x5d0 fs/read_write.c:559
 ksys_write+0x1ee/0x250 fs/read_write.c:612
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x4553a9
Code: 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48
89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d
01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:7f556b7f5cc8 EFLAGS: 0246 ORIG_RAX: 0001
RAX: ffda RBX: 006d9588 RCX: 004553a9
RDX: fc85 RSI: 2040 RDI: 0004
RBP: 006d9580 R08:  R09: 
R10:  R11: 0246 R12: 006d958c
R13:  R14: 006d9580 R15: 7fff34bcb390

Allocated by task 6797:
 save_stack+0x1b/0x40 mm/kasan/common.c:49
 set_track mm/kasan/common.c:57 [inline]
 __kasan_kmalloc mm/kasan/common.c:495 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:468
 kmalloc_node include/linux/slab.h:578 [inline]
 kvmalloc_node+0x61/0xf0 mm/util.c:574
 kvmalloc include/linux/mm.h:757 [inline]
 kvzalloc include/linux/mm.h:765 [inline]
 snd_rawmidi_runtime_create sound/core/rawmidi.c:141 [inline]
 open_substream+0x33d/0x880 sound/core/rawmidi.c:285
 rawmidi_open_priv+0x58e/0x6e0 sound/core/rawmidi.c:336
 snd_rawmidi_open+0x455/0xb20 sound/core/rawmidi.c:433
 snd_open+0x212/0x3d0 sound/core/sound.c:163
 chrdev_open+0x219/0x5c0 fs/char_dev.c:414
 do_dentry_open+0x4ba/0x1290 fs/open.c:797
 do_open fs/namei.c:3229 [inline]
 path_openat+0x1e59/0x27d0 fs/namei.c:3346
 do_filp_open+0x192/0x260 fs/namei.c:3373
 do_sys_openat2+0x585/0x7d0 fs/open.c:1148
 do_sys_open+0xc3/0x140 fs/open.c:1164
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 6798:
 save_stack+0x1b/0x40 mm/kasan/common.c:49
 set_track mm/kasan/common.c:57 [inline]
 kasan_set_free_info mm/kasan/common.c:317 [inline]
 __kasan_slab_free+0x126/0x170 mm/kasan/common.c:456
 slab_free_hook mm/slub.c:1445 [inline]
 slab_free_freelist_hook+0xc4/0x1c0 mm/slub.c:1478
 slab_free mm/slub.c:3035 [inline]
 kfree+0xd8/0x330 mm/slub.c:4003
 kvfree+0x42/0x50 mm/util.c:603
 resize_runtime_buffer+0x29e/0x370 sound/core/rawmidi.c:677
 snd_rawmidi_output_params+0x128/0x170 sound/core/rawmidi.c:690
 snd_rawmidi_ioctl+0x544/0x5b0 sound/core/rawmidi.c:841
 vfs_ioctl fs/ioctl.c:47 [inline]
 ksys_ioctl+0x11a/0x180 fs/ioctl.c:763
 __do_sys_ioctl fs/ioctl.c:772 [inline]
 __se_sys_ioctl fs/ioctl.c:770 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:770
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

The buggy address belongs to the object at 888069da4000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 970 bytes inside of
 4096-byte region [888069da4000, 888069da5000)
The buggy address belongs to the page:
page:ea0001a76800 refcount:1 mapcount:0 mapping:c136e8e7
index:0x0 head:ea0001a76800 order:3 compound_mapcount:0
compound_pincount:0
flags: 0xfffe010200(slab|head)
raw: 00fffe010200 dead0100 dead0122 88806bc0c280
raw:  80040004 0001 
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 888069da4280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 888069da4300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>888069da4380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
  ^
 888069da4400: fb fb fb fb fb 

[PATCH V1 1/7] dt-bindings: mmc: Add information for DLL register properties

2020-05-07 Thread Sarthak Garg
Add information regarding DLL register properties for getting target
specific configurations. These DLL register settings may vary from
target to target.

Also new compatible string value for sm8250 target.

Signed-off-by: Sarthak Garg 
---
 Documentation/devicetree/bindings/mmc/sdhci-msm.txt | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/sdhci-msm.txt 
b/Documentation/devicetree/bindings/mmc/sdhci-msm.txt
index 5445931..b8e1d2b 100644
--- a/Documentation/devicetree/bindings/mmc/sdhci-msm.txt
+++ b/Documentation/devicetree/bindings/mmc/sdhci-msm.txt
@@ -17,6 +17,7 @@ Required properties:
"qcom,msm8916-sdhci", "qcom,sdhci-msm-v4"
"qcom,msm8992-sdhci", "qcom,sdhci-msm-v4"
"qcom,msm8996-sdhci", "qcom,sdhci-msm-v4"
+   "qcom,sm8250-sdhci", "qcom,sdhci-msm-v5"
"qcom,sdm845-sdhci", "qcom,sdhci-msm-v5"
"qcom,qcs404-sdhci", "qcom,sdhci-msm-v5"
"qcom,sc7180-sdhci", "qcom,sdhci-msm-v5";
@@ -46,6 +47,13 @@ Required properties:
"cal"   - reference clock for RCLK delay calibration (optional)
"sleep" - sleep clock for RCLK delay calibration (optional)
 
+- qcom,ddr-config: Certain chipsets and platforms require particular settings
+   for the DDR_CONFIG register. Use this field to specify the register
+   value as per the Hardware Programming Guide.
+
+- qcom,dll-config: Chipset and Platform specific value. Use this field to
+   specify the DLL_CONFIG register value as per Hardware Programming Guide.
+
 Example:
 
sdhc_1: sdhci@f9824900 {
@@ -63,6 +71,9 @@ Example:
 
clocks = <&gcc GCC_SDCC1_APPS_CLK>, <&gcc GCC_SDCC1_AHB_CLK>;
clock-names = "core", "iface";
+
+   qcom,dll-config = <0x000f642c>;
+   qcom,ddr-config = <0x80040868>;
};
 
sdhc_2: sdhci@f98a4900 {
@@ -80,4 +91,7 @@ Example:
 
clocks = <&gcc GCC_SDCC2_APPS_CLK>, <&gcc GCC_SDCC2_AHB_CLK>;
clock-names = "core", "iface";
+
+   qcom,dll-config = <0x0007642c>;
+   qcom,ddr-config = <0x80040868>;
};
-- 
2.7.4



RE: [PATCH v5 0/6] Add support for O_MAYEXEC

2020-05-07 Thread David Laight
From: Mickaël Salaün
> Sent: 05 May 2020 16:32
> 
> This fifth patch series add new kernel configurations (OMAYEXEC_STATIC,
> OMAYEXEC_ENFORCE_MOUNT, and OMAYEXEC_ENFORCE_FILE) to enable to
> configure the security policy at kernel build time.  As requested by
> Mimi Zohar, I completed the series with one of her patches for IMA.
> 
> The goal of this patch series is to enable to control script execution
> with interpreters help.  A new O_MAYEXEC flag, usable through
> openat2(2), is added to enable userspace script interpreter to delegate
> to the kernel (and thus the system security policy) the permission to
> interpret/execute scripts or other files containing what can be seen as
> commands.
> 
> A simple system-wide security policy can be enforced by the system
> administrator through a sysctl configuration consistent with the mount
> points or the file access rights.  The documentation patch explains the
> prerequisites.
> 
> Furthermore, the security policy can also be delegated to an LSM, either
> a MAC system or an integrity system.  For instance, the new kernel
> MAY_OPENEXEC flag closes a major IMA measurement/appraisal interpreter
> integrity gap by bringing the ability to check the use of scripts [1].
> Other uses are expected, such as for openat2(2) [2], SGX integration
> [3], bpffs [4] or IPE [5].
> 
> Userspace needs to adapt to take advantage of this new feature.  For
> example, the PEP 578 [6] (Runtime Audit Hooks) enables Python 3.8 to be
> extended with policy enforcement points related to code interpretation,
> which can be used to align with the PowerShell audit features.
> Additional Python security improvements (e.g. a limited interpreter
> withou -c, stdin piping of code) are on their way.
> 
> The initial idea come from CLIP OS 4 and the original implementation has
> been used for more than 12 years:
> https://github.com/clipos-archive/clipos4_doc
> 
> An introduction to O_MAYEXEC was given at the Linux Security Summit
> Europe 2018 - Linux Kernel Security Contributions by ANSSI:
> https://www.youtube.com/watch?v=chNjCRtPKQY&t=17m15s
> The "write xor execute" principle was explained at Kernel Recipes 2018 -
> CLIP OS: a defense-in-depth OS:
> https://www.youtube.com/watch?v=PjRE0uBtkHU&t=11m14s
> 
> This patch series can be applied on top of v5.7-rc4.  This can be tested
> with CONFIG_SYSCTL.  I would really appreciate constructive comments on
> this patch series.

None of that description actually says what the patch actually does.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)


RE: [PATCH v7 2/3] media: ov8856: Add devicetree support

2020-05-07 Thread Kao, Ben
Hi Robert,

On 20-05-05 12:01, Robert Foss wrote:
> Add match table, enable ov8856_probe() to support both ACPI and DT modes.
> 
> ACPI and DT modes are primarily distinguished from by checking for ACPI mode
> and by having resource like be NULL.
> 
> Signed-off-by: Robert Foss 
> ---
> 
> - Changes since v6:
>   * Marco: Bail out of __ov8856_power_on earlier if ACPI mode
> 
> - Changes since v5:
>   * Maxime & Sakari: Replaced clock tolerance check with warning
> 
> - Changes since v4:
>   * Maxime & Sakari: Switch to clock-frequency
> 
> - Changes since v3:
>   * Remove redundant {}-brackets
>   * Compare xvclk_rate to 5% tolerance
>   * Andy: Use dev_fwnode()
>   * Andy: Use %pe instead of %ld + PTR_ERR()
>   * Andy: Invert reset_gpio logic
>   * Andy: Remove dev_dbg() from failing reset_gpio setup
>   * Andy: Use dev_err for logging for failures
>   * Andy: Remove dev_warn from EDEFER/regulator error path
>   * Andy & Sakari: Replaced GPIOD_OUT_XXX with 0/1
>   * Maxime & Sakari: Verify clock frequency from DT
>   * Sakari: Verify the 'xvclk_rate' is set correctly for ACPI/DT devices
>   * Sakari: Remove duplicate ov8856->dev assignment
> 
> - Changes since v2:
>   * Added "struct device *dev" member to struct ov8856
>   * Andy: Switch to optional version of devm_gpiod_get
>   * Andy: Switch to optional version of devm_clk_get
>   * Fabio: Add reset sleep period
>   * Sakari: Unify defines for 19.2Mhz
>   * Sakari: Remove 24Mhz clock, since it isn't needed for supported modes
>   * Sakari: Replace dev_info() with dev_dbg()
>   * Sakari: Switch induction variable type to unsigned
>   * Sakari: Don't wait for reset_gpio when in ACPI mode
>   * Sakari: Pull reset GPIO high on power on failure
>   * Sakari: Add power on/off to resume/suspend
>   * Sakari: Fix indentation
>   * Sakari: Power off during ov8856_remove()
>   * Sakari: Don't sleep during power-on in ACPI mode
>   * Sakari: Switch to getting xvclk from clk_get_rate
> 
> - Changes since v1:
>   * Andy & Sakari: Make XVCLK optional since to not break ACPI
>   * Fabio: Change n_shutdown_gpio name to reset_gpio
>   * Fabio: Invert reset_gpio due to GPIO_ACTIVE_HIGH -> GPIO_ACTIVE_LOW
> change
>   * Fabio: Remove empty line
>   * Fabio: Remove real error from devm_gpiod_get() failures
>   * Sakari: ARRAY_SIZE() directly instead of through OV8856_NUM_SUPPLIES
>   * Sakari: Use XVCLK rate as provided by DT
> 
>  drivers/media/i2c/ov8856.c | 137 +
>  1 file changed, 123 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c index
> 8655842af275..e6418a79801e 100644
> --- a/drivers/media/i2c/ov8856.c
> +++ b/drivers/media/i2c/ov8856.c
> @@ -3,10 +3,13 @@
> 
>  #include 
>  #include 
> +#include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -18,7 +21,7 @@
>  #define OV8856_LINK_FREQ_360MHZ  36000ULL
>  #define OV8856_LINK_FREQ_180MHZ  18000ULL
>  #define OV8856_SCLK  14400ULL
> -#define OV8856_MCLK  1920
> +#define OV8856_XVCLK_19_21920
>  #define OV8856_DATA_LANES4
>  #define OV8856_RGB_DEPTH 10
> 
> @@ -64,6 +67,12 @@
> 
>  #define to_ov8856(_sd)   container_of(_sd, struct 
> ov8856, sd)
> 
> +static const char * const ov8856_supply_names[] = {
> + "dovdd",/* Digital I/O power */
> + "avdd", /* Analog power */
> + "dvdd", /* Digital core power */
> +};
> +
>  enum {
>   OV8856_LINK_FREQ_720MBPS,
>   OV8856_LINK_FREQ_360MBPS,
> @@ -566,6 +575,11 @@ struct ov8856 {
>   struct media_pad pad;
>   struct v4l2_ctrl_handler ctrl_handler;
> 
> + struct device   *dev;
> + struct clk  *xvclk;
> + struct gpio_desc*reset_gpio;
> + struct regulator_bulk_data
> supplies[ARRAY_SIZE(ov8856_supply_names)];
> +
>   /* V4L2 Controls */
>   struct v4l2_ctrl *link_freq;
>   struct v4l2_ctrl *pixel_rate;
> @@ -908,6 +922,52 @@ static int ov8856_set_stream(struct v4l2_subdev *sd,
> int enable)
>   return ret;
>  }
> 
> +static int __ov8856_power_on(struct ov8856 *ov8856) {
> + struct i2c_client *client = v4l2_get_subdevdata(&ov8856->sd);
> + int ret;
> +
> + if (is_acpi_node(dev_fwnode(ov8856->dev)))
> + return 0;
> +
> + ret = clk_prepare_enable(ov8856->xvclk);
> + if (ret < 0) {
> + dev_err(&client->dev, "failed to enable xvclk\n");
> + return ret;
> + }
> +
> + if (ov8856->reset_gpio) {
> + gpiod_set_value_cansleep(ov8856->reset_gpio, 1);
> + usleep_range(1000, 2000);
> + }
> +
> + ret = regulator_bulk_enable(ARRAY_SIZE(ov8856_supply_names),
> + ov8856->supplies);
> + if (ret < 0) {
> + dev_err(&client->dev, "failed to enable regula

Re: [PATCH 2/2] KVM: SVM: Add support for MPK feature on AMD

2020-05-07 Thread Paolo Bonzini
On 07/05/20 00:26, Sean Christopherson wrote:
>> +/* Load the guest pkru state */
>> +if (static_cpu_has(X86_FEATURE_PKU) &&
>> +kvm_read_cr4_bits(vcpu, X86_CR4_PKE) &&
>> +vcpu->arch.pkru != svm->host_pkru)
>> +__write_pkru(vcpu->arch.pkru);
> This and the restoration should be moved to common x86 helpers, at a glance
> they look identical.
> 
> In short, pretty much all of this belongs in common x86.
> 

We could stick this in kvm_load_guest_xsave_state
kvm_load_host_xsave_state.  It's not a perfect match, after all the code
itself proves that PKRU can be loaded without XSAVE; but it's close
enough and it's exactly in the right point of vmx_vcpu_run and svm_vcpu_run.

Paolo



[PATCH 0/1] hibernate: restrict writes to the snapshot device

2020-05-07 Thread Domenico Andreoli
Dear maintainers,

  here I'm proposing an improvement to [0] which aimed to quickly solve
a regression. The aim is to complete [1] with regards of uswsusp needs,
at the time not considered.

Kind regards,
Domenico

[0] https://lore.kernel.org/linux-pm/20200304170646.GA31552@dumbo/
[1] 
https://lore.kernel.org/linux-fsdevel/156588514105.111054.13645634739408399209.stgit@magnolia/

-- 
rsa4096: 3B10 0CA1 8674 ACBA B4FE  FCD2 CE5B CF17 9960 DE13
ed25519: FFB4 0CC3 7F2E 091D F7DA  356E CC79 2832 ED38 CB05


[PATCH 1/1] hibernate: restrict writes to the snapshot device

2020-05-07 Thread Domenico Andreoli
From: Domenico Andreoli 

Hibernation via snapshot device requires write permission to the swap
block device, the one that more often (but not necessarily) is used to
store the hibernation image.

With this patch, such permissions are granted iff:

1) snapshot device config option is enabled
2) swap partition is used as snapshot device

In other circumstance the swap device is not writable from userspace.

In order to achieve this, every write attempt to a swap device is
checked against the device configured as part of the uswsusp API [0]
using a pointer to the inode struct in memory. If the swap device being
written was not configured for snapshotting, the write request is denied.

NOTE: this implementation works only for swap block devices, where the
inode configured by swapon (which sets S_SWAPFILE) is the same used
by SNAPSHOT_SET_SWAP_AREA.

In case of swapfile, SNAPSHOT_SET_SWAP_AREA indeed receives the inode
of the block device containing the filesystem where the swap files is
located (+ offset in it) which is never passed to swapon and then has
not the S_SWAPFILE set.

As result, the swapfile itself (as a file) has never an option to be
written from userspace. Instead it remains writable if accessed directly
from the containing block device, which is always writeable from root.

[0] Documentation/power/userland-swsusp.rst

Signed-off-by: Domenico Andreoli 
Cc: "Rafael J. Wysocki" 
Cc: Pavel Machek 
Cc: Darrick J. Wong 
Cc: Christoph Hellwig 
Cc: v...@zeniv.linux.org.uk
Cc: ty...@mit.edu
Cc: len.br...@intel.com
Cc: linux...@vger.kernel.org
Cc: linux...@kvack.org
Cc: linux-...@vger.kernel.org
Cc: linux-fsde...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
 fs/block_dev.c  |3 +--
 include/linux/suspend.h |6 ++
 kernel/power/user.c |   14 +-
 3 files changed, 20 insertions(+), 3 deletions(-)

Index: b/include/linux/suspend.h
===
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -466,6 +466,12 @@ static inline bool system_entering_hiber
 static inline bool hibernation_available(void) { return false; }
 #endif /* CONFIG_HIBERNATION */
 
+#ifdef CONFIG_HIBERNATION_SNAPSHOT_DEV
+int is_hibernate_snapshot_dev(const struct inode *);
+#else
+static inline int is_hibernate_snapshot_dev(const struct inode *i) { return 0; 
}
+#endif
+
 /* Hibernation and suspend events */
 #define PM_HIBERNATION_PREPARE 0x0001 /* Going to hibernate */
 #define PM_POST_HIBERNATION0x0002 /* Hibernation finished */
Index: b/kernel/power/user.c
===
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -35,8 +35,14 @@ static struct snapshot_data {
bool ready;
bool platform_support;
bool free_bitmaps;
+   struct inode *bd_inode;
 } snapshot_state;
 
+int is_hibernate_snapshot_dev(const struct inode *bd_inode)
+{
+   return hibernation_available() && snapshot_state.bd_inode == bd_inode;
+}
+
 static int snapshot_open(struct inode *inode, struct file *filp)
 {
struct snapshot_data *data;
@@ -95,6 +101,7 @@ static int snapshot_open(struct inode *i
data->frozen = false;
data->ready = false;
data->platform_support = false;
+   data->bd_inode = NULL;
 
  Unlock:
unlock_system_sleep();
@@ -110,6 +117,7 @@ static int snapshot_release(struct inode
 
swsusp_free();
data = filp->private_data;
+   data->bd_inode = NULL;
free_all_swap_pages(data->swap);
if (data->frozen) {
pm_restore_gfp_mask();
@@ -202,6 +210,7 @@ struct compat_resume_swap_area {
 static int snapshot_set_swap_area(struct snapshot_data *data,
void __user *argp)
 {
+   struct block_device *bdev;
sector_t offset;
dev_t swdev;
 
@@ -232,9 +241,12 @@ static int snapshot_set_swap_area(struct
data->swap = -1;
return -EINVAL;
}
-   data->swap = swap_type_of(swdev, offset, NULL);
+   data->swap = swap_type_of(swdev, offset, &bdev);
if (data->swap < 0)
return -ENODEV;
+
+   data->bd_inode = bdev->bd_inode;
+   bdput(bdev);
return 0;
 }
 
Index: b/fs/block_dev.c
===
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -2023,8 +2023,7 @@ ssize_t blkdev_write_iter(struct kiocb *
if (bdev_read_only(I_BDEV(bd_inode)))
return -EPERM;
 
-   /* uswsusp needs write permission to the swap */
-   if (IS_SWAPFILE(bd_inode) && !hibernation_available())
+   if (IS_SWAPFILE(bd_inode) && !is_hibernate_snapshot_dev(bd_inode))
return -ETXTBSY;
 
if (!iov_iter_count(from))



RE: [PATCH V2] pwm: tegra: dynamic clk freq configuration by PWM driver

2020-05-07 Thread Sandipan Patra
Hello,

> -Original Message-
> From: Uwe Kleine-König 
> Sent: Tuesday, May 5, 2020 1:42 AM
> To: Sandipan Patra 
> Cc: Thierry Reding ; robh...@kernel.org; Jonathan
> Hunter ; Bibek Basu ; Laxman
> Dewangan ; linux-...@vger.kernel.org;
> devicet...@vger.kernel.org; linux-te...@vger.kernel.org; linux-
> ker...@vger.kernel.org
> Subject: Re: [PATCH V2] pwm: tegra: dynamic clk freq configuration by PWM
> driver
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello,
> 
> On Mon, Apr 20, 2020 at 09:24:03PM +0530, Sandipan Patra wrote:
> > Added support for dynamic clock freq configuration in pwm kernel driver.
> > Earlier the pwm driver used to cache boot time clock rate by pwm clock
> > parent during probe. Hence dynamically changing pwm frequency was not
> > possible for all the possible ranges. With this change, dynamic
> > calculation is enabled and it is able to set the requested period from
> > sysfs knob provided the value is supported by clock source.
> >
> > Changes mainly have 2 parts:
> >   - T186 and later chips [1]
> >   - T210 and prior chips [2]
> >
> > For [1] - Changes implemented to set pwm period dynamically and
> >   also checks added to allow only if requested period(ns) is
> >   below or equals to higher range.
> >
> > For [2] - Only checks if the requested period(ns) is below or equals
> >   to higher range defined by max clock limit. The limitation
> >   in T210 or prior chips are due to the reason of having only
> >   one pwm-controller supporting multiple channels. But later
> >   chips have multiple pwm controller instances each having
> > single channel support.
> >
> > Signed-off-by: Sandipan Patra 
> > ---
> > V2:
> > 1. Min period_ns calculation is moved to probe.
> > 2. Added descriptioins for PWM register bits and regarding behaviour
> >of the controller when new configuration is applied or pwm is disabled.
> > 3. Setting period with possible value when supplied period is below limit.
> > 4. Corrected the earlier code comment:
> >plus 1 instead of minus 1 during pwm calculation
> >
> >  drivers/pwm/pwm-tegra.c | 110
> > +---
> >  1 file changed, 94 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c index
> > d26ed8f..7a36325 100644
> > --- a/drivers/pwm/pwm-tegra.c
> > +++ b/drivers/pwm/pwm-tegra.c
> > @@ -4,8 +4,39 @@
> >   *
> >   * Tegra pulse-width-modulation controller driver
> >   *
> > - * Copyright (c) 2010, NVIDIA Corporation.
> > - * Based on arch/arm/plat-mxc/pwm.c by Sascha Hauer
> > 
> > + * Copyright (c) 2010-2020, NVIDIA Corporation.
> > + *
> > + * Overview of Tegra Pulse Width Modulator Register:
> > + * 1. 13-bit: Frequency division (SCALE)
> > + * 2. 8-bit : Puls division (DUTY)
> > + * 3. 1-bit : Enable bit
> > + *
> > + * The PWM clock frequency is divided by 256 before subdividing it
> > + based
> > + * on the programmable frequency division value to generate the
> > + required
> > + * frequency for PWM output. The maximum output frequency that can be
> > + * achieved is (max rate of source clock) / 256.
> > + * i.e. if source clock rate is 408 MHz, maximum output frequency cab be:
> 
> s/i.e./e.g./, s/cab/can/

Noted, correction in next patch.

> 
> > + * 408 MHz/256 = 1.6 MHz.
> > + * This 1.6 MHz frequency can further be divided using SCALE value in PWM.
> > + *
> > + * PWM pulse width: 8 bits are usable [23:16] for varying pulse width.
> > + * To achieve 100% duty cycle, program Bit [24] of this register to
> > + * 1’b1. In which case the other bits [23:16] are set to don't care.
> > + *
> > + * Limitations and known facts:
> 
> Please use "Limitations:" here to make this easier greppable.

Will update in next patch.

> 
> > + * - When PWM is disabled, the output is driven to 0.
> 
> 0 or inactive?

Yes, Inactive. When it is 0, it is disabled.
Will update it to "inactive".

> 
> > + * - It does not allow the current PWM period to complete and
> > + *   stops abruptly.
> > + *
> > + * - If the register is reconfigured while pwm is running,
> 
> s/pwm/PWM/
 
Noted, correction in next patch.

> 
> > + *   It does not let the currently running period to complete.
> 
> s/It/it/; s/let/complete/; s/ to complete//
>

Noted, correction in next patch
 
> > + *
> > + * - Pulse width of the pwm can never be out of bound.
> 
> I don't understand that one.

As I understand:
Pulse width is configured on bits [23:16]. So any misconfiguration or overflow 
from
Software will be restricted by the hardware and only the respective bits will 
be considered.
Also the explanation is added above during register bit field descriptions.
Please advise if that doesn't help.
 
> 
> > + *   It's taken care at HW and SW
> > + * - If the user input duty is below limit, then driver sets it to
> > + *   minimum possible value.
> 
> that is 0? Do you mean "input period"? If so, better refuse the reque

binder: transaction latency tracking for user build

2020-05-07 Thread Frankie Chang

Frankie.Chang (3):
  binder: move structs from core file to header file
  binder: add trace at free transaction.
  binder: add transaction latency tracer

 drivers/android/Kconfig |   8 +
 drivers/android/Makefile|   1 +
 drivers/android/binder.c| 408 +--
 drivers/android/binder_internal.h   | 416 
 drivers/android/binder_latency_tracer.c | 105 ++
 drivers/android/binder_trace.h  |  47 +++
 6 files changed, 581 insertions(+), 404 deletions(-)
 create mode 100644 drivers/android/binder_latency_tracer.c

Re: [PATCH 1/4] scripts/checkstack.pl: don't display $dre as different entity

2020-05-07 Thread Masahiro Yamada
On Thu, Apr 30, 2020 at 9:50 PM Maninder Singh  wrote:
>
> currnetly script prints stack usage for functions
> in two ways:($re and $dre)
>
> dre breaks sorting mechanism.
> 0xa00011f26f88 sunxi_mux_clk_setup.isra.0 [vmlinux]:Dynamic (0x140)
> ..
> 0xa00011f27210 sunxi_divs_clk_setup [vmlinux]:  Dynamic (0x1d0)
>
> so we can print it in decimal only.
>
> Also address before function name is changed to function
> start address rather than stack consumption address.
> Because in next patch, arm has two ways to use stack
> which can be clubbed and printed in one function only.
>
> All symbols whose stack by adding(re and dre) is greater than
> 100, will be printed.
>
> 0xa00011f2720c0 sunxi_divs_clk_setup [vmlinux]: 464
> ...
> 0xa00011f26f840 sunxi_mux_clk_setup.isra.0 [vmlinux]:320
>
> Signed-off-by: Vaneet Narang 
> Signed-off-by: Maninder Singh 
> ---
>  scripts/checkstack.pl | 52 
> +--
>  1 file changed, 25 insertions(+), 27 deletions(-)
>
> diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
> index 371bd17..412c459 100755
> --- a/scripts/checkstack.pl
> +++ b/scripts/checkstack.pl
> @@ -109,11 +109,28 @@ my (@stack, $re, $dre, $x, $xs, $funcre);
>  #
>  # main()
>  #
> -my ($func, $file, $lastslash);
> +my ($func, $file, $lastslash, $total_size, $addr, $intro);


$total_size is undefined for the first function.
I think 0 is implied, but is it clearer to initialize it here?

$total_size = 0;



>  while (my $line = ) {
> if ($line =~ m/$funcre/) {
> +   if ($total_size > 100) {
> +   push @stack, "$intro$total_size\n";
> +   }
> +
> $func = $1;
> +   next if $line !~ m/^($xs*)/;

Hmm, I think this 'next' is unlikely to happen.
But, it happened, the same line would be pushed twice.

Maybe, is it better to move 'next it' above
the 'if ($total_size > 100)' check?




> +   $addr = $1;
> +   $addr =~ s/ /0/g;
> +   $addr = "0x$addr";
> +
> +   $intro = "$addr $func [$file]:";
> +   my $padlen = 56 - length($intro);
> +   while ($padlen > 0) {
> +   $intro .= ' ';
> +   $padlen -= 8;
> +   }
> +
> +   $total_size = 0;
> }
> elsif ($line =~ m/(.*):\s*file format/) {
> $file = $1;
> @@ -134,37 +151,18 @@ while (my $line = ) {
> }
> next if ($size > 0x1000);
>
> -   next if $line !~ m/^($xs*)/;
> -   my $addr = $1;
> -   $addr =~ s/ /0/g;
> -   $addr = "0x$addr";
> -
> -   my $intro = "$addr $func [$file]:";
> -   my $padlen = 56 - length($intro);
> -   while ($padlen > 0) {
> -   $intro .= ' ';
> -   $padlen -= 8;
> -   }
> -   next if ($size < 100);
> -   push @stack, "$intro$size\n";
> +   $total_size = $total_size + $size


For consistency, I personally prefer adding ';'
to every statement even for the last one in the block...


Is this simpler ?

  $total_size += $size;






> }
> elsif (defined $dre && $line =~ m/$dre/) {
> -   my $size = "Dynamic ($1)";
> -
> -   next if $line !~ m/^($xs*)/;
> -   my $addr = $1;
> -   $addr =~ s/ /0/g;
> -   $addr = "0x$addr";
> +   my $size = $1;
>
> -   my $intro = "$addr $func [$file]:";
> -   my $padlen = 56 - length($intro);
> -   while ($padlen > 0) {
> -   $intro .= ' ';
> -   $padlen -= 8;
> -   }
> -   push @stack, "$intro$size\n";
> +   $size = hex($size) if ($size =~ /^0x/);
> +   $total_size = $total_size + $size



Ditto. How about this?

  $total_size += $size;


> }
>  }
> +if ($total_size > 100) {
> +   push @stack, "$intro$total_size\n";
> +}
>
>  # Sort output by size (last field)
>  print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
> --
> 1.9.1
>


--
Best Regards
Masahiro Yamada


Re: [PATCH 1/2] media: venus: Add support for MSM8939

2020-05-07 Thread Stanimir Varbanov
Hi Konrad,

On 5/7/20 12:23 AM, Konrad Dybcio wrote:
> Hi Stan,
> 
> I have found some issues with the submitted GCC driver, related to
> venus, but I have to further look into them locally and work out some
> stuff. One of the things is that freq table for venus clock should be
> changed to the values found here [1] (currently it has 8916
> frequencies). When I find all the causes I'll resubmit this and
> include them in the cover letter, as I might've overlooked something
> wrt venus driver itself when creating this patch from my WIP branch.
> Also it seems like I tested this very patch incorrectly (getting
> segfaults in ffmpeg with v4l2m2m now)... Anyways, I'll get back to you
> when I make it work for sure. Sorry again for the inconvenience.

OK. Thanks for the details, I'm waiting for good news :). If you need
some help with Venus bringup ping me on IRC - my nickname is svarbanov
on #v4l channel.

Regarding to venus clocks, these two clocks exist in below gcc driver
but missing in msm8916:

gcc_venus0_core0_vcodec0_clk
gcc_venus0_core1_vcodec0_clk

but the Venus IP block should be the same as in msm8916. Can you point
me to the donwstream gcc driver or check from where they comes.

> 
> 
> [1] 
> https://github.com/konradybcio/android_kernel_asus_msm8916-1/blob/minimal/drivers/clk/qcom/clock-gcc-8936.c#L1613-L1618
> 
> Konrad
> 
> wt., 5 maj 2020 o 13:43 Stanimir Varbanov
>  napisał(a):
>>
>> Hi Konrad,
>>
>> On 5/1/20 11:35 PM, Konrad Dybcio wrote:
>>> Signed-off-by: Konrad Dybcio 
>>> ---
>>>  drivers/media/platform/qcom/venus/core.c | 33 
>>>  1 file changed, 33 insertions(+)
>>>
>>> diff --git a/drivers/media/platform/qcom/venus/core.c 
>>> b/drivers/media/platform/qcom/venus/core.c
>>> index 194b10b987672..f3a15991ac763 100644
>>> --- a/drivers/media/platform/qcom/venus/core.c
>>> +++ b/drivers/media/platform/qcom/venus/core.c
>>> @@ -405,6 +405,38 @@ static const struct venus_resources msm8916_res = {
>>>   .fwname = "qcom/venus-1.8/venus.mdt",
>>>  };
>>>
>>> +static const struct freq_tbl msm8939_freq_table[] = {
>>> + { 489600, 26667 },  /* 1080p @ 60 */
>>> + { 244800, 2 },  /* 1080p @ 30 */
>>> + { 244800, 1 },  /* 1080p @ 30 (decode only) */
>>> + { 220800, 1 },  /* 720p @ 60 (decode only?) */
>>> + { 108000, 1 },  /* 720p @ 30*/
>>> + { 72000, 1 },  /* VGA @ 60 */
>>> + { 36000, 1 },  /* VGA @ 30 */
>>
>> 133MHz is the minimum clock frequency in the GCC driver? Do you think
>> that will change?
>>
>>> +};
>>> +
>>> +static const struct reg_val msm8939_reg_preset[] = {
>>> + { 0xe0020, 0x0aaa },
>>> + { 0xe0024, 0x0aaa },
>>> + { 0x80124, 0x0003 },
>>> +};
>>> +
>>> +static const struct venus_resources msm8939_res = {
>>> + .freq_tbl = msm8939_freq_table,
>>> + .freq_tbl_size = ARRAY_SIZE(msm8939_freq_table),
>>> + .reg_tbl = msm8939_reg_preset,
>>> + .reg_tbl_size = ARRAY_SIZE(msm8939_reg_preset),
>>> + .clks = { "core", "iface", "bus", },
>>> + .clks_num = 3,
>>> + .max_load = 489600, /* 1080p @ 60 */
>>> + .hfi_version = HFI_VERSION_1XX,
>>> + .vmem_id = VIDC_RESOURCE_NONE,
>>> + .vmem_size = 0,
>>> + .vmem_addr = 0,
>>> + .dma_mask = 0xddc0 - 1,
>>> + .fwname = "qcom/venus-1.8/venus.mdt",
>>> +};
>>> +
>>>  static const struct freq_tbl msm8996_freq_table[] = {
>>>   { 1944000, 52000 }, /* 4k UHD @ 60 (decode only) */
>>>   {  972000, 52000 }, /* 4k UHD @ 30 */
>>> @@ -567,6 +599,7 @@ static const struct venus_resources sc7180_res = {
>>>
>>>  static const struct of_device_id venus_dt_match[] = {
>>>   { .compatible = "qcom,msm8916-venus", .data = &msm8916_res, },
>>> + { .compatible = "qcom,msm8939-venus", .data = &msm8939_res, },
>>>   { .compatible = "qcom,msm8996-venus", .data = &msm8996_res, },
>>>   { .compatible = "qcom,sdm845-venus", .data = &sdm845_res, },
>>>   { .compatible = "qcom,sdm845-venus-v2", .data = &sdm845_res_v2, },
>>>
>>
>> --
>> regards,
>> Stan

-- 
regards,
Stan


Re: [PATCH 2/4] scripts/checkstack.pl: Add argument to print stacks greather than value.

2020-05-07 Thread Masahiro Yamada
On Thu, Apr 30, 2020 at 9:50 PM Maninder Singh  wrote:
>
> Add arguments support to print stacks which are greater than
> argument value only.
>
> Signed-off-by: Vaneet Narang 
> Signed-off-by: Maninder Singh 
> ---
>  scripts/checkstack.pl | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
> index 412c459..8e5ef98 100755
> --- a/scripts/checkstack.pl
> +++ b/scripts/checkstack.pl
> @@ -35,7 +35,7 @@ use strict;
>  # $1 (first bracket) matches the dynamic amount of the stack growth
>  #
>  # use anything else and feel the pain ;)
> -my (@stack, $re, $dre, $x, $xs, $funcre);
> +my (@stack, $re, $dre, $x, $xs, $funcre, $min_stack);
>  {
> my $arch = shift;
> if ($arch eq "") {
> @@ -43,6 +43,11 @@ my (@stack, $re, $dre, $x, $xs, $funcre);
> chomp($arch);
> }
>
> +   $min_stack = shift;
> +   if ($min_stack eq "" || $min_stack !~ /^\d+$/) {
> +   $min_stack = 100;
> +   }
> +
> $x  = "[0-9a-f]";   # hex character
> $xs = "[0-9a-f ]";  # hex character or space
> $funcre = qr/^$x* <(.*)>:$/;
> @@ -113,7 +118,7 @@ my ($func, $file, $lastslash, $total_size, $addr, $intro);
>
>  while (my $line = ) {
> if ($line =~ m/$funcre/) {
> -   if ($total_size > 100) {
> +   if ($total_size > $min_stack) {
> push @stack, "$intro$total_size\n";
> }
>
> @@ -150,7 +155,6 @@ while (my $line = ) {
> $size += 0x8000;
> }
> next if ($size > 0x1000);
> -


This is a noise change.

You can do this in 1/4 if you want to.



> $total_size = $total_size + $size
> }
> elsif (defined $dre && $line =~ m/$dre/) {
> @@ -160,7 +164,7 @@ while (my $line = ) {
> $total_size = $total_size + $size
> }
>  }
> -if ($total_size > 100) {
> +if ($total_size > $min_stack) {
> push @stack, "$intro$total_size\n";
>  }
>
> --
> 1.9.1
>


--
Best Regards

Masahiro Yamada


[RFC PATCH 4/7] perf metricgroup: always place duration_time last

2020-05-07 Thread Ian Rogers
If a metric contains the duration_time event then the event is placed
outside of the metric's group of events. Rather than split the group,
make it so the duration_time is immediately after the group.

Signed-off-by: Ian Rogers 
---
 tools/perf/util/metricgroup.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 2356dda92a07..48d0143b4b0c 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -421,8 +421,8 @@ static void metricgroup__add_metric_weak_group(struct 
strbuf *events,
   struct expr_parse_ctx *ctx)
 {
struct hashmap_entry *cur;
-   size_t bkt, i = 0;
-   bool no_group = false;
+   size_t bkt;
+   bool no_group = true, has_duration = false;
 
hashmap__for_each_entry((&ctx->ids), cur, bkt) {
pr_debug("found event %s\n", (const char*)cur->key);
@@ -432,20 +432,20 @@ static void metricgroup__add_metric_weak_group(struct 
strbuf *events,
 * group.
 */
if (!strcmp(cur->key, "duration_time")) {
-   if (i > 0)
-   strbuf_addf(events, "}:W,");
-   strbuf_addf(events, "duration_time");
-   no_group = true;
+   has_duration = true;
continue;
}
strbuf_addf(events, "%s%s",
-   i == 0 || no_group ? "{" : ",",
+   no_group ? "{" : ",",
(const char*)cur->key);
no_group = false;
-   i++;
}
-   if (!no_group)
-   strbuf_addf(events, "}:W");
+   if (!no_group) {
+strbuf_addf(events, "}:W");
+   if (has_duration)
+   strbuf_addf(events, ",duration_time");
+   } else if (has_duration)
+   strbuf_addf(events, "duration_time");
 }
 
 static void metricgroup__add_metric_non_group(struct strbuf *events,
-- 
2.26.2.526.g744177e7f7-goog



[RFC PATCH 7/7] perf metricgroup: remove duped metric group events

2020-05-07 Thread Ian Rogers
A metric group contains multiple metrics. These metrics may use the same
events. If metrics use separate events then it leads to more
multiplexing and overall metric counts fail to sum to 100%.
Modify how metrics are associated with events so that if the events in
an earlier group satisfy the current metric, the same events are used.
A record of used events is kept and at the end of processing unnecessary
events are eliminated.

Before:
$ perf stat -a -M TopDownL1 sleep 1

 Performance counter stats for 'system wide':

   920,211,343  uops_issued.any   #  0.5 Backend_Bound  
  (16.56%)
 1,977,733,128  idq_uops_not_delivered.core 
(16.56%)
51,668,510  int_misc.recovery_cycles
  (16.56%)
   732,305,692  uops_retired.retire_slots   
  (16.56%)
 1,497,621,849  cycles  
  (16.56%)
   721,098,274  uops_issued.any   #  0.1 Bad_Speculation
  (16.79%)
 1,332,681,791  cycles  
  (16.79%)
   552,475,482  uops_retired.retire_slots   
  (16.79%)
47,708,340  int_misc.recovery_cycles
  (16.79%)
 1,383,713,292  cycles
  #  0.4 Frontend_Bound 
  (16.76%)
 2,013,757,701  idq_uops_not_delivered.core 
(16.76%)
 1,373,363,790  cycles
  #  0.1 Retiring   
  (33.54%)
   577,302,589  uops_retired.retire_slots   
  (33.54%)
   392,766,987  inst_retired.any  #  0.3 IPC
  (50.24%)
 1,351,873,350  cpu_clk_unhalted.thread 
  (50.24%)
 1,332,510,318  cycles
  # 5330041272.0 SLOTS  
  (49.90%)

   1.006336145 seconds time elapsed

After:
$ perf stat -a -M TopDownL1 sleep 1

 Performance counter stats for 'system wide':

   765,949,145  uops_issued.any   #  0.1 Bad_Speculation
  #  0.5 Backend_Bound  
  (50.09%)
 1,883,830,591  idq_uops_not_delivered.core #  0.3 Frontend_Bound   
(50.09%)
48,237,080  int_misc.recovery_cycles
  (50.09%)
   581,798,385  uops_retired.retire_slots #  0.1 Retiring   
  (50.09%)
 1,361,628,527  cycles
  # 5446514108.0 SLOTS  
  (50.09%)
   391,415,714  inst_retired.any  #  0.3 IPC
  (49.91%)
 1,336,486,781  cpu_clk_unhalted.thread 
  (49.91%)

   1.005469298 seconds time elapsed

Note: Bad_Speculation + Backend_Bound + Frontend_Bound + Retiring = 100%
after, where as before it is 110%. After there are 2 groups, whereas
before there are 6. After the cycles event appears once, before it
appeared 5 times.

Signed-off-by: Ian Rogers 
---
 tools/perf/util/metricgroup.c | 97 ++-
 1 file changed, 61 insertions(+), 36 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 25e3e8df6b45..8bb2aeeb70ad 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -93,44 +93,72 @@ struct egroup {
bool has_constraint;
 };
 
+/**
+ * Find a group of events in perf_evlist that correpond to those from a parsed
+ * metric expression.
+ * @perf_evlist: a list of events something like: {metric1 leader, metric1
+ * sibling, metric1 sibling}:W,duration_time,{metric2 leader, metric2 sibling,
+ * metric2 sibling}:W,duration_time
+ * @pctx: the parse context for the metric expression.
+ * @has_constraint: is there a contraint on the group of events? In which case
+ * the events won't be grouped.
+ * @metric_events: out argument, null terminated array of evsel's associated
+ * with the metric.
+ * @evlist_used: in/out argument, bitmap tracking which evlist events are used.
+ * @return the first metric event or NULL on failure.
+ */
 static struct evsel *find_evsel_group(struct evlist *perf_evlist,
  struct expr_parse_ctx *pctx,
+ bool has_constraint,
  struct evsel **metric_events,
  unsigned long *evlist_used)
 {
-   struct evsel *ev;
-   bool leader_found;
-   const size_t idnum = hashmap__size(&pctx->ids);
-   size_t i = 0;
-   int j = 0;
-   double *val_ptr;
+   struct evsel *ev, *c

[RFC PATCH 0/7] Share events between metrics

2020-05-07 Thread Ian Rogers
Metric groups contain metrics. Metrics create groups of events to
ideally be scheduled together. Often metrics refer to the same events,
for example, a cache hit and cache miss rate. Using separate event
groups means these metrics are multiplexed at different times and the
counts don't sum to 100%. More multiplexing also decreases the
accuracy of the measurement.

This change orders metrics from groups or the command line, so that
the ones with the most events are set up first. Later metrics see if
groups already provide their events, and reuse them if
possible. Unnecessary events and groups are eliminated.

RFC because:
 - without this change events within a metric may get scheduled
   together, after they may appear as part of a larger group and be
   multiplexed at different times, lowering accuracy - however, less
   multiplexing may compensate for this.
 - libbpf's hashmap is used, however, libbpf is an optional
   requirement for building perf.
 - other things I'm not thinking of.

Thanks!

Ian Rogers (7):
  perf expr: migrate expr ids table to libbpf's hashmap
  perf metricgroup: change evlist_used to a bitmap
  perf metricgroup: free metric_events on error
  perf metricgroup: always place duration_time last
  perf metricgroup: delay events string creation
  perf metricgroup: order event groups by size
  perf metricgroup: remove duped metric group events

 tools/perf/tests/expr.c   |  32 ++---
 tools/perf/tests/pmu-events.c |  22 ++--
 tools/perf/util/expr.c| 125 ++
 tools/perf/util/expr.h|  22 ++--
 tools/perf/util/expr.y|  22 +---
 tools/perf/util/metricgroup.c | 242 +-
 tools/perf/util/stat-shadow.c |  46 ---
 7 files changed, 280 insertions(+), 231 deletions(-)

-- 
2.26.2.526.g744177e7f7-goog



linux-next: Tree for May 7

2020-05-07 Thread Stephen Rothwell
Hi all,

Changes since 20200505:

My fixes tree contains:

  bbefc924d0ff ("ubsan: disable UBSAN_ALIGNMENT under COMPILE_TEST")
  7cb1d38f52b1 ("drm/msm: Fix undefined "rd_full" link error")
  41ef83a65305 ("device_cgroup: Fix RCU list debugging warning")
  d58ae1991898 ("ipmr: Add lockdep expression to ipmr_for_each_table macro")
  74ba3ef16042 ("ipmr: Fix RCU list debugging warning")

The qcom tree still had its build failure for which I reverted a commit.

The vfs tree gained a build failure for which I applied a patch.

The drm tree gained a conflict against the drm-intel-fixes tree.

The iommu tree gained a conflict against the s390 tree.

The chrome-platform tree gained a conflict against the pstore tree.

The vhost tree gained a build failure so I used the version from
next-20200505.

The akpm tree lost 8 patches that turned up elsewhere.

Non-merge commits (relative to Linus' tree): 6714
 7472 files changed, 258640 insertions(+), 104145 deletions(-)



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

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

Below is a summary of the state of the merge.

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

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

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

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

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (3c40cdb0e93e Merge branch 'linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6)
Merging fixes/master (41ef83a65305 device_cgroup: Fix RCU list debugging 
warning)
Merging kbuild-current/fixes (6a8b55ed4056 Linux 5.7-rc3)
Merging arc-current/for-curr (40db9367ec1e ARC: guard dsp early init against 
non ARCv2)
Merging arm-current/fixes (2c962369d72f ARM: 8970/1: decompressor: increase tag 
size)
Merging arm-soc-fixes/arm/fixes (f42ae4cd4cae Merge tag 
'arm-soc/for-5.7/devicetree-fixes' of https://github.com/Broadcom/stblinux into 
arm/fixes)
Merging arm64-fixes/for-next/fixes (20bf6ebaec5f arm64: hugetlb: avoid 
potential NULL dereference)
Merging m68k-current/for-linus (86cded5fc525 m68k: defconfig: Update defconfigs 
for v5.6-rc4)
Merging powerpc-fixes/fixes (5990cdee689c lib/mpi: Fix building for powerpc 
with clang)
Merging s390-fixes/fixes (6a8b55ed4056 Linux 5.7-rc3)
Merging sparc/master (57829ea46875 sparc: mm: return true,false in 
kern_addr_valid())
Merging fscrypt-current/for-stable (2b4eae95c736 fscrypt: don't evict dirty 
inodes after removing key)
Merging net/master (29ca3cdfe13b net: macsec: fix rtnl locking issue)
Merging bpf/master (81aabbb9fb7b bpf, sockmap: bpf_tcp_ingress needs to 
subtract bytes from sg.size)
Merging ipsec/master (c95c5f58b35e xfrm interface: fix oops when deleting a 
x-netns interface)
Merging netfilter/master (b959c77dac09 net: macb: fix an issue about leak 
related system resources)
Merging ipvs/master (0141317611ab Merge branch 'hns3-fixes')
Merging wireless-drivers/master (10e41f34a019 MAINTAINERS: update mt76 
reviewers)
Merging mac80211/master (4a3de90b1184 mac80211: sta_info: Add lockdep condition 
for RCU list usage)
Merging rdma-fixes/for-rc (221e97d6fb66 IB/i40iw: Remove bogus call to 
netdev_master_upper_dev_get())
Merging sound-current/for-linus (da7a8f1a8fc3 ALSA: usb-audio: add mapping for 
ASRock TRX40 Creator)
Merging sound-asoc-fixes/for-linus (f92cc2772ce0 Merge remote-tracking branch 
'asoc/for-5.7' into asoc-linus)
Merging regmap-fixes/for-linus (cef570d20922 Merge remote-tracking branch 
'regmap/for-5.7' into regmap-linus)
Merging regulator-fixes/f

[RFC PATCH 3/7] perf metricgroup: free metric_events on error

2020-05-07 Thread Ian Rogers
Avoid a simple memory leak.

Signed-off-by: Ian Rogers 
---
 tools/perf/util/metricgroup.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index dcd175c05872..2356dda92a07 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -185,6 +185,7 @@ static int metricgroup__setup_events(struct list_head 
*groups,
if (!evsel) {
pr_debug("Cannot resolve %s: %s\n",
eg->metric_name, eg->metric_expr);
+   free(metric_events);
continue;
}
for (i = 0; metric_events[i]; i++)
@@ -192,11 +193,13 @@ static int metricgroup__setup_events(struct list_head 
*groups,
me = metricgroup__lookup(metric_events_list, evsel, true);
if (!me) {
ret = -ENOMEM;
+   free(metric_events);
break;
}
expr = malloc(sizeof(struct metric_expr));
if (!expr) {
ret = -ENOMEM;
+   free(metric_events);
break;
}
expr->metric_expr = eg->metric_expr;
-- 
2.26.2.526.g744177e7f7-goog



[RFC PATCH 6/7] perf metricgroup: order event groups by size

2020-05-07 Thread Ian Rogers
When adding event groups to the group list, insert them in size order.
This performs an insertion sort on the group list. By placing the
largest groups at the front of the group list it is possible to see if a
larger group contains the same events as a later group. This can make
the later group redundant - it can reuse the events from the large group.
A later patch will add this sharing.

Signed-off-by: Ian Rogers 
---
 tools/perf/util/metricgroup.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 0a00c0f87872..25e3e8df6b45 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -519,7 +519,21 @@ static int __metricgroup__add_metric(struct list_head 
*group_list,
return -EINVAL;
}
 
-   list_add_tail(&eg->nd, group_list);
+   if (list_empty(group_list))
+   list_add(&eg->nd, group_list);
+   else {
+   struct list_head *pos;
+
+   /* Place the largest groups at the front. */
+   list_for_each_prev(pos, group_list) {
+   struct egroup *old = list_entry(pos, struct egroup, nd);
+
+   if (hashmap__size(&eg->pctx.ids) <=
+   hashmap__size(&old->pctx.ids))
+   break;
+   }
+   list_add(&eg->nd, pos);
+   }
 
return 0;
 }
-- 
2.26.2.526.g744177e7f7-goog



[RFC PATCH 5/7] perf metricgroup: delay events string creation

2020-05-07 Thread Ian Rogers
Currently event groups are placed into groups_list at the same time as
the events string containing the events is built. Separate these two
operations and build the groups_list first, then the event string from
the groups_list. This adds an ability to reorder the groups_list that
will be used in a later patch.

Signed-off-by: Ian Rogers 
---
 tools/perf/util/metricgroup.c | 38 +++
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 48d0143b4b0c..0a00c0f87872 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -90,6 +90,7 @@ struct egroup {
const char *metric_expr;
const char *metric_unit;
int runtime;
+   bool has_constraint;
 };
 
 static struct evsel *find_evsel_group(struct evlist *perf_evlist,
@@ -496,8 +497,8 @@ int __weak arch_get_runtimeparam(void)
return 1;
 }
 
-static int __metricgroup__add_metric(struct strbuf *events,
-   struct list_head *group_list, struct pmu_event *pe, int runtime)
+static int __metricgroup__add_metric(struct list_head *group_list,
+struct pmu_event *pe, int runtime)
 {
struct egroup *eg;
 
@@ -510,6 +511,7 @@ static int __metricgroup__add_metric(struct strbuf *events,
eg->metric_expr = pe->metric_expr;
eg->metric_unit = pe->unit;
eg->runtime = runtime;
+   eg->has_constraint = metricgroup__has_constraint(pe);
 
if (expr__find_other(pe->metric_expr, NULL, &eg->pctx, runtime) < 0) {
expr__ctx_clear(&eg->pctx);
@@ -517,14 +519,6 @@ static int __metricgroup__add_metric(struct strbuf *events,
return -EINVAL;
}
 
-   if (events->len > 0)
-   strbuf_addf(events, ",");
-
-   if (metricgroup__has_constraint(pe))
-   metricgroup__add_metric_non_group(events, &eg->pctx);
-   else
-   metricgroup__add_metric_weak_group(events, &eg->pctx);
-
list_add_tail(&eg->nd, group_list);
 
return 0;
@@ -535,6 +529,7 @@ static int metricgroup__add_metric(const char *metric, 
struct strbuf *events,
 {
struct pmu_events_map *map = perf_pmu__find_map(NULL);
struct pmu_event *pe;
+   struct egroup *eg;
int i, ret = -EINVAL;
 
if (!map)
@@ -553,7 +548,8 @@ static int metricgroup__add_metric(const char *metric, 
struct strbuf *events,
pr_debug("metric expr %s for %s\n", pe->metric_expr, 
pe->metric_name);
 
if (!strstr(pe->metric_expr, "?")) {
-   ret = __metricgroup__add_metric(events, 
group_list, pe, 1);
+   ret = __metricgroup__add_metric(group_list,
+   pe, 1);
} else {
int j, count;
 
@@ -564,13 +560,29 @@ static int metricgroup__add_metric(const char *metric, 
struct strbuf *events,
 * those events to group_list.
 */
 
-   for (j = 0; j < count; j++)
-   ret = __metricgroup__add_metric(events, 
group_list, pe, j);
+   for (j = 0; j < count; j++) {
+   ret = __metricgroup__add_metric(
+   group_list, pe, j);
+   }
}
if (ret == -ENOMEM)
break;
}
}
+   if (!ret) {
+   list_for_each_entry (eg, group_list, nd) {
+   if (events->len > 0)
+   strbuf_addf(events, ",");
+
+   if (eg->has_constraint) {
+   metricgroup__add_metric_non_group(events,
+ &eg->pctx);
+   } else {
+   metricgroup__add_metric_weak_group(events,
+  &eg->pctx);
+   }
+   }
+   }
return ret;
 }
 
-- 
2.26.2.526.g744177e7f7-goog



[RFC PATCH 2/7] perf metricgroup: change evlist_used to a bitmap

2020-05-07 Thread Ian Rogers
Use a bitmap rather than an array of bools.

Signed-off-by: Ian Rogers 
---
 tools/perf/util/metricgroup.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 2f92dbc05226..dcd175c05872 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -95,7 +95,7 @@ struct egroup {
 static struct evsel *find_evsel_group(struct evlist *perf_evlist,
  struct expr_parse_ctx *pctx,
  struct evsel **metric_events,
- bool *evlist_used)
+ unsigned long *evlist_used)
 {
struct evsel *ev;
bool leader_found;
@@ -105,7 +105,7 @@ static struct evsel *find_evsel_group(struct evlist 
*perf_evlist,
double *val_ptr;
 
evlist__for_each_entry (perf_evlist, ev) {
-   if (evlist_used[j++])
+   if (test_bit(j++, evlist_used))
continue;
if (hashmap__find(&pctx->ids, ev->name, (void**)&val_ptr)) {
if (!metric_events[i])
@@ -149,7 +149,7 @@ static struct evsel *find_evsel_group(struct evlist 
*perf_evlist,
j++;
}
ev = metric_events[i];
-   evlist_used[ev->idx] = true;
+   set_bit(ev->idx, evlist_used);
}
 
return metric_events[0];
@@ -165,13 +165,11 @@ static int metricgroup__setup_events(struct list_head 
*groups,
int ret = 0;
struct egroup *eg;
struct evsel *evsel;
-   bool *evlist_used;
+   unsigned long *evlist_used;
 
-   evlist_used = calloc(perf_evlist->core.nr_entries, sizeof(bool));
-   if (!evlist_used) {
-   ret = -ENOMEM;
-   return ret;
-   }
+   evlist_used = bitmap_alloc(perf_evlist->core.nr_entries);
+   if (!evlist_used)
+   return -ENOMEM;
 
list_for_each_entry (eg, groups, nd) {
struct evsel **metric_events;
@@ -209,7 +207,7 @@ static int metricgroup__setup_events(struct list_head 
*groups,
list_add(&expr->nd, &me->head);
}
 
-   free(evlist_used);
+   bitmap_free(evlist_used);
 
return ret;
 }
-- 
2.26.2.526.g744177e7f7-goog



[RFC PATCH 1/7] perf expr: migrate expr ids table to libbpf's hashmap

2020-05-07 Thread Ian Rogers
Use a hashmap between a char* string and a double* value. While bpf's
hashmap entries are size_t in size, we can't guarantee sizeof(size_t) >=
sizeof(double). Avoid a memory allocation when gathering ids by making 0.0
a special value encoded as NULL.

Suggested by Andi Kleen:
https://lore.kernel.org/lkml/20200224210308.gq160...@tassilo.jf.intel.com/
and seconded by Jiri Olsa:
https://lore.kernel.org/lkml/20200423112915.GH1136647@krava/

Signed-off-by: Ian Rogers 
---
 tools/perf/tests/expr.c   |  32 -
 tools/perf/tests/pmu-events.c |  22 +++---
 tools/perf/util/expr.c| 125 ++
 tools/perf/util/expr.h|  22 +++---
 tools/perf/util/expr.y|  22 +-
 tools/perf/util/metricgroup.c |  86 +++
 tools/perf/util/stat-shadow.c |  46 -
 7 files changed, 176 insertions(+), 179 deletions(-)

diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
index 3f742612776a..bb948226be1d 100644
--- a/tools/perf/tests/expr.c
+++ b/tools/perf/tests/expr.c
@@ -19,11 +19,9 @@ static int test(struct expr_parse_ctx *ctx, const char *e, 
double val2)
 int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
 {
const char *p;
-   const char **other;
-   double val;
-   int i, ret;
+   double val, *val_ptr;
+   int ret;
struct expr_parse_ctx ctx;
-   int num_other;
 
expr__ctx_init(&ctx);
expr__add_id(&ctx, "FOO", 1);
@@ -52,25 +50,23 @@ int test__expr(struct test *t __maybe_unused, int subtest 
__maybe_unused)
ret = expr__parse(&val, &ctx, p, 1);
TEST_ASSERT_VAL("missing operand", ret == -1);
 
+   hashmap__clear(&ctx.ids);
TEST_ASSERT_VAL("find other",
-   expr__find_other("FOO + BAR + BAZ + BOZO", "FOO", 
&other, &num_other, 1) == 0);
-   TEST_ASSERT_VAL("find other", num_other == 3);
-   TEST_ASSERT_VAL("find other", !strcmp(other[0], "BAR"));
-   TEST_ASSERT_VAL("find other", !strcmp(other[1], "BAZ"));
-   TEST_ASSERT_VAL("find other", !strcmp(other[2], "BOZO"));
-   TEST_ASSERT_VAL("find other", other[3] == NULL);
+   expr__find_other("FOO + BAR + BAZ + BOZO", "FOO", &ctx, 
1) == 0);
+   TEST_ASSERT_VAL("find other", hashmap__size(&ctx.ids) == 3);
+   TEST_ASSERT_VAL("find other", hashmap__find(&ctx.ids, "BAR", 
(void**)&val_ptr));
+   TEST_ASSERT_VAL("find other", hashmap__find(&ctx.ids, "BAZ", 
(void**)&val_ptr));
+   TEST_ASSERT_VAL("find other", hashmap__find(&ctx.ids, "BOZO", 
(void**)&val_ptr));
 
+   hashmap__clear(&ctx.ids);
TEST_ASSERT_VAL("find other",
expr__find_other("EVENT1\\,param\\=?@ + 
EVENT2\\,param\\=?@", NULL,
-  &other, &num_other, 3) == 0);
-   TEST_ASSERT_VAL("find other", num_other == 2);
-   TEST_ASSERT_VAL("find other", !strcmp(other[0], "EVENT1,param=3/"));
-   TEST_ASSERT_VAL("find other", !strcmp(other[1], "EVENT2,param=3/"));
-   TEST_ASSERT_VAL("find other", other[2] == NULL);
+  &ctx, 3) == 0);
+   TEST_ASSERT_VAL("find other", hashmap__size(&ctx.ids) == 2);
+   TEST_ASSERT_VAL("find other", hashmap__find(&ctx.ids, 
"EVENT1,param=3/", (void**)&val_ptr));
+   TEST_ASSERT_VAL("find other", hashmap__find(&ctx.ids, 
"EVENT2,param=3/", (void**)&val_ptr));
 
-   for (i = 0; i < num_other; i++)
-   zfree(&other[i]);
-   free((void *)other);
+   expr__ctx_clear(&ctx);
 
return 0;
 }
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index c18b9ce8cace..6ce6b8a31e1f 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -428,8 +428,6 @@ static int test_parsing(void)
struct pmu_events_map *map;
struct pmu_event *pe;
int i, j, k;
-   const char **ids;
-   int idnum;
int ret = 0;
struct expr_parse_ctx ctx;
double result;
@@ -443,13 +441,16 @@ static int test_parsing(void)
}
j = 0;
for (;;) {
+   struct hashmap_entry *cur;
+   size_t bkt;
+
pe = &map->table[j++];
if (!pe->name && !pe->metric_group && !pe->metric_name)
break;
if (!pe->metric_expr)
continue;
-   if (expr__find_other(pe->metric_expr, NULL,
-   &ids, &idnum, 0) < 0) {
+   if (expr__find_other(pe->metric_expr, NULL, &ctx, 0)
+ < 0) {
pr_debug("Parse other failed for map %s %s 
%s\n",
map->cpuid, map->version, map->type);
pr_debug("On metric %s\n", pe->metric_name);
@@ -464,1

  1   2   3   4   5   6   7   8   9   10   >