Re: [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy

2020-08-07 Thread Greg KH
On Fri, Aug 07, 2020 at 05:33:53PM -0700, Chris Lew wrote:
> Hi Greg,
> 
> On 8/7/2020 12:59 AM, Greg KH wrote:
> > On Wed, Jun 24, 2020 at 10:15:19PM +0530, Deepak Kumar Singh wrote:
> > > From: Chris Lew 
> > > 
> > > In RPMSG GLINK the chrdev device will allocate an ept as part of the
> > > rpdev creation. This device will not register endpoint ops even though
> > > it has an allocated ept. Protect against the case where the device is
> > > being destroyed.
> > > 
> > > Signed-off-by: Chris Lew 
> > > Signed-off-by: Deepak Kumar Singh 
> > > Signed-off-by: Arun Kumar Neelakantam 
> > 
> > Should this be marked for stable kernels?
> > 
> > And if so, what commit does this fix?  Any reason the Fixes: tag was not
> > used here?
> > 
> 
> The crash that this fixes doesn't show up unless one of the previous patches
> in the series is applied.
> 
> [PATCH V6 3/5] rpmsg: glink: Add support for rpmsg glink chrdev
> 
> I'm not sure if the fixes tag should apply to this change or one of the
> commits to the base rpmsg code.

That's a different series, why not merge this patch with that one so
there is no need for a fix if none of this has been merged yet?

> > And what happened to this series?  I don't see it in linux-next, did the
> > maintainer ignore it?
> > 
> 
> I believe most of the review feedback for the series has been addressed by
> Deepak. There is one remaining action item for me and Deepak to provide more
> concrete evidence that the first patch in the series is needed.
> 
> [PATCH V6 1/5] rpmsg: glink: Use complete_all for open states

Ok, thanks, just didn't want to see this get forgotten...

greg k-h


Re: [RFC PATCH 4/7] core/metricfs: expose softirq information through metricfs

2020-08-07 Thread Greg KH
On Fri, Aug 07, 2020 at 02:29:13PM -0700, Jonathan Adams wrote:
> Add metricfs support for displaying percpu softirq counters.  The
> top directory is /sys/kernel/debug/metricfs/softirq.  Then there
> is a subdirectory for each softirq type.  For example:
> 
> cat /sys/kernel/debug/metricfs/softirq/NET_RX/values
> 
> Signed-off-by: Jonathan Adams 
> 
> ---
> 
> jwad...@google.com: rebased to 5.8-pre6
>   This is work originally done by another engineer at
>   google, who would rather not have their name associated with this
>   patchset. They're okay with me sending it under my name.
> ---
>  kernel/softirq.c | 45 +
>  1 file changed, 45 insertions(+)
> 
> diff --git a/kernel/softirq.c b/kernel/softirq.c
> index c4201b7f42b1..1ae3a540b789 100644
> --- a/kernel/softirq.c
> +++ b/kernel/softirq.c
> @@ -25,6 +25,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #define CREATE_TRACE_POINTS
>  #include 
> @@ -738,3 +740,46 @@ unsigned int __weak arch_dynirq_lower_bound(unsigned int 
> from)
>  {
>   return from;
>  }
> +
> +#ifdef CONFIG_METRICFS
> +
> +#define METRICFS_ITEM(name) \
> +static void \
> +metricfs_##name(struct metric_emitter *e, int cpu) \
> +{ \
> + int64_t v = kstat_softirqs_cpu(name##_SOFTIRQ, cpu); \
> + METRIC_EMIT_PERCPU_INT(e, cpu, v); \
> +} \
> +METRIC_EXPORT_PERCPU_COUNTER(name, #name " softirq", metricfs_##name)
> +
> +METRICFS_ITEM(HI);
> +METRICFS_ITEM(TIMER);
> +METRICFS_ITEM(NET_TX);
> +METRICFS_ITEM(NET_RX);
> +METRICFS_ITEM(BLOCK);
> +METRICFS_ITEM(IRQ_POLL);
> +METRICFS_ITEM(TASKLET);
> +METRICFS_ITEM(SCHED);
> +METRICFS_ITEM(HRTIMER);
> +METRICFS_ITEM(RCU);
> +
> +static int __init init_softirq_metricfs(void)
> +{
> + struct metricfs_subsys *subsys;
> +
> + subsys = metricfs_create_subsys("softirq", NULL);
> + metric_init_HI(subsys);
> + metric_init_TIMER(subsys);
> + metric_init_NET_TX(subsys);
> + metric_init_NET_RX(subsys);
> + metric_init_BLOCK(subsys);
> + metric_init_IRQ_POLL(subsys);
> + metric_init_TASKLET(subsys);
> + metric_init_SCHED(subsys);
> + metric_init_RCU(subsys);
> +
> + return 0;
> +}
> +module_init(init_softirq_metricfs);

I like the "simple" ways these look, and think you will be better off
just adding this type of api to debugfs.  That way people can use them
anywhere they currently use debugfs.

But note, we already have simple ways of exporting single variable data
in debugfs, so why do we need yet-another-macro for them?

thanks,

greg k-h


Re: [PATCH v1 1/2] kunit: tool: fix running kunit_tool from outside kernel tree

2020-08-07 Thread David Gow
On Sat, Aug 8, 2020 at 9:17 AM Brendan Higgins
 wrote:
>
> Currently kunit_tool does not work correctly when executed from a path
> outside of the kernel tree, so make sure that the current working
> directory is correct and the kunit_dir is properly initialized before
> running.
>
> Signed-off-by: Brendan Higgins 
> ---
>  tools/testing/kunit/kunit.py | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
> index 425ef40067e7..96344a11ff1f 100755
> --- a/tools/testing/kunit/kunit.py
> +++ b/tools/testing/kunit/kunit.py
> @@ -237,9 +237,14 @@ def main(argv, linux=None):
>
> cli_args = parser.parse_args(argv)
>
> +   if get_kernel_root_path():
> +   print('cd ' + get_kernel_root_path())
Do we want to print this, or is it a leftover debug statement?


> +   os.chdir(get_kernel_root_path())
> +
> if cli_args.subcommand == 'run':
> if not os.path.exists(cli_args.build_dir):
> os.mkdir(cli_args.build_dir)
> +   create_default_kunitconfig()
Why are we adding this everywhere when it's already in config_tests,
which should already be called in all of the places where a
kunitconfig is required?
Is the goal to always copy the default kunitconfig when creating a new
build_dir? While I can sort-of see why we might want to do that, if
the build dir doesn't exist, most of the subcommands will fail anyway
(maybe we should only create the build-dir for 'config' and 'run'?)


>
> if not linux:
> linux = kunit_kernel.LinuxSourceTree()
> @@ -257,6 +262,7 @@ def main(argv, linux=None):
> if cli_args.build_dir:
> if not os.path.exists(cli_args.build_dir):
> os.mkdir(cli_args.build_dir)
> +   create_default_kunitconfig()
>
> if not linux:
> linux = kunit_kernel.LinuxSourceTree()
> @@ -273,6 +279,7 @@ def main(argv, linux=None):
> if cli_args.build_dir:
> if not os.path.exists(cli_args.build_dir):
> os.mkdir(cli_args.build_dir)
> +   create_default_kunitconfig()
>
> if not linux:
> linux = kunit_kernel.LinuxSourceTree()
> @@ -291,6 +298,7 @@ def main(argv, linux=None):
> if cli_args.build_dir:
> if not os.path.exists(cli_args.build_dir):
> os.mkdir(cli_args.build_dir)
> +   create_default_kunitconfig()
>
> if not linux:
> linux = kunit_kernel.LinuxSourceTree()
>
> base-commit: 30185b69a2d533c4ba6ca926b8390ce7de495e29
> --
> 2.28.0.236.gb10cc79966-goog
>


Re: [RFC PATCH 3/7] core/metricfs: metric for kernel warnings

2020-08-07 Thread Greg KH
On Fri, Aug 07, 2020 at 02:29:12PM -0700, Jonathan Adams wrote:
> Count kernel warnings by function name of the caller.
> 
> Each time WARN() is called, which includes WARN_ON(), increment a counter
> in a 256-entry hash table. The table key is the entry point of the calling
> function, which is found using kallsyms.

Why is this needed?

As systems seem to like to reboot when WARN() is called, will this only
ever show 1?  :)

> 
> We store the name of the function in the table (because it may be a
> module address); reporting the metric just walks the table and prints
> the values.
> 
> The "warnings" metric is cumulative.

If you are creating specific files in a specific location that people
can rely on, shouldn't they show up in Documentation/ABI/ as well?

But again, is this feature something that anyone really needs/wants?
What can the number of warnings show you?

thanks,

greg k-h


Re: [RFC PATCH 2/7] core/metricfs: add support for percpu metricfs files

2020-08-07 Thread Greg KH
On Fri, Aug 07, 2020 at 02:29:11PM -0700, Jonathan Adams wrote:
> Add a simple mechanism for exporting percpu data through metricfs.
> The API follows the existing metricfs pattern.  A percpu file is
> defined with:
> 
> METRIC_EXPORT_PERCPU_INT(name, desc, fn)
> METRIC_EXPORT_PERCPU_COUNTER(name, desc, fn)
> 
> The first defines a file for exposing a percpu int.  The second is
> similar, but is for a counter that accumulates since boot.  The
> 'name' is used as the metricfs file.  The 'desc' is a description
> of the metric.  The 'fn' is a callback function to emit a single
> percpu value:
> 
> void (*fn)(struct metric_emitter *e, int cpu);
> 
> The callback must call METRIC_EMIT_PERCPU_INT with the value for
> the specified CPU.
> 
> Signed-off-by: Jonathan Adams 
> 
> ---
> 
> jwad...@google.com: rebased to 5.6-pre6, renamed funcs to start with
>   metric_.  This is work originally done by another engineer at
>   google, who would rather not have their name associated with this
>   patchset. They're okay with me sending it under my name.
> ---
>  include/linux/metricfs.h | 28 +++
>  kernel/metricfs.c| 58 

fs/metricfs/ ?  This isn't a kernel "core" feature.

Or just put it in fs/debugfs/ and tack it along with one of the debugfs
helper functions to make it easier for everyone to use these (if they
actually are valuable.  It's hard to see how this differs from any other
debugfs interface today.

thanks,

greg k-h


Re: [RFC PATCH 1/7] core/metricfs: Create metricfs, standardized files under debugfs.

2020-08-07 Thread Greg KH
debugfs interaction nits:

On Fri, Aug 07, 2020 at 02:29:10PM -0700, Jonathan Adams wrote:
> +static struct dentry *metricfs_init_dentry(void)
> +{
> + static int once;
> +
> + if (d_metricfs)
> + return d_metricfs;
> +
> + if (!debugfs_initialized())
> + return NULL;
> +
> + d_metricfs = debugfs_create_dir("metricfs", NULL);
> +
> + if (!d_metricfs && !once) {

As it is impossible for d_metricfs to ever be NULL, why are you checking
it?

> + once = 1;
> + pr_warn("Could not create debugfs directory 'metricfs'\n");

There is a pr_warn_once I think, but again, how can this ever trigger?

> + return NULL;
> + }
> +
> + return d_metricfs;
> +}
> +
> +/* We always cast in and out to struct dentry. */
> +struct metricfs_subsys {
> + struct dentry dentry;
> +};
> +
> +static struct dentry *metricfs_create_file(const char *name,
> +mode_t mode,
> +struct dentry *parent,
> +void *data,
> +const struct file_operations *fops)
> +{
> + struct dentry *ret;
> +
> + ret = debugfs_create_file(name, mode, parent, data, fops);
> + if (!ret)
> + pr_warn("Could not create debugfs '%s' entry\n", name);

As ret can never be NULL, why check?

There is no need to ever check debugfs return values, just keep on
going, that's the design of it.

thanks,

greg k-h


Re: fs/init.c:72:8: warning: Variable 'error' is reassigned a value before the old one has been used.

2020-08-07 Thread Christoph Hellwig
On Sat, Aug 08, 2020 at 11:35:45AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
> commit: 4b7ca5014cbef51cdb99fd644eae4f3773747a05 init: add an init_chroot 
> helper
> date:   8 days ago
> compiler: hppa-linux-gcc (GCC) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> 
> cppcheck warnings: (new ones prefixed by >>)
> 
> >> fs/init.c:72:8: warning: Variable 'error' is reassigned a value before the 
> >> old one has been used. [redundantAssignment]
> error = security_path_chroot();
>   ^
>fs/init.c:69:8: note: Variable 'error' is reassigned a value before the 
> old one has been used.
> error = -EPERM;
>   ^
>fs/init.c:72:8: note: Variable 'error' is reassigned a value before the 
> old one has been used.
> error = security_path_chroot();

I really don't understand the warning.  We assign a value to error, if
there is an error we jump the out labe and return it, or else continue.

That is a pretty common pattern in the kernel.  What do I miss?

> 
> vim +/error +72 fs/init.c
> 
> 57
> 58int __init init_chroot(const char *filename)
> 59{
> 60struct path path;
> 61int error;
> 62
> 63error = kern_path(filename, LOOKUP_FOLLOW | 
> LOOKUP_DIRECTORY, );
> 64if (error)
> 65return error;
> 66error = inode_permission(path.dentry->d_inode, MAY_EXEC 
> | MAY_CHDIR);
> 67if (error)
> 68goto dput_and_out;
> 69error = -EPERM;
> 70if (!ns_capable(current_user_ns(), CAP_SYS_CHROOT))
> 71goto dput_and_out;
>   > 72error = security_path_chroot();
> 73if (error)
> 74goto dput_and_out;
> 75set_fs_root(current->fs, );
> 76dput_and_out:
> 77path_put();
> 78return error;
> 79}
> 80
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
---end quoted text---


drivers/usb/core/devio.c:1155 do_proc_control() error: copy_from_user() 'tbuf' too small (4096 vs 8192)

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   049eb096da48db0421dd5e358b9b082a1a8a2025
commit: c17536d0abde2fd24afca542e3bb73b45a299633 usb: usbfs: stop using 
compat_alloc_user_space
date:   2 weeks ago
config: nds32-randconfig-m031-20200808 (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

smatch warnings:
drivers/usb/core/devio.c:1155 do_proc_control() error: copy_from_user() 'tbuf' 
too small (4096 vs 8192)

vim +/tbuf +1155 drivers/usb/core/devio.c

  1104  
  1105  static int do_proc_control(struct usb_dev_state *ps,
  1106  struct usbdevfs_ctrltransfer *ctrl)
  1107  {
  1108  struct usb_device *dev = ps->dev;
  1109  unsigned int tmo;
  1110  unsigned char *tbuf;
    unsigned wLength;
  1112  int i, pipe, ret;
  1113  
  1114  ret = check_ctrlrecip(ps, ctrl->bRequestType, ctrl->bRequest,
  1115ctrl->wIndex);
  1116  if (ret)
  1117  return ret;
  1118  wLength = ctrl->wLength;/* To suppress 64k PAGE_SIZE 
warning */
  1119  if (wLength > PAGE_SIZE)
  1120  return -EINVAL;
  1121  ret = usbfs_increase_memory_usage(PAGE_SIZE + sizeof(struct 
urb) +
  1122  sizeof(struct usb_ctrlrequest));
  1123  if (ret)
  1124  return ret;
  1125  tbuf = (unsigned char *)__get_free_page(GFP_KERNEL);
  1126  if (!tbuf) {
  1127  ret = -ENOMEM;
  1128  goto done;
  1129  }
  1130  tmo = ctrl->timeout;
  1131  snoop(>dev, "control urb: bRequestType=%02x "
  1132  "bRequest=%02x wValue=%04x "
  1133  "wIndex=%04x wLength=%04x\n",
  1134  ctrl->bRequestType, ctrl->bRequest, ctrl->wValue,
  1135  ctrl->wIndex, ctrl->wLength);
  1136  if (ctrl->bRequestType & 0x80) {
  1137  pipe = usb_rcvctrlpipe(dev, 0);
  1138  snoop_urb(dev, NULL, pipe, ctrl->wLength, tmo, SUBMIT, 
NULL, 0);
  1139  
  1140  usb_unlock_device(dev);
  1141  i = usb_control_msg(dev, pipe, ctrl->bRequest,
  1142  ctrl->bRequestType, ctrl->wValue, 
ctrl->wIndex,
  1143  tbuf, ctrl->wLength, tmo);
  1144  usb_lock_device(dev);
  1145  snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), 
COMPLETE,
  1146tbuf, max(i, 0));
  1147  if ((i > 0) && ctrl->wLength) {
  1148  if (copy_to_user(ctrl->data, tbuf, i)) {
  1149  ret = -EFAULT;
  1150  goto done;
  1151  }
  1152  }
  1153  } else {
  1154  if (ctrl->wLength) {
> 1155  if (copy_from_user(tbuf, ctrl->data, 
> ctrl->wLength)) {
  1156  ret = -EFAULT;
  1157  goto done;
  1158  }
  1159  }
  1160  pipe = usb_sndctrlpipe(dev, 0);
  1161  snoop_urb(dev, NULL, pipe, ctrl->wLength, tmo, SUBMIT,
  1162  tbuf, ctrl->wLength);
  1163  
  1164  usb_unlock_device(dev);
  1165  i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 
ctrl->bRequest,
  1166  ctrl->bRequestType, ctrl->wValue, 
ctrl->wIndex,
  1167  tbuf, ctrl->wLength, tmo);
  1168  usb_lock_device(dev);
  1169  snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), 
COMPLETE, NULL, 0);
  1170  }
  1171  if (i < 0 && i != -EPIPE) {
  1172  dev_printk(KERN_DEBUG, >dev, "usbfs: 
USBDEVFS_CONTROL "
  1173 "failed cmd %s rqt %u rq %u len %u ret %d\n",
  1174 current->comm, ctrl->bRequestType, 
ctrl->bRequest,
  1175 ctrl->wLength, i);
  1176  }
  1177  ret = i;
  1178   done:
  1179  free_page((unsigned long) tbuf);
  1180  usbfs_decrease_memory_usage(PAGE_SIZE + sizeof(struct urb) +
  1181  sizeof(struct usb_ctrlrequest));
  1182  return ret;
  1183  }
  1184  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH 1/1] kvm: mmu: zap pages when zapping only parent

2020-08-07 Thread Sean Christopherson
On Wed, Aug 05, 2020 at 08:48:03PM +0200, Paolo Bonzini wrote:
> On 05/08/20 19:10, Ben Gardon wrote:
> >>
> >> Alternatively, what about moving this logic into mmu_page_zap_pte()?  That
> >> can be done with a little massaging of FNAME(invlpg) and would avoid what 
> >> is
> >> effectively redundant checks on is_shadow_present_pte() and is_last_spte().
> >> Patches attached and somewhat tested.
> > That seems like a good change to me and the patches you attached look
> > good to me. I'm happy to review them more if you want to send them to
> > the mailing list as their own series. Thanks for putting them
> > together.
> > 
> 
> Thanks, I'll wait for that.

Sorry for the delay, been buried with internal stuff.  I'll get the series
posted on Monday.


Re: [PATCH] drivers: watchdog: rdc321x_wdt: Fix race condition bugs

2020-08-07 Thread Guenter Roeck
[ ... ]
> The R8610-G datasheet is the one that I have had and used thus far.
> 

Mine is draft version 0.2. Do you have a newer version, by any chance ?

>> Unfortunately, none of those
>> describes the use of bit(31) in the watchdog register, nor the meaning
>> of bit(12) and bit(13). Bit(31) is described in the code as "Mask",
>> and it is set by a couple of commands. I _suspect_ that bit(31) has to be
>> set to change some of the register bits, for example the counter value.
>> That is just a wild guess, but it would explain why the driver works
>> in the first place.
>>
>> It is also not clear if the bits in the counter register are accumulative
>> or if only the highest bit counts. The datasheets suggest that only the
>> highest bit counts, but then the value of RDC_CLS_TMR doesn't make much
>> sense since it sets two bits.
>>
>> Since you wrote the driver, I was hoping that you might have a datasheet
>> which explains all this in more detail.
> 
> I do not, and this was over 12 years ago, and I honestly do not recall
> all the details, when I get the board running a newish kernel, I will
> poke around.
> 
Surprise :-)

Thanks,
Guenter


Re: [git pull] regression fix in syscalls-for-init series

2020-08-07 Thread pr-tracker-bot
The pull request you sent on Sat, 8 Aug 2020 00:23:53 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git fixes

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/d57b2b5bc4301f37d1b07e3351d575bd634c7300

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


Re: [git pull] assorted vfs patches

2020-08-07 Thread pr-tracker-bot
The pull request you sent on Sat, 8 Aug 2020 00:26:27 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.misc

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/b79675e15a754ca51b9fc631e0961ccdd4ec3fc7

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


Re: [GIT PULL] power-supply changes for 5.9

2020-08-07 Thread pr-tracker-bot
The pull request you sent on Sat, 8 Aug 2020 00:59:43 +0200:

> ssh://g...@gitolite.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git
>  tags/for-v5.9

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/449dc8c97089a6e09fb2dac4d92b1b7ac0eb7c1e

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


[RFC][PATCH] pinctrl: Rework driver_deferred_probe_check_state() evaluation since default timeout has changed

2020-08-07 Thread John Stultz
In commit bec6c0ecb243 ("pinctrl: Remove use of
driver_deferred_probe_check_state_continue()"), we removed the
use of driver_deferred_probe_check_state_continue() which
effectively never returned -ETIMED_OUT, with the
driver_deferred_probe_check_state() function that had been
reworked to properly return ETIMED_OUT when the deferred probe
timeout expired. Along with that change, we set the default
timeout to 30 seconds.

However, since moving the timeout to 30 seconds caused some
issues for some users with optional dt links, we set the
default timeout back to zero - see commit ce68929f07de ("driver
core: Revert default driver_deferred_probe_timeout value to 0")

This in essence changed the behavior of the pinctrl's usage
of driver_deferred_probe_check_state(), as it now would return
ETIMED_OUT by default. Thierry reported this caused problems with
resume on tegra platforms.

Thus this patch tweaks the pinctrl logic so that it behaves as
before. If modules are enabled, we'll only return EPROBE_DEFERRED
while we're missing drivers linked in the DT.

Cc: linux...@vger.kernel.org
Cc: Greg Kroah-Hartman 
Cc: Linus Walleij 
Cc: Thierry Reding 
Cc: Mark Brown 
Cc: Liam Girdwood 
Cc: Bjorn Andersson 
Cc: Saravana Kannan 
Cc: Todd Kjos 
Cc: Len Brown 
Cc: Pavel Machek 
Cc: Ulf Hansson 
Cc: Kevin Hilman 
Cc: "Rafael J. Wysocki" 
Cc: Rob Herring 
Fixes: bec6c0ecb243 ("pinctrl: Remove use of 
driver_deferred_probe_check_state_continue()")
Fixes: ce68929f07de ("driver core: Revert default driver_deferred_probe_timeout 
value to 0")
Reported-by: Thierry Reding 
Signed-off-by: John Stultz 
---
 drivers/pinctrl/devicetree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index c6fe7d64c913..09ddf567ccb4 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -129,9 +129,8 @@ static int dt_to_map_one_config(struct pinctrl *p,
if (!np_pctldev || of_node_is_root(np_pctldev)) {
of_node_put(np_pctldev);
ret = driver_deferred_probe_check_state(p->dev);
-   /* keep deferring if modules are enabled unless we've 
timed out */
-   if (IS_ENABLED(CONFIG_MODULES) && !allow_default &&
-   (ret == -ENODEV))
+   /* keep deferring if modules are enabled */
+   if (IS_ENABLED(CONFIG_MODULES) && !allow_default)
ret = -EPROBE_DEFER;
return ret;
}
-- 
2.17.1



Teo En Ming’s Guide to Upgrading Firmware and Performing Basic Configuration of Fortigate 60D Firewall Appliance

2020-08-07 Thread Turritopsis Dohrnii Teo En Ming
Subject: Teo En Ming’s Guide to Upgrading Firmware and Performing Basic 
Configuration of Fortigate 60D Firewall Appliance


Author: Mr. Turritopsis Dohrnii Teo En Ming (Targeted Individual)
Country: Singapore
Date: 8th August 2020 Saturday Singapore Time
Version: 20200808.01

INTRODUCTION


I think this is the first time I have prepared a PDF manual with not 
only screenshots and photos, but text explanation as well. In the past, 
I have prepared lots of PDF manuals with only screenshots and photos and 
without any text explanation. You can search for all of my PDF manuals 
on my blogs. The links to my RAID 1 mirroring redundant blogs are:


https://tdtemcerts.blogspot.sg
https://tdtemcerts.wordpress.com

I placed an order for my SGD$157 refurbished Fortigate 60D firewall 
appliance on 1st August 2020 Saturday at 7:47 PM Singapore Time. The 
seller is in Japan. I must say that FedEx international shipping from 
Japan to Singapore is very fast. I received my Fortigate 60D firewall 
appliance in Singapore on 4th August 2020 Tuesday at 12 noon Singapore 
Time. It took only 4 days for my Fortigate 60D to be shipped from Japan 
to Singapore.


Fortigate firewall appliances are based on the Linux Kernel and open 
source software.


Redundant Google Drive download links for Teo En Ming's PDF Manual:

[1] 
https://drive.google.com/file/d/1PBjobvMhLzWysT2snEysF1TDeDtAWW4M/view?usp=sharing


[2] 
https://drive.google.com/file/d/1z_Mii63vJfVCRONvPz3uRnp8u11ZYqNK/view?usp=sharing


[3] 
https://drive.google.com/file/d/1aSreo6WndsQR3Ph6eCxJopVwYev0XVNh/view?usp=sharing


[4] 
https://drive.google.com/file/d/1oIYdOuvVeWDk9HEyLd-davkRoyOO92os/view?usp=sharing


[5] 
https://drive.google.com/file/d/1sGFq8GycVe0_5fCHRnBad4sM2WYiqgwK/view?usp=sharing


[6] 
https://drive.google.com/file/d/1Xn6gnhapo6hNcwrSUM9oTpXrLNaLdH2j/view?usp=sharing


I will be performing advanced configuration of my Fortigate 60D firewall 
soon. Do check out my blogs in the future.







--
-BEGIN EMAIL SIGNATURE-

The Gospel for all Targeted Individuals (TIs):

[The New York Times] Microwave Weapons Are Prime Suspect in Ills of
U.S. Embassy Workers

Link: 
https://www.nytimes.com/2018/09/01/science/sonic-attack-cuba-microwave.html




Singaporean Mr. Turritopsis Dohrnii Teo En Ming's Academic
Qualifications as at 14 Feb 2019 and refugee seeking attempts at the 
United Nations Refugee Agency Bangkok (21 Mar 2017), in Taiwan (5 Aug 
2019) and Australia (25 Dec 2019 to 9 Jan 2020):


[1] https://tdtemcerts.wordpress.com/

[2] https://tdtemcerts.blogspot.sg/

[3] https://www.scribd.com/user/270125049/Teo-En-Ming

-END EMAIL SIGNATURE-


[Linux-kernel-mentees] [PATCH net] Bluetooth: Fix NULL pointer dereference in amp_read_loc_assoc_final_data()

2020-08-07 Thread Peilin Ye
Prevent amp_read_loc_assoc_final_data() from dereferencing `mgr` as NULL.

Reported-and-tested-by: syzbot+f4fb0eaafdb51c32a...@syzkaller.appspotmail.com
Fixes: 9495b2ee757f ("Bluetooth: AMP: Process Chan Selected event")
Signed-off-by: Peilin Ye 
---
 net/bluetooth/amp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index 9c711f0dfae3..be2d469d6369 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -297,6 +297,9 @@ void amp_read_loc_assoc_final_data(struct hci_dev *hdev,
struct hci_request req;
int err;
 
+   if (!mgr)
+   return;
+
cp.phy_handle = hcon->handle;
cp.len_so_far = cpu_to_le16(0);
cp.max_len = cpu_to_le16(hdev->amp_assoc_size);
-- 
2.25.1



Re: [PATCH v2] i2c: iproc: fix race between client unreg and isr

2020-08-07 Thread Dhananjay Phadke
On 8/7/2020, Florian Fainelli wrote:
> > When i2c client unregisters, synchronize irq before setting
> > iproc_i2c->slave to NULL.
> > 
> > (1) disable_irq()
> > (2) Mask event enable bits in control reg
> > (3) Erase slave address (avoid further writes to rx fifo)
> > (4) Flush tx and rx FIFOs
> > (5) Clear pending event (interrupt) bits in status reg
> > (6) enable_irq()
> > (7) Set client pointer to NULL
> > 
> 
> > @@ -1091,6 +1091,17 @@ static int bcm_iproc_i2c_unreg_slave(struct 
> > i2c_client *slave)
> > tmp &= ~BIT(S_CFG_EN_NIC_SMB_ADDR3_SHIFT);
> > iproc_i2c_wr_reg(iproc_i2c, S_CFG_SMBUS_ADDR_OFFSET, tmp);
> >  
> > +   /* flush TX/RX FIFOs */
> > +   tmp = (BIT(S_FIFO_RX_FLUSH_SHIFT) | BIT(S_FIFO_TX_FLUSH_SHIFT));
> > +   iproc_i2c_wr_reg(iproc_i2c, S_FIFO_CTRL_OFFSET, tmp);
> > +
> > +   /* clear all pending slave interrupts */
> > +   iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, ISR_MASK_SLAVE);
> > +
> > +   enable_irq(iproc_i2c->irq);
> > +
> > +   iproc_i2c->slave = NULL;
> 
> There is nothing that checks on iproc_i2c->slave being valid within the
> interrupt handler, we assume that the pointer is valid which is fin,
> however non functional it may be, it may feel more natural to move the
> assignment before the enable_irq()?

As far as the teardown sequence ensures no more interrupts arrive after
enable_irq() and they are enabled only after setting pointer during
client register(); checking for NULL in ISR isn't necessary. 

If The teardown sequence doesn't guarantee quiescing of interrupts,
setting NULL before or after enable_irq() is equally vulnerable.

Dhananjay



drivers/usb/gadget/legacy/hid.c:196:11-12: ERROR: invalid reference to the index variable of the iterator on line 145

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: df8df5e4bc37e39010cfdf5d50cf726fe08aae5b usb: get rid of 'choice' for 
legacy gadget drivers
date:   5 months ago
config: i386-randconfig-c003-20200807 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


coccinelle warnings: (new ones prefixed by >>)

>> drivers/usb/gadget/legacy/hid.c:196:11-12: ERROR: invalid reference to the 
>> index variable of the iterator on line 145

vim +196 drivers/usb/gadget/legacy/hid.c

71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  130  
c94e289f195e0e drivers/usb/gadget/legacy/hid.c Arnd Bergmann 
2015-04-11  131  static int hid_bind(struct usb_composite_dev *cdev)
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  132  {
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  133struct usb_gadget *gadget = cdev->gadget;
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  134struct list_head *tmp;
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  135struct hidg_func_node *n, *m;
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  136struct f_hid_opts *hid_opts;
ed9cbda63d4563 drivers/usb/gadget/hid.cSebastian Andrzej Siewior 
2012-09-10  137int status, funcs = 0;
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  138  
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  139list_for_each(tmp, _func_list)
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  140funcs++;
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  141  
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  142if (!funcs)
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  143return -ENODEV;
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  144  
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06 @145list_for_each_entry(n, _func_list, node) {
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  146n->fi = usb_get_function_instance("hid");
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  147if (IS_ERR(n->fi)) {
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  148status = PTR_ERR(n->fi);
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  149goto put;
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  150}
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  151hid_opts = container_of(n->fi, struct 
f_hid_opts, func_inst);
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  152hid_opts->subclass = n->func->subclass;
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  153hid_opts->protocol = n->func->protocol;
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  154hid_opts->report_length = n->func->report_length;
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  155hid_opts->report_desc_length = 
n->func->report_desc_length;
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  156hid_opts->report_desc = n->func->report_desc;
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  157}
4bc8a33f240797 drivers/usb/gadget/legacy/hid.c Andrzej Pietrasiewicz 
2014-11-06  158  
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  159  
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  160/* Allocate string descriptor numbers ... note that 
string
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  161 * contents can be overridden by the composite_dev glue.
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  162 */
71adf118946957 drivers/usb/gadget/hid.cFabien Chouteau   
2010-04-08  163  
e1f15ccbae40b5 drivers/usb/gadget/hi

Re: [PATCH net-next v1] hinic: fix strncpy output truncated compile warnings

2020-08-07 Thread David Miller
From: "luobin (L)" 
Date: Sat, 8 Aug 2020 11:36:42 +0800

> On 2020/8/7 17:32, David Laight wrote:
>>> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>>> b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>>> index c6adc776f3c8..1ec88ebf81d6 100644
>>> --- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>>> +++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>>> @@ -342,9 +342,9 @@ static int chip_fault_show(struct devlink_fmsg *fmsg,
>>>
>>> level = event->event.chip.err_level;
>>> if (level < FAULT_LEVEL_MAX)
>>> -   strncpy(level_str, fault_level[level], 
>>> strlen(fault_level[level]));
>>> +   strncpy(level_str, fault_level[level], 
>>> strlen(fault_level[level]) + 1);
>> 
>> Have you even considered what that code is actually doing?
 ...
> I'm sorry that I haven't got what you mean and I haven't found any defects in 
> that code. Can you explain more to me?

David is trying to express the same thing I was trying to explain to
you, you should use sizeof(level_str) as the third argument because
the code is trying to make sure that the destination buffer is not
overrun.

If you use the strlen() of the source buffer, the strncpy() can still
overflow the destination buffer.

Now do you understand?


[PATCH v2 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-07 Thread Grant Feng
generate a 5ms low pulse on sdb pin when startup, then the chip
becomes more stable in the complex EM environment.

Signed-off-by: Grant Feng 
---
 drivers/leds/leds-is31fl319x.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index ca6634b8683c..5c499a5895e0 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* register numbers */
 #define IS31FL319X_SHUTDOWN0x00
@@ -61,6 +63,7 @@
 struct is31fl319x_chip {
const struct is31fl319x_chipdef *cdef;
struct i2c_client   *client;
+   struct gpio_desc*sdb_gpio;
struct regmap   *regmap;
struct mutexlock;
u32 audio_gain_db;
@@ -207,6 +210,15 @@ static int is31fl319x_parse_dt(struct device *dev,
if (!np)
return -ENODEV;
 
+   is31->sdb_gpio = devm_gpiod_get_optional(dev,
+   "sdb",
+   GPIOD_OUT_HIGH);
+   if (IS_ERR(is31->sdb_gpio)) {
+   ret = PTR_ERR(is31->sdb_gpio);
+   dev_err(dev, "Failed to get sdb gpio: %d\n", ret);
+   return ret;
+   }
+
of_dev_id = of_match_device(of_is31fl319x_match, dev);
if (!of_dev_id) {
dev_err(dev, "Failed to match device with supported chips\n");
@@ -350,6 +362,12 @@ static int is31fl319x_probe(struct i2c_client *client,
if (err)
goto free_mutex;
 
+   if (is31->sdb_gpio) {
+   gpiod_direction_output(is31->sdb_gpio, 0);
+   mdelay(5);
+   gpiod_direction_output(is31->sdb_gpio, 1);
+   }
+
is31->client = client;
is31->regmap = devm_regmap_init_i2c(client, _config);
if (IS_ERR(is31->regmap)) {
-- 
2.17.1




[PATCH v2 2/2] leds: Add an optional property named 'sdb-gpios'

2020-08-07 Thread Grant Feng
The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
 Documentation/devicetree/bindings/leds/leds-is31fl319x.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
index fc2603484544..e8bef4be57dc 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
@@ -16,6 +16,7 @@ Optional properties:
 - audio-gain-db : audio gain selection for external analog modulation input.
Valid values: 0 - 21, step by 3 (rounded down)
Default: 0
+- sdb-gpios : Specifier of the GPIO connected to SDB pin.
 
 Each led is represented as a sub-node of the issi,is31fl319x device.
 There can be less leds subnodes than the chip can support but not more.
@@ -44,6 +45,7 @@ fancy_leds: leds@65 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x65>;
+   sdb-gpios = < 11 GPIO_ACTIVE_HIGH>;
 
red_aux: led@1 {
label = "red:aux";
-- 
2.17.1




Re: [PATCH net-next v1] hinic: fix strncpy output truncated compile warnings

2020-08-07 Thread luobin (L)
On 2020/8/7 17:32, David Laight wrote:
> From: Luo bin
>> Sent: 07 August 2020 03:09
>>
>> fix the compile warnings of 'strncpy' output truncated before
>> terminating nul copying N bytes from a string of the same length
>>
>> Signed-off-by: Luo bin 
>> Reported-by: kernel test robot 
>> ---
>> V0~V1:
>> - use the strlen()+1 pattern consistently
>>
>>  drivers/net/ethernet/huawei/hinic/hinic_devlink.c | 8 
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>> b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>> index c6adc776f3c8..1ec88ebf81d6 100644
>> --- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>> +++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>> @@ -342,9 +342,9 @@ static int chip_fault_show(struct devlink_fmsg *fmsg,
>>
>>  level = event->event.chip.err_level;
>>  if (level < FAULT_LEVEL_MAX)
>> -strncpy(level_str, fault_level[level], 
>> strlen(fault_level[level]));
>> +strncpy(level_str, fault_level[level], 
>> strlen(fault_level[level]) + 1);
> 
> Have you even considered what that code is actually doing?
> 
>   David
> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 
> 1PT, UK
> Registration No: 1397386 (Wales)
> 
> .
> 
I'm sorry that I haven't got what you mean and I haven't found any defects in 
that code. Can you explain more to me?


fs/init.c:72:8: warning: Variable 'error' is reassigned a value before the old one has been used.

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: 4b7ca5014cbef51cdb99fd644eae4f3773747a05 init: add an init_chroot helper
date:   8 days ago
compiler: hppa-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


cppcheck warnings: (new ones prefixed by >>)

>> fs/init.c:72:8: warning: Variable 'error' is reassigned a value before the 
>> old one has been used. [redundantAssignment]
error = security_path_chroot();
  ^
   fs/init.c:69:8: note: Variable 'error' is reassigned a value before the old 
one has been used.
error = -EPERM;
  ^
   fs/init.c:72:8: note: Variable 'error' is reassigned a value before the old 
one has been used.
error = security_path_chroot();
  ^

vim +/error +72 fs/init.c

57  
58  int __init init_chroot(const char *filename)
59  {
60  struct path path;
61  int error;
62  
63  error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, 
);
64  if (error)
65  return error;
66  error = inode_permission(path.dentry->d_inode, MAY_EXEC | 
MAY_CHDIR);
67  if (error)
68  goto dput_and_out;
69  error = -EPERM;
70  if (!ns_capable(current_user_ns(), CAP_SYS_CHROOT))
71  goto dput_and_out;
  > 72  error = security_path_chroot();
73  if (error)
74  goto dput_and_out;
75  set_fs_root(current->fs, );
76  dput_and_out:
77  path_put();
78  return error;
79  }
80  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


Hello

2020-08-07 Thread Jennifer
Hello
My name is Jenifer Alex
Please reply, so that we can know more better 
and share photos,
Thank you.


Re: [PATCH v11 0/6] KASAN-KUnit Integration

2020-08-07 Thread David Gow
On Fri, Aug 7, 2020 at 9:15 PM 'Andrey Konovalov' via kasan-dev
 wrote:
>
> On Wed, Aug 5, 2020 at 6:29 AM David Gow  wrote:
> >
> > This patchset contains everything needed to integrate KASAN and KUnit.
> >
> > KUnit will be able to:
> > (1) Fail tests when an unexpected KASAN error occurs
> > (2) Pass tests when an expected KASAN error occurs
> >
> > Convert KASAN tests to KUnit with the exception of copy_user_test
> > because KUnit is unable to test those.
> >
> > Add documentation on how to run the KASAN tests with KUnit and what to
> > expect when running these tests.
> >
> > This patchset depends on:
> > - "kunit: extend kunit resources API" [1]
> >  - This is included in the KUnit 5.9-rci pull request[8]
> >
> > I'd _really_ like to get this into 5.9 if possible: we also have some
> > other changes which depend on some things here.
>
> Found a small issue in patch #3, but otherwise:
>
> Tested-by: Andrey Konovalov 
>
> for the series.

Cheers! The issue in #3 looks to be a rebase issue: I'll send a fixed
version out soon.
>
> The patches apply cleanly on top of the latest linux-next/akpm branch.
>
> There are some tests that fail for tag-based mode, but those are
> unrelated to this series, and require KASAN improvements.
>
Do you think it's worth disabling these tests if tag-based mode is
disabled? Personally, I'm leaning "no", but if the planned support for
explicitly skipping tests existed, this could be a good case for it: a
test which is expected to fail due to a feature not existing in the
current config.

Thanks,
-- David

> >
> > Changes from v10:
> >  - Fixed some whitespace issues in patch 2.
> >  - Split out the renaming of the KUnit test suite into a separate patch.
> >
> > Changes from v9:
> >  - Rebased on top of linux-next (20200731) + kselftest/kunit and [7]
> >  - Note that the kasan_rcu_uaf test has not been ported to KUnit, and
> >remains in test_kasan_module. This is because:
> >(a) KUnit's expect failure will not check if the RCU stacktraces
> >show.
> >(b) KUnit is unable to link the failure to the test, as it occurs in
> >an RCU callback.
> >
> > Changes from v8:
> >  - Rebased on top of kselftest/kunit
> >  - (Which, with this patchset, should rebase cleanly on 5.8-rc7)
> >  - Renamed the KUnit test suite, config name to patch the proposed
> >naming guidelines for KUnit tests[6]
> >
> > Changes from v7:
> >  - Rebased on top of kselftest/kunit
> >  - Rebased on top of v4 of the kunit resources API[1]
> >  - Rebased on top of v4 of the FORTIFY_SOURCE fix[2,3,4]
> >  - Updated the Kconfig entry to support KUNIT_ALL_TESTS
> >
> > Changes from v6:
> >  - Rebased on top of kselftest/kunit
> >  - Rebased on top of Daniel Axtens' fix for FORTIFY_SOURCE
> >incompatibilites [2]
> >  - Removed a redundant report_enabled() check.
> >  - Fixed some places with out of date Kconfig names in the
> >documentation.
> >
> > Changes from v5:
> >  - Split out the panic_on_warn changes to a separate patch.
> >  - Fix documentation to fewer to the new Kconfig names.
> >  - Fix some changes which were in the wrong patch.
> >  - Rebase on top of kselftest/kunit (currently identical to 5.7-rc1)
> >
> > Changes from v4:
> >  - KASAN no longer will panic on errors if both panic_on_warn and
> >kasan_multishot are enabled.
> >  - As a result, the KASAN tests will no-longer disable panic_on_warn.
> >  - This also means panic_on_warn no-longer needs to be exported.
> >  - The use of temporary "kasan_data" variables has been cleaned up
> >somewhat.
> >  - A potential refcount/resource leak should multiple KASAN errors
> >appear during an assertion was fixed.
> >  - Some wording changes to the KASAN test Kconfig entries.
> >
> > Changes from v3:
> >  - KUNIT_SET_KASAN_DATA and KUNIT_DO_EXPECT_KASAN_FAIL have been
> >  combined and included in KUNIT_DO_EXPECT_KASAN_FAIL() instead.
> >  - Reordered logic in kasan_update_kunit_status() in report.c to be
> >  easier to read.
> >  - Added comment to not use the name "kasan_data" for any kunit tests
> >  outside of KUNIT_EXPECT_KASAN_FAIL().
> >
> > Changes since v2:
> >  - Due to Alan's changes in [1], KUnit can be built as a module.
> >  - The name of the tests that could not be run with KUnit has been
> >  changed to be more generic: test_kasan_module.
> >  - Documentation on how to run the new KASAN tests and what to expect
> >  when running them has been added.
> >  - Some variables and functions are now static.
> >  - Now save/restore panic_on_warn in a similar way to kasan_multi_shot
> >  and renamed the init/exit functions to be more generic to accommodate.
> >  - Due to [4] in kasan_strings, kasan_memchr, and
> >  kasan_memcmp will fail if CONFIG_AMD_MEM_ENCRYPT is enabled so return
> >  early and print message explaining this circumstance.
> >  - Changed preprocessor checks to C checks where applicable.
> >
> > Changes since v1:
> >  - Make use of Alan Maguire's suggestion to use his patch that allows

Re: [PATCH] ubi: check kthread_should_stop() after the setting of task state

2020-08-07 Thread Zhihao Cheng

在 2020/8/8 3:29, Richard Weinberger 写道:

On Fri, Aug 7, 2020 at 4:18 AM Zhihao Cheng  wrote:



Maybe it's just me being dense and in need for a vacation. ;-)

I have quite a few ubi/ubifs patches in pending list, may you 
comment/check them before 5.9 ending please? thanks. \( ̄▽ ̄)


For example:

https://patchwork.ozlabs.org/project/linux-mtd/patch/20200601091037.3794172-2-chengzhih...@huawei.com/

https://patchwork.ozlabs.org/project/linux-mtd/patch/20200602112410.660785-1-chengzhih...@huawei.com/

https://patchwork.ozlabs.org/project/linux-mtd/cover/20200616071146.2607061-1-chengzhih...@huawei.com/



Re: [GIT PULL] tracing: Updates for 5.9

2020-08-07 Thread pr-tracker-bot
The pull request you sent on Fri, 7 Aug 2020 17:28:04 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git 
> trace-v5.9

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/32663c78c10f80df90b832de0428a6cb98a64e9a

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


Re: [GIT PULL] PCI changes for v5.9

2020-08-07 Thread pr-tracker-bot
The pull request you sent on Fri, 7 Aug 2020 17:04:53 -0500:

> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git 
> tags/pci-v5.9-changes

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/049eb096da48db0421dd5e358b9b082a1a8a2025

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


drivers/dma/pl330.c:2981:9: warning: Identical condition 'ret', second condition is always false

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: a39cddc9e3775100100a4272feed64faac831be9 dmaengine: pl330: Drop 
boilerplate code for suspend/resume
date:   8 months ago
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


cppcheck warnings: (new ones prefixed by >>)

>> drivers/dma/pl330.c:2981:9: warning: Identical condition 'ret', second 
>> condition is always false [identicalConditionAfterEarlyExit]
return ret;
   ^
   drivers/dma/pl330.c:2976:6: note: first condition
if (ret)
^
   drivers/dma/pl330.c:2981:9: note: second condition
return ret;
   ^
>> drivers/dma/pl330.c:2798:23: warning: Variable 'desc->rqcfg.brst_len' is 
>> reassigned a value before the old one has been used. [redundantAssignment]
desc->rqcfg.brst_len = get_burst_len(desc, len);
 ^
   drivers/dma/pl330.c:2796:24: note: Variable 'desc->rqcfg.brst_len' is 
reassigned a value before the old one has been used.
 desc->rqcfg.brst_len = 1;
  ^
   drivers/dma/pl330.c:2798:23: note: Variable 'desc->rqcfg.brst_len' is 
reassigned a value before the old one has been used.
desc->rqcfg.brst_len = get_burst_len(desc, len);
 ^

vim +/ret +2981 drivers/dma/pl330.c

42bc9cf45939c2 Boojin Kim  2011-09-02  2753  
b3040e40675ec2 Jassi Brar  2010-05-23  2754  static struct 
dma_async_tx_descriptor *
b3040e40675ec2 Jassi Brar  2010-05-23  2755  
pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
b3040e40675ec2 Jassi Brar  2010-05-23  2756 dma_addr_t src, 
size_t len, unsigned long flags)
b3040e40675ec2 Jassi Brar  2010-05-23  2757  {
b3040e40675ec2 Jassi Brar  2010-05-23  2758 struct dma_pl330_desc 
*desc;
b3040e40675ec2 Jassi Brar  2010-05-23  2759 struct dma_pl330_chan 
*pch = to_pchan(chan);
f5636854f3fcee Maninder Singh  2015-05-26  2760 struct pl330_dmac 
*pl330;
b3040e40675ec2 Jassi Brar  2010-05-23  2761 int burst;
b3040e40675ec2 Jassi Brar  2010-05-23  2762  
4e0e6109a1cc18 Rob Herring 2011-07-25  2763 if (unlikely(!pch || 
!len))
b3040e40675ec2 Jassi Brar  2010-05-23  2764 return NULL;
b3040e40675ec2 Jassi Brar  2010-05-23  2765  
f5636854f3fcee Maninder Singh  2015-05-26  2766 pl330 = pch->dmac;
f5636854f3fcee Maninder Singh  2015-05-26  2767  
b3040e40675ec2 Jassi Brar  2010-05-23  2768 desc = 
__pl330_prep_dma_memcpy(pch, dst, src, len);
b3040e40675ec2 Jassi Brar  2010-05-23  2769 if (!desc)
b3040e40675ec2 Jassi Brar  2010-05-23  2770 return NULL;
b3040e40675ec2 Jassi Brar  2010-05-23  2771  
b3040e40675ec2 Jassi Brar  2010-05-23  2772 desc->rqcfg.src_inc = 1;
b3040e40675ec2 Jassi Brar  2010-05-23  2773 desc->rqcfg.dst_inc = 1;
9dc5a315fe515e Lars-Peter Clausen  2014-07-06  2774 desc->rqtype = 
DMA_MEM_TO_MEM;
b3040e40675ec2 Jassi Brar  2010-05-23  2775  
b3040e40675ec2 Jassi Brar  2010-05-23  2776 /* Select max possible 
burst size */
f6f2421c0a1cb6 Lars-Peter Clausen  2014-07-06  2777 burst = 
pl330->pcfg.data_bus_width / 8;
b3040e40675ec2 Jassi Brar  2010-05-23  2778  
137bd11090d89b Jon Medhurst2014-11-07  2779 /*
137bd11090d89b Jon Medhurst2014-11-07  2780  * Make sure we use a 
burst size that aligns with all the memcpy
137bd11090d89b Jon Medhurst2014-11-07  2781  * parameters because 
our DMA programming algorithm doesn't cope with
137bd11090d89b Jon Medhurst2014-11-07  2782  * transfers which 
straddle an entry in the DMA device's MFIFO.
137bd11090d89b Jon Medhurst2014-11-07  2783  */
137bd11090d89b Jon Medhurst2014-11-07  2784 while ((src | dst | 
len) & (burst - 1))
b3040e40675ec2 Jassi Brar  2010-05-23  2785 burst /= 2;
b3040e40675ec2 Jassi Brar  2010-05-23  2786  
b3040e40675ec2 Jassi Brar  2010-05-23  2787 desc->rqcfg.brst_size = 
0;
b3040e40675ec2 Jassi Brar  2010-05-23  2788 while (burst != (1 << 
desc->rqcfg.brst_size))
b3040e40675ec2 Jassi Brar  2010-05-23  2789 
desc->rqcfg.brst_size++;
b3040e40675ec2 Jassi Brar  2010-05-23  2790  
137bd11090d89b Jon Medhurst2014-11-07  2791 /*
137bd11090d89b Jon Medhurst2014-11-07  2792  * If burst size is 
smaller than bus width then make sure we only
137bd11090d89b Jon Medhurst2014-11-07  2793  * transfer one at a 
time to avoid a burst stradling an MFIFO entry.
137bd11090d89b Jon Medhurst2014-11-07  2794  */
137bd11090d89b Jon Medhurst2014-11-07  2795 if 
(desc->rqcfg.brst_size * 8 < pl330->pcfg.data_bus_width)

[RESEND v7, PATCH 0/7] add drm support for MT8183

2020-08-07 Thread Yongqiang Niu
This series are based on 5.8-rc1 and provide 7 patch
to support mediatek SOC MT8183

Change since v6
- move ddp component define into mtk_mmsys.h
- add mmsys private data to support different ic path connection
- add mt8183-mmsys.c to support 8183 path connection
- fix reviewed issue in v6

Change since v5
- fix reviewed issue in v5
base https://patchwork.kernel.org/project/linux-mediatek/list/?series=213219

Change since v4
- fix reviewed issue in v4

Change since v3
- fix reviewed issue in v3
- fix type error in v3
- fix conflict with iommu patch

Change since v2
- fix reviewed issue in v2
- add mutex node into dts file

Changes since v1:
- fix reviewed issue in v1
- add dts for mt8183 display nodes
- adjust display clock control flow in patch 22
- add vmap support for mediatek drm in patch 23
- fix page offset issue for mmap function in patch 24
- enable allow_fb_modifiers for mediatek drm in patch 25

Yongqiang Niu (7):
  dt-bindings: mediatek: add rdma_fifo_size description for mt8183
display
  drm/mediatek: move ddp component define into mtk_mmsys.h
  mtk-mmsys: add mmsys private data
  mtk-mmsys: add mt8183 mmsys support
  drm/mediatek: add fifo_size into rdma private data
  drm/mediatek: add support for mediatek SOC MT8183
  arm64: dts: add display nodes for mt8183

 .../bindings/display/mediatek/mediatek,disp.txt|  14 ++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi   |  98 
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c|  18 ++
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c   |  25 +-
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c |  47 
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h|  34 +--
 drivers/gpu/drm/mediatek/mtk_drm_drv.c |  43 
 drivers/soc/mediatek/Makefile  |   1 +
 drivers/soc/mediatek/mmsys/Makefile|   3 +
 drivers/soc/mediatek/mmsys/mt2701-mmsys.c  | 250 +++
 drivers/soc/mediatek/mmsys/mt8183-mmsys.c  | 154 
 drivers/soc/mediatek/mtk-mmsys.c   | 276 -
 include/linux/soc/mediatek/mtk-mmsys.h |  48 
 13 files changed, 749 insertions(+), 262 deletions(-)
 create mode 100644 drivers/soc/mediatek/mmsys/Makefile
 create mode 100644 drivers/soc/mediatek/mmsys/mt2701-mmsys.c
 create mode 100644 drivers/soc/mediatek/mmsys/mt8183-mmsys.c

-- 
1.8.1.1.dirty


[RESEND v7, PATCH 3/7] mtk-mmsys: add mmsys private data

2020-08-07 Thread Yongqiang Niu
the reason why split out display connection function:
1. there will more and more Mediatek Soc upstream, and the display path
connection function mtk_mmsys_ddp_mout_en, mtk_mmsys_ddp_sel_in and
mtk_mmsys_ddp_sout_sel will complicated more and more
2. many of the connection are only used in some SoC, and useless for
other SoC and not readable,
3. if we add a new SoC connection, we need check is this affect other
Soc

the reason why not apply the previous series method:
this version is more readable and clear
if go on use v6, except mt2701/mt8173/mt2712, we need add two more
private data array for mt6779 and mt6797, and the connect function
will add more if/else usecase

move current display connection function into mt2701-mmsys.c
keep mt2701/mt8173/mt2712/mt6779/mt6797 with original version
connection function
the corresponded SoC upstream member will coding these and test it
on the SoC if it is need.

Signed-off-by: Yongqiang Niu 
---
 drivers/soc/mediatek/Makefile |   1 +
 drivers/soc/mediatek/mmsys/Makefile   |   2 +
 drivers/soc/mediatek/mmsys/mt2701-mmsys.c | 250 +++
 drivers/soc/mediatek/mtk-mmsys.c  | 271 +-
 include/linux/soc/mediatek/mtk-mmsys.h|  15 ++
 5 files changed, 314 insertions(+), 225 deletions(-)
 create mode 100644 drivers/soc/mediatek/mmsys/Makefile
 create mode 100644 drivers/soc/mediatek/mmsys/mt2701-mmsys.c

diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
index 2afa7b9..b37ac2c 100644
--- a/drivers/soc/mediatek/Makefile
+++ b/drivers/soc/mediatek/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq-helper.o
 obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
 obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
 obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o
+obj-$(CONFIG_MTK_MMSYS) += mmsys/
diff --git a/drivers/soc/mediatek/mmsys/Makefile 
b/drivers/soc/mediatek/mmsys/Makefile
new file mode 100644
index 000..33b0dab
--- /dev/null
+++ b/drivers/soc/mediatek/mmsys/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-y += mt2701-mmsys.o
diff --git a/drivers/soc/mediatek/mmsys/mt2701-mmsys.c 
b/drivers/soc/mediatek/mmsys/mt2701-mmsys.c
new file mode 100644
index 000..b8e53b0
--- /dev/null
+++ b/drivers/soc/mediatek/mmsys/mt2701-mmsys.c
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (c) 2020 MediaTek Inc.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DISP_REG_CONFIG_DISP_OVL0_MOUT_EN  0x040
+#define DISP_REG_CONFIG_DISP_OVL1_MOUT_EN  0x044
+#define DISP_REG_CONFIG_DISP_OD_MOUT_EN0x048
+#define DISP_REG_CONFIG_DISP_GAMMA_MOUT_EN 0x04c
+#define DISP_REG_CONFIG_DISP_UFOE_MOUT_EN  0x050
+#define DISP_REG_CONFIG_DISP_COLOR0_SEL_IN 0x084
+#define DISP_REG_CONFIG_DISP_COLOR1_SEL_IN 0x088
+#define DISP_REG_CONFIG_DSIE_SEL_IN0x0a4
+#define DISP_REG_CONFIG_DSIO_SEL_IN0x0a8
+#define DISP_REG_CONFIG_DPI_SEL_IN 0x0ac
+#define DISP_REG_CONFIG_DISP_RDMA2_SOUT0x0b8
+#define DISP_REG_CONFIG_DISP_RDMA0_SOUT_EN 0x0c4
+#define DISP_REG_CONFIG_DISP_RDMA1_SOUT_EN 0x0c8
+#define DISP_REG_CONFIG_MMSYS_CG_CON0  0x100
+
+#define DISP_REG_CONFIG_DISP_OVL_MOUT_EN   0x030
+#define DISP_REG_CONFIG_OUT_SEL0x04c
+#define DISP_REG_CONFIG_DSI_SEL0x050
+#define DISP_REG_CONFIG_DPI_SEL0x064
+
+#define OVL0_MOUT_EN_COLOR00x1
+#define OD_MOUT_EN_RDMA0   0x1
+#define OD1_MOUT_EN_RDMA1  BIT(16)
+#define UFOE_MOUT_EN_DSI0  0x1
+#define COLOR0_SEL_IN_OVL0 0x1
+#define OVL1_MOUT_EN_COLOR10x1
+#define GAMMA_MOUT_EN_RDMA10x1
+#define RDMA0_SOUT_DPI00x2
+#define RDMA0_SOUT_DPI10x3
+#define RDMA0_SOUT_DSI10x1
+#define RDMA0_SOUT_DSI20x4
+#define RDMA0_SOUT_DSI30x5
+#define RDMA1_SOUT_DPI00x2
+#define RDMA1_SOUT_DPI10x3
+#define RDMA1_SOUT_DSI10x1
+#define RDMA1_SOUT_DSI20x4
+#define RDMA1_SOUT_DSI30x5
+#define RDMA2_SOUT_DPI00x2
+#define RDMA2_SOUT_DPI10x3
+#define RDMA2_SOUT_DSI10x1
+#define RDMA2_SOUT_DSI20x4
+#define RDMA2_SOUT_DSI30x5
+#define DPI0_SEL_IN_RDMA1  0x1
+#define DPI0_SEL_IN_RDMA2  0x3
+#define DPI1_SEL_IN_RDMA1  (0x1 << 8)
+#define DPI1_SEL_IN_RDMA2  (0x3 << 8)
+#define DSI0_SEL_IN_RDMA1 

[RESEND v7, PATCH 4/7] mtk-mmsys: add mt8183 mmsys support

2020-08-07 Thread Yongqiang Niu
add mt8183 mmsys support

Signed-off-by: Yongqiang Niu 
---
 drivers/soc/mediatek/mmsys/Makefile   |   1 +
 drivers/soc/mediatek/mmsys/mt8183-mmsys.c | 154 ++
 drivers/soc/mediatek/mtk-mmsys.c  |   1 +
 3 files changed, 156 insertions(+)
 create mode 100644 drivers/soc/mediatek/mmsys/mt8183-mmsys.c

diff --git a/drivers/soc/mediatek/mmsys/Makefile 
b/drivers/soc/mediatek/mmsys/Makefile
index 33b0dab..62cfedf 100644
--- a/drivers/soc/mediatek/mmsys/Makefile
+++ b/drivers/soc/mediatek/mmsys/Makefile
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-y += mt2701-mmsys.o
+obj-y += mt8183-mmsys.o
diff --git a/drivers/soc/mediatek/mmsys/mt8183-mmsys.c 
b/drivers/soc/mediatek/mmsys/mt8183-mmsys.c
new file mode 100644
index 000..e5170b5
--- /dev/null
+++ b/drivers/soc/mediatek/mmsys/mt8183-mmsys.c
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (c) 2020 MediaTek Inc.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DISP_OVL0_MOUT_EN  0xf00
+#define DISP_OVL0_2L_MOUT_EN   0xf04
+#define DISP_OVL1_2L_MOUT_EN   0xf08
+#define DISP_DITHER0_MOUT_EN   0xf0c
+#define DISP_PATH0_SEL_IN  0xf24
+#define DISP_DSI0_SEL_IN   0xf2c
+#define DISP_DPI0_SEL_IN   0xf30
+#define DISP_RDMA0_SOUT_SEL_IN 0xf50
+#define DISP_RDMA1_SOUT_SEL_IN 0xf54
+
+#define OVL0_MOUT_EN_OVL0_2L   BIT(4)
+#define OVL0_2L_MOUT_EN_DISP_PATH0 BIT(0)
+#define OVL1_2L_MOUT_EN_RDMA1  BIT(4)
+#define DITHER0_MOUT_IN_DSI0   BIT(0)
+#define DISP_PATH0_SEL_IN_OVL0_2L  0x1
+#define DSI0_SEL_IN_RDMA0  0x1
+#define DSI0_SEL_IN_RDMA1  0x3
+#define DPI0_SEL_IN_RDMA0  0x1
+#define DPI0_SEL_IN_RDMA1  0x2
+#define RDMA0_SOUT_COLOR0  0x1
+#define RDMA1_SOUT_DSI00x1
+
+struct mmsys_path_sel {
+   enum mtk_ddp_comp_id cur;
+   enum mtk_ddp_comp_id next;
+   u32 addr;
+   u32 val;
+};
+
+static struct mmsys_path_sel mmsys_mout_en[] = {
+   {
+   DDP_COMPONENT_OVL0, DDP_COMPONENT_OVL_2L0,
+   DISP_OVL0_MOUT_EN, OVL0_MOUT_EN_OVL0_2L,
+   },
+   {
+   DDP_COMPONENT_OVL_2L0, DDP_COMPONENT_RDMA0,
+   DISP_OVL0_2L_MOUT_EN, OVL0_2L_MOUT_EN_DISP_PATH0,
+   },
+   {
+   DDP_COMPONENT_OVL_2L1, DDP_COMPONENT_RDMA1,
+   DISP_OVL1_2L_MOUT_EN, OVL1_2L_MOUT_EN_RDMA1,
+   },
+   {
+   DDP_COMPONENT_DITHER, DDP_COMPONENT_DSI0,
+   DISP_DITHER0_MOUT_EN, DITHER0_MOUT_IN_DSI0,
+   },
+};
+
+static struct mmsys_path_sel mmsys_sel_in[] = {
+   {
+   DDP_COMPONENT_OVL_2L0, DDP_COMPONENT_RDMA0,
+   DISP_PATH0_SEL_IN, DISP_PATH0_SEL_IN_OVL0_2L,
+   },
+   {
+   DDP_COMPONENT_RDMA1, DDP_COMPONENT_DPI0,
+   DISP_DPI0_SEL_IN, DPI0_SEL_IN_RDMA1,
+   },
+};
+
+static struct mmsys_path_sel mmsys_sout_sel[] = {
+   {
+   DDP_COMPONENT_RDMA0, DDP_COMPONENT_COLOR0,
+   DISP_RDMA0_SOUT_SEL_IN, RDMA0_SOUT_COLOR0,
+   },
+};
+
+static unsigned int mtk_mmsys_ddp_mout_en(enum mtk_ddp_comp_id cur,
+ enum mtk_ddp_comp_id next,
+ unsigned int *addr)
+{
+   u32 i;
+   struct mmsys_path_sel *path;
+
+   for (i = 0; i < ARRAY_SIZE(mmsys_mout_en); i++) {
+   path = _mout_en[i];
+   if (cur == path->cur && next == path->next) {
+   *addr = path->addr;
+   return path->val;
+   }
+   }
+
+   return 0;
+}
+
+static unsigned int mtk_mmsys_ddp_sel_in(enum mtk_ddp_comp_id cur,
+enum mtk_ddp_comp_id next,
+unsigned int *addr)
+{
+   u32 i;
+   struct mmsys_path_sel *path;
+
+   for (i = 0; i < ARRAY_SIZE(mmsys_sel_in); i++) {
+   path = _sel_in[i];
+   if (cur == path->cur && next == path->next) {
+   *addr = path->addr;
+   return path->val;
+   }
+   }
+
+   return 0;
+}
+
+static void mtk_mmsys_ddp_sout_sel(void __iomem *config_regs,
+  enum mtk_ddp_comp_id cur,
+  enum mtk_ddp_comp_id next)
+{
+   u32 i;
+   u32 val = 0;
+   u32 addr = 0;
+   struct mmsys_path_sel *path;
+
+   for (i = 0; i < ARRAY_SIZE(mmsys_sout_sel); i++) {
+   path = _sout_sel[i];
+   if (cur == path->cur && next == path->next) {
+   addr = path->addr;
+   writel_relaxed(path->val, config_regs + addr);
+   return;
+   

[RESEND v7, PATCH 6/7] drm/mediatek: add support for mediatek SOC MT8183

2020-08-07 Thread Yongqiang Niu
This patch add support for mediatek SOC MT8183
1. add ovl private data
2. add rdma private data
3. add mutes private data
4. add main and external path module for crtc create

Signed-off-by: Yongqiang Niu 
---
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c  | 18 
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c |  6 
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c   | 47 
 drivers/gpu/drm/mediatek/mtk_drm_drv.c   | 43 +
 4 files changed, 114 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
index 28651bc..8cf9f3b 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
@@ -430,11 +430,29 @@ static int mtk_disp_ovl_remove(struct platform_device 
*pdev)
.fmt_rgb565_is_0 = true,
 };
 
+static const struct mtk_disp_ovl_data mt8183_ovl_driver_data = {
+   .addr = DISP_REG_OVL_ADDR_MT8173,
+   .gmc_bits = 10,
+   .layer_nr = 4,
+   .fmt_rgb565_is_0 = true,
+};
+
+static const struct mtk_disp_ovl_data mt8183_ovl_2l_driver_data = {
+   .addr = DISP_REG_OVL_ADDR_MT8173,
+   .gmc_bits = 10,
+   .layer_nr = 2,
+   .fmt_rgb565_is_0 = true,
+};
+
 static const struct of_device_id mtk_disp_ovl_driver_dt_match[] = {
{ .compatible = "mediatek,mt2701-disp-ovl",
  .data = _ovl_driver_data},
{ .compatible = "mediatek,mt8173-disp-ovl",
  .data = _ovl_driver_data},
+   { .compatible = "mediatek,mt8183-disp-ovl",
+ .data = _ovl_driver_data},
+   { .compatible = "mediatek,mt8183-disp-ovl-2l",
+ .data = _ovl_2l_driver_data},
{},
 };
 MODULE_DEVICE_TABLE(of, mtk_disp_ovl_driver_dt_match);
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c 
b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
index 794acc5..51f2a0c 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
@@ -355,11 +355,17 @@ static int mtk_disp_rdma_remove(struct platform_device 
*pdev)
.fifo_size = SZ_8K,
 };
 
+static const struct mtk_disp_rdma_data mt8183_rdma_driver_data = {
+   .fifo_size = 5 * SZ_1K,
+};
+
 static const struct of_device_id mtk_disp_rdma_driver_dt_match[] = {
{ .compatible = "mediatek,mt2701-disp-rdma",
  .data = _rdma_driver_data},
{ .compatible = "mediatek,mt8173-disp-rdma",
  .data = _rdma_driver_data},
+   { .compatible = "mediatek,mt8183-disp-rdma",
+ .data = _rdma_driver_data},
{},
 };
 MODULE_DEVICE_TABLE(of, mtk_disp_rdma_driver_dt_match);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c 
b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
index 014c1bb..60788c1 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
@@ -15,6 +15,8 @@
 
 #define MT2701_DISP_MUTEX0_MOD00x2c
 #define MT2701_DISP_MUTEX0_SOF00x30
+#define MT8183_DISP_MUTEX0_MOD00x30
+#define MT8183_DISP_MUTEX0_SOF00x2c
 
 #define DISP_REG_MUTEX_EN(n)   (0x20 + 0x20 * (n))
 #define DISP_REG_MUTEX(n)  (0x24 + 0x20 * (n))
@@ -25,6 +27,18 @@
 
 #define INT_MUTEX  BIT(1)
 
+#define MT8183_MUTEX_MOD_DISP_RDMA00
+#define MT8183_MUTEX_MOD_DISP_RDMA11
+#define MT8183_MUTEX_MOD_DISP_OVL0 9
+#define MT8183_MUTEX_MOD_DISP_OVL0_2L  10
+#define MT8183_MUTEX_MOD_DISP_OVL1_2L  11
+#define MT8183_MUTEX_MOD_DISP_WDMA012
+#define MT8183_MUTEX_MOD_DISP_COLOR0   13
+#define MT8183_MUTEX_MOD_DISP_CCORR0   14
+#define MT8183_MUTEX_MOD_DISP_AAL0 15
+#define MT8183_MUTEX_MOD_DISP_GAMMA0   16
+#define MT8183_MUTEX_MOD_DISP_DITHER0  17
+
 #define MT8173_MUTEX_MOD_DISP_OVL0 11
 #define MT8173_MUTEX_MOD_DISP_OVL1 12
 #define MT8173_MUTEX_MOD_DISP_RDMA013
@@ -74,6 +88,10 @@
 #define MUTEX_SOF_DSI2 5
 #define MUTEX_SOF_DSI3 6
 
+#define MT8183_MUTEX_SOF_DPI0  2
+#define MT8183_MUTEX_EOF_DSI0  (MUTEX_SOF_DSI0 << 6)
+#define MT8183_MUTEX_EOF_DPI0  (MT8183_MUTEX_SOF_DPI0 << 6)
+
 
 struct mtk_disp_mutex {
int id;
@@ -153,6 +171,20 @@ struct mtk_ddp {
[DDP_COMPONENT_WDMA1] = MT8173_MUTEX_MOD_DISP_WDMA1,
 };
 
+static const unsigned int mt8183_mutex_mod[DDP_COMPONENT_ID_MAX] = {
+   [DDP_COMPONENT_AAL0] = MT8183_MUTEX_MOD_DISP_AAL0,
+   [DDP_COMPONENT_CCORR] = MT8183_MUTEX_MOD_DISP_CCORR0,
+   [DDP_COMPONENT_COLOR0] = MT8183_MUTEX_MOD_DISP_COLOR0,
+   [DDP_COMPONENT_DITHER] = MT8183_MUTEX_MOD_DISP_DITHER0,
+   [DDP_COMPONENT_GAMMA] = MT8183_MUTEX_MOD_DISP_GAMMA0,
+   [DDP_COMPONENT_OVL0] = MT8183_MUTEX_MOD_DISP_OVL0,
+   [DDP_COMPONENT_OVL_2L0] = MT8183_MUTEX_MOD_DISP_OVL0_2L,
+   

[RESEND v7, PATCH 1/7] dt-bindings: mediatek: add rdma_fifo_size description for mt8183 display

2020-08-07 Thread Yongqiang Niu
rdma fifo size may be different even in same SOC, add this
property to the corresponding rdma

Change-Id: I67635ec7f3f59cf4cbc7737285e5e28ff0ab71c9
Signed-off-by: Yongqiang Niu 
---
 .../devicetree/bindings/display/mediatek/mediatek,disp.txt | 14 ++
 1 file changed, 14 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt 
b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
index b91e709..e6bbe32 100644
--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
@@ -66,6 +66,11 @@ Required properties (DMA function blocks):
   argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
   for details.
 
+Optional properties (RDMA function blocks):
+- mediatek,rdma_fifo_size: rdma fifo size may be different even in same SOC, 
add this
+  property to the corresponding rdma
+  the value is the Max value which defined in hardware data sheet.
+
 Examples:
 
 mmsys: clock-controller@1400 {
@@ -207,3 +212,12 @@ od@14023000 {
power-domains = < MT8173_POWER_DOMAIN_MM>;
clocks = < CLK_MM_DISP_OD>;
 };
+
+rdma1: rdma@1400c000 {
+   compatible = "mediatek,mt8183-disp-rdma";
+   reg = <0 0x1400c000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_RDMA1>;
+   mediatek,rdma_fifo_size = <2048>;
+};
-- 
1.8.1.1.dirty


[RESEND v7, PATCH 2/7] drm/mediatek: move ddp component define into mtk_mmsys.h

2020-08-07 Thread Yongqiang Niu
mmsys is the driver which control the routing of these ddp component,
so the definition of mtk_ddp_comp_id should be placed in mtk-mmsys.h

Signed-off-by: Yongqiang Niu 
---
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 34 +
 drivers/soc/mediatek/mtk-mmsys.c|  4 +---
 include/linux/soc/mediatek/mtk-mmsys.h  | 33 
 3 files changed, 35 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h 
b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
index debe363..161201f 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
@@ -7,6 +7,7 @@
 #define MTK_DRM_DDP_COMP_H
 
 #include 
+#include 
 
 struct device;
 struct device_node;
@@ -35,39 +36,6 @@ enum mtk_ddp_comp_type {
MTK_DDP_COMP_TYPE_MAX,
 };
 
-enum mtk_ddp_comp_id {
-   DDP_COMPONENT_AAL0,
-   DDP_COMPONENT_AAL1,
-   DDP_COMPONENT_BLS,
-   DDP_COMPONENT_CCORR,
-   DDP_COMPONENT_COLOR0,
-   DDP_COMPONENT_COLOR1,
-   DDP_COMPONENT_DITHER,
-   DDP_COMPONENT_DPI0,
-   DDP_COMPONENT_DPI1,
-   DDP_COMPONENT_DSI0,
-   DDP_COMPONENT_DSI1,
-   DDP_COMPONENT_DSI2,
-   DDP_COMPONENT_DSI3,
-   DDP_COMPONENT_GAMMA,
-   DDP_COMPONENT_OD0,
-   DDP_COMPONENT_OD1,
-   DDP_COMPONENT_OVL0,
-   DDP_COMPONENT_OVL_2L0,
-   DDP_COMPONENT_OVL_2L1,
-   DDP_COMPONENT_OVL1,
-   DDP_COMPONENT_PWM0,
-   DDP_COMPONENT_PWM1,
-   DDP_COMPONENT_PWM2,
-   DDP_COMPONENT_RDMA0,
-   DDP_COMPONENT_RDMA1,
-   DDP_COMPONENT_RDMA2,
-   DDP_COMPONENT_UFOE,
-   DDP_COMPONENT_WDMA0,
-   DDP_COMPONENT_WDMA1,
-   DDP_COMPONENT_ID_MAX,
-};
-
 struct mtk_ddp_comp;
 struct cmdq_pkt;
 struct mtk_ddp_comp_funcs {
diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c
index a55f255..36ad66b 100644
--- a/drivers/soc/mediatek/mtk-mmsys.c
+++ b/drivers/soc/mediatek/mtk-mmsys.c
@@ -5,13 +5,11 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
 
-#include "../../gpu/drm/mediatek/mtk_drm_ddp.h"
-#include "../../gpu/drm/mediatek/mtk_drm_ddp_comp.h"
-
 #define DISP_REG_CONFIG_DISP_OVL0_MOUT_EN  0x040
 #define DISP_REG_CONFIG_DISP_OVL1_MOUT_EN  0x044
 #define DISP_REG_CONFIG_DISP_OD_MOUT_EN0x048
diff --git a/include/linux/soc/mediatek/mtk-mmsys.h 
b/include/linux/soc/mediatek/mtk-mmsys.h
index 7bab5d9..2228bf6 100644
--- a/include/linux/soc/mediatek/mtk-mmsys.h
+++ b/include/linux/soc/mediatek/mtk-mmsys.h
@@ -9,6 +9,39 @@
 enum mtk_ddp_comp_id;
 struct device;
 
+enum mtk_ddp_comp_id {
+   DDP_COMPONENT_AAL0,
+   DDP_COMPONENT_AAL1,
+   DDP_COMPONENT_BLS,
+   DDP_COMPONENT_CCORR,
+   DDP_COMPONENT_COLOR0,
+   DDP_COMPONENT_COLOR1,
+   DDP_COMPONENT_DITHER,
+   DDP_COMPONENT_DPI0,
+   DDP_COMPONENT_DPI1,
+   DDP_COMPONENT_DSI0,
+   DDP_COMPONENT_DSI1,
+   DDP_COMPONENT_DSI2,
+   DDP_COMPONENT_DSI3,
+   DDP_COMPONENT_GAMMA,
+   DDP_COMPONENT_OD0,
+   DDP_COMPONENT_OD1,
+   DDP_COMPONENT_OVL0,
+   DDP_COMPONENT_OVL_2L0,
+   DDP_COMPONENT_OVL_2L1,
+   DDP_COMPONENT_OVL1,
+   DDP_COMPONENT_PWM0,
+   DDP_COMPONENT_PWM1,
+   DDP_COMPONENT_PWM2,
+   DDP_COMPONENT_RDMA0,
+   DDP_COMPONENT_RDMA1,
+   DDP_COMPONENT_RDMA2,
+   DDP_COMPONENT_UFOE,
+   DDP_COMPONENT_WDMA0,
+   DDP_COMPONENT_WDMA1,
+   DDP_COMPONENT_ID_MAX,
+};
+
 void mtk_mmsys_ddp_connect(struct device *dev,
   enum mtk_ddp_comp_id cur,
   enum mtk_ddp_comp_id next);
-- 
1.8.1.1.dirty


[RESEND v7, PATCH 7/7] arm64: dts: add display nodes for mt8183

2020-08-07 Thread Yongqiang Niu
This patch add display nodes for mt8183

Signed-off-by: Yongqiang Niu 
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 98 
 1 file changed, 98 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 7b781eb..440cf22 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -31,6 +31,11 @@
i2c9 = 
i2c10 = 
i2c11 = 
+   ovl0 = 
+   ovl_2l0 = _2l0;
+   ovl_2l1 = _2l1;
+   rdma0 = 
+   rdma1 = 
};
 
cpus {
@@ -707,9 +712,102 @@
mmsys: syscon@1400 {
compatible = "mediatek,mt8183-mmsys", "syscon";
reg = <0 0x1400 0 0x1000>;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
#clock-cells = <1>;
};
 
+   ovl0: ovl@14008000 {
+   compatible = "mediatek,mt8183-disp-ovl";
+   reg = <0 0x14008000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_OVL0>;
+   };
+
+   ovl_2l0: ovl@14009000 {
+   compatible = "mediatek,mt8183-disp-ovl-2l";
+   reg = <0 0x14009000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_OVL0_2L>;
+   };
+
+   ovl_2l1: ovl@1400a000 {
+   compatible = "mediatek,mt8183-disp-ovl-2l";
+   reg = <0 0x1400a000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_OVL1_2L>;
+   };
+
+   rdma0: rdma@1400b000 {
+   compatible = "mediatek,mt8183-disp-rdma";
+   reg = <0 0x1400b000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_RDMA0>;
+   mediatek,rdma_fifo_size = <5120>;
+   };
+
+   rdma1: rdma@1400c000 {
+   compatible = "mediatek,mt8183-disp-rdma";
+   reg = <0 0x1400c000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_RDMA1>;
+   mediatek,rdma_fifo_size = <2048>;
+   };
+
+   color0: color@1400e000 {
+   compatible = "mediatek,mt8183-disp-color",
+"mediatek,mt8173-disp-color";
+   reg = <0 0x1400e000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_COLOR0>;
+   };
+
+   ccorr0: ccorr@1400f000 {
+   compatible = "mediatek,mt8183-disp-ccorr";
+   reg = <0 0x1400f000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_CCORR0>;
+   };
+
+   aal0: aal@1401 {
+   compatible = "mediatek,mt8183-disp-aal",
+"mediatek,mt8173-disp-aal";
+   reg = <0 0x1401 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_AAL0>;
+   };
+
+   gamma0: gamma@14011000 {
+   compatible = "mediatek,mt8183-disp-gamma",
+"mediatek,mt8173-disp-gamma";
+   reg = <0 0x14011000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_GAMMA0>;
+   };
+
+   dither0: dither@14012000 {
+   compatible = "mediatek,mt8183-disp-dither";
+   reg = <0 0x14012000 0 0x1000>;
+   interrupts = ;
+   power-domains = < MT8183_POWER_DOMAIN_DISP>;
+   clocks = < CLK_MM_DISP_DITHER0>;
+   };
+
+   mutex: mutex@14016000 {
+   compatible = "mediatek,mt8183-disp-mutex";
+   reg = <0 0x14016000 0 0x1000>;
+   interrupts = ;
+   

[RESEND v7, PATCH 5/7] drm/mediatek: add fifo_size into rdma private data

2020-08-07 Thread Yongqiang Niu
Get the fifo size from device tree
because each rdma in the same SoC may have different fifo size

Signed-off-by: Yongqiang Niu 
---
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c 
b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
index e04319f..794acc5 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
@@ -63,6 +63,7 @@ struct mtk_disp_rdma {
struct mtk_ddp_comp ddp_comp;
struct drm_crtc *crtc;
const struct mtk_disp_rdma_data *data;
+   u32 fifo_size;
 };
 
 static inline struct mtk_disp_rdma *comp_to_rdma(struct mtk_ddp_comp *comp)
@@ -131,12 +132,18 @@ static void mtk_rdma_config(struct mtk_ddp_comp *comp, 
unsigned int width,
unsigned int threshold;
unsigned int reg;
struct mtk_disp_rdma *rdma = comp_to_rdma(comp);
+   u32 rdma_fifo_size;
 
mtk_ddp_write_mask(cmdq_pkt, width, comp,
   DISP_REG_RDMA_SIZE_CON_0, 0xfff);
mtk_ddp_write_mask(cmdq_pkt, height, comp,
   DISP_REG_RDMA_SIZE_CON_1, 0xf);
 
+   if (rdma->fifo_size)
+   rdma_fifo_size = rdma->fifo_size;
+   else
+   rdma_fifo_size = RDMA_FIFO_SIZE(rdma);
+
/*
 * Enable FIFO underflow since DSI and DPI can't be blocked.
 * Keep the FIFO pseudo size reset default of 8 KiB. Set the
@@ -145,7 +152,7 @@ static void mtk_rdma_config(struct mtk_ddp_comp *comp, 
unsigned int width,
 */
threshold = width * height * vrefresh * 4 * 7 / 100;
reg = RDMA_FIFO_UNDERFLOW_EN |
- RDMA_FIFO_PSEUDO_SIZE(RDMA_FIFO_SIZE(rdma)) |
+ RDMA_FIFO_PSEUDO_SIZE(rdma_fifo_size) |
  RDMA_OUTPUT_VALID_FIFO_THRESHOLD(threshold);
mtk_ddp_write(cmdq_pkt, reg, comp, DISP_REG_RDMA_FIFO_CON);
 }
@@ -291,6 +298,16 @@ static int mtk_disp_rdma_probe(struct platform_device 
*pdev)
return comp_id;
}
 
+   if (of_find_property(dev->of_node, "mediatek,rdma_fifo_size", )) {
+   ret = of_property_read_u32(dev->of_node,
+  "mediatek,rdma_fifo_size",
+  >fifo_size);
+   if (ret) {
+   dev_err(dev, "Failed to get rdma fifo size\n");
+   return ret;
+   }
+   }
+
ret = mtk_ddp_comp_init(dev, dev->of_node, >ddp_comp, comp_id,
_disp_rdma_funcs);
if (ret) {
-- 
1.8.1.1.dirty


Re: [PATCH] KVM: SVM: Mark SEV launch secret pages as dirty.

2020-08-07 Thread Krish Sadhukhan



On 8/6/20 6:23 PM, Cfir Cohen wrote:

The LAUNCH_SECRET command performs encryption of the
launch secret memory contents. Mark pinned pages as
dirty, before unpinning them.
This matches the logic in sev_launch_update().

sev_launch_update_data() instead of sev_launch_update() ?


Signed-off-by: Cfir Cohen 
---
  arch/x86/kvm/svm/sev.c | 15 ++-
  1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 5573a97f1520..37c47d26b9f7 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -850,7 +850,7 @@ static int sev_launch_secret(struct kvm *kvm, struct 
kvm_sev_cmd *argp)
struct kvm_sev_launch_secret params;
struct page **pages;
void *blob, *hdr;
-   unsigned long n;
+   unsigned long n, i;
int ret, offset;
  
  	if (!sev_guest(kvm))

@@ -863,6 +863,14 @@ static int sev_launch_secret(struct kvm *kvm, struct 
kvm_sev_cmd *argp)
if (!pages)
return -ENOMEM;
  
+	/*

+* The LAUNCH_SECRET command will perform in-place encryption of the
+* memory content (i.e it will write the same memory region with C=1).
+* It's possible that the cache may contain the data with C=0, i.e.,
+* unencrypted so invalidate it first.
+*/
+   sev_clflush_pages(pages, n);
+
/*
 * The secret must be copied into contiguous memory region, lets verify
 * that userspace memory pages are contiguous before we issue command.
@@ -908,6 +916,11 @@ static int sev_launch_secret(struct kvm *kvm, struct 
kvm_sev_cmd *argp)
  e_free:
kfree(data);
  e_unpin_memory:
+   /* content of memory is updated, mark pages dirty */
+   for (i = 0; i < n; i++) {
+   set_page_dirty_lock(pages[i]);
+   mark_page_accessed(pages[i]);
+   }
sev_unpin_memory(kvm, pages, n);
return ret;
  }

Reviewed-by: Krish Sadhukhan 


RE: drivers/usb/chipidea/core.c:657 ci_usb_role_switch_set() error: double unlocked 'ci->lock' (orig line 638)

2020-08-07 Thread Jun Li
Hi,

> -Original Message-
> From: kernel test robot 
> Sent: Friday, August 7, 2020 6:00 PM
> To: Jun Li 
> Cc: kbuild-...@lists.01.org; linux-kernel@vger.kernel.org; Peter Chen
> 
> Subject: drivers/usb/chipidea/core.c:657 ci_usb_role_switch_set() error: 
> double
> unlocked 'ci->lock' (orig line 638)
> 
> tree:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel.o
> rg%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.gitdata=02%7C01%
> 7Cjun.li%40nxp.com%7Ce261827f14f6446b3e8308d83ab8c407%7C686ea1d3bc2b4c6fa92cd9
> 9c5c301635%7C0%7C0%7C637323912694699319sdata=ioDexF9tIACz%2BlnZC%2BzZsiFz
> iOeeLembxqr9PwE%2Fpgg%3Dreserved=0 master
> head:   86cfccb66937dd6cbf26ed619958b9e587e6a115
> commit: 05559f10ed797b79f7fa47313682c48919a2b111 usb: chipidea: add role 
> switch
> class support
> date:   12 months ago
> config: parisc-randconfig-m031-20200807 (attached as .config)
> compiler: hppa-linux-gcc (GCC) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> smatch warnings:
> drivers/usb/chipidea/core.c:657 ci_usb_role_switch_set() error: double 
> unlocked
> 'ci->lock' (orig line 638)
> 
> vim +657 drivers/usb/chipidea/core.c
> 
>615
>616static int ci_usb_role_switch_set(struct device *dev, enum 
> usb_role role)
>617{
>618struct ci_hdrc *ci = dev_get_drvdata(dev);
>619struct ci_hdrc_cable *cable = NULL;
>620enum usb_role current_role = ci_role_to_usb_role(ci);
>621unsigned long flags;
>622
>623if (current_role == role)
>624return 0;
>625
>626pm_runtime_get_sync(ci->dev);
>627/* Stop current role */
>628spin_lock_irqsave(>lock, flags);
>629if (current_role == USB_ROLE_DEVICE)
>630cable = >platdata->vbus_extcon;
>631else if (current_role == USB_ROLE_HOST)
>632cable = >platdata->id_extcon;
>633
>634if (cable) {
>635cable->changed = true;
>636cable->connected = false;
>637ci_irq(ci->irq, ci);
>  > 638spin_unlock_irqrestore(>lock, flags);
>639if (ci->wq && role != USB_ROLE_NONE)
>640flush_workqueue(ci->wq);
>641spin_lock_irqsave(>lock, flags);

Here we hold the lock again.

>642}
>643
>644cable = NULL;
>645
>646/* Start target role */
>647if (role == USB_ROLE_DEVICE)
>648cable = >platdata->vbus_extcon;
>649else if (role == USB_ROLE_HOST)
>650cable = >platdata->id_extcon;
>651
>652if (cable) {
>653cable->changed = true;
>654cable->connected = true;
>655ci_irq(ci->irq, ci);
>656}
>  > 657spin_unlock_irqrestore(>lock, flags);

So it's fine to unlock here.

Thanks
Li Jun
>658pm_runtime_put_sync(ci->dev);
>659
>660return 0;
>661}
>662
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01.org
> %2Fhyperkitty%2Flist%2Fkbuild-all%40lists.01.orgdata=02%7C01%7Cjun.li%40n
> xp.com%7Ce261827f14f6446b3e8308d83ab8c407%7C686ea1d3bc2b4c6fa92cd99c5c301635%7
> C0%7C0%7C637323912694709319sdata=tAxmh6eq3yT3A89mY2RrGQxwdkUN4A9r708lFQJW
> gcI%3Dreserved=0


Re: [PATCH 2/3] remoteproc: qcom: Add capability to collect minidumps

2020-08-07 Thread kernel test robot
Hi Gurbir,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20200807]
[cannot apply to linux/master linus/master v5.8 v5.8-rc7 v5.8-rc6 v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Gurbir-Arora/Introduce-mini-dump-support-for-remoteproc/20200808-073315
base:471e638c4c5df4c0035a76a561ada4d28228e5fd
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# save the attached .config to linux build tree
make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   In file included from arch/x86/include/asm/page_32.h:35,
from arch/x86/include/asm/page.h:14,
from arch/x86/include/asm/thread_info.h:12,
from include/linux/thread_info.h:38,
from arch/x86/include/asm/preempt.h:7,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/swait.h:7,
from include/linux/completion.h:12,
from drivers/remoteproc/remoteproc_coredump.c:8:
   In function 'memcpy',
   inlined from 'add_minidump_segments' at 
drivers/remoteproc/remoteproc_coredump.c:491:4,
   inlined from 'rproc_minidump' at 
drivers/remoteproc/remoteproc_coredump.c:530:10:
>> include/linux/string.h:393:4: error: call to '__write_overflow' declared 
>> with attribute error: detected write beyond size of object passed as 1st 
>> parameter
 393 |__write_overflow();
 |^~

vim +/__write_overflow +393 include/linux/string.h

6974f0c4555e28 Daniel Micay  2017-07-12  386  
6974f0c4555e28 Daniel Micay  2017-07-12  387  __FORTIFY_INLINE void 
*memcpy(void *p, const void *q, __kernel_size_t size)
6974f0c4555e28 Daniel Micay  2017-07-12  388  {
6974f0c4555e28 Daniel Micay  2017-07-12  389size_t p_size = 
__builtin_object_size(p, 0);
6974f0c4555e28 Daniel Micay  2017-07-12  390size_t q_size = 
__builtin_object_size(q, 0);
6974f0c4555e28 Daniel Micay  2017-07-12  391if (__builtin_constant_p(size)) 
{
6974f0c4555e28 Daniel Micay  2017-07-12  392if (p_size < size)
6974f0c4555e28 Daniel Micay  2017-07-12 @393
__write_overflow();
6974f0c4555e28 Daniel Micay  2017-07-12  394if (q_size < size)
6974f0c4555e28 Daniel Micay  2017-07-12  395
__read_overflow2();
6974f0c4555e28 Daniel Micay  2017-07-12  396}
6974f0c4555e28 Daniel Micay  2017-07-12  397if (p_size < size || q_size < 
size)
6974f0c4555e28 Daniel Micay  2017-07-12  398fortify_panic(__func__);
47227d27e2fcb0 Daniel Axtens 2020-06-03  399return __underlying_memcpy(p, 
q, size);
6974f0c4555e28 Daniel Micay  2017-07-12  400  }
6974f0c4555e28 Daniel Micay  2017-07-12  401  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH 00/13] MIPS: Convert Ingenic to a generic board

2020-08-07 Thread Jiaxun Yang




在 2020/8/8 上午12:45, Paul Cercueil 写道:

Hi Zhou,

Le sam. 8 août 2020 à 0:23, Zhou Yanjie  a 
écrit :

Hi Paul,

I'm not too sure if remove "cpu-feature-overrides.h" will cause some 
problems for X2000, because according to my current test on X2000, I 
found that it is somewhat different from the SoCs using XBurst1 CPU 
core, with the kernel source code provided by Ingenic, for example, 
we must configure "#define cpu_has_tlbinv 1" in 
"cpu-feature-overrides.h" to make the X2000 work normally, otherwise 
the kernel will get stuck. And X2000's interrupt controller has also 
been redesigned. If these differences make it impossible to share 
code, should we set a subdirectory of "xburst" and "xburst2" in 
"arch/mips/ingenic"? (I am just worried about this situation, so far 
I have not been able to successfully run the mainline kernel on X2000).


Hi Yanjie,

TLBINV is a optional feature. We can always invalidate TLB via rewrite 
TLB entry. If X2000 can't work

without TLBINV it means there are some thing went wrong with TLB.
You'd better investigate in detail.

Refined interrupt controller can be enabled via DeviceTree, you only 
have to write a new irqchip driver for it.


Btw: My X2000 EVB is on the way thanks to Taobao~

Thanks.



The  is kind of a hack, to hardcode settings 
in case the CPU is not properly detected. The cpu-probe.c should be 
able to auto-detect these settings, including the inverted TLB that 
the X2000 has, reading from the CPU config registers ("TLB INV" info 
should be in config4). Right now cpu_probe_ingenic() doesn't read 
config4 (not present on older SoCs) but that's trivial to add.


As for your other question, I don't see any reason why we wouldn't be 
able to support the X2000 aside the others in a generic kernel, so 
don't worry :)


Cheers,
-Paul



[PATCH v8 18/18] perf ftrace: add change log

2020-08-07 Thread Changbin Du
Add a change log after previous enhancements.

Signed-off-by: Changbin Du 
---
 tools/perf/builtin-ftrace.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 9da38dc8b542..167f1f57aba3 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -3,6 +3,7 @@
  * builtin-ftrace.c
  *
  * Copyright (c) 2013  LG Electronics,  Namhyung Kim 
+ * Copyright (c) 2020  Changbin Du , significant 
enhancement.
  */
 
 #include "builtin.h"
-- 
2.25.1



[PATCH v8 15/18] perf ftrace: add option -D/--delay to delay tracing

2020-08-07 Thread Changbin Du
This adds an option '-D/--delay' to allow us to start tracing some
times later after workload is launched.

Signed-off-by: Changbin Du 
---
 tools/perf/Documentation/perf-ftrace.txt |  4 
 tools/perf/builtin-ftrace.c  | 19 ---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 08216634d2bc..29c684b3b3fd 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -39,6 +39,10 @@ OPTIONS
 --pid=::
Trace on existing process id (comma separated list).
 
+-D::
+--delay::
+   Time (ms) to wait before starting tracing after program start.
+
 -a::
 --all-cpus::
Force system-wide collection.  Scripts run without a 
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index bc3b35d18167..5f9a9ebea0a2 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -49,6 +49,7 @@ struct perf_ftrace {
int graph_noirqs;
int graph_verbose;
int graph_thresh;
+   unsigned intinitial_delay;
 };
 
 struct filter_entry {
@@ -596,13 +597,23 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
/* display column headers */
read_tracing_file_to_stdout("trace");
 
-   if (write_tracing_file("tracing_on", "1") < 0) {
-   pr_err("can't enable tracing\n");
-   goto out_close_fd;
+   if (!ftrace->initial_delay) {
+   if (write_tracing_file("tracing_on", "1") < 0) {
+   pr_err("can't enable tracing\n");
+   goto out_close_fd;
+   }
}
 
perf_evlist__start_workload(ftrace->evlist);
 
+   if (ftrace->initial_delay) {
+   usleep(ftrace->initial_delay * 1000);
+   if (write_tracing_file("tracing_on", "1") < 0) {
+   pr_err("can't enable tracing\n");
+   goto out_close_fd;
+   }
+   }
+
while (!done) {
if (poll(, 1, -1) < 0)
break;
@@ -827,6 +838,8 @@ int cmd_ftrace(int argc, const char **argv)
 "size of per cpu buffer", parse_buffer_size),
OPT_BOOLEAN(0, "inherit", ,
"trace children processes"),
+   OPT_UINTEGER('D', "delay", _delay,
+"ms to wait before starting tracing after program start"),
OPT_END()
};
 
-- 
2.25.1



[PATCH v8 17/18] perf: ftrace: Add set_tracing_options() to set all trace options

2020-08-07 Thread Changbin Du
Now the __cmd_ftrace() becomes a bit long. This moves the trace
option setting code to a separate function set_tracing_options().

Suggested-by: Namhyung Kim 
Signed-off-by: Changbin Du 
---
 tools/perf/builtin-ftrace.c | 118 +++-
 1 file changed, 63 insertions(+), 55 deletions(-)

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 13abb737fd12..9da38dc8b542 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -465,110 +465,118 @@ static int set_tracing_thresh(struct perf_ftrace 
*ftrace)
return 0;
 }
 
-static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
+static int set_tracing_options(struct perf_ftrace *ftrace)
 {
-   char *trace_file;
-   int trace_fd;
-   char buf[4096];
-   struct pollfd pollfd = {
-   .events = POLLIN,
-   };
-
-   if (!(perf_cap__capable(CAP_PERFMON) ||
- perf_cap__capable(CAP_SYS_ADMIN))) {
-   pr_err("ftrace only works for %s!\n",
-#ifdef HAVE_LIBCAP_SUPPORT
-   "users with the CAP_PERFMON or CAP_SYS_ADMIN capability"
-#else
-   "root"
-#endif
-   );
-   return -1;
-   }
-
-   signal(SIGINT, sig_handler);
-   signal(SIGUSR1, sig_handler);
-   signal(SIGCHLD, sig_handler);
-   signal(SIGPIPE, sig_handler);
-
-   if (ftrace->list_avail_functions)
-   return 
read_tracing_file_to_stdout("available_filter_functions");
-
-   if (reset_tracing_files(ftrace) < 0) {
-   pr_err("failed to reset ftrace\n");
-   goto out;
-   }
-
-   /* reset ftrace buffer */
-   if (write_tracing_file("trace", "0") < 0)
-   goto out;
-
-   if (argc && perf_evlist__prepare_workload(ftrace->evlist,
-   >target, argv, false,
-   ftrace__workload_exec_failed_signal) < 0) {
-   goto out;
-   }
-
if (set_tracing_pid(ftrace) < 0) {
pr_err("failed to set ftrace pid\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_cpu(ftrace) < 0) {
pr_err("failed to set tracing cpumask\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_func_stack_trace(ftrace) < 0) {
pr_err("failed to set tracing option func_stack_trace\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_func_irqinfo(ftrace) < 0) {
pr_err("failed to set tracing option irq-info\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_filters(ftrace) < 0) {
pr_err("failed to set tracing filters\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_depth(ftrace) < 0) {
pr_err("failed to set graph depth\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_percpu_buffer_size(ftrace) < 0) {
pr_err("failed to set tracing per-cpu buffer size\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_trace_inherit(ftrace) < 0) {
pr_err("failed to set tracing option function-fork\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_sleep_time(ftrace) < 0) {
pr_err("failed to set tracing option sleep-time\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_funcgraph_irqs(ftrace) < 0) {
pr_err("failed to set tracing option funcgraph-irqs\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_funcgraph_verbose(ftrace) < 0) {
pr_err("failed to set tracing option 
funcgraph-proc/funcgraph-abstime\n");
-   goto out_reset;
+   return -1;
}
 
if (set_tracing_thresh(ftrace) < 0) {
pr_err("failed to set tracing thresh\n");
-   goto out_reset;
+   return -1;
+   }
+
+   return 0;
+}
+
+static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
+{
+   char *trace_file;
+   int trace_fd;
+   char buf[4096];
+   struct pollfd pollfd = {
+   .events = POLLIN,
+   };
+
+   if (!(perf_cap__capable(CAP_PERFMON) ||
+ perf_cap__capable(CAP_SYS_ADMIN))) {
+   pr_err("ftrace only works for %s!\n",
+#ifdef HAVE_LIBCAP_SUPPORT
+   "users with the CAP_PERFMON or CAP_SYS_ADMIN capability"
+#else
+   "root"
+#endif
+   );
+   return -1;
}
 
+   signal(SIGINT, sig_handler);
+   signal(SIGUSR1, sig_handler);
+   signal(SIGCHLD, sig_handler);
+   

[PATCH v8 09/18] perf ftrace: add support for trace option sleep-time

2020-08-07 Thread Changbin Du
This adds an option '--graph-opts nosleep-time' which allow us
only to measure on-CPU time. This option is function_graph tracer
only.

Signed-off-by: Changbin Du 

---
v3: switch to uniform option --graph-opts.
v2: option name '--nosleep-time' -> '--graph-nosleep-time'.
---
 tools/perf/Documentation/perf-ftrace.txt |  4 +++
 tools/perf/builtin-ftrace.c  | 41 
 2 files changed, 45 insertions(+)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 8f08ad0992c2..3380a2e2c9ad 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -101,6 +101,10 @@ OPTIONS
 --graph-depth=::
Set max depth for function graph tracer to follow
 
+--graph-opts::
+   List of options allowed to set:
+ nosleep-time - Measure on-CPU time only for function_graph tracer.
+
 SEE ALSO
 
 linkperf:perf-record[1], linkperf:perf-trace[1]
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 469b89748c42..47d63bba6a48 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -44,6 +44,7 @@ struct perf_ftrace {
unsigned long   percpu_buffer_size;
boolinherit;
int func_stack_trace;
+   int graph_nosleep_time;
 };
 
 struct filter_entry {
@@ -205,6 +206,7 @@ static void reset_tracing_options(struct perf_ftrace 
*ftrace __maybe_unused)
 {
write_tracing_option_file("function-fork", "0");
write_tracing_option_file("func_stack_trace", "0");
+   write_tracing_option_file("sleep-time", "1");
 }
 
 static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
@@ -386,6 +388,17 @@ static int set_tracing_trace_inherit(struct perf_ftrace 
*ftrace)
return 0;
 }
 
+static int set_tracing_sleep_time(struct perf_ftrace *ftrace)
+{
+   if (!ftrace->graph_nosleep_time)
+   return 0;
+
+   if (write_tracing_option_file("sleep-time", "0") < 0)
+   return -1;
+
+   return 0;
+}
+
 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
 {
char *trace_file;
@@ -465,6 +478,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
goto out_reset;
}
 
+   if (set_tracing_sleep_time(ftrace) < 0) {
+   pr_err("failed to set tracing option sleep-time\n");
+   goto out_reset;
+   }
+
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
goto out_reset;
@@ -637,6 +655,26 @@ static int parse_func_tracer_opts(const struct option *opt,
return 0;
 }
 
+static int parse_graph_tracer_opts(const struct option *opt,
+ const char *str, int unset)
+{
+   int ret;
+   struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value;
+   struct sublevel_option graph_tracer_opts[] = {
+   { .name = "nosleep-time",   .value_ptr = 
>graph_nosleep_time },
+   { .name = NULL, }
+   };
+
+   if (unset)
+   return 0;
+
+   ret = perf_parse_sublevel_options(str, graph_tracer_opts);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
 static void select_tracer(struct perf_ftrace *ftrace)
 {
bool graph = !list_empty(>graph_funcs) ||
@@ -694,6 +732,9 @@ int cmd_ftrace(int argc, const char **argv)
 "Set nograph filter on given functions", 
parse_filter_func),
OPT_INTEGER('D', "graph-depth", _depth,
"Max depth for function graph tracer"),
+   OPT_CALLBACK(0, "graph-opts", , "options",
+"graph tracer options, available options: nosleep-time",
+parse_graph_tracer_opts),
OPT_CALLBACK('m', "buffer-size", _buffer_size, "size",
 "size of per cpu buffer", parse_buffer_size),
OPT_BOOLEAN(0, "inherit", ,
-- 
2.25.1



[PATCH v8 13/18] perf ftrace: add support for trace option tracing_thresh

2020-08-07 Thread Changbin Du
This adds an option '--graph-opts thresh' to setup trace duration
threshold for funcgraph tracer.

$ sudo ./perf ftrace -G '*' --graph-opts thresh=100
 3) ! 184.060 us  |} /* schedule */
 3) ! 185.600 us  |  } /* exit_to_usermode_loop */
 2) ! 225.989 us  |} /* schedule_idle */
 2) # 4140.051 us |  } /* do_idle */

Signed-off-by: Changbin Du 
---
 tools/perf/Documentation/perf-ftrace.txt |  1 +
 tools/perf/builtin-ftrace.c  | 26 +++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index a2056aaf2ece..6fa927e5971b 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -107,6 +107,7 @@ OPTIONS
  nosleep-time - Measure on-CPU time only for function_graph tracer.
  noirqs   - Ignore functions that happen inside interrupt.
  verbose  - Show process names, PIDs, timestamps, etc.
+ thresh=   - Setup trace duration threshold in microseconds.
 
 SEE ALSO
 
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 8ee5287bd84a..ca61f8b8bbf6 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -48,6 +48,7 @@ struct perf_ftrace {
int graph_nosleep_time;
int graph_noirqs;
int graph_verbose;
+   int graph_thresh;
 };
 
 struct filter_entry {
@@ -234,6 +235,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace 
__maybe_unused)
if (write_tracing_file("max_graph_depth", "0") < 0)
return -1;
 
+   if (write_tracing_file("tracing_thresh", "0") < 0)
+   return -1;
+
reset_tracing_filters();
reset_tracing_options(ftrace);
return 0;
@@ -446,6 +450,20 @@ static int set_tracing_funcgraph_verbose(struct 
perf_ftrace *ftrace)
return 0;
 }
 
+static int set_tracing_thresh(struct perf_ftrace *ftrace)
+{
+   int ret;
+
+   if (ftrace->graph_thresh == 0)
+   return 0;
+
+   ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh);
+   if (ret < 0)
+   return ret;
+
+   return 0;
+}
+
 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
 {
char *trace_file;
@@ -545,6 +563,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
goto out_reset;
}
 
+   if (set_tracing_thresh(ftrace) < 0) {
+   pr_err("failed to set tracing thresh\n");
+   goto out_reset;
+   }
+
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
goto out_reset;
@@ -727,6 +750,7 @@ static int parse_graph_tracer_opts(const struct option *opt,
{ .name = "nosleep-time",   .value_ptr = 
>graph_nosleep_time },
{ .name = "noirqs", .value_ptr = 
>graph_noirqs },
{ .name = "verbose",.value_ptr = 
>graph_verbose },
+   { .name = "thresh", .value_ptr = 
>graph_thresh },
{ .name = NULL, }
};
 
@@ -798,7 +822,7 @@ int cmd_ftrace(int argc, const char **argv)
OPT_INTEGER('D', "graph-depth", _depth,
"Max depth for function graph tracer"),
OPT_CALLBACK(0, "graph-opts", , "options",
-"graph tracer options, available options: 
nosleep-time,noirqs,verbose",
+"graph tracer options, available options: 
nosleep-time,noirqs,verbose,thresh=",
 parse_graph_tracer_opts),
OPT_CALLBACK('m', "buffer-size", _buffer_size, "size",
 "size of per cpu buffer", parse_buffer_size),
-- 
2.25.1



[PATCH v8 14/18] perf: ftrace: allow set graph depth by '--graph-opts'

2020-08-07 Thread Changbin Du
This is to have a consistent view of all graph tracer options.
The original option '--graph-depth' is marked as deprecated.

Signed-off-by: Changbin Du 
---
 tools/perf/Documentation/perf-ftrace.txt | 5 +
 tools/perf/builtin-ftrace.c  | 5 ++---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 6fa927e5971b..08216634d2bc 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -98,16 +98,13 @@ OPTIONS
specify multiple functions. It will be passed to 'set_graph_notrace'
in tracefs.
 
--D::
---graph-depth=::
-   Set max depth for function graph tracer to follow
-
 --graph-opts::
List of options allowed to set:
  nosleep-time - Measure on-CPU time only for function_graph tracer.
  noirqs   - Ignore functions that happen inside interrupt.
  verbose  - Show process names, PIDs, timestamps, etc.
  thresh=   - Setup trace duration threshold in microseconds.
+ depth=- Set max depth for function graph tracer to follow.
 
 SEE ALSO
 
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index ca61f8b8bbf6..bc3b35d18167 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -751,6 +751,7 @@ static int parse_graph_tracer_opts(const struct option *opt,
{ .name = "noirqs", .value_ptr = 
>graph_noirqs },
{ .name = "verbose",.value_ptr = 
>graph_verbose },
{ .name = "thresh", .value_ptr = 
>graph_thresh },
+   { .name = "depth",  .value_ptr = 
>graph_depth },
{ .name = NULL, }
};
 
@@ -819,10 +820,8 @@ int cmd_ftrace(int argc, const char **argv)
 parse_filter_func),
OPT_CALLBACK('g', "nograph-funcs", _funcs, "func",
 "Set nograph filter on given functions", 
parse_filter_func),
-   OPT_INTEGER('D', "graph-depth", _depth,
-   "Max depth for function graph tracer"),
OPT_CALLBACK(0, "graph-opts", , "options",
-"graph tracer options, available options: 
nosleep-time,noirqs,verbose,thresh=",
+"graph tracer options, available options: 
nosleep-time,noirqs,verbose,thresh=,depth=",
 parse_graph_tracer_opts),
OPT_CALLBACK('m', "buffer-size", _buffer_size, "size",
 "size of per cpu buffer", parse_buffer_size),
-- 
2.25.1



[PATCH v8 11/18] perf ftrace: add support for tracing option 'irq-info'

2020-08-07 Thread Changbin Du
This adds support to display irq context info for function tracer. To do
this, just specify a '--func-opts irq-info' option.

Signed-off-by: Changbin Du 
---
 tools/perf/Documentation/perf-ftrace.txt |  1 +
 tools/perf/builtin-ftrace.c  | 21 -
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index fca55ac55ff3..37ea3ea97922 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -79,6 +79,7 @@ OPTIONS
 --func-opts::
List of options allowed to set:
  call-graph - Display kernel stack trace for function tracer.
+ irq-info   - Display irq context info for function tracer.
 
 -G::
 --graph-funcs=::
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index b4c821be4fb5..d1241febe143 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -44,6 +44,7 @@ struct perf_ftrace {
unsigned long   percpu_buffer_size;
boolinherit;
int func_stack_trace;
+   int func_irq_info;
int graph_nosleep_time;
int graph_noirqs;
 };
@@ -209,6 +210,7 @@ static void reset_tracing_options(struct perf_ftrace 
*ftrace __maybe_unused)
write_tracing_option_file("func_stack_trace", "0");
write_tracing_option_file("sleep-time", "1");
write_tracing_option_file("funcgraph-irqs", "1");
+   write_tracing_option_file("irq-info", "0");
 }
 
 static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
@@ -296,6 +298,17 @@ static int set_tracing_func_stack_trace(struct perf_ftrace 
*ftrace)
return 0;
 }
 
+static int set_tracing_func_irqinfo(struct perf_ftrace *ftrace)
+{
+   if (!ftrace->func_irq_info)
+   return 0;
+
+   if (write_tracing_option_file("irq-info", "1") < 0)
+   return -1;
+
+   return 0;
+}
+
 static int reset_tracing_cpu(void)
 {
struct perf_cpu_map *cpumap = perf_cpu_map__new(NULL);
@@ -471,6 +484,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
goto out_reset;
}
 
+   if (set_tracing_func_irqinfo(ftrace) < 0) {
+   pr_err("failed to set tracing option irq-info\n");
+   goto out_reset;
+   }
+
if (set_tracing_filters(ftrace) < 0) {
pr_err("failed to set tracing filters\n");
goto out_reset;
@@ -660,6 +678,7 @@ static int parse_func_tracer_opts(const struct option *opt,
struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value;
struct sublevel_option func_tracer_opts[] = {
{ .name = "call-graph", .value_ptr = >func_stack_trace 
},
+   { .name = "irq-info",   .value_ptr = >func_irq_info },
{ .name = NULL, }
};
 
@@ -742,7 +761,7 @@ int cmd_ftrace(int argc, const char **argv)
OPT_CALLBACK('N', "notrace-funcs", , "func",
 "do not trace given functions", parse_filter_func),
OPT_CALLBACK(0, "func-opts", , "options",
-"function tracer options, available options: call-graph",
+"function tracer options, available options: 
call-graph,irq-info",
 parse_func_tracer_opts),
OPT_CALLBACK('G', "graph-funcs", _funcs, "func",
 "trace given functions using function_graph tracer",
-- 
2.25.1



[PATCH v8 12/18] perf ftrace: add option 'verbose' to show more info for graph tracer

2020-08-07 Thread Changbin Du
Sometimes we want ftrace display more and longer information about
the trace.

$ sudo perf ftrace -G '*'
 2)   0.979 us|  mutex_unlock();
 2)   1.540 us|  __fsnotify_parent();
 2)   0.433 us|  fsnotify();

$ sudo perf ftrace -G '*' --graph-opts verbose
14160.770883 |   0)  <...>-47814   |   |   1.289 us|  mutex_unlock();
14160.770886 |   0)  <...>-47814   |   |   1.624 us|  
__fsnotify_parent();
14160.770887 |   0)  <...>-47814   |   |   0.636 us|  fsnotify();
14160.770888 |   0)  <...>-47814   |   |   0.328 us|  __sb_end_write();
14160.770888 |   0)  <...>-47814   |  d... |   0.430 us|  
fpregs_assert_state_consistent();
14160.770889 |   0)  <...>-47814   |  d... |   |  do_syscall_64() {
14160.770889 |   0)  <...>-47814   |   |   |
__x64_sys_close() {

Signed-off-by: Changbin Du 
---
 tools/perf/Documentation/perf-ftrace.txt |  1 +
 tools/perf/builtin-ftrace.c  | 29 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 37ea3ea97922..a2056aaf2ece 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -106,6 +106,7 @@ OPTIONS
List of options allowed to set:
  nosleep-time - Measure on-CPU time only for function_graph tracer.
  noirqs   - Ignore functions that happen inside interrupt.
+ verbose  - Show process names, PIDs, timestamps, etc.
 
 SEE ALSO
 
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index d1241febe143..8ee5287bd84a 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -47,6 +47,7 @@ struct perf_ftrace {
int func_irq_info;
int graph_nosleep_time;
int graph_noirqs;
+   int graph_verbose;
 };
 
 struct filter_entry {
@@ -210,6 +211,9 @@ static void reset_tracing_options(struct perf_ftrace 
*ftrace __maybe_unused)
write_tracing_option_file("func_stack_trace", "0");
write_tracing_option_file("sleep-time", "1");
write_tracing_option_file("funcgraph-irqs", "1");
+   write_tracing_option_file("funcgraph-proc", "0");
+   write_tracing_option_file("funcgraph-abstime", "0");
+   write_tracing_option_file("latency-format", "0");
write_tracing_option_file("irq-info", "0");
 }
 
@@ -425,6 +429,23 @@ static int set_tracing_funcgraph_irqs(struct perf_ftrace 
*ftrace)
return 0;
 }
 
+static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace)
+{
+   if (!ftrace->graph_verbose)
+   return 0;
+
+   if (write_tracing_option_file("funcgraph-proc", "1") < 0)
+   return -1;
+
+   if (write_tracing_option_file("funcgraph-abstime", "1") < 0)
+   return -1;
+
+   if (write_tracing_option_file("latency-format", "1") < 0)
+   return -1;
+
+   return 0;
+}
+
 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
 {
char *trace_file;
@@ -519,6 +540,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
goto out_reset;
}
 
+   if (set_tracing_funcgraph_verbose(ftrace) < 0) {
+   pr_err("failed to set tracing option 
funcgraph-proc/funcgraph-abstime\n");
+   goto out_reset;
+   }
+
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
goto out_reset;
@@ -700,6 +726,7 @@ static int parse_graph_tracer_opts(const struct option *opt,
struct sublevel_option graph_tracer_opts[] = {
{ .name = "nosleep-time",   .value_ptr = 
>graph_nosleep_time },
{ .name = "noirqs", .value_ptr = 
>graph_noirqs },
+   { .name = "verbose",.value_ptr = 
>graph_verbose },
{ .name = NULL, }
};
 
@@ -771,7 +798,7 @@ int cmd_ftrace(int argc, const char **argv)
OPT_INTEGER('D', "graph-depth", _depth,
"Max depth for function graph tracer"),
OPT_CALLBACK(0, "graph-opts", , "options",
-"graph tracer options, available options: 
nosleep-time,noirqs",
+"graph tracer options, available options: 
nosleep-time,noirqs,verbose",
 parse_graph_tracer_opts),
OPT_CALLBACK('m', "buffer-size", _buffer_size, "size",
 "size of per cpu buffer", parse_buffer_size),
-- 
2.25.1



[PATCH v8 07/18] perf: util: add general function to parse sublevel options

2020-08-07 Thread Changbin Du
This factors out a general function perf_parse_sublevel_options() to parse
sublevel options. The 'sublevel' options is something like the '--debug'
options which allow more sublevel options.

Signed-off-by: Changbin Du 

---
v2: add util/parse-sublevel-options.c
---
 tools/perf/util/Build|  1 +
 tools/perf/util/debug.c  | 61 ++---
 tools/perf/util/parse-sublevel-options.c | 70 
 tools/perf/util/parse-sublevel-options.h | 11 
 4 files changed, 99 insertions(+), 44 deletions(-)
 create mode 100644 tools/perf/util/parse-sublevel-options.c
 create mode 100644 tools/perf/util/parse-sublevel-options.h

diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 8d18380ecd10..e86607ada0b5 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -117,6 +117,7 @@ endif
 perf-y += parse-branch-options.o
 perf-y += dump-insn.o
 perf-y += parse-regs-options.o
+perf-y += parse-sublevel-options.o
 perf-y += term.o
 perf-y += help-unknown-cmd.o
 perf-y += mem-events.o
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index adb656745ecc..5cda5565777a 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -20,6 +20,7 @@
 #include "target.h"
 #include "ui/helpline.h"
 #include "ui/ui.h"
+#include "util/parse-sublevel-options.h"
 
 #include 
 
@@ -173,65 +174,37 @@ void trace_event(union perf_event *event)
 trace_event_printer, event);
 }
 
-static struct debug_variable {
-   const char *name;
-   int *ptr;
-} debug_variables[] = {
-   { .name = "verbose",.ptr =  },
-   { .name = "ordered-events", .ptr = _ordered_events},
-   { .name = "stderr", .ptr = _to_stderr},
-   { .name = "data-convert",   .ptr = _data_convert },
-   { .name = "perf-event-open",.ptr = _peo_args },
+static struct sublevel_option debug_opts[] = {
+   { .name = "verbose",.value_ptr =  },
+   { .name = "ordered-events", .value_ptr = _ordered_events},
+   { .name = "stderr", .value_ptr = _to_stderr},
+   { .name = "data-convert",   .value_ptr = _data_convert },
+   { .name = "perf-event-open",.value_ptr = _peo_args },
{ .name = NULL, }
 };
 
 int perf_debug_option(const char *str)
 {
-   struct debug_variable *var = _variables[0];
-   char *vstr, *s = strdup(str);
-   int v = 1;
-
-   vstr = strchr(s, '=');
-   if (vstr)
-   *vstr++ = 0;
-
-   while (var->name) {
-   if (!strcmp(s, var->name))
-   break;
-   var++;
-   }
-
-   if (!var->name) {
-   pr_err("Unknown debug variable name '%s'\n", s);
-   free(s);
-   return -1;
-   }
+   int ret;
 
-   if (vstr) {
-   v = atoi(vstr);
-   /*
-* Allow only values in range (0, 10),
-* otherwise set 0.
-*/
-   v = (v < 0) || (v > 10) ? 0 : v;
-   }
+   ret = perf_parse_sublevel_options(str, debug_opts);
+   if (ret)
+   return ret;
 
-   if (quiet)
-   v = -1;
+   /* Allow only verbose value in range (0, 10), otherwise set 0. */
+   verbose = (verbose < 0) || (verbose > 10) ? 0 : verbose;
 
-   *var->ptr = v;
-   free(s);
return 0;
 }
 
 int perf_quiet_option(void)
 {
-   struct debug_variable *var = _variables[0];
+   struct sublevel_option *opt = _opts[0];
 
/* disable all debug messages */
-   while (var->name) {
-   *var->ptr = -1;
-   var++;
+   while (opt->name) {
+   *opt->value_ptr = -1;
+   opt++;
}
 
return 0;
diff --git a/tools/perf/util/parse-sublevel-options.c 
b/tools/perf/util/parse-sublevel-options.c
new file mode 100644
index ..a841d17ffd57
--- /dev/null
+++ b/tools/perf/util/parse-sublevel-options.c
@@ -0,0 +1,70 @@
+#include 
+#include 
+#include 
+#include 
+
+#include "util/debug.h"
+#include "util/parse-sublevel-options.h"
+
+static int parse_one_sublevel_option(const char *str,
+struct sublevel_option *opts)
+{
+   struct sublevel_option *opt = opts;
+   char *vstr, *s = strdup(str);
+   int v = 1;
+
+   if (!s) {
+   pr_err("no memory\n");
+   return -1;
+   }
+
+   vstr = strchr(s, '=');
+   if (vstr)
+   *vstr++ = 0;
+
+   while (opt->name) {
+   if (!strcmp(s, opt->name))
+   break;
+   opt++;
+   }
+
+   if (!opt->name) {
+   pr_err("Unknown option name '%s'\n", s);
+   free(s);
+   return -1;
+   }
+
+   if (vstr)
+   v = atoi(vstr);
+
+   *opt->value_ptr = v;
+   free(s);
+   return 0;
+}
+
+/* parse options like --foo 

[PATCH v8 10/18] perf ftrace: add support for trace option funcgraph-irqs

2020-08-07 Thread Changbin Du
This adds an option '--graph-opts noirqs' to filter out functions executed
in irq context.

Signed-off-by: Changbin Du 

---
v2: option name '--nofuncgraph-irqs' -> '--graph-noirqs'.
---
 tools/perf/Documentation/perf-ftrace.txt |  1 +
 tools/perf/builtin-ftrace.c  | 21 -
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 3380a2e2c9ad..fca55ac55ff3 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -104,6 +104,7 @@ OPTIONS
 --graph-opts::
List of options allowed to set:
  nosleep-time - Measure on-CPU time only for function_graph tracer.
+ noirqs   - Ignore functions that happen inside interrupt.
 
 SEE ALSO
 
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 47d63bba6a48..b4c821be4fb5 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -45,6 +45,7 @@ struct perf_ftrace {
boolinherit;
int func_stack_trace;
int graph_nosleep_time;
+   int graph_noirqs;
 };
 
 struct filter_entry {
@@ -207,6 +208,7 @@ static void reset_tracing_options(struct perf_ftrace 
*ftrace __maybe_unused)
write_tracing_option_file("function-fork", "0");
write_tracing_option_file("func_stack_trace", "0");
write_tracing_option_file("sleep-time", "1");
+   write_tracing_option_file("funcgraph-irqs", "1");
 }
 
 static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
@@ -399,6 +401,17 @@ static int set_tracing_sleep_time(struct perf_ftrace 
*ftrace)
return 0;
 }
 
+static int set_tracing_funcgraph_irqs(struct perf_ftrace *ftrace)
+{
+   if (!ftrace->graph_noirqs)
+   return 0;
+
+   if (write_tracing_option_file("funcgraph-irqs", "0") < 0)
+   return -1;
+
+   return 0;
+}
+
 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
 {
char *trace_file;
@@ -483,6 +496,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
goto out_reset;
}
 
+   if (set_tracing_funcgraph_irqs(ftrace) < 0) {
+   pr_err("failed to set tracing option funcgraph-irqs\n");
+   goto out_reset;
+   }
+
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
goto out_reset;
@@ -662,6 +680,7 @@ static int parse_graph_tracer_opts(const struct option *opt,
struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value;
struct sublevel_option graph_tracer_opts[] = {
{ .name = "nosleep-time",   .value_ptr = 
>graph_nosleep_time },
+   { .name = "noirqs", .value_ptr = 
>graph_noirqs },
{ .name = NULL, }
};
 
@@ -733,7 +752,7 @@ int cmd_ftrace(int argc, const char **argv)
OPT_INTEGER('D', "graph-depth", _depth,
"Max depth for function graph tracer"),
OPT_CALLBACK(0, "graph-opts", , "options",
-"graph tracer options, available options: nosleep-time",
+"graph tracer options, available options: 
nosleep-time,noirqs",
 parse_graph_tracer_opts),
OPT_CALLBACK('m', "buffer-size", _buffer_size, "size",
 "size of per cpu buffer", parse_buffer_size),
-- 
2.25.1



[PATCH v8 08/18] perf ftrace: add support for tracing option 'func_stack_trace'

2020-08-07 Thread Changbin Du
This adds support to display call trace for function tracer. To do this,
just specify a '--func-opts call-graph' option.

$ sudo perf ftrace -T vfs_read --func-opts call-graph
 iio-sensor-prox-855   [003]   6168.369657: vfs_read <-ksys_read
 iio-sensor-prox-855   [003]   6168.369677: 
 => vfs_read
 => ksys_read
 => __x64_sys_read
 => do_syscall_64
 => entry_SYSCALL_64_after_hwframe
 ...

Signed-off-by: Changbin Du 

---
v3: switch to uniform option --func-opts.
v2: option name '-s' -> '--func-call-graph'
---
 tools/perf/Documentation/perf-ftrace.txt |  4 +++
 tools/perf/builtin-ftrace.c  | 42 
 2 files changed, 46 insertions(+)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index c46d0a09b38c..8f08ad0992c2 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -76,6 +76,10 @@ OPTIONS
specify multiple functions (or glob patterns).  It will be
passed to 'set_ftrace_notrace' in tracefs.
 
+--func-opts::
+   List of options allowed to set:
+ call-graph - Display kernel stack trace for function tracer.
+
 -G::
 --graph-funcs=::
Select function_graph tracer and set graph filter on the given
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 07b81d0c1658..469b89748c42 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -27,6 +27,7 @@
 #include "util/cap.h"
 #include "util/config.h"
 #include "util/units.h"
+#include "util/parse-sublevel-options.h"
 
 #define DEFAULT_TRACER  "function_graph"
 
@@ -42,6 +43,7 @@ struct perf_ftrace {
int graph_depth;
unsigned long   percpu_buffer_size;
boolinherit;
+   int func_stack_trace;
 };
 
 struct filter_entry {
@@ -202,6 +204,7 @@ static void reset_tracing_filters(void);
 static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused)
 {
write_tracing_option_file("function-fork", "0");
+   write_tracing_option_file("func_stack_trace", "0");
 }
 
 static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
@@ -278,6 +281,17 @@ static int set_tracing_cpu(struct perf_ftrace *ftrace)
return set_tracing_cpumask(cpumap);
 }
 
+static int set_tracing_func_stack_trace(struct perf_ftrace *ftrace)
+{
+   if (!ftrace->func_stack_trace)
+   return 0;
+
+   if (write_tracing_option_file("func_stack_trace", "1") < 0)
+   return -1;
+
+   return 0;
+}
+
 static int reset_tracing_cpu(void)
 {
struct perf_cpu_map *cpumap = perf_cpu_map__new(NULL);
@@ -426,6 +440,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
goto out_reset;
}
 
+   if (set_tracing_func_stack_trace(ftrace) < 0) {
+   pr_err("failed to set tracing option func_stack_trace\n");
+   goto out_reset;
+   }
+
if (set_tracing_filters(ftrace) < 0) {
pr_err("failed to set tracing filters\n");
goto out_reset;
@@ -598,6 +617,26 @@ static int parse_buffer_size(const struct option *opt,
return -1;
 }
 
+static int parse_func_tracer_opts(const struct option *opt,
+ const char *str, int unset)
+{
+   int ret;
+   struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value;
+   struct sublevel_option func_tracer_opts[] = {
+   { .name = "call-graph", .value_ptr = >func_stack_trace 
},
+   { .name = NULL, }
+   };
+
+   if (unset)
+   return 0;
+
+   ret = perf_parse_sublevel_options(str, func_tracer_opts);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
 static void select_tracer(struct perf_ftrace *ftrace)
 {
bool graph = !list_empty(>graph_funcs) ||
@@ -645,6 +684,9 @@ int cmd_ftrace(int argc, const char **argv)
 parse_filter_func),
OPT_CALLBACK('N', "notrace-funcs", , "func",
 "do not trace given functions", parse_filter_func),
+   OPT_CALLBACK(0, "func-opts", , "options",
+"function tracer options, available options: call-graph",
+parse_func_tracer_opts),
OPT_CALLBACK('G', "graph-funcs", _funcs, "func",
 "trace given functions using function_graph tracer",
 parse_filter_func),
-- 
2.25.1



[PATCH v8 16/18] perf ftrace: add option --tid to filter by thread id

2020-08-07 Thread Changbin Du
This allows us to trace single thread instead of the whole process.

Signed-off-by: Changbin Du 
---
 tools/perf/Documentation/perf-ftrace.txt | 3 +++
 tools/perf/builtin-ftrace.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 29c684b3b3fd..78358af9a1c4 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -39,6 +39,9 @@ OPTIONS
 --pid=::
Trace on existing process id (comma separated list).
 
+--tid=::
+   Trace on existing thread id (comma separated list).
+
 -D::
 --delay::
Time (ms) to wait before starting tracing after program start.
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 5f9a9ebea0a2..13abb737fd12 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -812,6 +812,9 @@ int cmd_ftrace(int argc, const char **argv)
"Show available functions to filter"),
OPT_STRING('p', "pid", , "pid",
   "trace on existing process id"),
+   /* TODO: Add short option -t after -t/--tracer can be removed. */
+   OPT_STRING(0, "tid", , "tid",
+  "trace on existing thread id (exclusive to --pid)"),
OPT_INCR('v', "verbose", ,
 "be more verbose"),
OPT_BOOLEAN('a', "all-cpus", _wide,
-- 
2.25.1



[PATCH v8 06/18] perf ftrace: add option '--inherit' to trace children processes

2020-08-07 Thread Changbin Du
This adds an option '--inherit' to allow us trace children
processes spawned by our target.

Signed-off-by: Changbin Du 

---
v2: option name '--trace-children' -> '--inherit'.
---
 tools/perf/Documentation/perf-ftrace.txt |  3 ++
 tools/perf/builtin-ftrace.c  | 38 
 2 files changed, 41 insertions(+)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 7a5d915f60b0..c46d0a09b38c 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -58,6 +58,9 @@ OPTIONS
Set the size of per-cpu tracing buffer,  is expected to
be a number with appended unit character - B/K/M/G.
 
+--inherit::
+   Trace children processes spawned by our target.
+
 -T::
 --trace-funcs=::
Select function tracer and set function filter on the given
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 39c694be2b71..07b81d0c1658 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -41,6 +41,7 @@ struct perf_ftrace {
struct list_headnograph_funcs;
int graph_depth;
unsigned long   percpu_buffer_size;
+   boolinherit;
 };
 
 struct filter_entry {
@@ -182,9 +183,27 @@ static int write_tracing_file_int(const char *name, int 
value)
return 0;
 }
 
+static int write_tracing_option_file(const char *name, const char *val)
+{
+   char *file;
+   int ret;
+
+   if (asprintf(, "options/%s", name) < 0)
+   return -1;
+
+   ret = __write_tracing_file(file, val, false);
+   free(file);
+   return ret;
+}
+
 static int reset_tracing_cpu(void);
 static void reset_tracing_filters(void);
 
+static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused)
+{
+   write_tracing_option_file("function-fork", "0");
+}
+
 static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
 {
if (write_tracing_file("tracing_on", "0") < 0)
@@ -203,6 +222,7 @@ static int reset_tracing_files(struct perf_ftrace *ftrace 
__maybe_unused)
return -1;
 
reset_tracing_filters();
+   reset_tracing_options(ftrace);
return 0;
 }
 
@@ -341,6 +361,17 @@ static int set_tracing_percpu_buffer_size(struct 
perf_ftrace *ftrace)
return 0;
 }
 
+static int set_tracing_trace_inherit(struct perf_ftrace *ftrace)
+{
+   if (!ftrace->inherit)
+   return 0;
+
+   if (write_tracing_option_file("function-fork", "1") < 0)
+   return -1;
+
+   return 0;
+}
+
 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
 {
char *trace_file;
@@ -410,6 +441,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
goto out_reset;
}
 
+   if (set_tracing_trace_inherit(ftrace) < 0) {
+   pr_err("failed to set tracing option function-fork\n");
+   goto out_reset;
+   }
+
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
goto out_reset;
@@ -618,6 +654,8 @@ int cmd_ftrace(int argc, const char **argv)
"Max depth for function graph tracer"),
OPT_CALLBACK('m', "buffer-size", _buffer_size, "size",
 "size of per cpu buffer", parse_buffer_size),
+   OPT_BOOLEAN(0, "inherit", ,
+   "trace children processes"),
OPT_END()
};
 
-- 
2.25.1



[PATCH v8 04/18] perf ftrace: add option '-m/--buffer-size' to set per-cpu buffer size

2020-08-07 Thread Changbin Du
This adds an option '-m/--buffer-size' to allow us set the size of per-cpu
tracing buffer.

Signed-off-by: Changbin Du 

---
v2: support units as a suffix.
---
 tools/perf/Documentation/perf-ftrace.txt |  5 +++
 tools/perf/builtin-ftrace.c  | 55 
 2 files changed, 60 insertions(+)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 4f5628445a63..7a5d915f60b0 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -53,6 +53,11 @@ OPTIONS
Ranges of CPUs are specified with -: 0-2.
Default is to trace on all online CPUs.
 
+-m::
+--buffer-size::
+   Set the size of per-cpu tracing buffer,  is expected to
+   be a number with appended unit character - B/K/M/G.
+
 -T::
 --trace-funcs=::
Select function tracer and set function filter on the given
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 4b3fcee5725a..a3a4f4be9dde 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -26,6 +26,7 @@
 #include "thread_map.h"
 #include "util/cap.h"
 #include "util/config.h"
+#include "util/units.h"
 
 #define DEFAULT_TRACER  "function_graph"
 
@@ -39,6 +40,7 @@ struct perf_ftrace {
struct list_headgraph_funcs;
struct list_headnograph_funcs;
int graph_depth;
+   unsigned long   percpu_buffer_size;
 };
 
 struct filter_entry {
@@ -324,6 +326,21 @@ static int set_tracing_depth(struct perf_ftrace *ftrace)
return 0;
 }
 
+static int set_tracing_percpu_buffer_size(struct perf_ftrace *ftrace)
+{
+   int ret;
+
+   if (ftrace->percpu_buffer_size == 0)
+   return 0;
+
+   ret = write_tracing_file_int("buffer_size_kb",
+ftrace->percpu_buffer_size / 1024);
+   if (ret < 0)
+   return ret;
+
+   return 0;
+}
+
 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
**argv)
 {
char *trace_file;
@@ -388,6 +405,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
goto out_reset;
}
 
+   if (set_tracing_percpu_buffer_size(ftrace) < 0) {
+   pr_err("failed to set tracing per-cpu buffer size\n");
+   goto out_reset;
+   }
+
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
goto out_reset;
@@ -506,6 +528,37 @@ static void delete_filter_func(struct list_head *head)
}
 }
 
+static int parse_buffer_size(const struct option *opt,
+const char *str, int unset)
+{
+   unsigned long *s = (unsigned long *)opt->value;
+   static struct parse_tag tags_size[] = {
+   { .tag  = 'B', .mult = 1   },
+   { .tag  = 'K', .mult = 1 << 10 },
+   { .tag  = 'M', .mult = 1 << 20 },
+   { .tag  = 'G', .mult = 1 << 30 },
+   { .tag  = 0 },
+   };
+   unsigned long val;
+
+   if (unset) {
+   *s = 0;
+   return 0;
+   }
+
+   val = parse_tag_value(str, tags_size);
+   if (val != (unsigned long) -1) {
+   if (val < 1024) {
+   pr_err("buffer size too small, must larger than 1KB.");
+   return -1;
+   }
+   *s = val;
+   return 0;
+   }
+
+   return -1;
+}
+
 static void select_tracer(struct perf_ftrace *ftrace)
 {
bool graph = !list_empty(>graph_funcs) ||
@@ -560,6 +613,8 @@ int cmd_ftrace(int argc, const char **argv)
 "Set nograph filter on given functions", 
parse_filter_func),
OPT_INTEGER('D', "graph-depth", _depth,
"Max depth for function graph tracer"),
+   OPT_CALLBACK('m', "buffer-size", _buffer_size, "size",
+"size of per cpu buffer", parse_buffer_size),
OPT_END()
};
 
-- 
2.25.1



[PATCH v8 03/18] perf ftrace: factor out function write_tracing_file_int()

2020-08-07 Thread Changbin Du
We will reuse this function later.

Signed-off-by: Changbin Du 
---
 tools/perf/builtin-ftrace.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 1ebf71ecc1a8..4b3fcee5725a 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -169,6 +169,17 @@ static int read_tracing_file_to_stdout(const char *name)
return ret;
 }
 
+static int write_tracing_file_int(const char *name, int value)
+{
+   char buf[16];
+
+   snprintf(buf, sizeof(buf), "%d", value);
+   if (write_tracing_file(name, buf) < 0)
+   return -1;
+
+   return 0;
+}
+
 static int reset_tracing_cpu(void);
 static void reset_tracing_filters(void);
 
@@ -299,8 +310,6 @@ static void reset_tracing_filters(void)
 
 static int set_tracing_depth(struct perf_ftrace *ftrace)
 {
-   char buf[16];
-
if (ftrace->graph_depth == 0)
return 0;
 
@@ -309,9 +318,7 @@ static int set_tracing_depth(struct perf_ftrace *ftrace)
return -1;
}
 
-   snprintf(buf, sizeof(buf), "%d", ftrace->graph_depth);
-
-   if (write_tracing_file("max_graph_depth", buf) < 0)
+   if (write_tracing_file_int("max_graph_depth", ftrace->graph_depth) < 0)
return -1;
 
return 0;
-- 
2.25.1



[PATCH v8 05/18] perf ftrace: show trace column header

2020-08-07 Thread Changbin Du
This makes perf-ftrace display column header before printing trace.

  $ sudo perf ftrace
  # tracer: function
  #
  # entries-in-buffer/entries-written: 0/0   #P:8
  #
  #TASK-PID CPU#   TIMESTAMP  FUNCTION
  #  | | |   | |
 <...>-9246  [006]  10726.262760: mutex_unlock <-rb_simple_write
 <...>-9246  [006]  10726.262764: __fsnotify_parent <-vfs_write
 <...>-9246  [006]  10726.262765: fsnotify <-vfs_write
 <...>-9246  [006]  10726.262766: __sb_end_write <-vfs_write
 <...>-9246  [006]  10726.262767: fpregs_assert_state_consistent 
<-do_syscall_64

Signed-off-by: Changbin Du 
---
 tools/perf/builtin-ftrace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index a3a4f4be9dde..39c694be2b71 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -435,6 +435,9 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
fcntl(trace_fd, F_SETFL, O_NONBLOCK);
pollfd.fd = trace_fd;
 
+   /* display column headers */
+   read_tracing_file_to_stdout("trace");
+
if (write_tracing_file("tracing_on", "1") < 0) {
pr_err("can't enable tracing\n");
goto out_close_fd;
-- 
2.25.1



[PATCH v8 01/18] perf ftrace: select function/function_graph tracer automatically

2020-08-07 Thread Changbin Du
The '-g/-G' options have already implied function_graph tracer should be
used instead of function tracer. So we don't need extra option '--tracer'
in this case.

This patch changes the behavior as below:
  - If '-g' or '-G' option is on, then function_graph tracer is used.
  - If '-T' or '-N' option is on, then function tracer is used.
  - The function_graph has priority over function tracer.
  - The option '--tracer' only take effect if neither -g/-G nor -T/-N
is specified.

Here are some examples.

This will start tracing all functions using default tracer:
  $ sudo perf ftrace

This will trace all functions using function graph tracer:
  $ sudo perf ftrace -G '*'

This will trace function vfs_read using function graph tracer:
  $ sudo perf ftrace -G vfs_read

This will trace function vfs_read using function tracer:
  $ sudo perf ftrace -T vfs_read

Signed-off-by: Changbin Du 

---
v4: changed tracer selection policy.
v3: remove default '*' for -G/-T.
---
 tools/perf/Documentation/perf-config.txt |  5 +--
 tools/perf/Documentation/perf-ftrace.txt | 41 +---
 tools/perf/builtin-ftrace.c  | 25 +--
 3 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt 
b/tools/perf/Documentation/perf-config.txt
index c7d3df5798e2..76408d986aed 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -614,8 +614,9 @@ trace.*::
 
 ftrace.*::
ftrace.tracer::
-   Can be used to select the default tracer. Possible values are
-   'function' and 'function_graph'.
+   Can be used to select the default tracer when neither -G nor
+   -F option is not specified. Possible values are 'function' and
+   'function_graph'.
 
 llvm.*::
llvm.clang-path::
diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index b80c84307dc9..821d4d334a09 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -24,7 +24,8 @@ OPTIONS
 
 -t::
 --tracer=::
-   Tracer to use: function_graph or function.
+   Tracer to use when neither -G nor -F option is not
+   specified: function_graph or function.
 
 -v::
 --verbose=::
@@ -50,33 +51,35 @@ OPTIONS
 
 -T::
 --trace-funcs=::
-   Only trace functions given by the argument.  Multiple functions
-   can be given by using this option more than once.  The function
-   argument also can be a glob pattern.  It will be passed to
-   'set_ftrace_filter' in tracefs.
+   Select function tracer and set function filter on the given
+   function (or a glob pattern). Multiple functions can be given
+   by using this option more than once. The function argument also
+   can be a glob pattern. It will be passed to 'set_ftrace_filter'
+   in tracefs.
 
 -N::
 --notrace-funcs=::
-   Do not trace functions given by the argument.  Like -T option,
-   this can be used more than once to specify multiple functions
-   (or glob patterns).  It will be passed to 'set_ftrace_notrace'
-   in tracefs.
+   Select function tracer and do not trace functions given by the
+   argument.  Like -T option, this can be used more than once to
+   specify multiple functions (or glob patterns).  It will be
+   passed to 'set_ftrace_notrace' in tracefs.
 
 -G::
 --graph-funcs=::
-   Set graph filter on the given function (or a glob pattern).
-   This is useful for the function_graph tracer only and enables
-   tracing for functions executed from the given function.
-   This can be used more than once to specify multiple functions.
-   It will be passed to 'set_graph_function' in tracefs.
+   Select function_graph tracer and set graph filter on the given
+   function (or a glob pattern). This is useful to trace for
+   functions executed from the given function. This can be used more
+   than once to specify multiple functions. It will be passed to
+   'set_graph_function' in tracefs.
 
 -g::
 --nograph-funcs=::
-   Set graph notrace filter on the given function (or a glob pattern).
-   Like -G option, this is useful for the function_graph tracer only
-   and disables tracing for function executed from the given function.
-   This can be used more than once to specify multiple functions.
-   It will be passed to 'set_graph_notrace' in tracefs.
+   Select function_graph tracer and set graph notrace filter on the
+   given function (or a glob pattern). Like -G option, this is useful
+   for the function_graph tracer only and disables tracing for function
+   executed from the given function. This can be used more than once to
+   specify multiple functions. It will be passed to 'set_graph_notrace'
+   in tracefs.
 
 -D::
 --graph-depth=::
diff --git a/tools/perf/builtin-ftrace.c 

[PATCH v8 00/18] [PATCH v7 00/18] perf: ftrace enhancement

2020-08-07 Thread Changbin Du
The perf has basic kernel ftrace support but lack support of most tracing
options. This serias is target to enhance the perf ftrace functionality so
that we can make full use of kernel ftrace with perf.

In general, this serias be cataloged into two main changes:
  1) Improve usability of existing functions. For example, we don't need to type
 extra option to select the tracer.
  2) Add new options to support all other ftrace functions.

Here is a glance of all ftrace functions with this serias:

$ sudo perf ftrace -h

 Usage: perf ftrace [] []
or: perf ftrace [] --  []

-a, --all-cpussystem-wide collection from all CPUs
-C, --cpulist of cpus to monitor
-D, --delayms to wait before starting tracing after program start
-F, --funcs   Show available functions to filter
-G, --graph-funcs 
  trace given functions using function_graph tracer
-g, --nograph-funcs 
  Set nograph filter on given functions
-m, --buffer-size 
  size of per cpu buffer
-N, --notrace-funcs 
  do not trace given functions
-p, --pidtrace on existing process id
-T, --trace-funcs 
  trace given functions using function tracer
-t, --tracer 
  tracer to use: function_graph(default) or function
-v, --verbose be more verbose
--func-opts 
  function tracer options, available options: 
call-graph,irq-info
--graph-opts 
  graph tracer options, available options: 
nosleep-time,noirqs,verbose,thresh=,depth=
--inherit trace children processes
--tidtrace on existing thread id (exclusive to --pid)

v8:
  o change tracer selection policy ([PATCH 01/18]).
v7:
  o add back '--tid '.
v6:
  o fix return value of read_tracing_file_to_stdout().
  o make __cmd_ftrace() shorter.
  o remove option '-t, --tid '.
v5:
  o trivial fixes.
v4:
  o add util/parse-sublevel-options.c
  O remove -D/--graph-depth
v3:
  o add --func-opts and --graph-opts to set tracer specific options.
  o support units as a suffix for option '-m/--buffer-size'.
v2:
  o patches for option '-u/--userstacktrace' and '--no-pager' are dropped.
  o update all related perf documentation.
  o rename some options. Now all funcgraph tracer options are prefixed with
'--graph-', while all function tracer options are prefixed with '--func-'.
  o mark old options deprecated instead of removing them.

Acked-by: Namhyung Kim 

Changbin Du (18):
  perf ftrace: select function/function_graph tracer automatically
  perf ftrace: add option '-F/--funcs' to list available functions
  perf ftrace: factor out function write_tracing_file_int()
  perf ftrace: add option '-m/--buffer-size' to set per-cpu buffer size
  perf ftrace: show trace column header
  perf ftrace: add option '--inherit' to trace children processes
  perf: util: add general function to parse sublevel options
  perf ftrace: add support for tracing option 'func_stack_trace'
  perf ftrace: add support for trace option sleep-time
  perf ftrace: add support for trace option funcgraph-irqs
  perf ftrace: add support for tracing option 'irq-info'
  perf ftrace: add option 'verbose' to show more info for graph tracer
  perf ftrace: add support for trace option tracing_thresh
  perf: ftrace: allow set graph depth by '--graph-opts'
  perf ftrace: add option -D/--delay to delay tracing
  perf ftrace: add option --tid to filter by thread id
  perf: ftrace: Add set_tracing_options() to set all trace options
  perf ftrace: add change log

 tools/perf/Documentation/perf-config.txt |   5 +-
 tools/perf/Documentation/perf-ftrace.txt |  75 ++--
 tools/perf/builtin-ftrace.c  | 424 +--
 tools/perf/util/Build|   1 +
 tools/perf/util/debug.c  |  61 +---
 tools/perf/util/parse-sublevel-options.c |  70 
 tools/perf/util/parse-sublevel-options.h |  11 +
 7 files changed, 550 insertions(+), 97 deletions(-)
 create mode 100644 tools/perf/util/parse-sublevel-options.c
 create mode 100644 tools/perf/util/parse-sublevel-options.h

-- 
2.25.1



[PATCH v8 02/18] perf ftrace: add option '-F/--funcs' to list available functions

2020-08-07 Thread Changbin Du
This adds an option '-F/--funcs' to list all available functions to trace,
which is read from tracing file 'available_filter_functions'.

$ sudo ./perf ftrace -F | head
trace_initcall_finish_cb
initcall_blacklisted
do_one_initcall
do_one_initcall
trace_initcall_start_cb
run_init_process
try_to_run_init_process
match_dev_by_label
match_dev_by_uuid
rootfs_init_fs_context

Signed-off-by: Changbin Du 

---
v3: fix return value issue.
v2: option name '-l/--list-functions' -> '-F/--funcs'
---
 tools/perf/Documentation/perf-ftrace.txt |  4 +++
 tools/perf/builtin-ftrace.c  | 46 
 2 files changed, 50 insertions(+)

diff --git a/tools/perf/Documentation/perf-ftrace.txt 
b/tools/perf/Documentation/perf-ftrace.txt
index 821d4d334a09..4f5628445a63 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -31,6 +31,10 @@ OPTIONS
 --verbose=::
 Verbosity level.
 
+-F::
+--funcs::
+List all available functions to trace.
+
 -p::
 --pid=::
Trace on existing process id (comma separated list).
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 048a11192b59..1ebf71ecc1a8 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -33,6 +33,7 @@ struct perf_ftrace {
struct evlist   *evlist;
struct target   target;
const char  *tracer;
+   boollist_avail_functions;
struct list_headfilters;
struct list_headnotrace;
struct list_headgraph_funcs;
@@ -128,6 +129,46 @@ static int append_tracing_file(const char *name, const 
char *val)
return __write_tracing_file(name, val, true);
 }
 
+static int read_tracing_file_to_stdout(const char *name)
+{
+   char buf[4096];
+   char *file;
+   int fd;
+   int ret = -1;
+
+   file = get_tracing_file(name);
+   if (!file) {
+   pr_debug("cannot get tracing file: %s\n", name);
+   return -1;
+   }
+
+   fd = open(file, O_RDONLY);
+   if (fd < 0) {
+   pr_debug("cannot open tracing file: %s: %s\n",
+name, str_error_r(errno, buf, sizeof(buf)));
+   goto out;
+   }
+
+   /* read contents to stdout */
+   while (true) {
+   int n = read(fd, buf, sizeof(buf));
+   if (n == 0)
+   break;
+   else if (n < 0)
+   goto out_close;
+
+   if (fwrite(buf, n, 1, stdout) != 1)
+   goto out_close;
+   }
+   ret = 0;
+
+out_close:
+   close(fd);
+out:
+   put_tracing_file(file);
+   return ret;
+}
+
 static int reset_tracing_cpu(void);
 static void reset_tracing_filters(void);
 
@@ -302,6 +343,9 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
argc, const char **argv)
signal(SIGCHLD, sig_handler);
signal(SIGPIPE, sig_handler);
 
+   if (ftrace->list_avail_functions)
+   return 
read_tracing_file_to_stdout("available_filter_functions");
+
if (reset_tracing_files(ftrace) < 0) {
pr_err("failed to reset ftrace\n");
goto out;
@@ -487,6 +531,8 @@ int cmd_ftrace(int argc, const char **argv)
const struct option ftrace_options[] = {
OPT_STRING('t', "tracer", , "tracer",
   "tracer to use: function_graph(default) or function"),
+   OPT_BOOLEAN('F', "funcs", _avail_functions,
+   "Show available functions to filter"),
OPT_STRING('p', "pid", , "pid",
   "trace on existing process id"),
OPT_INCR('v', "verbose", ,
-- 
2.25.1



Re: [PATCH 2/3] remoteproc: qcom: Add capability to collect minidumps

2020-08-07 Thread kernel test robot
Hi Gurbir,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20200807]
[cannot apply to linux/master linus/master v5.8 v5.8-rc7 v5.8-rc6 v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Gurbir-Arora/Introduce-mini-dump-support-for-remoteproc/20200808-073315
base:471e638c4c5df4c0035a76a561ada4d28228e5fd
config: x86_64-randconfig-s022-20200807 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-118-ge1578773-dirty
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   ld: drivers/remoteproc/remoteproc_coredump.o: in function `rproc_minidump':
>> drivers/remoteproc/remoteproc_coredump.c:510: undefined reference to 
>> `qcom_smem_get'

sparse warnings: (new ones prefixed by >>)

>> drivers/remoteproc/remoteproc_coredump.c:489:25: sparse: sparse: incorrect 
>> type in argument 2 (different address spaces) @@ expected void const 
>> *from @@ got struct md_ss_region [noderef] __iomem *[assigned] 
>> region_info @@
>> drivers/remoteproc/remoteproc_coredump.c:489:25: sparse: expected void 
>> const *from
>> drivers/remoteproc/remoteproc_coredump.c:489:25: sparse: got struct 
>> md_ss_region [noderef] __iomem *[assigned] region_info
>> drivers/remoteproc/remoteproc_coredump.c:491:25: sparse: sparse: incorrect 
>> type in argument 2 (different address spaces) @@ expected void const 
>> *from @@ got void [noderef] __iomem *[assigned] offset @@
   drivers/remoteproc/remoteproc_coredump.c:491:25: sparse: expected void 
const *from
>> drivers/remoteproc/remoteproc_coredump.c:491:25: sparse: got void 
>> [noderef] __iomem *[assigned] offset
   drivers/remoteproc/remoteproc_coredump.c:493:25: sparse: sparse: incorrect 
type in argument 2 (different address spaces) @@ expected void const *from 
@@ got void [noderef] __iomem *[assigned] offset @@
   drivers/remoteproc/remoteproc_coredump.c:493:25: sparse: expected void 
const *from
   drivers/remoteproc/remoteproc_coredump.c:493:25: sparse: got void 
[noderef] __iomem *[assigned] offset

vim +510 drivers/remoteproc/remoteproc_coredump.c

   460  
   461  static void add_minidump_segments(struct rproc *rproc, struct md_ss_toc 
*minidump_ss)
   462  {
   463  struct md_ss_region __iomem *region_info, *ptr;
   464  int i, seg_cnt = minidump_ss->ss_region_count;
   465  void __iomem *offset;
   466  dma_addr_t da;
   467  size_t size;
   468  char *name;
   469  
   470  if (!list_empty(>dump_segments))
   471  goto minidump;
   472  
   473  region_info = ioremap((unsigned 
long)minidump_ss->md_ss_smem_regions_baseptr,
   474seg_cnt * sizeof(struct md_ss_region));
   475  
   476  if (!region_info) {
   477  dev_err(>dev, "invalid minidump subsystem 
table\n");
   478  return;
   479  }
   480  
   481  /* Iterate over the subsystem's segments and create rproc 
custom dump segments */
   482  ptr = region_info;
   483  offset = ptr;
   484  for (i = 0; i < seg_cnt; i++) {
   485  offset = region_info;
   486  offset += sizeof(region_info->name) + 
sizeof(region_info->seq_num);
   487  if (__raw_readl(offset) == MD_REGION_VALID) {
   488  name = kmalloc(MAX_REGION_NAME_LENGTH, 
GFP_KERNEL);
 > 489  memcpy(name, region_info, 
 > sizeof(region_info->name));
   490  offset += sizeof(region_info->md_valid);
 > 491  memcpy(, offset, 
 > sizeof(region_info->region_base_address));
   492  offset += 
sizeof(region_info->region_base_address);
   493  memcpy(, offset, 
sizeof(region_info->region_size));
   494  rproc_coredump_add_custom_segment(rproc, da, 
size, NULL, name);
   495  }
   496  region_info++;
   497  }
   498  
   499  minidump:
   500  return do_rproc_minidump(rproc);
   501  }
   502  
   503  void rproc_minidump(struct rproc *rproc)
   504  {
   505  struct md_ss_toc *minidump_ss;
   506  size_t size;
   507  
   508  /* Get Global minidump ToC*/
   509   

Re: [PATCH v7 01/18] perf ftrace: select function/function_graph tracer automatically

2020-08-07 Thread Changbin Du
On Wed, Aug 05, 2020 at 10:05:03PM -0300, Arnaldo Carvalho de Melo wrote:
> 
> 
> On August 5, 2020 9:14:48 PM GMT-03:00, Changbin Du  
> wrote:
> >On Tue, Aug 04, 2020 at 09:51:15AM -0300, Arnaldo Carvalho de Melo
> >wrote:
> >> Em Sat, Jul 18, 2020 at 02:48:09PM +0800, Changbin Du escreveu:
> >> > The '-g/-G' options have already implied function_graph tracer
> >should be
> >> > used instead of function tracer. So the extra option '--tracer' can
> >be
> >> > killed.
> >> > 
> >> > This patch changes the behavior as below:
> >> >   - By default, function tracer is used.
> >> >   - If '-g' or '-G' option is on, then function_graph tracer is
> >used.
> >> >   - The perf configuration item 'ftrace.tracer' is marked as
> >deprecated.
> >> >   - The option '--tracer' is marked as deprecated.
> >> 
> >> You should try to be more granular, for instance, I think the
> >decision
> >> to change the default is questionable, but could be acceptable.
> >> 
> >> But why deprecate the perf configuration for the default tracer?
> >> 
> >> Say people who already use 'perf ftrace ls' go and use with this
> >patch
> >> and see that it changed the default from the function_graph tracer to
> >> the function tracer and disagree with you, they want the default to
> >be
> >> the function graph tracer, know that there is (or there was) a
> >> ftrace.tracer in ~/.prefconfig, and then try that, only to find out
> >that
> >> it is not possible, frustrating :-\
> >> 
> >> So can we please remove this deprecation of ftrace.tracer so that
> >people
> >> used to how it was can get that behaviour back?
> >> 
> >Agreed. If no -F or -G is given, we can use the ftrace.tracer as
> >default tracer.
> >Let me update it. Thanks.
> 
> Thanks, I'm general try to be as granular as possible, doing one thing per 
> patch, this way the reviewer can do some preliminary cherry picking and we 
> also improve git bisectability.
>
Arnaldo, I changed the policy as below:
  - Preserve the default tracerr which is function_graph.
  - If '-g' or '-G' option is on, then function_graph tracer is used.
  - If '-T' or '-N' option is on, then function tracer is used.
  - The option '--tracer' or configuration ftrace.tracer only takes
effect if neither -g/-G nor -T/-N is specified.
  - The function_graph has priority over function tracer if both -G/-g
and -T/-N are given.

Please check updatae in v8. Thanks.
> - Arnaldo
> 
> -- 
> Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
Cheers,
Changbin Du


Re: [PATCH v4 5/5] docs: Update RCU's hotplug requirements with a bit about design

2020-08-07 Thread Randy Dunlap
Hi--

On 8/7/20 10:07 AM, Joel Fernandes (Google) wrote:
> RCU's hotplug design will help understand the requirements an RCU
> implementation needs to fullfill, such as dead-lock avoidance.
> 
> The rcu_barrier() section of the "Hotplug CPU" section already talks
> about deadlocks, however the description of what else can deadlock other
> than rcu_barrier is rather incomplete.
> 
> This commit therefore continues the section by describing how RCU's
> design handles CPU hotplug in a deadlock-free way.
> 
> Signed-off-by: Joel Fernandes (Google) 
> ---
>  .../RCU/Design/Requirements/Requirements.rst  | 22 +++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst 
> b/Documentation/RCU/Design/Requirements/Requirements.rst
> index 16c64a2eff93..0a4148b9f743 100644
> --- a/Documentation/RCU/Design/Requirements/Requirements.rst
> +++ b/Documentation/RCU/Design/Requirements/Requirements.rst
> @@ -1940,6 +1940,28 @@ deadlock. Furthermore, ``rcu_barrier()`` blocks 
> CPU-hotplug operations
>  during its execution, which results in another type of deadlock when
>  invoked from a CPU-hotplug notifier.
>  
> +Also, RCU's implementation avoids serious deadlocks which could occur due to
> +interaction between hotplug, timers and grace period processing. It does so 
> by
> +maintaining its own bookkeeping of every CPU's hotplug state, independent of
> +the various CPU masks and by reporting quiescent states at explicit points.  
> It
> +may come across as a surprise, but the force quiescent state loop (FQS) does
> +not report quiescent states for offline CPUs and is not required to.
> +
> +For an offline CPU, the quiescent state will be reported in either of:
> +1. During CPU offlining, using RCU's hotplug notifier 
> (``rcu_report_dead()``).

note, uses (), which is good:  ()

> +2. During grace period initialization (``rcu_gp_init``) if it detected a race

  add for consistency & readability:rcu_gp_init()

> +   with CPU offlining, or a race with a task unblocking on a node which
> +   previously had all of its CPUs offlined.
> +
> +The CPU onlining path (``rcu_cpu_starting``) does not need to a report

  ditto:rcu_cpu_starting()

> +quiescent state for an offline CPU in fact it would trigger a warning if a

Missing something; maybe like so:

   for an offline CPU; in fact

> +quiescent state was not already reported for that CPU.
> +
> +During the checking/modification of RCU's hotplug bookkeeping, the
> +corresponding CPU's leaf node lock is held. This avoids race conditions 
> between
> +RCU's hotplug notifier hooks, grace period initialization code and the FQS 
> loop
> +which can concurrently refer to or modify the bookkeeping.
> +
>  Scheduler and RCU
>  ~
>  
> 

cheers.
-- 
~Randy



Re: [RFC PATCH 0/7] metricfs metric file system and examples

2020-08-07 Thread Andrew Lunn
> net/dev/stats/tx_bytes/annotations
>   DESCRIPTION net\ device\ transmited\ bytes\ count
>   CUMULATIVE
> net/dev/stats/tx_bytes/fields
>   interface value
>   str int
> net/dev/stats/tx_bytes/values
>   lo 4394430608
>   eth0 33353183843
>   eth1 16228847091

This is a rather small system. Have you tested it at scale? An
Ethernet switch with 64 physical interfaces, and say 32 VLAN
interfaces stack on top. So this one file will contain 2048 entries?

And generally, you are not interested in one statistic, but many
statistics. So you will need to cat each file, not just one file. And
the way this is implemented:

+static void dev_stats_emit(struct metric_emitter *e,
+  struct net_device *dev,
+  struct metric_def *metricd)
+{
+   struct rtnl_link_stats64 temp;
+   const struct rtnl_link_stats64 *stats = dev_get_stats(dev, );
+
+   if (stats) {
+   __u8 *ptr = (((__u8 *)stats) + metricd->off);
+
+   METRIC_EMIT_INT(e, *(__u64 *)ptr, dev->name, NULL);
+   }
+}

means you are going to be calling dev_get_stats() for each file, and
there are 23 files if i counted correctly. So dev_get_stats() will be
called 47104 times, in this made up example. And this is not always
cheap, these counts can be atomic.

So i personally don't think netdev statistics is a good idea, i doubt
it scales.

I also think you are looking at the wrong set of netdev counters. I
would be more interested in ethtool -S counters. But it appears you
make the assumption that each object you are collecting metrics for
has the same set of counters. This is untrue for network interfaces,
where each driver can export whatever counters it wants, and they can
be dynamic.

Andrew


[PATCH v2 1/2] leds: is31fl32xx: Add sdb pin and generate a 5ms low pulse when startup

2020-08-07 Thread Grant Feng
generate a 5ms low pulse on sdb pin when startup, then the chip
becomes more stable in the complex EM environment.

Signed-off-by: Grant Feng 
---
 drivers/leds/leds-is31fl32xx.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c
index cd768f991da1..07b543120e06 100644
--- a/drivers/leds/leds-is31fl32xx.c
+++ b/drivers/leds/leds-is31fl32xx.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* Used to indicate a device has no such register */
 #define IS31FL32XX_REG_NONE 0xFF
@@ -43,6 +45,7 @@ struct is31fl32xx_led_data {
 struct is31fl32xx_priv {
const struct is31fl32xx_chipdef *cdef;
struct i2c_client *client;
+   struct gpio_desc *sdb_gpio;
unsigned int num_leds;
struct is31fl32xx_led_data leds[];
 };
@@ -282,11 +285,17 @@ static int is31fl32xx_software_shutdown(struct 
is31fl32xx_priv *priv,
return 0;
 }
 
-static int is31fl32xx_init_regs(struct is31fl32xx_priv *priv)
+static int is31fl32xx_init(struct is31fl32xx_priv *priv)
 {
const struct is31fl32xx_chipdef *cdef = priv->cdef;
int ret;
 
+   if (priv->sdb_gpio) {
+   gpiod_direction_output(priv->sdb_gpio, 0);
+   mdelay(5);
+   gpiod_direction_output(priv->sdb_gpio, 1);
+   }
+
ret = is31fl32xx_reset_regs(priv);
if (ret)
return ret;
@@ -372,6 +381,15 @@ static int is31fl32xx_parse_dt(struct device *dev,
struct device_node *child;
int ret = 0;
 
+   priv->sdb_gpio = devm_gpiod_get_optional(dev,
+   "sdb",
+   GPIOD_OUT_HIGH);
+   if (IS_ERR(priv->sdb_gpio)) {
+   ret = PTR_ERR(priv->sdb_gpio);
+   dev_err(dev, "Failed to get sdb gpio: %d\n", ret);
+   return ret;
+   }
+
for_each_child_of_node(dev->of_node, child) {
struct is31fl32xx_led_data *led_data =
>leds[priv->num_leds];
@@ -453,11 +471,11 @@ static int is31fl32xx_probe(struct i2c_client *client,
priv->cdef = cdef;
i2c_set_clientdata(client, priv);
 
-   ret = is31fl32xx_init_regs(priv);
+   ret = is31fl32xx_parse_dt(dev, priv);
if (ret)
return ret;
 
-   ret = is31fl32xx_parse_dt(dev, priv);
+   ret = is31fl32xx_init(priv);
if (ret)
return ret;
 
-- 
2.17.1




[PATCH v2 2/2] leds: Add an optional property named 'sdb-gpios'

2020-08-07 Thread Grant Feng
The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
 Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
index 926c2117942c..94f02827fd83 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
@@ -15,6 +15,8 @@ Required properties:
 - reg: I2C slave address
 - address-cells : must be 1
 - size-cells : must be 0
+- sdb-gpios : (optional)
+  Specifier of the GPIO connected to SDB pin.
 
 LED sub-node properties:
 - reg : LED channel number (1..N)
@@ -31,6 +33,7 @@ is31fl3236: led-controller@3c {
reg = <0x3c>;
#address-cells = <1>;
#size-cells = <0>;
+   sdb-gpios = < 11 GPIO_ACTIVE_HIGH>;
 
led@1 {
reg = <1>;
-- 
2.17.1




Re: [PATCH 2/3] remoteproc: qcom: Add capability to collect minidumps

2020-08-07 Thread kernel test robot
Hi Gurbir,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20200807]
[cannot apply to linux/master linus/master v5.8 v5.8-rc7 v5.8-rc6 v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Gurbir-Arora/Introduce-mini-dump-support-for-remoteproc/20200808-073315
base:471e638c4c5df4c0035a76a561ada4d28228e5fd
config: nios2-randconfig-s032-20200807 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-118-ge1578773-dirty
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=nios2 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)

>> drivers/remoteproc/remoteproc_coredump.c:489:38: sparse: sparse: incorrect 
>> type in argument 2 (different address spaces) @@ expected void const *s 
>> @@ got struct md_ss_region [noderef] __iomem *[assigned] region_info @@
>> drivers/remoteproc/remoteproc_coredump.c:489:38: sparse: expected void 
>> const *s
   drivers/remoteproc/remoteproc_coredump.c:489:38: sparse: got struct 
md_ss_region [noderef] __iomem *[assigned] region_info
>> drivers/remoteproc/remoteproc_coredump.c:491:37: sparse: sparse: incorrect 
>> type in argument 2 (different address spaces) @@ expected void const *s 
>> @@ got void [noderef] __iomem *[assigned] offset @@
   drivers/remoteproc/remoteproc_coredump.c:491:37: sparse: expected void 
const *s
   drivers/remoteproc/remoteproc_coredump.c:491:37: sparse: got void 
[noderef] __iomem *[assigned] offset
   drivers/remoteproc/remoteproc_coredump.c:493:39: sparse: sparse: incorrect 
type in argument 2 (different address spaces) @@ expected void const *s @@  
   got void [noderef] __iomem *[assigned] offset @@
   drivers/remoteproc/remoteproc_coredump.c:493:39: sparse: expected void 
const *s
   drivers/remoteproc/remoteproc_coredump.c:493:39: sparse: got void 
[noderef] __iomem *[assigned] offset

vim +489 drivers/remoteproc/remoteproc_coredump.c

   460  
   461  static void add_minidump_segments(struct rproc *rproc, struct md_ss_toc 
*minidump_ss)
   462  {
   463  struct md_ss_region __iomem *region_info, *ptr;
   464  int i, seg_cnt = minidump_ss->ss_region_count;
   465  void __iomem *offset;
   466  dma_addr_t da;
   467  size_t size;
   468  char *name;
   469  
   470  if (!list_empty(>dump_segments))
   471  goto minidump;
   472  
   473  region_info = ioremap((unsigned 
long)minidump_ss->md_ss_smem_regions_baseptr,
   474seg_cnt * sizeof(struct md_ss_region));
   475  
   476  if (!region_info) {
   477  dev_err(>dev, "invalid minidump subsystem 
table\n");
   478  return;
   479  }
   480  
   481  /* Iterate over the subsystem's segments and create rproc 
custom dump segments */
   482  ptr = region_info;
   483  offset = ptr;
   484  for (i = 0; i < seg_cnt; i++) {
   485  offset = region_info;
   486  offset += sizeof(region_info->name) + 
sizeof(region_info->seq_num);
   487  if (__raw_readl(offset) == MD_REGION_VALID) {
   488  name = kmalloc(MAX_REGION_NAME_LENGTH, 
GFP_KERNEL);
 > 489  memcpy(name, region_info, 
 > sizeof(region_info->name));
   490  offset += sizeof(region_info->md_valid);
 > 491  memcpy(, offset, 
 > sizeof(region_info->region_base_address));
   492  offset += 
sizeof(region_info->region_base_address);
   493  memcpy(, offset, 
sizeof(region_info->region_size));
   494  rproc_coredump_add_custom_segment(rproc, da, 
size, NULL, name);
   495  }
   496  region_info++;
   497  }
   498  
   499  minidump:
   500  return do_rproc_minidump(rproc);
   501  }
   502  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH] x86/boot: avoid relaxable symbols with Clang

2020-08-07 Thread Arvind Sankar
On Fri, Aug 07, 2020 at 02:54:39PM -0700, Nick Desaulniers wrote:
> On Fri, Aug 7, 2020 at 2:29 PM Arvind Sankar  wrote:
> >
> > On Fri, Aug 07, 2020 at 12:41:00PM -0700, Nick Desaulniers wrote:
> > > A recent change to a default value of configuration variable
> > > (ENABLE_X86_RELAX_RELOCATIONS OFF -> ON) in LLVM now causes Clang's
> > > integrated assembler to emit R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX
> > > relocations. LLD will relax instructions with these relocations based on
> > > whether the image is being linked as position independent or not.  When
> > > not, then LLD will relax these instructions to use absolute addressing
> > > mode (R_RELAX_GOT_PC_NOPIC). This causes kernels built with Clang
> > > and linked with LLD to fail to boot.
> >
> > It could also cause kernels compiled with gcc and linked with LLD to
> > fail in the same way, no? The gcc/gas combination will generate the
> > relaxed relocations from I think gas-2.26 onward. Although the only
> > troublesome symbol in the case of gcc/gas is trampoline_32bit_src,
> > referenced from pgtable_64.c (gcc doesn't use a GOTPC reloc for _pgtable
> > etc).
> 
> Thanks for taking a look, and the feedback. I appreciate it!
> 
> $ gcc --version | head -n 1
> gcc (Debian 9.3.0-11) 9.3.0
> $ make -j71 clean defconfig bzImage
> $ llvm-readelf -r arch/x86/boot/compressed/*.o | grep -e
> R_X86_64_GOTPCRELX -e R_X86_64_REX_GOTPCRELX
> 0114  0012002a R_X86_64_REX_GOTPCRELX
>  trampoline_32bit_src - 4
> $ llvm-readelf -r arch/x86/boot/compressed/vmlinux | grep -e
> R_X86_64_GOTPCRELX -e R_X86_64_REX_GOTPCRELX
> $
> 
> So it looks like yes.  I guess then we'd need to add a check for
> CONFIG_LD_IS_LLD and CONFIG_CC_IS_GCC and binutils version is 2.26+?
> I don't mind adding support for that combination, but I'd like to skip
> it in this patch for the sake of backporting something small to stable
> to get our CI green ASAP, since CONFIG_LD_IS_LLD probably doesn't
> exist for those stable branches, which will complicate the backport of
> such a patch.  So I'd do it in a follow up patch if we're cool with
> that?
> 

What if we did it only if we couldn't enable -pie, like the below patch?
I think this should cover all the cases without needing LD_IS_LLD
checks.

For BFD, the only case that should change is binutils-2.26, which
supports relaxations but not -z noreloc-overflow, and will now have
relax-relocations disabled. It currently works (with gcc) only because
the relaxation of
movq foo@GOTPCREL(%rip), %reg
to
movq $foo, %reg
in the non-pie case was only added in 2.27, which is also when -z
noreloc-overflow was added, allowing -pie to be enabled. With 2.26, it
only gets relaxed to
leaq foo(%rip), %reg
which is all LLD currently does as well.

diff --git a/arch/x86/boot/compressed/Makefile 
b/arch/x86/boot/compressed/Makefile
index 8abc30b27ba3..d25bb71f195a 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -60,6 +60,13 @@ else
 KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
&& echo "-z noreloc-overflow -pie --no-dynamic-linker")
 endif
+
+# Disable relocation relaxation if not building as PIE
+ifeq ($(filter -pie,$(KBUILD_LDFLAGS)),)
+KBUILD_CFLAGS += $(call as-option, -Wa$(comma)-mrelax-relocations=no)
+KBUILD_AFLAGS += $(call as-option, -Wa$(comma)-mrelax-relocations=no)
+endif
+
 LDFLAGS_vmlinux := -T
 
 hostprogs  := mkpiggy


[PATCH] ASoC: various vendors: delete repeated words in comments

2020-08-07 Thread Randy Dunlap
Drop the repeated words {related, we, is, the} in comments.

Signed-off-by: Randy Dunlap 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: alsa-de...@alsa-project.org
---
 sound/soc/fsl/fsl_dma.c |2 +-
 sound/soc/intel/skylake/skl-sst.c   |2 +-
 sound/soc/meson/axg-tdm-formatter.c |2 +-
 sound/soc/sprd/sprd-pcm-compress.c  |2 +-
 sound/soc/sunxi/sun4i-codec.c   |2 +-
 sound/soc/ti/davinci-mcasp.c|2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

--- linux-next-20200807.orig/sound/soc/fsl/fsl_dma.c
+++ linux-next-20200807/sound/soc/fsl/fsl_dma.c
@@ -154,7 +154,7 @@ static void fsl_dma_abort_stream(struct
 /**
  * fsl_dma_update_pointers - update LD pointers to point to the next period
  *
- * As each period is completed, this function changes the the link
+ * As each period is completed, this function changes the link
  * descriptor pointers for that period to point to the next period.
  */
 static void fsl_dma_update_pointers(struct fsl_dma_private *dma_private)
--- linux-next-20200807.orig/sound/soc/intel/skylake/skl-sst.c
+++ linux-next-20200807/sound/soc/intel/skylake/skl-sst.c
@@ -354,7 +354,7 @@ static int skl_transfer_module(struct ss
/*
 * if bytes_left > 0 then wait for BDL complete interrupt and
 * copy the next chunk till bytes_left is 0. if bytes_left is
-* is zero, then wait for load module IPC reply
+* zero, then wait for load module IPC reply
 */
while (bytes_left > 0) {
curr_pos = size - bytes_left;
--- linux-next-20200807.orig/sound/soc/meson/axg-tdm-formatter.c
+++ linux-next-20200807/sound/soc/meson/axg-tdm-formatter.c
@@ -398,7 +398,7 @@ void axg_tdm_stream_free(struct axg_tdm_
/*
 * If the list is not empty, it would mean that one of the formatter
 * widget is still powered and attached to the interface while we
-* we are removing the TDM DAI. It should not be possible
+* are removing the TDM DAI. It should not be possible
 */
WARN_ON(!list_empty(>formatter_list));
mutex_destroy(>lock);
--- linux-next-20200807.orig/sound/soc/sprd/sprd-pcm-compress.c
+++ linux-next-20200807/sound/soc/sprd/sprd-pcm-compress.c
@@ -559,7 +559,7 @@ static int sprd_platform_compr_copy(stru
} else {
/*
 * If the data count is larger than the available spaces
-* of the the stage 0 IRAM buffer, we should copy one
+* of the stage 0 IRAM buffer, we should copy one
 * partial data to the stage 0 IRAM buffer, and copy
 * the left to the stage 1 DDR buffer.
 */
--- linux-next-20200807.orig/sound/soc/sunxi/sun4i-codec.c
+++ linux-next-20200807/sound/soc/sunxi/sun4i-codec.c
@@ -335,7 +335,7 @@ static int sun4i_codec_prepare_capture(s
 
/*
 * FIXME: Undocumented in the datasheet, but
-*Allwinner's code mentions that it is related
+*Allwinner's code mentions that it is
 *related to microphone gain
 */
if (of_device_is_compatible(scodec->dev->of_node,
--- linux-next-20200807.orig/sound/soc/ti/davinci-mcasp.c
+++ linux-next-20200807/sound/soc/ti/davinci-mcasp.c
@@ -633,7 +633,7 @@ static int __davinci_mcasp_set_clkdiv(st
 * right channels), so it has to be divided by number
 * of tdm-slots (for I2S - divided by 2).
 * Instead of storing this ratio, we calculate a new
-* tdm_slot width by dividing the the ratio by the
+* tdm_slot width by dividing the ratio by the
 * number of configured tdm slots.
 */
mcasp->slot_width = div / mcasp->tdm_slots;


[PATCH] ASoC: codecs: delete repeated words in comments

2020-08-07 Thread Randy Dunlap
Drop the repeated words {start, it, the} in comments.

Signed-off-by: Randy Dunlap 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: alsa-de...@alsa-project.org
---
 sound/soc/codecs/nau8825.c |2 +-
 sound/soc/codecs/tas5086.c |2 +-
 sound/soc/codecs/wm9713.c  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

--- linux-next-20200807.orig/sound/soc/codecs/nau8825.c
+++ linux-next-20200807/sound/soc/codecs/nau8825.c
@@ -251,7 +251,7 @@ static const unsigned short logtable[256
  *
  * Acquires the semaphore without jiffies. Try to acquire the semaphore
  * atomically. Returns 0 if the semaphore has been acquired successfully
- * or 1 if it it cannot be acquired.
+ * or 1 if it cannot be acquired.
  */
 static int nau8825_sema_acquire(struct nau8825 *nau8825, long timeout)
 {
--- linux-next-20200807.orig/sound/soc/codecs/tas5086.c
+++ linux-next-20200807/sound/soc/codecs/tas5086.c
@@ -487,7 +487,7 @@ static int tas5086_init(struct device *d
/*
 * If any of the channels is configured to start in Mid-Z mode,
 * configure 'part 1' of the PWM starts to use Mid-Z, and tell
-* all configured mid-z channels to start start under 'part 1'.
+* all configured mid-z channels to start under 'part 1'.
 */
if (priv->pwm_start_mid_z)
regmap_write(priv->regmap, TAS5086_PWM_START,
--- linux-next-20200807.orig/sound/soc/codecs/wm9713.c
+++ linux-next-20200807/sound/soc/codecs/wm9713.c
@@ -755,7 +755,7 @@ static void pll_factors(struct snd_soc_c
u64 Kpart;
unsigned int K, Ndiv, Nmod, target;
 
-   /* The the PLL output is always 98.304MHz. */
+   /* The PLL output is always 98.304MHz. */
target = 98304000;
 
/* If the input frequency is over 14.4MHz then scale it down. */


[PATCH] ASoC: SOF: delete repeated words in comments

2020-08-07 Thread Randy Dunlap
Drop the repeated words {that, the} in comments.

Signed-off-by: Randy Dunlap 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: alsa-de...@alsa-project.org
---
 sound/soc/sof/intel/cnl.c |2 +-
 sound/soc/sof/sof-audio.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- linux-next-20200807.orig/sound/soc/sof/intel/cnl.c
+++ linux-next-20200807/sound/soc/sof/intel/cnl.c
@@ -202,7 +202,7 @@ static int cnl_ipc_send_msg(struct snd_s
 * IPCs are sent at a high-rate. mod_delayed_work()
 * modifies the timer if the work is pending.
 * Also, a new delayed work should not be queued after the
-* the CTX_SAVE IPC, which is sent before the DSP enters D3.
+* CTX_SAVE IPC, which is sent before the DSP enters D3.
 */
if (hdr->cmd != (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE))
mod_delayed_work(system_wq, >d0i3_work,
--- linux-next-20200807.orig/sound/soc/sof/sof-audio.c
+++ linux-next-20200807/sound/soc/sof/sof-audio.c
@@ -29,7 +29,7 @@ bool snd_sof_dsp_only_d0i3_compatible_st
continue;
 
/*
-* substream->runtime being not NULL indicates that
+* substream->runtime being not NULL indicates
 * that the stream is open. No need to check the
 * stream state.
 */


HELLO

2020-08-07 Thread Miss Ayesha Gaddafi
Assalamu Alaikum Wa Rahmatullahi Wa Barakatuh,

My name is Aisha Gaddafi the only biological Daughter of Late Colonel
Muammar Gaddafi, Libyan formal President.

I'm a Widow with three Children, presently living in Oman as a refugee
with my three children, i have been under political asylum protection
by the Government of Oman however, I have an investment funds which i
want to entrust on you for investment project in your country or your
company.

I am willing to negotiate investment/business profit sharing ratio
with you  base on the future investment earning profits.
If you are willing to handle this project on my behalf kindly reply
urgent  to enable me provide you more information about the investment
funds.

PLease in the name of Allah/God, I hope to hear from you for more
details if you're interested,

Warmest regards
Mrs Aisha Gaddafi


[PATCH v1 2/2] kunit: tool: allow generating test results in JSON

2020-08-07 Thread Brendan Higgins
From: Heidi Fahim 

Add a --json flag, which when specified when kunit_tool is run,
generates JSON formatted test results conforming to the KernelCI API
test_group spec[1]. The user can the new flag to specify a filename as
the value to json in order to store the JSON results under linux/.

Link[1]: https://api.kernelci.org/schema-test-group.html#post
Signed-off-by: Heidi Fahim 
Signed-off-by: Brendan Higgins 
---
 tools/testing/kunit/kunit.py   | 35 +++---
 tools/testing/kunit/kunit_json.py  | 63 ++
 tools/testing/kunit/kunit_tool_test.py | 33 ++
 3 files changed, 125 insertions(+), 6 deletions(-)
 create mode 100644 tools/testing/kunit/kunit_json.py

diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index 96344a11ff1f..485b7c63b967 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -17,6 +17,7 @@ from collections import namedtuple
 from enum import Enum, auto
 
 import kunit_config
+import kunit_json
 import kunit_kernel
 import kunit_parser
 
@@ -30,9 +31,9 @@ KunitBuildRequest = namedtuple('KunitBuildRequest',
 KunitExecRequest = namedtuple('KunitExecRequest',
  ['timeout', 'build_dir', 'alltests'])
 KunitParseRequest = namedtuple('KunitParseRequest',
-  ['raw_output', 'input_data'])
+  ['raw_output', 'input_data', 'build_dir', 
'json'])
 KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs',
-  'build_dir', 'alltests',
+  'build_dir', 'alltests', 'json',
   'make_options'])
 
 KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0]
@@ -113,12 +114,22 @@ def parse_tests(request: KunitParseRequest) -> 
KunitResult:
test_result = kunit_parser.TestResult(kunit_parser.TestStatus.SUCCESS,
  [],
  'Tests not Parsed.')
+
if request.raw_output:
kunit_parser.raw_output(request.input_data)
else:
test_result = kunit_parser.parse_run_tests(request.input_data)
parse_end = time.time()
 
+   if request.json:
+   json_obj = kunit_json.get_json_result(
+   test_result=test_result,
+   def_config='kunit_defconfig',
+   build_dir=request.build_dir,
+   json_path=request.json)
+   if request.json == 'stdout':
+   print(json_obj)
+
if test_result.status != kunit_parser.TestStatus.SUCCESS:
return KunitResult(KunitStatus.TEST_FAILURE, test_result,
   parse_end - parse_start)
@@ -151,7 +162,9 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree,
return exec_result
 
parse_request = KunitParseRequest(request.raw_output,
- exec_result.result)
+ exec_result.result,
+ request.build_dir,
+ request.json)
parse_result = parse_tests(parse_request)
 
run_end = time.time()
@@ -195,7 +208,12 @@ def add_exec_opts(parser):
 def add_parse_opts(parser):
parser.add_argument('--raw_output', help='don\'t format output from 
kernel',
action='store_true')
-
+   parser.add_argument('--json',
+   nargs='?',
+   help='Stores test results in a JSON, and either '
+   'prints to stdout or saves to file if a '
+   'filename is specified',
+   type=str, const='stdout', default=None)
 
 def main(argv, linux=None):
parser = argparse.ArgumentParser(
@@ -254,6 +272,7 @@ def main(argv, linux=None):
   cli_args.jobs,
   cli_args.build_dir,
   cli_args.alltests,
+  cli_args.json,
   cli_args.make_options)
result = run_tests(linux, request)
if result.status != KunitStatus.SUCCESS:
@@ -308,7 +327,9 @@ def main(argv, linux=None):
cli_args.alltests)
exec_result = exec_tests(linux, exec_request)
parse_request = KunitParseRequest(cli_args.raw_output,
- exec_result.result)
+ exec_result.result,
+ cli_args.build_dir,
+ 

[PATCH v1 1/2] kunit: tool: fix running kunit_tool from outside kernel tree

2020-08-07 Thread Brendan Higgins
Currently kunit_tool does not work correctly when executed from a path
outside of the kernel tree, so make sure that the current working
directory is correct and the kunit_dir is properly initialized before
running.

Signed-off-by: Brendan Higgins 
---
 tools/testing/kunit/kunit.py | 8 
 1 file changed, 8 insertions(+)

diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index 425ef40067e7..96344a11ff1f 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -237,9 +237,14 @@ def main(argv, linux=None):
 
cli_args = parser.parse_args(argv)
 
+   if get_kernel_root_path():
+   print('cd ' + get_kernel_root_path())
+   os.chdir(get_kernel_root_path())
+
if cli_args.subcommand == 'run':
if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir)
+   create_default_kunitconfig()
 
if not linux:
linux = kunit_kernel.LinuxSourceTree()
@@ -257,6 +262,7 @@ def main(argv, linux=None):
if cli_args.build_dir:
if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir)
+   create_default_kunitconfig()
 
if not linux:
linux = kunit_kernel.LinuxSourceTree()
@@ -273,6 +279,7 @@ def main(argv, linux=None):
if cli_args.build_dir:
if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir)
+   create_default_kunitconfig()
 
if not linux:
linux = kunit_kernel.LinuxSourceTree()
@@ -291,6 +298,7 @@ def main(argv, linux=None):
if cli_args.build_dir:
if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir)
+   create_default_kunitconfig()
 
if not linux:
linux = kunit_kernel.LinuxSourceTree()

base-commit: 30185b69a2d533c4ba6ca926b8390ce7de495e29
-- 
2.28.0.236.gb10cc79966-goog



Re: INFO: task hung in pipe_read (2)

2020-08-07 Thread Tetsuo Handa
On 2020/08/07 14:31, Andrea Arcangeli wrote:
>> Andrea? Comments? As mentioned, this is probably much too aggressive,
>> but I do think we need to limit the time that the kernel will wait for
>> page faults.
> 
> Why is pipe preventing to SIGKILL the task that is blocked on the
> mutex_lock? Is there any good reason for it or it simply has margin
> for improvement regardless of the hangcheck report? It'd be great if
> we can look into that before looking into the uffd specific bits.

It would be possible to use _killable version for this specific function, but

> 
> The hangcheck timer would have zero issues with tasks that can be
> killed, if only the pipe code could be improved to use mutex_lock_killable.
> 
>   /* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
>   if (t->state == TASK_UNINTERRUPTIBLE)
>   check_hung_task(t, timeout);
> 
> The hangcheck report is just telling us one task was in D state a
> little too long, but it wasn't fatal error and the kernel wasn't
> actually destabilized and the only malfunction reported is that a task
> was unkillable for too long.

use of killable waits disables ability to detect possibility of deadlock 
(because
lockdep can't check possibility of deadlock which involves actions in 
userspace), for
syzkaller process is SIGKILLed after 5 seconds while khungtaskd's timeout is 
140 seconds.

If we encounter a deadlock in an unattended operation (e.g. some server 
process),
we don't have a method for resolving the deadlock. Therefore, I consider that
t->state == TASK_UNINTERRUPTIBLE check is a bad choice. Unless a sleep is 
neutral
(e.g. no lock is held, or obviously safe to sleep with that specific lock held),
sleeping for 140 seconds inside the kernel is a bad sign even if 
interruptible/killable.

> 
> Now if it's impossible to improve the pipe code so it works better not
> just for uffd, there's still no reason to worry: we could disable uffd
> in the pipe context. For example ptrace opts-out of uffds, so that gdb
> doesn't get stuck if you read a pointer that should be handled by the
> process that is under debug. I hope it won't be necessary but it
> wouldn't be a major issue, certainly it wouldn't risk breaking qemu
> (and non-cooperative APIs are privileged so it could still skip the
> timeout).

Can we do something like this?

  bool retried = false;
retry:
  lock();
  disable_fault();
  ret = access_memory_that_might_fault();
  enable_fault();
  if (ret == -EWOULDFAULT && !retried)
goto retry_without_lock;
  if (ret == 0)
ret = do_something();
  unlock();
  return ret;
retry_without_lock:
  unlock();
  ret = access_memory_that_might_fault();
  retried = true;
  goto retry;



Re: [v2] i2c: mediatek: Fix i2c_spec_values description

2020-08-07 Thread Qii Wang
On Fri, 2020-08-07 at 15:19 +0200, matthias@kernel.org wrote:
> From: Matthias Brugger 
> 
> The struct i2c_spec_values have it's members documented but is
> missing the starting '@', which leads to warings like:
> 
> drivers/i2c/busses/i2c-mt65xx.c:267: warning: Function parameter or member 
> 'min_low_ns' not described in 'i2c_spec_values'
> 
> We also delete min_high_ns member as it is not used in the code.
> 
> Signed-off-by: Matthias Brugger 

Reviewed-by: Qii Wang 

> ---
> 
> Changes since v1:
> delete mint_high_ns member
> 
>  drivers/i2c/busses/i2c-mt65xx.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index e889f74703e4..efc14041d45b 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -253,14 +253,13 @@ struct mtk_i2c {
>  
>  /**
>   * struct i2c_spec_values:
> - * min_low_ns: min LOW period of the SCL clock
> - * min_su_sta_ns: min set-up time for a repeated START condition
> - * max_hd_dat_ns: max data hold time
> - * min_su_dat_ns: min data set-up time
> + * @min_low_ns: min LOW period of the SCL clock
> + * @min_su_sta_ns: min set-up time for a repeated START condition
> + * @max_hd_dat_ns: max data hold time
> + * @min_su_dat_ns: min data set-up time
>   */
>  struct i2c_spec_values {
>   unsigned int min_low_ns;
> - unsigned int min_high_ns;
>   unsigned int min_su_sta_ns;
>   unsigned int max_hd_dat_ns;
>   unsigned int min_su_dat_ns;



Re: [PATCH V2 4/9] PCI/AER: Extend AER error handling to RCECs

2020-08-07 Thread Sean V Kelley

On 7 Aug 2020, at 15:53, Bjorn Helgaas wrote:


On Tue, Aug 04, 2020 at 12:40:47PM -0700, Sean V Kelley wrote:

From: Jonathan Cameron 

Currently the kernel does not handle AER errors for Root Complex 
integrated
End Points (RCiEPs)[0]. These devices sit on a root bus within the 
Root Complex
(RC). AER handling is performed by a Root Complex Event Collector 
(RCEC) [1]

which is a effectively a type of RCiEP on the same root bus.

For an RCEC (technically not a Bridge), error messages "received" 
from
associated RCiEPs must be enabled for "transmission" in order to 
cause a
System Error via the Root Control register or (when the Advanced 
Error

Reporting Capability is present) reporting via the Root Error Command
register and logging in the Root Error Status register and Error 
Source

Identification register.

In addition to the defined OS level handling of the reset flow for 
the
associated RCiEPs of an RCEC, it is possible to also have a firmware 
first
model. In that case there is no need to take any actions on the RCEC 
because
the firmware is responsible for them. This is true where APEI [2] is 
used

to report the AER errors via a GHES[v2] HEST entry [3] and relevant
AER CPER record [4] and Firmware First handling is in use.


I don't see anything in the patch that mentions "firmware first." Do
we need it in the commit log?  After
https://git.kernel.org/linus/708b20003624 ("PCI/AER: Remove
HEST/FIRMWARE_FIRST parsing for AER ownership"), I think we no longer
know anything about firmware-first in the kernel.


I’ll let Jonathan reply here.




We effectively end up with two different types of discovery for
purposes of handling AER errors:

1) Normal bus walk - we pass the downstream port above a bus to which
the device is attached and it walks everything below that point.

2) An RCiEP with no visible association with an RCEC as there is no 
need to
walk devices. In that case, the flow is to just call the callbacks 
for the actual

device.

A new walk function, similar to pci_bus_walk is provided that takes a 
pci_dev
instead of a bus. If that dev corresponds to a downstream port it 
will walk
the subordinate bus of that downstream port. If the dev does not then 
it

will call the function on that device alone.


Maybe mention the new function name here?


Agree, I will mention it here.



Add "()" after function names in commit logs and comments so they
don't look like English words.


Will fix.



Wrap commit logs so they fit in 75 columns, so they don't wrap when
"git log" indents them in a default 80 column window.  Yes, I know I
could use wider windows, but I'd still want *some* default so commits
don't just have random widths.


Will fix.



[0] ACPI PCI Express Base Specification 5.0-1 1.3.2.3 Root Complex 
Integrated

Endpoint Rules.
[1] ACPI PCI Express Base Specification 5.0-1 6.2 Error Signalling 
and Logging
[2] ACPI Specification 6.3 Chapter 18 ACPI Platform Error Interface 
(APEI)

[3] ACPI Specification 6.3 18.2.3.7 Generic Hardware Error Source
[4] UEFI Specification 2.8, N.2.7 PCI Express Error Section

Signed-off-by: Jonathan Cameron 
Signed-off-by: Sean V Kelley 
---
 drivers/pci/pcie/err.c | 59 
+-

 1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index c543f419d8f9..682302dfb55b 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -146,38 +146,69 @@ static int report_resume(struct pci_dev *dev, 
void *data)

return 0;
 }

+/**
+ * pci_walk_dev_affected - walk devices potentially AER affected
+ * @dev  device which may be an RCEC with associated RCiEPs,
+ *   an RCiEP associated with an RCEC, or a Port.


Does this mean that if dev is an RCEC, we call the callback for the
*RCEC* itself?  I would have thought we'd want to do that for the
associated *RCiEPs*?


Yes, we do. The errors can come from either an RCEC or its respective 
RCiEPs. Both Root Port and RCEC can report error for themselves. So both 
an error Root Port device and an error RCEC device can be passed here 
for error handling. In fact, the bit corresponding to the device number 
of the RCEC is always set in the RCiEP Bitmap (section 7.9.2). And an 
RCEC must also follow all the rules for an RCiEP (section 1.3.4).


I was wanting to do a test with an AER injection of the RCEC itself. But 
it looks like current aer_inject.c doesn’t support injecting an error 
to Root Ports or RCECs. Will need to take a look at it.





+ * @cb   callback to be called for each device found
+ * @userdata arbitrary pointer to be passed to callback.
+ *
+ * If the device provided is a port, walk the subordinate bus,


This usage of "port" doesn't seem quite right.  "Port" includes root
ports, switch upstream ports, switch downstream ports, *and* the
upstream ports on endpoints.  The endpoint upstream ports obviously
don't have subordinate buses.  We typically use "bridge" as the
generic term 

Re: [PATCH 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-07 Thread Grant Feng

Thanks for the review, I will rewrit it.

Grant

On 2020-08-06 23:00, Dan Murphy wrote:

Grant

On 8/6/20 1:21 AM, Grant Feng wrote:

generate a 5ms low pulse on sdb pin when startup, then the chip
becomes more stable in the complex EM environment.

Signed-off-by: Grant Feng 
---
  drivers/leds/leds-is31fl319x.c | 12 
  1 file changed, 12 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c 
b/drivers/leds/leds-is31fl319x.c

index ca6634b8683c..b4f70002cec9 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
    /* register numbers */
  #define IS31FL319X_SHUTDOWN    0x00
@@ -61,6 +63,7 @@
  struct is31fl319x_chip {
  const struct is31fl319x_chipdef *cdef;
  struct i2c_client   *client;
+    struct gpio_desc    *sdb_pin;
  struct regmap   *regmap;
  struct mutex    lock;
  u32 audio_gain_db;
@@ -265,6 +268,15 @@ static int is31fl319x_parse_dt(struct device *dev,
  is31->audio_gain_db = min(is31->audio_gain_db,
    IS31FL319X_AUDIO_GAIN_DB_MAX);
  +    is31->sdb_pin = gpiod_get(dev, "sdb", GPIOD_ASIS);


Since this is optional maybe use devm_gpiod_get_optional.

If this is required for stability then if the GPIO is not present then 
the parse_dt should return the error.


And use the devm_gpiod_get call.  Otherwise you are missing the 
gpiod_put when exiting or removing the driver.


Dan





drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: sparse: incorrect type in argument 2 (different address spaces)

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to 
define address spaces
date:   7 weeks ago
config: xtensa-randconfig-s031-20200808 (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-118-ge1578773-dirty
git checkout 670d0a4b10704667765f7d18f7592993d02783aa
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=xtensa 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)

   drivers/net/ethernet/natsemi/xtsonic.c:198:5: sparse: sparse: symbol 
'xtsonic_probe' was not declared. Should it be static?
   drivers/net/ethernet/natsemi/xtsonic.c: note: in included file:
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void volatile 
>> [noderef] __iomem *addr @@ got unsigned short [usertype] * @@
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: expected void 
>> volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: got unsigned short 
[usertype] *
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef] __iomem *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: expected void 
volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: got unsigned short 
[usertype] *
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void volatile 
>> [noderef] __iomem *addr @@ got unsigned short [usertype] * @@
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: expected void 
>> volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: got unsigned short 
[usertype] *
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef] __iomem *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: expected void 
volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: got unsigned short 
[usertype] *
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void volatile 
>> [noderef] __iomem *addr @@ got unsigned short [usertype] * @@
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: expected void 
>> volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: got unsigned short 
[usertype] *
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef] __iomem *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: expected void 
volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: got unsigned short 
[usertype] *
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void volatile 
>> [noderef] __iomem *addr @@ got unsigned short [usertype] * @@
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: expected void 
>> volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: got unsigned short 
[usertype] *
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef] __iomem *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: expected void 
volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:361:55: sparse: got unsigned short 
[usertype] *
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void volatile 
>> [noderef] __iomem *addr @@ got unsigned short [usertype] * @@
>> drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: expected void 
>> volatile [noderef] __iomem *addr
   drivers/net/ethernet/natsemi/sonic.h:356:55: sparse: got unsigned short 
[usertype] *
   

arch/mips/kvm/vz.c:32:10: fatal error: loongson_regs.h: No such file or directory

2020-08-07 Thread kernel test robot
Hi Huacai,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: 7f2a83f1c2a941ebfee53f504ed5fdbc61cfb333 KVM: MIPS: Add CPUCFG 
emulation for Loongson-3
date:   9 weeks ago
config: mips-randconfig-r024-20200808 (attached as .config)
compiler: mips64el-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 7f2a83f1c2a941ebfee53f504ed5fdbc61cfb333
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

>> arch/mips/kvm/vz.c:32:10: fatal error: loongson_regs.h: No such file or 
>> directory
  32 | #include "loongson_regs.h"
 |  ^
   compilation terminated.

vim +32 arch/mips/kvm/vz.c

30  
31  #include "interrupt.h"
  > 32  #include "loongson_regs.h"
33  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH] seg6: using DSCP of inner IPv4 packets

2020-08-07 Thread David Miller
From: Ahmed Abdelsalam 
Date: Thu, 6 Aug 2020 08:43:06 +0200

> SRv6 as defined in [1][2] does not mandate that the hop_limit of the
> outer IPv6 header has to be copied from the inner packet.

This is not an issue of seg6 RFCs, but rather generic ip6 in ip6
tunnel encapsulation.

Therefore, what the existing ip6 tunnel encap does is our guide,
and it inherits from the inner header.

And that's what the original seg6 code almost certainly used to
guide the decision making in this area.


Re: [PATCH] drivers: watchdog: rdc321x_wdt: Fix race condition bugs

2020-08-07 Thread Florian Fainelli



On 8/7/2020 4:23 PM, Guenter Roeck wrote:
> Hi Florian,
> 
> On 8/7/20 1:09 PM, Florian Fainelli wrote:
>>
>> On 8/7/2020 12:08 PM, Guenter Roeck wrote:
>>> On 8/7/20 11:08 AM, Florian Fainelli wrote:


 On 8/7/2020 9:21 AM, Guenter Roeck wrote:
> On Fri, Aug 07, 2020 at 04:59:02PM +0530, madhuparnabhowmi...@gmail.com 
> wrote:
>> From: Madhuparna Bhowmik 
>>
>> In rdc321x_wdt_probe(), rdc321x_wdt_device.queue is initialized
>> after misc_register(), hence if ioctl is called before its
>> initialization which can call rdc321x_wdt_start() function,
>> it will see an uninitialized value of rdc321x_wdt_device.queue,
>> hence initialize it before misc_register().
>> Also, rdc321x_wdt_device.default_ticks is accessed in reset()
>> function called from write callback, thus initialize it before
>> misc_register().
>>
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Madhuparna Bhowmik 
>
> Reviewed-by: Guenter Roeck 
>
> Having said that ... this is yet another potentially obsolete driver.
> You are really wasting your (and, fwiw, my) time.
>
> Florian, any thoughts if support for this chip can/should be deprecated
> or even removed ?

 I am still using my rdc321x-based SoC, so no, this is not obsolete as
 far as I am concerned, time permitting, modernizing the driver is on my
 TODO after checking/fixing the Ethernet driver first.

>>>
>>> Do you have a manual ? I'd give it a try if you can test it - conversion
>>> should be simple enough (I have a coccinelle script which partially
>>> automates it), but this chip seems to have a fast timeout, and the
>>> comments in the code ("set the timeout to 81.92 us") seem to be quite
>>> obviously wrong.
>>
>> Yes, there is a public manual for that SoC, search for RDC R8610 and the
>> first link you find should be a 276 page long manual for the SoC.
>>
> 
> I found two, one for R8610 and one for R8610-G.

The R8610-G datasheet is the one that I have had and used thus far.

> Unfortunately, none of those
> describes the use of bit(31) in the watchdog register, nor the meaning
> of bit(12) and bit(13). Bit(31) is described in the code as "Mask",
> and it is set by a couple of commands. I _suspect_ that bit(31) has to be
> set to change some of the register bits, for example the counter value.
> That is just a wild guess, but it would explain why the driver works
> in the first place.
> 
> It is also not clear if the bits in the counter register are accumulative
> or if only the highest bit counts. The datasheets suggest that only the
> highest bit counts, but then the value of RDC_CLS_TMR doesn't make much
> sense since it sets two bits.
> 
> Since you wrote the driver, I was hoping that you might have a datasheet
> which explains all this in more detail.

I do not, and this was over 12 years ago, and I honestly do not recall
all the details, when I get the board running a newish kernel, I will
poke around.
-- 
Florian


Re: [PATCH v2 net-next] net/tls: allow MSG_CMSG_COMPAT in sendmsg

2020-08-07 Thread David Miller
From: Rouven Czerwinski 
Date: Thu,  6 Aug 2020 08:49:06 +0200

> Trying to use ktls on a system with 32-bit userspace and 64-bit kernel
> results in a EOPNOTSUPP message during sendmsg:
> 
>   setsockopt(3, SOL_TLS, TLS_TX, …, 40) = 0
>   sendmsg(3, …, msg_flags=0}, 0) = -1 EOPNOTSUPP (Operation not supported)
> 
> The tls_sw implementation does strict flag checking and does not allow
> the MSG_CMSG_COMPAT flag, which is set if the message comes in through
> the compat syscall.
> 
> This patch adds MSG_CMSG_COMPAT to the flag check to allow the usage of
> the TLS SW implementation on systems using the compat syscall path.
> 
> Note that the same check is present in the sendmsg path for the TLS
> device implementation, however the flag hasn't been added there for lack
> of testing hardware.
> 
> Signed-off-by: Rouven Czerwinski 

I'll apply this, thank you.


[PATCH v2] KVM: SVM: Mark SEV launch secret pages as dirty.

2020-08-07 Thread Cfir Cohen
The LAUNCH_SECRET command performs encryption of the
launch secret memory contents. Mark pinned pages as
dirty, before unpinning them.
This matches the logic in sev_launch_update_data().

Signed-off-by: Cfir Cohen 
---
Changelog since v1:
 - Updated commit message.

 arch/x86/kvm/svm/sev.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 5573a97f1520..37c47d26b9f7 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -850,7 +850,7 @@ static int sev_launch_secret(struct kvm *kvm, struct 
kvm_sev_cmd *argp)
struct kvm_sev_launch_secret params;
struct page **pages;
void *blob, *hdr;
-   unsigned long n;
+   unsigned long n, i;
int ret, offset;
 
if (!sev_guest(kvm))
@@ -863,6 +863,14 @@ static int sev_launch_secret(struct kvm *kvm, struct 
kvm_sev_cmd *argp)
if (!pages)
return -ENOMEM;
 
+   /*
+* The LAUNCH_SECRET command will perform in-place encryption of the
+* memory content (i.e it will write the same memory region with C=1).
+* It's possible that the cache may contain the data with C=0, i.e.,
+* unencrypted so invalidate it first.
+*/
+   sev_clflush_pages(pages, n);
+
/*
 * The secret must be copied into contiguous memory region, lets verify
 * that userspace memory pages are contiguous before we issue command.
@@ -908,6 +916,11 @@ static int sev_launch_secret(struct kvm *kvm, struct 
kvm_sev_cmd *argp)
 e_free:
kfree(data);
 e_unpin_memory:
+   /* content of memory is updated, mark pages dirty */
+   for (i = 0; i < n; i++) {
+   set_page_dirty_lock(pages[i]);
+   mark_page_accessed(pages[i]);
+   }
sev_unpin_memory(kvm, pages, n);
return ret;
 }
-- 
2.28.0.236.gb10cc79966-goog



Re: [PATCH v2] i2c: iproc: fix race between client unreg and isr

2020-08-07 Thread Florian Fainelli



On 8/7/2020 3:02 PM, Dhananjay Phadke wrote:
> When i2c client unregisters, synchronize irq before setting
> iproc_i2c->slave to NULL.
> 
> (1) disable_irq()
> (2) Mask event enable bits in control reg
> (3) Erase slave address (avoid further writes to rx fifo)
> (4) Flush tx and rx FIFOs
> (5) Clear pending event (interrupt) bits in status reg
> (6) enable_irq()
> (7) Set client pointer to NULL
> 
> Unable to handle kernel NULL pointer dereference at virtual address 
> 0318
> 
> [  371.020421] pc : bcm_iproc_i2c_isr+0x530/0x11f0
> [  371.025098] lr : __handle_irq_event_percpu+0x6c/0x170
> [  371.030309] sp : 800010003e40
> [  371.033727] x29: 800010003e40 x28: 0060
> [  371.039206] x27: 800010ca9de0 x26: 800010f895df
> [  371.044686] x25: 800010f1 x24: 0008f7ff3600
> [  371.050165] x23: 0003 x22: 0160
> [  371.055645] x21: 800010f1 x20: 0160
> [  371.061124] x19: 0008f726f080 x18: 
> [  371.066603] x17:  x16: 
> [  371.072082] x15:  x14: 
> [  371.077561] x13:  x12: 0001
> [  371.083040] x11:  x10: 0040
> [  371.088519] x9 : 800010f317c8 x8 : 800010f317c0
> [  371.093999] x7 : 0008f805b3b0 x6 : 
> [  371.099478] x5 : 0008f7ff36a4 x4 : 8008ee43d000
> [  371.104957] x3 :  x2 : 8000107d64c0
> [  371.110436] x1 : c0af x0 : 
> 
> [  371.115916] Call trace:
> [  371.118439]  bcm_iproc_i2c_isr+0x530/0x11f0
> [  371.122754]  __handle_irq_event_percpu+0x6c/0x170
> [  371.127606]  handle_irq_event_percpu+0x34/0x88
> [  371.132189]  handle_irq_event+0x40/0x120
> [  371.136234]  handle_fasteoi_irq+0xcc/0x1a0
> [  371.140459]  generic_handle_irq+0x24/0x38
> [  371.144594]  __handle_domain_irq+0x60/0xb8
> [  371.148820]  gic_handle_irq+0xc0/0x158
> [  371.152687]  el1_irq+0xb8/0x140
> [  371.155927]  arch_cpu_idle+0x10/0x18
> [  371.159615]  do_idle+0x204/0x290
> [  371.162943]  cpu_startup_entry+0x24/0x60
> [  371.166990]  rest_init+0xb0/0xbc
> [  371.170322]  arch_call_rest_init+0xc/0x14
> [  371.174458]  start_kernel+0x404/0x430
> 
> Fixes: c245d94ed106 ("i2c: iproc: Add multi byte read-write support for slave 
> mode")
> 
> Signed-off-by: Dhananjay Phadke 
> ---
>  drivers/i2c/busses/i2c-bcm-iproc.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c 
> b/drivers/i2c/busses/i2c-bcm-iproc.c
> index 8a3c98866fb7..c576776ffb10 100644
> --- a/drivers/i2c/busses/i2c-bcm-iproc.c
> +++ b/drivers/i2c/busses/i2c-bcm-iproc.c
> @@ -1078,7 +1078,7 @@ static int bcm_iproc_i2c_unreg_slave(struct i2c_client 
> *slave)
>   if (!iproc_i2c->slave)
>   return -EINVAL;
>  
> - iproc_i2c->slave = NULL;
> + disable_irq(iproc_i2c->irq);
>  
>   /* disable all slave interrupts */
>   tmp = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET);
> @@ -1091,6 +1091,17 @@ static int bcm_iproc_i2c_unreg_slave(struct i2c_client 
> *slave)
>   tmp &= ~BIT(S_CFG_EN_NIC_SMB_ADDR3_SHIFT);
>   iproc_i2c_wr_reg(iproc_i2c, S_CFG_SMBUS_ADDR_OFFSET, tmp);
>  
> + /* flush TX/RX FIFOs */
> + tmp = (BIT(S_FIFO_RX_FLUSH_SHIFT) | BIT(S_FIFO_TX_FLUSH_SHIFT));
> + iproc_i2c_wr_reg(iproc_i2c, S_FIFO_CTRL_OFFSET, tmp);
> +
> + /* clear all pending slave interrupts */
> + iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, ISR_MASK_SLAVE);
> +
> + enable_irq(iproc_i2c->irq);
> +
> + iproc_i2c->slave = NULL;

There is nothing that checks on iproc_i2c->slave being valid within the
interrupt handler, we assume that the pointer is valid which is fin,
however non functional it may be, it may feel more natural to move the
assignment before the enable_irq()?
-- 
Florian


drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: got unsigned short COPYING CREDITS Documentation Kbuild Kconfig LICENSES MAINTAINERS Makefile README arch block certs crypto drivers fs include ini

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: e3885f576196ddfc670b3d53e745de96ffcb49ab net/sonic: Use MMIO accessors
date:   7 months ago
config: xtensa-randconfig-s031-20200808 (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-118-ge1578773-dirty
git checkout e3885f576196ddfc670b3d53e745de96ffcb49ab
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=xtensa 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)

   drivers/net/ethernet/natsemi/xtsonic.c: note: in included file (through 
arch/xtensa/include/uapi/asm/unistd.h, arch/xtensa/include/asm/unistd.h, 
include/uapi/linux/unistd.h, ...):
   ./arch/xtensa/include/generated/uapi/asm/unistd_32.h:391:41: sparse: sparse: 
no newline at end of file
   drivers/net/ethernet/natsemi/xtsonic.c:234:5: sparse: sparse: symbol 
'xtsonic_probe' was not declared. Should it be static?
   drivers/net/ethernet/natsemi/xtsonic.c: note: in included file:
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: expected void 
volatile [noderef]  *addr
>> drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: got unsigned short 
>> [usertype] *
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: expected void 
volatile [noderef]  *addr
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: got unsigned short 
[usertype] *
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: expected void 
volatile [noderef]  *addr
>> drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: got unsigned short 
>> [usertype] *
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: expected void 
volatile [noderef]  *addr
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: got unsigned short 
[usertype] *
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: expected void 
volatile [noderef]  *addr
>> drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: got unsigned short 
>> [usertype] *
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: expected void 
volatile [noderef]  *addr
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: got unsigned short 
[usertype] *
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: expected void 
volatile [noderef]  *addr
>> drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: got unsigned short 
>> [usertype] *
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: expected void 
volatile [noderef]  *addr
   drivers/net/ethernet/natsemi/sonic.h:358:55: sparse: got unsigned short 
[usertype] *
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void volatile 
[noderef]  *addr @@ got unsigned short [usertype] * @@
   drivers/net/ethernet/natsemi/sonic.h:353:55: sparse: expected void 
volatile 

Re: [PATCH V7 2/4] rpmsg: Guard against null endpoint ops in destroy

2020-08-07 Thread Chris Lew

Hi Greg,

On 8/7/2020 12:59 AM, Greg KH wrote:

On Wed, Jun 24, 2020 at 10:15:19PM +0530, Deepak Kumar Singh wrote:

From: Chris Lew 

In RPMSG GLINK the chrdev device will allocate an ept as part of the
rpdev creation. This device will not register endpoint ops even though
it has an allocated ept. Protect against the case where the device is
being destroyed.

Signed-off-by: Chris Lew 
Signed-off-by: Deepak Kumar Singh 
Signed-off-by: Arun Kumar Neelakantam 


Should this be marked for stable kernels?

And if so, what commit does this fix?  Any reason the Fixes: tag was not
used here?



The crash that this fixes doesn't show up unless one of the previous 
patches in the series is applied.


[PATCH V6 3/5] rpmsg: glink: Add support for rpmsg glink chrdev

I'm not sure if the fixes tag should apply to this change or one of the 
commits to the base rpmsg code.



And what happened to this series?  I don't see it in linux-next, did the
maintainer ignore it?



I believe most of the review feedback for the series has been addressed 
by Deepak. There is one remaining action item for me and Deepak to 
provide more concrete evidence that the first patch in the series is 
needed.


[PATCH V6 1/5] rpmsg: glink: Use complete_all for open states


thanks,

greg k-h



Thanks,
Chris

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


include/linux/bits.h:25:21: error: first argument to '__builtin_choose_expr' not a constant

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: 295bcca84916cb5079140a89fccb472bb8d1f6e2 linux/bits.h: add compile time 
sanity check of GENMASK inputs
date:   4 months ago
config: s390-randconfig-r001-20200808 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 295bcca84916cb5079140a89fccb472bb8d1f6e2
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
ARCH=s390 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   drivers/mux/mmio.c: In function 'mux_mmio_probe':
   drivers/mux/mmio.c:76:20: error: storage size of 'field' isn't known
  76 |   struct reg_field field;
 |^
   In file included from include/linux/bits.h:23,
from include/linux/bitops.h:5,
from drivers/mux/mmio.c:8:
>> include/linux/bits.h:25:21: error: first argument to '__builtin_choose_expr' 
>> not a constant
  25 |  (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
 | ^
   include/linux/build_bug.h:16:62: note: in definition of macro 
'BUILD_BUG_ON_ZERO'
  16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); 
})))
 |  ^
   include/linux/bits.h:39:3: note: in expansion of macro 'GENMASK_INPUT_CHECK'
  39 |  (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
 |   ^~~
   drivers/mux/mmio.c:96:15: note: in expansion of macro 'GENMASK'
  96 |   if (mask != GENMASK(field.msb, field.lsb)) {
 |   ^~~
   include/linux/build_bug.h:16:51: error: bit-field '' width not an 
integer constant
  16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); 
})))
 |   ^
   include/linux/bits.h:25:3: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
  25 |  (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
 |   ^
   include/linux/bits.h:39:3: note: in expansion of macro 'GENMASK_INPUT_CHECK'
  39 |  (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
 |   ^~~
   drivers/mux/mmio.c:96:15: note: in expansion of macro 'GENMASK'
  96 |   if (mask != GENMASK(field.msb, field.lsb)) {
 |   ^~~
   drivers/mux/mmio.c:102:15: error: implicit declaration of function 
'devm_regmap_field_alloc' [-Werror=implicit-function-declaration]
 102 |   fields[i] = devm_regmap_field_alloc(dev, regmap, field);
 |   ^~~
   drivers/mux/mmio.c:76:20: warning: unused variable 'field' 
[-Wunused-variable]
  76 |   struct reg_field field;
 |^
   cc1: some warnings being treated as errors

vim +/__builtin_choose_expr +25 include/linux/bits.h

15  
16  /*
17   * Create a contiguous bitmask starting at bit position @l and ending at
18   * position @h. For example
19   * GENMASK_ULL(39, 21) gives us the 64bit vector 0x00e0.
20   */
21  #if !defined(__ASSEMBLY__) && \
22  (!defined(CONFIG_CC_IS_GCC) || CONFIG_GCC_VERSION >= 49000)
  > 23  #include 
24  #define GENMASK_INPUT_CHECK(h, l) \
  > 25  (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
26  __builtin_constant_p((l) > (h)), (l) > (h), 0)))
27  #else
28  /*
29   * BUILD_BUG_ON_ZERO is not available in h files included from asm 
files,
30   * disable the input check if that is the case.
31   */
32  #define GENMASK_INPUT_CHECK(h, l) 0
33  #endif
34  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH v5 0/2] Add 802.1AD protocol support for dsa switch and ocelot driver

2020-08-07 Thread David Miller
From: hongbo.w...@nxp.com
Date: Fri,  7 Aug 2020 19:13:47 +0800

> From: "hongbo.wang" 
> 
> 1. the patch 0001* is for setting single port into 802.1AD(QinQ) mode,
> before this patch, the function dsa_slave_vlan_rx_add_vid didn't pass 
> the parameter "proto" to next port level, so switch's port can't get
> parameter "proto"
>   after applying this patch, the following command can be supported:
>   ip link set br0 type bridge vlan_protocol 802.1ad
>   ip link add link swp1 name swp1.100 type vlan protocol 802.1ad id 100
> 
> 2. the patch 0002* is for setting QinQ related registers in ocelot 
> switch driver, after applying this patch, the switch(VSC99599)'s port can
> enable or disable QinQ mode.
> 
> 3. Version log
> v5:
> a. add devlink to enable qinq_mode of ocelot's single port
> b. modify br_switchdev_port_vlan_add to pass bridge's vlan_proto to port 
> driver
> c. enable NETIF_F_HW_VLAN_STAG_FILTER in ocelot driver
> v4:
> a. modify slave.c to support "ip set br0 type bridge vlan_protocol 802.1ad"
> b. modify ocelot.c, if enable QinQ, set VLAN_AWARE_ENA and VLAN_POP_CNT per
>port when vlan_filter=1
> v3: combine two patches to one post

Please defer new feature changes, like this, until the net-next tree is open
again.  It is closed right now.

Thank you.


Re: [GIT PULL] sound updates for 5.9

2020-08-07 Thread John Stultz
On Thu, Aug 6, 2020 at 3:33 AM Takashi Iwai  wrote:
>
> Linus,
>
> please pull sound updates for v5.9 from:
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git 
> tags/sound-5.9-rc1
>
> The topmost commit is c7fabbc51352f50cc58242a6dc3b9c1a3599849b
>
> 
>
> sound updates for 5.9
>
> This became wide and scattered updates all over the sound tree as
> diffstat shows: lots of (still ongoing) refactoring works in ASoC,
> fixes and cleanups caught by static analysis, inclusive term
> conversions as well as lots of new drivers.  Below are highlights:
>
> ASoC core:
> * API cleanups and conversions to the unified mute_stream() call
> * Simplify I/O helper functions
> * Use helper macros to retrieve RTD from substreams
...
> Kuninori Morimoto (90):
>   ASoC: soc-component: add soc_component_pin() and share code
>   ASoC: soc-component: move snd_soc_component_xxx_regmap() to 
> soc-component
>   ASoC: soc-component: move snd_soc_component_initialize() to 
> soc-component.c
>   ASoC: soc-component: add soc_component_err()
>   ASoC: soc-component: add snd_soc_pcm_component_prepare()
>   ASoC: soc-component: add snd_soc_pcm_component_hw_params()
>   ASoC: soc-component: add snd_soc_pcm_component_hw_free()
>   ASoC: soc-component: add snd_soc_pcm_component_trigger()
>   ASoC: soc-component: add snd_soc_component_init()
>   ASoC: soc-component: merge soc-io.c into soc-component.c

So oddly, today I bisected down the change "ASoC: soc-component: merge
soc-io.c into soc-component.c":
  
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=460b42d162e3cf634586999e6a84e74ca52e626d

as causing audio regressions on Dragonboard 845c running AOSP.

On boot I was seeing tons of:
q6routing remoteproc-adsp:glink-edge:apr:apr-service@8:routing: ASoC:
error at soc_component_read_no_lock on
remoteproc-adsp:glink-edge:apr:: -5

And when audio was supposed to play I'd see:
[  227.462986] qcom-q6afe aprsvc:apr-service:4:4: cmd = 0x100e5
returned error = 0x9
[  227.470720] qcom-q6afe aprsvc:apr-service:4:4: DSP returned error[9]
[  227.477168] qcom-q6afe aprsvc:apr-service:4:4: AFE enable for port
0x4000 failed -22
[  227.485038] q6afe-dai
remoteproc-adsp:glink-edge:apr:apr-service@4:dais: fail to start AFE
port 2
[  227.494013] q6afe-dai
remoteproc-adsp:glink-edge:apr:apr-service@4:dais: ASoC: error at
snd_soc_pcm_dai_prepare on SLIMBUS_0_RX: -22
[  227.506034]  SLIM Playback: ASoC: DAI prepare error: -22
[  227.511415]  SLIM Playback: ASoC: backend prepare failed -22

Its strange, as the bisected patch is really just moving code around
and there's very little in the way of logic changes. After minimizing
the code movement and just focusing on what changed I forward ported a
revert to mainline and minimized it until things were working.

The resulting patch is a twoliner here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?h=dev/db845c-mainline-WIP=a3527193f39b1224d59bf1519fce3ef8c57d0f5e

I'm a bit baffled as to why this patch works. Logically we are
returning the same value. I suspect when we hit the error, all the
extra error print messages on the console slow things down and end up
causing some timing related initialization failure?

Anyway, I wanted to raise the issue in case anyone had ideas what
might be going wrong.

thanks
-john


Re: [PATCH v7 3/9] net/scm: Regularize compat handling of scm_detach_fds()

2020-08-07 Thread John Stultz
On Fri, Aug 7, 2020 at 3:18 PM Kees Cook  wrote:
>
> On Fri, Aug 07, 2020 at 01:29:24PM -0700, John Stultz wrote:
> > On Thu, Jul 9, 2020 at 11:28 AM Kees Cook  wrote:
> > >
> > > Duplicate the cleanups from commit 2618d530dd8b ("net/scm: cleanup
> > > scm_detach_fds") into the compat code.
> > >
> > > Replace open-coded __receive_sock() with a call to the helper.
> > >
> > > Move the check added in commit 1f466e1f15cf ("net: cleanly handle kernel
> > > vs user buffers for ->msg_control") to before the compat call, even
> > > though it should be impossible for an in-kernel call to also be compat.
> > >
> > > Correct the int "flags" argument to unsigned int to match fd_install()
> > > and similar APIs.
> > >
> > > Regularize any remaining differences, including a whitespace issue,
> > > a checkpatch warning, and add the check from commit 6900317f5eff ("net,
> > > scm: fix PaX detected msg_controllen overflow in scm_detach_fds") which
> > > fixed an overflow unique to 64-bit. To avoid confusion when comparing
> > > the compat handler to the native handler, just include the same check
> > > in the compat handler.
> > >
> > > Acked-by: Christian Brauner 
> > > Signed-off-by: Kees Cook 
> > > ---
> >
> > Hey Kees,
> >   So during the merge window (while chasing a few other regressions),
> > I noticed occasionally my Dragonboard 845c running AOSP having trouble
> > with the web browser crashing or other apps hanging, and I've bisected
> > the issue down to this change.
> >
> > Unfortunately it doesn't revert cleanly so I can't validate reverting
> > it sorts things against linus/HEAD.  Anyway, I wanted to check and see
> > if you had any other reports of similar or any ideas what might be
> > going wrong?
>
> Hi; Yes, sorry for the trouble. I had a typo in a refactor of
> SCM_RIGHTS. I suspect it'll be fixed by this:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1fa2c0a0c814fbae0eb3e79a510765225570d043
>
> Can you verify Linus's latest tree works for you? If not, there might be
> something else hiding in the corners...

Thanks so much! Yes, I just updated to Linus' latest and the issue has
disappeared!

thanks again!
-john


Re: [PATCH v4 05/10] sched/topology: Define and assign sched_domain flag metadata

2020-08-07 Thread Valentin Schneider


On 06/08/20 17:18, Valentin Schneider wrote:
> In the grand scheme of things I'd actually like to have this file output
> the names of the flags rather than their values (since I now save them when
> SCHED_DEBUG=y), but I didn't find a simple way to hack the existing SD ctl
> table (sd_alloc_ctl_domain_table() and co) into doing this.
>

I "just" had to spend some more time grokking how the whole ctl
proc_handler thing is supposed to work; I now have a mostly working
solution, i.e. on my Juno:

  $ cat /proc/sys/kernel/sched_domain/cpu0/domain*/flags
  SD_BALANCE_NEWIDLE SD_BALANCE_EXEC SD_BALANCE_FORK SD_WAKE_AFFINE 
SD_SHARE_PKG_RESOURCES
  SD_BALANCE_NEWIDLE SD_BALANCE_EXEC SD_BALANCE_FORK SD_WAKE_AFFINE 
SD_ASYM_CPUCAPACITY SD_PREFER_SIBLING

I'll clean that up and go for the automagic ordering I previously
described.

>
> Now as to making this fully automagic, I *think* I could do something like
> having a first enum to set up an ordering:
>
>   #define SD_FLAG(name, ...) __##name,
>   enum {
> #include 
>   };
>
> A second one to have powers of 2:
>
>   #define SD_FLAG(name, ...) name = 1 << __##name,
>   enum {
> #include 
>   };
>
> And finally the metadata array assignment might be doable with:
>
>   #define SD_FLAG(_name, mflags) [__##_name] = { .meta_flags = mflags, .name 
> = #_name },
>
> Or, if there is a way somehow to directly get powers of 2 out of an enum:
>
>   #define SD_FLAG(_name, mflags) [_ffs(_name)] = { .meta_flags = mflags, 
> .name = #_name },
>
>>> +#ifdef CONFIG_SCHED_DEBUG
>>> +#define SD_FLAG(_name, idx, mflags) [idx] = {.meta_flags = mflags, .name = 
>>> #_name},
>>
>> s/{./{ .
>> s/e}/e }
>>
>> Thanks,
>>
>>   Ingo


arch/powerpc/kexec/crash.c:200 crash_kexec_secondary() warn: inconsistent returns 'flags'.

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: 793b08e2efff3ec020c5c5861d00ed394fcdd488 powerpc/kexec: Move kexec 
files into a dedicated subdir.
date:   9 months ago
config: powerpc-randconfig-m031-20200808 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

smatch warnings:
arch/powerpc/kexec/crash.c:200 crash_kexec_secondary() warn: inconsistent 
returns 'flags'.

vim +/flags +200 arch/powerpc/kexec/crash.c

c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  178  
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  179  /*
9b00ac06978c54 arch/powerpc/kernel/crash.c Anton Blanchard 2011-11-30  180   * 
This function will be called by secondary cpus.
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  181   */
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  182  
void crash_kexec_secondary(struct pt_regs *regs)
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  183  {
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  184  
unsigned long flags;
549e88a134b3b3 arch/powerpc/kernel/crash.c Anton Blanchard 2011-11-30  185  
int msecs = SECONDARY_TIMEOUT;
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  186  
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  187  
local_irq_save(flags);
9b00ac06978c54 arch/powerpc/kernel/crash.c Anton Blanchard 2011-11-30  188  
549e88a134b3b3 arch/powerpc/kernel/crash.c Anton Blanchard 2011-11-30  189  
/* Wait for the primary crash CPU to signal its progress */
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  190  
while (crashing_cpu < 0) {
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  191  
if (--msecs < 0) {
9b00ac06978c54 arch/powerpc/kernel/crash.c Anton Blanchard 2011-11-30  192  
/* No response, kdump image may not have been loaded */
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  193  
local_irq_restore(flags);
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  194  
return;
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  195  
}
9b00ac06978c54 arch/powerpc/kernel/crash.c Anton Blanchard 2011-11-30  196  
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  197  
mdelay(1);
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  198  
}
9b00ac06978c54 arch/powerpc/kernel/crash.c Anton Blanchard 2011-11-30  199  
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23 @200  
crash_ipi_callback(regs);
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  201  }
c0ce7d0886cf0c arch/powerpc/kernel/crash.c David Wilder2006-06-23  202  

:: The code at line 200 was first introduced by commit
:: c0ce7d0886cf0c2579c604eac41a7e125bc0e96d [POWERPC] Add the use of the 
firmware soft-reset-nmi to kdump.

:: TO: David Wilder 
:: CC: Paul Mackerras 

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


drivers/usb/gadget/udc/max3420_udc.c:1065:5-6: ERROR: invalid reference to the index variable of the iterator on line 1057

2020-08-07 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   30185b69a2d533c4ba6ca926b8390ce7de495e29
commit: 48ba02b2e2b1a1c80718e93fefe99c8319597c4a usb: gadget: add udc driver 
for max3420
date:   5 months ago
config: i386-randconfig-c003-20200807 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


coccinelle warnings: (new ones prefixed by >>)

>> drivers/usb/gadget/udc/max3420_udc.c:1065:5-6: ERROR: invalid reference to 
>> the index variable of the iterator on line 1057

vim +1065 drivers/usb/gadget/udc/max3420_udc.c

  1047  
  1048  static int max3420_ep_dequeue(struct usb_ep *_ep, struct usb_request 
*_req)
  1049  {
  1050  struct max3420_req *t, *req = to_max3420_req(_req);
  1051  struct max3420_ep *ep = to_max3420_ep(_ep);
  1052  unsigned long flags;
  1053  
  1054  spin_lock_irqsave(>lock, flags);
  1055  
  1056  /* Pluck the descriptor from queue */
> 1057  list_for_each_entry(t, >queue, queue)
  1058  if (t == req) {
  1059  list_del_init(>queue);
  1060  break;
  1061  }
  1062  
  1063  spin_unlock_irqrestore(>lock, flags);
  1064  
> 1065  if (t == req)
  1066  max3420_req_done(req, -ECONNRESET);
  1067  
  1068  return 0;
  1069  }
  1070  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH 5/7] dyndbg: WIP replace __dyndbg_callsite section with a zs-pool copy.

2020-08-07 Thread kernel test robot
Hi Jim,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on next-20200807]
[cannot apply to linux/master asm-generic/master v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Jim-Cromie/dyndbg-WIP-diet-plan/20200808-041343
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
86cfccb66937dd6cbf26ed619958b9e587e6a115
config: i386-randconfig-a003-20200807 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# save the attached .config to linux build tree
make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   ld: lib/dynamic_debug.o: in function `ddebug_callsite_put':
   lib/dynamic_debug.c:176: undefined reference to `zs_unmap_object'
   ld: lib/dynamic_debug.o: in function `ddebug_callsite_get':
   lib/dynamic_debug.c:164: undefined reference to `zs_map_object'
   ld: lib/dynamic_debug.o: in function `ddebug_zpool_add':
   lib/dynamic_debug.c:985: undefined reference to `zs_malloc'
   ld: lib/dynamic_debug.c:994: undefined reference to `zs_map_object'
   ld: lib/dynamic_debug.c:1004: undefined reference to `zs_unmap_object'
   ld: lib/dynamic_debug.o: in function `ddebug_callsite_put':
   lib/dynamic_debug.c:176: undefined reference to `zs_unmap_object'
   ld: lib/dynamic_debug.o: in function `ddebug_callsite_get':
   lib/dynamic_debug.c:164: undefined reference to `zs_map_object'
   ld: lib/dynamic_debug.o: in function `ddebug_callsite_put':
   lib/dynamic_debug.c:176: undefined reference to `zs_unmap_object'
   ld: lib/dynamic_debug.o: in function `ddebug_callsite_get':
   lib/dynamic_debug.c:164: undefined reference to `zs_map_object'
   ld: lib/dynamic_debug.o: in function `ddebug_zpool_remove':
>> lib/dynamic_debug.c:1016: undefined reference to `zs_free'
   ld: lib/dynamic_debug.c:1011: undefined reference to `zs_unmap_object'
   ld: lib/dynamic_debug.o: in function `ddebug_zpool_init':
   lib/dynamic_debug.c:1178: undefined reference to `zs_create_pool'
   ld: lib/dynamic_debug.c:1188: undefined reference to `zs_compact'
   ld: lib/dynamic_debug.c:1188: undefined reference to `zs_get_total_pages'

vim +1016 lib/dynamic_debug.c

  1006  
  1007  static void ddebug_zpool_remove(struct _ddebug *dp)
  1008  {
  1009  if (dp->site) {
  1010  pr_warn("zhandle shouldnt be mapped now\n");
  1011  zs_unmap_object(dd_callsite_zpool, dp->zhandle);
  1012  }
  1013  if (!dp->zhandle)
  1014  pr_err("zhandle already cleared !\n");
  1015  else
> 1016  zs_free(dd_callsite_zpool, dp->zhandle);
  1017  }
  1018  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[RFC PATCH v2 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scaling

2020-08-07 Thread Ansuel Smith
Document dedicated Krait CPU Cache Scaling driver.

Signed-off-by: Ansuel Smith 
---
 .../bindings/cpufreq/krait-cache-scale.yaml   | 92 +++
 1 file changed, 92 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml

diff --git a/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml 
b/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
new file mode 100644
index ..f10b1f386a99
--- /dev/null
+++ b/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
@@ -0,0 +1,92 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/cpufreq/krait-cache-scale.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Krait Cpu Cache Frequency Scaling dedicated driver
+
+maintainers:
+  - Ansuel Smith 
+
+description: |
+  This Scale the Krait CPU Cache Frequency and optionally voltage
+  when the Cpu Frequency is changed (using the cpufreq notifier).
+
+  Cache is scaled with the max frequency across all core and the cache
+  frequency will scale based on the configured threshold in the dts.
+
+  The cache is hardcoded to 3 frequency bin, idle, nominal and high.
+
+properties:
+  compatible:
+const: qcom,krait-cache
+
+  clocks:
+description: Phandle to the L2 CPU clock
+
+  clock-names:
+const: "l2"
+
+  voltage-tolerance:
+description: Same voltage tollerance of the Krait CPU
+
+  l2-rates:
+description: |
+  Frequency the L2 cache will be scaled at.
+  Value is in Hz.
+$ref: /schemas/types.yaml#/definitions/uint32-array
+items:
+  - description: idle
+  - description: nominal
+  - description: high
+
+  l2-cpufreq:
+description: |
+  Threshold used by the driver to scale the L2 cache.
+  If the max CPU Frequency is more than the set frequency,
+  the driver will transition to the next frequency bin.
+  Value is in kHz
+$ref: /schemas/types.yaml#/definitions/uint32-array
+items:
+  - description: idle
+  - description: nominal
+  - description: high
+
+  l2-volt:
+description: |
+  Threshold used by the driver to scale the L2 cache.
+  If the max CPU Frequency is more than the set frequency,
+  the driver will transition to the next frequency bin.
+  Value is in microvolt.
+$ref: /schemas/types.yaml#/definitions/uint32-array
+items:
+  - description: idle
+  - description: nominal
+  - description: high
+
+  l2-supply:
+description: Phandle to the L2 regulator supply.
+
+required:
+  - compatible
+  - clocks
+  - clock-names
+  - voltage-tolerance
+  - l2-rates
+  - l2-cpufreq
+  - l2-supply
+  - l2-volt
+
+examples:
+  - |
+qcom-krait-cache {
+  compatible = "qcom,krait-cache";
+  clocks = < 4>;
+  clock-names = "l2";
+  voltage-tolerance = <5>;
+  l2-rates = <38400 10 12>;
+  l2-cpufreq = <384000 60 120>;
+  l2-volt = <110 110 115>;
+  l2-supply = <_s1a>;
+};
-- 
2.27.0



[RFC PATCH v2 0/2] Add Krait Cache Scaling support

2020-08-07 Thread Ansuel Smith
This adds Krait Cache scaling support using the cpufreq notifier.
I have some doubt about where this should be actually placed (clk or cpufreq)?
Also the original idea was to create a dedicated cpufreq driver (like it's done 
in
the codeaurora qcom repo) by copying the cpufreq-dt driver and adding the cache
scaling logic but i still don't know what is better. Have a very similar driver 
or
add a dedicated driver only for the cache using the cpufreq notifier and do the
scale on every freq transition.
Thanks to everyone who will review or answer these questions.

v2:
* Fix Documentation error reported by bot
* Rework code to fail probe on missing required params
* Optimize notifier callback to reduce CPU cycle

Ansuel Smith (2):
  cpufreq: qcom: Add Krait Cache Scaling support
  dt-bindings: cpufreq: Document Krait CPU Cache scaling

 .../bindings/cpufreq/krait-cache-scale.yaml   |  92 
 drivers/cpufreq/Kconfig.arm   |   9 +
 drivers/cpufreq/Makefile  |   1 +
 drivers/cpufreq/krait-cache.c | 214 ++
 4 files changed, 316 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
 create mode 100644 drivers/cpufreq/krait-cache.c

-- 
2.27.0



[RFC PATCH v2 1/2] cpufreq: qcom: Add Krait Cache Scaling support

2020-08-07 Thread Ansuel Smith
Qcom Krait CPUs use the generic cpufreq-dt driver and doesn't actually
scale the Cache frequency when the CPU frequency is changed. This
companion driver register with the cpu notifier and scale the Cache
based on the max Freq across all core as the CPU cache is shared across
all of them. If provided this also scale the voltage of the regulator
attached to the CPU cache. The scaling logic is based on the CPU freq
and the 3 scaling interval are set by the device dts.

Signed-off-by: Ansuel Smith 
---
 drivers/cpufreq/Kconfig.arm   |   9 ++
 drivers/cpufreq/Makefile  |   1 +
 drivers/cpufreq/krait-cache.c | 213 ++
 3 files changed, 223 insertions(+)
 create mode 100644 drivers/cpufreq/krait-cache.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index c6cbfc8baf72..4ed5e73051df 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -126,6 +126,15 @@ config ARM_OMAP2PLUS_CPUFREQ
depends on ARCH_OMAP2PLUS
default ARCH_OMAP2PLUS
 
+config ARM_QCOM_KRAIT_CACHE_SCALE
+   tristate "Scaling support for Krait CPU Cache"
+   depends on ARCH_QCOM || COMPILE_TEST
+   help
+ This adds the Scaling support for the Krait CPU Cache shared by
+ all cores.
+
+ If in doubt, say N.
+
 config ARM_QCOM_CPUFREQ_NVMEM
tristate "Qualcomm nvmem based CPUFreq"
depends on ARCH_QCOM
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index f6670c4abbb0..eee53d7e8b09 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_MACH_MVEBU_V7)   += mvebu-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)+= omap-cpufreq.o
 obj-$(CONFIG_ARM_PXA2xx_CPUFREQ)   += pxa2xx-cpufreq.o
 obj-$(CONFIG_PXA3xx)   += pxa3xx-cpufreq.o
+obj-$(CONFIG_ARM_QCOM_KRAIT_CACHE_SCALE) += krait-cache.o
 obj-$(CONFIG_ARM_QCOM_CPUFREQ_HW)  += qcom-cpufreq-hw.o
 obj-$(CONFIG_ARM_QCOM_CPUFREQ_NVMEM)   += qcom-cpufreq-nvmem.o
 obj-$(CONFIG_ARM_RASPBERRYPI_CPUFREQ)  += raspberrypi-cpufreq.o
diff --git a/drivers/cpufreq/krait-cache.c b/drivers/cpufreq/krait-cache.c
new file mode 100644
index ..a2a14eb38dc0
--- /dev/null
+++ b/drivers/cpufreq/krait-cache.c
@@ -0,0 +1,213 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct krait_data {
+   struct clk *l2_clk; /* L2 clock */
+   unsigned int l2_volt_tol; /* L2 voltage tolerance */
+
+   struct regulator *l2_regulator; /* L2 supply */
+   unsigned int l2_rate[3]; /* L2 bus clock rate */
+
+   unsigned int l2_cpufreq[3]; /* L2 target CPU frequency */
+   unsigned int l2_volt[3]; /* L2 voltage array */
+
+   unsigned long curr_l2_freq;
+   unsigned long curr_l2_volt;
+
+   struct notifier_block nb;
+};
+
+static int krait_cache_notifier(struct notifier_block *nb, unsigned long cmd,
+   void *v)
+{
+   unsigned int target_freq, cpu, cur_cpu, l2_index, tol;
+   unsigned long curr_l2_freq, target_l2_freq;
+   unsigned long curr_l2_vol, target_l2_volt;
+   struct cpufreq_freqs *freqs;
+   struct krait_data *data;
+   struct clk *l2_clk;
+   int ret = 0;
+
+   if (cmd == CPUFREQ_PRECHANGE) {
+   freqs = (struct cpufreq_freqs *)v;
+   target_freq = freqs->new;
+   cur_cpu = freqs->policy->cpu;
+
+   data = container_of(nb, struct krait_data, nb);
+
+   l2_clk = data->l2_clk;
+
+   /* find the max freq across all core */
+   for_each_present_cpu(cpu)
+   if (cpu != cur_cpu)
+   target_freq = max(target_freq,
+ cpufreq_quick_get(cpu));
+
+   /* find l2_freq and l2_volt  */
+   for (l2_index = 0;
+l2_index < 2 && target_freq <= data->l2_cpufreq[l2_index];
+l2_index++)
+   break;
+
+   curr_l2_freq = data->curr_l2_freq;
+   target_l2_freq = data->l2_rate[l2_index];
+
+   /* scale only if needed */
+   if (curr_l2_freq != target_l2_freq) {
+   /*
+* Set to idle bin if switching from normal to high bin
+* or vice versa. It has been notice that a bug is 
triggered
+* in cache scaling when more than one bin is scaled, 
to fix
+* this we first need to transition to the base rate 
and then
+* to target rate
+*/
+   if (likely(l2_index > 0 &&
+  curr_l2_freq != data->l2_rate[0])) {
+   ret = clk_set_rate(l2_clk, data->l2_rate[0]);
+   if 

Re: KASAN: use-after-free Read in rc_dev_uevent

2020-08-07 Thread Ezequiel Garcia
Hello Sean,

On Fri, 7 Aug 2020 at 06:15, Sean Young  wrote:
>
> On Fri, Aug 07, 2020 at 12:26:29AM -0700, syzbot wrote:
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit:7b4ea945 Revert "x86/mm/64: Do not sync vmalloc/ioremap ma..
> > git tree:   
> > https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
> > console output: https://syzkaller.appspot.com/x/log.txt?x=11a7813a90
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=72a84c46d0c668c
> > dashboard link: https://syzkaller.appspot.com/bug?extid=ceef16277388d6f24898
> > compiler:   gcc (GCC) 10.1.0-syz 20200507
> >
> > Unfortunately, I don't have any reproducer for this issue yet.
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+ceef16277388d6f24...@syzkaller.appspotmail.com
> >
> > ==
> > BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:611 [inline]
> > BUG: KASAN: use-after-free in string+0x39c/0x3d0 lib/vsprintf.c:693
> > Read of size 1 at addr 8881ca21cd20 by task systemd-udevd/5147
> >
> > CPU: 1 PID: 5147 Comm: systemd-udevd Not tainted 5.8.0-syzkaller #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> > Google 01/01/2011
> > Call Trace:
> >  __dump_stack lib/dump_stack.c:77 [inline]
> >  dump_stack+0xf6/0x16e lib/dump_stack.c:118
> >  print_address_description.constprop.0+0x1a/0x210 mm/kasan/report.c:383
> >  __kasan_report mm/kasan/report.c:513 [inline]
> >  kasan_report.cold+0x37/0x7c mm/kasan/report.c:530
> >  string_nocheck lib/vsprintf.c:611 [inline]
> >  string+0x39c/0x3d0 lib/vsprintf.c:693
> >  vsnprintf+0x71b/0x14f0 lib/vsprintf.c:2617
> >  add_uevent_var+0x14d/0x310 lib/kobject_uevent.c:664
> >  rc_dev_uevent+0x54/0x140 drivers/media/rc/rc-main.c:1616
> >  dev_uevent+0x30e/0x780 drivers/base/core.c:1916
> >  uevent_show+0x1bb/0x360 drivers/base/core.c:1963
> >  dev_attr_show+0x4b/0x90 drivers/base/core.c:1667
> >  sysfs_kf_seq_show+0x1f8/0x400 fs/sysfs/file.c:60
> >  seq_read+0x432/0x1070 fs/seq_file.c:208
> >  kernfs_fop_read+0xe9/0x590 fs/kernfs/file.c:251
> >  vfs_read+0x1df/0x520 fs/read_write.c:479
> >  ksys_read+0x12d/0x250 fs/read_write.c:607
> >  do_syscall_64+0x2d/0x40 arch/x86/entry/common.c:46
> >  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> > RIP: 0033:0x7f6e6c02f910
> > Code: b6 fe ff ff 48 8d 3d 0f be 08 00 48 83 ec 08 e8 06 db 01 00 66 0f 1f 
> > 44 00 00 83 3d f9 2d 2c 00 00 75 10 b8 00 00 00 00 0f 05 <48> 3d 01 f0 ff 
> > ff 73 31 c3 48 83 ec 08 e8 de 9b 01 00 48 89 04 24
> > RSP: 002b:7fff3cddeae8 EFLAGS: 0246 ORIG_RAX: 
> > RAX: ffda RBX: 558492caaae0 RCX: 7f6e6c02f910
> > RDX: 1000 RSI: 558492cc7530 RDI: 0007
> > RBP: 7f6e6c2ea440 R08: 7f6e6c2ee298 R09: 1010
> > R10: 558492caaae0 R11: 0246 R12: 1000
> > R13: 0d68 R14: 558492cc7530 R15: 7f6e6c2e9900
>
> This thread is reading the uevent sysfs file, which reads
> rc_dev->map.name, and also rc_dev->device_name, but that is not causing
> problems is this case.
>
> >
> > Allocated by task 5:
> >  save_stack+0x1b/0x40 mm/kasan/common.c:48
> >  set_track mm/kasan/common.c:56 [inline]
> >  __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
> >  slab_post_alloc_hook mm/slab.h:586 [inline]
> >  slab_alloc_node mm/slub.c:2824 [inline]
> >  slab_alloc mm/slub.c:2832 [inline]
> >  __kmalloc_track_caller+0xec/0x280 mm/slub.c:4430
> >  kstrdup+0x36/0x70 mm/util.c:60
> >  ir_create_table drivers/media/rc/rc-main.c:217 [inline]
> >  ir_setkeytable drivers/media/rc/rc-main.c:477 [inline]
> >  rc_prepare_rx_device drivers/media/rc/rc-main.c:1786 [inline]
> >  rc_register_device+0x464/0x1600 drivers/media/rc/rc-main.c:1914
> >  igorplugusb_probe+0x7e6/0xc98 drivers/media/rc/igorplugusb.c:209
> >  usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:374
> >  really_probe+0x291/0xde0 drivers/base/dd.c:553
> >  driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:738
> >  __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:844
> >  bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
> >  __device_attach+0x228/0x4a0 drivers/base/dd.c:912
> >  bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
> >  device_add+0xb51/0x1c70 drivers/base/core.c:2930
> >  usb_set_configuration+0xf05/0x18a0 drivers/usb/core/message.c:2032
> >  usb_generic_driver_probe+0xba/0xf2 drivers/usb/core/generic.c:239
> >  usb_probe_device+0xd9/0x250 drivers/usb/core/driver.c:272
> >  really_probe+0x291/0xde0 drivers/base/dd.c:553
> >  driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:738
> >  __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:844
> >  bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
> >  __device_attach+0x228/0x4a0 drivers/base/dd.c:912
> >  bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
> >  

[PATCH 3/3] remoteproc: qcom: Add minidump id for sm8150 modem remoteproc

2020-08-07 Thread Gurbir Arora
Add minidump id for modem in sm8150 chipset.

Signed-off-by: Rishabh Bhatnagar 
Signed-off-by: Gurbir Arora 
---
 drivers/remoteproc/qcom_q6v5_pas.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/remoteproc/qcom_q6v5_pas.c 
b/drivers/remoteproc/qcom_q6v5_pas.c
index 270c640..ce2a83d 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -623,6 +623,7 @@ static int adsp_remove(struct platform_device *pdev)
.crash_reason_smem = 421,
.firmware_name = "modem.mdt",
.pas_id = 4,
+   .minidump_id = 3,
.has_aggre2_clk = false,
.auto_boot = false,
.active_pd_names = (char*[]){
-- 
1.9.1



  1   2   3   4   5   6   7   8   9   10   >